summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorJameson Graef Rollins <jrollins@finestructure.net>2009-02-17 19:07:24 -0500
committerJameson Graef Rollins <jrollins@finestructure.net>2009-02-17 19:07:24 -0500
commitf85639e234d72429a2d848b1b875d615a47bf120 (patch)
tree360afdd4614d17049aaf6f4479e6287130d31621 /src
parenta2a3d02d1aaf2d3dae3afea90c85cd6ca9f7ce4d (diff)
add test to su_monkeysphere_user to check that the user is
monkeysphere user or root, and fail otherwise. this is so that there is no password prompt for unpriviledged users (see bug #519).
Diffstat (limited to 'src')
-rw-r--r--src/share/common23
1 files changed, 15 insertions, 8 deletions
diff --git a/src/share/common b/src/share/common
index 42df684..773c11f 100644
--- a/src/share/common
+++ b/src/share/common
@@ -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
- bash -c "$@"
+ 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