From be8168529b55361dabbbe5da4b53837f63bb73d7 Mon Sep 17 00:00:00 2001 From: Will Andrews Date: Sat, 28 Oct 2000 03:06:49 +0000 Subject: Add pop3gwd 1.2, an app-level proxy for mail retrieval behind firewalls. It appears to have been heavily audited (at least as far as string format paranoia goes, and optimizes: snprintf() -> strlcpy()). PR: 22123 Submitted by: Joao Carlos Mendes Luis Obtained from: OpenBSD --- mail/pop3gwd/Makefile | 20 ++++++++++ mail/pop3gwd/distinfo | 1 + mail/pop3gwd/files/SECURITY | 8 ++++ mail/pop3gwd/files/patch-connect_loginc | 34 ++++++++++++++++ mail/pop3gwd/files/patch-get_remote_datac | 65 +++++++++++++++++++++++++++++++ mail/pop3gwd/files/patch-ioc | 21 ++++++++++ mail/pop3gwd/files/patch-mainc | 28 +++++++++++++ mail/pop3gwd/files/patch-makefile | 32 +++++++++++++++ mail/pop3gwd/files/patch-parse_cmd_linec | 25 ++++++++++++ mail/pop3gwd/files/patch-pop3-gwh | 12 ++++++ mail/pop3gwd/files/patch-relay_datac | 12 ++++++ mail/pop3gwd/pkg-comment | 1 + mail/pop3gwd/pkg-descr | 11 ++++++ mail/pop3gwd/pkg-plist | 5 +++ 14 files changed, 275 insertions(+) create mode 100644 mail/pop3gwd/Makefile create mode 100644 mail/pop3gwd/distinfo create mode 100644 mail/pop3gwd/files/SECURITY create mode 100644 mail/pop3gwd/files/patch-connect_loginc create mode 100644 mail/pop3gwd/files/patch-get_remote_datac create mode 100644 mail/pop3gwd/files/patch-ioc create mode 100644 mail/pop3gwd/files/patch-mainc create mode 100644 mail/pop3gwd/files/patch-makefile create mode 100644 mail/pop3gwd/files/patch-parse_cmd_linec create mode 100644 mail/pop3gwd/files/patch-pop3-gwh create mode 100644 mail/pop3gwd/files/patch-relay_datac create mode 100644 mail/pop3gwd/pkg-comment create mode 100644 mail/pop3gwd/pkg-descr create mode 100644 mail/pop3gwd/pkg-plist (limited to 'mail/pop3gwd') diff --git a/mail/pop3gwd/Makefile b/mail/pop3gwd/Makefile new file mode 100644 index 000000000000..066851cf5725 --- /dev/null +++ b/mail/pop3gwd/Makefile @@ -0,0 +1,20 @@ +# New ports collection makefile for: pop3gwd +# Date created: 19 October 2000 +# Whom: jonny@jonny.eng.br +# +# $OpenBSD: Makefile,v 1.9 2000/10/23 16:08:13 espie Exp $ +# $FreeBSD$ +# + +PORTNAME= pop3gwd +PORTVERSION= 1.2 +CATEGORIES= mail net +MASTER_SITES= http://www.go.dlr.de/linux/src/ \ + ftp://ftp.eos.hokudai.ac.jp/pub/mail/pop/ \ + ftp://ftp.win.ne.jp/pub/network/mail/pop/ + +MAINTAINER= jonny@jonny.eng.br + +WRKSRC= ${WRKDIR}/${PORTNAME} + +.include diff --git a/mail/pop3gwd/distinfo b/mail/pop3gwd/distinfo new file mode 100644 index 000000000000..790287c226b4 --- /dev/null +++ b/mail/pop3gwd/distinfo @@ -0,0 +1 @@ +MD5 (pop3gwd-1.2.tar.gz) = 529734de6f2e2a576ea1c59b202a56d5 diff --git a/mail/pop3gwd/files/SECURITY b/mail/pop3gwd/files/SECURITY new file mode 100644 index 000000000000..afe7d01c173d --- /dev/null +++ b/mail/pop3gwd/files/SECURITY @@ -0,0 +1,8 @@ +# $OpenBSD: SECURITY,v 1.1.1.1 2000/01/03 02:22:42 kevlo Exp $ + +ianm@cit.nepean.uws.edu.au 1999/12/29. + +Makes good use of snprintf. + +Made use of strncpy. I've converted them all to +strlcpy for some performance improvements. diff --git a/mail/pop3gwd/files/patch-connect_loginc b/mail/pop3gwd/files/patch-connect_loginc new file mode 100644 index 000000000000..1c6e2ddb5253 --- /dev/null +++ b/mail/pop3gwd/files/patch-connect_loginc @@ -0,0 +1,34 @@ +# $OpenBSD: patch-connect_loginc,v 1.1.1.1 2000/01/03 02:22:43 kevlo Exp $ +--- connect_login.c.orig Thu Jun 19 19:06:28 1997 ++++ connect_login.c Wed Dec 29 12:23:12 1999 +@@ -42,10 +42,10 @@ + if ((remote_fd = socket(AF_INET, SOCK_STREAM, IPPROTO_TCP)) < 0) + remote_fd = BAD; + else { +- bzero(&tcp_srv_addr, sizeof(tcp_srv_addr)); ++ memset(&tcp_srv_addr, 0, sizeof(tcp_srv_addr)); + tcp_srv_addr.sin_family = AF_INET; + tcp_srv_addr.sin_port = htons(port); +- bcopy(host_ptr->h_addr_list[0], &tcp_srv_addr.sin_addr, host_ptr->h_length); ++ memcpy(&tcp_srv_addr.sin_addr, host_ptr->h_addr_list[0], host_ptr->h_length); + if (connect(remote_fd, (struct sockaddr *) &tcp_srv_addr, sizeof(tcp_srv_addr)) <0) { + close(remote_fd); + remote_fd = BAD; +@@ -136,7 +136,7 @@ + if (result == TRUE) { + /* server replied, check if reply is empty */ + /* must save response in case it is good */ +- strncpy(to_client, input, MAX_IO_LEN); ++ (void)strlcpy(to_client, input, MAX_IO_LEN); + if ((next_tok = strtok(input, " ")) == NULL) { + /* empty response, POP3 violation */ + close(*remote_filedes); +@@ -159,7 +159,7 @@ + syslog(LOG_PRIO, "%s", to_client); + #endif + +- strncat(to_client, termin, MAX_IO_LEN); ++ (void)strlcat(to_client, termin, MAX_IO_LEN); + if ((count = writen(first_filedes, to_client, strlen(to_client), maxwait)) == strlen(to_client)) + *out += count; + else diff --git a/mail/pop3gwd/files/patch-get_remote_datac b/mail/pop3gwd/files/patch-get_remote_datac new file mode 100644 index 000000000000..bcdef02adb13 --- /dev/null +++ b/mail/pop3gwd/files/patch-get_remote_datac @@ -0,0 +1,65 @@ +# $OpenBSD: patch-get_remote_datac,v 1.1.1.1 2000/01/03 02:22:43 kevlo Exp $ +--- get_remote_data.c.orig Wed Dec 29 12:30:32 1999 ++++ get_remote_data.c Wed Dec 29 12:31:29 1999 +@@ -39,36 +39,36 @@ + + /* look for user command, can be USER or QUIT */ + if ((next_tok = strtok(input, " ")) != NULL) +- strncpy(cmd, next_tok, maxlen); ++ strlcpy(cmd, next_tok, maxlen); + else { + result = BAD; +- strncpy(error, "no command in input", maxlen); ++ strlcpy(error, "no command in input", maxlen); + cmd[0] = 0; /* we terminate the string anyway, better be safe than sorry */ + } + + if (result == GOOD && strcasecmp(cmd, user_c) == 0) { + /* look for hostname to connect to (after last delimiter, if present) */ + if (delim_pos != NULL) { +- strncpy(hostname, delim_pos+1, MAXHOSTNAMELEN); ++ strlcpy(hostname, delim_pos+1, MAXHOSTNAMELEN); + *delim_pos = 0; /* terminate the string here, so strtok will ignore this part */ + if (strlen(hostname) != 0) { + if ((next_tok = strtok(NULL, " ")) != NULL) { +- strncpy(username, next_tok, maxlen); ++ strlcpy(username, next_tok, maxlen); + } + else { + result = BAD; +- strncpy(error, "no username in input", maxlen); ++ strlcpy(error, "no username in input", maxlen); + } + + } + else { + result = BAD; +- strncpy(error, "no hostname in input", maxlen); ++ strlcpy(error, "no hostname in input", maxlen); + } + } + else { + result = BAD; +- strncpy(error, "no username/hostname delimiter in input", maxlen); ++ strlcpy(error, "no username/hostname delimiter in input", maxlen); + } + } + +@@ -76,7 +76,7 @@ + if (result == GOOD) { + if (strcasecmp(cmd, user_c) != 0 && strcasecmp(cmd, quit_c) != 0) { + result = BAD; +- strncpy(error, "command must be either USER or QUIT", maxlen); ++ strlcpy(error, "command must be either USER or QUIT", maxlen); + } + } + +@@ -133,7 +133,7 @@ + if (parse_res == GOOD && strcasecmp(cmd, quit_c) == 0) { + /* set server's hostname and setup farewell */ + if (gethostname(server_name, MAXHOSTNAMELEN) != 0) +- strncpy(server_name, "localhost", MAXHOSTNAMELEN); ++ strlcpy(server_name, "localhost", MAXHOSTNAMELEN); + snprintf(output, MAX_IO_LEN, "%s %s %s %s%s", pos_re, server_name, + GREETING, "signing off", termin); + if ((count = writen(client_filedes, output, strlen(output), maxwait)) == strlen(output)) diff --git a/mail/pop3gwd/files/patch-ioc b/mail/pop3gwd/files/patch-ioc new file mode 100644 index 000000000000..5d419684144e --- /dev/null +++ b/mail/pop3gwd/files/patch-ioc @@ -0,0 +1,21 @@ +# $OpenBSD: patch-ioc,v 1.1.1.1 2000/01/03 02:22:43 kevlo Exp $ +--- io.c.orig Wed Dec 29 12:26:16 1999 ++++ io.c Wed Dec 29 12:27:39 1999 +@@ -52,7 +52,7 @@ + + while (++count < maxlen && term_flag == FALSE) { + +- bcopy(&master, ©, sizeof(fd_set)); /* select() trashes copy */ ++ memcpy(©, &master, sizeof(fd_set)); /* select() trashes copy */ + deadline.tv_sec = maxwait; + deadline.tv_usec = 0; + +@@ -115,7 +115,7 @@ + nleft = nbytes; + + do { +- bcopy(&master, ©, sizeof(fd_set)); /* select() trashes copy */ ++ memcpy(©, &master, sizeof(fd_set)); /* select() trashes copy */ + deadline.tv_sec = maxwait; + deadline.tv_usec = 0; + diff --git a/mail/pop3gwd/files/patch-mainc b/mail/pop3gwd/files/patch-mainc new file mode 100644 index 000000000000..4415b468a2e9 --- /dev/null +++ b/mail/pop3gwd/files/patch-mainc @@ -0,0 +1,28 @@ +# $OpenBSD: patch-mainc,v 1.1.1.1 2000/01/03 02:22:43 kevlo Exp $ +--- main.c.orig Tue Dec 28 12:16:25 1999 ++++ main.c Tue Dec 28 12:28:45 1999 +@@ -23,7 +23,7 @@ + static char rcsid[] = "$Id: patch-mainc,v 1.1.1.1 2000/01/03 02:22:43 kevlo Exp $"; + + +-void main(int argc, char *argv[]) { ++int main(int argc, char *argv[]) { + /* default proxy identification and setup */ + char delimiter = '#'; /* needed to parse username and hostname */ + int timeout = 120; /* timeout is 2 minutes */ +@@ -60,7 +60,7 @@ + + /* set server's hostname and setup greeting */ + if (gethostname(server_name, MAXHOSTNAMELEN) != 0) +- strncpy(server_name, "localhost", MAXHOSTNAMELEN); ++ (void)strlcpy(server_name, "localhost", MAXHOSTNAMELEN); + snprintf(output, MAX_IO_LEN, "%s %s %s %s%s", pos_reply, server_name, + GREETING, "ready", terminator); + +@@ -88,5 +88,6 @@ + + syslog(LOG_PRIO, "signing off (in: %d bytes, out: %d bytes)", in_bytes, out_bytes); + closelog(); ++ return(0); + } + diff --git a/mail/pop3gwd/files/patch-makefile b/mail/pop3gwd/files/patch-makefile new file mode 100644 index 000000000000..878d98111a8f --- /dev/null +++ b/mail/pop3gwd/files/patch-makefile @@ -0,0 +1,32 @@ +# $OpenBSD: patch-makefile,v 1.1.1.1 2000/01/03 02:22:43 kevlo Exp $ +--- Makefile.orig Thu Jun 19 19:06:28 1997 ++++ Makefile Wed Dec 29 12:25:33 1999 +@@ -3,22 +3,23 @@ + + + CC=gcc +-CFLAGS= -O2 ++CFLAGS= -O2 -Wall + MODULES=main.o parse_cmd_line.o get_remote_data.o connect_login.o io.o relay_data.o + DOCS=README COPYING HISTORY +-INSTALL_DIR=/usr/sbin ++INSTALL_DIR=${PREFIX}/libexec + VERSION=1.2 +-DOC_DIR=/usr/doc/pop3gwd-$(VERSION) ++DOC_DIR=${PREFIX}/share/doc/pop3gwd-$(VERSION) + + + in.pop3gwd: pop3-gw.h $(MODULES) + $(CC) $(CFLAGS) -o $@ $(MODULES) + strip $@ + chmod 755 $@ ++all: ++ make + + install: +- make +- cp -f in.pop3gwd $(INSTALL_DIR)/ ++ cp -f in.pop3gwd $(INSTALL_DIR)/pop3gwd + [ -d $(DOC_DIR) ] || mkdir $(DOC_DIR) + cp -f $(DOCS) $(DOC_DIR) + diff --git a/mail/pop3gwd/files/patch-parse_cmd_linec b/mail/pop3gwd/files/patch-parse_cmd_linec new file mode 100644 index 000000000000..81b0e28b5d0a --- /dev/null +++ b/mail/pop3gwd/files/patch-parse_cmd_linec @@ -0,0 +1,25 @@ +# $OpenBSD: patch-parse_cmd_linec,v 1.1.1.1 2000/01/03 02:22:43 kevlo Exp $ +--- parse_cmd_line.c.orig Thu Jun 19 19:06:28 1997 ++++ parse_cmd_line.c Wed Dec 29 12:41:02 1999 +@@ -21,6 +21,7 @@ + /* parse_cmd_line.c: modify setup according to command line parameters */ + /* ---------------------------------------------------------------------- */ + ++#include + #include "pop3-gw.h" + + +@@ -34,11 +35,11 @@ + + + /* there is always at least 1 arg and that's the name of the program */ +- strncpy(log_id, argv[0], maxlen); ++ strlcpy(log_id, argv[0], maxlen); + + /* arguments must be in the form , without blanks in between */ + while (count < argc) { +- strncpy(value, argv[count]+1, MAX_IO_LEN); ++ strlcpy(value, argv[count]+1, MAX_IO_LEN); + if (strlen(value) != 0) + switch (*argv[count]) { + case 'd': if (ispunct(value[0])) diff --git a/mail/pop3gwd/files/patch-pop3-gwh b/mail/pop3gwd/files/patch-pop3-gwh new file mode 100644 index 000000000000..bae7065b4fd4 --- /dev/null +++ b/mail/pop3gwd/files/patch-pop3-gwh @@ -0,0 +1,12 @@ +# $OpenBSD: patch-pop3-gwh,v 1.1.1.1 2000/01/03 02:22:43 kevlo Exp $ +--- pop3-gw.h.orig Thu Jun 19 19:06:28 1997 ++++ pop3-gw.h Tue Dec 28 12:15:22 1999 +@@ -96,7 +96,7 @@ + #define BAD -1 + #define FALSE 0 + #define TRUE 1 +-#ifndef __FreeBSD__ ++#if !defined( BSD4_4 ) + #define MAX(A, B) ((A) > (B) ? (A) : (B)) + #endif + diff --git a/mail/pop3gwd/files/patch-relay_datac b/mail/pop3gwd/files/patch-relay_datac new file mode 100644 index 000000000000..97c01f44e3db --- /dev/null +++ b/mail/pop3gwd/files/patch-relay_datac @@ -0,0 +1,12 @@ +# $OpenBSD: patch-relay_datac,v 1.1.1.1 2000/01/03 02:22:43 kevlo Exp $ +--- relay_data.c.orig Wed Dec 29 12:28:21 1999 ++++ relay_data.c Wed Dec 29 12:29:06 1999 +@@ -39,7 +39,7 @@ + + while (logged_in == TRUE) { + +- bcopy(&master, ©, sizeof(fd_set)); /* select() trashes copy */ ++ memcpy(©, &master, sizeof(fd_set)); /* select() trashes copy */ + deadline.tv_sec = maxwait; + deadline.tv_usec = 0; + diff --git a/mail/pop3gwd/pkg-comment b/mail/pop3gwd/pkg-comment new file mode 100644 index 000000000000..0d4bf2b52357 --- /dev/null +++ b/mail/pop3gwd/pkg-comment @@ -0,0 +1 @@ +App-level proxy for Mail retrieval behind Firewalls. diff --git a/mail/pop3gwd/pkg-descr b/mail/pop3gwd/pkg-descr new file mode 100644 index 000000000000..af38f6bb750e --- /dev/null +++ b/mail/pop3gwd/pkg-descr @@ -0,0 +1,11 @@ +This program is an application-level gateway, or proxy, designed to allow +mail retrieval from POP3 servers by systems that either: + + (a) are behind a firewall or screening router OR + (b) do not have an assigned IP number OR + (c) must share a SLIP/PPP connection on another system + +It connects to the POP3 server on behalf of the client, performs the login +and then passes data both ways until either the client or the server shut +down the connection. In the meanwhile, the connection will appear to have +originated on the host running the proxy. diff --git a/mail/pop3gwd/pkg-plist b/mail/pop3gwd/pkg-plist new file mode 100644 index 000000000000..6bbf1e1f1644 --- /dev/null +++ b/mail/pop3gwd/pkg-plist @@ -0,0 +1,5 @@ +libexec/pop3gwd +share/doc/pop3gwd-1.2/COPYING +share/doc/pop3gwd-1.2/HISTORY +share/doc/pop3gwd-1.2/README +@dirrm share/doc/pop3gwd-1.2 -- cgit v1.2.3