dcavalca / rpms / util-linux

Forked from rpms/util-linux 2 years ago
Clone
Blob Blame History Raw
diff -up util-linux-2.23.2/login-utils/login.c.kzak util-linux-2.23.2/login-utils/login.c
--- util-linux-2.23.2/login-utils/login.c.kzak	2015-06-24 11:03:45.123285155 +0200
+++ util-linux-2.23.2/login-utils/login.c	2015-06-24 11:46:19.168114438 +0200
@@ -495,6 +495,7 @@ static void log_audit(struct login_conte
 
 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_con
 	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 | O_CREAT, 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_con
 	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 */
 }
 
 /*