X-Git-Url: https://codewiz.org/gitweb?a=blobdiff_plain;f=src%2Fshare%2Fcommon;h=11e7969952f2b8dfb2cca4f1f87cd4959ca38f89;hb=c2a85da2be8f884cb7e96f05d8a37dcb6ddd80b5;hp=ac0b5d6382a9dd2c345209d0b18d605b1ee84d27;hpb=8a10cedafffa08873508598c9bff0c12e1c5d278;p=monkeysphere.git diff --git a/src/share/common b/src/share/common index ac0b5d6..11e7969 100644 --- a/src/share/common +++ b/src/share/common @@ -390,7 +390,7 @@ translate_ssh_variables() { path="$2" # get the user's home directory - userHome=$(getent passwd "$uname" | cut -d: -f6) + userHome=$(get_homedir "$uname") # translate '%u' to user name path=${path/\%u/"$uname"} @@ -458,6 +458,25 @@ check_key_file_permissions() { fi } +# return a list of all users on the system +list_users() { + if type getent &>/dev/null ; then + # for linux and FreeBSD systems + getent passwd | cut -d: -f1 + elif type dscl &>/dev/null ; then + # for Darwin systems + dscl localhost -list /Search/Users + else + failure "Neither getent or dscl is in the path! Could not determine list of users." + fi +} + +# return the path to the home directory of a user +get_homedir() { + local uname=${1:-`whoami`} + eval "echo ~${uname}" +} + ### CONVERSION UTILITIES # output the ssh key for a given key ID