Bugzilla – Attachment 1432 Details for
Bug 1424
Cannot signal a process over a channel (rfc 4254, section 6.9)
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Requests
|
Help
|
New Account
|
Log In
[x]
|
Forgot Password
Login:
[x]
[patch]
Implement "signal" channel request type, server and client.
openssh-signal.patch (text/plain), 5.60 KB, created by
Darren Tucker
on 2008-01-01 10:31:47 AEDT
(
hide
)
Description:
Implement "signal" channel request type, server and client.
Filename:
MIME Type:
Creator:
Darren Tucker
Created:
2008-01-01 10:31:47 AEDT
Size:
5.60 KB
patch
obsolete
>Index: clientloop.c >=================================================================== >RCS file: /cvs/openssh/clientloop.c,v >retrieving revision 1.171 >diff -u -p -r1.171 clientloop.c >--- clientloop.c 28 Dec 2007 22:37:10 -0000 1.171 >+++ clientloop.c 31 Dec 2007 23:21:35 -0000 >@@ -950,6 +950,16 @@ client_process_control(fd_set *readset) > } > > static void >+ssh_send_signal(char *signame) >+{ >+ debug("sending signal %s to session %d", signame, session_ident); >+ channel_request_start(session_ident, "signal", 0); >+ packet_put_cstring(signame); >+ packet_send(); >+ packet_write_wait(); >+} >+ >+static void > process_cmdline(void) > { > void (*handler)(int); >@@ -982,6 +992,9 @@ process_cmdline(void) > "Request remote forward"); > logit(" -KR[bind_address:]port " > "Cancel remote forward"); >+ if (compat20) >+ logit(" -S[signal] " >+ "Send signal"); > if (!options.permit_local_command) > goto out; > logit(" !args " >@@ -995,6 +1008,12 @@ process_cmdline(void) > goto out; > } > >+ if (*s == 'S' && compat20) { >+ s++; >+ ssh_send_signal(s); >+ goto out; >+ } >+ > if (*s == 'K') { > delete = 1; > s++; >@@ -1551,6 +1570,26 @@ client_loop(int have_pty, int escape_cha > if (FD_ISSET(connection_out, writeset)) > packet_write_poll(); > } >+ >+ /* >+ * If there was no shell or command requested, there will be no remote >+ * exit status to be returned. In that case, clear error code if the >+ * connection was deliberately terminated at this end. >+ */ >+ if (no_shell_flag && received_signal == SIGTERM) { >+ received_signal = 0; >+ exit_status = 0; >+ } >+ >+ if (received_signal && compat20) { >+ char *signame = signo2name(received_signal); >+ if (signame != NULL) { >+ debug("passed signal %s to server", signame); >+ ssh_send_signal(signame); >+ } else >+ debug("non-standard signal %s", signame); >+ } >+ > if (readset) > xfree(readset); > if (writeset) >@@ -1573,16 +1612,6 @@ client_loop(int have_pty, int escape_cha > unset_nonblock(fileno(stdout)); > if (!isatty(fileno(stderr))) > unset_nonblock(fileno(stderr)); >- >- /* >- * If there was no shell or command requested, there will be no remote >- * exit status to be returned. In that case, clear error code if the >- * connection was deliberately terminated at this end. >- */ >- if (no_shell_flag && received_signal == SIGTERM) { >- received_signal = 0; >- exit_status = 0; >- } > > if (received_signal) > fatal("Killed by signal %d.", (int) received_signal); >Index: misc.c >=================================================================== >RCS file: /cvs/openssh/misc.c,v >retrieving revision 1.84 >diff -u -p -r1.84 misc.c >--- misc.c 28 Dec 2007 15:43:51 -0000 1.84 >+++ misc.c 31 Dec 2007 23:21:38 -0000 >@@ -56,6 +56,48 @@ > #include "log.h" > #include "ssh.h" > >+static struct { >+ int signo; >+ char *name; >+} no2name[] = { >+ { SIGABRT, "ABRT" }, >+ { SIGALRM, "ALRM" }, >+ { SIGFPE, "FPE" }, >+ { SIGHUP, "HUP" }, >+ { SIGILL, "ILL" }, >+ { SIGINT, "INT" }, >+ { SIGKILL, "KILL" }, >+ { SIGPIPE, "PIPE" }, >+ { SIGQUIT, "QUIT" }, >+ { SIGSEGV, "SEGV" }, >+ { SIGTERM, "TERM" }, >+ { SIGUSR1, "USR1" }, >+ { SIGUSR2, "USR2" }, >+ { -1 , NULL } >+}; >+ >+int >+signame2no(char *name) >+{ >+ int i; >+ >+ for (i = 0; no2name[i].signo != -1; i++) >+ if (strcmp(no2name[i].name, name) == 0) >+ return no2name[i].signo; >+ return -1; >+} >+ >+char * >+signo2name(int signo) >+{ >+ int i; >+ >+ for (i = 0; no2name[i].signo != -1; i++) >+ if (no2name[i].signo == signo) >+ return no2name[i].name; >+ return NULL; >+} >+ > /* remove newline at end of string */ > char * > chop(char *s) >Index: misc.h >=================================================================== >RCS file: /cvs/openssh/misc.h,v >retrieving revision 1.40 >diff -u -p -r1.40 misc.h >--- misc.h 28 Dec 2007 15:43:51 -0000 1.40 >+++ misc.h 31 Dec 2007 23:21:38 -0000 >@@ -17,6 +17,9 @@ > > /* misc.c */ > >+ >+int signame2no(char *); >+char *signo2name(int); > char *chop(char *); > char *strdelim(char **); > int set_nonblock(int); >@@ -75,7 +78,6 @@ void put_u32(void *, u_int32_t) > __attribute__((__bounded__( __minbytes__, 1, 4))); > void put_u16(void *, u_int16_t) > __attribute__((__bounded__( __minbytes__, 1, 2))); >- > > /* readpass.c */ > >Index: session.c >=================================================================== >RCS file: /cvs/openssh/session.c,v >retrieving revision 1.356 >diff -u -p -r1.356 session.c >--- session.c 17 Sep 2007 06:09:15 -0000 1.356 >+++ session.c 31 Dec 2007 23:21:39 -0000 >@@ -87,6 +87,7 @@ > #include "session.h" > #include "kex.h" > #include "monitor_wrap.h" >+#include "misc.h" > > #if defined(KRB5) && defined(USE_AFS) > #include <kafs.h> >@@ -1989,6 +1990,36 @@ session_env_req(Session *s) > } > > static int >+session_signal_req(Session *s) >+{ >+ char *signame; >+ int sig, success = 0; >+ >+ signame = packet_get_string(NULL); >+ sig = signame2no(signame); >+ packet_check_eom(); >+ >+ if (sig >= 0) { >+ if (s->pid > 0) { >+ debug("session_signal_req: signal %s, killpg(%d, %d)", >+ signame, s->pid, sig); >+ temporarily_use_uid(s->pw); >+ if (killpg(s->pid, sig) < 0) >+ error("session_signal_req: killpg(%d, %d): %s", >+ s->pid, sig, strerror(errno)); >+ else >+ success = 1; >+ restore_uid(); >+ } >+ } else { >+ debug("session_signal_req: unknown signal %s", signame); >+ } >+ xfree(signame); >+ return success; >+} >+ >+ >+static int > session_auth_agent_req(Session *s) > { > static int called = 0; >@@ -2043,7 +2074,9 @@ session_input_channel_req(Channel *c, co > success = session_window_change_req(s); > } else if (strcmp(rtype, "break") == 0) { > success = session_break_req(s); >- } >+ } else if (strcmp(rtype, "signal") == 0) { >+ success = session_signal_req(s); >+ } > > return success; > }
You cannot view the attachment while viewing its details because your browser does not support IFRAMEs.
View the attachment on a separate page
.
View Attachment As Diff
View Attachment As Raw
Actions:
View
|
Diff
Attachments on
bug 1424
:
1432
|
1438
|
1699
|
1700
|
1709
|
2500
|
3120