1
0
mirror of https://git.FreeBSD.org/ports.git synced 2025-01-15 07:56:36 +00:00

Remove the modula-3-socks port. It is obsolete. CVSup works fine

now with standard runsocks, and I have finally updated the manual
page to reflect that.
This commit is contained in:
John Polstra 2002-01-02 19:31:55 +00:00
parent c9c5953045
commit d1c25fc9c9
Notes: svn2git 2021-03-31 03:12:20 +00:00
svn path=/head/; revision=52508
37 changed files with 0 additions and 1078 deletions

View File

@ -94,7 +94,6 @@
SUBDIR += mit-scheme
SUBDIR += mixal
SUBDIR += mmix
SUBDIR += modula-3-socks
SUBDIR += moscow_ml
SUBDIR += mozart
SUBDIR += nawk

View File

@ -1,55 +0,0 @@
# New ports collection makefile for: modula-3-socks
# Date created: 31 Oct 1996
# Whom: John Polstra <jdp@polstra.com>
#
# $FreeBSD$
#
PORTNAME= modula-3-socks
PORTVERSION= 1.0
CATEGORIES= lang
MASTER_SITES= ftp://ftp.cup.hp.com/dist/socks/A.B9.06/
DISTNAME= socks
MAINTAINER= jdp@polstra.com
NO_WRKSUBDIR= yes
MANCOMPRESSED= yes
MAN1= m3socks.1
MAN5= m3socks.conf.5
libm3socks_files= accept.c bind.c close.c connect.c dup.c dup2.c \
gethostbyaddr.c gethostbyname.c getpeername.c \
getsockname.c listen.c read.c recv.c recvfrom.c \
select.c send.c sendto.c shutdown.c socket.c \
socksconf.h wrap.h write.c
m3socks_files= m3socks.sh m3socks.1 m3socks.conf.5
post-extract:
@${CP} -p ${FILESDIR}/Makefile.top ${WRKSRC}/Makefile
@test -d ${WRKSRC}/libm3socks || ${MKDIR} ${WRKSRC}/libm3socks
@cd ${FILESDIR}; \
${CP} -p Makefile.libm3socks ${WRKSRC}/libm3socks/Makefile; \
${CP} -p ${libm3socks_files} ${WRKSRC}/libm3socks
@test -d ${WRKSRC}/m3socks || ${MKDIR} ${WRKSRC}/m3socks
@cd ${FILESDIR}; \
${CP} -p Makefile.m3socks ${WRKSRC}/m3socks/Makefile; \
${CP} -p ${m3socks_files} ${WRKSRC}/m3socks
pre-install:
@cd ${PREFIX}/lib; \
test -d m3/FreeBSD2 || { \
${MKDIR} m3/FreeBSD2; \
${CHOWN} ${BINOWN}:${BINGRP} m3 m3/FreeBSD2; \
}
post-install:
@if [ ! -f ${PREFIX}/etc/m3socks.conf ]; then \
${ECHO_MSG} -n "Please create a configuration file in "; \
${ECHO_MSG} "${PREFIX}/etc/m3socks.conf"; \
${ECHO_MSG} "Read m3socks.conf(5) for details"; \
fi
.include <bsd.port.mk>

View File

@ -1 +0,0 @@
MD5 (socks.tar.gz) = e20003ba420c94582ede06b1243e395d

View File

@ -1,19 +0,0 @@
PROG= libm3socks.so
SRCS= accept.c bind.c close.c connect.c dup.c dup2.c \
gethostbyaddr.c gethostbyname.c getpeername.c getsockname.c \
listen.c read.c recv.c recvfrom.c select.c send.c sendto.c \
shutdown.c socket.c socksconf.h wrap.h write.c \
Xconnect.c bytes.c check_cconf.c check_user.c percent_x.c \
saddrtoname.c shell_cmd.c stubs.c
CFLAGS+= -I${.CURDIR}/../SOCKS-SOURCE/h -DPIC -fpic -w
LDFLAGS+= -Bshareable
BINDIR= ${PREFIX}/lib/m3/FreeBSD2
NOMAN= yes
.PATH: ${.CURDIR}/../SOCKS-SOURCE/lib \
${.CURDIR}/../SOCKS-SOURCE/client
${PROG}:
${LD} -o ${PROG} ${LDFLAGS} ${OBJS} ${LDADD}
.include <bsd.prog.mk>

View File

