diff --git a/nfs-utils-1.0.12-mountd-etab.patch b/nfs-utils-1.0.12-mountd-etab.patch new file mode 100644 index 0000000..8b9d0b9 --- /dev/null +++ b/nfs-utils-1.0.12-mountd-etab.patch @@ -0,0 +1,132 @@ +commit ec08843916d07c28045398e5b17e7347a8fa0135 +Author: Steve Dickson +Date: Fri May 11 12:13:06 2007 -0400 + + nfs-utils: have mountd hold open etab file to force inode number to change + + This patch changes mountd to hold the etab file open so that when it's + changed by exportfs, the inode number should change. We then change + auth_reload to reload the file based on whether st_ino is different + from the last time it was checked. It also changes auth_reload to + maintain a static counter value and return it instead of a timestamp + and fixes up get_exportlist accordingly. Finally, it adds some + comments to xtab_write to warn people about editing the etab in place. + + Signed-off-by: Jeff Layton + + Signed-off-by: Steve Dickson + +diff --git a/support/export/xtab.c b/support/export/xtab.c +index 0ddb251..292087b 100644 +--- a/support/export/xtab.c ++++ b/support/export/xtab.c +@@ -80,6 +80,12 @@ xtab_export_read(void) + return xtab_read(_PATH_ETAB, 1); + } + ++/* ++ * mountd now keeps an open fd for the etab at all times to make sure that the ++ * inode number changes when the xtab_export_write is done. If you change the ++ * routine below such that the files are edited in place, then you'll need to ++ * fix the auth_reload logic as well... ++ */ + static int + xtab_write(char *xtab, char *xtabtmp, int is_export) + { +diff --git a/utils/mountd/auth.c b/utils/mountd/auth.c +index 183c9ea..f7fe23d 100644 +--- a/utils/mountd/auth.c ++++ b/utils/mountd/auth.c +@@ -14,6 +14,7 @@ + #include + #include + #include ++#include + #include "misc.h" + #include "nfslib.h" + #include "exportfs.h" +@@ -46,24 +47,34 @@ auth_init(char *exports) + xtab_mount_write(); + } + +-time_t ++unsigned int + auth_reload() + { + struct stat stb; +- static time_t last_modified = 0; +- +- if (stat(_PATH_ETAB, &stb) < 0) ++ static ino_t last_inode; ++ static int last_fd; ++ static unsigned int counter; ++ int fd; ++ ++ if ((fd = open(_PATH_ETAB, O_RDONLY)) < 0) { ++ xlog(L_FATAL, "couldn't open %s", _PATH_ETAB); ++ } else if (fstat(fd, &stb) < 0) { + xlog(L_FATAL, "couldn't stat %s", _PATH_ETAB); +- if (stb.st_mtime == last_modified) +- return last_modified; +- last_modified = stb.st_mtime; ++ } else if (stb.st_ino == last_inode) { ++ close(fd); ++ return counter; ++ } else { ++ close(last_fd); ++ last_fd = fd; ++ last_inode = stb.st_ino; ++ } + + export_freeall(); + memset(&my_client, 0, sizeof(my_client)); +- // export_read(export_file); + xtab_export_read(); ++ ++counter; + +- return last_modified; ++ return counter; + } + + static nfs_export * +diff --git a/utils/mountd/mountd.c b/utils/mountd/mountd.c +index fc9a73c..09cab84 100644 +--- a/utils/mountd/mountd.c ++++ b/utils/mountd/mountd.c +@@ -465,18 +465,18 @@ 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; ++ static unsigned int ecounter; ++ unsigned int acounter; + +- atime = auth_reload(); +- if (elist && atime == etime) ++ acounter = auth_reload(); ++ if (elist && acounter == ecounter) + return elist; + +- etime = atime; ++ ecounter = acounter; + + for (e = elist; e != NULL; e = ne) { + ne = e->ex_next; +diff --git a/utils/mountd/mountd.h b/utils/mountd/mountd.h +index b539278..31bacb5 100644 +--- a/utils/mountd/mountd.h ++++ b/utils/mountd/mountd.h +@@ -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); +-time_t auth_reload(void); ++unsigned int auth_reload(void); + nfs_export * auth_authenticate(char *what, struct sockaddr_in *sin, + char *path); + void auth_export(nfs_export *exp); diff --git a/nfs-utils.spec b/nfs-utils.spec index 10932f8..ec9c7fb 100644 --- a/nfs-utils.spec +++ b/nfs-utils.spec @@ -51,6 +51,7 @@ Patch83: nfs-utils-1.0.12-rmtab-ipaddr-manupdate.patch Patch84: nfs-utils-1.0.12-mountd-memleak.patch Patch85: nfs-utils-1.0.12-nfsd-macargs.patch Patch86: nfs-utils-1.0.12-mtab-mis-unlock.patch +Patch87: nfs-utils-1.0.12-mountd-etab.patch %if %{enablefscache} Patch90: nfs-utils-1.0.9-mount-fsc.patch @@ -127,6 +128,7 @@ This package also contains the mount.nfs and umount.nfs program. %patch84 -p1 %patch85 -p1 %patch86 -p1 +%patch87 -p1 %if %{enablefscache} %patch90 -p1 %endif @@ -320,6 +322,7 @@ fi the /var/lib/nfs/statd with the rpcuser id. (bz 235216) - Correct some sanity checking in rpc.nfsd. (bz 220887) - Added missing unlock_mtab() call in moutnd +- Have mountd hold open etab file to force inode number to change (bz 236823) * Tue Apr 3 2007 Steve Dickson 1.0.12-4 - Replace portmap dependency with an rpcbind dependency (bz 228894)