summaryrefslogtreecommitdiff
path: root/ssh.c
diff options
context:
space:
mode:
Diffstat (limited to 'ssh.c')
-rw-r--r--ssh.c39
1 files changed, 25 insertions, 14 deletions
diff --git a/ssh.c b/ssh.c
index 03a23fb6a..ee0b16dc2 100644
--- a/ssh.c
+++ b/ssh.c
@@ -1,4 +1,4 @@
1/* $OpenBSD: ssh.c,v 1.445 2016/07/17 04:20:16 djm Exp $ */ 1/* $OpenBSD: ssh.c,v 1.448 2016/12/06 07:48:01 djm Exp $ */
2/* 2/*
3 * Author: Tatu Ylonen <ylo@cs.hut.fi> 3 * Author: Tatu Ylonen <ylo@cs.hut.fi>
4 * Copyright (c) 1995 Tatu Ylonen <ylo@cs.hut.fi>, Espoo, Finland 4 * Copyright (c) 1995 Tatu Ylonen <ylo@cs.hut.fi>, Espoo, Finland
@@ -109,6 +109,7 @@
109#include "version.h" 109#include "version.h"
110#include "ssherr.h" 110#include "ssherr.h"
111#include "myproposal.h" 111#include "myproposal.h"
112#include "utf8.h"
112 113
113#ifdef ENABLE_PKCS11 114#ifdef ENABLE_PKCS11
114#include "ssh-pkcs11.h" 115#include "ssh-pkcs11.h"
@@ -213,10 +214,6 @@ static int ssh_session2(void);
213static void load_public_identity_files(void); 214static void load_public_identity_files(void);
214static void main_sigchld_handler(int); 215static void main_sigchld_handler(int);
215 216
216/* from muxclient.c */
217void muxclient(const char *);
218void muxserver_listen(void);
219
220/* ~/ expand a list of paths. NB. assumes path[n] is heap-allocated. */ 217/* ~/ expand a list of paths. NB. assumes path[n] is heap-allocated. */
221static void 218static void
222tilde_expand_paths(char **paths, u_int num_paths) 219tilde_expand_paths(char **paths, u_int num_paths)
@@ -593,7 +590,7 @@ main(int ac, char **av)
593 */ 590 */
594 umask(022); 591 umask(022);
595 592
596 setlocale(LC_CTYPE, ""); 593 msetlocale();
597 594
598 /* 595 /*
599 * Initialize option structure to indicate that no values have been 596 * Initialize option structure to indicate that no values have been
@@ -668,6 +665,8 @@ main(int ac, char **av)
668 muxclient_command = SSHMUX_COMMAND_STOP; 665 muxclient_command = SSHMUX_COMMAND_STOP;
669 else if (strcmp(optarg, "cancel") == 0) 666 else if (strcmp(optarg, "cancel") == 0)
670 muxclient_command = SSHMUX_COMMAND_CANCEL_FWD; 667 muxclient_command = SSHMUX_COMMAND_CANCEL_FWD;
668 else if (strcmp(optarg, "proxy") == 0)
669 muxclient_command = SSHMUX_COMMAND_PROXY;
671 else 670 else
672 fatal("Invalid multiplex command."); 671 fatal("Invalid multiplex command.");
673 break; 672 break;
@@ -685,11 +684,11 @@ main(int ac, char **av)
685 else if (strcmp(optarg, "kex") == 0) 684 else if (strcmp(optarg, "kex") == 0)
686 cp = kex_alg_list('\n'); 685 cp = kex_alg_list('\n');
687 else if (strcmp(optarg, "key") == 0) 686 else if (strcmp(optarg, "key") == 0)
688 cp = key_alg_list(0, 0); 687 cp = sshkey_alg_list(0, 0, '\n');
689 else if (strcmp(optarg, "key-cert") == 0) 688 else if (strcmp(optarg, "key-cert") == 0)
690 cp = key_alg_list(1, 0); 689 cp = sshkey_alg_list(1, 0, '\n');
691 else if (strcmp(optarg, "key-plain") == 0) 690 else if (strcmp(optarg, "key-plain") == 0)
692 cp = key_alg_list(0, 1); 691 cp = sshkey_alg_list(0, 1, '\n');
693 else if (strcmp(optarg, "protocol-version") == 0) { 692 else if (strcmp(optarg, "protocol-version") == 0) {
694#ifdef WITH_SSH1 693#ifdef WITH_SSH1
695 cp = xstrdup("1\n2"); 694 cp = xstrdup("1\n2");
@@ -1162,7 +1161,8 @@ main(int ac, char **av)
1162 tty_flag = options.request_tty != REQUEST_TTY_NO; 1161 tty_flag = options.request_tty != REQUEST_TTY_NO;
1163 1162
1164 /* Force no tty */ 1163 /* Force no tty */
1165 if (options.request_tty == REQUEST_TTY_NO || muxclient_command != 0) 1164 if (options.request_tty == REQUEST_TTY_NO ||
1165 (muxclient_command && muxclient_command != SSHMUX_COMMAND_PROXY))
1166 tty_flag = 0; 1166 tty_flag = 0;
1167 /* Do not allocate a tty if stdin is not a tty. */ 1167 /* Do not allocate a tty if stdin is not a tty. */
1168 if ((!isatty(fileno(stdin)) || stdin_null_flag) && 1168 if ((!isatty(fileno(stdin)) || stdin_null_flag) &&
@@ -1239,8 +1239,16 @@ main(int ac, char **av)
1239 1239
1240 if (muxclient_command != 0 && options.control_path == NULL) 1240 if (muxclient_command != 0 && options.control_path == NULL)
1241 fatal("No ControlPath specified for \"-O\" command"); 1241 fatal("No ControlPath specified for \"-O\" command");
1242 if (options.control_path != NULL) 1242 if (options.control_path != NULL) {
1243 muxclient(options.control_path); 1243 int sock;
1244 if ((sock = muxclient(options.control_path)) >= 0) {
1245 packet_set_connection(sock, sock);
1246 ssh = active_state; /* XXX */
1247 enable_compat20(); /* XXX */
1248 packet_set_mux();
1249 goto skip_connect;
1250 }
1251 }
1244 1252
1245 /* 1253 /*
1246 * If hostname canonicalisation was not enabled, then we may not 1254 * If hostname canonicalisation was not enabled, then we may not
@@ -1443,6 +1451,7 @@ main(int ac, char **av)
1443 options.certificate_files[i] = NULL; 1451 options.certificate_files[i] = NULL;
1444 } 1452 }
1445 1453
1454 skip_connect:
1446 exit_status = compat20 ? ssh_session2() : ssh_session(); 1455 exit_status = compat20 ? ssh_session2() : ssh_session();
1447 packet_close(); 1456 packet_close();
1448 1457
@@ -1953,7 +1962,8 @@ ssh_session2(void)
1953 ssh_init_forwarding(); 1962 ssh_init_forwarding();
1954 1963
1955 /* Start listening for multiplex clients */ 1964 /* Start listening for multiplex clients */
1956 muxserver_listen(); 1965 if (!packet_get_mux())
1966 muxserver_listen();
1957 1967
1958 /* 1968 /*
1959 * If we are in control persist mode and have a working mux listen 1969 * If we are in control persist mode and have a working mux listen
@@ -2118,8 +2128,9 @@ load_public_identity_files(void)
2118 free(cp); 2128 free(cp);
2119 continue; 2129 continue;
2120 } 2130 }
2131 /* NB. leave filename pointing to private key */
2132 identity_files[n_ids] = xstrdup(filename);
2121 identity_keys[n_ids] = public; 2133 identity_keys[n_ids] = public;
2122 identity_files[n_ids] = cp;
2123 n_ids++; 2134 n_ids++;
2124 } 2135 }
2125 2136