Commit | Line | Data |
---|---|---|
fe24e6e7 KB |
1 | /* |
2 | * Copyright (c) 1988 The Regents of the University of California. | |
3 | * All rights reserved. | |
4 | * | |
1343342a | 5 | * %sccs.include.redist.c% |
fe24e6e7 KB |
6 | */ |
7 | ||
8 | #if defined(LIBC_SCCS) && !defined(lint) | |
1343342a | 9 | static char sccsid[] = "@(#)login.c 5.4 (Berkeley) %G%"; |
fe24e6e7 KB |
10 | #endif /* LIBC_SCCS and not lint */ |
11 | ||
12 | #include <sys/types.h> | |
13 | #include <sys/file.h> | |
14 | #include <utmp.h> | |
15 | #include <stdio.h> | |
16 | ||
fe24e6e7 KB |
17 | void |
18 | login(ut) | |
19 | struct utmp *ut; | |
20 | { | |
21 | register int fd; | |
22 | int tty; | |
23 | off_t lseek(); | |
24 | ||
25 | tty = ttyslot(); | |
49a1db6b | 26 | if (tty > 0 && (fd = open(_PATH_UTMP, O_WRONLY|O_CREAT, 0644)) >= 0) { |
fe24e6e7 KB |
27 | (void)lseek(fd, (long)(tty * sizeof(struct utmp)), L_SET); |
28 | (void)write(fd, (char *)ut, sizeof(struct utmp)); | |
29 | (void)close(fd); | |
30 | } | |
579320b6 | 31 | if ((fd = open(_PATH_WTMP, O_WRONLY|O_APPEND, 0)) >= 0) { |
fe24e6e7 KB |
32 | (void)write(fd, (char *)ut, sizeof(struct utmp)); |
33 | (void)close(fd); | |
34 | } | |
35 | } |