summaryrefslogtreecommitdiff
path: root/loginrec.h
diff options
context:
space:
mode:
authorandre <andre>2000-06-04 17:07:49 +0000
committerandre <andre>2000-06-04 17:07:49 +0000
commit61e67250dc0d6a3406c4b2cd6cb787663d194481 (patch)
tree96fa7767605aa224256e26a3ac8977ba3019ea57 /loginrec.h
parenta86c7eccbf2d2c53bac38b8194cb7fa8b71ad290 (diff)
Many changes to new login code based on Damien's feedback:
- Removed many redundant accessor/mutator methods as they're not necesary in OpenSSH - Added proper credits for OpenBSD code in loginrec.c - Changed function definitions to the OpenBSD style - Removed spurious 'L' prefix in line filename abbreviation for ut_line - Added some documentation in loginrec.c - Changed lastlog access function names - Removed #include lines in mid-file loginrec.c - loginrec.h, login.c and logintest.c changed to reflect new interface - Added TODO note for ttyslot() replacement
Diffstat (limited to 'loginrec.h')
-rw-r--r--loginrec.h66
1 files changed, 20 insertions, 46 deletions
diff --git a/loginrec.h b/loginrec.h
index 0f268ce6a..ed9828c29 100644
--- a/loginrec.h
+++ b/loginrec.h
@@ -40,28 +40,21 @@
40#include <netinet/in.h> 40#include <netinet/in.h>
41#include <sys/socket.h> 41#include <sys/socket.h>
42 42
43/* RCSID("$Id: loginrec.h,v 1.1 2000/06/03 14:57:40 andre Exp $"); */ 43/* RCSID("$Id: loginrec.h,v 1.2 2000/06/04 17:07:49 andre Exp $"); */
44 44
45/** 45/**
46 ** you should use the login_* calls to work around platform dependencies 46 ** you should use the login_* calls to work around platform dependencies
47 **/ 47 **/
48 48
49/* check if we have IP6 on this system */
50#if defined(AF_INET6) || defined(INET6_ADDRSTRLEN)
51# define LOGIN_HAVE_IP6
52#endif
53
54/* 49/*
55 * login_netinfo structure 50 * login_netinfo structure
56 */ 51 */
57 52
58struct login_netinfo { 53union login_netinfo {
59 struct sockaddr_in sa_in4; 54 struct sockaddr sa;
60#ifdef LOGIN_HAVE_IP6 55 struct sockaddr_in sa_in;
61 struct sockaddr_in6 sa_in6; 56 struct sockaddr_storage sa_storage;
62#endif 57};
63
64}; /* struct login_netinfo */
65 58
66 59
67/* 60/*
@@ -102,8 +95,7 @@ struct logininfo {
102 unsigned int tv_sec; 95 unsigned int tv_sec;
103 unsigned int tv_usec; 96 unsigned int tv_usec;
104 97
105 struct login_netinfo hostaddr; /* caller's host address(es) */ 98 union login_netinfo hostaddr; /* caller's host address(es) */
106
107}; /* struct logininfo */ 99}; /* struct logininfo */
108 100
109 101
@@ -111,34 +103,20 @@ struct logininfo {
111 * login recording functions 103 * login recording functions
112 */ 104 */
113/* construct a new login entry */ 105/* construct a new login entry */
114struct logininfo *login_alloc_entry(int pid, 106struct logininfo *login_alloc_entry(int pid, const char *username,
115 const char *username,
116 const char *hostname, const char *line); 107 const char *hostname, const char *line);
108/* free a structure */
117void login_free_entry(struct logininfo *li); 109void login_free_entry(struct logininfo *li);
118int login_init_entry(struct logininfo *li, 110/* fill out a pre-allocated structure with useful information */
119 int pid, const char *username, 111int login_init_entry(struct logininfo *li, int pid, const char *username,
120 const char *hostname, const char *line); 112 const char *hostname, const char *line);
121void login_set_progname(struct logininfo *li, 113/* place the current time in a logininfo struct */
122 const char *progname);
123/* set the type field (skip if using ...login or ...logout) */
124void login_set_type(struct logininfo *li, int type);
125void login_set_pid(struct logininfo *li, int pid);
126void login_set_uid(struct logininfo *li, int uid);
127void login_set_line(struct logininfo *li, const char *line);
128void login_set_username(struct logininfo *li, const char *username);
129void login_set_hostname(struct logininfo *li, const char *hostname);
130/* set the exit status (used by [uw]tmpx) */
131void login_set_exitstatus(struct logininfo *li, int exit, int termination);
132void login_set_time(struct logininfo *li, unsigned int tv_sec,
133 unsigned int tv_usec);
134void login_set_current_time(struct logininfo *li); 114void login_set_current_time(struct logininfo *li);
115
135/* set the network address based on network address type */ 116/* set the network address based on network address type */
136void login_set_ip4(struct logininfo *li, 117void login_set_addr(struct logininfo *li, const struct sockaddr *sa,
137 const struct sockaddr_in *sa_in4); 118 const unsigned int sa_size);
138# ifdef LOGIN_HAVE_IP6 119
139void login_set_ip6(struct logininfo *li,
140 const struct sockaddr_in6 *sa_in6);
141# endif /* LOGIN_HAVE_IP6 */
142/* record the entry */ 120/* record the entry */
143int login_write (struct logininfo *li); 121int login_write (struct logininfo *li);
144int login_login (struct logininfo *li); 122int login_login (struct logininfo *li);
@@ -146,16 +124,12 @@ int login_logout(struct logininfo *li);
146int login_log_entry(struct logininfo *li); 124int login_log_entry(struct logininfo *li);
147 125
148/* 126/*
149 * login record retrieval functions 127 * lastlog retrieval functions
150 */ 128 */
151/* lastlog *entry* functions fill out a logininfo */ 129/* lastlog *entry* functions fill out a logininfo */
152struct logininfo *login_getlastentry_name(struct logininfo *li, 130struct logininfo *login_get_lastlog(struct logininfo *li, const int uid);
153 const char *username);
154struct logininfo *login_getlastentry_uid(struct logininfo *li,
155 const int pid);
156/* lastlog *time* functions return time_t equivalent (uint) */ 131/* lastlog *time* functions return time_t equivalent (uint) */
157unsigned int login_getlasttime_name(const char *username); 132unsigned int login_get_lastlog_time(const int uid);
158unsigned int login_getlasttime_uid(const int pid);
159 133
160/* produce various forms of the line filename */ 134/* produce various forms of the line filename */
161char *line_fullname(char *dst, const char *src, int dstsize); 135char *line_fullname(char *dst, const char *src, int dstsize);