diff -U4 -r util-linux-2.12r/login-utils/agetty.c util-linux-2.12r+byte/login-utils/agetty.c --- util-linux-2.12r/login-utils/agetty.c 2002-07-29 08:36:42.000000000 +0100 +++ util-linux-2.12r+byte/login-utils/agetty.c 2007-03-16 19:57:57.000000000 +0000 @@ -304,12 +304,16 @@ #endif /* Update the utmp file. */ + #ifdef SYSV_STYLE update_utmp(options.tty); +#else +#error WHAT #endif + debug(_("calling open_tty\n")); /* Open the tty as standard { input, output, error }. */ open_tty(options.tty, &termio, options.flags & F_LOCAL); @@ -556,10 +560,8 @@ update_utmp(line) char *line; { struct utmp ut; - time_t t; - int mypid = getpid(); struct utmp *utp; /* * The utmp file holds miscellaneous information about things started by @@ -572,36 +574,19 @@ utmpname(_PATH_UTMP); setutent(); - /* Find mypid in utmp. Earlier code here tested only - utp->ut_type != INIT_PROCESS, so maybe the >= here should be >. - The present code is taken from login.c, so if this is changed, - maybe login has to be changed as well. */ - while ((utp = getutent())) - if (utp->ut_pid == mypid - && utp->ut_type >= INIT_PROCESS - && utp->ut_type <= DEAD_PROCESS) - break; - - if (utp) { - memcpy(&ut, utp, sizeof(ut)); - } else { - /* some inits don't initialize utmp... */ - memset(&ut, 0, sizeof(ut)); - strncpy(ut.ut_id, line + 3, sizeof(ut.ut_id)); + /* + * Remove utmp entries for this line. + */ + while ((utp = getutent())) { + if (!strcmp(utp->ut_line, line) && utp->ut_type!=DEAD_PROCESS) { + utp->ut_type=DEAD_PROCESS; + utp->ut_time=0; + memset(utp->ut_user,0,UT_NAMESIZE); + pututline(utp); + } } - - strncpy(ut.ut_user, "LOGIN", sizeof(ut.ut_user)); - strncpy(ut.ut_line, line, sizeof(ut.ut_line)); - if (fakehost) - strncpy(ut.ut_host, fakehost, sizeof(ut.ut_host)); - time(&t); - ut.ut_time = t; - ut.ut_type = LOGIN_PROCESS; - ut.ut_pid = mypid; - - pututline(&ut); endutent(); { #ifdef HAVE_updwtmp