]> granicus.if.org Git - sudo/commitdiff
Use AC_PATH_PROG to find programs instead of checking the path manually.
authorTodd C. Miller <Todd.Miller@courtesan.com>
Mon, 19 Jan 2015 21:25:17 +0000 (14:25 -0700)
committerTodd C. Miller <Todd.Miller@courtesan.com>
Mon, 19 Jan 2015 21:25:17 +0000 (14:25 -0700)
configure
m4/sudo.m4

index 9675bd79b0285e4520b7ae4988bc79dbcf14794b..fbf453628ed540433c6703dc3c367c6e74fa0fa1 100755 (executable)
--- a/configure
+++ b/configure
@@ -831,7 +831,11 @@ PACKAGE_VERSION
 PACKAGE_TARNAME
 PACKAGE_NAME
 PATH_SEPARATOR
-SHELL'
+SHELL
+BSHELLPROG
+MVPROG
+VIPROG
+SENDMAILPROG'
 ac_subst_files=''
 ac_user_opts='
 enable_option_checking
@@ -959,7 +963,11 @@ with_pam_login
 enable_pam_session
 enable_kerb5_instance
 '
-      ac_precious_vars='build_alias
+      ac_precious_vars='SENDMAILPROG
+VIPROG
+MVPROG
+BSHELLPROG
+build_alias
 host_alias
 target_alias
 CC
@@ -1732,6 +1740,11 @@ Optional Packages:
   --with-pam-login        enable specific PAM session for sudo -i
 
 Some influential environment variables:
+  SENDMAILPROG
+              The fully-qualified path to the sendmail program to use.
+  VIPROG      The fully-qualified path to the vi program to use.
+  MVPROG      The fully-qualified path to the mv program to use.
+  BSHELLPROG  The fully-qualified path to the Bourne shell to use.
   CC          C compiler command
   CFLAGS      C compiler flags
   LDFLAGS     linker flags, e.g. -L<lib dir> if you have libraries in a
@@ -15704,88 +15717,193 @@ $as_echo "no" >&6; }
 fi
 
 
-{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for mv" >&5
-$as_echo_n "checking for mv... " >&6; }
-found=no
-for p in "/usr/bin/mv" "/bin/mv" "/usr/ucb/mv" "/usr/sbin/mv"; do
-    if test -f "$p"; then
-       found=yes
-       { $as_echo "$as_me:${as_lineno-$LINENO}: result: $p" >&5
-$as_echo "$p" >&6; }
-       cat >>confdefs.h <<EOF
-#define _PATH_MV "$p"
-EOF
 
-       break
-    fi
+    # Extract the first word of "mv", so it can be a program name with args.
+set dummy mv; ac_word=$2
+{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5
+$as_echo_n "checking for $ac_word... " >&6; }
+if ${ac_cv_path_MVPROG+:} false; then :
+  $as_echo_n "(cached) " >&6
+else
+  case $MVPROG in
+  [\\/]* | ?:[\\/]*)
+  ac_cv_path_MVPROG="$MVPROG" # Let the user override the test with a path.
+  ;;
+  *)
+  as_save_IFS=$IFS; IFS=$PATH_SEPARATOR
+for as_dir in /usr/bin$PATH_SEPARATOR/bin$PATH_SEPARATOR/usr/ucb$PATH_SEPARATOR/usr/local/bin
+do
+  IFS=$as_save_IFS
+  test -z "$as_dir" && as_dir=.
+    for ac_exec_ext in '' $ac_executable_extensions; do
+  if as_fn_executable_p "$as_dir/$ac_word$ac_exec_ext"; then
+    ac_cv_path_MVPROG="$as_dir/$ac_word$ac_exec_ext"
+    $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5
+    break 2
+  fi
 done
-if test X"$found" != X"yes"; then
-    { $as_echo "$as_me:${as_lineno-$LINENO}: result: not found" >&5
-$as_echo "not found" >&6; }
+  done
+IFS=$as_save_IFS
+
+  ;;
+esac
+fi
+MVPROG=$ac_cv_path_MVPROG
+if test -n "$MVPROG"; then
+  { $as_echo "$as_me:${as_lineno-$LINENO}: result: $MVPROG" >&5
+$as_echo "$MVPROG" >&6; }
+else
+  { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5
+$as_echo "no" >&6; }
 fi
 
