116 lines
3.3 KiB
Diff
116 lines
3.3 KiB
Diff
|
From a6856a042a0669ac3f8bc675e8e1de14b5d09b94 Mon Sep 17 00:00:00 2001
|
||
|
From: Andreas Schwab <schwab@suse.de>
|
||
|
Date: Thu, 24 Jan 2013 12:32:09 +0100
|
||
|
Subject: [PATCH] Properly cache the result from looking up the nss database
|
||
|
config
|
||
|
|
||
|
[BZ #15048]
|
||
|
* nscd/aicache.c (addhstaiX): Properly use the cache variable for
|
||
|
the nss database lookup.
|
||
|
* nscd/initgrcache.c (addinitgroupsX): Likewise.
|
||
|
* sysdeps/posix/getaddrinfo.c (gaih_inet): Likewise.
|
||
|
---
|
||
|
nscd/aicache.c | 15 +++++++--------
|
||
|
nscd/initgrcache.c | 15 +++++++--------
|
||
|
sysdeps/posix/getaddrinfo.c | 14 ++++++--------
|
||
|
3 files changed, 20 insertions(+), 24 deletions(-)
|
||
|
|
||
|
diff --git a/nscd/aicache.c b/nscd/aicache.c
|
||
|
index 23dcf80..17e06e7 100644
|
||
|
--- a/nscd/aicache.c
|
||
|
+++ b/nscd/aicache.c
|
||
|
@@ -85,20 +85,19 @@ addhstaiX (struct database_dyn *db, int fd, request_header *req,
|
||
|
}
|
||
|
|
||
|
static service_user *hosts_database;
|
||
|
- service_user *nip = NULL;
|
||
|
+ service_user *nip;
|
||
|
int no_more;
|
||
|
int rc6 = 0;
|
||
|
int rc4 = 0;
|
||
|
int herrno = 0;
|
||
|
|
||
|
- if (hosts_database != NULL)
|
||
|
- {
|
||
|
- nip = hosts_database;
|
||
|
- no_more = 0;
|
||
|
- }
|
||
|
- else
|
||
|
+ if (hosts_database == NULL)
|
||
|
no_more = __nss_database_lookup ("hosts", NULL,
|
||
|
- "dns [!UNAVAIL=return] files", &nip);
|
||
|
+ "dns [!UNAVAIL=return] files",
|
||
|
+ &hosts_database);
|
||
|
+ else
|
||
|
+ no_more = 0;
|
||
|
+ nip = hosts_database;
|
||
|
|
||
|
if (__res_maybe_init (&_res, 0) == -1)
|
||
|
no_more = 1;
|
||
|
diff --git a/nscd/initgrcache.c b/nscd/initgrcache.c
|
||
|
index 462780e..4580884 100644
|
||
|
--- a/nscd/initgrcache.c
|
||
|
+++ b/nscd/initgrcache.c
|
||
|
@@ -80,17 +80,16 @@ addinitgroupsX (struct database_dyn *db, int fd, request_header *req,
|
||
|
}
|
||
|
|
||
|
static service_user *group_database;
|
||
|
- service_user *nip = NULL;
|
||
|
+ service_user *nip;
|
||
|
int no_more;
|
||
|
|
||
|
- if (group_database != NULL)
|
||
|
- {
|
||
|
- nip = group_database;
|
||
|
- no_more = 0;
|
||
|
- }
|
||
|
- else
|
||
|
+ if (group_database == NULL)
|
||
|
no_more = __nss_database_lookup ("group", NULL,
|
||
|
- "compat [NOTFOUND=return] files", &nip);
|
||
|
+ "compat [NOTFOUND=return] files",
|
||
|
+ &group_database);
|
||
|
+ else
|
||
|
+ no_more = 0;
|
||
|
+ nip = group_database;
|
||
|
|
||
|
/* We always use sysconf even if NGROUPS_MAX is defined. That way, the
|
||
|
limit can be raised in the kernel configuration without having to
|
||
|
diff --git a/sysdeps/posix/getaddrinfo.c b/sysdeps/posix/getaddrinfo.c
|
||
|
index d368306..4800599 100644
|
||
|
--- a/sysdeps/posix/getaddrinfo.c
|
||
|
+++ b/sysdeps/posix/getaddrinfo.c
|
||
|
@@ -557,7 +557,7 @@ gaih_inet (const char *name, const struct gaih_service *service,
|
||
|
struct gaih_addrtuple **pat = &at;
|
||
|
int no_data = 0;
|
||
|
int no_inet6_data = 0;
|
||
|
- service_user *nip = NULL;
|
||
|
+ service_user *nip;
|
||
|
enum nss_status inet6_status = NSS_STATUS_UNAVAIL;
|
||
|
enum nss_status status = NSS_STATUS_UNAVAIL;
|
||
|
int no_more;
|
||
|
@@ -790,15 +790,13 @@ gaih_inet (const char *name, const struct gaih_service *service,
|
||
|
}
|
||
|
#endif
|
||
|
|
||
|
- if (__nss_hosts_database != NULL)
|
||
|
- {
|
||
|
- no_more = 0;
|
||
|
- nip = __nss_hosts_database;
|
||
|
- }
|
||
|
- else
|
||
|
+ if (__nss_hosts_database == NULL)
|
||
|
no_more = __nss_database_lookup ("hosts", NULL,
|
||
|
"dns [!UNAVAIL=return] files",
|
||
|
- &nip);
|
||
|
+ &__nss_hosts_database);
|
||
|
+ else
|
||
|
+ no_more = 0;
|
||
|
+ nip = __nss_hosts_database;
|
||
|
|
||
|
/* Initialize configurations. */
|
||
|
if (__builtin_expect (!_res_hconf.initialized, 0))
|
||
|
--
|
||
|
1.8.2.3
|
||
|
|