summaryrefslogtreecommitdiff
path: root/mux.c
diff options
context:
space:
mode:
authordjm@openbsd.org <djm@openbsd.org>2018-09-26 01:48:57 +0000
committerDamien Miller <djm@mindrot.org>2018-09-26 11:50:28 +1000
commit9d883a1ce4f89b175fd77405ff32674620703fb2 (patch)
tree3ecb8b9dcf54d6fee63b1978e2e9db5d6dd8d770 /mux.c
parentc2fa53cd6462da82d3a851dc3a4a3f6b920337c8 (diff)
upstream: s/process_mux_master/mux_master_process/ in mux master
function names, Gives better symmetry with the existing mux_client_*() names and makes it more obvious when a message comes from the master vs client (they are interleved in ControlMaster=auto mode). no functional change beyond prefixing a could of log messages with __func__ where they were previously lacking. OpenBSD-Commit-ID: b01f7c3fdf92692e1713a822a89dc499333daf75
Diffstat (limited to 'mux.c')
-rw-r--r--mux.c74
1 files changed, 38 insertions, 36 deletions
diff --git a/mux.c b/mux.c
index e607acd08..f472cdd29 100644
--- a/mux.c
+++ b/mux.c
@@ -1,4 +1,4 @@
1/* $OpenBSD: mux.c,v 1.75 2018/07/31 03:07:24 djm Exp $ */ 1/* $OpenBSD: mux.c,v 1.76 2018/09/26 01:48:57 djm Exp $ */
2/* 2/*
3 * Copyright (c) 2002-2008 Damien Miller <djm@openbsd.org> 3 * Copyright (c) 2002-2008 Damien Miller <djm@openbsd.org>
4 * 4 *
@@ -164,23 +164,23 @@ struct mux_master_state {
164static void mux_session_confirm(struct ssh *, int, int, void *); 164static void mux_session_confirm(struct ssh *, int, int, void *);
165static void mux_stdio_confirm(struct ssh *, int, int, void *); 165static void mux_stdio_confirm(struct ssh *, int, int, void *);
166 166
167static int process_mux_master_hello(struct ssh *, u_int, 167static int mux_master_process_hello(struct ssh *, u_int,
168 Channel *, struct sshbuf *, struct sshbuf *); 168 Channel *, struct sshbuf *, struct sshbuf *);
169static int process_mux_new_session(struct ssh *, u_int, 169static int mux_master_process_new_session(struct ssh *, u_int,
170 Channel *, struct sshbuf *, struct sshbuf *); 170 Channel *, struct sshbuf *, struct sshbuf *);
171static int process_mux_alive_check(struct ssh *, u_int, 171static int mux_master_process_alive_check(struct ssh *, u_int,
172 Channel *, struct sshbuf *, struct sshbuf *); 172 Channel *, struct sshbuf *, struct sshbuf *);
173static int process_mux_terminate(struct ssh *, u_int, 173static int mux_master_process_terminate(struct ssh *, u_int,
174 Channel *, struct sshbuf *, struct sshbuf *); 174 Channel *, struct sshbuf *, struct sshbuf *);
175static int process_mux_open_fwd(struct ssh *, u_int, 175static int mux_master_process_open_fwd(struct ssh *, u_int,
176 Channel *, struct sshbuf *, struct sshbuf *); 176 Channel *, struct sshbuf *, struct sshbuf *);
177static int process_mux_close_fwd(struct ssh *, u_int, 177static int mux_master_process_close_fwd(struct ssh *, u_int,
178 Channel *, struct sshbuf *, struct sshbuf *); 178 Channel *, struct sshbuf *, struct sshbuf *);
179static int process_mux_stdio_fwd(struct ssh *, u_int, 179static int mux_master_process_stdio_fwd(struct ssh *, u_int,
180 Channel *, struct sshbuf *, struct sshbuf *); 180 Channel *, struct sshbuf *, struct sshbuf *);
181static int process_mux_stop_listening(struct ssh *, u_int, 181static int mux_master_process_stop_listening(struct ssh *, u_int,
182 Channel *, struct sshbuf *, struct sshbuf *); 182 Channel *, struct sshbuf *, struct sshbuf *);
183static int process_mux_proxy(struct ssh *, u_int, 183static int mux_master_process_proxy(struct ssh *, u_int,
184 Channel *, struct sshbuf *, struct sshbuf *); 184 Channel *, struct sshbuf *, struct sshbuf *);
185 185
186static const struct { 186static const struct {
@@ -188,15 +188,15 @@ static const struct {
188 int (*handler)(struct ssh *, u_int, Channel *, 188 int (*handler)(struct ssh *, u_int, Channel *,
189 struct sshbuf *, struct sshbuf *); 189 struct sshbuf *, struct sshbuf *);
190} mux_master_handlers[] = { 190} mux_master_handlers[] = {
191 { MUX_MSG_HELLO, process_mux_master_hello }, 191 { MUX_MSG_HELLO, mux_master_process_hello },
192 { MUX_C_NEW_SESSION, process_mux_new_session }, 192 { MUX_C_NEW_SESSION, mux_master_process_new_session },
193 { MUX_C_ALIVE_CHECK, process_mux_alive_check }, 193 { MUX_C_ALIVE_CHECK, mux_master_process_alive_check },
194 { MUX_C_TERMINATE, process_mux_terminate }, 194 { MUX_C_TERMINATE, mux_master_process_terminate },
195 { MUX_C_OPEN_FWD, process_mux_open_fwd }, 195 { MUX_C_OPEN_FWD, mux_master_process_open_fwd },
196 { MUX_C_CLOSE_FWD, process_mux_close_fwd }, 196 { MUX_C_CLOSE_FWD, mux_master_process_close_fwd },
197 { MUX_C_NEW_STDIO_FWD, process_mux_stdio_fwd }, 197 { MUX_C_NEW_STDIO_FWD, mux_master_process_stdio_fwd },
198 { MUX_C_STOP_LISTENING, process_mux_stop_listening }, 198 { MUX_C_STOP_LISTENING, mux_master_process_stop_listening },
199 { MUX_C_PROXY, process_mux_proxy }, 199 { MUX_C_PROXY, mux_master_process_proxy },
200 { 0, NULL } 200 { 0, NULL }
201}; 201};
202 202
@@ -264,7 +264,7 @@ env_permitted(char *env)
264 return 0; 264 return 0;
265 ret = snprintf(name, sizeof(name), "%.*s", (int)(cp - env), env); 265 ret = snprintf(name, sizeof(name), "%.*s", (int)(cp - env), env);
266 if (ret <= 0 || (size_t)ret >= sizeof(name)) { 266 if (ret <= 0 || (size_t)ret >= sizeof(name)) {
267 error("env_permitted: name '%.100s...' too long", env); 267 error("%s: name '%.100s...' too long", __func__, env);
268 return 0; 268 return 0;
269 } 269 }
270 270
@@ -278,7 +278,7 @@ env_permitted(char *env)
278/* Mux master protocol message handlers */ 278/* Mux master protocol message handlers */
279 279
280static int 280static int
281process_mux_master_hello(struct ssh *ssh, u_int rid, 281mux_master_process_hello(struct ssh *ssh, u_int rid,
282 Channel *c, struct sshbuf *m, struct sshbuf *reply) 282 Channel *c, struct sshbuf *m, struct sshbuf *reply)
283{ 283{
284 u_int ver; 284 u_int ver;
@@ -296,8 +296,8 @@ process_mux_master_hello(struct ssh *ssh, u_int rid,
296 return -1; 296 return -1;
297 } 297 }
298 if (ver != SSHMUX_VER) { 298 if (ver != SSHMUX_VER) {
299 error("Unsupported multiplexing protocol version %d " 299 error("%s: unsupported multiplexing protocol version %u "
300 "(expected %d)", ver, SSHMUX_VER); 300 "(expected %u)", __func__, ver, SSHMUX_VER);
301 return -1; 301 return -1;
302 } 302 }
303 debug2("%s: channel %d slave version %u", __func__, c->self, ver); 303 debug2("%s: channel %d slave version %u", __func__, c->self, ver);
@@ -305,14 +305,16 @@ process_mux_master_hello(struct ssh *ssh, u_int rid,
305 /* No extensions are presently defined */ 305 /* No extensions are presently defined */
306 while (sshbuf_len(m) > 0) { 306 while (sshbuf_len(m) > 0) {
307 char *name = NULL; 307 char *name = NULL;
308 size_t value_len = 0;
308 309
309 if ((r = sshbuf_get_cstring(m, &name, NULL)) != 0 || 310 if ((r = sshbuf_get_cstring(m, &name, NULL)) != 0 ||
310 (r = sshbuf_skip_string(m)) != 0) { /* value */ 311 (r = sshbuf_get_string_direct(m, NULL, &value_len)) != 0) {
311 error("%s: malformed extension: %s", 312 error("%s: malformed extension: %s",
312 __func__, ssh_err(r)); 313 __func__, ssh_err(r));
313 return -1; 314 return -1;
314 } 315 }
315 debug2("Unrecognised slave extension \"%s\"", name); 316 debug2("%s: Unrecognised extension \"%s\" length %zu",
317 __func__, name, value_len);
316 free(name); 318 free(name);
317 } 319 }
318 state->hello_rcvd = 1; 320 state->hello_rcvd = 1;
@@ -343,7 +345,7 @@ reply_error(struct sshbuf *reply, u_int type, u_int rid, const char *msg)
343} 345}
344 346
345static int 347static int
346process_mux_new_session(struct ssh *ssh, u_int rid, 348mux_master_process_new_session(struct ssh *ssh, u_int rid,
347 Channel *c, struct sshbuf *m, struct sshbuf *reply) 349 Channel *c, struct sshbuf *m, struct sshbuf *reply)
348{ 350{
349 Channel *nc; 351 Channel *nc;
@@ -391,8 +393,8 @@ process_mux_new_session(struct ssh *ssh, u_int rid,
391 cctx->env[env_len++] = cp; 393 cctx->env[env_len++] = cp;
392 cctx->env[env_len] = NULL; 394 cctx->env[env_len] = NULL;
393 if (env_len > MUX_MAX_ENV_VARS) { 395 if (env_len > MUX_MAX_ENV_VARS) {
394 error(">%d environment variables received, ignoring " 396 error("%s: >%d environment variables received, "
395 "additional", MUX_MAX_ENV_VARS); 397 "ignoring additional", __func__, MUX_MAX_ENV_VARS);
396 break; 398 break;
397 } 399 }
398 } 400 }
@@ -509,7 +511,7 @@ process_mux_new_session(struct ssh *ssh, u_int rid,
509} 511}
510 512
511static int 513static int
512process_mux_alive_check(struct ssh *ssh, u_int rid, 514mux_master_process_alive_check(struct ssh *ssh, u_int rid,
513 Channel *c, struct sshbuf *m, struct sshbuf *reply) 515 Channel *c, struct sshbuf *m, struct sshbuf *reply)
514{ 516{
515 int r; 517 int r;
@@ -526,7 +528,7 @@ process_mux_alive_check(struct ssh *ssh, u_int rid,
526} 528}
527 529
528static int 530static int
529process_mux_terminate(struct ssh *ssh, u_int rid, 531mux_master_process_terminate(struct ssh *ssh, u_int rid,
530 Channel *c, struct sshbuf *m, struct sshbuf *reply) 532 Channel *c, struct sshbuf *m, struct sshbuf *reply)
531{ 533{
532 debug2("%s: channel %d: terminate request", __func__, c->self); 534 debug2("%s: channel %d: terminate request", __func__, c->self);
@@ -694,7 +696,7 @@ mux_confirm_remote_forward(struct ssh *ssh, int type, u_int32_t seq, void *ctxt)
694} 696}
695 697
696static int 698static int
697process_mux_open_fwd(struct ssh *ssh, u_int rid, 699mux_master_process_open_fwd(struct ssh *ssh, u_int rid,
698 Channel *c, struct sshbuf *m, struct sshbuf *reply) 700 Channel *c, struct sshbuf *m, struct sshbuf *reply)
699{ 701{
700 struct Forward fwd; 702 struct Forward fwd;
@@ -823,7 +825,7 @@ process_mux_open_fwd(struct ssh *ssh, u_int rid,
823 if (!channel_setup_local_fwd_listener(ssh, &fwd, 825 if (!channel_setup_local_fwd_listener(ssh, &fwd,
824 &options.fwd_opts)) { 826 &options.fwd_opts)) {
825 fail: 827 fail:
826 logit("slave-requested %s failed", fwd_desc); 828 logit("%s: requested %s failed", __func__, fwd_desc);
827 reply_error(reply, MUX_S_FAILURE, rid, 829 reply_error(reply, MUX_S_FAILURE, rid,
828 "Port forwarding failed"); 830 "Port forwarding failed");
829 goto out; 831 goto out;
@@ -861,7 +863,7 @@ process_mux_open_fwd(struct ssh *ssh, u_int rid,
861} 863}
862 864
863static int 865static int
864process_mux_close_fwd(struct ssh *ssh, u_int rid, 866mux_master_process_close_fwd(struct ssh *ssh, u_int rid,
865 Channel *c, struct sshbuf *m, struct sshbuf *reply) 867 Channel *c, struct sshbuf *m, struct sshbuf *reply)
866{ 868{
867 struct Forward fwd, *found_fwd; 869 struct Forward fwd, *found_fwd;
@@ -973,7 +975,7 @@ process_mux_close_fwd(struct ssh *ssh, u_int rid,
973} 975}
974 976
975static int 977static int
976process_mux_stdio_fwd(struct ssh *ssh, u_int rid, 978mux_master_process_stdio_fwd(struct ssh *ssh, u_int rid,
977 Channel *c, struct sshbuf *m, struct sshbuf *reply) 979 Channel *c, struct sshbuf *m, struct sshbuf *reply)
978{ 980{
979 Channel *nc; 981 Channel *nc;
@@ -1111,7 +1113,7 @@ mux_stdio_confirm(struct ssh *ssh, int id, int success, void *arg)
1111} 1113}
1112 1114
1113static int 1115static int
1114process_mux_stop_listening(struct ssh *ssh, u_int rid, 1116mux_master_process_stop_listening(struct ssh *ssh, u_int rid,
1115 Channel *c, struct sshbuf *m, struct sshbuf *reply) 1117 Channel *c, struct sshbuf *m, struct sshbuf *reply)
1116{ 1118{
1117 debug("%s: channel %d: stop listening", __func__, c->self); 1119 debug("%s: channel %d: stop listening", __func__, c->self);
@@ -1141,7 +1143,7 @@ process_mux_stop_listening(struct ssh *ssh, u_int rid,
1141} 1143}
1142 1144
1143static int 1145static int
1144process_mux_proxy(struct ssh *ssh, u_int rid, 1146mux_master_process_proxy(struct ssh *ssh, u_int rid,
1145 Channel *c, struct sshbuf *m, struct sshbuf *reply) 1147 Channel *c, struct sshbuf *m, struct sshbuf *reply)
1146{ 1148{
1147 int r; 1149 int r;