-{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for bourne shell" >&5
-$as_echo_n "checking for bourne shell... " >&6; }
-found=no
-for p in "/usr/bin/sh" "/bin/sh" "/usr/sbin/sh" "/sbin/sh" "/usr/bin/ksh" "/bin/ksh" "/usr/bin/bash" "/bin/bash"; do
-    if test -f "$p"; then
-       found=yes
-       { $as_echo "$as_me:${as_lineno-$LINENO}: result: $p" >&5
-$as_echo "$p" >&6; }
-       cat >>confdefs.h <<EOF
-#define _PATH_BSHELL "$p"
+
+    test -n "${ac_cv_path_MVPROG}" && cat >>confdefs.h <<EOF
+#define _PATH_MV "${ac_cv_path_MVPROG}"
 EOF
 
-       break
-    fi
+
+
+    # Extract the first word of "sh", so it can be a program name with args.
+set dummy sh; ac_word=$2
+{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5
+$as_echo_n "checking for $ac_word... " >&6; }
+if ${ac_cv_path_BSHELLPROG+:} false; then :
+  $as_echo_n "(cached) " >&6
+else
+  case $BSHELLPROG in
+  [\\/]* | ?:[\\/]*)
+  ac_cv_path_BSHELLPROG="$BSHELLPROG" # Let the user override the test with a path.
+  ;;
+  *)
+  as_save_IFS=$IFS; IFS=$PATH_SEPARATOR
+for as_dir in $PATH
+do
+  IFS=$as_save_IFS
+  test -z "$as_dir" && as_dir=.
+    for ac_exec_ext in '' $ac_executable_extensions; do
+  if as_fn_executable_p "$as_dir/$ac_word$ac_exec_ext"; then
+    ac_cv_path_BSHELLPROG="$as_dir/$ac_word$ac_exec_ext"
+    $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5
+    break 2
+  fi
 done
-if test X"$found" != X"yes"; then
-    { $as_echo "$as_me:${as_lineno-$LINENO}: result: not found" >&5
-$as_echo "not found" >&6; }
+  done
+IFS=$as_save_IFS
+
+  test -z "$ac_cv_path_BSHELLPROG" && ac_cv_path_BSHELLPROG="/usr/bin$PATH_SEPARATOR/bin$PATH_SEPARATOR/usr/sbin$PATH_SEPARATOR/sbin"
+  ;;
+esac
+fi
+BSHELLPROG=$ac_cv_path_BSHELLPROG
+if test -n "$BSHELLPROG"; then
+  { $as_echo "$as_me:${as_lineno-$LINENO}: result: $BSHELLPROG" >&5
+$as_echo "$BSHELLPROG" >&6; }
+else
+  { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5
+$as_echo "no" >&6; }
 fi
 
-if test -z "$with_sendmail"; then
-    { $as_echo "$as_me:${as_lineno-$LINENO}: checking for sendmail" >&5
-$as_echo_n "checking for sendmail... " >&6; }
-found=no
-for p in "/usr/sbin/sendmail" "/usr/lib/sendmail" "/usr/etc/sendmail" "/usr/ucblib/sendmail" "/usr/local/lib/sendmail" "/usr/local/bin/sendmail"; do
-    if test -f "$p"; then
-       found=yes
-       { $as_echo "$as_me:${as_lineno-$LINENO}: result: $p" >&5
-$as_echo "$p" >&6; }
-       cat >>confdefs.h <<EOF
-#define _PATH_SUDO_SENDMAIL "$p"
+
+    test -n "${ac_cv_path_BSHELLPROG}" && cat >>confdefs.h <<EOF
+#define _PATH_BSHELL "${ac_cv_path_BSHELLPROG}"
 EOF
 
-       break
-    fi
+
+if test -z "$with_sendmail"; then
+
+    # Extract the first word of "sendmail", so it can be a program name with args.
+set dummy sendmail; ac_word=$2
+{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5
+$as_echo_n "checking for $ac_word... " >&6; }
+if ${ac_cv_path_SENDMAILPROG+:} false; then :
+  $as_echo_n "(cached) " >&6
+else
+  case $SENDMAILPROG in
+  [\\/]* | ?:[\\/]*)
+  ac_cv_path_SENDMAILPROG="$SENDMAILPROG" # Let the user override the test with a path.
+  ;;
+  *)
+  as_save_IFS=$IFS; IFS=$PATH_SEPARATOR
+for as_dir in /usr/sbin$PATH_SEPARATOR/usr/lib$PATH_SEPARATOR/usr/etc$PATH_SEPARATOR/usr/ucblib$PATH_SEPARATOR/usr/local/lib$PATH_SEPARATOR/usr/local/bin
+do
+  IFS=$as_save_IFS
+  test -z "$as_dir" && as_dir=.
+    for ac_exec_ext in '' $ac_executable_extensions; do
+  if as_fn_executable_p "$as_dir/$ac_word$ac_exec_ext"; then
+    ac_cv_path_SENDMAILPROG="$as_dir/$ac_word$ac_exec_ext"
+    $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5
+    break 2
+  fi
 done
