Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

[PHP-WIN] how to use umask() ???

8 views
Skip to first unread message

Jill Ramonsky

unread,
Apr 2, 2003, 6:50:35 AM4/2/03
to ai...@nospam.dk, php-w...@lists.php.net
The PHP manual (unfortunately) assumes some Unix knowledge here.
The paramter to umask is a bitfield, passed as an integer. Within this
bitfield:

bit 0 set implies that anyone in the world can execute the file
bit 1 set implies that anyone in the world can write to the file
bit 2 set implies that anyone in the world can read the file
bit 3 set implies that anyone in the file's group (a Unix concept) can
execute the file
bit 4 set implies that anyone in the file's group (a Unix concept) can write
to the file
bit 5 set implies that anyone in the file's group (a Unix concept) can read
the file
bit 6 set implies that the owner of the file can execute the file
bit 7 set implies that the owner of the file can write to the file
bit 8 set implies that the owner of the file can read the file

When accessing a file, the lower 9 bits of the permissions of the file (as
stored on the server) are logically ANDed with the complement of the current
"umask" - which you can set with the umask() function - and the resulting
bitfield is inspected to see whether or not to grant permission for the
specified action.

Jill

-----Original Message-----
From: Aidal [mailto:ai...@nospam.dk]
Sent: Wednesday, April 02, 2003 9:11 AM
To: php-w...@lists.php.net
Subject: [PHP-WIN] how to use umask() ???


Hi NG.

I'm having problems with my web application changing file permissions when
creating, editing or deleting text files.
My web host thinks it's because I need to use umask() but I'm not quite sure
just how to use this function.

I've read the describtion on www.php.net but that didn't enlighten me much.
(As in, don't give me a link to www.php.net because it wont help me)

Can anyone explain to me how to use this function?

My php application creates, reads, wrrites, copies and deletes text files
and I want the file permissions to stay intact.
The application needs all permissions to the files: read, write and execute
(as i recall them stated when accessing through FTP).

Any help would be much apreciated thanks...

/Aidal

--
PHP Windows Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php

Aidal

unread,
Apr 2, 2003, 7:03:55 AM4/2/03
to php-w...@lists.php.net
Thanks for the explanation though I did know some of this already. What I'm
not sure of is how and where to use this.
Below is a little example of a member function that creates a new text file.

How/where should I use umask() ?
Also does it have any effect if the file isn't properly closet by fclose() ?

Little function example (member function of class file_handler):
--------------------------------------
function create_file($file_name) {
if (!$this->fp = @fopen($file_name, wb)) {
$this->error_msg .= $this->error_create ." ". $file_name .".";
return false;
} else {
$this->file = $file_name;
return $this->fp;
}
}
---------------------------------------

"Jill Ramonsky" <Jill.R...@Aculab.com> wrote in message
news:8C9A566C643ED6119E8...@saturn.aculab.com...

0 new messages