note 119493 added to function.umask
| From: | malcolm.murphy | Date: | Tue, 21 Jun 2016 11:09:22 +0000 |
| Subject: | note 119493 added to function.umask | ||
| Groups: | php.notes | ||
| Request: | Send a blank email to php-notes+get-205768@lists.php.net to get a copy of this message | ||
Clarification Of "mask & 0777":
The manual's comment "umask() sets PHP's umask to mask & 0777 [...]" is
merely implying that the method only affects file permissions, but not special modes such as the
setuid, setgid or sticky bits. Curiously, PHP does not actually perform the bitwise operation
itself, but instead assumes it will be done by a system call of the same name. On some systems such
as OS X, umask effectively sets the umask as mask & 07777, but the extraneous bits are not
applicable to subsequent PHP calls like mkdir(). Linux's umask does use 0777. Its manual entry
has a comment similar to the PHP one, but with a parenthetical statement that helps explain what it
means:
"umask() sets the calling process's file mode creation mask (umask) to mask & 0777
(i.e., only the file permission bits of mask are used) [...]"
The fact that permissions can be determined by inverting a mask using the operation $mask &
~0777 is irrelevant, despite its similar appearance to $mask & 0777. The latter operation
instead truncates $mask to the first nine low-order bits (i.e., the three rightmost octal digits
[and note that the leading zero for octal notation is not itself a digit]). It does not change the
remaining bits.
For example, all of the following calls have the same effect: umask(0022), umask(07022),
umask(261650) (decimal value of 0777022), and umask(0b111000010010) (binary notation for 07022).
----
Server IP: 72.52.91.14
Probable Submitter: 72.21.64.178
----
Manual Page -- http://php.net/manual/en/function.umask.php
Edit -- https://master.php.net/note/edit/119493
Del: integrated -- https://master.php.net/note/delete/119493/integrated
Del: useless -- https://master.php.net/note/delete/119493/useless
Del: bad code -- https://master.php.net/note/delete/119493/bad+code
Del: spam -- https://master.php.net/note/delete/119493/spam
Del: non-english -- https://master.php.net/note/delete/119493/non-english
Del: in docs -- https://master.php.net/note/delete/119493/in+docs
Del: other reasons-- https://master.php.net/note/delete/119493
Reject -- https://master.php.net/note/reject/119493
Search -- https://master.php.net/manage/user-notes.php