135743Sbostic /* 235743Sbostic * Copyright (c) 1988 The Regents of the University of California. 335743Sbostic * All rights reserved. 435743Sbostic * 535743Sbostic * Redistribution and use in source and binary forms are permitted 635743Sbostic * provided that the above copyright notice and this paragraph are 735743Sbostic * duplicated in all such forms and that any documentation, 835743Sbostic * advertising materials, and other materials related to such 935743Sbostic * distribution and use acknowledge that the software was developed 1035743Sbostic * by the University of California, Berkeley. The name of the 1135743Sbostic * University may not be used to endorse or promote products derived 1235743Sbostic * from this software without specific prior written permission. 1335743Sbostic * THIS SOFTWARE IS PROVIDED ``AS IS'' AND WITHOUT ANY EXPRESS OR 1435743Sbostic * IMPLIED WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED 1535743Sbostic * WARRANTIES OF MERCHANTIBILITY AND FITNESS FOR A PARTICULAR PURPOSE. 1635743Sbostic */ 1735743Sbostic 1835743Sbostic #if defined(LIBC_SCCS) && !defined(lint) 19*40660Smckusick static char sccsid[] = "@(#)login.c 5.3 (Berkeley) 03/29/90"; 2035743Sbostic #endif /* LIBC_SCCS and not lint */ 2135743Sbostic 2235743Sbostic #include <sys/types.h> 2335743Sbostic #include <sys/file.h> 2435743Sbostic #include <utmp.h> 2535743Sbostic #include <stdio.h> 2635743Sbostic 2735743Sbostic void 2835743Sbostic login(ut) 2935743Sbostic struct utmp *ut; 3035743Sbostic { 3135743Sbostic register int fd; 3235743Sbostic int tty; 3335743Sbostic off_t lseek(); 3435743Sbostic 3535743Sbostic tty = ttyslot(); 36*40660Smckusick if (tty > 0 && (fd = open(_PATH_UTMP, O_WRONLY|O_CREAT, 0644)) >= 0) { 3735743Sbostic (void)lseek(fd, (long)(tty * sizeof(struct utmp)), L_SET); 3835743Sbostic (void)write(fd, (char *)ut, sizeof(struct utmp)); 3935743Sbostic (void)close(fd); 4035743Sbostic } 4137446Sbostic if ((fd = open(_PATH_WTMP, O_WRONLY|O_APPEND, 0)) >= 0) { 4235743Sbostic (void)write(fd, (char *)ut, sizeof(struct utmp)); 4335743Sbostic (void)close(fd); 4435743Sbostic } 4535743Sbostic } 46