ref: 52b500af6185068233ff021b2160463192f69ef0
parent: 3bf1e0798b9d002801d5af114052474f08aa1c64
author: cinap_lenrek <[email protected]>
date: Fri Dec 7 01:30:26 EST 2012
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.
--- a/sys/src/cmd/cwfs/9p1.c
+++ b/sys/src/cmd/cwfs/9p1.c
@@ -82,7 +82,7 @@
return 1;
if(strcmp(in->uname, "none") == 0)
- return 1;
+ return !nonone;
if(in->type == Toattach)
return 0;
--- a/sys/src/cmd/cwfs/9p2.c
+++ b/sys/src/cmd/cwfs/9p2.c
@@ -201,20 +201,20 @@
db = cons.flags & authdebugflag;
- if(strcmp(f->uname, "none") == 0){
+ if(noauth || wstatallow){
uid = strtouid(f->uname);
if(db)
- fprint(2, "permission granted to none: uid %s = %d\n",
+ fprint(2, "permission granted by noauth uid %s = %d\n",
f->uname, uid);
return uid;
}
- if(noauth || wstatallow){
+ if(f->afid == NOFID && !nonone){
uid = strtouid(f->uname);
if(db)
- fprint(2, "permission granted by noauth uid %s = %d\n",
+ fprint(2, "permission granted to none: uid %s = %d\n",
f->uname, uid);
- return uid;
+ return 0; /* none */
}
af = filep(chan, f->afid, 0);
--- a/sys/src/cmd/cwfs/all.h
+++ b/sys/src/cmd/cwfs/all.h
@@ -84,6 +84,7 @@
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 */
--- a/sys/src/cmd/cwfs/con.c
+++ b/sys/src/cmd/cwfs/con.c
@@ -694,6 +694,13 @@
}
void
+cmd_nonone(int, char *[])
+{
+ nonone = !nonone;
+ print("none %s\n", nonone ? "disabled" : "enabled");
+}
+
+void
cmd_noattach(int, char *[])
{
noattach = !noattach;
@@ -767,6 +774,7 @@
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);
--- a/sys/src/cmd/cwfs/config.c
+++ b/sys/src/cmd/cwfs/config.c
@@ -21,6 +21,7 @@
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 @@
if(!noauthset)
noauth = 0;
+ if(!nononeset)
+ nonone = 0;
if(!noatimeset)
noatime = 0;
if(!readonlyset)
@@ -450,6 +453,9 @@
} 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 @@
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)
@@ -1006,6 +1014,13 @@
noauth = !noauth;
print("auth %s\n", noauth ? "disabled" : "enabled");
noauthset++;
+ f.modconf = 1;
+ continue;
+ }
+ if(strcmp(word, "nonone") == 0) {
+ nonone = !nonone;
+ print("none %s\n", nonone ? "disabled" : "enabled");
+ nononeset++;
f.modconf = 1;
continue;
}