Bug 779 - Chroot environment for sftp client crazy
Summary: Chroot environment for sftp client crazy
Status: CLOSED INVALID
Alias: None
Product: Portable OpenSSH
Classification: Unclassified
Component: sftp-server (show other bugs)
Version: 3.7.1p2
Hardware: Other AIX
: P2 normal
Assignee: OpenSSH Bugzilla mailing list
URL: http://aixpanish.com
Keywords:
Depends on:
Blocks:
 
Reported: 2003-12-26 05:41 AEDT by jose
Modified: 2004-04-14 12:24 AEST (History)
0 users

See Also:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description jose 2003-12-26 05:41:22 AEDT
Hello.
I have compiled openssh 3.7.1p2 on Aix 4.3.3 with gcc 3.2.1.
All works fine and chroot environment(users only can connect with sftp in
their jail home) seems to be work fine, but from sftp client if i make a
file transfer or i create a new folder inside user home it become crazy.
EG:
1.- User home /home/user  (chroot environment and from sftp client this
folder is / )
2.- I'm inside /home/user/htdocs (for user is /htdocs/)
3.- If i make a folder called "folder",  it create /home/user/htdocsfolder,
instead /home/user/htdocs/folder
4.- The same occur if it is a file name.


I have changed session.c file with this lines to chroot environment for aix:

+1228  do_setusercontext(struct passwd *pw)
 +1229  {
 +1230
 +1231      /* CHROOT patch start */
 +1232
 +1233      char *user_dir;
 +1234      char *new_root;
 +1235
 +1236      user_dir = xstrdup(pw->pw_dir);
 +1237      new_root = user_dir + 1;
 +1238
 +1239      while((new_root = strchr(new_root, '.')) != NULL) {
 +1240        new_root--;
 +1241        if(strncmp(new_root, "/./", 3) == 0) {
 +1242          *new_root = '\0';
 +1243           new_root += 2;
 +1244           debug("chrooting to user directory %s", user_dir);
 +1245           if(chroot(user_dir) != 0)
 +1246             fatal("Couldn't chroot to user directory %s", user_dir);
 +1247           pw->pw_dir = new_root;
 +1248           if (chdir("/") < 0)
 +1249             fatal("Couldn't cd to / after chroot to user directory %s: %
s", user_dir, strerror(errno));
 +1250           break;
 +1251        }
 +1252        new_root += 2;
 +1253        fatal("Couldn't chroot%s", user_dir);
 +1254     }
 +1255
 +1256     /* CHROOT patch end */
 +1257
 +1258  #ifndef HAVE_CYGWIN
 +1259          if (getuid() == 0 || geteuid() == 0)
 +1260  #endif /* HAVE_CYGWIN */
 +1261          {
 +1262
Comment 1 Ben Lindstrom 2003-12-26 09:57:16 AEDT
I'm not seeing how this is our problem.  We don't support any chroot patches
within OpenSSH.  Please complain to the person whom you got the patch from.
Comment 2 Damien Miller 2004-04-14 12:24:20 AEST
Mass change of RESOLVED bugs to CLOSED