]> andersk Git - nss_nonlocal.git/commitdiff
Merge tag '2.1' into debian
authorAnders Kaseorg <andersk@mit.edu>
Thu, 13 Jun 2013 03:24:34 +0000 (23:24 -0400)
committerAnders Kaseorg <andersk@mit.edu>
Thu, 13 Jun 2013 03:24:34 +0000 (23:24 -0400)
nss_nonlocal 2.1

Makefile.am
configure.ac
nonlocal-group.c
nonlocal-passwd.c
nonlocal-shadow.c
nonlocal.h
walk_nss.h

index a22eb6eda32166379a5a492de8f0648f291af9f5..6d7ba8cf598e7edc51dc4516c4a73c4eeaff21be 100644 (file)
@@ -1,7 +1,7 @@
 lib_LTLIBRARIES = libnss_nonlocal.la
 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 \
     -export-symbols-regex '^_nss_nonlocal_' \
@@ -10,3 +10,6 @@ libnss_nonlocal_la_LDFLAGS = \
 install-exec-hook:
        rm -f $(DESTDIR)$(libdir)/libnss_nonlocal.so
        rm -f $(DESTDIR)$(libdir)/libnss_nonlocal.la
+
+uninstall-local:
+       rm -f $(DESTDIR)$(libdir)/libnss_nonlocal.so.*
index 115ea61d2ebe44293bc941a46854b11d7f3a2f85..6718d779e35aa3eaf089ac9e1ba4d1eebb3b9f7b 100644 (file)
@@ -1,4 +1,4 @@
-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])
 m4_ifdef([AM_SILENT_RULES],[AM_SILENT_RULES([yes])])
@@ -6,7 +6,7 @@ m4_ifdef([AM_SILENT_RULES],[AM_SILENT_RULES([yes])])
 AC_PREFIX_DEFAULT([/])
 AC_DISABLE_STATIC
 AC_PROG_CC
-AC_PROG_INSTALL
+m4_ifdef([AM_PROG_AR], [AM_PROG_AR])
 AC_PROG_LIBTOOL
 
 AC_HEADER_STDBOOL
index 5b4dd7d40c89311463a8f0fad185cd5d0adecc15..57f01e2c8d1dce948687cd732c378dc244202d97 100644 (file)
  */
 
 #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"
 
@@ -169,6 +171,7 @@ get_local_group(const char *name, struct group *grp, char **buffer, int *errnop)
     return status;
 }
 
+static bool grent_initialized = false;
 static service_user *grent_startp, *grent_nip;
 static void *grent_fct_start;
 static union {
@@ -193,9 +196,12 @@ _nss_nonlocal_setgrent(int stayopen)
     if (status != NSS_STATUS_SUCCESS)
        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;
     return NSS_STATUS_SUCCESS;
@@ -207,7 +213,7 @@ _nss_nonlocal_endgrent(void)
     enum nss_status status;
     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;
 
@@ -355,7 +361,7 @@ _nss_nonlocal_initgroups_dyn(const char *user, gid_t group, long int *start,
     enum nss_status status;
     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;
 
@@ -444,7 +450,9 @@ _nss_nonlocal_initgroups_dyn(const char *user, gid_t group, long int *start,
 #define args (user, group, start, size, groupsp, limit, errnop)
 #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;
 
     for (; in < *start; ++in) {
index 7529d9b886a1c45b08579add50aeb465c6259de4..41ea498689cbd707e03c08a88c4fb19b7986cc09 100644 (file)
 
 
 #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"
 
@@ -161,6 +162,7 @@ get_nonlocal_passwd(const char *name, struct passwd *pwd, char **buffer,
 }
 
 
+static bool pwent_initialized = false;
 static service_user *pwent_startp, *pwent_nip;
 static void *pwent_fct_start;
 static union {
@@ -185,9 +187,12 @@ _nss_nonlocal_setpwent(int stayopen)
     if (status != NSS_STATUS_SUCCESS)
        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;
     return NSS_STATUS_SUCCESS;
@@ -199,7 +204,7 @@ _nss_nonlocal_endpwent(void)
     enum nss_status status;
     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 ab8f44258f6576711325bd3b39429981b7dea472..98142e183cfbfc9cc269cde1c1922793ab931a79 100644 (file)
  */
 
 #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 <shadow.h>
 #include <nss.h>
+#include <shadow.h>
+#include <stdbool.h>
+#include <stddef.h>
+#include <stdlib.h>
+#include <string.h>
+#include <syslog.h>
 
 #include "nsswitch-internal.h"
 #include "nonlocal.h"
@@ -58,6 +58,7 @@ __nss_shadow_nonlocal_lookup(service_user **ni, const char *fct_name,
 }
 
 
+static bool spent_initialized = false;
 static service_user *spent_startp, *spent_nip;
 static void *spent_fct_start;
 static union {
@@ -82,9 +83,12 @@ _nss_nonlocal_setspent(int stayopen)
     if (status != NSS_STATUS_SUCCESS)
        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;
     return NSS_STATUS_SUCCESS;
@@ -113,6 +117,11 @@ _nss_nonlocal_getspent_r(struct spwd *pwd, char *buffer, size_t buflen,
                         int *errnop)
 {
     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);
        if (status != NSS_STATUS_SUCCESS)
index 9574ff8f99d6bce8f57ed5930a6bf1d9788b5bd1..7b8ca2f326c58ba680d0ba6f9ab49e916f4eba0b 100644 (file)
@@ -49,6 +49,7 @@ typedef bool _Bool;
 
 struct walk_nss {
     enum nss_status *status;
+    int all_values;
     int (*lookup)(service_user **ni, const char *fct_name,
                  void **fctp) internal_function;
     const char *fct_name;
index 93af177121ff0ae4d2791de003153729cd2c5b2f..24cf4c5c2580f1cbd452daadc7c1f981555cc846 100644 (file)
@@ -24,8 +24,9 @@
  */
 
 {
-    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;
     union {
     } fct;
     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;
     }
 
     nip = startp;
@@ -75,7 +79,8 @@
            }
            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) {
        free(*w.buf);
This page took 0.213237 seconds and 5 git commands to generate.