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

y++ #952

Merged
merged 1 commit into from
Feb 17, 2024
Merged

y++ #952

merged 1 commit into from
Feb 17, 2024

Conversation

alejandro-colomar
Copy link
Collaborator

@alejandro-colomar alejandro-colomar commented Feb 15, 2024

Instead of adding 1, we should add the value the we stored previously in the variable.

Fixes: 45c6603 ("[svn-upgrade] Integrating new upstream version, shadow (19990709)")
Closes: #939
Link: #942
Reported-by: @jubalh
Reported-by: @kenion
Cc: @ikerexxe


And here goes my first patch to a YACC file. Please be very skeptic. Disclaimer: this comes with no warrany, neither expressed nor implied. :)

Here goes some test:

alx@debian:~/src/shadow/shadow/gd$ sudo docker run --rm -ti c7c6e69aefb6 bash
root@9f4cb0e11d43:/usr/local/src/shadow# adduser foo
Adding user `foo' ...
Adding new group `foo' (1000) ...
Adding new user `foo' (1000) with group `foo (1000)' ...
Creating home directory `/home/foo' ...
Copying files from `/etc/skel' ...
Changing password for foo
Enter the new password (minimum of 5 characters)
Please use a combination of upper and lower case letters and numbers.
New password: 
Re-enter new password: 
passwd: password changed.
Changing the user information for foo
Enter the new value, or press ENTER for the default
	Full Name []: 
	Room Number []: 
	Work Phone []: 
	Home Phone []: 
	Other []: 
Is the information correct? [Y/n] y
Adding new user `foo' to supplemental / extra groups `users' ...
Adding user `foo' to group `users' ...
root@9f4cb0e11d43:/usr/local/src/shadow# date
Thu Feb 15 12:16:32 UTC 2024
root@9f4cb0e11d43:/usr/local/src/shadow# chage -d yesterday foo
root@9f4cb0e11d43:/usr/local/src/shadow# chage -l foo
Last password change					: Feb 14, 2024
Password expires					: never
Password inactive					: never
Account expires						: never
Minimum number of days between password change		: 0
Maximum number of days between password change		: 99999
Number of days of warning before password expires	: 7
root@9f4cb0e11d43:/usr/local/src/shadow# chage -d today foo
root@9f4cb0e11d43:/usr/local/src/shadow# chage -l foo
Last password change					: Feb 15, 2024
Password expires					: never
Password inactive					: never
Account expires						: never
Minimum number of days between password change		: 0
Maximum number of days between password change		: 99999
Number of days of warning before password expires	: 7
root@9f4cb0e11d43:/usr/local/src/shadow# chage -d tomorrow foo
root@9f4cb0e11d43:/usr/local/src/shadow# chage -l foo
Last password change					: Feb 16, 2024
Password expires					: never
Password inactive					: never
Account expires						: never
Minimum number of days between password change		: 0
Maximum number of days between password change		: 99999
Number of days of warning before password expires	: 7
root@9f4cb0e11d43:/usr/local/src/shadow# chage -d '1 day ago' foo
root@9f4cb0e11d43:/usr/local/src/shadow# chage -l foo
Last password change					: Feb 14, 2024
Password expires					: never
Password inactive					: never
Account expires						: never
Minimum number of days between password change		: 0
Maximum number of days between password change		: 99999
Number of days of warning before password expires	: 7

Does it break anything else? Good question. I don't have an answer. :)

This was referenced Feb 15, 2024
Instead of adding 1, we should add the value the we stored previously in
the variable.

Fixes: 45c6603 ("[svn-upgrade] Integrating new upstream version, shadow (19990709)")
Closes: <shadow-maint#939>
Link: <shadow-maint#942>
Reported-by: Michael Vetter <jubalh@iodoru.org>
Reported-by: Gus Kenion <https://github.com/kenion>
Cc: Iker Pedrosa <ipedrosa@redhat.com>
Cc: Serge Hallyn <serge@hallyn.com>
Signed-off-by: Alejandro Colomar <alx@kernel.org>
@alejandro-colomar
Copy link
Collaborator Author

v1b changes:

$ git range-diff shadow/master gh/gd gd 
1:  c3f35090 ! 1:  d53bc201 lib/getdate.y: get_date(): Fix calculation
    @@ Commit message
         Reported-by: Michael Vetter <jubalh@iodoru.org>
         Reported-by: Gus Kenion <https://github.com/kenion>
         Cc: Iker Pedrosa <ipedrosa@redhat.com>
    +    Cc: Serge Hallyn <serge@hallyn.com>
         Signed-off-by: Alejandro Colomar <alx@kernel.org>
     
      ## lib/getdate.y ##

@jubalh
Copy link
Member

jubalh commented Feb 15, 2024

Thanks for taking care of that @alejandro-colomar !
The test looks good, I also don't have experience with yacc unfortunately though.

@alejandro-colomar
Copy link
Collaborator Author

alejandro-colomar commented Feb 15, 2024

BTW, in the test above:

Enter the new password (minimum of 5 characters)
Please use a combination of upper and lower case letters and numbers.
New password: 
Re-enter new password: 
passwd: password changed.

This is funny, and nothing transcendental, but I entered 000, so that (minimum of %d characters) should be revised.

@hallyn
Copy link
Member

hallyn commented Feb 17, 2024

Sorry, took me awhile ... but it looks correct, thanks.

@hallyn hallyn merged commit 4d139ca into shadow-maint:master Feb 17, 2024
9 checks passed
@alejandro-colomar
Copy link
Collaborator Author

alejandro-colomar commented Feb 17, 2024 via email

alejandro-colomar added a commit that referenced this pull request Feb 17, 2024
Instead of adding 1, we should add the value the we stored previously in
the variable.

Fixes: 45c6603 ("[svn-upgrade] Integrating new upstream version, shadow (19990709)")
Closes: <#939>
Link: <#942>
Reported-by: Michael Vetter <jubalh@iodoru.org>
Reported-by: Gus Kenion <https://github.com/kenion>
Cc: Iker Pedrosa <ipedrosa@redhat.com>
Cc: Serge Hallyn <serge@hallyn.com>
Signed-off-by: Alejandro Colomar <alx@kernel.org>
Cherry-picked-from: 4d139ca ("lib/getdate.y: get_date(): Fix calculation")
Link: <#952>
Signed-off-by: Alejandro Colomar <alx@kernel.org>
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.

Chage miscalculation
3 participants