]> git.ipfire.org Git - thirdparty/shadow.git/commitdiff
login: conditionally build lastlog functionality
authorIker Pedrosa <ipedrosa@redhat.com>
Thu, 13 Jul 2023 10:59:33 +0000 (12:59 +0200)
committerSerge Hallyn <serge@hallyn.com>
Sat, 15 Jul 2023 12:39:53 +0000 (07:39 -0500)
Resolves: https://github.com/shadow-maint/shadow/issues/674

Signed-off-by: Iker Pedrosa <ipedrosa@redhat.com>
lib/prototypes.h
libmisc/Makefile.am
src/login.c

index c9e7dce288a4b0325029a99cf70cacf3e196cc3e..350893e0eeef6e0526f0d2bbd22c2099448d6b2c 100644 (file)
@@ -28,7 +28,9 @@
 #include <pwd.h>
 #include <grp.h>
 #include <shadow.h>
+#ifdef ENABLE_LASTLOG
 #include <lastlog.h>
+#endif /* ENABLE_LASTLOG */
 
 #include "defines.h"
 #include "commonio.h"
@@ -222,12 +224,14 @@ extern /*@only@*/ /*@out@*/char **dup_list (char *const *);
 extern bool is_on_list (char *const *list, const char *member);
 extern /*@only@*/char **comma_to_list (const char *);
 
+#ifdef ENABLE_LASTLOG
 /* log.c */
 extern void dolastlog (
        struct lastlog *ll,
        const struct passwd *pw,
        /*@unique@*/const char *line,
        /*@unique@*/const char *host);
+#endif /* ENABLE_LASTLOG */
 
 /* login_nopam.c */
 extern int login_access (const char *user, const char *from);
index 47ad5c53e30e5db88bd86964d8e1cdd35c26bb9b..cc24901e441feaa53d6e950fc76bbff9cae3deee 100644 (file)
@@ -48,7 +48,7 @@ libmisc_la_SOURCES = \
        idmapping.c \
        isexpired.c \
        limits.c \
-       list.c log.c \
+       list.c \
        loginprompt.c \
        mail.c \
        mempcpy.c \
@@ -92,3 +92,6 @@ if WITH_BTRFS
 libmisc_la_SOURCES += btrfs.c
 endif
 
+if ENABLE_LASTLOG
+libmisc_la_SOURCES += log.c
+endif
index be6af4635836aae1e9fca8ba0850393c1a04ec09..58d6912670a01d65e83a9722009cf09ab2d7ee1b 100644 (file)
@@ -14,7 +14,9 @@
 #include <errno.h>
 #include <grp.h>
 #ifndef USE_PAM
+#ifdef ENABLE_LASTLOG
 #include <lastlog.h>
+#endif                                 /* ENABLE_LASTLOG */
 #endif                         /* !USE_PAM */
 #include <pwd.h>
 #include <signal.h>
@@ -69,7 +71,9 @@ static /*@null@*/ /*@only@*/char *username = NULL;
 static int reason = PW_LOGIN;
 
 #ifndef USE_PAM
+#ifdef ENABLE_LASTLOG
 static struct lastlog ll;
+#endif                         /* ENABLE_LASTLOG */
 #endif                         /* !USE_PAM */
 static bool pflg = false;
 static bool fflg = false;
@@ -498,7 +502,9 @@ int main (int argc, char **argv)
        char term[128] = "";
 #endif                         /* RLOGIN */
 #if !defined(USE_PAM)
+#ifdef ENABLE_LASTLOG
        char ptime[80];
+#endif /* ENABLE_LASTLOG */
 #endif
        unsigned int delay;
        unsigned int retries;
@@ -1128,11 +1134,13 @@ int main (int argc, char **argv)
 #endif                         /* WITH_AUDIT */
 
 #ifndef USE_PAM                        /* pam_lastlog handles this */
+#ifdef ENABLE_LASTLOG
        if (   getdef_bool ("LASTLOG_ENAB")
            && pwd->pw_uid <= (uid_t) getdef_ulong ("LASTLOG_UID_MAX", 0xFFFFFFFFUL)) {
                /* give last login and log this one */
                dolastlog (&ll, pwd, tty, hostname);
        }
+#endif /* ENABLE_LASTLOG */
 #endif
 
 #ifndef USE_PAM                        /* PAM handles this as well */
@@ -1266,6 +1274,7 @@ int main (int argc, char **argv)
                                         username, (int) faillog.fail_cnt));
                        }
                }
+#ifdef ENABLE_LASTLOG
                if (   getdef_bool ("LASTLOG_ENAB")
                    && pwd->pw_uid <= (uid_t) getdef_ulong ("LASTLOG_UID_MAX", 0xFFFFFFFFUL)
                    && (ll.ll_time != 0)) {
@@ -1284,6 +1293,7 @@ int main (int argc, char **argv)
 #endif
                        printf (".\n");
                }
+#endif /* ENABLE_LASTLOG */
                agecheck (spwd);
 
                mailcheck ();   /* report on the status of mail */