webapp: Run ssh server probes in a way that will work when the login shell is a monstrosity that should have died 25 years ago, such as csh.

This commit is contained in:
Joey Hess 2013-03-29 13:09:30 -04:00
parent 65c7fcc77a
commit 6fa0d0ecc8
5 changed files with 23 additions and 3 deletions

View file

@ -206,7 +206,7 @@ testServer sshinput@(SshInput { inputHostname = Just hn }) = do
, rsyncOnly = status == UsableRsyncServer
}
probe extraopts = do
let remotecommand = join ";"
let remotecommand = shellWrap $ join ";"
[ report "loggedin"
, checkcommand "git-annex-shell"
, checkcommand "rsync"
@ -236,6 +236,7 @@ testServer sshinput@(SshInput { inputHostname = Just hn }) = do
"Failed to ssh to the server. Transcript: " ++ s
where
reported r = token r `isInfixOf` s
checkcommand c = "if which " ++ c ++ "; then " ++ report c ++ "; fi"
token r = "git-annex-probe " ++ r
report r = "echo " ++ token r
@ -287,7 +288,7 @@ makeSsh' rsync setup sshdata keypair =
where
sshhost = genSshHost (sshHostName sshdata) (sshUserName sshdata)
remotedir = T.unpack $ sshDirectory sshdata
remoteCommand = join "&&" $ catMaybes
remoteCommand = shellWrap $ join "&&" $ catMaybes
[ Just $ "mkdir -p " ++ shellEscape remotedir
, Just $ "cd " ++ shellEscape remotedir
, if rsync then Nothing else Just "git init --bare --shared"

View file

@ -55,8 +55,16 @@ safeSystemEnv command params environ = do
{ env = environ }
waitForProcess pid
{- Wraps a shell command line inside sh -c, allowing it to be run in a
- login shell that may not support POSIX shell, eg csh. -}
shellWrap :: String -> String
shellWrap cmdline = "sh -c " ++ shellEscape cmdline
{- Escapes a filename or other parameter to be safely able to be exposed to
- the shell. -}
- the shell.
-
- This method works for POSIX shells, as well as other shells like csh.
-}
shellEscape :: String -> String
shellEscape f = "'" ++ escaped ++ "'"
where

3
debian/changelog vendored
View file

@ -7,6 +7,9 @@ git-annex (4.20130324) UNRELEASED; urgency=low
* webapp: Progess bar fixes for many types of special remotes.
* Build debian package without using cabal, which writes to HOME.
Closes: #704205
* webapp: Run ssh server probes in a way that will work when the
login shell is a monstrosity that should have died 25 years ago,
such as csh.
-- Joey Hess <joeyh@debian.org> Mon, 25 Mar 2013 10:21:46 -0400

View file

@ -18,3 +18,7 @@ git-annex version: 3.20121017
Not everyone has bash as there login-shell.
[[!tag /design/assistant]]
> [[done]]; assistant now uses sh -c "sane shell stuff here" to work
> around csh. (There are systems without bash, but probably fewer without sh)
> --[[Joey]]

View file

@ -13,3 +13,7 @@ ssh keys were installed to allow login, when ssh-askpass was not found on osx ve
[[!meta title="webapp rsync probe command failed on FreeNAS box"]]
[[!tag /design/assistant]]
> [[done]]; based on the error message it's using csh and
> the assistant will now wrap its shell commands to work with csh.
> --[[Joey]]