From: Jameson Graef Rollins Date: Wed, 18 Feb 2009 00:07:24 +0000 (-0500) Subject: add test to su_monkeysphere_user to check that the user is X-Git-Tag: monkeysphere_0.23~77 X-Git-Url: https://codewiz.org/gitweb?p=monkeysphere.git;a=commitdiff_plain;h=f85639e234d72429a2d848b1b875d615a47bf120 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). --- 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