diff options
-rw-r--r-- | lib/param/loadparm.c | 16 | ||||
-rw-r--r-- | lib/param/loadparm.h | 2 | ||||
-rw-r--r-- | source3/param/loadparm.c | 34 |
3 files changed, 37 insertions, 15 deletions
diff --git a/lib/param/loadparm.c b/lib/param/loadparm.c index 7d7b314a407..c1d1f5393d1 100644 --- a/lib/param/loadparm.c +++ b/lib/param/loadparm.c @@ -1009,6 +1009,8 @@ void add_to_file_list(TALLOC_CTX *mem_ctx, struct file_lists **list, const char *fname, const char *subfname) { struct file_lists *f = *list; + struct stat sb = {0}; + int rc; while (f) { if (f->name && !strcmp(f->name, fname)) @@ -1017,7 +1019,7 @@ void add_to_file_list(TALLOC_CTX *mem_ctx, struct file_lists **list, } if (!f) { - f = talloc(mem_ctx, struct file_lists); + f = talloc_zero(mem_ctx, struct file_lists); if (!f) goto fail; f->next = *list; @@ -1032,12 +1034,14 @@ void add_to_file_list(TALLOC_CTX *mem_ctx, struct file_lists **list, goto fail; } *list = f; - f->modtime = file_modtime(subfname); - } else { - time_t t = file_modtime(subfname); - if (t) - f->modtime = t; } + + rc = stat(subfname, &sb); + if (rc != 0) { + return; + } + f->modtime = get_mtimespec(&sb); + return; fail: diff --git a/lib/param/loadparm.h b/lib/param/loadparm.h index 98263f0e62b..af6b530366a 100644 --- a/lib/param/loadparm.h +++ b/lib/param/loadparm.h @@ -102,7 +102,7 @@ struct file_lists { struct file_lists *next; char *name; char *subfname; - time_t modtime; + struct timespec modtime; }; #define DEFAULT_NAME_RESOLVE_ORDER "lmhosts wins host bcast" diff --git a/source3/param/loadparm.c b/source3/param/loadparm.c index 56a8bc2d28b..0eb63fe3f36 100644 --- a/source3/param/loadparm.c +++ b/source3/param/loadparm.c @@ -79,6 +79,7 @@ #include "auth/credentials/credentials.h" #include "source3/lib/substitute.h" #include "source3/librpc/gen_ndr/ads.h" +#include "lib/util/time_basic.h" #ifdef HAVE_SYS_SYSCTL_H #include <sys/sysctl.h> @@ -2408,8 +2409,15 @@ bool lp_file_list_changed(void) return true; } } else { - time_t mod_time; + struct timespec mod_time = { + .tv_sec = 0, + }; + struct timeval_buf tbuf = { + .buf = {0}, + }; char *n2 = NULL; + struct stat sb = {0}; + int rc; n2 = talloc_sub_basic(talloc_tos(), get_current_username(), @@ -2419,19 +2427,29 @@ bool lp_file_list_changed(void) return false; } DEBUGADD(6, ("file %s -> %s last mod_time: %s\n", - f->name, n2, ctime(&f->modtime))); - - mod_time = file_modtime(n2); + f->name, n2, + timespec_string_buf(&f->modtime, + true, + &tbuf))); + + rc = stat(n2, &sb); + if (rc == 0) { + mod_time = get_mtimespec(&sb); + } - if (mod_time && - ((f->modtime != mod_time) || + if (mod_time.tv_sec > 0 && + ((timespec_compare(&mod_time, &f->modtime) != 0) || (f->subfname == NULL) || (strcmp(n2, f->subfname) != 0))) { + f->modtime = mod_time; + DEBUGADD(6, ("file %s modified: %s\n", n2, - ctime(&mod_time))); - f->modtime = mod_time; + timespec_string_buf(&f->modtime, + true, + &tbuf))); + TALLOC_FREE(f->subfname); f->subfname = talloc_strdup(f, n2); if (f->subfname == NULL) { |