]> git.ipfire.org Git - thirdparty/systemd.git/commitdiff
core: allow unset pidref in manager_log_caller 41236/head
authorMichael Vogt <michael@amutable.com>
Sat, 21 Mar 2026 21:36:20 +0000 (22:36 +0100)
committerMichael Vogt <michael@amutable.com>
Sat, 21 Mar 2026 21:40:52 +0000 (22:40 +0100)
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
src/core/varlink-manager.c

index 79fa19d976eb3212080f765064a5a4b9777ea7ff..e8c5f008958474ae0452f17c762a3a82c3866851 100644 (file)
@@ -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);
 
index a12f14e121897dc495eba54168c8d2230d56df00..bad37206328ddc0a6bfc5db6a841fe783eb14e73 100644 (file)
@@ -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) {