aboutsummaryrefslogtreecommitdiff
path: root/src/cmd/upas/common/become.c
diff options
context:
space:
mode:
authorrsc <devnull@localhost>2005-10-29 16:26:32 +0000
committerrsc <devnull@localhost>2005-10-29 16:26:32 +0000
commitd1f529f46f957c78a3db73b42c2fcd2d3c9f8a34 (patch)
treea4d6f28106cca984926b9dd5ecddd6053b654617 /src/cmd/upas/common/become.c
parent9f1fdc128738b2ed76258ac22a8574c681f3df3a (diff)
downloadplan9port-d1f529f46f957c78a3db73b42c2fcd2d3c9f8a34.tar.gz
plan9port-d1f529f46f957c78a3db73b42c2fcd2d3c9f8a34.tar.bz2
plan9port-d1f529f46f957c78a3db73b42c2fcd2d3c9f8a34.zip
Thanks to John Cummings.
Diffstat (limited to 'src/cmd/upas/common/become.c')
-rw-r--r--src/cmd/upas/common/become.c28
1 files changed, 28 insertions, 0 deletions
diff --git a/src/cmd/upas/common/become.c b/src/cmd/upas/common/become.c
new file mode 100644
index 00000000..1b5aa456
--- /dev/null
+++ b/src/cmd/upas/common/become.c
@@ -0,0 +1,28 @@
+#include "common.h"
+#include <auth.h>
+#include <ndb.h>
+
+/*
+ * become powerless user
+ */
+int
+become(char **cmd, char *who)
+{
+ int fd;
+
+ USED(cmd);
+ if(strcmp(who, "none") == 0) {
+ fd = open("#c/user", OWRITE);
+ if(fd < 0 || write(fd, "none", strlen("none")) < 0) {
+ werrstr("can't become none");
+ return -1;
+ }
+ close(fd);
+ // jpc if(newns("none", 0)) {
+ // jpc werrstr("can't set new namespace");
+ // jpc return -1;
+ // jpc }
+ }
+ return 0;
+}
+