summaryrefslogtreecommitdiff
path: root/login.c
diff options
context:
space:
mode:
authorDamien Miller <djm@mindrot.org>1999-12-25 10:11:29 +1100
committerDamien Miller <djm@mindrot.org>1999-12-25 10:11:29 +1100
commit2e1b082dfbc5dcdae80957a3d889abe9fa480d77 (patch)
treec2bfe8d4115d22146448ce829fb7b16e9b762b4f /login.c
parent1b0c228ec48d54705474701b6486f1593539a88a (diff)
- Prepare for 1.2.1pre20
19991225 - More fixes from Andre Lucas <andre.lucas@dial.pipex.com> - Cleanup of auth-passwd.c for shadow and MD5 passwords - Cleanup and bugfix of PAM authentication code 19991223 - Merged later HPUX patch from Andre Lucas <andre.lucas@dial.pipex.com> - Above patch included better utmpx support from Ben Taylor <bent@clark.net>:
Diffstat (limited to 'login.c')
-rw-r--r--login.c40
1 files changed, 28 insertions, 12 deletions
diff --git a/login.c b/login.c
index fb9c8f871..c551da898 100644
--- a/login.c
+++ b/login.c
@@ -18,7 +18,7 @@
18 */ 18 */
19 19
20#include "includes.h" 20#include "includes.h"
21RCSID("$Id: login.c,v 1.10 1999/12/22 05:09:48 damien Exp $"); 21RCSID("$Id: login.c,v 1.11 1999/12/24 23:11:29 damien Exp $");
22 22
23#if defined(HAVE_UTMPX_H) && defined(USE_UTMPX) 23#if defined(HAVE_UTMPX_H) && defined(USE_UTMPX)
24# include <utmpx.h> 24# include <utmpx.h>
@@ -133,28 +133,44 @@ record_login(int pid, const char *ttyname, const char *user, uid_t uid,
133 struct lastlog ll; 133 struct lastlog ll;
134 char *lastlog; 134 char *lastlog;
135#endif /* defined(_PATH_LASTLOG) && !defined(DISABLE_LASTLOG) */ 135#endif /* defined(_PATH_LASTLOG) && !defined(DISABLE_LASTLOG) */
136 struct UTMP_STR u; 136 struct utmp u;
137 const char *utmp, *wtmp; 137#if defined(HAVE_UTMPX_H) && defined(USE_UTMPX)
138 struct utmpx utx;
139#endif
138 140
139 /* Construct an utmp/wtmp entry. */ 141 /* Construct an utmp/wtmp entry. */
140 memset(&u, 0, sizeof(u)); 142 memset(&u, 0, sizeof(u));
141 strncpy(u.ut_line, ttyname + 5, sizeof(u.ut_line)); 143 strncpy(u.ut_line, ttyname + 5, sizeof(u.ut_line));
142#if defined(HAVE_UTMPX_H) && defined(USE_UTMPX) 144 u.ut_pid = (pid_t)pid;
143 u.ut_tv.tv_sec = time(NULL);
144 strncpy(u.ut_user, user, sizeof(u.ut_name));
145#else
146 u.ut_time = time(NULL); 145 u.ut_time = time(NULL);
147 strncpy(u.ut_name, user, sizeof(u.ut_name)); 146 strncpy(u.ut_name, user, sizeof(u.ut_name));
148#endif 147 u.ut_type = (uid == -1)?DEAD_PROCESS:USER_PROCESS;
149#if defined(HAVE_HOST_IN_UTMP) || defined(HAVE_HOST_IN_UTMPX) 148#if defined(HAVE_HOST_IN_UTMP)
150 strncpy(u.ut_host, host, sizeof(u.ut_host)); 149 strncpy(u.ut_host, host, sizeof(u.ut_host));
151#endif 150#endif
152 151
153 /* Figure out the file names. */ 152#if defined(HAVE_UTMPX_H) && defined(USE_UTMPX)
154 utmp = _PATH_UTMP; 153 memset(&utx, 0, sizeof(utx));
155 wtmp = _PATH_WTMP; 154 strncpy(utx.ut_user, user, sizeof(utx.ut_name));
155 strncpy(utx.ut_line, ttyname + 5, sizeof(utx.ut_line));
156 utx.ut_pid = (pid_t)pid;
157 utx.ut_tv.tv_sec = time(NULL);
158 u.ut_type = (uid == -1)?DEAD_PROCESS:USER_PROCESS;
159#ifdef HAVE_HOST_IN_UTMPX
160#ifdef HAVE_SYSLEN_IN_UTMPX
161 utx.ut_syslen = strlen(host);
162 strncpy(utx.ut_host, host, utx.ut_syslen );
163#else
164 strncpy(utx.ut_host, host, sizeof(utx.ut_host));
165#endif /* HAVE_SYSLEN_IN_UTMPX */
166#endif
167#endif /* defined(HAVE_UTMPX_H) && defined(USE_UTMPX) */
156 168
169#if defined(HAVE_UTMPX_H) && defined(USE_UTMPX) && !defined(HAVE_LOGIN)
170 login(&u, &utx);
171#else /* defined(HAVE_UTMPX_H) && defined(USE_UTMPX) */
157 login(&u); 172 login(&u);
173#endif /* defined(HAVE_UTMPX_H) && defined(USE_UTMPX) */
158 174
159#if defined(_PATH_LASTLOG) && !defined(DISABLE_LASTLOG) 175#if defined(_PATH_LASTLOG) && !defined(DISABLE_LASTLOG)
160 lastlog = _PATH_LASTLOG; 176 lastlog = _PATH_LASTLOG;