libauth: change programs to use the new procsetuser() function
This commit is contained in:
parent
fc5070c600
commit
eb1dfed9ab
|
@ -43,13 +43,8 @@ main(int argc, char *argv[])
|
|||
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");
|
||||
|
||||
|
|
|
@ -338,12 +338,8 @@ scandir(char *proto, char *protodir, char *addr, char *dname)
|
|||
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");
|
||||
}
|
||||
|
|
|
@ -18,12 +18,8 @@ usage(void)
|
|||
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");
|
||||
}
|
||||
|
|
|
@ -129,16 +129,12 @@ main(int argc, char **argv)
|
|||
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*
|
||||
|
|
|
@ -83,8 +83,7 @@ main(int argc, char *argv[])
|
|||
}
|
||||
|
||||
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);
|
||||
|
|
|
@ -202,12 +202,11 @@ Mount:
|
|||
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)
|
||||
|
|
|
@ -8,17 +8,13 @@
|
|||
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;
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue