]> git.ipfire.org Git - thirdparty/systemd.git/commitdiff
shutdown: paranoia, switch to secure_getenv()
authorLennart Poettering <lennart@amutable.com>
Fri, 20 Mar 2026 13:00:23 +0000 (14:00 +0100)
committerLennart Poettering <lennart@amutable.com>
Sat, 4 Apr 2026 20:49:47 +0000 (22:49 +0200)
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

index 73c6dd6d8708b0fcc332bc2811753151744c5694..83fa8c0b668f0be57e978cc29979d768c2667704 100644 (file)
@@ -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;