summaryrefslogtreecommitdiff
path: root/Assistant
diff options
context:
space:
mode:
authorGravatar Joey Hess <joey@kitenet.net>2013-03-12 07:12:39 -0400
committerGravatar Joey Hess <joey@kitenet.net>2013-03-12 07:12:39 -0400
commit59227667ea41c7e255c2124ebf346c408c56eaa2 (patch)
treeedaa95d45be61b4342cc3abcc685eec2d145e742 /Assistant
parent9348bb82fee581c26898e3c862dbeb4dbb3184e6 (diff)
assistant: Fix ~/.ssh/git-annex-shell wrapper to work when the ssh key does not force a command.
Without a forced command, SSH_ORIGINAL_COMMAND is not set. So instead, in this case, run $@
Diffstat (limited to 'Assistant')
-rw-r--r--Assistant/Install.hs17
-rw-r--r--Assistant/Ssh.hs7
2 files changed, 17 insertions, 7 deletions
diff --git a/Assistant/Install.hs b/Assistant/Install.hs
index 0db021ef7..b5d3ca98d 100644
--- a/Assistant/Install.hs
+++ b/Assistant/Install.hs
@@ -15,6 +15,7 @@ import Assistant.Ssh
import Locations.UserConfig
import Utility.FileMode
import Utility.Shell
+import Utility.TempFile
#ifdef darwin_HOST_OS
import Utility.OSX
@@ -53,21 +54,25 @@ ensureInstalled = go =<< standaloneAppBase
installAutoStart program autostartfile
{- This shim is only updated if it doesn't
- - already exist with the right content. This
- - ensures that there's no race where it would have
- - worked, but is unavailable due to being updated. -}
+ - already exist with the right content. -}
sshdir <- sshDir
let shim = sshdir </> "git-annex-shell"
+ let runshell var = "exec " ++ base </> "runshell" ++
+ " git-annex-shell -c \"" ++ var ++ "\""
let content = unlines
[ shebang
, "set -e"
- , "exec", base </> "runshell" ++
- " git-annex-shell -c \"$SSH_ORIGINAL_COMMAND\""
+ , "if [ \"x$SSH_ORIGINAL_COMMAND\" != \"x\" ]; then"
+ , runshell "$SSH_ORIGINAL_COMMAND"
+ , "else"
+ , runshell "$@"
+ , "fi"
]
+
curr <- catchDefaultIO "" $ readFileStrict shim
when (curr /= content) $ do
createDirectoryIfMissing True (parentDir shim)
- writeFile shim content
+ viaTmp writeFile shim content
modifyFileMode shim $ addModes [ownerExecuteMode]
{- Returns a cleaned up environment that lacks settings used to make the
diff --git a/Assistant/Ssh.hs b/Assistant/Ssh.hs
index 4c8d8afbf..98b21b13b 100644
--- a/Assistant/Ssh.hs
+++ b/Assistant/Ssh.hs
@@ -127,8 +127,13 @@ addAuthorizedKeysCommand rsynconly dir pubkey = join "&&"
script =
[ shebang
, "set -e"
- , "exec git-annex-shell -c \"$SSH_ORIGINAL_COMMAND\""
+ , "if [ \"x$SSH_ORIGINAL_COMMAND\" != \"x\" ]; then"
+ , runshell "$SSH_ORIGINAL_COMMAND"
+ , "else"
+ , runshell "$@"
+ , "fi"
]
+ runshell var = "exec git-annex-shell -c \"" ++ var ++ "\""
authorizedKeysLine :: Bool -> FilePath -> SshPubKey -> String
authorizedKeysLine rsynconly dir pubkey