diff options
author | Ulrich Drepper <drepper@gmail.com> | 2011-10-07 10:06:31 -0400 |
---|---|---|
committer | Ulrich Drepper <drepper@gmail.com> | 2011-10-07 10:06:31 -0400 |
commit | 684ae515993269277448150a1ca70db3b94aa5bd (patch) | |
tree | 493609057fdfc4aa2dd41f8d6e0c2047616b5d9c /nss | |
parent | 21fd49a9ef9c21cd2c87d0facf9f53bedb5cea20 (diff) | |
download | glibc-684ae515993269277448150a1ca70db3b94aa5bd.zip glibc-684ae515993269277448150a1ca70db3b94aa5bd.tar.gz glibc-684ae515993269277448150a1ca70db3b94aa5bd.tar.bz2 |
Implement caching of nscd
Diffstat (limited to 'nss')
-rw-r--r-- | nss/Versions | 2 | ||||
-rw-r--r-- | nss/getent.c | 18 | ||||
-rw-r--r-- | nss/nss_files/files-init.c | 3 | ||||
-rw-r--r-- | nss/nsswitch.c | 2 | ||||
-rw-r--r-- | nss/nsswitch.h | 3 |
5 files changed, 22 insertions, 6 deletions
diff --git a/nss/Versions b/nss/Versions index 666915d..d13d570 100644 --- a/nss/Versions +++ b/nss/Versions @@ -12,7 +12,7 @@ libc { __nss_disable_nscd; __nss_lookup_function; _nss_files_parse_sgent; __nss_passwd_lookup2; __nss_group_lookup2; __nss_hosts_lookup2; - __nss_services_lookup2; __nss_next2; + __nss_services_lookup2; __nss_next2; __nss_lookup; } } diff --git a/nss/getent.c b/nss/getent.c index 9d43e2f..b843433 100644 --- a/nss/getent.c +++ b/nss/getent.c @@ -480,18 +480,28 @@ netgroup_keys (int number, char *key[]) return 3; } - for (i = 0; i < number; ++i) + if (number == 4) + { + char *host = strcmp (key[1], "*") == 0 ? NULL : key[1]; + char *user = strcmp (key[2], "*") == 0 ? NULL : key[2]; + char *domain = strcmp (key[3], "*") == 0 ? NULL : key[3]; + + printf ("%-21s (%s,%s,%s) = %d\n", + key[0], host ?: "", user ?: "", domain ?: "", + innetgr (key[0], host, user, domain)); + } + else if (number == 1) { - if (!setnetgrent (key[i])) + if (!setnetgrent (key[0])) result = 2; else { char *p[3]; - printf ("%-21s", key[i]); + printf ("%-21s", key[0]); while (getnetgrent (p, p + 1, p + 2)) - printf (" (%s, %s, %s)", p[0] ?: " ", p[1] ?: "", p[2] ?: ""); + printf (" (%s,%s,%s)", p[0] ?: " ", p[1] ?: "", p[2] ?: ""); putchar_unlocked ('\n'); } } diff --git a/nss/nss_files/files-init.c b/nss/nss_files/files-init.c index b33cc3e..7012ab2 100644 --- a/nss/nss_files/files-init.c +++ b/nss/nss_files/files-init.c @@ -38,6 +38,7 @@ TF (grp, "/etc/group"); TF (hst, "/etc/hosts"); TF (resolv, "/etc/resolv.conf", .call_res_init = 1); TF (serv, "/etc/services"); +TF (netgr, "/etc/netgroup"); void @@ -52,4 +53,6 @@ _nss_files_init (void (*cb) (size_t, struct traced_file *)) cb (hstdb, &resolv_traced_file.file); cb (servdb, &serv_traced_file.file); + + cb (netgrdb, &netgr_traced_file.file); } diff --git a/nss/nsswitch.c b/nss/nsswitch.c index 924cc84..09fa0a6 100644 --- a/nss/nsswitch.c +++ b/nss/nsswitch.c @@ -176,6 +176,7 @@ __nss_lookup (service_user **ni, const char *fct_name, const char *fct2_name, return *fctp != NULL ? 0 : (*ni)->next == NULL ? 1 : -1; } +libc_hidden_def (__nss_lookup) /* -1 == not found @@ -812,6 +813,7 @@ __nss_disable_nscd (void (*cb) (size_t, struct traced_file *)) __nss_not_use_nscd_group = -1; __nss_not_use_nscd_hosts = -1; __nss_not_use_nscd_services = -1; + __nss_not_use_nscd_netgroup = -1; } #endif diff --git a/nss/nsswitch.h b/nss/nsswitch.h index 3e37bc8..1bf663c 100644 --- a/nss/nsswitch.h +++ b/nss/nsswitch.h @@ -125,7 +125,8 @@ libc_hidden_proto (__nss_database_lookup) position is remembered in NI. The function returns a value < 0 if an error occurred or no such function exists. */ extern int __nss_lookup (service_user **ni, const char *fct_name, - const char *fct2_name, void **fctp) attribute_hidden; + const char *fct2_name, void **fctp); +libc_hidden_proto (__nss_lookup) /* Determine the next step in the lookup process according to the result STATUS of the call to the last function returned by |