summaryrefslogtreecommitdiff
path: root/ssh.c
diff options
context:
space:
mode:
authorDamien Miller <djm@mindrot.org>2005-07-06 09:44:19 +1000
committerDamien Miller <djm@mindrot.org>2005-07-06 09:44:19 +1000
commit1339002e8b05d89b10767849d9ee9be55e460f4c (patch)
tree58e307b74579313f31732dfdf21f756d6a051ce9 /ssh.c
parenta7270309fc5e95b29c91d0190b13ef5a9b1df339 (diff)
- djm@cvs.openbsd.org 2005/07/04 00:58:43
[channels.c clientloop.c clientloop.h misc.c misc.h ssh.c ssh_config.5] implement support for X11 and agent forwarding over multiplex slave connections. Because of protocol limitations, the slave connections inherit the master's DISPLAY and SSH_AUTH_SOCK rather than distinctly forwarding their own. ok dtucker@ "put it in" deraadt@
Diffstat (limited to 'ssh.c')
-rw-r--r--ssh.c45
1 files changed, 24 insertions, 21 deletions
diff --git a/ssh.c b/ssh.c
index 67af53e69..43d97abcc 100644
--- a/ssh.c
+++ b/ssh.c
@@ -40,7 +40,7 @@
40 */ 40 */
41 41
42#include "includes.h" 42#include "includes.h"
43RCSID("$OpenBSD: ssh.c,v 1.246 2005/06/25 22:47:49 djm Exp $"); 43RCSID("$OpenBSD: ssh.c,v 1.247 2005/07/04 00:58:43 djm Exp $");
44 44
45#include <openssl/evp.h> 45#include <openssl/evp.h>
46#include <openssl/err.h> 46#include <openssl/err.h>
@@ -1250,41 +1250,44 @@ control_client(const char *path)
1250 error("Control socket connect(%.100s): %s", path, 1250 error("Control socket connect(%.100s): %s", path,
1251 strerror(errno)); 1251 strerror(errno));
1252 } 1252 }
1253 close(sock); 1253 close(sock);
1254 return; 1254 return;
1255 } 1255 }
1256 1256
1257 if (stdin_null_flag) { 1257 if (stdin_null_flag) {
1258 if ((fd = open(_PATH_DEVNULL, O_RDONLY)) == -1) 1258 if ((fd = open(_PATH_DEVNULL, O_RDONLY)) == -1)
1259 fatal("open(/dev/null): %s", strerror(errno)); 1259 fatal("open(/dev/null): %s", strerror(errno));
1260 if (dup2(fd, STDIN_FILENO) == -1) 1260 if (dup2(fd, STDIN_FILENO) == -1)
1261 fatal("dup2: %s", strerror(errno)); 1261 fatal("dup2: %s", strerror(errno));
1262 if (fd > STDERR_FILENO) 1262 if (fd > STDERR_FILENO)
1263 close(fd); 1263 close(fd);
1264 } 1264 }
1265 1265
1266 if ((term = getenv("TERM")) == NULL) 1266 term = getenv("TERM");
1267 term = "";
1268 1267
1269 flags = 0; 1268 flags = 0;
1270 if (tty_flag) 1269 if (tty_flag)
1271 flags |= SSHMUX_FLAG_TTY; 1270 flags |= SSHMUX_FLAG_TTY;
1272 if (subsystem_flag) 1271 if (subsystem_flag)
1273 flags |= SSHMUX_FLAG_SUBSYS; 1272 flags |= SSHMUX_FLAG_SUBSYS;
1273 if (options.forward_x11)
1274 flags |= SSHMUX_FLAG_X11_FWD;
1275 if (options.forward_agent)
1276 flags |= SSHMUX_FLAG_AGENT_FWD;
1274 1277
1275 buffer_init(&m); 1278 buffer_init(&m);
1276 1279
1277 /* Send our command to server */ 1280 /* Send our command to server */
1278 buffer_put_int(&m, mux_command); 1281 buffer_put_int(&m, mux_command);
1279 buffer_put_int(&m, flags); 1282 buffer_put_int(&m, flags);
1280 if (ssh_msg_send(sock, /* version */1, &m) == -1) 1283 if (ssh_msg_send(sock, SSHMUX_VER, &m) == -1)
1281 fatal("%s: msg_send", __func__); 1284 fatal("%s: msg_send", __func__);
1282 buffer_clear(&m); 1285 buffer_clear(&m);
1283 1286
1284 /* Get authorisation status and PID of controlee */ 1287 /* Get authorisation status and PID of controlee */
1285 if (ssh_msg_recv(sock, &m) == -1) 1288 if (ssh_msg_recv(sock, &m) == -1)
1286 fatal("%s: msg_recv", __func__); 1289 fatal("%s: msg_recv", __func__);
1287 if (buffer_get_char(&m) != 1) 1290 if (buffer_get_char(&m) != SSHMUX_VER)
1288 fatal("%s: wrong version", __func__); 1291 fatal("%s: wrong version", __func__);
1289 if (buffer_get_int(&m) != 1) 1292 if (buffer_get_int(&m) != 1)
1290 fatal("Connection to master denied"); 1293 fatal("Connection to master denied");
@@ -1308,7 +1311,7 @@ control_client(const char *path)
1308 } 1311 }
1309 1312
1310 /* SSHMUX_COMMAND_OPEN */ 1313 /* SSHMUX_COMMAND_OPEN */
1311 buffer_put_cstring(&m, term); 1314 buffer_put_cstring(&m, term ? term : "");
1312 buffer_append(&command, "\0", 1); 1315 buffer_append(&command, "\0", 1);
1313 buffer_put_cstring(&m, buffer_ptr(&command)); 1316 buffer_put_cstring(&m, buffer_ptr(&command));
1314 1317
@@ -1330,7 +1333,7 @@ control_client(const char *path)
1330 } 1333 }
1331 } 1334 }
1332 1335
1333 if (ssh_msg_send(sock, /* version */1, &m) == -1) 1336 if (ssh_msg_send(sock, SSHMUX_VER, &m) == -1)
1334 fatal("%s: msg_send", __func__); 1337 fatal("%s: msg_send", __func__);
1335 1338
1336 mm_send_fd(sock, STDIN_FILENO); 1339 mm_send_fd(sock, STDIN_FILENO);
@@ -1341,7 +1344,7 @@ control_client(const char *path)
1341 buffer_clear(&m); 1344 buffer_clear(&m);
1342 if (ssh_msg_recv(sock, &m) == -1) 1345 if (ssh_msg_recv(sock, &m) == -1)
1343 fatal("%s: msg_recv", __func__); 1346 fatal("%s: msg_recv", __func__);
1344 if (buffer_get_char(&m) != 1) 1347 if (buffer_get_char(&m) != SSHMUX_VER)
1345 fatal("%s: wrong version", __func__); 1348 fatal("%s: wrong version", __func__);
1346 buffer_free(&m); 1349 buffer_free(&m);
1347 1350