@ -1,18 +0,0 @@
CLEANFILES+= m3socks
MAN1= m3socks.1
MAN5= m3socks.conf.5
BINDIR= ${PREFIX}/bin
MANDIR= ${PREFIX}/man/man
all: m3socks
.SUFFIXES: .sh
.sh:
cp $@.sh $@
realinstall:
${INSTALL} ${COPY} -o ${BINOWN} -g ${BINGRP} -m ${BINMODE} \
m3socks ${BINDIR}
.include <bsd.prog.mk>

View File

@ -1,3 +0,0 @@
SUBDIR= libm3socks m3socks
.include <bsd.subdir.mk>

View File

@ -1,16 +0,0 @@
#include "wrap.h"
#include <sys/types.h>
#include <sys/socket.h>
int
m3_accept(int s, struct sockaddr *addr, int *addrlen)
{
int result;
ENTER_CRITICAL;
MAKE_WRITABLE(addr);
MAKE_WRITABLE(addrlen);
result = accept(s, addr, addrlen);
EXIT_CRITICAL;
return result;
}

View File

@ -1,15 +0,0 @@
#include "wrap.h"
#include <sys/types.h>
#include <sys/socket.h>
int
m3_bind(int s, const struct sockaddr *name, int namelen)
{
int result;
ENTER_CRITICAL;
MAKE_READABLE(name);
result = bind(s, name, namelen);
EXIT_CRITICAL;
return result;
}

View File

@ -1,13 +0,0 @@
#include "wrap.h"
#include <unistd.h>
int
m3_close(int d)
{
int result;
ENTER_CRITICAL;
result = close(d);
EXIT_CRITICAL;
return result;
}

View File

@ -1,15 +0,0 @@
#include "wrap.h"
#include <sys/types.h>
#include <sys/socket.h>
int
m3_connect(int s, const struct sockaddr *name, int namelen)
{
int result;
ENTER_CRITICAL;
MAKE_READABLE(name);
result = connect(s, name, namelen);
EXIT_CRITICAL;
return result;
}

View File

@ -1,13 +0,0 @@
#include "wrap.h"
#include <unistd.h>
int
m3_dup(int oldd)
{
int result;
ENTER_CRITICAL;
result = dup(oldd);
EXIT_CRITICAL;
return result;
}

View File

@ -1,13 +0,0 @@
#include "wrap.h"
#include <unistd.h>
int
m3_dup2(int oldd, int newd)
{
int result;
ENTER_CRITICAL;
result = dup2(oldd, newd);
EXIT_CRITICAL;
return result;
}

View File

@ -1,14 +0,0 @@
#include "wrap.h"
#include <netdb.h>
struct hostent *
m3_gethostbyaddr(const char *addr, int len, int type)
{
struct hostent *result;
ENTER_CRITICAL;
MAKE_READABLE(addr);
result = gethostbyaddr(addr, len, type);
EXIT_CRITICAL;
return result;
}

View File

@ -1,14 +0,0 @@
#include "wrap.h"
#include <netdb.h>
struct hostent *
m3_gethostbyname(const char *name)
{
struct hostent *result;
ENTER_CRITICAL;
MAKE_READABLE(name);
result = gethostbyname(name);
EXIT_CRITICAL;
return result;
}

View File

@ -1,16 +0,0 @@
#include "wrap.h"
#include <sys/types.h>
#include <sys/socket.h>
int
m3_getpeername(int s, struct sockaddr *name, int *namelen)
{
int result;
ENTER_CRITICAL;
MAKE_WRITABLE(name);
MAKE_WRITABLE(namelen);
result = getpeername(s, name, namelen);
EXIT_CRITICAL;
return result;
}

View File

@ -1,16 +0,0 @@
#include "wrap.h"
#include <sys/types.h>
#include <sys/socket.h>
int
m3_getsockname(int s, struct sockaddr *name, int *namelen)
{
int result;
ENTER_CRITICAL;
MAKE_WRITABLE(name);
MAKE_WRITABLE(namelen);
result = getsockname(s, name, namelen);
EXIT_CRITICAL;
return result;
}

View File

@ -1,14 +0,0 @@
#include "wrap.h"
#include <sys/types.h>
#include <sys/socket.h>
int
m3_listen(int s, int backlog)
{
int result;
ENTER_CRITICAL;
result = listen(s, backlog);
EXIT_CRITICAL;
return result;
}

View File

