pop3gwd 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
This commit is contained in:
kevlo 2000-01-03 02:22:42 +00:00
parent fa86cc645b
commit 748a3eadcb
14 changed files with 277 additions and 0 deletions

16
net/pop3gwd/Makefile Normal file
View File

@ -0,0 +1,16 @@
# $OpenBSD: Makefile,v 1.1.1.1 2000/01/03 02:22:42 kevlo Exp $
#
# OpenBSD port for pop3gwd.
# Created: 1999/12/28 ianm@cit.nepean.uws.edu.au
#
DISTNAME= pop3gwd-1.2
CATEGORIES= net mail
MAINTAINER= ianm@cit.nepean.uws.edu.au
MASTER_SITES= http://www.students.cs.unibo.it/~borgia/homepage/Software/
EXTRACT_SUFX= .tar.gz
WRKSRC= ${WRKDIR}/pop3gwd/
.include <bsd.port.mk>

3
net/pop3gwd/files/md5 Normal file
View File

@ -0,0 +1,3 @@
MD5 (pop3gwd-1.2.tar.gz) = 529734de6f2e2a576ea1c59b202a56d5
RMD160 (pop3gwd-1.2.tar.gz) = eb241ce6ef5d3cc8624f0e2ff01bb697adbdb53b
SHA1 (pop3gwd-1.2.tar.gz) = f64c9b299e20efaabe7561d2332dbb3ab6d4eaad

View File

@ -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

View File

@ -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))

View File

@ -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, &copy, sizeof(fd_set)); /* select() trashes copy */
+ memcpy(&copy, &master, sizeof(fd_set)); /* select() trashes copy */
deadline.tv_sec = maxwait;
deadline.tv_usec = 0;
@@ -115,7 +115,7 @@
nleft = nbytes;
do {
- bcopy(&master, &copy, sizeof(fd_set)); /* select() trashes copy */
+ memcpy(&copy, &master, sizeof(fd_set)); /* select() trashes copy */
deadline.tv_sec = maxwait;
deadline.tv_usec = 0;

View File

@ -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);
}

View File

@ -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)

View File

@ -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 <ctype.h>
#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 <id><value>, 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]))

View File

@ -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

View File

@ -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, &copy, sizeof(fd_set)); /* select() trashes copy */
+ memcpy(&copy, &master, sizeof(fd_set)); /* select() trashes copy */
deadline.tv_sec = maxwait;
deadline.tv_usec = 0;

2
net/pop3gwd/pkg/COMMENT Normal file
View File

@ -0,0 +1,2 @@
App-level proxy for Mail retrieval behind Firewalls.

12
net/pop3gwd/pkg/DESCR Normal file
View File

@ -0,0 +1,12 @@
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.

5
net/pop3gwd/pkg/PLIST Normal file
View File

@ -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

10
net/pop3gwd/pkg/SECURITY Normal file
View File

@ -0,0 +1,10 @@
# $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.