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

Before executing svnserve, change the CWD to a readable directory

Summary: Fixes T10941. This avoids a confusing dead end when configuring Subversion hosting, where `svnserve` will fail to execute hooks if the CWD isn't readable by the vcs-user.

Test Plan:
- Updated and committed in a hosted SVN repository.
- Ran some git operations, too.
- @dpotter confirmed this locally in T10941.

Reviewers: chad

Reviewed By: chad

Subscribers: dpotter

Maniphest Tasks: T10941

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

+28 -2
+1 -2
src/applications/diffusion/protocol/DiffusionGitCommandEngine.php
··· 24 24 // really silly, but seems like the least damaging approach to 25 25 // mitigating the issue. 26 26 27 - $root = dirname(phutil_get_library_root('phabricator')); 28 - $env['HOME'] = $root.'/support/empty/'; 27 + $env['HOME'] = PhabricatorEnv::getEmptyCWD(); 29 28 30 29 if ($this->isAnySSHProtocol()) { 31 30 $env['GIT_SSH'] = $this->getSSHWrapper();
+10
src/applications/diffusion/ssh/DiffusionSubversionServeSSHWorkflow.php
··· 148 148 if ($this->shouldProxy()) { 149 149 $command = $this->getProxyCommand(); 150 150 $this->isProxying = true; 151 + $cwd = null; 151 152 } else { 152 153 $command = csprintf( 153 154 'svnserve -t --tunnel-user=%s', 154 155 $this->getUser()->getUsername()); 156 + $cwd = PhabricatorEnv::getEmptyCWD(); 155 157 } 156 158 157 159 $command = PhabricatorDaemon::sudoCommandAsDaemonUser($command); 158 160 $future = new ExecFuture('%C', $command); 161 + 162 + // If we're receiving a commit, svnserve will fail to execute the commit 163 + // hook with an unhelpful error if the CWD isn't readable by the user we 164 + // are sudoing to. Switch to a readable, empty CWD before running 165 + // svnserve. See T10941. 166 + if ($cwd !== null) { 167 + $future->setCWD($cwd); 168 + } 159 169 160 170 $this->inProtocol = new DiffusionSubversionWireProtocol(); 161 171 $this->outProtocol = new DiffusionSubversionWireProtocol();
+17
src/infrastructure/env/PhabricatorEnv.php
··· 877 877 umask(022); 878 878 } 879 879 880 + 881 + /** 882 + * Get the path to an empty directory which is readable by all of the system 883 + * user accounts that Phabricator acts as. 884 + * 885 + * In some cases, a binary needs some valid HOME or CWD to continue, but not 886 + * all user accounts have valid home directories and even if they do they 887 + * may not be readable after a `sudo` operation. 888 + * 889 + * @return string Path to an empty directory suitable for use as a CWD. 890 + */ 891 + public static function getEmptyCWD() { 892 + $root = dirname(phutil_get_library_root('phabricator')); 893 + return $root.'/support/empty/'; 894 + } 895 + 896 + 880 897 }