diff --git a/src/libgsystem b/src/libgsystem index 0734be8c..b11ad335 160000 --- a/src/libgsystem +++ b/src/libgsystem @@ -1 +1 @@ -Subproject commit 0734be8c1211ba04ecdd14ff30b6c07dbf3b9a84 +Subproject commit b11ad335f459e3c61b317308da57de441660efd0 diff --git a/src/libotutil/ot-spawn-utils.c b/src/libotutil/ot-spawn-utils.c index 71937e23..f798264b 100644 --- a/src/libotutil/ot-spawn-utils.c +++ b/src/libotutil/ot-spawn-utils.c @@ -26,31 +26,6 @@ #include -gboolean -ot_spawn_sync_checked (const char *cwd, - char **argv, - GCancellable *cancellable, - GError **error) -{ - gboolean ret = FALSE; - gs_unref_object GSSubprocessContext *context = NULL; - gs_unref_object GSSubprocess *proc = NULL; - - context = gs_subprocess_context_new (argv); - if (cwd) - gs_subprocess_context_set_cwd (context, cwd); - - if ((proc = gs_subprocess_new (context, cancellable, error)) == NULL) - goto out; - - if (!gs_subprocess_wait_sync_check (proc, cancellable, error)) - goto out; - - ret = TRUE; - out: - return ret; -} - /** * ot_thread_pool_new_nproc: * diff --git a/src/libotutil/ot-spawn-utils.h b/src/libotutil/ot-spawn-utils.h index 4673e27c..4e85fc85 100644 --- a/src/libotutil/ot-spawn-utils.h +++ b/src/libotutil/ot-spawn-utils.h @@ -27,11 +27,6 @@ G_BEGIN_DECLS -gboolean ot_spawn_sync_checked (const char *cwd, - char **argv, - GCancellable *cancellable, - GError **error); - GThreadPool * ot_thread_pool_new_nproc (GFunc func, gpointer user_data); diff --git a/src/ostree/ot-admin-builtin-deploy.c b/src/ostree/ot-admin-builtin-deploy.c index 94e697a3..127f1d78 100644 --- a/src/ostree/ot-admin-builtin-deploy.c +++ b/src/ostree/ot-admin-builtin-deploy.c @@ -579,19 +579,16 @@ do_update_kernel (OtAdminDeploy *self, GError **error) { gboolean ret = FALSE; - ot_lptrarray GPtrArray *args = NULL; - args = g_ptr_array_new (); - ot_ptrarray_add_many (args, "ostree", "admin", - "--ostree-dir", gs_file_get_path_cached (self->ostree_dir), - "update-kernel", - gs_file_get_path_cached (deploy_path), NULL); - if (opt_no_kernel) - g_ptr_array_add (args, "--modules-only"); - g_ptr_array_add (args, NULL); - - if (!ot_spawn_sync_checked (gs_file_get_path_cached (self->ostree_dir), - (char**)args->pdata, cancellable, error)) + if (!gs_subprocess_simple_run_sync (gs_file_get_path_cached (self->ostree_dir), + GS_SUBPROCESS_STREAM_DISPOSITION_NULL, + cancellable, error, + "ostree", "admin", + "--ostree-dir", gs_file_get_path_cached (self->ostree_dir), + "update-kernel", + gs_file_get_path_cached (deploy_path), + opt_no_kernel ? "--modules-only" : NULL, + NULL)) goto out; ret = TRUE; diff --git a/src/ostree/ot-admin-builtin-prune.c b/src/ostree/ot-admin-builtin-prune.c index 3e5d7553..14ebee6c 100644 --- a/src/ostree/ot-admin-builtin-prune.c +++ b/src/ostree/ot-admin-builtin-prune.c @@ -156,18 +156,15 @@ ot_admin_builtin_prune (int argc, char **argv, GFile *ostree_dir, GError **error if (!opt_no_repo_prune) { - ot_lptrarray GPtrArray *prune_argv = NULL; ot_lfree char *repo_arg = NULL; repo_arg = g_strconcat ("--repo=", gs_file_get_path_cached (repo_path), NULL); - - prune_argv = g_ptr_array_new (); - ot_ptrarray_add_many (prune_argv, "ostree", repo_arg, "prune", "--refs-only", "--depth=0", NULL); - g_ptr_array_add (prune_argv, NULL); - if (!ot_spawn_sync_checked (gs_file_get_path_cached (ostree_dir), - (char**)prune_argv->pdata, - cancellable, error)) + if (!gs_subprocess_simple_run_sync (gs_file_get_path_cached (ostree_dir), + GS_SUBPROCESS_STREAM_DISPOSITION_NULL, + cancellable, error, + "ostree", repo_arg, "prune", "--refs-only", + "--depth=0", NULL)) goto out; } diff --git a/src/ostree/ot-admin-builtin-pull-deploy.c b/src/ostree/ot-admin-builtin-pull-deploy.c index 7fed1e6e..4c67f6b0 100644 --- a/src/ostree/ot-admin-builtin-pull-deploy.c +++ b/src/ostree/ot-admin-builtin-pull-deploy.c @@ -144,34 +144,27 @@ ot_admin_builtin_pull_deploy (int argc, char **argv, GFile *ostree_dir, GError * remote_name = remote_name_from_path (ostree_repo_get_config (repo), deploy_name); - subproc_args = g_ptr_array_new (); { ot_lfree char *repo_arg = g_strconcat ("--repo=", gs_file_get_path_cached (repo_path), NULL); - ot_ptrarray_add_many (subproc_args, "ostree", "pull", repo_arg, remote_name, NULL); - g_ptr_array_add (subproc_args, NULL); - if (!ot_spawn_sync_checked (gs_file_get_path_cached (ostree_dir), - (char**)subproc_args->pdata, - cancellable, error)) + if (!gs_subprocess_simple_run_sync (gs_file_get_path_cached (ostree_dir), + GS_SUBPROCESS_STREAM_DISPOSITION_NULL, + cancellable, error, + "ostree", "pull", repo_arg, remote_name, NULL)) goto out; - - g_clear_pointer (&subproc_args, (GDestroyNotify)g_ptr_array_unref); } - subproc_args = g_ptr_array_new (); { ot_lfree char *opt_ostree_dir_arg = g_strconcat ("--ostree-dir=", gs_file_get_path_cached (ostree_dir), NULL); - ot_ptrarray_add_many (subproc_args, "ostree", "admin", opt_ostree_dir_arg, "deploy", - deploy_name, NULL); - g_ptr_array_add (subproc_args, NULL); - - if (!ot_spawn_sync_checked (gs_file_get_path_cached (ostree_dir), - (char**)subproc_args->pdata, - cancellable, error)) + if (!gs_subprocess_simple_run_sync (gs_file_get_path_cached (ostree_dir), + GS_SUBPROCESS_STREAM_DISPOSITION_NULL, + cancellable, error, + "ostree", "admin", opt_ostree_dir_arg, "deploy", + deploy_name, NULL)) goto out; } diff --git a/src/ostree/ot-admin-builtin-update-kernel.c b/src/ostree/ot-admin-builtin-update-kernel.c index 8d6774e1..0a1b6392 100644 --- a/src/ostree/ot-admin-builtin-update-kernel.c +++ b/src/ostree/ot-admin-builtin-update-kernel.c @@ -84,7 +84,6 @@ update_initramfs (OtAdminUpdateKernel *self, initramfs_file = ot_gfile_from_build_path ("/boot", initramfs_name, NULL); if (!g_file_query_exists (initramfs_file, NULL)) { - ot_lptrarray GPtrArray *mkinitramfs_args = NULL; ot_lobj GFile *tmpdir = NULL; ot_lfree char *initramfs_tmp_path = NULL; ot_lobj GFile *ostree_vardir = NULL; @@ -110,27 +109,24 @@ update_initramfs (OtAdminUpdateKernel *self, if (!g_output_stream_close (tmp_log_out, cancellable, error)) goto out; - mkinitramfs_args = g_ptr_array_new (); /* Note: the hardcoded /tmp path below is not actually a * security flaw, because we've bind-mounted dracut's view * of /tmp to the securely-created tmpdir above. */ - ot_ptrarray_add_many (mkinitramfs_args, - "linux-user-chroot", - "--mount-readonly", "/", - "--mount-proc", "/proc", - "--mount-bind", "/dev", "/dev", - "--mount-bind", gs_file_get_path_cached (ostree_vardir), "/var", - "--mount-bind", gs_file_get_path_cached (tmpdir), "/tmp", - "--mount-bind", gs_file_get_path_cached (ostree_moduledir), "/lib/modules", - deploy_path, - "dracut", "-f", "/tmp/initramfs-ostree.img", release, - NULL); - g_ptr_array_add (mkinitramfs_args, NULL); - g_print ("Generating initramfs using %s...\n", deploy_path); - if (!ot_spawn_sync_checked (NULL, (char**)mkinitramfs_args->pdata, - cancellable, error)) + if (!gs_subprocess_simple_run_sync (NULL, GS_SUBPROCESS_STREAM_DISPOSITION_NULL, + cancellable, error, + "linux-user-chroot", + "--mount-readonly", "/", + "--mount-proc", "/proc", + "--mount-bind", "/dev", "/dev", + "--mount-bind", gs_file_get_path_cached (ostree_vardir), "/var", + "--mount-bind", gs_file_get_path_cached (tmpdir), "/tmp", + "--mount-bind", gs_file_get_path_cached (ostree_moduledir), "/lib/modules", + deploy_path, + "dracut", "-f", "/tmp/initramfs-ostree.img", release, + + NULL)) goto out; initramfs_tmp_file = g_file_get_child (tmpdir, "initramfs-ostree.img"); @@ -241,7 +237,6 @@ update_grub (OtAdminUpdateKernel *self, if (!have_grub_entry) { - ot_lptrarray GPtrArray *grubby_args = NULL; ot_lfree char *add_kernel_arg = NULL; ot_lfree char *initramfs_arg = NULL; ot_lobj GFile *kernel_path = NULL; @@ -257,16 +252,13 @@ update_grub (OtAdminUpdateKernel *self, goto out; } - grubby_args = g_ptr_array_new (); add_kernel_arg = g_strconcat ("--add-kernel=", gs_file_get_path_cached (kernel_path), NULL); initramfs_arg = g_strconcat ("--initrd=", "/boot/initramfs-ostree-", release, ".img", NULL); - ot_ptrarray_add_many (grubby_args, "grubby", "--grub", add_kernel_arg, initramfs_arg, - "--copy-default", "--title=OSTree", NULL); - g_ptr_array_add (grubby_args, NULL); - g_print ("Adding OSTree grub entry...\n"); - if (!ot_spawn_sync_checked (NULL, (char**)grubby_args->pdata, - cancellable, error)) + if (!gs_subprocess_simple_run_sync (NULL, GS_SUBPROCESS_STREAM_DISPOSITION_NULL, + cancellable, error, + "grubby", "--grub", add_kernel_arg, initramfs_arg, + "--copy-default", "--title=OSTree", NULL)) goto out; } else diff --git a/src/ostree/ot-admin-functions.c b/src/ostree/ot-admin-functions.c index e7e3e5ad..0336e80b 100644 --- a/src/ostree/ot-admin-functions.c +++ b/src/ostree/ot-admin-functions.c @@ -55,9 +55,10 @@ ot_admin_ensure_initialized (GFile *ostree_dir, { ot_lfree char *opt_repo_arg = g_strdup_printf ("--repo=%s/repo", gs_file_get_path_cached (ostree_dir)); - const char *child_argv[] = { "ostree", opt_repo_arg, "init", NULL }; - if (!ot_spawn_sync_checked (NULL, (char**)child_argv, cancellable, error)) + if (!gs_subprocess_simple_run_sync (NULL, GS_SUBPROCESS_STREAM_DISPOSITION_NULL, + cancellable, error, + "ostree", opt_repo_arg, "init", NULL)) { g_prefix_error (error, "Failed to initialize repository: "); goto out;