135456Sbostic /* 235456Sbostic * Copyright (c) 1988 The Regents of the University of California. 335456Sbostic * All rights reserved. 435456Sbostic * 5*42662Sbostic * %sccs.include.redist.c% 635456Sbostic */ 735456Sbostic 835456Sbostic #if defined(LIBC_SCCS) && !defined(lint) 9*42662Sbostic static char sccsid[] = "@(#)logwtmp.c 5.5 (Berkeley) 06/01/90"; 1035456Sbostic #endif /* LIBC_SCCS and not lint */ 1135456Sbostic 1235456Sbostic #include <sys/types.h> 1335456Sbostic #include <sys/file.h> 1435456Sbostic #include <sys/time.h> 1535605Sbostic #include <sys/stat.h> 1635456Sbostic #include <utmp.h> 1735456Sbostic 1835605Sbostic logwtmp(line, name, host) 1935605Sbostic char *line, *name, *host; 2035456Sbostic { 2135456Sbostic struct utmp ut; 2235605Sbostic struct stat buf; 2335456Sbostic int fd; 2435456Sbostic time_t time(); 2535456Sbostic char *strncpy(); 2635456Sbostic 2737273Sbostic if ((fd = open(_PATH_WTMP, O_WRONLY|O_APPEND, 0)) < 0) 2835456Sbostic return; 2941464Skarels if (fstat(fd, &buf) == 0) { 3041464Skarels (void) strncpy(ut.ut_line, line, sizeof(ut.ut_line)); 3141464Skarels (void) strncpy(ut.ut_name, name, sizeof(ut.ut_name)); 3241464Skarels (void) strncpy(ut.ut_host, host, sizeof(ut.ut_host)); 3341464Skarels (void) time(&ut.ut_time); 3435605Sbostic if (write(fd, (char *)&ut, sizeof(struct utmp)) != 3535605Sbostic sizeof(struct utmp)) 3635605Sbostic (void) ftruncate(fd, buf.st_size); 3735605Sbostic } 3841464Skarels (void) close(fd); 3935456Sbostic } 40