-if test X"$found" != X"yes"; then
-    { $as_echo "$as_me:${as_lineno-$LINENO}: result: not found" >&5
-$as_echo "not found" >&6; }
-fi
+  done
+IFS=$as_save_IFS
 
+  ;;
+esac
 fi
-{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for vi" >&5
-$as_echo_n "checking for vi... " >&6; }
-found=no
-for editor in "/usr/bin/vi" "/bin/vi" "/usr/ucb/vi" "/usr/bsd/vi" "/usr/local/bin/vi"; do
-    if test -f "$editor"; then
-       found=yes
-       { $as_echo "$as_me:${as_lineno-$LINENO}: result: $editor" >&5
-$as_echo "$editor" >&6; }
-       cat >>confdefs.h <<EOF
-#define _PATH_VI "$editor"
+SENDMAILPROG=$ac_cv_path_SENDMAILPROG
+if test -n "$SENDMAILPROG"; then
+  { $as_echo "$as_me:${as_lineno-$LINENO}: result: $SENDMAILPROG" >&5
+$as_echo "$SENDMAILPROG" >&6; }
+else
+  { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5
+$as_echo "no" >&6; }
+fi
+
+
+    test -n "${ac_cv_path_SENDMAILPROG}" && cat >>confdefs.h <<EOF
+#define _PATH_SUDO_SENDMAIL "${ac_cv_path_SENDMAILPROG}"
 EOF
 
-       break
-    fi
+
+fi
+
+    # Extract the first word of "vi", so it can be a program name with args.
+set dummy vi; ac_word=$2
+{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5
+$as_echo_n "checking for $ac_word... " >&6; }
+if ${ac_cv_path_VIPROG+:} false; then :
+  $as_echo_n "(cached) " >&6
+else
+  case $VIPROG in
+  [\\/]* | ?:[\\/]*)
+  ac_cv_path_VIPROG="$VIPROG" # Let the user override the test with a path.
+  ;;
+  *)
+  as_save_IFS=$IFS; IFS=$PATH_SEPARATOR
+for as_dir in /usr/bin$PATH_SEPARATOR/bin$PATH_SEPARATOR/usr/ucb$PATH_SEPARATOR/usr/bsd$PATH_SEPARATOR/usr/local/bin
+do
+  IFS=$as_save_IFS
+  test -z "$as_dir" && as_dir=.
+    for ac_exec_ext in '' $ac_executable_extensions; do
+  if as_fn_executable_p "$as_dir/$ac_word$ac_exec_ext"; then
+    ac_cv_path_VIPROG="$as_dir/$ac_word$ac_exec_ext"
+    $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5
+    break 2
+  fi
 done
-if test X"$found" != X"yes"; then
-    { $as_echo "$as_me:${as_lineno-$LINENO}: result: not found" >&5
-$as_echo "not found" >&6; }
+  done
+IFS=$as_save_IFS
+
+  ;;
+esac
+fi
+VIPROG=$ac_cv_path_VIPROG
+if test -n "$VIPROG"; then
+  { $as_echo "$as_me:${as_lineno-$LINENO}: result: $VIPROG" >&5
+$as_echo "$VIPROG" >&6; }
+else
+  { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5
+$as_echo "no" >&6; }
 fi
 
+
+    test -n "${ac_cv_path_VIPROG}" && cat >>confdefs.h <<EOF
+#define _PATH_VI "${ac_cv_path_VIPROG}"
+EOF
+
+
 { $as_echo "$as_me:${as_lineno-$LINENO}: checking which syslog facility sudo should log with" >&5
 $as_echo_n "checking which syslog facility sudo should log with... " >&6; }
 if test X"$with_logfac" = X""; then
index f94dbfb295c8f51e7ab859251fbe056d00537486..9087155fac91ef60d86badea2fbe43ab0060ae62 100644 (file)
@@ -10,73 +10,37 @@ dnl checks for programs
 dnl
 dnl check for sendmail in well-known locations
 dnl
