Page Menu
Home
Phabricator
Search
Configure Global Search
Log In
Files
F13960012
D16391.diff
No One
Temporary
Actions
View File
Edit File
Delete File
View Transforms
Subscribe
Mute Notifications
Award Token
Flag For Later
Size
1 KB
Referenced Files
None
Subscribers
None
D16391.diff
View Options
diff --git a/src/infrastructure/daemon/PhabricatorDaemon.php b/src/infrastructure/daemon/PhabricatorDaemon.php
--- a/src/infrastructure/daemon/PhabricatorDaemon.php
+++ b/src/infrastructure/daemon/PhabricatorDaemon.php
@@ -34,6 +34,24 @@
return $command;
}
+ // We may reach this method while already running as the daemon user: for
+ // example, active and passive synchronization of clustered repositories
+ // run the same commands through the same code, but as different users.
+
+ // By default, `sudo` won't let you sudo to yourself, so we can get into
+ // trouble if we're already running as the daemon user unless the host has
+ // been configured to let the daemon user run commands as itself.
+
+ // Since this is silly and more complicated than doing this check, don't
+ // use `sudo` if we're already running as the correct user.
+ if (function_exists('posix_getuid')) {
+ $uid = posix_getuid();
+ $info = posix_getpwuid($uid);
+ if ($info && $info['name'] == $user) {
+ return $command;
+ }
+ }
+
// Get the absolute path so we're safe against the caller wiping out
// PATH.
$sudo = Filesystem::resolveBinary('sudo');
File Metadata
Details
Attached
Mime Type
text/plain
Expires
Oct 15 2024, 9:39 PM (4 w, 6 d ago)
Storage Engine
blob
Storage Format
Encrypted (AES-256-CBC)
Storage Handle
6714535
Default Alt Text
D16391.diff (1 KB)
Attached To
Mode
D16391: When already running as the daemon user, don't "sudo" daemon commands
Attached
Detach File
Event Timeline
Log In to Comment