From 8d53a2630763f8f639d2de2ddd26282bff1c7cad Mon Sep 17 00:00:00 2001 From: neilbrown Date: Wed, 12 Sep 2001 02:14:43 +0000 Subject: [PATCH] 2001-09-12 NeilBrown * support/nfs/exports.c (putexportent): \octal quote any spaces etc in a path name * support/nfs/xio.c (xgettok): recognise double-quote and \octal quoting in path names * utils/exportfs/exports.man: document quoting conventions for path names --- ChangeLog | 9 +++++++++ support/nfs/exports.c | 9 ++++++++- support/nfs/xio.c | 20 +++++++++++++++++++- utils/exportfs/exports.man | 5 ++++- 4 files changed, 40 insertions(+), 3 deletions(-) diff --git a/ChangeLog b/ChangeLog index 95832a1..2dc842f 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,12 @@ +2001-09-12 NeilBrown + + * support/nfs/exports.c (putexportent): \octal quote any spaces + etc in a path name + * support/nfs/xio.c (xgettok): recognise double-quote and + \octal quoting in path names + * utils/exportfs/exports.man: document quoting conventions + for path names + 2001-09-12 NeilBrown * utils/mountd/auth.c (auth_authenticate_internal): Reverse diff --git a/support/nfs/exports.c b/support/nfs/exports.c index dbb2da0..eb1bf2c 100644 --- a/support/nfs/exports.c +++ b/support/nfs/exports.c @@ -135,12 +135,19 @@ putexportent(struct exportent *ep) { FILE *fp; int *id, i; + char *esc=ep->e_path; if (!efp) return; fp = efp->x_fp; - fprintf(fp, "%s\t%s(", ep->e_path, ep->e_hostname); + for (i=0; esc[i]; i++) + if (iscntrl(esc[i]) || esc[i] == '"' || esc[i] == '\\'|| isspace(esc[i])) + fprintf(fp, "\\%03o", esc[i]); + else + fprintf(fp, "%c", esc[i]); + + 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" : ""); fprintf(fp, "%swdelay,", (ep->e_flags & NFSEXP_GATHERED_WRITES)? diff --git a/support/nfs/xio.c b/support/nfs/xio.c index cfdb1d1..9bb5100 100644 --- a/support/nfs/xio.c +++ b/support/nfs/xio.c @@ -83,14 +83,32 @@ xfunlock(int fd) close(fd); } +#define isoctal(x) (isdigit(x) && ((x)<'8')) int xgettok(XFILE *xfp, char sepa, char *tok, int len) { int i = 0; int c = 0; + int quoted=0; - while (i < len && (c = xgetc(xfp)) != EOF && c != sepa && !isspace(c)) + while (i < len && (c = xgetc(xfp)) != EOF && + (quoted || (c != sepa && !isspace(c)))) { + if (c == '"') { + quoted = !quoted; + continue; + } tok[i++] = c; + if (i >= 4 && + tok[i-4] == '\\' && + isoctal(tok[i-3]) && + isoctal(tok[i-2]) && + isoctal(tok[i-1]) && + ((tok[i]=0), + (c = strtol(tok+i-3,NULL, 8)) < 256)) { + i -= 4; + tok[i++] = c; + } + } if (c == '\n') xungetc(c, xfp); if (!i) diff --git a/utils/exportfs/exports.man b/utils/exportfs/exports.man index 8d08667..4b31ccf 100644 --- a/utils/exportfs/exports.man +++ b/utils/exportfs/exports.man @@ -22,7 +22,10 @@ contains an export point and a list of machine or netgroup names allowed to mount the file system at that point. An optional parenthesized list of export parameters may follow each machine name. Blank lines are ignored, and a # introduces a comment to the end of the line. Entries may -be continued across newlines using a backslash. +be continued across newlines using a backslash. If export name contains spaces +it should be quoted using double-quotes. You can also specify spaces +or any other unusual characters in the export path name using a +backslash followed by the character code as 3 octal digits. .PP .SS Machine Name Formats NFS clients may be specified in a number of ways: -- 2.39.5