]> granicus.if.org Git - sudo/commitdiff
Always define _PATH_SUDO_NOEXEC, _PATH_SUDO_SESH, _PATH_SUDO_PLUGIN_DIR,
authorTodd C. Miller <Todd.Miller@courtesan.com>
Wed, 16 Nov 2016 17:13:26 +0000 (10:13 -0700)
committerTodd C. Miller <Todd.Miller@courtesan.com>
Wed, 16 Nov 2016 17:13:26 +0000 (10:13 -0700)
even if only defined to NULL.  This means the accessors can always be
present.

Use RTLD_PRELOAD_VAR instead of _PATH_SUDO_NOEXEC to tell when
noexec is available.

Add ENABLE_SUDO_PLUGIN_API and use it instead of _PATH_SUDO_PLUGIN_DIR
to tell when the plugin API is available.

Add sudo_conf_clear_paths() to clear the path values so the
regress tests are not affected by compile-time settings.

12 files changed:
config.h.in
configure
configure.ac
include/sudo_conf.h
lib/util/regress/sudo_conf/conf_test.c
lib/util/regress/sudo_conf/test1.out.ok
lib/util/sudo_conf.c
lib/util/util.exp.in
plugins/sudoers/policy.c
src/exec_common.c
src/load_plugins.c
src/parse_args.c

index 0fb1b98e2147567459639642d7a9ba2ccd39a6ec..b07626dd39e9892697fa4a21298a8d76d436f5a6 100644 (file)
@@ -16,6 +16,9 @@
 /* A colon-separated list of pathnames to be used as the editor for visudo. */
 #undef EDITOR
 
+/* Define to 1 to enable sudo's plugin interface. */
+#undef ENABLE_SUDO_PLUGIN_API
+
 /* Define to 1 to enable environment function debugging. */
 #undef ENV_DEBUG
 
index d16b64e98892ba6493182a93949202bd257d3b7b..645faa2c2c78d766bddbea8a3b1c5a0df4123e0f 100755 (executable)
--- a/configure
+++ b/configure
@@ -24396,14 +24396,29 @@ EOF
 #define _PATH_SUDO_PLUGIN_DIR "$PLUGINDIR/"
 EOF
 
+
+$as_echo "#define ENABLE_SUDO_PLUGIN_API 1" >>confdefs.h
+
     fi
     exec_prefix="$oexec_prefix"
+fi
+if test X"$with_noexec" = X"no"; then
+    cat >>confdefs.h <<EOF
+#define _PATH_SUDO_NOEXEC NULL
+EOF
+
 fi
 if test X"$with_selinux" = X"no"; then
     cat >>confdefs.h <<EOF
 #define _PATH_SUDO_SESH NULL
 EOF
 
+fi
+if test X"$enable_shared" = X"no"; then
+    cat >>confdefs.h <<EOF
+#define _PATH_SUDO_PLUGIN_DIR NULL
+EOF
+
 fi
 
 if test X"$LDFLAGS_R" != X""; then
index 8ddd651ec3e04da2ae19641252ff9de9f9fc76d2..1407211d648c18fab65a6b9ecf5111d939906cc7 100644 (file)
@@ -4183,12 +4183,19 @@ if test X"$with_noexec" != X"no" -o X"$with_selinux" != X"no" -o "$enabled_share
            eval PLUGINDIR="$_PLUGINDIR"
        done
        SUDO_DEFINE_UNQUOTED(_PATH_SUDO_PLUGIN_DIR, "$PLUGINDIR/")
