From 1f769dd9053409565b1384626170ba5c14628d68 Mon Sep 17 00:00:00 2001 From: "Kyle J. McKay" Date: Sat, 8 Oct 2016 01:02:51 -0700 Subject: [PATCH] install.sh: verify $Girocco::Config::nc_openbsd_bin supports -U Having a netcat (nc) that supports the -U (unix socket) option is REQUIRED. Therefore verify that the -U support actually works during the install process and fail if it does not. Signed-off-by: Kyle J. McKay --- install.sh | 30 ++++++++++++++++++++++++++++++ 1 file changed, 30 insertions(+) diff --git a/install.sh b/install.sh index 036c052..e64c8f7 100755 --- a/install.sh +++ b/install.sh @@ -248,6 +248,36 @@ EOT sleep 5 fi +test_nc_U() { + [ -n "$1" ] || return 1 + _cmdnc="$(command -v "$1" 2>/dev/null || :)" + [ -n "$_cmdnc" ] && [ -x "$_cmdnc" ] || return 1 + _tmpdir="$(mktemp -d /tmp/nc-u-XXXXXX)" + [ -n "$_tmpdir" ] && [ -d "$_tmpdir" ] || return 1 + >"$_tmpdir/output" + (sleep 3 | "$_cmdnc" -l -U "$_tmpdir/socket" 2>/dev/null >"$_tmpdir/output" || >"$_tmpdir/failed")& + _bgpid="$!" + sleep 1 + echo "testing" | "$_cmdnc" -w 1 -U "$_tmpdir/socket" >/dev/null 2>&1 || >"$_tmpdir/failed" + sleep 1 + kill "$_bgpid" >/dev/null 2>&1 || : + read -r _result <"$_tmpdir/output" || : + _bad= + ! [ -e "$_tmpdir/failed" ] || _bad=1 + rm -rf "$_tmpdir" + [ -z "$_bad" ] && [ "$_result" = "testing" ] +} >/dev/null 2>&1 + +echo "*** Verifying \$Girocco::Config::nc_openbsd_bin supports -U option..." +test_nc_U "$cfg_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 + if [ "$(uname -s 2>/dev/null)" = "DragonFly" ]; then + echo "ERROR: see the src/dragonfly/README file for a solution" >&2 + fi + exit 1 +} + chown_make() { if [ "$LOGNAME" = root -a -n "$SUDO_USER" -a "$SUDO_USER" != root ]; then find "$@" -user root -print0 2>/dev/null | \ -- 2.11.4.GIT