[network-manager-libreswan/th/vpn-plugin-debug-bgo766872: 18/22] service: add @out_stdout argument to do_spawn()



commit 4ceace45ad0032a4e89552d9e81f8b442d8412cb
Author: Thomas Haller <thaller redhat com>
Date:   Fri May 27 19:05:00 2016 +0200

    service: add @out_stdout argument to do_spawn()

 src/nm-libreswan-service.c |   34 ++++++++++++++--------------------
 1 files changed, 14 insertions(+), 20 deletions(-)
---
diff --git a/src/nm-libreswan-service.c b/src/nm-libreswan-service.c
index e53d206..9e31b54 100644
--- a/src/nm-libreswan-service.c
+++ b/src/nm-libreswan-service.c
@@ -608,18 +608,12 @@ child_watch_cb (GPid pid, gint status, gpointer user_data)
        g_clear_error (&error);
 }
 
-static gboolean do_spawn (NMLibreswanPlugin *self,
-                          GPid *out_pid,
-                          int *out_stdin,
-                          int *out_stderr,
-                          GError **error,
-                          const char *progname,
-                          ...) G_GNUC_NULL_TERMINATED;
-
+G_GNUC_NULL_TERMINATED
 static gboolean
 do_spawn (NMLibreswanPlugin *self,
           GPid *out_pid,
           int *out_stdin,
+          int *out_stdout,
           int *out_stderr,
           GError **error,
           const char *progname,
@@ -644,11 +638,11 @@ do_spawn (NMLibreswanPlugin *self,
 
        _LOGI ("Spawn: %s", (cmdline = g_strjoinv (" ", (char **) argv->pdata)));
 
-       if (out_stdin || out_stderr) {
+       if (out_stdin || out_stderr || out_stdout) {
                success = g_spawn_async_with_pipes (NULL, (char **) argv->pdata, NULL,
                                                    G_SPAWN_DO_NOT_REAP_CHILD,
                                                    NULL, NULL, &pid, out_stdin,
-                                                   NULL, out_stderr, &local);
+                                                   out_stdout, out_stderr, &local);
        } else {
                success = g_spawn_async (NULL, (char **) argv->pdata, NULL,
                                         G_SPAWN_DO_NOT_REAP_CHILD,
@@ -1562,7 +1556,7 @@ connect_step (NMLibreswanPlugin *self, GError **error)
                priv->connect_step++;
 
        case CONNECT_STEP_CHECK_RUNNING:
-               if (!do_spawn (self, &priv->pid, NULL, NULL, error, priv->ipsec_path, "auto", "--status", 
NULL))
+               if (!do_spawn (self, &priv->pid, NULL, NULL, NULL, error, priv->ipsec_path, "auto", 
"--status", NULL))
                        return FALSE;
                priv->watch_id = g_child_watch_add (priv->pid, check_running_cb, self);
                return TRUE;
@@ -1576,7 +1570,7 @@ connect_step (NMLibreswanPlugin *self, GError **error)
                                return FALSE;
 
                        /* Ensure the right IPsec kernel stack is loaded */
-                       success = do_spawn (self, &priv->pid, NULL, NULL, error, stackman_path, "start", 
NULL);
+                       success = do_spawn (self, &priv->pid, NULL, NULL, NULL, error, stackman_path, 
"start", NULL);
                        if (success)
                                priv->watch_id = g_child_watch_add (priv->pid, child_watch_cb, self);
                        return success;
@@ -1587,7 +1581,7 @@ connect_step (NMLibreswanPlugin *self, GError **error)
        case CONNECT_STEP_CHECK_NSS:
                /* Start the IPsec service */
                if (!priv->openswan) {
-                       success = do_spawn (self, &priv->pid, NULL, NULL, error,
+                       success = do_spawn (self, &priv->pid, NULL, NULL, NULL, error,
                                            priv->ipsec_path, "--checknss", NULL);
                        if (success)
                                priv->watch_id = g_child_watch_add (priv->pid, child_watch_cb, self);
@@ -1599,9 +1593,9 @@ connect_step (NMLibreswanPlugin *self, GError **error)
        case CONNECT_STEP_IPSEC_START:
                /* Start the IPsec service */
                if (priv->openswan)
-                       success = do_spawn (self, &priv->pid, NULL, NULL, error, priv->ipsec_path, "setup", 
"start", NULL);
+                       success = do_spawn (self, &priv->pid, NULL, NULL, NULL, error, priv->ipsec_path, 
"setup", "start", NULL);
                else {
-                       success = do_spawn (self, &priv->pid, NULL, NULL, error,
+                       success = do_spawn (self, &priv->pid, NULL, NULL, NULL, error,
                                            priv->pluto_path, "--config", NM_IPSEC_CONF,
                                            NULL);
                }
@@ -1614,7 +1608,7 @@ connect_step (NMLibreswanPlugin *self, GError **error)
        case CONNECT_STEP_WAIT_READY:
                if (!priv->retries)
                        priv->retries = 30;
-               if (!do_spawn (self, &priv->pid, NULL, NULL, error, priv->ipsec_path, "auto", "--ready", 
NULL))
+               if (!do_spawn (self, &priv->pid, NULL, NULL, NULL, error, priv->ipsec_path, "auto", 
"--ready", NULL))
                        return FALSE;
                priv->watch_id = g_child_watch_add (priv->pid, child_watch_cb, self);
                return TRUE;
@@ -1623,7 +1617,7 @@ connect_step (NMLibreswanPlugin *self, GError **error)
                gs_free char *bus_name = NULL;
                gs_free char *ifupdown_script = NULL;
 
-               if (!do_spawn (self, &priv->pid, &fd, NULL, error, priv->ipsec_path,
+               if (!do_spawn (self, &priv->pid, &fd, NULL, NULL, error, priv->ipsec_path,
                               "auto", "--replace", "--config", "-", uuid, NULL))
                        return FALSE;
                priv->watch_id = g_child_watch_add (priv->pid, child_watch_cb, self);
@@ -1880,13 +1874,13 @@ real_disconnect (NMVpnServicePlugin *plugin, GError **error)
 
        if (!priv->managed) {
                 const char *uuid = nm_connection_get_uuid (priv->connection);
-               ret = do_spawn (plugin, &priv->pid, NULL, NULL, error,
+               ret = do_spawn (plugin, &priv->pid, NULL, NULL, NULL, error,
                                priv->ipsec_path, "auto", "--delete", uuid, NULL);
        } else if (priv->openswan) {
-               ret = do_spawn (plugin, &priv->pid, NULL, NULL, error,
+               ret = do_spawn (plugin, &priv->pid, NULL, NULL, NULL, error,
                                 priv->ipsec_path, "setup", "stop", NULL);
        } else {
-               ret = do_spawn (plugin, &priv->pid, NULL, NULL, error,
+               ret = do_spawn (plugin, &priv->pid, NULL, NULL, NULL, error,
                                priv->whack_path, "--shutdown", NULL);
        }
 


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