[BACK]Return to mux.c CVS log [TXT][DIR] Up to [local] / src / usr.bin / ssh

Diff for /src/usr.bin/ssh/mux.c between version 1.75 and 1.76

version 1.75, 2018/07/31 03:07:24 version 1.76, 2018/09/26 01:48:57
Line 151 
Line 151 
 static void mux_session_confirm(struct ssh *, int, int, void *);  static void mux_session_confirm(struct ssh *, int, int, void *);
 static void mux_stdio_confirm(struct ssh *, int, int, void *);  static void mux_stdio_confirm(struct ssh *, int, int, void *);
   
 static int process_mux_master_hello(struct ssh *, u_int,  static int mux_master_process_hello(struct ssh *, u_int,
             Channel *, struct sshbuf *, struct sshbuf *);              Channel *, struct sshbuf *, struct sshbuf *);
 static int process_mux_new_session(struct ssh *, u_int,  static int mux_master_process_new_session(struct ssh *, u_int,
             Channel *, struct sshbuf *, struct sshbuf *);              Channel *, struct sshbuf *, struct sshbuf *);
 static int process_mux_alive_check(struct ssh *, u_int,  static int mux_master_process_alive_check(struct ssh *, u_int,
             Channel *, struct sshbuf *, struct sshbuf *);              Channel *, struct sshbuf *, struct sshbuf *);
 static int process_mux_terminate(struct ssh *, u_int,  static int mux_master_process_terminate(struct ssh *, u_int,
             Channel *, struct sshbuf *, struct sshbuf *);              Channel *, struct sshbuf *, struct sshbuf *);
 static int process_mux_open_fwd(struct ssh *, u_int,  static int mux_master_process_open_fwd(struct ssh *, u_int,
             Channel *, struct sshbuf *, struct sshbuf *);              Channel *, struct sshbuf *, struct sshbuf *);
 static int process_mux_close_fwd(struct ssh *, u_int,  static int mux_master_process_close_fwd(struct ssh *, u_int,
             Channel *, struct sshbuf *, struct sshbuf *);              Channel *, struct sshbuf *, struct sshbuf *);
 static int process_mux_stdio_fwd(struct ssh *, u_int,  static int mux_master_process_stdio_fwd(struct ssh *, u_int,
             Channel *, struct sshbuf *, struct sshbuf *);              Channel *, struct sshbuf *, struct sshbuf *);
 static int process_mux_stop_listening(struct ssh *, u_int,  static int mux_master_process_stop_listening(struct ssh *, u_int,
             Channel *, struct sshbuf *, struct sshbuf *);              Channel *, struct sshbuf *, struct sshbuf *);
 static int process_mux_proxy(struct ssh *, u_int,  static int mux_master_process_proxy(struct ssh *, u_int,
             Channel *, struct sshbuf *, struct sshbuf *);              Channel *, struct sshbuf *, struct sshbuf *);
   
 static const struct {  static const struct {
Line 175 
Line 175 
         int (*handler)(struct ssh *, u_int, Channel *,          int (*handler)(struct ssh *, u_int, Channel *,
             struct sshbuf *, struct sshbuf *);              struct sshbuf *, struct sshbuf *);
 } mux_master_handlers[] = {  } mux_master_handlers[] = {
         { MUX_MSG_HELLO, process_mux_master_hello },          { MUX_MSG_HELLO, mux_master_process_hello },
         { MUX_C_NEW_SESSION, process_mux_new_session },          { MUX_C_NEW_SESSION, mux_master_process_new_session },
         { MUX_C_ALIVE_CHECK, process_mux_alive_check },          { MUX_C_ALIVE_CHECK, mux_master_process_alive_check },
         { MUX_C_TERMINATE, process_mux_terminate },          { MUX_C_TERMINATE, mux_master_process_terminate },
         { MUX_C_OPEN_FWD, process_mux_open_fwd },          { MUX_C_OPEN_FWD, mux_master_process_open_fwd },
         { MUX_C_CLOSE_FWD, process_mux_close_fwd },          { MUX_C_CLOSE_FWD, mux_master_process_close_fwd },
         { MUX_C_NEW_STDIO_FWD, process_mux_stdio_fwd },          { MUX_C_NEW_STDIO_FWD, mux_master_process_stdio_fwd },
         { MUX_C_STOP_LISTENING, process_mux_stop_listening },          { MUX_C_STOP_LISTENING, mux_master_process_stop_listening },
         { MUX_C_PROXY, process_mux_proxy },          { MUX_C_PROXY, mux_master_process_proxy },
         { 0, NULL }          { 0, NULL }
 };  };
   
