Index: nscd/cache.c =================================================================== --- nscd/cache.c.orig +++ nscd/cache.c @@ -267,28 +267,31 @@ prune_cache (struct database_dyn *table, if (table->inotify_descr < 0 && table->check_file && now != LONG_MAX) { struct stat64 st; + time_t mtime; - if (stat64 (table->filename, &st) < 0) + mtime = stat64 (table->filename, &st) ? LONG_MAX : st.st_mtime; + if (mtime != table->file_mtime) { - char buf[128]; - /* We cannot stat() the file, disable file checking if the - file does not exist. */ - dbg_log (_("cannot stat() file `%s': %s"), - table->filename, strerror_r (errno, buf, sizeof (buf))); - if (errno == ENOENT) - table->check_file = 0; + /* The file changed. Invalidate all entries. */ + now = LONG_MAX; + table->file_mtime = mtime; } - else + if (*table->filename2) { - if (st.st_mtime != table->file_mtime) + mtime = stat64 (table->filename2, &st) ? LONG_MAX : st.st_mtime; + if (mtime != table->file_mtime2) { /* The file changed. Invalidate all entries. */ now = LONG_MAX; - table->file_mtime = st.st_mtime; + table->file_mtime2 = mtime; } } } + /* now == 0 means just check for changed files */ + if (now == (time_t)0) + return; + /* We run through the table and find values which are not valid anymore. Note that for the initial step, finding the entries to be removed, Index: nscd/connections.c =================================================================== --- nscd/connections.c.orig +++ nscd/connections.c @@ -119,6 +119,7 @@ struct database_dyn dbs[lastdb] = .suggested_module = DEFAULT_SUGGESTED_MODULE, .reset_res = 0, .filename = "/etc/passwd", + .filename2 = "", .db_filename = _PATH_NSCD_PASSWD_DB, .disabled_iov = &pwd_iov_disabled, .postimeout = 3600, @@ -140,6 +141,7 @@ struct database_dyn dbs[lastdb] = .suggested_module = DEFAULT_SUGGESTED_MODULE, .reset_res = 0, .filename = "/etc/group", + .filename2 = "", .db_filename = _PATH_NSCD_GROUP_DB, .disabled_iov = &grp_iov_disabled, .postimeout = 3600, @@ -161,6 +163,7 @@ struct database_dyn dbs[lastdb] = .suggested_module = DEFAULT_SUGGESTED_MODULE, .reset_res = 1, .filename = "/etc/hosts", + .filename2 = "/etc/resolv.conf", .db_filename = _PATH_NSCD_HOSTS_DB, .disabled_iov = &hst_iov_disabled, .postimeout = 3600, @@ -855,15 +858,9 @@ cannot set socket to close on exec: %s; /* We need the modification date of the file. */ struct stat64 st; - if (stat64 (dbs[cnt].filename, &st) < 0) - { - /* We cannot stat() the file, disable file checking. */ - dbg_log (_("cannot stat() file `%s': %s"), - dbs[cnt].filename, strerror (errno)); - dbs[cnt].check_file = 0; - } - else - dbs[cnt].file_mtime = st.st_mtime; + dbs[cnt].file_mtime = stat64 (dbs[cnt].filename, &st) ? LONG_MAX : st.st_mtime; + if (*dbs[cnt].filename2) + dbs[cnt].file_mtime2 = stat64 (dbs[cnt].filename2, &st) ? LONG_MAX : st.st_mtime; } } Index: nscd/nscd.conf =================================================================== --- nscd/nscd.conf.orig +++ nscd/nscd.conf @@ -61,11 +61,11 @@ auto-propagate group yes enable-cache hosts yes - positive-time-to-live hosts 3600 - negative-time-to-live hosts 20 + positive-time-to-live hosts 600 + negative-time-to-live hosts 0 suggested-size hosts 211 check-files hosts yes - persistent hosts yes + persistent hosts no shared hosts yes max-db-size hosts 33554432 Index: nscd/nscd.h =================================================================== --- nscd/nscd.h.orig +++ nscd/nscd.h @@ -80,8 +80,10 @@ struct database_dyn int propagate; int reset_res; const char filename[16]; + const char filename2[17]; const char *db_filename; time_t file_mtime; + time_t file_mtime2; size_t suggested_module; size_t max_db_size; Index: nscd/nscd_stat.c =================================================================== --- nscd/nscd_stat.c.orig +++ nscd/nscd_stat.c @@ -302,7 +302,7 @@ receive_print_stats (void) data.dbs[i].maxnsearched, data.dbs[i].rdlockdelayed, data.dbs[i].wrlockdelayed, - data.dbs[i].addfailed, check_file, dbnames[i]); + data.dbs[i].addfailed, check_file, (strcmp(dbnames[i], "hosts") ? dbnames[i] : "{hosts,resolv.conf}")); } if (selinux_enabled)