]> git.decadent.org.uk Git - nfs-utils.git/commitdiff
Ensure 'showmount -e' gets current information.
authorNeil Brown <neilb@suse.de>
Thu, 11 Jan 2007 01:51:29 +0000 (12:51 +1100)
committerNeil Brown <neilb@suse.de>
Thu, 11 Jan 2007 01:51:29 +0000 (12:51 +1100)
If auth_reload has been called by someone else, get_exportlist
can incorrectly return old data.  So track modify times better
and only use cached data if the modify time matches.

utils/mountd/auth.c
utils/mountd/mountd.c
utils/mountd/mountd.h

index 4f803d7aa0511bac1e9c9fc163ee278dca25220d..183c9ea8c5b27b747925b832405333543eba97f0 100644 (file)
@@ -46,7 +46,7 @@ auth_init(char *exports)
        xtab_mount_write();
 }
 
-int
+time_t
 auth_reload()
 {
        struct stat             stb;
@@ -55,7 +55,7 @@ auth_reload()
        if (stat(_PATH_ETAB, &stb) < 0)
                xlog(L_FATAL, "couldn't stat %s", _PATH_ETAB);
        if (stb.st_mtime == last_modified)
-               return 0;
+               return last_modified;
        last_modified = stb.st_mtime;
 
        export_freeall();
@@ -63,7 +63,7 @@ auth_reload()
        // export_read(export_file);
        xtab_export_read();
 
-       return 1;
+       return last_modified;
 }
 
 static nfs_export *
index 72332ce7772ad559519516293b5dedcec47b3349..5204faa62b4a1d6b7f750c4923818f9fcec7df51 100644 (file)
@@ -463,14 +463,19 @@ static exports
 get_exportlist(void)
 {
        static exports          elist = NULL;
+       static time_t           etime = 0;
+       time_t                  atime;
        struct exportnode       *e, *ne;
        struct groupnode        *g, *ng, *c, **cp;
        nfs_export              *exp;
        int                     i;
 
-       if (!auth_reload() && elist)
+       atime = auth_reload();
+       if (elist && atime == etime)
                return elist;
 
+       etime = atime;
+
        for (e = elist; e != NULL; e = ne) {
                ne = e->ex_next;
                for (g = e->ex_groups; g != NULL; g = ng) {
index d64c17121006f3f433a38557adf0aa377412a194..b539278aaf0354d8f77b56bcfecac7ccce7e2371 100644 (file)
@@ -40,7 +40,7 @@ bool_t                mount_mnt_3_svc(struct svc_req *, dirpath *, mountres3 *);
 
 void           mount_dispatch(struct svc_req *, SVCXPRT *);
 void           auth_init(char *export_file);
-int            auth_reload(void);
+time_t         auth_reload(void);
 nfs_export *   auth_authenticate(char *what, struct sockaddr_in *sin,
                                        char *path);
 void           auth_export(nfs_export *exp);