Re: scp3.sh regression test fails if scp not already installed

[Date Prev] [Date Next] [Thread Prev] [Thread Next] [Date Index] [Thread Index]

 



Hi.

On Sat, 23 Jul 2022 at 05:34, rapier <rapier@xxxxxxx> wrote:
[...]
> The following patch checks to see if it's in the path or if it's only in
> the openssh-portable build directory. I have a strong suspicion that
> this test will fail in debuild or rpmbuild environments but it will fail
> in a way that the test is run.

Thanks for the report.  I am fine with doing this in principle but
there's a few problems with the specifics of this patch:

> +scp_path=$(which -a scp)
> +if [ -x "$scp_path" ]

"which" is not POSIX, its semantics vary wildly and not all of them
have a "-a".  This test is probably also going to do the wrong thing
in the case where there are two scps on the path.  There's a
"have_prog" function in test-exec.sh in portable for this specific
purpose.

Also, the $() subshell syntax is not in the earlier POSIX standards
and doesn't work on older shells.  Solaris is particularly annoying in
this regard: /bin/sh on Solaris <=10 doesn't understand $() while on
Solaris 11 it's ksh in disguise and does but will complain about
backticks (under at least some conditions).

> || [ $scp_path == "*openssh-portable*" ]; then

What's the purpose of this?  In case the build dir is in the build
shell's path but not the login shell's?  There's no guarantee the
build directory is going to be named in a way that matches.  Also,
pattern matching with "==" is not POSIX (we would use a "case" if we
needed to do this, but I think there's a better way here).

Instead, I think what we would need to do is check for scp in the path
over the ssh connection in a similar way to how have_prog does it.

> +       echo "scp not found in path. Skipping scp3 test."
> +       echo "*****************"
> +       exit

test-exec.sh has a "skip" function to do this in a consistent (and shorter) way.

After a bit of fiddling, this seems to work, which I'll commit shortly:

$SSH -F $OBJ/ssh_proxy somehost \
    'IFS=":"; for i in $PATH;do [ -x "$i/scp" ] && exit 0; done; exit 1'
if [ $? -eq 1 ]; then
       skip "No scp on remote path."
fi

-- 
Darren Tucker (dtucker at dtucker.net)
GPG key 11EAA6FA / A86E 3E07 5B19 5880 E860  37F4 9357 ECEF 11EA A6FA (new)
    Good judgement comes with experience. Unfortunately, the experience
usually comes from bad judgement.
_______________________________________________
openssh-unix-dev mailing list
openssh-unix-dev@xxxxxxxxxxx
https://lists.mindrot.org/mailman/listinfo/openssh-unix-dev



[Date Prev] [Date Next] [Thread Prev] [Thread Next] [Date Index] [Thread Index]

[Index of Archives]     [Linux ARM Kernel]     [Linux ARM]     [Linux Omap]     [Fedora ARM]     [IETF Annouce]     [Security]     [Bugtraq]     [Linux]     [Linux OMAP]     [Linux MIPS]     [ECOS]     [Asterisk Internet PBX]     [Linux API]

  Powered by Linux