]> git.ipfire.org Git - thirdparty/shadow.git/commitdiff
configure.ac, lib/, src/: Use _PATH_LASTLOG from <paths.h>
authorAlejandro Colomar <alx@kernel.org>
Sun, 31 Aug 2025 11:53:54 +0000 (13:53 +0200)
committerAlejandro Colomar <foss+github@alejandro-colomar.es>
Mon, 15 Sep 2025 09:47:22 +0000 (11:47 +0200)
That's the libc macro for this file.

Signed-off-by: Alejandro Colomar <alx@kernel.org>
configure.ac
lib/log.c
src/lastlog.c
src/login.c
src/useradd.c
src/usermod.c

index 4821c1e8162eb13f69613c4ce339692a1a82d781..b524029610723391b2c6e4b5704fddc1280d9756 100644 (file)
@@ -100,8 +100,6 @@ AC_CACHE_CHECK([location of faillog/lastlog/wtmp], [shadow_cv_logdir],
 done])
 AC_DEFINE_UNQUOTED([_WTMP_FILE], ["$shadow_cv_logdir/wtmp"],
        [Path for wtmp file.])
-AC_DEFINE_UNQUOTED([LASTLOG_FILE], ["$shadow_cv_logdir/lastlog"],
-       [Path for lastlog file.])
 AC_DEFINE_UNQUOTED([FAILLOG_FILE], ["$shadow_cv_logdir/faillog"],
        [Path for faillog file.])
 
index 44415c73fcdff5a5eae8fe031c96a7023cd04268..fb09615ea02541f38f154d877926e854f35043d9 100644 (file)
--- a/lib/log.c
+++ b/lib/log.c
@@ -9,14 +9,14 @@
 
 #include "config.h"
 
-#ident "$Id$"
-
-#include <sys/types.h>
+#include <lastlog.h>
+#include <paths.h>
 #include <pwd.h>
 #include <fcntl.h>
+#include <sys/types.h>
 #include <time.h>
+
 #include "defines.h"
-#include <lastlog.h>
 #include "prototypes.h"
 #include "string/memset/memzero.h"
 #include "string/strcpy/strncpy.h"
@@ -45,7 +45,7 @@ void dolastlog (
         * If the file does not exist, don't create it.
         */
 
-       fd = open (LASTLOG_FILE, O_RDWR);
+       fd = open(_PATH_LASTLOG, O_RDWR);
        if (-1 == fd) {
                return;
        }
@@ -60,7 +60,7 @@ void dolastlog (
        if (lseek (fd, offset, SEEK_SET) != offset) {
                SYSLOG ((LOG_WARN,
                         "Can't read last lastlog entry for UID %lu in %s. Entry not updated.",
-                        (unsigned long) pw->pw_uid, LASTLOG_FILE));
+                        (unsigned long) pw->pw_uid, _PATH_LASTLOG));
                (void) close (fd);
                return;
        }
@@ -105,5 +105,5 @@ err_write:
 err_close:
        SYSLOG ((LOG_WARN,
                 "Can't write lastlog entry for UID %lu in %s: %m",
-                (unsigned long) pw->pw_uid, LASTLOG_FILE));
+                (unsigned long) pw->pw_uid, _PATH_LASTLOG));
 }
index 7413f6a433e2b52e973d6794568d63b6e4d4be56..0f8793c521b7d3a4b2cd3e9c1cdddaee849e50b4 100644 (file)
@@ -13,6 +13,7 @@
 
 #include <getopt.h>
 #include <lastlog.h>
+#include <paths.h>
 #include <pwd.h>
 #include <stdio.h>
 #include <sys/stat.h>
 #include "string/strftime.h"
 
 
-
-/*
- * Needed for MkLinux DR1/2/2.1 - J.
- */
-#ifndef LASTLOG_FILE
-#define LASTLOG_FILE "/var/log/lastlog"
-#endif
-
 /*
  * Global variables
  */
@@ -433,9 +426,9 @@ int main (int argc, char **argv)
                }
        }
 
