[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Signals support (RFC 4254, section 6.9)
[Thread Prev] | [Thread Next]
- Subject: Signals support (RFC 4254, section 6.9)
- From: "Dmitry V. Krivenok" <krivenok@xxxxxxxxxxxxxxx>
- Reply-to: krivenok@xxxxxxxxxxxxxxx
- Reply-to: libssh@xxxxxxxxxx
- Date: Thu, 10 Sep 2009 13:48:58 +0400
- To: libssh@xxxxxxxxxx
Hello! I've implemented signals delivery support. Patch is attached. I'm new to libssh and it's my first patch. So, I'm not sure that changes I made are correct :) Only SSH-v2 is currently supported. Does SSH-v1 support signals delivery? Note, that openssh-5.2p1 ignores "signal" requests. The problem is described in my post here: http://groups.google.com/group/mailing.unix.openssh-dev/browse_thread/thread/7c5c811b05c63c29?hl=en# Anyway I think that libssh should support signals delivery. -- Sincerely yours, Dmitry V. Krivenok Orange System Co., Ltd. Saint-Petersburg, Russia work phone: +7 812 332-32-40 cellular phone: +7 921 576-70-91 e-mail: krivenok@xxxxxxxxxxxxxxx web: http://www.orangesystem.ru skype: krivenok_dmitry jabber: krivenok_dmitry@xxxxxxxxx icq: 242-526-443
From 6b4a19cc5cd20b7140ca78ed5abf977ff20de186 Mon Sep 17 00:00:00 2001
From: Dmitry V. Krivenok <krivenok@xxxxxxxxxxxxxxx>
Date: Thu, 10 Sep 2009 13:34:40 +0400
Subject: [PATCH] Support for sending signals (RFC 4254, section 6.9).
Added function
int channel_request_send_signal(ssh_channel channel, const char *signal);
which implements signals delivery (as described in RFC 4254).
Only SSH-v2 is currently supported.
Signed-off-by: Dmitry V. Krivenok <krivenok@xxxxxxxxxxxxxxx>
---
include/libssh/libssh.h | 1 +
libssh/channels.c | 51 +++++++++++++++++++++++++++++++++++++++++++++++
2 files changed, 52 insertions(+), 0 deletions(-)
diff --git a/include/libssh/libssh.h b/include/libssh/libssh.h
index f18e406..8ae0faf 100644
--- a/include/libssh/libssh.h
+++ b/include/libssh/libssh.h
@@ -332,6 +332,7 @@ LIBSSH_API int channel_request_shell(ssh_channel channel);
LIBSSH_API int channel_request_subsystem(ssh_channel channel, const char *system);
LIBSSH_API int channel_request_env(ssh_channel channel, const char *name, const char *value);
LIBSSH_API int channel_request_exec(ssh_channel channel, const char *cmd);
+LIBSSH_API int channel_request_send_signal(ssh_channel channel, const char *signal);
LIBSSH_API int channel_request_sftp(ssh_channel channel);
LIBSSH_API int channel_request_x11(ssh_channel channel, int single_connection, const char *protocol,
const char *cookie, int screen_number);
diff --git a/libssh/channels.c b/libssh/channels.c
index 6e70285..ed40589 100644
--- a/libssh/channels.c
+++ b/libssh/channels.c
@@ -1654,6 +1654,57 @@ error:
return rc;
}
+
+/**
+ * @brief Send a signal to remote process (as described in RFC 4254, section 6.9).
+ *
+ * Sends a signal 'signal' to the remote process.
+ * Note, that remote system may not support signals concept.
+ * In such a case this request will be silently ignored.
+ * Only SSH-v2 is supported (I'm not sure about SSH-v1).
+ *
+ * @param channel The channel to send signal.
+ *
+ * @param signal The signal to send (without SIG prefix)
+ * (e.g. "TERM" or "KILL").
+ *
+ * @return SSH_SUCCESS on success, SSH_ERROR on error (including attempt to send signal via SSH-v1 session).
+ *
+ */
+int channel_request_send_signal(ssh_channel channel, const char *signal) {
+ ssh_buffer buffer = NULL;
+ ssh_string encoded_signal = NULL;
+ int rc = SSH_ERROR;
+
+#ifdef WITH_SSH1
+ if (channel->version == 1) {
+ return SSH_ERROR; // TODO: Add support for SSH-v1 if possible.
+ }
+#endif
+
+ buffer = buffer_new();
+ if (buffer == NULL) {
+ goto error;
+ }
+
+ encoded_signal = string_from_char(signal);
+ if (encoded_signal == NULL) {
+ goto error;
+ }
+
+ if (buffer_add_ssh_string(buffer, encoded_signal) < 0) {
+ goto error;
+ }
+
+ rc = channel_request(channel, "signal", buffer, 0);
+error:
+ buffer_free(buffer);
+ string_free(encoded_signal);
+ return rc;
+}
+
+
+
/* TODO : fix the delayed close thing */
/* TODO : fix the blocking behaviours */
--
1.6.3.3
Archive administrator: postmaster@lists.cynapses.org