summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rwxr-xr-xsrc/share/common8
1 files changed, 6 insertions, 2 deletions
diff --git a/src/share/common b/src/share/common
index 508b064..78fb04e 100755
--- a/src/share/common
+++ b/src/share/common
@@ -101,15 +101,19 @@ su_monkeysphere_user() {
# introduce an extra dependency just for this. This may be a
# candidate for re-factoring if we switch implementation languages.
+ # singlequote-escape strings - like this bashism:
+ # printf -v CMDLINE "%q " "$@"
+ local CMDLINE="$(perl -0 -e "foreach (@ARGV) {s/'/'\\\\''/g; print \"'\$_' \"}" "$@")"
+
case $(id -un) in
# if monkeysphere user, run the command under bash
"$MONKEYSPHERE_USER")
- bash -c "$*"
+ bash -c "$CMDLINE"
;;
# if root, su command as monkeysphere user
'root')
- su "$MONKEYSPHERE_USER" -c "$*"
+ su "$MONKEYSPHERE_USER" -c "$CMDLINE"
;;
# otherwise, fail