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

Collapse All | Expand All

(-)clientloop.c (-10 / +39 lines)
Lines 950-955 client_process_control(fd_set *readset) Link Here
950
}
950
}
951
951
952
static void
952
static void
953
ssh_send_signal(char *signame)
954
{
955
	debug("sending signal %s to session %d", signame, session_ident);
956
	channel_request_start(session_ident, "signal", 0);
957
	packet_put_cstring(signame);
958
	packet_send();
959
	packet_write_wait();
960
}
961
962
static void
953
process_cmdline(void)
963
process_cmdline(void)
954
{
964
{
955
	void (*handler)(int);
965
	void (*handler)(int);
Lines 982-987 process_cmdline(void) Link Here
982
		    "Request remote forward");
992
		    "Request remote forward");
983
		logit("      -KR[bind_address:]port                 "
993
		logit("      -KR[bind_address:]port                 "
984
		    "Cancel remote forward");
994
		    "Cancel remote forward");
995
		if (compat20)
996
			logit("      -S[signal]                             "
997
			    "Send signal");
985
		if (!options.permit_local_command)
998
		if (!options.permit_local_command)
986
			goto out;
999
			goto out;
987
		logit("      !args                                  "
1000
		logit("      !args                                  "
Lines 995-1000 process_cmdline(void) Link Here
995
		goto out;
1008
		goto out;
996
	}
1009
	}
997
1010
1011
	if (*s == 'S' && compat20) {
1012
		s++;
1013
		ssh_send_signal(s);
1014
		goto out;
1015
	}
