cwfs: make noauth a storable config option so one can boot without factotum and nvram
This commit is contained in:
parent
edca9072a5
commit
95758309f3
7 changed files with 31 additions and 42 deletions
|
@ -264,14 +264,8 @@ f_attach(Chan *cp, Fcall *in, Fcall *ou)
|
||||||
|
|
||||||
strncpy(cp->whoname, in->uname, sizeof(cp->whoname));
|
strncpy(cp->whoname, in->uname, sizeof(cp->whoname));
|
||||||
cp->whotime = time(nil);
|
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:
|
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)
|
if(p)
|
||||||
putbuf(p);
|
putbuf(p);
|
||||||
if(f) {
|
if(f) {
|
||||||
|
|
|
@ -165,7 +165,7 @@ auth(Chan* chan, Fcall* f, Fcall* r)
|
||||||
Filsys *fs;
|
Filsys *fs;
|
||||||
int error;
|
int error;
|
||||||
|
|
||||||
if(cons.flags & authdisableflag)
|
if(noauth || wstatallow)
|
||||||
return Eauthdisabled;
|
return Eauthdisabled;
|
||||||
|
|
||||||
error = 0;
|
error = 0;
|
||||||
|
@ -202,9 +202,6 @@ auth(Chan* chan, Fcall* f, Fcall* r)
|
||||||
}
|
}
|
||||||
r->aqid = file->qid;
|
r->aqid = file->qid;
|
||||||
out:
|
out:
|
||||||
if((cons.flags & attachflag) && error)
|
|
||||||
print("9p2: auth %s %T SUCK EGGS --- %s\n",
|
|
||||||
f->uname, time(nil), errstr9p[error]);
|
|
||||||
if(file != nil){
|
if(file != nil){
|
||||||
qunlock(file);
|
qunlock(file);
|
||||||
if(error)
|
if(error)
|
||||||
|
@ -229,10 +226,10 @@ authorize(Chan* chan, Fcall* f)
|
||||||
return uid;
|
return uid;
|
||||||
}
|
}
|
||||||
|
|
||||||
if(cons.flags & authdisableflag){
|
if(noauth || wstatallow){
|
||||||
uid = strtouid(f->uname);
|
uid = strtouid(f->uname);
|
||||||
if(db)
|
if(db)
|
||||||
print("permission granted by authdisable uid %s = %d\n",
|
print("permission granted by noauth uid %s = %d\n",
|
||||||
f->uname, uid);
|
f->uname, uid);
|
||||||
return uid;
|
return uid;
|
||||||
}
|
}
|
||||||
|
@ -326,14 +323,7 @@ attach(Chan* chan, Fcall* f, Fcall* r)
|
||||||
|
|
||||||
strncpy(chan->whoname, f->uname, sizeof(chan->whoname));
|
strncpy(chan->whoname, f->uname, sizeof(chan->whoname));
|
||||||
chan->whotime = time(nil);
|
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:
|
out:
|
||||||
if((cons.flags & attachflag) && error)
|
|
||||||
print("9p2: attach %s %T SUCK EGGS --- %s\n",
|
|
||||||
f->uname, time(nil), errstr9p[error]);
|
|
||||||
if(p != nil)
|
if(p != nil)
|
||||||
putbuf(p);
|
putbuf(p);
|
||||||
if(file != nil){
|
if(file != nil){
|
||||||
|
|
|
@ -81,16 +81,14 @@ struct Fspar {
|
||||||
ulong roflag;
|
ulong roflag;
|
||||||
ulong errorflag;
|
ulong errorflag;
|
||||||
ulong chatflag;
|
ulong chatflag;
|
||||||
ulong attachflag;
|
|
||||||
ulong authdebugflag;
|
ulong authdebugflag;
|
||||||
ulong authdisableflag;
|
int noattach; /* attach is disabled */
|
||||||
int noattach;
|
int noauth; /* auth is disable */
|
||||||
int wstatallow; /* set to circumvent wstat permissions */
|
int wstatallow; /* set to circumvent wstat permissions */
|
||||||
int writeallow; /* set to circumvent write permissions */
|
int writeallow; /* set to circumvent write permissions */
|
||||||
int duallow; /* single user to allow du */
|
int duallow; /* single user to allow du */
|
||||||
int readonly; /* disable writes if true */
|
int readonly; /* disable writes if true */
|
||||||
|
|
||||||
int noauth; /* Debug */
|
|
||||||
|
|
||||||
int rawreadok; /* allow reading raw data */
|
int rawreadok; /* allow reading raw data */
|
||||||
|
|
||||||
|
|
|
@ -695,6 +695,14 @@ cmd_time(int argc, char *argv[])
|
||||||
print("time = %ld ms\n", TK2MS(t2-t1));
|
print("time = %ld ms\n", TK2MS(t2-t1));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void
|
||||||
|
cmd_noauth(int, char *[])
|
||||||
|
{
|
||||||
|
noauth = !noauth;
|
||||||
|
if(noauth)
|
||||||
|
print("authentication is DISABLED\n");
|
||||||
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
cmd_noattach(int, char *[])
|
cmd_noattach(int, char *[])
|
||||||
{
|
{
|
||||||
|
@ -759,15 +767,14 @@ installcmds(void)
|
||||||
cmd_install("who", "[user ...] -- print attaches", cmd_who);
|
cmd_install("who", "[user ...] -- print attaches", cmd_who);
|
||||||
cmd_install("hangup", "chan -- clunk files", cmd_hangup);
|
cmd_install("hangup", "chan -- clunk files", cmd_hangup);
|
||||||
cmd_install("printconf", "-- print configuration", cmd_printconf);
|
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("noattach", "toggle noattach flag", cmd_noattach);
|
||||||
cmd_install("files", "report on files structure", cmd_files);
|
cmd_install("files", "report on files structure", cmd_files);
|
||||||
|
|
||||||
attachflag = flag_install("attach", "-- attach calls");
|
|
||||||
chatflag = flag_install("chat", "-- verbose");
|
chatflag = flag_install("chat", "-- verbose");
|
||||||
errorflag = flag_install("error", "-- on errors");
|
errorflag = flag_install("error", "-- on errors");
|
||||||
whoflag = flag_install("allchans", "-- on who");
|
whoflag = flag_install("allchans", "-- on who");
|
||||||
authdebugflag = flag_install("authdebug", "-- report authentications");
|
authdebugflag = flag_install("authdebug", "-- report authentications");
|
||||||
authdisableflag = flag_install("authdisable", "-- disable authentication");
|
|
||||||
}
|
}
|
||||||
|
|
||||||
int
|
int
|
||||||
|
|
|
@ -440,6 +440,10 @@ mergeconf(Iobuf *p)
|
||||||
cp = getwrd(word, cp);
|
cp = getwrd(word, cp);
|
||||||
if(service[0] == 0)
|
if(service[0] == 0)
|
||||||
strncpy(service, word, sizeof service);
|
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 */
|
} else if(strcmp(word, "ipauth") == 0) /* obsolete */
|
||||||
cp = getwrd(word, cp);
|
cp = getwrd(word, cp);
|
||||||
else if(astrcmp(word, "ip") == 0) /* obsolete */
|
else if(astrcmp(word, "ip") == 0) /* obsolete */
|
||||||
|
@ -579,7 +583,10 @@ start:
|
||||||
if(fs->conf && fs->conf[0] != '\0')
|
if(fs->conf && fs->conf[0] != '\0')
|
||||||
cp = seprint(cp, ep, "filsys %s %s\n", fs->name,
|
cp = seprint(cp, ep, "filsys %s %s\n", fs->name,
|
||||||
fs->conf);
|
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++)
|
for (fsp = fspar; fsp->name != nil; fsp++)
|
||||||
cp = seprint(cp, ep, "%s %ld\n",
|
cp = seprint(cp, ep, "%s %ld\n",
|
||||||
fsp->name, fsp->declared);
|
fsp->name, fsp->declared);
|
||||||
|
@ -954,12 +961,6 @@ arginit(void)
|
||||||
querychanger(iconfig(word));
|
querychanger(iconfig(word));
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
if(strcmp(word, "allow") == 0) {
|
|
||||||
wstatallow = 1;
|
|
||||||
writeallow = 1;
|
|
||||||
continue;
|
|
||||||
}
|
|
||||||
if(strcmp(word, "copyworm") == 0) {
|
if(strcmp(word, "copyworm") == 0) {
|
||||||
copyworm = 1;
|
copyworm = 1;
|
||||||
continue;
|
continue;
|
||||||
|
@ -976,16 +977,18 @@ arginit(void)
|
||||||
copydev = 1;
|
copydev = 1;
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
if(strcmp(word, "noauth") == 0) {
|
|
||||||
noauth = !noauth;
|
|
||||||
continue;
|
|
||||||
}
|
|
||||||
if(strcmp(word, "noattach") == 0) {
|
if(strcmp(word, "noattach") == 0) {
|
||||||
noattach = !noattach;
|
noattach = !noattach;
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
if(strcmp(word, "noauth") == 0) {
|
||||||
|
noauth = !noauth;
|
||||||
|
f.modconf = 1;
|
||||||
|
continue;
|
||||||
|
}
|
||||||
if(strcmp(word, "readonly") == 0) {
|
if(strcmp(word, "readonly") == 0) {
|
||||||
readonly = 1;
|
readonly = !readonly;
|
||||||
|
f.modconf = 1;
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -1,5 +1,4 @@
|
||||||
#include "all.h"
|
#include "all.h"
|
||||||
|
|
||||||
#include "9p1.h"
|
#include "9p1.h"
|
||||||
|
|
||||||
void
|
void
|
||||||
|
|
|
@ -44,9 +44,7 @@ struct Network {
|
||||||
|
|
||||||
static Network netif[Maxnets];
|
static Network netif[Maxnets];
|
||||||
|
|
||||||
char *annstrs[Maxnets] = {
|
char *annstrs[Maxnets];
|
||||||
"tcp!*!9fs",
|
|
||||||
};
|
|
||||||
|
|
||||||
static void
|
static void
|
||||||
neti(void *v)
|
neti(void *v)
|
||||||
|
|
Loading…
Reference in a new issue