5 * Author: Tatu Ylonen <ylo@cs.hut.fi>
7 * Copyright (c) 1995 Tatu Ylonen <ylo@cs.hut.fi>, Espoo, Finland
10 * Created: Fri Mar 24 14:51:08 1995 ylo
12 * This file performs some of the things login(1) normally does. We cannot
13 * easily use something like login -p -h host -f user, because there are
14 * several different logins around, and it is hard to determined what kind of
15 * login the current system has. Also, we want to be able to execute commands
21 RCSID("$OpenBSD: login.c,v 1.14 2000/06/20 01:39:42 markus Exp $");
26 * Returns the time when the user last logged in. Returns 0 if the
27 * information is not available. This must be called before record_login.
28 * The host the user logged in from will be returned in buf.
32 get_last_login_time(uid_t uid, const char *logname,
33 char *buf, unsigned int bufsize)
37 login_get_lastlog(&li, uid);
38 strlcpy(buf, li.hostname, bufsize);
43 * Records that the user has logged in. I these parts of operating systems
44 * were more standardized.
48 record_login(pid_t pid, const char *ttyname, const char *user, uid_t uid,
49 const char *host, struct sockaddr * addr)
53 li = login_alloc_entry(pid, user, host, ttyname);
54 login_set_addr(li, addr, sizeof(struct sockaddr));
59 /* Records that the user has logged out. */
62 record_logout(pid_t pid, const char *ttyname)
66 li = login_alloc_entry(pid, NULL, NULL, ttyname);