From 114c89cc9437bf9793295cf0beee92148844c845 Mon Sep 17 00:00:00 2001 From: Michael Vogt Date: Sat, 21 Mar 2026 22:36:20 +0100 Subject: [PATCH] core: allow unset pidref in manager_log_caller This commit allows unset pidref when calling manager_log_caller(). With that we can log manager calls even if we cannot resolve the caller. Currently when we cannot resolve the caller we are just not logging anything. With this commit we at least log the call (even though we don't know what caller it was). Thanks to keszybz for the suggestion. --- src/core/manager.c | 6 +++++- src/core/varlink-manager.c | 8 +++----- 2 files changed, 8 insertions(+), 6 deletions(-) diff --git a/src/core/manager.c b/src/core/manager.c index 79fa19d976e..e8c5f008958 100644 --- a/src/core/manager.c +++ b/src/core/manager.c @@ -5220,9 +5220,13 @@ void manager_log_caller(Manager *manager, PidRef *caller, const char *method) { _cleanup_free_ char *comm = NULL; assert(manager); - assert(pidref_is_set(caller)); assert(method); + if (!pidref_is_set(caller)) { + log_notice("%s requested from unknown client PID...", method); + return; + } + (void) pidref_get_comm(caller, &comm); Unit *caller_unit = manager_get_unit_by_pidref(manager, caller); diff --git a/src/core/varlink-manager.c b/src/core/varlink-manager.c index a12f14e1218..bad37206328 100644 --- a/src/core/varlink-manager.c +++ b/src/core/varlink-manager.c @@ -220,13 +220,11 @@ static void varlink_log_caller(sd_varlink *link, Manager *manager, const char *m assert(manager); assert(method); - /* We need at least the pidref, otherwise there's nothing to log about. */ r = varlink_get_peer_pidref(link, &pidref); if (r < 0) - /* We use log_notice here just as manager_log_caller would */ - log_notice_errno(r, "Failed to get peer pidref when trying to log caller for %s, ignoring: %m", method); - else - manager_log_caller(manager, &pidref, method); + log_debug_errno(r, "Failed to get peer pidref, ignoring: %m"); + + manager_log_caller(manager, &pidref, method); } int vl_method_reload_manager(sd_varlink *link, sd_json_variant *parameters, sd_varlink_method_flags_t flags, void *userdata) { -- 2.47.3