@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.

Fix "daemons running as wrong user" setup issue

Summary:
Fixes T9385. This was accidentally mangled a bit a long time ago by D12797, which was a 1,000-file change which got almost everything right.

Simplify the message and fix all the `%s` conversions and how they map to parameters.

Test Plan: {F1220400}

Reviewers: chad

Reviewed By: chad

Maniphest Tasks: T9385

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

+30 -39
+30 -39
src/applications/config/check/PhabricatorDaemonsSetupCheck.php
··· 46 46 ->addCommand('phabricator/ $ ./bin/phd start'); 47 47 } 48 48 49 - $phd_user = PhabricatorEnv::getEnvConfig('phd.user'); 50 - $all_daemons = id(new PhabricatorDaemonLogQuery()) 51 - ->setViewer(PhabricatorUser::getOmnipotentUser()) 52 - ->withStatus(PhabricatorDaemonLogQuery::STATUS_ALIVE) 53 - ->execute(); 54 - foreach ($all_daemons as $daemon) { 49 + $expect_user = PhabricatorEnv::getEnvConfig('phd.user'); 50 + if (strlen($expect_user)) { 51 + $all_daemons = id(new PhabricatorDaemonLogQuery()) 52 + ->setViewer(PhabricatorUser::getOmnipotentUser()) 53 + ->withStatus(PhabricatorDaemonLogQuery::STATUS_ALIVE) 54 + ->execute(); 55 + foreach ($all_daemons as $daemon) { 56 + $actual_user = $daemon->getRunningAsUser(); 57 + if ($actual_user == $expect_user) { 58 + continue; 59 + } 55 60 56 - if ($phd_user) { 57 - if ($daemon->getRunningAsUser() != $phd_user) { 58 - $doc_href = PhabricatorEnv::getDocLink('Managing Daemons with phd'); 61 + $summary = pht( 62 + 'At least one daemon is currently running as the wrong user.'); 59 63 60 - $summary = pht( 61 - 'At least one daemon is currently running as a different '. 62 - 'user than configured in the Phabricator %s setting', 63 - 'phd.user'); 64 + $message = pht( 65 + 'A daemon is running as user %s, but daemons should be '. 66 + 'running as %s.'. 67 + "\n\n". 68 + 'Either adjust the configuration setting %s or restart the '. 69 + 'daemons. Daemons should attempt to run as the proper user when '. 70 + 'restarted.', 71 + phutil_tag('tt', array(), $actual_user), 72 + phutil_tag('tt', array(), $expect_user), 73 + phutil_tag('tt', array(), 'phd.user')); 64 74 65 - $message = pht( 66 - 'A daemon is running as user %s while the Phabricator config '. 67 - 'specifies %s to be %s.'. 68 - "\n\n". 69 - 'Either adjust %s to match %s or start '. 70 - 'the daemons as the correct user. '. 71 - "\n\n". 72 - '%s Daemons will try to use %s to start as the configured user. '. 73 - 'Make sure that the user who starts %s has the correct '. 74 - 'sudo permissions to start %s daemons as %s', 75 - 'phd.user', 76 - 'phd.user', 77 - 'phd', 78 - 'sudo', 79 - 'phd', 80 - 'phd', 81 - phutil_tag('tt', array(), $daemon->getRunningAsUser()), 82 - phutil_tag('tt', array(), $phd_user), 83 - phutil_tag('tt', array(), $daemon->getRunningAsUser()), 84 - phutil_tag('tt', array(), $phd_user)); 75 + $this->newIssue('daemons.run-as-different-user') 76 + ->setName(pht('Daemon Running as Wrong User')) 77 + ->setSummary($summary) 78 + ->setMessage($message) 79 + ->addPhabricatorConfig('phd.user') 80 + ->addCommand('phabricator/ $ ./bin/phd restart'); 85 81 86 - $this->newIssue('daemons.run-as-different-user') 87 - ->setName(pht('Daemons are running as the wrong user')) 88 - ->setSummary($summary) 89 - ->setMessage($message) 90 - ->addCommand('phabricator/ $ ./bin/phd restart'); 91 - } 82 + break; 92 83 } 93 84 } 94 85 }