SOURCES: rpm-user_group.sh - assemble usermod -G arg properly

glen glen at pld-linux.org
Thu Jun 15 18:19:13 CEST 2006


Author: glen                         Date: Thu Jun 15 16:19:13 2006 GMT
Module: SOURCES                       Tag: HEAD
---- Log message:
- assemble usermod -G arg properly

---- Files affected:
SOURCES:
   rpm-user_group.sh (1.8 -> 1.9) 

---- Diffs:

================================================================
Index: SOURCES/rpm-user_group.sh
diff -u SOURCES/rpm-user_group.sh:1.8 SOURCES/rpm-user_group.sh:1.9
--- SOURCES/rpm-user_group.sh:1.8	Thu Jun 15 17:24:58 2006
+++ SOURCES/rpm-user_group.sh	Thu Jun 15 18:19:07 2006
@@ -63,12 +63,15 @@
 		fi
 	fi
 elif [ "$MODE" = "user" -a "$1" = "addtogroup" ]; then
-	CUSER="$2"
-	CGROUP="$3"
-	CGROUPS=$(id -n -G $CUSER)
-	if [[ " $CGROUPS " != *\ $CGROUP\ * ]]; then
-	    echo "Adding user $CUSER to group $CGROUP" | `bannercmd "${MODE}mod-$CUSER"`
-	    usermod -G "$CGROUPS,$CGROUP" $CUSER
+	user="$2"
+	group="$3"
+	groups=$(id -n -G $user)
+	if [[ " $groups " != *\ $group\ * ]]; then
+	    echo "Adding user $user to group $group" | `bannercmd "${MODE}mod-$user"`
+		for grp in $groups $group; do
+			new="$new${new:+,}$grp"
+		done
+	    usermod -G "$new" $user
 	fi
 else
 	echo ERROR
================================================================

---- CVS-web:
    http://cvs.pld-linux.org/SOURCES/rpm-user_group.sh?r1=1.8&r2=1.9&f=u



More information about the pld-cvs-commit mailing list