Well, now I am trying slowly to understand what tterm_reset_utmp() in term.c is doing, however, $ man getutid says:
If ut->ut_type is one of INIT_PROCESS, LOGIN_PROCESS,
USER_PROCESS, or DEAD_PROCESS, getutid() will find the
first entry whose ut_id field matches ut->ut_id.
So changing strncpy(utmp.ut_id, tn, sizeof(utmp.ut_id)); to
strncpy(utmp.ut_line, tn, sizeof(utmp.ut_line)); before calling
utp = getutid(&utmp); seems wrong to me: As memset is called beforehand, after your patch is applied utmp.ut_id will be "\0" when getutid(&utmp) is called, and utp will be always NULL (perhaps).
Well, now I am trying slowly to understand what tterm_reset_utmp() in term.c is doing, however, $ man getutid says:
If ut->ut_type is one of INIT_PROCESS, LOGIN_PROCESS,
USER_PROCESS, or DEAD_PROCESS, getutid() will find the
first entry whose ut_id field matches ut->ut_id.
So changing strncpy(utmp.ut_id, tn, sizeof( utmp.ut_ id)); to utmp.ut_ line, tn, sizeof( utmp.ut_ line)); before calling
strncpy(
utp = getutid(&utmp); seems wrong to me: As memset is called beforehand, after your patch is applied utmp.ut_id will be "\0" when getutid(&utmp) is called, and utp will be always NULL (perhaps).