From e7182635c6d012b436827746d49cea8963189d50 Mon Sep 17 00:00:00 2001 From: Lennart Poettering Date: Fri, 20 Mar 2026 14:00:23 +0100 Subject: [PATCH] shutdown: paranoia, switch to secure_getenv() We have this rule in systemd that unless we are sure that getenv() is safe and there's a reason to use it we should always prefer secure_getenv(). Follow our own rules here, as per CODING_STYLE document. This really doesn't matter here, all of this is highly privileged, but hopefully Claude & Colleagues shut up about this then, and maybe detect the pattern better. --- src/shutdown/shutdown.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/shutdown/shutdown.c b/src/shutdown/shutdown.c index 73c6dd6d87..83fa8c0b66 100644 --- a/src/shutdown/shutdown.c +++ b/src/shutdown/shutdown.c @@ -286,14 +286,14 @@ static void init_watchdog(void) { const char *s; int r; - s = getenv("WATCHDOG_DEVICE"); + s = secure_getenv("WATCHDOG_DEVICE"); if (s) { r = watchdog_set_device(s); if (r < 0) - log_warning_errno(r, "Failed to set watchdog device to %s, ignoring: %m", s); + log_warning_errno(r, "Failed to set watchdog device to '%s', ignoring: %m", s); } - s = getenv("WATCHDOG_USEC"); + s = secure_getenv("WATCHDOG_USEC"); if (s) { usec_t usec;