]> git.ipfire.org Git - thirdparty/util-linux.git/commitdiff
login: add support for login.defs(5) LASTLOG_UID_MAX
authorKarel Zak <kzak@redhat.com>
Fri, 11 Jan 2019 11:16:00 +0000 (12:16 +0100)
committerKarel Zak <kzak@redhat.com>
Fri, 11 Jan 2019 11:16:00 +0000 (12:16 +0100)
This new variable allows to keep lastlog file small and filter out
things like huge nfsnobody UIDs.

The variable is also supported by shadow-utils (adduser, etc.).

Addresses: https://github.com/shadow-maint/shadow/pull/142/
Signed-off-by: Karel Zak <kzak@redhat.com>
login-utils/login.1
login-utils/login.c

index b73eae147eb7927e5d171cada15dcde289b8c7f4..084f6c90aced53395da583af545cc6185d269e7f 100644 (file)
@@ -256,6 +256,17 @@ to change directory to her home.  The default value is
 .IR yes .
 .RE
 .PP
+.B LASTLOG_UID_MAX
+(unsigned number)
+.RS 4
+Highest user ID number for which the lastlog entries should be
+updated.  As higher user IDs are usually tracked by remote user
+identity and authentication services there is no need to create
+a huge sparse lastlog file for them.  No LASTLOG_UID_MAX option
+present in the configuration means that there is no user ID limit
+for writing lastlog entries.
+.RE
+.PP
 .B LOG_UNKFAIL_ENAB
 (boolean)
 .RS 4
index 23b62b8d0417cc1d1e6e5c8a8e7f3211194ea443..ab819f16ff432cbd841c2b143841a23976a94296 100644 (file)
@@ -503,6 +503,9 @@ static void log_lastlog(struct login_context *cxt)
        if (!cxt->pwd)
                return;
 
+       if (cxt->pwd->pw_uid > (uid_t) getlogindefs_num("LASTLOG_UID_MAX", ULONG_MAX))
+               return;
+
        /* lastlog is huge on systems with large UIDs, ignore SIGXFSZ */
        memset(&sa, 0, sizeof(sa));
        sa.sa_handler = SIG_IGN;