phingofficial/phing — pull request #128 by sandermarechal (2012-05-31 09:42:27+00:00)
Title: Take default directory mode from umask

Some tasks, like the MkdirTask and the CopyTask have a hard-coded value as the default mode for creating files/directories. This PR uses the environment's umask is used to set the default mode for new directories.

As an example, take the following build file:

When I am on machine A my linux umask is set to '0022'. When I execute this buildfile I expect the 'test' directory to be created with 0755 permissions.

When I am on machine B my linux umask is set to '0002'. Now I expect 'test' to be created with permissions '0775', but Phing still creates it with '0755' instead.

This functionality can be really useful. For example, a typical way to run a website is as the www-data user. In such cases it's easy have the files owned by myself, but assign the group as www-data and make sure it can write.

The standard Linux way of doing this is setting `chmod -R g+ws .` on my project directory, followed by `chgrp -R www-data .` and setting my umask to `0002`.

If I now manually create a subdirectory here from the commandline then the new directory will have 0775 permissions and belong to the www-data group. But in this case Phing still creates it with 0755 permissions. That means my project can't write in these directories, possibly causing problems.