shadow-maint / shadow

Upstream shadow tree
Other
292 stars 228 forks source link

Half-life #942

Closed alejandro-colomar closed 6 months ago

alejandro-colomar commented 7 months ago

@jubalh Would you please test this (I didn't test it at all yet)? Thanks!

alejandro-colomar commented 7 months ago

v2 changes:

$ git range-diff shadow/master 3d4a3a3 HEAD
1:  d636dbc7 < -:  -------- src/login.c: Fix off-by-one buggs
2:  855e3f2e < -:  -------- lib/: Don't say 'len' where 'size' is meant
3:  d893a0d6 < -:  -------- src/login.c: Fix off-by-one bugss
4:  12fd1121 < -:  -------- lib/chkname.c: is_valid_user_name(): Remove unnecessary check
5:  e5ce948a < -:  -------- lib/chkname.c: is_valid_user_name(): Avoid a cast
6:  3d4a3a39 = 1:  1b4652b0 lib/strtoday.c: strtoday(): Fix calculation
alejandro-colomar commented 7 months ago

v2b changes:

$ git range-diff shadow/master gh/half-life half-life 
1:  1b4652b0 ! 1:  e5d83e68 lib/strtoday.c: strtoday(): Fix calculation
    @@ Commit message

         Also, remove the comment.  It's likely to get stale.

    -    So, get_date() gets the number of seconds since the epoch.  I wonder how
    +    So, get_date() gets the number of seconds since the Epoch.  I wonder how
         that thing works, but I'll assume it's something similar to strptime(3)
         + mktime(3).  After that, we need to convert seconds since Epoch to days
         since Epoch.  That should be a simple division, AFAICS, since Epoch is
alejandro-colomar commented 7 months ago

v2c changes:

$ git range-diff shadow/master gh/half-life half-life 
1:  e5d83e68 ! 1:  1b054708 lib/strtoday.c: strtoday(): Fix calculation
    @@ Commit message
         Also, remove the comment.  It's likely to get stale.

         So, get_date() gets the number of seconds since the Epoch.  I wonder how
    -    that thing works, but I'll assume it's something similar to strptime(3)
    +    that thing works, but I'll assume it's something similar to getdate(3)
         + mktime(3).  After that, we need to convert seconds since Epoch to days
         since Epoch.  That should be a simple division, AFAICS, since Epoch is
         "1970‐01‐01 00:00:00 +0000 (UTC)".  See mktime(3).
kenion commented 6 months ago

Hi @alejandro-colomar, I'm helping @jubalh out with testing for this. I pulled this patch in and am still seeing the date discrepancy (see screenshot) screenshot Testing occurred on 2024-02-12 in CET time zone. With the patch in place, chage still behaves differently for 'yesterday' (incorrect) vs '1 day ago' (correct).

alejandro-colomar commented 6 months ago

Hi @kenion ,

Hi @alejandro-colomar, I'm helping @jubalh out with testing for this. I pulled this patch in and am still seeing the date discrepancy (see screenshot) screenshot Testing occurred on 2024-02-12 in CET time zone. With the patch in place, chage still behaves differently for 'yesterday' (incorrect) vs '1 day ago' (correct).

Thanks for testing!

Does it at least fix the second issue (the wrap at 12:00 UTC, 14:00 CET)? Maybe we're seeing two different bugs.

Have a lovely day! Alex

alejandro-colomar commented 6 months ago

I expect that this shouldn't be reproducible anymore:

# date
Wed Sep  2 13:57:31 CEST 2020

# chage -l joesix
Last password change                    : Sep 02, 2020

# date
Wed Sep  2 14:05:21 CEST 2020

# chage -d 'today' joesix
# chage -l joesix
Last password change                    : Sep 03, 2020

https://github.com/shadow-maint/shadow/issues/939#issue-2121111329

kenion commented 6 months ago

Thanks @alejandro-colomar, you're right. I can no longer replicate the timezone wrap.

alejandro-colomar commented 6 months ago

v2d changes:

$ git range-diff shadow/master gh/half-life half-life 
1:  1b054708 ! 1:  ee1e9ae3 lib/strtoday.c: strtoday(): Fix calculation
    @@ Commit message
         "1970‐01‐01 00:00:00 +0000 (UTC)".  See mktime(3).

         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/issues/939>
         Reported-by: Michael Vetter <jubalh@iodoru.org>
    +    Tested-by: Gus Kenion <https://github.com/kenion>
         Signed-off-by: Alejandro Colomar <alx@kernel.org>

      ## lib/strtoday.c ##