ref: 2ae2e5f856f8f95f8d780f9ffe0a0ebb634ffb1a
parent: 4c8689551f48fa8668eeb71c26b6ffdd89c4834a
author: cinap_lenrek <cinap_lenrek@localhost>
date: Sun Apr 17 05:29:38 EDT 2011
cwfs: make noauth a storable config option so one can boot without factotum and nvram
--- a/sys/src/cmd/cwfs/9p1.c
+++ b/sys/src/cmd/cwfs/9p1.c
@@ -264,14 +264,8 @@
strncpy(cp->whoname, in->uname, sizeof(cp->whoname));
cp->whotime = time(nil);
- if(cons.flags & attachflag)
- print("9p1: attach %s %T to \"%s\" C%d\n",- cp->whoname, cp->whotime, fs->name, cp->chan);
out:
- if((cons.flags & attachflag) && ou->err)
- print("9p1: attach %s %T SUCK EGGS --- %s\n",- in->uname, time(nil), errstr9p[ou->err]);
if(p)
putbuf(p);
if(f) {--- a/sys/src/cmd/cwfs/9p2.c
+++ b/sys/src/cmd/cwfs/9p2.c
@@ -165,7 +165,7 @@
Filsys *fs;
int error;
- if(cons.flags & authdisableflag)
+ if(noauth || wstatallow)
return Eauthdisabled;
error = 0;
@@ -202,9 +202,6 @@
}
r->aqid = file->qid;
out:
- if((cons.flags & attachflag) && error)
- print("9p2: auth %s %T SUCK EGGS --- %s\n",- f->uname, time(nil), errstr9p[error]);
if(file != nil){qunlock(file);
if(error)
@@ -229,10 +226,10 @@
return uid;
}
- if(cons.flags & authdisableflag){+ if(noauth || wstatallow){uid = strtouid(f->uname);
if(db)
- print("permission granted by authdisable uid %s = %d\n",+ print("permission granted by noauth uid %s = %d\n",f->uname, uid);
return uid;
}
@@ -326,14 +323,7 @@
strncpy(chan->whoname, f->uname, sizeof(chan->whoname));
chan->whotime = time(nil);
- if(cons.flags & attachflag)
- print("9p2: attach %s %T to \"%s\" C%d\n",- chan->whoname, chan->whotime, fs->name, chan->chan);
-
out:
- if((cons.flags & attachflag) && error)
- print("9p2: attach %s %T SUCK EGGS --- %s\n",- f->uname, time(nil), errstr9p[error]);
if(p != nil)
putbuf(p);
if(file != nil){--- a/sys/src/cmd/cwfs/all.h
+++ b/sys/src/cmd/cwfs/all.h
@@ -81,16 +81,14 @@
ulong roflag;
ulong errorflag;
ulong chatflag;
-ulong attachflag;
ulong authdebugflag;
-ulong authdisableflag;
-int noattach;
+int noattach; /* attach is disabled */
+int noauth; /* auth is disable */
int wstatallow; /* set to circumvent wstat permissions */
int writeallow; /* set to circumvent write permissions */
int duallow; /* single user to allow du */
int readonly; /* disable writes if true */
-int noauth; /* Debug */
int rawreadok; /* allow reading raw data */
--- a/sys/src/cmd/cwfs/con.c
+++ b/sys/src/cmd/cwfs/con.c
@@ -696,6 +696,14 @@
}
void
+cmd_noauth(int, char *[])
+{+ noauth = !noauth;
+ if(noauth)
+ print("authentication is DISABLED\n");+}
+
+void
cmd_noattach(int, char *[])
{noattach = !noattach;
@@ -759,15 +767,14 @@
cmd_install("who", "[user ...] -- print attaches", cmd_who); 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("noattach", "toggle noattach flag", cmd_noattach); cmd_install("files", "report on files structure", cmd_files);- attachflag = flag_install("attach", "-- attach calls"); chatflag = flag_install("chat", "-- verbose"); errorflag = flag_install("error", "-- on errors"); whoflag = flag_install("allchans", "-- on who"); authdebugflag = flag_install("authdebug", "-- report authentications");- authdisableflag = flag_install("authdisable", "-- disable authentication");}
int
--- a/sys/src/cmd/cwfs/config.c
+++ b/sys/src/cmd/cwfs/config.c
@@ -440,6 +440,10 @@
cp = getwrd(word, cp);
if(service[0] == 0)
strncpy(service, word, sizeof service);
+ } else if(strcmp(word, "noauth") == 0){+ noauth = 1;
+ } else if(strcmp(word, "readonly") == 0){+ readonly = 1;
} else if(strcmp(word, "ipauth") == 0) /* obsolete */
cp = getwrd(word, cp);
else if(astrcmp(word, "ip") == 0) /* obsolete */
@@ -579,7 +583,10 @@
if(fs->conf && fs->conf[0] != '\0')
cp = seprint(cp, ep, "filsys %s %s\n", fs->name,
fs->conf);
-
+ if(noauth)
+ cp = seprint(cp, ep, "noauth\n");
+ if(readonly)
+ cp = seprint(cp, ep, "readonly\n");
for (fsp = fspar; fsp->name != nil; fsp++)
cp = seprint(cp, ep, "%s %ld\n",
fsp->name, fsp->declared);
@@ -591,7 +598,7 @@
}
putbuf(p);
- print("service %s\n", service);+ print("service %s\n", service);loop:
/*
@@ -954,12 +961,6 @@
querychanger(iconfig(word));
continue;
}
-
- if(strcmp(word, "allow") == 0) {- wstatallow = 1;
- writeallow = 1;
- continue;
- }
if(strcmp(word, "copyworm") == 0) {copyworm = 1;
continue;
@@ -976,16 +977,18 @@
copydev = 1;
continue;
}
- if(strcmp(word, "noauth") == 0) {- noauth = !noauth;
- continue;
- }
if(strcmp(word, "noattach") == 0) {noattach = !noattach;
continue;
}
+ if(strcmp(word, "noauth") == 0) {+ noauth = !noauth;
+ f.modconf = 1;
+ continue;
+ }
if(strcmp(word, "readonly") == 0) {- readonly = 1;
+ readonly = !readonly;
+ f.modconf = 1;
continue;
}
--- a/sys/src/cmd/cwfs/console.c
+++ b/sys/src/cmd/cwfs/console.c
@@ -1,5 +1,4 @@
#include "all.h"
-
#include "9p1.h"
void
--- a/sys/src/cmd/cwfs/net.c
+++ b/sys/src/cmd/cwfs/net.c
@@ -44,9 +44,7 @@
static Network netif[Maxnets];
-char *annstrs[Maxnets] = {- "tcp!*!9fs",
-};
+char *annstrs[Maxnets];
static void
neti(void *v)
--
⑨