Skip to content
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

Test expiration date #1233

Draft
wants to merge 27 commits into
base: master
Choose a base branch
from

Conversation

ikerexxe
Copy link
Collaborator

@ikerexxe ikerexxe commented Mar 3, 2025

Testing for #1217

alejandro-colomar and others added 23 commits March 3, 2025 09:25
Our caller, strtoday(), already handles a raw number.

Signed-off-by: Alejandro Colomar <[email protected]>
The yacc(1) code is now completely ignored.  The next commits will
remove it.

Signed-off-by: Alejandro Colomar <[email protected]>
Add copyright and license, since there remains nothing of the original
code.

Signed-off-by: Alejandro Colomar <[email protected]>
Signed-off-by: Alejandro Colomar <[email protected]>
If it fails, let's fall back to get_date().

Signed-off-by: Alejandro Colomar <[email protected]>
get_date() doesn't treat "" as a date anymore, so the comment is
obsolete.  We still need the code, though, as for example usermod(8)
uses an empty string as a synonym for -1.

Link: <shadow-maint#1217 (comment)>
Reported-by: Chris Hofstaedtler <[email protected]>
Signed-off-by: Alejandro Colomar <[email protected]>
Provide a way for the system framework to run `getent shadow $name` and
check its output in a meaningful way.

Signed-off-by: Iker Pedrosa <[email protected]>
@ikerexxe
Copy link
Collaborator Author

ikerexxe commented Mar 3, 2025

@alejandro-colomar this is the testing for #1217. It contains all your commits there + the implementation to run getent shadow $name from the test framework + the test themselves. Do you mind taking a look to the last commit and confirm that I have tested all possible cases? Nothing else came to my mind, but you might have additional ideas.

In addition, one of the test cases (usermod -e -1 $name) returns success (0) even though the expiration date wasn't changed. Do you mind taking a look at it? I think it's a failure in the code.

Finally, does the aforementioned PR also change the date behaviour for useradd and chage? If so, I'll add additional tests for them.

@alejandro-colomar
Copy link
Collaborator

alejandro-colomar commented Mar 3, 2025

@alejandro-colomar this is the testing for #1217. It contains all your commits there + the implementation to run getent shadow $name from the test framework + the test themselves. Do you mind taking a look to the last commit and confirm that I have tested all possible cases? Nothing else came to my mind, but you might have additional ideas.

In addition, one of the test cases (usermod -e -1 $name) returns success (0) even though the expiration date wasn't changed. Do you mind taking a look at it? I think it's a failure in the code.

I think I commented on the one you're mentioning. Was it that one that you were referring to?

Finally, does the aforementioned PR also change the date behaviour for useradd and chage? If so, I'll add additional tests for them.

It affects all of these (since I'm changing strtoday()):

$ grep -rli strtoday 
ChangeLog
src/usermod.c
src/useradd.c
src/chage.c
lib/prototypes.h
lib/strtoday.c
lib/Makefile.am
po/POTFILES.in
NEWS

@ikerexxe ikerexxe force-pushed the test-expiration-date branch from f4c55c4 to 9ea12c2 Compare March 4, 2025 11:41
@ikerexxe ikerexxe force-pushed the test-expiration-date branch from 9ea12c2 to 8a901b3 Compare March 4, 2025 12:02
@ikerexxe
Copy link
Collaborator Author

ikerexxe commented Mar 4, 2025

@alejandro-colomar do you know why alpine fails when useradd/usermod/chage set the expiration date as YYYY-MM-DD? They all fail even though the date is valid (i.e. 2025-01-01).

@alejandro-colomar
Copy link
Collaborator

alejandro-colomar commented Mar 4, 2025

@alejandro-colomar do you know why alpine fails when useradd/usermod/chage set the expiration date as YYYY-MM-DD? They all fail even though the date is valid (i.e. 2025-01-01).

Is it a regression in my patches or is it a failure in master? Could you please open a PR without my changes, to test the tests against master?

@ikerexxe
Copy link
Collaborator Author

ikerexxe commented Mar 4, 2025

It's also failing without your patches. You can set up an alpine container and check it there. Can this be related to the shell they are using? If I'm being honest my knowledge in that area is very limited.

@alejandro-colomar
Copy link
Collaborator

It's also failing without your patches. You can set up an alpine container and check it there. Can this be related to the shell they are using? If I'm being honest my knowledge in that area is very limited.

I don't know. It might be related to the signedness of time_t, or one of those little details. I'll check this weekend when I'm back home and have better internet to create the docker container and install all the deps.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants