diff options
author | Trond Myklebust <trond.myklebust@hammerspace.com> | 2019-06-04 15:31:37 -0400 |
---|---|---|
committer | Steve Dickson <steved@redhat.com> | 2019-06-10 09:50:38 -0400 |
commit | bdd07a6c852514f4d0a39d5bb312b8f3d0df36f6 (patch) | |
tree | 63a81685b14c653c15a9f9a86c53ba45f53adc84 /support/misc | |
parent | 4ef89ebb514183aed6292f83227ddf57078d6d3b (diff) | |
download | nfs-utils-bdd07a6c852514f4d0a39d5bb312b8f3d0df36f6.tar.gz |
mountd: Ensure nfsd_path_strip_root() uses the canonicalised path
When attempting to strip the root path, we should first canonicalise
the root pathname.
Signed-off-by: Trond Myklebust <trond.myklebust@hammerspace.com>
Signed-off-by: Steve Dickson <steved@redhat.com>
Diffstat (limited to 'support/misc')
-rw-r--r-- | support/misc/nfsd_path.c | 17 |
1 files changed, 12 insertions, 5 deletions
diff --git a/support/misc/nfsd_path.c b/support/misc/nfsd_path.c index 2f41a79..84e4802 100644 --- a/support/misc/nfsd_path.c +++ b/support/misc/nfsd_path.c @@ -1,6 +1,7 @@ #include <errno.h> #include <sys/types.h> #include <sys/stat.h> +#include <limits.h> #include <stdlib.h> #include <unistd.h> @@ -62,13 +63,19 @@ nfsd_path_nfsd_rootdir(void) char * nfsd_path_strip_root(char *pathname) { + char buffer[PATH_MAX]; const char *dir = nfsd_path_nfsd_rootdir(); - char *ret; - ret = strstr(pathname, dir); - if (!ret || ret != pathname) - return pathname; - return pathname + strlen(dir); + if (!dir) + goto out; + + if (realpath(dir, buffer)) + return strstr(pathname, buffer) == pathname ? + pathname + strlen(buffer) : NULL; + + xlog(D_GENERAL, "%s: failed to resolve path %s: %m", __func__, dir); +out: + return pathname; } char * |