]> git.ipfire.org Git - thirdparty/glibc.git/commitdiff
nss: Turn __nss_database_lookup into a compatibility symbol
authorFlorian Weimer <fweimer@redhat.com>
Wed, 15 May 2019 11:51:35 +0000 (13:51 +0200)
committerFlorian Weimer <fweimer@redhat.com>
Wed, 15 May 2019 13:07:49 +0000 (15:07 +0200)
The function uses the internal service_user type, so it is not
really usable from the outside of glibc.  Rename the function
to __nss_database_lookup2 for internal use, and change
__nss_database_lookup to always indicate failure to the caller.

__nss_next already was a compatibility symbol.  The new
implementation always fails and no longer calls __nss_next2.

unscd, the alternative nscd implementation, does not use
__nss_database_lookup, so it is not affected by this change.

15 files changed:
ChangeLog
grp/initgroups.c
nscd/aicache.c
nscd/initgrcache.c
nscd/netgroupcache.c
nss/Versions
nss/XXX-lookup.c
nss/compat-lookup.c
nss/nss_compat/compat-grp.c
nss/nss_compat/compat-initgroups.c
nss/nss_compat/compat-pwd.c
nss/nss_compat/compat-spwd.c
nss/nsswitch.c
nss/nsswitch.h
sysdeps/posix/getaddrinfo.c

index dc4a814c3ff28df9341ff45ee1cecb05a273c7dc..c01a2fdc514abac5e066125cb94e7836e51035d3 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,30 @@
+2019-05-15  Florian Weimer  <fweimer@redhat.com>
+
+       nss: Turn __nss_database_lookup into a compatibility symbol.
+       * nss/nsswitch.h (__nss_database_lookup2): Renamed from
+       __nss_database_lookup.
+       * nss/nsswitch.c (__nss_database_lookup2): Likewise.
+       (nss_load_all_libraries): Call __nss_database_lookup2 instead of
+       __nss_database_lookup.
+       (__nss_next): Move to …
+       * nss/compat-lookup.c (nss_next): … here.  Change it to fail
+       unconditionally.
+       (__nss_database_lookup): New function.
+       * nss/Versions (GLIBC_2.0): Update comment.
+       (GLIBC_PRIVATE): Export __nss_database_lookup2.
+       * grp/initgroups.c (internal_getgrouplist): Call
+       __nss_database_lookup2 instead of __nss_database_lookup.
+       * nscd/aicache.c (addhstaiX): Likewise.
+       * nscd/initgrcache.c (addinitgroupsX): Likewise.
+       * nscd/netgroupcache.c (addgetnetgrentX): Likewise.
+       * nss/XXX-lookup.c (DB_LOOKUP_FCT): Likewise.
+       * nss/nss_compat/compat-grp.c (init_nss_interface): Likewise.
+       * nss/nss_compat/compat-initgroups.c (init_nss_interface):
+       Likewise.
+       * nss/nss_compat/compat-pwd.c (init_nss_interface): Likewise.
+       * nss/nss_compat/compat-spwd.c (init_nss_interface): Likewise.
+       * sysdeps/posix/getaddrinfo.c (gaih_inet): Likewise.
+
 2019-05-15  Alexandra Hajkova  <ahajkova@redhat.com>
        * support/support.h (support_install_rootsbindir): New variable.
        * support/support_paths.c: Likewise.
