[Cdd-commits] cdd/common/cdd/share/cdd/unixgroups cdd-actions,1.11,1.12
Andreas Tille
debian-custom@lists.debian.org
Fri, 18 Jun 2004 12:43:59 +0000
Update of /cvsroot/cdd/cdd/common/cdd/share/cdd/unixgroups
In directory haydn:/tmp/cvs-serv29137
Modified Files:
cdd-actions
Log Message:
Try to implement functionality of get-group-users - but failed for the moment.
Index: cdd-actions
===================================================================
RCS file: /cvsroot/cdd/cdd/common/cdd/share/cdd/unixgroups/cdd-actions,v
retrieving revision 1.11
retrieving revision 1.12
diff -u -d -r1.11 -r1.12
--- cdd-actions 14 Jun 2004 20:57:47 -0000 1.11
+++ cdd-actions 18 Jun 2004 12:43:55 -0000 1.12
@@ -8,6 +8,11 @@
#checkCDD() is backend indep, and is defined in ${SHAREDIR}/cdd-action
+# Read adduser config to find out from which ID normal users start
+# Default = 1000
+FIRST_UID=1000
+[ -s /etc/adduser.conf ] && . /etc/adduser.conf
+
# checks if User $1 exists as a system user
checkUser() {
RET=0
@@ -82,7 +87,6 @@
return ${RET}
}
-
# echoes list of users having role $2 in CDD $1
# if $3 exists use ',' as separator between user names
getUsersInRole() {
@@ -102,6 +106,41 @@
fi
return ${RET}
}
+
+# echoes list of all users of the system
+# $1 = 1 - simply login names, $1 = 0 (or anything else) - login names and real name
+# if $1 exists use ',' as separator between user names
+getAllUsers() {
+ RET=0
+ if [ "$#" -ne 1 -a "$#" -ne 2 ]; then
+ RET=64 # EX_USAGE
+ else
+ SIMPLE=$1
+ KOMMA=" "
+ # Append ',' if second argument is given
+ if [ "$#" -eq 2 ]; then
+ KOMMA=", "
+ fi
+ USERS=""
+ (IFS=":"
+ while read user pass uid gid name rest ; do
+ if [ $uid -ge $FIRST_UID -a "$user" != "nobody" ] ; then
+ name=`echo $name | sed "s/,.*//"`
+ if [ "$USERS" != "" ] ; then
+ USERS="$USERS$KOMMA"
+ fi
+ if [ $SIMPLE -eq 1 ] ; then
+ USERS="$USERS$user"
+ else
+ USERS="$USERS$user ($name)"
+ fi
+ fi
+ done < /etc/passwd
+ echo $USERS
+ )
+ fi
+ return ${RET}
+}
# echo all Role covered by user $2 in CDD $1
getUserRoles() {
RET=0
@@ -156,7 +195,7 @@
if [ "$#" -ne 2 ]; then
RET=64 # EX_USAGE
else
- ${DRYRUN} addgroup --system "${ROLE}"
+ ${DRYRUN} addgroup --system "${ROLE}" || true
RET=$?
fi
return ${RET}