Skip to content

Commit

Permalink
lib/, src/: Use STRFTIME() instead of its pattern
Browse files Browse the repository at this point in the history
Reviewed-by: "Serge E. Hallyn" <[email protected]>
Signed-off-by: Alejandro Colomar <[email protected]>
  • Loading branch information
alejandro-colomar committed Mar 23, 2024
1 parent b3affb2 commit 0460dac
Show file tree
Hide file tree
Showing 5 changed files with 19 additions and 8 deletions.
4 changes: 3 additions & 1 deletion lib/failure.c
Original file line number Diff line number Diff line change
Expand Up @@ -14,11 +14,13 @@
#include <fcntl.h>
#include <stdio.h>
#include <unistd.h>

#include "defines.h"
#include "faillog.h"
#include "failure.h"
#include "memzero.h"
#include "prototypes.h"
#include "string/strftime.h"
#include "string/strtcpy.h"


Expand Down Expand Up @@ -252,7 +254,7 @@ void failprint (const struct faillog *fail)
/*
* Print all information we have.
*/
(void) strftime (lasttimeb, sizeof lasttimeb, "%c", tp);
STRFTIME(lasttimeb, "%c", tp);

/*@-formatconst@*/
(void) printf (ngettext ("%d failure since last login.\n"
Expand Down
3 changes: 2 additions & 1 deletion src/chage.c
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@
#include "shadowio.h"
#include "shadowlog.h"
#include "string/sprintf.h"
#include "string/strftime.h"
#include "string/strtcpy.h"
#include "time/day_to_str.h"
/*@-exitarg@*/
Expand Down Expand Up @@ -253,7 +254,7 @@ print_day_as_date(long day)
return;
}

(void) strftime (buf, sizeof buf, iflg ? "%Y-%m-%d" : "%b %d, %Y", &tm);
STRFTIME(buf, iflg ? "%Y-%m-%d" : "%b %d, %Y", &tm);
(void) puts (buf);
}

Expand Down
5 changes: 4 additions & 1 deletion src/faillog.c
Original file line number Diff line number Diff line change
Expand Up @@ -18,13 +18,16 @@
#include <sys/types.h>
#include <time.h>
#include <assert.h>

#include "defines.h"
#include "faillog.h"
#include "memzero.h"
#include "prototypes.h"
/*@-exitarg@*/
#include "exitcodes.h"
#include "shadowlog.h"
#include "string/strftime.h"


/* local function prototypes */
NORETURN static void usage (int status);
Expand Down Expand Up @@ -167,7 +170,7 @@ static void print_one (/*@null@*/const struct passwd *pw, bool force)
fprintf (stderr, "Cannot read time from faillog.\n");
return;
}
strftime (ptime, sizeof (ptime), "%D %H:%M:%S %z", tm);
STRFTIME(ptime, "%D %H:%M:%S %z", tm);
cp = ptime;

printf ("%-9s %5d %5d ",
Expand Down
5 changes: 4 additions & 1 deletion src/lastlog.c
Original file line number Diff line number Diff line change
Expand Up @@ -22,13 +22,16 @@
#ifdef HAVE_LL_HOST
#include <net/if.h>
#endif

#include "defines.h"
#include "prototypes.h"
#include "getdef.h"
#include "memzero.h"
/*@-exitarg@*/
#include "exitcodes.h"
#include "shadowlog.h"
#include "string/strftime.h"


/*
* Needed for MkLinux DR1/2/2.1 - J.
Expand Down Expand Up @@ -156,7 +159,7 @@ static void print_one (/*@null@*/const struct passwd *pw)
if (tm == NULL) {
cp = "(unknown)";
} else {
strftime (ptime, sizeof (ptime), "%a %b %e %H:%M:%S %z %Y", tm);
STRFTIME(ptime, "%a %b %e %H:%M:%S %z %Y", tm);
cp = ptime;
}
if (ll.ll_time == (time_t) 0) {
Expand Down
10 changes: 6 additions & 4 deletions src/login.c
Original file line number Diff line number Diff line change
Expand Up @@ -38,8 +38,10 @@
#include "exitcodes.h"
#include "shadowlog.h"
#include "string/sprintf.h"
#include "string/strftime.h"
#include "string/strtcpy.h"


#ifdef USE_PAM
#include "pam_defs.h"

Expand Down Expand Up @@ -1249,12 +1251,12 @@ int main (int argc, char **argv)
#ifdef ENABLE_LASTLOG
if ( getdef_bool ("LASTLOG_ENAB")
&& pwd->pw_uid <= (uid_t) getdef_ulong ("LASTLOG_UID_MAX", 0xFFFFFFFFUL)
&& (ll.ll_time != 0)) {
&& (ll.ll_time != 0))
{
time_t ll_time = ll.ll_time;

(void) strftime (ptime, sizeof (ptime),
"%a %b %e %H:%M:%S %z %Y",
localtime (&ll_time));
STRFTIME(ptime, "%a %b %e %H:%M:%S %z %Y",
localtime(&ll_time));
printf (_("Last login: %s on %s"),
ptime, ll.ll_line);
#ifdef HAVE_LL_HOST /* __linux__ || SUN4 */
Expand Down

0 comments on commit 0460dac

Please sign in to comment.