diff options
author | Harshula Jayasuriya <harshula@redhat.com> | 2013-11-20 14:35:00 -0500 |
---|---|---|
committer | Steve Dickson <steved@redhat.com> | 2013-11-20 15:04:47 -0500 |
commit | ad7814093205b669650a60e16fbe4e4b25b50f12 (patch) | |
tree | 1b5417457cb9ba02e928069bd218149481aaf895 | |
parent | f41c591f8f4d492ee84994bb86810fb90bef8d4b (diff) | |
download | nfs-utils-ad7814093205b669650a60e16fbe4e4b25b50f12.tar.gz nfs-utils-ad7814093205b669650a60e16fbe4e4b25b50f12.tar.xz nfs-utils-ad7814093205b669650a60e16fbe4e4b25b50f12.zip |
exportfs: modify can_test() to use LONG_MAX when appropriate
This patch is the nfs-utils patch corresponding to the kernel patch
commit 2f74f972 "sunrpc: prepare NFS for 2038". The kernel sunrpc
code needs to handle seconds since epoch greater than 2147483647.
This means functions that parse time as an int need to
handle it as time_t."
When appropriate exportfs should use LONG_MAX in can_test()
instead of INT_MAX.
Signed-off-by: Harshula Jayasuriya <harshula@redhat.com>
Signed-off-by: Steve Dickson <steved@redhat.com>
-rw-r--r-- | utils/exportfs/exportfs.c | 28 |
1 files changed, 24 insertions, 4 deletions
diff --git a/utils/exportfs/exportfs.c b/utils/exportfs/exportfs.c index da5fe21..00667e9 100644 --- a/utils/exportfs/exportfs.c +++ b/utils/exportfs/exportfs.c @@ -27,6 +27,10 @@ #include <netdb.h> #include <errno.h> #include <dirent.h> +#include <limits.h> +#include <time.h> + +#define INT_TO_LONG_THRESHOLD_SECS (INT_MAX - (60 * 60 * 24)) #include "sockaddr.h" #include "misc.h" @@ -406,17 +410,33 @@ unexportfs(char *arg, int verbose) static int can_test(void) { + char buf[1024]; int fd; int n; - char *setup = "nfsd 0.0.0.0 2147483647 -test-client-\n"; + fd = open("/proc/net/rpc/auth.unix.ip/channel", O_WRONLY); - if ( fd < 0) return 0; - n = write(fd, setup, strlen(setup)); + if (fd < 0) + return 0; + + /* + * We introduce tolerance of 1 day to ensure that we use a + * LONG_MAX for the expiry timestamp before it is actually + * needed. To use LONG_MAX, the kernel code must have + * commit 2f74f972 (sunrpc: prepare NFS for 2038). + */ + if (time(NULL) > INT_TO_LONG_THRESHOLD_SECS) + sprintf(buf, "nfsd 0.0.0.0 %ld -test-client-\n", LONG_MAX); + else + sprintf(buf, "nfsd 0.0.0.0 %d -test-client-\n", INT_MAX); + + n = write(fd, buf, strlen(buf)); close(fd); if (n < 0) return 0; + fd = open("/proc/net/rpc/nfsd.export/channel", O_WRONLY); - if ( fd < 0) return 0; + if (fd < 0) + return 0; close(fd); return 1; } |