Subject: connect to another machine from withing ftpd

From: "James E. Hetrick" <[email-masked]>
Date: Thu, 13 Aug 1998 19:19:54 -0700

Hi,

I'm trying to hack wu-ftpd to achieve the following, and want to know
if this has already been done (and where I can get the code).

If a particular user logs into machine A, I want to open an ftp
connection to another machine B (more or less unknown to the user),
and redirect a limited set of commands there, in particular cd, pwd,
ls, get/get, and some status stuff. get/mget will first get the
requested files from B->A, then send them from A to the user's
machine.

Has this been done by anyone?

While trying to do this... I find the following behavior, which I'm 
sure is the correct operation of wu-ftp, but which I don't understand
at all.

Under normal operation, I can login with this response:

...........................
# ftp localhost
Connected to localhost.
220 cliodhna FTP server (wu-ftpd 2.6.0(6) Wed Aug 12 20:27:21 PDT 1998) ready.
Name (localhost:hetrick): reposit
331 Password required for reposit.
Password:
230 User reposit logged in.
Remote system type is UNIX.
Using binary mode to transfer files.
............................

As a simple test, I want to output a string after the login if the
user is "reposit", so I put:

        reply(230, "User %s logged in.%s", pw->pw_name, guest ?
              "  Access restrictions apply." : "");

>        if(!strcmp(pw->pw_name, "reposit")) 
>	   reply(230, "Hello user reposit");

after the reply(230,"User %s logged in"). Now I get the following
output:

............................
# ftp localhost
Connected to localhost.
220 cliodhna FTP server (wu-ftpd 2.6.0(6) Wed Aug 12 20:27:21 PDT 1998) ready.
Name (localhost:hetrick): reposit
331 Password required for reposit.
Password:
230 User reposit logged in.
Remote system type is Hello.
ftp> quit
215 UNIX Type: L8
.............................

Why does adding a reply() munge the output? And, how can I add
reply()'s or send output back to the user in a way which makes sense?
This must be obvious, so please forgive my ignorance.

Thanks,  --Jim

-- 
==============================================================
James E. Hetrick                        Physics Department
Assistant Professor                  University of the Pacific
[email-masked]    Ph:209-946-3128     Stockton, CA  95211
     ------http://cliodhna.cop.uop.edu/~hetrick------