From: Sven Eden Date: Fri, 31 Aug 2018 06:07:35 +0000 (+0200) Subject: Prep v239: Fix and add debug messages to method_can_shutdown_or_sleep() X-Git-Url: https://www.chiark.greenend.org.uk/ucgi/~ianmdlvl/git?p=elogind.git;a=commitdiff_plain;h=c8a0f0cb9aa8773a8133d990f5fd5d22b7cc5523 Prep v239: Fix and add debug messages to method_can_shutdown_or_sleep() --- diff --git a/src/libelogind/sd-bus/bus-convenience.c b/src/libelogind/sd-bus/bus-convenience.c index 41910515d..68a419c6d 100644 --- a/src/libelogind/sd-bus/bus-convenience.c +++ b/src/libelogind/sd-bus/bus-convenience.c @@ -529,6 +529,11 @@ _public_ int sd_bus_query_sender_creds(sd_bus_message *call, uint64_t mask, sd_b return sd_bus_get_owner_creds(call->bus, mask, creds); } + log_debug_elogind("Called by UID %u ; %s [%s] (%s)", c->uid, + c->unique_name ? c->unique_name : "no name", + c->label ? c->label : "no label", + c->description ? c->description : "no desc"); + return bus_creds_extend_by_pid(c, mask, creds); } diff --git a/src/login/logind-dbus.c b/src/login/logind-dbus.c index e75fb023b..9d7092869 100644 --- a/src/login/logind-dbus.c +++ b/src/login/logind-dbus.c @@ -2367,8 +2367,9 @@ static int method_can_shutdown_or_sleep( blocked = manager_is_inhibited(m, w, INHIBIT_BLOCK, NULL, false, true, uid, NULL); handle = handle_action_from_string(sleep_verb); -#if 0 /// elogind uses its own variant, which can use the handle directly. + if (handle >= 0) { +#if 0 /// elogind uses its own variant, which can use the handle directly. const char *target; target = manager_target_for_action(handle); @@ -2384,12 +2385,12 @@ static int method_can_shutdown_or_sleep( goto finish; } } -#else - if ( _HANDLE_ACTION_INVALID == handle ) { - result = "no"; - goto finish; } +#else + log_debug_elogind("CanShutDownOrSleep: %s [%d] %s blocked", + sleep_verb, handle, blocked ? "is" : "not"); #endif // 0 + } if (multiple_sessions) { r = bus_test_polkit(message, CAP_SYS_BOOT, action_multiple_sessions, NULL, UID_INVALID, &challenge, error); @@ -2402,6 +2403,8 @@ static int method_can_shutdown_or_sleep( result = "challenge"; else result = "no"; + log_debug_elogind("CanShutDownOrSleep: multiple_sessions: %s = %s", + action_multiple_sessions, result); } if (blocked) { @@ -2415,6 +2418,8 @@ static int method_can_shutdown_or_sleep( result = "challenge"; else result = "no"; + log_debug_elogind("CanShutDownOrSleep: blocked : %s = %s", + action_ignore_inhibit, result); } if (!multiple_sessions && !blocked) { @@ -2431,6 +2436,8 @@ static int method_can_shutdown_or_sleep( result = "challenge"; else result = "no"; + log_debug_elogind("CanShutDownOrSleep: regular : %s = %s", + action, result); } finish: