envpass.sh revision 180720
191621Sphantom#	$OpenBSD: envpass.sh,v 1.4 2005/03/04 08:48:46 djm Exp $
291621Sphantom#	Placed in the Public Domain.
391621Sphantom
491621Sphantomtid="environment passing"
591621Sphantom
691621Sphantom# NB accepted env vars are in test-exec.sh (_XXX_TEST_* and _XXX_TEST)
791621Sphantom
891621Sphantom# Prepare a custom config to test for a configuration parsing bug fixed in 4.0
991621Sphantomcat << EOF > $OBJ/ssh_proxy_envpass
1091621SphantomHost test-sendenv-confparse-bug
1191621Sphantom	SendEnv *
1291621SphantomEOF
1391621Sphantomcat $OBJ/ssh_proxy >> $OBJ/ssh_proxy_envpass
1491621Sphantom
1591621Sphantomtrace "pass env, don't accept"
1691621Sphantomverbose "test $tid: pass env, don't accept"
1791621Sphantom_TEST_ENV=blah ${SSH} -oSendEnv="*" -F $OBJ/ssh_proxy_envpass otherhost \
1891621Sphantom	sh << 'EOF'
1991621Sphantom	test -z "$_TEST_ENV"
2091621SphantomEOF
2191621Sphantomr=$?
2291621Sphantomif [ $r -ne 0 ]; then
2391621Sphantom	fail "environment found"
2499257Srufi
2599257Sru
2699257Srutrace "don't pass env, accept"
2794940Sruverbose "test $tid: don't pass env, accept"
28142666Sphantom_XXX_TEST_A=1 _XXX_TEST_B=2 ${SSH} -F $OBJ/ssh_proxy_envpass otherhost \
2991621Sphantom	sh << 'EOF'
3091621Sphantom	test -z "$_XXX_TEST_A" && test -z "$_XXX_TEST_B"
3191621SphantomEOF
3291621Sphantomr=$?
3391621Sphantomif [ $r -ne 0 ]; then
3491621Sphantom	fail "environment found"
3599257Srufi
3699257Sru
3791621Sphantomtrace "pass single env, accept single env"
3891621Sphantomverbose "test $tid: pass single env, accept single env"
3991621Sphantom_XXX_TEST=blah ${SSH} -oSendEnv="_XXX_TEST" -F $OBJ/ssh_proxy_envpass \
4099257Sru    otherhost sh << 'EOF'
4191621Sphantom	test X"$_XXX_TEST" = X"blah"
4299257SruEOF
4399257Srur=$?
4491628Sphantomif [ $r -ne 0 ]; then
4591621Sphantom	fail "environment not found"
4699257Srufi
4799257Sru
4891621Sphantomtrace "pass multiple env, accept multiple env"
4999257Sruverbose "test $tid: pass multiple env, accept multiple env"
5099257Sru_XXX_TEST_A=1 _XXX_TEST_B=2 ${SSH} -oSendEnv="_XXX_TEST_*" \
5191621Sphantom    -F $OBJ/ssh_proxy_envpass otherhost \
5291621Sphantom	sh << 'EOF'
5391621Sphantom	test X"$_XXX_TEST_A" = X"1" -a X"$_XXX_TEST_B" = X"2"
5491621SphantomEOF
5591621Sphantomr=$?
5691621Sphantomif [ $r -ne 0 ]; then
5799257Sru	fail "environment not found"
5899257Srufi
5999257Sru
6099257Srurm -f $OBJ/ssh_proxy_envpass
6199257Sru