Deleted Added
full compact
loginrec.c (99768) loginrec.c (106130)
1/*
2 * Copyright (c) 2000 Andre Lucas. All rights reserved.
3 * Portions copyright (c) 1998 Todd C. Miller
4 * Portions copyright (c) 1996 Jason Downs
5 * Portions copyright (c) 1996 Theo de Raadt
6 *
7 * Redistribution and use in source and binary forms, with or without
8 * modification, are permitted provided that the following conditions

--- 149 unchanged lines hidden (view full) ---

158#include "includes.h"
159
160#include "ssh.h"
161#include "xmalloc.h"
162#include "loginrec.h"
163#include "log.h"
164#include "atomicio.h"
165
1/*
2 * Copyright (c) 2000 Andre Lucas. All rights reserved.
3 * Portions copyright (c) 1998 Todd C. Miller
4 * Portions copyright (c) 1996 Jason Downs
5 * Portions copyright (c) 1996 Theo de Raadt
6 *
7 * Redistribution and use in source and binary forms, with or without
8 * modification, are permitted provided that the following conditions

--- 149 unchanged lines hidden (view full) ---

158#include "includes.h"
159
160#include "ssh.h"
161#include "xmalloc.h"
162#include "loginrec.h"
163#include "log.h"
164#include "atomicio.h"
165
166RCSID("$Id: loginrec.c,v 1.40 2002/04/23 13:09:19 djm Exp $");
167RCSID("$FreeBSD: head/crypto/openssh/loginrec.c 99768 2002-07-11 10:36:10Z des $");
166RCSID("$Id: loginrec.c,v 1.44 2002/09/26 00:38:49 tim Exp $");
167RCSID("$FreeBSD: head/crypto/openssh/loginrec.c 106130 2002-10-29 10:16:02Z des $");
168
169#ifdef HAVE_UTIL_H
170# include <util.h>
171#endif
172
173#ifdef HAVE_LIBUTIL_H
174# include <libutil.h>
175#endif

--- 442 unchanged lines hidden (view full) ---

618 line_abbrevname(ut->ut_id, li->line, sizeof(ut->ut_id));
619# endif
620
621# ifdef HAVE_TYPE_IN_UTMP
622 /* This is done here to keep utmp constants out of struct logininfo */
623 switch (li->type) {
624 case LTYPE_LOGIN:
625 ut->ut_type = USER_PROCESS;
168
169#ifdef HAVE_UTIL_H
170# include <util.h>
171#endif
172
173#ifdef HAVE_LIBUTIL_H
174# include <libutil.h>
175#endif

--- 442 unchanged lines hidden (view full) ---

618 line_abbrevname(ut->ut_id, li->line, sizeof(ut->ut_id));
619# endif
620
621# ifdef HAVE_TYPE_IN_UTMP
622 /* This is done here to keep utmp constants out of struct logininfo */
623 switch (li->type) {
624 case LTYPE_LOGIN:
625 ut->ut_type = USER_PROCESS;
626#ifdef _CRAY
626#ifdef _UNICOS
627 cray_set_tmpdir(ut);
628#endif
629 break;
630 case LTYPE_LOGOUT:
631 ut->ut_type = DEAD_PROCESS;
627 cray_set_tmpdir(ut);
628#endif
629 break;
630 case LTYPE_LOGOUT:
631 ut->ut_type = DEAD_PROCESS;
632#ifdef _CRAY
632#ifdef _UNICOS
633 cray_retain_utmp(ut, li->pid);
634#endif
635 break;
636 }
637# endif
638 set_utmp_time(li, ut);
639
640 line_stripname(ut->ut_line, li->line, sizeof(ut->ut_line));

--- 605 unchanged lines hidden (view full) ---

1246
1247 if ((fd = open(WTMPX_FILE, O_RDONLY)) < 0) {
1248 log("wtmpx_get_entry: problem opening %s: %s",
1249 WTMPX_FILE, strerror(errno));
1250 return 0;
1251 }
1252 if (fstat(fd, &st) != 0) {
1253 log("wtmpx_get_entry: couldn't stat %s: %s",
633 cray_retain_utmp(ut, li->pid);
634#endif
635 break;
636 }
637# endif
638 set_utmp_time(li, ut);
639
640 line_stripname(ut->ut_line, li->line, sizeof(ut->ut_line));

--- 605 unchanged lines hidden (view full) ---

1246
1247 if ((fd = open(WTMPX_FILE, O_RDONLY)) < 0) {
1248 log("wtmpx_get_entry: problem opening %s: %s",
1249 WTMPX_FILE, strerror(errno));
1250 return 0;
1251 }
1252 if (fstat(fd, &st) != 0) {
1253 log("wtmpx_get_entry: couldn't stat %s: %s",
1254 WTMP_FILE, strerror(errno));
1254 WTMPX_FILE, strerror(errno));
1255 close(fd);
1256 return 0;
1257 }
1258
1259 /* Seek to the start of the last struct utmpx */
1260 if (lseek(fd, -(off_t)sizeof(struct utmpx), SEEK_END) == -1 ) {
1261 /* probably a newly rotated wtmpx file */
1262 close(fd);

--- 5 unchanged lines hidden (view full) ---

1268 log("wtmpx_get_entry: read of %s failed: %s",
1269 WTMPX_FILE, strerror(errno));
1270 close (fd);
1271 return 0;
1272 }
1273 /* Logouts are recorded as a blank username on a particular line.
1274 * So, we just need to find the username in struct utmpx */
1275 if ( wtmpx_islogin(li, &utx) ) {
1255 close(fd);
1256 return 0;
1257 }
1258
1259 /* Seek to the start of the last struct utmpx */
1260 if (lseek(fd, -(off_t)sizeof(struct utmpx), SEEK_END) == -1 ) {
1261 /* probably a newly rotated wtmpx file */
1262 close(fd);

--- 5 unchanged lines hidden (view full) ---

1268 log("wtmpx_get_entry: read of %s failed: %s",
1269 WTMPX_FILE, strerror(errno));
1270 close (fd);
1271 return 0;
1272 }
1273 /* Logouts are recorded as a blank username on a particular line.
1274 * So, we just need to find the username in struct utmpx */
1275 if ( wtmpx_islogin(li, &utx) ) {
1276 found = 1;
1276# ifdef HAVE_TV_IN_UTMPX
1277 li->tv_sec = utx.ut_tv.tv_sec;
1278# else
1279# ifdef HAVE_TIME_IN_UTMPX
1280 li->tv_sec = utx.ut_time;
1281# endif
1282# endif
1283 line_fullname(li->line, utx.ut_line, sizeof(li->line));

--- 229 unchanged lines hidden ---
1277# ifdef HAVE_TV_IN_UTMPX
1278 li->tv_sec = utx.ut_tv.tv_sec;
1279# else
1280# ifdef HAVE_TIME_IN_UTMPX
1281 li->tv_sec = utx.ut_time;
1282# endif
1283# endif
1284 line_fullname(li->line, utx.ut_line, sizeof(li->line));

--- 229 unchanged lines hidden ---