[Pkg-shadow-commits] r2487 - in upstream/trunk: . libmisc

nekral-guest at alioth.debian.org nekral-guest at alioth.debian.org
Sun Feb 22 23:23:16 UTC 2009


Author: nekral-guest
Date: 2009-02-22 23:23:15 +0000 (Sun, 22 Feb 2009)
New Revision: 2487

Modified:
   upstream/trunk/ChangeLog
   upstream/trunk/libmisc/find_new_gid.c
   upstream/trunk/libmisc/find_new_uid.c
Log:
	* libmisc/find_new_gid.c, libmisc/find_new_uid.c: Avoid calling
	getgrent()/getpwent() after they return NULL. This caused LDAP to
	return at the beginning of the group/user entries.


Modified: upstream/trunk/ChangeLog
===================================================================
--- upstream/trunk/ChangeLog	2009-01-27 18:17:54 UTC (rev 2486)
+++ upstream/trunk/ChangeLog	2009-02-22 23:23:15 UTC (rev 2487)
@@ -1,3 +1,9 @@
+2009-02-22  Nicolas François  <nicolas.francois at centraliens.net>
+
+	* libmisc/find_new_gid.c, libmisc/find_new_uid.c: Avoid calling
+	getgrent()/getpwent() after they return NULL. This caused LDAP to
+	return at the beginning of the group/user entries.
+
 2009-01-27  Nicolas François  <nicolas.francois at centraliens.net>
 
 	* man/nologin.8.xml: Fix typo (HYSTORY -> HISTORY).

Modified: upstream/trunk/libmisc/find_new_gid.c
===================================================================
--- upstream/trunk/libmisc/find_new_gid.c	2009-01-27 18:17:54 UTC (rev 2486)
+++ upstream/trunk/libmisc/find_new_gid.c	2009-02-22 23:23:15 UTC (rev 2487)
@@ -89,9 +89,18 @@
 	 * some groups were created but the changes were not committed yet.
 	 */
 	setgrent ();
+	while ((grp = getgrent ()) != NULL) {
+		if ((grp->gr_gid >= group_id) && (grp->gr_gid <= gid_max)) {
+			group_id = grp->gr_gid + 1;
+		}
+		/* create index of used GIDs */
+		if (grp->gr_gid <= gid_max) {
+			used_gids[grp->gr_gid] = 1;
+		}
+	}
+	endgrent ();
 	gr_rewind ();
-	while (   ((grp = getgrent ()) != NULL)
-	       || ((grp = gr_next ()) != NULL)) {
+	while ((grp = getgrent ()) != NULL) {
 		if ((grp->gr_gid >= group_id) && (grp->gr_gid <= gid_max)) {
 			group_id = grp->gr_gid + 1;
 		}
@@ -100,7 +109,6 @@
 			used_gids[grp->gr_gid] = 1;
 		}
 	}
-	endgrent ();
 
 	/*
 	 * If a group with GID equal to GID_MAX exists, the above algorithm

Modified: upstream/trunk/libmisc/find_new_uid.c
===================================================================
--- upstream/trunk/libmisc/find_new_uid.c	2009-01-27 18:17:54 UTC (rev 2486)
+++ upstream/trunk/libmisc/find_new_uid.c	2009-02-22 23:23:15 UTC (rev 2487)
@@ -90,9 +90,18 @@
 	 * some users were created but the changes were not committed yet.
 	 */
 	setpwent ();
+	while ((pwd = getpwent ()) != NULL) {
+		if ((pwd->pw_uid >= user_id) && (pwd->pw_uid <= uid_max)) {
+			user_id = pwd->pw_uid + 1;
+		}
+		/* create index of used UIDs */
+		if (pwd->pw_uid <= uid_max) {
+			used_uids[pwd->pw_uid] = 1;
+		}
+	}
+	endpwent ();
 	pw_rewind ();
-	while (   ((pwd = getpwent ()) != NULL)
-	       || ((pwd = pw_next ()) != NULL)) {
+	while ((pwd = pw_next ()) != NULL) {
 		if ((pwd->pw_uid >= user_id) && (pwd->pw_uid <= uid_max)) {
 			user_id = pwd->pw_uid + 1;
 		}
@@ -101,7 +110,6 @@
 			used_uids[pwd->pw_uid] = 1;
 		}
 	}
-	endpwent ();
 
 	/*
 	 * If a user with UID equal to UID_MAX exists, the above algorithm




More information about the Pkg-shadow-commits mailing list