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 $@
This commit is contained in:
Joey Hess 2013-03-12 07:12:39 -04:00
parent e5f812c4c3
commit 796f1d806f
3 changed files with 19 additions and 7 deletions

View file

@ -15,6 +15,7 @@ import Assistant.Ssh
import Locations.UserConfig import Locations.UserConfig
import Utility.FileMode import Utility.FileMode
import Utility.Shell import Utility.Shell
import Utility.TempFile
#ifdef darwin_HOST_OS #ifdef darwin_HOST_OS
import Utility.OSX import Utility.OSX
@ -53,21 +54,25 @@ ensureInstalled = go =<< standaloneAppBase
installAutoStart program autostartfile installAutoStart program autostartfile
{- This shim is only updated if it doesn't {- This shim is only updated if it doesn't
- already exist with the right content. This - already exist with the right content. -}
- ensures that there's no race where it would have
- worked, but is unavailable due to being updated. -}
sshdir <- sshDir sshdir <- sshDir
let shim = sshdir </> "git-annex-shell" let shim = sshdir </> "git-annex-shell"
let runshell var = "exec " ++ base </> "runshell" ++
" git-annex-shell -c \"" ++ var ++ "\""
let content = unlines let content = unlines
[ shebang [ shebang
, "set -e" , "set -e"
, "exec", base </> "runshell" ++ , "if [ \"x$SSH_ORIGINAL_COMMAND\" != \"x\" ]; then"
" git-annex-shell -c \"$SSH_ORIGINAL_COMMAND\"" , runshell "$SSH_ORIGINAL_COMMAND"
, "else"
, runshell "$@"
, "fi"
] ]
curr <- catchDefaultIO "" $ readFileStrict shim curr <- catchDefaultIO "" $ readFileStrict shim
when (curr /= content) $ do when (curr /= content) $ do
createDirectoryIfMissing True (parentDir shim) createDirectoryIfMissing True (parentDir shim)
writeFile shim content viaTmp writeFile shim content
modifyFileMode shim $ addModes [ownerExecuteMode] modifyFileMode shim $ addModes [ownerExecuteMode]
{- Returns a cleaned up environment that lacks settings used to make the {- Returns a cleaned up environment that lacks settings used to make the

View file

@ -127,8 +127,13 @@ addAuthorizedKeysCommand rsynconly dir pubkey = join "&&"
script = script =
[ shebang [ shebang
, "set -e" , "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 :: Bool -> FilePath -> SshPubKey -> String
authorizedKeysLine rsynconly dir pubkey authorizedKeysLine rsynconly dir pubkey

2
debian/changelog vendored
View file

@ -55,6 +55,8 @@ git-annex (4.20130228) UNRELEASED; urgency=low
* assistant: Detects most renames, including directory renames, and * assistant: Detects most renames, including directory renames, and
combines all their changes into a single commit. combines all their changes into a single commit.
* addurl: Add --relaxed option. * addurl: Add --relaxed option.
* assistant: Fix ~/.ssh/git-annex-shell wrapper to work when the
ssh key does not force a command.
-- Joey Hess <joeyh@debian.org> Wed, 27 Feb 2013 23:20:40 -0400 -- Joey Hess <joeyh@debian.org> Wed, 27 Feb 2013 23:20:40 -0400