From d0045301c0a67c2b038c16087223e4a4b67c2ef2 Mon Sep 17 00:00:00 2001 From: "Kyle J. McKay" Date: Sat, 8 Oct 2016 02:15:47 -0700 Subject: [PATCH] install: make sure to record full paths for utilities At install time various utility paths are recorded for later use. Make sure these are always full paths in case the environment at install time differs from the environment at normal operation time. This makes sure that a setting in Config.pm of, for example, "nc" gets expanded to a full path rather than being left haphazardly as-is. Signed-off-by: Kyle J. McKay --- chrootsetup_dragonfly.sh | 4 ++-- chrootsetup_freebsd.sh | 4 ++-- chrootsetup_linux.sh | 4 ++-- install.sh | 4 ++-- shlib.sh | 19 +++++++++++++++---- 5 files changed, 23 insertions(+), 12 deletions(-) diff --git a/chrootsetup_dragonfly.sh b/chrootsetup_dragonfly.sh index e9bac5a..61ec5d7 100644 --- a/chrootsetup_dragonfly.sh +++ b/chrootsetup_dragonfly.sh @@ -118,5 +118,5 @@ chroot_update_permissions() { chmod 0664 etc/master.passwd etc/pwd.db etc/spwd.db } -# the nc.openbsd compatible utility is available as $Girocco::Config::nc_openbsd_bin -pull_in_bin "$(command -v "$cfg_nc_openbsd_bin")" bin/nc.openbsd +# the nc.openbsd compatible utility is available as $var_nc_openbsd_bin +pull_in_bin "$var_nc_openbsd_bin" bin/nc.openbsd diff --git a/chrootsetup_freebsd.sh b/chrootsetup_freebsd.sh index 18f3eec..b9ebdc3 100644 --- a/chrootsetup_freebsd.sh +++ b/chrootsetup_freebsd.sh @@ -112,5 +112,5 @@ chroot_update_permissions() { chmod 0664 etc/master.passwd etc/pwd.db etc/spwd.db } -# the nc.openbsd compatible utility is available as /usr/bin/nc -pull_in_bin /usr/bin/nc bin/nc.openbsd +# the nc.openbsd compatible utility is available as $var_nc_openbsd_bin +pull_in_bin "$var_nc_openbsd_bin" bin/nc.openbsd diff --git a/chrootsetup_linux.sh b/chrootsetup_linux.sh index bbe6e70..b888697 100644 --- a/chrootsetup_linux.sh +++ b/chrootsetup_linux.sh @@ -149,5 +149,5 @@ chroot_update_permissions() { chown -R 0:0 bin dev lib sbin var } -# nothing special here, the nc.openbsd compatible utility is nc.openbsd -pull_in_bin /bin/nc.openbsd bin +# the nc.openbsd compatible utility is available as $var_nc_openbsd_bin +pull_in_bin "$var_nc_openbsd_bin" bin/nc.openbsd diff --git a/install.sh b/install.sh index e64c8f7..9a63239 100755 --- a/install.sh +++ b/install.sh @@ -269,9 +269,9 @@ test_nc_U() { } >/dev/null 2>&1 echo "*** Verifying \$Girocco::Config::nc_openbsd_bin supports -U option..." -test_nc_U "$cfg_nc_openbsd_bin" || { +test_nc_U "$var_nc_openbsd_bin" || { echo "ERROR: invalid Girocco::Config::nc_openbsd_bin setting" >&2 - echo "ERROR: \"$cfg_nc_openbsd_bin\" does not grok the -U option" >&2 + echo "ERROR: \"$var_nc_openbsd_bin\" does not grok the -U option" >&2 if [ "$(uname -s 2>/dev/null)" = "DragonFly" ]; then echo "ERROR: see the src/dragonfly/README file for a solution" >&2 fi diff --git a/shlib.sh b/shlib.sh index 329b9d1..c080390 100644 --- a/shlib.sh +++ b/shlib.sh @@ -62,6 +62,15 @@ get_girocco_config_pm_var_list() ( }' ) +# Returns full command path for "$1" if it's a valid command otherwise returns "$1" +_fcp() { + if _fp="$(command -v "$1" 2>/dev/null)"; then + printf '%s\n' "$_fp" + else + printf '%s\n' "$1" + fi +} + get_girocco_config_var_list() ( # Same as get_girocco_config_pm_var_list except that # the following variables (all starting with var_) are added: @@ -71,6 +80,7 @@ get_girocco_config_var_list() ( # var_sh_bin Full path to the posix sh interpreter to use # var_perl_bin Full path to the perl interpreter to use # var_gzip_bin Full path to the gzip executable to use + # var_nc_openbsd_bin Full path to the netcat (nc) with -U support # var_have_git_171 Set to 1 if git version >= 1.7.1 otherwise '' # var_have_git_172 Set to 1 if git version >= 1.7.2 otherwise '' # var_have_git_173 Set to 1 if git version >= 1.7.3 otherwise '' @@ -93,9 +103,10 @@ get_girocco_config_var_list() ( LC_ALL=C sed -ne 's/^[^0-9]*\([0-9][0-9]*\(\.[0-9][0-9]*\)*\).*$/\1/p')" printf 'var_git_ver=%s\n' "$_gver" printf 'var_git_exec_path="%s"\n' "$("$cfg_git_bin" --exec-path 2>/dev/null)" - printf 'var_sh_bin="%s"\n' "${cfg_posix_sh_bin:-/bin/sh}" - printf 'var_perl_bin="%s"\n' "${cfg_perl_bin:-$(unset -f perl; command -v perl)}" - printf 'var_gzip_bin="%s"\n' "${cfg_gzip_bin:-$(unset -f gzip; command -v gzip)}" + printf 'var_sh_bin="%s"\n' "$(_fcp "${cfg_posix_sh_bin:-/bin/sh}")" + printf 'var_perl_bin="%s"\n' "$(_fcp "${cfg_perl_bin:-$(unset -f perl; command -v perl)}")" + printf 'var_gzip_bin="%s"\n' "$(_fcp "${cfg_gzip_bin:-$(unset -f gzip; command -v gzip)}")" + printf 'var_nc_openbsd_bin="%s"\n' "$(_fcp "${cfg_nc_openbsd_bin:-$(unset -f nc; command -v nc)}")" printf 'var_have_git_171=%s\n' "$([ $(vcmp "$_gver" 1.7.1) -ge 0 ] && echo 1)" printf 'var_have_git_172=%s\n' "$([ $(vcmp "$_gver" 1.7.2) -ge 0 ] && echo 1)" printf 'var_have_git_173=%s\n' "$([ $(vcmp "$_gver" 1.7.3) -ge 0 ] && echo 1)" @@ -285,7 +296,7 @@ git_updateref_stdin() { perl() { command "${var_perl_bin:-perl}" "$@"; } gzip() { command "${var_gzip_bin:-gzip}" "$@"; } -nc_openbsd() { "$cfg_nc_openbsd_bin" "$@"; } +nc_openbsd() { command "$var_nc_openbsd_bin" "$@"; } list_packs() { command "$cfg_basedir/bin/list_packs" "$@"; } -- 2.11.4.GIT