View | Details | Raw Unified | Return to bug 1349 | Differences between
and this patch

Collapse All | Expand All

(-)ssh.c~ (-11 / +23 lines)
Lines 1045-1062 Link Here
1045
	}
1045
	}
1046
}
1046
}
1047
1047
1048
static void
1048
static int
1049
ssh_control_listener(void)
1049
ssh_control_listener(int test)
1050
{
1050
{
1051
	struct sockaddr_un addr;
1051
	struct sockaddr_un addr;
1052
	mode_t old_umask;
1052
	mode_t old_umask;
1053
	int addr_len;
1053
	int addr_len;
1054
1054
1055
	if (options.control_path == NULL ||
1055
	if (options.control_path == NULL ||
1056
	    options.control_master == SSHCTL_MASTER_NO)
1056
	    options.control_master == SSHCTL_MASTER_NO ||
1057
		return;
1057
	    control_fd != -1)
1058
		return 1;
1058
1059
1059
	debug("setting up multiplex master socket");
1060
	debug("trying to set up multiplex master socket");
1060
1061
1061
	memset(&addr, '\0', sizeof(addr));
1062
	memset(&addr, '\0', sizeof(addr));
1062
	addr.sun_family = AF_UNIX;
1063
	addr.sun_family = AF_UNIX;
Lines 1073-1083 Link Here
1073
	old_umask = umask(0177);
1074
	old_umask = umask(0177);
1074
	if (bind(control_fd, (struct sockaddr *)&addr, addr_len) == -1) {
1075
	if (bind(control_fd, (struct sockaddr *)&addr, addr_len) == -1) {
1075
		control_fd = -1;
1076
		control_fd = -1;
1076
		if (errno == EINVAL || errno == EADDRINUSE)
1077
		if (errno != EINVAL && errno != EADDRINUSE)
1077
			fatal("ControlSocket %s already exists",
1078
			    options.control_path);
1079
		else
1080
			fatal("%s bind(): %s", __func__, strerror(errno));
1078
			fatal("%s bind(): %s", __func__, strerror(errno));
1079
		return 0;
1081
	}
1080
	}
1082
	umask(old_umask);
1081
	umask(old_umask);
1083
1082
Lines 1085-1090 Link Here
1085
		fatal("%s listen(): %s", __func__, strerror(errno));
1084
		fatal("%s listen(): %s", __func__, strerror(errno));
1086
1085
1087
	set_nonblock(control_fd);
1086
	set_nonblock(control_fd);
1087
1088
	debug("control master listening on %s", options.control_path);
1089
	return 1;
1088
}
1090
}
1089
1091
1090
/* request pty/x11/agent/tcpfwd/shell for channel */
1092
/* request pty/x11/agent/tcpfwd/shell for channel */
Lines 1201-1207 Link Here
1201
1203
1202
	/* XXX should be pre-session */
1204
	/* XXX should be pre-session */
1203
	ssh_init_forwarding();
1205
	ssh_init_forwarding();
1204
	ssh_control_listener();
1206
	if (!ssh_control_listener(0))
1207
		fatal("control master socket %s already exists",
1208
		    options.control_path);
1205
1209
1206
	if (!no_shell_flag || (datafellows & SSH_BUG_DUMMYCHAN))
1210
	if (!no_shell_flag || (datafellows & SSH_BUG_DUMMYCHAN))
1207
		id = ssh_session2_open();
1211
		id = ssh_session2_open();
Lines 1319-1325 Link Here
1319
	switch (options.control_master) {
1323
	switch (options.control_master) {
1320
	case SSHCTL_MASTER_AUTO:
1324
	case SSHCTL_MASTER_AUTO:
1321
	case SSHCTL_MASTER_AUTO_ASK:
1325
	case SSHCTL_MASTER_AUTO_ASK:
1322
		debug("auto-mux: Trying existing master");
1326
		/* see if we can create a control master socket
1327
		   to avoid a race between two auto clients */
1328
		if (mux_command == SSHMUX_COMMAND_OPEN &&
1329
		    ssh_control_listener(1))
1330
			return;
1331
		debug("trying to connect to control master socket %s",
1332
		    options.control_path);
1323
		/* FALLTHROUGH */
1333
		/* FALLTHROUGH */
1324
	case SSHCTL_MASTER_NO:
1334
	case SSHCTL_MASTER_NO:
1325
		break;
1335
		break;
Lines 1452-1457 Link Here
1452
	signal(SIGINT, control_client_sighandler);
1462
	signal(SIGINT, control_client_sighandler);
1453
	signal(SIGTERM, control_client_sighandler);
1463
	signal(SIGTERM, control_client_sighandler);
1454
	signal(SIGWINCH, control_client_sigrelay);
1464
	signal(SIGWINCH, control_client_sigrelay);
1465
1466
	debug("connected to control master; waiting for exit");
1455
1467
1456
	if (tty_flag)
1468
	if (tty_flag)
1457
		enter_raw_mode();
1469
		enter_raw_mode();

Return to bug 1349