Index: trunk/server/common/oursrc/nss_nonlocal/Makefile.am
===================================================================
--- trunk/server/common/oursrc/nss_nonlocal/Makefile.am	(revision 2428)
+++ trunk/server/common/oursrc/nss_nonlocal/Makefile.am	(revision 2432)
@@ -2,5 +2,5 @@
 libnss_nonlocal_la_SOURCES = \
     nonlocal-passwd.c nonlocal-group.c nonlocal-shadow.c \
-    nonlocal.h nsswitch-internal.h
+    nonlocal.h nsswitch-internal.h walk_nss.h
 libnss_nonlocal_la_LDFLAGS = \
     -version-info 2:0:0 \
@@ -11,2 +11,5 @@
 	rm -f $(DESTDIR)$(libdir)/libnss_nonlocal.so
 	rm -f $(DESTDIR)$(libdir)/libnss_nonlocal.la
+
+uninstall-local:
+	rm -f $(DESTDIR)$(libdir)/libnss_nonlocal.so.*
Index: trunk/server/common/oursrc/nss_nonlocal/configure.ac
===================================================================
--- trunk/server/common/oursrc/nss_nonlocal/configure.ac	(revision 2428)
+++ trunk/server/common/oursrc/nss_nonlocal/configure.ac	(revision 2432)
@@ -1,3 +1,3 @@
-AC_INIT([nss_nonlocal], [2.0], [andersk@mit.edu])
+AC_INIT([nss_nonlocal], [2.1], [andersk@mit.edu])
 AC_CANONICAL_TARGET
 AM_INIT_AUTOMAKE([-Wall -Werror foreign])
@@ -7,5 +7,5 @@
 AC_DISABLE_STATIC
 AC_PROG_CC
-AC_PROG_INSTALL
+m4_ifdef([AM_PROG_AR], [AM_PROG_AR])
 AC_PROG_LIBTOOL
 
Index: trunk/server/common/oursrc/nss_nonlocal/nonlocal-group.c
===================================================================
--- trunk/server/common/oursrc/nss_nonlocal/nonlocal-group.c	(revision 2428)
+++ trunk/server/common/oursrc/nss_nonlocal/nonlocal-group.c	(revision 2432)
@@ -25,16 +25,18 @@
 
 #define _GNU_SOURCE
+
 #include <sys/types.h>
-#include <unistd.h>
-#include <stdlib.h>
-#include <stdint.h>
-#include <string.h>
 #include <dlfcn.h>
-#include <stdio.h>
-#include <syslog.h>
 #include <errno.h>
-#include <pwd.h>
 #include <grp.h>
 #include <nss.h>
+#include <pwd.h>
+#include <stdbool.h>
+#include <stddef.h>
+#include <stdlib.h>
+#include <string.h>
+#include <syslog.h>
+#include <unistd.h>
+
 #include "nsswitch-internal.h"
 #include "nonlocal.h"
@@ -170,4 +172,5 @@
 }
 
+static bool grent_initialized = false;
 static service_user *grent_startp, *grent_nip;
 static void *grent_fct_start;
@@ -194,7 +197,10 @@
 	return status;
 
-    if (grent_fct_start == NULL)
+    if (!grent_initialized) {
 	__nss_group_nonlocal_lookup(&grent_startp, grent_fct_name,
 				    &grent_fct_start);
+	__sync_synchronize();
+	grent_initialized = true;
+    }
     grent_nip = grent_startp;
     grent_fct.ptr = grent_fct_start;
@@ -208,5 +214,5 @@
     const struct walk_nss w = {
 	.lookup = &__nss_group_nonlocal_lookup, .fct_name = "endgrent",
-	.status = &status
+	.status = &status, .all_values = 1,
     };
     const __typeof__(&_nss_nonlocal_endgrent) self = NULL;
