Imported Upstream version 1.8.5p2 upstream upstream/1.8.5p2
authorBdale Garbee <bdale@gag.com>
Thu, 28 Jun 2012 18:01:05 +0000 (12:01 -0600)
committerBdale Garbee <bdale@gag.com>
Thu, 28 Jun 2012 18:01:05 +0000 (12:01 -0600)
ChangeLog
NEWS
configure
configure.in
plugins/sudoers/set_perms.c
plugins/sudoers/sudoers.c
plugins/sudoers/toke.c
plugins/sudoers/toke.l
src/env_hooks.c
src/sudo.h
src/tgetpass.c

index ddfb38918497b8f72495c4ce7067f552296fd2a2..ce737280e68e89b1c4c2632b11e5277aa5d825f5 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,44 @@
+2012-05-29  Todd C. Miller  <Todd.Miller@courtesan.com>
+
+       * NEWS:
+       Update for sudo 1.8.5p2
+       [d369d4d40a19]
+
+2012-05-27  Todd C. Miller  <Todd.Miller@courtesan.com>
+
+       * src/env_hooks.c, src/sudo.h, src/tgetpass.c:
+       Provide unhooked version of getenv() and use it when looking up
+       DISPLAY and SUDO_ASKPASS in the environment.
+       [04dbdccf4a14]
+
+2012-05-21  Todd C. Miller  <Todd.Miller@courtesan.com>
+
+       * plugins/sudoers/set_perms.c, plugins/sudoers/sudoers.c:
+       If sudoers_mode is group-readable but the actual sudoers file is
+       not, open the file as uid 0, not uid 1. This fixes a problem when
+       sudoers has a more restrictive mode than what sudo expects to find.
+       In older versions, sudo would silently chmod the file to add the
+       group-readable bit.
+       [c056b6003e6f]
+
+2012-05-17  Todd C. Miller  <Todd.Miller@courtesan.com>
+
+       * NEWS, configure, configure.in:
+       Update for 1.8.5p1
+       [c33c49bf5b4b]
+
+       * plugins/sudoers/toke.c, plugins/sudoers/toke.l:
+       Fix #includedir; from Mike Frysinger
+       [d4833d4e39a0]
+
+       * plugins/sudoers/check.c:
+       Don't prompt for a password if the user is in the exempt group, is
+       root, or is running the command as themselves even if the -k option
+       was specified. This makes "sudo -k command" consistent with the
+       behavior one would get if the user ran "sudo -k" immediately before
+       running the command.
+       [632b3961df00]
+
 2012-05-15  Todd C. Miller  <Todd.Miller@courtesan.com>
 
        * INSTALL:
diff --git a/NEWS b/NEWS
index 2e65329c770516e3445d627c5d911254ccdde1cc..34e7b9a5830c75286fe111113223b1ed91f8783c 100644 (file)
--- a/NEWS
+++ b/NEWS
@@ -1,3 +1,17 @@
+What's new in Sudo 1.8.5p2?
+
+ * Fixed use of the SUDO_ASKPASS environment variable which was
+   broken in Sudo 1.8.5.
+
+ * Fixed a problem reading the sudoers file when the file mode is
+   more restrictive than the expected mode.  For example, when the
+   expected sudoers file mode is 0440 but the actual mode is 0400.
+
+What's new in Sudo 1.8.5p1?
+
+ * Fixed a bug that prevented files in an include directory from
+   being evaluated.
+
 What's new in Sudo 1.8.5?
 
  * When "noexec" is enabled, sudo_noexec.so will now be prepended
index 9c2fcba8dcb1be2d918e9c418974c93701f7b638..4d12595f0ac0c1e7ffababe9b6c059d15910666f 100755 (executable)
--- a/configure
+++ b/configure
@@ -1,6 +1,6 @@
 #! /bin/sh
 # Guess values for system-dependent variables and create Makefiles.
-# Generated by GNU Autoconf 2.68 for sudo 1.8.5.
+# Generated by GNU Autoconf 2.68 for sudo 1.8.5p2.
 #
 # Report bugs to <http://www.sudo.ws/bugs/>.
 #
@@ -570,8 +570,8 @@ MAKEFLAGS=
 # Identity of this package.
 PACKAGE_NAME='sudo'
 PACKAGE_TARNAME='sudo'
