From 26bd1d8dc48b8e5bc6ad8ae5221cedd9703dc473 Mon Sep 17 00:00:00 2001 From: Giacomo Tesio Date: Wed, 25 Oct 2017 01:59:04 +0200 Subject: [PATCH] kern: fix working dir after ns clone After sending the "clone" request to /proc/$pid/ns, the current process will be moved to the working directory of $pid. Otherwise the current process could still access the file and folders on the service providing its dot, even if such service was not visible to $pid. Also, keeping the original working directory means that the 'cd' line of the current process's ns file would be different from that of $pid: the two ns files must match since the command asked for a "clone". See also https://marc.info/?l=9fans&m=150893734909969&w=2 --- sys/src/kern/port/devproc.c | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/sys/src/kern/port/devproc.c b/sys/src/kern/port/devproc.c index cae8c03..23ef89a 100644 --- a/sys/src/kern/port/devproc.c +++ b/sys/src/kern/port/devproc.c @@ -1281,6 +1281,11 @@ procwrite(Chan *c, void *va, long n, int64_t off) pgrpcpy(up->pgrp, p->pgrp); /* inherit noattach */ up->pgrp->noattach = p->pgrp->noattach; + /* inherit dot */ + if(up->dot != nil) + cclose(up->dot); + up->dot = p->dot; + incref(&up->dot->r); closepgrp(opg); break;