+2010-03-19 Nicolas François <nicolas.francois@centraliens.net>
+
+ * lib/commonio.c: Stop sorting entries when we reach the first
+ NIS line.
+
2010-03-18 Nicolas François <nicolas.francois@centraliens.net>
* src/chsh.c: Even for root, warn if an invalid shell is
{
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;
}
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);
/* 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++) {