[loginrec.c session.c sshlogin.c sshlogin.h] Bug 84

patch by wknox@mitre.org (William Knox).
[sshlogin.h] declare record_utmp_only for session.c
This commit is contained in:
Tim Rice 2002-02-24 17:56:46 -08:00
parent 839ac4f8aa
commit e06ae4a4bc
5 changed files with 17 additions and 11 deletions

View File

@ -4,6 +4,9 @@
coming). coming).
- (bal) Part two.. Drop unused AIX header, fix up missing char *cp. All - (bal) Part two.. Drop unused AIX header, fix up missing char *cp. All
that is left is handling aix_usrinfo(). that is left is handling aix_usrinfo().
- (tim) [loginrec.c session.c sshlogin.c sshlogin.h] Bug 84
patch by wknox@mitre.org (William Knox).
[sshlogin.h] declare record_utmp_only for session.c
20020221 20020221
- (bal) Minor session.c fixup for cygwin. mispelt 'is_winnt' variable. - (bal) Minor session.c fixup for cygwin. mispelt 'is_winnt' variable.
@ -7663,4 +7666,4 @@
- Wrote replacements for strlcpy and mkdtemp - Wrote replacements for strlcpy and mkdtemp
- Released 1.0pre1 - Released 1.0pre1
$Id: ChangeLog,v 1.1872 2002/02/24 20:42:46 mouring Exp $ $Id: ChangeLog,v 1.1873 2002/02/25 01:56:46 tim Exp $

View File

@ -163,7 +163,7 @@
#include "log.h" #include "log.h"
#include "atomicio.h" #include "atomicio.h"
RCSID("$Id: loginrec.c,v 1.38 2001/10/30 02:50:40 tim Exp $"); RCSID("$Id: loginrec.c,v 1.39 2002/02/25 01:56:47 tim Exp $");
#ifdef HAVE_UTIL_H #ifdef HAVE_UTIL_H
# include <util.h> # include <util.h>
@ -701,6 +701,8 @@ construct_utmpx(struct logininfo *li, struct utmpx *utx)
line_stripname(utx->ut_line, li->line, sizeof(utx->ut_line)); line_stripname(utx->ut_line, li->line, sizeof(utx->ut_line));
set_utmpx_time(li, utx); set_utmpx_time(li, utx);
utx->ut_pid = li->pid; utx->ut_pid = li->pid;
/* strncpy(): Don't necessarily want null termination */
strncpy(utx->ut_name, li->username, MIN_SIZEOF(utx->ut_name, li->username));
if (li->type == LTYPE_LOGOUT) if (li->type == LTYPE_LOGOUT)
return; return;
@ -710,8 +712,6 @@ construct_utmpx(struct logininfo *li, struct utmpx *utx)
* for logouts. * for logouts.
*/ */
/* strncpy(): Don't necessarily want null termination */
strncpy(utx->ut_name, li->username, MIN_SIZEOF(utx->ut_name, li->username));
# ifdef HAVE_HOST_IN_UTMPX # ifdef HAVE_HOST_IN_UTMPX
strncpy(utx->ut_host, li->hostname, MIN_SIZEOF(utx->ut_host, li->hostname)); strncpy(utx->ut_host, li->hostname, MIN_SIZEOF(utx->ut_host, li->hostname));
# endif # endif
@ -942,9 +942,7 @@ utmpx_perform_logout(struct logininfo *li)
{ {
struct utmpx utx; struct utmpx utx;
memset(&utx, '\0', sizeof(utx)); construct_utmpx(li, &utx);
set_utmpx_time(li, &utx);
line_stripname(utx.ut_line, li->line, sizeof(utx.ut_line));
# ifdef HAVE_ID_IN_UTMPX # ifdef HAVE_ID_IN_UTMPX
line_abbrevname(utx.ut_id, li->line, sizeof(utx.ut_id)); line_abbrevname(utx.ut_id, li->line, sizeof(utx.ut_id));
# endif # endif

View File

@ -1677,7 +1677,7 @@ session_pty_cleanup(void *session)
/* Record that the user has logged out. */ /* Record that the user has logged out. */
if (s->pid != 0) if (s->pid != 0)
record_logout(s->pid, s->tty); record_logout(s->pid, s->tty, s->pw->pw_name);
/* Release the pseudo-tty. */ /* Release the pseudo-tty. */
pty_release(s->tty); pty_release(s->tty);

View File

@ -94,11 +94,11 @@ record_utmp_only(pid_t pid, const char *ttyname, const char *user,
/* Records that the user has logged out. */ /* Records that the user has logged out. */
void void
record_logout(pid_t pid, const char *ttyname) record_logout(pid_t pid, const char *ttyname, const char *user)
{ {
struct logininfo *li; struct logininfo *li;
li = login_alloc_entry(pid, NULL, NULL, ttyname); li = login_alloc_entry(pid, user, NULL, ttyname);
login_logout(li); login_logout(li);
login_free_entry(li); login_free_entry(li);
} }

View File

@ -17,7 +17,12 @@
void void
record_login(pid_t, const char *, const char *, uid_t, record_login(pid_t, const char *, const char *, uid_t,
const char *, struct sockaddr *); const char *, struct sockaddr *);
void record_logout(pid_t, const char *); void record_logout(pid_t, const char *, const char *);
u_long get_last_login_time(uid_t, const char *, char *, u_int); u_long get_last_login_time(uid_t, const char *, char *, u_int);
#ifdef LOGIN_NEEDS_UTMPX
void record_utmp_only(pid_t, const char *, const char *, const char *,
struct sockaddr *);
#endif
#endif #endif