Subject: Virtual ftp setup - HELP!

From: Harshal Savalia <[email-masked]>
Date: Thu, 19 Mar 1998 12:50:42 +0500 (IST)

Hello,

	Please can  anyone  help me in  setting  up  virtual  ftp.  I am
	resending the attached mail as nobody  replied it.  Mean while I
	continued  my  effort.  When I  login  as  anonymous  user it is
	chrooted to  "/virtual"  directory as  mentioned  in the virtual
	directive.  For ftp my /etc/passwd has following entry :

	ftp:*:500:1:Anonymous FTP user:/home/ftp:/usr/bin/false

	So I think this is the way anonymous  ftp works when ftp is done
	to virtual ftp server.  Am I right ?

	Now for one of my guest user - abtuser, I have  following  entry
	in /etc/passwd file :

	abtuser:q8VFkdF0G1zkU:7140:713:abt1 test acct:/scaf/abtuser:/usr/bin/sh

	When this user  tries to  connect to  virtual  ftp  server he is
	chrooted to its home directory - /scaf/abtuser and welcome banner
	is displayed as I defiend in /virtual directory.  So is  this the
	way guest users work when they  connect to virtual ftp server or
	I have to create  /scaf/abtuser inside /virtual and the entry in
	/etc/passwd for this user should read as

	abtuser:q8VFkdF0G1zkU:7140:713:abt1 test acct:/virtual/./scaf/abtuser:/usr/bin/sh

	But   when   I   tried    this    user    initially    logs   in
	/virtual/scaf/abtuser  directory,  but  he is  allowed  to cd to
	/virtual directory.

	Those of you who knows how to set up virtual ftp please help me.

Thanks,
Harshal

>Hello everybody,
>
>	I am trying to set up "virtual  ftp".  But some concepts are not
>	clear in my mind.  I went  thro'  all  related  FAQs  and  other
>	documents which  describes  virtual ftp, but I couldn't clear my
>	doubts.
>
>	I have  aliased my IP  address  to  15.70.178.100.  Then I added
>	following lines in my ftpaccess file :
>
>	virtual 15.70.178.100 root /virtual
>	virtual 15.70.178.100 banner /virtual/banner.msg
>	virtual 15.70.178.100 logfile /virtual/xferlog
>
>	Now  my  question  is do I need  to  create  a user  whose  home
>	directory falls into "/virtual"  directory as I mentioned in the
>	directive ?  Something like "/virtual/home/joe" for example.  So
>	when user joe logs in with this IP  address he will be  chrooted
>	to his home  directory.  Similar  thing  applies  to  guest  and
>	anonymous users who does ftp using this aliased IP address ?
>
>	Thanks in advance for your help.
>
>Best Regards,
>Harshal
-- 
-------------------------------------------------------------------------------
Harshal Savalia					email : [email-masked]
-------------------------------------------------------------------------------

---

From: Harshal Savalia <[email-masked]>
Date: Fri, 20 Mar 1998 11:57:04 +0500 (IST)

Hello  Michael,

	Thank you very much for your reply.

>
>You don't say what version of wu-ftpd you are running.  If you are not
>running the latest beta, get it and install it first. 

	I am  running  wu-ftpd-2.4.2-beta-15.  I am running  it on HP-UX
	box.

>This is missing a /./; I don't understand why it chroots without it. 

	This is the code portion of pass() function from ftpd.c, which I
	think does the chroot for guest user

    if (anonymous || guest) {
	    char *sp;
	    /* We MUST do a chdir() after the chroot. Otherwise the old current
	     * directory will be accessible as "." outside the new root! */
     #ifdef VIRTUAL
	     if (virtual_mode && !guest) {
			 if (pw->pw_dir)
				 free(pw->pw_dir);
               		 pw->pw_dir = sgetsave(virtual_root);
	     }
     #endif
											     /* determine root and home directory */

	     if ((sp = strstr(pw->pw_dir, "/./")) == NULL) {
		 if (chroot(pw->pw_dir) < 0 || chdir("/") < 0) {
			 reply(530, "Can't set guest privileges.");
			 goto bad;
                 }
	    } else{
	      *sp++ = '\0';
		if (chroot(pw->pw_dir) < 0 || chdir(++sp) < 0) {
		    reply(550, "Can't set guest privileges.");
	            goto bad;
		  }
	  }
      }

>Your results are just backward of what should be happening.  The user
>without /./ should not be chrooted, and you say he is.  The user with
>/./ should be chrooted, and you say he is not.  ???
>
>Examining the source should help you decipher what is happening.

	From the above  snippet of the code as per my  understanding  it
	does the  chroot for guest user when they login to  virtual  ftp
	server.  There is no need for /./  entry in  /etc/passswd  file.
	Is there any thing I have misunderstood ?

	Other  thing  which I noted is when  anonymous  user  logs in to
	virtual ftp server they are chrooted to the  directory  which is
	mentioned in the "virtual <IP ADDRESS> root" directive.  Is this
	behaviour  correct or they should be chrooted to the  account of
	ftp user as mentioned in the /etc/passwd file ?

	Looking forward for some help from you people.

Thanks and Regards,
Harshal