xref: /csrg-svn/lib/libutil/login.c (revision 54586)
135743Sbostic /*
235743Sbostic  * Copyright (c) 1988 The Regents of the University of California.
335743Sbostic  * All rights reserved.
435743Sbostic  *
542662Sbostic  * %sccs.include.redist.c%
635743Sbostic  */
735743Sbostic 
835743Sbostic #if defined(LIBC_SCCS) && !defined(lint)
9*54586Sbostic static char sccsid[] = "@(#)login.c	5.5 (Berkeley) 07/01/92";
1035743Sbostic #endif /* LIBC_SCCS and not lint */
1135743Sbostic 
1235743Sbostic #include <sys/types.h>
13*54586Sbostic 
14*54586Sbostic #include <fcntl.h>
15*54586Sbostic #include <unistd.h>
16*54586Sbostic #include <stdlib.h>
1735743Sbostic #include <utmp.h>
1835743Sbostic #include <stdio.h>
1935743Sbostic 
2035743Sbostic void
2135743Sbostic login(ut)
2235743Sbostic 	struct utmp *ut;
2335743Sbostic {
2435743Sbostic 	register int fd;
2535743Sbostic 	int tty;
2635743Sbostic 
2735743Sbostic 	tty = ttyslot();
2840660Smckusick 	if (tty > 0 && (fd = open(_PATH_UTMP, O_WRONLY|O_CREAT, 0644)) >= 0) {
29*54586Sbostic 		(void)lseek(fd, (off_t)(tty * sizeof(struct utmp)), L_SET);
30*54586Sbostic 		(void)write(fd, ut, sizeof(struct utmp));
3135743Sbostic 		(void)close(fd);
3235743Sbostic 	}
3337446Sbostic 	if ((fd = open(_PATH_WTMP, O_WRONLY|O_APPEND, 0)) >= 0) {
34*54586Sbostic 		(void)write(fd, ut, sizeof(struct utmp));
3535743Sbostic 		(void)close(fd);
3635743Sbostic 	}
3735743Sbostic }
38