Line 251 
Line 251 
                 return 0;                  return 0;
         ret = snprintf(name, sizeof(name), "%.*s", (int)(cp - env), env);          ret = snprintf(name, sizeof(name), "%.*s", (int)(cp - env), env);
         if (ret <= 0 || (size_t)ret >= sizeof(name)) {          if (ret <= 0 || (size_t)ret >= sizeof(name)) {
                 error("env_permitted: name '%.100s...' too long", env);                  error("%s: name '%.100s...' too long", __func__, env);
                 return 0;                  return 0;
         }          }
   
Line 265 
Line 265 
 /* Mux master protocol message handlers */  /* Mux master protocol message handlers */
   
 static int  static int
 process_mux_master_hello(struct ssh *ssh, u_int rid,  mux_master_process_hello(struct ssh *ssh, u_int rid,
     Channel *c, struct sshbuf *m, struct sshbuf *reply)      Channel *c, struct sshbuf *m, struct sshbuf *reply)
 {  {
         u_int ver;          u_int ver;
Line 283 
Line 283 
                 return -1;                  return -1;
         }          }
         if (ver != SSHMUX_VER) {          if (ver != SSHMUX_VER) {
                 error("Unsupported multiplexing protocol version %d "                  error("%s: unsupported multiplexing protocol version %u "
                     "(expected %d)", ver, SSHMUX_VER);                      "(expected %u)", __func__, ver, SSHMUX_VER);
                 return -1;                  return -1;
         }          }
         debug2("%s: channel %d slave version %u", __func__, c->self, ver);          debug2("%s: channel %d slave version %u", __func__, c->self, ver);
Line 292 
Line 292 
         /* No extensions are presently defined */          /* No extensions are presently defined */
         while (sshbuf_len(m) > 0) {          while (sshbuf_len(m) > 0) {
                 char *name = NULL;                  char *name = NULL;
                   size_t value_len = 0;
   
                 if ((r = sshbuf_get_cstring(m, &name, NULL)) != 0 ||                  if ((r = sshbuf_get_cstring(m, &name, NULL)) != 0 ||
                     (r = sshbuf_skip_string(m)) != 0) { /* value */                      (r = sshbuf_get_string_direct(m, NULL, &value_len)) != 0) {
                         error("%s: malformed extension: %s",                          error("%s: malformed extension: %s",
                             __func__, ssh_err(r));                              __func__, ssh_err(r));
                         return -1;                          return -1;
                 }                  }
                 debug2("Unrecognised slave extension \"%s\"", name);                  debug2("%s: Unrecognised extension \"%s\" length %zu",
                       __func__, name, value_len);
                 free(name);                  free(name);
         }          }
         state->hello_rcvd = 1;          state->hello_rcvd = 1;
Line 330 
Line 332 
 }  }
   
 static int  static int
 process_mux_new_session(struct ssh *ssh, u_int rid,  mux_master_process_new_session(struct ssh *ssh, u_int rid,
     Channel *c, struct sshbuf *m, struct sshbuf *reply)      Channel *c, struct sshbuf *m, struct sshbuf *reply)
 {  {
         Channel *nc;          Channel *nc;
Line 378 
Line 380 
                 cctx->env[env_len++] = cp;                  cctx->env[env_len++] = cp;
                 cctx->env[env_len] = NULL;                  cctx->env[env_len] = NULL;
                 if (env_len > MUX_MAX_ENV_VARS) {                  if (env_len > MUX_MAX_ENV_VARS) {
                         error(">%d environment variables received, ignoring "                          error("%s: >%d environment variables received, "
                             "additional", MUX_MAX_ENV_VARS);                              "ignoring additional", __func__, MUX_MAX_ENV_VARS);
                         break;                          break;
                 }                  }
         }          }
