Source-Changes-HG archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]

[src/trunk]: src/external/bsd/tmux/usr.bin/tmux PR/52288: ben: Fix utmp clean...



details:   https://anonhg.NetBSD.org/src/rev/6475f3031cc0
branches:  trunk
changeset: 824615:6475f3031cc0
user:      christos <christos%NetBSD.org@localhost>
date:      Sun Jun 11 14:34:49 2017 +0000

description:
PR/52288: ben: Fix utmp cleanup did not work.
XXX: pullup-8

diffstat:

 external/bsd/tmux/usr.bin/tmux/utempter.c |  20 +++++++++++++-------
 1 files changed, 13 insertions(+), 7 deletions(-)

diffs (65 lines):

diff -r 720132f66f50 -r 6475f3031cc0 external/bsd/tmux/usr.bin/tmux/utempter.c
--- a/external/bsd/tmux/usr.bin/tmux/utempter.c Sun Jun 11 13:05:43 2017 +0000
+++ b/external/bsd/tmux/usr.bin/tmux/utempter.c Sun Jun 11 14:34:49 2017 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: utempter.c,v 1.1 2017/04/23 02:02:00 christos Exp $    */
+/*     $NetBSD: utempter.c,v 1.2 2017/06/11 14:34:49 christos 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.2 2017/06/11 14:34:49 christos Exp $");
 
 #include <sys/types.h>
 #include <sys/param.h>
@@ -86,9 +86,9 @@
 }
 
 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 @@
 }
 
 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 @@
 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;
 }



Home | Main Index | Thread Index | Old Index