1 |
diff -up sudo-1.8.6p7/src/ttyname.c.get_process_ttyname sudo-1.8.6p7/src/ttyname.c |
2 |
--- sudo-1.8.6p7/src/ttyname.c.get_process_ttyname 2013-02-25 20:46:09.000000000 +0100 |
3 |
+++ sudo-1.8.6p7/src/ttyname.c 2017-05-25 10:23:28.720850944 +0200 |
4 |
@@ -171,6 +171,8 @@ static char *search_devs[] = { |
5 |
|
6 |
static char *ignore_devs[] = { |
7 |
"/dev/fd/", |
8 |
+ "/dev/mqueue/", |
9 |
+ "/dev/shm/", |
10 |
"/dev/stdin", |
11 |
"/dev/stdout", |
12 |
"/dev/stderr", |
13 |
@@ -437,9 +439,13 @@ get_process_ttyname(void) |
14 |
len = getline(&line, &linesize, fp); |
15 |
fclose(fp); |
16 |
if (len != -1) { |
17 |
- /* Field 7 is the tty dev (0 if no tty) */ |
18 |
- char *cp = line; |
19 |
- int field = 1; |
20 |
+ /* |
21 |
+ * Field 7 is the tty dev (0 if no tty). |
22 |
+ * Since the process name at field 2 "(comm)" may include spaces, |
23 |
+ * start at the last ')' found. |
24 |
+ */ |
25 |
+ char *cp = strrchr(line, ')'); |
26 |
+ int field = 2; |
27 |
while (*cp != '\0') { |
28 |
if (*cp++ == ' ') { |
29 |
if (++field == 7) { |