@@ -356,5 +362,5 @@
     const struct walk_nss w = {
 	.lookup = &__nss_group_nonlocal_lookup, .fct_name = "initgroups_dyn",
-	.status = &status, .errnop = errnop
+	.status = &status, .all_values = 1, .errnop = errnop
     };
     const __typeof__(&_nss_nonlocal_initgroups_dyn) self = NULL;
@@ -445,5 +451,7 @@
 #include "walk_nss.h"
 #undef args
-    if (status != NSS_STATUS_SUCCESS)
+    if (status == NSS_STATUS_NOTFOUND || status == NSS_STATUS_UNAVAIL)
+	return NSS_STATUS_SUCCESS;
+    else if (status != NSS_STATUS_SUCCESS)
         return status;
 
Index: trunk/server/common/oursrc/nss_nonlocal/nonlocal-passwd.c
===================================================================
--- trunk/server/common/oursrc/nss_nonlocal/nonlocal-passwd.c	(revision 2428)
+++ trunk/server/common/oursrc/nss_nonlocal/nonlocal-passwd.c	(revision 2432)
@@ -26,16 +26,17 @@
 
 #define _GNU_SOURCE
+
 #include <sys/types.h>
+#include <dlfcn.h>
+#include <errno.h>
+#include <nss.h>
+#include <pwd.h>
+#include <stdbool.h>
+#include <stddef.h>
+#include <stdlib.h>
+#include <string.h>
+#include <syslog.h>
 #include <unistd.h>
-#include <stdlib.h>
-#include <stdint.h>
-#include <string.h>
-#include <dlfcn.h>
-#include <stdio.h>
-#include <syslog.h>
-#include <errno.h>
-#include <pwd.h>
-#include <grp.h>
-#include <nss.h>
+
 #include "nsswitch-internal.h"
 #include "nonlocal.h"
@@ -162,4 +163,5 @@
 
 
+static bool pwent_initialized = false;
 static service_user *pwent_startp, *pwent_nip;
 static void *pwent_fct_start;
@@ -186,7 +188,10 @@
 	return status;
 
-    if (pwent_fct_start == NULL)
+    if (!pwent_initialized) {
 	__nss_passwd_nonlocal_lookup(&pwent_startp, pwent_fct_name,
 				     &pwent_fct_start);
+	__sync_synchronize();
+	pwent_initialized = true;
+    }
     pwent_nip = pwent_startp;
     pwent_fct.ptr = pwent_fct_start;
@@ -200,5 +205,5 @@
     const struct walk_nss w = {
 	.lookup = &__nss_passwd_nonlocal_lookup, .fct_name = "endpwent",
-	.status = &status
+	.status = &status, .all_values = 1,
     };
     const __typeof__(&_nss_nonlocal_endpwent) self = NULL;
Index: trunk/server/common/oursrc/nss_nonlocal/nonlocal-shadow.c
===================================================================
--- trunk/server/common/oursrc/nss_nonlocal/nonlocal-shadow.c	(revision 2428)
+++ trunk/server/common/oursrc/nss_nonlocal/nonlocal-shadow.c	(revision 2432)
@@ -24,15 +24,15 @@
 
 #define _GNU_SOURCE
+
 #include <sys/types.h>
-#include <unistd.h>
+#include <dlfcn.h>
+#include <errno.h>
+#include <nss.h>
+#include <shadow.h>
+#include <stdbool.h>
+#include <stddef.h>
 #include <stdlib.h>
-#include <stdint.h>
 #include <string.h>
-#include <dlfcn.h>
-#include <stdio.h>
 #include <syslog.h>
-#include <errno.h>
-#include <shadow.h>
-#include <nss.h>
 
 #include "nsswitch-internal.h"
@@ -59,4 +59,5 @@
 
 
+static bool spent_initialized = false;
 static service_user *spent_startp, *spent_nip;
 static void *spent_fct_start;
@@ -83,7 +84,10 @@
 	return status;
 
-    if (spent_fct_start == NULL)
+    if (!spent_initialized) {
 	__nss_shadow_nonlocal_lookup(&spent_startp, spent_fct_name,
 				     &spent_fct_start);
+	__sync_synchronize();
+	spent_initialized = true;
+    }
     spent_nip = spent_startp;
     spent_fct.ptr = spent_fct_start;
