protected function newCustomEnvironment()
 {
     $env = array();
     // NOTE: See T2965. Some time after Git 1.7.5.4, Git started fataling if
     // it can not read $HOME. For many users, $HOME points at /root (this
     // seems to be a default result of Apache setup). Instead, explicitly
     // point $HOME at a readable, empty directory so that Git looks for the
     // config file it's after, fails to locate it, and moves on. This is
     // really silly, but seems like the least damaging approach to
     // mitigating the issue.
     $env['HOME'] = PhabricatorEnv::getEmptyCWD();
     if ($this->isAnySSHProtocol()) {
         $env['GIT_SSH'] = $this->getSSHWrapper();
     }
     if ($this->isAnyHTTPProtocol()) {
         $uri = $this->getURI();
         if ($uri) {
             $proxy = PhutilHTTPEngineExtension::buildHTTPProxyURI($uri);
             if ($proxy) {
                 if ($this->isHTTPSProtocol()) {
                     $env_key = 'https_proxy';
                 } else {
                     $env_key = 'http_proxy';
                 }
                 $env[$env_key] = (string) $proxy;
             }
         }
     }
     return $env;
 }
 protected function executeRepositoryOperations()
 {
     $repository = $this->getRepository();
     $args = $this->getArgs();
     if (!$args->getArg('tunnel')) {
         throw new Exception(pht('Expected `%s`!', 'svnserve -t'));
     }
     if ($this->shouldProxy()) {
         $command = $this->getProxyCommand();
         $this->isProxying = true;
         $cwd = null;
     } else {
         $command = csprintf('svnserve -t --tunnel-user=%s', $this->getUser()->getUsername());
         $cwd = PhabricatorEnv::getEmptyCWD();
     }
     $command = PhabricatorDaemon::sudoCommandAsDaemonUser($command);
     $future = new ExecFuture('%C', $command);
     // If we're receiving a commit, svnserve will fail to execute the commit
     // hook with an unhelpful error if the CWD isn't readable by the user we
     // are sudoing to. Switch to a readable, empty CWD before running
     // svnserve. See T10941.
     if ($cwd !== null) {
         $future->setCWD($cwd);
     }
     $this->inProtocol = new DiffusionSubversionWireProtocol();
     $this->outProtocol = new DiffusionSubversionWireProtocol();
     $this->command = id($this->newPassthruCommand())->setIOChannel($this->getIOChannel())->setCommandChannelFromExecFuture($future)->setWillWriteCallback(array($this, 'willWriteMessageCallback'))->setWillReadCallback(array($this, 'willReadMessageCallback'));
     $this->command->setPauseIOReads(true);
     $err = $this->command->execute();
     if (!$err && $this->didSeeWrite) {
         $this->getRepository()->writeStatusMessage(PhabricatorRepositoryStatusMessage::TYPE_NEEDS_UPDATE, PhabricatorRepositoryStatusMessage::CODE_OKAY);
     }
     return $err;
 }