From: Karel Zak Date: Wed, 19 Nov 2014 14:45:42 +0000 (+0100) Subject: login: ignore SIGXFSZ when write to lastlog X-Git-Tag: v2.26-rc1~193 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=6f7eba20aff93f4a583dd81d16e2a8cd4a4e39c9;p=thirdparty%2Futil-linux.git login: ignore SIGXFSZ when write to lastlog 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 --- diff --git a/login-utils/login.c b/login-utils/login.c index ebb76f5e97..5546435593 100644 --- a/login-utils/login.c +++ b/login-utils/login.c @@ -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 */ } /*