@ -1,46 +0,0 @@
.Dd October 31, 1996
.Os FreeBSD
.Dt M3SOCKS 1
.Sh NAME
.Nm m3socks
.Nd execute a Modula-3 program using a SOCKS proxy server
.Sh SYNOPSIS
.Nm
.Ar command
.Op Ar arguments
.Sh DESCRIPTION
.Nm
runs
.Ar command
after dynamically linking SOCKS support into its memory image.
The
.Ar command
must be a dynamically linked Modula-3 program.
.Sh ENVIRONMENT
.Nm
exports the environment setting
.Ev M3SOCKS=1
to
.Ar command .
This can be used by
.Ar command
to detect whether it is being run using SOCKS.
.Sh FILES
.Bl -tag -width /usr/local/etc/m3socks.confxx -compact
.It Pa /usr/local/etc/m3socks.conf
SOCKS configuration file.
.El
.Sh SEE ALSO
.Xr m3socks.conf 5
.Sh STANDARDS
.Nm
uses version 4 of the SOCKS protocol.
This protocol is supported by version 4 and version 5 SOCKS servers.
.Sh BUGS
.Nm
has no effect if the
.Ar command
is a set-user-ID or set-group-ID program.
.Sh AUTHORS
John Polstra,
.Aq jdp@polstra.com .

View File

