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

Collapse All | Expand All

(-)clientloop.c (+28 lines)
Lines 1008-1013 Link Here
1008
    {"B",  "send a BREAK to the remote system", SUPPRESS_PROTO1},
1008
    {"B",  "send a BREAK to the remote system", SUPPRESS_PROTO1},
1009
    {"C",  "open a command line", SUPPRESS_MUXCLIENT},
1009
    {"C",  "open a command line", SUPPRESS_MUXCLIENT},
1010
    {"R",  "request rekey", SUPPRESS_PROTO1},
1010
    {"R",  "request rekey", SUPPRESS_PROTO1},
1011
    {"S",  "send signal to remote process", SUPPRESS_PROTO1},
1011
    {"V/v",  "decrease/increase verbosity (LogLevel)", SUPPRESS_MUXCLIENT},
1012
    {"V/v",  "decrease/increase verbosity (LogLevel)", SUPPRESS_MUXCLIENT},
1012
    {"^Z", "suspend ssh", SUPPRESS_MUXCLIENT},
1013
    {"^Z", "suspend ssh", SUPPRESS_MUXCLIENT},
1013
    {"#",  "list forwarded connections", SUPPRESS_NEVER},
1014
    {"#",  "list forwarded connections", SUPPRESS_NEVER},
Lines 1047-1052 Link Here
1047
	buffer_append(b, string, strlen(string));
1048
	buffer_append(b, string, strlen(string));
1048
}
1049
}
1049
1050
1051
static void
1052
process_signal(void)
1053
{
1054
	void (*handler)(int);
1055
	char *sig;
1056
1057
	leave_raw_mode(options.request_tty == REQUEST_TTY_FORCE);
1058
	handler = signal(SIGINT, SIG_IGN);
1059
	sig = read_passphrase("SIG", RP_ECHO);
1060
	if (sig != NULL && *sig != '\0') {
1061
		debug("sending signal %s to session %d", sig, session_ident);
1062
		channel_request_start(session_ident, "signal", 0);
1063
		packet_put_cstring(sig);
1064
		packet_send();
1065
		packet_write_wait();
1066
	}
1067
	if (sig != NULL)
1068
		free(sig);
1069
	signal(SIGINT, handler);
1070
	enter_raw_mode(options.request_tty == REQUEST_TTY_FORCE);
1071
}
1072
1050
/* 
1073
/* 
1051
 * Process the characters one by one, call with c==NULL for proto1 case.
1074
 * Process the characters one by one, call with c==NULL for proto1 case.
1052
 */
1075
 */
Lines 1248-1253 Link Here
1248
				s = channel_open_message();
1271
				s = channel_open_message();
1249
				buffer_append(berr, s, strlen(s));
1272
				buffer_append(berr, s, strlen(s));
1250
				free(s);
1273
				free(s);
1274
				continue;
1275
1276
			case 'S':
1277
				if (compat20)
1278
					process_signal();
1251
				continue;
1279
				continue;
1252
1280
1253
			case 'C':
1281
			case 'C':
(-)session.c (+57 lines)
Lines 2256-2261 Link Here
2256
	return (0);
2256
	return (0);
2257
}
2257
}
2258
2258
2259
/*
2260
 * For conversion of signals to/from ssh channel request names.
2261
 * List of signals from RFC 4254 section 6.10.
2262
 */
2263
2264
static int
2265
name2sig(char *name)
2266
{
2267
#define SSH_SIG(x) if (strcmp(name, #x) == 0) return SIG ## x
2268
	SSH_SIG(ABRT);
2269
	SSH_SIG(ALRM);
2270
	SSH_SIG(FPE);
2271
	SSH_SIG(HUP);
2272
	SSH_SIG(ILL);
2273
	SSH_SIG(INT);
2274
	SSH_SIG(KILL);
2275
	SSH_SIG(PIPE);
2276
	SSH_SIG(QUIT);
2277
	SSH_SIG(SEGV);
2278
	SSH_SIG(TERM);
2279
	SSH_SIG(USR1);
2280
	SSH_SIG(USR2);
2281
#undef	SSH_SIG
2282
	return -1;
2283
}
2284
2285
static int
2286
session_signal_req(Session *s)
2287
{
2288
	char *signame;
2289
	int sig, success = 0;
2290
2291
	signame = packet_get_string(NULL);
2292
	sig = name2sig(signame);
2293
	packet_check_eom();
2294
2295
	if (sig >= 0) {
2296
		if (s->pid > 0) {
2297
			debug("session_signal_req: signal %s, killpg(%d, %d)",
2298
			    signame, s->pid, sig);
2299
			temporarily_use_uid(s->pw);
2300
			if (killpg(s->pid, sig) < 0)
2301
				error("session_signal_req: killpg(%d, %d): %s",
2302
				    s->pid, sig, strerror(errno));
2303
			else
2304
				success = 1;
2305
			restore_uid();
2306
		}
2307
	} else
2308
		debug("session_signal_req: unknown signal %s", signame);
2309
2310
	free(signame);
2311
	return success;
2312
}
2313
2259
static int
2314
static int
2260
session_auth_agent_req(Session *s)
2315
session_auth_agent_req(Session *s)
2261
{
2316
{
Lines 2311-2316 Link Here
2311
		success = session_window_change_req(s);
2366
		success = session_window_change_req(s);
2312
	} else if (strcmp(rtype, "break") == 0) {
2367
	} else if (strcmp(rtype, "break") == 0) {
2313
		success = session_break_req(s);
2368
		success = session_break_req(s);
2369
	} else if (strcmp(rtype, "signal") == 0) {
2370
		success = session_signal_req(s);
2314
	}
2371
	}
2315
2372
2316
	return success;
2373
	return success;
(-)ssh.1 (+5 lines)
Lines 948-953 Link Here
948
.It Cm ~R
948
.It Cm ~R
949
Request rekeying of the connection
949
Request rekeying of the connection
950
(only useful for SSH protocol version 2 and if the peer supports it).
950
(only useful for SSH protocol version 2 and if the peer supports it).
951
.It Cm ~S
952
Send a signal to the remote system
953
(only useful for SSH protocol version 2 and if the peer supports it).
954
The standard signals are ABRT ALRM FPE HUP ILL INT KILL PIPE QUIT SEGV TERM
955
USR1 USR2 but other signals can be sent if the server supports them.
951
.It Cm ~V
956
.It Cm ~V
952
Decrease the verbosity
957
Decrease the verbosity
953
.Pq Ic LogLevel
958
.Pq Ic LogLevel

Return to bug 1424