Gentoo Websites Logo
Go to: Gentoo Home Documentation Forums Lists Bugs Planet Store Wiki Get Gentoo!
Bug 867982 - sys-apps/shadow-4.12.3 chage date display broken
Summary: sys-apps/shadow-4.12.3 chage date display broken
Status: RESOLVED FIXED
Alias: None
Product: Gentoo Linux
Classification: Unclassified
Component: Current packages (show other bugs)
Hardware: All Linux
: Normal normal (vote)
Assignee: Gentoo's Team for Core System packages
URL:
Whiteboard:
Keywords:
Depends on: 888452
Blocks:
  Show dependency tree
 
Reported: 2022-09-02 07:18 UTC by xiaojie+bugzillagentoo
Modified: 2022-12-25 19:47 UTC (History)
1 user (show)

See Also:
Package list:
Runtime testing required: ---


Attachments
Patch to chage.c to correct date format (print_time.patch,589 bytes, patch)
2022-09-02 07:21 UTC, xiaojie+bugzillagentoo
Details | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description xiaojie+bugzillagentoo 2022-09-02 07:18:37 UTC
There has been a change in the chage.c/print_date function between 4.11.1 and 4.12.3, and the date format is « wrong » because of double % :

diff -c shadow-4.11.1/work/shadow-4.11.1/src/chage.c shadow-4.12.3/work/shadow-4.12.3/src/chage.c 
*** shadow-4.11.1/work/shadow-4.11.1/src/chage.c        2022-01-03 01:46:53.000000000 +0100
--- shadow-4.12.3/work/shadow-4.12.3/src/chage.c        2022-08-09 00:30:40.000000000 +0200
***************
*** 223,242 ****
  {
        struct tm *tp;
        char buf[80];
-       char format[80];
- 
-       if (iflg) {
-               (void) snprintf (format, 80, "%%Y-%%m-%%d");
-       }
-       else {
-               (void) snprintf (format, 80, "%%b %%d, %%Y");
-       }
  
        tp = gmtime (&date);
        if (NULL == tp) {
                (void) printf ("time_t: %lu\n", (unsigned long)date);
        } else {
!               (void) strftime (buf, sizeof buf, format, tp);
                (void) puts (buf);
        }
  }
--- 223,234 ----
  {
        struct tm *tp;
        char buf[80];
  
        tp = gmtime (&date);
        if (NULL == tp) {
                (void) printf ("time_t: %lu\n", (unsigned long)date);
        } else {
!               (void) strftime (buf, sizeof buf, iflg ? "%%Y-%%m-%%d" : "%%b %%d, %%Y", tp);
                (void) puts (buf);
        }
  }


Thus, when running chage -l <user>, we do not get the dates displayed but the format :

% chage -l <someuser>
Last password change                                    : %b %d, %Y
Password expires                                        : %b %d, %Y
...


Reproducible: Always

Steps to Reproduce:
1. run 'chage -l <user>'
2.
3.
Actual Results:  
Print format displayed

Expected Results:  
Dates should be displayep

Attaching patch.
Beware : the chage program is suid root. I do not think the patch could bring some security risk, but I did not check thoroughly.
Comment 1 xiaojie+bugzillagentoo 2022-09-02 07:21:10 UTC
Created attachment 802654 [details, diff]
Patch to chage.c to correct date format

Should be safe (chage is suid root), but no extensive checks done.
Comment 2 Mike Gilbert gentoo-dev 2022-09-02 15:45:15 UTC
Please submit your change upstream; we can backport from there.

https://github.com/shadow-maint/shadow
Comment 3 xiaojie+bugzillagentoo 2022-09-02 17:00:37 UTC
(In reply to Mike Gilbert from comment #2)
> Please submit your change upstream; we can backport from there.
> 
> https://github.com/shadow-maint/shadow

I should have thought about it.

https://github.com/shadow-maint/shadow/issues/564
Comment 4 Sam James archtester Gentoo Infrastructure gentoo-dev Security 2022-12-25 19:47:49 UTC
Thanks! Fixed in 4.13.