From 5794e511da896191ef8da0b8aeac2300435e400e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ignacy=20Gaw=C4=99dzki?= Date: Wed, 15 Jan 2025 11:58:27 +0100 Subject: [PATCH] Fix getting ppid in get_process_ttyname for Linux. MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit The ppid field in /proc/self/stat is the fourth and not the third. The latter is the process state (S, R, etc.). Signed-off-by: Ignacy Gawędzki --- src/ttyname.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/ttyname.c b/src/ttyname.c index 0e6e8467f..1e1047511 100644 --- a/src/ttyname.c +++ b/src/ttyname.c @@ -301,7 +301,7 @@ get_process_ttyname(char *name, size_t namelen) } break; } - if (field == 3) { + if (field == 4) { ppid = (int)sudo_strtonum(cp, INT_MIN, INT_MAX, NULL); }