135457Sbostic /* 235457Sbostic * Copyright (c) 1988 The Regents of the University of California. 335457Sbostic * All rights reserved. 435457Sbostic * 5*42662Sbostic * %sccs.include.redist.c% 635457Sbostic */ 735457Sbostic 835457Sbostic #if defined(LIBC_SCCS) && !defined(lint) 9*42662Sbostic static char sccsid[] = "@(#)logout.c 5.5 (Berkeley) 06/01/90"; 1035457Sbostic #endif /* LIBC_SCCS and not lint */ 1135457Sbostic 1235457Sbostic #include <sys/types.h> 1335457Sbostic #include <sys/file.h> 1435457Sbostic #include <sys/time.h> 1535457Sbostic #include <utmp.h> 1635457Sbostic 1739179Sbostic typedef struct utmp UTMP; 1836826Sbostic 1935457Sbostic logout(line) 2035457Sbostic register char *line; 2135457Sbostic { 2239179Sbostic register int fd; 2339179Sbostic UTMP ut; 2435457Sbostic int rval; 2539179Sbostic off_t lseek(); 2635457Sbostic time_t time(); 2735457Sbostic 2839179Sbostic if ((fd = open(_PATH_UTMP, O_RDWR)) < 0) 2935457Sbostic return(0); 3036826Sbostic rval = 0; 3139179Sbostic while (read(fd, (char *)&ut, sizeof(UTMP)) == sizeof(UTMP)) { 3239179Sbostic if (!ut.ut_name[0] || strncmp(ut.ut_line, line, UT_LINESIZE)) 3335457Sbostic continue; 3439179Sbostic bzero(ut.ut_name, UT_NAMESIZE); 3539179Sbostic bzero(ut.ut_host, UT_HOSTSIZE); 3635457Sbostic (void)time(&ut.ut_time); 3739179Sbostic (void)lseek(fd, -(long)sizeof(UTMP), L_INCR); 3839179Sbostic (void)write(fd, (char *)&ut, sizeof(UTMP)); 3936826Sbostic rval = 1; 4035457Sbostic } 4139179Sbostic (void)close(fd); 4235457Sbostic return(rval); 4335457Sbostic } 44