2
0
mirror of https://github.com/sudo-project/sudo.git synced 2025-08-22 09:57:41 +00:00

Substitute for _PATH_SUDO* variables in pathnames.h.

Previously these were hard-coded with Makefile overrides.
This commit is contained in:
Todd C. Miller 2023-02-08 16:47:18 -07:00
parent f17b35471f
commit 9ad6dfa371
5 changed files with 174 additions and 50 deletions

143
configure vendored
View File

@ -35508,26 +35508,6 @@ while test X"$plugindir" != X"$_plugindir"; do
done done
exec_prefix="$oexec_prefix" 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" if test X"$enable_intercept" != X"no"
then : then :
@ -35632,6 +35612,129 @@ test "$localstatedir" = '${prefix}/var' && localstatedir='$(prefix)/var'
test "$runstatedir" = '${localstatedir}/run' && runstatedir='$(localstatedir)/run' test "$runstatedir" = '${localstatedir}/run' && runstatedir='$(localstatedir)/run'
test "$sysconfdir" = '${prefix}/etc' && sysconfdir='/etc' 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"" if test X"$INIT_SCRIPT" != X""
then : then :

View File

@ -4257,26 +4257,6 @@ while test X"$plugindir" != X"$_plugindir"; do
done done
exec_prefix="$oexec_prefix" 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
dnl Defer setting _PATH_SUDO_NOEXEC, etc until after exec_prefix is set dnl Defer setting _PATH_SUDO_NOEXEC, etc until after exec_prefix is set
dnl dnl
@ -4355,6 +4335,15 @@ test "$localstatedir" = '${prefix}/var' && localstatedir='$(prefix)/var'
test "$runstatedir" = '${localstatedir}/run' && runstatedir='$(localstatedir)/run' test "$runstatedir" = '${localstatedir}/run' && runstatedir='$(localstatedir)/run'
test "$sysconfdir" = '${prefix}/etc' && sysconfdir='/etc' 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
dnl Substitute into the Makefile and man pages dnl Substitute into the Makefile and man pages
dnl dnl

View File

@ -555,7 +555,6 @@ AC_DEFUN([SUDO_APPEND_COMPAT_EXP], [
done done
]) ])
dnl
dnl dnl
dnl Append one or more symbols to INTERCEPT_EXP dnl Append one or more symbols to INTERCEPT_EXP
dnl dnl
@ -680,3 +679,36 @@ m4_define([SUDO_DEFINE_UNQUOTED],
[@%:@define] $1 m4_if($#, 2, [$2], $#, 3, [$2], 1) [@%:@define] $1 m4_if($#, 2, [$2], $#, 3, [$2], 1)
EOF 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")
])

View File

@ -57,38 +57,38 @@
# define _PATH_ENVIRONMENT "/etc/environment" # define _PATH_ENVIRONMENT "/etc/environment"
#endif /* _PATH_ENVIRONMENT */ #endif /* _PATH_ENVIRONMENT */
/*
* The following paths are controlled via the configure script.
*/
/* /*
* NOTE: _PATH_SUDO_CONF is usually overridden by the Makefile. * NOTE: _PATH_SUDO_CONF is usually overridden by the Makefile.
*/ */
#ifndef _PATH_SUDO_CONF #ifndef _PATH_SUDO_CONF
# define _PATH_SUDO_CONF "/etc/sudo.conf" # undef _PATH_SUDO_CONF
#endif /* _PATH_SUDO_CONF */ #endif /* _PATH_SUDO_CONF */
/* /*
* NOTE: _PATH_SUDOERS is usually overridden by the Makefile. * NOTE: _PATH_SUDOERS is usually overridden by the Makefile.
*/ */
#ifndef _PATH_SUDOERS #ifndef _PATH_SUDOERS
# define _PATH_SUDOERS "/etc/sudoers" # undef _PATH_SUDOERS
#endif /* _PATH_SUDOERS */ #endif /* _PATH_SUDOERS */
/* /*
* NOTE: _PATH_CVTSUDOERS_CONF is usually overridden by the Makefile. * NOTE: _PATH_CVTSUDOERS_CONF is usually overridden by the Makefile.
*/ */
#ifndef _PATH_CVTSUDOERS_CONF #ifndef _PATH_CVTSUDOERS_CONF
# define _PATH_CVTSUDOERS_CONF "/etc/cvtsudoers.conf" # undef _PATH_CVTSUDOERS_CONF
#endif /* _PATH_CVTSUDOERS_CONF */ #endif /* _PATH_CVTSUDOERS_CONF */
/* /*
* NOTE: _PATH_SUDO_LOGSRVD_CONF is usually overridden by the Makefile. * NOTE: _PATH_SUDO_LOGSRVD_CONF is usually overridden by the Makefile.
*/ */
#ifndef _PATH_SUDO_LOGSRVD_CONF #ifndef _PATH_SUDO_LOGSRVD_CONF
# define _PATH_SUDO_LOGSRVD_CONF "/etc/sudo_logsrvd.conf" # undef _PATH_SUDO_LOGSRVD_CONF
#endif /* _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 * Where sudo_logsrvd stores its pid file files. Defaults to
* /var/run/sudo/sudo_logsrvd.pid, /var/db/sudo/sudo_logsrvd.pid, * /var/run/sudo/sudo_logsrvd.pid, /var/db/sudo/sudo_logsrvd.pid,

View File

@ -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 (fd == -1 || (sudoersin = fdopen(fd, "r")) == NULL) {
if (!quiet) if (!quiet)
sudo_warn(U_("unable to open %s"), fname); sudo_warn(U_("unable to open %s"), fname);
if (fd != -1 if (fd != -1)
close(fd); close(fd);
goto done; goto done;
} }