scp-ssh-wrapper.sh 1.1 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273
  1. #!/usr/bin/env sh
  2. # $OpenBSD: scp-ssh-wrapper.sh,v 1.4 2019/07/19 03:45:44 djm Exp $
  3. # Placed in the Public Domain.
  4. printname()
  5. {
  6. NAME=$1
  7. save_IFS=$IFS
  8. IFS=/
  9. set -- $(echo "$NAME")
  10. IFS="$save_IFS"
  11. while [ $# -ge 1 ]; do
  12. if [ "x$1" != "x" ]; then
  13. echo "D0755 0 $1"
  14. fi
  15. shift
  16. done
  17. }
  18. # Discard all but last argument. We use arg later.
  19. while test "x$1" != "x"; do
  20. arg="$1"
  21. shift
  22. done
  23. BAD="../../../../../../../../../../../../../${DIR}/dotpathdir"
  24. case "$SCPTESTMODE" in
  25. badserver_0)
  26. echo "D0755 0 /${DIR}/rootpathdir"
  27. echo "C755 2 rootpathfile"
  28. echo "X"
  29. ;;
  30. badserver_1)
  31. echo "D0755 0 $BAD"
  32. echo "C755 2 file"
  33. echo "X"
  34. ;;
  35. badserver_2)
  36. echo "D0755 0 $BAD"
  37. echo "C755 2 file"
  38. echo "X"
  39. ;;
  40. badserver_3)
  41. printname $BAD
  42. echo "C755 2 file"
  43. echo "X"
  44. ;;
  45. badserver_4)
  46. printname $BAD
  47. echo "D0755 0 .."
  48. echo "C755 2 file"
  49. echo "X"
  50. ;;
  51. badserver_5)
  52. echo "D0555 0 "
  53. echo "X"
  54. ;;
  55. badserver_6)
  56. echo "D0555 0 ."
  57. echo "X"
  58. ;;
  59. badserver_7)
  60. echo "C0755 2 extrafile"
  61. echo "X"
  62. ;;
  63. *)
  64. set -- $arg
  65. shift
  66. exec $SCP "$@"
  67. ;;
  68. esac