Bugzilla – Attachment 2500 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]
Update of #1699 versus 6.7p1
signal-passing.diff (text/plain), 3.97 KB, created by
Iain Morgan
on 2014-10-30 10:19:42 AEDT
(
hide
)
Description:
Update of #1699 versus 6.7p1
Filename:
MIME Type:
Creator:
Iain Morgan
Created:
2014-10-30 10:19:42 AEDT
Size:
3.97 KB
patch
obsolete
>Index: clientloop.c >=================================================================== >RCS file: /cvs/openssh/clientloop.c,v >retrieving revision 1.250 >diff -u -u -r1.250 clientloop.c >--- clientloop.c 18 Jul 2014 04:11:26 -0000 1.250 >+++ clientloop.c 29 Oct 2014 00:55:02 -0000 >@@ -1008,6 +1008,7 @@ > {"B", "send a BREAK to the remote system", SUPPRESS_PROTO1}, > {"C", "open a command line", SUPPRESS_MUXCLIENT}, > {"R", "request rekey", SUPPRESS_PROTO1}, >+ {"S", "send signal to remote process", SUPPRESS_PROTO1}, > {"V/v", "decrease/increase verbosity (LogLevel)", SUPPRESS_MUXCLIENT}, > {"^Z", "suspend ssh", SUPPRESS_MUXCLIENT}, > {"#", "list forwarded connections", SUPPRESS_NEVER}, >@@ -1047,6 +1048,28 @@ > buffer_append(b, string, strlen(string)); > } > >+static void >+process_signal(void) >+{ >+ void (*handler)(int); >+ char *sig; >+ >+ leave_raw_mode(options.request_tty == REQUEST_TTY_FORCE); >+ handler = signal(SIGINT, SIG_IGN); >+ sig = read_passphrase("SIG", RP_ECHO); >+ if (sig != NULL && *sig != '\0') { >+ debug("sending signal %s to session %d", sig, session_ident); >+ channel_request_start(session_ident, "signal", 0); >+ packet_put_cstring(sig); >+ packet_send(); >+ packet_write_wait(); >+ } >+ if (sig != NULL) >+ free(sig); >+ signal(SIGINT, handler); >+ enter_raw_mode(options.request_tty == REQUEST_TTY_FORCE); >+} >+ > /* > * Process the characters one by one, call with c==NULL for proto1 case. > */ >@@ -1248,6 +1271,11 @@ > s = channel_open_message(); > buffer_append(berr, s, strlen(s)); > free(s); >+ continue; >+ >+ case 'S': >+ if (compat20) >+ process_signal(); > continue; > > case 'C': >Index: session.c >=================================================================== >RCS file: /cvs/openssh/session.c,v >retrieving revision 1.434 >diff -u -u -r1.434 session.c >--- session.c 18 Jul 2014 04:11:26 -0000 1.434 >+++ session.c 29 Oct 2014 00:55:03 -0000 >@@ -2256,6 +2256,61 @@ > return (0); > } > >+/* >+ * For conversion of signals to/from ssh channel request names. >+ * List of signals from RFC 4254 section 6.10. >+ */ >+ >+static int >+name2sig(char *name) >+{ >+#define SSH_SIG(x) if (strcmp(name, #x) == 0) return SIG ## x >+ SSH_SIG(ABRT); >+ SSH_SIG(ALRM); >+ SSH_SIG(FPE); >+ SSH_SIG(HUP); >+ SSH_SIG(ILL); >+ SSH_SIG(INT); >+ SSH_SIG(KILL); >+ SSH_SIG(PIPE); >+ SSH_SIG(QUIT); >+ SSH_SIG(SEGV); >+ SSH_SIG(TERM); >+ SSH_SIG(USR1); >+ SSH_SIG(USR2); >+#undef SSH_SIG >+ return -1; >+} >+ >+static int >+session_signal_req(Session *s) >+{ >+ char *signame; >+ int sig, success = 0; >+ >+ signame = packet_get_string(NULL); >+ sig = name2sig(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); >+ >+ free(signame); >+ return success; >+} >+ > static int > session_auth_agent_req(Session *s) > { >@@ -2311,6 +2366,8 @@ > 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; >Index: ssh.1 >=================================================================== >RCS file: /cvs/openssh/ssh.1,v >retrieving revision 1.307 >diff -u -u -r1.307 ssh.1 >--- ssh.1 30 Jul 2014 02:32:28 -0000 1.307 >+++ ssh.1 29 Oct 2014 00:55:03 -0000 >@@ -948,6 +948,11 @@ > .It Cm ~R > Request rekeying of the connection > (only useful for SSH protocol version 2 and if the peer supports it). >+.It Cm ~S >+Send a signal to the remote system >+(only useful for SSH protocol version 2 and if the peer supports it). >+The standard signals are ABRT ALRM FPE HUP ILL INT KILL PIPE QUIT SEGV TERM >+USR1 USR2 but other signals can be sent if the server supports them. > .It Cm ~V > Decrease the verbosity > .Pq Ic LogLevel
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