aboutsummaryrefslogtreecommitdiff
path: root/Utility/SafeCommand.hs
diff options
context:
space:
mode:
authorGravatar Joey Hess <joey@kitenet.net>2013-03-29 13:09:30 -0400
committerGravatar Joey Hess <joey@kitenet.net>2013-03-29 13:09:30 -0400
commit846642da916800f2ea42dc2e1b97da32a11fc1bf (patch)
treeda8a455f45c3e14d7e822c9ab4875d351f734d3a /Utility/SafeCommand.hs
parent987b11fdf42b58a92d817131c416edbdbcb94297 (diff)
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.
Diffstat (limited to 'Utility/SafeCommand.hs')
-rw-r--r--Utility/SafeCommand.hs10
1 files changed, 9 insertions, 1 deletions
diff --git a/Utility/SafeCommand.hs b/Utility/SafeCommand.hs
index e6075e888..785aec578 100644
--- a/Utility/SafeCommand.hs
+++ b/Utility/SafeCommand.hs
@@ -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