[hotssh] gssh: Dup fd for libssh
- From: Colin Walters <walters src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [hotssh] gssh: Dup fd for libssh
- Date: Thu, 5 Dec 2013 14:41:43 +0000 (UTC)
commit a3125d42b4709b90ba69e9acd6d8c89eecc47711
Author: Colin Walters <walters verbum org>
Date: Thu Dec 5 08:48:18 2013 -0500
gssh: Dup fd for libssh
Unfortunately libssh takes ownership of the fd, so we need to dup it.
libgssh/gssh-connection.c | 10 +++++++++-
1 files changed, 9 insertions(+), 1 deletions(-)
---
diff --git a/libgssh/gssh-connection.c b/libgssh/gssh-connection.c
index 794d6ef..33e1aae 100644
--- a/libgssh/gssh-connection.c
+++ b/libgssh/gssh-connection.c
@@ -26,6 +26,8 @@
#include "libgsystem.h"
+#include <glib-unix.h>
+
enum {
PROP_0,
PROP_ADDRESS,
@@ -696,6 +698,7 @@ on_socket_client_connected (GObject *src,
GError *local_error = NULL;
GError **error = &local_error;
int fd;
+ int duped_fd;
g_assert (src == (GObject*)self->socket_client);
@@ -717,9 +720,14 @@ on_socket_client_connected (GObject *src,
}
fd = g_socket_get_fd (self->socket);
+ do
+ duped_fd = dup (fd);
+ while (G_UNLIKELY (duped_fd == -1 && errno == EINTR));
+ fcntl (duped_fd, F_SETFD, fcntl (duped_fd, F_GETFD) | FD_CLOEXEC);
ssh_set_blocking (self->session, 0);
- ssh_options_set (self->session, SSH_OPTIONS_FD, &fd);
+ /* The session takes ownership of this fd, unfortunately */
+ ssh_options_set (self->session, SSH_OPTIONS_FD, &duped_fd);
ssh_options_set (self->session, SSH_OPTIONS_USER, self->username);
state_transition (self, GSSH_CONNECTION_STATE_HANDSHAKING);
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]