index b4c8633ea3aecf468f116cf90cbe62ccdc6e0870..a22f33c934d395e045888b4b76d35149d845da00 100644 (file)
@@ -79,12 +79,12 @@ internal_getgrouplist (const char *user, gid_t group, long int *size,
 
   if (__nss_initgroups_database == NULL)
     {
-      if (__nss_database_lookup ("initgroups", NULL, "",
-                                &__nss_initgroups_database) < 0)
+      if (__nss_database_lookup2 ("initgroups", NULL, "",
+                                 &__nss_initgroups_database) < 0)
        {
          if (__nss_group_database == NULL)
-           no_more = __nss_database_lookup ("group", NULL, DEFAULT_CONFIG,
-                                            &__nss_group_database);
+           no_more = __nss_database_lookup2 ("group", NULL, DEFAULT_CONFIG,
+                                             &__nss_group_database);
 
          __nss_initgroups_database = __nss_group_database;
        }
index 5b94e2aa9e8c611eab3b074ca1d0df023d6db78a..5d8222e3b76dcf8657686f419890443f6670d248 100644 (file)
@@ -92,9 +92,9 @@ addhstaiX (struct database_dyn *db, int fd, request_header *req,
   int herrno = 0;
 
   if (hosts_database == NULL)
-    no_more = __nss_database_lookup ("hosts", NULL,
-                                    "dns [!UNAVAIL=return] files",
-                                    &hosts_database);
+    no_more = __nss_database_lookup2 ("hosts", NULL,
+                                     "dns [!UNAVAIL=return] files",
+                                     &hosts_database);
   else
     no_more = 0;
   nip = hosts_database;
index 186a8b58b55bdca90e6f44991bfa87a8713a79db..cf38c59b8eb119a3e5a7f80361338b61a7d36bdb 100644 (file)
@@ -88,8 +88,8 @@ addinitgroupsX (struct database_dyn *db, int fd, request_header *req,
   int no_more;
 
   if (group_database == NULL)
-    no_more = __nss_database_lookup ("group", NULL, DEFAULT_CONFIG,
-                                    &group_database);
+    no_more = __nss_database_lookup2 ("group", NULL, DEFAULT_CONFIG,
+                                     &group_database);
   else
     no_more = 0;
   nip = group_database;
index 9a9783318b852703e98ecd510bfc8190627595e9..cda276eadefbf69cd6a6d8dadc3e86671322b41a 100644 (file)
@@ -143,7 +143,7 @@ addgetnetgrentX (struct database_dyn *db, int fd, request_header *req,
   *tofreep = NULL;
 
   if (netgroup_database == NULL
-      && __nss_database_lookup ("netgroup", NULL, NULL, &netgroup_database))
+      && __nss_database_lookup2 ("netgroup", NULL, NULL, &netgroup_database))
     {
       /* No such service.  */
       cacheable = do_notfound (db, fd, req, key, &dataset, &total, &timeout,
index db8c8877202fbcd1956595622a730ec2196a2215..afc82a23c2175be86a05bd071f07088051ef86ce 100644 (file)
@@ -1,8 +1,10 @@
 libc {
   GLIBC_2.0 {
-     # functions used in other libraries
+    __nss_configure_lookup;
+
+    # Functions exported as no-op compat symbols.
     __nss_passwd_lookup; __nss_group_lookup; __nss_hosts_lookup; __nss_next;
-    __nss_database_lookup; __nss_configure_lookup;
+    __nss_database_lookup;
   }
   GLIBC_2.2.2 {
     __nss_hostname_digits_dots;
@@ -15,7 +17,7 @@ libc {
 
     __nss_passwd_lookup2; __nss_group_lookup2; __nss_hosts_lookup2;
     __nss_services_lookup2; __nss_next2; __nss_lookup;
-    __nss_hash;
+    __nss_hash; __nss_database_lookup2;
   }
 }
 
index cb0900d68fac901ed3d9f8b86b25c9a8cd1e6c75..bc5f91adeca5eddb7559f44481cf60e2ce5abe9c 100644 (file)
@@ -57,8 +57,8 @@ DB_LOOKUP_FCT (service_user **ni, const char *fct_name, const char *fct2_name,
               void **fctp)
 {
   if (DATABASE_NAME_SYMBOL == NULL
-      && __nss_database_lookup (DATABASE_NAME_STRING, ALTERNATE_NAME_STRING,
-                               DEFAULT_CONFIG, &DATABASE_NAME_SYMBOL) < 0)
+      && __nss_database_lookup2 (DATABASE_NAME_STRING, ALTERNATE_NAME_STRING,
+                                DEFAULT_CONFIG, &DATABASE_NAME_SYMBOL) < 0)
     return -1;
 
   *ni = DATABASE_NAME_SYMBOL;
index 636b1bf18415fbfbcd92918bdffe7949a322d983..79f7d96314b082622957b897a4a9b402a0a25c86 100644 (file)
    License along with the GNU C Library; if not, see
    <http://www.gnu.org/licenses/>.  */
 
+#include <nsswitch.h>
+
 #include <shlib-compat.h>
 #if SHLIB_COMPAT (libc, GLIBC_2_0, GLIBC_2_27)
 
 # include <errno.h>
-# include <nsswitch.h>
 
 /* On i386, the function calling convention changed from the standard
    ABI calling convention to three register parameters in glibc 2.8.
@@ -40,3 +41,30 @@ strong_alias (__nss_passwd_lookup, __nss_hosts_lookup)
 compat_symbol (libc, __nss_hosts_lookup, __nss_hosts_lookup, GLIBC_2_0);
 
 #endif /* SHLIB_COMPAT */
+
+#if SHLIB_COMPAT (libc, GLIBC_2_0, GLIBC_2_30)
+
+/* These functions were exported under a non-GLIBC_PRIVATE version,
+   even though it is not usable externally due to the service_user
+   type dependency.  */
+
+int
+attribute_compat_text_section
+__nss_next (service_user **ni, const char *fct_name, void **fctp, int status,
+            int all_values)
+{
+  return -1;
+}
+compat_symbol (libc, __nss_next, __nss_next, GLIBC_2_0);
+
+int
+attribute_compat_text_section
+__nss_database_lookup (const char *database, const char *alternate_name,
+                       const char *defconfig, service_user **ni)
+{
+  *ni = NULL;
+  return -1;
+}
+compat_symbol (libc, __nss_database_lookup, __nss_database_lookup, GLIBC_2_0);
+
+#endif /* SHLIB_COMPAT */
index 24e499cc999ce70b33a30253561384523534a6bc..8f01e44a7252697b50b42297c9677bc8aa6e2704 100644 (file)
@@ -78,7 +78,7 @@ static bool in_blacklist (const char *, int, ent_t *);
 static void
 init_nss_interface (void)
 {
-  if (__nss_database_lookup ("group_compat", NULL, "nis", &ni) >= 0)
+  if (__nss_database_lookup2 ("group_compat", NULL, "nis", &ni) >= 0)
     {
       nss_setgrent = __nss_lookup_function (ni, "setgrent");
       nss_getgrnam_r = __nss_lookup_function (ni, "getgrnam_r");
index 318144b66b174966ec3aaae493d0eb589693df91..b1df6a4e4396139c2434d1b820ee3b25c92eb03f 100644 (file)
@@ -89,7 +89,7 @@ init_nss_interface (void)
 
   /* Retest.  */
   if (ni == NULL
-      && __nss_database_lookup ("group_compat", NULL, "nis", &ni) >= 0)
+      && __nss_database_lookup2 ("group_compat", NULL, "nis", &ni) >= 0)
     {
       nss_initgroups_dyn = __nss_lookup_function (ni, "initgroups_dyn");
       nss_getgrnam_r = __nss_lookup_function (ni, "getgrnam_r");
index bf9786179bffcf0e89773b0f261cfd3517d531f2..37f883f35ad01317223d7e10d78c21491159d93a 100644 (file)
@@ -88,7 +88,7 @@ static bool in_blacklist (const char *, int, ent_t *);
 static void
 init_nss_interface (void)
 {
-  if (__nss_database_lookup ("passwd_compat", NULL, "nis", &ni) >= 0)
+  if (__nss_database_lookup2 ("passwd_compat", NULL, "nis", &ni) >= 0)
     {
       nss_setpwent = __nss_lookup_function (ni, "setpwent");
       nss_getpwnam_r = __nss_lookup_function (ni, "getpwnam_r");
index c5e04cb96785fff632dec2ef7722f5c0cd4bac17..bd310ab9aa1269f46922a1da018ffd99fa75d074 100644 (file)
@@ -85,8 +85,8 @@ static bool in_blacklist (const char *, int, ent_t *);
 static void
 init_nss_interface (void)
 {
-  if (__nss_database_lookup ("shadow_compat", "passwd_compat",
-                            "nis", &ni) >= 0)
+  if (__nss_database_lookup2 ("shadow_compat", "passwd_compat",
+                             "nis", &ni) >= 0)
     {
       nss_setspent = __nss_lookup_function (ni, "setspent");
       nss_getspnam_r = __nss_lookup_function (ni, "getspnam_r");
index 3d828f9a21a5dbb4e0c9b3773f12ca53b6187b4b..c4a9ffb5750436ad55262aad9fbd7fd1401a8bc4 100644 (file)
@@ -115,8 +115,8 @@ static void (*nscd_init_cb) (size_t, struct traced_file *);
 /* -1 == database not found
     0 == database entry pointer stored */
 int
-__nss_database_lookup (const char *database, const char *alternate_name,
-                      const char *defconfig, service_user **ni)
+__nss_database_lookup2 (const char *database, const char *alternate_name,
+                       const char *defconfig, service_user **ni)
 {
   /* Prevent multiple threads to change the service table.  */
   __libc_lock_lock (lock);
@@ -185,7 +185,7 @@ __nss_database_lookup (const char *database, const char *alternate_name,
 
   return *ni != NULL ? 0 : -1;
 }
-libc_hidden_def (__nss_database_lookup)
+libc_hidden_def (__nss_database_lookup2)
 
 
 /* -1 == not found
@@ -260,16 +260,6 @@ __nss_next2 (service_user **ni, const char *fct_name, const char *fct2_name,
 }
 libc_hidden_def (__nss_next2)
 
-
-int
-attribute_compat_text_section
-__nss_next (service_user **ni, const char *fct_name, void **fctp, int status,
-           int all_values)
-{
-  return __nss_next2 (ni, fct_name, NULL, fctp, status, all_values);
-}
-
-
 int
 __nss_configure_lookup (const char *dbname, const char *service_line)
 {
@@ -835,7 +825,7 @@ nss_load_all_libraries (const char *service, const char *def)
 {
   service_user *ni = NULL;
 
-  if (__nss_database_lookup (service, NULL, def, &ni) == 0)
+  if (__nss_database_lookup2 (service, NULL, def, &ni) == 0)
     while (ni != NULL)
       {
        nss_load_library (ni);
index 475e007e33790ea3318fc4bb465cba8c03c349b2..79a874e9d66f383b512974287db2b784c6fdc165 100644 (file)
@@ -125,10 +125,10 @@ extern bool __nss_database_custom[NSS_DBSIDX_max] attribute_hidden;
    If there is no configuration for this database in the file,
    parse a service list from DEFCONFIG and use that.  More
    than one function can use the database.  */
-extern int __nss_database_lookup (const char *database,
-                                 const char *alternative_name,
-                                 const char *defconfig, service_user **ni);
-libc_hidden_proto (__nss_database_lookup)
+extern int __nss_database_lookup2 (const char *database,
+                                  const char *alternative_name,
+                                  const char *defconfig, service_user **ni);
+libc_hidden_proto (__nss_database_lookup2)
 
 /* Put first function with name FCT_NAME for SERVICE in FCTP.  The
    position is remembered in NI.  The function returns a value < 0 if
index f212d1c601dde29ef1ee529276de8edb2a8cf2a1..2e50dbc98fc24fd3f610fcab3d732acd52cd3b00 100644 (file)
@@ -732,9 +732,9 @@ gaih_inet (const char *name, const struct gaih_service *service,
 #endif
 
          if (__nss_hosts_database == NULL)
-           no_more = __nss_database_lookup ("hosts", NULL,
-                                            "dns [!UNAVAIL=return] files",
-                                            &__nss_hosts_database);
+           no_more = __nss_database_lookup2 ("hosts", NULL,
+                                             "dns [!UNAVAIL=return] files",
+                                             &__nss_hosts_database);
          else
            no_more = 0;
          nip = __nss_hosts_database;