Module Name:    src
Committed By:   snj
Date:           Thu Jun 15 05:35:07 UTC 2017

Modified Files:
        src/external/bsd/tmux/usr.bin/tmux [netbsd-8]: utempter.c

Log Message:
Pull up following revision(s) (requested by christos in ticket #36):
        external/bsd/tmux/usr.bin/tmux/utempter.c: revision 1.2
PR/52288: ben: Fix utmp cleanup did not work.


To generate a diff of this commit:
cvs rdiff -u -r1.1 -r1.1.6.1 src/external/bsd/tmux/usr.bin/tmux/utempter.c

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/external/bsd/tmux/usr.bin/tmux/utempter.c
diff -u src/external/bsd/tmux/usr.bin/tmux/utempter.c:1.1 src/external/bsd/tmux/usr.bin/tmux/utempter.c:1.1.6.1
--- src/external/bsd/tmux/usr.bin/tmux/utempter.c:1.1	Sun Apr 23 02:02:00 2017
+++ src/external/bsd/tmux/usr.bin/tmux/utempter.c	Thu Jun 15 05:35:07 2017
@@ -1,4 +1,4 @@
-/*	$NetBSD: utempter.c,v 1.1 2017/04/23 02:02:00 christos Exp $	*/
+/*	$NetBSD: utempter.c,v 1.1.6.1 2017/06/15 05:35:07 snj Exp $	*/
 
 /*-
  * Copyright (c) 2011, 2017 The NetBSD Foundation, Inc.
@@ -36,7 +36,7 @@
  * POSSIBILITY OF SUCH DAMAGE.
  */
 #include <sys/cdefs.h>
-__RCSID("$NetBSD: utempter.c,v 1.1 2017/04/23 02:02:00 christos Exp $");
+__RCSID("$NetBSD: utempter.c,v 1.1.6.1 2017/06/15 05:35:07 snj Exp $");
 
 #include <sys/types.h>
 #include <sys/param.h>
@@ -86,9 +86,9 @@ login_utmpx(const char *username, const 
 }
 
 static void
-logout_utmpx(const char *tty, const struct timeval *now)
+logout_utmpx(const char *username, const char *tty, const struct timeval *now)
 {
-	doutmpx("", "", tty, now, DEAD_PROCESS, 0);
+	doutmpx(username, "", tty, now, DEAD_PROCESS, 0);
 }
 #endif
 
@@ -108,7 +108,8 @@ login_utmp(const char *username, const c
 }
 
 static void
-logout_utmp(const char *tty, const struct timeval *now __unused)
+logout_utmp(const char *username __unused,
+    const char *tty, const struct timeval *now __unused)
 {
 	logout(tty);
 }
@@ -142,17 +143,22 @@ static int
 utmp_destroy(int fd)
 {
 	struct timeval tv;
+	char username[LOGIN_NAME_MAX];
 	char tty[128], *ttyp;
 
+	if (getlogin_r(username, sizeof(username)) == -1)
+		return -1;
+
 	if ((errno = ttyname_r(fd, tty, sizeof(tty))) != 0)
 		return -1;
+
 	ttyp = tty + sizeof(_PATH_DEV) - 1;
 	(void)gettimeofday(&tv, NULL);
 #ifdef SUPPORT_UTMPX
-	logout_utmpx(ttyp, &tv);
+	logout_utmpx(username, ttyp, &tv);
 #endif
 #ifdef SUPPORT_UTMP
-	logout_utmp(ttyp, &tv);
+	logout_utmp(username, ttyp, &tv);
 #endif
 	return 0;
 }

Reply via email to