Line 496 
Line 498 
 }  }
   
 static int  static int
 process_mux_alive_check(struct ssh *ssh, u_int rid,  mux_master_process_alive_check(struct ssh *ssh, u_int rid,
     Channel *c, struct sshbuf *m, struct sshbuf *reply)      Channel *c, struct sshbuf *m, struct sshbuf *reply)
 {  {
         int r;          int r;
Line 513 
Line 515 
 }  }
   
 static int  static int
 process_mux_terminate(struct ssh *ssh, u_int rid,  mux_master_process_terminate(struct ssh *ssh, u_int rid,
     Channel *c, struct sshbuf *m, struct sshbuf *reply)      Channel *c, struct sshbuf *m, struct sshbuf *reply)
 {  {
         debug2("%s: channel %d: terminate request", __func__, c->self);          debug2("%s: channel %d: terminate request", __func__, c->self);
Line 681 
Line 683 
 }  }
   
 static int  static int
 process_mux_open_fwd(struct ssh *ssh, u_int rid,  mux_master_process_open_fwd(struct ssh *ssh, u_int rid,
     Channel *c, struct sshbuf *m, struct sshbuf *reply)      Channel *c, struct sshbuf *m, struct sshbuf *reply)
 {  {
         struct Forward fwd;          struct Forward fwd;
Line 810 
Line 812 
                 if (!channel_setup_local_fwd_listener(ssh, &fwd,                  if (!channel_setup_local_fwd_listener(ssh, &fwd,
                     &options.fwd_opts)) {                      &options.fwd_opts)) {
  fail:   fail:
                         logit("slave-requested %s failed", fwd_desc);                          logit("%s: requested %s failed", __func__, fwd_desc);
                         reply_error(reply, MUX_S_FAILURE, rid,                          reply_error(reply, MUX_S_FAILURE, rid,
                             "Port forwarding failed");                              "Port forwarding failed");
                         goto out;                          goto out;
Line 848 
Line 850 
 }  }
   
 static int  static int
 process_mux_close_fwd(struct ssh *ssh, u_int rid,  mux_master_process_close_fwd(struct ssh *ssh, u_int rid,
     Channel *c, struct sshbuf *m, struct sshbuf *reply)      Channel *c, struct sshbuf *m, struct sshbuf *reply)
 {  {
         struct Forward fwd, *found_fwd;          struct Forward fwd, *found_fwd;
Line 960 
Line 962 
 }  }
   
 static int  static int
 process_mux_stdio_fwd(struct ssh *ssh, u_int rid,  mux_master_process_stdio_fwd(struct ssh *ssh, u_int rid,
     Channel *c, struct sshbuf *m, struct sshbuf *reply)      Channel *c, struct sshbuf *m, struct sshbuf *reply)
 {  {
         Channel *nc;          Channel *nc;
Line 1098 
Line 1100 
 }  }
   
 static int  static int
 process_mux_stop_listening(struct ssh *ssh, u_int rid,  mux_master_process_stop_listening(struct ssh *ssh, u_int rid,
     Channel *c, struct sshbuf *m, struct sshbuf *reply)      Channel *c, struct sshbuf *m, struct sshbuf *reply)
 {  {
         debug("%s: channel %d: stop listening", __func__, c->self);          debug("%s: channel %d: stop listening", __func__, c->self);
Line 1128 
Line 1130 
 }  }
   
 static int  static int
 process_mux_proxy(struct ssh *ssh, u_int rid,  mux_master_process_proxy(struct ssh *ssh, u_int rid,
     Channel *c, struct sshbuf *m, struct sshbuf *reply)      Channel *c, struct sshbuf *m, struct sshbuf *reply)
 {  {
         int r;          int r;

Legend:
Removed from v.1.75  
changed lines
  Added in v.1.76