Unified · Split
| @@ -1,3 +1,7 @@ | ||
| 1 | +20080111 | |
| 2 | + add newuser to newns(2) | |
| 3 | +20080109 | |
| 4 | + Sys->iounit should accept any valid file descriptor, not just ORDWR | |
| 1 | 5 | 20071227 |
| 2 | 6 | add styxflush(2) etc. |
| 3 | 7 | add NetBSD, emu/NetBSD |
| @@ -272,7 +272,8 @@ mount(argv: list of string, facfd: ref Sys->FD): string · 271 unmodified lines | ||
| 272 | 272 | return ig(r, sys->sprint("cannot load %s: %r", Factotum->PATH)); |
| 273 | 273 | factotum->init(); |
| 274 | 274 | afd := sys->fauth(fd, spec); |
| 275 | − ai := factotum->proxy(afd, facfd, "proto=p9any role=client"); # TO DO: something with ai | |
| 275 | + if(afd != nil) | |
| 276 | + factotum->proxy(afd, facfd, "proto=p9any role=client"); # ignore result; if it fails, mount will fail | |
| 276 | 277 | if(sys->mount(fd, afd, dir, r.flags, spec) < 0) |
| 277 | 278 | return ig(r, sys->sprint("mount %q %q: %r", addr, dir)); |
| 278 | 279 | return nil; |
| @@ -351,7 +352,8 @@ import9(argv: list of string, facfd: ref Sys->FD): string · 72 unmodified lines | ||
| 351 | 352 | } |
| 352 | 353 | # TO DO: new style: impo aan|nofilter clear|ssl|tls\n |
| 353 | 354 | afd := sys->fauth(fd, ""); |
| 354 | − ai := factotum->proxy(afd, facfd, "proto=p9any role=client"); # TO DO: something with ai | |
| 355 | + if(afd != nil) | |
| 356 | + factotum->proxy(afd, facfd, "proto=p9any role=client"); | |
| 355 | 357 | if(sys->mount(fd, afd, dir, r.flags, "") < 0) |
| 356 | 358 | return ig(r, sys->sprint("import %q %q: %r", addr, dir)); |
| 357 | 359 | return nil; |
| @@ -440,3 +442,24 @@ netmkaddr(addr, net, svc: string): string · 82 unmodified lines | ||
| 440 | 442 | return addr; |
| 441 | 443 | return sys->sprint("%s!%s", addr, svc); |
| 442 | 444 | } |
| 445 | + | |
| 446 | +newuser(user: string, cap: string, nsfile: string): string | |
| 447 | +{ | |
| 448 | + if(cap == nil) | |
| 449 | + return "no capability"; | |
| 450 | + | |
| 451 | + sys = load Sys Sys->PATH; | |
| 452 | + fd := sys->open("#¤/capuse", Sys->OWRITE); | |
| 453 | + if(fd == nil) | |
| 454 | + return sys->sprint("opening #¤/capuse: %r"); | |
| 455 | + | |
| 456 | + b := array of byte cap; | |
| 457 | + if(sys->write(fd, b, len b) < 0) | |
| 458 | + return sys->sprint("writing %s to #¤/capuse: %r", cap); | |
| 459 | + | |
| 460 | + # mount factotum as new user (probably unhelpful if not factotum owner) | |
| 461 | + sys->unmount(nil, "/mnt/factotum"); | |
| 462 | + sys->bind("#sfactotum", "/mnt/factotum", Sys->MREPL); | |
| 463 | + | |
| 464 | + return newns(user, nsfile); | |
| 465 | +} | |
Binary file not shown.
| @@ -1 +1 @@ | ||
| 1 | −#define VERSION "Fourth Edition (20080109)" | |
| 1 | +#define VERSION "Fourth Edition (20080111)" | |
| @@ -277,6 +277,7 @@ pathname names · 276 unmodified lines | ||
| 277 | 277 | relative names |
| 278 | 278 | rooted names |
| 279 | 279 | newns newns |
| 280 | +newuser newns | |
| 280 | 281 | categories palmfile |
| 281 | 282 | dbinfo palmfile |
| 282 | 283 | doc palmfile |
| @@ -1,12 +1,13 @@ | ||
| 1 | 1 | .TH NEWNS 2 |
| 2 | 2 | .SH NAME |
| 3 | −newns \- build a new name space from a description file | |
| 3 | +Newns: newns, newuser \- build a new name space from a description file | |
| 4 | 4 | .SH SYNOPSIS |
| 5 | 5 | .EX |
| 6 | 6 | include "newns.m"; |
| 7 | 7 | ns := load Newns Newns->PATH; |
| 8 | 8 | |
| 9 | −newns: fn(user: string, nsfile: string): string; | |
| 9 | +newns: fn(user: string, nsfile: string): string; | |
| 10 | +newuser: fn(user: string, cap: string, nsfile: string): string; | |
| 10 | 11 | .EE |
| 11 | 12 | .SH DESCRIPTION |
| 12 | 13 | .B Newns |
| @@ -23,12 +24,28 @@ or empty, then · 10 unmodified lines | ||
| 23 | 24 | .B newns |
| 24 | 25 | attempts to read file the file |
| 25 | 26 | .BR namespace . |
| 27 | +.PP | |
| 28 | +.B Newuser | |
| 29 | +uses a capability | |
| 30 | +.I cap | |
| 31 | +suitable for | |
| 32 | +.IR cap (3) | |
| 33 | +to change the current process's user name to | |
| 34 | +.IR user , | |
| 35 | +and uses | |
| 36 | +.B newns | |
| 37 | +and | |
| 38 | +.I nsfile | |
| 39 | +to build it a new name space. | |
| 40 | +The capability is typically obtained via | |
| 41 | +.IR factotum (4). | |
| 26 | 42 | .SH SOURCE |
| 27 | 43 | .B /appl/lib/newns.b |
| 28 | 44 | .SH SEE ALSO |
| 29 | 45 | .IR sys-bind (2), |
| 30 | 46 | .IR sys-chdir (2), |
| 31 | 47 | .IR sys-pctl (2), |
| 48 | +.IR factotum (4), | |
| 32 | 49 | .IR namespace (6) |
| 33 | 50 | .SH BUGS |
| 34 | 51 | The |
| @@ -1,8 +1,7 @@ | ||
| 1 | 1 | Newns: module |
| 2 | 2 | { |
| 3 | 3 | PATH: con "/dis/lib/newns.dis"; |
| 4 | − # | |
| 5 | − # Build a new namespace from a description file | |
| 6 | − # | |
| 4 | + | |
| 7 | 5 | newns: fn(user: string, nsfile: string): string; |
| 6 | + newuser: fn(user: string, cap: string, nsfile: string): string; | |
| 8 | 7 | }; |