From c4dba3f0e5d28265fb6af8e368d03859470398a3 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Bj=C3=B6rn=20Groenvall?= Date: Mon, 16 Oct 1995 16:24:28 +0000 Subject: [PATCH] Initial revision git-svn-id: svn://svn.h5l.se/heimdal/trunk/heimdal@153 ec53bebd-3082-4978-b11e-865c3cabbd6b --- appl/login/utmpx_login.c | 52 ++++++++++++++++++++++++++++++++++++++++ 1 file changed, 52 insertions(+) create mode 100644 appl/login/utmpx_login.c diff --git a/appl/login/utmpx_login.c b/appl/login/utmpx_login.c new file mode 100644 index 000000000..666c3395b --- /dev/null +++ b/appl/login/utmpx_login.c @@ -0,0 +1,52 @@ +/* Author: Wietse Venema */ + +#include + +#ifdef SYSV_UTMP + +#include +#include +#include +#include + +/* utmpx_login - update utmp and wtmp after login */ + +utmpx_login(line, user, host) +char *line; +char *user; +char *host; +{ + struct utmpx *ut; + pid_t mypid = getpid(); + int ret = (-1); + + /* + * SYSV4 ttymon and login use tty port names with the "/dev/" prefix + * stripped off. Rlogind and telnetd, on the other hand, make utmpx + * entries with device names like /dev/pts/nnn. We therefore cannot use + * getutxline(). Return nonzero if no utmp entry was found with our own + * process ID for a login or user process. + */ + + while ((ut = getutxent())) { + if (ut->ut_pid == mypid && (ut->ut_type == INIT_PROCESS + || ut->ut_type == LOGIN_PROCESS || ut->ut_type == USER_PROCESS)) { + strncpy(ut->ut_line, line, sizeof(ut->ut_line)); + strncpy(ut->ut_user, user, sizeof(ut->ut_user)); + strncpy(ut->ut_host, host, sizeof(ut->ut_host)); + ut->ut_syslen = strlen(host) + 1; + if (ut->ut_syslen > sizeof(ut->ut_host)) + ut->ut_syslen = sizeof(ut->ut_host); + ut->ut_type = USER_PROCESS; + gettimeofday(&(ut->ut_tv)); + pututxline(ut); + updwtmpx(WTMPX_FILE, ut); + ret = 0; + break; + } + } + endutxent(); + return (ret); +} + +#endif /* SYSV_UTMP */