diff --git a/.gitignore b/.gitignore index a29091b8..4d9cb900 100644 --- a/.gitignore +++ b/.gitignore @@ -48,7 +48,6 @@ /config.status.lineno /configure /configure.lineno -/dbus-run-session /gtk-doc.make /insttree/ /libglnx.la diff --git a/Makefile-tests.am b/Makefile-tests.am index 009663ed..c78c2286 100644 --- a/Makefile-tests.am +++ b/Makefile-tests.am @@ -22,11 +22,8 @@ uninstalled_test_scripts = \ $(NULL) uninstalled_test_extra_programs = \ - dbus-run-session \ $(NULL) -dbus_run_session_SOURCES = tests/utils/dbus-run-session.c - check-local: @echo " *** NOTE ***" @echo " \"make check\" only runs unit tests, which have limited coverage currently." @@ -52,13 +49,3 @@ vmoverlay: # development so that e.g. we automatically overlay. vmcheck: vmoverlay @tests/vmcheck.sh - -testenv: - @echo "===== ENTERING TESTENV =====" - test_tmpdir=$$(mktemp -d test.XXXXXX) && \ - cd $$test_tmpdir && \ - env $(BASE_TESTS_ENVIRONMENT) PATH=$(abs_builddir):$$PATH TESTENV=1 \ - sh ../tests/utils/setup-session.sh bash && \ - cd .. && \ - rm -rf $$test_tmpdir - @echo "===== LEAVING TESTENV =====" diff --git a/buildutil/glib-tap.mk b/buildutil/glib-tap.mk index 279625eb..0c904163 100644 --- a/buildutil/glib-tap.mk +++ b/buildutil/glib-tap.mk @@ -117,7 +117,7 @@ installed_test_meta_DATA = $(installed_testcases:=.test) %.test: %$(EXEEXT) Makefile $(AM_V_GEN) (echo '[Test]' > $@.tmp; \ echo 'Type=session' >> $@.tmp; \ - echo 'Exec=$(installed_testdir)/setup-session.sh $(installed_testdir)/$(notdir $<)' >> $@.tmp; \ + echo 'Exec=$(installed_testdir)/$(notdir $<)' >> $@.tmp; \ mv $@.tmp $@) CLEANFILES += $(installed_test_meta_DATA) diff --git a/src/app/libmain.cxx b/src/app/libmain.cxx index 61d17aa1..0eb0ee74 100644 --- a/src/app/libmain.cxx +++ b/src/app/libmain.cxx @@ -220,7 +220,6 @@ rpmostree_option_context_parse (GOptionContext *context, const char *const* *out_install_pkgs, const char *const* *out_uninstall_pkgs, RPMOSTreeSysroot **out_sysroot_proxy, - GBusType *out_bus_type, GError **error) { /* with --version there's no command, don't require a daemon for it */ @@ -302,11 +301,8 @@ rpmostree_option_context_parse (GOptionContext *context, /* ignore errors; we print out a warning if we fail to spawn pkttyagent */ (void)rpmostree_polkit_agent_open (); - if (!rpmostree_load_sysroot (opt_sysroot, - opt_force_peer, - cancellable, + if (!rpmostree_load_sysroot (opt_sysroot, cancellable, out_sysroot_proxy, - out_bus_type, error)) return FALSE; } @@ -393,7 +389,7 @@ rpmostree_handle_subcommand (int argc, char **argv, &argc, &argv, invocation, cancellable, - NULL, NULL, NULL, NULL, NULL); + NULL, NULL, NULL, NULL); if (subcommand_name == NULL) { g_set_error (error, G_IO_ERROR, G_IO_ERROR_FAILED, @@ -508,7 +504,7 @@ rpmostree_main_inner (const rust::Slice args) /* This will not return for some options (e.g. --version). */ (void) rpmostree_option_context_parse (context, NULL, &argc, &argv, NULL, NULL, NULL, NULL, NULL, - NULL, NULL); + NULL); g_autofree char *help = g_option_context_get_help (context, FALSE, NULL); g_printerr ("%s", help); if (command_name == NULL) diff --git a/src/app/rpmostree-builtin-cancel.cxx b/src/app/rpmostree-builtin-cancel.cxx index b7747e04..36ae8f04 100644 --- a/src/app/rpmostree-builtin-cancel.cxx +++ b/src/app/rpmostree-builtin-cancel.cxx @@ -73,7 +73,6 @@ rpmostree_builtin_cancel (int argc, cancellable, NULL, NULL, &sysroot_proxy, - NULL, error)) return FALSE; diff --git a/src/app/rpmostree-builtin-cleanup.cxx b/src/app/rpmostree-builtin-cleanup.cxx index 96344468..e4005347 100644 --- a/src/app/rpmostree-builtin-cleanup.cxx +++ b/src/app/rpmostree-builtin-cleanup.cxx @@ -65,7 +65,6 @@ rpmostree_builtin_cleanup (int argc, cancellable, NULL, NULL, &sysroot_proxy, - NULL, error)) return FALSE; diff --git a/src/app/rpmostree-builtin-db.cxx b/src/app/rpmostree-builtin-db.cxx index ffab0a52..6a7d1f55 100644 --- a/src/app/rpmostree-builtin-db.cxx +++ b/src/app/rpmostree-builtin-db.cxx @@ -61,7 +61,7 @@ rpmostree_db_option_context_parse (GOptionContext *context, argc, argv, invocation, cancellable, - NULL, NULL, NULL, NULL, + NULL, NULL, NULL, error)) return FALSE; diff --git a/src/app/rpmostree-builtin-deploy.cxx b/src/app/rpmostree-builtin-deploy.cxx index ade72081..d8306b77 100644 --- a/src/app/rpmostree-builtin-deploy.cxx +++ b/src/app/rpmostree-builtin-deploy.cxx @@ -78,7 +78,6 @@ rpmostree_builtin_deploy (int argc, context = g_option_context_new ("REVISION"); - GBusType bus_type; if (!rpmostree_option_context_parse (context, option_entries, &argc, &argv, @@ -87,7 +86,6 @@ rpmostree_builtin_deploy (int argc, &install_pkgs, &uninstall_pkgs, &sysroot_proxy, - &bus_type, error)) return FALSE; @@ -133,7 +131,7 @@ rpmostree_builtin_deploy (int argc, { if (!opt_bypass_driver) { - if (!error_if_driver_registered (bus_type, sysroot_proxy, cancellable, error)) + if (!error_if_driver_registered (sysroot_proxy, cancellable, error)) return FALSE; } diff --git a/src/app/rpmostree-builtin-finalize-deployment.cxx b/src/app/rpmostree-builtin-finalize-deployment.cxx index 817836a8..2ac9f1b3 100644 --- a/src/app/rpmostree-builtin-finalize-deployment.cxx +++ b/src/app/rpmostree-builtin-finalize-deployment.cxx @@ -48,7 +48,7 @@ rpmostree_builtin_finalize_deployment (int argc, glnx_unref_object RPMOSTreeSysroot *sysroot_proxy = NULL; if (!rpmostree_option_context_parse (context, option_entries, &argc, &argv, invocation, cancellable, NULL, NULL, - &sysroot_proxy, NULL, error)) + &sysroot_proxy, error)) return FALSE; const char *checksum = NULL; diff --git a/src/app/rpmostree-builtin-initramfs-etc.cxx b/src/app/rpmostree-builtin-initramfs-etc.cxx index c6b9fc37..d678ac95 100644 --- a/src/app/rpmostree-builtin-initramfs-etc.cxx +++ b/src/app/rpmostree-builtin-initramfs-etc.cxx @@ -68,7 +68,6 @@ rpmostree_ex_builtin_initramfs_etc (int argc, cancellable, NULL, NULL, &sysroot_proxy, - NULL, error)) return FALSE; diff --git a/src/app/rpmostree-builtin-initramfs.cxx b/src/app/rpmostree-builtin-initramfs.cxx index b5bdae5b..4a8e69bc 100644 --- a/src/app/rpmostree-builtin-initramfs.cxx +++ b/src/app/rpmostree-builtin-initramfs.cxx @@ -63,7 +63,6 @@ rpmostree_builtin_initramfs (int argc, cancellable, NULL, NULL, &sysroot_proxy, - NULL, error)) return FALSE; diff --git a/src/app/rpmostree-builtin-kargs.cxx b/src/app/rpmostree-builtin-kargs.cxx index d605f807..270a84f0 100644 --- a/src/app/rpmostree-builtin-kargs.cxx +++ b/src/app/rpmostree-builtin-kargs.cxx @@ -181,7 +181,6 @@ rpmostree_builtin_kargs (int argc, cancellable, NULL, NULL, &sysroot_proxy, - NULL, error)) return FALSE; diff --git a/src/app/rpmostree-builtin-rebase.cxx b/src/app/rpmostree-builtin-rebase.cxx index dec46c64..d20bdeb8 100644 --- a/src/app/rpmostree-builtin-rebase.cxx +++ b/src/app/rpmostree-builtin-rebase.cxx @@ -83,7 +83,6 @@ rpmostree_builtin_rebase (int argc, const char *const *install_pkgs = NULL; const char *const *uninstall_pkgs = NULL; - GBusType bus_type; if (!rpmostree_option_context_parse (context, option_entries, &argc, &argv, @@ -92,7 +91,6 @@ rpmostree_builtin_rebase (int argc, &install_pkgs, &uninstall_pkgs, &sysroot_proxy, - &bus_type, error)) return FALSE; @@ -103,7 +101,7 @@ rpmostree_builtin_rebase (int argc, } if (!opt_bypass_driver) - if (!error_if_driver_registered (bus_type, sysroot_proxy, cancellable, error)) + if (!error_if_driver_registered (sysroot_proxy, cancellable, error)) return FALSE; if (!rpmostree_load_os_proxy (sysroot_proxy, opt_osname, diff --git a/src/app/rpmostree-builtin-refresh-md.cxx b/src/app/rpmostree-builtin-refresh-md.cxx index 92382574..de4d2166 100644 --- a/src/app/rpmostree-builtin-refresh-md.cxx +++ b/src/app/rpmostree-builtin-refresh-md.cxx @@ -65,7 +65,6 @@ rpmostree_builtin_refresh_md (int argc, cancellable, NULL, NULL, &sysroot_proxy, - NULL, error)) return FALSE; diff --git a/src/app/rpmostree-builtin-reload.cxx b/src/app/rpmostree-builtin-reload.cxx index 5a5c291c..51998dea 100644 --- a/src/app/rpmostree-builtin-reload.cxx +++ b/src/app/rpmostree-builtin-reload.cxx @@ -50,7 +50,6 @@ rpmostree_builtin_reload (int argc, cancellable, NULL, NULL, &sysroot_proxy, - NULL, error)) return FALSE; diff --git a/src/app/rpmostree-builtin-reset.cxx b/src/app/rpmostree-builtin-reset.cxx index 0e006024..eeb7af8b 100644 --- a/src/app/rpmostree-builtin-reset.cxx +++ b/src/app/rpmostree-builtin-reset.cxx @@ -68,7 +68,6 @@ rpmostree_builtin_reset (int argc, &install_pkgs, &uninstall_pkgs, &sysroot_proxy, - NULL, error)) return FALSE; diff --git a/src/app/rpmostree-builtin-rollback.cxx b/src/app/rpmostree-builtin-rollback.cxx index 30f650c5..01f1942a 100644 --- a/src/app/rpmostree-builtin-rollback.cxx +++ b/src/app/rpmostree-builtin-rollback.cxx @@ -66,7 +66,6 @@ rpmostree_builtin_rollback (int argc, cancellable, NULL, NULL, &sysroot_proxy, - NULL, error)) return FALSE; diff --git a/src/app/rpmostree-builtin-start-daemon.cxx b/src/app/rpmostree-builtin-start-daemon.cxx index 7c1bf2e7..a90e5c91 100644 --- a/src/app/rpmostree-builtin-start-daemon.cxx +++ b/src/app/rpmostree-builtin-start-daemon.cxx @@ -46,12 +46,10 @@ typedef enum { static AppState appstate = APPSTATE_STARTING; static gboolean opt_debug = FALSE; static char *opt_sysroot = NULL; -static gint service_dbus_fd = -1; static GOptionEntry opt_entries[] = { { "debug", 'd', 0, G_OPTION_ARG_NONE, &opt_debug, "Print debug information on stderr", NULL }, { "sysroot", 0, 0, G_OPTION_ARG_STRING, &opt_sysroot, "Use system root SYSROOT (default: /)", "SYSROOT" }, - { "dbus-peer", 0, 0, G_OPTION_ARG_INT, &service_dbus_fd, "Use a peer to peer dbus connection on this fd", "FD" }, { NULL } }; @@ -67,13 +65,6 @@ state_transition (AppState state) g_main_context_wakeup (NULL); } -static void -state_transition_fatal_err (GError *error) -{ - sd_journal_print (LOG_ERR, "%s", error->message); - state_transition (APPSTATE_FLUSHING); -} - static gboolean start_daemon (GDBusConnection *connection, GError **error) @@ -84,7 +75,11 @@ start_daemon (GDBusConnection *connection, "connection", connection, "sysroot-path", opt_sysroot ?: "/", NULL); - return rpm_ostree_daemon != NULL; + if (rpm_ostree_daemon == NULL) + return FALSE; + (void) g_bus_own_name_on_connection (connection, DBUS_NAME, G_BUS_NAME_OWNER_FLAGS_NONE, + NULL, NULL, NULL, NULL); + return TRUE; } static void @@ -95,26 +90,6 @@ on_bus_name_released (GDBusConnection *connection, state_transition (APPSTATE_EXITING); } -static void -on_peer_acquired (GObject *source, - GAsyncResult *result, - gpointer user_data) -{ - g_autoptr(GError) error = NULL; - g_autoptr(GDBusConnection) connection = g_dbus_connection_new_finish (result, &error); - if (!connection) - { - state_transition_fatal_err (error); - return; - } - - if (!start_daemon (connection, &error)) - { - state_transition_fatal_err (error); - return; - } -} - static gboolean on_sigint (gpointer user_data) { @@ -250,29 +225,6 @@ on_log_handler (const gchar *log_domain, sd_journal_print (priority, "%s", message); } - -static gboolean -connect_to_peer (int fd, GError **error) -{ - g_autoptr(GSocketConnection) stream = NULL; - g_autoptr(GSocket) socket = NULL; - g_autofree gchar *guid = NULL; - - socket = g_socket_new_from_fd (fd, error); - if (!socket) - return FALSE; - - stream = g_socket_connection_factory_create_connection (socket); - g_assert_nonnull (stream); - - guid = g_dbus_generate_guid (); - g_dbus_connection_new (G_IO_STREAM (stream), guid, - (GDBusConnectionFlags)(G_DBUS_CONNECTION_FLAGS_AUTHENTICATION_SERVER | - G_DBUS_CONNECTION_FLAGS_DELAY_MESSAGE_PROCESSING), - NULL, NULL, on_peer_acquired, NULL); - return TRUE; -} - gboolean rpmostree_builtin_start_daemon (int argc, char **argv, @@ -305,31 +257,11 @@ rpmostree_builtin_start_daemon (int argc, g_unix_signal_add (SIGINT, on_sigint, NULL); g_unix_signal_add (SIGTERM, on_sigint, NULL); - g_autoptr(GDBusConnection) bus = NULL; - if (service_dbus_fd == -1) - { - GBusType bus_type; - - /* To facilitate testing, use whichever message bus activated - * this process. If the process was started directly, assume - * the system bus. */ - if (g_getenv ("DBUS_STARTER_BUS_TYPE") != NULL) - bus_type = G_BUS_TYPE_STARTER; - else if (g_getenv ("RPMOSTREE_USE_SESSION_BUS") != NULL) - bus_type = G_BUS_TYPE_SESSION; - else - bus_type = G_BUS_TYPE_SYSTEM; - - /* Get an explicit ref to the bus so we can use it later */ - bus = g_bus_get_sync (bus_type, NULL, error); - if (!bus) - return FALSE; - if (!start_daemon (bus, error)) - return FALSE; - (void) g_bus_own_name_on_connection (bus, DBUS_NAME, G_BUS_NAME_OWNER_FLAGS_NONE, - NULL, NULL, NULL, NULL); - } - else if (!connect_to_peer (service_dbus_fd, error)) + /* Get an explicit ref to the bus so we can use it later */ + g_autoptr(GDBusConnection) bus = g_bus_get_sync (G_BUS_TYPE_SYSTEM, NULL, error); + if (!bus) + return FALSE; + if (!start_daemon (bus, error)) return FALSE; state_transition (APPSTATE_RUNNING); diff --git a/src/app/rpmostree-builtin-status.cxx b/src/app/rpmostree-builtin-status.cxx index 5c057a35..d31497a3 100644 --- a/src/app/rpmostree-builtin-status.cxx +++ b/src/app/rpmostree-builtin-status.cxx @@ -341,7 +341,6 @@ get_update_driver_state (RPMOSTreeSysroot *sysroot_proxy, static gboolean print_daemon_state (RPMOSTreeSysroot *sysroot_proxy, - GBusType bus_type, GCancellable *cancellable, GError **error) { @@ -370,16 +369,13 @@ print_daemon_state (RPMOSTreeSysroot *sysroot_proxy, g_print ("AutomaticUpdatesDriver: %s\n", update_driver_name); /* only try to get unit's StatusText if we're on the system bus */ - if (bus_type == G_BUS_TYPE_SYSTEM) - { - g_autofree const char *update_driver_state = NULL; - g_autoptr(GError) local_error = NULL; - if (!get_update_driver_state (sysroot_proxy, update_driver_sd_unit, - &update_driver_state, cancellable, &local_error)) - g_printerr ("%s", local_error->message); - else if (update_driver_state) - g_print (" DriverState: %s\n", update_driver_state); - } + g_autofree const char *update_driver_state = NULL; + g_autoptr(GError) local_error = NULL; + if (!get_update_driver_state (sysroot_proxy, update_driver_sd_unit, + &update_driver_state, cancellable, &local_error)) + g_printerr ("%s", local_error->message); + else if (update_driver_state) + g_print (" DriverState: %s\n", update_driver_state); } else if (g_str_equal (policy, "none")) { @@ -393,60 +389,51 @@ print_daemon_state (RPMOSTreeSysroot *sysroot_proxy, { g_print ("AutomaticUpdates: %s", policy); - /* don't try to get info from systemd if we're not on the system bus */ - if (bus_type != G_BUS_TYPE_SYSTEM) - g_print ("\n"); - else + AutoUpdateSdState state; + g_autofree char *last_run = NULL; + g_print ("; "); + GDBusConnection *connection = + g_dbus_proxy_get_connection (G_DBUS_PROXY (sysroot_proxy)); + if (!get_last_auto_update_run (connection, &state, &last_run, cancellable, error)) + return FALSE; + switch (state) { - AutoUpdateSdState state; - g_autofree char *last_run = NULL; - - g_print ("; "); - - GDBusConnection *connection = - g_dbus_proxy_get_connection (G_DBUS_PROXY (sysroot_proxy)); - if (!get_last_auto_update_run (connection, &state, &last_run, cancellable, error)) - return FALSE; - - switch (state) - { - case AUTO_UPDATE_SDSTATE_TIMER_UNKNOWN: - { - g_print ("%s: unknown state\n", RPMOSTREE_AUTOMATIC_TIMER_UNIT); - break; - } - case AUTO_UPDATE_SDSTATE_TIMER_INACTIVE: - { - g_print ("%s: inactive\n", RPMOSTREE_AUTOMATIC_TIMER_UNIT); - break; - } - case AUTO_UPDATE_SDSTATE_SERVICE_FAILED: - { - g_print ("%s: %s%slast run failed%s%s\n", - RPMOSTREE_AUTOMATIC_SERVICE_UNIT, - get_red_start (), get_bold_start (), - get_bold_end (), get_red_end ()); - break; - } - case AUTO_UPDATE_SDSTATE_SERVICE_RUNNING: - { - g_print ("%s: running\n", RPMOSTREE_AUTOMATIC_SERVICE_UNIT); - break; - } - case AUTO_UPDATE_SDSTATE_SERVICE_EXITED: - { - if (last_run) - /* e.g. "last run 4h 32min ago" */ - g_print ("%s: last run %s\n", RPMOSTREE_AUTOMATIC_TIMER_UNIT, last_run); - else - g_print ("%s: no runs since boot\n", RPMOSTREE_AUTOMATIC_TIMER_UNIT); - break; - } - default: - { - g_assert_not_reached (); - } - } + case AUTO_UPDATE_SDSTATE_TIMER_UNKNOWN: + { + g_print ("%s: unknown state\n", RPMOSTREE_AUTOMATIC_TIMER_UNIT); + break; + } + case AUTO_UPDATE_SDSTATE_TIMER_INACTIVE: + { + g_print ("%s: inactive\n", RPMOSTREE_AUTOMATIC_TIMER_UNIT); + break; + } + case AUTO_UPDATE_SDSTATE_SERVICE_FAILED: + { + g_print ("%s: %s%slast run failed%s%s\n", + RPMOSTREE_AUTOMATIC_SERVICE_UNIT, + get_red_start (), get_bold_start (), + get_bold_end (), get_red_end ()); + break; + } + case AUTO_UPDATE_SDSTATE_SERVICE_RUNNING: + { + g_print ("%s: running\n", RPMOSTREE_AUTOMATIC_SERVICE_UNIT); + break; + } + case AUTO_UPDATE_SDSTATE_SERVICE_EXITED: + { + if (last_run) + /* e.g. "last run 4h 32min ago" */ + g_print ("%s: last run %s\n", RPMOSTREE_AUTOMATIC_TIMER_UNIT, last_run); + else + g_print ("%s: no runs since boot\n", RPMOSTREE_AUTOMATIC_TIMER_UNIT); + break; + } + default: + { + g_assert_not_reached (); + } } } @@ -1102,7 +1089,6 @@ rpmostree_builtin_status (int argc, glnx_unref_object RPMOSTreeOS *os_proxy = NULL; glnx_unref_object RPMOSTreeSysroot *sysroot_proxy = NULL; - GBusType bus_type; if (!rpmostree_option_context_parse (context, option_entries, &argc, &argv, @@ -1110,7 +1096,6 @@ rpmostree_builtin_status (int argc, cancellable, NULL, NULL, &sysroot_proxy, - &bus_type, error)) return FALSE; @@ -1185,7 +1170,7 @@ rpmostree_builtin_status (int argc, } else { - if (!print_daemon_state (sysroot_proxy, bus_type, cancellable, error)) + if (!print_daemon_state (sysroot_proxy, cancellable, error)) return FALSE; gboolean printed_cached_update = FALSE; @@ -1372,7 +1357,7 @@ rpmostree_ex_builtin_history (int argc, &argc, &argv, invocation, cancellable, - NULL, NULL, NULL, NULL, + NULL, NULL, NULL, error)) return FALSE; diff --git a/src/app/rpmostree-builtin-upgrade.cxx b/src/app/rpmostree-builtin-upgrade.cxx index c1161060..aaf0fc8c 100644 --- a/src/app/rpmostree-builtin-upgrade.cxx +++ b/src/app/rpmostree-builtin-upgrade.cxx @@ -77,7 +77,6 @@ rpmostree_builtin_upgrade (int argc, const char *const *install_pkgs = NULL; const char *const *uninstall_pkgs = NULL; - GBusType bus_type; if (!rpmostree_option_context_parse (context, option_entries, &argc, &argv, @@ -86,7 +85,6 @@ rpmostree_builtin_upgrade (int argc, &install_pkgs, &uninstall_pkgs, &sysroot_proxy, - &bus_type, error)) return FALSE; @@ -132,7 +130,7 @@ rpmostree_builtin_upgrade (int argc, } if (!opt_bypass_driver) - if (!error_if_driver_registered (bus_type, sysroot_proxy, cancellable, error)) + if (!error_if_driver_registered (sysroot_proxy, cancellable, error)) return FALSE; g_autoptr(GVariant) previous_deployment = rpmostree_os_dup_default_deployment (os_proxy); diff --git a/src/app/rpmostree-builtin-usroverlay.cxx b/src/app/rpmostree-builtin-usroverlay.cxx index 71f6bcca..5973022c 100644 --- a/src/app/rpmostree-builtin-usroverlay.cxx +++ b/src/app/rpmostree-builtin-usroverlay.cxx @@ -50,7 +50,6 @@ rpmostree_builtin_usroverlay (int argc, cancellable, NULL, NULL, &sysroot_proxy, - NULL, error)) return FALSE; diff --git a/src/app/rpmostree-builtins.h b/src/app/rpmostree-builtins.h index 5b6ae003..9b8d4dd9 100644 --- a/src/app/rpmostree-builtins.h +++ b/src/app/rpmostree-builtins.h @@ -72,7 +72,6 @@ rpmostree_option_context_parse (GOptionContext *context, const char *const* *out_install_pkgs, const char *const* *out_uninstall_pkgs, RPMOSTreeSysroot **out_sysroot_proxy, - GBusType *out_bus_type, GError **error); int diff --git a/src/app/rpmostree-clientlib.cxx b/src/app/rpmostree-clientlib.cxx index 5f2d0efc..975fe518 100644 --- a/src/app/rpmostree-clientlib.cxx +++ b/src/app/rpmostree-clientlib.cxx @@ -48,97 +48,6 @@ impl_transaction_get_response_sync (GDBusConnection *connection, #define RPMOSTREE_CLI_ID "cli" -static void -child_setup_pdeathsig (void *unused) -{ - if (prctl (PR_SET_PDEATHSIG, SIGTERM) < 0) - err (EXIT_FAILURE, "prctl(PR_SET_PDEATHSIG)"); -} - -static GDBusConnection* -get_connection_for_path (const char *sysroot, - gboolean force_peer, - GBusType *out_bus_type, - GCancellable *cancellable, - GError **error) -{ - /* This is only intended for use by installed tests. - * Note that it disregards the 'sysroot' and 'force_peer' options - * and assumes the service activation command has been configured - * to use the desired system root path. */ - if (g_getenv ("RPMOSTREE_USE_SESSION_BUS") != NULL) - { - if (sysroot != NULL) - g_warning ("RPMOSTREE_USE_SESSION_BUS set, ignoring --sysroot=%s", sysroot); - - /* NB: as opposed to other early returns, this is _also_ a happy path */ - GDBusConnection *ret = g_bus_get_sync (G_BUS_TYPE_SESSION, cancellable, error); - if (!ret) - return (GDBusConnection*)(glnx_prefix_error_null (error, "Connecting to session bus")); - - *out_bus_type = G_BUS_TYPE_SESSION; - return ret; - } - - if (sysroot == NULL) - sysroot = "/"; - - if (g_strcmp0 ("/", sysroot) == 0 && force_peer == FALSE) - { - /* NB: as opposed to other early returns, this is _also_ a happy path */ - GDBusConnection *ret = g_bus_get_sync (G_BUS_TYPE_SYSTEM, cancellable, error); - if (!ret) - return (GDBusConnection*)(glnx_prefix_error_null (error, "Connecting to system bus")); - - *out_bus_type = G_BUS_TYPE_SYSTEM; - return ret; - } - - gchar buffer[16]; - int pair[2]; - const gchar *args[] = { - "rpm-ostree", - "start-daemon", - "--sysroot", sysroot, - "--dbus-peer", buffer, - NULL - }; - - g_print ("Running in single user mode. Be sure no other users are modifying the system\n"); - if (socketpair (AF_UNIX, SOCK_STREAM, 0, pair) < 0) - return (GDBusConnection*)glnx_null_throw_errno_prefix (error, "couldn't create socket pair"); - - g_snprintf (buffer, sizeof (buffer), "%d", pair[1]); - - g_autoptr(GSocket) socket = g_socket_new_from_fd (pair[0], error); - if (socket == NULL) - { - close (pair[0]); - close (pair[1]); - return NULL; - } - - if (!g_spawn_async (NULL, (gchar **)args, NULL, - static_cast(G_SPAWN_LEAVE_DESCRIPTORS_OPEN), - child_setup_pdeathsig, NULL, NULL, error)) - { - close (pair[1]); - return NULL; - } - - g_autoptr(GSocketConnection) stream = - g_socket_connection_factory_create_connection (socket); - g_autoptr(GDBusConnection) connection = - g_dbus_connection_new_sync (G_IO_STREAM (stream), NULL, - G_DBUS_CONNECTION_FLAGS_AUTHENTICATION_CLIENT, - NULL, cancellable, error); - if (!connection) - return NULL; - - *out_bus_type = G_BUS_TYPE_NONE; - return connection; -} - /* Used to close race conditions by ensuring the daemon status is up-to-date */ static void on_reload_done (GObject *src, @@ -166,19 +75,16 @@ await_reload_sync (RPMOSTreeSysroot *sysroot_proxy) * is in the process of auto-exiting. */ static gboolean -app_load_sysroot_impl (const char *sysroot, gboolean force_peer, +app_load_sysroot_impl (const char *sysroot, GCancellable *cancellable, - GDBusConnection **out_conn, GBusType *out_bus_type, + GDBusConnection **out_conn, GError **error) { const char *bus_name = NULL; - glnx_unref_object GDBusConnection *connection = NULL; - GBusType bus_type; - connection = get_connection_for_path (sysroot, force_peer, &bus_type, - cancellable, error); - if (connection == NULL) - return FALSE; + g_autoptr(GDBusConnection) connection = g_bus_get_sync (G_BUS_TYPE_SYSTEM, cancellable, error); + if (!connection) + return glnx_prefix_error (error, "Connecting to system bus"); if (g_dbus_connection_get_unique_name (connection) != NULL) bus_name = BUS_NAME; @@ -241,8 +147,6 @@ app_load_sysroot_impl (const char *sysroot, gboolean force_peer, } *out_conn = util::move_nullify(connection); - if (out_bus_type) - *out_bus_type = bus_type; return TRUE; } @@ -253,11 +157,10 @@ new_client_connection() { g_autoptr(GError) local_error = NULL; GDBusConnection *conn = NULL; - GBusType bus_type; - if (!app_load_sysroot_impl(NULL, false, NULL, &conn, &bus_type, &local_error)) + if (!app_load_sysroot_impl("/", NULL, &conn, &local_error)) util::throw_gerror(local_error); - return std::make_unique(conn, bus_type); + return std::make_unique(conn); } // Connect to a transaction DBus and monitor its progress synchronously, @@ -282,8 +185,6 @@ ClientConnection::transaction_connect_progress_sync(const rust::Str address) con /** * rpmostree_load_sysroot -* @sysroot: sysroot path -* @force_peer: Force a peer connection * @cancellable: A GCancellable * @out_sysroot: (out) Return location for sysroot * @error: A pointer to a GError pointer. @@ -291,17 +192,14 @@ ClientConnection::transaction_connect_progress_sync(const rust::Str address) con * Returns: True on success **/ gboolean -rpmostree_load_sysroot (gchar *sysroot, - gboolean force_peer, - GCancellable *cancellable, +rpmostree_load_sysroot (const char *sysroot, + GCancellable *cancellable, RPMOSTreeSysroot **out_sysroot_proxy, - GBusType *out_bus_type, - GError **error) + GError **error) { g_autoptr(GDBusConnection) connection = NULL; - GBusType bus_type; - if (!app_load_sysroot_impl (sysroot, force_peer, cancellable, &connection, &bus_type, error)) + if (!app_load_sysroot_impl (sysroot, cancellable, &connection, error)) return FALSE; const char *bus_name; @@ -319,8 +217,6 @@ rpmostree_load_sysroot (gchar *sysroot, await_reload_sync (sysroot_proxy); *out_sysroot_proxy = util::move_nullify (sysroot_proxy); - if (out_bus_type) - *out_bus_type = bus_type; return TRUE; } @@ -1731,8 +1627,7 @@ check_sd_unit_contains_pid (char *sd_unit, /* Throw an error if an updates driver is registered and active. */ gboolean -error_if_driver_registered (GBusType bus_type, - RPMOSTreeSysroot *sysroot_proxy, +error_if_driver_registered (RPMOSTreeSysroot *sysroot_proxy, GCancellable *cancellable, GError **error) { @@ -1763,17 +1658,14 @@ error_if_driver_registered (GBusType bus_type, update_driver_name, update_driver_sd_unit); g_string_append_printf (error_msg, "See %s's documentation", update_driver_name); // Only try to get unit's `Documentation` and check unit's state if we're on the system bus. - if (bus_type == G_BUS_TYPE_SYSTEM) - { - gboolean sd_unit_is_active = TRUE; - if (!check_sd_unit_state_is_active (update_driver_sd_unit, &sd_unit_is_active, - connection, cancellable, error)) - return FALSE; - // Ignore driver if driver's `ActiveState` is not "active", even if registered. - if (!sd_unit_is_active) - return TRUE; - append_docs_to_str (error_msg, connection, update_driver_sd_unit, cancellable); - } + gboolean sd_unit_is_active = TRUE; + if (!check_sd_unit_state_is_active (update_driver_sd_unit, &sd_unit_is_active, + connection, cancellable, error)) + return FALSE; + // Ignore driver if driver's `ActiveState` is not "active", even if registered. + if (!sd_unit_is_active) + return TRUE; + append_docs_to_str (error_msg, connection, update_driver_sd_unit, cancellable); g_string_append_printf (error_msg, "Use --bypass-driver to bypass %s and perform the operation anyways", update_driver_name); diff --git a/src/app/rpmostree-clientlib.h b/src/app/rpmostree-clientlib.h index 59671f4a..aacf283e 100644 --- a/src/app/rpmostree-clientlib.h +++ b/src/app/rpmostree-clientlib.h @@ -37,9 +37,8 @@ namespace rpmostreecxx { class ClientConnection final { private: GDBusConnection *conn; - GBusType bus_type; public: - ClientConnection(GDBusConnection *connp, GBusType bus_typep) : conn(connp), bus_type(bus_typep) {} + ClientConnection(GDBusConnection *connp) : conn(connp) {} ~ClientConnection() { g_clear_object(&conn); } @@ -48,10 +47,6 @@ public: return *conn; } - GBusType get_bus_type() const { - return bus_type; - } - void transaction_connect_progress_sync(const rust::Str address) const; }; @@ -66,11 +61,9 @@ G_BEGIN_DECLS #define BUS_NAME "org.projectatomic.rpmostree1" gboolean -rpmostree_load_sysroot (gchar *sysroot, - gboolean force_peer, - GCancellable *cancellable, +rpmostree_load_sysroot (const char *sysroot, + GCancellable *cancellable, RPMOSTreeSysroot **out_sysroot_proxy, - GBusType *out_bus_type, GError **error); gboolean @@ -171,8 +164,7 @@ get_sd_unit_objpath (GDBusConnection *connection, GError **error); gboolean -error_if_driver_registered (GBusType bus_type, - RPMOSTreeSysroot *sysroot_proxy, +error_if_driver_registered (RPMOSTreeSysroot *sysroot_proxy, GCancellable *cancellable, GError **error); diff --git a/src/app/rpmostree-compose-builtin-tree.cxx b/src/app/rpmostree-compose-builtin-tree.cxx index 7fec8808..4d88ee95 100644 --- a/src/app/rpmostree-compose-builtin-tree.cxx +++ b/src/app/rpmostree-compose-builtin-tree.cxx @@ -1197,7 +1197,7 @@ rpmostree_compose_builtin_install (int argc, &argc, &argv, invocation, cancellable, - NULL, NULL, NULL, NULL, + NULL, NULL, NULL, error)) return FALSE; @@ -1264,7 +1264,7 @@ rpmostree_compose_builtin_postprocess (int argc, &argc, &argv, invocation, cancellable, - NULL, NULL, NULL, NULL, + NULL, NULL, NULL, error)) return FALSE; @@ -1327,7 +1327,7 @@ rpmostree_compose_builtin_commit (int argc, &argc, &argv, invocation, cancellable, - NULL, NULL, NULL, NULL, + NULL, NULL, NULL, error)) return FALSE; @@ -1373,7 +1373,7 @@ rpmostree_compose_builtin_tree (int argc, &argc, &argv, invocation, cancellable, - NULL, NULL, NULL, NULL, + NULL, NULL, NULL, error)) return FALSE; @@ -1437,7 +1437,7 @@ rpmostree_compose_builtin_extensions (int argc, &argc, &argv, invocation, cancellable, - NULL, NULL, NULL, NULL, + NULL, NULL, NULL, error)) return FALSE; diff --git a/src/app/rpmostree-override-builtins.cxx b/src/app/rpmostree-override-builtins.cxx index ca435ff0..e187d5ad 100644 --- a/src/app/rpmostree-override-builtins.cxx +++ b/src/app/rpmostree-override-builtins.cxx @@ -156,7 +156,6 @@ rpmostree_override_builtin_replace (int argc, char **argv, &install_pkgs, &uninstall_pkgs, &sysroot_proxy, - NULL, error)) return FALSE; @@ -198,7 +197,6 @@ rpmostree_override_builtin_remove (int argc, char **argv, &install_pkgs, &uninstall_pkgs, &sysroot_proxy, - NULL, error)) return FALSE; @@ -240,7 +238,6 @@ rpmostree_override_builtin_reset (int argc, char **argv, &install_pkgs, &uninstall_pkgs, &sysroot_proxy, - NULL, error)) return FALSE; diff --git a/src/app/rpmostree-pkg-builtins.cxx b/src/app/rpmostree-pkg-builtins.cxx index 0597f4b0..9ce16aea 100644 --- a/src/app/rpmostree-pkg-builtins.cxx +++ b/src/app/rpmostree-pkg-builtins.cxx @@ -169,7 +169,6 @@ rpmostree_builtin_install (int argc, cancellable, NULL, NULL, &sysroot_proxy, - NULL, error)) return FALSE; @@ -220,7 +219,6 @@ rpmostree_builtin_uninstall (int argc, cancellable, NULL, NULL, &sysroot_proxy, - NULL, error)) return FALSE; diff --git a/src/daemon/rpmostreed-sysroot.cxx b/src/daemon/rpmostreed-sysroot.cxx index 1218a3c0..c930c22e 100644 --- a/src/daemon/rpmostreed-sysroot.cxx +++ b/src/daemon/rpmostreed-sysroot.cxx @@ -542,9 +542,6 @@ rpmostreed_sysroot_init (RpmostreedSysroot *self) self->monitor = NULL; - if (g_getenv ("RPMOSTREE_USE_SESSION_BUS") != NULL) - self->on_session_bus = TRUE; - /* Only use polkit when running as root on system bus; self-tests don't need it */ if (!self->on_session_bus) { diff --git a/tests/common/libtest.sh b/tests/common/libtest.sh index 60c681a5..10a77eec 100644 --- a/tests/common/libtest.sh +++ b/tests/common/libtest.sh @@ -99,13 +99,6 @@ check_root_test () fi } -ensure_dbus () -{ - if test -z "$RPMOSTREE_USE_SESSION_BUS"; then - exec "$topsrcdir/tests/utils/setup-session.sh" "$self" - fi -} - # https://github.com/ostreedev/ostree/commit/47b4dd1b38e422254afa67756873957c25aeab6d # Unfortunately, introspection uses dlopen(), which doesn't quite # work when the DSO is compiled with ASAN but the outer executable diff --git a/tests/utils/dbus-run-session.c b/tests/utils/dbus-run-session.c deleted file mode 100644 index 441b9d26..00000000 --- a/tests/utils/dbus-run-session.c +++ /dev/null @@ -1,464 +0,0 @@ -/* -*- mode: C; c-file-style: "gnu"; indent-tabs-mode: nil; -*- */ -/* dbus-run-session.c - run a child process in its own session - * - * Copyright © 2003-2006 Red Hat, Inc. - * Copyright © 2006 Thiago Macieira - * Copyright © 2011-2012 Nokia Corporation - * - * Licensed under the Academic Free License version 2.1 - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA - * - */ - -#include - -#include -#include -#include -#include -#include -#include - -#include -#include -#include - -#define VERSION "0" - -#define MAX_ADDR_LEN 512 -#define PIPE_READ_END 0 -#define PIPE_WRITE_END 1 - -/* PROCESSES - * - * If you are in a shell and run "dbus-run-session myapp", here is what - * happens (compare and contrast with dbus-launch): - * - * shell - * \- dbus-run-session myapp - * \- dbus-daemon --nofork --print-address --session - * \- myapp - * - * All processes are long-running. - * - * When myapp exits, dbus-run-session kills dbus-daemon and terminates. - * - * If dbus-daemon exits, dbus-run-session warns and continues to run. - * - * PIPES - * - * dbus-daemon --print-address -> bus_address_pipe -> d-r-s - */ - -static const char me[] = "dbus-run-session"; - -static void -usage (int ecode) -{ - fprintf (stderr, - "%s [OPTIONS] [--] PROGRAM [ARGUMENTS]\n" - "%s --version\n" - "%s --help\n" - "\n" - "Options:\n" - "--dbus-daemon=BINARY run BINARY instead of dbus-daemon\n" - "--config-file=FILENAME pass to dbus-daemon instead of --session\n" - "\n", - me, me, me); - exit (ecode); -} - -static void -version (void) -{ - printf ("%s %s\n" - "Copyright (C) 2003-2006 Red Hat, Inc.\n" - "Copyright (C) 2006 Thiago Macieira\n" - "Copyright © 2011-2012 Nokia Corporation\n" - "\n" - "This is free software; see the source for copying conditions.\n" - "There is NO warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.\n", - me, VERSION); - exit (0); -} - -static void -oom (void) -{ - fprintf (stderr, "%s: out of memory\n", me); - exit (1); -} - -typedef enum -{ - READ_STATUS_OK, /**< Read succeeded */ - READ_STATUS_ERROR, /**< Some kind of error */ - READ_STATUS_EOF /**< EOF returned */ -} ReadStatus; - -static ReadStatus -read_line (int fd, - char *buf, - size_t maxlen) -{ - size_t bytes = 0; - ReadStatus retval; - - memset (buf, '\0', maxlen); - maxlen -= 1; /* ensure nul term */ - - retval = READ_STATUS_OK; - - while (1) - { - ssize_t chunk; - size_t to_read; - - again: - to_read = maxlen - bytes; - - if (to_read == 0) - break; - - chunk = read (fd, - buf + bytes, - to_read); - if (chunk < 0 && errno == EINTR) - goto again; - - if (chunk < 0) - { - retval = READ_STATUS_ERROR; - break; - } - else if (chunk == 0) - { - retval = READ_STATUS_EOF; - break; /* EOF */ - } - else /* chunk > 0 */ - bytes += chunk; - } - - if (retval == READ_STATUS_EOF && - bytes > 0) - retval = READ_STATUS_OK; - - /* whack newline */ - if (retval != READ_STATUS_ERROR && - bytes > 0 && - buf[bytes-1] == '\n') - buf[bytes-1] = '\0'; - - return retval; -} - -static void -exec_dbus_daemon (const char *dbus_daemon, - int bus_address_pipe[2], - const char *config_file) -{ - /* Child process, which execs dbus-daemon or dies trying */ -#define MAX_FD_LEN 64 - char write_address_fd_as_string[MAX_FD_LEN]; - - close (bus_address_pipe[PIPE_READ_END]); - - sprintf (write_address_fd_as_string, "%d", bus_address_pipe[PIPE_WRITE_END]); - - execlp (dbus_daemon, - dbus_daemon, - "--nofork", - "--print-address", write_address_fd_as_string, - config_file ? "--config-file" : "--session", - config_file, /* has to be last in this varargs list */ - NULL); - - fprintf (stderr, "%s: failed to execute message bus daemon '%s': %s\n", - me, dbus_daemon, strerror (errno)); -} - -static void -exec_app (int prog_arg, char **argv) -{ - execvp (argv[prog_arg], argv + prog_arg); - - fprintf (stderr, "%s: failed to exec '%s': %s\n", me, argv[prog_arg], - strerror (errno)); - exit (1); -} - -int -main (int argc, char **argv) -{ - int prog_arg = 0; - int bus_address_pipe[2] = { 0, 0 }; - const char *config_file = NULL; - const char *dbus_daemon = NULL; - char bus_address[MAX_ADDR_LEN] = { 0 }; - const char *prev_arg = NULL; - int i = 1; - int requires_arg = 0; - pid_t bus_pid; - pid_t app_pid; - - while (i < argc) - { - const char *arg = argv[i]; - - if (requires_arg) - { - const char **arg_dest; - - assert (prev_arg != NULL); - - if (strcmp (prev_arg, "--config-file") == 0) - { - arg_dest = &config_file; - } - else if (strcmp (prev_arg, "--dbus-daemon") == 0) - { - arg_dest = &dbus_daemon; - } - else - { - /* shouldn't happen */ - fprintf (stderr, "%s: internal error: %s not fully implemented\n", - me, prev_arg); - return 127; - } - - if (*arg_dest != NULL) - { - fprintf (stderr, "%s: %s given twice\n", me, prev_arg); - return 127; - } - - *arg_dest = arg; - requires_arg = 0; - prev_arg = arg; - ++i; - continue; - } - - if (strcmp (arg, "--help") == 0 || - strcmp (arg, "-h") == 0 || - strcmp (arg, "-?") == 0) - { - usage (0); - } - else if (strcmp (arg, "--version") == 0) - { - version (); - } - else if (strstr (arg, "--config-file=") == arg) - { - const char *file; - - if (config_file != NULL) - { - fprintf (stderr, "%s: --config-file given twice\n", me); - return 127; - } - - file = strchr (arg, '='); - ++file; - - config_file = file; - } - else if (strstr (arg, "--dbus-daemon=") == arg) - { - const char *file; - - if (dbus_daemon != NULL) - { - fprintf (stderr, "%s: --dbus-daemon given twice\n", me); - return 127; - } - - file = strchr (arg, '='); - ++file; - - dbus_daemon = file; - } - else if (strcmp (arg, "--config-file") == 0 || - strcmp (arg, "--dbus-daemon") == 0) - { - requires_arg = 1; - } - else if (arg[0] == '-') - { - if (strcmp (arg, "--") != 0) - { - fprintf (stderr, "%s: option '%s' is unknown\n", me, arg); - return 127; - } - else - { - prog_arg = i + 1; - break; - } - } - else - { - prog_arg = i; - break; - } - - prev_arg = arg; - ++i; - } - - /* "dbus-run-session" and "dbus-run-session ... --" are not allowed: - * there must be something to run */ - if (prog_arg < 1 || prog_arg >= argc) - { - fprintf (stderr, "%s: a non-option argument is required\n", me); - return 127; - } - - if (requires_arg) - { - fprintf (stderr, "%s: option '%s' requires an argument\n", me, prev_arg); - return 127; - } - - if (dbus_daemon == NULL) - dbus_daemon = "dbus-daemon"; - - if (pipe (bus_address_pipe) < 0) - { - fprintf (stderr, "%s: failed to create pipe: %s\n", me, strerror (errno)); - return 127; - } - - bus_pid = fork (); - - if (bus_pid < 0) - { - fprintf (stderr, "%s: failed to fork: %s\n", me, strerror (errno)); - return 127; - } - - if (bus_pid == 0) - { - /* child */ - exec_dbus_daemon (dbus_daemon, bus_address_pipe, config_file); - /* not reached */ - return 127; - } - - close (bus_address_pipe[PIPE_WRITE_END]); - - switch (read_line (bus_address_pipe[PIPE_READ_END], bus_address, MAX_ADDR_LEN)) - { - case READ_STATUS_OK: - break; - - case READ_STATUS_EOF: - fprintf (stderr, "%s: EOF reading address from bus daemon\n", me); - return 127; - break; - - case READ_STATUS_ERROR: - fprintf (stderr, "%s: error reading address from bus daemon: %s\n", - me, strerror (errno)); - return 127; - break; - } - - close (bus_address_pipe[PIPE_READ_END]); - - if (setenv ("DBUS_SESSION_BUS_ADDRESS", bus_address, 1) < 0 || - unsetenv ("DBUS_SESSION_BUS_PID") < 0 || - unsetenv ("DBUS_SESSION_BUS_WINDOWID") < 0 || - unsetenv ("DBUS_STARTER_ADDRESS") < 0 || - unsetenv ("DBUS_STARTER_BUS_TYPE") < 0) - oom (); - - app_pid = fork (); - - if (app_pid < 0) - { - fprintf (stderr, "%s: failed to fork: %s\n", me, strerror (errno)); - return 127; - } - - if (app_pid == 0) - { - /* child */ - exec_app (prog_arg, argv); - /* not reached */ - return 127; - } - - while (1) - { - int child_status; - pid_t child_pid = waitpid (-1, &child_status, 0); - - if (child_pid == (pid_t) -1) - { - int errsv = errno; - - if (errsv == EINTR) - continue; - - /* shouldn't happen: the only other documented errors are ECHILD, - * which shouldn't happen because we terminate when all our children - * have died, and EINVAL, which would indicate programming error */ - fprintf (stderr, "%s: waitpid() failed: %s\n", me, strerror (errsv)); - return 127; - } - else if (child_pid == bus_pid) - { - /* no need to kill it, now */ - bus_pid = 0; - - if (WIFEXITED (child_status)) - fprintf (stderr, "%s: dbus-daemon exited with code %d\n", - me, WEXITSTATUS (child_status)); - else if (WIFSIGNALED (child_status)) - fprintf (stderr, "%s: dbus-daemon terminated by signal %d\n", - me, WTERMSIG (child_status)); - else - fprintf (stderr, "%s: dbus-daemon died or something\n", me); - } - else if (child_pid == app_pid) - { - if (bus_pid != 0) - kill (bus_pid, SIGTERM); - - if (WIFEXITED (child_status)) - return WEXITSTATUS (child_status); - - /* if it died from a signal, behave like sh(1) */ - if (WIFSIGNALED (child_status)) - return 128 + WTERMSIG (child_status); - - /* I give up (this should never be reached) */ - fprintf (stderr, "%s: child process died or something\n", me); - return 127; - } - else - { - fprintf (stderr, "%s: ignoring unknown child process %ld\n", me, - (long) child_pid); - } - } - - return 0; -} diff --git a/tests/utils/setup-session.sh b/tests/utils/setup-session.sh deleted file mode 100755 index f66c3038..00000000 --- a/tests/utils/setup-session.sh +++ /dev/null @@ -1,66 +0,0 @@ -#!/bin/bash -# -# Configure a D-Bus session for shell script tests -# -# Copyright (C) 2015 Red Hat, Inc. -# -# This library is free software; you can redistribute it and/or -# modify it under the terms of the GNU Lesser General Public -# License as published by the Free Software Foundation; either -# version 2 of the License, or (at your option) any later version. -# -# This library is distributed in the hope that it will be useful, -# but WITHOUT ANY WARRANTY; without even the implied warranty of -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU -# Lesser General Public License for more details. -# -# You should have received a copy of the GNU Lesser General Public -# License along with this library; if not, write to the -# Free Software Foundation, Inc., 59 Temple Place - Suite 330, -# Boston, MA 02111-1307, USA. - -set -e - -. ${commondir}/libtest.sh - -# libtest.sh should have added the builddir which contains rpm-ostreed to our -# path -exec_binary="$(which rpm-ostree)" - -mkdir -p sysroot -mkdir -p session-services - -# Create a busconfig file with a custom -cat > session.conf < - - session - - - - - unix:tmpdir=/tmp - - ${test_tmpdir}/session-services - - - - - - - -EOF - -# Create a service file with a custom --sysroot -cat > session-services/rpmostree.service <