diff options
author | Ulrich Drepper <drepper@redhat.com> | 2006-04-26 17:32:10 +0000 |
---|---|---|
committer | Ulrich Drepper <drepper@redhat.com> | 2006-04-26 17:32:10 +0000 |
commit | 797ed6f7e17732cb207293d406d6cf14336f5de0 (patch) | |
tree | c264c8be61ed68f7da042492c4a5a5a823f3c4ce /nscd | |
parent | 1f063dcadb802c57759e2ca2bf9c08e108bb3d70 (diff) | |
download | glibc-797ed6f7e17732cb207293d406d6cf14336f5de0.tar.gz glibc-797ed6f7e17732cb207293d406d6cf14336f5de0.tar.xz glibc-797ed6f7e17732cb207293d406d6cf14336f5de0.zip |
* nscd/nscd.h (struct database_dyn): Add propagate field.
* nscd/nscd_conf.c (nscd_parse_file): Parse auto-propagate lines. * nscd/nscd.conf: Add auto-propagate lines. * nscd/connections.c (dbs): Initialize .propagate fields. * nscd/grpcache.c (cache_addgr): Do not add ID entry for name lookups and vice versa if propagation is disabled for the database. * nscd/pwdcache.c (cache_addpw): Likewise.
Diffstat (limited to 'nscd')
-rw-r--r-- | nscd/connections.c | 3 | ||||
-rw-r--r-- | nscd/grpcache.c | 18 | ||||
-rw-r--r-- | nscd/nscd.conf | 5 | ||||
-rw-r--r-- | nscd/nscd.h | 3 | ||||
-rw-r--r-- | nscd/nscd_conf.c | 13 | ||||
-rw-r--r-- | nscd/pwdcache.c | 17 |
6 files changed, 42 insertions, 17 deletions
diff --git a/nscd/connections.c b/nscd/connections.c index b24e7fb527..814d1c7883 100644 --- a/nscd/connections.c +++ b/nscd/connections.c @@ -103,6 +103,7 @@ struct database_dyn dbs[lastdb] = .enabled = 0, .check_file = 1, .persistent = 0, + .propagate = 1, .shared = 0, .max_db_size = DEFAULT_MAX_DB_SIZE, .filename = "/etc/passwd", @@ -119,6 +120,7 @@ struct database_dyn dbs[lastdb] = .enabled = 0, .check_file = 1, .persistent = 0, + .propagate = 1, .shared = 0, .max_db_size = DEFAULT_MAX_DB_SIZE, .filename = "/etc/group", @@ -135,6 +137,7 @@ struct database_dyn dbs[lastdb] = .enabled = 0, .check_file = 1, .persistent = 0, + .propagate = 0, /* Not used. */ .shared = 0, .max_db_size = DEFAULT_MAX_DB_SIZE, .filename = "/etc/hosts", diff --git a/nscd/grpcache.c b/nscd/grpcache.c index 4bc9977bc4..5a8fba4759 100644 --- a/nscd/grpcache.c +++ b/nscd/grpcache.c @@ -342,10 +342,10 @@ cache_addgr (struct database_dyn *db, int fd, request_header *req, marked with FIRST first. Otherwise we end up with dangling "pointers" in case a latter hash entry cannot be added. */ - bool first = req->type == GETGRBYNAME; + bool first = true; /* If the request was by GID, add that entry first. */ - if (req->type != GETGRBYNAME) + if (req->type == GETGRBYGID) { if (cache_add (GETGRBYGID, cp, key_offset, &dataset->head, true, db, owner) < 0) @@ -355,12 +355,14 @@ cache_addgr (struct database_dyn *db, int fd, request_header *req, dataset->head.usable = false; goto out; } + + first = false; } /* If the key is different from the name add a separate entry. */ else if (strcmp (key_copy, gr_name) != 0) { if (cache_add (GETGRBYNAME, key_copy, key_len + 1, - &dataset->head, first, db, owner) < 0) + &dataset->head, true, db, owner) < 0) { /* Could not allocate memory. Make sure the data gets discarded. */ @@ -372,11 +374,13 @@ cache_addgr (struct database_dyn *db, int fd, request_header *req, } /* We have to add the value for both, byname and byuid. */ - if (__builtin_expect (cache_add (GETGRBYNAME, gr_name, gr_name_len, - &dataset->head, first, db, owner) - == 0, 1)) + if ((req->type == GETGRBYNAME || db->propagate) + && __builtin_expect (cache_add (GETGRBYNAME, gr_name, + gr_name_len, + &dataset->head, first, db, owner) + == 0, 1)) { - if (req->type == GETGRBYNAME) + if (req->type == GETGRBYNAME && db->propagate) (void) cache_add (GETGRBYGID, cp, key_offset, &dataset->head, req->type != GETGRBYNAME, db, owner); } diff --git a/nscd/nscd.conf b/nscd/nscd.conf index 9491e16472..289eb2eb6e 100644 --- a/nscd/nscd.conf +++ b/nscd/nscd.conf @@ -23,7 +23,8 @@ # check-files <service> <yes|no> # persistent <service> <yes|no> # shared <service> <yes|no> -# max-db-szie <service> <number bytes> +# max-db-size <service> <number bytes> +* auto-propagate <service> <yes|no> # # Currently supported cache names (services): passwd, group, hosts # @@ -47,6 +48,7 @@ persistent passwd yes shared passwd yes max-db-size passwd 33554432 + auto-propagate passwd yes enable-cache group yes positive-time-to-live group 3600 @@ -56,6 +58,7 @@ persistent group yes shared group yes max-db-size group 33554432 + auto-propagate group yes enable-cache hosts yes positive-time-to-live hosts 3600 diff --git a/nscd/nscd.h b/nscd/nscd.h index ed686bea7e..f826c7ada4 100644 --- a/nscd/nscd.h +++ b/nscd/nscd.h @@ -1,4 +1,4 @@ -/* Copyright (c) 1998, 1999, 2000, 2001, 2003, 2004, 2005 +/* Copyright (c) 1998, 1999, 2000, 2001, 2003, 2004, 2005, 2006 Free Software Foundation, Inc. This file is part of the GNU C Library. Contributed by Thorsten Kukuk <kukuk@suse.de>, 1998. @@ -63,6 +63,7 @@ struct database_dyn int check_file; int persistent; int shared; + int propagate; size_t max_db_size; const char *filename; const char *db_filename; diff --git a/nscd/nscd_conf.c b/nscd/nscd_conf.c index 579ddd402f..2048eca886 100644 --- a/nscd/nscd_conf.c +++ b/nscd/nscd_conf.c @@ -1,4 +1,4 @@ -/* Copyright (c) 1998, 2000, 2003, 2004, 2005 Free Software Foundation, Inc. +/* Copyright (c) 1998,2000,2003,2004,2005,2006 Free Software Foundation, Inc. This file is part of the GNU C Library. Contributed by Thorsten Kukuk <kukuk@suse.de>, 1998. @@ -256,6 +256,17 @@ nscd_parse_file (const char *fname, struct database_dyn dbs[lastdb]) else error (0, 0, _("Must specify value for restart-interval option")); } + else if (strcmp (entry, "auto-propagate") == 0) + { + int idx = find_db (arg1); + if (idx >= 0) + { + if (strcmp (arg2, "no") == 0) + dbs[idx].propagate = 0; + else if (strcmp (arg2, "yes") == 0) + dbs[idx].propagate = 1; + } + } else error (0, 0, _("Unknown option: %s %s %s"), entry, arg1, arg2); } diff --git a/nscd/pwdcache.c b/nscd/pwdcache.c index 2daff79d78..01c223add5 100644 --- a/nscd/pwdcache.c +++ b/nscd/pwdcache.c @@ -338,10 +338,10 @@ cache_addpw (struct database_dyn *db, int fd, request_header *req, marked with FIRST first. Otherwise we end up with dangling "pointers" in case a latter hash entry cannot be added. */ - bool first = req->type == GETPWBYNAME; + bool first = true; /* If the request was by UID, add that entry first. */ - if (req->type != GETPWBYNAME) + if (req->type == GETPWBYUID) { if (cache_add (GETPWBYUID, cp, key_offset, &dataset->head, true, db, owner) < 0) @@ -351,12 +351,14 @@ cache_addpw (struct database_dyn *db, int fd, request_header *req, dataset->head.usable = false; goto out; } + + first = false; } /* If the key is different from the name add a separate entry. */ else if (strcmp (key_copy, dataset->strdata) != 0) { if (cache_add (GETPWBYNAME, key_copy, key_len + 1, - &dataset->head, first, db, owner) < 0) + &dataset->head, true, db, owner) < 0) { /* Could not allocate memory. Make sure the data gets discarded. */ @@ -368,11 +370,12 @@ cache_addpw (struct database_dyn *db, int fd, request_header *req, } /* We have to add the value for both, byname and byuid. */ - if (__builtin_expect (cache_add (GETPWBYNAME, dataset->strdata, - pw_name_len, &dataset->head, first, - db, owner) == 0, 1)) + if ((req->type == GETPWBYNAME || db->propagate) + && __builtin_expect (cache_add (GETPWBYNAME, dataset->strdata, + pw_name_len, &dataset->head, + first, db, owner) == 0, 1)) { - if (req->type == GETPWBYNAME) + if (req->type == GETPWBYNAME && db->propagate) (void) cache_add (GETPWBYUID, cp, key_offset, &dataset->head, req->type != GETPWBYNAME, db, owner); } |