135456Sbostic /* 235456Sbostic * Copyright (c) 1988 The Regents of the University of California. 335456Sbostic * All rights reserved. 435456Sbostic * 535456Sbostic * Redistribution and use in source and binary forms are permitted 635456Sbostic * provided that the above copyright notice and this paragraph are 735456Sbostic * duplicated in all such forms and that any documentation, 835456Sbostic * advertising materials, and other materials related to such 935456Sbostic * distribution and use acknowledge that the software was developed 1035456Sbostic * by the University of California, Berkeley. The name of the 1135456Sbostic * University may not be used to endorse or promote products derived 1235456Sbostic * from this software without specific prior written permission. 1335456Sbostic * THIS SOFTWARE IS PROVIDED ``AS IS'' AND WITHOUT ANY EXPRESS OR 1435456Sbostic * IMPLIED WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED 1535456Sbostic * WARRANTIES OF MERCHANTIBILITY AND FITNESS FOR A PARTICULAR PURPOSE. 1635456Sbostic */ 1735456Sbostic 1835456Sbostic #if defined(LIBC_SCCS) && !defined(lint) 19*37273Sbostic static char sccsid[] = "@(#)logwtmp.c 5.3 (Berkeley) 04/02/89"; 2035456Sbostic #endif /* LIBC_SCCS and not lint */ 2135456Sbostic 2235456Sbostic #include <sys/types.h> 2335456Sbostic #include <sys/file.h> 2435456Sbostic #include <sys/time.h> 2535605Sbostic #include <sys/stat.h> 2635456Sbostic #include <utmp.h> 2735456Sbostic 2835605Sbostic logwtmp(line, name, host) 2935605Sbostic char *line, *name, *host; 3035456Sbostic { 3135456Sbostic struct utmp ut; 3235605Sbostic struct stat buf; 3335456Sbostic int fd; 3435456Sbostic time_t time(); 3535456Sbostic char *strncpy(); 3635456Sbostic 37*37273Sbostic if ((fd = open(_PATH_WTMP, O_WRONLY|O_APPEND, 0)) < 0) 3835456Sbostic return; 3935605Sbostic if (!fstat(fd, &buf)) { 4035605Sbostic (void)strncpy(ut.ut_line, line, sizeof(ut.ut_line)); 4135605Sbostic (void)strncpy(ut.ut_name, name, sizeof(ut.ut_name)); 4235605Sbostic (void)strncpy(ut.ut_host, host, sizeof(ut.ut_host)); 4335605Sbostic (void)time(&ut.ut_time); 4435605Sbostic if (write(fd, (char *)&ut, sizeof(struct utmp)) != 4535605Sbostic sizeof(struct utmp)) 4635605Sbostic (void) ftruncate(fd, buf.st_size); 4735605Sbostic } 4835456Sbostic (void)close(fd); 4935456Sbostic } 50