From c8719b2f757364178ecbe621b027765c8ce58ef4 Mon Sep 17 00:00:00 2001 From: Daniel Kahn Gillmor Date: Mon, 6 Apr 2009 22:32:56 -0400 Subject: replacing head -c with dd (for portability reasons, see #673) --- src/share/ma/setup | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'src/share/ma') diff --git a/src/share/ma/setup b/src/share/ma/setup index b453f3c..4c87009 100644 --- a/src/share/ma/setup +++ b/src/share/ma/setup @@ -57,9 +57,9 @@ EOF if [ -z "$CORE_FPR" ] ; then log info "setting up Monkeysphere authentication trust core..." - local CORE_UID=$(printf "Monkeysphere authentication trust core UID (random string: %s)" $(head -c21 Date: Mon, 6 Apr 2009 22:40:08 -0700 Subject: Add two new compatibility functions: - list_user to list all users on the system - get_homedir to return the path to a users home directory These functions should provide compatibility on linux, FreeBSD and Darwin systems. --- src/share/common | 19 ++++++++++++++++++- src/share/ma/update_users | 2 +- 2 files changed, 19 insertions(+), 2 deletions(-) (limited to 'src/share/ma') diff --git a/src/share/common b/src/share/common index ac0b5d6..f954bb9 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,23 @@ 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 + 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 diff --git a/src/share/ma/update_users b/src/share/ma/update_users index 3a5c006..c5c74cf 100644 --- a/src/share/ma/update_users +++ b/src/share/ma/update_users @@ -24,7 +24,7 @@ if [ "$1" ] ; then unames="$@" else # or just look at all users if none specified - unames=$(getent passwd | cut -d: -f1) + unames=$(list_users) fi # set mode -- cgit v1.2.3