[evolution-data-server] CamelIMAPXServer: Copy child setup gunk from CamelStreamProcess.



commit c65083dc2073906772510f83bacad65dbc2a3f43
Author: Matthew Barnes <mbarnes redhat com>
Date:   Tue Mar 4 08:47:39 2014 -0500

    CamelIMAPXServer: Copy child setup gunk from CamelStreamProcess.

 camel/providers/imapx/camel-imapx-server.c |   30 +++++++++++++++++++++++++++-
 1 files changed, 29 insertions(+), 1 deletions(-)
---
diff --git a/camel/providers/imapx/camel-imapx-server.c b/camel/providers/imapx/camel-imapx-server.c
index 162b34c..f6f2ab4 100644
--- a/camel/providers/imapx/camel-imapx-server.c
+++ b/camel/providers/imapx/camel-imapx-server.c
@@ -26,8 +26,12 @@
  *     GLIB_CHECK_VERSION macros. */
 #define GLIB_DISABLE_DEPRECATION_WARNINGS
 
-#include <time.h>
 #include <errno.h>
+#include <fcntl.h>
+#include <time.h>
+#include <unistd.h>
+#include <sys/ioctl.h>
+#include <sys/types.h>
 #include <glib/gstdio.h>
 #include <glib/gi18n-lib.h>
 #include <gio/gnetworking.h>
@@ -4303,6 +4307,26 @@ imapx_server_set_streams (CamelIMAPXServer *is,
        g_mutex_unlock (&is->priv->stream_lock);
 }
 
+#if GLIB_CHECK_VERSION(2,39,0)
+static void
+imapx_server_child_process_setup (gpointer user_data)
+{
+       gint fd;
+
+       setsid ();
+
+#ifdef TIOCNOTTY
+       /* Detach from the controlling tty if we have one.  Otherwise,
+        * SSH might do something stupid like trying to use it instead
+        * of running $SSH_ASKPASS. */
+       if ((fd = open ("/dev/tty", O_RDONLY)) != -1) {
+               ioctl (fd, TIOCNOTTY, NULL);
+               close (fd);
+       }
+#endif /* TIOCNOTTY */
+}
+#endif
+
 static gboolean
 connect_to_server_process (CamelIMAPXServer *is,
                            const gchar *cmd,
@@ -4332,6 +4356,10 @@ connect_to_server_process (CamelIMAPXServer *is,
                G_SUBPROCESS_FLAGS_STDOUT_PIPE |
                G_SUBPROCESS_FLAGS_STDERR_SILENCE);
 
+       g_subprocess_launcher_set_child_setup (
+               launcher, imapx_server_child_process_setup,
+               NULL, (GDestroyNotify) NULL);
+
        store = camel_imapx_server_ref_store (is);
 
        password = camel_service_get_password (CAMEL_SERVICE (store));


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]