improve function to get primary group to make it more portable
[monkeysphere.git] / src / share / common
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