+       AC_DEFINE(ENABLE_SUDO_PLUGIN_API, 1, [Define to 1 to enable sudo's plugin interface.])
     fi
     exec_prefix="$oexec_prefix"
 fi
+if test X"$with_noexec" = X"no"; then
+    SUDO_DEFINE_UNQUOTED(_PATH_SUDO_NOEXEC, NULL)
+fi
 if test X"$with_selinux" = X"no"; then
     SUDO_DEFINE_UNQUOTED(_PATH_SUDO_SESH, NULL)
 fi
+if test X"$enable_shared" = X"no"; then
+    SUDO_DEFINE_UNQUOTED(_PATH_SUDO_PLUGIN_DIR, NULL)
+fi
 
 dnl
 dnl Add -R options to LDFLAGS, etc.
index 468533e73c3f2b54b07e33cfc53aa9c6557bd3ba..14fe55f16187e6e5a63d626f5403134c9f2854a4 100644 (file)
@@ -66,6 +66,7 @@ __dso_public bool sudo_conf_disable_coredump_v1(void);
 __dso_public bool sudo_conf_probe_interfaces_v1(void);
 __dso_public int sudo_conf_group_source_v1(void);
 __dso_public int sudo_conf_max_groups_v1(void);
+__dso_public void sudo_conf_clear_paths_v1(void);
 #define sudo_conf_askpass_path() sudo_conf_askpass_path_v1()
 #define sudo_conf_sesh_path() sudo_conf_sesh_path_v1()
 #define sudo_conf_noexec_path() sudo_conf_noexec_path_v1()
@@ -77,5 +78,6 @@ __dso_public int sudo_conf_max_groups_v1(void);
 #define sudo_conf_probe_interfaces() sudo_conf_probe_interfaces_v1()
 #define sudo_conf_group_source() sudo_conf_group_source_v1()
 #define sudo_conf_max_groups() sudo_conf_max_groups_v1()
+#define sudo_conf_clear_paths() sudo_conf_clear_paths_v1()
 
 #endif /* SUDO_CONF_H */
index 97995e25620d54189191ee688a52180386932c93..93ccd154dfc3c54cdf460e7ca69e19ed6e04db58 100644 (file)
@@ -53,6 +53,7 @@ main(int argc, char *argv[])
        fprintf(stderr, "usage: %s conf_file\n", getprogname());
        exit(EXIT_FAILURE);
     }
+    sudo_conf_clear_paths();
     if (sudo_conf_read(argv[1], SUDO_CONF_ALL) == -1)
        exit(EXIT_FAILURE);
     sudo_conf_dump();
@@ -77,10 +78,12 @@ sudo_conf_dump(void)
     printf("Set max_groups %d\n", sudo_conf_max_groups());
     if (sudo_conf_askpass_path() != NULL)
        printf("Path askpass %s\n", sudo_conf_askpass_path());
-#ifdef _PATH_SUDO_NOEXEC
+    if (sudo_conf_sesh_path() != NULL)
+       printf("Path sesh %s\n", sudo_conf_sesh_path());
     if (sudo_conf_noexec_path() != NULL)
        printf("Path noexec %s\n", sudo_conf_noexec_path());
-#endif
+    if (sudo_conf_plugin_dir_path() != NULL)
+       printf("Path plugin_dir %s\n", sudo_conf_plugin_dir_path());
     TAILQ_FOREACH(info, plugins, entries) {
        printf("Plugin %s %s", info->symbol_name, info->path);
        if (info->options) {
index 54e067180235f788e3c02a4c1747cd50cc237c26..18807483d40cde3b00cd4373fe89a74216810426 100644 (file)
@@ -2,5 +2,6 @@ Set disable_coredump false
 Set group_source static
 Set max_groups -1
 Path askpass /usr/X11R6/bin/ssh-askpass
+Path noexec /usr/libexec/sudo_noexec.so
 Plugin sudoers_policy sudoers.so
 Plugin sudoers_io sudoers.so
index d7988e793f392e93bddfe48a0d8771982282185b..f5dd57a9dd33a2c3e9e3e885a2af92104d97a98f 100644 (file)
 # define ROOT_UID      0
 #endif
 
-/* Avoid excessive #ifdefs in the code. */
-#ifndef _PATH_SUDO_NOEXEC
-# define _PATH_SUDO_NOEXEC     NULL
-#endif
-#ifndef _PATH_SUDO_PLUGIN_DIR
-# define _PATH_SUDO_PLUGIN_DIR NULL
-#endif
-
 struct sudo_conf_table {
     const char *name;
     unsigned int namelen;
@@ -631,3 +623,16 @@ done:
     free(prev_locale);
     debug_return_int(ret);
 }
+
+/*
+ * Used by the sudo_conf regress test to clear compile-time path settings.
+ */
+void
+sudo_conf_clear_paths_v1(void)
+{
+    struct sudo_conf_path_table *cur;
+    debug_decl(sudo_conf_clear_paths, SUDO_DEBUG_UTIL)
+
+    for (cur = sudo_conf_data.path_table; cur->pname != NULL; cur++)
+       cur->pval = NULL;
+}
index d29a00669e94887aa4f7a0bf78316243d335e8f1..0164491e8310188a1c787dcaf1f3317f698241fc 100644 (file)
@@ -1,5 +1,6 @@
 @COMPAT_EXP@initprogname
 sudo_conf_askpass_path_v1
+sudo_conf_clear_paths_v1
 sudo_conf_debug_files_v1
 sudo_conf_debugging_v1
 sudo_conf_disable_coredump_v1
index 08ac25a8139deb8ebc97c476ffeb855c71b9fef0..2fa684b98d2c28f661e86ebc3fd5728f1cd618a3 100644 (file)
@@ -256,7 +256,7 @@ sudoers_policy_deserialize_info(void *v, char **runas_user, char **runas_group)
            remhost = *cur + sizeof("remote_host=") - 1;
            continue;
        }
-#ifdef _PATH_SUDO_PLUGIN_DIR
+#ifdef ENABLE_SUDO_PLUGIN_API
        if (MATCHES(*cur, "plugin_dir=")) {
            path_plugin_dir = *cur + sizeof("plugin_dir=") - 1;
            continue;
index 9dd2b2b8c9899e44f47610a22c12a9325c5b3c8c..f0b345d26413d28823b5db877937f37974d6b8c8 100644 (file)
@@ -36,7 +36,7 @@
 #include "sudo.h"
 #include "sudo_exec.h"
 
-#ifdef _PATH_SUDO_NOEXEC
+#ifdef RTLD_PRELOAD_VAR
 /*
  * Add a DSO file to LD_PRELOAD or the system equivalent.
  */
@@ -144,7 +144,7 @@ preload_dso(char *envp[], const char *dso_file)
 
     debug_return_ptr(envp);
 }
-#endif /* _PATH_SUDO_NOEXEC */
+#endif /* RTLD_PRELOAD_VAR */
 
 /*
  * Disable execution of child processes in the command we are about
@@ -166,10 +166,10 @@ disable_execute(char *envp[], const char *dso)
     sudo_warn(U_("unable to remove PRIV_PROC_EXEC from PRIV_LIMIT"));
 #endif /* HAVE_PRIV_SET */
 
-#ifdef _PATH_SUDO_NOEXEC
+#ifdef RTLD_PRELOAD_VAR
     if (dso != NULL)
        envp = preload_dso(envp, dso);
-#endif /* _PATH_SUDO_NOEXEC */
+#endif /* RTLD_PRELOAD_VAR */
 
     debug_return_ptr(envp);
 }
index 5fd6eafbf0101b0286dfc938ade6315b4877444c..fb620b121c420b00076b383d6bfa644d983dd814 100644 (file)
@@ -37,7 +37,7 @@
 /* We always use the same name for the sudoers plugin, regardless of the OS */
 #define SUDOERS_PLUGIN "sudoers.so"
 
-#ifdef _PATH_SUDO_PLUGIN_DIR
+#ifdef ENABLE_SUDO_PLUGIN_API
 static int
 sudo_stat_plugin(struct plugin_info *info, char *fullpath,
     size_t pathsize, struct stat *sb)
@@ -144,7 +144,7 @@ sudo_check_plugin(struct plugin_info *info, char *fullpath, size_t pathsize)
     (void)strlcpy(fullpath, info->path, pathsize);
     debug_return_bool(true);
 }
-#endif /* _PATH_SUDO_PLUGIN_DIR */
+#endif /* ENABLE_SUDO_PLUGIN_API */
 
 /*
  * Load the plugin specified by "info".
index 22efddd72f422fe445ceb028efffa40f78508cea..b6dd2b87a1a75fdabca99de0d5d9b47fb4d1aeec 100644 (file)
@@ -441,7 +441,7 @@ parse_args(int argc, char **argv, int *nargc, char ***nargv,
        SET(flags, (MODE_IMPLIED_SHELL | MODE_SHELL));
        sudo_settings[ARG_IMPLIED_SHELL].value = "true";
     }
-#ifdef _PATH_SUDO_PLUGIN_DIR
+#ifdef ENABLE_SUDO_PLUGIN_API
     sudo_settings[ARG_PLUGIN_DIR].value = sudo_conf_plugin_dir_path();
 #endif