t9pserve: add -n flag to reject auth by clients - plan9port - [fork] Plan 9 from user space
git clone git://src.adamsgaard.dk/plan9port
Log
Files
Refs
README
LICENSE
---
commit 9b25329723e3284db7b060bbb301a139b8f2ace1
parent 4ff69507837bb2501cba25dfa219c252333cc185
Author: Russ Cox 
Date:   Fri, 12 Oct 2007 12:55:19 -0400

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

Diffstat:
  M man/man4/9pserve.4                  |       7 ++++++-
  M src/cmd/9pserve.c                   |      10 +++++++++-

2 files changed, 15 insertions(+), 2 deletions(-)
---
diff --git a/man/man4/9pserve.4 b/man/man4/9pserve.4
t@@ -4,7 +4,7 @@
 .SH SYNOPSIS
 .B 9pserve
 [
-.B -lv
+.B -lnv
 ]
 [
 .B -A
t@@ -55,6 +55,11 @@ The options are:
 logging; write a debugging log to
 .IB addr .log \fR.
 .TP
+.B -n
+no authentication; respond to Tauth
+messages with an error (see 
+.IR attach (9P)).
+.TP
 .B -v
 verbose; more verbose when repeated
 .TP
diff --git a/src/cmd/9pserve.c b/src/cmd/9pserve.c
t@@ -92,6 +92,7 @@ u32int xafid = NOFID;
 int attached;
 int versioned;
 int dotu;
+int noauth;
 
 void *gethash(Hash**, uint);
 int puthash(Hash**, uint, void*);
t@@ -135,7 +136,7 @@ int cvtustat(Fcall*, uchar**, int);
 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");
         threadexitsall("usage");
 }
t@@ -165,6 +166,9 @@ threadmain(int argc, char **argv)
                 versioned = 1;
                 msize = atoi(EARGF(usage()));
                 break;
+        case 'n':
+                noauth = 1;
+                break;
         case 'v':
                 verbose++;
                 break;
t@@ -450,6 +454,10 @@ connthread(void *arg)
                                 err(m, "authentication not required");
                                 continue;
                         }
+                        if(noauth){
+                                err(m, "authentication rejected");
+                                continue;
+                        }
                         m->afid = fidnew(m->tx.afid);
                         if(puthash(c->fid, m->tx.afid, m->afid) < 0){
                                 err(m, "duplicate fid");