note 117942 added to function.umask
| From: | RichardSnell | Date: | Fri, 04 Sep 2015 14:52:40 +0000 |
| Subject: | note 117942 added to function.umask | ||
| Groups: | php.notes | ||
| Request: | Send a blank email to php-notes+get-203624@lists.php.net to get a copy of this message | ||
It is important to note that the mask parameter will accept values other than octal and that this
can cause unexpected results.
Setting umask(22) could be expected to reduce a file with default 0666 permission to 0644 by
applying a mask of 0022 but as the parameter is being supplied as a decimal it will be converted to
octal silently and actually apply a mask of 0026 resulting in a final file permission of 0642.
Similarly the value returned by umask is in decimal format. If you correctly apply a mask using
umask(0022) and then query the new setting with umask() it will return a value of 18 (0022 octal is
18 decimal).
In short, when applying permissions it is best to pad the supplied value with zeros to create an
octal value (22 becomes 0022) and if you want to analyze the returned value remember to convert it
to octal for ease of interpretation.
----
Server IP: 72.52.91.14
Probable Submitter: 144.47.201.14
----
Manual Page -- http://php.net/manual/en/function.umask.php
Edit -- https://master.php.net/note/edit/117942
Del: integrated -- https://master.php.net/note/delete/117942/integrated
Del: useless -- https://master.php.net/note/delete/117942/useless
Del: bad code -- https://master.php.net/note/delete/117942/bad+code
Del: spam -- https://master.php.net/note/delete/117942/spam
Del: non-english -- https://master.php.net/note/delete/117942/non-english
Del: in docs -- https://master.php.net/note/delete/117942/in+docs
Del: other reasons-- https://master.php.net/note/delete/117942
Reject -- https://master.php.net/note/reject/117942
Search -- https://master.php.net/manage/user-notes.php