]> git.ipfire.org Git - thirdparty/shadow.git/commitdiff
lib/, src/: Use STRFTIME() instead of its pattern
authorAlejandro Colomar <alx@kernel.org>
Mon, 29 Jan 2024 12:50:33 +0000 (13:50 +0100)
committerAlejandro Colomar <alx@kernel.org>
Sat, 23 Mar 2024 23:16:00 +0000 (00:16 +0100)
Reviewed-by: "Serge E. Hallyn" <serge@hallyn.com>
Signed-off-by: Alejandro Colomar <alx@kernel.org>
lib/failure.c
src/chage.c
src/faillog.c
src/lastlog.c
src/login.c

index 376b102b4a9921c486c99e845bafa305ff0cdcee..e42e7107396ec77698f36335718c07215612599b 100644 (file)
 #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"
 
 
@@ -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"
index ca61cffdc6efa2dc3c4f11ae61692e9825d4700d..1c4a20172ad41578e1ef2874ceb19b726788211d 100644 (file)
@@ -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@*/
@@ -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);
 }
 
index 3681e595532f17d244fcb828ff32166f8e39d8b7..611802731d4b6f0831c9b04cfc87babce21a86d5 100644 (file)
@@ -18,6 +18,7 @@
 #include <sys/types.h>
 #include <time.h>
 #include <assert.h>
+
 #include "defines.h"
 #include "faillog.h"
 #include "memzero.h"
@@ -25,6 +26,8 @@
 /*@-exitarg@*/
 #include "exitcodes.h"
 #include "shadowlog.h"
+#include "string/strftime.h"
+
 
 /* local function prototypes */
 NORETURN static void usage (int status);
@@ -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   ",
index 5500fbc5f419038997c3a82c84190cae9c6760b1..74b2faea3f229a2d67acecf23aa5b46d901ad271 100644 (file)
@@ -22,6 +22,7 @@
 #ifdef HAVE_LL_HOST
 #include <net/if.h>
 #endif
+
 #include "defines.h"
 #include "prototypes.h"
 #include "getdef.h"
@@ -29,6 +30,8 @@
 /*@-exitarg@*/
 #include "exitcodes.h"
 #include "shadowlog.h"
+#include "string/strftime.h"
+
 
 /*
  * Needed for MkLinux DR1/2/2.1 - J.
@@ -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) {
index 04423a21d885a08800c3b36a4c5a7d2e5ab96da7..16236de327b32b29cdaff1679ec41a4f62c5a060 100644 (file)
 #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"
 
@@ -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 */