diff options
author | Lance Shelton <lance.shelton@hammerspace.com> | 2020-05-04 13:41:22 -0400 |
---|---|---|
committer | Steve Dickson <steved@redhat.com> | 2020-05-04 14:50:49 -0400 |
commit | c5dd634d579253d038e2db05513533dc306e95f3 (patch) | |
tree | 5a18e68f676c4e20d64ab16b8145ef11d136bbb3 | |
parent | 06b819e6ee12689628c59a7467810db4b01d5354 (diff) | |
download | nfs-utils-c5dd634d579253d038e2db05513533dc306e95f3.tar.gz |
mountd: Preserve special characters in refer and replica path options
Allow referral paths to contain special character by adding an
escaping mechanism.
Signed-off-by: Lance Shelton <lance.shelton@hammerspace.com>
Signed-off-by: Trond Myklebust <trond.myklebust@hammerspace.com>
Signed-off-by: Steve Dickson <steved@redhat.com>
-rw-r--r-- | support/nfs/exports.c | 27 |
1 files changed, 18 insertions, 9 deletions
diff --git a/support/nfs/exports.c b/support/nfs/exports.c index 8fbb6b15..97eb3183 100644 --- a/support/nfs/exports.c +++ b/support/nfs/exports.c @@ -247,23 +247,28 @@ void secinfo_show(FILE *fp, struct exportent *ep) } } +static void +fprintpath(FILE *fp, const char *path) +{ + int i; + for (i=0; path[i]; i++) + if (iscntrl(path[i]) || path[i] == '"' || path[i] == '\\' || path[i] == '#' || isspace(path[i])) + fprintf(fp, "\\%03o", path[i]); + else + fprintf(fp, "%c", path[i]); +} + void putexportent(struct exportent *ep) { FILE *fp; int *id, i; - char *esc=ep->e_path; if (!efp) return; fp = efp->x_fp; - for (i=0; esc[i]; i++) - if (iscntrl(esc[i]) || esc[i] == '"' || esc[i] == '\\' || esc[i] == '#' || isspace(esc[i])) - fprintf(fp, "\\%03o", esc[i]); - else - fprintf(fp, "%c", esc[i]); - + fprintpath(fp, ep->e_path); fprintf(fp, "\t%s(", ep->e_hostname); fprintf(fp, "%s,", (ep->e_flags & NFSEXP_READONLY)? "ro" : "rw"); fprintf(fp, "%ssync,", (ep->e_flags & NFSEXP_ASYNC)? "a" : ""); @@ -302,10 +307,14 @@ putexportent(struct exportent *ep) case FSLOC_NONE: break; case FSLOC_REFER: - fprintf(fp, "refer=%s,", ep->e_fslocdata); + fprintf(fp, "refer="); + fprintpath(fp, ep->e_fslocdata); + fprintf(fp, ","); break; case FSLOC_REPLICA: - fprintf(fp, "replicas=%s,", ep->e_fslocdata); + fprintf(fp, "replicas="); + fprintpath(fp, ep->e_fslocdata); + fprintf(fp, ","); break; #ifdef DEBUG case FSLOC_STUB: |