]> git.lizzy.rs Git - plan9front.git/commitdiff
libauth: change programs to use the new procsetuser() function
authorcinap_lenrek <cinap_lenrek@felloff.net>
Sat, 19 Dec 2020 17:02:37 +0000 (18:02 +0100)
committercinap_lenrek <cinap_lenrek@felloff.net>
Sat, 19 Dec 2020 17:02:37 +0000 (18:02 +0100)
sys/src/cmd/auth/none.c
sys/src/cmd/aux/listen.c
sys/src/cmd/aux/listen1.c
sys/src/cmd/ip/httpd/httpd.c
sys/src/cmd/mount.c
sys/src/cmd/srv.c
sys/src/cmd/upas/common/become.c

index 75d8b70fa64976e351bacaf050dcfc3f2b753c26..42c264b42e00dac80d4443e2064a202f271040c7 100644 (file)
@@ -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");
 
index 9969a9f2c270bd7583198811776620023864aff2..9990445973b9323bc1bf5b44a622157599edb3df 100644 (file)
@@ -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");
 }
index 5946e059103d619411e97ab66694e53a8a2d9e5f..58d5719f2afbcdfb0fc34836f7bdab4435abda52 100644 (file)
@@ -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");
 }
index 657ae548763d3da7509c4459dadfe6808ddfd773..9740a1185a400886c21ce1922fe078c0135000d6 100644 (file)
@@ -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*
index 2c8371911f17a06d8c07818f68f68290bad5b7cf..3d30269aad790e157558bcbcb8b216b92acc0999 100644 (file)
@@ -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);
index 0839c839335be388b5a6be5e45a5a0660ffe5b85..fa7a6ad07316cf9e66c764ed9a7119d7f4a44f93 100644 (file)
@@ -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)
index 37cd119972ec86deb255e325dcd369ebac2833ea..6de87179a427199ee53b4c8abf72f71ec70e5f50 100644 (file)
@@ -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;
                }
        }