[gnome-builder] plugins/podman: Fix envvar setup in launcher



commit d223cf3ed6cf1902354b22a5cd2a4b5a729a0562
Author: Ondřej Míchal <harrymichal seznam cz>
Date:   Sun Sep 6 14:59:35 2020 +0200

    plugins/podman: Fix envvar setup in launcher
    
    The problem with setting envvars could be encountered when 'clear_env'
    was set to 'False' in the runtime launcher. In some cases, the envvar
    did not exist but the index still got incremented, causing problems in
    the 'ide_subprocess_launcher_push_argv' function. With this the index
    is only incremented when the said envvar is set.

 .../podman/gbp-podman-subprocess-launcher.c        | 31 +++++++++++-----------
 1 file changed, 16 insertions(+), 15 deletions(-)
---
diff --git a/src/plugins/podman/gbp-podman-subprocess-launcher.c 
b/src/plugins/podman/gbp-podman-subprocess-launcher.c
index e749d4c61..3b34942da 100644
--- a/src/plugins/podman/gbp-podman-subprocess-launcher.c
+++ b/src/plugins/podman/gbp-podman-subprocess-launcher.c
@@ -42,7 +42,7 @@ static GParamSpec *properties [N_PROPS];
 
 static void
 copy_envvar (IdeSubprocessLauncher *launcher,
-             guint                  position,
+             guint                 *position,
              const gchar           *key)
 {
   const gchar *val;
@@ -50,7 +50,8 @@ copy_envvar (IdeSubprocessLauncher *launcher,
   if ((val = g_getenv (key)))
     {
       g_autofree gchar *arg = g_strdup_printf ("--env=%s=%s", key, val);
-      ide_subprocess_launcher_insert_argv (launcher, position, arg);
+      ide_subprocess_launcher_insert_argv (launcher, *position, arg);
+      (*position)++;
     }
 }
 
@@ -111,19 +112,19 @@ gbp_podman_subprocess_launcher_spawn (IdeSubprocessLauncher  *launcher,
 
       if (!ide_subprocess_launcher_get_clear_env (launcher))
         {
-          copy_envvar (launcher, i++, "COLORTERM");
-          copy_envvar (launcher, i++, "DBUS_SESSION_BUS_ADDRESS");
-          copy_envvar (launcher, i++, "DESKTOP_SESSION");
-          copy_envvar (launcher, i++, "DISPLAY");
-          copy_envvar (launcher, i++, "LANG");
-          copy_envvar (launcher, i++, "SSH_AUTH_SOCK");
-          copy_envvar (launcher, i++, "WAYLAND_DISPLAY");
-          copy_envvar (launcher, i++, "XDG_CURRENT_DESKTOP");
-          copy_envvar (launcher, i++, "XDG_SEAT");
-          copy_envvar (launcher, i++, "XDG_SESSION_DESKTOP");
-          copy_envvar (launcher, i++, "XDG_SESSION_ID");
-          copy_envvar (launcher, i++, "XDG_SESSION_TYPE");
-          copy_envvar (launcher, i++, "XDG_VTNR");
+          copy_envvar (launcher, &i, "COLORTERM");
+          copy_envvar (launcher, &i, "DBUS_SESSION_BUS_ADDRESS");
+          copy_envvar (launcher, &i, "DESKTOP_SESSION");
+          copy_envvar (launcher, &i, "DISPLAY");
+          copy_envvar (launcher, &i, "LANG");
+          copy_envvar (launcher, &i, "SSH_AUTH_SOCK");
+          copy_envvar (launcher, &i, "WAYLAND_DISPLAY");
+          copy_envvar (launcher, &i, "XDG_CURRENT_DESKTOP");
+          copy_envvar (launcher, &i, "XDG_SEAT");
+          copy_envvar (launcher, &i, "XDG_SESSION_DESKTOP");
+          copy_envvar (launcher, &i, "XDG_SESSION_ID");
+          copy_envvar (launcher, &i, "XDG_SESSION_TYPE");
+          copy_envvar (launcher, &i, "XDG_VTNR");
         }
 
       if ((environ_ = ide_subprocess_launcher_get_environ (launcher)))


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