ref: 9782a0980f5fd5fff080a8e73fce38173705f58c
parent: 78145ee40fd02fd5f831b9652207c2d58a0163aa
author: cinap_lenrek <cinap_lenrek@felloff.net>
date: Sat Feb 24 22:24:31 EST 2018
ns, devproc: quote path and spec arguments for /proc/$pid/ns, namespace(6) does support quoting
--- a/sys/man/6/namespace
+++ b/sys/man/6/namespace
@@ -13,8 +13,7 @@
which is typically called by
.IR init (8).
Each line specifies one name space operation.
-Spaces and tabs separate arguments to operations;
-no quotes or escapes are recognized.
+Spaces and tabs separate arguments to operations.
Blank lines and lines with
.B #
as the first non-space character are ignored.
--- a/sys/src/9/port/devproc.c
+++ b/sys/src/9/port/devproc.c
@@ -661,7 +661,7 @@
if(bestmid == ~0) {c->nrock = bestmid;
- i = snprint(buf, nbuf, "cd %s\n", p->dot->path->s);
+ i = snprint(buf, nbuf, "cd %q\n", p->dot->path->s);
} else {c->nrock = bestmid+1;
@@ -668,12 +668,12 @@
int2flag(cm->mflag, flag);
if(strcmp(cm->to->path->s, "#M") == 0){srv = srvname(cm->to->mchan);
- i = snprint(buf, nbuf, "mount %s %s %s %s\n", flag,
- srv==nil? cm->to->mchan->path->s : srv,
- mh->from->path->s, cm->spec? cm->spec : "");
+ i = snprint(buf, nbuf, (cm->spec && *cm->spec)?
+ "mount %s %q %q %q\n": "mount %s %q %q\n", flag,
+ srv? srv: cm->to->mchan->path->s, mh->from->path->s, cm->spec);
free(srv);
}else{- i = snprint(buf, nbuf, "bind %s %s %s\n", flag,
+ i = snprint(buf, nbuf, "bind %s %q %q\n", flag,
cm->to->path->s, mh->from->path->s);
}
}
--- a/sys/src/cmd/ns.c
+++ b/sys/src/cmd/ns.c
@@ -90,7 +90,7 @@
switch(n){case 2:
if(strcmp(av[0], "cd") == 0){- Bprint(&stdout, "%s %s\n", av[0], av[1]);
+ Bprint(&stdout, "%s %s\n", av[0], quote(av[1]));
continue;
}
/* fall through */
--
⑨