1 /* 2 * Copyright (c) 1988 The Regents of the University of California. 3 * All rights reserved. 4 * 5 * %sccs.include.redist.c% 6 */ 7 8 #if defined(LIBC_SCCS) && !defined(lint) 9 static char sccsid[] = "@(#)logout.c 5.5 (Berkeley) 06/01/90"; 10 #endif /* LIBC_SCCS and not lint */ 11 12 #include <sys/types.h> 13 #include <sys/file.h> 14 #include <sys/time.h> 15 #include <utmp.h> 16 17 typedef struct utmp UTMP; 18 19 logout(line) 20 register char *line; 21 { 22 register int fd; 23 UTMP ut; 24 int rval; 25 off_t lseek(); 26 time_t time(); 27 28 if ((fd = open(_PATH_UTMP, O_RDWR)) < 0) 29 return(0); 30 rval = 0; 31 while (read(fd, (char *)&ut, sizeof(UTMP)) == sizeof(UTMP)) { 32 if (!ut.ut_name[0] || strncmp(ut.ut_line, line, UT_LINESIZE)) 33 continue; 34 bzero(ut.ut_name, UT_NAMESIZE); 35 bzero(ut.ut_host, UT_HOSTSIZE); 36 (void)time(&ut.ut_time); 37 (void)lseek(fd, -(long)sizeof(UTMP), L_INCR); 38 (void)write(fd, (char *)&ut, sizeof(UTMP)); 39 rval = 1; 40 } 41 (void)close(fd); 42 return(rval); 43 } 44