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 | 20071227 | 5 | 20071227 |
| 2 | add styxflush(2) etc. | 6 | add styxflush(2) etc. |
| 3 | add NetBSD, emu/NetBSD | 7 | add NetBSD, emu/NetBSD |
| @@ -272,7 +272,8 @@ mount(argv: list of string, facfd: ref Sys->FD): string · 271 unmodified lines | |||
| 272 | return ig(r, sys->sprint("cannot load %s: %r", Factotum->PATH)); | 272 | return ig(r, sys->sprint("cannot load %s: %r", Factotum->PATH)); |
| 273 | factotum->init(); | 273 | factotum->init(); |
| 274 | afd := sys->fauth(fd, spec); | 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 | if(sys->mount(fd, afd, dir, r.flags, spec) < 0) | 277 | if(sys->mount(fd, afd, dir, r.flags, spec) < 0) |
| 277 | return ig(r, sys->sprint("mount %q %q: %r", addr, dir)); | 278 | return ig(r, sys->sprint("mount %q %q: %r", addr, dir)); |
| 278 | return nil; | 279 | return nil; |
| @@ -351,7 +352,8 @@ import9(argv: list of string, facfd: ref Sys->FD): string · 72 unmodified lines | |||
| 351 | } | 352 | } |
| 352 | # TO DO: new style: impo aan|nofilter clear|ssl|tls\n | 353 | # TO DO: new style: impo aan|nofilter clear|ssl|tls\n |
| 353 | afd := sys->fauth(fd, ""); | 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 | if(sys->mount(fd, afd, dir, r.flags, "") < 0) | 357 | if(sys->mount(fd, afd, dir, r.flags, "") < 0) |
| 356 | return ig(r, sys->sprint("import %q %q: %r", addr, dir)); | 358 | return ig(r, sys->sprint("import %q %q: %r", addr, dir)); |
| 357 | return nil; | 359 | return nil; |
| @@ -440,3 +442,24 @@ netmkaddr(addr, net, svc: string): string · 82 unmodified lines | |||
| 440 | return addr; | 442 | return addr; |
| 441 | return sys->sprint("%s!%s", addr, svc); | 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 | relative names | 277 | relative names |
| 278 | rooted names | 278 | rooted names |
| 279 | newns newns | 279 | newns newns |
| 280 | newuser newns | ||
| 280 | categories palmfile | 281 | categories palmfile |
| 281 | dbinfo palmfile | 282 | dbinfo palmfile |
| 282 | doc palmfile | 283 | doc palmfile |
| @@ -1,12 +1,13 @@ | |||
| 1 | .TH NEWNS 2 | 1 | .TH NEWNS 2 |
| 2 | .SH NAME | 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 | .SH SYNOPSIS | 4 | .SH SYNOPSIS |
| 5 | .EX | 5 | .EX |
| 6 | include "newns.m"; | 6 | include "newns.m"; |
| 7 | ns := load Newns Newns->PATH; | 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 | .EE | 11 | .EE |
| 11 | .SH DESCRIPTION | 12 | .SH DESCRIPTION |
| 12 | .B Newns | 13 | .B Newns |
| @@ -23,12 +24,28 @@ or empty, then · 10 unmodified lines | |||
| 23 | .B newns | 24 | .B newns |
| 24 | attempts to read file the file | 25 | attempts to read file the file |
| 25 | .BR namespace . | 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 | .SH SOURCE | 42 | .SH SOURCE |
| 27 | .B /appl/lib/newns.b | 43 | .B /appl/lib/newns.b |
| 28 | .SH SEE ALSO | 44 | .SH SEE ALSO |
| 29 | .IR sys-bind (2), | 45 | .IR sys-bind (2), |
| 30 | .IR sys-chdir (2), | 46 | .IR sys-chdir (2), |
| 31 | .IR sys-pctl (2), | 47 | .IR sys-pctl (2), |
| 48 | .IR factotum (4), | ||
| 32 | .IR namespace (6) | 49 | .IR namespace (6) |
| 33 | .SH BUGS | 50 | .SH BUGS |
| 34 | The | 51 | The |
| @@ -1,8 +1,7 @@ | |||
| 1 | Newns: module | 1 | Newns: module |
| 2 | { | 2 | { |
| 3 | PATH: con "/dis/lib/newns.dis"; | 3 | PATH: con "/dis/lib/newns.dis"; |
| 4 | # | 4 | |
| 5 | # Build a new namespace from a description file | ||
| 6 | # | ||
| 7 | newns: fn(user: string, nsfile: string): string; | 5 | newns: fn(user: string, nsfile: string): string; |
| 6 | newuser: fn(user: string, cap: string, nsfile: string): string; | ||
| 8 | }; | 7 | }; |