diff --git a/appl/telnet/telnetd/sys_term.c b/appl/telnet/telnetd/sys_term.c index e73348615..57fa633f8 100644 --- a/appl/telnet/telnetd/sys_term.c +++ b/appl/telnet/telnetd/sys_term.c @@ -1083,6 +1083,22 @@ clean_ttyname (char *tty) return res; } +/* + * Generate a name usable as an `ut_id', typically without `tty'. + */ + +static char * +make_id (char *tty) +{ + char *res = tty; + + if (strncmp (res, "pts/", 4) == 0) + res += 4; + if (strncmp (res, "tty", 3) == 0) + res += 3; + return res; +} + /* * startslave(host) * @@ -1244,6 +1260,9 @@ void start_login(char *host, int autologin, char *name) strncpy(utmpx.ut_user, ".telnet", sizeof(utmpx.ut_user)); strncpy(utmpx.ut_line, clean_ttyname(line), sizeof(utmpx.ut_line)); +#ifdef HAVE_UT_ID + strncpy(utmpx.ut_id, make_id(utmpx.ut_line), sizeof(utmpx.ut_id)); +#endif utmpx.ut_pid = pid; utmpx.ut_type = LOGIN_PROCESS;