diff options
author | Jameson Graef Rollins <jrollins@finestructure.net> | 2009-07-11 16:25:52 -0400 |
---|---|---|
committer | Jameson Graef Rollins <jrollins@finestructure.net> | 2009-07-11 16:25:52 -0400 |
commit | ba3ca3e10f4975510dfeedcb6dfe8e2374ca3097 (patch) | |
tree | 5f15be76c1be31fd6fed62d544cf592de1421f68 /src | |
parent | 3e5df3def466a61cd32bdcc1fd29da09dff43729 (diff) |
improve function to get primary group to make it more portable
Diffstat (limited to 'src')
-rwxr-xr-x | src/monkeysphere-authentication | 2 | ||||
-rwxr-xr-x | src/monkeysphere-host | 2 | ||||
-rw-r--r-- | src/share/common | 6 |
3 files changed, 8 insertions, 2 deletions
diff --git a/src/monkeysphere-authentication b/src/monkeysphere-authentication index 0e6f986..5b30628 100755 --- a/src/monkeysphere-authentication +++ b/src/monkeysphere-authentication @@ -120,7 +120,7 @@ LOG_LEVEL=${MONKEYSPHERE_LOG_LEVEL:=$LOG_LEVEL} KEYSERVER=${MONKEYSPHERE_KEYSERVER:=$KEYSERVER} CHECK_KEYSERVER=${MONKEYSPHERE_CHECK_KEYSERVER:=$CHECK_KEYSERVER} MONKEYSPHERE_USER=${MONKEYSPHERE_MONKEYSPHERE_USER:=$MONKEYSPHERE_USER} -MONKEYSPHERE_GROUP=$(groups "$MONKEYSPHERE_USER" | cut -d: -f2 | awk '{ print $1 }') +MONKEYSPHERE_GROUP=$(get_primary_group "$MONKEYSPHERE_USER") PROMPT=${MONKEYSPHERE_PROMPT:=$PROMPT} AUTHORIZED_USER_IDS=${MONKEYSPHERE_AUTHORIZED_USER_IDS:=$AUTHORIZED_USER_IDS} RAW_AUTHORIZED_KEYS=${MONKEYSPHERE_RAW_AUTHORIZED_KEYS:=$RAW_AUTHORIZED_KEYS} diff --git a/src/monkeysphere-host b/src/monkeysphere-host index 60b627a..ebd29c8 100755 --- a/src/monkeysphere-host +++ b/src/monkeysphere-host @@ -226,7 +226,7 @@ LOG_LEVEL=${MONKEYSPHERE_LOG_LEVEL:=$LOG_LEVEL} KEYSERVER=${MONKEYSPHERE_KEYSERVER:=$KEYSERVER} CHECK_KEYSERVER=${MONKEYSPHERE_CHECK_KEYSERVER:=$CHECK_KEYSERVER} MONKEYSPHERE_USER=${MONKEYSPHERE_MONKEYSPHERE_USER:=$MONKEYSPHERE_USER} -MONKEYSPHERE_GROUP=$(groups "$MONKEYSPHERE_USER" | cut -d: -f2 | awk '{ print $1 }') +MONKEYSPHERE_GROUP=$(get_primary_group "$MONKEYSPHERE_USER") PROMPT=${MONKEYSPHERE_PROMPT:=$PROMPT} # other variables diff --git a/src/share/common b/src/share/common index bd887d3..76b539f 100644 --- a/src/share/common +++ b/src/share/common @@ -483,6 +483,12 @@ get_homedir() { eval "echo ~${uname}" } +# return the primary group of a user +get_primary_group() { + local uname=${1:-`whoami`} + groups "$uname" | sed 's/^..* : //' | awk '{ print $1 }' +} + ### CONVERSION UTILITIES # output the ssh key for a given key ID |