@ -1,256 +0,0 @@
.\" From: /3a/socks/man/RCS/socks.conf.4,v 2.11 1995/05/05 18:05:26 lamont Exp
.Dd May 5, 1995
.Os FreeBSD
.Dt M3SOCKS.CONF 5
.Sh NAME
.Nm m3socks.conf
.Nd configuration file for Modula-3 socks clients
.Sh DESCRIPTION
The Modula-3 SOCKS library reads its configuration information from
.Pa /usr/local/etc/m3socks.conf
when
.Fn bind
or
.Fn connect
is called.
If the file does not exist, then the environment variable
.Ev SOCKS_CONF
is expected to give the name of the configuration file.
.Pp
Each non-blank, non-comment line in the file contains a direction on how
to process requests that match certain criteria.
Comments are denoted by a
.Ql #
at any point in the line prior to the
.Ic : Ns Ar shellcmd ,
if present.
Non-comment lines take the form:
.Pp
.Bl -item -compact
.It
.Ic bind default Ns \*(Ba Ns Ic wild
.It
.Ic domain Ar domain
.It
.Ic nameserver Ar nameserver
.It
.Ic findserver Ar findserver
.It
.Ic sockd
.Op Ic @= Ns Ar server
.Op Ic *= Ns Ar users
.Ar destspec
.Op Ar op Ar dport Op Ar dport2
.Op Ic : Ns Ar shellcmd
.It
.Ic direct
.Op Ic *= Ns Ar users
.Ar destspec
.Op Ar op Ar dport Op Ar dport2
.Op Ic : Ns Ar shellcmd
.It
.Ic deny
.Op Ic *= Ns Ar users
.Ar destspec
.Op Ar op Ar dport Op Ar dport2
.Op Ic : Ns Ar shellcmd
.El
.Pp
Fields are constructed as follows:
.Bl -tag -width Fl
.It Ar domain
The
.Dq local
domain: the default name resolver is assumed to have
information for all hosts in
.Ar domain .
The user can override this field using the
.Ev SOCKS_LOCAL_DOMAIN
environment variable.
To indicate that the default server is able to resolve all addresses,
use the command:
.Ql domain \&. .
.It Ar nameserver
A comma separated list of name servers that are able to resolve addresses
outside of
.Ar domain .
The user can override this field using the
.Ev SOCKS_NS
environment variable.
.It Ar findserver
One of
.Ic Yes
or
.Ic \&No .
The default is
.Ic Yes .
If set, the client will attempt to find the
.Dq best
SOCKS server, based
on the results of looking up
.Ar destnet Ns Ic .socks-addr
(note that this is not an FQDN).
.Ar destnet
consists of the first one, two, or three octets of the destination network,
depending on whether the destination network is class A, B, or C. The octets
are used in reverse order, just like
.Ic IN-ADDR.ARPA .
For example, if the destination address is 129.105.69.100, then a search for
TXT records for '105.129.socks-addr' would be made. If any TXT records are
found, the record is prepended
to the list of servers from the config file. There is no environment
variable to override this.
.Pp
If clear
.Pq Ic findserver Ic \&No ,
then the lookup is not performed.
.It Ar server
A comma separated list of SOCKS servers that can
be used as proxy for this destination. No spaces or tabs are allowed
inside the list. Names beginning with a
.Ql $
are expanded from the users
environment. Each server in the list is tried until a successful
connection is established. When a server has multiple addresses, it
is assumed to be a group of hosts: the address list is randomized and
each address is tried before proceeding to the next name in the list.
The user can override this field using the
.Ev SOCKS_SERVER
environment variable.
.It Ar users
Specifies the users on the requesting host (not the destination host
or server host) to whom this line should apply. This is a comma
separated list of names and/or filenames, with no spaces or tabs.
Filenames must be fully qualified with a leading
.Ql / .
Inside the file, user names may be listed one or several
per line, with spaces, tabs, and commas being valid separators.
The appearance of
.Ql #
marks the remainder of the line as a comment. Each line in a file
is limited to 1023 characters. If
.Ar users
is omitted, the line applies to all users.
.It Ar destspec
The destination specification, which is either
.Ar daddr dmask
or
.Ic *. Ns Ar some.domain ,
which indicates that the line applies to all IP addresses
whose reverse lookup, using
.Fn gethostbyaddr ,
produces a name ending in
.Ql Cm . Ns Ar some.domain .
.It Ar daddr
The destination address to which this line applies. This is
usually specified in dotted form (e.g., 15.28.96.137).
If a hostname is used, then the first address returned by
.Fn gethostbyname
is used.
.It Ar dmask
Mask for
.Ar daddr ,
in dotted form. Bits in
.Ar dmask
which are 0 are ignored in
.Ar daddr .
Specifying 255.255.255.255 requires an exact match, while 0.0.0.0 matches
regardless of the value of
.Ar daddr .
This is the same way netmasks are specified, and is the opposite
of the interpretation used in older versions of SOCKS.
.It Ar op dport Op Ar dport2
A constraint on the destination TCP port.
If
.Ar op
is
.Ic eq ,
.Ic neq ,
.Ic \&lt ,
.Ic gt ,
.Ic le ,
or
.Ic ge ,
the destination port must have the corresponding relation to
.Ar dport .
If
.Ar op
is
.Ic btw ,
the destination port must be between
.Ar dport
and
.Ar dport2 ,
inclusive.
.It Ic : Ns Ar shellcmd
When the line is matched,
.Ar shellcmd
is passed to
.Pa /bin/sh ,
with stdin, stdout, and stderr redirected to
.Pa /dev/null .
The following substitutions occur before the string
is presented to the shell:
.Bl -tag -width \&%Xxx
.It Cm \&%A
replaced by the client host's domainname if known,
by its IP address otherwise.
.It Cm \&%a
replaced by the client host's IP address.
.It Cm \&%c
replaced by
.Ql connect
or
.Ql bind .
.It Cm \&%p
replaced by the process id of the client program.
.It Cm \&%S
replaced by the service name (e.g., ftp) if known,
by the destination port number otherwise.
.It Cm \&%s
replaced by the destination port number.
.It Cm \&%U
replaced by the user-id at login.
.It Cm \&%u
replaced by the effective user-id.
.It Cm \&%Z
replaced by the destination host's domainname if known,
by its IP address otherwise.
.It Cm \&%z
replaced by the destination host's IP address.
.It Cm \&%%
replaced by a single
.Ql \&% .
.El
.El
.Sh EXAMPLES
All connections to net 15 are local:
.Dl Ic direct 15.0.0.0 255.0.0.0
.Pp
Deny all requests destined for hosts on network 23:
.Dl Ic deny 23.0.0.0 255.0.0.0
.Pp
Use the server my-server for hosts on network 36:
.Dl Ic sockd @=my-server 36.0.0.0 255.0.0.0
.Pp
A typical complete configuration file:
.Bd -literal -offset indent
# The default name server is used for addresses inside
# the FreeBSD.org domain.
domain FreeBSD.org
# ns.FreeBSD.org is used as the name server for addresses
# outside FreeBSD.org.
nameserver ns.FreeBSD.org
# Don't find socks servers automatically.
findserver No
# All local connections are direct.
direct *.FreeBSD.org
# All other connections use the SOCKS server
# on socks.FreeBSD.org.
sockd @=socks.FreeBSD.org 0.0.0.0 0.0.0.0
.Ed
.Sh SEE ALSO
.Xr m3socks 1
.Sh AUTHORS
SOCKS was developed by David Koblas and Ying-Da Lee.
The HP enhancements were done by LaMont Jones.

View File

@ -1,10 +0,0 @@
#! /bin/sh
if [ $# -eq 0 ]; then
echo "Usage: $0 command [arguments]" >&2
exit 2
fi
export M3SOCKS=1
export LD_PRELOAD=/usr/local/lib/m3/FreeBSD2/libm3socks.so
exec "$@"

View File

@ -1,27 +0,0 @@
Index: SOCKS-SOURCE/h/socksdef.h
--- SOCKS-SOURCE/h/socksdef.h.orig Wed Aug 7 19:25:31 1996
+++ SOCKS-SOURCE/h/socksdef.h Wed Oct 30 21:05:37 1996
@@ -15,9 +15,11 @@
#define P_(x) ()
#endif /* ! ANSI C */
+#ifndef __FreeBSD__
extern int syslog P_((int , const char *, ...));
extern int openlog P_((const char *, int , int ));
extern int closelog P_((void));
+#endif
#define LOG_LOW LOG_NOTICE
#define LOG_HIGH LOG_ERR
@@ -34,9 +36,9 @@
#define INETD_SEC "/var/adm/inetd.sec"
#define DEFAULT_DEST "/opt/socks/bin" /* for socksify */
#else /* ! V4FS */
-#define SOCKD_DUMP_FILE "/usr/tmp/sockd.conf.dump"
+#define SOCKD_DUMP_FILE "/var/tmp/sockd.conf.dump"
#define SOCKD_CONF "/usr/local/etc/sockd.conf"
-#define SOCKS_CONF "/etc/socks.conf"
+#define SOCKS_CONF "/usr/local/etc/m3socks.conf"
#define OTHER_SOCKS_CONF "/usr/local/etc/socks.conf"
#define INETD_SEC "/usr/adm/inetd.sec"
#define DEFAULT_DEST "." /* for socksify */

View File

@ -1,249 +0,0 @@
Index: SOCKS-SOURCE/client/Xconnect.c
diff -r -u SOCKS-SOURCE/client/Xconnect.c socks-jdp/client/Xconnect.c
--- SOCKS-SOURCE/client/Xconnect.c Wed Aug 7 19:25:51 1996
+++ socks-jdp/client/Xconnect.c Thu Oct 24 21:35:47 1996
@@ -24,7 +24,9 @@
#include <netdb.h>
#include <arpa/nameser.h>
int res_init PARAM((void));
+#ifndef __FreeBSD__
int res_search PARAM((char*,int,int,u_char*,int));
+#endif
int dn_skipname PARAM((u_char*,u_char*));
#include <arpa/inet.h>
#include <resolv.h>
@@ -39,6 +41,10 @@
#include "bytes.h"
#include "check_user.h"
+#ifndef FIOSNBIO
+# define FIOSNBIO FIONBIO
+#endif
+
unsigned char _SOCKS_version=SOCKS_VERSION;
char *socks_dst_serv=NULL, *socks_dst_name=NULL;
@@ -102,6 +108,8 @@
struct info *l; /* must be first field */
int snum;
unsigned short type;
+ int connect_done:8;
+ int bind_done:8;
int sin_valid:8;
int peer_valid:8;
struct sockaddr_in sin;
@@ -185,16 +193,34 @@
#ifndef INTERNAL_ONLY
if (_SOCKS_external) {
u_short port;
+ int status, oldf;
+
+ oldf = -1;
+ status = 0;
+ while (1)
+ {
+ if ((oldf = fcntl(s, F_GETFL, NULL)) == -1)
+ {
+ break;
+ }
+ (void)fcntl(s, F_SETFL, oldf&~(O_NDELAY|O_NONBLOCK));
if (_SOCKS_read(s,&net.version,sizeof(net.version)) < -1)
- return -1;
+ break;
if (_SOCKS_read(s,&net.cmd,sizeof(net.cmd)) < -1)
- return -1;
+ break;
if (_SOCKS_read(s,&port,sizeof(port)) < -1)
- return -1;
- net.port=port;
+ break;
+ net.port = port;
if (_SOCKS_read(s,&net.host,sizeof(net.host)) < -1)
- return -1;
- } else
+ break;
+ status = 1;
+ break;
+ }
+ if (oldf != -1)
+ (void)fcntl(s, F_SETFL, oldf);
+ if (!status)
+ return (-1);
+ } else
#endif /* INTERNAL_ONLY */
{
if (_SOCKS_read(s,&net,sizeof(net)) < -1)
@@ -297,6 +323,12 @@
if (s>=0 && af == AF_INET) {
(void)add_sock(s,NULL,type);
+#if 1
+ bval = size;
+ blen = sizeof(bval);
+ (void)setsockopt(s,SOL_SOCKET,SO_RCVBUF,&bval,blen);
+ (void)setsockopt(s,SOL_SOCKET,SO_SNDBUF,&bval,blen);
+#else
if (getsockopt(s,SOL_SOCKET,SO_RCVBUF,&bval,&blen)==0 && bval<size) {
bval=size;
(void)setsockopt(s,SOL_SOCKET,SO_RCVBUF,&bval,blen);
@@ -305,6 +337,7 @@
bval=size;
(void)setsockopt(s,SOL_SOCKET,SO_SNDBUF,&bval,blen);
}
+#endif
}
return s;
}
@@ -380,6 +413,7 @@
oldf=fcntl(sock,F_GETFL,NULL);
(void)fcntl(sock,F_SETFL,oldf&~(O_NDELAY|O_NONBLOCK));
(void)ioctl(sock,FIOSNBIO,0);
+ errno = 0;
if (Xconnect(sock, sin, sizeof(struct sockaddr_in)) == 0) {
if (SendDst(sock, dst) < 0) {
ret_val=-1;
@@ -389,6 +423,7 @@
lastSocksHost=sin->sin_addr.s_addr;
lastSocksPort=sin->sin_port;
*dst=mydst;
+ (void)fcntl(sock,F_SETFL,oldf);
return 0;
} else {
errno=ECONNREFUSED;
@@ -402,7 +437,7 @@
exit(1);
}
Xclose(new_sock);
-
+ (void)fcntl(sock,F_SETFL,oldf);
return ret_val;
}
#ifdef PROTOTYPES
@@ -605,6 +640,12 @@
l->sin.sin_family = AF_INET;
l->sin_valid = 1;
+ if (type == SOCKS_CONNECT) {
+ l->connect_done = 1;
+ } else if (type == SOCKS_BIND) {
+ l->bind_done = 1;
+ }
+
return 0;
break;
default:
@@ -627,9 +668,20 @@
struct sockaddr_in *sin=(struct sockaddr_in *)usin;
if (size == sizeof(struct sockaddr_in) && sin->sin_family == AF_INET) {
+ register infot *l=find_sock(sock);
_SOCKS_last_connect=*sin;
- return _SOCKS_cbind(sock,sin,size,
- sin->sin_addr.s_addr,SOCKS_CONNECT);
+ if (l == NULL || !l->connect_done) {
+ return _SOCKS_cbind(sock,sin,size,
+ sin->sin_addr.s_addr,
+ SOCKS_CONNECT);
+ l=find_sock(sock);
+ if (l) {
+ l->connect_done = 1;
+ }
+ } else {
+ errno = EISCONN;
+ return -1;
+ }
} else {
register infot *l=find_sock(sock);
if (l!=NULL)
@@ -713,10 +765,10 @@
}
#ifdef PROTOTYPES
-int Rrecvfrom(int s,char *m,int len,int f,struct sockaddr_in *from,int *size)
+int Rrecvfrom(int s,char *m,size_t len,int f,struct sockaddr_in *from,int *size)
#else
int Rrecvfrom(s,m,len,f,from,size)
-int s;char *m;int len;int f;struct sockaddr_in *from;int *size;
+int s;char *m;size_t len;int f;struct sockaddr_in *from;int *size;
#endif
{
infot *l=find_sock(s);
@@ -758,10 +810,10 @@
}
#ifdef PROTOTYPES
-int Rrecv(int s,char *m,int len,int f)
+int Rrecv(int s,char *m,size_t len,int f)
#else
int Rrecv(s,m,len,f)
-int s;char *m;int len;int f;
+int s;char *m;size_t len;int f;
#endif
{
struct sockaddr_in from;
@@ -771,10 +823,10 @@
}
#ifdef PROTOTYPES
-int Rsendto(int s,char *m,int len,int f,struct sockaddr_in *to,int size)
+int Rsendto(int s,char *m,size_t len,int f,struct sockaddr_in *to,int size)
#else
int Rsendto(s,m,len,f,to,size)
-int s;char *m;int len;int f;struct sockaddr_in *to;int size;
+int s;char *m;size_t len;int f;struct sockaddr_in *to;int size;
#endif
{
infot *l=find_sock(s);
@@ -805,10 +857,10 @@
return _SOCKS_write(s,m,len);
}
#ifdef PROTOTYPES
-int Rsend(int s,char *m,int len,int f)
+int Rsend(int s,char *m,size_t len,int f)
#else
int Rsend(s,m,len,f)
-int s;char *m;int len;int f;
+int s;char *m;size_t len;int f;
#endif
{
infot *l=find_sock(s);
@@ -877,17 +929,28 @@
fd_set fds;
Socks_t dst;
infot *l=find_sock(sock);
+ int nfds;
+ struct timeval timeout, *tptr=NULL;
+ int flags;
+ errno = 0;
if (l == NULL || !l->sin_valid)
return Xaccept(sock,sin,size);
/* if we found the entry, bind or connect was called, so no
SOCKSinit is needed. */
+ flags = fcntl(sock, F_GETFL, 0);
+ if (flags != -1 && (flags & O_NONBLOCK)) {
+ timeout.tv_sec = 0;
+ timeout.tv_usec = 0;
+ tptr = &timeout;
+ }
+
FD_ZERO(&fds);
FD_SET(sock, &fds);
- if (select(sock+1, (int*)&fds, NULL, NULL, NULL) > 0)
+ if ((nfds = select(sock+1, &fds, NULL, NULL, tptr)) > 0) {
if (FD_ISSET(sock, &fds)) {
if (GetDst(sock, &dst) < 0)
return -1;
@@ -901,6 +964,9 @@
return dup(sock);
}
+ }
+ if (nfds == 0)
+ errno = EWOULDBLOCK;
return -1;
}
#ifdef PROTOTYPES

View File

@ -1,15 +0,0 @@
#include "wrap.h"
#include <sys/types.h>
#include <unistd.h>
ssize_t
m3_read(int d, void *buf, size_t nbytes)
{
int result;
ENTER_CRITICAL;
MAKE_WRITABLE(buf);
result = read(d, buf, nbytes);
EXIT_CRITICAL;
return result;
}

View File

@ -1,15 +0,0 @@
#include "wrap.h"
#include <sys/types.h>
#include <sys/socket.h>
ssize_t
m3_recv(int s, void *buf, size_t len, int flags)
{
int result;
ENTER_CRITICAL;
MAKE_WRITABLE(buf);
result = recv(s, buf, len, flags);
EXIT_CRITICAL;
return result;
}

View File

@ -1,18 +0,0 @@
#include "wrap.h"
#include <sys/types.h>
#include <sys/socket.h>
ssize_t
m3_recvfrom(int s, void *buf, size_t len, int flags,
struct sockaddr *from, int *fromlen)
{
int result;
ENTER_CRITICAL;
MAKE_WRITABLE(buf);
MAKE_WRITABLE(from);
MAKE_WRITABLE(fromlen);
result = recvfrom(s, buf, len, flags, from, fromlen);
EXIT_CRITICAL;
return result;
}

View File

@ -1,20 +0,0 @@
#include "wrap.h"
#include <sys/types.h>
#include <sys/time.h>
#include <unistd.h>
int
m3_select(int nfds, fd_set *readfds, fd_set *writefds,
fd_set *exceptfds, struct timeval *timeout)
{
int result;
ENTER_CRITICAL;
MAKE_WRITABLE(readfds);
MAKE_WRITABLE(writefds);
MAKE_WRITABLE(exceptfds);
MAKE_READABLE(timeout);
result = select(nfds, readfds, writefds, exceptfds, timeout);
EXIT_CRITICAL;
return result;
}

View File

@ -1,15 +0,0 @@
#include "wrap.h"
#include <sys/types.h>
#include <sys/socket.h>
ssize_t
m3_send(int s, const void *msg, size_t len, int flags)
{
int result;
ENTER_CRITICAL;
MAKE_READABLE(msg);
result = send(s, msg, len, flags);
EXIT_CRITICAL;
return result;
}

View File

@ -1,17 +0,0 @@
#include "wrap.h"
#include <sys/types.h>
#include <sys/socket.h>
ssize_t
m3_sendto(int s, const void *msg, size_t len, int flags,
const struct sockaddr *to, int tolen)
{
int result;
ENTER_CRITICAL;
MAKE_READABLE(msg);
MAKE_READABLE(to);
result = sendto(s, msg, len, flags, to, tolen);
EXIT_CRITICAL;
return result;
}

View File

@ -1,14 +0,0 @@
#include "wrap.h"
#include <sys/types.h>
#include <sys/socket.h>
int
m3_shutdown(int s, int how)
{
int result;
ENTER_CRITICAL;
result = shutdown(s, how);
EXIT_CRITICAL;
return result;
}

View File

@ -1,14 +0,0 @@
#include "wrap.h"
#include <sys/types.h>
#include <sys/socket.h>
int
m3_socket(int domain, int type, int protocol)
{
int result;
ENTER_CRITICAL;
result = socket(domain, type, protocol);
EXIT_CRITICAL;
return result;
}

View File

@ -1,6 +0,0 @@
/*
* Define 0 or 1 of these, to select the variety of SOCKS support you want.
*/
#define HPSOCKS
#undef SOCKS4
#undef SOCKS5

View File

@ -1,61 +0,0 @@
#include "socksconf.h"
#if defined(HPSOCKS) /* { */
#define accept Raccept
#define bind Rxbind
#define close Rclose
#define connect Rconnect
#define dup Rdup
#define dup2 Rdup2
#define gethostbyaddr Rgethostbyaddr
#define gethostbyname Rgethostbyname
#define getpeername Rgetpeername
#define getsockname Rgetsockname
#define listen Rlisten
#define recv Rrecv
#define recvfrom Rrecvfrom
#define send Rsend
#define sendto Rsendto
#define shutdown Rshutdown
#define socket Rsocket
#elif defined(SOCKS4) /* } { */
#define accept Raccept
#define bind Rbind
#define connect Rconnect
#define getpeername Rgetpeername
#define getsockname Rgetsockname
#define listen Rlisten
#define select Rselect
#elif defined(SOCKS5) /* } { */
#define accept SOCKSaccept
#define bind SOCKSbind
#define close SOCKSclose
#define connect SOCKSconnect
#define dup SOCKSdup
#define dup2 SOCKSdup2
#define fclose SOCKSfclose
#define gethostbyname SOCKSgethostbyname
#define getpeername SOCKSgetpeername
#define getsockname SOCKSgetsockname
#define listen SOCKSlisten
#define read SOCKSread
#define recv SOCKSrecv
#define recvfrom SOCKSrecvfrom
#define rresvport SOCKSrresvport
#define select SOCKSselect
#define send SOCKSsend
#define sendto SOCKSsendto
#define shutdown SOCKSshutdown
#define write SOCKSwrite
#endif /* } */
extern int RT0u__inCritical;
#define ENTER_CRITICAL RT0u__inCritical++
#define EXIT_CRITICAL RT0u__inCritical--
static char RTHeapDepC__c;
#define MAKE_READABLE(x) \
if ((int)x) { RTHeapDepC__c = *(char*)(x); }
#define MAKE_WRITABLE(x) \
if ((int)x) { *(char*)(x) = RTHeapDepC__c = *(char*)(x); }

View File

@ -1,15 +0,0 @@
#include "wrap.h"
#include <sys/types.h>
#include <unistd.h>
size_t
m3_write(int fd, const void *buf, int nbytes)
{
int result;
ENTER_CRITICAL;
MAKE_READABLE(buf);
result = write(fd, buf, nbytes);
EXIT_CRITICAL;
return result;
}

View File

@ -1 +0,0 @@
SOCKS support for Modula-3 programs

View File

@ -1,7 +0,0 @@
This provides SOCKS support for Modula-3 network applications. It is
based on the H-P SOCKS library, with modifications developed by Darryl
Okahata to support Modula-3's thread package. It uses version 4 of the
SOCKS protocol, which is compatible with both version 4 and version 5
SOCKS servers.
jdp@freebsd.org

View File

@ -1,3 +0,0 @@
bin/m3socks
lib/m3/FreeBSD2/libm3socks.so
@exec if [ ! -f %D/etc/m3socks.conf ]; then echo "Please create a configuration file in %D/etc/m3socks.conf"; echo "Read m3socks.conf(5) for details"; fi

View File

@ -1,13 +0,0 @@
#! /bin/sh
files="SOCKS-SOURCE/h/socksdef.h \
m3socks/m3socks.sh \
m3socks/m3socks.1 \
m3socks/m3socks.conf.5"
cd ${WRKSRC}
for i in ${files}; do
test -f $i.bak || cp $i $i.bak
chmod +w $i
sed "s|/usr/local/|${PREFIX}/|g" $i.bak > $i && rm -f $i.bak
done