summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorRichard Hughes <richard@hughsie.com>2007-07-24 12:22:43 +0000
committerRichard Hughes <richard@hughsie.com>2007-07-24 12:22:43 +0000
commitea3bdfba1023a9977e8da7a06541bb879f59c846 (patch)
treef55437cfd47a89cff51be16a30a6d0ba2f84b8e4
parent6ceffb591878e3a806d340ab07fbb12a2f74e79f (diff)
2007-07-24 Richard Hughes <richard@hughsie.com>
* bus/activation.c: (handle_activation_exit_error), (babysitter_watch_callback): Map the child exit status integer to a proper dbus error.
-rw-r--r--ChangeLog6
-rw-r--r--bus/activation.c54
2 files changed, 60 insertions, 0 deletions
diff --git a/ChangeLog b/ChangeLog
index 0f83d791..006d3348 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,5 +1,11 @@
2007-07-24 Richard Hughes <richard@hughsie.com>
+ * bus/activation.c: (handle_activation_exit_error),
+ (babysitter_watch_callback):
+ Map the child exit status integer to a proper dbus error.
+
+2007-07-24 Richard Hughes <richard@hughsie.com>
+
* bus/bus.c: (process_config_first_time_only),
(process_config_every_time), (bus_context_unref),
(bus_context_get_servicehelper):
diff --git a/bus/activation.c b/bus/activation.c
index 41671d3d..b0ca14c4 100644
--- a/bus/activation.c
+++ b/bus/activation.c
@@ -1118,6 +1118,49 @@ pending_activation_failed (BusPendingActivation *pending_activation,
pending_activation->service_name);
}
+/**
+ * Depending on the exit code of the helper, set the error accordingly
+ */
+static void
+handle_activation_exit_error (int exit_code, DBusError *error)
+{
+ switch (exit_code)
+ {
+ case BUS_SPAWN_EXIT_CODE_NO_MEMORY:
+ dbus_set_error (error, DBUS_ERROR_SPAWN_SETUP_FAILED,
+ "Launcher could not run as out of memory");
+ break;
+ case BUS_SPAWN_EXIT_CODE_SETUP_FAILED:
+ dbus_set_error (error, DBUS_ERROR_SPAWN_SETUP_FAILED,
+ "Failed to setup environment correctly");
+ break;
+ case BUS_SPAWN_EXIT_CODE_NAME_INVALID:
+ dbus_set_error (error, DBUS_ERROR_SPAWN_SERVICE_INVALID,
+ "Bus name is not valid or missing");
+ break;
+ case BUS_SPAWN_EXIT_CODE_SERVICE_NOT_FOUND:
+ dbus_set_error (error, DBUS_ERROR_SPAWN_SERVICE_NOT_FOUND,
+ "Bus name not found in system service directory");
+ break;
+ case BUS_SPAWN_EXIT_CODE_PERMISSIONS_INVALID:
+ dbus_set_error (error, DBUS_ERROR_SPAWN_PERMISSIONS_INVALID,
+ "The permission of the setuid helper is not correct");
+ break;
+ case BUS_SPAWN_EXIT_CODE_FILE_INVALID:
+ dbus_set_error (error, DBUS_ERROR_SPAWN_PERMISSIONS_INVALID,
+ "The service file is incorrect or does not have all required attributes");
+ break;
+ case BUS_SPAWN_EXIT_CODE_EXEC_FAILED:
+ dbus_set_error (error, DBUS_ERROR_SPAWN_EXEC_FAILED,
+ "Cannot launch daemon, file not found or permissions invalid");
+ break;
+ default:
+ dbus_set_error (error, DBUS_ERROR_SPAWN_CHILD_EXITED,
+ "Launch helper exited with unknown return code %i", exit_code);
+ break;
+ }
+}
+
static dbus_bool_t
babysitter_watch_callback (DBusWatch *watch,
unsigned int condition,
@@ -1151,6 +1194,17 @@ babysitter_watch_callback (DBusWatch *watch,
dbus_error_init (&error);
_dbus_babysitter_set_child_exit_error (babysitter, &error);
+ /* refine the error code if we got an exit code */
+ if (dbus_error_has_name (&error, DBUS_ERROR_SPAWN_CHILD_EXITED))
+ {
+ int exit_code = 0;
+ if (_dbus_babysitter_get_child_exit_status (babysitter, &exit_code))
+ {
+ dbus_error_free (&error);
+ handle_activation_exit_error (exit_code, &error);
+ }
+ }
+
/* Destroy all pending activations with the same exec */
_dbus_hash_iter_init (pending_activation->activation->pending_activations,
&iter);