Very true, very true.
Wasn't thinking of the case of threads and signals. Like you said, however, you start with permissions equal or higher than you want, and reduce the restrictions when ready to open it up, not the other way around.
I just reread my post, and yeah, it did not say what I was thinking. Ugh. The specific cases I was thinking of for security bugs were cases where this sequence of code was executed:
umask(000); mkdir($dir, 0777); # or creating a file mode 0666, etc ... ... chmod($dir, $mode);
or even the same thing with creating files. By restricting the mode to just what you need to be able to set up your files / directories (umask(0077)), and then opening it up once setup is complete (chmod(...)), you can more easily avoid some of these situations. But as you stated, you need to be aware of these restrictions in your asynchronous areas of your code.
--MidLifeXis
In reply to Re^5: mkdir with variable mask
by MidLifeXis
in thread mkdir with variable mask
by kreetrapper
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |