Add support for controlling whether utmp is updated and which user is

listed in the entry.
This commit is contained in:
Todd C. Miller
2011-03-15 15:53:49 -04:00
parent cf7ec7a3cc
commit 3506f01077
12 changed files with 72 additions and 16 deletions

View File

@@ -118,7 +118,7 @@ cleanup(int gotsignal)
#ifdef HAVE_SELINUX
selinux_restore_tty();
#endif
utmp_logout(slavename);
utmp_logout(slavename); /* XXX - only if CD_SET_UTMP */
}
/*
@@ -127,17 +127,16 @@ cleanup(int gotsignal)
* and slavename globals.
*/
void
pty_setup(uid_t uid, const char *tty)
pty_setup(uid_t uid, const char *tty, const char *utmp_user)
{
io_fds[SFD_USERTTY] = open(_PATH_TTY, O_RDWR|O_NOCTTY, 0);
if (io_fds[SFD_USERTTY] != -1) {
if (!get_pty(&io_fds[SFD_MASTER], &io_fds[SFD_SLAVE],
slavename, sizeof(slavename), uid))
error(1, "Can't get pty");
/*
* Add entry to utmp/utmpx.
*/
utmp_login(tty, slavename, io_fds[SFD_SLAVE]);
/* Add entry to utmp/utmpx? */
if (utmp_user != NULL)
utmp_login(tty, slavename, io_fds[SFD_SLAVE], utmp_user);
}
}
@@ -656,7 +655,7 @@ pty_close(struct command_status *cstat)
}
}
}
utmp_logout(slavename);
utmp_logout(slavename); /* XXX - only if CD_SET_UTMP */
}
/*