diff options
author | tron <tron@pkgsrc.org> | 1998-02-24 00:20:30 +0000 |
---|---|---|
committer | tron <tron@pkgsrc.org> | 1998-02-24 00:20:30 +0000 |
commit | e7926bb1df4a683ca65bd7e7531707afb1f78709 (patch) | |
tree | 3a91849cf15f4b5d7b6a929cd6f0cb7a00d407e4 /sysutils/socket | |
parent | 06ef01b602326edbfe21f0928ad10169ca0cf7a9 (diff) | |
download | pkgsrc-e7926bb1df4a683ca65bd7e7531707afb1f78709.tar.gz |
Initial import of FreeBSD's "socket" port.
Diffstat (limited to 'sysutils/socket')
-rw-r--r-- | sysutils/socket/Makefile | 17 | ||||
-rw-r--r-- | sysutils/socket/files/md5 | 1 | ||||
-rw-r--r-- | sysutils/socket/patches/patch-aa | 218 | ||||
-rw-r--r-- | sysutils/socket/pkg/COMMENT | 1 | ||||
-rw-r--r-- | sysutils/socket/pkg/DESCR | 146 | ||||
-rw-r--r-- | sysutils/socket/pkg/PLIST | 2 |
6 files changed, 385 insertions, 0 deletions
diff --git a/sysutils/socket/Makefile b/sysutils/socket/Makefile new file mode 100644 index 00000000000..583ecc6e114 --- /dev/null +++ b/sysutils/socket/Makefile @@ -0,0 +1,17 @@ +# New ports collection makefile for: socket +# Version required: 1.1 +# Date created: 14 August 1996 +# Whom: wosch +# +# $FreeBSD Id: Makefile,v 1.7 1997/08/16 10:14:56 wosch Exp +# + +DISTNAME= socket-1.1 +CATEGORIES= sysutils net +MASTER_SITES= http://www.freebsd.org/~wosch/src/ + +MAINTAINER= wosch@FreeBSD.org + +MAN1= socket.1 + +.include <bsd.port.mk> diff --git a/sysutils/socket/files/md5 b/sysutils/socket/files/md5 new file mode 100644 index 00000000000..966c04f46f1 --- /dev/null +++ b/sysutils/socket/files/md5 @@ -0,0 +1 @@ +MD5 (socket-1.1.tar.gz) = 708ac32dcaef8ae4e82b01a563c6c1c5 diff --git a/sysutils/socket/patches/patch-aa b/sysutils/socket/patches/patch-aa new file mode 100644 index 00000000000..6b0cc1de704 --- /dev/null +++ b/sysutils/socket/patches/patch-aa @@ -0,0 +1,218 @@ +--- Makefile.orig Thu Sep 10 16:59:31 1992 ++++ Makefile Wed Aug 14 16:57:57 1996 +@@ -43,7 +43,8 @@ + ### CDC 4680 EP/IX: (I know it *has* setsid(2), but not with bsd43) + # SWITCHES = -systype bsd43 -DNOSETSID + +- ++# FreeBSD 2.x (4.4BSD) ++SWITCHES=-DHAVE_SYS_PARAM_H -Wall + + ### It should not be necessary to change anything below this line. + ################################################################## +--- README.orig Wed Sep 9 16:45:16 1992 ++++ README Wed Aug 14 16:57:58 1996 +@@ -166,4 +166,4 @@ + 1000 Berlin 10 + Germany + +- <nickel@cs.tu-berlin.de> ++Juergen Nickelsen <jn@berlin.snafu.de> +--- globals.h.orig Sun Aug 30 21:04:27 1992 ++++ globals.h Wed Aug 14 16:57:58 1996 +@@ -8,6 +8,11 @@ + */ + + #include "patchlevel.h" ++ ++#if HAVE_SYS_PARAM_H ++# include <sys/param.h> ++#endif ++ + + /* globals for socket */ + +@@ -49,4 +54,7 @@ + extern int crlfflag ; + extern int active_socket ; + extern char *progname ; +-extern char *sys_errlist[], *sys_siglist[] ; ++ ++#if !(defined(BSD) && (BSD >=199306)) ++ extern char *sys_errlist[], *sys_siglist[] ; ++#endif +--- io.c.orig Sun Aug 30 19:15:26 1992 ++++ io.c Wed Aug 14 16:57:58 1996 +@@ -16,6 +16,8 @@ + #endif + #include <errno.h> + #include <stdio.h> ++#include <string.h> ++#include <unistd.h> + #include "globals.h" + + /* read from from, write to to. select(2) has returned, so input +@@ -90,7 +92,7 @@ + + /* all IO to and from the socket is handled here. The main part is + * a loop around select(2). */ +-do_io() ++void do_io() + { + fd_set readfds ; + int fdset_width ; +--- siglist.c.orig Sun Aug 30 15:50:48 1992 ++++ siglist.c Wed Aug 14 16:57:58 1996 +@@ -32,12 +32,18 @@ + # endif /* !_NSIG */ + #endif /* !NSIG */ + +-char *sys_siglist[NSIG]; ++#if HAVE_SYS_PARAM_H ++# include <sys/param.h> ++#endif + ++#if !(defined(BSD) && (BSD >=199306)) ++char *sys_siglist[NSIG]; ++#endif + extern *malloc (); + +-initialize_siglist () ++void initialize_siglist () + { ++#if !(defined(BSD) && (BSD >=199306)) + register int i; + + for (i = 0; i < NSIG; i++) +@@ -219,4 +225,5 @@ + sprintf (sys_siglist[i], "Unknown Signal #%d", i); + } + } ++#endif /* !(defined(BSD) && (BSD >=199306)) */ + } +--- socket.1.orig Wed Sep 9 16:38:19 1992 ++++ socket.1 Wed Aug 14 16:57:58 1996 +@@ -158,4 +158,4 @@ + .SH VERSION + This manual page describes Socket\-1.1. + .SH AUTHOR +-Juergen Nickelsen <nickel@cs.tu-berlin.de> ++Juergen Nickelsen <jn@berlin.snafu.de> +--- socket.c.orig Wed Sep 9 16:14:34 1992 ++++ socket.c Wed Aug 14 16:57:59 1996 +@@ -18,6 +18,8 @@ + #else + #include <string.h> + #endif ++#include <stdlib.h> ++#include <unistd.h> + #include "globals.h" + + /* global variables */ +@@ -37,6 +39,8 @@ + void server A((int port, char *service_name)) ; + void handle_server_connection A((void)) ; + void client A((char *host, int port, char *service_name)) ; ++extern void init_signals A((void)) ; ++extern void do_io A((void)) ; + + int main(argc, argv) + int argc ; +@@ -46,7 +50,7 @@ + int opt ; /* option character */ + int error = 0 ; /* usage error occurred */ + extern int optind ; /* from getopt() */ +- char *host ; /* name of remote host */ ++ /* char *host ; */ /* name of remote host */ + int port ; /* port number for socket */ + char *service_name ; /* name of service for port */ + +@@ -58,7 +62,7 @@ + + /* set up progname for later use */ + progname = argv[0] ; +- if (cp = strrchr(progname, '/')) progname = cp + 1 ; ++ if ((cp = strrchr(progname, '/'))) progname = cp + 1 ; + + /* parse options */ + while ((opt = getopt(argc, argv, "bcflp:qrsvw?")) != -1) { +@@ -185,15 +189,15 @@ + long norder ; + char dotted[20] ; + +- he = gethostbyaddr(&sa.sin_addr.s_addr, ++ he = gethostbyaddr((char *)&sa.sin_addr.s_addr, + sizeof(sa.sin_addr.s_addr), AF_INET) ; + if (!he) { + norder = htonl(sa.sin_addr.s_addr) ; + sprintf(dotted, "%d.%d.%d.%d", +- (norder >> 24) & 0xff, +- (norder >> 16) & 0xff, +- (norder >> 8) & 0xff, +- norder & 0xff) ; ++ (int)((norder >> 24) & 0xff), ++ (int)((norder >> 16) & 0xff), ++ (int)((norder >> 8) & 0xff), ++ (int)(norder & 0xff)) ; + } + fprintf(stderr, "connection from %s\n", + (he ? he->h_name : dotted)) ; +--- socketp.c.orig Sun Aug 9 03:41:42 1992 ++++ socketp.c Wed Aug 14 16:57:59 1996 +@@ -11,10 +11,16 @@ + #include <sys/socket.h> + #include <sys/errno.h> + #include <netinet/in.h> ++#include <arpa/inet.h> + #include <netdb.h> + #include <stdio.h> ++#include <stdlib.h> ++#include <string.h> ++#include <unistd.h> + #include "globals.h" + ++extern int is_number A((char *)); ++ + /* + * create a server socket on PORT accepting QUEUE_LENGTH connections + */ +@@ -52,7 +58,7 @@ + { + struct sockaddr_in sa ; + struct hostent *hp ; +- int a, s ; ++ int s ; + long addr ; + + +@@ -76,7 +82,7 @@ + if ((s = socket(sa.sin_family, SOCK_STREAM, 0)) < 0) { /* get socket */ + return -1 ; + } +- if (connect(s, &sa, sizeof(sa)) < 0) { /* connect */ ++ if (connect(s, (struct sockaddr *)&sa, sizeof(sa)) < 0) { /* connect */ + close(s) ; + return -1 ; + } +--- utils.c.orig Wed Sep 9 16:31:16 1992 ++++ utils.c Wed Aug 14 16:57:59 1996 +@@ -25,8 +25,10 @@ + #else + #include <sys/resource.h> + #endif ++#include <unistd.h> + #include "globals.h" + ++extern void initialize_siglist A((void)) ; + + /* Signal handler, print message and exit */ + SIG_HANDLER_RET exitsig(sig) +@@ -70,7 +72,7 @@ + + /* set up signal handling. All except TSTP, CONT, CLD, and QUIT + * are caught with exitsig(). */ +-init_signals() ++void init_signals() + { + int i ; + #ifdef SIG_SETMASK /* only with BSD signals */ diff --git a/sysutils/socket/pkg/COMMENT b/sysutils/socket/pkg/COMMENT new file mode 100644 index 00000000000..79c5385bb94 --- /dev/null +++ b/sysutils/socket/pkg/COMMENT @@ -0,0 +1 @@ +create tcp socket and connect to stdin/out diff --git a/sysutils/socket/pkg/DESCR b/sysutils/socket/pkg/DESCR new file mode 100644 index 00000000000..ba54719621b --- /dev/null +++ b/sysutils/socket/pkg/DESCR @@ -0,0 +1,146 @@ +This is the README file for Socket-1.1. + +What is it? + +The program Socket implements access to TCP sockets from shell level. +First written for the need to open a server socket and read and write +to the socket interactively for testing purposes, it quickly evolved +into a generic tool providing the socket interface for shell script +and interactive use. + + +Client mode + +In client mode (which is the default) it connects to a given port at a +given host. Data read from the socket is written to stdout, data read +from stdin is written to the socket. When the peer closes the +connection or a signal is received, the program terminates. An +example for this is the following command: + + % socket coma.cs.tu-berlin.de nntp + +This connects to the host coma.cs.tu-berlin.de at the nntp port +(provided these two names can be resolved through gethostbyname(3) and +getservbyname(3)). The user can now issue commands to the NNTP +server, any output from the server is written to the user's terminal. + + +Server mode + +In server mode (indicated by the "-s" command line switch) it binds a +server socket to the given port on the local host and accepts a +connection. When a client connects to this socket, all data read from +the socket is written to stdout, data read from stdin is written to +the socket. For example, the command + + % socket -s 3917 + +accepts a connection on port 3917. + + +Restricting data flow + +It is not always desirable to have data flow in both directions, e.g. +when the program is running in the background, it would be stopped if +it tried to read from the terminal. So the user can advise the program +only to read from the socket ("-r") or only to write to the socket +("-w"). Especially when Socket executes a program (see below), it is +important *not* to write to the program's stdin if the program doesn't +read it. This is the main reason why I added this option. + + +Closing connection on EOF + +For non-interactive use it is not always clear when to close the +network connection; this is still an unsolved problem. But often it +will be enough to close the connection when some data has been written +to the socket. In this case the "quit" switch ("-q") can be used: +when an end-of-file condition on stdin occurs, Socket closes the +connection. + + +Executing a program + +An interesting use of a server socket is to execute a program when a +client connects to it. This done with the "-p" switch. Stdin, +stdout, and stderr of the program are read from resp. written to the +socket. Since the server is usually expected to accept another +connection after a connection has been closed, the "loop" switch +("-l") makes it do exactly that. + + +CRLF conversion + +The Internet protocols specify a CRLF sequence (Carriage Return +Linefeed) to terminate a line, whereas UNIX uses only a single LF. If +the user specifies the "crlf" switch ("-c"), all CRLF sequences that +are read from the socket are converted to a single LF on output. All +single LFs on input are converted to a CRLF sequence when written to +the socket. + + +Background mode + +It may be desirable for a server program to run in background. For +that purpose the "background" switch ("-b") is provided. If it is +set, Socket runs in background, detaches itself from the controlling +tty, closes the file descriptors associated with the tty, and changes +it current directory to the root directory. It is still possible to +redirect the standard file descriptors to a file. + + +Forking child to handle connection + +Often one wants the server to be able to respond to another client +immediately, even before the connection to the previous client has +been closed. For this case, Socket can fork a client to handle a +connection while the father process already accepts the next +connection. To get this behaviour, specify the "-f" option. + + +With all these options, a typical server call would look like + + % socket -bcfslqp program port + +Gee, I know that's a lot of options for the standard case, but I +really want to make all these things *optional*. + + +Verbose + +At last, there is also a "verbose" option ("-v"). If this option is +specified, a message is given for each opening and closing of a +connection. This is convenient especially in interactive use, but can +also provide some kind of logging. See fingerd.sh for an example. + + +WARNING + +Nothing prevents you from using Socket like this: + + % socket -slqp sh 5678 + +THIS IS DANGEROUS! If your machine is connected to the Internet, +*anyone* on the Internet can connect to this server and issue shell +commands to your shell. These commands are executed with your user +ID. Some people may think of this program as a BAD THING, because it +allows its user to open his machine for world-wide access to all kinds +of malicious crackers, crashers, etc. I don't know if I should +consider this as a real security risk or not. Anyway, it is not my +program which is so dangerous -- anyone with moderate programming +skill can write a something like this. + +Another problem is that any server program that uses Socket may not be +secure. I tried to avoid any holes -- especially that one that made +fingerd vulnerable to the attack of Morris' Internet Worm, but I don't +give any warranty. Also the program run by Socket may have security +holes. + +I would like to hear your opinion about this topic. Do you consider it +a security risk to have a program like Socket around? + +Comments + +Please send any comments, suggestions, bug reports etc. to me: + +Juergen Nickelsen <jn@berlin.snafu.de> diff --git a/sysutils/socket/pkg/PLIST b/sysutils/socket/pkg/PLIST new file mode 100644 index 00000000000..1a28d36992e --- /dev/null +++ b/sysutils/socket/pkg/PLIST @@ -0,0 +1,2 @@ +bin/socket +man/man1/socket.1.gz |