From 01ccc1b497332084bfd8910bd0d8851f567ec24f Mon Sep 17 00:00:00 2001 From: Chengwei Yang Date: Tue, 8 Oct 2013 21:30:26 +0800 Subject: [PATCH v2] launch-helper: fix error code parsing Bug: https://bugs.freedesktop.org/show_bug.cgi?id=66728 --- bus/activation-helper-bin.c | 5 ++++- bus/activation-helper.c | 4 ++-- bus/activation.c | 5 +++++ 3 files changed, 11 insertions(+), 3 deletions(-) diff --git a/bus/activation-helper-bin.c b/bus/activation-helper-bin.c index a360acc..f5f16d2 100644 --- a/bus/activation-helper-bin.c +++ b/bus/activation-helper-bin.c @@ -45,6 +45,9 @@ convert_error_to_exit_code (DBusError *error) return BUS_SPAWN_EXIT_CODE_SETUP_FAILED; if (dbus_error_has_name (error, DBUS_ERROR_SPAWN_SERVICE_INVALID)) + return BUS_SPAWN_EXIT_CODE_NAME_INVALID; + + if (dbus_error_has_name (error, DBUS_ERROR_SPAWN_SERVICE_NOT_FOUND)) return BUS_SPAWN_EXIT_CODE_SERVICE_NOT_FOUND; if (dbus_error_has_name (error, DBUS_ERROR_SPAWN_PERMISSIONS_INVALID)) @@ -65,7 +68,7 @@ convert_error_to_exit_code (DBusError *error) /* should we assert? */ fprintf(stderr, "%s: %s\n", error->name, error->message); - return BUS_SPAWN_EXIT_CODE_SETUP_FAILED; + return BUS_SPAWN_EXIT_CODE_GENERIC_FAILURE; } int diff --git a/bus/activation-helper.c b/bus/activation-helper.c index e3b3323..24fddef 100644 --- a/bus/activation-helper.c +++ b/bus/activation-helper.c @@ -372,7 +372,7 @@ check_bus_name (const char *bus_name, _dbus_string_init_const (&str, bus_name); if (!_dbus_validate_bus_name (&str, 0, _dbus_string_get_length (&str))) { - dbus_set_error (error, DBUS_ERROR_SPAWN_SERVICE_NOT_FOUND, + dbus_set_error (error, DBUS_ERROR_SPAWN_SERVICE_INVALID, "bus name '%s' is not a valid bus name\n", bus_name); return FALSE; @@ -497,7 +497,7 @@ check_dbus_user (BusConfigParser *parser, DBusError *error) if (dbus_user == NULL) { dbus_set_error (error, DBUS_ERROR_SPAWN_CONFIG_INVALID, - "could not get user from config file\n"); + "Invalid configuration (missing or empty ?)"); return FALSE; } diff --git a/bus/activation.c b/bus/activation.c index e03b6fe..ddc5ceb 100644 --- a/bus/activation.c +++ b/bus/activation.c @@ -1289,6 +1289,10 @@ handle_servicehelper_exit_error (int exit_code, { switch (exit_code) { + case BUS_SPAWN_EXIT_CODE_CONFIG_INVALID: + dbus_set_error (error, DBUS_ERROR_SPAWN_CONFIG_INVALID, + "Invalid configuration (missing or empty ?"); + break; case BUS_SPAWN_EXIT_CODE_NO_MEMORY: dbus_set_error (error, DBUS_ERROR_NO_MEMORY, "Launcher could not run (out of memory)"); @@ -1325,6 +1329,7 @@ handle_servicehelper_exit_error (int exit_code, dbus_set_error (error, DBUS_ERROR_SPAWN_CHILD_SIGNALED, "Launched child was signaled, it probably crashed"); break; + case BUS_SPAWN_EXIT_CODE_GENERIC_FAILURE: default: dbus_set_error (error, DBUS_ERROR_SPAWN_CHILD_EXITED, "Launch helper exited with unknown return code %i", exit_code); -- 1.7.9.5