-
Notifications
You must be signed in to change notification settings - Fork 254
Regression fix (affects 4.18 and 4.17): Some empty lists have 0 elements, not 1 empty string #1422
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
|
Sounds like we should add a test to |
f7aa7b4 to
cbe7205
Compare
This actually doesn't affect usermod(8). See the programs and configurations which are affected: |
Or maybe it does... I originally only checked code modified by the same commit that introduced the bug in groupmod(8), but maybe there are other faulty commits. I'll revise. |
I can confirm that usermod(8) is bug-free. alx@devuan:~$ sudo useradd foo
alx@devuan:~$ sudo groupadd foo1
alx@devuan:~$ sudo groupadd foo2
alx@devuan:~$ sudo groupadd foo3
alx@devuan:~$ sudo usermod -G foo1,foo2,foo3 foo
alx@devuan:~$ cat /etc/group | grep foo
foo:x:1004:
foo1:x:1005:foo
foo2:x:1006:foo
foo3:x:1007:foo
alx@devuan:~$ sudo usermod -G foo1,foo2 foo
alx@devuan:~$ cat /etc/group | grep foo
foo:x:1004:
foo1:x:1005:foo
foo2:x:1006:foo
foo3:x:1007:
alx@devuan:~$ sudo usermod -G "" foo
alx@devuan:~$ cat /etc/group | grep foo
foo:x:1004:
foo1:x:1005:
foo2:x:1006:
foo3:x:1007:And reading the source code, I can see it has the Line 243 in f973c40
|
Would you mind adding a test to We should also test groupadd(8), which should be very similar. If you write the test for groupmod(8), I could imitate it for groupadd(8). We should also test at least one of su(1), login(1), and/or expiry(1). |
|
I'm a little slow this morning, so forgive me if I ask some very basic questions.
This reproduces the bug in shadow 4.17.0+ and up to this PR. But the bug only reproduces if PAM is not used. Is my understanding correct? |
The bugs in groupmod(8) and groupadd(8) occur regardless of PAM. You should be able to reproduce them in PAM systems. The bugs in su(1), login(1), and expiry(1) occur only if PAM. |
|
I added the python tests for groupadd and groupmod in #1427
Unfortunately I didn't have time to implement the python wrappers for those binaries yet, so I'm unable to test those for the moment |
I think those tests should give us enough confidence that this PR is good. It would be nice to have tests for su(1) and login(1) in the future, but I'm happy with this for now. I don't care at all about expiry(1), TBH. I would like to deprecate that program, and all features about expiration of passwords. I'll open an issue to deprecate it in 4.20, and remove it in 4.21. |
cbe7205 to
3c364eb
Compare
…pty string Test verifies that groupmod -U '' correctly clears group membership. Signed-off-by: Iker Pedrosa <ipedrosa@redhat.com>
…pty string Test verifies that groupadd -U '' correctly creates group with no members. Signed-off-by: Iker Pedrosa <ipedrosa@redhat.com>
74feae9 to
9451f9c
Compare
|
@ikerexxe I've included your tests in this PR, to show that they pass. |
This is in preparation for the following patch. Signed-off-by: Alejandro Colomar <alx@kernel.org>
9451f9c to
7f77d0a
Compare
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: 90afe61 (2024-12-05; "lib/, src/: Use strsep(3) instead of strtok(3)")
Link: <shadow-maint#1420>
Reported-by: Osark Vieira <https://github.com/osark084>
Signed-off-by: Alejandro Colomar <alx@kernel.org>
Signed-off-by: Alejandro Colomar <alx@kernel.org>
7f77d0a to
a893c00
Compare
|
I'm ok with this, but how do you want to coordinate this with PR 1427? |
Either merge the other one and then this one immediately, or merge this one, and then the other one would need to be rebased. |
I.e., I don't care too much. :) |
|
I'm fine with that, but can you remove the tests I developed? Or include all of them, since you only have a partial content of #1427 PS: I prefer the first option |
You mean that the test tests/system/tests/test_groupmod.py: add test for groupmod -U with user list is missing. However, that test is testing something unrelated to this bug, which is why I left it out, and why I think it should go in a separate PR. |
My ideal preference would be that you split #1472 into two PRs: one that tests this PR (so only the first two commits), and one that adds the other test (and the other "fix", which BTW would benefit from some explanation in the commit message). The unrelated PR should pass CI, since it is testing code that should be okay already. #1472 should indeed fail CI because it's fixed by this PR. |
Thanks! @hallyn please merge first #1472 (which will make CI fail precisely because of the regression we'll be testing) and immediately afterwards this one, which will fix CI by fixing the regression. |
Reported-by: @osark084
This is not a fix for the bug you reported, but it fixes the regression I found, which is very related to what you reported.
Please check if this somehow changes the reproducibility of the other bug.
Tested:
Revisions:
v1b
v1c
v1d
v1e
v2
v3
Interdiff:
v3b