@@ -114,4 +118,9 @@
 {
     enum nss_status status;
+
+    char *nonlocal_ignore = getenv(NONLOCAL_IGNORE_ENV);
+    if (nonlocal_ignore != NULL && nonlocal_ignore[0] != '\0')
+	return NSS_STATUS_UNAVAIL;
+
     if (spent_nip == NULL) {
 	status = _nss_nonlocal_setspent(0);
Index: trunk/server/common/oursrc/nss_nonlocal/nonlocal.h
===================================================================
--- trunk/server/common/oursrc/nss_nonlocal/nonlocal.h	(revision 2428)
+++ trunk/server/common/oursrc/nss_nonlocal/nonlocal.h	(revision 2432)
@@ -50,4 +50,5 @@
 struct walk_nss {
     enum nss_status *status;
+    int all_values;
     int (*lookup)(service_user **ni, const char *fct_name,
 		  void **fctp) internal_function;
Index: trunk/server/common/oursrc/nss_nonlocal/walk_nss.h
===================================================================
--- trunk/server/common/oursrc/nss_nonlocal/walk_nss.h	(revision 2428)
+++ trunk/server/common/oursrc/nss_nonlocal/walk_nss.h	(revision 2432)
@@ -1,5 +1,31 @@
+/*
+ * walk_nss.h
+ * NSS walking template for nss_nonlocal proxy
+ *
+ * Copyright © 2011 Anders Kaseorg <andersk@mit.edu> and Tim Abbott
+ * <tabbott@mit.edu>
+ *
+ * This file is part of nss_nonlocal.
+ *
+ * nss_nonlocal is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public License
+ * as published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * nss_nonlocal is distributed in the hope that it will be useful, but
+ * WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with nss_nonlocal; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
+ * 02110-1301  USA
+ */
+
 {
-    static service_user *startp = NULL;
-    static void *fct_start = NULL;
+    static bool initialized = false;
+    static service_user *startp;
+    static void *fct_start;
 
     service_user *nip;
@@ -10,8 +36,11 @@
     int old_errno = errno;
 
-    if (fct_start == NULL &&
-	w.lookup(&startp, w.fct_name, &fct_start) != 0) {
-	*w.status = NSS_STATUS_UNAVAIL;
-	goto walk_nss_out;
+    if (!initialized) {
+	if (w.lookup(&startp, w.fct_name, &fct_start) != 0) {
+	    *w.status = NSS_STATUS_UNAVAIL;
+	    goto walk_nss_out;
+	}
+	__sync_synchronize();
+	initialized = true;
     }
 
@@ -51,5 +80,6 @@
 	    goto walk_nss_morebuf;
 	}
-    } while (__nss_next(&nip, w.fct_name, &fct.ptr, *w.status, 0) == 0);
+    } while (__nss_next(&nip, w.fct_name, &fct.ptr, *w.status, w.all_values) ==
+	     0);
 
     if (w.buf != NULL && *w.status != NSS_STATUS_SUCCESS) {
Index: trunk/server/fedora/specs/nss_nonlocal.spec
===================================================================
--- trunk/server/fedora/specs/nss_nonlocal.spec	(revision 2428)
+++ trunk/server/fedora/specs/nss_nonlocal.spec	(revision 2432)
@@ -2,5 +2,5 @@
 Group: System Environment/Libraries
 Name: nss_nonlocal
-Version: 2.0
+Version: 2.1
 Release: 1
 URL: http://debathena.mit.edu/nss_nonlocal/
@@ -63,4 +63,7 @@
 %changelog
 
+* Thu Jun 13 2013 Anders Kaseorg <andersk@mit.edu> 2.1-1
+- New upstream version.
+
 * Tue Mar 29 2011 Anders Kaseorg <andersk@mit.edu> 2.0-1
 - New upstream version.