1016
998
	if (*s == 'K') {
1017
	if (*s == 'K') {
999
		delete = 1;
1018
		delete = 1;
1000
		s++;
1019
		s++;
Lines 1551-1556 client_loop(int have_pty, int escape_cha Link Here
1551
		if (FD_ISSET(connection_out, writeset))
1570
		if (FD_ISSET(connection_out, writeset))
1552
			packet_write_poll();
1571
			packet_write_poll();
1553
	}
1572
	}
1573
1574
	/*
1575
	 * If there was no shell or command requested, there will be no remote
1576
	 * exit status to be returned.  In that case, clear error code if the
1577
	 * connection was deliberately terminated at this end.
1578
	 */
1579
	if (no_shell_flag && received_signal == SIGTERM) {
1580
		received_signal = 0;
1581
		exit_status = 0;
1582
	}
1583
1584
	if (received_signal && compat20) {
1585
		char *signame = signo2name(received_signal);
1586
		if (signame != NULL) {
1587
			debug("passed signal %s to server", signame);
1588
			ssh_send_signal(signame);
1589
		} else
1590
			debug("non-standard signal %s", signame);
1591
	}
1592
1554
	if (readset)
1593
	if (readset)
1555
		xfree(readset);
1594
		xfree(readset);
1556
	if (writeset)
1595
	if (writeset)
Lines 1573-1588 client_loop(int have_pty, int escape_cha Link Here
1573
		unset_nonblock(fileno(stdout));
1612
		unset_nonblock(fileno(stdout));
1574
	if (!isatty(fileno(stderr)))
1613
	if (!isatty(fileno(stderr)))
1575
		unset_nonblock(fileno(stderr));
1614
		unset_nonblock(fileno(stderr));
1576
1577
	/*
1578
	 * If there was no shell or command requested, there will be no remote
1579
	 * exit status to be returned.  In that case, clear error code if the
1580
	 * connection was deliberately terminated at this end.
1581
	 */
1582
	if (no_shell_flag && received_signal == SIGTERM) {
1583
		received_signal = 0;
1584
		exit_status = 0;
1585
	}
1586
1615
1587
	if (received_signal)
1616
	if (received_signal)
1588
		fatal("Killed by signal %d.", (int) received_signal);
1617
		fatal("Killed by signal %d.", (int) received_signal);
(-)misc.c (+42 lines)
Lines 56-61 Link Here
56
#include "log.h"
56
#include "log.h"
57
#include "ssh.h"
57
#include "ssh.h"
58
58
59
static struct {
60
	int signo;
61
	char *name;
62
} no2name[] = {
63
	{ SIGABRT,	"ABRT" },
64
	{ SIGALRM,	"ALRM" },
65
	{ SIGFPE,	"FPE" },
66
	{ SIGHUP,	"HUP" },
67
	{ SIGILL,	"ILL" },
68
	{ SIGINT,	"INT" },
69
	{ SIGKILL,	"KILL" },
70
	{ SIGPIPE,	"PIPE" },
71
	{ SIGQUIT,	"QUIT" },
72
	{ SIGSEGV,	"SEGV" },
73
	{ SIGTERM,	"TERM" },
74
	{ SIGUSR1,	"USR1" },
75
	{ SIGUSR2,	"USR2" },
76
	{ -1	,	NULL }
77
};
78
79
int
80
signame2no(char *name)
81
{
82
	int i;
83
84
	for (i = 0; no2name[i].signo != -1; i++)
85
		if (strcmp(no2name[i].name, name) == 0)
86
			return no2name[i].signo;
87
	return -1;
88
}
89
90
char *
91
signo2name(int signo)
92
{
93
	int i;
94
95
	for (i = 0; no2name[i].signo != -1; i++)
96
		if (no2name[i].signo == signo)
97
			return no2name[i].name;
98
	return NULL;
99
}
100
59
/* remove newline at end of string */
101
/* remove newline at end of string */
60
char *
102
char *
61
chop(char *s)
103
chop(char *s)
(-)misc.h (-1 / +3 lines)
Lines 17-22 Link Here
17
17
18
/* misc.c */
18
/* misc.c */
19
19
20
21
int	 signame2no(char *);
22
char	*signo2name(int);
20
char	*chop(char *);
23
char	*chop(char *);
21
char	*strdelim(char **);
24
char	*strdelim(char **);
22
int	 set_nonblock(int);
25
int	 set_nonblock(int);
Lines 75-81 void put_u32(void *, u_int32_t) Link Here
75
    __attribute__((__bounded__( __minbytes__, 1, 4)));
78
    __attribute__((__bounded__( __minbytes__, 1, 4)));
76
void		put_u16(void *, u_int16_t)
79
void		put_u16(void *, u_int16_t)
77
    __attribute__((__bounded__( __minbytes__, 1, 2)));
80
    __attribute__((__bounded__( __minbytes__, 1, 2)));
78
79
81
80
/* readpass.c */
82
/* readpass.c */
81
83
(-)session.c (-1 / +34 lines)
Lines 87-92 Link Here
87
#include "session.h"
87
#include "session.h"
88
#include "kex.h"
88
#include "kex.h"
89
#include "monitor_wrap.h"
89
#include "monitor_wrap.h"
90
#include "misc.h"
90
91
91
#if defined(KRB5) && defined(USE_AFS)
92
#if defined(KRB5) && defined(USE_AFS)
92
#include <kafs.h>
93
#include <kafs.h>
Lines 1989-1994 session_env_req(Session *s) Link Here
1989
}
1990
}
1990
1991
1991
static int
1992
static int
1993
session_signal_req(Session *s)
1994
{
1995
	char *signame;
1996
	int sig, success = 0;
1997
1998
	signame = packet_get_string(NULL);
1999
	sig = signame2no(signame);
2000
	packet_check_eom();
2001
2002
	if (sig >= 0) {
2003
		if (s->pid > 0) {
2004
			debug("session_signal_req: signal %s, killpg(%d, %d)",
2005
			    signame, s->pid, sig);
2006
			temporarily_use_uid(s->pw);
2007
			if (killpg(s->pid, sig) < 0)
2008
				error("session_signal_req: killpg(%d, %d): %s",
2009
				    s->pid, sig, strerror(errno));
2010
			else
2011
				success = 1;
2012
			restore_uid();
2013
		}
2014
	} else {
2015
		debug("session_signal_req: unknown signal %s", signame);
2016
	}
2017
	xfree(signame);
2018
	return success;
2019
}
2020
2021
2022
static int
1992
session_auth_agent_req(Session *s)
2023
session_auth_agent_req(Session *s)
1993
{
2024
{
1994
	static int called = 0;
2025
	static int called = 0;
Lines 2043-2049 session_input_channel_req(Channel *c, co Link Here
2043
		success = session_window_change_req(s);
2074
		success = session_window_change_req(s);
2044
	} else if (strcmp(rtype, "break") == 0) {
2075
	} else if (strcmp(rtype, "break") == 0) {
2045
		success = session_break_req(s);
2076
		success = session_break_req(s);
2046
	}
2077
	} else if (strcmp(rtype, "signal") == 0) {
2078
		success = session_signal_req(s);
2079
 	}
2047
2080
2048
	return success;
2081
	return success;
2049
}
2082
}

Return to bug 1424