Okay, I looked here: http://us.php.net/umask
That helped a bit! So, umask() can be used to capture the user's
current umask value when called with no arguments or, when called with
arguments, it will set the user's umask value. So, this line,
$current_umask = umask(0000);
since umask has an argument, does it set the umask to 0000 as opposed
to 'saving' the user's original umask value? Or both??

It is more obvious to me what is happening here in php_dir/symfony/
vendor/pake/pakeFunction.php. The user's current umask value is saved
in $current_umask. Then umask is changed in the next line to 0000. In
last line, umask is restored to original value.umask(0000) in the next
line.
----------------------------------------------------------
function pake_chmod($arg, $target_dir, $mode, $umask = 0000)
{
  $current_umask = umask();
  umask($umask);

  $files = pakeApp::get_files_from_argument($arg, $target_dir, true);

  foreach ($files as $file)
  {
    pake_echo_action(sprintf('chmod %o', $mode),
$target_dir.DIRECTORY_SEPARATOR.$file);
    chmod($target_dir.DIRECTORY_SEPARATOR.$file, $mode);
  }

  umask($current_umask);
}
-----------------------------------------------------------------
I had an 'ah-ha' moment when I realize the reason to set umask to 0000
is to make sure it does not interfere with directory & file permission
settings. Since umask really is a 'mask', its value will be
'subtracted' from the directory permission settings. For instance, if
the user's umask is 0022, and the directory permission setting in the
function is 0755, end result is directory permission of 733 (0755 -
0022 = 0733) which is not the desired result. So, symfony uses a call
to umask(0000) to prevent this. Is this right, or am I still
crazy?? ;-)

So, next I see that symfony defines its own umask function in php_dir/
symfony/vendor/phing/system/io/FileSystem.php
-----------------------------------------------------------------
    /**
     * Set the umask for file and directory creation.
     *
     * @param    mode    Int. Permissions usually in octal. Use
leading 0 for
     *                    octal. Number between 0 and 0755.
     *
     * @return void
     * @throws Exception if there is an error performing
operation.
     */
    function umask($mode) {
        global $php_errormsg;

        // CONSIDERME:
        // Throw a warning if mode is 0. PHP converts illegal octal
numbers to
        // 0 so 0 might not be what the user intended.

        $str_mode = decoct($mode); // Show octal in messages.

        if (false === @umask($mode)) { // FAILED.
            // Add error from php to end of log message.
$php_errormsg.
            $msg = "FileSystem::Umask() FAILED. Value $mode.
$php_errormsg";
            throw new Exception($msg);
        }
    }
------------------------------------------------------------
I do not see where the value of $mode is set?

I try not to lose sight of the goal to make symfony's directory & file
permission settings manageable (put them in one spot for user
configuration), so I need to understand more about how umask affects
this. Thank you so much for any help!
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups 
"symfony developers" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/symfony-devs?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to