improve function to get primary group to make it more portable
authorJameson Graef Rollins <jrollins@finestructure.net>
Sat, 11 Jul 2009 20:25:52 +0000 (16:25 -0400)
committerJameson Graef Rollins <jrollins@finestructure.net>
Sat, 11 Jul 2009 20:25:52 +0000 (16:25 -0400)
src/monkeysphere-authentication
src/monkeysphere-host
src/share/common

index 0e6f986fc1d23a3a3809c79112483015d54e3285..5b30628a188341d2e8c64dbc339d377220caa2f7 100755 (executable)
@@ -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}
index 60b627a63d631cc82f81081edae506b581c6bb18..ebd29c81754bf7103e0b6f21f9cb51914add333d 100755 (executable)
@@ -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
index bd887d39b410d333badc6048b08d5e777322ce4b..76b539f4ab89dc9ddd8d585a751f64ed4f514430 100644 (file)
@@ -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