]> git.lizzy.rs Git - plan9front.git/blobdiff - sys/src/cmd/ssh.c
ip/ipconfig: format ipmask with %M instead of %I
[plan9front.git] / sys / src / cmd / ssh.c
index 51514aa801371c67dfb5e1af329f6df4bb344763..92d8d27b5d0340a1c42ec2ca824fed014193f6d9 100644 (file)
@@ -110,8 +110,6 @@ wasintr(void)
        char err[ERRMAX];
        int r;
 
-       if(intr)
-               return 1;
        memset(err, 0, sizeof(err));
        errstr(err, sizeof(err));
        r = strcmp(err, "interrupted") == 0;
@@ -963,7 +961,14 @@ dispatch(void)
 
        switch(recv.r[0]){
        case MSG_IGNORE:
+               return;
        case MSG_GLOBAL_REQUEST:
+               if(unpack(recv.r, recv.w-recv.r, "_sb", &s, &n, &b) < 0)
+                       break;
+               if(debug)
+                       fprint(2, "%s: global request: %.*s\n", argv0, n, s);
+               if(b != 0)
+                       sendpkt("b", MSG_REQUEST_FAILURE);
                return;
        case MSG_DISCONNECT:
                if(unpack(recv.r, recv.w-recv.r, "_us", &c, &s, &n) < 0)
@@ -1021,14 +1026,20 @@ dispatch(void)
                                break;
                        if(n != 0 && status == nil)
                                status = smprint("%.*s", n, s);
+                       c = MSG_CHANNEL_SUCCESS;
                } else if(n == 11 && memcmp(s, "exit-status", n) == 0){
                        if(unpack(p, recv.w-p, "u", &n) < 0)
                                break;
                        if(n != 0 && status == nil)
                                status = smprint("%d", n);
-               } else if(debug) {
-                       fprint(2, "%s: channel request: %.*s\n", argv0, n, s);
+                       c = MSG_CHANNEL_SUCCESS;
+               } else {
+                       if(debug)
+                               fprint(2, "%s: channel request: %.*s\n", argv0, n, s);
+                       c = MSG_CHANNEL_FAILURE;
                }
+               if(b != 0)
+                       sendpkt("bu", c, recv.chan);
                return;
        case MSG_CHANNEL_EOF:
                recv.eof = 1;
@@ -1331,25 +1342,25 @@ Next1:  switch(recvpkt()){
                qlock(&sl);
                if(send.eof)
                        break;
-               if(n < 0 && wasintr()){
+               if(n < 0 && wasintr())
+                       intr = 1;
+               if(intr){
                        if(!raw) break;
-                       if(intr){
-                               getdim();
-                               sendpkt("busbuuuu", MSG_CHANNEL_REQUEST,
-                                       send.chan,
-                                       "window-change", 13,
-                                       0,
-                                       tty.cols,
-                                       tty.lines,
-                                       tty.xpixels,
-                                       tty.ypixels);
-                               sendpkt("busbs", MSG_CHANNEL_REQUEST,
-                                       send.chan,
-                                       "signal", 6,
-                                       0,
-                                       "INT", 3);
-                               intr = 0;
-                       }
+                       getdim();
+                       sendpkt("busbuuuu", MSG_CHANNEL_REQUEST,
+                               send.chan,
+                               "window-change", 13,
+                               0,
+                               tty.cols,
+                               tty.lines,
+                               tty.xpixels,
+                               tty.ypixels);
+                       sendpkt("busbs", MSG_CHANNEL_REQUEST,
+                               send.chan,
+                               "signal", 6,
+                               0,
+                               "INT", 3);
+                       intr = 0;
                        continue;
                }
                if(n <= 0)