Subject: chroot() user _on_ virtual ip | not usual question.....

From: Christopher McCrory <[email-masked]>
Date: Fri, 6 Dec 1996 17:15:33 -0800

Hello...

	I do not think this has been asked before...read on......
using wu-ftpd 2.4.2 beta 11
linux 2.0.2x (currently 2.0.27)
This is the directory structure:

/regular_stuff
/home
/home/company_name
/home/company_name/user1_dir
/home/company_name/user2_dir
                                 ^ chroot()
/home/company_name/virtual_html_dir
/home/company_name/virtual_ftp_dir
/home/company_name/virtual_ftp_dir/usual_stuff
                                                     ^ chroot()

The virtual ftp stuff works for the virtual ip.  The user chroot() works
for the real ip.
The user chroot() does not work on the virtual ip.

It seems that the wu-ftpd senses that the connection is coming in on a
virtual ip address and does the chroot() at
"/home/company_name/virtual_ftp_dir" before checking if the logon name
is a real user.  If the logon name is a real user then the chroot()
should be at "/home/company_name" .  But it is too late, the "chroot()
ing"  is already done and is not re-configured.  After the connection is
accepted all the user can "see" is the files in
"/home/company_name/virtual_ftp_dir" .  I think the logic would go
something like this but, I am not very much of  programmer and something
like this is beyond my abilities.

accept incoming connection
if on virtual ip then chroot()
accept authentication
if authentication is not anon and a valid user then re-chroot()
<--this is the part to be added
continue with connection

Any help with this situation would be great.

Christopher McCrory
Lead Bithead, Netus Inc.
[email-masked]
[email-masked]

"Some can do things others cannot"  R.J.

---

From: Bob Myers <[email-masked]>
Date: Fri, 06 Dec 1996 19:02:11 -0800

Christopher McCrory wrote:
> "/home/company_name/virtual_ftp_dir".

You're right.  This is exactly how it works.

Personally, I went in to the wu-ftpd source and changed that.  If it's a 
real user, I don't think it should chroot at all - except for the usual 
"guest" users.  I think the guest user chroot solves the problem sufficiently.

Here is my patch to Beta-11 for this.  Basically it just moves the check for 
anonymous before the virtual root is set.

--- ftpd.c.~1~  Sun Apr 14 22:51:11 1996
+++ ftpd.c      Wed Aug  7 23:26:22 1996
@@ -1430,12 +1445,12 @@
     if (anonymous || guest) {
         /* We MUST do a chdir() after the chroot. Otherwise the old current
          * directory will be accessible as "." outside the new root! */
+        if (anonymous) {
 #ifdef VIRTUAL
-      if (virtual_mode) {
-        strcpy(pw->pw_dir, virtual_root);
-      }
+           if (virtual_mode) {
+               strcpy(pw->pw_dir, virtual_root);
+           }
 #endif 
-        if (anonymous) {
             if (chroot(pw->pw_dir) < 0 || chdir("/") < 0) {
                 reply(550, "Can't set guest privileges.");
                 goto bad;