]> git.ipfire.org Git - thirdparty/shadow.git/commit
lib/, src/: Some empty lists have 0 elements, not 1 empty string
authorAlejandro Colomar <alx@kernel.org>
Sat, 13 Dec 2025 23:51:34 +0000 (00:51 +0100)
committerSerge Hallyn <serge@hallyn.com>
Mon, 29 Dec 2025 03:19:22 +0000 (21:19 -0600)
commit0ff87bf37a5f47d4bcc26911a9bd2818a8b8d866
tree495c029b0ac7e11cc2ac47e18b66dde2f1a09385
parent977d76760b25bec1159198dc6b365abf13bdc744
lib/, src/: Some empty lists have 0 elements, not 1 empty string

In general, empty fields in a CSV are errors.  However, in some cases,
we want to allow passing empty lists, and the way to encode that is as
an empty string.  This was accidentally broken in 4.17.0, when we
switched from using strtok(3) to strsep(3), without remembering to
special-case an empty CSV.

The bug affected directly groupadd(8) and groupmod(8).

The bug also affected the library function add_groups().  In systems
using PAM, that function is unused.  On systems without PAM, it is
called by the library function setup_uid_gid(), with the contents of the
"CONSOLE_GROUPS" configuration (login.defs) CSV string.

setup_uid_gid() is directly called by su(1) and login(1) on systems
without PAM.

setup_uid_gid() is also called by the library function expire().

expire() is directly called by expiry(1), su(1), and login(1).

This bug is a regression introduced in the release 4.17.0, and present
in the releases 4.17.{0..4} and 4.18.0.

Fixes: 90afe61003ef (2024-12-05; "lib/, src/: Use strsep(3) instead of strtok(3)")
Link: <https://github.com/shadow-maint/shadow/issues/1420>
Reported-by: Osark Vieira <https://github.com/osark084>
Signed-off-by: Alejandro Colomar <alx@kernel.org>
lib/addgrps.c
src/groupadd.c
src/groupmod.c