|
|
0e1944 |
diff -ru sudo-1.8.20/src/ttyname.c sudo-1.8.20-Q/src/ttyname.c
|
|
|
0e1944 |
--- sudo-1.8.20/src/ttyname.c 2017-05-10 08:38:44.000000000 -0700
|
|
|
0e1944 |
+++ sudo-1.8.20-Q/src/ttyname.c 2017-05-19 02:15:48.442705049 -0700
|
|
|
0e1944 |
@@ -1,5 +1,5 @@
|
|
|
0e1944 |
/*
|
|
|
0e1944 |
- * Copyright (c) 2012-2016 Todd C. Miller <Todd.Miller@courtesan.com>
|
|
|
0e1944 |
+ * Copyright (c) 2012-2017 Todd C. Miller <Todd.Miller@courtesan.com>
|
|
|
0e1944 |
*
|
|
|
0e1944 |
* Permission to use, copy, modify, and distribute this software for any
|
|
|
0e1944 |
* purpose with or without fee is hereby granted, provided that the above
|
|
|
0e1944 |
@@ -159,6 +159,8 @@
|
|
|
0e1944 |
|
|
|
0e1944 |
static char *ignore_devs[] = {
|
|
|
0e1944 |
"/dev/fd/",
|
|
|
0e1944 |
+ "/dev/mqueue/",
|
|
|
0e1944 |
+ "/dev/shm/",
|
|
|
0e1944 |
"/dev/stdin",
|
|
|
0e1944 |
"/dev/stdout",
|
|
|
0e1944 |
"/dev/stderr",
|
|
|
0e1944 |
@@ -493,28 +495,35 @@
|
|
|
0e1944 |
len = getline(&line, &linesize, fp);
|
|
|
0e1944 |
fclose(fp);
|
|
|
0e1944 |
if (len != -1) {
|
|
|
0e1944 |
- /* Field 7 is the tty dev (0 if no tty) */
|
|
|
0e1944 |
- char *cp = line;
|
|
|
0e1944 |
- char *ep = line;
|
|
|
0e1944 |
- const char *errstr;
|
|
|
0e1944 |
- int field = 0;
|
|
|
0e1944 |
- while (*++ep != '\0') {
|
|
|
0e1944 |
- if (*ep == ' ') {
|
|
|
0e1944 |
- *ep = '\0';
|
|
|
0e1944 |
- if (++field == 7) {
|
|
|
0e1944 |
- dev_t tdev = strtonum(cp, INT_MIN, INT_MAX, &errstr);
|
|
|
0e1944 |
- if (errstr) {
|
|
|
0e1944 |
- sudo_debug_printf(SUDO_DEBUG_ERROR|SUDO_DEBUG_LINENO,
|
|
|
0e1944 |
- "%s: tty device %s: %s", path, cp, errstr);
|
|
|
0e1944 |
+ /*
|
|
|
0e1944 |
+ * Field 7 is the tty dev (0 if no tty).
|
|
|
0e1944 |
+ * Since the process name at field 2 "(comm)" may include spaces,
|
|
|
0e1944 |
+ * start at the last ')' found.
|
|
|
0e1944 |
+ */
|
|
|
0e1944 |
+ char *cp = strrchr(line, ')');
|
|
|
0e1944 |
+ if (cp != NULL) {
|
|
|
0e1944 |
+ char *ep = cp;
|
|
|
0e1944 |
+ const char *errstr;
|
|
|
0e1944 |
+ int field = 1;
|
|
|
0e1944 |
+
|
|
|
0e1944 |
+ while (*++ep != '\0') {
|
|
|
0e1944 |
+ if (*ep == ' ') {
|
|
|
0e1944 |
+ *ep = '\0';
|
|
|
0e1944 |
+ if (++field == 7) {
|
|
|
0e1944 |
+ dev_t tdev = strtonum(cp, INT_MIN, INT_MAX, &errstr);
|
|
|
0e1944 |
+ if (errstr) {
|
|
|
0e1944 |
+ sudo_debug_printf(SUDO_DEBUG_ERROR|SUDO_DEBUG_LINENO,
|
|
|
0e1944 |
+ "%s: tty device %s: %s", path, cp, errstr);
|
|
|
0e1944 |
+ }
|
|
|
0e1944 |
+ if (tdev > 0) {
|
|
|
0e1944 |
+ errno = serrno;
|
|
|
0e1944 |
+ ret = sudo_ttyname_dev(tdev, name, namelen);
|
|
|
0e1944 |
+ goto done;
|
|
|
0e1944 |
+ }
|
|
|
0e1944 |
+ break;
|
|
|
0e1944 |
}
|
|
|
0e1944 |
- if (tdev > 0) {
|
|
|
0e1944 |
- errno = serrno;
|
|
|
0e1944 |
- ret = sudo_ttyname_dev(tdev, name, namelen);
|
|
|
0e1944 |
- goto done;
|
|
|
0e1944 |
- }
|
|
|
0e1944 |
- break;
|
|
|
0e1944 |
+ cp = ep + 1;
|
|
|
0e1944 |
}
|
|
|
0e1944 |
- cp = ep + 1;
|
|
|
0e1944 |
}
|
|
|
0e1944 |
}
|
|
|
0e1944 |
}
|
|
|
0e1944 |
|