]> git.ipfire.org Git - thirdparty/systemd.git/commitdiff
nspawn: avoid passing NULL to log_syntax()
authorFrantisek Sumsal <frantisek@sumsal.cz>
Fri, 17 Apr 2026 12:55:29 +0000 (14:55 +0200)
committerFrantisek Sumsal <frantisek@sumsal.cz>
Fri, 17 Apr 2026 12:55:29 +0000 (14:55 +0200)
If range is NULL (i.e. when PrivateUsers= doesn't contain ':'),
both later error paths will then pass NULL to log_syntax():

~# cat foo.nspawn
[Exec]
PrivateUsers=9999999999999999999

~# SYSTEMD_LOG_LEVEL=debug systemd-nspawn -D foo |& grep foo.nspawn
Found settings file: /root/foo.nspawn
/root/foo.nspawn:2: UID/GID shift invalid, ignoring: (null)

or

~# cat foo.nspawn
[Exec]
PrivateUsers=4294967294

~ # SYSTEMD_LOG_LEVEL=debug systemd-nspawn -D foo |& grep foo.nspawn
Found settings file: /root/foo.nspawn
/root/foo.nspawn:2: UID/GID shift and range combination invalid, ignoring: (null)

Let's just use rvalue in both of these cases instead.

src/nspawn/nspawn-settings.c

index 9abd5024a5049b4250529f8f116c60c47fcad8a0..30c603394c1fe8e0601b39f00430d4fba36d6529 100644 (file)
@@ -720,12 +720,12 @@ int config_parse_private_users(
 
                 r = parse_uid(shift, &sh);
                 if (r < 0) {
-                        log_syntax(unit, LOG_WARNING, filename, line, r, "UID/GID shift invalid, ignoring: %s", range);
+                        log_syntax(unit, LOG_WARNING, filename, line, r, "UID/GID shift invalid, ignoring: %s", rvalue);
                         return 0;
                 }
 
                 if (!userns_shift_range_valid(sh, rn)) {
-                        log_syntax(unit, LOG_WARNING, filename, line, 0, "UID/GID shift and range combination invalid, ignoring: %s", range);
+                        log_syntax(unit, LOG_WARNING, filename, line, 0, "UID/GID shift and range combination invalid, ignoring: %s", rvalue);
                         return 0;
                 }