reexec.sh 1.0 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758
  1. # $OpenBSD: reexec.sh,v 1.12 2017/08/07 03:52:55 dtucker Exp $
  2. # Placed in the Public Domain.
  3. tid="reexec tests"
  4. SSHD_ORIG=$SSHD
  5. SSHD_COPY=$OBJ/sshd
  6. # Start a sshd and then delete it
  7. start_sshd_copy()
  8. {
  9. # NB. prefer ln to cp here. On some OSX 19.4 configurations,
  10. # djm has seen failure after fork() when the executable image
  11. # has been removed from the filesystem.
  12. ln $SSHD_ORIG $SSHD_COPY || cp $SSHD_ORIG $SSHD_COPY
  13. SSHD=$SSHD_COPY
  14. start_sshd
  15. SSHD=$SSHD_ORIG
  16. }
  17. # Do basic copy tests
  18. copy_tests()
  19. {
  20. rm -f ${COPY}
  21. ${SSH} -nq -F $OBJ/ssh_config somehost \
  22. cat ${DATA} > ${COPY}
  23. if [ $? -ne 0 ]; then
  24. fail "ssh cat $DATA failed"
  25. fi
  26. cmp ${DATA} ${COPY} || fail "corrupted copy"
  27. rm -f ${COPY}
  28. }
  29. verbose "test config passing"
  30. cp $OBJ/sshd_config $OBJ/sshd_config.orig
  31. start_sshd
  32. echo "InvalidXXX=no" >> $OBJ/sshd_config
  33. copy_tests
  34. stop_sshd
  35. cp $OBJ/sshd_config.orig $OBJ/sshd_config
  36. # cygwin can't fork a deleted binary
  37. if [ "$os" != "cygwin" ]; then
  38. verbose "test reexec fallback"
  39. start_sshd_copy
  40. rm -f $SSHD_COPY
  41. copy_tests
  42. stop_sshd
  43. fi