xref: /csrg-svn/lib/libutil/login.c (revision 61340)
135743Sbostic /*
2*61340Sbostic  * Copyright (c) 1988, 1993
3*61340Sbostic  *	The Regents of the University of California.  All rights reserved.
435743Sbostic  *
542662Sbostic  * %sccs.include.redist.c%
635743Sbostic  */
735743Sbostic 
835743Sbostic #if defined(LIBC_SCCS) && !defined(lint)
9*61340Sbostic static char sccsid[] = "@(#)login.c	8.1 (Berkeley) 06/04/93";
1035743Sbostic #endif /* LIBC_SCCS and not lint */
1135743Sbostic 
1235743Sbostic #include <sys/types.h>
1354586Sbostic 
1454586Sbostic #include <fcntl.h>
1554586Sbostic #include <unistd.h>
1654586Sbostic #include <stdlib.h>
1735743Sbostic #include <utmp.h>
1835743Sbostic #include <stdio.h>
1935743Sbostic 
2035743Sbostic void
login(ut)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) {
2954586Sbostic 		(void)lseek(fd, (off_t)(tty * sizeof(struct utmp)), L_SET);
3054586Sbostic 		(void)write(fd, ut, sizeof(struct utmp));
3135743Sbostic 		(void)close(fd);
3235743Sbostic 	}
3337446Sbostic 	if ((fd = open(_PATH_WTMP, O_WRONLY|O_APPEND, 0)) >= 0) {
3454586Sbostic 		(void)write(fd, ut, sizeof(struct utmp));
3535743Sbostic 		(void)close(fd);
3635743Sbostic 	}
3735743Sbostic }
38