* nscd/nscd.h (struct database_dyn): Add propagate field.
authorUlrich Drepper <drepper@redhat.com>
Wed, 26 Apr 2006 17:32:10 +0000 (17:32 +0000)
committerUlrich Drepper <drepper@redhat.com>
Wed, 26 Apr 2006 17:32:10 +0000 (17:32 +0000)
* 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.

ChangeLog
nscd/connections.c
nscd/grpcache.c
nscd/nscd.conf
nscd/nscd.h
nscd/nscd_conf.c
nscd/pwdcache.c

index 3980c3c..4515bfa 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,13 @@
+2006-04-26  Ulrich Drepper  <drepper@redhat.com>
+
+       * 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.
+
 2006-04-26  James Antill  <james.antill@redhat.com>
            Ulrich Drepper  <drepper@redhat.com>
 
index b24e7fb..814d1c7 100644 (file)
@@ -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",
index 4bc9977..5a8fba4 100644 (file)
@@ -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);
            }
index 9491e16..289eb2e 100644 (file)
@@ -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
index ed686be..f826c7a 100644 (file)
@@ -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;
index 579ddd4..2048eca 100644 (file)
@@ -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);
     }
index 2daff79..01c223a 100644 (file)
@@ -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);
            }