From 6982b6541fe4d8e11e39c3a7ddb95b350b6f385e Mon Sep 17 00:00:00 2001 From: Dan Cross Date: Mon, 11 Jan 2021 01:55:56 +0000 Subject: [PATCH] finger: widen TTY field to avoid truncation The width of the "TTY" field in the output of finger(1) is only three characters, which truncates e.g. 'pts/' lines as used by `sshd`. For example: dfly% finger Login Name TTY Idle Login Time Office Phone cross Dan Cross pts Sun 13:55 cross Dan Cross pts Mon 00:29 dfly% This change exapnds the field to 7 characters, which should be sufficient for "pts/" plus a three digit line number. dfly% ./finger Login Name TTY Idle Login Time Office Phone cross Dan Cross pts/1 Sun 13:55 cross Dan Cross pts/2 Mon 00:29 dfly% Signed-off-by: Dan Cross --- usr.bin/finger/sprint.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/usr.bin/finger/sprint.c b/usr.bin/finger/sprint.c index 7e1eaa9e31..65eac98091 100644 --- a/usr.bin/finger/sprint.c +++ b/usr.bin/finger/sprint.c @@ -78,7 +78,7 @@ sflag_print(void) #define MAXREALNAME 20 #define MAXHOSTNAME 17 /* in reality, hosts are never longer than 16 */ (void)printf("%-*s %-*s%s %s\n", MAXLOGNAME, "Login", MAXREALNAME, - "Name", " TTY Idle Login Time ", (gflag) ? "" : + "Name", " TTY Idle Login Time ", (gflag) ? "" : oflag ? "Office Phone" : "Where"); for (sflag = R_FIRST;; sflag = R_NEXT) { @@ -104,7 +104,7 @@ sflag_print(void) (void)putchar(w->info == LOGGEDIN && !w->writable ? '*' : ' '); if (*w->tty) - (void)printf("%-3.3s ", + (void)printf("%-7.7s ", (strncmp(w->tty, "tty", 3) && strncmp(w->tty, "cua", 3)) ? w->tty : w->tty + 3); -- 2.28.0