[Pkg-shadow-devel] patch for userdel

Nicolas François nicolas.francois@centraliens.net
Thu, 16 Jun 2005 01:23:27 +0200


--iFRdW5/EC4oqxDHL
Content-Type: text/plain; charset=us-ascii
Content-Disposition: inline

Hello Tomasz,

This patch removes the group from gshadow.

More info at: http://bugs.debian.org/99442

Best Regards,
-- 
Nekral

--iFRdW5/EC4oqxDHL
Content-Type: text/plain; charset=us-ascii
Content-Disposition: attachment; filename=008_userdel_remove_group_from_gshadow

Goal: userdel now deletes user groups from /etc/gshdow as well as
      /etc/group.
Fixes: #99442

Status wrt upstream: It could certainly be submitted to upstream.

Index: src/userdel.c
===================================================================
RCS file: /cvsroot/shadow/src/userdel.c,v
retrieving revision 1.39
diff -u -r1.39 userdel.c
--- src/userdel.c	25 May 2005 19:31:51 -0000	1.39
+++ src/userdel.c	15 Jun 2005 18:06:17 -0000
@@ -122,6 +122,7 @@
 	struct group *ngrp;
 
 #ifdef	SHADOWGRP
+	int deleted_user_group = 0;
 	const struct sgrp *sgrp;
 	struct sgrp *nsgrp;
 #endif				/* SHADOWGRP */
@@ -174,6 +175,10 @@
 
 		gr_remove (grp->gr_name);
 
+#ifdef SHADOWGRP
+		deleted_user_group = 1;
+#endif
+
 		SYSLOG ((LOG_INFO, "removed group `%s' owned by `%s'\n",
 			 grp->gr_name, user_name));
 	}
@@ -218,6 +223,9 @@
 		SYSLOG ((LOG_INFO, "delete `%s' from shadow group `%s'\n",
 			 user_name, nsgrp->sg_name));
 	}
+
+	if (deleted_user_group)
+		sgr_remove(user_name);
 #endif				/* SHADOWGRP */
 }
 

--iFRdW5/EC4oqxDHL--