[Pkg-shadow-commits] r3166 - in upstream/trunk: . lib

Nicolas FRANÇOIS nekral-guest at alioth.debian.org
Thu Mar 18 23:21:23 UTC 2010


Author: nekral-guest
Date: 2010-03-18 23:21:21 +0000 (Thu, 18 Mar 2010)
New Revision: 3166

Modified:
   upstream/trunk/ChangeLog
   upstream/trunk/lib/commonio.c
Log:
	* lib/commonio.c: Stop sorting entries when we reach the first
	NIS line.

Modified: upstream/trunk/ChangeLog
===================================================================
--- upstream/trunk/ChangeLog	2010-03-18 23:21:10 UTC (rev 3165)
+++ upstream/trunk/ChangeLog	2010-03-18 23:21:21 UTC (rev 3166)
@@ -1,3 +1,8 @@
+2010-03-19  Nicolas François  <nicolas.francois at centraliens.net>
+
+	* lib/commonio.c: Stop sorting entries when we reach the first
+	NIS line.
+
 2010-03-18  Nicolas François  <nicolas.francois at centraliens.net>
 
 	* src/chsh.c: Even for root, warn if an invalid shell is

Modified: upstream/trunk/lib/commonio.c
===================================================================
--- upstream/trunk/lib/commonio.c	2010-03-18 23:21:10 UTC (rev 3165)
+++ upstream/trunk/lib/commonio.c	2010-03-18 23:21:21 UTC (rev 3166)
@@ -706,10 +706,24 @@
 {
 	struct commonio_entry **entries, *ptr;
 	size_t n = 0, i;
+#if KEEP_NIS_AT_END
+	struct commonio_entry *nis = NULL
+#endif
 
-	for (ptr = db->head; NULL != ptr; ptr = ptr->next) {
+	for (ptr = db->head;
+	        (NULL != ptr)
+#if KEEP_NIS_AT_END
+	     && ('+' != ptr->line[0])
+#endif
+	     ;
+	     ptr = ptr->next) {
 		n++;
 	}
+#if KEEP_NIS_AT_END
+	if (NULL != ptr) {
+		nis = ptr;
+	}
+#endif
 
 	if (n <= 1) {
 		return 0;
@@ -721,7 +735,13 @@
 	}
 
 	n = 0;
-	for (ptr = db->head; NULL != ptr; ptr = ptr->next) {
+	for (ptr = db->head;
+#if KEEP_NIS_AT_END
+	     nis != ptr;
+#else
+	     NULL != ptr;
+#endif
+	     ptr = ptr->next) {
 		entries[n++] = ptr;
 	}
 	qsort (entries, n, sizeof (struct commonio_entry *), cmp);
@@ -729,11 +749,16 @@
 	/* Take care of the head and tail separately */
 	db->head = entries[0];
 	n--;
-	db->tail = entries[n];
+#if KEEP_NIS_AT_END
+	if (NULL == nis)
+#endif
+	{
+		db->tail = entries[n];
+	}
 	db->head->prev = NULL;
 	db->head->next = entries[1];
-	db->tail->prev = entries[n - 1];
-	db->tail->next = NULL;
+	entries[n]->prev = entries[n - 1];
+	entries[n]->next = NULL;
 
 	/* Now other elements have prev and next entries */
 	for (i = 1; i < n; i++) {




More information about the Pkg-shadow-commits mailing list