3 static char elsieid
[] = "@(#)logwtmp.c 7.7";
4 /* As received from UCB, with include reordering and OLD_TIME condition. */
5 #endif /* !defined NOID */
6 #endif /* !defined lint */
9 * Copyright (c) 1988 The Regents of the University of California.
10 * All rights reserved.
12 * Redistribution and use in source and binary forms are permitted
13 * provided that the above copyright notice and this paragraph are
14 * duplicated in all such forms and that any documentation,
15 * advertising materials, and other materials related to such
16 * distribution and use acknowledge that the software was developed
17 * by the University of California, Berkeley. The name of the
18 * University may not be used to endorse or promote products derived
19 * from this software without specific prior written permission.
20 * THIS SOFTWARE IS PROVIDED ``AS IS'' AND WITHOUT ANY EXPRESS OR
21 * IMPLIED WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED
22 * WARRANTIES OF MERCHANT[A]BILITY AND FITNESS FOR A PARTICULAR PURPOSE.
27 static char sccsid
[] = "@(#)logwtmp.c 5.2 (Berkeley) 9/20/88";
28 #endif /* defined LIBC_SCCS */
29 #endif /* !defined lint */
31 #include <sys/types.h>
41 char dummy_to_keep_linker_happy
;
43 #endif /* defined OLD_TIME */
51 #define WTMPFILE "/usr/adm/wtmp"
53 void logwtmp( char *line
, char *name
, char *host
)
59 if ((fd
= open(WTMPFILE
, O_WRONLY
|O_APPEND
, 0)) < 0)
61 if (!fstat(fd
, &buf
)) {
62 (void)strncpy(ut
.ut_line
, line
, sizeof(ut
.ut_line
));
63 (void)strncpy(ut
.ut_name
, name
, sizeof(ut
.ut_name
));
64 (void)strncpy(ut
.ut_host
, host
, sizeof(ut
.ut_host
));
65 (void)time(&ut
.ut_time
);
66 if (write(fd
, (char *)&ut
, sizeof(struct utmp
)) !=
68 (void)ftruncate(fd
, buf
.st_size
);
73 #endif /* !defined OLD_TIME */