xref: /csrg-svn/lib/libutil/login.c (revision 42662)
135743Sbostic /*
235743Sbostic  * Copyright (c) 1988 The Regents of the University of California.
335743Sbostic  * All rights reserved.
435743Sbostic  *
5*42662Sbostic  * %sccs.include.redist.c%
635743Sbostic  */
735743Sbostic 
835743Sbostic #if defined(LIBC_SCCS) && !defined(lint)
9*42662Sbostic static char sccsid[] = "@(#)login.c	5.4 (Berkeley) 06/01/90";
1035743Sbostic #endif /* LIBC_SCCS and not lint */
1135743Sbostic 
1235743Sbostic #include <sys/types.h>
1335743Sbostic #include <sys/file.h>
1435743Sbostic #include <utmp.h>
1535743Sbostic #include <stdio.h>
1635743Sbostic 
1735743Sbostic void
1835743Sbostic login(ut)
1935743Sbostic 	struct utmp *ut;
2035743Sbostic {
2135743Sbostic 	register int fd;
2235743Sbostic 	int tty;
2335743Sbostic 	off_t lseek();
2435743Sbostic 
2535743Sbostic 	tty = ttyslot();
2640660Smckusick 	if (tty > 0 && (fd = open(_PATH_UTMP, O_WRONLY|O_CREAT, 0644)) >= 0) {
2735743Sbostic 		(void)lseek(fd, (long)(tty * sizeof(struct utmp)), L_SET);
2835743Sbostic 		(void)write(fd, (char *)ut, sizeof(struct utmp));
2935743Sbostic 		(void)close(fd);
3035743Sbostic 	}
3137446Sbostic 	if ((fd = open(_PATH_WTMP, O_WRONLY|O_APPEND, 0)) >= 0) {
3235743Sbostic 		(void)write(fd, (char *)ut, sizeof(struct utmp));
3335743Sbostic 		(void)close(fd);
3435743Sbostic 	}
3535743Sbostic }
36