X-Git-Url: https://codewiz.org/gitweb?p=monkeysphere.git;a=blobdiff_plain;f=src%2Fsubcommands%2Fma%2Fupdate-users;h=73685f6ddce6d532cd168065fadf5ef50145e55d;hp=0335e31448f9b3dbc409bf71af406f62ff5cc27f;hb=e4c566d5a1dd25d87d07dac1459a395321b9a5ef;hpb=8001b4523c665ee7d9ded64cbdb7081b023b75c1 diff --git a/src/subcommands/ma/update-users b/src/subcommands/ma/update-users index 0335e31..73685f6 100644 --- a/src/subcommands/ma/update-users +++ b/src/subcommands/ma/update-users @@ -13,6 +13,11 @@ update_users() { +local unames +local uname +local authorizedKeysDir +local authorizedUserIDs + if [ "$1" ] ; then # get users from command line unames="$@" @@ -21,13 +26,16 @@ else unames=$(getent passwd | cut -d: -f1) fi -RETCODE=0 +RETURN=0 # set mode MODE="authorized_keys" # set gnupg home -GNUPGHOME="$GNUPGHOME_AUTHENTICATION" +GNUPGHOME="$GNUPGHOME_SPHERE" + +# the authorized_keys directory +authorizedKeysDir="${SYSDATADIR}/authentication/authorized_keys" # check to see if the gpg trust database has been initialized if [ ! -s "${GNUPGHOME}/trustdb.gpg" ] ; then @@ -35,7 +43,7 @@ if [ ! -s "${GNUPGHOME}/trustdb.gpg" ] ; then fi # make sure the authorized_keys directory exists -mkdir -p "${SYSDATADIR}/authorized_keys" +mkdir -p "${authorizedKeysDir}" # loop over users for uname in $unames ; do @@ -48,7 +56,7 @@ for uname in $unames ; do log verbose "----- user: $uname -----" # make temporary directory - TMPLOC=$(mktemp -d ${MSTMPDIR}/tmp.XXXXXXXXXX) || failure "Could not create temporary directory!" + TMPLOC=$(mktemp -d ${MATMPDIR}/tmp.XXXXXXXXXX) || failure "Could not create temporary directory!" # trap to delete temporary directory on exit trap "rm -rf $TMPLOC" EXIT @@ -128,15 +136,15 @@ for uname in $unames ; do chown $(whoami) "$AUTHORIZED_KEYS" && \ chgrp $(id -g "$uname") "$AUTHORIZED_KEYS" && \ chmod g+r "$AUTHORIZED_KEYS" && \ - mv -f "$AUTHORIZED_KEYS" "${SYSDATADIR}/authorized_keys/${uname}" || \ + mv -f "$AUTHORIZED_KEYS" "${authorizedKeysDir}/${uname}" || \ { log error "Failed to install authorized_keys for '$uname'!" - rm -f "${SYSDATADIR}/authorized_keys/${uname}" + rm -f "${authorizedKeysDir}/${uname}" # indicate that there has been a failure: RETURN=1 } else - rm -f "${SYSDATADIR}/authorized_keys/${uname}" + rm -f "${authorizedKeysDir}/${uname}" fi # unset the trap