diff options
author | pst <pst@FreeBSD.org> | 1996-05-30 03:08:17 +0000 |
---|---|---|
committer | pst <pst@FreeBSD.org> | 1996-05-30 03:08:17 +0000 |
commit | 93cb831554dbe0e43e154dbf039bd862f4c3bafe (patch) | |
tree | 0d2838764f1b4d3e7487cd1b0c8ce5f33bf39681 /usr.bin/ftp | |
parent | 10d32f7a70eaa6dcc9bd498e4bf78130094d6fdd (diff) | |
download | FreeBSD-src-93cb831554dbe0e43e154dbf039bd862f4c3bafe.zip FreeBSD-src-93cb831554dbe0e43e154dbf039bd862f4c3bafe.tar.gz |
1. Remove SOCKS support (unneded with SOCKS v5 port)
2. Update quarantine port support to use new kernel mechanism.
Diffstat (limited to 'usr.bin/ftp')
-rw-r--r-- | usr.bin/ftp/Makefile | 8 | ||||
-rw-r--r-- | usr.bin/ftp/ftp.c | 69 | ||||
-rw-r--r-- | usr.bin/ftp/main.c | 4 |
3 files changed, 20 insertions, 61 deletions
diff --git a/usr.bin/ftp/Makefile b/usr.bin/ftp/Makefile index 12a718f..dc8197f 100644 --- a/usr.bin/ftp/Makefile +++ b/usr.bin/ftp/Makefile @@ -4,13 +4,5 @@ PROG= ftp SRCS= cmds.c cmdtab.c ftp.c main.c ruserpass.c domacro.c LINKS= ${BINDIR}/ftp ${BINDIR}/pftp MLINKS= ftp.1 pftp.1 -CFLAGS+=-DFTP_DATA_BOTTOM=40000 -DFTP_DATA_TOP=44999 - -.if defined(SOCKS) -CFLAGS+=-DSOCKS -CFLAGS+=-Dconnect=Rconnect -Dgetsockname=Rgetsockname -Dlisten=Rlisten \ - -Daccept=Raccept -Drcmd=Rrcmd -Dbind=Rbind -Dselect=Rselect -LDADD+= -lsocks -.endif .include <bsd.prog.mk> diff --git a/usr.bin/ftp/ftp.c b/usr.bin/ftp/ftp.c index a98bb96..fd091b4 100644 --- a/usr.bin/ftp/ftp.c +++ b/usr.bin/ftp/ftp.c @@ -1000,9 +1000,8 @@ initconn() char *p, *a; int result, len, tmpno = 0; int on = 1; - int count; + int tos, ports; u_long a1,a2,a3,a4,p1,p2; - static u_short last_port = FTP_DATA_BOTTOM; if (passivemode) { data = socket(AF_INET, SOCK_STREAM, 0); @@ -1044,15 +1043,18 @@ initconn() return(1); } #ifdef IP_TOS - on = IPTOS_THROUGHPUT; - if (setsockopt(data, IPPROTO_IP, IP_TOS, (char *)&on, - sizeof(int)) < 0) + tos = IPTOS_THROUGHPUT; + if (setsockopt(data, IPPROTO_IP, IP_TOS, (char *)&tos, + sizeof(tos)) < 0) perror("ftp: setsockopt TOS (ignored)"); #endif return(0); } noport: + data_addr = myctladdr; + if (sendport) + data_addr.sin_port = 0; /* let system pick one */ if (data != -1) (void) close(data); data = socket(AF_INET, SOCK_STREAM, 0); @@ -1062,53 +1064,22 @@ noport: sendport = 1; return (1); } - data_addr = myctladdr; - if (sendport) { - if (restricted_data_ports) { - for (count = 0; - count < FTP_DATA_TOP-FTP_DATA_BOTTOM; count++) { - last_port++; - if (last_port < FTP_DATA_BOTTOM || - last_port > FTP_DATA_TOP) - last_port = FTP_DATA_BOTTOM; - - data_addr.sin_port = htons(last_port); - if (bind(data, (struct sockaddr *)&data_addr, - sizeof(data_addr)) < 0) { - if (errno == EADDRINUSE) - continue; - else { - warn("bind"); - goto bad; - } - } - break; - } - if (count >= FTP_DATA_TOP-FTP_DATA_BOTTOM) { - perror("ftp: all data ports in use"); - goto bad; - } - } else { - data_addr.sin_port = 0; /* use any port */ - if (bind(data, (struct sockaddr *)&data_addr, - sizeof(data_addr)) < 0) { - warn("bind"); - goto bad; - } - } - } else { - if (setsockopt(data, SOL_SOCKET, SO_REUSEADDR, - (char *)&on, sizeof (on)) < 0) { + if (!sendport) + if (setsockopt(data, SOL_SOCKET, SO_REUSEADDR, (char *)&on, + sizeof (on)) < 0) { warn("setsockopt (reuse address)"); goto bad; } - if (bind(data, (struct sockaddr *)&data_addr, - sizeof (data_addr)) < 0) { - warn("bind"); - goto bad; - } - } - +#ifdef IP_PORTRANGE + ports = restricted_data_ports ? IP_PORTRANGE_HIGH : IP_PORTRANGE_DEFAULT; + if (setsockopt(data, IPPROTO_IP, IP_PORTRANGE, (char *)&ports, + sizeof (ports)) < 0) + warn("setsockopt PORTRANGE (ignored)"); +#endif + if (bind(data, (struct sockaddr *)&data_addr, sizeof (data_addr)) < 0) { + warn("bind"); + goto bad; + } if (options & SO_DEBUG && setsockopt(data, SOL_SOCKET, SO_DEBUG, (char *)&on, sizeof (on)) < 0) warn("setsockopt (ignored)"); diff --git a/usr.bin/ftp/main.c b/usr.bin/ftp/main.c index 2a96c0a..cca7a919 100644 --- a/usr.bin/ftp/main.c +++ b/usr.bin/ftp/main.c @@ -72,10 +72,6 @@ main(argc, argv) char *cp, homedir[MAXPATHLEN]; struct servent sp_default; -#ifdef SOCKS - SOCKSinit(argv[0]); -#endif - sp = getservbyname("ftp", "tcp"); if (sp == 0) { sp = &sp_default; |