usage();
}ARGEND
- fd = open("#c/user", OWRITE);
- if(fd < 0)
- sysfatal("can't open #c/user: %r");
- if(write(fd, "none", strlen("none")) < 0)
+ if(procsetuser("none") < 0)
sysfatal("can't become none: %r");
- close(fd);
-
if(newns("none", namespace) < 0)
sysfatal("can't build namespace: %r");
void
becomenone(void)
{
- int fd;
-
- fd = open("#c/user", OWRITE);
- if(fd < 0 || write(fd, "none", strlen("none")) < 0)
+ if(procsetuser("none") < 0)
error("can't become none");
- close(fd);
if(newns("none", namespace) < 0)
error("can't build namespace");
}
void
becomenone(void)
{
- int fd;
-
- fd = open("#c/user", OWRITE);
- if(fd < 0 || write(fd, "none", strlen("none")) < 0)
+ if(procsetuser("none") < 0)
sysfatal("can't become none: %r");
- close(fd);
if(newns("none", nsfile) < 0)
sysfatal("can't build namespace: %r");
}
static void
becomenone(char *namespace)
{
- int fd;
-
- fd = open("#c/user", OWRITE);
- if(fd < 0 || write(fd, "none", strlen("none")) < 0)
- sysfatal("can't become none");
- close(fd);
+ if(procsetuser("none") < 0)
+ sysfatal("can't become none: %r");
if(newns("none", nil) < 0)
- sysfatal("can't build normal namespace");
+ sysfatal("can't build normal namespace: %r");
if(addns("none", namespace) < 0)
- sysfatal("can't build httpd namespace");
+ sysfatal("can't build httpd namespace: %r");
}
static HConnect*
}
if(asnone){
- rv = open("#c/user", OWRITE);
- if(rv < 0 || write(rv, "none", 4) != 4){
+ if(procsetuser("none") < 0){
if(qflag)
exits(0);
fprint(2, "%s: can't become none: %r\n", argv0);
exits(0);
if(asnone){
- try = open("#c/user", OWRITE);
- if(try < 0 || write(try, "none", 4) != 4){
+ if(procsetuser("none") < 0){
fprint(2, "srv %s: can't become none: %r\n", dest);
exits("becomenone");
}
- try = 0;
+ try = 0; /* no retry */
}
if((!doauth && mount(fd, -1, mtpt, mountflag, "") == -1)
int
become(char **, char *who)
{
- int fd;
-
if(strcmp(who, "none") == 0) {
- fd = open("#c/user", OWRITE);
- if(fd < 0 || write(fd, "none", strlen("none")) < 0) {
- werrstr("can't become none");
+ if(procsetuser("none") < 0) {
+ werrstr("can't become none: %r");
return -1;
}
- close(fd);
- if(newns("none", 0)) {
- werrstr("can't set new namespace");
+ if(newns("none", nil) < 0) {
+ werrstr("can't set new namespace: %r");
return -1;
}
}