envpass.sh 1.5 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061
  1. # $OpenBSD: envpass.sh,v 1.4 2005/03/04 08:48:46 djm Exp $
  2. # Placed in the Public Domain.
  3. tid="environment passing"
  4. # NB accepted env vars are in test-exec.sh (_XXX_TEST_* and _XXX_TEST)
  5. # Prepare a custom config to test for a configuration parsing bug fixed in 4.0
  6. cat << EOF > $OBJ/ssh_proxy_envpass
  7. Host test-sendenv-confparse-bug
  8. SendEnv *
  9. EOF
  10. cat $OBJ/ssh_proxy >> $OBJ/ssh_proxy_envpass
  11. trace "pass env, don't accept"
  12. verbose "test $tid: pass env, don't accept"
  13. _TEST_ENV=blah ${SSH} -oSendEnv="*" -F $OBJ/ssh_proxy_envpass otherhost \
  14. sh << 'EOF'
  15. test -z "$_TEST_ENV"
  16. EOF
  17. r=$?
  18. if [ $r -ne 0 ]; then
  19. fail "environment found"
  20. fi
  21. trace "don't pass env, accept"
  22. verbose "test $tid: don't pass env, accept"
  23. _XXX_TEST_A=1 _XXX_TEST_B=2 ${SSH} -F $OBJ/ssh_proxy_envpass otherhost \
  24. sh << 'EOF'
  25. test -z "$_XXX_TEST_A" && test -z "$_XXX_TEST_B"
  26. EOF
  27. r=$?
  28. if [ $r -ne 0 ]; then
  29. fail "environment found"
  30. fi
  31. trace "pass single env, accept single env"
  32. verbose "test $tid: pass single env, accept single env"
  33. _XXX_TEST=blah ${SSH} -oSendEnv="_XXX_TEST" -F $OBJ/ssh_proxy_envpass \
  34. otherhost sh << 'EOF'
  35. test X"$_XXX_TEST" = X"blah"
  36. EOF
  37. r=$?
  38. if [ $r -ne 0 ]; then
  39. fail "environment not found"
  40. fi
  41. trace "pass multiple env, accept multiple env"
  42. verbose "test $tid: pass multiple env, accept multiple env"
  43. _XXX_TEST_A=1 _XXX_TEST_B=2 ${SSH} -oSendEnv="_XXX_TEST_*" \
  44. -F $OBJ/ssh_proxy_envpass otherhost \
  45. sh << 'EOF'
  46. test X"$_XXX_TEST_A" = X"1" -a X"$_XXX_TEST_B" = X"2"
  47. EOF
  48. r=$?
  49. if [ $r -ne 0 ]; then
  50. fail "environment not found"
  51. fi
  52. rm -f $OBJ/ssh_proxy_envpass