From: Iker Pedrosa Date: Thu, 13 Jul 2023 10:59:33 +0000 (+0200) Subject: login: conditionally build lastlog functionality X-Git-Tag: 4.14.0-rc1~26 X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=84a10ca019083ce971f43e29eb22bf4d3242481e;p=thirdparty%2Fshadow.git login: conditionally build lastlog functionality Resolves: https://github.com/shadow-maint/shadow/issues/674 Signed-off-by: Iker Pedrosa --- diff --git a/lib/prototypes.h b/lib/prototypes.h index c9e7dce28..350893e0e 100644 --- a/lib/prototypes.h +++ b/lib/prototypes.h @@ -28,7 +28,9 @@ #include #include #include +#ifdef ENABLE_LASTLOG #include +#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); diff --git a/libmisc/Makefile.am b/libmisc/Makefile.am index 47ad5c53e..cc24901e4 100644 --- a/libmisc/Makefile.am +++ b/libmisc/Makefile.am @@ -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 diff --git a/src/login.c b/src/login.c index be6af4635..58d691267 100644 --- a/src/login.c +++ b/src/login.c @@ -14,7 +14,9 @@ #include #include #ifndef USE_PAM +#ifdef ENABLE_LASTLOG #include +#endif /* ENABLE_LASTLOG */ #endif /* !USE_PAM */ #include #include @@ -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 */