-       lastlogfile = fopen (LASTLOG_FILE, (Cflg || Sflg)?"r+":"r");
+       lastlogfile = fopen(_PATH_LASTLOG, (Cflg || Sflg)?"r+":"r");
        if (NULL == lastlogfile) {
-               perror (LASTLOG_FILE);
+               perror(_PATH_LASTLOG);
                exit (EXIT_FAILURE);
        }
 
@@ -443,7 +436,7 @@ int main (int argc, char **argv)
        if (fstat (fileno (lastlogfile), &statbuf) != 0) {
                fprintf (stderr,
                         _("%s: Cannot get the size of %s: %s\n"),
-                        Prog, LASTLOG_FILE, strerror (errno));
+                        Prog, _PATH_LASTLOG, strerror(errno));
                exit (EXIT_FAILURE);
        }
 
index ce2076dec83bd1842b268bbca853ffe77c52236a..ff6b98e07c51c99605090124609058229eee0c27 100644 (file)
@@ -63,14 +63,6 @@ static pam_handle_t *pamh = NULL;
 
 #endif                         /* USE_PAM */
 
-#ifndef USE_PAM
-/*
- * Needed for MkLinux DR1/2/2.1 - J.
- */
-#ifndef LASTLOG_FILE
-#define LASTLOG_FILE "/var/log/lastlog"
-#endif
-#endif                         /* !USE_PAM */
 
 /*
  * Global variables
index 2b3b42b683b42641cc10dead162b0fed3ad80d4a..5b6a9d2737044f89d449373afec736bf11aa9843 100644 (file)
@@ -28,6 +28,7 @@
 #include "pam_defs.h"
 #endif                         /* USE_PAM */
 #endif                         /* ACCT_TOOLS_SETUID */
+#include <paths.h>
 #include <stdio.h>
 #include <string.h>
 #include <sys/stat.h>
 #define USER_DEFAULTS_FILE "/etc/default/useradd"
 #define NEW_USER_FILE "/etc/default/nuaddXXXXXX"
 #endif
-/*
- * Needed for MkLinux DR1/2/2.1 - J.
- */
-#ifndef LASTLOG_FILE
-#define LASTLOG_FILE "/var/log/lastlog"
-#endif
+
+
 /*
  * Global variables
  */
@@ -1984,7 +1981,7 @@ static void lastlog_reset (uid_t uid)
        uid_t max_uid;
        struct stat st;
 
-       if (stat (LASTLOG_FILE, &st) != 0 || st.st_size <= offset_uid) {
+       if (stat(_PATH_LASTLOG, &st) != 0 || st.st_size <= offset_uid) {
                return;
        }
 
@@ -1996,7 +1993,7 @@ static void lastlog_reset (uid_t uid)
 
        memzero (&ll, sizeof (ll));
 
-       fd = open (LASTLOG_FILE, O_RDWR);
+       fd = open(_PATH_LASTLOG, O_RDWR);
        if (-1 == fd) {
                fprintf (stderr,
                         _("%s: failed to open the lastlog file for UID %lu: %s\n"),
index ceb0ad60e2f3ee6f7be631f7505e8c7591be57d8..8295165a52fcc7de03b45bb97bad7ce158a78979 100644 (file)
@@ -26,6 +26,7 @@
 #include "pam_defs.h"
 #endif                         /* USE_PAM */
 #endif                         /* ACCT_TOOLS_SETUID */
+#include <paths.h>
 #include <stdio.h>
 #include <strings.h>
 #include <sys/stat.h>
@@ -1927,7 +1928,7 @@ static void update_lastlog (void)
        off_t off_newuid = (off_t) user_newid * sizeof ll;
        uid_t max_uid;
 
-       if (access (LASTLOG_FILE, F_OK) != 0) {
+       if (access(_PATH_LASTLOG, F_OK) != 0) {
                return;
        }
 
@@ -1937,7 +1938,7 @@ static void update_lastlog (void)
                return;
        }
 
-       fd = open (LASTLOG_FILE, O_RDWR);
+       fd = open(_PATH_LASTLOG, O_RDWR);
 
        if (-1 == fd) {
                fprintf (stderr,