dcavalca / rpms / util-linux

Forked from rpms/util-linux 2 years ago
Clone
531551
diff -up util-linux-2.23.2/login-utils/login.c.kzak util-linux-2.23.2/login-utils/login.c
531551
--- util-linux-2.23.2/login-utils/login.c.kzak	2015-06-24 11:03:45.123285155 +0200
531551
+++ util-linux-2.23.2/login-utils/login.c	2015-06-24 11:46:19.168114438 +0200
531551
@@ -495,6 +495,7 @@ static void log_audit(struct login_conte
531551
 
531551
 static void log_lastlog(struct login_context *cxt)
531551
 {
531551
+	struct sigaction sa, oldsa_xfsz;
531551
 	struct lastlog ll;
531551
 	time_t t;
531551
 	int fd;
531551
@@ -502,9 +503,14 @@ static void log_lastlog(struct login_con
531551
 	if (!cxt->pwd)
531551
 		return;
531551
 
531551
+	/* lastlog is huge on systems with large UIDs, ignore SIGXFSZ */
531551
+	memset(&sa, 0, sizeof(sa));
531551
+	sa.sa_handler = SIG_IGN;
531551
+	sigaction(SIGXFSZ, &sa, &oldsa_xfsz);
531551
+
531551
 	fd = open(_PATH_LASTLOG, O_RDWR | O_CREAT, 0);
531551
 	if (fd < 0)
531551
-		return;
531551
+		goto done;
531551
 
531551
 	if (lseek(fd, (off_t) cxt->pwd->pw_uid * sizeof(ll), SEEK_SET) == -1)
531551
 		goto done;
531551
@@ -542,7 +548,10 @@ static void log_lastlog(struct login_con
531551
 	if (write_all(fd, (char *)&ll, sizeof(ll)))
531551
 		warn(_("write lastlog failed"));
531551
 done:
531551
-	close(fd);
531551
+	if (fd >= 0)
531551
+		close(fd);
531551
+
531551
+	sigaction(SIGXFSZ, &oldsa_xfsz, NULL);		/* restore original setting */
531551
 }
531551
 
531551
 /*