cwfs: make none attach work
allow attach as none. (this was supposed to work but it doesnt for 9p2000 because we have to check for afid being NOFID instead of checking the uname string). and add "nonone" flag to disable this.
This commit is contained in:
parent
3bf1e0798b
commit
52b500af61
5 changed files with 33 additions and 9 deletions
|
@ -82,7 +82,7 @@ authorize(Chan *cp, Fcall *in, Fcall *ou)
|
|||
return 1;
|
||||
|
||||
if(strcmp(in->uname, "none") == 0)
|
||||
return 1;
|
||||
return !nonone;
|
||||
|
||||
if(in->type == Toattach)
|
||||
return 0;
|
||||
|
|
|
@ -201,14 +201,6 @@ authorize(Chan* chan, Fcall* f)
|
|||
|
||||
db = cons.flags & authdebugflag;
|
||||
|
||||
if(strcmp(f->uname, "none") == 0){
|
||||
uid = strtouid(f->uname);
|
||||
if(db)
|
||||
fprint(2, "permission granted to none: uid %s = %d\n",
|
||||
f->uname, uid);
|
||||
return uid;
|
||||
}
|
||||
|
||||
if(noauth || wstatallow){
|
||||
uid = strtouid(f->uname);
|
||||
if(db)
|
||||
|
@ -217,6 +209,14 @@ authorize(Chan* chan, Fcall* f)
|
|||
return uid;
|
||||
}
|
||||
|
||||
if(f->afid == NOFID && !nonone){
|
||||
uid = strtouid(f->uname);
|
||||
if(db)
|
||||
fprint(2, "permission granted to none: uid %s = %d\n",
|
||||
f->uname, uid);
|
||||
return 0; /* none */
|
||||
}
|
||||
|
||||
af = filep(chan, f->afid, 0);
|
||||
if(af == nil){
|
||||
if(db)
|
||||
|
|
|
@ -84,6 +84,7 @@ ulong chatflag;
|
|||
ulong authdebugflag;
|
||||
int noattach; /* attach is disabled */
|
||||
int noauth; /* auth is disable */
|
||||
int nonone; /* attach as none disabled */
|
||||
int noatime; /* atime is disabled */
|
||||
int noatimeset; /* noatime was changed (reset after dump) */
|
||||
int wstatallow; /* set to circumvent wstat permissions */
|
||||
|
|
|
@ -693,6 +693,13 @@ cmd_noauth(int, char *[])
|
|||
print("auth %s\n", noauth ? "disabled" : "enabled");
|
||||
}
|
||||
|
||||
void
|
||||
cmd_nonone(int, char *[])
|
||||
{
|
||||
nonone = !nonone;
|
||||
print("none %s\n", nonone ? "disabled" : "enabled");
|
||||
}
|
||||
|
||||
void
|
||||
cmd_noattach(int, char *[])
|
||||
{
|
||||
|
@ -767,6 +774,7 @@ installcmds(void)
|
|||
cmd_install("hangup", "chan -- clunk files", cmd_hangup);
|
||||
cmd_install("printconf", "-- print configuration", cmd_printconf);
|
||||
cmd_install("noauth", "toggle noauth flag", cmd_noauth);
|
||||
cmd_install("nonone", "toggle nonone flag", cmd_nonone);
|
||||
cmd_install("noattach", "toggle noattach flag", cmd_noattach);
|
||||
cmd_install("files", "report on files structure", cmd_files);
|
||||
|
||||
|
|
|
@ -21,6 +21,7 @@ static Device* confdev;
|
|||
static int copyworm = 0, copydev = 0;
|
||||
static char *src, *dest;
|
||||
|
||||
static int nononeset;
|
||||
static int noauthset;
|
||||
static int readonlyset;
|
||||
static int resetparams;
|
||||
|
@ -432,6 +433,8 @@ mergeconf(Iobuf *p)
|
|||
|
||||
if(!noauthset)
|
||||
noauth = 0;
|
||||
if(!nononeset)
|
||||
nonone = 0;
|
||||
if(!noatimeset)
|
||||
noatime = 0;
|
||||
if(!readonlyset)
|
||||
|
@ -450,6 +453,9 @@ mergeconf(Iobuf *p)
|
|||
} else if(strcmp(word, "noauth") == 0){
|
||||
if(!noauthset)
|
||||
noauth = 1;
|
||||
} else if(strcmp(word, "nonone") == 0){
|
||||
if(!nononeset)
|
||||
nonone = 1;
|
||||
} else if(strcmp(word, "noatime") == 0){
|
||||
if(!noatimeset)
|
||||
noatime = 1;
|
||||
|
@ -600,6 +606,8 @@ start:
|
|||
fs->conf);
|
||||
if(noauth)
|
||||
cp = seprint(cp, ep, "noauth\n");
|
||||
if(nonone)
|
||||
cp = seprint(cp, ep, "nonone\n");
|
||||
if(noatime)
|
||||
cp = seprint(cp, ep, "noatime\n");
|
||||
if(readonly)
|
||||
|
@ -1009,6 +1017,13 @@ arginit(void)
|
|||
f.modconf = 1;
|
||||
continue;
|
||||
}
|
||||
if(strcmp(word, "nonone") == 0) {
|
||||
nonone = !nonone;
|
||||
print("none %s\n", nonone ? "disabled" : "enabled");
|
||||
nononeset++;
|
||||
f.modconf = 1;
|
||||
continue;
|
||||
}
|
||||
if(strcmp(word, "noatime") == 0) {
|
||||
noatime = !noatime;
|
||||
print("atime %s\n", noatime ? "disabled" : "enabled");
|
||||
|
|
Loading…
Reference in a new issue