Always define _PATH_SUDO_NOEXEC, _PATH_SUDO_SESH, _PATH_SUDO_PLUGIN_DIR,
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.
This commit is contained in:
@@ -16,6 +16,9 @@
|
|||||||
/* A colon-separated list of pathnames to be used as the editor for visudo. */
|
/* A colon-separated list of pathnames to be used as the editor for visudo. */
|
||||||
#undef EDITOR
|
#undef EDITOR
|
||||||
|
|
||||||
|
/* Define to 1 to enable sudo's plugin interface. */
|
||||||
|
#undef ENABLE_SUDO_PLUGIN_API
|
||||||
|
|
||||||
/* Define to 1 to enable environment function debugging. */
|
/* Define to 1 to enable environment function debugging. */
|
||||||
#undef ENV_DEBUG
|
#undef ENV_DEBUG
|
||||||
|
|
||||||
|
15
configure
vendored
15
configure
vendored
@@ -24396,14 +24396,29 @@ EOF
|
|||||||
#define _PATH_SUDO_PLUGIN_DIR "$PLUGINDIR/"
|
#define _PATH_SUDO_PLUGIN_DIR "$PLUGINDIR/"
|
||||||
EOF
|
EOF
|
||||||
|
|
||||||
|
|
||||||
|
$as_echo "#define ENABLE_SUDO_PLUGIN_API 1" >>confdefs.h
|
||||||
|
|
||||||
fi
|
fi
|
||||||
exec_prefix="$oexec_prefix"
|
exec_prefix="$oexec_prefix"
|
||||||
|
fi
|
||||||
|
if test X"$with_noexec" = X"no"; then
|
||||||
|
cat >>confdefs.h <<EOF
|
||||||
|
#define _PATH_SUDO_NOEXEC NULL
|
||||||
|
EOF
|
||||||
|
|
||||||
fi
|
fi
|
||||||
if test X"$with_selinux" = X"no"; then
|
if test X"$with_selinux" = X"no"; then
|
||||||
cat >>confdefs.h <<EOF
|
cat >>confdefs.h <<EOF
|
||||||
#define _PATH_SUDO_SESH NULL
|
#define _PATH_SUDO_SESH NULL
|
||||||
EOF
|
EOF
|
||||||
|
|
||||||
|
fi
|
||||||
|
if test X"$enable_shared" = X"no"; then
|
||||||
|
cat >>confdefs.h <<EOF
|
||||||
|
#define _PATH_SUDO_PLUGIN_DIR NULL
|
||||||
|
EOF
|
||||||
|
|
||||||
fi
|
fi
|
||||||
|
|
||||||
if test X"$LDFLAGS_R" != X""; then
|
if test X"$LDFLAGS_R" != X""; then
|
||||||
|
@@ -4183,12 +4183,19 @@ if test X"$with_noexec" != X"no" -o X"$with_selinux" != X"no" -o "$enabled_share
|
|||||||
eval PLUGINDIR="$_PLUGINDIR"
|
eval PLUGINDIR="$_PLUGINDIR"
|
||||||
done
|
done
|
||||||
SUDO_DEFINE_UNQUOTED(_PATH_SUDO_PLUGIN_DIR, "$PLUGINDIR/")
|
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
|
fi
|
||||||
exec_prefix="$oexec_prefix"
|
exec_prefix="$oexec_prefix"
|
||||||
fi
|
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
|
if test X"$with_selinux" = X"no"; then
|
||||||
SUDO_DEFINE_UNQUOTED(_PATH_SUDO_SESH, NULL)
|
SUDO_DEFINE_UNQUOTED(_PATH_SUDO_SESH, NULL)
|
||||||
fi
|
fi
|
||||||
|
if test X"$enable_shared" = X"no"; then
|
||||||
|
SUDO_DEFINE_UNQUOTED(_PATH_SUDO_PLUGIN_DIR, NULL)
|
||||||
|
fi
|
||||||
|
|
||||||
dnl
|
dnl
|
||||||
dnl Add -R options to LDFLAGS, etc.
|
dnl Add -R options to LDFLAGS, etc.
|
||||||
|
@@ -66,6 +66,7 @@ __dso_public bool sudo_conf_disable_coredump_v1(void);
|
|||||||
__dso_public bool sudo_conf_probe_interfaces_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_group_source_v1(void);
|
||||||
__dso_public int sudo_conf_max_groups_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_askpass_path() sudo_conf_askpass_path_v1()
|
||||||
#define sudo_conf_sesh_path() sudo_conf_sesh_path_v1()
|
#define sudo_conf_sesh_path() sudo_conf_sesh_path_v1()
|
||||||
#define sudo_conf_noexec_path() sudo_conf_noexec_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_probe_interfaces() sudo_conf_probe_interfaces_v1()
|
||||||
#define sudo_conf_group_source() sudo_conf_group_source_v1()
|
#define sudo_conf_group_source() sudo_conf_group_source_v1()
|
||||||
#define sudo_conf_max_groups() sudo_conf_max_groups_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 */
|
#endif /* SUDO_CONF_H */
|
||||||
|
@@ -53,6 +53,7 @@ main(int argc, char *argv[])
|
|||||||
fprintf(stderr, "usage: %s conf_file\n", getprogname());
|
fprintf(stderr, "usage: %s conf_file\n", getprogname());
|
||||||
exit(EXIT_FAILURE);
|
exit(EXIT_FAILURE);
|
||||||
}
|
}
|
||||||
|
sudo_conf_clear_paths();
|
||||||
if (sudo_conf_read(argv[1], SUDO_CONF_ALL) == -1)
|
if (sudo_conf_read(argv[1], SUDO_CONF_ALL) == -1)
|
||||||
exit(EXIT_FAILURE);
|
exit(EXIT_FAILURE);
|
||||||
sudo_conf_dump();
|
sudo_conf_dump();
|
||||||
@@ -77,10 +78,12 @@ sudo_conf_dump(void)
|
|||||||
printf("Set max_groups %d\n", sudo_conf_max_groups());
|
printf("Set max_groups %d\n", sudo_conf_max_groups());
|
||||||
if (sudo_conf_askpass_path() != NULL)
|
if (sudo_conf_askpass_path() != NULL)
|
||||||
printf("Path askpass %s\n", sudo_conf_askpass_path());
|
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)
|
if (sudo_conf_noexec_path() != NULL)
|
||||||
printf("Path noexec %s\n", sudo_conf_noexec_path());
|
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) {
|
TAILQ_FOREACH(info, plugins, entries) {
|
||||||
printf("Plugin %s %s", info->symbol_name, info->path);
|
printf("Plugin %s %s", info->symbol_name, info->path);
|
||||||
if (info->options) {
|
if (info->options) {
|
||||||
|
@@ -2,5 +2,6 @@ Set disable_coredump false
|
|||||||
Set group_source static
|
Set group_source static
|
||||||
Set max_groups -1
|
Set max_groups -1
|
||||||
Path askpass /usr/X11R6/bin/ssh-askpass
|
Path askpass /usr/X11R6/bin/ssh-askpass
|
||||||
|
Path noexec /usr/libexec/sudo_noexec.so
|
||||||
Plugin sudoers_policy sudoers.so
|
Plugin sudoers_policy sudoers.so
|
||||||
Plugin sudoers_io sudoers.so
|
Plugin sudoers_io sudoers.so
|
||||||
|
@@ -55,14 +55,6 @@
|
|||||||
# define ROOT_UID 0
|
# define ROOT_UID 0
|
||||||
#endif
|
#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 {
|
struct sudo_conf_table {
|
||||||
const char *name;
|
const char *name;
|
||||||
unsigned int namelen;
|
unsigned int namelen;
|
||||||
@@ -631,3 +623,16 @@ done:
|
|||||||
free(prev_locale);
|
free(prev_locale);
|
||||||
debug_return_int(ret);
|
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;
|
||||||
|
}
|
||||||
|
@@ -1,5 +1,6 @@
|
|||||||
@COMPAT_EXP@initprogname
|
@COMPAT_EXP@initprogname
|
||||||
sudo_conf_askpass_path_v1
|
sudo_conf_askpass_path_v1
|
||||||
|
sudo_conf_clear_paths_v1
|
||||||
sudo_conf_debug_files_v1
|
sudo_conf_debug_files_v1
|
||||||
sudo_conf_debugging_v1
|
sudo_conf_debugging_v1
|
||||||
sudo_conf_disable_coredump_v1
|
sudo_conf_disable_coredump_v1
|
||||||
|
@@ -256,7 +256,7 @@ sudoers_policy_deserialize_info(void *v, char **runas_user, char **runas_group)
|
|||||||
remhost = *cur + sizeof("remote_host=") - 1;
|
remhost = *cur + sizeof("remote_host=") - 1;
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
#ifdef _PATH_SUDO_PLUGIN_DIR
|
#ifdef ENABLE_SUDO_PLUGIN_API
|
||||||
if (MATCHES(*cur, "plugin_dir=")) {
|
if (MATCHES(*cur, "plugin_dir=")) {
|
||||||
path_plugin_dir = *cur + sizeof("plugin_dir=") - 1;
|
path_plugin_dir = *cur + sizeof("plugin_dir=") - 1;
|
||||||
continue;
|
continue;
|
||||||
|
@@ -36,7 +36,7 @@
|
|||||||
#include "sudo.h"
|
#include "sudo.h"
|
||||||
#include "sudo_exec.h"
|
#include "sudo_exec.h"
|
||||||
|
|
||||||
#ifdef _PATH_SUDO_NOEXEC
|
#ifdef RTLD_PRELOAD_VAR
|
||||||
/*
|
/*
|
||||||
* Add a DSO file to LD_PRELOAD or the system equivalent.
|
* 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);
|
debug_return_ptr(envp);
|
||||||
}
|
}
|
||||||
#endif /* _PATH_SUDO_NOEXEC */
|
#endif /* RTLD_PRELOAD_VAR */
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Disable execution of child processes in the command we are about
|
* 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"));
|
sudo_warn(U_("unable to remove PRIV_PROC_EXEC from PRIV_LIMIT"));
|
||||||
#endif /* HAVE_PRIV_SET */
|
#endif /* HAVE_PRIV_SET */
|
||||||
|
|
||||||
#ifdef _PATH_SUDO_NOEXEC
|
#ifdef RTLD_PRELOAD_VAR
|
||||||
if (dso != NULL)
|
if (dso != NULL)
|
||||||
envp = preload_dso(envp, dso);
|
envp = preload_dso(envp, dso);
|
||||||
#endif /* _PATH_SUDO_NOEXEC */
|
#endif /* RTLD_PRELOAD_VAR */
|
||||||
|
|
||||||
debug_return_ptr(envp);
|
debug_return_ptr(envp);
|
||||||
}
|
}
|
||||||
|
@@ -37,7 +37,7 @@
|
|||||||
/* We always use the same name for the sudoers plugin, regardless of the OS */
|
/* We always use the same name for the sudoers plugin, regardless of the OS */
|
||||||
#define SUDOERS_PLUGIN "sudoers.so"
|
#define SUDOERS_PLUGIN "sudoers.so"
|
||||||
|
|
||||||
#ifdef _PATH_SUDO_PLUGIN_DIR
|
#ifdef ENABLE_SUDO_PLUGIN_API
|
||||||
static int
|
static int
|
||||||
sudo_stat_plugin(struct plugin_info *info, char *fullpath,
|
sudo_stat_plugin(struct plugin_info *info, char *fullpath,
|
||||||
size_t pathsize, struct stat *sb)
|
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);
|
(void)strlcpy(fullpath, info->path, pathsize);
|
||||||
debug_return_bool(true);
|
debug_return_bool(true);
|
||||||
}
|
}
|
||||||
#endif /* _PATH_SUDO_PLUGIN_DIR */
|
#endif /* ENABLE_SUDO_PLUGIN_API */
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Load the plugin specified by "info".
|
* Load the plugin specified by "info".
|
||||||
|
@@ -441,7 +441,7 @@ parse_args(int argc, char **argv, int *nargc, char ***nargv,
|
|||||||
SET(flags, (MODE_IMPLIED_SHELL | MODE_SHELL));
|
SET(flags, (MODE_IMPLIED_SHELL | MODE_SHELL));
|
||||||
sudo_settings[ARG_IMPLIED_SHELL].value = "true";
|
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();
|
sudo_settings[ARG_PLUGIN_DIR].value = sudo_conf_plugin_dir_path();
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user