mirror of
git://anongit.mindrot.org/openssh.git
synced 2024-12-22 10:00:14 +00:00
- Added support for directory-based lastlogs
- Really fix typedefs, patch from Ben Taylor <bent@clark.net> - Prevent multiple inclusion of config.h and defines.h. Suggested by Andre Lucas <andre.lucas@dial.pipex.com>
This commit is contained in:
parent
7cfd3e6fb6
commit
6b85a7ffa6
@ -13,6 +13,12 @@
|
||||
- Really fix broken default path. Fix from Jim Knoble
|
||||
<jmknoble@pobox.com>
|
||||
- Remove test for quad_t. No longer needed.
|
||||
- Released 1.2.1pre24
|
||||
|
||||
- Added support for directory-based lastlogs
|
||||
- Really fix typedefs, patch from Ben Taylor <bent@clark.net>
|
||||
- Prevent multiple inclusion of config.h and defines.h. Suggested
|
||||
by Andre Lucas <andre.lucas@dial.pipex.com>
|
||||
|
||||
19991230
|
||||
- OpenBSD CVS updates:
|
||||
|
@ -1,3 +1,6 @@
|
||||
#ifndef _CONFIG_H
|
||||
#define _CONFIG_H
|
||||
|
||||
/* Generated automatically from acconfig.h by autoheader. */
|
||||
/* Please make your changes there */
|
||||
|
||||
@ -143,3 +146,5 @@
|
||||
/* ******************* Shouldn't need to edit below this line ************** */
|
||||
|
||||
#include "defines.h"
|
||||
|
||||
#endif _CONFIG_H
|
||||
|
@ -33,6 +33,8 @@
|
||||
**
|
||||
*/
|
||||
|
||||
#include "config.h"
|
||||
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
@ -47,7 +49,6 @@
|
||||
|
||||
#include "xmalloc.h"
|
||||
#include "ssh.h"
|
||||
#include "config.h"
|
||||
#include "bsd-misc.h"
|
||||
|
||||
#ifndef offsetof
|
||||
|
@ -354,8 +354,6 @@ AC_ARG_WITH(lastlog,
|
||||
if test "x$gotlastlog" = "xdir" ; then
|
||||
AC_MSG_RESULT(${lastlog}/)
|
||||
AC_DEFINE(LASTLOG_IS_DIR)
|
||||
AC_MSG_WARN([*** Directory-based lastlogs are not yet supported ***])
|
||||
nolastlog=1
|
||||
else
|
||||
AC_MSG_RESULT($lastlog)
|
||||
AC_DEFINE_UNQUOTED(LASTLOG_LOCATION, "$lastlog")
|
||||
|
@ -1,3 +1,6 @@
|
||||
#ifndef _DEFINES_H
|
||||
#define _DEFINES_H
|
||||
|
||||
/* Necessary headers */
|
||||
|
||||
#include <sys/types.h> /* For u_intXX_t */
|
||||
@ -61,7 +64,7 @@ typedef long int int64_t;
|
||||
# else
|
||||
# if (SIZEOF_LONG_LONG_INT == 8)
|
||||
typedef long long int int64_t;
|
||||
# define HAVE_INTXX_T
|
||||
# define HAVE_INTXX_T 1
|
||||
# else
|
||||
# error "64 bit int type not found."
|
||||
# endif
|
||||
@ -74,6 +77,7 @@ typedef long long int int64_t;
|
||||
typedef uint16_t u_int16_t;
|
||||
typedef uint32_t u_int32_t;
|
||||
typedef uint64_t u_int64_t;
|
||||
# define HAVE_U_INTXX_T 1
|
||||
# else
|
||||
# if (SIZEOF_SHORT_INT == 2)
|
||||
typedef unsigned short int u_int16_t;
|
||||
@ -90,7 +94,7 @@ typedef unsigned long int u_int64_t;
|
||||
# else
|
||||
# if (SIZEOF_LONG_LONG_INT == 8)
|
||||
typedef unsigned long long int u_int64_t;
|
||||
# define HAVE_U_INTXX_T
|
||||
# define HAVE_U_INTXX_T 1
|
||||
# else
|
||||
# error "64 bit int type not found."
|
||||
# endif
|
||||
@ -224,3 +228,4 @@ typedef unsigned int size_t;
|
||||
# define PAM_STRERROR(a,b) pam_strerror((a),(b))
|
||||
#endif
|
||||
|
||||
#endif /* _DEFINES_H */
|
||||
|
21
login.c
21
login.c
@ -18,7 +18,7 @@
|
||||
*/
|
||||
|
||||
#include "includes.h"
|
||||
RCSID("$Id: login.c,v 1.16 1999/12/30 22:42:24 damien Exp $");
|
||||
RCSID("$Id: login.c,v 1.17 2000/01/02 00:45:33 damien Exp $");
|
||||
|
||||
#if defined(HAVE_UTMPX_H) && defined(USE_UTMPX)
|
||||
# include <utmpx.h>
|
||||
@ -57,14 +57,24 @@ get_last_login_time(uid_t uid, const char *logname,
|
||||
struct lastlog ll;
|
||||
char *lastlog;
|
||||
int fd;
|
||||
#ifdef LASTLOG_IS_DIR
|
||||
char buf[1024];
|
||||
#endif /* LASTLOG_IS_DIR */
|
||||
|
||||
lastlog = _PATH_LASTLOG;
|
||||
buf[0] = '\0';
|
||||
|
||||
#ifdef LASTLOG_IS_DIR
|
||||
fd = open(lastlog, O_RDONLY);
|
||||
if (fd < 0)
|
||||
return 0;
|
||||
lseek(fd, (off_t) ((long) uid * sizeof(ll)), SEEK_SET);
|
||||
#else /* LASTLOG_IS_DIR */
|
||||
snprintf(buf, sizeof(buf), "%s/%s", lastlog, logname);
|
||||
fd = open(buf, O_RDONLY);
|
||||
if (fd < 0)
|
||||
return 0;
|
||||
#endif /* LASTLOG_IS_DIR */
|
||||
if (read(fd, &ll, sizeof(ll)) != sizeof(ll)) {
|
||||
close(fd);
|
||||
return 0;
|
||||
@ -132,6 +142,9 @@ record_login(int pid, const char *ttyname, const char *user, uid_t uid,
|
||||
#if defined(_PATH_LASTLOG) && !defined(DISABLE_LASTLOG)
|
||||
struct lastlog ll;
|
||||
char *lastlog;
|
||||
#ifdef LASTLOG_IS_DIR
|
||||
char buf[1024];
|
||||
#endif /* LASTLOG_IS_DIR */
|
||||
#endif /* defined(_PATH_LASTLOG) && !defined(DISABLE_LASTLOG) */
|
||||
struct utmp u;
|
||||
#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,
|
||||
ll.ll_time = time(NULL);
|
||||
strncpy(ll.ll_line, ttyname + 5, sizeof(ll.ll_line));
|
||||
strncpy(ll.ll_host, host, sizeof(ll.ll_host));
|
||||
#ifdef LASTLOG_IS_DIR
|
||||
snprintf(buf, sizeof(buf), "%s/%s", lastlog, logname);
|
||||
fd = open(buf, O_RDWR);
|
||||
if (fd >= 0) {
|
||||
#else /* LASTLOG_IS_DIR */
|
||||
fd = open(lastlog, O_RDWR);
|
||||
if (fd >= 0) {
|
||||
lseek(fd, (off_t) ((long) uid * sizeof(ll)), SEEK_SET);
|
||||
#endif /* LASTLOG_IS_DIR */
|
||||
if (write(fd, &ll, sizeof(ll)) != sizeof(ll))
|
||||
log("Could not write %.100s: %.100s", lastlog, strerror(errno));
|
||||
close(fd);
|
||||
|
Loading…
Reference in New Issue
Block a user