From c7a1c846ba4c3266aa604a65f7a5c6aab1ad9bd7 Mon Sep 17 00:00:00 2001 From: Sam Hartman Date: Tue, 1 Aug 1995 12:01:49 +0000 Subject: [PATCH] Add missing logwtmp file git-svn-id: svn://anonsvn.mit.edu/krb5/trunk@6372 dc483132-0cff-0310-8789-dd5450dbe970 --- src/util/pty/logwtmp.c | 64 ++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 64 insertions(+) create mode 100644 src/util/pty/logwtmp.c diff --git a/src/util/pty/logwtmp.c b/src/util/pty/logwtmp.c new file mode 100644 index 000000000..53a109e00 --- /dev/null +++ b/src/util/pty/logwtmp.c @@ -0,0 +1,64 @@ +/* + * pty_logwtmp: Implement the logwtmp function if not present. + * and utmp entries. + * + * Copyright 1990 by the Massachusetts Institute of Technology. + * + * + *Permission to use, copy, modify, and + * distribute this software and its documentation for any purpose and + * without fee is hereby granted, provided that the above copyright + * notice appear in all copies and that both that copyright notice and + * this permission notice appear in supporting documentation, and that + * the name of M.I.T. not be used in advertising or publicity pertaining + * to distribution of the software without specific, written prior + * permission. M.I.T. makes no representations about the suitability of + * this software for any purpose. It is provided "as is" without express + * or implied warranty. + * + */ + +#include "mit-copyright.h" +#include +#include "libpty.h" +#include "pty-int.h" + +long pty_logwtmp (tty, user, host ) + char *user, *tty, *host; +{ + #ifdef HAVE_LOGWTMP + logwtmp(tty,user,host); + return 0; + #else + struct utmp ut; + char *tmpx; + char utmp_id[5]; + + /* Will be empty for logout */ + int loggingin = user[0]; + + +#ifndef NO_UT_HOST + strncpy(ut.ut_host, host, sizeof(ut.ut_host)); +#endif + + strncpy(ut.ut_line, tty, sizeof(ut.ut_line)); + ut.ut_time = time(0); + +#ifndef NO_UT_PID + ut.ut_pid = getpid(); + strncpy(ut.ut_user, user, sizeof(ut.ut_user)); + + tmpx = tty + strlen(tty) - 2; + sprintf(utmp_id, "kr%s", tmpx); + strncpy(ut.ut_id, utmp_id, sizeof(ut.ut_id)); + ut.ut_pid = (loggingin ? getpid() : 0); + ut.ut_type = (loggingin ? USER_PROCESS : DEAD_PROCESS); +#else + strncpy(ut.ut_name, user, sizeof(ut.ut_name)); +#endif + + return pty_update_wtmp(&ut); +#endif /*HAVE_LOGWTMP*/ +} + -- 2.26.2