ns, devproc: quote path and spec arguments for /proc/$pid/ns, namespace(6) does support quoting

This commit is contained in:
cinap_lenrek 2018-02-25 03:24:31 +01:00
parent be8a8129a2
commit 05cd5cb200
3 changed files with 7 additions and 8 deletions

View file

@ -13,8 +13,7 @@ subroutines
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.

View file

@ -661,19 +661,19 @@ readns1(Chan *c, Proc *p, char *buf, int nbuf)
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;
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);
}
}

View file

@ -90,7 +90,7 @@ main(int argc, char **argv)
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 */