@recaptime-dev's working patches + fork for Phorge, a community fork of Phabricator. (Upstream dev and stable branches are at upstream/main and upstream/stable respectively.) hq.recaptime.dev/wiki/Phorge
phorge phabricator
1
fork

Configure Feed

Select the types of activity you want to include in your feed.

Reset umask to 022 for all Phabricator processes

Summary:
Fixes T7475. If you do something like:

$ umask 123
$ ./bin/phd start

...the daemons might inherit the weird umask, do a `git fetch` with the weird umask, and end up creating files with weird permissions in repositories.

Instead, just normalize the umask to 022 in all cases. This is overwhelmingly the most common setting, and the one we assume things are configured with.

(When we want to force permissions to a certain setting, we do so explicitly.)

Test Plan:
- Added `var_dump(umask())` to observe umask.
- Ran `bin/phd`, saw proper umask (`18`, which is decimal of `022` octal).
- Set `umask 123`, then ran `bin/phd`, saw it correct properly again.

Reviewers: chad

Reviewed By: chad

Maniphest Tasks: T7475

Differential Revision: https://secure.phabricator.com/D15721

+14
+14
src/infrastructure/env/PhabricatorEnv.php
··· 91 91 private static function initializeCommonEnvironment() { 92 92 PhutilErrorHandler::initialize(); 93 93 94 + self::resetUmask(); 94 95 self::buildConfigurationSourceStack(); 95 96 96 97 // Force a valid timezone. If both PHP and Phabricator configuration are ··· 861 862 862 863 private static function dropConfigCache() { 863 864 self::$cache = array(); 865 + } 866 + 867 + private static function resetUmask() { 868 + // Reset the umask to the common standard umask. The umask controls default 869 + // permissions when files are created and propagates to subprocesses. 870 + 871 + // "022" is the most common umask, but sometimes it is set to something 872 + // unusual by the calling environment. 873 + 874 + // Since various things rely on this umask to work properly and we are 875 + // not aware of any legitimate reasons to adjust it, unconditionally 876 + // normalize it until such reasons arise. See T7475 for discussion. 877 + umask(022); 864 878 } 865 879 866 880 }