note 100198 added to function.umask
| From: | bishop at osu1 dot php dot net | Date: | Thu, 30 Sep 2010 13:01:19 +0000 |
| Subject: | note 100198 added to function.umask | ||
| Groups: | php.notes | ||
| Request: | Send a blank email to php-notes+get-172841@lists.php.net to get a copy of this message | ||
"It is better to change the file permissions with chmod() after creating the file."
If you take that advice seriously, consider setting your umask so that files are created private to
your user, then use chmod to open them up.
<?php
// files will create as -rw-------
umask(0077);
// create a file, eg fopen()
// give access: -rw-r--r--
chmod('/path/to/file', 0644);
?>
Whenever reasonable, default to shut and open as needed (like above) instead of default to open and
shut as needed. The above still has a race condition, but the race condition will deny appropriate
access instead of granting inappropriate access.
----
Server IP: 64.71.164.2
Probable Submitter: 24.148.150.180
----
Manual Page -- http://www.php.net/manual/en/function.umask.php
Edit -- https://master.php.net/note/edit/100198
Del: integrated -- https://master.php.net/note/delete/100198/integrated
Del: useless -- https://master.php.net/note/delete/100198/useless
Del: bad code -- https://master.php.net/note/delete/100198/bad+code
Del: spam -- https://master.php.net/note/delete/100198/spam
Del: non-english -- https://master.php.net/note/delete/100198/non-english
Del: in docs -- https://master.php.net/note/delete/100198/in+docs
Del: other reasons-- https://master.php.net/note/delete/100198
Reject -- https://master.php.net/note/reject/100198
Search -- https://master.php.net/manage/user-notes.php