]> git.ipfire.org Git - thirdparty/util-linux.git/commitdiff
login: ignore SIGXFSZ when write to lastlog
authorKarel Zak <kzak@redhat.com>
Wed, 19 Nov 2014 14:45:42 +0000 (15:45 +0100)
committerKarel Zak <kzak@redhat.com>
Wed, 19 Nov 2014 14:45:42 +0000 (15:45 +0100)
the lastlog file is huge and on systems with large UIDs, it's so huge that
it generates SIGXFSZ when the FSIZE limit is too small.

Addresses: https://bugzilla.redhat.com/show_bug.cgi?id=1165702
Signed-off-by: Karel Zak <kzak@redhat.com>
login-utils/login.c

index ebb76f5e97e05dc02b3554e14b82163e42399388..5546435593ef5117df94d16c7ea2f201f9aa6796 100644 (file)
@@ -495,6 +495,7 @@ static void log_audit(struct login_context *cxt, int status)
 
 static void log_lastlog(struct login_context *cxt)
 {
+       struct sigaction sa, oldsa_xfsz;
        struct lastlog ll;
        time_t t;
        int fd;
@@ -502,9 +503,14 @@ static void log_lastlog(struct login_context *cxt)
        if (!cxt->pwd)
                return;
 
+       /* lastlog is huge on systems with large UIDs, ignore SIGXFSZ */
+       memset(&sa, 0, sizeof(sa));
+       sa.sa_handler = SIG_IGN;
+       sigaction(SIGXFSZ, &sa, &oldsa_xfsz);
+
        fd = open(_PATH_LASTLOG, O_RDWR, 0);
        if (fd < 0)
-               return;
+               goto done;
 
        if (lseek(fd, (off_t) cxt->pwd->pw_uid * sizeof(ll), SEEK_SET) == -1)
                goto done;
@@ -542,7 +548,10 @@ static void log_lastlog(struct login_context *cxt)
        if (write_all(fd, (char *)&ll, sizeof(ll)))
                warn(_("write lastlog failed"));
 done:
-       close(fd);
+       if (fd >= 0)
+               close(fd);
+
+       sigaction(SIGXFSZ, &oldsa_xfsz, NULL);          /* restore original setting */
 }
 
 /*