summaryrefslogtreecommitdiff
path: root/sys/src/cmd/cwfs/con.c
diff options
context:
space:
mode:
authorcinap_lenrek <cinap_lenrek@felloff.net>2014-08-11 22:36:59 +0200
committercinap_lenrek <cinap_lenrek@felloff.net>2014-08-11 22:36:59 +0200
commit427e925eea1ea4ca9a5308b7b08af01785389991 (patch)
treeec23e79aea9861e9945ae05cfffc62b87e497655 /sys/src/cmd/cwfs/con.c
parent30d4d8984bfc64e971bfbb3b913c37ed8a8da17b (diff)
cwfs: add optional uid argument to allow command, unify permission override code
the allow command now takes an optional uid argument for the user to be granted temporary god status on the fileserver for maintenance. this was kenji okomotos idea, so thanks :) remove wstatallow and writeallow flags. instead, we have global: int allowed; that contains the uid of the currently allowed user id or -1 if permission checking is globally disabled for the fileserver. when zero, normal permission checking takes place. added int isallowed(File*) function that returns non-zero when the context is the console, or the allowed user. this is also used internally by iaccess(), so all the extra code of in the callers of iaccess() is gone now. dont conflate allowed user with noauth flag and auto-allow on ream. the installer already knows about noauth and allow flags so theres no problem with bootstraping.
Diffstat (limited to 'sys/src/cmd/cwfs/con.c')
-rw-r--r--sys/src/cmd/cwfs/con.c26
1 files changed, 21 insertions, 5 deletions
diff --git a/sys/src/cmd/cwfs/con.c b/sys/src/cmd/cwfs/con.c
index 00fadf6bb..bace9df29 100644
--- a/sys/src/cmd/cwfs/con.c
+++ b/sys/src/cmd/cwfs/con.c
@@ -461,15 +461,31 @@ cmd_clri(int argc, char *argv[])
}
static void
-cmd_allow(int, char**)
+cmd_allow(int argc, char *argv[])
{
- wstatallow = writeallow = 1;
+ char *name;
+ int uid;
+
+ uid = -1;
+ name = "any user";
+ if(argc > 1){
+ name = argv[1];
+ uid = strtouid(name);
+ if(uid < 0)
+ uid = number(name, -2, 10);
+ if(uid < 0) {
+ print("bad uid %s\n", name);
+ return;
+ }
+ }
+ print("allowed %s\n", name);
+ allowed = uid;
}
static void
cmd_disallow(int, char**)
{
- wstatallow = writeallow = 0;
+ allowed = 0;
}
void
@@ -748,14 +764,14 @@ cmd_chatty(int argc, char *argv[])
static void
installcmds(void)
{
- cmd_install("allow", "-- disable permission checking", cmd_allow);
+ cmd_install("allow", "[uid] -- disable permission checking", cmd_allow);
cmd_install("cfs", "[file] -- set current filesystem", cmd_cfs);
cmd_install("chatty", "n -- set chattiness", cmd_chatty);
cmd_install("clean", "file [bno [addr]] -- block print/fix", cmd_clean);
cmd_install("check", "[options]", cmd_check);
cmd_install("clri", "[file ...] -- purge files/dirs", cmd_clri);
cmd_install("create", "path uid gid perm [lad] -- make a file/dir", cmd_create);
- cmd_install("disallow", "-- enable permission checking", cmd_disallow);
+ cmd_install("disallow", "-- (re)enable permission checking", cmd_disallow);
cmd_install("duallow", "uid -- duallow", cmd_duallow);
cmd_install("flag", "-- print set flags", cmd_flag);
cmd_install("fstat", "path -- print info on a file/dir", cmd_fstat);