summaryrefslogtreecommitdiff
path: root/usr.sbin/faithd
diff options
context:
space:
mode:
authorJun-ichiro itojun Hagino <itojun@cvs.openbsd.org>1999-12-20 16:32:54 +0000
committerJun-ichiro itojun Hagino <itojun@cvs.openbsd.org>1999-12-20 16:32:54 +0000
commit865faff95d195731bc635a0ecb6b82240bdf01ad (patch)
tree583eded31cf49fa2f3eda4a89d21d11147538c07 /usr.sbin/faithd
parent05d299e7b204e7e1df159eed593901871dbe66da (diff)
rcsid police.
pathname change (/usr/local/v6/libexec -> /usr/libexec) bring in some of kame fixes (sprintf -> snprintf, proc title).
Diffstat (limited to 'usr.sbin/faithd')
-rw-r--r--usr.sbin/faithd/Makefile13
-rw-r--r--usr.sbin/faithd/README3
-rw-r--r--usr.sbin/faithd/faithd.816
-rw-r--r--usr.sbin/faithd/faithd.c16
-rw-r--r--usr.sbin/faithd/faithd.h4
-rw-r--r--usr.sbin/faithd/ftp.c52
-rw-r--r--usr.sbin/faithd/rsh.c2
-rw-r--r--usr.sbin/faithd/tcp.c2
8 files changed, 68 insertions, 40 deletions
diff --git a/usr.sbin/faithd/Makefile b/usr.sbin/faithd/Makefile
new file mode 100644
index 00000000000..da285983e0f
--- /dev/null
+++ b/usr.sbin/faithd/Makefile
@@ -0,0 +1,13 @@
+# $OpenBSD: Makefile,v 1.1 1999/12/20 16:32:53 itojun Exp $
+
+PROG= faithd
+SRCS= faithd.c tcp.c ftp.c rsh.c
+
+MAN= faithd.8
+
+#CPPFLAGS+= -DFAITH4
+
+LDADD+= -lutil
+DPADD+= ${LIBUTIL}
+
+.include <bsd.prog.mk>
diff --git a/usr.sbin/faithd/README b/usr.sbin/faithd/README
index 10ada6fa328..bd1ab6be47a 100644
--- a/usr.sbin/faithd/README
+++ b/usr.sbin/faithd/README
@@ -1,7 +1,8 @@
Configuring FAITH IPv6-to-IPv4 TCP relay
Kazu Yamamoto and Jun-ichiro itojun Hagino
-$Id: README,v 1.1 1999/12/20 16:07:42 itojun Exp $
+$OpenBSD: README,v 1.2 1999/12/20 16:32:53 itojun Exp $
+KAME Id: README,v 1.1.1.1 1999/12/20 16:07:42 itojun Exp
Introduction
diff --git a/usr.sbin/faithd/faithd.8 b/usr.sbin/faithd/faithd.8
index 5c0521e1f7d..a1131346b0a 100644
--- a/usr.sbin/faithd/faithd.8
+++ b/usr.sbin/faithd/faithd.8
@@ -1,3 +1,5 @@
+.\" $OpenBSD: faithd.8,v 1.2 1999/12/20 16:32:53 itojun Exp $
+.\"
.\" Copyright (C) 1995, 1996, 1997, and 1998 WIDE Project.
.\" All rights reserved.
.\"
@@ -25,11 +27,11 @@
.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
.\" SUCH DAMAGE.
.\"
-.\" $Id: faithd.8,v 1.1 1999/12/20 16:07:42 itojun Exp $
+.\" KAME Id: faithd.8,v 1.1.1.1 1999/12/20 16:07:42 itojun Exp
.\"
.Dd May 17, 1998
.Dt FAITHD 8
-.Os KAME
+.Os
.Sh NAME
.Nm faithd
.Nd FAITH IPv6/v4 translator daemon
@@ -199,21 +201,21 @@ as either of the following:
If you would like to provide local telnet service via
.Xr telnetd 8
on
-.Pa /usr/local/v6/libexec/telnetd ,
+.Pa /usr/libexec/telnetd ,
user the following command line:
.Bd -literal -offset
-# faithd telnet /usr/local/v6/libexec/telnetd telnetd
+# faithd telnet /usr/libexec/telnetd telnetd
.Ed
.Pp
If you would like to pass extra arguments to the local daemon:
.Bd -literal -offset
-# faithd ftpd /usr/local/v6/libexec/ftpd ftpd -l
+# faithd ftpd /usr/libexec/ftpd ftpd -l
.Ed
.Pp
Here are some other examples:
.Bd -literal -offset
-# faithd login /usr/local/v6/libexec/rlogin rlogind
-# faithd shell /usr/local/v6/libexec/rshd rshd
+# faithd login /usr/libexec/rlogin rlogind
+# faithd shell /usr/libexec/rshd rshd
# faithd sshd
.Ed
.\"
diff --git a/usr.sbin/faithd/faithd.c b/usr.sbin/faithd/faithd.c
index d2abde0aaac..74326156381 100644
--- a/usr.sbin/faithd/faithd.c
+++ b/usr.sbin/faithd/faithd.c
@@ -1,3 +1,5 @@
+/* $OpenBSD: faithd.c,v 1.2 1999/12/20 16:32:53 itojun Exp $ */
+
/*
* Copyright (C) 1997 and 1998 WIDE Project.
* All rights reserved.
@@ -83,6 +85,7 @@ char *serverpath = NULL;
char *serverarg[MAXARGV + 1];
static char *faithdname = NULL;
char logname[BUFSIZ];
+char procname[BUFSIZ];
struct myaddrs {
struct myaddrs *next;
struct sockaddr *addr;
@@ -167,7 +170,7 @@ main(int argc, char *argv[])
memset(&ss, 0, sizeof(ss));
memset(&hints, 0, sizeof(hints));
- sprintf(serv, "%u", NAMESERVER_PORT);
+ snprintf(serv, sizeof(serv), "%u", NAMESERVER_PORT);
hints.ai_flags = AI_NUMERICHOST;
if (getaddrinfo(ns, serv, &hints, &res) == 0) {
res_init();
@@ -270,7 +273,8 @@ main(int argc, char *argv[])
start_daemon();
- sprintf(logname, "accepting port %s", service);
+ snprintf(logname, sizeof(logname), "faithd %s", service);
+ snprintf(procname, sizeof(procname), "accepting port %s", service);
openlog(logname, LOG_PID | LOG_NOWAIT, LOG_DAEMON);
syslog(LOG_INFO, "Staring faith daemon for %s port", service);
@@ -294,7 +298,7 @@ play_service(int s_wld)
* Wait, accept, fork, faith....
*/
again:
- setproctitle(logname);
+ setproctitle(procname);
FD_ZERO(&rfds);
FD_SET(s_wld, &rfds);
@@ -640,7 +644,7 @@ exit_error(const char *fmt, ...)
char buf[BUFSIZ];
va_start(ap, fmt);
- vsprintf(buf, fmt, ap);
+ vsnprintf(buf, sizeof(buf), fmt, ap);
va_end(ap);
fprintf(stderr, "%s\n", buf);
exit(EXIT_FAILURE);
@@ -653,7 +657,7 @@ exit_failure(const char *fmt, ...)
char buf[BUFSIZ];
va_start(ap, fmt);
- vsprintf(buf, fmt, ap);
+ vsnprintf(buf, sizeof(buf), fmt, ap);
va_end(ap);
syslog(LOG_ERR, buf);
exit(EXIT_FAILURE);
@@ -666,7 +670,7 @@ exit_success(const char *fmt, ...)
char buf[BUFSIZ];
va_start(ap, fmt);
- vsprintf(buf, fmt, ap);
+ vsnprintf(buf, sizeof(buf), fmt, ap);
va_end(ap);
syslog(LOG_INFO, buf);
exit(EXIT_SUCCESS);
diff --git a/usr.sbin/faithd/faithd.h b/usr.sbin/faithd/faithd.h
index 15566b28140..52c05df7380 100644
--- a/usr.sbin/faithd/faithd.h
+++ b/usr.sbin/faithd/faithd.h
@@ -1,3 +1,5 @@
+/* $OpenBSD: faithd.h,v 1.2 1999/12/20 16:32:53 itojun Exp $ */
+
/*
* Copyright (C) 1997 and 1998 WIDE Project.
* All rights reserved.
@@ -41,7 +43,7 @@ extern void exit_success __P((const char *fmt, ...));
extern void exit_failure __P((const char *fmt, ...));
#define DEFAULT_PORT_NAME "telnet"
-#define DEFAULT_PATH "/usr/local/v6/libexec/telnetd"
+#define DEFAULT_PATH "/usr/libexec/telnetd"
#define DEFAULT_NAME "telnetd"
#define FTP_PORT 21
diff --git a/usr.sbin/faithd/ftp.c b/usr.sbin/faithd/ftp.c
index 96258f32e19..28eced1b716 100644
--- a/usr.sbin/faithd/ftp.c
+++ b/usr.sbin/faithd/ftp.c
@@ -1,3 +1,5 @@
+/* $OpenBSD: ftp.c,v 1.2 1999/12/20 16:32:53 itojun Exp $ */
+
/*
* Copyright (C) 1997 and 1998 WIDE Project.
* All rights reserved.
@@ -402,7 +404,7 @@ ftp_copyresult(int src, int dst, enum state state)
case NONE:
if (!passivemode && rbuf[0] == '1') {
if (ftp_activeconn() < 0) {
- n = sprintf(rbuf,
+ n = snprintf(rbuf, sizeof(rbuf),
"425 Cannot open data connetion\r\n");
}
}
@@ -495,7 +497,7 @@ passivefail0:
wport6 = socket(sin6->sin6_family, SOCK_STREAM, 0);
if (wport6 == -1) {
passivefail:
- n = sprintf(sbuf,
+ n = snprintf(sbuf, sizeof(sbuf),
"500 could not translate from PASV\r\n");
write(src, sbuf, n);
return n;
@@ -551,7 +553,7 @@ passivefail:
a = (char *)&sin6->sin6_addr;
p = (char *)&sin6->sin6_port;
- n = sprintf(sbuf,
+ n = snprintf(sbuf, sizeof(sbuf),
"228 Entering Long Passive Mode (%d,%d,%d,%d,%d,%d,%d,%d,%d,%d,%d,%d,%d,%d,%d,%d,%d,%d,%d,%d,%d)\r\n",
6, 16, UC(a[0]), UC(a[1]), UC(a[2]), UC(a[3]),
UC(a[4]), UC(a[5]), UC(a[6]), UC(a[7]),
@@ -562,7 +564,7 @@ passivefail:
passivemode = 1;
return n;
} else {
- n = sprintf(sbuf,
+ n = snprintf(sbuf, sizeof(sbuf),
"229 Entering Extended Passive Mode (|||%d|)\r\n",
ntohs(sin6->sin6_port));
write(dst, sbuf, n);
@@ -616,7 +618,7 @@ passivefail1:
wport6 = socket(sin->sin_family, SOCK_STREAM, 0);
if (wport6 == -1) {
passivefail2:
- n = sprintf(sbuf,
+ n = snprintf(sbuf, sizeof(sbuf),
"500 could not translate from EPSV\r\n");
write(src, sbuf, n);
return n;
@@ -672,7 +674,7 @@ passivefail2:
a = (char *)&sin->sin_addr;
p = (char *)&sin->sin_port;
- n = sprintf(sbuf,
+ n = snprintf(sbuf, sizeof(sbuf),
"227 Entering Passive Mode (%d,%d,%d,%d,%d,%d)\r\n",
UC(a[0]), UC(a[1]), UC(a[2]), UC(a[3]),
UC(p[0]), UC(p[1]));
@@ -776,7 +778,7 @@ ftp_copycommand(int src, int dst, enum state *state)
wport4 = wport6 = port4 = port6 = -1;
if (epsvall) {
- n = sprintf(sbuf, "501 %s disallowed in EPSV ALL\r\n",
+ n = snprintf(sbuf, sizeof(sbuf), "501 %s disallowed in EPSV ALL\r\n",
cmd);
write(src, sbuf, n);
return n;
@@ -790,7 +792,7 @@ ftp_copycommand(int src, int dst, enum state *state)
&ho[12], &ho[13], &ho[14], &ho[15],
&pal, &po[0], &po[1]);
if (n != 21 || af != 6 || hal != 16|| pal != 2) {
- n = sprintf(sbuf,
+ n = snprintf(sbuf, sizeof(sbuf),
"501 illegal parameter to LPRT\r\n");
write(src, sbuf, n);
return n;
@@ -811,7 +813,7 @@ sendport:
error = getsockname(dst, (struct sockaddr *)&data4, &n);
if (error == -1) {
lprtfail:
- n = sprintf(sbuf,
+ n = snprintf(sbuf, sizeof(sbuf),
"500 could not translate to PORT\r\n");
write(src, sbuf, n);
return n;
@@ -852,7 +854,7 @@ lprtfail:
sin = (struct sockaddr_in *)&data4;
a = (char *)&sin->sin_addr;
p = (char *)&sin->sin_port;
- n = sprintf(sbuf, "PORT %d,%d,%d,%d,%d,%d\r\n",
+ n = snprintf(sbuf, sizeof(sbuf), "PORT %d,%d,%d,%d,%d,%d\r\n",
UC(a[0]), UC(a[1]), UC(a[2]), UC(a[3]),
UC(p[0]), UC(p[1]));
write(dst, sbuf, n);
@@ -875,7 +877,7 @@ lprtfail:
wport4 = wport6 = port4 = port6 = -1;
if (epsvall) {
- n = sprintf(sbuf, "501 %s disallowed in EPSV ALL\r\n",
+ n = snprintf(sbuf, sizeof(sbuf), "501 %s disallowed in EPSV ALL\r\n",
cmd);
write(src, sbuf, n);
return n;
@@ -888,7 +890,7 @@ lprtfail:
p++;
if (!*p) {
eprtparamfail:
- n = sprintf(sbuf,
+ n = snprintf(sbuf, sizeof(sbuf),
"501 illegal parameter to EPRT\r\n");
write(src, sbuf, n);
return n;
@@ -909,7 +911,7 @@ eprtparamfail:
n = sscanf(afp, "%d", &af);
if (n != 1 || af != 2) {
- n = sprintf(sbuf,
+ n = snprintf(sbuf, sizeof(sbuf),
"501 unsupported address family to EPRT\r\n");
write(src, sbuf, n);
return n;
@@ -918,13 +920,13 @@ eprtparamfail:
hints.ai_family = AF_UNSPEC;
error = getaddrinfo(hostp, portp, &hints, &res);
if (error) {
- n = sprintf(sbuf,
+ n = snprintf(sbuf, sizeof(sbuf),
"501 EPRT: %s\r\n", gai_strerror(error));
write(src, sbuf, n);
return n;
}
if (res->ai_next) {
- n = sprintf(sbuf,
+ n = snprintf(sbuf, sizeof(sbuf),
"501 EPRT: %s resolved to multiple addresses\r\n", hostp);
write(src, sbuf, n);
return n;
@@ -946,14 +948,14 @@ eprtparamfail:
wport4 = wport6 = port4 = port6 = -1;
if (epsvall) {
- n = sprintf(sbuf, "501 %s disallowed in EPSV ALL\r\n",
+ n = snprintf(sbuf, sizeof(sbuf), "501 %s disallowed in EPSV ALL\r\n",
cmd);
write(src, sbuf, n);
return n;
}
/* transmit PASV */
- n = sprintf(sbuf, "PASV\r\n");
+ n = snprintf(sbuf, sizeof(sbuf), "PASV\r\n");
write(dst, sbuf, n);
*state = LPSV;
passivemode = 0; /* to be set to 1 later */
@@ -968,7 +970,7 @@ eprtparamfail:
close(port6);
wport4 = wport6 = port4 = port6 = -1;
- n = sprintf(sbuf, "PASV\r\n");
+ n = snprintf(sbuf, sizeof(sbuf), "PASV\r\n");
write(dst, sbuf, n);
*state = EPSV;
passivemode = 0; /* to be set to 1 later */
@@ -979,7 +981,7 @@ eprtparamfail:
* EPSV ALL
*/
epsvall = 1;
- n = sprintf(sbuf, "200 EPSV ALL command successful.\r\n");
+ n = snprintf(sbuf, sizeof(sbuf), "200 EPSV ALL command successful.\r\n");
write(src, sbuf, n);
return n;
#ifdef FAITH4
@@ -1001,7 +1003,7 @@ eprtparamfail:
n = sscanf(p, "%u,%u,%u,%u,%u,%u",
&ho[0], &ho[1], &ho[2], &ho[3], &po[0], &po[1]);
if (n != 6) {
- n = sprintf(sbuf,
+ n = snprintf(sbuf, sizeof(sbuf),
"501 illegal parameter to PORT\r\n");
write(src, sbuf, n);
return n;
@@ -1021,7 +1023,7 @@ eprtparamfail:
error = getsockname(dst, (struct sockaddr *)&data4, &n);
if (error == -1) {
portfail:
- n = sprintf(sbuf,
+ n = snprintf(sbuf, sizeof(sbuf),
"500 could not translate to EPRT\r\n");
write(src, sbuf, n);
return n;
@@ -1063,7 +1065,7 @@ portfail:
wport4 = -1;
goto portfail;
}
- n = sprintf(sbuf, "EPRT |%d|%s|%s|\r\n", af, host, serv);
+ n = snprintf(sbuf, sizeof(sbuf), "EPRT |%d|%s|%s|\r\n", af, host, serv);
write(dst, sbuf, n);
*state = nstate;
passivemode = 0;
@@ -1082,7 +1084,7 @@ portfail:
wport4 = wport6 = port4 = port6 = -1;
/* transmit EPSV */
- n = sprintf(sbuf, "EPSV\r\n");
+ n = snprintf(sbuf, sizeof(sbuf), "EPSV\r\n");
write(dst, sbuf, n);
*state = PASV;
passivemode = 0; /* to be set to 1 later */
@@ -1092,7 +1094,7 @@ portfail:
/*
* reject PORT/PASV
*/
- n = sprintf(sbuf, "502 %s not implemented.\r\n", cmd);
+ n = snprintf(sbuf, sizeof(sbuf), "502 %s not implemented.\r\n", cmd);
write(src, sbuf, n);
return n;
#endif /* FAITH4 */
@@ -1109,7 +1111,7 @@ portfail:
*/
if (ftp_passiveconn() < 0) {
- n = sprintf(sbuf, "425 Cannot open data connetion\r\n");
+ n = snprintf(sbuf, sizeof(sbuf), "425 Cannot open data connetion\r\n");
write(src, sbuf, n);
} else {
/* simply relay the command */
diff --git a/usr.sbin/faithd/rsh.c b/usr.sbin/faithd/rsh.c
index 8dc0ead6a84..83157419c13 100644
--- a/usr.sbin/faithd/rsh.c
+++ b/usr.sbin/faithd/rsh.c
@@ -1,3 +1,5 @@
+/* $OpenBSD: rsh.c,v 1.2 1999/12/20 16:32:53 itojun Exp $ */
+
/*
* Copyright (C) 1997 and 1998 WIDE Project.
* All rights reserved.
diff --git a/usr.sbin/faithd/tcp.c b/usr.sbin/faithd/tcp.c
index c11faea30dd..6b486a69d5b 100644
--- a/usr.sbin/faithd/tcp.c
+++ b/usr.sbin/faithd/tcp.c
@@ -1,3 +1,5 @@
+/* $OpenBSD: tcp.c,v 1.2 1999/12/20 16:32:53 itojun Exp $ */
+
/*
* Copyright (C) 1997 and 1998 WIDE Project.
* All rights reserved.