cpu: add -n flag for the remote site to allow "none" authentification method (inspired from sources cpu-noauth patch)

This commit is contained in:
cinap_lenrek 2013-12-05 22:39:43 +01:00
parent 919863dab3
commit 5c000bbe63
2 changed files with 24 additions and 2 deletions

View file

@ -30,6 +30,8 @@ cpu \- connection to CPU server
.PP .PP
.B cpu .B cpu
[ [
.B -n
] [
.B -A .B -A
.I address .I address
] [ ] [
@ -127,6 +129,11 @@ back to
This is used if the local host is in a different protection domain than This is used if the local host is in a different protection domain than
the server or if the user wants to log into the server as a different the server or if the user wants to log into the server as a different
user. user.
.TP
.B none
This skips authentication. This requires the
.IR -n
flag to be specified on the remote side.
.PD .PD
.PP .PP
The The
@ -181,6 +188,16 @@ flag is similar but simulates the pre-9P2000 version
of the of the
.I cpu .I cpu
protocol. protocol.
The
.B -n
option allows using the
.B none
authentication method for incoming connections and must be
specified before the
.B -R
and
.B -O
flags.
.PP .PP
The The
.B -p .B -p

View file

@ -30,6 +30,7 @@ int notechan;
int exportpid; int exportpid;
char *system; char *system;
int cflag; int cflag;
int nflag;
int dbg; int dbg;
char *user; char *user;
char *patternfile; char *patternfile;
@ -59,7 +60,7 @@ struct AuthMethod {
{ {
{ "p9", p9auth, srvp9auth,}, { "p9", p9auth, srvp9auth,},
{ "netkey", netkeyauth, netkeysrvauth,}, { "netkey", netkeyauth, netkeysrvauth,},
// { "none", noauth, srvnoauth,}, { "none", noauth, srvnoauth,},
{ nil, nil} { nil, nil}
}; };
AuthMethod *am = authmethod; /* default is p9 */ AuthMethod *am = authmethod; /* default is p9 */
@ -176,6 +177,10 @@ main(int argc, char **argv)
case 'f': case 'f':
/* ignored but accepted for compatibility */ /* ignored but accepted for compatibility */
break; break;
case 'n':
/* must be specified before -R/-O */
nflag++;
break;
case 'A': case 'A':
anstring = EARGF(usage()); anstring = EARGF(usage());
break; break;
@ -349,7 +354,7 @@ remoteside(int old)
if(n < 0) if(n < 0)
fatal("authenticating: %r"); fatal("authenticating: %r");
} }
if(setamalg(cmd) < 0){ if(setamalg(cmd) < 0 || (nflag == 0 && am->sf == srvnoauth)) {
writestr(fd, "unsupported auth method", nil, 0); writestr(fd, "unsupported auth method", nil, 0);
fatal("bad auth method %s", cmd); fatal("bad auth method %s", cmd);
} else } else