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