shadow-maint / shadow

Upstream shadow tree
Other
290 stars 228 forks source link

y++ #952

Closed alejandro-colomar closed 5 months ago

alejandro-colomar commented 5 months ago

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

Fixes: 45c6603cc86c ("[svn-upgrade] Integrating new upstream version, shadow (19990709)") Closes: https://github.com/shadow-maint/shadow/issues/939 Link: https://github.com/shadow-maint/shadow/pull/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. :)

alejandro-colomar commented 5 months ago

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 commented 5 months ago

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

alejandro-colomar commented 5 months ago

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 commented 5 months ago

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

alejandro-colomar commented 5 months ago

Hi Serge,

On Fri, Feb 16, 2024 at 05:58:49PM -0800, Serge Hallyn wrote:

Sorry, took me awhile ...

No problem! :)

but it looks correct, thanks.

Thanks!

Have a lovely night, Alex

-- https://www.alejandro-colomar.es/ Looking for a remote C programming job at the moment.