Date: Thu, 17 Oct 1996 15:26:38 -0500 (CDT) From: SysAdmin <flaq@synwork.com> To: Steve Ames <steve@cioeserv.cioe.com> Cc: freebsd-isp@FreeBSD.org Subject: Re: multi homed FTP? Message-ID: <Pine.BSF.3.95.961017152616.4811C-200000@synwork.com> In-Reply-To: <199610171652.LAA10019@cioeserv.cioe.com>
next in thread | previous in thread | raw e-mail | index | archive | help
[-- Attachment #1 --]
On Thu, 17 Oct 1996, Steve Ames wrote:
-->
-->While back I thought I saw a pointer to a patch for wuftpd that would
-->allow it to multi-home in a manner similar to the way httpd does...
-->
-->anyone know where that is? Or anyone got a better solution?
-->
--> -Steve
-->
~*-,._.,-*~'`^`'~*-,._.,-*~'`^`'~*-,._.,-*~'`^`'~*-,._.,-*~'`^`'~*-,._.,-*~
Syn-Work Media, Inc. | WWW Development & Hosting | Life Safety
http://www.synwork.com | Systems Integration | CCTV
mike@synwork.com | Voice/Data/Fiber | Access Control
Flaq on IRC | Dukane Distributor | BICSI/RCDD
:|:|:|: Powered By FreeBSD :|:|:|:
Turning PC's Into Workstations
~*-,._.,-*~'`^`'~*-,._.,-*~'`^`'~*-,._.,-*~'`^`'~*-,._.,-*~'`^`'~*-,._.,-*~
[-- Attachment #2 --]
Date: Fri, 26 May 1995 21:33:23 -0400 (EDT)
From: Brian Kramer <bjkramer@pluto.njcc.com>
To: wu-ftpd@wugate.wustl.edu
Subject: Virtual FTP Servers
I'm attaching a patch for wu-ftpd 2.4 to allow virtual ftp servers to be
setup. Basically so a user ftping to ftp1.domain.com gets one ftp banner
and one ftp directory and a user ftping to ftp2.domain.com gets another
banner and directory even though they are on the same machine and port.
I was the person who originally asked how to do it, and got
enough answers to write a patch that would allow it. You have to be able
to setup alias IP addresses in order for this to work. I know linux and
bsdi support this. (Linux with patches) and those are the only two
systems this has been tested on. I do not warrant this code at all. Use
it AT YOUR OWN RISK. If it causes your computer to blow up, TOUGH!
If you have suggestions, improvements, bugs, etc...send me some mail.
If enough people are interested in it, I can put it up on our ftp server.
Please send me comments, I'm interested in improving it, and hearing
how it works for people.
Here's the steps.
Basically setup an alias ip address for the machine.
Apply the patch
Add lines similar to the following for each virtual server to ftpaccess:
# Virtual Servers
virtual 165.254.117.200 /home/home3/ftp2 /home/home3/ftp2/etc/banner.msg
where the 1st arg is the ip # of the virtual server, the second is the
new root, and the third is the banner to display upon login.
Note: all the other message files, etc, and permissions and other settings
in the ftpaccess file apply to all virtual servers.
Here's the patch
CUT HERE***************************************************************
--- extensions.c
+++ extensions.c Fri May 26 20:48:13 1995
@@ -278,7 +278,7 @@
/*************************************************************************/
void
-show_banner(int msgcode)
+show_banner(int msgcode, int virtual_mode, char *virtual_banner)
{
char *crptr,
linebuf[1024],
@@ -286,22 +286,38 @@
struct aclmember *entry = NULL;
FILE *infile;
- /* banner <path> */
- while (getaclentry("banner", &entry)) {
+ if (virtual_mode) {
+ infile = fopen(virtual_banner, "r");
+ if (infile) {
+ while (fgets(linebuf, 255, infile) != NULL) {
+ if ((crptr = strchr(linebuf, '\n')) != NULL)
+ *crptr = '\0';
+ msg_massage(linebuf, outbuf);
+ lreply(msgcode, "%s", outbuf);
+ }
+ fclose(infile);
+ lreply(msgcode, "");
+ }
+ }
+ else {
+ /* banner <path> */
+ while (getaclentry("banner", &entry)) {
if (ARG0 && strlen(ARG0) > 0) {
- infile = fopen(ARG0, "r");
- if (infile) {
- while (fgets(linebuf, 255, infile) != NULL) {
- if ((crptr = strchr(linebuf, '\n')) != NULL)
- *crptr = '\0';
- msg_massage(linebuf, outbuf);
- lreply(msgcode, "%s", outbuf);
- }
- fclose(infile);
- lreply(msgcode, "");
- }
- }
+ infile = fopen(ARG0, "r");
+ if (infile) {
+ while (fgets(linebuf, 255, infile) != NULL) {
+ if ((crptr = strchr(linebuf, '\n')) != NULL)
+ *crptr = '\0';
+ msg_massage(linebuf, outbuf);
+ lreply(msgcode, "%s", outbuf);
+ }
+ fclose(infile);
+ lreply(msgcode, "");
+ }
+ }
+ }
}
+
}
/*************************************************************************/
--- ftpd.c
+++ ftpd.c Fri May 26 20:53:57 1995
@@ -150,6 +150,14 @@
struct sockaddr_in his_addr;
struct sockaddr_in pasv_addr;
+int virtual_mode=0;
+#ifdef VIRTUAL
+struct sockaddr_in virtual_addr;
+struct sockaddr_in *virtual_ptr;
+char virtual_root[MAXPATHLEN];
+char virtual_banner[MAXPATHLEN];
+#endif
+
int data;
jmp_buf errcatch,
urgcatch;
@@ -261,6 +269,11 @@
#endif
char *cp;
+#ifdef VIRTUAL
+ int virtual_len;
+ int set;
+#endif
+
#ifdef SecureWare
setluid(1); /* make sure there is a valid luid */
set_auth_parameters(argc,argv);
@@ -499,6 +512,31 @@
authenticate();
conv_init();
+
+#ifdef VIRTUAL
+ virtual_len = sizeof(virtual_addr);
+ if (getsockname(0, (struct sockaddr *) &virtual_addr,
+ &virtual_len) < 0) {
+ virtual_mode = 0;
+ }
+ else {
+ virtual_ptr = (struct sockaddr_in *) &virtual_addr;
+ set = 0;
+ entry = (struct aclmember *) NULL;
+ while (!set && getaclentry("virtual", &entry)) {
+ if (!strcmp(ARG0, inet_ntoa(virtual_ptr->sin_addr))) {
+ if (ARG1 != NULL && ARG2 != NULL) {
+ virtual_mode = 1;
+ strncpy(virtual_root, ARG1, MAXPATHLEN);
+ strncpy(virtual_banner, ARG2, MAXPATHLEN);
+ syslog(LOG_ERR, "VirtualFTP Connect to: %s",
+ inet_ntoa(virtual_ptr->sin_addr));
+ }
+ }
+ }
+ }
+#endif
+
if (is_shutdown(1) != 0) {
syslog(LOG_INFO, "connection refused (server shut down) from %s [%s]",
remotehost, remoteaddr);
@@ -506,7 +544,8 @@
hostname);
exit(0);
}
- show_banner(220);
+
+ show_banner(220, virtual_mode, virtual_banner);
entry = (struct aclmember *) NULL;
if (getaclentry("lslong", &entry) && ARG0 && strlen(ARG0) > 0) {
@@ -1108,6 +1147,13 @@
if (anonymous || guest) {
/* 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) {
+ strcpy(pw->pw_dir, virtual_root);
+ }
+#endif
+
if (anonymous) {
if (chroot(pw->pw_dir) < 0 || chdir("/") < 0) {
reply(550, "Can't set guest privileges.");
--- makefiles/Makefile.aix
+++ makefiles/Makefile.aix Fri May 26 20:57:36 1995
@@ -1,13 +1,14 @@
CC = cc
IFLAGS = -I.. -I../support
LFLAGS = -L../support
-CFLAGS = -O -DDEBUG ${IFLAGS} ${LFLAGS}
+CFLAGS = -O -DDEBUG -DVIRTUAL ${IFLAGS} ${LFLAGS}
LIBES = -lsupport
LIBC = /lib/libc.a
LINTFLAGS=
LKERB = -lauth -lckrb -lkrb -ldes
MKDEP = ../util/mkdep
+
SRCS = ftpd.c ftpcmd.c glob.c logwtmp.c popen.c vers.c access.c extensions.c \
realpath.c acl.c private.c authenticate.c conversions.c hostacc.c
OBJS = ftpd.o ftpcmd.o glob.o logwtmp.o popen.o vers.o access.o extensions.o \
--- makefiles/Makefile.bsd
+++ makefiles/Makefile.bsd Fri May 26 20:57:56 1995
@@ -1,12 +1,13 @@
CC = cc
IFLAGS = -I.. -I../support
LFLAGS = -L../support
-CFLAGS = -O -DDEBUG ${IFLAGS} ${LFLAGS}
+CFLAGS = -O -DDEBUG -DVIRTUAL ${IFLAGS} ${LFLAGS}
LIBES = -lsupport
LIBC = /usr/lib/libc.a
LINTFLAGS=
LKERB = -lauth -lckrb -lkrb -ldes
MKDEP = ../util/mkdep
+
SRCS = ftpd.c ftpcmd.c glob.c logwtmp.c popen.c vers.c access.c extensions.c \
realpath.c acl.c private.c authenticate.c conversions.c hostacc.c
--- makefiles/Makefile.dgx
+++ makefiles/Makefile.dgx Fri May 26 20:58:05 1995
@@ -1,12 +1,13 @@
CC = gcc
IFLAGS = -I.. -I../support
LFLAGS = -L../support
-CFLAGS = -g -DDEBUG ${IFLAGS} ${LFLAGS}
+CFLAGS = -g -DDEBUG -DVIRTUAL ${IFLAGS} ${LFLAGS}
LIBES = -lsupport
LIBC = -lc
LINTFLAGS=
LKERB = -lauth -lckrb -lkrb -ldes
MKDEP = ../util/mkdep
+
SRCS = ftpd.c ftpcmd.c glob.c logwtmp.c popen.c vers.c access.c extensions.c \
realpath.c acl.c private.c authenticate.c conversions.c hostacc.c
--- makefiles/Makefile.dyn
+++ makefiles/Makefile.dyn Fri May 26 20:58:15 1995
@@ -1,7 +1,7 @@
CC = gcc
IFLAGS = -I.. -I../support
LFLAGS = -L../support
-CFLAGS = -O -DDEBUG ${IFLAGS} ${LFLAGS}
+CFLAGS = -O -DDEBUG -DVIRTUAL ${IFLAGS} ${LFLAGS}
LIBES = -lsupport
LIBC = /lib/libc.a
LINTFLAGS=
--- makefiles/Makefile.gen
+++ makefiles/Makefile.gen Fri May 26 20:58:25 1995
@@ -1,12 +1,14 @@
CC = cc
IFLAGS = -I.. -I../support
LFLAGS = -L../support
-CFLAGS = -O -DDEBUG ${IFLAGS} ${LFLAGS}
+CFLAGS = -O -DDEBUG -DVIRTUAL ${IFLAGS} ${LFLAGS}
LIBES = -lsupport
LIBC = /lib/libc.a
LINTFLAGS=
LKERB = -lauth -lckrb -lkrb -ldes
MKDEP = ../util/mkdep
+DEFINES = -DVIRTUAL
+
SRCS = ftpd.c ftpcmd.c glob.c logwtmp.c popen.c vers.c access.c extensions.c \
realpath.c acl.c private.c authenticate.c conversions.c hostacc.c
--- makefiles/Makefile.hpx
+++ makefiles/Makefile.hpx Fri May 26 20:58:46 1995
@@ -1,12 +1,13 @@
CC = cc
IFLAGS = -I.. -I../support
LFLAGS = -L../support
-CFLAGS = -Aa -Dunix -D_HPUX_SOURCE -O -DDEBUG ${IFLAGS} ${LFLAGS}
+CFLAGS = -Aa -Dunix -DVIRTUAL -D_HPUX_SOURCE -O -DDEBUG ${IFLAGS} ${LFLAGS}
LIBES = -lsupport -lc -lPW
LIBC = /lib/libc.a
LINTFLAGS=
LKERB = -lauth -lckrb -lkrb -ldes
MKDEP = ../util/mkdep.hpx
+
SRCS = ftpd.c ftpcmd.c glob.c logwtmp.c popen.c vers.c access.c extensions.c \
realpath.c acl.c private.c authenticate.c conversions.c hostacc.c
--- makefiles/Makefile.isc
+++ makefiles/Makefile.isc Fri May 26 20:58:57 1995
@@ -1,12 +1,13 @@
CC = gcc
IFLAGS = -I.. -I../support
LFLAGS = -L../support
-CFLAGS = -O -DISC -DM_UNIX -DPOSIX_JC -DHAVE_VPRINTF -DHAVE_DIRENT -DNBBY=8 -DHAVE_GETDTABLESIZE -DHAVE_GETCWD -DREGEX -DSHADOW_PASSWORD ${IFLAGS} ${LFLAGS}
+CFLAGS = -O -DVIRTUAL -DISC -DM_UNIX -DPOSIX_JC -DHAVE_VPRINTF -DHAVE_DIRENT -DNBBY=8 -DHAVE_GETDTABLESIZE -DHAVE_GETCWD -DREGEX -DSHADOW_PASSWORD ${IFLAGS} ${LFLAGS}
LIBES = -lsupport -linet -lnsl_s -lcposix -lPW -lsec
LIBC = /lib/libc.a
LINTFLAGS=
#LKERB =
MKDEP = ../util/mkdep
+
SRCS = ftpd.c ftpcmd.c glob.c logwtmp.c popen.c vers.c access.c extensions.c \
realpath.c acl.c private.c authenticate.c conversions.c hostacc.c
--- makefiles/Makefile.lnx
+++ makefiles/Makefile.lnx Fri May 26 20:59:22 1995
@@ -1,13 +1,13 @@
CC = gcc
IFLAGS = -I.. -I../support -I/usr/include/bsd
LFLAGS = -L../support
-CFLAGS = -O -DDEBUG ${IFLAGS} ${LFLAGS}
+CFLAGS = -O -DVIRTUAL -DDEBUG ${IFLAGS} ${LFLAGS}
LIBES = -lsupport -lbsd
LIBC = /usr/lib/libc.a
LINTFLAGS=
LKERB = -lauth -lckrb -lkrb -ldes
MKDEP = ../util/mkdep
-
+
SRCS = ftpd.c ftpcmd.c glob.c logwtmp.c popen.c vers.c access.c extensions.c \
realpath.c acl.c private.c authenticate.c conversions.c hostacc.c
OBJS = ftpd.o ftpcmd.o glob.o logwtmp.o popen.o vers.o access.o extensions.o \
@@ -22,7 +22,7 @@
${CC} ${CFLAGS} -o $@ ftpshut.c vers.o ${LIBES}
ftpd: ${OBJS} ${LIBC}
- ${CC} ${CFLAGS} -o $@ ${OBJS} ${LIBES}
+ ${CC} ${CFLAGS} ${DEFINES} -o $@ ${OBJS} ${LIBES}
ckconfig: ckconfig.c
${CC} ${CFLAGS} -o $@ ckconfig.c
--- makefiles/Makefile.nx2
+++ makefiles/Makefile.nx2 Fri May 26 20:59:12 1995
@@ -1,7 +1,7 @@
CC = cc
IFLAGS = -I.. -I../support
LFLAGS = -L../support
-CFLAGS = -O -DDEBUG ${IFLAGS} ${LFLAGS}
+CFLAGS = -O -DVIRTUAL -DDEBUG ${IFLAGS} ${LFLAGS}
LIBES = -lsupport
LIBC = /lib/libsys_s.a
LINTFLAGS=
--- makefiles/Makefile.nx3
+++ makefiles/Makefile.nx3 Fri May 26 20:59:31 1995
@@ -1,7 +1,7 @@
CC = cc
IFLAGS = -I..
LFLAGS = -L../support
-CFLAGS = -O2 ${IFLAGS} ${LFLAGS}
+CFLAGS = -O2 -DVIRTUAL ${IFLAGS} ${LFLAGS}
LIBES = -lsupport
LIBC =
LINTFLAGS=
--- makefiles/Makefile.osf
+++ makefiles/Makefile.osf Fri May 26 20:59:39 1995
@@ -1,7 +1,7 @@
CC = cc
IFLAGS = -I.. -I../support
LFLAGS = -L../support -s -x
-CFLAGS = -O -DDEBUG ${IFLAGS} ${LFLAGS}
+CFLAGS = -O -DVIRTUAL -DDEBUG ${IFLAGS} ${LFLAGS}
LIBES = -lsupport
LIBC = /lib/libc.a
LINTFLAGS=
--- makefiles/Makefile.ptx
+++ makefiles/Makefile.ptx Fri May 26 20:59:47 1995
@@ -1,7 +1,7 @@
CC = cc
IFLAGS = -I.. -I../support
LFLAGS = -L../support
-CFLAGS = -O -DDEBUG ${IFLAGS} ${LFLAGS}
+CFLAGS = -O -DVIRTUAL -DDEBUG ${IFLAGS} ${LFLAGS}
LIBES = -lsupport -lsec -lgen -lseq -lsocket -linet -lnsl -lmalloc
LIBC = /lib/libc.a
LINTFLAGS=
--- makefiles/Makefile.s41
+++ makefiles/Makefile.s41 Fri May 26 20:59:56 1995
@@ -2,7 +2,7 @@
#CC = acc
IFLAGS = -I.. -I../support
LFLAGS = -L../support
-CFLAGS = $(OPT) -DDEBUG ${IFLAGS} ${LFLAGS}
+CFLAGS = $(OPT) -DVIRTUAL -DDEBUG ${IFLAGS} ${LFLAGS}
OPT = -g
LIBES = -lsupport
LIBC = /lib/libc.a
--- makefiles/Makefile.sco
+++ makefiles/Makefile.sco Fri May 26 21:00:09 1995
@@ -1,7 +1,7 @@
CC = cc
IFLAGS = -I.. -I../support
LFLAGS = -L../support
-CFLAGS = -O ${IFLAGS} ${LFLAGS}
+CFLAGS = -O -DVIRTUAL ${IFLAGS} ${LFLAGS}
# 1) If you do not have -lprot_s, use -lprot instead.
# 2) -lcrypt can be used in place of -lcrypt_i. If you do not have any crypt
# library, get and install ftp.sco.com:/SLS/lng225* (International Crypt
--- makefiles/Makefile.sgi
+++ makefiles/Makefile.sgi Fri May 26 21:00:18 1995
@@ -1,7 +1,7 @@
CC = cc
IFLAGS = -I.. -I../support
LFLAGS = -L../support
-CFLAGS = -O -DDEBUG ${IFLAGS} ${LFLAGS}
+CFLAGS = -O -DVIRTUAL -DDEBUG ${IFLAGS} ${LFLAGS}
LIBES = -lsupport
LIBC = /usr/lib/libc.a
LINTFLAGS=
--- makefiles/Makefile.sny
+++ makefiles/Makefile.sny Fri May 26 21:00:26 1995
@@ -1,7 +1,7 @@
CC = cc
IFLAGS = -I.. -I../support
LFLAGS = -L../support
-CFLAGS = -O -DDEBUG ${IFLAGS} ${LFLAGS}
+CFLAGS = -O -DVIRTUAL -DDEBUG ${IFLAGS} ${LFLAGS}
LIBES = -lsupport
LIBC = /lib/libc.a
LINTFLAGS=
--- makefiles/Makefile.sol
+++ makefiles/Makefile.sol Fri May 26 21:00:35 1995
@@ -1,7 +1,7 @@
CC = cc
IFLAGS = -I.. -I../support
LFLAGS = -L../support
-CFLAGS = -g -DDEBUG ${IFLAGS} ${LFLAGS}
+CFLAGS = -g -DDEBUG -DVIRTUAL ${IFLAGS} ${LFLAGS}
LIBES = -lsupport -lsocket -lnsl -lgen
LIBC = /lib/libc.a
LINTFLAGS=
--- makefiles/Makefile.ult
+++ makefiles/Makefile.ult Fri May 26 21:00:47 1995
@@ -1,7 +1,7 @@
CC = cc
IFLAGS = -I.. -I../support
LFLAGS = -L../support
-CFLAGS = -Dconst="" -O -DDEBUG -DSYSSYSLOG ${IFLAGS} ${LFLAGS}
+CFLAGS = -Dconst="" -O -DVIRTUAL -DDEBUG -DSYSSYSLOG ${IFLAGS} ${LFLAGS}
LIBES = -lsupport
LIBC = /lib/libc.a
LINTFLAGS=
Brian Kramer - Owner/Systems Administrator - bjkramer@pluto.njcc.com
New Jersey Computer Connection - Public Access Unix Site - pluto.njcc.com
Voice: 609-896-2799 - Fax: 609-896-2994 - Dialups: 609-896-3191 & 896-2722
Web: http://www.njcc.com/ Telnet/Dialup: pluto.njcc.com login as guest.
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?Pine.BSF.3.95.961017152616.4811C-200000>
