From: Michael Vogt Date: Sat, 21 Mar 2026 21:36:20 +0000 (+0100) Subject: core: allow unset pidref in manager_log_caller X-Git-Tag: v261-rc1~769^2 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=refs%2Fpull%2F41236%2Fhead;p=thirdparty%2Fsystemd.git 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. --- 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) {