summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--ChangeLog6
-rw-r--r--acconfig.h5
-rw-r--r--bsd-misc.c3
-rw-r--r--configure.in2
-rw-r--r--defines.h9
-rw-r--r--login.c21
6 files changed, 40 insertions, 6 deletions
diff --git a/ChangeLog b/ChangeLog
index f68458ca2..04b200dca 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -13,6 +13,12 @@
13 - Really fix broken default path. Fix from Jim Knoble 13 - Really fix broken default path. Fix from Jim Knoble
14 <jmknoble@pobox.com> 14 <jmknoble@pobox.com>
15 - Remove test for quad_t. No longer needed. 15 - Remove test for quad_t. No longer needed.
16 - Released 1.2.1pre24
17
18 - Added support for directory-based lastlogs
19 - Really fix typedefs, patch from Ben Taylor <bent@clark.net>
20 - Prevent multiple inclusion of config.h and defines.h. Suggested
21 by Andre Lucas <andre.lucas@dial.pipex.com>
16 22
1719991230 2319991230
18 - OpenBSD CVS updates: 24 - OpenBSD CVS updates:
diff --git a/acconfig.h b/acconfig.h
index 91eb43afa..c66983e69 100644
--- a/acconfig.h
+++ b/acconfig.h
@@ -1,3 +1,6 @@
1#ifndef _CONFIG_H
2#define _CONFIG_H
3
1/* Generated automatically from acconfig.h by autoheader. */ 4/* Generated automatically from acconfig.h by autoheader. */
2/* Please make your changes there */ 5/* Please make your changes there */
3 6
@@ -143,3 +146,5 @@
143/* ******************* Shouldn't need to edit below this line ************** */ 146/* ******************* Shouldn't need to edit below this line ************** */
144 147
145#include "defines.h" 148#include "defines.h"
149
150#endif _CONFIG_H
diff --git a/bsd-misc.c b/bsd-misc.c
index 0ffe5168b..a4dafb9d9 100644
--- a/bsd-misc.c
+++ b/bsd-misc.c
@@ -33,6 +33,8 @@
33** 33**
34*/ 34*/
35 35
36#include "config.h"
37
36#include <stdio.h> 38#include <stdio.h>
37#include <stdlib.h> 39#include <stdlib.h>
38#include <string.h> 40#include <string.h>
@@ -47,7 +49,6 @@
47 49
48#include "xmalloc.h" 50#include "xmalloc.h"
49#include "ssh.h" 51#include "ssh.h"
50#include "config.h"
51#include "bsd-misc.h" 52#include "bsd-misc.h"
52 53
53#ifndef offsetof 54#ifndef offsetof
diff --git a/configure.in b/configure.in
index 8b3af35f8..34c4dfaf3 100644
--- a/configure.in
+++ b/configure.in
@@ -354,8 +354,6 @@ AC_ARG_WITH(lastlog,
354 if test "x$gotlastlog" = "xdir" ; then 354 if test "x$gotlastlog" = "xdir" ; then
355 AC_MSG_RESULT(${lastlog}/) 355 AC_MSG_RESULT(${lastlog}/)
356 AC_DEFINE(LASTLOG_IS_DIR) 356 AC_DEFINE(LASTLOG_IS_DIR)
357 AC_MSG_WARN([*** Directory-based lastlogs are not yet supported ***])
358 nolastlog=1
359 else 357 else
360 AC_MSG_RESULT($lastlog) 358 AC_MSG_RESULT($lastlog)
361 AC_DEFINE_UNQUOTED(LASTLOG_LOCATION, "$lastlog") 359 AC_DEFINE_UNQUOTED(LASTLOG_LOCATION, "$lastlog")
diff --git a/defines.h b/defines.h
index 2a2655953..40c1a3ead 100644
--- a/defines.h
+++ b/defines.h
@@ -1,3 +1,6 @@
1#ifndef _DEFINES_H
2#define _DEFINES_H
3
1/* Necessary headers */ 4/* Necessary headers */
2 5
3#include <sys/types.h> /* For u_intXX_t */ 6#include <sys/types.h> /* For u_intXX_t */
@@ -61,7 +64,7 @@ typedef long int int64_t;
61# else 64# else
62# if (SIZEOF_LONG_LONG_INT == 8) 65# if (SIZEOF_LONG_LONG_INT == 8)
63typedef long long int int64_t; 66typedef long long int int64_t;
64# define HAVE_INTXX_T 67# define HAVE_INTXX_T 1
65# else 68# else
66# error "64 bit int type not found." 69# error "64 bit int type not found."
67# endif 70# endif
@@ -74,6 +77,7 @@ typedef long long int int64_t;
74typedef uint16_t u_int16_t; 77typedef uint16_t u_int16_t;
75typedef uint32_t u_int32_t; 78typedef uint32_t u_int32_t;
76typedef uint64_t u_int64_t; 79typedef uint64_t u_int64_t;
80# define HAVE_U_INTXX_T 1
77# else 81# else
78# if (SIZEOF_SHORT_INT == 2) 82# if (SIZEOF_SHORT_INT == 2)
79typedef unsigned short int u_int16_t; 83typedef unsigned short int u_int16_t;
@@ -90,7 +94,7 @@ typedef unsigned long int u_int64_t;
90# else 94# else
91# if (SIZEOF_LONG_LONG_INT == 8) 95# if (SIZEOF_LONG_LONG_INT == 8)
92typedef unsigned long long int u_int64_t; 96typedef unsigned long long int u_int64_t;
93# define HAVE_U_INTXX_T 97# define HAVE_U_INTXX_T 1
94# else 98# else
95# error "64 bit int type not found." 99# error "64 bit int type not found."
96# endif 100# endif
@@ -224,3 +228,4 @@ typedef unsigned int size_t;
224# define PAM_STRERROR(a,b) pam_strerror((a),(b)) 228# define PAM_STRERROR(a,b) pam_strerror((a),(b))
225#endif 229#endif
226 230
231#endif /* _DEFINES_H */
diff --git a/login.c b/login.c
index 3dd208aa8..7adc4f22c 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.16 1999/12/30 22:42:24 damien Exp $"); 21RCSID("$Id: login.c,v 1.17 2000/01/02 00:45:33 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>
@@ -57,14 +57,24 @@ get_last_login_time(uid_t uid, const char *logname,
57 struct lastlog ll; 57 struct lastlog ll;
58 char *lastlog; 58 char *lastlog;
59 int fd; 59 int fd;
60#ifdef LASTLOG_IS_DIR
61 char buf[1024];
62#endif /* LASTLOG_IS_DIR */
60 63
61 lastlog = _PATH_LASTLOG; 64 lastlog = _PATH_LASTLOG;
62 buf[0] = '\0'; 65 buf[0] = '\0';
63 66
67#ifdef LASTLOG_IS_DIR
64 fd = open(lastlog, O_RDONLY); 68 fd = open(lastlog, O_RDONLY);
65 if (fd < 0) 69 if (fd < 0)
66 return 0; 70 return 0;
67 lseek(fd, (off_t) ((long) uid * sizeof(ll)), SEEK_SET); 71 lseek(fd, (off_t) ((long) uid * sizeof(ll)), SEEK_SET);
72#else /* LASTLOG_IS_DIR */
73 snprintf(buf, sizeof(buf), "%s/%s", lastlog, logname);
74 fd = open(buf, O_RDONLY);
75 if (fd < 0)
76 return 0;
77#endif /* LASTLOG_IS_DIR */
68 if (read(fd, &ll, sizeof(ll)) != sizeof(ll)) { 78 if (read(fd, &ll, sizeof(ll)) != sizeof(ll)) {
69 close(fd); 79 close(fd);
70 return 0; 80 return 0;
@@ -132,6 +142,9 @@ record_login(int pid, const char *ttyname, const char *user, uid_t uid,
132#if defined(_PATH_LASTLOG) && !defined(DISABLE_LASTLOG) 142#if defined(_PATH_LASTLOG) && !defined(DISABLE_LASTLOG)
133 struct lastlog ll; 143 struct lastlog ll;
134 char *lastlog; 144 char *lastlog;
145#ifdef LASTLOG_IS_DIR
146 char buf[1024];
147#endif /* LASTLOG_IS_DIR */
135#endif /* defined(_PATH_LASTLOG) && !defined(DISABLE_LASTLOG) */ 148#endif /* defined(_PATH_LASTLOG) && !defined(DISABLE_LASTLOG) */
136 struct utmp u; 149 struct utmp u;
137#if defined(HAVE_UTMPX_H) && defined(USE_UTMPX) 150#if defined(HAVE_UTMPX_H) && defined(USE_UTMPX)
@@ -207,9 +220,15 @@ record_login(int pid, const char *ttyname, const char *user, uid_t uid,
207 ll.ll_time = time(NULL); 220 ll.ll_time = time(NULL);
208 strncpy(ll.ll_line, ttyname + 5, sizeof(ll.ll_line)); 221 strncpy(ll.ll_line, ttyname + 5, sizeof(ll.ll_line));
209 strncpy(ll.ll_host, host, sizeof(ll.ll_host)); 222 strncpy(ll.ll_host, host, sizeof(ll.ll_host));
223#ifdef LASTLOG_IS_DIR
224 snprintf(buf, sizeof(buf), "%s/%s", lastlog, logname);
225 fd = open(buf, O_RDWR);
226 if (fd >= 0) {
227#else /* LASTLOG_IS_DIR */
210 fd = open(lastlog, O_RDWR); 228 fd = open(lastlog, O_RDWR);
211 if (fd >= 0) { 229 if (fd >= 0) {
212 lseek(fd, (off_t) ((long) uid * sizeof(ll)), SEEK_SET); 230 lseek(fd, (off_t) ((long) uid * sizeof(ll)), SEEK_SET);
231#endif /* LASTLOG_IS_DIR */
213 if (write(fd, &ll, sizeof(ll)) != sizeof(ll)) 232 if (write(fd, &ll, sizeof(ll)) != sizeof(ll))
214 log("Could not write %.100s: %.100s", lastlog, strerror(errno)); 233 log("Could not write %.100s: %.100s", lastlog, strerror(errno));
215 close(fd); 234 close(fd);