xref: /plan9/sys/src/cmd/upas/common/become.c (revision 9a747e4fd48b9f4522c70c07e8f882a15030f964)
1 #include "common.h"
2 #include <auth.h>
3 #include <ndb.h>
4 
5 /*
6  *  become powerless user
7  */
8 int
become(char ** cmd,char * who)9 become(char **cmd, char *who)
10 {
11 	int fd;
12 
13 	USED(cmd);
14 	if(strcmp(who, "none") == 0) {
15 		fd = open("#c/user", OWRITE);
16 		if(fd < 0 || write(fd, "none", strlen("none")) < 0) {
17 			werrstr("can't become none");
18 			return -1;
19 		}
20 		close(fd);
21 		if(newns("none", 0)) {
22 			werrstr("can't set new namespace");
23 			return -1;
24 		}
25 	}
26 	return 0;
27 }
28 
29