From 950706198644c4715efbc95ec79857fd4fa55353 Mon Sep 17 00:00:00 2001 From: cinap_lenrek Date: Fri, 7 Dec 2012 09:53:08 +0100 Subject: cwfs: allow previously authorized channels to attach as none we allow allow previously authorized channels to attach as none even if anonymous logins are disabled with nonone. --- sys/src/cmd/cwfs/9p1.c | 4 +++- sys/src/cmd/cwfs/9p2.c | 6 +++++- sys/src/cmd/cwfs/portdat.h | 1 + sys/src/cmd/cwfs/srv.c | 1 + 4 files changed, 10 insertions(+), 2 deletions(-) (limited to 'sys/src/cmd/cwfs') diff --git a/sys/src/cmd/cwfs/9p1.c b/sys/src/cmd/cwfs/9p1.c index 2517f086e..3c9a0a190 100644 --- a/sys/src/cmd/cwfs/9p1.c +++ b/sys/src/cmd/cwfs/9p1.c @@ -82,7 +82,7 @@ authorize(Chan *cp, Fcall *in, Fcall *ou) return 1; if(strcmp(in->uname, "none") == 0) - return !nonone; + return !nonone || cp->authok; if(in->type == Toattach) return 0; @@ -145,6 +145,8 @@ authorize(Chan *cp, Fcall *in, Fcall *ou) memmove(a.chal, aip->rchal, CHALLEN); convA2M9p1(&a, ou->rauth, t.key); + cp->authok = 1; + return 1; } diff --git a/sys/src/cmd/cwfs/9p2.c b/sys/src/cmd/cwfs/9p2.c index 692dcdceb..8c34691f5 100644 --- a/sys/src/cmd/cwfs/9p2.c +++ b/sys/src/cmd/cwfs/9p2.c @@ -209,7 +209,7 @@ authorize(Chan* chan, Fcall* f) return uid; } - if(f->afid == NOFID && !nonone){ + if(f->afid == NOFID && (!nonone || chan->authok)){ uid = strtouid(f->uname); if(db) fprint(2, "permission granted to none: uid %s = %d\n", @@ -230,6 +230,10 @@ authorize(Chan* chan, Fcall* f) if(db) fprint(2, "authorize: uid is %d\n", uid); qunlock(af); + + if(uid > 0) + chan->authok = 1; + return uid; } diff --git a/sys/src/cmd/cwfs/portdat.h b/sys/src/cmd/cwfs/portdat.h index fba14dbbe..d2af352e0 100644 --- a/sys/src/cmd/cwfs/portdat.h +++ b/sys/src/cmd/cwfs/portdat.h @@ -263,6 +263,7 @@ struct Chan Queue* send; Queue* reply; + int authok; uchar authinfo[64]; void* pdata; /* sometimes is a Netconn* */ diff --git a/sys/src/cmd/cwfs/srv.c b/sys/src/cmd/cwfs/srv.c index 813ac8337..f05aabc87 100644 --- a/sys/src/cmd/cwfs/srv.c +++ b/sys/src/cmd/cwfs/srv.c @@ -182,6 +182,7 @@ srvchan(int fd, char *name) chan->msize = 0; chan->whotime = 0; snprint(chan->whochan, sizeof(chan->whochan), "%s", name); + chan->authok = 0; incref(srv); srv->chan = chan; -- cgit v1.2.3