blob: af7eafe3d16ee4e52d7c2afb36cc1079a6d856ce [file] [log] [blame]
Darren Tucker5d909f02005-03-07 18:35:34 +11001# $OpenBSD: envpass.sh,v 1.4 2005/03/04 08:48:46 djm Exp $
Darren Tucker9fe95da2004-06-16 20:33:55 +10002# Placed in the Public Domain.
3
4tid="environment passing"
5
6# NB accepted env vars are in test-exec.sh (_XXX_TEST_* and _XXX_TEST)
7
Darren Tucker5d909f02005-03-07 18:35:34 +11008# Prepare a custom config to test for a configuration parsing bug fixed in 4.0
9cat << EOF > $OBJ/ssh_proxy_envpass
10Host test-sendenv-confparse-bug
11 SendEnv *
12EOF
13cat $OBJ/ssh_proxy >> $OBJ/ssh_proxy_envpass
14
Darren Tucker9fe95da2004-06-16 20:33:55 +100015trace "pass env, don't accept"
16verbose "test $tid: pass env, don't accept"
Darren Tucker5d909f02005-03-07 18:35:34 +110017_TEST_ENV=blah ${SSH} -oSendEnv="*" -F $OBJ/ssh_proxy_envpass otherhost \
Darren Tucker430c6a12004-06-22 13:38:56 +100018 sh << 'EOF'
Darren Tucker6eabe642004-06-23 09:23:58 +100019 test -z "$_TEST_ENV"
Darren Tucker430c6a12004-06-22 13:38:56 +100020EOF
Darren Tucker9fe95da2004-06-16 20:33:55 +100021r=$?
22if [ $r -ne 0 ]; then
23 fail "environment found"
24fi
25
26trace "don't pass env, accept"
27verbose "test $tid: don't pass env, accept"
Darren Tucker5d909f02005-03-07 18:35:34 +110028_XXX_TEST_A=1 _XXX_TEST_B=2 ${SSH} -F $OBJ/ssh_proxy_envpass otherhost \
Darren Tucker430c6a12004-06-22 13:38:56 +100029 sh << 'EOF'
Darren Tucker6eabe642004-06-23 09:23:58 +100030 test -z "$_XXX_TEST_A" && test -z "$_XXX_TEST_B"
Darren Tucker430c6a12004-06-22 13:38:56 +100031EOF
Darren Tucker9fe95da2004-06-16 20:33:55 +100032r=$?
33if [ $r -ne 0 ]; then
34 fail "environment found"
35fi
36
37trace "pass single env, accept single env"
38verbose "test $tid: pass single env, accept single env"
Darren Tucker5d909f02005-03-07 18:35:34 +110039_XXX_TEST=blah ${SSH} -oSendEnv="_XXX_TEST" -F $OBJ/ssh_proxy_envpass \
40 otherhost sh << 'EOF'
Darren Tucker430c6a12004-06-22 13:38:56 +100041 test X"$_XXX_TEST" = X"blah"
42EOF
Darren Tucker9fe95da2004-06-16 20:33:55 +100043r=$?
44if [ $r -ne 0 ]; then
45 fail "environment not found"
46fi
47
48trace "pass multiple env, accept multiple env"
49verbose "test $tid: pass multiple env, accept multiple env"
50_XXX_TEST_A=1 _XXX_TEST_B=2 ${SSH} -oSendEnv="_XXX_TEST_*" \
Darren Tucker5d909f02005-03-07 18:35:34 +110051 -F $OBJ/ssh_proxy_envpass otherhost \
Darren Tucker430c6a12004-06-22 13:38:56 +100052 sh << 'EOF'
53 test X"$_XXX_TEST_A" = X"1" -a X"$_XXX_TEST_B" = X"2"
54EOF
Darren Tucker9fe95da2004-06-16 20:33:55 +100055r=$?
56if [ $r -ne 0 ]; then
57 fail "environment not found"
58fi
Darren Tucker5d909f02005-03-07 18:35:34 +110059
60rm -f $OBJ/ssh_proxy_envpass