commit:     da9a451824ccd5e4e2b9be405fecad82599ba702
Author:     Ulrich Müller <ulm <AT> gentoo <DOT> org>
AuthorDate: Wed Jun  1 19:41:11 2016 +0000
Commit:     Ulrich Müller <ulm <AT> gentoo <DOT> org>
CommitDate: Wed Jun  1 19:41:11 2016 +0000
URL:        https://gitweb.gentoo.org/proj/eselect.git/commit/?id=da9a4518

Avoid absolute paths for programs.

* configure.ac: Where possible, use AC_CHECK_PROGS instead of
AC_PATH_PROGS, in order to avoid absolute paths, bug 122260.
* libs/core.bash.in (sed):
* libs/package-manager.bash.in (portageq): Invoke commands with
"command" so that they will work without a path.

 ChangeLog                    |  8 ++++++++
 configure.ac                 | 31 +++++++++++++------------------
 libs/core.bash.in            |  4 ++--
 libs/package-manager.bash.in |  4 ++--
 4 files changed, 25 insertions(+), 22 deletions(-)

diff --git a/ChangeLog b/ChangeLog
index 5bb2855..c166ad0 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,11 @@
+2016-06-01  Ulrich Müller  <u...@gentoo.org>
+
+       * configure.ac: Where possible, use AC_CHECK_PROGS instead of
+       AC_PATH_PROGS, in order to avoid absolute paths, bug 122260.
+       * libs/core.bash.in (sed):
+       * libs/package-manager.bash.in (portageq): Invoke commands with
+       "command" so that they will work without a path.
+
 2016-01-27  Ulrich Müller  <u...@gentoo.org>
 
        * bin/eselect.in: Set umask +rx, bug 572348.

diff --git a/configure.ac b/configure.ac
index 8f38759..6fce662 100644
--- a/configure.ac
+++ b/configure.ac
@@ -19,7 +19,7 @@ fi
 
 # AC_PROG_SED doesn't work here, because on Gentoo FreeBSD systems it
 # is confused by a wrapper script that is in the PATH at build time.
-AC_PATH_PROGS(SED, [gsed sed])
+AC_CHECK_PROGS(SED, [gsed sed])
 if test x$SED = x; then
     AC_MSG_ERROR([sed is required])
 fi
@@ -31,27 +31,22 @@ else
     AC_MSG_ERROR([GNU sed is required])
 fi
 
-AC_PATH_PROG(PORTAGEQ, portageq, /usr/bin/portageq,
-  [$prefix/bin:/usr/bin:/bin:$PATH])
 AC_PATH_PROG(ENV_UPDATE, env-update, /usr/sbin/env-update,
   [$PATH:$prefix/sbin:/usr/sbin])
 
-AC_PATH_PROG(READLINK, greadlink)
-if test x$READLINK = x; then
-    AC_PATH_PROG(READLINK, readlink)
-    if test x$READLINK != x; then
-        AC_MSG_CHECKING([whether readlink supports -f])
-        if $READLINK -f . >/dev/null 2>&1; then
-            AC_MSG_RESULT(yes)
-        else
-            AC_MSG_RESULT(no)
-            READLINK=""
-        fi
-    fi
-    if test x$READLINK = x; then
-        AC_PATH_PROG(REALPATH, realpath)
+AC_CHECK_PROGS(READLINK, [greadlink readlink])
+if test x$READLINK != x; then
+    AC_MSG_CHECKING([whether $READLINK supports -f])
+    if $READLINK -f . >/dev/null 2>&1; then
+        AC_MSG_RESULT(yes)
+    else
+        AC_MSG_RESULT(no)
+        READLINK=""
     fi
 fi
+if test x$READLINK = x; then
+    AC_CHECK_PROGS(REALPATH, realpath)
+fi
 if test x$READLINK != x; then
     CANONICALISE="$READLINK -f"
 elif test x$REALPATH != x; then
@@ -63,7 +58,7 @@ AC_SUBST(CANONICALISE)
 
 # Gentoo uses rst2html.py but most other
 # distros install it w/o the .py extension
-AC_PATH_PROGS(RST2HTML, [rst2html rst2html.py])
+AC_CHECK_PROGS(RST2HTML, [rst2html rst2html.py])
 
 # Support for Gentoo Prefix
 AC_MSG_CHECKING([if target installation is in an offset prefix])

diff --git a/libs/core.bash.in b/libs/core.bash.in
index 6b6f049..baddfde 100644
--- a/libs/core.bash.in
+++ b/libs/core.bash.in
@@ -119,7 +119,7 @@ inherit() {
        done
 }
 
-# GNU sed wrapper (real path to GNU sed determined by configure)
+# GNU sed wrapper (sed or gsed, as determined by configure)
 sed() {
-       @SED@ "$@"
+       command @SED@ "$@"
 }

diff --git a/libs/package-manager.bash.in b/libs/package-manager.bash.in
index 691bd3c..b6d8218 100644
--- a/libs/package-manager.bash.in
+++ b/libs/package-manager.bash.in
@@ -28,9 +28,9 @@ package_manager() {
 }
 
 # portageq
-# Run portageq with safe filename as set by configure. Redirect stderr
+# Run portageq. Redirect stderr
 portageq() {
-       @PORTAGEQ@ "$@" 2>/dev/null
+       command portageq "$@" 2>/dev/null
 }
 
 # run_paludis PRIVATE

Reply via email to