diff options
author | neilbrown <neilbrown> | 2001-09-12 02:14:43 +0000 |
---|---|---|
committer | neilbrown <neilbrown> | 2001-09-12 02:14:43 +0000 |
commit | 8d53a2630763f8f639d2de2ddd26282bff1c7cad (patch) | |
tree | ebc32858dd34a671807c64f7b5b1f85c763d653f /support/nfs/xio.c | |
parent | 5b9179e1d135ef4341516465222eaf9efb84c5f3 (diff) | |
download | nfs-utils-8d53a2630763f8f639d2de2ddd26282bff1c7cad.tar.gz nfs-utils-8d53a2630763f8f639d2de2ddd26282bff1c7cad.tar.xz nfs-utils-8d53a2630763f8f639d2de2ddd26282bff1c7cad.zip |
2001-09-12 NeilBrown <neilb@cse.unsw.edu.au>
* 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
Diffstat (limited to 'support/nfs/xio.c')
-rw-r--r-- | support/nfs/xio.c | 20 |
1 files changed, 19 insertions, 1 deletions
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) |