History

20080111-1121

Charles.Forsyth committed 18 years ago

Commit 642c93f1 parent 78a84407 files · +51 −7Browse files

Unified · Split

7 files
  1. CHANGES +4 −0
  2. appl/lib/newns.b +25 −2
  3. dis/lib/newns.dis +0 −0
  4. include/version.h +1 −1
  5. man/2/INDEX +1 −0
  6. man/2/newns +19 −2
  7. module/newns.m +2 −3
CHANGES+4−0
@@ -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
15 20071227
26 add styxflush(2) etc.
37 add NetBSD, emu/NetBSD
appl/lib/newns.b+25−2
@@ -272,7 +272,8 @@ mount(argv: list of string, facfd: ref Sys->FD): string · 271 unmodified lines
272272 return ig(r, sys->sprint("cannot load %s: %r", Factotum->PATH));
273273 factotum->init();
274274 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
276277 if(sys->mount(fd, afd, dir, r.flags, spec) < 0)
277278 return ig(r, sys->sprint("mount %q %q: %r", addr, dir));
278279 return nil;
@@ -351,7 +352,8 @@ import9(argv: list of string, facfd: ref Sys->FD): string · 72 unmodified lines
351352 }
352353 # TO DO: new style: impo aan|nofilter clear|ssl|tls\n
353354 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");
355357 if(sys->mount(fd, afd, dir, r.flags, "") < 0)
356358 return ig(r, sys->sprint("import %q %q: %r", addr, dir));
357359 return nil;
@@ -440,3 +442,24 @@ netmkaddr(addr, net, svc: string): string · 82 unmodified lines
440442 return addr;
441443 return sys->sprint("%s!%s", addr, svc);
442444 }
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+}
dis/lib/newns.dis+0−0

Binary file not shown.

include/version.h+1−1
@@ -1 +1 @@
1−#define VERSION "Fourth Edition (20080109)"
1+#define VERSION "Fourth Edition (20080111)"
man/2/INDEX+1−0
@@ -277,6 +277,7 @@ pathname names · 276 unmodified lines
277277 relative names
278278 rooted names
279279 newns newns
280+newuser newns
280281 categories palmfile
281282 dbinfo palmfile
282283 doc palmfile
man/2/newns+19−2
@@ -1,12 +1,13 @@
11 .TH NEWNS 2
22 .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
44 .SH SYNOPSIS
55 .EX
66 include "newns.m";
77 ns := load Newns Newns->PATH;
88
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;
1011 .EE
1112 .SH DESCRIPTION
1213 .B Newns
@@ -23,12 +24,28 @@ or empty, then · 10 unmodified lines
2324 .B newns
2425 attempts to read file the file
2526 .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).
2642 .SH SOURCE
2743 .B /appl/lib/newns.b
2844 .SH SEE ALSO
2945 .IR sys-bind (2),
3046 .IR sys-chdir (2),
3147 .IR sys-pctl (2),
48+.IR factotum (4),
3249 .IR namespace (6)
3350 .SH BUGS
3451 The
module/newns.m+2−3
@@ -1,8 +1,7 @@
11 Newns: module
22 {
33 PATH: con "/dis/lib/newns.dis";
4− #
5− # Build a new namespace from a description file
6− #
4+
75 newns: fn(user: string, nsfile: string): string;
6+ newuser: fn(user: string, cap: string, nsfile: string): string;
87 };

Keyboard shortcuts

General

Show keyboard shortcuts
?
Focus the current search
/

Issues and pull requests

Open filters
f

Issues, pull requests and Inbox

Select next item
j↓
Select previous item
k↑
Open selected item
Enter
Dismiss filters or clear selection
Esc

Repository code

Go to file
t