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

Specify HOME when invoking Git commands

Summary: Fixes T2965, see that task for discussion. This is dumb but seems like our best bet.

Test Plan:
- Installed newish version of Git.
- Set HOME on the websever to `/var/root` (or any other unreadable directory).
- Hit the error described in T2965 when viewing Diffusion.
- Applied this patch.
- Diffusion works.

Reviewers: btrahan, joel

Reviewed By: btrahan

CC: aran, chad

Maniphest Tasks: T2965

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

+27 -4
+21 -4
src/applications/repository/storage/PhabricatorRepository.php
··· 159 159 $pattern = $args[0]; 160 160 $args = array_slice($args, 1); 161 161 162 + $empty = $this->getEmptyReadableDirectoryPath(); 163 + 162 164 if ($this->shouldUseSSH()) { 163 165 switch ($this->getVersionControlSystem()) { 164 166 case PhabricatorRepositoryType::REPOSITORY_TYPE_SVN: ··· 175 177 'csprintf', 176 178 array_merge( 177 179 array( 178 - "(ssh-add %s && git {$pattern})", 180 + "(ssh-add %s && HOME=%s git {$pattern})", 179 181 $this->getSSHKeyfile(), 182 + $empty, 180 183 ), 181 184 $args)); 182 185 $pattern = "ssh-agent sh -c %s"; ··· 239 242 $pattern = "svn --non-interactive {$pattern}"; 240 243 break; 241 244 case PhabricatorRepositoryType::REPOSITORY_TYPE_GIT: 242 - $pattern = "git {$pattern}"; 245 + $pattern = "HOME=%s git {$pattern}"; 246 + array_unshift($args, $empty); 243 247 break; 244 248 case PhabricatorRepositoryType::REPOSITORY_TYPE_MERCURIAL: 245 249 $pattern = "hg {$pattern}"; ··· 258 262 $pattern = $args[0]; 259 263 $args = array_slice($args, 1); 260 264 265 + $empty = $this->getEmptyReadableDirectoryPath(); 266 + 261 267 switch ($this->getVersionControlSystem()) { 262 268 case PhabricatorRepositoryType::REPOSITORY_TYPE_SVN: 263 269 $pattern = "(cd %s && svn --non-interactive {$pattern})"; 264 270 array_unshift($args, $this->getLocalPath()); 265 271 break; 266 272 case PhabricatorRepositoryType::REPOSITORY_TYPE_GIT: 267 - $pattern = "(cd %s && git {$pattern})"; 268 - array_unshift($args, $this->getLocalPath()); 273 + $pattern = "(cd %s && HOME=%s git {$pattern})"; 274 + array_unshift($args, $this->getLocalPath(), $empty); 269 275 break; 270 276 case PhabricatorRepositoryType::REPOSITORY_TYPE_MERCURIAL: 271 277 $hgplain = (phutil_is_windows() ? "set HGPLAIN=1 &&" : "HGPLAIN=1"); ··· 279 285 array_unshift($args, $pattern); 280 286 281 287 return $args; 288 + } 289 + 290 + private function getEmptyReadableDirectoryPath() { 291 + // See T2965. Some time after Git 1.7.5.4, Git started fataling if it can 292 + // not read $HOME. For many users, $HOME points at /root (this seems to be 293 + // a default result of Apache setup). Instead, explicitly point $HOME at a 294 + // readable, empty directory so that Git looks for the config file it's 295 + // after, fails to locate it, and moves on. This is really silly, but seems 296 + // like the least damaging approach to mitigating the issue. 297 + $root = dirname(phutil_get_library_root('phabricator')); 298 + return $root.'/support/empty/'; 282 299 } 283 300 284 301 private function getSSHLogin() {
+6
support/empty/README
··· 1 + This is an empty, readable directory. If you need an empty, readable directory 2 + for some reason, you can use this one. 3 + 4 + Of course, it's not quite empty because it has this file in it. So it's a 5 + mostly-empty, readable directory. 6 +