xref: /csrg-svn/lib/libutil/login.c (revision 35743)
1*35743Sbostic /*
2*35743Sbostic  * Copyright (c) 1988 The Regents of the University of California.
3*35743Sbostic  * All rights reserved.
4*35743Sbostic  *
5*35743Sbostic  * Redistribution and use in source and binary forms are permitted
6*35743Sbostic  * provided that the above copyright notice and this paragraph are
7*35743Sbostic  * duplicated in all such forms and that any documentation,
8*35743Sbostic  * advertising materials, and other materials related to such
9*35743Sbostic  * distribution and use acknowledge that the software was developed
10*35743Sbostic  * by the University of California, Berkeley.  The name of the
11*35743Sbostic  * University may not be used to endorse or promote products derived
12*35743Sbostic  * from this software without specific prior written permission.
13*35743Sbostic  * THIS SOFTWARE IS PROVIDED ``AS IS'' AND WITHOUT ANY EXPRESS OR
14*35743Sbostic  * IMPLIED WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED
15*35743Sbostic  * WARRANTIES OF MERCHANTIBILITY AND FITNESS FOR A PARTICULAR PURPOSE.
16*35743Sbostic  */
17*35743Sbostic 
18*35743Sbostic #if defined(LIBC_SCCS) && !defined(lint)
19*35743Sbostic static char sccsid[] = "@(#)login.c	5.1 (Berkeley) 09/27/88";
20*35743Sbostic #endif /* LIBC_SCCS and not lint */
21*35743Sbostic 
22*35743Sbostic #include <sys/types.h>
23*35743Sbostic #include <sys/file.h>
24*35743Sbostic #include <utmp.h>
25*35743Sbostic #include <stdio.h>
26*35743Sbostic 
27*35743Sbostic #define	UTMPFILE	"/etc/utmp"
28*35743Sbostic #define	WTMPFILE	"/usr/adm/wtmp"
29*35743Sbostic 
30*35743Sbostic void
31*35743Sbostic login(ut)
32*35743Sbostic 	struct utmp *ut;
33*35743Sbostic {
34*35743Sbostic 	register int fd;
35*35743Sbostic 	int tty;
36*35743Sbostic 	off_t lseek();
37*35743Sbostic 
38*35743Sbostic 	tty = ttyslot();
39*35743Sbostic 	if (tty > 0 && (fd = open(UTMPFILE, O_WRONLY, 0)) >= 0) {
40*35743Sbostic 		(void)lseek(fd, (long)(tty * sizeof(struct utmp)), L_SET);
41*35743Sbostic 		(void)write(fd, (char *)ut, sizeof(struct utmp));
42*35743Sbostic 		(void)close(fd);
43*35743Sbostic 	}
44*35743Sbostic 	if ((fd = open(WTMPFILE, O_WRONLY|O_APPEND, 0)) >= 0) {
45*35743Sbostic 		(void)write(fd, (char *)ut, sizeof(struct utmp));
46*35743Sbostic 		(void)close(fd);
47*35743Sbostic 	}
48*35743Sbostic }
49