summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJacob Moody <moody@posixcafe.org>2022-06-10 04:10:54 +0000
committerJacob Moody <moody@posixcafe.org>2022-06-10 04:10:54 +0000
commit13065e16b3c4fba4d9200ed7fec89ee49338f12a (patch)
treee0ae2bf5aa65d2b389da0229415458b01b685e48
parent1b5ea51ee1203952900fafc0def48985d900f7a7 (diff)
auth/box: don't bother switching to none
Changing the user to none doesn't do much for us here. For kernel drivers that check the user of the current proc we'll be none, but anything from devmnt will still be accessed using creds from the original attachment. Instead, running with none can be done by chaining with auth/none: auth/none auth/box ...
-rw-r--r--sys/man/8/auth35
-rw-r--r--sys/src/cmd/auth/box.c7
2 files changed, 17 insertions, 25 deletions
diff --git a/sys/man/8/auth b/sys/man/8/auth
index fcfe8fcc9..e31730a30 100644
--- a/sys/man/8/auth
+++ b/sys/man/8/auth
@@ -279,27 +279,24 @@ It's an easy way to run a command as
.IR none .
.PP
.I Box
-sets up a restricted namespace and
-.IR exec's
-its arguments as the user
-.IR none .
-Components of the current namespace are bound
-into the child namespace with the
-.B -r
-and
-.B -c
-flags, using either
-.I MREPL
-or
-.I MCREATE
-respectively. The only components
-in the child namespace will be those
-defined this way.
-By default all further kernel driver
-access is blocked. The
+executes its arguments in a minimal namespace.
+This namespace is derived by binding in the specified
+program to the same name within a new hierarchy.
+The same is done with the paths
+provided as arguments. Paths provided with the
+.B -r
+flag are bound with
+.IR MREPL ,
+and those provided with the
+.B -c
+flag are bound with
+.IR MCREATE .
+.I Box
+removes access to all kernel drivers from
+the child namespace; the
.B -e
flag specifies a string of driver
-characters to keep in the child namespace.
+characters to keep.
.PP
.I As
executes
diff --git a/sys/src/cmd/auth/box.c b/sys/src/cmd/auth/box.c
index e2dac74c6..30eedce7d 100644
--- a/sys/src/cmd/auth/box.c
+++ b/sys/src/cmd/auth/box.c
@@ -163,17 +163,12 @@ main(int argc, char **argv)
mflags[nparts++] = MREPL;
argv[0] = b;
- rfork(RFNAMEG|RFENVG);
+ rfork(RFNAMEG|RFFDG);
dfd = open("/dev/drivers", OWRITE|OCEXEC);
if(dfd < 0)
sysfatal("could not /dev/drivers: %r");
resolvenames(parts, nparts);
-
- if(procsetuser("none") < 0)
- sysfatal("cant become none: %r");
- putenv("user", "none");
-
sandbox(parts, mflags, nparts);
if(debug)