]> andersk Git - nss_nonlocal.git/commitdiff
Switch from __nss_next API to __nss_next2 API
authorAnders Kaseorg <andersk@mit.edu>
Sat, 5 May 2018 18:04:26 +0000 (14:04 -0400)
committerAnders Kaseorg <andersk@mit.edu>
Sat, 5 May 2018 19:33:55 +0000 (15:33 -0400)
__nss_passwd_lookup2, __nss_group_lookup2, and __nss_next2 were added
in glibc 2.8.

__nss_passwd_lookup, __nss_group_lookup, and __nss_next were removed
in glibc 2.27.

Signed-off-by: Anders Kaseorg <andersk@mit.edu>
nonlocal-group.c
nonlocal-passwd.c
nonlocal-shadow.c
nonlocal.h
nsswitch-internal.h
walk_nss.h

index 57f01e2c8d1dce948687cd732c378dc244202d97..ecf6fed686e132c0903131cdfc478afaf222ffd6 100644 (file)
@@ -77,8 +77,8 @@ static service_user *__nss_group_nonlocal_database;
 
 static int
 internal_function
-__nss_group_nonlocal_lookup(service_user **ni, const char *fct_name,
-                           void **fctp)
+__nss_group_nonlocal_lookup2(service_user **ni, const char *fct_name,
+                            const char *fct2_name, void **fctp)
 {
     if (__nss_group_nonlocal_database == NULL
        && __nss_database_lookup("group_nonlocal", NULL, NULL,
@@ -88,6 +88,8 @@ __nss_group_nonlocal_lookup(service_user **ni, const char *fct_name,
     *ni = __nss_group_nonlocal_database;
 
     *fctp = __nss_lookup_function(*ni, fct_name);
+    if (*fctp == NULL && fct2_name != NULL)
+       *fctp = __nss_lookup_function(*ni, fct2_name);
     return 0;
 }
 
@@ -100,7 +102,7 @@ check_nonlocal_gid(const char *user, const char *group, gid_t gid, int *errnop)
     char *buf;
     size_t buflen = sysconf(_SC_GETGR_R_SIZE_MAX);
     const struct walk_nss w = {
-       .lookup = &__nss_group_lookup, .fct_name = "getgrgid_r",
+       .lookup2 = &__nss_group_lookup2, .fct_name = "getgrgid_r",
        .status = &status, .errnop = errnop, .buf = &buf, .buflen = &buflen
     };
     const __typeof__(&_nss_nonlocal_getgrgid_r) self = &_nss_nonlocal_getgrgid_r;
@@ -161,7 +163,7 @@ get_local_group(const char *name, struct group *grp, char **buffer, int *errnop)
     enum nss_status status;
     size_t buflen = sysconf(_SC_GETGR_R_SIZE_MAX);
     const struct walk_nss w = {
-       .lookup = &__nss_group_lookup, .fct_name = "getgrnam_r",
+       .lookup2 = &__nss_group_lookup2, .fct_name = "getgrnam_r",
        .status = &status, .errnop = errnop, .buf = buffer, .buflen = &buflen
     };
     const __typeof__(&_nss_nonlocal_getgrnam_r) self = &_nss_nonlocal_getgrnam_r;
@@ -186,7 +188,7 @@ _nss_nonlocal_setgrent(int stayopen)
 {
     enum nss_status status;
     const struct walk_nss w = {
-       .lookup = &__nss_group_nonlocal_lookup, .fct_name = "setgrent",
+       .lookup2 = &__nss_group_nonlocal_lookup2, .fct_name = "setgrent",
        .status = &status
     };
     const __typeof__(&_nss_nonlocal_setgrent) self = NULL;
@@ -197,8 +199,8 @@ _nss_nonlocal_setgrent(int stayopen)
        return status;
 
     if (!grent_initialized) {
-       __nss_group_nonlocal_lookup(&grent_startp, grent_fct_name,
-                                   &grent_fct_start);
+       __nss_group_nonlocal_lookup2(&grent_startp, grent_fct_name, NULL,
+                                    &grent_fct_start);
        __sync_synchronize();
        grent_initialized = true;
     }
@@ -212,7 +214,7 @@ _nss_nonlocal_endgrent(void)
 {
     enum nss_status status;
     const struct walk_nss w = {
-       .lookup = &__nss_group_nonlocal_lookup, .fct_name = "endgrent",
+       .lookup2 = &__nss_group_nonlocal_lookup2, .fct_name = "endgrent",
        .status = &status, .all_values = 1,
     };
     const __typeof__(&_nss_nonlocal_endgrent) self = NULL;
@@ -255,7 +257,8 @@ _nss_nonlocal_getgrent_r(struct group *grp, char *buffer, size_t buflen,
 
        if (status == NSS_STATUS_SUCCESS)
            return NSS_STATUS_SUCCESS;
-    } while (__nss_next(&grent_nip, grent_fct_name, &grent_fct.ptr, status, 0) == 0);
+    } while (__nss_next2(&grent_nip, grent_fct_name, NULL, &grent_fct.ptr,
+                        status, 0) == 0);
 
     grent_nip = NULL;
     return NSS_STATUS_NOTFOUND;
@@ -268,7 +271,7 @@ _nss_nonlocal_getgrnam_r(const char *name, struct group *grp,
 {
     enum nss_status status;
     const struct walk_nss w = {
-       .lookup = &__nss_group_nonlocal_lookup, .fct_name = "getgrnam_r",
+       .lookup2 = &__nss_group_nonlocal_lookup2, .fct_name = "getgrnam_r",
        .status = &status, .errnop = errnop
     };
     const __typeof__(&_nss_nonlocal_getgrnam_r) self = NULL;
@@ -297,7 +300,7 @@ _nss_nonlocal_getgrgid_r(gid_t gid, struct group *grp,
 {
     enum nss_status status;
     const struct walk_nss w = {
-       .lookup = &__nss_group_nonlocal_lookup, .fct_name = "getgrgid_r",
+       .lookup2 = &__nss_group_nonlocal_lookup2, .fct_name = "getgrgid_r",
        .status = &status, .errnop = errnop
     };
     const __typeof__(&_nss_nonlocal_getgrgid_r) self = NULL;
@@ -360,7 +363,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",
+       .lookup2 = &__nss_group_nonlocal_lookup2, .fct_name = "initgroups_dyn",
        .status = &status, .all_values = 1, .errnop = errnop
     };
     const __typeof__(&_nss_nonlocal_initgroups_dyn) self = NULL;
index 41ea498689cbd707e03c08a88c4fb19b7986cc09..3bc9398b4abc5d2627e83be1e92038ea2ef4d86a 100644 (file)
@@ -54,8 +54,8 @@ static service_user *__nss_passwd_nonlocal_database;
 
 static int
 internal_function
-__nss_passwd_nonlocal_lookup(service_user **ni, const char *fct_name,
-                            void **fctp)
+__nss_passwd_nonlocal_lookup2(service_user **ni, const char *fct_name,
+                             const char *fct2_name, void **fctp)
 {
     if (__nss_passwd_nonlocal_database == NULL
        && __nss_database_lookup("passwd_nonlocal", NULL, NULL,
@@ -65,6 +65,8 @@ __nss_passwd_nonlocal_lookup(service_user **ni, const char *fct_name,
     *ni = __nss_passwd_nonlocal_database;
 
     *fctp = __nss_lookup_function(*ni, fct_name);
+    if (*fctp == NULL && fct2_name != NULL)
+       *fctp = __nss_lookup_function(*ni, fct2_name);
     return 0;
 }
 
@@ -77,7 +79,7 @@ check_nonlocal_uid(const char *user, uid_t uid, int *errnop)
     char *buf;
     size_t buflen = sysconf(_SC_GETPW_R_SIZE_MAX);
     const struct walk_nss w = {
-       .lookup = &__nss_passwd_lookup, .fct_name = "getpwuid_r",
+       .lookup2 = &__nss_passwd_lookup2, .fct_name = "getpwuid_r",
        .status = &status, .errnop = errnop, .buf = &buf, .buflen = &buflen
     };
     const __typeof__(&_nss_nonlocal_getpwuid_r) self = &_nss_nonlocal_getpwuid_r;
@@ -126,7 +128,7 @@ check_nonlocal_user(const char *user, int *errnop)
     char *buf;
     size_t buflen = sysconf(_SC_GETPW_R_SIZE_MAX);
     const struct walk_nss w = {
-       .lookup = __nss_passwd_lookup, .fct_name = "getpwnam_r",
+       .lookup2 = __nss_passwd_lookup2, .fct_name = "getpwnam_r",
        .status = &status, .errnop = errnop, .buf = &buf, .buflen = &buflen
     };
     const __typeof__(&_nss_nonlocal_getpwnam_r) self = &_nss_nonlocal_getpwnam_r;
@@ -151,7 +153,7 @@ get_nonlocal_passwd(const char *name, struct passwd *pwd, char **buffer,
     enum nss_status status;
     size_t buflen = sysconf(_SC_GETPW_R_SIZE_MAX);
     const struct walk_nss w = {
-       .lookup = __nss_passwd_nonlocal_lookup, .fct_name = "getpwnam_r",
+       .lookup2 = __nss_passwd_nonlocal_lookup2, .fct_name = "getpwnam_r",
        .status = &status, .errnop = errnop, .buf = buffer, .buflen = &buflen
     };
     const __typeof__(&_nss_nonlocal_getpwnam_r) self = NULL;
@@ -177,7 +179,7 @@ _nss_nonlocal_setpwent(int stayopen)
 {
     enum nss_status status;
     const struct walk_nss w = {
-       .lookup = &__nss_passwd_nonlocal_lookup, .fct_name = "setpwent",
+       .lookup2 = &__nss_passwd_nonlocal_lookup2, .fct_name = "setpwent",
        .status = &status
     };
     const __typeof__(&_nss_nonlocal_setpwent) self = NULL;
@@ -188,8 +190,8 @@ _nss_nonlocal_setpwent(int stayopen)
        return status;
 
     if (!pwent_initialized) {
-       __nss_passwd_nonlocal_lookup(&pwent_startp, pwent_fct_name,
-                                    &pwent_fct_start);
+       __nss_passwd_nonlocal_lookup2(&pwent_startp, pwent_fct_name, NULL,
+                                     &pwent_fct_start);
        __sync_synchronize();
        pwent_initialized = true;
     }
@@ -203,7 +205,7 @@ _nss_nonlocal_endpwent(void)
 {
     enum nss_status status;
     const struct walk_nss w = {
-       .lookup = &__nss_passwd_nonlocal_lookup, .fct_name = "endpwent",
+       .lookup2 = &__nss_passwd_nonlocal_lookup2, .fct_name = "endpwent",
        .status = &status, .all_values = 1,
     };
     const __typeof__(&_nss_nonlocal_endpwent) self = NULL;
@@ -246,7 +248,8 @@ _nss_nonlocal_getpwent_r(struct passwd *pwd, char *buffer, size_t buflen,
 
        if (status == NSS_STATUS_SUCCESS)
            return NSS_STATUS_SUCCESS;
-    } while (__nss_next(&pwent_nip, pwent_fct_name, &pwent_fct.ptr, status, 0) == 0);
+    } while (__nss_next2(&pwent_nip, pwent_fct_name, 0, &pwent_fct.ptr, status,
+                         0) == 0);
 
     pwent_nip = NULL;
     return NSS_STATUS_NOTFOUND;
@@ -260,7 +263,7 @@ _nss_nonlocal_getpwnam_r(const char *name, struct passwd *pwd,
     enum nss_status status;
     int group_errno;
     const struct walk_nss w = {
-       .lookup = __nss_passwd_nonlocal_lookup, .fct_name = "getpwnam_r",
+       .lookup2 = __nss_passwd_nonlocal_lookup2, .fct_name = "getpwnam_r",
        .status = &status, .errnop = errnop
     };
     const __typeof__(&_nss_nonlocal_getpwnam_r) self = NULL;
@@ -297,7 +300,7 @@ _nss_nonlocal_getpwuid_r(uid_t uid, struct passwd *pwd,
     enum nss_status status;
     int group_errno;
     const struct walk_nss w = {
-       .lookup = &__nss_passwd_nonlocal_lookup, .fct_name = "getpwuid_r",
+       .lookup2 = &__nss_passwd_nonlocal_lookup2, .fct_name = "getpwuid_r",
        .status = &status, .errnop = errnop
     };
     const __typeof__(&_nss_nonlocal_getpwuid_r) self = NULL;
index 98142e183cfbfc9cc269cde1c1922793ab931a79..9a78f08bd81c77deaff7efdc0ed24b620723036a 100644 (file)
@@ -43,8 +43,8 @@ static service_user *__nss_shadow_nonlocal_database;
 
 static int
 internal_function
-__nss_shadow_nonlocal_lookup(service_user **ni, const char *fct_name,
-                           void **fctp)
+__nss_shadow_nonlocal_lookup2(service_user **ni, const char *fct_name,
+                             const char *fct2_name, void **fctp)
 {
     if (__nss_shadow_nonlocal_database == NULL
        && __nss_database_lookup("shadow_nonlocal", NULL, NULL,
@@ -54,6 +54,8 @@ __nss_shadow_nonlocal_lookup(service_user **ni, const char *fct_name,
     *ni = __nss_shadow_nonlocal_database;
 
     *fctp = __nss_lookup_function(*ni, fct_name);
+    if (*fctp == NULL && fct2_name != NULL)
+       *fctp = __nss_lookup_function(*ni, fct2_name);
     return 0;
 }
 
@@ -73,7 +75,7 @@ _nss_nonlocal_setspent(int stayopen)
 {
     enum nss_status status;
     const struct walk_nss w = {
-       .lookup = &__nss_shadow_nonlocal_lookup, .fct_name = "setspent",
+       .lookup2 = &__nss_shadow_nonlocal_lookup2, .fct_name = "setspent",
        .status = &status
     };
     const __typeof__(&_nss_nonlocal_setspent) self = NULL;
@@ -84,8 +86,8 @@ _nss_nonlocal_setspent(int stayopen)
        return status;
 
     if (!spent_initialized) {
-       __nss_shadow_nonlocal_lookup(&spent_startp, spent_fct_name,
-                                    &spent_fct_start);
+       __nss_shadow_nonlocal_lookup2(&spent_startp, spent_fct_name, NULL,
+                                     &spent_fct_start);
        __sync_synchronize();
        spent_initialized = true;
     }
@@ -99,7 +101,7 @@ _nss_nonlocal_endspent(void)
 {
     enum nss_status status;
     const struct walk_nss w = {
-       .lookup = &__nss_shadow_nonlocal_lookup, .fct_name = "endspent",
+       .lookup2 = &__nss_shadow_nonlocal_lookup2, .fct_name = "endspent",
        .status = &status
     };
     const __typeof__(&_nss_nonlocal_endspent) self = NULL;
@@ -137,7 +139,8 @@ _nss_nonlocal_getspent_r(struct spwd *pwd, char *buffer, size_t buflen,
 
        if (status == NSS_STATUS_SUCCESS)
            return NSS_STATUS_SUCCESS;
-    } while (__nss_next(&spent_nip, spent_fct_name, &spent_fct.ptr, status, 0) == 0);
+    } while (__nss_next2(&spent_nip, spent_fct_name, NULL, &spent_fct.ptr,
+                        status, 0) == 0);
 
     spent_nip = NULL;
     return NSS_STATUS_NOTFOUND;
@@ -150,7 +153,7 @@ _nss_nonlocal_getspnam_r(const char *name, struct spwd *pwd,
 {
     enum nss_status status;
     const struct walk_nss w = {
-       .lookup = __nss_shadow_nonlocal_lookup, .fct_name = "getspnam_r",
+       .lookup2 = __nss_shadow_nonlocal_lookup2, .fct_name = "getspnam_r",
        .status = &status, .errnop = errnop
     };
     const __typeof__(&_nss_nonlocal_getspnam_r) self = NULL;
index 7b8ca2f326c58ba680d0ba6f9ab49e916f4eba0b..384e2eea6eaa47a0b0af4a0158ce7cda49c8e5e3 100644 (file)
@@ -50,8 +50,8 @@ 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;
+    int (*lookup2)(service_user **ni, const char *fct_name,
+                  const char *fct2_name, void **fctp) internal_function;
     const char *fct_name;
     int *errnop;
     char **buf;
index df460501f54696c88d3675c00e27e43c4ca73898..d61914c4c2b205e2e775dc24aac60cf830a46827 100644 (file)
 /* glibc/nss/nsswitch.h */
 typedef struct service_user service_user;
 
-extern int __nss_next (service_user **ni, const char *fct_name, void **fctp,
-                      int status, int all_values);
+extern int __nss_next2 (service_user **ni, const char *fct_name,
+                       const char *fct2_name, void **fctp, int status,
+                       int all_values);
 extern int __nss_database_lookup (const char *database,
                                  const char *alternative_name,
                                  const char *defconfig, service_user **ni);
 extern void *__nss_lookup_function (service_user *ni, const char *fct_name);
 
 /* glibc/nss/XXX-lookup.c */
-extern int __nss_passwd_lookup (service_user **ni, const char *fct_name,
-                               void **fctp) internal_function;
-extern int __nss_group_lookup (service_user **ni, const char *fct_name,
-                               void **fctp) internal_function;
+extern int __nss_passwd_lookup2 (service_user **ni, const char *fct_name,
+                                const char *fct2_name, void **fctp)
+    internal_function;
+extern int __nss_group_lookup2 (service_user **ni, const char *fct_name,
+                               const char *fct2_name, void **fctp)
+    internal_function;
 
 #endif /* NSSWITCH_INTERNAL_H */
index 24cf4c5c2580f1cbd452daadc7c1f981555cc846..0e45d5b0e7d74dc89a7db135d394ebd66d863254 100644 (file)
@@ -36,7 +36,7 @@
     int old_errno = errno;
 
     if (!initialized) {
-       if (w.lookup(&startp, w.fct_name, &fct_start) != 0) {
+       if (w.lookup2(&startp, w.fct_name, NULL, &fct_start) != 0) {
            *w.status = NSS_STATUS_UNAVAIL;
            goto walk_nss_out;
        }
@@ -79,8 +79,8 @@
            }
            goto walk_nss_morebuf;
        }
-    } while (__nss_next(&nip, w.fct_name, &fct.ptr, *w.status, w.all_values) ==
-            0);
+    } while (__nss_next2(&nip, w.fct_name, NULL, &fct.ptr, *w.status,
+                        w.all_values) == 0);
 
     if (w.buf != NULL && *w.status != NSS_STATUS_SUCCESS) {
        free(*w.buf);
This page took 0.501213 seconds and 5 git commands to generate.