home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Usenet 1994 October
/
usenetsourcesnewsgroupsinfomagicoctober1994disk2.iso
/
misc
/
volume6
/
shadow-2.pt2
/
log.c
< prev
next >
Wrap
C/C++ Source or Header
|
1989-02-03
|
888b
|
47 lines
#include <sys/types.h>
#include <utmp.h>
#include <pwd.h>
#include <fcntl.h>
#include <time.h>
#include <string.h>
#include "config.h"
extern struct utmp utent;
extern struct passwd pwent;
extern struct lastlog lastlog;
extern char **environ;
long lseek ();
time_t time ();
#ifdef LASTLOG
#include "lastlog.h"
void log ()
{
int fd;
long offset;
struct lastlog newlog;
if ((fd = open ("/usr/adm/lastlog", O_RDWR)) == -1)
return;
offset = pwent.pw_uid * sizeof lastlog;
if (lseek (fd, offset, 0) != offset)
return;
if (read (fd, (char *) &lastlog, sizeof lastlog) != sizeof lastlog)
memset ((char *) &lastlog, sizeof lastlog, 0);
newlog = lastlog;
(void) time (&newlog.ll_time);
(void) strncpy (newlog.ll_line, utent.ut_line, sizeof newlog.ll_line);
(void) lseek (fd, offset, 0);
(void) write (fd, (char *) &newlog, sizeof newlog);
(void) close (fd);
}
#endif