Merge commit 'jrollins/master'
[monkeysphere.git] / src / share / common
index d60631e0ab99e1c074d9b5fef9a5b9b863510c4b..773c11fe9fe42a6e3ef21ba5ecc9f856fb64500e 100644 (file)
@@ -92,15 +92,22 @@ log() {
 
 # run command as monkeysphere user
 su_monkeysphere_user() {
-    # if the current user is the monkeysphere user, then just eval
-    # command
-    if [ $(id -un) = "$MONKEYSPHERE_USER" ] ; then
-       eval "$@"
+    case $(id -un) in
+       # if monkeysphere user, run the command under bash
+       "$MONKEYSPHERE_USER")
+           bash -c "$@"
+           ;;
 
-    # otherwise su command as monkeysphere user
-    else
-       su "$MONKEYSPHERE_USER" -c "$@"
-    fi
+         # if root, su command as monkeysphere user
+       'root')
+           su "$MONKEYSPHERE_USER" -c "$@"
+           ;;
+
+       # otherwise, fail
+       *)
+           log error "non-privileged user."
+           ;;
+    esac
 }
 
 # cut out all comments(#) and blank lines from standard input