openssh-chroot.diff 2.2 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980
  1. --- openssh-3.0.2p1/session.c.orig Sat Dec 1 18:37:08 2001
  2. +++ openssh-3.0.2p1/session.c Thu Dec 20 14:35:11 2001
  3. @@ -1038,6 +1038,10 @@
  4. struct stat st;
  5. char *argv[10];
  6. int do_xauth;
  7. +#ifdef HAVE_CHROOT
  8. + char *user_dir;
  9. + char *new_root;
  10. +#endif /* HAVE_CHROOT */
  11. #ifdef WITH_IRIX_PROJECT
  12. prid_t projid;
  13. #endif /* WITH_IRIX_PROJECT */
  14. @@ -1111,6 +1115,24 @@
  15. if (setlogin(pw->pw_name) < 0)
  16. error("setlogin failed: %s", strerror(errno));
  17. +#ifdef HAVE_CHROOT
  18. + user_dir = xstrdup(pw->pw_dir);
  19. + new_root = user_dir + 1;
  20. + while((new_root = strchr(new_root, '.')) != NULL) {
  21. + new_root--;
  22. + if(strncmp(new_root, "/./", 3) == 0) {
  23. + *new_root = '\0';
  24. + new_root += 2;
  25. +
  26. + if(chroot(user_dir) != 0)
  27. + fatal("Couldn't chroot to user directory %s", user_dir);
  28. +
  29. + pw->pw_dir = new_root;
  30. + break;
  31. + }
  32. + new_root += 2;
  33. + }
  34. +#endif /* HAVE_CHROOT */
  35. if (setgid(pw->pw_gid) < 0) {
  36. perror("setgid");
  37. exit(1);
  38. --- openssh-3.0.2p1/configure.ac.orig Thu Dec 20 14:25:33 2001
  39. +++ openssh-3.0.2p1/configure.ac Thu Dec 20 14:28:58 2001
  40. @@ -1721,6 +1721,18 @@
  41. ]
  42. )
  43. +# Check whether to enable chroot support
  44. +CHROOT_MSG="no"
  45. +AC_ARG_WITH(chroot,
  46. + [ --with-chroot Enable use of chroot home directories],
  47. + [
  48. + if test "x$withval" != "xno" ; then
  49. + AC_DEFINE(HAVE_CHROOT)
  50. + MD5_MSG="yes"
  51. + fi
  52. + ]
  53. +)
  54. +
  55. # Whether to disable shadow password support
  56. AC_ARG_WITH(shadow,
  57. [ --without-shadow Disable shadow password support],
  58. @@ -2207,6 +2219,7 @@
  59. echo " S/KEY support: $SKEY_MSG"
  60. echo " TCP Wrappers support: $TCPW_MSG"
  61. echo " MD5 password support: $MD5_MSG"
  62. +echo " chroot support: $CHROOT_MSG"
  63. echo " IP address in \$DISPLAY hack: $DISPLAY_HACK_MSG"
  64. echo " Use IPv4 by default hack: $IPV4_HACK_MSG"
  65. echo " Translate v4 in v6 hack: $IPV4_IN6_HACK_MSG"
  66. --- openssh-3.0.2p1/config.h.in.orig Thu Dec 20 14:43:20 2001
  67. +++ openssh-3.0.2p1/config.h.in Thu Dec 20 14:44:08 2001
  68. @@ -780,6 +780,9 @@
  69. /* Define if you have the `__b64_ntop' function. */
  70. #undef HAVE___B64_NTOP
  71. +/* Define if you want the chroot capability */
  72. +#undef HAVE_CHROOT
  73. +
  74. /* The size of a `char', as computed by sizeof. */
  75. #undef SIZEOF_CHAR