summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJun-ichiro itojun Hagino <itojun@cvs.openbsd.org>2002-05-09 14:12:18 +0000
committerJun-ichiro itojun Hagino <itojun@cvs.openbsd.org>2002-05-09 14:12:18 +0000
commit8c98091f2ad4dae8c89198d65112941ae3bec400 (patch)
tree5ba00f95edfe8d2159e98c3bf8b904ef1910f0ff
parent7603c12efc38c32ec12f82afbbf3ce3ddbd2b704 (diff)
drop support for rlogin/rsh service (we shouldn't have support it as
they usually use IP address for authentication). sync with kame
-rw-r--r--usr.sbin/faithd/Makefile4
-rw-r--r--usr.sbin/faithd/README6
-rw-r--r--usr.sbin/faithd/faithd.839
-rw-r--r--usr.sbin/faithd/faithd.c37
-rw-r--r--usr.sbin/faithd/faithd.h6
-rw-r--r--usr.sbin/faithd/ftp.c8
-rw-r--r--usr.sbin/faithd/rsh.c220
7 files changed, 31 insertions, 289 deletions
diff --git a/usr.sbin/faithd/Makefile b/usr.sbin/faithd/Makefile
index b36a0d2fc26..29adde41e69 100644
--- a/usr.sbin/faithd/Makefile
+++ b/usr.sbin/faithd/Makefile
@@ -1,7 +1,7 @@
-# $OpenBSD: Makefile,v 1.2 2001/02/15 17:37:33 itojun Exp $
+# $OpenBSD: Makefile,v 1.3 2002/05/09 14:12:16 itojun Exp $
PROG= faithd
-SRCS= faithd.c tcp.c ftp.c rsh.c prefix.c
+SRCS= faithd.c tcp.c ftp.c prefix.c
MAN= faithd.8
diff --git a/usr.sbin/faithd/README b/usr.sbin/faithd/README
index 5bcf4fa288c..bf9ee6c846b 100644
--- a/usr.sbin/faithd/README
+++ b/usr.sbin/faithd/README
@@ -1,8 +1,8 @@
Configuring FAITH IPv6-to-IPv4 TCP relay
Kazu Yamamoto and Jun-ichiro itojun Hagino
-$OpenBSD: README,v 1.8 2001/05/01 07:40:04 itojun Exp $
-$KAME: README,v 1.7 2001/04/25 11:25:19 itojun Exp $
+$OpenBSD: README,v 1.9 2002/05/09 14:12:16 itojun Exp $
+$KAME: README,v 1.9 2002/05/09 14:10:06 itojun Exp $
Introduction
@@ -74,8 +74,6 @@ The following example assumes:
More examples:
- # faithd login /usr/libexec/rlogin rlogind
- # faithd shell /usr/libexec/rshd rshd
# faithd ftpd /usr/libexec/ftpd ftpd -l
# faithd sshd
diff --git a/usr.sbin/faithd/faithd.8 b/usr.sbin/faithd/faithd.8
index 94bdc38dcf3..4a0f47ec767 100644
--- a/usr.sbin/faithd/faithd.8
+++ b/usr.sbin/faithd/faithd.8
@@ -1,5 +1,5 @@
-.\" $OpenBSD: faithd.8,v 1.20 2002/05/06 23:34:33 millert Exp $
-.\" $KAME: faithd.8,v 1.31 2001/06/30 00:57:01 itojun Exp $
+.\" $OpenBSD: faithd.8,v 1.21 2002/05/09 14:12:17 itojun Exp $
+.\" $KAME: faithd.8,v 1.36 2002/05/09 13:59:16 itojun Exp $
.\"
.\" Copyright (C) 1995, 1996, 1997, and 1998 WIDE Project.
.\" All rights reserved.
@@ -115,7 +115,6 @@ at
.Pa http://www.vermicelli.pasta.cs.uit.no/ipv6/software.html .
Make sure you do not propagate translated DNS records to normal DNS cloud,
it is highly harmful.
-.Pp
.\".Ss Daemon mode
When
.Nm
@@ -170,8 +169,6 @@ Use privileged TCP port number as source port,
for IPv4 TCP connection toward final destination.
For relaying
.Xr ftp 1
-and
-.Xr rsh 1 ,
this flag is not necessary as special program code is supplied.
.El
.Pp
@@ -180,9 +177,7 @@ will relay both normal and out-of-band TCP data.
It is capable of emulating TCP half close as well.
.Nm
includes special support for protocols used by
-.Xr ftp 1
-and
-.Xr rsh 1 .
+.Xr ftp 1 .
When translating FTP protocol,
.Nm
translates network level addresses in
@@ -190,13 +185,6 @@ translates network level addresses in
and
.Li PASV/LPSV/EPSV
commands.
-For RLOGIN protocol,
-.Nm
-will relay back connection from
-.Nm rlogind
-on the server to
-.Nm rlogin
-on client.
.Pp
Inactive sessions will be disconnected in 30 minutes,
to avoid stale sessions from chewing up resources.
@@ -244,9 +232,12 @@ permit the connection.
.Pp
The directives are evaluated in sequence,
and the first matching entry will be effective.
+If there is no match
+.Pq if we reach the end of the ruleset
+the traffic will be denied.
.\".Pp
.\"With inetd mode,
-.\"traffic may be filtered by using access control functionality in
+.\"traffic may be filtered by using access control functionality in
.\".Xr inetd 8 .
.Sh EXAMPLES
Before invoking
@@ -261,7 +252,6 @@ interface has to be configured properly.
# route add -inet6 3ffe:501:4819:ffff:: -prefixlen 96 ::1
# route change -inet6 3ffe:501:4819:ffff:: -prefixlen 96 -ifp faith0
.Ed
-.Pp
.\".Ss Daemon mode samples
To translate
.Li telnet
@@ -289,18 +279,11 @@ If you would like to pass extra arguments to the local daemon:
Here are some other examples.
You may need
.Fl p
-to translate rsh/rlogin services.
+if the service checks the source port range.
.Bd -literal -offset
# faithd ssh
-# faithd login /usr/libexec/rlogin rlogind
-# faithd shell /usr/libexec/rshd rshd
+# faithd telnet /usr/libexec/telnetd telnetd
.Ed
-.Pp
-However, you should be careful when translating rlogin or rsh
-connections.
-See
-.Sx SECURITY CONSIDERATIONS
-for more details.
.Ss Access control samples
The following illustrates a simple
.Pa faithd.conf
@@ -343,9 +326,7 @@ The
command first appeared in WIDE Hydrangea IPv6 protocol stack kit.
.\"
.Sh SECURITY CONSIDERATIONS
-It is very insecure to use
-.Xr rhosts 5
-and other IP-address based authentication, for connections relayed by
+It is very insecure to use IP-address based authentication, for connections relayed by
.Nm Ns ,
and any other TCP relaying services.
.Pp
diff --git a/usr.sbin/faithd/faithd.c b/usr.sbin/faithd/faithd.c
index 2314f30c90a..0ce09b3719a 100644
--- a/usr.sbin/faithd/faithd.c
+++ b/usr.sbin/faithd/faithd.c
@@ -1,5 +1,5 @@
-/* $OpenBSD: faithd.c,v 1.18 2002/02/16 21:28:02 millert Exp $ */
-/* $KAME: faithd.c,v 1.40 2001/07/02 14:36:48 itojun Exp $ */
+/* $OpenBSD: faithd.c,v 1.19 2002/05/09 14:12:17 itojun Exp $ */
+/* $KAME: faithd.c,v 1.50 2002/05/09 14:06:52 itojun Exp $ */
/*
* Copyright (C) 1997 and 1998 WIDE Project.
@@ -439,7 +439,9 @@ again:
len = sizeof(srcaddr);
s_src = accept(s_wld, (struct sockaddr *)&srcaddr,
&len);
- if (s_src == -1) {
+ if (s_src < 0) {
+ if (errno == ECONNABORTED)
+ goto again;
exit_failure("socket: %s", strerror(errno));
/*NOTREACHED*/
}
@@ -469,9 +471,9 @@ play_child(int s_src, struct sockaddr *srcaddr)
{
struct sockaddr_storage dstaddr6;
struct sockaddr_storage dstaddr4;
- char src[MAXHOSTNAMELEN];
- char dst6[MAXHOSTNAMELEN];
- char dst4[MAXHOSTNAMELEN];
+ char src[NI_MAXHOST];
+ char dst6[NI_MAXHOST];
+ char dst4[NI_MAXHOST];
int len = sizeof(dstaddr6);
int s_dst, error, hport, nresvport, on = 1;
struct timeval tv;
@@ -574,18 +576,10 @@ play_child(int s_src, struct sockaddr *srcaddr)
else /* AF_INET */
hport = ntohs(((struct sockaddr_in *)&dstaddr4)->sin_port);
- switch (hport) {
- case RLOGIN_PORT:
- case RSH_PORT:
+ if (pflag)
s_dst = rresvport_af(&nresvport, sa4->sa_family);
- break;
- default:
- if (pflag)
- s_dst = rresvport_af(&nresvport, sa4->sa_family);
- else
- s_dst = socket(sa4->sa_family, SOCK_STREAM, 0);
- break;
- }
+ else
+ s_dst = socket(sa4->sa_family, SOCK_STREAM, 0);
if (s_dst < 0) {
exit_failure("socket: %s", strerror(errno));
/*NOTREACHED*/
@@ -626,15 +620,6 @@ play_child(int s_src, struct sockaddr *srcaddr)
case FTP_PORT:
ftp_relay(s_src, s_dst);
break;
- case RSH_PORT:
- syslog(LOG_WARNING,
- "WARINNG: it is insecure to relay rsh port");
- rsh_relay(s_src, s_dst);
- break;
- case RLOGIN_PORT:
- syslog(LOG_WARNING,
- "WARINNG: it is insecure to relay rlogin port");
- /*FALLTHROUGH*/
default:
tcp_relay(s_src, s_dst, service);
break;
diff --git a/usr.sbin/faithd/faithd.h b/usr.sbin/faithd/faithd.h
index 82311b1e0ea..9ce8e5b4b41 100644
--- a/usr.sbin/faithd/faithd.h
+++ b/usr.sbin/faithd/faithd.h
@@ -1,5 +1,5 @@
-/* $OpenBSD: faithd.h,v 1.7 2002/02/16 21:28:02 millert Exp $ */
-/* $KAME: faithd.h,v 1.7 2001/07/02 14:36:48 itojun Exp $ */
+/* $OpenBSD: faithd.h,v 1.8 2002/05/09 14:12:17 itojun Exp $ */
+/* $KAME: faithd.h,v 1.9 2002/05/09 09:41:24 itojun Exp $ */
/*
* Copyright (C) 1997 and 1998 WIDE Project.
@@ -37,8 +37,6 @@ extern void tcp_relay(int, int, const char *);
extern void ftp_relay(int, int);
extern int ftp_active(int, int, int *, int *);
extern int ftp_passive(int, int, int *, int *);
-extern void rsh_relay(int, int);
-extern void rsh_dual_relay(int, int);
extern void exit_success(const char *, ...)
__attribute__((__format__(__printf__, 1, 2)));
extern void exit_failure(const char *, ...)
diff --git a/usr.sbin/faithd/ftp.c b/usr.sbin/faithd/ftp.c
index 8537a34120d..ad01bf19ca5 100644
--- a/usr.sbin/faithd/ftp.c
+++ b/usr.sbin/faithd/ftp.c
@@ -1,5 +1,5 @@
-/* $OpenBSD: ftp.c,v 1.6 2002/02/16 21:28:02 millert Exp $ */
-/* $KAME: ftp.c,v 1.13 2001/09/05 01:10:30 itojun Exp $ */
+/* $OpenBSD: ftp.c,v 1.7 2002/05/09 14:12:17 itojun Exp $ */
+/* $KAME: ftp.c,v 1.14 2002/04/24 08:17:23 itojun Exp $ */
/*
* Copyright (C) 1997 and 1998 WIDE Project.
@@ -258,7 +258,7 @@ ftp_activeconn()
return -1;
}
error = connect(port6, sa, sa->sa_len);
- if (port6 == -1) {
+ if (error < 0) {
close(port6);
close(port4);
close(wport4);
@@ -305,7 +305,7 @@ ftp_passiveconn()
return -1;
}
error = connect(port4, sa, sa->sa_len);
- if (port4 == -1) {
+ if (error < 0) {
close(wport6);
close(port4);
close(port6);
diff --git a/usr.sbin/faithd/rsh.c b/usr.sbin/faithd/rsh.c
deleted file mode 100644
index 0d3faa8bb19..00000000000
--- a/usr.sbin/faithd/rsh.c
+++ /dev/null
@@ -1,220 +0,0 @@
-/* $OpenBSD: rsh.c,v 1.5 2001/09/05 01:31:33 itojun Exp $ */
-/* $KAME: rsh.c,v 1.7 2001/09/05 01:10:30 itojun Exp $ */
-
-/*
- * Copyright (C) 1997 and 1998 WIDE Project.
- * All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- * 1. Redistributions of source code must retain the above copyright
- * notice, this list of conditions and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above copyright
- * notice, this list of conditions and the following disclaimer in the
- * documentation and/or other materials provided with the distribution.
- * 3. Neither the name of the project nor the names of its contributors
- * may be used to endorse or promote products derived from this software
- * without specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY THE PROJECT AND CONTRIBUTORS ``AS IS'' AND
- * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
- * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
- * ARE DISCLAIMED. IN NO EVENT SHALL THE PROJECT OR CONTRIBUTORS BE LIABLE
- * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
- * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
- * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
- * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
- * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
- * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
- * SUCH DAMAGE.
- */
-
-#include <sys/param.h>
-#include <sys/types.h>
-#include <sys/socket.h>
-#include <sys/ioctl.h>
-#include <sys/time.h>
-
-#include <stdio.h>
-#include <stdlib.h>
-#include <string.h>
-#include <syslog.h>
-#include <unistd.h>
-#include <errno.h>
-
-#include <netinet/in.h>
-#include <arpa/inet.h>
-#include <netdb.h>
-
-#include "faithd.h"
-
-char rshbuf[MSS];
-
-int s_ctl, s_ctl6, s_rcv, s_snd;
-int half;
-
-void
-rsh_relay(int s_src, int s_dst)
-{
- ssize_t n;
- fd_set readfds;
- int error;
- struct timeval tv;
-
- FD_ZERO(&readfds);
- FD_SET(s_src, &readfds);
- tv.tv_sec = FAITH_TIMEOUT;
- tv.tv_usec = 0;
- error = select(s_src + 1, &readfds, NULL, NULL, &tv);
- if (error == -1)
- exit_failure("select %d: %s", s_src, strerror(errno));
- else if (error == 0)
- exit_failure("connection timeout");
-
- n = read(s_src, rshbuf, sizeof(rshbuf));
- if (rshbuf[0] != 0) {
- rsh_dual_relay(s_src, s_dst);
- /* NOTREACHED */
- }
- write(s_dst, rshbuf, n);
- tcp_relay(s_src, s_dst, "rsh");
- /* NOTREACHED */
-}
-
-static void
-relay(int src, int dst)
-{
- int error;
- ssize_t n;
- int atmark;
-
- error = ioctl(s_rcv, SIOCATMARK, &atmark);
- if (error != -1 && atmark == 1) {
- n = read(s_rcv, rshbuf, 1);
- if (n == 1)
- send(s_snd, rshbuf, 1, MSG_OOB);
- return;
- }
-
- n = read(s_rcv, rshbuf, sizeof(rshbuf));
-
- switch (n) {
- case -1:
- exit_failure("%s", strerror(errno));
- case 0:
- if (s_rcv == src) {
- /* half close */
- shutdown(dst, 1);
- half = YES;
- break;
- }
- close(src);
- close(dst);
- close(s_ctl);
- close(s_ctl6);
- exit_success("terminating rsh/contorol connections");
- break;
- default:
- write(s_snd, rshbuf, n);
- }
-}
-
-void
-rsh_dual_relay(int s_src, int s_dst)
-{
- fd_set readfds;
- int len, s_wld, error;
- struct sockaddr_storage ctladdr6;
- struct sockaddr_storage ctladdr;
- int port6 = 0, lport, lport6;
- char *p;
- struct timeval tv;
- struct sockaddr *sa;
-
- half = NO;
- s_rcv = s_src;
- s_snd = s_dst;
- syslog(LOG_INFO, "starting rsh connection");
-
- for (p = rshbuf; *p; p++)
- port6 = port6 * 10 + *p - '0';
-
- len = sizeof(ctladdr6);
- getpeername(s_src, (struct sockaddr *)&ctladdr6, &len);
- if (((struct sockaddr *)&ctladdr6)->sa_family == AF_INET6)
- ((struct sockaddr_in6 *)&ctladdr6)->sin6_port = htons(port6);
- else
- ((struct sockaddr_in *)&ctladdr6)->sin_port = htons(port6);
-
- s_wld = rresvport(&lport);
- if (s_wld == -1) goto bad;
- error = listen(s_wld, 1);
- if (error == -1) goto bad;
- snprintf(rshbuf, sizeof(rshbuf), "%d", lport);
- write(s_dst, rshbuf, strlen(rshbuf)+1);
-
- len = sizeof(ctladdr);
- s_ctl = accept(s_wld, (struct sockaddr *)&ctladdr, &len);
- if (s_ctl == -1) goto bad;
- close(s_wld);
-
- sa = (struct sockaddr *)&ctladdr6;
- s_ctl6 = rresvport_af(&lport6, sa->sa_family);
- if (s_ctl6 == -1) goto bad;
- error = connect(s_ctl6, sa, sa->sa_len);
- if (error == -1) goto bad;
-
- syslog(LOG_INFO, "starting rsh control connection");
-
- for (;;) {
- int maxfd = 0;
-
- FD_ZERO(&readfds);
- if (half == NO)
- FD_SET(s_src, &readfds);
- FD_SET(s_dst, &readfds);
- if (s_dst > maxfd)
- maxfd = s_dst;
- FD_SET(s_ctl, &readfds);
- if (s_ctl > maxfd)
- maxfd = s_ctl;
- FD_SET(s_ctl6, &readfds);
- if (s_ctl6 > maxfd)
- maxfd = s_ctl6;
-
- tv.tv_sec = FAITH_TIMEOUT;
- tv.tv_usec = 0;
-
- error = select(maxfd + 1, &readfds, NULL, NULL, &tv);
- if (error == -1)
- exit_failure("select 4 sockets: %s", strerror(errno));
- else if (error == 0)
- exit_failure("connection timeout");
-
- if (half == NO && FD_ISSET(s_src, &readfds)) {
- s_rcv = s_src;
- s_snd = s_dst;
- relay(s_src, s_dst);
- }
- if (FD_ISSET(s_dst, &readfds)) {
- s_rcv = s_dst;
- s_snd = s_src;
- relay(s_src, s_dst);
- }
- if (FD_ISSET(s_ctl, &readfds)) {
- s_rcv = s_ctl;
- s_snd = s_ctl6;
- relay(s_src, s_dst);
- }
- if (FD_ISSET(s_ctl6, &readfds)) {
- s_rcv = s_ctl6;
- s_snd = s_ctl;
- relay(s_src, s_dst);
- }
- }
- /* NOTREACHED */
-
- bad:
- exit_failure("%s", strerror(errno));
-}