GNOME Bugzilla – Bug 725651
GSubprocessLauncher: Does not copy the calling process environment.
Last modified: 2014-03-04 15:48:32 UTC
glib2-2.39.91-1.fc21.x86_64 Run the following test program in a environment with SSH_ASKPASS,SSH_AUTH_SOCK set #include <gio/gio.h> GPtrArray *args = NULL; int main() { GSubprocessLauncher *launcher; GError *local_error = NULL; GError **error = &local_error; args = g_ptr_array_new_with_free_func (g_free); g_ptr_array_add (args, "/usr/bin/printenv"); g_ptr_array_add (args, "SSH_ASKPASS"); g_ptr_array_add (args, "SSH_AUTH_SOCK"); g_ptr_array_add (args, NULL); launcher = g_subprocess_launcher_new (G_SUBPROCESS_FLAGS_NONE); g_subprocess_launcher_spawnv (launcher, (const gchar * const *) args->pdata, } Expected result: the contents of the SSH_ASKPASS,SSH_AUTH_SOCK variables on two lines Actual result: nothing
seems g_subprocess_launcher_init should use g_get_environ instead of g_listenv
Created attachment 270902 [details] [review] GSubprocessLauncher: don't get empty environment Use g_get_environ() to get the environment variables with their values instead of g_listenv() which only lists off the keys.
Created attachment 270903 [details] [review] gsubprocess: test environment a bit more Add a test for GSubprocess to test setting, unsetting and inheritance of environment variables. Use communicate() to give it a bit more of a workout as well.
Review of attachment 270903 [details] [review]: ::: gio/tests/gsubprocess.c @@ +1232,3 @@ + g_assert_no_error (error); + + g_assert_cmpstr (out, ==, "C=D\nE=F\n"); I wonder if the order is actually guaranteed here, or if you could also get "E=F\nC=d\n". I guess we can wait for this to fail on some exotic system
Review of attachment 270902 [details] [review]: sure
Review of attachment 270903 [details] [review]: ::: gio/tests/gsubprocess.c @@ +1232,3 @@ + g_assert_no_error (error); + + g_assert_cmpstr (out, ==, "C=D\nE=F\n"); It is guaranteed because its our own implementation of printenv, from the test utility program. See the other file in the patch.
Attachment 270902 [details] pushed as e767204 - GSubprocessLauncher: don't get empty environment Attachment 270903 [details] pushed as 2b11af4 - gsubprocess: test environment a bit more Thanks for the report!