9pserve: add -n flag to reject auth by clients

This commit is contained in:
Russ Cox 2007-10-12 12:55:19 -04:00
parent 4ff6950783
commit 9b25329723
2 changed files with 15 additions and 2 deletions

View file

@ -4,7 +4,7 @@
.SH SYNOPSIS .SH SYNOPSIS
.B 9pserve .B 9pserve
[ [
.B -lv .B -lnv
] ]
[ [
.B -A .B -A
@ -55,6 +55,11 @@ The options are:
logging; write a debugging log to logging; write a debugging log to
.IB addr .log \fR. .IB addr .log \fR.
.TP .TP
.B -n
no authentication; respond to Tauth
messages with an error (see
.IR attach (9P)).
.TP
.B -v .B -v
verbose; more verbose when repeated verbose; more verbose when repeated
.TP .TP

View file

@ -92,6 +92,7 @@ u32int xafid = NOFID;
int attached; int attached;
int versioned; int versioned;
int dotu; int dotu;
int noauth;
void *gethash(Hash**, uint); void *gethash(Hash**, uint);
int puthash(Hash**, uint, void*); int puthash(Hash**, uint, void*);
@ -135,7 +136,7 @@ int cvtustat(Fcall*, uchar**, int);
void void
usage(void) usage(void)
{ {
fprint(2, "usage: 9pserve [-lv] [-A aname afid] [-M msize] address\n"); fprint(2, "usage: 9pserve [-lnv] [-A aname afid] [-M msize] address\n");
fprint(2, "\treads/writes 9P messages on stdin/stdout\n"); fprint(2, "\treads/writes 9P messages on stdin/stdout\n");
threadexitsall("usage"); threadexitsall("usage");
} }
@ -165,6 +166,9 @@ threadmain(int argc, char **argv)
versioned = 1; versioned = 1;
msize = atoi(EARGF(usage())); msize = atoi(EARGF(usage()));
break; break;
case 'n':
noauth = 1;
break;
case 'v': case 'v':
verbose++; verbose++;
break; break;
@ -450,6 +454,10 @@ connthread(void *arg)
err(m, "authentication not required"); err(m, "authentication not required");
continue; continue;
} }
if(noauth){
err(m, "authentication rejected");
continue;
}
m->afid = fidnew(m->tx.afid); m->afid = fidnew(m->tx.afid);
if(puthash(c->fid, m->tx.afid, m->afid) < 0){ if(puthash(c->fid, m->tx.afid, m->afid) < 0){
err(m, "duplicate fid"); err(m, "duplicate fid");