tsrv: add -n flag to reject auth by clients - plan9port - [fork] Plan 9 from user space
 (HTM) git clone git://src.adamsgaard.dk/plan9port
 (DIR) Log
 (DIR) Files
 (DIR) Refs
 (DIR) README
 (DIR) LICENSE
       ---
 (DIR) commit 151b86a03703255445a2165f714e914032f6c4a8
 (DIR) parent 9b25329723e3284db7b060bbb301a139b8f2ace1
 (HTM) Author: Russ Cox <rsc@swtch.com>
       Date:   Fri, 12 Oct 2007 12:56:57 -0400
       
       srv: add -n flag to reject auth by clients
       
       Diffstat:
         M man/man4/srv.4                      |      10 +++++++++-
         M src/cmd/srv.c                       |      12 ++++++++----
       
       2 files changed, 17 insertions(+), 5 deletions(-)
       ---
 (DIR) diff --git a/man/man4/srv.4 b/man/man4/srv.4
       t@@ -4,7 +4,7 @@ srv, 9fs \- start network file service
        .SH SYNOPSIS
        .B srv
        [
       -.B -a
       +.B -an
        ]
        [
        .B -k
       t@@ -37,6 +37,14 @@ to post a pre-authenticated connection to the file system
        (by default, the empty string;
        see
        .IR attach (9p)).
       +.PP
       +The 
       +.B -n
       +option causes 
       +.I srv
       +to reject authentication attempts by clients,
       +useful if the remote server is known not to require authentication.
       +.PP
        .I Srv
        authenticates over the 9P connection to establish a valid auth fid.
        .IR Keypattern ,
 (DIR) diff --git a/src/cmd/srv.c b/src/cmd/srv.c
       t@@ -41,6 +41,9 @@ threadmain(int argc, char **argv)
                case 'a':
                        doauth = 1;
                        break;
       +        case 'n':
       +                doauth = -1;
       +                break;
                case 'k':
                        keypattern = EARGF(usage());
                        break;
       t@@ -55,7 +58,7 @@ threadmain(int argc, char **argv)
                if((fd = dial(addr, nil, nil, nil)) < 0)
                        sysfatal("dial %s: %r", addr);
        
       -        if(doauth)
       +        if(doauth > 0)
                        xauth();
        
                if(argc == 2)
       t@@ -216,7 +219,7 @@ post9pservice(int fd, char *name)
                        dup(fd, 1);
                        for(i=3; i<20; i++)
                                close(i);
       -                if(doauth)
       +                if(doauth > 0)
                                execlp("9pserve", "9pserve", "-u",
                                        "-M",
                                                smprint("%d", msize),
       t@@ -224,8 +227,9 @@ post9pservice(int fd, char *name)
                                                aname,
                                                smprint("%d", afid),
                                        s, (char*)0);
       -                else                
       -                        execlp("9pserve", "9pserve", "-u", s, (char*)0);
       +                else
       +                        execlp("9pserve", "9pserve",
       +                                doauth < 0 ? "-nu" : "-u", s, (char*)0);
                        fprint(2, "exec 9pserve: %r\n");
                        _exits("exec");
                default: