This patch will upgrade Sudo version 1.8.14 patchlevel 2 to Sudo version 1.8.14 patchlevel 3. To apply: $ cd sudo-1.8.14p2 $ patch -p1 < sudo-1.8.14p3.patch diff -urNa sudo-1.8.14p2/ChangeLog sudo-1.8.14p3/ChangeLog --- sudo-1.8.14p2/ChangeLog Mon Jul 20 20:28:44 2015 +++ sudo-1.8.14p3/ChangeLog Wed Jul 22 06:24:43 2015 @@ -1,3 +1,24 @@ +2015-07-22 Todd C. Miller + + * src/ttyname.c: + fix typo in previous commit + [094488696f2c] + + * NEWS, configure, configure.ac: + Sudo 1.8.14p3 + [0079c43d8247] + +2015-07-21 Todd C. Miller + + * src/ttyname.c: + Fix errno value from get_process_ttyname() when no tty is present. + [ff7b12bb0638] + + * src/ttyname.c: + On AIX, only convert the tty device number from dev64_t to dev32_t + if dev_t is 32-bits. + [0e728a1eb07a] + 2015-07-20 Todd C. Miller * NEWS, configure, configure.ac: diff -urNa sudo-1.8.14p2/NEWS sudo-1.8.14p3/NEWS --- sudo-1.8.14p2/NEWS Mon Jul 20 20:27:54 2015 +++ sudo-1.8.14p3/NEWS Wed Jul 22 06:23:17 2015 @@ -1,3 +1,10 @@ +What's new in Sudo 1.8.14p3 + + * Fixed a bug introduced in sudo 1.8.14p2 that prevented sudo + from working when no tty was present. + + * Fixed tty detection on newer AIX systems where dev_t is 64-bit. + What's new in Sudo 1.8.14p2 * Fixed a bug introduced in sudo 1.8.14 that prevented the lecture diff -urNa sudo-1.8.14p2/configure sudo-1.8.14p3/configure --- sudo-1.8.14p2/configure Mon Jul 20 20:27:54 2015 +++ sudo-1.8.14p3/configure Wed Jul 22 06:23:17 2015 @@ -1,6 +1,6 @@ #! /bin/sh # Guess values for system-dependent variables and create Makefiles. -# Generated by GNU Autoconf 2.69 for sudo 1.8.14p2. +# Generated by GNU Autoconf 2.69 for sudo 1.8.14p3. # # Report bugs to . # @@ -590,8 +590,8 @@ # Identity of this package. PACKAGE_NAME='sudo' PACKAGE_TARNAME='sudo' -PACKAGE_VERSION='1.8.14p2' -PACKAGE_STRING='sudo 1.8.14p2' +PACKAGE_VERSION='1.8.14p3' +PACKAGE_STRING='sudo 1.8.14p3' PACKAGE_BUGREPORT='http://www.sudo.ws/bugs/' PACKAGE_URL='' @@ -1524,7 +1524,7 @@ # Omit some internal or obsolete options to make the list less imposing. # This message is too long to be a string in the A/UX 3.1 sh. cat <<_ACEOF -\`configure' configures sudo 1.8.14p2 to adapt to many kinds of systems. +\`configure' configures sudo 1.8.14p3 to adapt to many kinds of systems. Usage: $0 [OPTION]... [VAR=VALUE]... @@ -1589,7 +1589,7 @@ if test -n "$ac_init_help"; then case $ac_init_help in - short | recursive ) echo "Configuration of sudo 1.8.14p2:";; + short | recursive ) echo "Configuration of sudo 1.8.14p3:";; esac cat <<\_ACEOF @@ -1835,7 +1835,7 @@ test -n "$ac_init_help" && exit $ac_status if $ac_init_version; then cat <<\_ACEOF -sudo configure 1.8.14p2 +sudo configure 1.8.14p3 generated by GNU Autoconf 2.69 Copyright (C) 2012 Free Software Foundation, Inc. @@ -2361,7 +2361,7 @@ This file contains any messages produced by compilers while running configure, to aid debugging if configure makes a mistake. -It was created by sudo $as_me 1.8.14p2, which was +It was created by sudo $as_me 1.8.14p3, which was generated by GNU Autoconf 2.69. Invocation command line was $ $0 $@ @@ -25089,7 +25089,7 @@ # report actual input values of CONFIG_FILES etc. instead of their # values after options handling. ac_log=" -This file was extended by sudo $as_me 1.8.14p2, which was +This file was extended by sudo $as_me 1.8.14p3, which was generated by GNU Autoconf 2.69. Invocation command line was CONFIG_FILES = $CONFIG_FILES @@ -25155,7 +25155,7 @@ cat >>$CONFIG_STATUS <<_ACEOF || ac_write_fail=1 ac_cs_config="`$as_echo "$ac_configure_args" | sed 's/^ //; s/[\\""\`\$]/\\\\&/g'`" ac_cs_version="\\ -sudo config.status 1.8.14p2 +sudo config.status 1.8.14p3 configured by $0, generated by GNU Autoconf 2.69, with options \\"\$ac_cs_config\\" diff -urNa sudo-1.8.14p2/configure.ac sudo-1.8.14p3/configure.ac --- sudo-1.8.14p2/configure.ac Mon Jul 20 20:27:54 2015 +++ sudo-1.8.14p3/configure.ac Wed Jul 22 06:23:17 2015 @@ -4,7 +4,7 @@ dnl Copyright (c) 1994-1996,1998-2015 Todd C. Miller dnl AC_PREREQ([2.59]) -AC_INIT([sudo], [1.8.14p2], [http://www.sudo.ws/bugs/], [sudo]) +AC_INIT([sudo], [1.8.14p3], [http://www.sudo.ws/bugs/], [sudo]) AC_CONFIG_HEADER([config.h pathnames.h]) AC_CONFIG_SRCDIR([src/sudo.c]) dnl diff -urNa sudo-1.8.14p2/src/ttyname.c sudo-1.8.14p3/src/ttyname.c --- sudo-1.8.14p2/src/ttyname.c Mon Jul 20 20:27:54 2015 +++ sudo-1.8.14p3/src/ttyname.c Wed Jul 22 06:23:17 2015 @@ -382,8 +382,8 @@ { struct sudo_kinfo_proc *ki_proc = NULL; size_t size = sizeof(*ki_proc); + int mib[6], rc, serrno = errno; char *rval = NULL; - int mib[6], rc; debug_decl(get_process_ttyname, SUDO_DEBUG_UTIL) /* @@ -407,8 +407,10 @@ ki_proc = kp; rc = sysctl(mib, sudo_kp_namelen, ki_proc, &size, NULL, 0); } while (rc == -1 && errno == ENOMEM); + errno = ENOENT; if (rc != -1) { if ((dev_t)ki_proc->sudo_kp_tdev != (dev_t)-1) { + errno = serrno; rval = sudo_ttyname_dev(ki_proc->sudo_kp_tdev, name, namelen); if (rval == NULL) { sudo_debug_printf(SUDO_DEBUG_WARN|SUDO_DEBUG_LINENO|SUDO_DEBUG_ERRNO, @@ -435,7 +437,7 @@ char path[PATH_MAX], *rval = NULL; struct psinfo psinfo; ssize_t nread; - int fd; + int fd, serrno = errno; debug_decl(get_process_ttyname, SUDO_DEBUG_UTIL) /* Try to determine the tty from pr_ttydev in /proc/pid/psinfo. */ @@ -446,14 +448,19 @@ if (nread == (ssize_t)sizeof(psinfo)) { dev_t rdev = (dev_t)psinfo.pr_ttydev; #if defined(_AIX) && defined(DEVNO64) - if (psinfo.pr_ttydev & DEVNO64) + if ((psinfo.pr_ttydev & DEVNO64) && sizeof(dev_t) == 4) rdev = makedev(major64(psinfo.pr_ttydev), minor64(psinfo.pr_ttydev)); #endif - if (rdev != (dev_t)-1) + if (rdev != (dev_t)-1) { + errno = serrno; rval = sudo_ttyname_dev(rdev, name, namelen); + goto done; + } } } + errno = ENOENT; +done: if (rval == NULL) sudo_debug_printf(SUDO_DEBUG_WARN|SUDO_DEBUG_LINENO|SUDO_DEBUG_ERRNO, "unable to resolve tty via %s", path); @@ -471,6 +478,7 @@ char path[PATH_MAX], *line = NULL; char *rval = NULL; size_t linesize = 0; + int serrno = errno; ssize_t len; FILE *fp; debug_decl(get_process_ttyname, SUDO_DEBUG_UTIL) @@ -495,8 +503,11 @@ sudo_debug_printf(SUDO_DEBUG_ERROR|SUDO_DEBUG_LINENO, "%s: tty device %s: %s", path, cp, errstr); } - if (tdev > 0) + if (tdev > 0) { + errno = serrno; rval = sudo_ttyname_dev(tdev, name, namelen); + goto done; + } break; } cp = ep + 1; @@ -505,7 +516,9 @@ } free(line); } + errno = ENOENT; +done: if (rval == NULL) sudo_debug_printf(SUDO_DEBUG_WARN|SUDO_DEBUG_LINENO|SUDO_DEBUG_ERRNO, "unable to resolve tty via %s", path); @@ -522,7 +535,7 @@ { struct pst_status pstat; char *rval = NULL; - int rc; + int rc, serrno = errno; debug_decl(get_process_ttyname, SUDO_DEBUG_UTIL) /* @@ -532,10 +545,15 @@ rc = pstat_getproc(&pstat, sizeof(pstat), (size_t)0, (int)getpid()); if (rc != -1 || errno == EOVERFLOW) { if (pstat.pst_term.psd_major != -1 && pstat.pst_term.psd_minor != -1) { + errno = serrno; rval = sudo_ttyname_dev(makedev(pstat.pst_term.psd_major, pstat.pst_term.psd_minor), name, namelen); + goto done; } } + errno = ENOENT; + +done: if (rval == NULL) sudo_debug_printf(SUDO_DEBUG_WARN|SUDO_DEBUG_LINENO|SUDO_DEBUG_ERRNO, "unable to resolve tty via pstat");