Skip to content

Commit

Permalink
Fix git-ssh hangs on Linux
Browse files Browse the repository at this point in the history
  • Loading branch information
jcheng5 committed Sep 21, 2011
1 parent 68a2a18 commit da8b377
Show file tree
Hide file tree
Showing 2 changed files with 31 additions and 3 deletions.
26 changes: 24 additions & 2 deletions src/cpp/session/modules/SessionSourceControl.cpp
Expand Up @@ -1558,11 +1558,30 @@ core::Error initialize()
s_pVcsImpl_.reset(new VCSImpl(workingDir));

bool interceptSsh;
bool interceptAskPass;

if (options().programMode() == kSessionProgramModeServer)
{
interceptSsh = true;
interceptAskPass = true;
}
else
{
#ifdef __APPLE__
interceptSsh = options().programMode() != kSessionProgramModeDesktop;
// Default behavior on Mac desktop works great
interceptSsh = false;
interceptAskPass = false;
#elif defined(_WIN32)
// Windows probably unlikely to have either ssh-agent or askpass
interceptSsh = true;
interceptAskPass = true;
#else
interceptSsh = true;
// Everything fine on Linux except we need to detach the console
// using setsid
interceptSsh = true;
interceptAskPass = false;
#endif
}

if (interceptSsh)
{
Expand All @@ -1573,7 +1592,10 @@ core::Error initialize()
if (error)
return error;
core::system::setenv("GIT_SSH", toBashPath(gitSshCmd));
}

if (interceptAskPass)
{
std::string sshAskCmd;
error = module_context::registerPostbackHandler("askpass",
postbackSSHAskPass,
Expand Down
8 changes: 7 additions & 1 deletion src/cpp/session/postback/rpostback-gitssh
Expand Up @@ -17,4 +17,10 @@ set -e

SSH_AGENT_SCRIPT=`$(dirname $0)/rpostback gitssh`
eval "$SSH_AGENT_SCRIPT" &> /dev/null
ssh -o StrictHostKeyChecking=no $*

unamestr=`uname`
if [[ "$unamestr" == "Linux" ]]; then
setsid ssh -o StrictHostKeyChecking=no $*
else
ssh -o StrictHostKeyChecking=no $*
fi

0 comments on commit da8b377

Please sign in to comment.