-PACKAGE_VERSION='1.8.5'
-PACKAGE_STRING='sudo 1.8.5'
+PACKAGE_VERSION='1.8.5p2'
+PACKAGE_STRING='sudo 1.8.5p2'
 PACKAGE_BUGREPORT='http://www.sudo.ws/bugs/'
 PACKAGE_URL=''
 
@@ -1447,7 +1447,7 @@ if test "$ac_init_help" = "long"; then
   # 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.5 to adapt to many kinds of systems.
+\`configure' configures sudo 1.8.5p2 to adapt to many kinds of systems.
 
 Usage: $0 [OPTION]... [VAR=VALUE]...
 
@@ -1512,7 +1512,7 @@ fi
 
 if test -n "$ac_init_help"; then
   case $ac_init_help in
-     short | recursive ) echo "Configuration of sudo 1.8.5:";;
+     short | recursive ) echo "Configuration of sudo 1.8.5p2:";;
    esac
   cat <<\_ACEOF
 
@@ -1730,7 +1730,7 @@ fi
 test -n "$ac_init_help" && exit $ac_status
 if $ac_init_version; then
   cat <<\_ACEOF
-sudo configure 1.8.5
+sudo configure 1.8.5p2
 generated by GNU Autoconf 2.68
 
 Copyright (C) 2010 Free Software Foundation, Inc.
@@ -2434,7 +2434,7 @@ cat >config.log <<_ACEOF
 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.5, which was
+It was created by sudo $as_me 1.8.5p2, which was
 generated by GNU Autoconf 2.68.  Invocation command line was
 
   $ $0 $@
@@ -20682,7 +20682,7 @@ cat >>$CONFIG_STATUS <<\_ACEOF || ac_write_fail=1
 # 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.5, which was
+This file was extended by sudo $as_me 1.8.5p2, which was
 generated by GNU Autoconf 2.68.  Invocation command line was
 
   CONFIG_FILES    = $CONFIG_FILES
@@ -20748,7 +20748,7 @@ _ACEOF
 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.5
+sudo config.status 1.8.5p2
 configured by $0, generated by GNU Autoconf 2.68,
   with options \\"\$ac_cs_config\\"
 
index 3ab4fa2d7ea0c429af1b2a3359557dd83aa6a750..6ec6016e5afb9ffc1556a4c76437fa06a068f407 100644 (file)
@@ -3,7 +3,7 @@ dnl Process this file with GNU autoconf to produce a configure script.
 dnl
 dnl Copyright (c) 1994-1996,1998-2012 Todd C. Miller <Todd.Miller@courtesan.com>
 dnl
-AC_INIT([sudo], [1.8.5], [http://www.sudo.ws/bugs/], [sudo])
+AC_INIT([sudo], [1.8.5p2], [http://www.sudo.ws/bugs/], [sudo])
 AC_CONFIG_HEADER([config.h pathnames.h])
 dnl
 dnl Note: this must come after AC_INIT
index 97d6ee9e755ea952cb5197915d1c8bb18d4213f9..e2ae5122f5b45c64b13120ccd33a2747d5568551 100644 (file)
@@ -307,7 +307,7 @@ set_perms(int perm)
         * we use a non-zero uid in order to avoid NFS lossage.
         * Using uid 1 is a bit bogus but should work on all OS's.
         */
-       if (sudoers_uid == ROOT_UID && (sudoers_mode & 040))
+       if (sudoers_uid == ROOT_UID && (sudoers_mode & S_IRGRP))
            state->euid = 1;
        else
            state->euid = sudoers_uid;
@@ -617,7 +617,7 @@ set_perms(int perm)
         * we use a non-zero uid in order to avoid NFS lossage.
         * Using uid 1 is a bit bogus but should work on all OS's.
         */
-       if (sudoers_uid == ROOT_UID && (sudoers_mode & 040))
+       if (sudoers_uid == ROOT_UID && (sudoers_mode & S_IRGRP))
            state->euid = 1;
        else
            state->euid = sudoers_uid;
@@ -990,7 +990,7 @@ set_perms(int perm)
         * we use a non-zero uid in order to avoid NFS lossage.
         * Using uid 1 is a bit bogus but should work on all OS's.
         */
-       if (sudoers_uid == ROOT_UID && (sudoers_mode & 040))
+       if (sudoers_uid == ROOT_UID && (sudoers_mode & S_IRGRP))
            state->euid = 1;
        else
            state->euid = sudoers_uid;
@@ -1276,7 +1276,7 @@ set_perms(int perm)
         * we use a non-zero uid in order to avoid NFS lossage.
         * Using uid 1 is a bit bogus but should work on all OS's.
         */
-       if (sudoers_uid == ROOT_UID && (sudoers_mode & 040))
+       if (sudoers_uid == ROOT_UID && (sudoers_mode & S_IRGRP))
            state->euid = 1;
        else
            state->euid = sudoers_uid;
index af72c378f8ce0c6ce2ac7eb384258dcefabea4fd..9002712bc158a95ea56908278a19b7c8bee6b0eb 100644 (file)
@@ -975,13 +975,23 @@ open_sudoers(const char *sudoers, bool doedit, bool *keepopen)
 
     switch (sudo_secure_file(sudoers, sudoers_uid, sudoers_gid, &sb)) {
        case SUDO_PATH_SECURE:
+           /*
+            * If we are expecting sudoers to be group readable but
+            * it is not, we must open the file as root, not uid 1.
+            */
+           if (sudoers_uid == ROOT_UID && (sudoers_mode & S_IRGRP)) {
+               if ((sb.st_mode & S_IRGRP) == 0) {
+                   restore_perms();
+                   set_perms(PERM_ROOT);
+               }
+           }
+           /*
+            * Open sudoers and make sure we can read it so we can present
+            * the user with a reasonable error message (unlike the lexer).
+            */
            if ((fp = fopen(sudoers, "r")) == NULL) {
                log_error(USE_ERRNO, _("unable to open %s"), sudoers);
            } else {
-               /*
-                * Make sure we can actually read sudoers so we can present the
-                * user with a reasonable error message (unlike the lexer).
-                */
                if (sb.st_size != 0 && fgetc(fp) == EOF) {
                    log_error(USE_ERRNO, _("unable to read %s"),
                        sudoers);
index 83125a30cfaac1bf32a6bf17a537803e8b7b9922..40bc1472f693e3eed7002bd5acae8c37648c2160 100644 (file)
@@ -3525,6 +3525,8 @@ _push_include(char *path, bool isdir)
     if (isdir) {
        struct stat sb;
        switch (sudo_secure_dir(path, sudoers_uid, sudoers_gid, &sb)) {
+           case SUDO_PATH_SECURE:
+               break;
            case SUDO_PATH_MISSING:
                debug_return_bool(false);
            case SUDO_PATH_BAD_TYPE:
index 40981cd8392b0d4aec507499fe47d27f27e85b6a..84e8de62dd9819a98b876a6a25eb47813c5a12e6 100644 (file)
@@ -816,6 +816,8 @@ _push_include(char *path, bool isdir)
     if (isdir) {
        struct stat sb;
        switch (sudo_secure_dir(path, sudoers_uid, sudoers_gid, &sb)) {
+           case SUDO_PATH_SECURE:
+               break;
            case SUDO_PATH_MISSING:
                debug_return_bool(false);
            case SUDO_PATH_BAD_TYPE:
index c518cb1bc40e16ad9ea90c1023979a3a07891932..1e1db8cc05c20a723034c5094bb3429f5815c3b4 100644 (file)
@@ -69,6 +69,19 @@ rpl_getenv(const char *name)
 
 typedef char * (*sudo_fn_getenv_t)(const char *);
 
+char *
+getenv_unhooked(const char *name)
+{
+#if defined(HAVE_DLOPEN) && defined(RTLD_NEXT)
+    sudo_fn_getenv_t fn;
+
+    fn = (sudo_fn_getenv_t)dlsym(RTLD_NEXT, "getenv");
+    if (fn != NULL)
+       return fn(name);
+#endif /* HAVE_DLOPEN && RTLD_NEXT */
+    return rpl_getenv(name);
+}
+
 char *
 getenv(const char *name)
 {
@@ -79,16 +92,8 @@ getenv(const char *name)
            return val;
        case SUDO_HOOK_RET_ERROR:
            return NULL;
-       default: {
-#if defined(HAVE_DLOPEN) && defined(RTLD_NEXT)
-           sudo_fn_getenv_t fn;
-
-           fn = (sudo_fn_getenv_t)dlsym(RTLD_NEXT, "getenv");
-           if (fn != NULL)
-               return fn(name);
-#endif /* HAVE_DLOPEN && RTLD_NEXT */
-           return rpl_getenv(name);
-       }
+       default:
+           return getenv_unhooked(name);
     }
 }
 
@@ -136,6 +141,19 @@ rpl_putenv(PUTENV_CONST char *string)
 
 typedef int (*sudo_fn_putenv_t)(PUTENV_CONST char *);
 
+static int
+putenv_unhooked(PUTENV_CONST char *string)
+{
+#if defined(HAVE_DLOPEN) && defined(RTLD_NEXT)
+    sudo_fn_putenv_t fn;
+
+    fn = (sudo_fn_putenv_t)dlsym(RTLD_NEXT, "putenv");
+    if (fn != NULL)
+       return fn(string);
+#endif /* HAVE_DLOPEN && RTLD_NEXT */
+    return rpl_putenv(string);
+}
+
 int
 putenv(PUTENV_CONST char *string)
 {
@@ -144,16 +162,8 @@ putenv(PUTENV_CONST char *string)
            return 0;
        case SUDO_HOOK_RET_ERROR:
            return -1;
-       default: {
-#if defined(HAVE_DLOPEN) && defined(RTLD_NEXT)
-           sudo_fn_putenv_t fn;
-
-           fn = (sudo_fn_putenv_t)dlsym(RTLD_NEXT, "putenv");
-           if (fn != NULL)
-               return fn(string);
-#endif /* HAVE_DLOPEN && RTLD_NEXT */
-           return rpl_putenv(string);
-       }
+       default:
+           return putenv_unhooked(string);
     }
 }
 
@@ -201,6 +211,19 @@ rpl_setenv(const char *var, const char *val, int overwrite)
 
 typedef int (*sudo_fn_setenv_t)(const char *, const char *, int);
 
+static int
+setenv_unhooked(const char *var, const char *val, int overwrite)
+{
+#if defined(HAVE_SETENV) && defined(HAVE_DLOPEN) && defined(RTLD_NEXT)
+    sudo_fn_setenv_t fn;
+
+    fn = (sudo_fn_setenv_t)dlsym(RTLD_NEXT, "setenv");
+    if (fn != NULL)
+       return fn(var, val, overwrite);
+#endif /* HAVE_SETENV && HAVE_DLOPEN && RTLD_NEXT */
+    return rpl_setenv(var, val, overwrite);
+}
+
 int
 setenv(const char *var, const char *val, int overwrite)
 {
@@ -209,24 +232,12 @@ setenv(const char *var, const char *val, int overwrite)
            return 0;
        case SUDO_HOOK_RET_ERROR:
            return -1;
-       default: {
-#if defined(HAVE_SETENV) && defined(HAVE_DLOPEN) && defined(RTLD_NEXT)
-           sudo_fn_setenv_t fn;
-
-           fn = (sudo_fn_setenv_t)dlsym(RTLD_NEXT, "setenv");
-           if (fn != NULL)
-               return fn(var, val, overwrite);
-#endif /* HAVE_SETENV && HAVE_DLOPEN && RTLD_NEXT */
-           return rpl_setenv(var, val, overwrite);
-       }
+       default:
+           return setenv_unhooked(var, val, overwrite);
     }
 }
 
-#ifdef UNSETENV_VOID
-static void
-#else
-int
-#endif
+static int
 rpl_unsetenv(const char *var)
 {
     char **ep = environ;
@@ -234,11 +245,7 @@ rpl_unsetenv(const char *var)
 
     if (var == NULL || *var == '\0' || strchr(var, '=') != NULL) {
        errno = EINVAL;
-#ifdef UNSETENV_VOID
-       return;
-#else
        return -1;
-#endif
     }
 
     len = strlen(var);
@@ -253,9 +260,7 @@ rpl_unsetenv(const char *var)
            ep++;
        }
     }
-#ifndef UNSETENV_VOID
     return 0;
-#endif
 }
 
 #ifdef UNSETENV_VOID
@@ -264,47 +269,49 @@ typedef void (*sudo_fn_unsetenv_t)(const char *);
 typedef int (*sudo_fn_unsetenv_t)(const char *);
 #endif
 
-#ifdef UNSETENV_VOID
-void
-unsetenv(const char *var)
+static int
+unsetenv_unhooked(const char *var)
 {
-    switch (process_hooks_unsetenv(var)) {
-       case SUDO_HOOK_RET_STOP:
-           return 0;
-       case SUDO_HOOK_RET_ERROR:
-           return -1;
-       default: {
+    int rval = 0;
 #if defined(HAVE_UNSETENV) && defined(HAVE_DLOPEN) && defined(RTLD_NEXT)
-           sudo_fn_unsetenv_t fn;
-
-           fn = (sudo_fn_unsetenv_t)dlsym(RTLD_NEXT, "unsetenv");
-           if (fn != NULL)
-               fn(var);
-           else
+    sudo_fn_unsetenv_t fn;
+
+    fn = (sudo_fn_unsetenv_t)dlsym(RTLD_NEXT, "unsetenv");
+    if (fn != NULL) {
+# ifdef UNSETENV_VOID
+       fn(var);
+# else
+       rval = fn(var);
+# endif
+    } else
 #endif /* HAVE_UNSETENV && HAVE_DLOPEN && RTLD_NEXT */
-               rpl_unsetenv(var);
-       }
+    {
+       rval = rpl_unsetenv(var);
     }
+    return rval;
 }
+
+#ifdef UNSETENV_VOID
+void
 #else
 int
+#endif
 unsetenv(const char *var)
 {
+    int rval;
+
     switch (process_hooks_unsetenv(var)) {
        case SUDO_HOOK_RET_STOP:
-           return 0;
+           rval = 0;
+           break;
        case SUDO_HOOK_RET_ERROR:
-           return -1;
-       default: {
-#if defined(HAVE_UNSETENV) && defined(HAVE_DLOPEN) && defined(RTLD_NEXT)
-           sudo_fn_unsetenv_t fn;
-
-           fn = (sudo_fn_unsetenv_t)dlsym(RTLD_NEXT, "unsetenv");
-           if (fn != NULL)
-               return fn(var);
-#endif /* HAVE_UNSETENV && HAVE_DLOPEN && RTLD_NEXT */
-           return rpl_unsetenv(var);
-       }
+           rval = -1;
+           break;
+       default:
+           rval = unsetenv_unhooked(var);
+           break;
     }
+#ifndef UNSETENV_VOID
+    return rval;
+#endif
 }
-#endif /* UNSETENV_VOID */
index 8843914b6cab4039765ba8c0fe7f544c0802e173..c50f1e1d6dd66b8f95ea853ad065efc0b3b7025c 100644 (file)
@@ -237,6 +237,9 @@ int process_hooks_setenv(const char *name, const char *value, int overwrite);
 int process_hooks_putenv(char *string);
 int process_hooks_unsetenv(const char *name);
 
+/* env_hooks.c */
+char *getenv_unhooked(const char *name);
+
 /* interfaces.c */
 int get_net_ifs(char **addrinfo);
 
index e9915b2bdd7af6a7e96341214d9e31387c4747d3..b23db4cc5fe87c9b3b9a1e684e9cb1fb47c668f4 100644 (file)
@@ -78,7 +78,7 @@ tgetpass(const char *prompt, int timeout, int flags)
     (void) fflush(stdout);
 
     if (askpass == NULL) {
-       askpass = getenv("SUDO_ASKPASS");
+       askpass = getenv_unhooked("SUDO_ASKPASS");
        if (askpass == NULL || *askpass == '\0')
            askpass = sudo_conf_askpass_path();
     }
@@ -86,7 +86,7 @@ tgetpass(const char *prompt, int timeout, int flags)
     /* If no tty present and we need to disable echo, try askpass. */
     if (!ISSET(flags, TGP_STDIN|TGP_ECHO|TGP_ASKPASS|TGP_NOECHO_TRY) &&
        !tty_present()) {
-       if (askpass == NULL || getenv("DISPLAY") == NULL) {
+       if (askpass == NULL || getenv_unhooked("DISPLAY") == NULL) {
            warningx(_("no tty present and no askpass program specified"));
            debug_return_str(NULL);
        }