summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorTodd C. Miller <Todd.Miller@sudo.ws>2023-02-08 16:47:18 -0700
committerTodd C. Miller <Todd.Miller@sudo.ws>2023-02-08 16:47:18 -0700
commitccc45780ac94473eb0c5df8f0873c28fe7d26d28 (patch)
tree2d78159987390f2b3bc63be30ad806e06f959ce0
parent96ac9744fa4391a373b5960ad37ac1443118e87b (diff)
downloadsudo-ccc45780ac94473eb0c5df8f0873c28fe7d26d28.tar.gz
Substitute for _PATH_SUDO* variables in pathnames.h.
Previously these were hard-coded with Makefile overrides.
-rwxr-xr-xconfigure143
-rw-r--r--configure.ac29
-rw-r--r--m4/sudo.m434
-rw-r--r--pathnames.h.in16
-rw-r--r--plugins/sudoers/visudo.c2
5 files changed, 174 insertions, 50 deletions
diff --git a/configure b/configure
index 7d997177d..42b67ff44 100755
--- a/configure
+++ b/configure
@@ -35508,26 +35508,6 @@ while test X"$plugindir" != X"$_plugindir"; do
done
exec_prefix="$oexec_prefix"
-# Convert exampledir to something that can be used in the man pages
-# I wish there was a better way to expand this.
-EXAMPLES="$exampledir"
-while :; do
- EXAMPLES="`echo \"$EXAMPLES\" | sed -e 's/(/{/g' -e 's/)/}/g'`"
- case "$EXAMPLES" in
- *\${[A-Za-z]*}*)
- eval EXAMPLES="$EXAMPLES"
- ;;
- *)
- break
- ;;
- esac
-done
-case "$EXAMPLES" in
- NONE/*)
- EXAMPLES="${ac_default_prefix}${EXAMPLES#NONE}"
- ;;
-esac
-
if test X"$enable_intercept" != X"no"
then :
@@ -35632,6 +35612,129 @@ test "$localstatedir" = '${prefix}/var' && localstatedir='$(prefix)/var'
test "$runstatedir" = '${localstatedir}/run' && runstatedir='$(localstatedir)/run'
test "$sysconfdir" = '${prefix}/etc' && sysconfdir='/etc'
+# Expand config file paths for use in pathnames.h
+
+
+ _sudo_define_path_exp="$cvtsudoers_conf"
+ while :; do
+ _sudo_define_path_exp="`echo \"$_sudo_define_path_exp\" | sed -e 's/(/{/g' -e 's/)/}/g'`"
+ case "$_sudo_define_path_exp" in
+ *\${[A-Za-z]*}*)
+ eval _sudo_define_path_exp="$_sudo_define_path_exp"
+ ;;
+ *)
+ break
+ ;;
+ esac
+done
+case "$_sudo_define_path_exp" in
+ NONE/*)
+ _sudo_define_path_exp="${ac_default_prefix}${_sudo_define_path_exp#NONE}"
+ ;;
+esac
+
+ cat >>confdefs.h <<EOF
+#define _PATH_CVTSUDOERS_CONF "$_sudo_define_path_exp"
+EOF
+
+
+
+
+ _sudo_define_path_exp="$sudo_conf"
+ while :; do
+ _sudo_define_path_exp="`echo \"$_sudo_define_path_exp\" | sed -e 's/(/{/g' -e 's/)/}/g'`"
+ case "$_sudo_define_path_exp" in
+ *\${[A-Za-z]*}*)
+ eval _sudo_define_path_exp="$_sudo_define_path_exp"
+ ;;
+ *)
+ break
+ ;;
+ esac
+done
+case "$_sudo_define_path_exp" in
+ NONE/*)
+ _sudo_define_path_exp="${ac_default_prefix}${_sudo_define_path_exp#NONE}"
+ ;;
+esac
+
+ cat >>confdefs.h <<EOF
+#define _PATH_SUDO_CONF "$_sudo_define_path_exp"
+EOF
+
+
+
+
+ _sudo_define_path_exp="$sudo_logsrvd_conf"
+ while :; do
+ _sudo_define_path_exp="`echo \"$_sudo_define_path_exp\" | sed -e 's/(/{/g' -e 's/)/}/g'`"
+ case "$_sudo_define_path_exp" in
+ *\${[A-Za-z]*}*)
+ eval _sudo_define_path_exp="$_sudo_define_path_exp"
+ ;;
+ *)
+ break
+ ;;
+ esac
+done
+case "$_sudo_define_path_exp" in
+ NONE/*)
+ _sudo_define_path_exp="${ac_default_prefix}${_sudo_define_path_exp#NONE}"
+ ;;
+esac
+
+ cat >>confdefs.h <<EOF
+#define _PATH_SUDO_LOGSRVD_CONF "$_sudo_define_path_exp"
+EOF
+
+
+
+
+ _sudo_define_path_exp="$sudoers_path"
+ while :; do
+ _sudo_define_path_exp="`echo \"$_sudo_define_path_exp\" | sed -e 's/(/{/g' -e 's/)/}/g'`"
+ case "$_sudo_define_path_exp" in
+ *\${[A-Za-z]*}*)
+ eval _sudo_define_path_exp="$_sudo_define_path_exp"
+ ;;
+ *)
+ break
+ ;;
+ esac
+done
+case "$_sudo_define_path_exp" in
+ NONE/*)
+ _sudo_define_path_exp="${ac_default_prefix}${_sudo_define_path_exp#NONE}"
+ ;;
+esac
+
+ cat >>confdefs.h <<EOF
+#define _PATH_SUDOERS "$_sudo_define_path_exp"
+EOF
+
+
+
+# Convert exampledir to something that can be used in the man pages
+
+ EXAMPLES="$exampledir"
+ while :; do
+ EXAMPLES="`echo \"$EXAMPLES\" | sed -e 's/(/{/g' -e 's/)/}/g'`"
+ case "$EXAMPLES" in
+ *\${[A-Za-z]*}*)
+ eval EXAMPLES="$EXAMPLES"
+ ;;
+ *)
+ break
+ ;;
+ esac
+done
+case "$EXAMPLES" in
+ NONE/*)
+ EXAMPLES="${ac_default_prefix}${EXAMPLES#NONE}"
+ ;;
+esac
+
+
if test X"$INIT_SCRIPT" != X""
then :
diff --git a/configure.ac b/configure.ac
index a16afc9fd..d4f074275 100644
--- a/configure.ac
+++ b/configure.ac
@@ -4257,26 +4257,6 @@ while test X"$plugindir" != X"$_plugindir"; do
done
exec_prefix="$oexec_prefix"
-# Convert exampledir to something that can be used in the man pages
-# I wish there was a better way to expand this.
-EXAMPLES="$exampledir"
-while :; do
- EXAMPLES="`echo \"$EXAMPLES\" | sed -e 's/(/{/g' -e 's/)/}/g'`"
- case "$EXAMPLES" in
- *\${[[A-Za-z]]*}*)
- eval EXAMPLES="$EXAMPLES"
- ;;
- *)
- break
- ;;
- esac
-done
-case "$EXAMPLES" in
- NONE/*)
- EXAMPLES="${ac_default_prefix}${EXAMPLES#NONE}"
- ;;
-esac
-
dnl
dnl Defer setting _PATH_SUDO_NOEXEC, etc until after exec_prefix is set
dnl
@@ -4355,6 +4335,15 @@ test "$localstatedir" = '${prefix}/var' && localstatedir='$(prefix)/var'
test "$runstatedir" = '${localstatedir}/run' && runstatedir='$(localstatedir)/run'
test "$sysconfdir" = '${prefix}/etc' && sysconfdir='/etc'
+# Expand config file paths for use in pathnames.h (after config dir override)
+SUDO_DEFINE_PATH([$cvtsudoers_conf], [_PATH_CVTSUDOERS_CONF])
+SUDO_DEFINE_PATH([$sudo_conf], [_PATH_SUDO_CONF])
+SUDO_DEFINE_PATH([$sudo_logsrvd_conf], [_PATH_SUDO_LOGSRVD_CONF])
+SUDO_DEFINE_PATH([$sudoers_path], [_PATH_SUDOERS])
+
+# Convert exampledir to something that can be used in the man pages
+SUDO_EXPAND_PATH([$exampledir], [EXAMPLES])
+
dnl
dnl Substitute into the Makefile and man pages
dnl
diff --git a/m4/sudo.m4 b/m4/sudo.m4
index 21a43a07d..7fa1e73bd 100644
--- a/m4/sudo.m4
+++ b/m4/sudo.m4
@@ -556,7 +556,6 @@ AC_DEFUN([SUDO_APPEND_COMPAT_EXP], [
])
dnl
-dnl
dnl Append one or more symbols to INTERCEPT_EXP
dnl
AC_DEFUN([SUDO_APPEND_INTERCEPT_EXP], [
@@ -680,3 +679,36 @@ m4_define([SUDO_DEFINE_UNQUOTED],
[@%:@define] $1 m4_if($#, 2, [$2], $#, 3, [$2], 1)
EOF
])
+
+dnl
+dnl Expand Makefile-style variables in $1 and store the result in $2.
+dnl Used to expand file paths for use in man pages and pathnames.h.
+dnl
+AC_DEFUN([SUDO_EXPAND_PATH], [
+ $2="$1"
+ while :; do
+ $2="`echo \"$$2\" | sed -e 's/(/{/g' -e 's/)/}/g'`"
+ case "$$2" in
+ *\${[[A-Za-z]]*}*)
+ eval $2="$$2"
+ ;;
+ *)
+ break
+ ;;
+ esac
+done
+case "$$2" in
+ NONE/*)
+ $2="${ac_default_prefix}${$2#NONE}"
+ ;;
+esac
+])
+
+dnl
+dnl Expand Makefile-style variables in $1 and define as the string $2.
+dnl Used to define file paths in pathnames.h.
+dnl
+AC_DEFUN([SUDO_DEFINE_PATH], [
+ SUDO_EXPAND_PATH([$1], [_sudo_define_path_exp])
+ SUDO_DEFINE_UNQUOTED($2, "$_sudo_define_path_exp")
+])
diff --git a/pathnames.h.in b/pathnames.h.in
index 366830a39..cf6fd47d5 100644
--- a/pathnames.h.in
+++ b/pathnames.h.in
@@ -58,38 +58,38 @@
#endif /* _PATH_ENVIRONMENT */
/*
+ * The following paths are controlled via the configure script.
+ */
+
+/*
* NOTE: _PATH_SUDO_CONF is usually overridden by the Makefile.
*/
#ifndef _PATH_SUDO_CONF
-# define _PATH_SUDO_CONF "/etc/sudo.conf"
+# undef _PATH_SUDO_CONF
#endif /* _PATH_SUDO_CONF */
/*
* NOTE: _PATH_SUDOERS is usually overridden by the Makefile.
*/
#ifndef _PATH_SUDOERS
-# define _PATH_SUDOERS "/etc/sudoers"
+# undef _PATH_SUDOERS
#endif /* _PATH_SUDOERS */
/*
* NOTE: _PATH_CVTSUDOERS_CONF is usually overridden by the Makefile.
*/
#ifndef _PATH_CVTSUDOERS_CONF
-# define _PATH_CVTSUDOERS_CONF "/etc/cvtsudoers.conf"
+# undef _PATH_CVTSUDOERS_CONF
#endif /* _PATH_CVTSUDOERS_CONF */
/*
* NOTE: _PATH_SUDO_LOGSRVD_CONF is usually overridden by the Makefile.
*/
#ifndef _PATH_SUDO_LOGSRVD_CONF
-# define _PATH_SUDO_LOGSRVD_CONF "/etc/sudo_logsrvd.conf"
+# undef _PATH_SUDO_LOGSRVD_CONF
#endif /* _PATH_SUDO_LOGSRVD_CONF */
/*
- * The following paths are controlled via the configure script.
- */
-
-/*
* Where sudo_logsrvd stores its pid file files. Defaults to
* /var/run/sudo/sudo_logsrvd.pid, /var/db/sudo/sudo_logsrvd.pid,
* /var/lib/sudo/sudo_logsrvd.pid, /var/adm/sudo/sudo_logsrvd.pid or
diff --git a/plugins/sudoers/visudo.c b/plugins/sudoers/visudo.c
index 13b017144..e738e123b 100644
--- a/plugins/sudoers/visudo.c
+++ b/plugins/sudoers/visudo.c
@@ -1060,7 +1060,7 @@ check_syntax(const char *path, bool quiet, bool strict, bool check_owner,
if (fd == -1 || (sudoersin = fdopen(fd, "r")) == NULL) {
if (!quiet)
sudo_warn(U_("unable to open %s"), fname);
- if (fd != -1
+ if (fd != -1)
close(fd);
goto done;
}