--- mingetty-0.9.4/mingetty.c.wtmplock Thu Jun 6 12:29:30 1996 +++ mingetty-0.9.4/mingetty.c Sun Sep 29 17:57:56 2002 @@ -131,6 +135,7 @@ struct utmp ut; int ut_fd; struct utmp *utp; + void locktimeout(); utmpname (_PATH_UTMP); setutent (); @@ -158,7 +163,10 @@ endutent (); if ((ut_fd = open (_PATH_WTMP, O_APPEND | O_WRONLY)) >= 0) { + (void)signal(SIGALRM, locktimeout); + (void)alarm(3); flock (ut_fd, LOCK_EX); + (void)alarm(0); write (ut_fd, &ut, sizeof (ut)); flock (ut_fd, LOCK_UN); close (ut_fd); @@ -437,3 +445,18 @@ exit (0); } +void locktimeout() +{ +#ifdef USE_SYSLOG + openlog (progname, LOG_PID, LOG_AUTH); + syslog(LOG_ALERT, "Lock failed on wtmp"); + closelog (); +#else + int fd; + char buf[]="Lock failed on wtmp\n"; + if ((fd = open ("/dev/console", 1)) >= 0) { + write (fd, buf, strlen (buf)); + close (fd); + } +#endif +}