From: Michal Koutný Date: Fri, 9 Feb 2024 15:03:00 +0000 (+0100) Subject: service: Demote log level of NotifyAccess= messages to debug X-Git-Tag: v256-rc1~898 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=5734d5d04c5bfbc2f4a4f01c539fd6991b56fff0;p=thirdparty%2Fsystemd.git service: Demote log level of NotifyAccess= messages to debug The situation is a service like Type=notify NotifyAccess=main and the service uses some of the systemd helper utilities, e.g. coredumpctl. The service process will pass NOTIFY_SOCKET to the helper child (accidentally) and the result is a spurious notification and the warning message: > Jan 18 09:38:01 host systemd[1]: sdnotify.service: Got notification message from PID 13736, but reception only permitted for main PID 13549 Notification from helpers seem like an unintentional composition of the commit c118b577fa ("coredumpctl: define main through macro") and commit 6b636c2d27 ("main-func: send main exit code to parent via sd_notify() on exit"). The former used the handy macro for a main function, the latter equipped any main function with the notification. (Further extended in the commit 623a00020f ("notify: Add EXIT_STATUS field").) Since notification from systemd utitilities are meant to extend rudimentary exit()/wait() pair generally, they may happen to land into service's NOTIFY_SOCKET. Tone down messages of notification that won't match NotifyAccess=. --- diff --git a/src/core/service.c b/src/core/service.c index d2b8c18af16..7809c6a5119 100644 --- a/src/core/service.c +++ b/src/core/service.c @@ -4313,29 +4313,30 @@ static bool service_notify_message_authorized(Service *s, pid_t pid, FDSet *fds) NotifyAccess notify_access = service_get_notify_access(s); if (notify_access == NOTIFY_NONE) { + /* Warn level only if no notifications are expected */ log_unit_warning(UNIT(s), "Got notification message from PID "PID_FMT", but reception is disabled.", pid); return false; } if (notify_access == NOTIFY_MAIN && pid != s->main_pid.pid) { if (pidref_is_set(&s->main_pid)) - log_unit_warning(UNIT(s), "Got notification message from PID "PID_FMT", but reception only permitted for main PID "PID_FMT, pid, s->main_pid.pid); + log_unit_debug(UNIT(s), "Got notification message from PID "PID_FMT", but reception only permitted for main PID "PID_FMT, pid, s->main_pid.pid); else - log_unit_warning(UNIT(s), "Got notification message from PID "PID_FMT", but reception only permitted for main PID which is currently not known", pid); + log_unit_debug(UNIT(s), "Got notification message from PID "PID_FMT", but reception only permitted for main PID which is currently not known", pid); return false; } if (notify_access == NOTIFY_EXEC && pid != s->main_pid.pid && pid != s->control_pid.pid) { if (pidref_is_set(&s->main_pid) && pidref_is_set(&s->control_pid)) - log_unit_warning(UNIT(s), "Got notification message from PID "PID_FMT", but reception only permitted for main PID "PID_FMT" and control PID "PID_FMT, + log_unit_debug(UNIT(s), "Got notification message from PID "PID_FMT", but reception only permitted for main PID "PID_FMT" and control PID "PID_FMT, pid, s->main_pid.pid, s->control_pid.pid); else if (pidref_is_set(&s->main_pid)) - log_unit_warning(UNIT(s), "Got notification message from PID "PID_FMT", but reception only permitted for main PID "PID_FMT, pid, s->main_pid.pid); + log_unit_debug(UNIT(s), "Got notification message from PID "PID_FMT", but reception only permitted for main PID "PID_FMT, pid, s->main_pid.pid); else if (pidref_is_set(&s->control_pid)) - log_unit_warning(UNIT(s), "Got notification message from PID "PID_FMT", but reception only permitted for control PID "PID_FMT, pid, s->control_pid.pid); + log_unit_debug(UNIT(s), "Got notification message from PID "PID_FMT", but reception only permitted for control PID "PID_FMT, pid, s->control_pid.pid); else - log_unit_warning(UNIT(s), "Got notification message from PID "PID_FMT", but reception only permitted for main PID and control PID which are currently not known", pid); + log_unit_debug(UNIT(s), "Got notification message from PID "PID_FMT", but reception only permitted for main PID and control PID which are currently not known", pid); return false; }