ssh: print usage for unknown flags, cleanup

This commit is contained in:
cinap_lenrek 2019-04-02 19:22:19 +02:00
parent 009b624fe6
commit 6d429cf9e8

View file

@ -1157,7 +1157,7 @@ kfmt(Fmt *f)
void
usage(void)
{
fprint(2, "usage: %s [-dRX] [-t thumbfile] [-T tries] [-u user] [-h] [user@]host [-W remote!port] [cmd args...]\n", argv0);
fprint(2, "usage: %s [-dR] [-t thumbfile] [-T tries] [-u user] [-h] [user@]host [-W remote!port] [cmd args...]\n", argv0);
exits("usage");
}
@ -1217,6 +1217,8 @@ main(int argc, char *argv[])
mux = 1;
raw = 0;
break;
default:
usage();
} ARGEND;
if(host == nil){
@ -1287,7 +1289,9 @@ Next0: switch(recvpkt()){
recv.win = send.win = WinPackets*recv.pkt;
recv.chan = send.win = 0;
if(!mux){
if(mux)
goto Mux;
/* open hailing frequencies */
if(remote != nil){
NetConnInfo *nci = getnetconninfo(nil, fd);
@ -1326,33 +1330,10 @@ Next1: switch(recvpkt()){
sysfatal("bad channel open confirmation");
if(send.pkt <= 0 || send.pkt > MaxPacket)
send.pkt = MaxPacket;
}
notify(catch);
atexit(shutdown);
if(remote != nil)
goto Mux;
recv.pid = getpid();
n = rfork(RFPROC|RFMEM);
if(n < 0)
sysfatal("fork: %r");
/* parent reads and dispatches packets */
if(n > 0) {
send.pid = n;
while(recv.eof == 0){
recvpkt();
qlock(&sl);
dispatch();
if((int)(send.kex - send.seq) <= 0 || (int)(recv.kex - recv.seq) <= 0)
kex(0);
qunlock(&sl);
}
exits(status);
}
/* child reads input and sends packets */
qlock(&sl);
if(remote == nil && !mux){
if(raw) {
rawon();
sendpkt("busbsuuuus", MSG_CHANNEL_REQUEST,
@ -1384,7 +1365,32 @@ Next1: switch(recvpkt()){
0,
cmd, strlen(cmd));
}
Mux:
notify(catch);
atexit(shutdown);
recv.pid = getpid();
n = rfork(RFPROC|RFMEM);
if(n < 0)
sysfatal("fork: %r");
/* parent reads and dispatches packets */
if(n > 0) {
send.pid = n;
while(recv.eof == 0){
recvpkt();
qlock(&sl);
dispatch();
if((int)(send.kex - send.seq) <= 0 || (int)(recv.kex - recv.seq) <= 0)
kex(0);
qunlock(&sl);
}
exits(status);
}
/* child reads input and sends packets */
qlock(&sl);
for(;;){
static uchar buf[MaxPacket];
qunlock(&sl);