summaryrefslogtreecommitdiff
path: root/src/libotutil
diff options
context:
space:
mode:
authorDan Nicholson <nicholson@endlessm.com>2019-09-06 16:52:15 -0600
committerAtomic Bot <atomic-devel@projectatomic.io>2019-09-07 18:42:22 +0000
commite49060c207fd201f71316bf174e1b467827abc7a (patch)
treea0abf80b6e3e4b0215adf0adbc520424bc1dd31d /src/libotutil
parentd14472a7f04d02d392d2754cfb3cec881aadc704 (diff)
downloadostree-e49060c207fd201f71316bf174e1b467827abc7a.tar.gz
lib/gpg: Use g_spawn_sync to kill gpg-agent
For reasons I don't understand, GSubprocess doesn't play nice with KDE's plasmashell. I assume this has something to do with the GSubprocess using the glib worker thread while plasmashell uses the glib main loop. Instead, just use g_spawn_sync to fork and wait in the current thread. Fixes: #1913 Closes: #1917 Approved by: cgwalters
Diffstat (limited to 'src/libotutil')
-rw-r--r--src/libotutil/ot-gpg-utils.c51
1 files changed, 26 insertions, 25 deletions
diff --git a/src/libotutil/ot-gpg-utils.c b/src/libotutil/ot-gpg-utils.c
index 97a1c756..743d941e 100644
--- a/src/libotutil/ot-gpg-utils.c
+++ b/src/libotutil/ot-gpg-utils.c
@@ -509,31 +509,32 @@ ot_gpgme_kill_agent (const char *homedir)
}
/* Run gpg-connect-agent killagent /bye */
+ g_autoptr(GPtrArray) argv = g_ptr_array_new ();
+ g_ptr_array_add (argv, "gpg-connect-agent");
+ g_ptr_array_add (argv, "--homedir");
+ g_ptr_array_add (argv, (gpointer)homedir);
+ g_ptr_array_add (argv, "killagent");
+ g_ptr_array_add (argv, "/bye");
+ g_ptr_array_add (argv, NULL);
+
g_autoptr(GError) local_error = NULL;
- GSubprocessFlags flags = G_SUBPROCESS_FLAGS_STDOUT_SILENCE | G_SUBPROCESS_FLAGS_STDERR_PIPE;
+ GSpawnFlags flags = G_SPAWN_SEARCH_PATH | G_SPAWN_STDOUT_TO_DEV_NULL;
+ gint proc_status = 0;
+ g_autofree gchar *proc_stderr = NULL;
g_debug ("Killing gpg-agent in %s", homedir);
- g_autoptr(GSubprocess) proc = g_subprocess_new (flags,
- &local_error,
- "gpg-connect-agent",
- "--homedir",
- homedir,
- "killagent",
- "/bye",
- NULL);
- if (proc == NULL) {
- g_debug ("Spawning gpg-connect-agent failed: %s", local_error->message);
- return;
- }
- if (!g_subprocess_wait_check (proc, NULL, &local_error)) {
- /* Dump out stderr on failures */
- GInputStream *stderr_in = g_subprocess_get_stderr_pipe (proc);
- g_autoptr(GOutputStream) stderr_out =
- G_OUTPUT_STREAM (g_unix_output_stream_new (STDERR_FILENO, FALSE));
- g_output_stream_splice (stderr_out, stderr_in, G_OUTPUT_STREAM_SPLICE_NONE,
- NULL, NULL);
-
- g_debug ("Killing GPG agent with gpg-connect-agent failed: %s",
- local_error->message);
- return;
- }
+ if (!g_spawn_sync (NULL, (char **)argv->pdata, NULL, flags, NULL, NULL,
+ NULL, &proc_stderr, &proc_status, &local_error))
+ {
+ g_debug ("Spawning gpg-connect-agent failed: %s", local_error->message);
+ return;
+ }
+ if (!g_spawn_check_exit_status (proc_status, &local_error))
+ {
+ /* Dump out stderr on failures */
+ g_printerr ("%s", proc_stderr);
+
+ g_debug ("Killing GPG agent with gpg-connect-agent failed: %s",
+ local_error->message);
+ return;
+ }
}