-AC_DEFUN([SUDO_PROG_SENDMAIL], [AC_MSG_CHECKING([for sendmail])
-found=no
-for p in "/usr/sbin/sendmail" "/usr/lib/sendmail" "/usr/etc/sendmail" "/usr/ucblib/sendmail" "/usr/local/lib/sendmail" "/usr/local/bin/sendmail"; do
-    if test -f "$p"; then
-       found=yes
-       AC_MSG_RESULT([$p])
-       SUDO_DEFINE_UNQUOTED(_PATH_SUDO_SENDMAIL, "$p")
-       break
-    fi
-done
-if test X"$found" != X"yes"; then
-    AC_MSG_RESULT([not found])
-fi
+AC_ARG_VAR([SENDMAILPROG], [The fully-qualified path to the sendmail program to use.])
+AC_DEFUN([SUDO_PROG_SENDMAIL], [
+    AC_PATH_PROG([SENDMAILPROG], [sendmail], [], [/usr/sbin$PATH_SEPARATOR/usr/lib$PATH_SEPARATOR/usr/etc$PATH_SEPARATOR/usr/ucblib$PATH_SEPARATOR/usr/local/lib$PATH_SEPARATOR/usr/local/bin])
+    test -n "${ac_cv_path_SENDMAILPROG}" && SUDO_DEFINE_UNQUOTED(_PATH_SUDO_SENDMAIL, "${ac_cv_path_SENDMAILPROG}")
 ])dnl
 
 dnl
 dnl check for vi in well-known locations
 dnl
-AC_DEFUN([SUDO_PROG_VI], [AC_MSG_CHECKING([for vi])
-found=no
-for editor in "/usr/bin/vi" "/bin/vi" "/usr/ucb/vi" "/usr/bsd/vi" "/usr/local/bin/vi"; do
-    if test -f "$editor"; then
-       found=yes
-       AC_MSG_RESULT([$editor])
-       SUDO_DEFINE_UNQUOTED(_PATH_VI, "$editor")
-       break
-    fi
-done
-if test X"$found" != X"yes"; then
-    AC_MSG_RESULT([not found])
-fi
+AC_ARG_VAR([VIPROG], [The fully-qualified path to the vi program to use.])
+AC_DEFUN([SUDO_PROG_VI], [
+    AC_PATH_PROG([VIPROG], [vi], [], [/usr/bin$PATH_SEPARATOR/bin$PATH_SEPARATOR/usr/ucb$PATH_SEPARATOR/usr/bsd$PATH_SEPARATOR/usr/local/bin])
+    test -n "${ac_cv_path_VIPROG}" && SUDO_DEFINE_UNQUOTED(_PATH_VI, "${ac_cv_path_VIPROG}")
 ])dnl
 
 dnl
 dnl check for mv in well-known locations
 dnl
-AC_DEFUN([SUDO_PROG_MV], [AC_MSG_CHECKING([for mv])
-found=no
-for p in "/usr/bin/mv" "/bin/mv" "/usr/ucb/mv" "/usr/sbin/mv"; do
-    if test -f "$p"; then
-       found=yes
-       AC_MSG_RESULT([$p])
-       SUDO_DEFINE_UNQUOTED(_PATH_MV, "$p")
-       break
-    fi
-done
-if test X"$found" != X"yes"; then
-    AC_MSG_RESULT([not found])
-fi
+AC_ARG_VAR([MVPROG], [The fully-qualified path to the mv program to use.])
+AC_DEFUN([SUDO_PROG_MV], [
+    AC_PATH_PROG([MVPROG], [mv], [], [/usr/bin$PATH_SEPARATOR/bin$PATH_SEPARATOR/usr/ucb$PATH_SEPARATOR/usr/local/bin])
+    test -n "${ac_cv_path_MVPROG}" && SUDO_DEFINE_UNQUOTED(_PATH_MV, "${ac_cv_path_MVPROG}")
 ])dnl
 
 dnl
 dnl check for bourne shell in well-known locations
 dnl
-AC_DEFUN([SUDO_PROG_BSHELL], [AC_MSG_CHECKING([for bourne shell])
-found=no
-for p in "/usr/bin/sh" "/bin/sh" "/usr/sbin/sh" "/sbin/sh" "/usr/bin/ksh" "/bin/ksh" "/usr/bin/bash" "/bin/bash"; do
-    if test -f "$p"; then
-       found=yes
-       AC_MSG_RESULT([$p])
-       SUDO_DEFINE_UNQUOTED(_PATH_BSHELL, "$p")
-       break
-    fi
-done
-if test X"$found" != X"yes"; then
-    AC_MSG_RESULT([not found])
-fi
+AC_ARG_VAR([BSHELLPROG], [The fully-qualified path to the Bourne shell to use.])
+AC_DEFUN([SUDO_PROG_BSHELL], [
+    AC_PATH_PROG([BSHELLPROG], [sh], [/usr/bin$PATH_SEPARATOR/bin$PATH_SEPARATOR/usr/sbin$PATH_SEPARATOR/sbin])
+    test -n "${ac_cv_path_BSHELLPROG}" && SUDO_DEFINE_UNQUOTED(_PATH_BSHELL, "${ac_cv_path_BSHELLPROG}")
 ])dnl
 
 dnl