socks4-server-4.3.beta2.orig/ 40755 7657 764 0 6157343077 14317 5ustar martinedvsocks4-server-4.3.beta2.orig/CHANGES100644 7657 764 31432 6155710433 15422 0ustar martinedvVersion 4.3 beta2 of SOCKS, dated June 6, 1996 -Fixed #include's for SunOS 4.1.3/4 and others. ( Chee-Wai Yeung) -Changed Rgethostbyname() to reuse the internal hostent entries. ========================================================= Version 4.3 beta of SOCKS, dated May 8, 1996 -Extended the protocol (now version 4A) to allow client to send the destination's domain name to the server if the client is unable to resolve the name. The server and the SOCKS library are modified to handle the extension. Rgethostbyname() is added to the library to provide easy SOCKSification. Servers using protocol 4A work with clients using protocol 4. Clients using protocol 4A work with servers using protol 4 if the clients can resolve all names. This eliminate the requirement that the clients have to be able to resolve all inetrnal and external domain names. They can now rely on the SOCKS server to resolve domain names that the cleints do not know. -Added use of domain names in the configuration files and the route files. This can drastically simplify (and shorten) the configuration files and reduce program start-up delay. -Added use of frozen configuration files, which are essentially memeory images of parsed configuration files. This also reduces program start-up delay since no parsing is necessary. Added six programs in new subdirectory mkfc to produce frozen configuration files and to list their contents. -Added rsockd, a SOCKSified SOCKS server. This allows a number of SOCKS servers to be strung together or oraganized into a tree or more complicated structures. A request may traverse through more than one SOCKS server before reaching its final destination. -Added NO_RBIND as an option in Makefile. SOCKS servers built with NO_RBIND defined does not support RBIND operation. ftp clients must use PASV mode in order to work with such SOCKS servers. -Dropped TRY_PASV from Makefile. ftp (rftp) now always try PASV mode first. If PASV mode fails and RBIND is supported (i.e., NO_RBIND is not defined), it will try the usual PORT command mode. -Modified the server for the non-multi-homed case so that it sends its own IP address in the DSTIP field in its response to BIND request. This also bypasses the getsockname() bug in linux. -Eliminated use of strtok() in SOCKS library. -Eliminated use of sigprocmask() in sockd.c, which is unnecessary and may cause problems in IRIX systems. (Dave Blob, ) -Dropped support for Rrcmd(). -Eliminated VERSATILE_CLIENTS and SHORTENED_RBIND as options. Both are automatically used and can not be changed. ============================================================ Version 4.2.2 of SOCKS.CSTC, dated August 29, 1995 -Changed 'defined(sony_news)' in rftp/ftp.c to 'defined(BIND_RESOLVER)'. (SAKAI Kiyotaka ) -Added '-DSYSTYPE_SVR4' to OTHER_CFLAGS for irix 4 in Makefile. (Ted E. Keller ) -Added #include in sockd.c for FreeBSD. (Chris Inacio ) -Corrected zombies problem with satnad-alone sockd. (Simon Lockhart , Ian Dunkin , Chuck Murcko , David Mischel ) -Corrected a problem in DoNewBind() of lib/Rconnect.c in which socket 'new' is used before it is created. (david higgins ) -Corrected a typo in read_cconf.c where it should be '=' rather than '=='. (Andrew Morrow ) -Moved the line #including "socks.h" to the end of the #include's. Caused some problems otherwise on some systems. (Stanley Hu ) -Made it possible to do ftp-globbing for AIX 3.2. (Quentin Fennessy ) -Corrected a parameter in setsockopt() in id_open.c for BSDI. (Shin Sato ) -Made it possible to try more than one SOCKS servers for Solaris 2.3. (Haruyuki Kawabe ) -Got rid of a spurious declaration of 'optind' in finger.c. (Sorry, I lost the relevant mail message and can't remember who reported that.) -Added compile-time macro TRY_PASV. With this defined, ftp (rftp) tries to set the ftp server in PASV mode, i.e., it tries to connect to the ftp server for the data connections rather than the usual way of having the server connecting to the client. It reverts back to the usual way if the PASV attempt fails. The code is adapted from that written by Patrick Horgan . ============================================================ General release of version 4.2 of SOCKS.CSTC, dated February 25, 1995 -Fixed a bug in rfinger that caused it to fail on remote servers (Bryan Curnutt) -Avoid variable name collisions with the pre-defined type "quad" (Bryan Curnutt, Hal Pomeranz, Chris Riney, Andreas Siegerti, Paul van_Deurzenq) -Fixed syslog and IP_TOS problems with DG/UX (Bryan Curnutt) -Fixed Rrcmd.c, sockd.c, and SendGetDst.c for ISC port. (Larry Jones) -Minor fix for IRIX 5 port. (Ian Dunkin) -Minor fix for AIX. (Paul van_Deurzen, Matt Ganis) -Added the file SOCKS4.protocol, containing a description of the SOCKS protocol, version 4. ============================================================== Pre-release 3 of version 4.2 of SOCKS.CSTC, dated February 14, 1995 -Got rid of the spurious f after #include in sockd.c. (Everybody had fun with this one.) -Corrected a mistake in argument for gethostname() in telnet.c. (Shin'ichiro Tanaka) -Corrected a mistake in argument for syslog() in sockd.c. (Rob Liebschutz) -Added -l44bsd to definition of RESOLV_LIB for Ultrix 4.4 (Stephen Ma) -Changed declarations for defaultNS, defaultDNAME, and defaultSERVER from arrays to pointers. Apparently IRIX 4 has problems with the previous declarations. (Brad Beach) -Changed #if ... (BSD <= 43) to #if ... (BSD - 43 <= 0). (Larry Jones, Adrian Colley) -Added #include for ISC in finger.c. (Andrew Fullford) -Corrected a couple of || in ftp.c where && should be used instead. (Andrew Fullford) -Corrected a typo and added comments on how to install in SCO portion of the top Makefile. (Thomas Essebier) -Added comments for doing install for SCO. (Thomas Essebier) -Modified Rrcmd.c for SCO. Also modify the code in sockd.c for supporting Rrcmd for SCO. (Thomas Essebier) -Corrected a bug (introduced in 4.2 pre2) which caused rtelnet not to work for OSF/1. (Bryan Curnutt) -Modified the setting for OTHER_FLAGS in LINUX portion of top Makefile. (Brian Clapper) -Added DNS_THROUGH_NIS as another flag to be passed down from top Makefile to the making of libsocks.a. (Paul van_Deurzen) -Changed GetAddr() to avoid calling gethostbyname() unless absolutely necessary. (Fred Stephens, David Blob) -Corrected an oversight in stand-alone sockd; previous version does not carry out actions specified in #BAD_ID: line. -Corrected stand-alone sockd's reaction to SIGUSR1; previous version neglects to list #BAD_ID: and #NO_IDENTD: lines. ==================================================== Pre-release 2 of version 4.2 of SOCKS.CSTC, dated November 21, 1994 -Added DG/UX port. (Brian Curnutt) -Added FreeBSD 1.1.5.1 port. (Brian Curnutt) -Overhauled the ISC 4.0.1 port. (Larry Jones) -Added IRIX 5 port (Ian Dunkin, Chris Riney) -Added macro BIND_RESOLVER in Makefile for systems that don't have h_errno defined in expected places. (Edwin Kremer) -Corrected typos in man pages and comments. (Edwin Kremer) -Deleted a spurious argument in a call to sprintf. (Edwin Kremer) -Changed the way to supress logging on clients. (Edwin Kremer) -Fixed long/int problem for Alpha OSF V1.3 in retlent/commands.c. (Heinz Naef) -Corrected some problems for Linux port. (Cornell Kinderknecht, Craig Metz) -Fixed problem with telnet's handling of repeated interrupts in Solaris and UnixWare. (Brian Clapper) -Fixed opendir() problem for Alpha OSF (David Mischel) -Includes stand-alone sockd as an option. (David Mishel) -Made client read and process socks.conf only once. (David Mischel) -Modified rfinger to work correctly with -l option. (David Blob) -Renamed some functions so that other than the R* functions and SOCKSinit, all other externally visible functions in libsocks.a have names that start with socks_ . ======================================= Pre-release 1 of version 4.2 of SOCKS.CSTC, dated June 30, 1994 -Made consistent use of u_int32 for alpha port. (David Mischel) -Included partial port (server and library) for NextStep 3.2. (William Lewis) -Made clients behave like non-SOCKSified programs if /etc/socks.conf is absent. -Made the printing of client banner controllable using environment variable SOCKS_BANNER. (Bryan Curnutt) -Added compile-time option to disable syslog from clients. (Jason Baietto) -Added DNS_THROUGH_NIS in Makefile to accommodate sites which resolve DNS through their NIS server and have no local /etc/resolv.conf. -Include bsdinstall, a shell script written by Phil Hochstetler, phil@sequent.com, which simulate BSD's install for SYSV systems. ======================================= Beta release of version 4.2 of SOCKS.CSTC, dated March 21, 1994 -Added code to allow use of filenames in the *=userlist field. The filenames must be a complete path (starting with /). Userids and comments can be used in such files. Updated the man pages sockd.conf.5 and socks.conf.5 to document the new feature. -Merged in code to show sockd's usage details in the output of ps commamd. Only works with non-SYSV hosts. (Matt Cohen) ======================================== Beta release of version 4.2 of SOCKS.CSTC, dated February 22, 1994 -Corrected mistakes in determining privileged/non-privileged port. -Dereferenced addr in saddrtoname.c. (Anthony Starks) -Added code to zero out all sockaddr_in structures before using them. (Carlos Mora) -Added code to treat IP address 0.0.0.0 as localhost. (Anthony Shipman) -Added code to save host and port after a successful direct connect. (Ian Dunkin) -Made the facility and the log levels for syslog configurable in socks.h. (Jon Luini) -Made the optimization flag for cc configurable in Makefile. (Craig Metz) -Made SendDst() and GetDst() quit when write() or read() returns 0. (David Nochlin) -Added code to use iotcl(...,FIOSSAIOOWN...) in place of fcntl(...F_SETOWN...) for hpux. (John Brezak) ======================================= Beta release of version 4.2 of SOCKS.CSTC, dated February 9, 1994. Changes since release 4.1 1) Merged in SCO/ODT 2.x and BSDi v1.0 ports by Chris Riney. 2) Merged in PS/2 AIX 1.2.1 port by Craig Metz. 3) Merged in DEC OSF 1.3 port by Alain Mellan. 4) Merged in the code to prevent premature closing of a TCP session on the SOCKS server when the server is much faster than the client host. Contributed by Andy McFadden. 5) Merged in the code for using environment variable SOCKS_DNAME to override the setting of SOCKS_DEFAULT_DNAME. Contributed by Jon Luini. 6) It handles non-blocking connect() call correctly, at least for the way non-blocking connect()'s are done in Mosaic 2.1. This necessitates the addition of Rselect() to the library. 7) You can build libsocks.a with Rbind() which accepts the same calling sequence as regular bind(), i.e., without the extra last argument. 8) Call to SOCKSinit() is made optional. 9) Rrcmd() is optionally added to the library. The combined effect of 6) through 9) is that, for most applications, you can do the SOOCKSification without doing anything to the code at all. Just add -Dconnect=Rconnect -Dbind=Rbind -Dgetsockname=Rgetsockname -Dlisten=Rlisten -Daccept=Raccept -Drcmd=Rrcmd -Dselect=Rselect to cc and make sure the appropriate SOCKS library is used in linking. I hope this will encourage developers to produce SOCKSified version of their applications. (By the way, if you really want that, you should certainly make the effort of letting your friendly software vendors or developers know about it. Customers's demands count a great deal in the software market.) 10) In anticipation of client hosts that can't run identd, a new filed '?=n' is added to the control line for sockd.conf. This enables the use of invoking sockd with -I option to use identd in general but have it turned off for some specific client hosts. (You can also use '?=I' or '?=i' to turn identd on for a line, I just see the use of '?=n' as more likely.) 11) Deliver out-of-band data end to end. 12) Connection to 127.0.0.1 (localhost) is always direct. No more need to specify that in /etc/socks.conf. Ying-Da Lee (214)518-3490 (214)518-3552 (FAX) Principal Member, Technical Staff NEC Systems Laboratory, C&C Software Technology Center / ylee@syl.dl.nec.com socks4-server-4.3.beta2.orig/COPYRIGHTS100644 7657 764 5422 5720234347 16027 0ustar martinedv----------------------------------------------------------------- Copyright (c) 1989 Regents of the University of California. All rights reserved. Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met: 1. Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer. 2. Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution. 3. All advertising materials mentioning features or use of this software must display the following acknowledgement: This product includes software developed by the University of California, Berkeley and its contributors. 4. Neither the name of the University nor the names of its contributors may be used to endorse or promote products derived from this software without specific prior written permission. THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. ----------------------------------------------------------------- Portions Copyright (c) 1993, 1994, 1995 by NEC Systems Laboratory. Permission to use, copy, modify, and distribute this software for any purpose with or without fee is hereby granted, provided that the above copyright notice and this permission notice appear in all copies, and that the name of NEC Systems Laboratory not be used in advertising or publicity pertaining to distribution of the document or software without specific, written prior permission. THE SOFTWARE IS PROVIDED ``AS IS'' AND NEC SYSTEMS LABORATORY DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL NEC SYSTEMS LABORATORY BE LIABLE FOR ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. socks4-server-4.3.beta2.orig/How_to_SOCKSify100644 7657 764 4024 6143512423 17234 0ustar martinedvFour Easy Steps to SOCKSify (Most of) Your Favorite Network Programs For use with SOCKS 4.3 (Ying-Da Lee, ylee@esd.sgi.com or yingda@best.com) =================================================================== 1) Find out if UDP is used in the program by doing "grep SOCK_DGRAM" on all the source files. If any such lines are found (and are not comments), you can't make it work with SOCKS. There is, however, a UDP relayer which is to UDP what SOCKS is to TCP, and you may want to look into it. It is written by Tom Fitzgerald and is available from host ftp.wang.com, file /pub/fitz/udprelay-0.2.tar.Z. 2) At or near the beginning of the main procedure, add this line: SOCKSinit(argv[0]); This step can be omitted. The only consequence is that the generic 'SOCKSclient' rather than the actual client program name will be used in the syslog lines on the client host. 3) Add -Dconnect=Rconnect -Dselect=Rselect -Dgethostbyname=Rgethostbyname -Dgetsockname=Rgetsockname -Dbind=Rbind -Daccept=Raccept -Dlisten=Rlisten (or, on AIX, -Dconnect=Rconnect -Dselect=Rselect -Dgethostbyname=Rgethostbyname -Dngetsockname=Rgetsockname -Dbind=Rbind -Dnaccept=Raccept -Dlisten=Rlisten ) to all cc lines. If Makefile is used, this is simply done by adding the above to the definition of macro CFLAGS. If the application does not use the bind/listen/accept/getsockname sequence to establish passive connections (most don't) or if your SOCKS server does not support RBIND ('sockd -ver' will tell you whether it does or not), you can drop the corresponding definitions for those functions; i.e., end with -Dgethostbyname=Rgethostbyname. 4) Make sure that the appropriate SOCKS library (version 4.2, built with -DSHORTENED_RBIND) is linked in in the ld or the last cc command to produce the executable. That's it for most programs. Build the program and try it, chances are it would work. If it doesn't and you still like to have a SOCKSified version, please read the file What_SOCKS_expects. socks4-server-4.3.beta2.orig/Makefile100644 7657 764 31002 6144762431 16063 0ustar martinedv# Be sure to check the file include/socks.h also and make # modifications as necessary. SHELL=/bin/sh # If you do not want to support bind() function across the firewall, # uncomment the next line. #NO_RBIND=-DNO_RBIND # # Among common applications, only ftp uses bind() and even it # can often work without bind() by using the PASV mode. # The program rftp in this package always uses PASV mode first # and only tries bind() after PASV mode fails. #SOCKS=-Dconnect=Rconnect -Dselect=Rselect -Dgethostbyname=Rgethostbyname # or SOCKS=-Dconnect=Rconnect -Dgetsockname=Rgetsockname -Dlisten=Rlisten -Daccept=Raccept -Dbind=Rbind -Dselect=Rselect -Dgethostbyname=Rgethostbyname # # If NO_RBIND is defined, you MUST use the first definition for SOCKS! # For AIX: accept() and getsockname() are called naccept() and ngetsockname(), # respectively. So you have to modify the SOCKS line above to accommodate # these, i.e., use -Dngetsockname=Rgetsocknam and -Dnaccept=Raccept. # If your system doesn't have PWD defined, define it here: #PWD=/disk2/socks.4.3 # It should be this current directory. # If your system has getcwd() but no getwd(), uncomment the next line: #GETCWD=-DGETCWD #If your system doesn't have waitpid(), uncomment the nextline: #NO_WAITPID=-DNO_WAITPID # Define FASCIST if you want ftp (rftp) to log names of all files transferred #FASCIST=-DFASCIST # Define FOR_PS if your system is not SYSV and you want to have the # command 'ps' show some details of sockd's activity. #FOR_PS=-DFOR_PS # optimization flag for cc OPTIMIZE=-g #OPTIMIZE=-O # Be careful with the OPTIMIZE flag. SunPro's SC2.0.1, for example, is # knwon to produce incorrect code when -O is used. #If your system does not have strdup() function, uncomment the next line: #STRDUP=strdup.o # Define NO_CLIENT_LOG if you don't want SOCKS clients to produce # log entries of its activities. #NO_CLIENT_LOG= -Dopenlog=socks_0openlog -Dsyslog=socks_0syslog -Dcloselog=socks_0closelog # Define DNS_THROUGH_NIS if your SOCKS client hosts let their NIS # servers do the DNS loopkup for them. You are in this category if # your client hosts has no /etc/resolv.conf but can resolve all # internal and external names. #DNS_THROUGH_NIS=-DDNS_THROUGH_NIS # If you get 'herror undefined', 'h_errno undefined', 'herror redefined' # or 'h_errno redefined' error message, # this is the macro to change. Define it or undefine it, whichever # works. The reasons are too messy to explain. #BIND_RESOLVER=-DBIND_RESOLVER # Directory into which to install the man pages MAN_DEST_DIR = /usr/local/man # Directory into which the SOCKS server should be installed SERVER_BIN_DIR = /usr/etc # Directory into the client programs should be installed CLIENTS_BIN_DIR = /usr/local/bin # Directory into which the socks library (libsocks.a) should be installed LIB_DEST_DIR = /usr/local/lib # SunOS 4.1.x should use #CC=cc #CC=gcc #OTHER_CFLAGS= $(GETCWD) $(FASCIST) -DCOMPAT $(DEBUG) $(NO_RBIND) #RANLIB=ranlib #OS=sun4.1 #INSTALL=install #GETPASS=getpass.o #RESOLV_LIB=-lresolv # ... or #RESOLV_LIB= # IRIX 4 should use #CC=cc #RESOLV_LIB=-lsun #OTHER_CFLAGS=-cckr $(GETCWD) $(FASCIST) -DCOMPAT -DSYSTYPE_SVR4 $(NO_RBIND) #RANLIB=/bin/true #OS=irix4 #INSTALL=$(PWD)/bsdinstall #GETPASS=getpass.o # IRIX 5 should use CC=cc RESOLV_LIB= OTHER_CFLAGS=-cckr $(GETCWD) $(FASCIST) -DCOMPAT -DSVR3 -DNCARGS=`sysconf ARG_MAX` -D_BSD_SIGNALS $(NO_RBIND) RANLIB=/bin/true OS=irix5 INSTALL=$(PWD)/bsdinstall GETPASS=getpass.o # Ultrix 4.0 should use #CC=cc #OTHER_CFLAGS= $(GETCWD) $(FASCIST) $(NO_RBIND) #RANLIB=ranlib #OS=ultrix4.0 #INSTALL=install #GETPASS=getpass.o #RESOLV_LIB=-lresolv # Ultrix 4.3 should use the one below instead #RESOLV_LIB= # Ultrix 4.4 should use the one below instead #RESOLV_LIB=-lresolv -l44bsd # HP-UX should use #CC=cc #OTHER_CFLAGS= $(GETCWD) $(FASCIST) -DCOMPAT $(NO_RBIND) #RANLIB=/bin/true #OS=hpux9 #INSTALL=install #GETPASS= #RESOLV_LIB= # HPUX does not allow 'nobody' to be used as the user in /etc/inetd.conf, # unless it has a gid between 0 and 60000, which it normally doe not. So # you either have to use a different user in /etc/inetd.conf or change # the gid of 'nobody'. # RS/6000 AIX 3.2 should use #CC=cc #RESOLV_LIB=-lbsd #OTHER_CFLAGS=-D_BSD -D_NONSTD_TYPES -D_NO_PROTO -DAIX $(GETCWD) $(FASCIST) -DCOMPAT $(NO_RBIND) #RANLIB=ranlib #OS=aix3.2 #INSTALL=$(PWD)/bsdinstall #GETPASS= # PS/2 AIX 1.2 should use #CC=cc #RESOLV_LIB=-lbsd #OTHER_CFLAGS=-D_BSD -D_NONSTD_TYPES -D_NO_PROTO -DAIX $(GETCWD) $(FASCIST) -DCOMPAT -I/usr/local/include -DAIX_PS2 $(NO_RBIND) #RANLIB=ranlib #OS=aix_ps2 #INSTALL=install #GETPASS= # SOLARIS should use #CC=cc #RESOLV_LIB=-lresolv -lnsl -lsocket #OTHER_CFLAGS=-DSOLARIS -Dindex=strchr -Drindex=strrchr -DUSE_DIRENT $(GETCWD) $(FASCIST) -DCOMPAT $(NO_RBIND) #RANLIB=/bin/true #OS=solaris2.2 #INSTALL=install #GETPASS=getpass.o # Interactive Systems Unix should use #OTHER_CFLAGS = -DISC -DSVR3 -Dindex=strchr -Drindex=strrchr -D_XOPEN_SOURCE -DGETCWD $(FASCIST) -DCOMPAT $(NO_RBIND) #CC=cc #RANLIB=: #OS=isc #INSTALL=$(PWD)/bsdinstall #GETPASS= #RESOLV_LIB=-linet -lc_s # netBSD should use #OTHER_CFLAGS = $(GETCWD) $(FASCIST) $(NO_RBIND) #CC=cc #RANLIB=ranlib #OS=netbsd0.9 #INSTALL=install #GETPASS= #RESOLV_LIB= # FreeBSD should use: #CC=cc #OS=freebsd1.1 #RESOLV_LIB= #OTHER_CFLAGS= $(GETCWD) $(FASCIST) $(NO_RBIND) #RANLIB=ranlib #GETPASS= #INSTALL=install # LINUX should use #CC=gcc #RANLIB=ranlib #RESOLV_LIB= # NOTE: Older versions of Linux may need to define the following variable, # as their files do not define "struct linger". #NEED_STRUCT_LINGER = -DNEED_STRUCT_LINGER #OTHER_CFLAGS=-traditional -DLINUX $(GETCWD) $(FASCIST) -DCOMPAT $(NEED_STRUCT_LINGER) -DCONST="" $(NO_RBIND) -DDIRENT_ILLEGAL_ACCESS #OS=linux #INSTALL=install #GETPASS=getpass.o # Additional notes for Linux: # 1) There is a bug in getsockname() which returns address 127.0.0.1 when # the result should be 0.0.0.0. Because of this, the non multi-homed # version of sockd doesn't work. The multi-homed version works fine # and can be used even on a single-homed Linux box. Just set up the # /etc/sockd.route file to direct all traffic through the one and only # interface. # 2) Linux doesn't define user 'nobody' in its distribution. To run sockd on # linux, you must either add 'nobody' (give it minimum privileges) or # run it under an existing userid (i.e., replace 'nobody' in the # /etc/inetd.conf entry by an existing userid). # UnixWare should use #CC=cc #RESOLV_LIB=-lresolv -lnsl -lsocket #OTHER_CFLAGS= -DSOLARIS -Dindex=strchr -Drindex=strrchr -DUSE_DIRENT $(GETCWD) $(FASCIST) -DCOMPAT $(NO_RBIND) #RANLIB=/bin/true #INSTALL=/usr/ucb/install #OS=UnixWare #GETPASS=getpass.o # Alpha OSF should use: #CC=cc #RESOLV_LIB=-lresolv #OS=alphaOSF #OTHER_CFLAGS= $(GETCWD) $(FASCIST) -DCOMPAT $(NO_RBIND) #RANLIB=ranlib #INSTALL=install #GETPASS= # SCO UNIX/ODT should use: #CC=cc #OS=sco #RESOLV_LIB=-lsocket #OTHER_CFLAGS= $(GETCWD) $(FASCIST) -DSCO -DSVR3 -Dindex=strchr -Drindex=strrchr -DUSE_DIRENT $(NO_RBIND) #RANLIB=/bin/true #GETPASS= #You MUST define PWD; see explanation earlier in this file. # >>> Thomas Essebier #SERVER_BIN_DIR = /etc # sco install does not work like 'other' installs. # assuming all calls to install here are: install -m xxx file dir # sco uses the convention: install -c dir -m xxx file # create scoinstall in a directory in the normal path (eg. /usr/local/bin) # its a 1 line script to munge the parameters to fit SCO's conventions # -> install -c $4 $1 $2 $3 #INSTALL=scoinstall # <<< Thomas Essebier # BSD/386 should use: #CC=cc #OS=bsdi #RESOLV_LIB= #OTHER_CFLAGS= $(GETCWD) $(FASCIST) $(NO_RBIND) #RANLIB=ranlib #GETPASS= # BSDI forgot to put appropriate lines in their /usr/include/netinet/in.h # to prevent the code from being processed multiple times. This causes # compiler to complain. You have to fix their oversight by adding # #ifndef _netinet_in_h # #define _netinet_in_h # at the beginning of the file, and adding # #endif # at the end of the file. # NextStep 3.2, SOCKS server and library only # (William Lewis, wiml@omnigroup.com) #CC=cc #OTHER_CFLAGS= $(GETCWD) $(FASCIST) -DCOMPAT $(DEBUG) -Dstrdup=NXCopyStringBuffer $(NO_RBIND) #RANLIB=ranlib #GETPASS=getpass.o #RESOLV_LIB=-lresolv # ... or #RESOLV_LIB= # DG/UX 5.4 should use #CC=cc #RESOLV_LIB= #OTHER_CFLAGS=-DDGUX -DUSE_DIRENT $(GETCWD) $(FASCIST) -DCOMPAT $(NO_RBIND) #RANLIB=/bin/true #OS=dgux5.4 #INSTALL=$(PWD)/bsdinstall #GETPASS= # NewsOS 4.x should use #CC=gcc #OTHER_CFLAGS= $(GETCWD) $(FASCIST) -DCOMPAT $(DEBUG) $(NO_RBIND) #RANLIB=ranlib #OS=newsos4 #INSTALL=install #GETPASS=getpass.o #RESOLV_LIB=-lresolv -l44bsd # !!! Remember to define NO_WAITPID !!! # >>>---------------- Others: # Define RESOLV_LIB if your system doesn't search resolver # library automatically. # Leave it undefined otherwise. #RESOLV_LIB=-lresolv # If your compiler or loader complains about _res_init being # an undefined symbol, then you must define RESOLV_LIB. #RANLIB=ranlib # Systems (e.g., IRIX) that do not need (and thus don't have) ranlib should use #RANLIB=/bin/true # Comment out defintion of GETPASS if your system has problems # compiling it, the version built into your system will then be used. # The getpass() function in most Unix systems truncates passwords # after 8 characters; the version provided here does not. # This only affects ftp with non-anonymous login, and telnet. # Ftp with anonymous login allows long passwords regardless # of whether GETPASS is defined or not. #GETPASS=getpass.o # The 'install' command is assumed to be the BSD variety (using -m to # set the file mode). If the default 'install' on your system doesn't # do that, you have to either specify an alternative one in the line below # (e.g., /usr/ucb/install) or modify the other Makefile. #INSTALL= install # Macro OS is used in making rtelnet. See the list near top of # rtelnet/telnet/Makefile for available choices. # Remember to include -Dindex=strchr -Drindex=strrchr in OTHER_CFLAGS if # you don't have index() and rindex() (Sys-V camp) # <<<---------------- # The Internet Whois server; used to be nic.ddn.mil. WHOIS_SERVER= WHOIS_SERVER=-DWHOIS_SERVER\'=\"rs.internic.net\"\' SOCKS_LIB=$(PWD)/lib/libsocks.a IDENT_LIB=$(PWD)/libident/libident.a #============================================================================== all: LIB LIBIDENT MKFC server clients server: LIB LIBIDENT (cd sockd; $(MAKE) CC="$(CC)" RESOLV_LIB="$(RESOLV_LIB)" \ OPTIMIZE="$(OPTIMIZE)" RANLIB="$(RANLIB)" \ SOCKS_LIB="$(SOCKS_LIB)" \ IDENT_LIB="$(IDENT_LIB)" \ OTHER_CFLAGS="$(OTHER_CFLAGS) $(FOR_PS) $(NO_WAITPID) $(NO_RBIND)") clients: RFINGER RFTP RTELNET LIB: (cd lib; $(MAKE) CC="$(CC)" GETPASS="$(GETPASS)" \ STRDUP="$(STRDUP)" OPTIMIZE="$(OPTIMIZE)" \ OTHER_CFLAGS="$(OTHER_CFLAGS) $(NO_CLIENT_LOG) $(BIND_RESOLVER) $(NO_WAITPID) $(DNS_THROUGH_NIS) $(NO_RBIND)" \ RANLIB="$(RANLIB)") LIBIDENT: (cd libident; $(MAKE) CC="$(CC)" OTHER_CFLAGS="$(OTHER_CFLAGS)" \ OPTIMIZE="$(OPTIMIZE)" RANLIB="$(RANLIB)") # This also build rwhois RFINGER: LIB (cd rfinger; $(MAKE) CC="$(CC)" $(WHOIS_SERVER) \ OPTIMIZE="$(OPTIMIZE)" SOCKS="$(SOCKS)" \ RESOLV_LIB="$(RESOLV_LIB)" SOCKS_LIB="$(SOCKS_LIB)" \ OTHER_CFLAGS="$(OTHER_CFLAGS) $(NO_CLIENT_LOG) $(NO_WAITPID) $(NO_RBIND)") RTELNET: LIB (cd rtelnet; $(MAKE) CC="$(CC)" OS="$(OS)" SOCKS_LIB="$(SOCKS_LIB)" \ OPTIMIZE="$(OPTIMIZE)" SOCKS="$(SOCKS)" \ RESOLV_LIB="$(RESOLV_LIB)" \ OTHER_CFLAGS="$(OTHER_CFLAGS) $(NO_CLIENT_LOG) $(NO_WAITPID) $(NO_RBIND)") RFTP: LIB (cd rftp; $(MAKE) CC="$(CC)" SOCKS_LIB="$(SOCKS_LIB)" \ OPTIMIZE="$(OPTIMIZE)" SOCKS="$(SOCKS)" \ RESOLV_LIB="$(RESOLV_LIB)" \ OTHER_CFLAGS="$(OTHER_CFLAGS) $(NO_CLIENT_LOG) $(BIND_RESOLVER) $(NO_WAITPID) $(NO_RBIND)") MKFC: LIB (cd mkfc; $(MAKE) CC="$(CC)" SOCKS_LIB="$(SOCKS_LIB)" \ RESOLV_LIB="$(RESOLV_LIB)" \ OPTIMIZE="$(OPTIMIZE)" OTHER_CFLAGS="$(OTHER_CFLAGS)" ) install.server: server (cd sockd; $(MAKE) INSTALL="$(INSTALL)" MAN_DEST_DIR="$(MAN_DEST_DIR)" \ SERVER_BIN_DIR="$(SERVER_BIN_DIR)" install install.man) install.clients: RFINGER RFTP RTELNET install.man for i in rfinger rftp rtelnet; do \ (cd $$i ; $(MAKE) INSTALL="$(INSTALL)" \ CLIENTS_BIN_DIR="$(CLIENTS_BIN_DIR)" \ install) done install.mkfc: MKFC (cd mkfc; $(MAKE) INSTALL="$(INSTALL)" \ MKFC_DIR="$(SERVER_BIN_DIR)" install) install.lib: LIB (cd lib; $(MAKE) INSTALL="$(INSTALL)" LIB_DEST_DIR="$(LIB_DEST_DIR)" install) install.man: (cd doc; $(MAKE) INSTALL="$(INSTALL)" MAN_DEST_DIR="$(MAN_DEST_DIR)" \ install) clean: for i in lib libident sockd rfinger rftp rtelnet mkfc; do \ ( cd $$i ; $(MAKE) clean) done socks4-server-4.3.beta2.orig/README.1st120777 7657 764 0 6507210314 20062 2README.4.3.beta2ustar martinedvsocks4-server-4.3.beta2.orig/README.4.0100644 7657 764 30743 5606334256 15620 0ustar martinedvThis is SOCKS, a package consisting of a proxy server (sockd) and client programs corresponding to finger, whois, ftp, telnet, xgopher, and xmosaic, as well as a library module (libsocks.a) for adapting other applications into new client programs. The original SOCKS was written by David Koblas , which included the library module and finger, whois, and ftp clients. Clients programs added since the original are: -telnet: adapted from telnet.91.03.25 by David Borman . This version is supposed to be much easier than the previous one to port to many different systems. -xgopher: adapted from xgopher ver. 1.2 by Allan Tuchman . -xmosaic: adapted from xmosaic ver. 1.2 by NCSA staff (contact Marc Andreesen, ). The SOCKS protocol has changed with this version. Since the server and the clients must use the same SOCKS protocol, this server does not work with clients of previous releases, and these clients do not work with servers of previous releases. The access control mechanism has been expanded: -A list of users can be included along with other fields (source address, destination address, service/port) for permission/denial of access. -Identd is used (controlled by option -i and -I) in SOCKS server to try to verify the actual user-ids. The code uses the library written by Peter Eriksson and /Pär Emanuelsson . -A shell command can optionally be specified with each line. The command is executed if the conditions of that line are satisfied. This is adapted from the same feature and code used in the log_tcp package by Wietse Venema . -Special entries (#NO_IDENTD: and #BAD_ID:) can be included to specify shell commands to be executed when the client host doesn't run identd and when identd's report doesn't agree with what the client prgram says. The following can be a reasonable sockd.conf using the new features: # Permit root on 129.101.64.3 all services permit *=root 129.101.64.3 0.0.0.0 # # Permit root and usersa on 129.101.112.10 telnet access to network 222.22.22 permit *=usera,root 129.101.112.10 0.0.0.0 222.22.22.0 0.0.0.255 eq telnet # # Permit all users on network 129.101 access to ftp permit 129.101.0.0 0.0.255.255 eq ftp # # Deny everything else. Upon an attempt, finger the client host and pipe # the result into an email to root with appropriate Subject line. deny 0.0.0.0 255.255.255.255 : finger @%A | /usr/ucb/mail -s 'SOCKD: rejected -- from %u@%A to host %Z (service %S)' root # # If the client doesn't run identd, tell the user and root there to run it. #NO_IDENTD: /usr/ucb/mail -s 'Please run identd on %A' %u@%A root@%A # # Someone is masquerading as someone else. Finger the client host # and pipe the result into an email message for local root and root on # the client host with appropriate Subject line. #BAD_ID: finger @%A | /usr/ucb/mail -s '%U pretends to be %u on host %A' root@%A root The test_sockd_conf program can be used to test the access control file, including the special entries and the execution of shell commands. The Identd server is available through anonymous ftp from many places. Consult archie. Or you can pick it up from ftp.inoc.dl.nec.com, the file is pub/security/pidentd-2.1.2.tar.gz. This copy corrected a mistake in the INSTALL file: In step 10, second paragraph, the line TELNET session and enter "4711 , 113", where you replace 4711 with the should read TELNET session and enter "113 , 4711", where you replace 4711 with the The author of pidentd is Peter Eriksson (pen@lysator.liu.se). Finally, the network/host byte order confusion has been cleaned up. That should make porting to other systems a lot easier. Only machines for which the assumptions that short=int=16 bits and long=32 bits do not hold are still likely to have serious problems. The package has been ported for ULTRIX 4.3 by Ian Dunkin and Anthony Shipman , for IRIX 4.0.1 by Ian Dunkin (again), and partially for HPUX by Anthony Shipman (again!). (We are a small bunch of busy bees.) I also include patches by Craig Metz to SOCKSize xarchie and ncftp. I have not try these patches out myself though. I want to thank all the people I have mentioned so far, as well as the following, who has helped with their bug reports, comments, and suggestions: Alain Mellan , Heinz Naef , Rejane Forre , Michael Lachowski , Nancy Ball , David Vincenzetti , LaMont Jones , Brandon Butterworth , Richard Schultz . Please read the file 'COPYRIGHTS' before you proceed further. In the following section, by 'top directory' we mean the top directory of the SOCKS package, i.e., the directory you are in right now. ------------------------------------------------------------- HOW TO BUILD THE PROGRAMS 1. Check and modify the following files to suit your systems: Makefile include/socks.h sockd/Makefile libident/Makefile lib/Makefile rfinger/Makefile rftp/Makefile rtelnet/Makefile rxgopher/Makefile rxmosaic/Makefile rxmosaic/libwww/Makefile rxmosaic/libhtmlw/Makefile rxmosaic/src/Makefile Be very careful with the Makefiles of rxgopher and rxmosaic. For rxgopher, the Makefile is an exact copy of Makefile.YDL in the same directory. If you have 'xmkmf' on your system, you may want to use that to generate the Makefile itself. See the comment under the section RXGOPHER in the Makefile in the top directory. The other Makefiles should not require much tweaking. Generally speaking, macros RESOLV_LIB, SOCKS_LIB, IDENT_LIB, CCKR, RANLIB, and INSTALL are defined in the top level Makfile and then passed down to lower level during the make, overriding the settings in the lower-level Makfiles, so you should define them in the top level Makfile and ignore them in other Makefiles. (The redundancy is provided so that you can do a make in the subdirectories. That is not recommended, however.) Be sure that the macro 'SOCKS_DEFAULT_SERVER' in include/sosks.h is set correctly to the host that will be running the proxy server for your site. Although this can be overridden at run time with environment variable SOCKS_SERVER, it is a lot simpler if you put in the right name at compile time. Also be sure to uncomment and set the macro 'SOCKS_DEFAULT_NS' in the same file if yor client machines normally cann't do DNS resolution for outside hosts. 2. cd to the top directory and issue 'make' command. It's a good idea to direct stdout and stderr to a file so that you can see what's being done afterwards. There will be a few warning messages which you can ignore. This builds the server as well as all the clients. If you only want to build the server (and the program for testing your sever configuration file), use comannd 'make server' instead. Use command 'make clients' to build only the client programs. You can also build the individual clients using 'make RFINGER', 'make RFTP', 'make RTELNET', 'make RXGOPHER', and 'make RXMOSAIC', all from the top directory. ------------------------------------------------------------- HOW TO INSTALL THE SERVER 1. Become superuser on the proxy server host for your site. 2. cd to the top directory and issue 'make install.server'. This installs programs sockd and test_sockd_conf as well as the man pages for them. Print the man pages and read them. 3. Add the line socks 1080/tcp to file /etc/services. It would be nice also to include gopher 70/tcp WWW 80/tcp in the file if you don't already have them. 4. Add the line socks stream tcp nowait nobody /usr/etc/sockd sockd to file /etc/inetd.conf. Use the actual path where sockd is installed if not in /usr/etc. If you want to make use of identd on your client machines when it is available, use socks stream tcp nowait nobody /usr/etc/sockd sockd -i If you want to REQUIRE identd be run on your client machines, use socks stream tcp nowait nobody /usr/etc/sockd sockd -I Running sockd with -I will reject all requests from hosts that do not run identd. 5. Set up access control with file /etc/sockd.conf. You have to read the man pages for sockd and test_sockd_conf for the details. For a quick test, you can use these four lines in the file: (Replace 'client_IP' with the IP address of the host on which you will be testing the client programs.) permit client_IP 0.0.0.0 deny 0.0.0.0 255.255.255.255 : /usr/ucb/finger @%A | /usr/ucb/mail -s 'SOCKD: rejected -- from %u@%A to host %Z (service %S)' root #BAD_ID: /usr/ucb/finger @%A | /usr/ucb/mail -s '%U pretends to be %u on host %A' root@%A root #NO_IDENTD: /usr/ucb/mail -s 'Please run identd on %A' %u@%A root@%A This is essentially the contents of file sockd/sockd.conf.sample. 6. Run a few tests using program test_sockd_conf to make sure your have the configuration file set up correctly. 7. Send a SIGHUP signal to the running inetd process so that it will use the new configuration. You may also have to do other things to accommodate syslog facility. Read the man pages. ------------------------------------------------------------- HOW TO TEST THE CLIENT PROGRAMS -- EXCEPT rxgopher NOTE: Build and install identd on your client hosts first. This is required if you run sockd with -I option. It is a good idea anyway. On a client host (for testing purpose, this can be the same as the proxy server), the clients rfinger, rwhois, rftp, rtelnet, and rxmosaic can be tried out without any special setup on the client host once the server is running. They shoudl behave like finger, whois, ftp, telnet, and xmosaic, respectively. rftp DOES echo your password IF you are using 'anonymous' as the log-in name. ------------------------------------------------------------- HOW TO TEST rxgopher [Lifted from README file of xgopher package.] 1. cd to rxgopher directory. 2. Modify the application defaults file (RXgopher.ad). Little change may be necessary. However, entries in this file for host name, port number, help file name, etc., override those defaults compiled into rxgopher through the configuration file. 3. Make the application defaults file (RXgopher.ad) known to X. There are several ways to do this for testing without installing the file in a system directory. Choose one of the following - whichever is most comfortable for you. IMPORTANT! Remove all of the application defaults from previous versions of rxgopher before you attempt to run rxgopher 1.2. a. xrdb -merge RXgopher.ad b. setenv XENVIRONMENT `pwd`/RXgopher.ad (`pwd` will return the current directory, which should be the rxgopher source directory.) c. if you have your own app-defaults directory, say ~/app-defaults: setenv XAPPLRESDIR ~/app-defaults/ cp RXgopher.ad ~/app-defaults/RXgopher Note the name change. COLOR OPTION: If you are using a color display, it is strongly recommended that you also include the rxgopher color resources. if you used method (a) above, then also use: xrdb -merge RXgopher-color.ad -nocpp Otherwise, consider using the file RXgopher-complete.ad instead of RXgopher.ad. The former file has all of the color resources included in it. This is sufficient for now, and to let you test. For permanent installation, see the later section of this document which discusses color resources. 4. To test, issue the command 'rxgopher' (without the quotes). ------------------------------------------------------------- HOW TO INSTALL CLIENT PROGRAMS 1. Become superuser on the client host. 2. cd to the top directory, then issue the command 'make install.clients'. This installs rfinger, rwhois, rftp, rtelnet, rxgopher, rxmosaic, and their man pages. It also installs the help file and the application defaults file for rxgopher. 3. For color setting and other details regarding rxgopher, please read the README file in rxgopher directory. ------------------------------------------------------------- Good luck and enjoy it. Ying-Da Lee (214)518-3490 (214)518-3552 (FAX) Principal Member Technical Staff NEC Systems Laboratory, C&C Software Technology Center / NEC USA, Corporate Network Administration Division ylee@syl.dl.nec.com socks4-server-4.3.beta2.orig/README.4.1100644 7657 764 35011 5606334256 15612 0ustar martinedvThis is CSTC 4.1 release of SOCKS, a package that allows Unix hosts behind a firewall to gain full access to the internet without requiring direct IP reachability. It does require a SOCKS server program being run on a hosts that can communicate directly to hosts behind the firewall as well as hosts on the Internet at large. It is based on the original SOCKS written by David Koblas . The package includes full source for the SOCKS server and SOCKSified client programs of finger, ftp, telnet, and whois. Other SOCKSified clients such as xgopher (ver. 1.3.1) and Mosaic (ver. 2.0) can be found on ftp.nec.com, in directory /pub/security/socks.cstc. (On WWW, the URL is file://ftp.nec.com/pub/security/socks.cstc ) Mosaic 2.1 as distributed by NCSA already contains the SOCKSification patch in its source, which is available from ftp.ncsa.uiuc.edu, in /Mosaic/Mosaic-source. This release is known to run on the following Unix platforms: SunOS 4.1.x (ylee@syl.dl.nec.com) Irix 4.0.x (imd1707@ggr.co.uk) Ultrix 4.3 (als@cpsg.com.au, imd1707@ggr.co.uk) HP-UX 9.0x (als@cpsg.com.au, ken.shackelford@sdrc.com, bryan@Stoner.COM) AIX 3.2.x (ken.shackelford@sdrc.com, bryan@Stoner.COM) Interactive Systems Unix (ken.shackelford@sdrc.com) Alpha OSF 1.3 (ken.shackelford@sdrc.com, amellan@acri.fr, treese@crl.dec.com) Solaris 2.2 (ylee@syl.dl.nec.com) NetBSD 0.9 (bryan@Stoner.COM) UnixWare (pax@ankh.metrolink.com) Linux 0.99pl13 (cornell@syl.dl.nec.com, cmetz@thor.tjhsst.edu) -------------------- MAJOR CHANGES SINCE 4.0 1)You now have the option to build 'sockd' to run on a multi-homed host by defining the symbol 'MULTIHOMED_SERVER' in include/socks.h. A multi-homed server requires another control file /etc/sockd.route to tell it which of its network interfaces it should use for communicating with which networks or hosts. For example: # Use interface 120.10.1.5 for host 100.1.2.3 120.10.1.5 100.1.2.3 255.255.255.255 # Use interface 120.10.2.10 for hosts in network 193.10.2 120.10.2.10 193.10.2.0 255.255.255.0 # Use interface 198.1.1.1 for all other connections 198.1.1.1 0.0.0.0 0.0.0.0 For a typical dual-homed server, all you need is a single line: outside_interface 0.0.0.0 0.0.0.0 where 'outside_interface' should be the IP address of the network interface going outside of your firewall. test_sockd_conf has been updated so that it also checks the new control file and tells you which interface will be used. 2)You can now build 'versatile' clients, which uses SOCKS server(s) to reach outside of your firewall but connects directly to hosts within the firewall. So, for example, you can save away your regular ftp program and replace it with the versatile SOCKS ftp client (rftp). You have to be careful with 'finger' though and make sure that the macro 'ORIG_FINGER' is properly defined in include/socks.h. All versatile clients use the file /etc/socks.conf to decide whether a connection should be denied, done directly, or done indirectly through SOCKS server at one or more hosts. For example: # Deny ftp and telnet access by baduser deny *=baduser 0.0.0.0 0.0.0.0 eq ftp: mail -s 'ftp by baduser' root deny *=baduser 0.0.0.0 0.0.0.0 eq telnet: mail -s 'telnet by baduser' root # Be sure to include the next line for localhost! direct 127.0.0.1 255.255.255.255 # Use direct connection to all hosts in network 120.10 direct 120.10.0.0 255.255.0.0 # Use the defaiult SOCKS server to connect to host 13.13.13.13 sockd 13.13.13.13 255.255.255.255 # For other connections, try SOCKS servers at 120.10.2.3, 120.10.50.1, # in that order sockd @=120.10.2.3,120.10.50.1 0.0.0.0 0.0.0.0 3)As you may have already noticed, the interpretation of address masks are changed. 1's in a mask now denote the bit positions that matter while 0's denote the don't-care bit positions. In other words, they are now interpreted the same way as IP netmasks. This holds true not only for the two new control files mentioned above, but also for /etc/sockd.conf. A new program 'flip_cfmasks' is provided in the sockd subdirectory to convert the old format to the new one. Just do flip_cfmasks /etc/sockd.conf sockd.conf.flip check the output file sockd.conf.flip to see if all is well (with any luck it should be) and then use that with the new server. 4)An optional getpass() is provided to communicate with systems that may require longer password (> 8 characters). This is for regular passwords. As in 4.0, "passwords" for anonymous ftp can be longer than 8 characters even without using the optional getpass(). 5)Termination of a TCP session is now also logged on the SOCKS server, including the number of bytes transported in either direction. 6)An compile time option is provided to make ftp (rftp) log the name of every file transferred. 7)The man pages are substantially revamped. All 4.1 clients work with all 4.0 and 4.1 servers. 4.0 clients work with single-homed 4.1 servers but NOT with 4.1 multi-homed servers. 'sockd -ver' tells you not only the version number but also whether it is single- or multi-homed. Please see below for the procedure for building and testing. Remember that the names of the control files are all configurable in include/socks.h. It will probably greatly reduce your frustration while you are flipping between the old and the new versions if you uses different file names for the new version. There is now a mailing list devoted to issues related to SOCKS. To join the list, please send an email subscription request with your email address to socks-request@inoc.dl.nec.com. Finally, I want to thanks all the people who have helped in making and shaping this release. I certainly remember discussions and contributions from the following, please forgive me (and remind me) if I inadvertently leave your name off the list. brandon@dd.eng.bbc.co.uk (Brandon.Butterworth), bryan@Stoner.COM (A. Bryan Curnutt), Ian Dunkin , Ingo_Dean@Warren.MentorG.com, Cornell Kinderknecht , kupec@agouron.com (John W. Kupec), jonl@hal.com (jon r. luini), amellan@acri.fr (Alain Mellan), Craig Metz , montnaro@ausable.crd.ge.com (Skip Montanaro), whna@nexos.com (Heinz Naef), nagler@olsen.ch (Rob Nagler), "Jason Ornstein" , pax@ankh.metrolink.com (Garry M. Paxinos), mikey@netcom.com (Michael Pechner), royle@knmi.nl (Keenan Royle), ken.shackelford@sdrc.com (Ken Shackelford), Anthony Shipman , Rich Schultz , treese@crl.dec.com (Win Treese), Paul.Vickers@barclays.co.uk (Paul Vickers), vince@dsi.unimi.it (David Vincenzetti), posc!waddell@uunet.uu.net (David Waddell) Ying-Da Lee (214)518-3490 (214)518-3552 (FAX) Principal Member, Technical Staff NEC Systems Laboratory, C&C Software Technology Center / NEC USA, Corporate Network Administration Division ylee@syl.dl.nec.com ==================================================================== Please read the file 'COPYRIGHTS' before you proceed further. In the following section, by 'top directory' we mean the top directory of the SOCKS package, i.e., the directory you are in right now. Ignore statements about rtelnet, rxgopher, and rxmosaic if you are not building them. ------------------------------------------------------------- HOW TO BUILD THE PROGRAMS 1. Check and modify the following files to suit your systems: Makefile include/socks.h Be sure that the macro 'SOCKS_DEFAULT_SERVER' in include/sosks.h is set correctly to the host that will be running the proxy server for your site. Although this can be overridden at run time with environment variable SOCKS_SERVER, it is a lot simpler if you put in the right name at compile time. Also be sure to uncomment and set the macro 'SOCKS_DEFAULT_NS' in the same file if yor client machines normally cann't do DNS resolution for outside hosts. Be sure that the macros 'ORIG_FINGER' and 'MULTIHOMED_SERVER' in include/socks.h are set correctly. In most cases, you should have no needs to modify the Makefiles in the subdirectories. But if you run into problems, you may have to look into modifying sockd/Makefile libident/Makefile lib/Makefile rfinger/Makefile rftp/Makefile rtelnet/Makefile If your system is not among those included in the top Makefile, then you may also have to construct an entry for your system in the file rtelnet/Config.local. 2. cd to the top directory and issue 'make' command. It's a good idea to direct stdout and stderr to a file so that you can see what's being done afterwards. There will be a few warning messages which you can ignore. This builds the server as well as all the clients. If you only want to build the server (and the program for testing your sever configuration file, AND THE PROGRAM FOR CONVERTING THE FILE TO THE NEW FORMAT), use comannd 'make server' instead. Use command 'make clients' to build only the client programs. You can also build the individual clients using 'make RFINGER', 'make RFTP', and 'make RTELNET', all from the top directory. 3. All the man pages (except for libident) are in directory doc. You are encouraged to print them out and read them before proceeding to the next part. ------------------------------------------------------------- HOW TO INSTALL THE SERVER 1. Become superuser on the proxy server host for your site. 2. cd to the top directory and issue 'make install.server'. This installs programs sockd and test_sockd_conf as well as the man pages for them. 3. Add the line socks 1080/tcp to file /etc/services. It would be nice also to include gopher 70/tcp WWW 80/tcp in the file if you don't already have them. 4. Add the line socks stream tcp nowait nobody /usr/etc/sockd sockd to file /etc/inetd.conf. Use the actual path where sockd is installed if not in /usr/etc. If you want to make use of identd on your client machines when it is available, use socks stream tcp nowait nobody /usr/etc/sockd sockd -i If you want to REQUIRE identd be run on your client machines, use socks stream tcp nowait nobody /usr/etc/sockd sockd -I Running sockd with -I will reject all requests from hosts that do not run identd. 5. Set up access control with file /etc/sockd.conf. You have to read the man pages for sockd, sockd.conf, and test_sockd_conf for the details. For a quick test, you can use these four lines in the file: (Replace 'client_IP' with the IP address of the host on which you will be testing the client programs.) permit client_IP 255.255.255.255 # One LONG line follows: deny 0.0.0.0 0.0.0.0 : /usr/ucb/finger @%A | /usr/ucb/mail -s 'SOCKD: rejected -- from %u@%A to host %Z (service %S)' root # Another LONG line: #BAD_ID: /usr/ucb/finger @%A | /usr/ucb/mail -s '%U pretends to be %u on host %A' root@%A root # Last line: #NO_IDENTD: /usr/ucb/mail -s 'Please run identd on %A' %u@%A root@%A This is essentially the contents of file sockd/sockd.conf.sample. *** NOTE *** The meanings of 1's and 0's in address masks are reversed from previous versions. If you already have a working /etc/sockd.conf with an earlier version, use the program sockd/flip_cfmasks to produce one for the new version. 6. If the server host is multi-homed and you built sockd with the macro MULTIHOMED_SERVER in include/socks.h defined, you must also supply the file /etc/sockd.route. For a typical dual-homed server, this can simply be a one-liner: out_interface 0.0.0.0 0.0.0.0 where out_interface is the IP address of the server's network interface leading to the outside world. The format for lines in this file should be # comments Interface_addr dst_addr dst_mask Read the man page on sockd.route !!! 7. Run a few tests using program test_sockd_conf to make sure you have the configuration file set up correctly. On a multi-homed server, the program also tests /etc/sockd.route and shows which interface is to be used. 8. Send a SIGHUP signal to the running inetd process so that it will use the new configuration. You may also have to do other things to accommodate syslog facility. Read the man pages. ------------------------------------------------------------- HOW TO TEST THE CLIENT PROGRAMS NOTE: Build and install identd on your client hosts first. This is required if you run sockd with -I option. It is a good idea anyway. Set up the file /etc/socks.conf on the client host. Lines in this file should be of the form # comments deny [*=userlist] dst_addr dst_mask [op port] direct [*=userlist] dst_addr dst_mask [op port] sockd [@=serverlist] [*=userlist] dst_addr dst_mask [op port] Fields in square brackets are optional. The optional @=serverlist field with a 'sockd' line specifies the list of SOCKS servers the client should try (in the given order) instead of the default SOCKS server. If the @=serverlist part is omitted, then the default SOCKS server is used. Commas are used in the userlist and serverlist as separators, no white spaces are allowed. Read the man page on socks.conf !!! On a client host (for testing purpose, this can be the same as the proxy server), the clients rfinger, rwhois, rftp, and rtelnet, can be tried out without any additional setup on the client host once the server is running. They should behave like finger, whois, ftp, and telnet, respectively. rftp DOES echo your password IF you are using 'anonymous' as the log-in name. Quite a lot of details of operations of both the clients and the server are logged. Checking the contents of the log files may be helpful when you run into problems. You should try using these clients to connect to both inside and outside hosts and check the log messages to see whether the correct ways are used. ------------------------------------------------------------- HOW TO INSTALL CLIENT PROGRAMS 1. Become superuser on the client host. 2. cd to the top directory, then issue the command 'make install.clients'. This installs rfinger, rwhois, rftp, rtelnet, and their man pages. 3. Rename your regular 'finger', 'whois', 'ftp', and 'telnet' to something else. The new name for the 'finger' program must be EXACTLY what you used for defining the macro ORIG_FINGER in include/socks.h. Then either rename the SOCKS clients or use symbolic links for them. For example, if you have installed the clients in directory /usr/local/bin and your regular 'finger', 'whois', 'ftp', and 'telnet' were in /usr/ucb, then you should do ln -s /usr/local/bin/rfinger /usr/ucb/finger ln -s /usr/local/bin/rftp /usr/ucb/ftp ln -s /usr/local/bin/rhwois /usr/ucb/whois ln -s /usr/local/bin/rtelnet /usr/ucb/telnet socks4-server-4.3.beta2.orig/README.4.2100644 7657 764 27447 5723717700 15630 0ustar martinedvThis is CSTC version 4.2 of SOCKS, a package that allows Unix hosts behind a firewall to gain full access to the internet without requiring direct IP reachability. It does require a SOCKS server program being run on a hosts that can communicate directly to hosts behind the firewall as well as hosts on the Internet at large. It is based on the original SOCKS written by David Koblas . The package includes full source for the SOCKS server and SOCKSified client programs of finger, ftp, telnet, and whois. A few other SOCKSified clients may be found on ftp.nec.com, in directory /pub/security/socks.cstc. Increasingly, software developers are beginning to include SOCKS support directly into their products, for example, Mosaic, Netscape, Trumpet Winsock, TCP/Connect II (from InterCon for Macintosh; they also intend to do so for their Windows version), OutsideVew for Windows (from Crystal Point, currently in beta). Besides various minor bug fixes and improvements, the major differences between this release and 4.1 are: 1) Can handle nonblocking connect() calls, or at least the way such calls are used in Mosaic. 2) SOCKSification of application programs is simplified. No code modification is necessary, just recompile with appropriate directives (see the file How_to_SOCKSify). 3) Option to build stand-alone sockd. This is especially beneficial for sites that have to use a big sockd.conf file. This version is known to work on the following Unix platforms: SunOS 4.1.3 Irix 4.0.5H, 5 Ultrix 4.3 HP-UX 9.05 AIX 3.2.5 Interactive 4.1 DEC OSF/1 AXP 3.0 Solaris 2.3, 2.4 Linux 1.1.18 SCO/ODT 2.x DG/UX 5.4.3 FreeBSD 1.1.5.1 Though I have not received final confirmation, it is likely that the package may also work on the following platforms: NetBSD 0.9 UnixWare BSDi 1.0 PS/2 AIX 1.2.1 NextStep 3.2 (server and library only) ------------------- All 4.2 clients work with all 4.x servers. 4.0 clients work with single-homed 4.2 servers but NOT with 4.2 multi-homed servers. 4.1 clients work with 4.2 servers, both single- and multi-homed. 'sockd -ver' tells you not only the version number but also whether it is single- or multi-homed. Please see below for the procedure for building and testing. Remember that the names of the control files are all configurable in include/socks.h. It will probably greatly reduce your frustration while you are flipping between the old and the new versions if you uses different file names for the new version. There is now a mailing list devoted to issues related to SOCKS. To join the list, please send an email subscription request to majordomo@syl.dl.nec.com with subscribe socks your@email.address in the body of the message. Finally, I want to thanks all the people who have helped in making and shaping this release. These are the ones that I remember: Jason Baietto, Brad Beach, David Blob, John Brezak, Dave Brower, Brian M. Clapper, Matt Cohen, Adrian Colley, Bryan Curnutt, Ian Dunkin, Steve Danz, Thomas Essebier, Andrew Fullford, Matthew R. Ganis, Phil Hochstetler, LaMont Jones, Larry Jones, Cornell Kinderknecht, Edwin Kremer, William Lewis, Rob Liebschutz, Jon Luini, Stephen Ma, Andy McFadden, Alain Mellan, Craig Metz, David Mischel, Heinz Naef, David Nochlin, Garry M. Paxinos, Hal Pomeranz, Chris Riney, Andreas Siegert, John Scott, Fred Stephens, Shin'ichiro Tanaka, Mike Tollerton, Satoshi Toyosawa, Paul van Deurzen, Syd Weinstein My sincere apologies to those that I forget to mention -- please remind me! Without in any way diminishing the contributions of others in the list, I would like to pay special tribute to David Mischel for his code for the stand-alone sockd, and to Bryan Curnutt for porting to and testing the package on 9 (!) platforms. Ying-Da Lee (214)518-3490 (214)518-3552 (FAX) Principal Member, Technical Staff NEC Systems Laboratory, C&C Software Technology Center / NEC USA, Corporate Network Administration Division ylee@syl.dl.nec.com ==================================================================== Please read the file 'COPYRIGHTS' before you proceed further. In the following section, by 'top directory' we mean the top directory of the SOCKS package, i.e., the directory you are in right now. ------------------------------------------------------------- HOW TO BUILD THE PROGRAMS 1. Check and modify the following files to suit your systems: Makefile include/socks.h Be sure that the macro 'SOCKS_DEFAULT_SERVER' in include/socks.h is set correctly to the host that will be running the proxy server for your site. Although this can be overridden at run time with environment variable SOCKS_SERVER, it is a lot simpler if you put in the right name at compile time. Also be sure to uncomment and set the macro 'SOCKS_DEFAULT_NS' in the same file if your client machines normally can't do DNS resolution for outside hosts. Be sure that the macros 'ORIG_FINGER' and 'MULTIHOMED_SERVER' in include/socks.h are set correctly. If you need a large configuartion file with many rules for access control (I have heard of sites with up to 2,000 lines in sockd.conf!), you should try using a stand-alone SOCKS server, i.e., one that runs without the control of inetd. To build a stand-alone SOCKS server, you must define the macro NOT_THROUGH_INETD in include/socks.h. In most cases, you should have no needs to modify the Makefiles in the subdirectories. But if you run into problems, you may have to look into modifying sockd/Makefile libident/Makefile lib/Makefile rfinger/Makefile rftp/Makefile rtelnet/Makefile If your system is not among those included in the top Makefile, then you may also have to construct an entry for your system in the file rtelnet/Config.local. 2. cd to the top directory and issue 'make' command. It's a good idea to direct stdout and stderr to a file so that you can see what's being done afterwards. There will be a few warning messages which you can ignore. This builds the server as well as all the clients. If you only want to build the server, use command 'make server' instead. Use command 'make clients' to build only the client programs. You can also build the individual clients using 'make RFINGER', 'make RFTP', and 'make RTELNET', all from the top directory. 3. All the man pages (except for libident) are in directory doc. You are encouraged to print them out and read them before proceeding to the next part. ------------------------------------------------------------- HOW TO INSTALL THE SERVER 1. Become superuser on the proxy server host for your site. 2. cd to the top directory and issue 'make install.server'. This installs sockd and its man page. 3. Add the line socks 1080/tcp to file /etc/services. It would be nice also to include gopher 70/tcp WWW 80/tcp in the file if you don't already have them. 4. Set up access control with file /etc/sockd.conf. You have to read the man pages for sockd and sockd.conf for the details. For a quick test, you can use these four lines in the file: (Replace 'client_IP' with the IP address of the host on which you will be testing the client programs.) permit client_IP 255.255.255.255 # One LONG line follows: deny 0.0.0.0 0.0.0.0 : /usr/ucb/finger @%A | /usr/ucb/mail -s 'SOCKD: rejected -- from %u@%A to host %Z (service %S)' root # Another LONG line: #BAD_ID: /usr/ucb/finger @%A | /usr/ucb/mail -s '%U pretends to be %u on host %A' root@%A root # Last line: #NO_IDENTD: /usr/ucb/mail -s 'Please run identd on %A' %u@%A root@%A This is essentially the contents of file sockd/sockd.conf.sample. 5. If the server host is multi-homed and you built sockd with the macro MULTIHOMED_SERVER in include/socks.h defined, you must also supply the file /etc/sockd.route. For a typical dual-homed server, this can simply be a one-liner: out_interface 0.0.0.0 0.0.0.0 where out_interface is the IP address of the server's network interface leading to the outside world. The format for lines in this file should be # comments Interface_addr dst_addr dst_mask Read the man page on sockd.route !!! 6a. For sockd that is to be controlled through inetd (i.e., you made the server with NOT_THROUGH_INETD in include/socks.h undefined): Add the line socks stream tcp nowait nobody /usr/etc/sockd sockd to file /etc/inetd.conf. Use the actual path where sockd is installed if not in /usr/etc. If you want to make use of identd on your client machines when it is available, use socks stream tcp nowait nobody /usr/etc/sockd sockd -i If you want to REQUIRE identd be run on your client machines, use socks stream tcp nowait nobody /usr/etc/sockd sockd -I Running sockd with -I will reject all requests from hosts that do not run identd. Send a SIGHUP signal to the running inetd process so that it will use the new configuration. 6b. For stand-alone sockd (i.e., you made the server with NOT_THROUGH_INETD in include/socks.h defined): Just invoke the sockd program, e.g., /usr/etc/sockd. Use the actual path where sockd is installed if not in /usr/etc. If you want to make use of identd on your client machine when it is available, use the -i option. If you want to REQUIRE identd be run on your client machines, use the -I option. 7. You may have to do some other things to accommodate syslog. Read the man pages on syslogd and syslog.conf. ------------------------------------------------------------- HOW TO TEST THE CLIENT PROGRAMS NOTE: Build and install identd on your client hosts first. This is required if you run sockd with -I option. It is a good idea anyway. Set up the file /etc/socks.conf on the client host. Lines in this file should be of the form # comments deny [*=userlist] dst_addr dst_mask [op port] direct [*=userlist] dst_addr dst_mask [op port] sockd [@=serverlist] [*=userlist] dst_addr dst_mask [op port] Fields in square brackets are optional. The optional @=serverlist field with a 'sockd' line specifies the list of SOCKS servers the client should try (in the given order) instead of the default SOCKS server. If the @=serverlist part is omitted, then the default SOCKS server is used. Commas are used in the userlist and serverlist as separators, no white spaces are allowed. Read the man page on socks.conf !!! On a client host (for testing purpose, this can be the same as the proxy server), the clients rfinger, rwhois, rftp, and rtelnet, can be tried out without any additional setup on the client host once the server is running. They should behave like finger, whois, ftp, and telnet, respectively. rftp DOES echo your password IF you are using 'anonymous' as the log-in name. Quite a lot of details of operations of both the clients and the server are logged. Checking the contents of the log files may be helpful when you run into problems. You should try using these clients to connect to both inside and outside hosts and check the log messages to see whether the correct ways are used. ------------------------------------------------------------- HOW TO INSTALL CLIENT PROGRAMS 1. Become superuser on the client host. 2. cd to the top directory, then issue the command 'make install.clients'. This installs rfinger, rwhois, rftp, rtelnet, and their man pages. 3. Rename your regular 'finger', 'whois', 'ftp', and 'telnet' to something else. The new name for the 'finger' program must be EXACTLY what you used for defining the macro ORIG_FINGER in include/socks.h. Then either rename the SOCKS clients or use symbolic links for them. For example, if you have installed the clients in directory /usr/local/bin and your regular 'finger', 'whois', 'ftp', and 'telnet' were in /usr/ucb, then you should do ln -s /usr/local/bin/rfinger /usr/ucb/finger ln -s /usr/local/bin/rftp /usr/ucb/ftp ln -s /usr/local/bin/rhwois /usr/ucb/whois ln -s /usr/local/bin/rtelnet /usr/ucb/telnet socks4-server-4.3.beta2.orig/README.4.3.beta2100644 7657 764 26430 6157343077 16620 0ustar martinedvWith 4.3, implementing 4A extension to the SOCKS 4 protocol, clients are no longer required to be able to resolve all internal and external domain names. They may rely on the SOCKS server to resolve names that they do not know. All 4.3 clients can still work with previous 4.x servers except when they expect the server to do name resolution for them, which is only available on 4.3 servers. With domain names now allowed in the configuration files for both the SOCKS server and the clients, it is much simpler to set up the configuration files. Most sites should find themselves needing nothing more elaborate than the two-liners below (replacing my.domain with your own domain name). For sockd.conf: deny ALL 0.0.0.0 .my.domain 0.0.0.0 permit .my.domain 0.0.0.0 ALL 0.0.0.0 For socks.conf: direct .my.domain 0.0.0.0 sockd ALL 0.0.0.0 4.3 servers work with all 4.x clients unless you build the server with NO_RBIND defined. The NO_RBIND servers does not support the facility of allowing incoming secondary connections such as those used in the normal mode of ftp. ftp (rftp) using PASSIVE mode works fine with NO_RBIND servers. No route file (/etc/sockd.route) is needed for NO_RBIND servers, even if they are multi-homed. Please see below for the procedure for building and testing. Since the configuration files now accept domain names which existing applications do not yet understand, a good way to ease the transition is to use a non-standard name for the new configuration (e.g., /etc/socks.conf.new) and produce a frozen configurations from it using 'make_socksfc /etc/socks.conf.new'. New applications can use the frozen configuration while existing ones can use the old configuration. The use of domain names in configuration files can greatly simplify their setup. On the other hand, it will also make SOCKS's actions depend heavily on your DNS (Domain Name System) setup. Be sure to read the man page on sockd.conf very carefully and consider how well you maaintain your DNS data if you want to use domain names in your configuration files. To join the SOCKS mailing list, please send an email subscription request to majordomo@syl.dl.nec.com with subscribe socks your@email.address in the body of the message. Ying-Da Lee yingda@best.com or yingda@esd.sgi.com http://www.best.com/~yingda/ ------------------- Please see the file CHANGES for things that are different from previous versions. I have incorporated patches and suggestions from many people, these are the ones that I have the records for: SAKAI Kiyotaka Ted E. Keller Ian Dunkin "Joe Rhett" rubenb@strat.jany.gs.com (W. Bradley Rubenstein) Laurent Julliard larry.jones@sdrc.com (Larry Jones) Mark Powell Chuck Murcko hal@netmarket.com (Hal Pomeranz) Damjan Lango ken_simpson@tmai.com (Kenneth Simpson) Russell Fulton john@oaty.com (John Grant) Stanley Hu Chee-Wai Yeung I am almost certain though that I lost a batch of mail messages when I changed my job. So please remind me so I don't let your contribution go unacknowledged. ==================================================================== In the following section, by 'top directory' we mean the top directory of the SOCKS package, i.e., the directory you are in right now. ------------------------------------------------------------- HOW TO BUILD THE PROGRAMS 1. Check and modify the following files to suit your systems: Makefile include/socks.h Be sure that the macro 'SOCKS_DEFAULT_SERVER' in include/socks.h is set correctly to the host that will be running the proxy server for your site. Although this can be overridden at run time with environment variable SOCKS_SERVER, it is a lot simpler if you put in the right name at compile time. Also be sure to uncomment and set the macro 'SOCKS_DEFAULT_NS' in the same file if your client machines normally can't do DNS resolution for outside hosts. Be sure that the macros 'ORIG_FINGER' and 'MULTIHOMED_SERVER' in include/socks.h are set correctly. If you need a large configuartion file with many rules for access control (I have heard of sites with up to 2,000 lines in sockd.conf!), you may want to use a stand-alone SOCKS server, i.e., one that runs without the control of inetd. To build a stand-alone SOCKS server, you must define the macro STAND_ALONE_SERVER in include/socks.h. In most cases, you should have no needs to modify the Makefiles in the subdirectories. But if you run into problems, you may have to look into modifying sockd/Makefile libident/Makefile lib/Makefile rfinger/Makefile rftp/Makefile rtelnet/Makefile If your system is not among those included in the top Makefile, then you may also have to construct an entry for your system in the file rtelnet/Config.local. 2. cd to the top directory and issue 'make' command. It's a good idea to direct stdout and stderr to a file so that you can see what's being done afterwards. There will be a few warning messages which you can ignore. This builds the server as well as all the clients. If you only want to build the server, use command 'make server' instead. Use command 'make clients' to build only the client programs. You can also build the individual clients using 'make RFINGER', 'make RFTP', and 'make RTELNET', all from the top directory. Similarly, use 'make MKFC' from the top directory to build the programs that produce and show the contents of frozen configuration files. If you are using gcc and it is having major fits with rtelnet, add -traditional flag and try it again. 3. All the man pages (except for libident) are in directory doc. You are encouraged to print them out and read them before proceeding to the next part. ------------------------------------------------------------- HOW TO INSTALL THE SERVER 1. Become superuser on the proxy server host for your site. 2. cd to the top directory and issue 'make install.server'. This installs sockd and its man page. 3. Add the line socks 1080/tcp to file /etc/services. It would be nice also to include gopher 70/tcp WWW 80/tcp in the file if you don't already have them. 4. Set up access control file. Two lines in this file should suffice for most sites: deny ALL 0.0.0.0 .xyz.com 0.0.0.0 permit .xyz.com 0.0.0.0 ALL 0.0.0.0 Use your own domain in place of xyz.com in the lines above; note the leading period before the domain name. You may want to use the program make_sockdfc to produce a frozen configuration after you have a stable setup for your configuration. Frozen configuration can reduce the server's startup time. Be sure to read the man page on sockd.conf very carefully! 5. If the server host is multi-homed and your server supports RBIND (i.e., you built sockd with the macro MULTIHOMED_SERVER in include/socks.h defined and NO_RBIND in the top Makefile undefined), you must also supply the file /etc/sockd.route. For a typical dual-homed server, this can simply be a one-liner: out_interface 0.0.0.0 0.0.0.0 where out_interface is the IP address of the server's network interface leading to the outside world. The format for lines in this file should be # comments Interface_addr dst_addr dst_mask Read the man page on sockd.route !!! 6a. For sockd that is to be controlled through inetd (i.e., you made the server with STAND_ALONE_SERVER in include/socks.h undefined): Add the line socks stream tcp nowait nobody /usr/etc/sockd sockd to file /etc/inetd.conf. Use the actual path where sockd is installed if not in /usr/etc. If you want to make use of identd on your client machines when it is available, use socks stream tcp nowait nobody /usr/etc/sockd sockd -i If you want to REQUIRE identd be run on your client machines, use socks stream tcp nowait nobody /usr/etc/sockd sockd -I Running sockd with -I will reject all requests from hosts that do not run identd. Send a SIGHUP signal to the running inetd process so that it will use the new configuration. 6b. For stand-alone sockd (i.e., you made the server with STAND_ALONE_SERVER in include/socks.h defined): Just invoke the sockd program, e.g., /usr/etc/sockd. Use the actual path where sockd is installed if not in /usr/etc. If you want to make use of identd on your client machine when it is available, use the -i option. If you want to REQUIRE identd be run on your client machines, use the -I option. 7. You may have to do some other things to accommodate syslog. Read the man pages on syslogd and syslog.conf. 8. If you are going to use a SOCKSified SOCKS server, please read the man page on rsockd. ------------------------------------------------------------- HOW TO TEST THE CLIENT PROGRAMS NOTE: Build and install identd on your client hosts first. This is required if you run sockd with -I option. It is a good idea anyway. Set up the configuration file. This should normally be /etc/socks.conf. However, if you have existing SOCKS clients and you want to use domain names in the configuration, which the existing applications do not understand, it's better to call it /etc/socks.conf.new and use the command make_socksfc /etc/socks.conf.new to produce frozen configuration for new SOCKS clients while the existing ones continue to use the old configuration. For most sites, two lines should suffice: direct .xyz.com 0.0.0.0 sockd ALL 0.0.0.0 Use your domain name in place of xyz.com in the first line; note the period before the domain anme. Read the man page on socks.conf !!! On a client host (for testing purpose, this can be the same as the proxy server), the clients rfinger, rwhois, rftp, and rtelnet, can be tried out without any additional setup on the client host once the server is running. They should behave like finger, whois, ftp, and telnet, respectively. rftp DOES echo your password IF you are using 'anonymous' as the log-in name. Quite a lot of details of operations of both the clients and the server are logged. Checking the contents of the log files may be helpful when you run into problems. You should try using these clients to connect to both inside and outside hosts and check the log messages to see whether the correct ways are used. ------------------------------------------------------------- HOW TO INSTALL CLIENT PROGRAMS 1. Become superuser on the client host. 2. cd to the top directory, then issue the command 'make install.clients'. This installs rfinger, rwhois, rftp, rtelnet, and their man pages. 3. Rename your regular 'finger', 'whois', 'ftp', and 'telnet' to something else. The new name for the 'finger' program must be EXACTLY what you used for defining the macro ORIG_FINGER in include/socks.h. Then either rename the SOCKS clients or use symbolic links for them. For example, if you have installed the clients in directory /usr/local/bin and your regular 'finger', 'whois', 'ftp', and 'telnet' were in /usr/ucb, then you should do ln -s /usr/local/bin/rfinger /usr/ucb/finger ln -s /usr/local/bin/rftp /usr/ucb/ftp ln -s /usr/local/bin/rhwois /usr/ucb/whois ln -s /usr/local/bin/rtelnet /usr/ucb/telnet socks4-server-4.3.beta2.orig/README.DK100644 7657 764 3461 5606334257 15573 0ustar martinedv ##### # # #### #### # # #### # # # # # # # # ##### # # # #### #### # # # # # # # # # # # # # # # # # ##### #### #### # # #### This system was described in a paper appearing the the 1992 USENIX Security Simposium. This code has been in use at a variety of sites for many years, and is now available for general consumption. One quick disclaimer, which is that documentation isn't up to snuff, the best best thing available is the USENIX procedings. If you notice something in particular lacking please let me know. I can reached at, for any questions comments or other sudgestions: koblas@netcom.com What the directories contain: include -- Common include file for both the daemon and library lib -- Standard library containting replacement calls rfinger -- Example Rconnect() program, contains both finger & whois rftp -- The standard BSD Networking release finger, copied from ftp.uu.net, and modified to work with Socks sockd -- The daemon that runs on the gateway host. doc -- Some unfinished documentation *** The short and simple installation instructions: 1) Look at the socks.h in the include directory, cusomize it for your site. 2) Put the following line in your /etc/services file socks 1080/tcp # Socks gateway service 3) Cusomize sockd/sockd.conf to your sites needs 4) Copy sockd/sockd and sockd/sockd.conf to your gateway host 5) Add the following line to your /etc/inetd.conf file on the gateway socks stream tcp nowait nobody /etc/sockd sockd 6) Reload your inetd on the gateway host (kill -HUP ) 7) Test out rwhois or rfinger in the rfinger directory to see if things are working. socks4-server-4.3.beta2.orig/SOCKS.products100644 7657 764 7301 6144227035 17053 0ustar martinedvWalker, Richer, and Quinn (WRQ, Inc.) in Seattle has put Socks support into our Reflection line of connectivity products. There are multiple product configurations and suites involved, but we have built Socks 4 support into our FTP, telnet, web, and finger clients for Windows 95 and NT. WRQ product questions can be answered at 800-872-2829. Our address is: 1500 Dexter Avenue North, Seattle WA 98109 WRQ has offices in Europe and Asia, and distributors throughout the world. See www.wrq.com for details. ========================================================== PrivateNet(tm) by the Internet Business Unit of NEC Technologies is a proxy-based firewall using SocksPlus(tm) ciruit-level proxies for clients accessing the Internet and application proxies for remote users accessing internal servers. SocksPlus is fully compatible with SOCKS 4.2. The system software is a security hardended BSD/OS (from BSDi) running on a Pentium processor. All the software executes from a CD-ROM which protects against tampering and simplifies updates. All hardware and software is included for list price of $14,950 for an unlimited user license. Web: www.PrivateNet.NEC.com E-mail: Info@PrivateNet.NEC.com Phone: 1-800-668-4869, Department Code: YCB for brochures and other hard copy information. ================================================ From: "Waseem Siddiqi" Organization: FTP Software The following products supports SOCKS FTP Software's OnNet 2.1 FTP Software's OnNet32 1.0 ====================================================== We have a commercial (free) Windows NT/95 DLL that does transparent socks4. Rudy Amid (rudy@hcl.com) [Home URL] http://www.warped.com/~radix Systems Administrator #include Hummingbird Communications, Ltd. "We're IT!" -MIS Dept. 1 Sparks Ave. Toronto, Canada. M2H 2W1. 416-496-2200 [URL] http://www.hcl.com =========================================================== Here is a product announcement: Company: Aventail Corporation Product: AutoSOCKS v4 Phone: 408-879-8093 WWW: www.aventail.com FTP: ftp.aventail.com Contact: Evan Kaplan Email: evank@aventail.com AutoSOCKS is a firewall traversal application for 16- and 32-bit bit Windows applications. Utilizing the WinSock Component Architecture (WCA), it transparently socksifies Windows-based TCP/IP (Internet and Intranet) applications thereby providing controlled, secure access to external networks. The product works by intercepting WinSock communication requests issued by applications, and processes the requests based on a set of rules. These rules govern whether or not a request is redirected through a SOCKS server. The product allows communications within the local network to proceed unchanged. All communication with external networks can be redirected through one or many SOCKS servers, providing a single controlled access point. You may download a BETA version at: http://www.aventail.com ===================================================== From: "Kevin Byrd" I am the Product Manager for Sterling Commerce's CONNECT:Firewall product. We support SOCKS 4.2 server. We would like to be listed in your list. Please let me know if you need more information. CONNECT:Firewall SOCKS 4.2 Server Today: SunOS 4.1.4 July 96: Solaris 2.5 and SolarisPC 4Q 96: NT Software Only Current list Price: $8,995 unlimited users Thanks. Kevin Byrd Manager, Product Marketing Sterling Commerce ===================================================== socks4-server-4.3.beta2.orig/SOCKS4.protocol100644 7657 764 15511 6157341640 17162 0ustar martinedv SOCKS: A protocol for TCP proxy across firewalls Ying-Da Lee yingda@best.com or yingda@esd.sgi.com SOCKS was originally developed by David Koblas and subsequently modified and extended by me to its current running version -- version 4. It is a protocol that relays TCP sessions at a firewall host to allow application users transparent access across the firewall. Because the protocol is independent of application protocols, it can be (and has been) used for many different services, such as telnet, ftp, finger, whois, gopher, WWW, etc. Access control can be applied at the beginning of each TCP session; thereafter the server simply relays the data between the client and the application server, incurring minimum processing overhead. Since SOCKS never has to know anything about the application protocol, it should also be easy for it to accommodate applications which use encryption to protect their traffic from nosey snoopers. Two operations are defined: CONNECT and BIND. 1) CONNECT The client connects to the SOCKS server and sends a CONNECT request when it wants to establish a connection to an application server. The client includes in the request packet the IP address and the port number of the destination host, and userid, in the following format. +----+----+----+----+----+----+----+----+----+----+....+----+ | VN | CD | DSTPORT | DSTIP | USERID |NULL| +----+----+----+----+----+----+----+----+----+----+....+----+ # of bytes: 1 1 2 4 variable 1 VN is the SOCKS protocol version number and should be 4. CD is the SOCKS command code and should be 1 for CONNECT request. NULL is a byte of all zero bits. The SOCKS server checks to see whether such a request should be granted based on any combination of source IP address, destination IP address, destination port number, the userid, and information it may obtain by consulting IDENT, cf. RFC 1413. If the request is granted, the SOCKS server makes a connection to the specified port of the destination host. A reply packet is sent to the client when this connection is established, or when the request is rejected or the operation fails. +----+----+----+----+----+----+----+----+ | VN | CD | DSTPORT | DSTIP | +----+----+----+----+----+----+----+----+ # of bytes: 1 1 2 4 VN is the version of the reply code and should be 0. CD is the result code with one of the following values: 90: request granted 91: request rejected or failed 92: request rejected becasue SOCKS server cannot connect to identd on the client 93: request rejected because the client program and identd report different user-ids The remaining fields are ignored. The SOCKS server closes its connection immediately after notifying the client of a failed or rejected request. For a successful request, the SOCKS server gets ready to relay traffic on both directions. This enables the client to do I/O on its connection as if it were directly connected to the application server. 2) BIND The client connects to the SOCKS server and sends a BIND request when it wants to prepare for an inbound connection from an application server. This should only happen after a primary connection to the application server has been established with a CONNECT. Typically, this is part of the sequence of actions: -bind(): obtain a socket -getsockname(): get the IP address and port number of the socket -listen(): ready to accept call from the application server -use the primary connection to inform the application server of the IP address and the port number that it should connect to. -accept(): accept a connection from the application server The purpose of SOCKS BIND operation is to support such a sequence but using a socket on the SOCKS server rather than on the client. The client includes in the request packet the IP address of the application server, the destination port used in the primary connection, and the userid. +----+----+----+----+----+----+----+----+----+----+....+----+ | VN | CD | DSTPORT | DSTIP | USERID |NULL| +----+----+----+----+----+----+----+----+----+----+....+----+ # of bytes: 1 1 2 4 variable 1 VN is again 4 for the SOCKS protocol version number. CD must be 2 to indicate BIND request. The SOCKS server uses the client information to decide whether the request is to be granted. The reply it sends back to the client has the same format as the reply for CONNECT request, i.e., +----+----+----+----+----+----+----+----+ | VN | CD | DSTPORT | DSTIP | +----+----+----+----+----+----+----+----+ # of bytes: 1 1 2 4 VN is the version of the reply code and should be 0. CD is the result code with one of the following values: 90: request granted 91: request rejected or failed 92: request rejected becasue SOCKS server cannot connect to identd on the client 93: request rejected because the client program and identd report different user-ids. However, for a granted request (CD is 90), the DSTPORT and DSTIP fields are meaningful. In that case, the SOCKS server obtains a socket to wait for an incoming connection and sends the port number and the IP address of that socket to the client in DSTPORT and DSTIP, respectively. If the DSTIP in the reply is 0 (the value of constant INADDR_ANY), then the client should replace it with the IP address of the SOCKS server to which the cleint is connected. (This happens if the SOCKS server is not a multi-homed host.) In the typical scenario, these two numbers are made available to the application client prgram via the result of the subsequent getsockname() call. The application protocol must provide a way for these two pieces of information to be sent from the client to the application server so that it can initiate the connection, which connects it to the SOCKS server rather than directly to the application client as it normally would. The SOCKS server sends a second reply packet to the client when the anticipated connection from the application server is established. The SOCKS server checks the IP address of the originating host against the value of DSTIP specified in the client's BIND request. If a mismatch is found, the CD field in the second reply is set to 91 and the SOCKS server closes both connections. If the two match, CD in the second reply is set to 90 and the SOCKS server gets ready to relay the traffic on its two connections. From then on the client does I/O on its connection to the SOCKS server as if it were directly connected to the application server. For both CONNECT and BIND operations, the server sets a time limit (2 minutes in current CSTC implementation) for the establishment of its connection with the application server. If the connection is still not establiched when the time limit expires, the server closes its connection to the client and gives up. socks4-server-4.3.beta2.orig/SOCKS4A.protocol100644 7657 764 3520 6157341701 17236 0ustar martinedv SOCKS 4A: A Simple Extension to SOCKS 4 Protocol Ying-Da Lee yingda@best.com or yingda@esd.sgi.com Please read SOCKS4.protocol first for an description of the version 4 protocol. This extension is intended to allow the use of SOCKS on hosts which are not capable of resolving all domain names. In version 4, the client sends the following packet to the SOCKS server to request a CONNECT or a BIND operation: +----+----+----+----+----+----+----+----+----+----+....+----+ | VN | CD | DSTPORT | DSTIP | USERID |NULL| +----+----+----+----+----+----+----+----+----+----+....+----+ # of bytes: 1 1 2 4 variable 1 VN is the SOCKS protocol version number and should be 4. CD is the SOCKS command code and should be 1 for CONNECT or 2 for BIND. NULL is a byte of all zero bits. For version 4A, if the client cannot resolve the destination host's domain name to find its IP address, it should set the first three bytes of DSTIP to NULL and the last byte to a non-zero value. (This corresponds to IP address 0.0.0.x, with x nonzero. As decreed by IANA -- The Internet Assigned Numbers Authority -- such an address is inadmissible as a destination IP address and thus should never occur if the client can resolve the domain name.) Following the NULL byte terminating USERID, the client must sends the destination domain name and termiantes it with another NULL byte. This is used for both CONNECT and BIND requests. A server using protocol 4A must check the DSTIP in the request packet. If it represent address 0.0.0.x with nonzero x, the server must read in the domain name that the client sends in the packet. The server should resolve the domain name and make connection to the destination host if it can. SOCKSified sockd may pass domain names that it cannot resolve to the next-hop SOCKS server. socks4-server-4.3.beta2.orig/What_SOCKS_expects100644 7657 764 3454 5606334257 17743 0ustar martinedv What SOCKS Expects In the Client Programs Ying-Da Lee SOCKS is intended for easy conversion of existing network TCP client programs. Towards that end, it expects that the programs are written in a certain way. SOCKS only pays attention to six socket functions: connect(), bind(), getsockname(), listen(), accept(), select(), and rcmd(). (select and rcmd() do not apply to versions prior to version 4.2 of SOCKS.CSTC.) SOCKS makes the following assumptions. 1) Everything is done in TCP. 2) The very first function invoked must be connect(), or rcmd(). 3) If connect() is used on a non-blocking socket, no I/O should occur on that socket until after another connect() with the same arguments returns with -1 and errno indicating EISCONN. This is required even if select() on write is used to check the readiness of that socket. Also, while a connection is still pending, no attempts may be made to start another connection via connect() or the bind()-- getsockname()--listen()--accept() sequence. 4) bind() is used after a successful connect() call to a host for a specific service. It is used to establish an auxiliary TCP session with the same host in the previous connect() call and for the same service. 5) bind() is followed by getsockname() listen() accept() in the order given above. Most client programs fit these assumptions very well; such programs can be SOCKSified without changing the code at all using the steps described in the file How_to_SOCKSified. Some client programs use a bind() before each connect(). If the bind() is used to claim a specific port or a specific network interface, the current SOCKS is not able to accommodate such use. Very often though, such a bind() call is there for no reason at all, and should simply be deleted. socks4-server-4.3.beta2.orig/What_are_the_risks100644 7657 764 5773 5626227412 20152 0ustar martinedv>From daemon@inoc.dl.nec.com Wed Dec 1 17:44:07 1993 Date: Wed, 1 Dec 93 17:42:55 CST From: ylee@syl.dl.nec.com (Ying-Da Lee) Message-Id: <9312012342.AA26065@florida.syl.dl.nec.com> To: socks@inoc.dl.nec.com, zz5@dswpa.dsdoe.ornl.gov Subject: Re: Comparing firewall packages... Cc: ylee@syl.dl.nec.com X-Mailing-List: socks@syl.dl.nec.com (SOCKS discussion list) Status: RO >I will be working with SOCKS now. Any information would be >appreciated. I just want to know how secure SOCKS is, and what >guarantees can be made about it... Thanks. I don't know about guarantees. Should we start with 'as far as I know, there is no way...' and see where it ends? As far as I know, there is no way to initiate an attack into your firewalled internal network through SOCKS if your SOCKS server is properly configured. For example, if your internal network is 200.100.50 and you put the line deny 0.0.0.0 0.0.0.0 200.100.50.0 255.255.255.0 at the top of your sockd.conf, the SOCKS server will fend off all attempts to go through it to reach your inside hosts. No routing tricks or IP address spoofing will make any difference. This is not to say that you are not incurring some risks by running SOCKS. You are, but these are the risks/vulnerabilities accompanying the applications you allow to run on top of SOCKS, not with SOCKS itself. For example, doing any network communication without encryption runs the risk of having your password or other confidential information stolen, whether you use SOCKS or not. Blindly "displaying" a postscript file can end in a disaster regardless of whether you retrieved the file through SOCKS or not. SOCKS doesn't add more on top of these risks, but it doesn't help you deal with them either. Should it? It really can't if SOCKS is to remain a general purpose TCP relayer without delving into the specific application protocols. This accounts for the server's high efficiency. This independence of the application protocol also makes it easy to convert an application program into a SOCKS client. In addition, SOCKS probably will have a fairly easy time accommodating security devices in the application protocols if and when they are used. So, if on balance you find the security risks of existing telnet, ftp, Mosaic, etc. outweigh their usefulness to you and you are unable or unwilling to develop a more secure version, then SOCKS is not for you. If the balance tilts the other way, welcome to SOCKS. I hope that's enough for a start. Ying-Da Lee (214)518-3490 (214)518-3552 (FAX) Principal Member, Technical Staff NEC Systems Laboratory, C&C Software Technology Center / NEC USA, Corporate Network Administration Division ylee@syl.dl.nec.com ************** The rest of this message was automatically appended by the socks list mail munger. To send a message to the entire list, address it to: socks@inoc.dl.nec.com. However, if you want to get off the list or change your address, please send a message to socks-request@inoc.dl.nec.com, and NOT the entire list. Thank you. ************** socks4-server-4.3.beta2.orig/bsdinstall100755 7657 764 2054 5626204145 16472 0ustar martinedv#!/bin/sh # A BSD-like install script for SYSV systems. # Written by Phil Hochstetler, phil@sequent.com # Modified by Larry Jones larry.jones@sdrc.com chmodcmd="" chowncmd="" chgrpcmd="" stripcmd="" FILE="" DIR="" while [ X"$1" != X ]; do case $1 in -m) chmodcmd="chmod $2" shift shift continue;; -o) chowncmd="chown $2" shift shift continue;; -g) chgrpcmd="chgrp $2" shift shift continue;; -s) stripcmd="strip" shift continue;; -*) echo "$0: unknown option $1" >&2 shift continue;; *) if [ X"$FILE" = X ] then FILE=$1 else DIR=$1 fi shift esac done if [ X"$FILE" = X -o X"$DIR" = X ]; then echo "Usage: install [-m ddd] [-o uid] [-g gid] [-s] srcfile dstdir" 1>&2 fi if [ ! -d "$DIR" ]; then mkdir $DIR fi dst=$DIR/`basename $FILE` rm -f $dst cp $FILE $dst if [ X"$chowncmd" != X ]; then $chowncmd $dst; fi if [ X"$chgrpcmd" != X ]; then $chgrpcmd $dst; fi if [ X"$stripcmd" != X ]; then $stripcmd $dst; fi if [ X"$chmodcmd" != X ]; then $chmodcmd $dst; fi exit 0 socks4-server-4.3.beta2.orig/doc/ 40755 7657 764 0 6156060500 15046 5ustar martinedvsocks4-server-4.3.beta2.orig/doc/Makefile100644 7657 764 630 6032340056 16562 0ustar martinedv# DO NOT start 'make' in this directory. Go to the top # directory of the SOCKS package and do it from there! #======================================================== install: for i in *.1; do \ $(INSTALL) -m 444 $$i $(MAN_DEST_DIR)/man1 ;\ done for i in *.5; do \ $(INSTALL) -m 444 $$i $(MAN_DEST_DIR)/man5 ;\ done for i in *.8; do \ $(INSTALL) -m 444 $$i $(MAN_DEST_DIR)/man8 ;\ done socks4-server-4.3.beta2.orig/doc/dump_sockdfc.8100644 7657 764 2412 6143524350 17700 0ustar martinedv.TH DUMP_SOCKDFC 8 "May 6, 1996" .SH NAME dump_sockdfc \- Display contents of frozen configuratyion file for SOCKS server .SH SYNOPSIS \fBdump_sockdfc [\fIinfile\fR]\fP .SH DESCRIPTION dump_sockdfc reads in a frozen configuration file for the SOCKS server and produces a listing of its contents on the standard output. The argument is optional; if omitted, \fB/etc/sockd.fc\fP is assumed. The frozen configuration file is produced by \fImake_sockdfc\fR and is essentially the memory image of the parsed configuration file. Using the frozen configuration file can reduce the start-up delay of the SOCKS server program since it no longer has to parse the file contents. When the SOCKS server starts, it always looks for the frozen configuration file \fB/etc/sockd.fc\fP first. If that file is not found, it then tries to use the plain-text configuration file \fB/etc/sockd.conf\fP. If you use frozen configuration, you must remember to run \fImake_sockdfc\fR every time after you modify the plain-text file or the SOCKS server will continue to use the frozen file of a previous configuration. .SH FILES \fB/etc/sockd.fc\fP, \fB/etc/sockd.conf\fP .SH SEE ALSO \fImake_sockdfc\fR(8), \fIsockd.conf\fR(5), \fIsockd.fc\fR(5) .SH AUTHOR .nf Ying-Da Lee, yingda@best.com or yingda@esd.sgi.com socks4-server-4.3.beta2.orig/doc/dump_sockdfr.8100644 7657 764 2322 6143524361 17721 0ustar martinedv.TH DUMP_SOCKDFR 8 "May 6, 1996" .SH NAME dump_sockdfr \- Display contents of frozen route file for SOCKS server .SH SYNOPSIS \fBdump_sockdfr [\fIinfile\fR]\fP .SH DESCRIPTION dump_sockdfr reads in a frozen route file for the SOCKS server and produces a listing of its contents on the standard output. The argument is optional; if omitted, \fB/etc/sockd.fr\fP is assumed. The frozen route file is produced by \fImake_sockdfr\fR and is essentially the memory image of the parsed route file. Using the frozen route file can reduce the start-up delay of the SOCKS server program since it no longer has to parse the file contents. When the SOCKS server starts, it always looks for the frozen route file \fB/etc/sockd.fr\fP first. If that file is not found, it then tries to use the plain-text route file \fB/etc/sockd.route\fP. If you use frozen route file, you must remember to run \fImake_sockdfr\fR every time after you modify the plain-text file or the SOCKS server will continue to use the frozen version of a previous route file. .SH FILES \fB/etc/sockd.fr\fP, \fB/etc/sockd.route\fP .SH SEE ALSO \fImake_sockdfr\fR(8), \fIsockd.fr\fR(5), \fIsockd.route\fR(5) .SH AUTHOR .nf Ying-Da Lee, yingda@esd.sgi.com or yingda@best.com socks4-server-4.3.beta2.orig/doc/dump_socksfc.8100644 7657 764 2422 6143524372 17724 0ustar martinedv.TH DUMP_SOCKSFC 8 "May 6, 1996" .SH NAME dump_socksfc \- Display contents of frozen configuratyion file for SOCKS clients .SH SYNOPSIS \fBdump_socksfc [\fIinfile\fR]\fP .SH DESCRIPTION dump_socksfc reads in a frozen configuration file for the SOCKS clients and produces a listing of its contents on the standard output. The argument is optional; if omitted, \fB/etc/socks.fc\fP is assumed. The frozen configuration file is produced by \fImake_socksfc\fR and is essentially the memory image of the parsed configuration file. Using the frozen configuration file can reduce the start-up delay of the SOCKS client programs since they no longer have to parse the file contents. When the SOCKS client starts, it always looks for the frozen configuration file \fB/etc/socks.fc\fP first . If that file is not found, it then tries to use the plain-text configuration file \fB/etc/socks.conf\fP. If you use frozen configuration, you must remember to run \fImake_socksfc\fR every time after you modify the plain-text file or the SOCKS clients will continue to use the frozen file of a previous configuration. .SH FILES \fB/etc/socks.fc\fP, \fB/etc/socks.conf\fP .SH SEE ALSO \fImake_socksfc\fR(8), \fIsocks.conf\fR(5), \fIsocks.fc\fR(5) .SH AUTHOR .nf Ying-Da Lee, yingda@esd.sgi.com or yingda@best.com socks4-server-4.3.beta2.orig/doc/make_sockdfc.8100644 7657 764 3014 6143524405 17650 0ustar martinedv.TH MAKE_SOCKDFC 8 "May 6, 1996" .SH NAME make_sockdfc \- Generates frozen configuratyion file for SOCKS server .SH SYNOPSIS \fBmake_sockdfc [\fIinfile\fR [\fIoutfile\fR] ]\fP .SH DESCRIPTION make_sockdfc reads in a plain-text configuration file for the SOCKS server and produces a frozen configuration file as the output. Both arguments are optional. The default for \fIinfile\fR is \fB/etc/sockd.conf\fP; the default for \fIoutfile\fP is \fB/etc/sockd.fc\fP. You may specify \fIinfile\fR while omitting \fIoutfile\fR, but you cannot specify \fIoutfile\fR without also speficying \fIinfile\fR. The contents of the frozen configuration file is essentially the memory image of the parsed input file. Using the frozen configuration file can reduce the start-up delay of the SOCKS server program since it no longer has to parse the file contents. When the SOCKS server starts, it always looks for the frozen configuration file \fB/etc/sockd.fc\fP first. If that file is not found, it then tries to use the plain-text configuration file \fB/etc/sockd.conf\fP. If you use frozen configuration, you must remember to run \fImake_sockdfc\fR every time after you modify the plain-text file or the SOCKS server will continue to use the frozen file of a previous configuration. To find out the contents of a frozen configuration file, use \fIdump_sockdfc\fR. .SH FILES \fB/etc/sockd.fc\fP, \fB/etc/sockd.conf\fP .SH SEE ALSO \fIdump_sockdfc\fR(8), \fIsockd.conf\fR(5), \fIsockd.fc\fR(5) .SH AUTHOR .nf Ying-Da Lee, yingda@best.com or yingda@esd.sgi.com socks4-server-4.3.beta2.orig/doc/make_sockdfr.8100644 7657 764 2714 6143524415 17676 0ustar martinedv.TH MAKE_SOCKDFR 8 "May 6, 1996" .SH NAME make_sockdfr \- Generates frozen route file for SOCKS server .SH SYNOPSIS \fBmake_sockdfr [\fIinfile\fR [\fIoutfile\fR] ]\fP .SH DESCRIPTION make_sockdfr reads in a plain-text route file for the SOCKS server and produces a frozen route file as the output. Both arguments are optional. The default for \fIinfile\fR is \fB/etc/sockd.route\fP; the default for \fIoutfile\fP is \fB/etc/sockd.fr\fP. You may specify \fIinfile\fR while omitting \fIoutfile\fR, but you cannot specify \fIoutfile\fR without also speficying \fIinfile\fR. The contents of the frozen route file is essentially the memory image of the parsed input file. Using the frozen route file can reduce the start-up delay of the SOCKS server program since it no longer has to parse the file contents. When the SOCKS server starts, it always looks for the frozen route file \fB/etc/sockd.fr\fP first. If that file is not found, it then tries to use the plain-text route file \fB/etc/sockd.route\fP. If you use frozen route file, you must remember to run \fImake_sockdfr\fR every time after you modify the plain-text file or the SOCKS server will continue to use the frozen version of a previous route file. To find out the contents of a frozen route file, use \fIdump_sockdfr\fR. .SH FILES \fB/etc/sockd.fr\fP, \fB/etc/sockd.route\fP .SH SEE ALSO \fIdump_sockdfr\fR(8), \fIsockd.fr\fR(5), \fIsockd.route\fR(5) .SH AUTHOR .nf Ying-Da Lee, yingda@esd.sgi.com or yingda@best.com socks4-server-4.3.beta2.orig/doc/make_socksfc.8100644 7657 764 3024 6143524427 17674 0ustar martinedv.TH MAKE_SOCKSFC 8 "May 6, 1996" .SH NAME make_socksfc \- Generates frozen configuratyion file for SOCKS clients .SH SYNOPSIS \fBmake_socksfc [\fIinfile\fR [\fIoutfile\fR] ]\fP .SH DESCRIPTION make_socksfc reads in a plain-text configuration file for the SOCKS clients and produces a frozen configuration file as the output. Both arguments are optional. The default for \fIinfile\fR is \fB/etc/socks.conf\fP; the default for \fIoutfile\fP is \fB/etc/socks.fc\fP. You may specify \fIinfile\fR while omitting \fIoutfile\fR, but you cannot specify \fIoutfile\fR without also speficying \fIinfile\fR. The contents of the frozen configuration file is essentially the memory image of the parsed input file. Using the frozen configuration file can reduce the start-up delay of the SOCKS client programs since they no longer have to parse the file contents. When the SOCKS client starts, it always looks for the frozen configuration file \fB/etc/socks.fc\fP first . If that file is not found, it then tries to use the plain-text configuration file \fB/etc/socks.conf\fP. If you use frozen configuration, you must remember to run \fImake_socksfc\fR every time after you modify the plain-text file or the SOCKS clients will continue to use the frozen file of a previous configuration. To find out the contents of a frozen configuration file, use \fIdump_socksfc\fR. .SH FILES \fB/etc/socks.fc\fP, \fB/etc/socks.conf\fP .SH SEE ALSO \fIdump_socksfc\fR(8), \fIsocks.conf\fR(5), \fIsocks.fc\fR(5) .SH AUTHOR .nf Ying-Da Lee, yingda@esd.sgi.com or yingda@best.com socks4-server-4.3.beta2.orig/doc/rfinger.1100644 7657 764 31 5606334260 16621 0ustar martinedv.so man1/socks_clients.1 socks4-server-4.3.beta2.orig/doc/rftp.1100644 7657 764 31 5606334261 16141 0ustar martinedv.so man1/socks_clients.1 socks4-server-4.3.beta2.orig/doc/rsockd.8100644 7657 764 10132 6143524466 16552 0ustar martinedv.TH RSOCKD 8 "May 6, 1996" .SH NAME rsockd \- SOCKSified SOCKS server .SH SYNOPSIS \fBrsockd [ \-ver | \-i | \-I ]\fP .SH DESCRIPTION \fIrsockd\fR is the SOCKSified version of the SOCKS server \fIsockd\fR. Functionally \fIrsockd\fR is identical to \fIsockd\fR except that it may (though not necessarily has to) make use of other SOCKS servers to reach some destinations. A number of \fIrsockd\fR's can be strung together or organized in a cascade or other more complicated structures to serve the needs of a particular network configuration and restrictions. Obviously this complicates the issues and make the setup and maintenance of the firewall more difficult. So use \fIsockd\fR instead whenever you can. This document only describes the features of \fIrsockd\fR that are different from \fIsockd\fR. You should read \fIsockd\fR(5) carefully to gain a basic understanding of of how the SOCKS server works. When \fIrsockd\fR receives a request, it checks the request again its configuration (in exactly the same way that \fIsockd\fR does) to decider whether the request is to be accepted. The primary difference between \fIsockd\fR and \fIrsockd\fR is in how they establish connection to the destination host of a accepted request. \fIsockd\fR assumes that it can connect directly to the destination host and proceeds to do so. \fIrsockd\fR makes no such assumption. Instead, it consults another configuration file to decide whether it can connect directly to the particular destination host or whether it has to use a proxy connection through another SOCKS server. In other words, it behaves just like a versatile SOCKS client in this regard. Therefore \fIrsockd\fR requires not only the SOCKS server configuration file \fB/etc/sockd.fc\fP or \fB/etc/sockd.conf\fP to decide whether to accept or reject a request, but also the client configuration file \fB/etc/socks.fc\fP or \fB/etc/socks.conf\fP to decide how to reach the destination host. If it is a multi-homed version \fIand\fR supports RBIND, it also needs the route file \fB/etc/sockd.fr\fP or \fB/etc/sockd.fr\fP to decide which network interface to use for a connection. Look at it in a different way, you can think of \fIsockd\fP as a special case of \fIrsockd\fP, one which can connect directly to all destination hosts. In fact, an \fIrsockd\fP using the client configuration consisting of only this line .nf .+1 \fBdirect ALL 0.0.0.0\fP .-1 .fi is functinally identical to the regular \fIsockd\fP. Anther thing to mention is related to the use of \fIidentd\fR. Only the SOCKS server which the requesting host directly connects to can find out the identity of the real user. Suppose user x on host C connects to \fIrsockd\fP on server B which in turn connects to \fIsockd\fP on server A in order to reach destination z. Host B can query \fIidentd\fR on host C to find out whether the user is indeed x. To host A, the request appears to originate from user x on host B. An \fIidentd\fR query from Host A to host B returns the userid that owns the \fIrsockd\fP process on host B, not the real user x. .SH OPTIONS See \fIsockd\fR(8). .SH EXAMPLES The follwoing is an example of the client configuration file. See related man pages for examples on server configuration and route files. .nf .+1 # /etc/socks.conf for rsockd of domain rnd.xyz.com # # Use proxy connection through SOCKS server on socks.market.xyz.com # to reach hosts within market.xyz.com sockd @=socks.market.xyz.com .market.xyz.com 0.0.0.0 # # Use direct connect to all other hosts within xyz.com direct .xyz.com 0.0.0.0 # # Use proxy connection through SOCKS server on gateway.xyz.com # to reach all others sockd @=gateway.xyz.com ALL 0.0.0.0 .-1 .fi .SH FILES \fB/etc/sockd.fc\fP, \fB/etc/sockd.conf\fP, \fB/etc/sockd.fr\fP, \fB/etc/sockd.route\fP, \fB/etc/socks.fc\fP, \fB/etc/socks.conf\fP, \fB/etc/inetd.conf\fP, \fB/etc/services\fP, \fB/var/adm/messages\fP, \fB/etc/syslog.conf\fP .SH SEE ALSO \fIsockd\fR(8), \fIsocks_clients\fR(1), \fIsockd.conf\fR(5), \fIsockd.route\fR(5), \fIsocks.conf\fR(5), \fImake_sockdfc\fR(8), \fImake_sockdfr\fR(8), \fIdump_sockdfc\fR(8), \fIdump_sockdfr\fR(8) .SH AUTHOR .nf Ying-Da Lee, ylee@syl.dl.nec.com socks4-server-4.3.beta2.orig/doc/rtelnet.1100644 7657 764 31 5606334261 16643 0ustar martinedv.so man1/socks_clients.1 socks4-server-4.3.beta2.orig/doc/rwhois.1100644 7657 764 31 5606334260 16500 0ustar martinedv.so man1/socks_clients.1 socks4-server-4.3.beta2.orig/doc/sockd.8100644 7657 764 15365 6156060500 16371 0ustar martinedv.TH SOCKD 8 "June 6, 1996" .SH NAME sockd \- Internet firewall secure socket server (proxy server) .SH SYNOPSIS \fBsockd [ \-ver | \-i | \-I ]\fP .SH DESCRIPTION \fIsockd \fR is an internet secure socket server, often referred to as a proxy server. It was designed primarily to provide hosts within a firewall access to resources outside of the firewall. Normally, hosts inside a firewall has no IP-accessibility to the network outside of the firewall. This reduces the risk of being intruded by unauthorized people from the Internet. Unfortunately, without IP-accessibility users on the inside hosts can no longer use many of the important tools such as telnet, ftp, xgopher, Mosaic, etc. to access the tremendous resources available in the Internet. With \fIsockd\fR installed on a server host, users on the other inside hosts can gain back the lost functionalities by using clients programs designed to work with \fIsockd\fR proxy server, e.g, \fIrtelnet\fR in place of \fItelnet\fR, \fIrftp\fR in place of \fIftp\fR, \fIrfinger\fR in place of \fIfinger\fR, etc. Since these client programs work like their normal counterparts without requiring direct IP-connectivity to the Internet, convenience to the users is accomplished without breaching the security. The server host that runs \fIsockd\fR does have to be open to the Internet, and it therefore requires special attention to make sure that it is secure. A configuration file \fB/etc/sockd.fc\fP (or \fB/etc/sockd.conf\fP) is used to control access to \fIsockd\fR and its services. Permission and denial of a service request can be decided based on various combinations of the requesting host, the destination host, the type of service (destination port number), as well as the requesting user. (See \fIsockd.conf\fR(5) and \fIsockd.fc\fR(5).) If the server host is multi-homed, i.e., having more than one network interface and with its IP_FORWARDING turned off, \fIand\fR the server support RBIND operation, then it must run a multi-homed version of \fIsockd\fP, which requires another control file \fB/etc/sockd.fr\fP (or \fB/etc/sockd.route\fP) to decide which interface to use for connection to any given destination host. See \fIsockd.route\fP(5) and \fIsockd.fr\fP(5). A multi-homed sockd can be run on a single-homed host as well if necessary; you just have to set up \fB/etc/sockd.route\fP to direct all traffic through the host's one and only network interface. \fIsockd\fR uses \fIsyslog\fR with facility \fBdaemon\fP and level \fBnotice\fP to log its activities and errors. Typical lines look like .nf .in +1 Apr 11 08:51:29 eon sockd[636]: connected -- Connect from don(don)@abc.edu to wxy.com (telnet) Apr 11 09:24:59 eon sockd[636]: terminated -- Connect from don(don)@abc.edu to wxy.com (telnet) Apr 11 09:24:59 eon sockd[636]: 1048 bytes from abc.edu, 285143 bytes from wxy.com Jun 22 18:24:54 eon sockd[884]: refused -- Connect from sam(unknown)@big.com to small.com (ftp) .in -1 .fi In these lines, the first user-id is the one reported by the client program, the second one (within the parentheses) is what is reported by \fIidentd\fP on the client host. These log lines usually appear in file \fB/var/adm/messages\fP though that can be changed by modifying \fB/etc/syslog.conf\fP. (See \fIsyslogd\fR(8) and \fIsyslog.conf\fR(5).) If you allow access to infosystems such as Gopher or WWW, you should be aware that they by nature would tend to get connections to hosts all over the world and would use not only Gopher and WWW ports but possibly also ports for finger, telnet, ftp, nntp, etc. as well as non-privileged ports ( > 1023). For a stand-alone sockd, \fB/etc/sockd.fc\fP (or \fB/etc/sockd.conf\fP) and \fB/etc/sockd.fr\fP (or \fB/etc/sockd.route\fP), if required, are only read and parsed once at the beginning of program execution. If you change the contents of either file and want to make the running sockd use the new contents, you must send a SIGHUP signal to the running sockd process. Sending a running stand-alone sockd a SIGUSR1 signal causes it to record on the systems's log file the effective contents of configuration and route files that it is currently using. You can find the process id of the stand-alone sockd in \fB/etc/sockd.pid\fP. Rather than using plain-text configuration file \fB/etc/sockd.conf\fP and route file \fB/etc/sockd.route\fP, \fIsockd\fR now looks for the corresponding \fIfrozen\fR files \fB/etc/sockd.fc\fP and \fB/etc/sockd.fr\fP first. The plain-text files are used only if the corresponding frozen files are not found. Use commands \fImake_sockdfc\fR and \fImake_sockdfr\fR to produce the frosen files. Use commands \fIdump_sockdfc\fR and \fIdump_sockdfr\fR to examine the contents of frozen files. (See \fImake_sockdfc\fR(8), \fImake_sockdfr\fR(8), \fIdump_sockdfc\fR(8), and \fIdump_sockdfr\fR(8).) Using frozen configuration and route files can save a lot of overhead at start-up of \fIsockd\fR. .SH OPTIONS The options are mutually exclusive and thus may only be used one at a time. .TP .B\-ver With this option, \fIsockd\fR prints its own version number, the version number of the SOCKS protocol, whether it is SOCKSified, whether it is a standalone daemon or must be run under inetd, whether it support RBIND, and whether a route file is required. .TP .B\-I Use \fIidentd\fR (RFC 1413) to verify the requester's user-id. Deny access if connection to client's \fIidentd\fR fails or if the result does not match the user-id reported by the client program. Client hosts without a properly installed \fIidentd\fR daemon will not be served. User verification is done before and in addition to the normal access control. This can be overridden in the sockd.conf file on a line by line basis. .TP .B\-i Similar to \fB-I\fP but more lenient. Access is denied only if client's \fIidentd\fR reports a user-id that's different from what the client program claims. This can be overridden in the sockd.conf file on a line by line basis. .PP Log entries similar to the following are produced upon failure of user-id verification: .nf .in +1 Apr 15 14:42:51 eon sockd[729]: cannot connect to identd on big.edu Apr 15 14:42:51 eon sockd[729]: refused -- Connect from bob(unknown)@big.edu to xyz.com (ftp) Jul 15 12:23:06 eon sockd[832]: *Alert*: real user is sam, not jim Jul 15 12:23:06 eon sockd[832]: refused -- Connect from jim(sam)@abc.org to bad.place.com (WWW) .in -1 .fi .SH FILES \fB/etc/sockd.fc\fP, \fB/etc/sockd.conf\fP, \fB/etc/sockd.fr\fP, \fB/etc/sockd.route\fP, \fB/etc/inetd.conf\fP, \fB/etc/services\fP, \fB/var/adm/messages\fP, \fB/etc/syslog.conf\fP .SH SEE ALSO \fIsocks_clients\fR(1), \fIsockd.conf\fR(5), \fIsockd.route\fR(5), \fIsocks.conf\fR(5), \fImake_sockdfc\fR(8), \fImake_sockdfr\fR(8), \fIdump_sockdfc\fR(8), \fIdump_sockdfr\fR(8) .SH AUTHOR .nf David Koblas, koblas@sgi.com Ying-Da Lee, ylee@syl.dl.nec.com David Mischel, dm@kansas.gene.com socks4-server-4.3.beta2.orig/doc/sockd.conf.5100644 7657 764 27463 6143524517 17325 0ustar martinedv.TH SOCKD.CONF 5 "May 6, 1996" .SH NAME sockd.conf \- SOCKS server configuration file .SH SYNOPSIS \fB/etc/sockd.conf\fP .SH DESCRIPTION The file \fB/etc/sockd.conf\fP is used to control access to SOCKS proxy server \fIsockd\fR and its services. (See \fIsockd\fP(8).) Permission and denial of a service request can be decided based on various combinations of the requesting host, the destination host, the type of service (destination port number), as well as the requesting user. A line in \fB/etc/sockd.conf\fP can be up to 1023 characters long. Each line may contain the following fields in the indicated order: .in +1 \fIaction [\fB?=\fIuse_identd] [\fB*=\fIuserlist] src_addr src_mask [dst_addr dst_mask] [op dst_port] [ : shell_cmd ]\fR .in -1 Spaces and tabs separate the fields. Fields enclosed in square brackets are optional. Blank lines are allowed. Except for lines that start with \fB#NO_IDENTD:\fP or \fB#BAD_ID:\fP, everything from the first appearance of \fB#\fP to the end of the line is considered comment and thus ignored by \fIsockd\fP during normal validation. The \fIaction\fR field must be either \fBpermit\fP or \fBdeny\fP and indicates the action to be taken if a request matches the conditions specified in that line. The \fIuse_identd\fR field, when present, must be \fBI\fP, \fBi\fP, or \fBn\fP, and is used to specify whether \fIidentd\fR verification should be employed for the current line. \fB?=I\fP demands the use of \fIidentd\fR for verifying the user's identity, denying access if connection to client's \fIidentd\fR fails or if the result does not match the user-id reported by the client program. \fB?=i\fP also specifies the use of \fIidentd\fR, but denies access only if client's \fIidentd\fR reports a user-id different from what the client program claims. \fB?=n\fP turns off the use of \fIidentd\fP. For the line in which these fields are used, they override the global \fIidentd\fR setting, which is determined by options \fB-I\fP and \fB-i\fP on the \fIsockd\fR command line. The \fIuserlist\fR field, when present, consists of one or more user-ids or filenames, with comma as separator. No spaces or tabs are allowed in the list. The user-ids should be ids of users on the requesting host, not those on the destination host or the SOCKS server host. The filenames must be full pathnames with the leading \fB/\fP. Inside the specified files, user-ids may be listed one or several per line, with any combination of blanks, tabs, and commas as separators. The appearance of \fB#\fP marks the remainder of the line as comment. Each line in the files may be up to 1023 characters long. If the \fB*=\fIuserlist\fR field is omitted, the line applies to all user-ids. The \fIsrc_addr\fR and \fIdst_addr\fR fields either specify IP addresses of hosts, networks, or subnets in the usual dotted form, e.g., \fB129.201.4.0\fP, or a domain name, e.g., \fBinternic.net\fP. The \fIsrc_mask\fR and \fIdst_mask\fR fields are masks for the corresponding IP addresses. Bits in these masks that are set to 0 indicate the bit positions to be ignored during comparisons of IP addresses. So, specifying 255.255.255.255 in the mask demands an exact match with the specified IP address field, whereas 0.0.0.0 in the mask causes a match no matter what IP address is specified. The contents of the mask fields are ignore, though they must still be supplied (use 0.0.0.0), if domain names are used for the corresponding address fields. If the domain name starts with a period, it specifies a zone and matches all domain names within that zone, otherwise it matches only the domain name itself. For example, \fBxyz.com\fP matches only xyz.com, while \fB.xyz.com\fP matches not only xyz.com, but also abc.xyz.com and this.and.that.xyz.com, among others. The special symbol \fBALL\fP (which must be entirely in uppercase) matches everything. Domain names are otherwise case-insensitive. If the \fIdst_addr dst_mask\fP pair is omitted, the line applies to all destination hosts. The \fIop\fR field must be \fBeq\fP, \fBneq\fP, \fBlt\fP, \fBgt\fP, \fBle\fP, or \fBge\fP, for the condition of equal, not equal, less than, greater than, less than or equal, and greater than or equal, respectively. The \fIdst_port\fR field can be either a port number, e.g., 23, or the equivalent service name as specified in the file /etc/services, e.g., \fBtelnet\fP for port number 23. If this pair is omitted, the line applies to all services, i.e., all destination port numbers. For example, consider the line .in +1 permit *=root,clivep 128.103.4.10 255.255.255.255 179.200.20.0 255.255.255.0 le 1023 .in -1 To match the conditions indicated in this line, a request must come from a user named 'root' or 'clivep' on the host whose IP address is 128.103.4.10 exactly, the destination host must have 179.200.20 in the first three bytes of its IP address (the last byte doesn't matter), and the service must use a port number less than or equal to 1023 on the destination host. Since the \fIaction\fR field is \fBpermit\fP, such requests will be granted. When a request is received by \fIsockd\fR, it checks against the lines in file \fB/etc/sockd.conf\fP, one line at a time. Once it finds a line with conditions that are matched by the request, the request is either granted or denied based on the \fIaction\fR field of that line. The remaining lines of file \fB/etc/sockd.conf\fP are skipped. If no matching line is found in the entire file, the request is denied. Be very careful how you order the lines in file \fB/etc/sockd.conf\fP. The following two lines in the indicated order .nf .in +1 deny *=abxyz 128.140.13.24 0.0.0.0 permit 128.140.13.24 0.0.0.0 .fi .in -1 disallow all requests by user 'abxyz' from host 128.140.13.24, but allow all requests by other users from the same host. Switch the order of the two lines and even requests by user 'abxyz' are granted. The \fIshell_cmd\fR field specifies a command string that is executed when the conditions on that line are satisfied. The following substitutions occur before the string is presented to the Borne shell for execution: .nf .in +1 %A -- replaced by the client host's domainname if known, by its IP address otherwise %a -- replaced by the client host's IP address %c -- replaced by "connect" or "bind", the command \fIsockd\fP is asked to execute %p -- replaced by the process id of \fIsockd\fP %S -- replaced by the service name (e.g., ftp) if known, by the destination port number otherwise %s -- replaced by the destination port number %U -- replaced by the user-id reported by \fIidentd\fP %u -- replaced by the user-id reported by the client program %Z -- replaced by the destination host's domainname if known, by its IP address otherwise %z -- replaced by the destination host's IP address %% -- replaced by a single % .fi .in -1 Several shell commands can be strung together in the usual way. For example, .nf .in +1 /usr/ucb/finger @%A | /usr/ucb/mail -s 'SOCKS: rejected %u@%A to %Z (%S)' root root@%A .in -1 .fi will \fIfinger\fP the client host and pipe the result into an email message for superusers at the server host and the client host with an appropriate Subject line. Most often this feature is used with a \fBdeny\fP line, but it can be used with \fBpermit\fP also. Although there is an implied 'deny all' at the end of the configuration file, you may supply one explicitly so as to take some specific action when requests are so rejected, e.g., (in one continuous line), .nf .in +1 deny 0.0.0.0 0.0.0.0 : /usr/ucb/finger @%A | /usr/ucb/mail -s 'SOCKS: rejected %u@%A to %Z (%S)' root root@%A .fi .in -1 You may also specify in \fB/etc/sockd.conf\fP commands to be executed when \fIsockd\fP cannot connect to client's \fIidentd\fP or when the user-ids reported by the client programs and the client's \fIidentd\fP do not match. These special entries must have \fB#NO_IDENTD:\fP and \fB#BAD_ID:\fP at the very beginning of the line, followed by the shell commands to be executed. For example: .nf .in +1 #NO_IDENTD: /usr/ucb/mail -s 'Please run identd on host %A' root@%A #BAD_ID: finger @%A | /usr/ucb/mail -s '%U pretends to be %u on %A' root root@%A .fi .in -1 Strictly speaking, \fIsockd\fP has no concept of inside/outside, it does know which is the requesting host and which the destination and that is the basis of its access control. Therefore it can be used to facilitate access from outside world into your internal networks as well. Needless to say, you have to take extreme caution if you choose to do so. If you don't need that kind of access, it is recommended that you specifically deny such connections in \fBsockd.conf\fR. For example, if the Class B IP network 129.1 is your internal network, use .nf .in +1 deny 0.0.0.0 0.0.0.0 129.1.0.0 255.255.0.0 .fi .in -1 as the first line of your \fBsockd.conf\fP to protect your inside hosts from all attempts of access from the outside world through SOCKS. If your internal network consists of several IP networks, you have to use one such line for each of them. In that case, it may be more convenient to use domain name instead, for instance, .nf .in +1 deny 0.0.0.0 0.0.0.0 .myowm.com 0.0.0.0 .fi .in -1 or .nf .in +1 deny ALL 0.0.0.0 .myown.com 0.0.0.0 .fi .in -1 may be used, assuming that myown.com is your domain. Though the use of domain names can be very convenient and can also reduce start-up overhead by reducing the number of lines in the configuration file, you should be very careful with your DNS (Domain Name System) setup. Here are some details that you should know. The original information the SOCKS server has of the source or the destination host is in the form of its IP address. The SOCKS server does a reverse DNS lookup to find the domain name correspodning to that IP address. It then does a normal DNS loopkup to translate the domain name back to an IP address. If the two IP addresses match, the SOCKS server retains both the domain name and the IP address as identifier of the host, and will use whichever as appropriate when it checkes the configuration file. If either of the two DNS lookups fails or if the two IP addresses do not match, SOCKS server retains only the original IP address as the only identifier of the host, with the consequence that it will not match any line in the configuration file which specifies a domain name (other than \fBALL\fP) in the corresponding address field. Suppose now you add a new host to your internal network before updating your nameserver's data with both the \fBA\fP record and the \fBPTR\fP record of the new host. When the SOCKS server receives a request with the IP address of the new host as its destination, at least one of the DNS lookups will fail. Consequently it will not be protected by lines in which the domain name is used in the destination address field. So, if you want to use domain name in the configuration file, be very sure that you always keep your DNS information up-to-date. It's probably a good idea to update your DNS data before adding a new host to your network. Also make sure that your SOCKS server always queries a nameserver which has the most up-to-date information of your internal network. You have the option of using the frozen configuration file \fB/etc/sockd.fc\fP instead of \fB/etc/sockd.conf\fP. The frozen file is produced by \fImake_sockdfc\fR and is essentially the memeory image of the parsed configuration file. Using it can reduce the start-up delay of the SOCKS server since it eliminates the need for parsing. When the SOCKS server starts, it always looks for the frozen configuration first and reverts to the unfrozen version only if no frozen configuration is found. All modifications to the configuration must be done on the plain-text, unfrozen file. Be sure that you run \fImake_sockdfc\fR every time after you modify /etc/sockd.conf or your SOCKS server would be using the frozen version of an older configuration. .SH SEE ALSO \fIdump_sockdfc\fP(8), \fImake_sockdfc\fP(8), \fIsockd\fP(8), \fIsocks.conf\fP(5), \fIsockd.fc\fP(5), socks4-server-4.3.beta2.orig/doc/sockd.fc.5100644 7657 764 2103 6143524543 16727 0ustar martinedv.TH SOCKD.FC 5 "May 6, 1996" .SH NAME sockd.fc \- Frozen configuration file for SOCKS server .SH SYNOPSIS \fB/etc/sockd.fc\fP .SH DESCRIPTION The frozen configuration file is produced by \fImake_sockdfc\fR and is essentially the memory image of the parsed configuration file. Using the frozen configuration file can reduce the start-up delay of the SOCKS server program since it no longer has to parse the file contents. When the SOCKS server starts, it always looks for the frozen configuration file \fB/etc/sockd.fc\fP first. If that file is not found, it then tries to use the plain-text configuration file \fB/etc/sockd.conf\fP. If you use frozen configuration, you must remember to run \fImake_sockdfc\fR every time after you modify the plain-text file or the SOCKS server will continue to use the frozen file of a previous configuration. To find out the contents of a frozen configuration file, use \fIdump_sockdfc\fR. .SH SEE ALSO \fIdump_sockdfc\fR(8), \fImake_sockdfc\fR(8), \fIsockd.conf\fR(5), \fIsockd.fc\fR(5) .SH AUTHOR .nf Ying-Da Lee, yingda@best.com or yingda@esd.sgi.com socks4-server-4.3.beta2.orig/doc/sockd.fr.5100644 7657 764 2031 6143524610 16741 0ustar martinedv.TH SOCKD.FR 5 "May 6, 1996" .SH NAME sockd.fr \- Frozen route file for multi-homed SOCKS proxy server .SH SYNOPSIS \fB/etc/sockd.fr\fP .SH DESCRIPTION The frozen route file is produced by \fImake_sockdfr\fR and is essentially the memory image of the parsed route file. Using the frozen route file can reduce the start-up delay of the SOCKS server program since it no longer has to parse the file contents. When the SOCKS server starts, it always looks for the frozen route file \fB/etc/sockd.fr\fP first. If that file is not found, it then tries to use the plain-text route file \fB/etc/sockd.route\fP. If you use frozen route file, you must remember to run \fImake_sockdfr\fR every time after you modify the plain-text file or the SOCKS server will continue to use the frozen version of a previous route file. To find out the contents of a frozen route file, use \fIdump_sockdfr\fR. .SH SEE ALSO \fIdump_sockdfr\fR(8), \fImake_sockdfr\fR(8), \fIsockd\fR(8), \fIsockd.route\fR(5) .SH AUTHOR .nf Ying-Da Lee, yingda@esd.sgi.com or yingda@best.com socks4-server-4.3.beta2.orig/doc/sockd.route.5100644 7657 764 11112 6143524622 17513 0ustar martinedv.TH SOCKD.ROUTE 5 "May 6, 1996" .SH NAME sockd.route \- Route file for multi-homed SOCKS proxy server .SH SYNOPSIS \fB/etc/sockd.route\fP .SH DESCRIPTION The file \fB/etc/sockd.route\fP is used by the SOCKS server program \fIsockd\fP to determine which of its network interfaces it should use to reach a given destination host. It is needed only if your SOCKS server host is multi-homed \fIand\fR your version of sockd supports RBIND. A multi-homed host is a host with more than one network interfaces and with its IP_FORWARDING turned off. Only the multi-homed version of \fIsockd\fP can be run on such hosts. You can find out the version of your sockd (or rsockd) by command .nf .+1 \fBsockd -ver\fP .-1 or .+1 \FBrsockd -ver\fP .-1 .fi A line in the file can be up to 1024 characters long. Lines starting with a `#' are comments. Non-comment lines must be of the form \fIif_addr dst_addr dst_mask\fR All three fields are required and are separated by spaces or tabs. Each filed is specified in the usual dotted form of IP addresses, e.g., 128.23.16.2. \fIif_addr\fR must be the IP address of one of the network interfaces on the SOCKS server host. \fIdst_addr\fR specifies either the IP address of a host, a network, or a subnet in the usual dotted form, e.g., \fB129.201.4.0\fP, or a domain name, e.g., \fBinternic.net\fP. \fIdst_mask\fR specifies mask for the IP address used in \fIdst_addr\fR. Bits in \fIdst_mask\fP that are set to 0 indicate the bit positions to be ignored during comparison of IP addresses. So, specifying 255.255.255.255 in \fIdst_mask\fP demands an exact match with \fIdst_addr\fP, whereas 0.0.0.0 in \fIdst_mask\fP causes a matching with any given destination address regardless of what is specified for \fIdst_addr\fP. If a domain name is used for \fIdst_addr\fR, the contents of \fIdst_mask\fR are ignored, though it must still be supplied (simply use 0.0.0.0). If the domain name starts with a period, it specifies a zone and matches all domain names within that zone, otherwise it matches only the domain name itself. For example, \fBxyz.com\fP matches only xyz.comP, while \fB.xyz.com\fP macthes not only xyz.com, but also abc.xyz.com and this.and.that.xyz.com, among others. The special symbol \fBALL\fP (which must be entirely in uppercase) matches everything. Domain names are otherwise case-insentive. When using a domain name in \fIdst_addr\fP, you have be very careful in maintaining your DNS setup. See the last few paragraphs in \fIsockd.conf\fP(5). When a multi-homed \fIsockd\fP receives a network request, it first checks with \fB/etc/sockd.fc\fP (or \fB/etc/sockd.conf\fP) to decide whether the request should be allowed or denied. For an allowable request, \fIsockd\fP then checks the given destination IP address or domain name against the \fIdst_addr dst_mask\fP pair in \fB/etc/sockd.route\fP, one line at a line. Once a match is found, the network interface of the corresponding \fIif_addr\fR field is used for connection to the destination host. Remaining lines in the file are skipped. Therefore the order of the lines in the file is of extreme importance. If no match is found throughout the file, a line indicating the error is produced using \fIsyslog\fP with facility \fBdaemon\fP and level \fIerr\fP and the request is ignored. You have the option of using the frozen route file \fB/etc/sockd.fr\fP instead of \fB/etc/sockd.route\fP. The frosen file is produced by \fImake_sockdfr\fR and is essentially the memory image of the parsed route file. Using it can reduce the start-up delay of the SOCKS server since it eliminate the need for parsing. Since the SOCKS server always looks for \fB/etc/sockd.fr\fP first, be sure that you always run \fImake_sockdfr\fR every time after you modifify \fB/etc/sockd.route\fP. .SH EXAMPLES Suppose you have a dual-homed host with interface 129.1.2.3 connecting to your internal Class B network 129.1, and interface 129.1.254.1 connecting to the outside world. If you only use the SOCKS server to provide connections to outside hosts, then the file \fB/etc/sockd.route\fP only needs one line: .nf .+1 129.1.254.1 0.0.0.0 0.0.0.0 .fi .-1 If you also use the SOCKS server to provide connection to internal hosts as well, then two lines would suffice: .nf .+1 129.1.2.3 129.1.0.0 255.255.0.0 129.1.254.1 0.0.0.0 0.0.0.0 .fi .-1 Note that these two lines must be in the order given above. If you prefer using domain name instead, the lines should be .nf .+1 129.1.2.3 .myown.com 0.0.0.0 129.1.254.1 0.0.0.0 0.0.0.0 .fi .-1 assuming that myown.com is your domain. .SH SEE ALSO \fIdump_sockdfr\fP(8), \fImake_sockdfr\fP(8), \fIsockd\fP(8), \fIsockd.fr\fP(5) socks4-server-4.3.beta2.orig/doc/socks.conf.5100644 7657 764 16730 6143524645 17341 0ustar martinedv.TH SOCKS.CONF 5 "May 6, 1996" .SH NAME .nf socks.conf \- SOCKS clients configuration file .fi .SH SYNOPSIS /etc/socks.conf .SH DESCRIPTION All SOCKS client programs use this file to determine whether to use direct or proxy connection to a given destination host, and to exert access control based on the destination host, the requested service (port number on the destination host), and the effective user-id of the requesting local user. If this file is absent, SOCKS clients will only try direct connections, making them behave like their regular counterparts. Each line in the file may be up to 1024 characters long. Lines starting with a \fB#\fP are comments. Non-comment lines must be of one of the three forms: .nf .+1 \fBdeny \fI[\fB*=\fIuserlist] dst_addr dst_mask [op dst_port] [: shell_cmd]\fP \fBdirect \fI[\fB*=\fIuserlist] dst_addr dst_mask [op dst_port] [: shell_cmd]\fP \fBsockd \fI[\fB@=\fIserverlist] [\fB*=\fIuserlist] dst_addr dst_mask [op dst_port] [: shell_cmd]\fR .-1 .fi A \fBdeny\fP line tells the SOCKS clients when to reject a request. A \fBdirect\fR lines tells when to use a direct connection. A \fBsockd\fR line indicates when to use a proxy connection and, optionally, which SOCKS proxy server or servers it should try. Spaces and tabs separate the fields. Fields enclosed in square brackets are optional. The \fIuserlist\fR field, when present, consists of one or more user-ids or filenames, with comma as separator. No spaces or tabs are allowed in the list. The user-ids should be ids of users on the local host, not those on the destination host or the SOCKS server host. The filenames must be full pathnames with the leading \fB/\fP. Inside the specified files, user-ids may be listed one or several per line, with any combination of blanks, tabs, and commas as separators. The appearance of \fB#\fP marks the remainder of the line as comment. Each line in the files may be up to 1023 characters long. If the \fB*=\fIuserlist\fR field is omitted, the line applies to all user-ids. The \fIdst_addr\fR field specifies either the IP address of a host, a network, or a subnet in the usual dotted form, e.g., \fB129.201.4.0\fP, or a doamin name, e.g., \fBinternic.net\fP. \fIdst_mask\fR specifies mask for the IP address used in \fIdst_addr\fR. Bits in \fIdst_mask\fP that are set to 0 indicate the bit positions to be ignored during comparison of IP addresses. So, specifying 255.255.255.255 in \fIdst_mask\fP demands an exact match with \fIdst_addr\fP, whereas 0.0.0.0 in \fIdst_mask\fP causes a matching with any given destination address regardless of what is specified for \fIdst_addr\fP. If a domain name is used for \fIdst_addr\fR, the contents of \fIdst_mask\fR are ignored, though it must still be supplied (simply use 0.0.0.0). If the domain name starts with a period, it specifies a zone and matches all domain names within that zone, otherwise it matches only the domain name itself. For example, \fBxyz.com\fP matches only xyz.comP, while \fB.xyz.com\fP macthes not only xyz.com, but also abc.xyz.com and this.and.that.xyz.com, among others. The special symbol \fBALL\fP (which must be entirely in uppercase) matches everything. Domain names are otherwise case-insentive. When using a domain name in \fIdst_addr\fP, you have be very careful in maintaining your DNS setup. See the last few paragraphs in \fIsockd.conf\fP(5). The \fIop\fP field must be \fBeq\fR, \fBneq\fR, \fBlt\fR, \fBgt\fR, \fBle\fR, or \fBge\fR, for the condition of equal, not equal, less than, greater than, less than or equal, and greater than or equal, respectively. The \fIdst_port\fP field can be either a port number, e.g., 23, or the equivalent service name as specified in file /etc/services, e.g., \fBtelnet\fR for port number 23. If this pair is omitted, the line applies to all services. The \fIserverlist\fP, which may only be used in a \fBsockd\fR line, consists of one or more SOCKS proxy servers, which the client program should try to use (in the indicated order) for establishing a proxy connection. Only commas can be used as separator, no spaces or tabs are allowed in the list. Domain names of the servers may be used in the list, though it is probably more prudent to specify IP addresses. If this field is omitted, the client program will use the default SOCKS proxy server, which is determined by the environment variable \fBSOCKS_SERVER\fR if it exists, or the name compiled into the SOCKS client program otherwise. Consider .nf .+1 sockd @=1.2.3.4 *=boss,root 11.12.13.14 255.255.255.255 eq telnet .-1 .fi To match the condition indicated in this line, a request must come from a local user whose effective id is either boss or root, the destination IP address must be 11.12.13.14 exactly, and the service requested must be telnet. In that case, connection to host 11.12.13.14 should be done via a SOCKS proxy server on host 1.2.3.4. Every time a SOCKS client has to make a network connection, it checks the pending request against the file \fB/etc/socks.conf\fR, one line at a time. Once it finds a line with conditions that are matched by the request, the action specified on that line is taken. The remaining lines of file \fB/etc/socks.conf\fR are skipped. So the order of the lines in the file is extremely important; switch two lines and you may have entirely different results. If no matching line is found throughout the file, the request is denied. The \fIshell_cmd\fR field specifies a command string that is executed when the conditions on that line are satisfied. The following substitutions occur before the string is presented to the Borne shell for execution: .nf .in +1 %A -- replaced by the client host's domainname if known, by its IP address otherwise %a -- replaced by the client host's IP address %c -- replaced by "connect" or "bind" %p -- replaced by the process id of the client program %S -- replaced by the service name (e.g., ftp) if known, by the destination port number otherwise %s -- replaced by the destination port number %U -- replaced by the user-id at login %u -- replaced by the effective user-id %Z -- replaced by the destination host's domainname if known, by its IP address otherwise %z -- replaced by the destination host's IP address %% -- replaced by a single % .fi .in -1 Several shell commands can be strung together in the usual way with `|', `;', etc. Although there is an implied 'deny all' at the end of the control file, you may supply one explicitly so as to take some specific action when requests are so rejected, e.g., .nf .in +1 deny 0.0.0.0 0.0.0.0 : /usr/ucb/mail -s 'SOCKS: rejected %S from %u to %Z' root .fi .in -1 Unlike the previous version, connection to address 127.0.0.1 or 0.0.0.0 is always done directly to localhost, so there is no need to specify either of them in \fB/etc/socks.conf\fP. You have the option of using the frozen file \fB/etc/socks.fc\fP instead of \fB/etc/socks.conf\fP. The frozen file is produced by \fImake_socksfc\fR and is essentially the memory image of the parsed configuration file. using it can reduced the start-up delay of SOCKS client applications since no parsing is needed. Because SOCKS client applications always look for \fB/etc/socks.fc\fP first, be sure that you always run \fImake_socksfc\fR every time after you modify \fB/etc/socks.conf\fP. .SH ENVIRONMENT \fBSOCKS_SERVER\fR, if defined, specifies the name or IP address of the SOCKS proxy server host to use, overriding the default server compiled into the programs. .SH SEE ALSO \fIdump_socksfc\fP(8), \fImake_socksfc\fP(8), \fIsockd\fP(8), \fIsockd.conf\fP(5), \fIsocks_clients\fP(1), \fIsocks.fc\fP(5) socks4-server-4.3.beta2.orig/doc/socks.fc.5100644 7657 764 2121 6143524656 16753 0ustar martinedv.TH SOCKS.FC 5 "May 6, 1996" .SH NAME .nf socks.fc \- Frozen configuration file for SOCKS clients .fi .SH SYNOPSIS /etc/socks.fc .SH DESCRIPTION The frozen configuration file is produced by \fImake_socksfc\fR and is essentially the memory image of the parsed configuration file. Using the frozen configuration file can reduce the start-up delay of the SOCKS client programs since they no longer have to parse the file contents. When the SOCKS client starts, it always looks for the frozen configuration file \fB/etc/socks.fc\fP first . If that file is not found, it then tries to use the plain-text configuration file \fB/etc/socks.conf\fP. If you use frozen configuration, you must remember to run \fImake_socksfc\fR every time after you modify the plain-text file or the SOCKS clients will continue to use the frozen file of a previous configuration. To find out the contents of a frozen configuration file, use \fIdump_socksfc\fR. .SH SEE ALSO \fIdump_socksfc\fR(8), \fImake_socksfc\fR(8), \fIsocks.conf\fR(5), \fIsocks_clients\fR(1) .SH AUTHOR .nf Ying-Da Lee, yingda@esd.sgi.com or yingda@best.com socks4-server-4.3.beta2.orig/doc/socks_clients.1100644 7657 764 11273 6143524700 20117 0ustar martinedv.TH SOCKS_CLIENTS 1 "May 6, 1996" .SH NAME .nf rfinger \- SOCKS client version of finger rftp \- SOCKS client version of ftp rtelnet \- SOCKS client version of telnet rwhois \- SOCKS client version of whois .fi .SH SYNOPSIS See the man pages on \fIfinger\fP(1), \fIftp\fP(1), \fItelnet\fP(1), \fIwhois\fP(1). .SH DESCRIPTION These programs provide the well-known functionalities to hosts within a firewall. Normally, when a firewall is constructed, IP-accessibility across the firewall is cut off to reduce security risk to hosts within the firewall. As a result, inside hosts can no longer use many of the well-known tools directly to access the resources outside the firewall. These programs restore the convenience of the well-known tools while maintaining the security requirement. Though the programs differ very much from their counterparts in the use of the communication scheme, they should behave almost indistinguishable to the users. Note though that rftp does echo the password as you type it in if you are using \fIanonymous\fP as log-in name. Unlike those of the previous versions, these are "versatile" clients, meaning that they can be used for connections to inside hosts directly and to outside hosts via SOCKS proxy servers. So they can be used as replacements of their traditional counterparts. When any of these programs starts, if the environment variable \fBSOCKS_BANNER\fR is defined, the program prints to \fBstderr\fP its version number and the name or IP address of its default SOCKS proxy server. It then consults the configuration file to determine whether a request should be allowed or denied based on the requesting user, the destination host, and the requested service. For allowable requests, the configuration file also dictates whether direct or proxy connection should be used to the given destination, and optionally the actual SOCKS servers to use for the proxy connection. The program lookps first for the frozen configuration file \fB/etc/socks.fc\fP first. If that's not found, it then looks for the file \fB/etc/socks.conf\fP. If both files are absent, these programs will only try direct connections to the destination hosts, making them behaving like their regular counterparts. You can use environment variable \fBSOCKS_NS\fR to set the nameserver for domainname resolutions. Be sure you use the IP address of the nameserver you want to use, not its domainname. If \fBSOCKS_NS\fR doesn't exist, the IP address defined by the symbol \fBSOCKS_DEFAULT_NS\fR at compile time is used if the programs were compiled with that symbol defined. Otherwise the nameservers specified in \fB/etc/resolv.conf\fR are used. All the client programs uses \fIsyslog\fP with facility \fBdaemon\fR and level \fBnotice\fR to log their activities. These log lines usually appear in file \fB/var/adm/messages\fP though that can be changed by modifying \fB/etc/syslog.conf\fR. (See \fIsyslogd\fP(8) and \fIsyslog.conf\fP(5).) Typical lines look like .nf .in +1 Apr 11 10:02:23 eon rfinger[631]: connect() from don(don) to abc.com (finger) using sockd at socksserv May 10 08:39:07 eon rftp[603]: connect() directly from blue(blue) to xyz.edu (ftp) May 10 08:39:09 eon rftp[603]: bind() directly from blue(blue) for xyz.edu (ftp) May 18 13:31:19 eon rtelnet[830]: connect() from root(jon) to xyz.edu (telnet) using sockd at sockd2 May 18 14:51:19 eon rtelnet[921]: refused -- connect() from jon(jon) to xyz.edu (telnet) .in -1 .fi Of the two user-ids appearing in each log line, the first is the effective user-id when the program is invoked, the second (that within the parentheses) is the one used at login. Access control applies to the effective user-ids. .SH SEE ALSO \fIfinger\fP(1), \fIftp\fP(1), \fIsockd\fP(8), \fIsockd.conf\fP(5), \fIsocks.conf\fP(5), \fItelnet\fP(1), \fIwhois\fP(1) .SH ENVIRONMENT \fBSOCKS_SERVER\fR, if defined, specifies the name or IP address of the SOCKS proxy server host to use, overriding the default server compiled into the programs. \fBSOCKS_NS\fR, if defined, specify the IP address of the domain nameserver that should be used for name resolution, overriding both the definition of symbol \fBSOCKS_DEFAULT_NS\fR and the file \fB/etc/resolv.conf\fR. \fBORIG_FINGER\fR, if defined, specified the (altered) full pathname of the original finger program, which should have been renamed before installing the rfinger as the regular finger. The \fIrfinger\fP program invokes the original \fIfinger\fP program to lookup information on local users. Normally this name should be compiled directly into \fIrfinger\fP, avoiding the need for this environment variable. Use \fBORIG_FINGER\FR only if you want to override what is compiled into \fIrfinger\fP. .SH AUTHOR David Koblas, koblas@netcom.com .PP Ying-Da Lee, ylee@syl.dl.nec.com socks4-server-4.3.beta2.orig/include/ 40755 7657 764 0 6156060414 15730 5ustar martinedvsocks4-server-4.3.beta2.orig/include/bstring.h100644 7657 764 351 5606334262 17631 0ustar martinedv/* for systems without bcopy(), bzero() and bcmp() */ #include #define bcopy(b1,b2,len) memmove(b2, b1, (size_t)(len)) #define bzero(b,len) memset(b, 0, (size_t)(len)) #define bcmp(b1,b2,len) memcmp(b1, b2, (size_t)(len)) socks4-server-4.3.beta2.orig/include/ptx-2.1.h100644 7657 764 1377 5606334262 17323 0ustar martinedv/* * Argument type passed to the wait() call. If you don't know what it is, then * leave it blank. The macro will place a pointer to the type for a cast... * This will either be "union wait" or "int". */ #define WAIT_ARG_TYPE int /* * Argument type passed to the signal() call (second parameter). If you don't * know what it is then don't define it.... this is placed in as a cast as-is. */ #define SIGNAL_ARG_TYPE void(*)(int) /* any additional missing headers */ #include #include #include #include #include /* any extra externs */ extern int h_errno; /* fix for missing gettimeofday() call */ #include #define gettimeofday(t, tz) get_process_stats((t), PS_SELF, NULL, NULL) socks4-server-4.3.beta2.orig/include/socks.h100644 7657 764 16221 6156060414 17342 0ustar martinedv#include #include /* * Default SOCKS server host; you MUST set this for your site. * This is overridden at run time by the contents of environment * variable SOCKS_SERVER if it exists. */ #define SOCKS_DEFAULT_SERVER "SOCKS.server.for.your.site" /* * Default Domain Nameserver for the SOCKS clients. * Leave it undefined if all your client mechines can do general * DNS lookup for all Internet hosts correctly with the DNS servers * specified in /etc/resolv.conf. * Otherwise, define it using the IP ADDRESS (NOT NAME!) of a DNS * server which can resolve all Internet hosts and which is IP-reachable * from your client machines. * This is overriden at run time by the contents of environment * variable SOCKS_NS if it exists. */ /* #define SOCKS_DEFAULT_NS "1.2.3.4" */ /* >>> jon r. luini */ /* * Default domain name to use for the resolver to use. * Leave it undefined unless you run in an environment where * you have a number of clients which will be running the socks * utilities without the correct domain name specified in /etc/resolv.conf * (or determined automatically by the system). If you try to run * socks and it complains that it cannot lookup the local hostname, * that is a good indication you need to define this appropriately. * This is overriden at run time by the contents of environment * variable SOCKS_DNAME if it exists. */ /* #define SOCKS_DEFAULT_DNAME "hal.COM" */ /* <<< jon r. luini */ /* * Full pathname of the regular 'finger' program. * You will have to rename your * regular 'finger' program to something else, e.g., from /usr/ucb/finger * to /usr/ucb/finger.orig and the pathname you should use here is the * new (altered) pathname, i.e., /usr/ucb/finger.orig. */ #define ORIG_FINGER "/usr/ucb/finger.orig" /* Overridden at runtime by environment variable ORIG_FINGER if it exists. */ /* Control file for clients */ #define SOCKS_CONF "/etc/socks.conf" #define SOCKS_FC "/etc/socks.fc" /* * Default port number for SOCKS services. * On the SOCKS server host, if the server is under inetd control, * then the port must be specified in socks/tcp entry in /etc/services. * For servers not under inetd control and for all clients, * the port number is obtained from socks/tcp entry in /etc/services if * it exists, otherwise the number defined by SOCKS_DEF_PORT will be used. */ #define SOCKS_DEF_PORT 1080 /* ** How long (in seconds) to keep a connection around while it is idle */ #define SOCKS_TIMEOUT 2*60*60 /* 2hr in seconds */ /* How long before connection attempts timed out */ #define CLIENT_CONN_TIMEOUT 60*2 /* 2 minutes */ #define SOCKD_CONN_TIMEOUT 60*3 /* 3 minutes */ /* You may have to adjust these to fit your network situation */ /* * Where the config file lives on the SOCKS server host. * This is the file that controls access to the SOCKS server * and its services. */ #define SOCKD_CONF "/etc/sockd.conf" #define SOCKD_FC "/etc/sockd.fc" /* * Define this if your SOCKS server is multi-homed (i.e., * having two or more network interfaces) and is not behaving * as a router (i.e., has its IP forwarding turned off). * Leave it undefined otherwise. * Has no effect is NO_RBIND is defined in the top Makefile. */ #define MULTIHOMED_SERVER /* * For multi-homed servers, you must supply the file /etc/sockd.route * to tell the program which interface to use for communicating with * which destination networks/hosts. See sockd man pages for details. * This has no effects if NO_RBIND (in top Makefile) is defined or * if MULTIHOMED_SERVER is undefined. */ #define SOCKD_ROUTE_FILE "/etc/sockd.route" #define SOCKD_FROUTE_FILE "/etc/sockd.fr" /* Current SOCKS protocol version */ #define SOCKS_VERSION 4 #define SOCKS_REPLY_VERSION 0 #define RELEASE "4.3" /* ** Response commands/codes */ #define SOCKS_CONNECT 1 #define SOCKS_BIND 2 #define SOCKS_RESULT 90 #define SOCKS_FAIL 91 #define SOCKS_NO_IDENTD 92 /* Failed to connect to Identd on client machine */ #define SOCKS_BAD_ID 93 /* Client's Identd reported a different user-id */ #if defined(__alpha) typedef unsigned int u_int32; #else typedef unsigned long u_int32; #endif typedef struct { u_int32 host; /* in network byte order */ unsigned short port; /* in network byte oreder */ unsigned char version; unsigned char cmd; } Socks_t; typedef enum portcmp Portcmp; enum portcmp { e_lt, e_gt, e_eq, e_neq, e_le, e_ge, e_nil }; /* * Define STAND_ALONE_SERVER if you want a standalone SOCKS server, * one which is not under the control of inetd. * This can drastically improve the performance if you have to use * a large sockd.conf file and especially if you are not using * frozen configuration files. */ /* #define STAND_ALONE_SERVER */ /* Location of the pid file of the running sockd. Meaningful only * when STAND_ALONE_SERVER is defined. */ #define PID_FILE "/etc/sockd.pid" #define BAD_ID_STR "#BAD_ID:" #define NO_IDENTD_STR "#NO_IDENTD:" /* structure for caching configurations. this improves performance in * clients or in servers * when STAND_ALONE_SERVER is defined. * Also used in the SOCKS library. */ struct config { char *userlist, *serverlist; int action; int use_identd; Portcmp tst; struct in_addr saddr, /* source addr, or */ /* output interface for route file */ smask, /* source mask */ daddr, /* destination addr */ dmask; /* destination mask */ unsigned short dport; char *cmdp, *sdomain, *ddomain; }; /* for the action field */ #define SOCKS_DIRECT 1 #define SOCKS_SOCKD 0 #define SOCKS_DENY -1 #define SOCKD_DENY 0 #define SOCKD_PERMIT 1 #define BAD_ID 5 #define NO_IDENTD 6 #ifdef MAKEFC #define CONF_INCR 1000 /* step increment for realloc */ #else #define CONF_INCR 100 /* step increment for realloc */ #endif /* #ifdef MAKEFC */ /* * Maximum number of concurrent requests a SOCKS server will accept. * Meaningful only if the server is not under the control * of inetd, i.e., when STAND_ALONE_SERVER is defined. */ #define MAX_CLIENTS 5 #ifdef SOLARIS /* for bcopy(), bzero() and bcmp() */ #include "bstring.h" #endif /* Define NO_SYSLOG to suppress logging */ /* #define NO_SYSLOG */ #if defined(NO_SYSLOG) # define syslog # define openlog #endif #define SYSLOG_FAC LOG_DAEMON /* #define SYSLOG_FAC LOG_LOCAL0 */ #define LOG_LOW LOG_NOTICE #define LOG_HIGH LOG_ERR /* The following struct linger declaration seemed to be * missing from older versions of LINUX but is present in * current. If you need it, you must define NEED_STRUCT_LINGER * in the top level Makefile. */ #ifdef NEED_STRUCT_LINGER /* * Structure used for manipulating linger option. */ struct linger { int l_onoff; /* option on/off */ int l_linger; /* linger time */ }; #endif /* ifdef NEED_STRUCT_LINGER */ #define IPADDRLENG 4 #define MAXIPPERHOST 20 #define MAXNAMESPERHOST 20 #define NAMELEN 128 struct sockshost_s { char *dmname[MAXNAMESPERHOST]; struct in_addr shipaddr[MAXIPPERHOST]; unsigned short port; /* in network order */ char portname[NAMELEN]; char user[NAMELEN]; char ruser[NAMELEN]; }; #define STREQ(a,b) (strcasecmp(a,b) == 0) #define IDENTD_TIMEOUT 15 #define NUMFAKEIP 20 /* must be <= 254 */ #define NUMHOSTENT 20 socks4-server-4.3.beta2.orig/lib/ 40755 7657 764 0 6157332562 15062 5ustar martinedvsocks4-server-4.3.beta2.orig/lib/Makefile100644 7657 764 2104 6057722166 16616 0ustar martinedv# DO NOT start 'make' in this directory. Go to the top # directory of the SOCKS package and do it from there! #============================================================================== OBJS = Rconnect.o SendGetDst.o porttoserv.o utils.o \ Rbind.o Rgethostbyname.o Rselect.o \ null_syslog.o porttoserv.o shell_cmd.o \ socks_ckcf.o socks_rdconf.o \ socks_rdfz.o socks_wrfz.o \ socks_dumpcf.o sockd_dumpcf.o sockd_dumprt.o \ sockd_rdconf.o sockd_rdroute.o \ $(GETPASS) $(STRDUP) LIB = libsocks.a CFLAGS = -I../include -I../libident $(OPTIMIZE) $(OTHER_CFLAGS) all: echocwd $(LIB) $(LIB): $(OBJS) ../include/socks.h ../Makefile rm -f $(LIB) ar rc $(LIB) $(OBJS) $(RANLIB) $(LIB) $(OBJS):: ../include/socks.h ../Makefile install: echocwd $(LIB) -if [ -d $(LIB_DEST_DIR) ]; then \ ($(INSTALL) -m 644 $(LIB) $(LIB_DEST_DIR); \ $(RANLIB) -t $(LIB_DEST_DIR)/$(LIB)); fi install.man: echocwd $(INSTALL) -m 444 ../doc/socks_clients.1 $(MAN_DEST_DIR)/man1 $(INSTALL) -m 444 ../doc/socks.conf.5 $(MAN_DEST_DIR)/man5 clean: echocwd rm -f *.o $(LIB) core echocwd: @pwd socks4-server-4.3.beta2.orig/lib/Rbind.c100644 7657 764 11534 6155435114 16400 0ustar martinedv/* Rbind.c */ #include #include #include #include #if defined(ISC) #include #endif /* #if defined(ISC) */ #include #include #include #include #if (defined(sun) && !defined(SOLARIS)) || defined(sgi) #include #else #include #endif #include "socks.h" extern int socksC_proto(); extern int socks_check_result(); extern int socks_connect_sockd(); extern int SOCKSinit(); extern int socks_ckcf(); extern struct sockshost_s socks_srcsh, socks_dstsh; #define socks_cmd socks_dstsh.user #define dst_name socks_dstsh.dmname[0] #define dst_serv socks_dstsh.portname #define src_user socks_srcsh.user #define real_user socks_srcsh.ruser #define src_name socks_srcsh.dmname[0] extern int socks_init_done; extern u_int32 socks_last_conn_host; extern unsigned short socks_last_conn_port; extern struct sockaddr_in socks_nsin; extern struct sockaddr_in socks_cursin; extern int socks_no_conf; extern struct config *scfAddr; extern int Nscf; extern int socks_useSyslog; extern char *socks_server; static int socks_direct; Rbind(sock, sin, size) int sock; struct sockaddr_in *sin; int size; { Socks_t dst; struct sockaddr_in psin; int i; int con_ret; struct timeval tmo; fd_set fds; int s; if (socks_init_done == 0) SOCKSinit("SOCKSclient"); bzero((char *)&psin, sizeof(psin)); strcpy(socks_cmd, "bind"); psin.sin_addr.s_addr = socks_last_conn_host; psin.sin_port = socks_last_conn_port; if (socks_no_conf) socks_direct = SOCKS_DIRECT; else socks_direct = socks_ckcf(&socks_srcsh, &socks_dstsh, scfAddr, Nscf, socks_useSyslog); if (socks_direct == SOCKS_DENY) { syslog(LOG_LOW, "Refused -- bind() from %s(%s) for %s (%s)", src_user, real_user, dst_name, dst_serv); errno = ECONNREFUSED; return -1; } if (socks_direct == SOCKS_DIRECT) { syslog(LOG_LOW, "bind() directly from %s(%s) for %s (%s)", src_user, real_user, dst_name, dst_serv); return (bind(sock, (struct sockaddr *)sin, size)); } con_ret = socks_connect_sockd(sock); if (con_ret == 0) { ; #ifdef SVR4 } else if ((errno == EINPROGRESS) || (errno == EAGAIN)) { #else } else if (errno == EINPROGRESS) { #endif while (1) { tmo.tv_sec = 0; tmo.tv_usec = 100000; FD_ZERO(&fds); FD_SET(sock, &fds); s = select(sock+1, NULL, &fds, NULL, &tmo); if ((s == 0) || ((s == -1) && (errno == EINTR))) continue; if (s < 0) { syslog(LOG_LOW, "select() in Rbind(): %m"); errno = ECONNREFUSED; return -1; } con_ret = connect(sock, (struct sockaddr *)&socks_nsin, sizeof(struct sockaddr_in)); if ((con_ret < 0) && (errno == EISCONN)) { con_ret = 0; break; #if defined(SVR4) } else if ((con_ret < 0) && ((errno == EALREADY) || (errno == EAGAIN))) { #else /* !defined(SVR4) */ } else if ((con_ret < 0) && (errno == EALREADY)) { #endif /* #if defined(SVR4) */ continue; } else break; } } if (con_ret < 0) { syslog(LOG_LOW, "Failed -- bind() from %s(%s) for %s (%s)", src_user, real_user, dst_name, dst_serv); errno = ECONNREFUSED; return -1; } syslog(LOG_LOW, "bind() from %s(%s) for %s (%s) using sockd at %s", src_user, real_user, dst_name, dst_serv, socks_server); dst.version = SOCKS_VERSION; dst.cmd = SOCKS_BIND; dst.port = socks_last_conn_port; dst.host = socks_last_conn_host; if (socksC_proto(sock, &dst) < 0) return(-1); socks_cursin.sin_family = AF_INET; socks_cursin.sin_port = dst.port; if (ntohl(dst.host) == INADDR_ANY) socks_cursin.sin_addr.s_addr = socks_nsin.sin_addr.s_addr; else socks_cursin.sin_addr.s_addr = dst.host; return (socks_check_result(dst.cmd)); } /* ** Stub routine since the listen will have alread succeded on the ** server. */ Rlisten(s, n) int s, n; { if (socks_direct) return (listen(s, n)); return 0; } /* ** Well we know where we got a connection from. */ Rgetsockname(sock, sin, size) int sock; struct sockaddr_in *sin; int *size; { if (socks_direct) return (getsockname(sock, (struct sockaddr *)sin, size)); *size = sizeof(struct sockaddr_in); *sin = socks_cursin; return 0; } /* ** Do an accept, which is really a select for some data on ** the present socket. */ Raccept(sock, sin, size) int sock; struct sockaddr_in *sin; int *size; { fd_set fds; Socks_t dst; int fdsbits = sock + 1; if (socks_direct) return(accept(sock, (struct sockaddr *)sin, size)); FD_ZERO(&fds); FD_SET(sock, &fds); if (select(fdsbits, &fds, NULL, NULL, NULL) > 0) { if (FD_ISSET(sock, &fds) && (socks_GetDst(sock, &dst) >= 0)) { sin->sin_family = AF_INET; sin->sin_port = dst.port; sin->sin_addr.s_addr = dst.host; return(dup(sock)); } } if (socks_useSyslog) syslog(LOG_LOW, "Connection refused by SOCKS server %s\n", socks_server); else fprintf(stderr, "Connection refused by SOCKS server %s\n", socks_server); return -1; } socks4-server-4.3.beta2.orig/lib/Rconnect.c100644 7657 764 34516 6155433304 17121 0ustar martinedv/* Rconnect */ #include #include #include #include #include #include #include #if defined(ISC) #include #endif /* #if defined(ISC) */ #include #include #include #include #include #include #if (defined(sun) && !defined(SOLARIS)) || defined(sgi) #include #else #include #endif #include "socks.h" #ifdef LINUX #include #endif /* >>> K. Shackelford */ #if defined(hpux) || defined(ultrix) || defined (__NetBSD__) || defined(__FreeBSD__) || defined(AIX) || defined(__bsdi__) || defined(SCO) || defined(ISC) || defined(BIND_RESOLVER) extern int h_errno; #endif /* <<< K.Shackelford */ #include #include char *socks_def_server; char *socks_server; char *socks_serverlist; extern char *getenv(); extern char *getlogin(); struct sockaddr_in socks_cursin; pid_t socks_conn_sock = 0; pid_t socks_conn_init = 0; unsigned short socks_conn_port = 0; u_int32 socks_conn_host = 0; int socks_conn_code = 0; int socks_init_done = 0; unsigned short socks_last_conn_port = 0; u_int32 socks_last_conn_host = 0; struct sockaddr_in socks_nsin; static struct sockaddr_in me; static struct passwd *pw; static int socks_direct = 0; struct config *scfAddr = NULL; int Nscf = 0; int socks_no_conf = 0; static char *cfStrings = NULL; int socks_useSyslog = 0; extern struct hostent socks_fakeIP[]; extern char *socks_porttoserv(); struct sockshost_s socks_srcsh, socks_dstsh; #define dst_name socks_dstsh.dmname[0] #define dst_serv socks_dstsh.portname #define src_user socks_srcsh.user #define real_user socks_srcsh.ruser #define src_name socks_srcsh.dmname[0] #define socks_cmd socks_dstsh.user struct in_addr socks_self; int socks_check_result(code) char code; { switch (code) { case SOCKS_FAIL: errno = ECONNREFUSED; return -1; case SOCKS_NO_IDENTD: errno = ECONNREFUSED; if (socks_useSyslog) syslog(LOG_LOW, "Error: SOCKS server %s cannot connect to identd on this host.\n", socks_server); else fprintf(stderr, "Error: SOCKS server %s cannot connect to identd on this host.\n", socks_server); return -1; case SOCKS_BAD_ID: errno = ECONNREFUSED; if (socks_useSyslog) syslog(LOG_LOW, "Error: user-id does not agree with the one reported by identd on this host.\n"); else fprintf(stderr, "Error: user-id does not agree with the one reported by identd on this host.\n"); return -1; default: return 0; } } int SOCKSinit(Progname) char *Progname; /* name of the calling program, "rfinger", "rftp", etc. */ { struct stat statfc, statcf; #ifdef SOCKS_DEFAULT_NS static char *defaultNS = SOCKS_DEFAULT_NS; #endif #ifdef SOCKS_DEFAULT_DNAME static char *defaultDNAME = SOCKS_DEFAULT_DNAME; #endif static char *defaultSERVER = SOCKS_DEFAULT_SERVER; char socks_src_name[NAMELEN]; char *cp, *ns, *dp; struct hostent *hp; struct servent *sp; int v,uid; if (socks_init_done) return; socks_init_done = 1; bzero((char *)&socks_cursin, sizeof(socks_cursin)); bzero((char *)&socks_nsin, sizeof(socks_nsin)); bzero((char *)&me, sizeof(me)); /* skip the path if included in Progname */ if( (cp = rindex(Progname, '/')) == NULL) cp = Progname; else cp++; #ifndef LOG_DAEMON (void) openlog(cp, LOG_PID); #else (void) openlog(cp, LOG_PID, SYSLOG_FAC); #endif socks_self.s_addr = inet_addr("127.0.0.1"); gethostname(socks_src_name, sizeof(socks_src_name)); if (socks_host(socks_src_name, &socks_srcsh) < 0) { if (socks_useSyslog) syslog(LOG_LOW, "Out of Memory\n"); else fprintf(stderr, "Out of Memory\n"); exit(1); } if (socks_srcsh.shipaddr[0].s_addr = 0) { if (socks_useSyslog) syslog(LOG_LOW, "Cannot resolve the host's own name: %s\n", socks_src_name); else fprintf(stderr, "Cannot resolve the host's own name: %s\n", socks_src_name); exit(1); } if ((cp = getlogin()) == NULL) { /* some systems returns NULL if process is not attached to a terminal */ strcpy(real_user, "unknown"); } else strncpy(real_user, cp, sizeof(real_user)); if ((pw = getpwuid(uid=geteuid())) == NULL) { if (socks_useSyslog) syslog(LOG_LOW, "Unknown user-id %d\n",uid); else fprintf(stderr, "Unknown user-id %d\n",uid); exit(1); } strncpy(src_user, pw->pw_name, sizeof(src_user)); #if !defined(DNS_THROUGH_NIS) if ((ns = getenv("SOCKS_NS")) == NULL) { #ifdef SOCKS_DEFAULT_NS ns = defaultNS; #else ; #endif } if ((dp = getenv("SOCKS_DNAME")) == NULL) { #ifdef SOCKS_DEFAULT_DNAME dp = defaultDNAME; #else ; #endif } if ((ns != NULL) || (dp != NULL)) { res_init(); #ifdef sgi sethostresorder("local:nis:bind"); #endif } #if defined(SOLARIS) (void)gethostbyname("dont.care"); /* without this, the first call to gethostbyname() will * wipe out what we put into the _res structure! */ #endif /* #if defined(SOLARIS) */ if (ns != NULL) { #ifdef ultrix _res.ns_list[0].addr.sin_addr.s_addr = inet_addr(ns); #else _res.nsaddr_list[0].sin_addr.s_addr = inet_addr(ns); #endif _res.nscount = 1; } if (dp != NULL) { strncpy(_res.defdname, dp, sizeof(_res.defdname)-1); } /* >>> jon r. luini */ /* #ifdef SOCKS_DEFAULT_DNAME bzero (_res.defdname, sizeof (_res.defdname)); if ( (cp = getenv("SOCKS_DNAME")) != NULL ) { strncpy (_res.defdname, cp, sizeof (_res.defdname)-1); } else { strncpy (_res.defdname, SOCKS_DEFAULT_DNAME, sizeof (_res.defdname)-1); } #endif */ /* <<< jon r. luini */ #endif /* #if !defined(DNS_THROUGH_NIS) */ if ((socks_def_server = getenv("SOCKS_SERVER")) == NULL) socks_def_server = defaultSERVER; socks_server = socks_def_server; if ((cp = getenv("SOCKS_BANNER")) != NULL) { if (socks_useSyslog) syslog(LOG_LOW, "SOCKS %s client. Default SOCKS server: %s\n", RELEASE, socks_def_server); else fprintf(stderr, "SOCKS lient. Default SOCKS server: %s\n", RELEASE, socks_def_server); } socks_nsin.sin_family = AF_INET; if ((sp = getservbyname("socks", "tcp")) != NULL) socks_nsin.sin_port = sp->s_port; else socks_nsin.sin_port = htons(SOCKS_DEF_PORT); /* if ((hp = gethostbyname(socks_server)) == NULL) { socks_nsin.sin_addr.s_addr = inet_addr(socks_server); } else { bcopy(hp->h_addr_list[0], &socks_nsin.sin_addr.s_addr, hp->h_length); } */ if (stat(SOCKS_FC, &statfc) == 0) socks_rdfz(SOCKS_FC, &scfAddr, &Nscf, &cfStrings, socks_useSyslog); else if (stat(SOCKS_CONF, &statcf) == 0) socks_rdconf(SOCKS_CONF, &scfAddr, &Nscf, socks_useSyslog); else socks_no_conf = 1; return 0; } int socks_connect_sockd(sock) int sock; /* returns 0 if successfully connected to a SOCKS server, returns -1 otherwise */ { int last = 0; int new_sock; struct hostent *hp; char **cp; while (socks_server = socks_serverlist) { if (socks_serverlist = index(socks_serverlist, ',')) *socks_serverlist = '\0'; if (socks_GetQuad(socks_server, &socks_nsin.sin_addr) != -1) { cp = NULL; } else if ((hp = gethostbyname(socks_server)) == NULL) { break; } else { cp = hp->h_addr_list; bcopy(*cp++, &socks_nsin.sin_addr, IPADDRLENG); } while (1) { new_sock = socket(PF_INET, SOCK_STREAM, 0); if (new_sock < 0) { return -1; } if (connect(new_sock, (struct sockaddr *)&socks_nsin, sizeof(struct sockaddr_in)) == 0) { if (dup2(new_sock, sock) < 0) { close(new_sock); return -1; } else { close(new_sock); return 0; } } else { close(new_sock); #ifdef EAGAIN if ((errno == EISCONN) || (errno == EINPROGRESS) || (errno == EAGAIN)) #else if ((errno == EISCONN) || (errno == EINPROGRESS)) #endif return -1; } if ((cp == NULL) || (*cp == NULL)) break; bcopy(*cp++, &socks_nsin.sin_addr, IPADDRLENG); } syslog(LOG_LOW, "Failed to connect to sockd at %s: %m", socks_server); if (!(socks_serverlist)) { return -1; } if (socks_serverlist) *socks_serverlist++ =','; } errno = ECONNREFUSED; return -1; } static int send_name(s, name) int s; char *name; { char *p = name; int i, n, ret; fd_set fds; int fdsbits = s + 1; struct timeval timeout; i = strlen(name) + 1; while ( i > 0) { FD_ZERO(&fds); FD_SET(s, &fds); timeout.tv_sec = 15; timeout.tv_usec = 0; if ((ret = select(fdsbits, NULL, &fds, NULL, &timeout)) < 0) { if (errno == EINTR) continue; return(-1); } if (ret == 0) continue; if((n = write(s, p, i)) <= 0) { return(-2); } p += n; i -= n; } return(0); } int socksC_proto(s, dst) int s; Socks_t *dst; { int sta; u_int32 addr; char *hostname; if ((sta = socks_SendDst(s, dst)) < 0) { if (socks_useSyslog) syslog(LOG_LOW, "Connection refused by SOCKS server %s\n", socks_server); else fprintf(stderr, "Connection refused by SOCKS server %s\n", socks_server); return(sta); } if ((sta = send_name(s, src_user)) < 0) { if (socks_useSyslog) syslog(LOG_LOW, "Connection refused by SOCKS server %s\n", socks_server); else fprintf(stderr, "Connection refused by SOCKS server %s\n", socks_server); return(sta); } addr = ntohl(dst->host); if ((addr >> 8) == 0) { /* Using fake IP, send destination hostname */ if ((sta = send_name(s, socks_fakeIP[addr-1].h_name)) < 0) { if (socks_useSyslog) syslog(LOG_LOW, "Connection refused by SOCKS server %s\n", socks_server); else fprintf(stderr, "Connection refused by SOCKS server %s\n", socks_server); } } if ((sta = socks_GetDst(s, dst)) < 0) { if (socks_useSyslog) syslog(LOG_LOW, "Connection refused by SOCKS server %s\n", socks_server); else fprintf(stderr, "Connection refused by SOCKS server %s\n", socks_server); return(sta); } return(0); } static void quit_C_proto() { exit(SOCKS_FAIL); } static void do_C_proto(sock, port, addr) int sock; unsigned short port; u_int32 addr; { Socks_t dst; signal(SIGALRM, quit_C_proto); alarm(CLIENT_CONN_TIMEOUT); dst.version = SOCKS_VERSION; dst.cmd = SOCKS_CONNECT; dst.port = port; dst.host = addr; if (socksC_proto(sock, &dst) < 0) { alarm(0); exit(SOCKS_FAIL); } alarm(0); if ((dst.cmd == SOCKS_FAIL) || (dst.cmd == SOCKS_NO_IDENTD) || (dst.cmd == SOCKS_BAD_ID)) { exit(dst.cmd); } exit(SOCKS_RESULT); } int Rconnect(sock, sin, size) int sock; struct sockaddr_in *sin; int size; { Socks_t dst; int i; int res_ret, con_ret, con_errno; u_int32 addr; int status, wait_ret, child_pid; if (sin->sin_family != AF_INET) { return connect(sock, (struct sockaddr *)sin, size); } if (socks_init_done == 0) SOCKSinit("SOCKSclient"); if ((sock != socks_conn_sock) || (sin->sin_port != socks_conn_port) || (sin->sin_addr.s_addr != socks_conn_host)) { if (socks_conn_init) kill(socks_conn_init, SIGKILL); socks_conn_code = 0; socks_conn_init = 0; strcpy(socks_cmd, "connect"); if (socks_IPtohost(&sin->sin_addr, &socks_dstsh) < 0) { if (socks_useSyslog) fprintf(stderr, "Out of memory\n"); else fprintf(stderr, "Out of memory\n"); exit(1); } socks_dstsh.port = sin->sin_port; socks_porttoserv(sin->sin_port, dst_serv, sizeof(dst_serv)); } else if (status = socks_conn_code) { socks_conn_init = 0; socks_conn_code = 0; socks_conn_sock = 0; socks_conn_port = 0; socks_conn_host = 0; res_ret = socks_check_result(status); if (status == SOCKS_RESULT) { errno = EISCONN; socks_last_conn_host = sin->sin_addr.s_addr; socks_last_conn_port = sin->sin_port; } else { syslog(LOG_LOW, "Connection failed.\n"); } return -1; } else if (socks_conn_init) { #if defined(NO_WAITPID) wait_ret = wait3(&status, WNOHANG, (struct rusage *) NULL); #else wait_ret = waitpid(socks_conn_init, &status, WNOHANG); #endif /* #if defined(NO_WAITPID) */ if (wait_ret == 0) { errno = EALREADY; return -1; } else if (wait_ret == socks_conn_init) { socks_conn_init = 0; socks_conn_code = 0; socks_conn_sock = 0; socks_conn_port = 0; socks_conn_host = 0; if (status & 0x00ff) { kill(socks_conn_init, SIGKILL); errno = ECONNREFUSED; syslog(LOG_LOW, "Connection failed.\n"); return -1; } else { status = (status >> 8) & 0x00ff; res_ret = socks_check_result(status); if (res_ret == 0) { errno = EISCONN; socks_last_conn_host = sin->sin_addr.s_addr; socks_last_conn_port = sin->sin_port; } else { syslog(LOG_LOW, "Connection failed.\n"); } return -1; } } else { kill(socks_conn_init, SIGKILL); errno = ECONNREFUSED; socks_conn_init = 0; socks_conn_code = 0; socks_conn_sock = 0; socks_conn_port = 0; socks_conn_host = 0; syslog(LOG_LOW, "Connection failed.\n"); return -1; } } if (socks_no_conf) socks_direct = SOCKS_DIRECT; else socks_direct = socks_ckcf(&socks_srcsh, &socks_dstsh, scfAddr, Nscf, socks_useSyslog); if (socks_direct == SOCKS_DENY) { syslog(LOG_LOW, "refused -- connect() from %s(%s) to %s (%s)", src_user, real_user, dst_name, dst_serv); errno = ECONNREFUSED; return -1; } if (socks_direct == SOCKS_DIRECT) { syslog(LOG_LOW, "connect() directly from %s(%s) to %s (%s)", src_user, real_user, dst_name, dst_serv); con_ret = connect(sock, (struct sockaddr *)sin, size); if (con_ret == 0) { socks_last_conn_host = sin->sin_addr.s_addr; socks_last_conn_port = sin->sin_port; } return(con_ret); } con_ret = socks_connect_sockd(sock); if (con_ret == 0) { syslog(LOG_LOW, "connect() from %s(%s) to %s (%s) using sockd at %s", src_user, real_user, dst_name, dst_serv, socks_server); dst.version = SOCKS_VERSION; dst.cmd = SOCKS_CONNECT; dst.port = sin->sin_port; dst.host = sin->sin_addr.s_addr; if (socksC_proto(sock, &dst) < 0) { return -1; } res_ret = socks_check_result(dst.cmd); if (res_ret == 0) { socks_last_conn_host = sin->sin_addr.s_addr; socks_last_conn_port = sin->sin_port; } return(res_ret); } if ((con_ret < 0) && (errno != EINPROGRESS)) { return -1; } syslog(LOG_LOW, "connect() from %s(%s) to %s (%s) using sockd at %s", src_user, real_user, dst_name, dst_serv, socks_server); switch (child_pid = fork()) { case -1: if (socks_useSyslog) syslog(LOG_LOW, "Rconnect(): cannot fork: %m\n"); else perror("Rconnect(): fork()"); errno = ECONNREFUSED; return -1; case 0: do_C_proto(sock, sin->sin_port, sin->sin_addr.s_addr); default: socks_conn_init = child_pid; socks_conn_code = 0; socks_conn_sock = sock; socks_conn_port = sin->sin_port; socks_conn_host = sin->sin_addr.s_addr; errno = EINPROGRESS; return -1; } } socks4-server-4.3.beta2.orig/lib/Rgethostbyname.c100644 7657 764 7614 6155621061 20317 0ustar martinedv/* Rgethostbynam.c */ #include #include #include #include #if defined(ISC) #include #endif /* #if defined(ISC) */ #include #include #include #if (defined(sun) && !defined(SOLARIS)) || defined(sgi) #include #else #include #endif #include "socks.h" #if !defined(NULL) #define NULL 0 #endif extern int socks_useSyslog; struct hostent socks_fakeIP[NUMFAKEIP]; static char *Fh_aliases[NUMFAKEIP], *Fh_addr_list[NUMFAKEIP*2]; static u_int32 F_iplist[NUMFAKEIP]; static struct hostent socks_Hostent[NUMHOSTENT]; static int initHostent() { int i; char **faddr_list = Fh_addr_list; for (i = 0; i < NUMFAKEIP; i++) { socks_fakeIP[i].h_name = NULL; Fh_aliases[i] = NULL; socks_fakeIP[i].h_aliases = &Fh_aliases[i]; socks_fakeIP[i].h_addrtype = AF_INET; socks_fakeIP[i].h_length = IPADDRLENG; socks_fakeIP[i].h_addr_list = faddr_list; *faddr_list++ = (char *)&F_iplist[i]; F_iplist[i] = htonl(i+1); *faddr_list++ = 0; } for (i = 0; i < NUMHOSTENT; i++) { socks_Hostent[i].h_name = NULL; socks_Hostent[i].h_addrtype = AF_INET; socks_Hostent[i].h_length = IPADDRLENG; } } /* initHostent */ struct hostent *Rgethostbyname(name) char *name; { static int initdone = 0; static int nextFIP = 0; static int currentFIP = 0; static int numFIP = 0; struct hostent *hr, *hp; int ipt, naliases, naddrs; char *iplist = NULL; char **iparray = NULL; char *halist = NULL; char **harray = NULL; char **p; char *q; int i, cl; static int nextHosetent = 0; static int numHostent = 0; static int currentHostent = 0; if (initdone == 0) { initHostent(); initdone = 1; } for (ipt = currentHostent, i = 0; i < numHostent; i++) { hr = &socks_Hostent[ipt]; if (strcasecmp(hr->h_name, name) == 0) return hr; if (--ipt < 0) ipt = NUMHOSTENT -1; } for (ipt = currentFIP, i = 0; i < numFIP; i++) { hr = &socks_fakeIP[ipt]; if ( strcasecmp(hr->h_name, name) == 0) return hr; if (--ipt < 0) ipt = NUMFAKEIP -1; } if ((hp = gethostbyname(name)) != NULL) goto realIP; /* Return hostent address of a fake IP */ if (++currentFIP >= NUMFAKEIP) currentFIP = 0; if (++numFIP >= NUMFAKEIP) numFIP = NUMFAKEIP; hr = &socks_fakeIP[currentFIP]; if (hr->h_name != NULL) { free(hr->h_name); } if ((hr->h_name = strdup(name)) == NULL) { goto out_of_memory; } return hr; realIP: /* Return hostent address of a real IP */ if (++currentHostent >= NUMHOSTENT) currentHostent = 0; if (++numHostent >= NUMHOSTENT) numHostent = NUMHOSTENT; hr = &socks_Hostent[currentHostent]; if (hr->h_name != NULL) { free(hr->h_name); harray = hr->h_aliases; if (*harray != NULL) free(*harray); free(harray); iparray = hr->h_addr_list; free(*iparray); free(iparray); } if ((hr->h_name = strdup(name)) == NULL) { goto out_of_memory; } naliases = 1; cl = 0; for (p = hp->h_aliases; *p != NULL; p++) { naliases++; cl += (strlen(*p) +1); } if (cl > 0) { if ((halist = (char *)malloc(cl)) == NULL) { goto out_of_memory; } } naddrs = 1; for (p = hp->h_addr_list; *p != NULL; p++) { naddrs++; } if (((harray = (char **)malloc(naliases * sizeof(iplist))) == NULL) || ((iparray = (char **)malloc(naddrs * sizeof(iplist))) == NULL) || ((iplist = (char *)malloc((naddrs - 1) * IPADDRLENG)) == NULL)) { goto out_of_memory; } hr->h_aliases = harray; for (p = hp->h_aliases; *p != NULL; p++) { *harray++ = halist; for (q = *p; *q != '\0'; ) *halist++ = *q++; *halist++ = '\0'; } *harray = NULL; hr->h_addr_list = iparray; for (p = hp->h_addr_list; *p != NULL; p++) { *iparray++ = iplist; q = *p; *iplist++ = *q++; *iplist++ = *q++; *iplist++ = *q++; *iplist++ = *q++; } *iparray = NULL; return hr; out_of_memory: if(socks_useSyslog) syslog(LOG_LOW, "Out of memory\n"); else fprintf(stderr, "Out of memory\n"); exit(1); } socks4-server-4.3.beta2.orig/lib/Rselect.c100644 7657 764 3357 6144760167 16736 0ustar martinedv#include #include #include /* >>> Chee-Wai Yeung */ #include /* <<< Chee-Wai Yeung */ #include "socks.h" #ifndef NULL #define NULL 0L #endif extern pid_t socks_conn_init; extern pid_t socks_conn_sock; extern int socks_conn_code; extern int socks_conn_host; extern int socks_conn_port; extern int socks_last_conn_host; extern int socks_last_conn_port; int Rselect(width, readfds, writefds, exceptfds, timeout) int width; fd_set *readfds, *writefds, *exceptfds; struct timeval *timeout; { int wait_ret, status; if(!socks_conn_init ) { return(select(width, readfds, writefds, exceptfds, timeout)); } if (readfds != NULL) FD_CLR(socks_conn_sock, readfds); if (exceptfds != NULL) FD_CLR(socks_conn_sock, exceptfds); if ((writefds == NULL) || !FD_ISSET(socks_conn_sock, writefds)) return(select(width, readfds, writefds, exceptfds, timeout)); #if defined(NO_WAITPID) wait_ret = wait3(&status, WNOHANG, (struct rusage *) NULL); #else wait_ret = waitpid(socks_conn_init, &status, WNOHANG); #endif /* #if defined(NO_WAITPID) */ if (wait_ret == 0) { FD_CLR(socks_conn_sock, writefds); return(select(width, readfds, writefds, exceptfds, timeout)); } else if (wait_ret == socks_conn_init) { if (status & 0x00ff) { kill(socks_conn_init, SIGKILL); socks_conn_init = 0; socks_conn_code = SOCKS_FAIL; } else { status = (status >> 8) & 0x00ff; if (status == SOCKS_RESULT) { socks_last_conn_host = socks_conn_host; socks_last_conn_port = socks_conn_port; } socks_conn_init = 0; socks_conn_code = status; } } else { kill(socks_conn_init, SIGKILL); socks_conn_init = 0; socks_conn_code = SOCKS_FAIL; } return(select(width, readfds, writefds, exceptfds, timeout)); } socks4-server-4.3.beta2.orig/lib/SendGetDst.c100644 7657 764 4064 6032623243 17322 0ustar martinedv/* SendGetDst */ #include #if defined(ISC) #include #endif /* #if defined(ISC) */ #include #include #include #if defined(ISC) #include #endif /* #if defined(ISC) */ #include "socks.h" #ifndef NULL #define NULL 0L #endif int socks_SendDst(s, dst) int s; Socks_t *dst; { char c[sizeof(Socks_t)]; char *p = c; int i = sizeof(Socks_t), n, ret; fd_set fds; int fdsbits = s + 1; struct timeval timeout; c[0] = dst->version; c[1] = dst->cmd; bcopy(&dst->port, c+2, sizeof(dst->port)); bcopy(&dst->host, c+2+sizeof(dst->port), sizeof(dst->host)); while ( i > 0) { FD_ZERO(&fds); FD_SET(s, &fds); timeout.tv_sec = 15; timeout.tv_usec = 0; if ((ret = select(fdsbits, NULL, &fds, NULL, &timeout)) == 0) continue; if (ret < 0) { if (errno == EINTR) continue; else { /* syslog(LOG_LOW, "select() in socks_SendDst(): %m"); */ return -1; } } if((n = write(s, p, i)) > 0) { p += n; i -= n; } else if ((n < 0) && ((errno == EWOULDBLOCK) || (errno == EINTR))) continue; else { /* syslog(LOG_LOW, "write() in socks_SendDst(): %m"); */ return (-2); } } return 0; } int socks_GetDst(s, dst) int s; Socks_t *dst; { char c[sizeof(Socks_t)]; char *p = c; int i = sizeof(Socks_t), n, ret; fd_set fds; int fdsbits = s + 1; struct timeval timeout; while ( i > 0) { FD_ZERO(&fds); FD_SET(s, &fds); timeout.tv_sec = 15; timeout.tv_usec = 0; if ((ret = select(fdsbits, &fds, NULL, NULL, &timeout)) == 0) continue; if (ret < 0) { if (errno == EINTR) continue; else { /* syslog(LOG_LOW, "select() in socks_GetDst(): %m"); */ return -1; } } if((n = read(s, p, i)) > 0) { p += n; i -= n; } else if ((n < 0) && ((errno == EWOULDBLOCK) || (errno == EINTR))) continue; else { /* syslog(LOG_LOW, "read() in socks_GetDst(): %m"); */ return -2; } } dst->version = c[0]; dst->cmd = c[1]; bcopy(c+2, &dst->port, sizeof(dst->port)); bcopy(c+2+sizeof(dst->port), &dst->host, sizeof(dst->host)); return 0; } socks4-server-4.3.beta2.orig/lib/getpass.c100644 7657 764 5724 6031633772 16777 0ustar martinedv/* getpass */ /* * Copyright (c) 1988 The Regents of the University of California. * All rights reserved. * * Redistribution and use in source and binary forms are permitted * provided that the above copyright notice and this paragraph are * duplicated in all such forms and that any documentation, * advertising materials, and other materials related to such * distribution and use acknowledge that the software was developed * by the University of California, Berkeley. The name of the * University may not be used to endorse or promote products derived * from this software without specific prior written permission. * THIS SOFTWARE IS PROVIDED ``AS IS'' AND WITHOUT ANY EXPRESS OR * IMPLIED WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED * WARRANTIES OF MERCHANTIBILITY AND FITNESS FOR A PARTICULAR PURPOSE. */ #if defined(LIBC_SCCS) && !defined(lint) static char sccsid[] = "@(#)getpass.c based on 5.3 (Berkeley) 9/22/88"; #endif /* LIBC_SCCS and not lint */ #if defined(__NetBSD__) #define USE_OLD_TTY #endif /* >>> Craig Metz */ #if defined(LINUX) #define SVR3 #endif /* <<< Craig Metz */ #if defined(SOLARIS) || defined(hpux) #include #include #include #else #ifdef SVR3 #include #else #include #endif #include #endif #include char * getpass(prompt) char *prompt; { #ifdef SVR3 struct termio term_struct; tcflag_t svflagval; #else struct sgttyb ttyb; int svflagval; #endif register int ch; register char *p; FILE *fp, *outfp; #ifdef SOLARIS sigset_t maskset; #else long omask; #endif #define PASSWD_LEN 128 static char buf[PASSWD_LEN + 1]; /* * read and write to /dev/tty if possible; else read from * stdin and write to stderr. */ if ((outfp = fp = fopen("/dev/tty", "w+")) == NULL) { outfp = stderr; fp = stdin; } #ifdef SVR3 (void)ioctl(fileno(fp), TCGETA, &term_struct); svflagval = term_struct.c_lflag; term_struct.c_lflag &= ~ECHO; #else (void)ioctl(fileno(fp), TIOCGETP, &ttyb); svflagval = ttyb.sg_flags; ttyb.sg_flags &= ~ECHO; #endif #ifdef SOLARIS if (sigprocmask(0, (sigset_t *)0, &maskset) || sighold(SIGINT)) { perror("Can't block SIGINT in getpass() "); exit(1); } #else omask = sigblock(sigmask(SIGINT)); #endif #ifdef SVR3 (void)ioctl(fileno(fp), TCSETA, &term_struct); #else (void)ioctl(fileno(fp), TIOCSETP, &ttyb); #endif fputs(prompt, outfp); rewind(outfp); /* implied flush */ for (p = buf; (ch = getc(fp)) != EOF && ch != '\n';) if (p < buf + PASSWD_LEN) *p++ = ch; *p = '\0'; (void)write(fileno(outfp), "\n", 1); #ifdef SVR3 term_struct.c_lflag = svflagval; (void)ioctl(fileno(fp), TCSETA, &term_struct); #else ttyb.sg_flags = svflagval; (void)ioctl(fileno(fp), TIOCSETP, &ttyb); #endif #ifdef SOLARIS if (sigprocmask(SIG_SETMASK, &maskset, (sigset_t *)0)) { perror("Can't restore signal mask in getpass() "); exit(1); } #else (void)sigsetmask(omask); #endif if (fp != stdin) (void)fclose(fp); return(buf); } socks4-server-4.3.beta2.orig/lib/null_syslog.c100644 7657 764 1573 6031634013 17666 0ustar martinedv/* null_syslog */ /* null_syslog.c - 05/Nov/94 * provides empty syslog() functions for those who * would rather not have the rClient programs logging * to the syslog daemon. */ /* varargs/stdarg, let's try to unify ANSI/non-ANSI variants here */ #ifdef __STDC__ #include #define VARARGS(func,type,arg) func(type arg, ...) #define VASTART(ap,type,name) va_start(ap,name) #define VAEND(ap) va_end(ap) #else #include #define VARARGS(func,type,arg) func(va_alist) va_dcl #define VASTART(ap,type,name) {type name; va_start(ap); name = va_arg(ap, type) #define VAEND(ap) va_end(ap);} #endif socks_0openlog(ident, log_opt, fac) char *ident; int log_opt, fac; { /* empty */ } socks_0closelog() { /* empty */ } VARARGS(socks_0syslog, int, prio) { va_list ap; VASTART(ap, int, prio); /* empty */ VAEND(ap); } socks4-server-4.3.beta2.orig/lib/porttoserv.c100644 7657 764 710 6072365207 17526 0ustar martinedv/* porttoserv */ #include #include #include #include char *socks_porttoserv(sin_port, name, namelen) int sin_port; /* port number in network byte order */ char *name; int namelen; { struct servent *serv; int port = ntohs((short)sin_port); if ((serv = getservbyport(port, "tcp")) != (struct servent *)0) strncpy(name, serv->s_name, namelen); else sprintf(name, "%u", port); return(name); } socks4-server-4.3.beta2.orig/lib/shell_cmd.c100644 7657 764 14364 6032063725 17277 0ustar martinedv/* shell_cmd */ /* * socks_shell_cmd() takes a shell command template and performs * %x substitutions. * The result is executed * by a /bin/sh child process, with standard input, standard output and * standard error connected to /dev/null. * * Diagnostics are reported through syslog(3). * * Author: Wietse Venema, Eindhoven University of Technology, The Netherlands. * * Adapted for use with SOCKS by Ying-Da Lee, NEC Systems Lab, CSTC * ylee@syl.dl.nec.com * */ #ifndef lint static char sccsid[] = "@(#) shell_cmd.c 1.2 92/06/11 22:21:28"; #endif /* System libraries. */ #include #include #include #include #include #include #include #include "socks.h" #if !defined(SOLARIS) extern char *strncpy(); extern char *strchr(); #endif #if defined(DGUX) extern int closelog(); #else extern void closelog(); #endif extern void exit(); #define src_name srcshp->dmname[0] #define src_user srcshp->user #define real_user srcshp->ruser #define dst_name dstshp->dmname[0] #define dst_serv dstshp->portname #define socks_cmd dstshp->user /* Forward declarations. */ static void do_child(); static void percent_x(); /* socks_shell_cmd - expand % sequences and execute shell command */ void socks_shell_cmd(string, srcshp, dstshp) char *string; struct sockshost_s *srcshp, *dstshp; { char cmd[BUFSIZ]; static char alpha_num[] = "abcdefghijklmnopqrstuvwxyz\ ABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789"; int child_pid; int wait_pid; int daemon_pid = getpid(); percent_x(cmd, sizeof(cmd), string, srcshp, dstshp, daemon_pid); if (strpbrk(cmd, alpha_num) == NULL) { syslog(LOG_HIGH, "error -- shell command \"%s\" contains no alphanumeric characters.", cmd); return; } /* * Most of the work is done within the child process, to minimize the * risk of damage to the parent. */ switch (child_pid = fork()) { case -1: /* error */ syslog(LOG_HIGH, "error -- socks_shell_cmd fork() %m"); break; case 00: /* child */ do_child(daemon_pid, cmd); /* NOTREACHED */ default: /* parent */ while ((wait_pid = wait((int *) 0)) != -1 && wait_pid != child_pid) /* void */ ; } } /* do_child - exec command with { stdin, stdout, stderr } to /dev/null */ static void do_child(daemon_pid, command) int daemon_pid; char *command; { char *error = 0; int tmp_fd; /* * Close a bunch of file descriptors. The Ultrix inetd only passes stdin, * but other inetd implementations set up stdout as well. Ignore errors. */ closelog(); for (tmp_fd = 0; tmp_fd < 10; tmp_fd++) (void) close(tmp_fd); /* Set up new stdin, stdout, stderr, and exec the shell command. */ if (open("/dev/null", 2) != 0) { error = "open /dev/null: %m"; } else if (dup(0) != 1 || dup(0) != 2) { error = "dup: %m"; } else { (void) execl("/bin/sh", "sh", "-c", command, (char *) 0); error = "execl /bin/sh: %m"; } /* We can reach the following code only if there was an error. */ #ifdef LOG_DAEMON (void) openlog("sockd", LOG_PID, SYSLOG_FAC); #else (void) openlog("sockd", LOG_PID); #endif syslog(LOG_HIGH, "Cannot execute shell command for pid %d", daemon_pid); exit(0); } /* * percent_x() takes a string and performs %x subsitutions. * It aborts the program when the result of * expansion would overflow the output buffer. Because the result of % * expansion is typically passed on to a shell process, characters that may * confuse the shell are replaced by underscores. * * Diagnostics are reported through syslog(3). * * Author: Wietse Venema, Eindhoven University of Technology, The Netherlands. * * Adapted for use with SOCKS by Ying-Da Lee, NEC Systems Lab, CSTC * ylee@syl.dl.nec.com * */ /* percent_x - do % expansion, abort if result buffer is too small */ static void percent_x(result, result_len, str, srcshp, dstshp, pid) char *result; int result_len; char *str; struct sockshost_s *srcshp, *dstshp; int pid; { char *end = result + result_len - 1; /* end of result buffer */ char *expansion; int expansion_len; char pid_buf[10]; char port_buf[10]; static char ok_chars[] = "1234567890!@%-_=+\\:,./\ abcdefghijklmnopqrstuvwxyz\ ABCDEFGHIJKLMNOPQRSTUVWXYZ"; char *cp; /* * %A: the client domainname if known, IP address otherwise * %a: the client IP address * %c: "connect" or "bind" * %p: the daemon or client program process id * %S: the service name (ftp, telnet,etc.) if known, port number otherwise * %s: the destination port number * %U: for sockd, this is the username as reported by identd; * for client program, this is the name used at login * %u: for sockd, this is the username as reported by the client program; * for client program, this is the username of the effective userid * %Z: the destination domainname if known, IP address otherwise * %z: the destination IP address * * %% becomes a %, and %other is ignored. We terminate with a diagnostic if * we would overflow the result buffer. Characters that may confuse the * shell are mapped to underscores. */ while (*str) { if (*str == '%') { str++; expansion = *str == 'A' ? (str++, src_name) : *str == 'a' ? (str++, inet_ntoa(srcshp->shipaddr[0])) : *str == 'c' ? (str++, socks_cmd) : *str == 'p' ? (str++, sprintf(pid_buf, "%d", pid), pid_buf) : *str == 'S' ? (str++, dst_serv) : *str == 's' ? (str++, sprintf(port_buf, "%u", ntohs(dstshp->port)), port_buf) : *str == 'U' ? (str++, real_user) : *str == 'u' ? (str++, src_user) : *str == 'Z' ? (str++, dst_name) : *str == 'z' ? (str++, inet_ntoa(dstshp->shipaddr[0])) : *str == '%' ? (str++, "%") : *str == 0 ? "" : (str++, ""); expansion_len = strlen(expansion); for (cp = expansion; *cp; cp++) if (strchr(ok_chars, *cp) == 0) *cp = '_'; } else { expansion = str++; expansion_len = 1; } if (result + expansion_len >= end) { syslog(LOG_HIGH, "shell command too long: %30s...", result); exit(0); } strncpy(result, expansion, expansion_len); result += expansion_len; } *result = 0; } socks4-server-4.3.beta2.orig/lib/sockd_dumpcf.c100644 7657 764 4351 6144443417 17765 0ustar martinedv/* sockd_dumpcf */ #include #include #include #include #include #include #include "socks.h" void sockd_dumpcf(cfAddr, Ncf, useSyslog) struct config *cfAddr; int Ncf; int useSyslog; { char buf[1024], *bp; struct config *cp; char buf2[1024]; int i, t; struct in_addr addr; if (useSyslog) syslog(LOG_HIGH,"Effective configuration entries: %d\n",Ncf); else printf("Effective configuration entries: %d\n",Ncf); for (i = 0, cp = cfAddr; i++ < Ncf; cp++) { switch (cp->action) { case NO_IDENTD: strcpy(buf, NO_IDENTD_STR); strcat(buf, " "); strcat(buf, cp->cmdp); buf2[0] = '\0'; goto dump_it; case BAD_ID: strcpy(buf, BAD_ID_STR); strcat(buf, " "); strcat(buf, cp->cmdp); buf2[0] = '\0'; goto dump_it; case SOCKD_PERMIT: strcpy(buf, "permit "); break; case SOCKD_DENY: strcpy(buf, "deny "); break; default: strcpy(buf, "*badaction* "); continue; } if ((t = cp->use_identd) != 0) { strcat(buf, t == 3 ? "?=n " : t == 1 ? "?=i " : t == 2 ? "?=I " : "?=*badvalue* "); } if (cp->userlist != NULL) { strcat(buf, "*="); strcat(buf, cp->userlist); strcat(buf, " "); } if (cp->sdomain != NULL) strcat(buf, cp->sdomain); else strcat(buf, inet_ntoa(cp->saddr)); strcat(buf, " "); strcat(buf, inet_ntoa(cp->smask)); strcat(buf, " "); if (cp->ddomain != NULL) strcat(buf, cp->ddomain); else strcat(buf, inet_ntoa(cp->daddr)); strcat(buf, " "); strcat(buf, inet_ntoa(cp->dmask)); switch (cp->tst) { case e_lt: sprintf(buf2,"lt %d ", cp->dport); break; case e_gt: sprintf(buf2,"gt %d ", cp->dport); break; case e_eq: sprintf(buf2,"eq %d ", cp->dport); break; case e_neq: sprintf(buf2,"neq %d ", cp->dport); break; case e_le: sprintf(buf2,"le %d ", cp->dport); break; case e_ge: sprintf(buf2,"ge %d ", cp->dport); break; case e_nil: buf2[0] = '\0'; break; default: sprintf(buf2, "*badcmp* %d ", cp->dport); } if (cp->cmdp) { strcat(buf2, ": "); strcat(buf2, cp->cmdp); } dump_it: if (useSyslog) syslog(LOG_HIGH, "CF%3d>>%s %s<<\n",i,buf, buf2); else printf("CF%3d>>%s %s<<\n",i,buf, buf2); } } socks4-server-4.3.beta2.orig/lib/sockd_dumprt.c100644 7657 764 1602 6144445331 20013 0ustar martinedv/* sockd_dumpcf */ #include #include #include #include #include #include #include "socks.h" void sockd_dumprt(rtAddr, Nrt, useSyslog) struct config *rtAddr; int Nrt; int useSyslog; { char buf[1024], *bp; struct config *cp; int i, t; struct in_addr addr; if (useSyslog) syslog(LOG_HIGH,"Effective route entries: %d\n",Nrt); else printf("Effective route entries: %d\n",Nrt); for (i = 0, cp = rtAddr; i++ < Nrt; cp++) { strcpy(buf, inet_ntoa(cp->saddr)); strcat(buf, " "); addr.s_addr = cp->daddr.s_addr; if (cp->ddomain != NULL) strcat(buf, cp->ddomain); else strcat(buf, inet_ntoa(cp->daddr)); strcat(buf, " "); addr.s_addr = cp->dmask.s_addr; strcat(buf, inet_ntoa(cp->dmask)); if (useSyslog) syslog(LOG_HIGH, "RT%3d>>%s<<\n",i,buf); else printf("RT%3d>>%s<<\n",i,buf); } } socks4-server-4.3.beta2.orig/lib/sockd_rdconf.c100644 7657 764 15722 6143755310 20003 0ustar martinedv/* sockd_rdconf */ #include #include #include #include #include #include #include #include "socks.h" int sockd_rdconf(filename, cfAddrPtr, NcfPtr, no_identd_cmd, bad_id_cmd, useSyslog) char *filename; struct config **cfAddrPtr; int *NcfPtr; char **no_identd_cmd, **bad_id_cmd; int useSyslog; { FILE *fd; static char buf[1024]; char *bp, *ch; int linenum = 0, permit; char *argv[10]; int argc; int next_arg; long p; int Ncf = 0, maxcf = 0; struct config *cfAddr, *cp; int has_error = 0; int i; int k; if ((fd = fopen(filename, "r")) == NULL) { if (useSyslog) syslog(LOG_HIGH, "Cannot open configuration file %s: %m\n", filename); else fprintf(stderr, "Cannot open configuration file %s: %m\n", filename); exit(1); } for (i = 0, cp = *cfAddrPtr; i++ < *NcfPtr; cp++) { if (cp->userlist != NULL) free(cp->userlist); if (cp->cmdp != NULL) free(cp->cmdp); if (cp->sdomain != NULL) free(cp->sdomain); if (cp->ddomain != NULL) free(cp->ddomain); } if (*cfAddrPtr) free(*cfAddrPtr); if (*no_identd_cmd != NULL) { free(*no_identd_cmd); *no_identd_cmd = NULL; } if (*bad_id_cmd != NULL) { free(*bad_id_cmd); *bad_id_cmd = NULL; } maxcf = CONF_INCR; cfAddr = (struct config *) malloc( maxcf * sizeof(struct config)); if (cfAddr == NULL) { goto out_of_memory; } Ncf = 0; cp = cfAddr; while (fgets(buf, sizeof(buf) - 1, fd) != NULL) { linenum++; bzero(cp, sizeof(struct config)); if ((bp = index(buf, '\n')) != NULL) *bp = '\0'; if ((*bad_id_cmd == NULL) && (strncmp(buf, BAD_ID_STR, strlen(BAD_ID_STR)) == 0)) { *bad_id_cmd = strdup(buf + strlen(BAD_ID_STR)); if (*bad_id_cmd == NULL) goto out_of_memory; cp->action = BAD_ID; cp->cmdp = *bad_id_cmd; goto update_count; } if ((*no_identd_cmd == NULL) && (strncmp(buf, NO_IDENTD_STR, strlen(NO_IDENTD_STR)) == 0)) { *no_identd_cmd = strdup(buf + strlen(NO_IDENTD_STR)); if (*no_identd_cmd == NULL) goto out_of_memory; cp->action = NO_IDENTD; cp->cmdp = *no_identd_cmd; goto update_count; } for (bp = buf; *bp != '\0'; bp++) { if (*bp == ':') { *bp++ = '\0'; cp->cmdp = strdup(bp); if (cp->cmdp == NULL) { goto out_of_memory; } break; } else if (*bp == '#') { *bp = '\0'; break; } else if (*bp == '\t') *bp = ' '; } if (strlen(buf) == 0) continue; socks_mkargs(buf, &argc, argv, 10); if (argc == 0) { continue; } if ((argc < 3) || (argc > 9)) { if (useSyslog) syslog(LOG_HIGH, "Invalid entry at line %d in file %s", linenum, filename); else fprintf(stderr, "Invalid entry at line %d in file %s\n", linenum, filename); exit(1); } /* first parse all args */ if (STREQ(argv[0], "permit")) { cp->action = SOCKD_PERMIT; } else if (STREQ(argv[0], "deny")) { cp->action = SOCKD_DENY; } else { if (useSyslog) syslog(LOG_HIGH, "Invalid permit/deny field at line %d in file %s", linenum, filename); else fprintf(stderr, "Invalid permit/deny field at line %d in file %s\n", linenum, filename); has_error = 1; continue; } next_arg = 1; k = strlen("?="); if (strncmp(argv[next_arg], "?=", k) == 0) { switch (*(argv[next_arg++] + k)) { case 'I': cp->use_identd = 2; break; case 'i': cp->use_identd = 1; break; case 'n': case '\0': cp->use_identd = 3; break; default: if (useSyslog) syslog(LOG_HIGH, "Invalid ?= field at line %d in file %s", linenum, filename); else fprintf(stderr, "Invalid ?= field at line %d in file %s\n", linenum, filename); has_error = 1; continue; } } k = strlen("*="); if (strncmp(argv[next_arg], "*=", k) == 0) { if (*(argv[next_arg] + k)) { cp->userlist = strdup(argv[next_arg] + k); if (cp->userlist == NULL) goto out_of_memory; } next_arg++; } if(argc <= next_arg+1) { if (useSyslog) syslog(LOG_HIGH, "Invalid entry at line %d in file %s", linenum, filename); else fprintf(stderr, "Invalid entry at line %d in file %s\n", linenum, filename); has_error = 1; continue; } if (socks_GetAddr(argv[next_arg++], &cp->saddr, &cp->sdomain) == -1){ goto out_of_memory; } if (socks_GetQuad(argv[next_arg++], &cp->smask) == -1) { if (useSyslog) syslog(LOG_HIGH, "Illegal destination mask at line %d in file %s", linenum, filename); else fprintf(stderr, "Illegal destination mask at line %d in file %s\n", linenum, filename); has_error = 1; continue; } ch = argv[next_arg]; if ((argc > next_arg + 1) && !(STREQ(ch, "eq") || STREQ(ch, "neq") || STREQ(ch, "lt") || STREQ(ch, "gt") || STREQ(ch, "le") || STREQ(ch, "ge"))) { if (socks_GetAddr(argv[next_arg++], &cp->daddr, &cp->ddomain) == -1) { if (useSyslog) syslog(LOG_HIGH, "Illegal destination IP at line %d in file %s", linenum, filename); else fprintf(stderr, "Illegal destination IP at line %d in file %s\n", linenum, filename); has_error = 1; continue; } if (socks_GetQuad(argv[next_arg++], &cp->dmask) == -1) { if (useSyslog) syslog(LOG_HIGH, "Illegal destination mask at line %d in file %s", linenum, filename); else fprintf(stderr, "Illegal destination mask at line %d in file %s\n", linenum, filename); has_error = 1; continue; } } if (argc > next_arg + 1) { ch = argv[next_arg]; if (STREQ(ch, "eq")) cp->tst = e_eq; else if (STREQ(ch, "neq")) cp->tst = e_neq; else if (STREQ(ch, "lt")) cp->tst = e_lt; else if (STREQ(ch, "gt")) cp->tst = e_gt; else if (STREQ(ch, "le")) cp->tst = e_le; else if (STREQ(ch, "ge")) cp->tst = e_ge; else { if (useSyslog) syslog(LOG_HIGH, "Invalid comparison at line %d in file %s", linenum, filename); else fprintf(stderr, "Invalid comparison at line %d in file %s\n", linenum, filename); has_error = 1; continue; } if (((p = socks_GetPort(argv[next_arg+1])) < 0) || (p >= (1L << 16))) { if (useSyslog) syslog(LOG_HIGH, "Invalid port number at line %d in file %s", linenum, filename); else fprintf(stderr, "Invalid port number at line %d in file %s\n", linenum, filename); has_error = 1; continue; } else { cp->dport = p; } } else { cp->tst = e_nil; } update_count: if (++Ncf >= maxcf) { maxcf += CONF_INCR; cfAddr = (struct config *) realloc(cfAddr, maxcf * sizeof(struct config)); } if (cfAddr == NULL) { goto out_of_memory; } cp = cfAddr + Ncf; } fclose(fd); if (Ncf == 0) { if (useSyslog) syslog(LOG_HIGH, "No valid entires in file %s", filename); else fprintf(stderr, "No valid entires in file %s\n", filename); exit(1); } if (has_error) exit(1); if (Ncf < maxcf) cfAddr = (struct config *) realloc(cfAddr, Ncf * sizeof(struct config)); *NcfPtr = Ncf; *cfAddrPtr = cfAddr; return 0; out_of_memory: if(useSyslog) syslog(LOG_HIGH, "Out of memory\n"); else fprintf(stderr, "Out of memory\n"); exit(1); } socks4-server-4.3.beta2.orig/lib/sockd_rdroute.c100644 7657 764 6260 6143755345 20201 0ustar martinedv/* sockd_rdroute */ #include #include #include #include #include #include #include #include "socks.h" int sockd_rdroute(filename, rtAddrPtr, NrtPtr, useSyslog) char *filename; struct config **rtAddrPtr; int *NrtPtr; int useSyslog; { FILE *fd; static char buf[1024]; char *bp; int linenum = 0, permit; char *argv[10]; int argc; int next_arg; long p; int Nrt = 0, maxrt = 0; struct config *rtAddr, *cp; int has_error = 0; int i; if ((fd = fopen(filename, "r")) == NULL) { if (useSyslog) syslog(LOG_HIGH, "Cannot open route file %s: %m\n", filename); else fprintf(stderr, "Cannot open route file %s: %m\n", filename); exit(1); } for (i = 0, cp = *rtAddrPtr; i++ < *NrtPtr; cp++) { if (cp->ddomain != NULL) free(cp->ddomain); } if (*rtAddrPtr) free(*rtAddrPtr); maxrt = CONF_INCR; rtAddr = (struct config *) malloc( maxrt * sizeof(struct config)); if (rtAddr == NULL) { goto out_of_memory; } Nrt = 0; cp = rtAddr; while (fgets(buf, sizeof(buf) - 1, fd) != NULL) { linenum++; bzero(cp, sizeof(struct config)); /* ** Comments start with a '#' anywhere on the line */ if ((bp = index(buf, '\n')) != NULL) *bp = '\0'; for (bp = buf; *bp != '\0'; bp++) { if (*bp == ':') { *bp++ = '\0'; cp->cmdp = strdup(bp); if (cp->cmdp == NULL) goto out_of_memory; break; } else if (*bp == '#') { *bp = '\0'; break; } else if (*bp == '\t') *bp = ' '; } if (strlen(buf) == 0) continue; socks_mkargs(buf, &argc, argv, 10); if (argc == 0) { continue; } if (argc != 3) { if (useSyslog) syslog(LOG_HIGH, "Invalid entry at line %d in file %s", linenum, filename); else fprintf(stderr, "Invalid entry at line %d in file %s\n", linenum, filename); exit(1); } if (socks_GetQuad(argv[0], &cp->saddr) == -1) { if (useSyslog) syslog(LOG_HIGH, "illegal interface address at line %d in file %s", linenum, filename); else fprintf(stderr, "illegal interface address at line %d in file %s\n", linenum, filename); has_error = 1; continue; } if (socks_GetAddr(argv[1], &cp->daddr, &cp->ddomain) == -1){ goto out_of_memory; } if (socks_GetQuad(argv[2], &cp->dmask) == -1) { if (useSyslog) syslog(LOG_HIGH, "illegal destination mask at line %d in file %s", linenum, filename); else fprintf(stderr, "illegal destination mask at line %d in file %s\n", linenum, filename); has_error = 1; continue; } update_count: if (++Nrt >= maxrt) { maxrt += CONF_INCR; rtAddr = (struct config *) realloc(rtAddr, maxrt * sizeof(struct config)); } if (rtAddr == NULL) { goto out_of_memory; } cp = rtAddr + Nrt; } fclose(fd); if (Nrt == 0) { if (useSyslog) syslog(LOG_HIGH, "No valid entires in file %s", filename); else fprintf(stderr, "No valid entires in file %s\n", filename); exit(1); } if (has_error) exit(1); if (Nrt < maxrt) rtAddr = (struct config *) realloc(rtAddr, Nrt * sizeof(struct config)); *NrtPtr = Nrt; *rtAddrPtr = rtAddr; return 0; out_of_memory: if (useSyslog) syslog(LOG_HIGH, "Out of memory\n"); else fprintf(stderr, "Out of memory\n"); exit(1); } socks4-server-4.3.beta2.orig/lib/socks_ckcf.c100644 7657 764 2760 6033114107 17422 0ustar martinedv/* socks_ckcf */ #include #include #include #include #include #include #include #include #if (defined(sun) && !defined(SOLARIS)) || defined(sgi) #include #else #include #endif #include "socks.h" extern int socks_check_addr(); extern int socks_check_user(); extern char *socks_def_server; extern char *socks_serverlist; extern struct in_addr socks_self; int socks_ckcf(srcshp, dstshp, cfAddr, Ncf, useSyslog) /* Return 0 if sockd should be used, 1 if direct connection should be made, -1 if the connection request should be denied. */ struct sockshost_s *srcshp, *dstshp; struct config *cfAddr; int Ncf; int useSyslog; { unsigned short dst_sin_port = ntohs(dstshp->port); int i; struct config *cp; if ((dstshp->shipaddr[0].s_addr == socks_self.s_addr) || (dstshp->shipaddr[0].s_addr == 0)) return SOCKS_DIRECT; for (i = 0, cp = cfAddr; i++ < Ncf; cp++) { socks_serverlist = cp->serverlist; /* comparisons of port numbers must be done in host order */ if (socks_ckadr(dstshp, cp->ddomain, &cp->daddr, &cp->dmask) && socks_ckusr(cp->userlist, srcshp->user, useSyslog) && socks_ckprt(cp->tst, dst_sin_port, cp->dport)) goto GotIt; } return SOCKS_DENY; GotIt: if ((socks_serverlist == NULL) || (*socks_serverlist == '\0')) socks_serverlist = socks_def_server; if (cp->cmdp != NULL) socks_shell_cmd(cp->cmdp, srcshp, dstshp); return cp->action; } socks4-server-4.3.beta2.orig/lib/socks_dumpcf.c100644 7657 764 3522 6144442617 20004 0ustar martinedv/* socks_dumpcf */ #include #include #include #include #include #include #include "socks.h" void socks_dumpcf(cfAddr, Ncf, useSyslog) struct config *cfAddr; int Ncf; int useSyslog; { char buf[1024], *bp; struct config *cp; char buf2[1024]; int i, t; struct in_addr addr; if (useSyslog) syslog(LOG_HIGH,"Effective configuration entries: %d\n",Ncf); else printf("Effective configuration entries: %d\n",Ncf); for (i = 0, cp = cfAddr; i++ < Ncf; cp++) { switch (cp->action) { case SOCKS_DIRECT: strcpy(buf, "direct "); break; case SOCKS_SOCKD: strcpy(buf, "sockd "); break; case SOCKS_DENY: strcpy(buf, "deny "); break; default: strcpy(buf, "*badaction* "); continue; } if (cp->serverlist != NULL) { strcat(buf, "@="); strcat(buf, cp->serverlist); strcat(buf, " "); } if (cp->userlist != NULL) { strcat(buf, "*="); strcat(buf, cp->userlist); strcat(buf, " "); } if (cp->ddomain != NULL) strcat(buf, cp->ddomain); else strcat(buf, inet_ntoa(cp->daddr)); strcat(buf, " "); strcat(buf, inet_ntoa(cp->dmask)); switch (cp->tst) { case e_lt: sprintf(buf2,"lt %d ", cp->dport); break; case e_gt: sprintf(buf2,"gt %d ", cp->dport); break; case e_eq: sprintf(buf2,"eq %d ", cp->dport); break; case e_neq: sprintf(buf2,"neq %d ", cp->dport); break; case e_le: sprintf(buf2,"le %d ", cp->dport); break; case e_ge: sprintf(buf2,"ge %d ", cp->dport); break; case e_nil: buf2[0] = '\0'; break; default: sprintf(buf2, "*badcmp* %d ", cp->dport); } if (cp->cmdp) { strcat(buf2, ": "); strcat(buf2, cp->cmdp); } dump_it: if (useSyslog) syslog(LOG_HIGH, "CF%3d>>%s %s<<\n",i,buf, buf2); else printf("CF%3d>>%s %s<<\n",i,buf, buf2); } } socks4-server-4.3.beta2.orig/lib/socks_rdconf.c100644 7657 764 14304 6143756723 20026 0ustar martinedv/* socks_rdconf */ #include #include #include #include #include #include #include #include "socks.h" int socks_rdconf(filename, cfAddrPtr, NcfPtr, useSyslog) char *filename; struct config **cfAddrPtr; int *NcfPtr; int useSyslog; { FILE *fd; static char buf[1024]; char *bp, *ch; int linenum = 0; char *argv[10]; int argc; int next_arg; long p; int Ncf = 0, maxcf = 0; struct config *cfAddr, *cp; int has_error = 0; int i; int k; if ((fd = fopen(filename, "r")) == NULL) { if (useSyslog) syslog(LOG_HIGH, "Cannot open %s\n", filename); else fprintf(stderr, "Cannot open %s\n", filename); exit(1); } for (i = 0, cp = *cfAddrPtr; i++ < *NcfPtr; cp++) { if (cp->userlist != NULL) free(cp->userlist); if (cp->serverlist != NULL) free(cp->serverlist); if (cp->cmdp != NULL) free(cp->cmdp); if (cp->ddomain != NULL) free(cp->ddomain); } if (*cfAddrPtr) free(*cfAddrPtr); maxcf = CONF_INCR; cfAddr = (struct config *) malloc( maxcf * sizeof(struct config)); if (cfAddr == NULL) { if (useSyslog) syslog(LOG_HIGH, "Out of memory\n"); else fprintf(stderr, "Out of memory\n"); exit(1); } Ncf = 0; cp = cfAddr; while (fgets(buf, sizeof(buf) - 1, fd) != NULL) { linenum++; bzero(cp, sizeof(struct config)); /* ** Comments start with a '#' anywhere on the line */ if ((bp = index(buf, '\n')) != NULL) *bp = '\0'; for (bp = buf; *bp != '\0'; bp++) { if (*bp == ':') { *bp++ = '\0'; cp->cmdp = strdup(bp); if (cp->cmdp == NULL) { if (useSyslog) syslog(LOG_HIGH, "Out of memory\n"); else fprintf(stderr, "Out of memory\n"); exit(1); } break; } else if (*bp == '#') { *bp = '\0'; break; } else if (*bp == '\t') *bp = ' '; } if (strlen(buf) == 0) continue; socks_mkargs(buf, &argc, argv, 10); if (argc == 0) { continue; } /* #ifdef hpux */ if (STREQ(*argv, "domain") || STREQ(*argv, "nameserver") || STREQ(*argv, "bind") || STREQ(*argv, "findserver")) continue; /* #endif */ /* #ifdef hpux */ if ((argc < 3) || (argc > 7)) { if (useSyslog) syslog(LOG_HIGH, "Invalid entry at line %d in file %s", linenum, filename); else fprintf(stderr, "Invalid entry at line %d in file %s\n", linenum, filename); has_error = 1; continue; } /* parse the whole entry now, once. */ next_arg = 1; if (STREQ(argv[0], "sockd")) { cp->action = SOCKS_SOCKD; k = strlen("@="); if (strncmp(argv[1], "@=", k) == 0) { if (*(argv[1] + k)) cp->serverlist = strdup(argv[1] + k); if (cp->serverlist == NULL) { if (useSyslog) syslog(LOG_HIGH, "Out of memory\n"); else fprintf(stderr, "Out of memory\n"); exit(1); } next_arg++; } } else if (strncmp(argv[0], "sockd@", (k=strlen("sockd@"))) == 0) { cp->action = SOCKS_SOCKD; cp->serverlist = strdup(argv[0] + k); if (cp->serverlist == NULL) { if (useSyslog) syslog(LOG_HIGH, "Out of memory\n"); else fprintf(stderr, "Out of memory\n"); exit(1); } } else if (STREQ(argv[0], "direct")) { cp->action = SOCKS_DIRECT; } else if (STREQ(argv[0], "deny")) { cp->action = SOCKS_DENY; } else { if (useSyslog) syslog(LOG_HIGH, "Invalid sockd/direct/deny field at line %d in file %s", linenum, filename); else fprintf(stderr, "Invalid sockd/direct/deny field at line %d in file %s\n", linenum, filename); has_error = 1; continue; } k = strlen("*="); if (strncmp(argv[next_arg], "*=", k) == 0) { if (*(argv[next_arg] + k)) { cp->userlist = strdup(argv[next_arg] + k); if (cp->userlist == NULL) { if (useSyslog) syslog(LOG_HIGH, "Out of memory\n"); else fprintf(stderr, "Out of memory\n"); exit(1); } } next_arg++; } if(argc <= next_arg+1) { if (useSyslog) syslog(LOG_HIGH, "Invalid entry at line %d in file %s", linenum, filename); else fprintf(stderr, "Invalid entry at line %d in file %s\n", linenum, filename); has_error = 1; continue; } if (socks_GetAddr(argv[next_arg++], &cp->daddr, &cp->ddomain) == -1) { if (useSyslog) syslog(LOG_HIGH, "Out of memory\n"); else fprintf(stderr, "Out of memory\n"); has_error = 1; continue; } if (socks_GetQuad(argv[next_arg++], &cp->dmask) == -1) { if (useSyslog) syslog(LOG_HIGH, "Illegal destination mask at line %d in file %s", linenum, filename); else fprintf(stderr, "Illegal destination mask at line %d in file %s\n", linenum, filename); has_error = 1; continue; } if (argc > next_arg + 1) { ch = argv[next_arg]; if (STREQ(ch, "eq")) cp->tst = e_eq; else if (STREQ(ch, "neq")) cp->tst = e_neq; else if (STREQ(ch, "lt")) cp->tst = e_lt; else if (STREQ(ch, "gt")) cp->tst = e_gt; else if (STREQ(ch, "le")) cp->tst = e_le; else if (STREQ(ch, "ge")) cp->tst = e_ge; else { if (useSyslog) syslog(LOG_HIGH, "Invalid comparison at line %d in file %s", linenum, filename); else fprintf(stderr, "Invalid comparison at line %d in file %s\n", linenum, filename); has_error = 1; continue; } if (((p = socks_GetPort(argv[next_arg+1])) < 0) || (p >= (1L << 16))) { if (useSyslog) syslog(LOG_HIGH, "Invalid port number at line %d in file %s", linenum, filename); else fprintf(stderr, "Invalid port number at line %d in file %s\n", linenum, filename); has_error = 1; continue; } else { cp->dport = p; } } else { cp->tst = e_nil; } if (++Ncf >= maxcf) { maxcf += CONF_INCR; cfAddr = (struct config *) realloc(cfAddr, maxcf * sizeof(struct config)); if (cfAddr == NULL) { if (useSyslog) syslog(LOG_HIGH, "Out of memory\n"); else fprintf(stderr, "Out of memory\n"); exit(1); } cp = cfAddr + Ncf; } else { cp++; } } fclose(fd); if (Ncf == 0) { if (useSyslog) syslog(LOG_HIGH, "No valid entires in file %s", filename); else fprintf(stderr, "No valid entires in file %s\n", filename); exit(1); } if (has_error) exit(1); if (Ncf < maxcf) cfAddr = (struct config *) realloc(cfAddr, Ncf * sizeof(struct config)); *NcfPtr = Ncf; *cfAddrPtr = cfAddr; return 0; } socks4-server-4.3.beta2.orig/lib/socks_rdfz.c100644 7657 764 4553 6144446674 17507 0ustar martinedv/* socks_rdfz */ #include #include #include #include #include #include #include #include "socks.h" int socks_rdfz(fc, cfAddrPtr, NcfPtr, cfstrings, useSyslog) char *fc; struct config **cfAddrPtr; int *NcfPtr; char **cfstrings; int useSyslog; { int fd, i; char *stringarea, *startaddr; int stringsize; int Ncf; struct config *cfAddr, *cp; if ((fd = open(fc, O_RDONLY)) < 0) { if (useSyslog) syslog(LOG_HIGH, "Cannot open %s: %m\n", fc); else perror("socks_rdfz(): open()"); exit(1); } if (*cfAddrPtr != NULL) free(*cfAddrPtr); if (*cfstrings != NULL) free(*cfstrings); if (read(fd, &Ncf, sizeof(Ncf)) != sizeof(Ncf)) { if (useSyslog) syslog(LOG_HIGH, "Error: read from %s: %m\n", fc); else perror("socks_rdfz(): read()"); exit(1); } if (read(fd, &stringsize, sizeof(stringsize)) != sizeof(stringsize)) { if (useSyslog) syslog(LOG_HIGH, "Error: read from %s: %m\n", fc); else perror("socks_rdfz(): read()"); exit(1); } cfAddr = (struct config *) malloc(Ncf * (sizeof(struct config))); if (cfAddr == NULL) { if (useSyslog) syslog(LOG_HIGH, "Out of memory\n"); else perror("socks_rdfz(): malloc()"); exit(1); } if (read(fd, cfAddr, Ncf * sizeof(struct config)) != (Ncf * sizeof(struct config))) { if (useSyslog) syslog(LOG_HIGH, "Error: read from %s: %m\n", fc); else perror("socks_rdfz(): read()"); exit(1); } *cfAddrPtr = cfAddr; *NcfPtr = Ncf; if (stringsize == 0) { close(fd); return 0; } if ((stringarea = (char *)malloc(stringsize)) == NULL) { if (useSyslog) syslog(LOG_HIGH, "Out of memory\n"); else perror("socks_rdfz(): malloc()"); exit(1); } *cfstrings = stringarea; if (read(fd, stringarea, stringsize) != stringsize) { if (useSyslog) syslog(LOG_HIGH, "Error: read from %s: %m\n", fc); else perror("socks_rdfz(): read()"); exit(1); } startaddr = stringarea - 1; for (i = 0, cp = cfAddr; i++ < Ncf; cp++) { if (cp->userlist != NULL) cp->userlist = startaddr + (int)cp->userlist; if (cp->serverlist != NULL) cp->serverlist = startaddr + (int)cp->serverlist; if (cp->sdomain != NULL) cp->sdomain = startaddr + (int)cp->sdomain; if (cp->ddomain != NULL) cp->ddomain = startaddr + (int)cp->ddomain; if (cp->cmdp != NULL) cp->cmdp = startaddr + (int)cp->cmdp; } return 0; } socks4-server-4.3.beta2.orig/lib/socks_wrfz.c100644 7657 764 5341 6144446737 17526 0ustar martinedv/* socks_wrfz */ #include #include #include #include #include #include #include #include "socks.h" int socks_wrfz(fc, confAddr, Nconf, useSyslog) char *fc; struct config *confAddr; int Nconf; int useSyslog; { char *stringarea, *p; char *startaddr; int stringsize = 0; int i; struct config *cp; int fd; for (i = 0, cp = confAddr; i++ < Nconf; cp++) { if (cp->userlist != NULL) stringsize += strlen(cp->userlist) + 1; if (cp->serverlist != NULL) stringsize += strlen(cp->serverlist) + 1; if (cp->sdomain != NULL) stringsize += strlen(cp->sdomain) + 1; if (cp->ddomain != NULL) stringsize += strlen(cp->ddomain) + 1; if (cp->cmdp != NULL) stringsize += strlen(cp->cmdp) + 1; } if (stringsize != 0) { if ((stringarea = (char *)malloc(stringsize)) == NULL) { if (useSyslog) syslog(LOG_HIGH, "OUt of memory\n"); else perror("socks_writefc(): malloc()"); exit(1); } startaddr = stringarea - 1; p = stringarea; for (i = 0, cp = confAddr; i++ < Nconf; cp++) { if (cp->userlist != NULL) { strcpy(p, cp->userlist); cp->userlist = (char *)(p - startaddr); p += strlen(p) + 1; } if (cp->serverlist != NULL) { strcpy(p, cp->serverlist); cp->serverlist = (char *)(p - startaddr); p += strlen(p) + 1; } if (cp->sdomain != NULL) { strcpy(p, cp->sdomain); cp->sdomain = (char *)(p - startaddr); p += strlen(p) + 1; } if (cp->ddomain != NULL) { strcpy(p, cp->ddomain); cp->ddomain = (char *)(p - startaddr); p += strlen(p) + 1; } if (cp->cmdp != NULL) { strcpy(p, cp->cmdp); cp->cmdp = (char *)(p - startaddr); p += strlen(p) + 1; } } } fd = creat(fc, S_IRUSR|S_IWUSR|S_IRGRP|S_IROTH); if (fd < 0) { if (useSyslog) syslog(LOG_HIGH, "Error: creat() %s: %m\n"); else perror("socks_writefc(): creat()"); exit(1); } if (write(fd, &Nconf, sizeof(Nconf)) != sizeof(Nconf)) { if (useSyslog) syslog(LOG_HIGH, "Error: write to %s: %m\n", fc); else perror("socks_writefc(): write()"); exit(1); } if (write(fd, &stringsize, sizeof(stringsize)) != sizeof(stringsize)) { if (useSyslog) syslog(LOG_HIGH, "Error: write to %s: %m\n", fc); else perror("socks_writefc(): write()"); exit(1); } if (write(fd, confAddr, Nconf * sizeof(struct config)) != (Nconf * sizeof(struct config))) { if (useSyslog) syslog(LOG_HIGH, "Error: write to %s: %m\n", fc); else perror("socks_writefc(): write()"); exit(1); } if ((stringsize != 0) && (write(fd, stringarea, stringsize) != stringsize)) { if (useSyslog) syslog(LOG_HIGH, "Error: write to %s: %m\n", fc); else perror("socks_writefc(): write()"); exit(1); } return 0; } socks4-server-4.3.beta2.orig/lib/strdup.c100644 7657 764 246 6031634212 16612 0ustar martinedv/* strdup */ #include #include char *strdup(s) char *s; { char *p; p = (char *)malloc(strlen(s) + 1); if (p) strcpy(p, s); return p; } socks4-server-4.3.beta2.orig/lib/utils.c100644 7657 764 17005 6155435235 16505 0ustar martinedv/* utils */ #include /* >>> K. Shackelford */ #include #include /* <<< K. Shackelford */ #include #include #include #if (defined(sun) && !defined(SOLARIS)) || defined(sgi) #include #endif #include #include #include #include "socks.h" #ifdef SOLARIS #include "bstring.h" #endif extern struct in_addr socks_self; extern struct hostent socks_fakeIP[]; /* * These functions are used by both Validate (for sockd) * and socks_check_cconf (for clients). */ /* ** Simple 'socks_mkargs' doesn't handle \, ", or '. */ void socks_mkargs(cp, argc, argv, max) char *cp; int *argc; char *argv[]; int max; { *argc = 0; while (isspace(*cp)) cp++; while (*cp != '\0') { argv[(*argc)++] = cp; if (*argc >= max) return; while (!isspace(*cp) && (*cp != '\0')) cp++; while (isspace(*cp)) *cp++ = '\0'; } } int socks_GetQuad(dotquad, addr) char *dotquad; struct in_addr *addr; /* dotquad must be in dotted quad form. Returns -1 if not. */ { if ((addr->s_addr = inet_addr(dotquad)) != (u_int32) -1) return 0; if (strcmp(dotquad, "255.255.255.255") == 0) return 0; return -1; } /* ** Get address, must be dotted quad, or full or partial domain name. ** Partial domain names are indicated by a leading period. */ int socks_GetAddr(name, addr, domain) char *name, **domain; struct in_addr *addr; { struct hostent *hp; struct netent *np; if (*domain != NULL) free(*domain); if (socks_GetQuad(name, addr) != -1) { *domain = NULL; return 0; } if ((*domain = strdup(name)) != NULL) { addr->s_addr = 0; return 0; } return -1; } long socks_GetPort(name) char *name; /* result is in HOST byte order */ { struct servent *sp; if ((sp = getservbyname(name, "tcp")) != NULL) { return ntohs((short)sp->s_port); } if (!isdigit(*name)) return -1; return atol(name); } int socks_IPtohost(ipaddr, shp) struct in_addr *ipaddr; struct sockshost_s *shp; { u_int32 addr; struct hostent *hp; char **p; int i, rvok; char *name; for (i = 0; i < MAXNAMESPERHOST; i++) { if (shp->dmname[i] != NULL) free(shp->dmname[i]); } bzero(shp, sizeof(struct sockshost_s)); if ((ipaddr->s_addr == 0) || (ipaddr->s_addr == socks_self.s_addr)) goto simple_conversion; addr = ntohl(ipaddr->s_addr); if ((addr >> 8) == 0) { shp->shipaddr[0].s_addr = ipaddr->s_addr; if ((shp->dmname[0] = strdup(socks_fakeIP[addr-1].h_name)) != NULL) return 0; else return -1; } hp = gethostbyaddr(&ipaddr->s_addr, IPADDRLENG, AF_INET); if (hp == NULL) goto simple_conversion; /* Double check -- it's too easy to fake IP->name data */ if ((name = strdup(hp->h_name)) == NULL) return -1; hp = gethostbyname(name); free(name); if (hp == NULL) goto simple_conversion; for (i = 0, p = hp->h_addr_list; (i < MAXIPPERHOST - 1) && (*p != NULL);) { bcopy(*p++, &(shp->shipaddr[i++].s_addr), IPADDRLENG); } /* make sure the original IP address is in the list */ rvok = 0; for (i = 0; shp->shipaddr[i].s_addr != 0; ) { if (ipaddr->s_addr == shp->shipaddr[i++].s_addr) { rvok = 1; break; } } if (!rvok) { /* no match; will only use the original IP address */ goto simple_conversion; } shp->shipaddr[0].s_addr = ipaddr->s_addr; shp->shipaddr[1].s_addr = 0; if ((shp->dmname[0] = strdup(hp->h_name)) == NULL) { return -1; } for (i = 1, p = hp->h_aliases; (*p != NULL) && (i < MAXNAMESPERHOST - 1); ) { if ((shp->dmname[i++] = strdup(*p++)) == NULL) return -1; } return 0; simple_conversion: shp->shipaddr[0].s_addr = ipaddr->s_addr; shp->shipaddr[1].s_addr = 0; if ((shp->dmname[0] = strdup(inet_ntoa(*ipaddr))) != NULL) return 0; else return -1; } int socks_host(name, shp) char *name; struct sockshost_s *shp; { struct in_addr addr; struct hostent *hp; char **p; int i; if (socks_GetQuad(name, &addr) != -1) return socks_IPtohost(&addr, shp); for (i = 0; i < MAXNAMESPERHOST; i++) { if (shp->dmname[i] != NULL) free(shp->dmname[i]); } bzero(shp, sizeof(struct sockshost_s)); hp = gethostbyname(name); if (hp == NULL) { if ((shp->dmname[0] = strdup(name)) != NULL) return 0; else return -1; } for (i = 0, p = hp->h_addr_list; (i < MAXIPPERHOST - 1) && (*p != NULL);) { bcopy(*p++, &(shp->shipaddr[i++].s_addr), IPADDRLENG); } if ((shp->dmname[0] = strdup(hp->h_name)) == NULL) { return -1; } for (i = 1, p = hp->h_aliases; (*p != NULL) && (i < MAXNAMESPERHOST - 1); ) { if ((shp->dmname[i++] = strdup(*p++)) == NULL) return -1; } return 0; } int socks_ckadr(shp, domain, addr, mask) struct sockshost_s *shp; char *domain; struct in_addr *addr, *mask; /* domain = '.xyz.com' will match 'a.xyz.com', 'q.wtr.xyz.com' AND 'xyz.com' */ { int i; u_int32 maddr; char **q; int dlen; if (domain == NULL) { if (mask->s_addr == 0) return 1; maddr = addr->s_addr & mask->s_addr; for (i = 0; (i < MAXIPPERHOST - 1) && (shp->shipaddr[i].s_addr != 0); ) { if ((shp->shipaddr[i++].s_addr & mask->s_addr) == maddr) return 1; } return 0; } if (strcmp(domain, "ALL") == 0) return 1; if (*domain != '.') { for (q = shp->dmname; *q != 0; ) { if (strcasecmp(*q++, domain) == 0) return 1; } return 0; } dlen = strlen(domain); for (q = shp->dmname; *q != 0; q++) { if ((strcasecmp(*q + (strlen(*q) - dlen), domain) == 0) || (strcasecmp(*q, domain + 1) == 0)) return 1; } return 0; } static int check_userfile(userfile, user, useSyslog) char *userfile, *user; int useSyslog; /* return 1 if match, 0 otherwise */ /* return -1 if cannot open file */ /* comparison is case-sensitive */ { FILE *fd; #define BUFLEN 1024 static char buf[BUFLEN]; char *p, *q; if ((fd = fopen(userfile, "r")) == NULL) { if (useSyslog) syslog(LOG_HIGH,"Unable to open userfile (%s): %m\n", userfile); else fprintf(stderr,"Unable to open userfile (%s)\n", userfile); return (-1); } while (fgets(buf, BUFLEN, fd) != NULL) { if ((p = index(buf, '\n')) != NULL) *p = '\0'; if (( p = index(buf, '#')) != NULL) *p = '\0'; p = buf; while (1) { p += strspn(p, " ,\t"); if ((q = strpbrk(p, " ,\t")) != NULL) *q = '\0'; if (strcmp(p, user) == 0) { fclose(fd); return 1; } if (q == NULL) break; p = q + 1; } } fclose(fd); return 0; } int socks_ckusr(userlist, user, useSyslog) char *userlist, *user; int useSyslog; /* * Unless userlist is a null pointer, in which case all users are * allowed (return 1), otherwise * userlist is a nonempty string containing userids separated by * commas, no other separators are allowed in the string. * 94/03/02: if userlist starts with '/', it specifies a file * containing userids. * * Return 1 if user is in the userlist; * return 0 if not, or if userfile cannot be open. */ { char *p, *q; if (!(p = userlist)) { return 1; } do { if (q = index(p, ',')) *q = '\0'; if (*p == '/') { switch (check_userfile(p, user, useSyslog)) { case 1: return 1; case -1: return 0; default: ; } } else if (strcmp(p, user) == 0) { return 1; } if (q) *q++ = ','; } while ( p = q); return 0; } int socks_ckprt(test, port1, port2) int test, port1, port2; { switch (test) { case e_nil: return 1; case e_eq: if (port1 == port2) return 1; return 0; case e_neq: if (port1 != port2) return 1; return 0; case e_gt: if (port1 > port2) return 1; return 0; case e_ge: if (port1 >= port2) return 1; return 0; case e_lt: if (port1 < port2) return 1; return 0; case e_le: if (port1 <= port2) return 1; return 0; default: return 0; } } socks4-server-4.3.beta2.orig/libident/ 40755 7657 764 0 6157332562 16106 5ustar martinedvsocks4-server-4.3.beta2.orig/libident/Makefile100644 7657 764 1606 6020676415 17643 0ustar martinedv# DO NOT start 'make' in this directory. Go to the top # directory of the SOCKS package and do it from there! #============================================================= OBJS = ident.o id_open.o id_close.o id_query.o id_parse.o CFLAGS = $(OPTIMIZE) $(OTHER_CFLAGS) all: echocwd libident.a libident.a: $(OBJS) -rm -f libident.a ar cq libident.a $(OBJS) $(RANLIB) libident.a ident.o: ident.c ident.h id_open.o: id_open.c ident.h id_close.o: id_close.c ident.h id_query.o: id_query.c ident.h id_parse.o: id_parse.c ident.h install: echocwd -if [ -d $(LIBDIR) ]; then \ ($(INSTALL) -m 644 libident.a $(LIBDIR); \ $(RANLIB) -t $(LIBDIR)/libident.a); fi -if [ -d $(INCDIR) ]; then \ $(INSTALL) -m 644 ident.h $(INCDIR); fi install.man: echocwd -if [ -d $(MANDIR) ]; then \ $(INSTALL) -m 644 ident.3 $(MANDIR); fi clean: echocwd -rm -f libident.a *~ core *.o \#* echocwd: @pwd socks4-server-4.3.beta2.orig/libident/README100644 7657 764 1232 5606334270 17055 0ustar martinedvThis is the second stab at a small library to interface to the Ident protocol server. Maybe this will work correctly on some machines.. :-) The ident-tester.c file is a small daemon (to be started from Inetd) that does an ident lookup on you if you telnet into it. Can be used to verify that your Ident server is working correctly. I'm currently running this "ident-tester" on port 114 at lysator.liu.se if you wish to test your server. /Peter Eriksson , 1 Aug 1992 This library now contains some higher-level routines, as well as a similar test program to test these (lookup-tester). /Pär Emanuelsson , 4 April 1993 socks4-server-4.3.beta2.orig/libident/id_close.c100644 7657 764 460 5606334270 20104 0ustar martinedv/* ** id_close.c Close a connection to an IDENT server ** ** Author: Peter Eriksson */ #include "ident.h" int id_close #ifdef __STDC__ (ident_t *id) #else (id) ident_t *id; #endif { int res; res = close(id->fd); free(id); return res; } socks4-server-4.3.beta2.orig/libident/id_open.c100644 7657 764 7432 6014506664 17770 0ustar martinedv/* ** id_open.c Establish/initiate a connection to an IDENT server ** ** Author: Peter Eriksson ** Fixes: Pdr Emanuelsson */ #include #include #if defined(ISC) #include #endif /* #if defined(ISC) */ #include #include #include #include #include #include #if defined(ISC) #include #endif /* #if defined(ISC) */ #include #include /* SOLARIS */ #if defined(__svr4__) || defined (SOLARIS) || defined(SCO) #include #endif /* LINUX */ #ifdef LINUX #include #include #include #ifdef FNDLEAY /*watch out for a ?typo? in fcntl.h !? */ #define FNDELAY FNDLEAY #endif #endif /* LINUX */ /* The following struct linger declaration seemed to be * missing from older versions of LINUX but is present in * current. If you need it, you must uncomment NEED_STRUCT_LINGER * in the top level Makefile. */ #ifdef NEED_STRUCT_LINGER /* * Structure used for manipulating linger option. */ struct linger { int l_onoff; /* option on/off */ int l_linger; /* linger time */ }; #endif /* #ifdef NEED_STRUCT_LINGER */ #include "ident.h" extern void *malloc __P((int size)); ident_t *id_open #ifdef __STDC__ (struct in_addr *laddr, struct in_addr *faddr, struct timeval *timeout) #else (laddr, faddr, timeout) struct in_addr *laddr; struct in_addr *faddr; struct timeval *timeout; #endif { ident_t *id; int res, tmperrno; struct sockaddr_in sin_laddr, sin_faddr; fd_set rs, ws, es; #if !defined(SO_DONTLINGER) || defined(SOLARIS) struct linger linger; #endif #if defined(sgi) || defined (SOLARIS) || defined(__bsdi__) int on = 1; #endif if ((id = (ident_t *) malloc(sizeof(*id))) == 0) return 0; if ((id->fd = socket(AF_INET, SOCK_STREAM, 0)) < 0) { free(id); return 0; } if (timeout) { if ((res = fcntl(id->fd, F_GETFL, 0)) < 0) goto ERROR; if (fcntl(id->fd, F_SETFL, res | FNDELAY) < 0) goto ERROR; } #if defined(SO_DONTLINGER) && !defined(SOLARIS) if (setsockopt(id->fd, SOL_SOCKET, SO_DONTLINGER, 0, 0) < 0) goto ERROR; #else linger.l_onoff = 0; linger.l_linger = 0; if (setsockopt(id->fd, SOL_SOCKET, SO_LINGER, &linger, sizeof(linger)) < 0) goto ERROR; #endif #if defined(sgi) || defined(SOLARIS) || defined(__bsdi__) if (setsockopt(id->fd, SOL_SOCKET, SO_REUSEADDR, (char *)&on, sizeof(on)) < 0) #else # if !defined(LINUX) if (setsockopt(id->fd, SOL_SOCKET, SO_REUSEADDR, 0, 0) < 0) # endif #endif goto ERROR; id->buf[0] = '\0'; memset(&sin_laddr, 0, sizeof(sin_laddr)); sin_laddr.sin_family = AF_INET; sin_laddr.sin_addr = *laddr; sin_laddr.sin_port = 0; if (bind(id->fd, (struct sockaddr *)&sin_laddr, sizeof(sin_laddr)) < 0) goto ERROR; memset(&sin_faddr, 0, sizeof(sin_faddr)); sin_faddr.sin_family = AF_INET; sin_faddr.sin_addr = *faddr; sin_faddr.sin_port = htons(IDPORT); res = connect(id->fd, (struct sockaddr *)&sin_faddr, sizeof(sin_faddr)); if (res < 0 && errno != EINPROGRESS) goto ERROR; if (timeout) { FD_ZERO(&rs); FD_ZERO(&ws); FD_ZERO(&es); FD_SET(id->fd, &rs); FD_SET(id->fd, &ws); FD_SET(id->fd, &es); if ((res = select(FD_SETSIZE, &rs, &ws, &es, timeout)) < 0) goto ERROR; if (res == 0) { errno = ETIMEDOUT; goto ERROR; } if (FD_ISSET(id->fd, &es)) goto ERROR; if (!FD_ISSET(id->fd, &rs) && !FD_ISSET(id->fd, &ws)) goto ERROR; } return id; ERROR: tmperrno = errno; /* Save, so close() won't erase it */ close(id->fd); free(id); errno = tmperrno; return 0; } socks4-server-4.3.beta2.orig/libident/id_parse.c100644 7657 764 7632 5626200111 20125 0ustar martinedv/* ** id_parse.c Receive and parse a reply from an IDENT server ** ** Author: Peter Eriksson ** Fiddling: Pär Emanuelsson */ #include #include #if defined(ISC) #include #endif /* #if defined(ISC) */ #include #include #include #if defined(ISC) #include #endif /* #if defined(ISC) */ #include #include #include "ident.h" /* >>> Ian Dunkin */ #if defined(ultrix) || defined(AIX_PS2) char *strdup(s) char *s; { char *malloc(); static char *p; if ((p = malloc(strlen(s) + 1)) != NULL) strcpy(p, s); return(p); } #endif /* <<< Ian Dunkin */ static char *xstrtok #ifdef __STDC__ (char *cp, char *cs, char *dc) #else (cp, cs, dc) char *cp; char *cs; char *dc; #endif { static char *bp = 0; if (cp) bp = cp; /* ** No delimitor cs - return whole buffer and point at end */ if (!cs) { while (*bp) bp++; return cs; } /* ** Skip leading spaces */ while (isspace(*bp)) bp++; /* ** No token found? */ if (!*bp) return 0; cp = bp; while (*bp && !index(cs, *bp)) bp++; /* ** Remove trailing spaces */ *dc = *bp; for (dc = bp-1; dc > cp && isspace(*dc); dc--) ; *++dc = '\0'; bp++; return cp; } int id_parse #ifdef __STDC__ (ident_t *id, struct timeval *timeout, int *lport, int *fport, char **identifier, char **opsys, char **charset) #else (id, timeout, lport, fport, identifier, opsys, charset) ident_t *id; struct timeval *timeout; int *lport; int *fport; char **identifier; char **opsys; char **charset; #endif { char c, *cp, *tmp_charset; fd_set rs; int pos, res, lp, fp; errno = 0; tmp_charset = 0; if (!id) return -1; if (lport) *lport = 0; if (fport) *fport = 0; if (identifier) *identifier = 0; if (opsys) *opsys = 0; if (charset) *charset = 0; pos = strlen(id->buf); if (timeout) { FD_ZERO(&rs); FD_SET(id->fd, &rs); if ((res = select(FD_SETSIZE, &rs, (fd_set *)0, (fd_set *)0, timeout)) < 0) return -1; if (res == 0) { errno = ETIMEDOUT; return -1; } } while (pos < sizeof(id->buf) && (res = read(id->fd, id->buf + pos, 1)) == 1 && id->buf[pos] != '\n') pos++; if (res < 0) return -1; if (res == 0) { errno = ENOTCONN; return -1; } if (id->buf[pos] != '\n') return 0; id->buf[pos++] = '\0'; /* ** Get first field ( , ) */ cp = xstrtok(id->buf, ":", &c); if (!cp) return -2; if (sscanf(cp, " %d , %d", &lp, &fp) != 2) { if (identifier) *identifier = strdup(cp); return -2; } if (lport) *lport = lp; if (fport) *fport = fp; /* ** Get second field (USERID or ERROR) */ cp = xstrtok((char *)0, ":", &c); if (!cp) return -2; if (strcmp(cp, "ERROR") == 0) { cp = xstrtok((char *)0, "\n\r", &c); if (!cp) return -2; if (identifier) *identifier = strdup(cp); return 2; } else if (strcmp(cp, "USERID") == 0) { /* ** Get first subfield of third field */ cp = xstrtok((char *)0, ",:", &c); if (!cp) return -2; if (opsys) *opsys = strdup(cp); /* ** We have a second subfield () */ if (c == ',') { cp = xstrtok((char *)0, ":", &c); if (!cp) return -2; tmp_charset = cp; if (charset) *charset = strdup(cp); /* ** We have even more subfields - ignore them */ if (c == ',') xstrtok((char *)0, ":", &c); } if (tmp_charset && strcmp(tmp_charset, "OCTET") == 0) cp = xstrtok((char *)0, (char *)0, &c); else cp = xstrtok((char *)0, "\n\r", &c); if (identifier) *identifier = strdup(cp); return 1; } else { if (identifier) *identifier = strdup(cp); return -3; } } socks4-server-4.3.beta2.orig/libident/id_query.c100644 7657 764 2252 6072365346 20173 0ustar martinedv/* ** id_query.c Transmit a query to an IDENT server ** ** Author: Peter Eriksson */ #include #include #if defined(ISC) #include #endif /* #if defined(ISC) */ #include #include #if defined(ISC) #include #endif /* #if defined(ISC) */ #include #include #include "ident.h" int id_query #ifdef __STDC__ (ident_t *id, int lport, int fport, struct timeval *timeout) #else (id, lport, fport, timeout) ident_t *id; int lport; int fport; struct timeval *timeout; #endif { #if defined(SOLARIS) || defined(_SEQUENT_) || defined(SCO) void (*old_sig)(); #else void *old_sig; #endif int res; char buf[80]; fd_set ws; sprintf(buf, "%d , %d\r\n", lport, fport); if (timeout) { FD_ZERO(&ws); FD_SET(id->fd, &ws); if ((res = select(FD_SETSIZE, (fd_set *)0, &ws, (fd_set *)0, timeout)) < 0) return -1; if (res == 0) { errno = ETIMEDOUT; return -1; } } old_sig = signal(SIGPIPE, SIG_IGN); res = write(id->fd, buf, strlen(buf)); signal(SIGPIPE, old_sig); return res; } socks4-server-4.3.beta2.orig/libident/ident-tester.c100644 7657 764 10023 5606334271 20767 0ustar martinedv/* ** ident-tester.c A small daemon that can be used to test Ident ** servers ** ** Author: Peter Eriksson , 10 Aug 1992 */ #include #include #include #include #include #include #include #include "ident.h" /* ** Return the name of the connecting host, or the IP number as a string. */ char *gethost(addr) struct in_addr *addr; { struct hostent *hp; hp = gethostbyaddr(addr, sizeof(struct in_addr), AF_INET); if (hp) return hp->h_name; else return inet_ntoa(*addr); } main(argc,argv) int argc; char *argv[]; { struct sockaddr_in laddr, faddr; int len, res, lport, fport; ident_t *id; char *identifier, *opsys, *charset; puts("Welcome to the IDENT server tester, version 1.7\r\n\r"); fflush(stdout); len = sizeof(faddr); getpeername(0, &faddr, &len); len = sizeof(laddr); getsockname(0, &laddr, &len); printf("Connecting to Ident server at %s...\r\n", inet_ntoa(faddr.sin_addr)); fflush(stdout); #ifdef LOG_LOCAL3 openlog("tidentd", 0, LOG_LOCAL3); #else openlog("tidentd", 0); #endif id = id_open(&laddr.sin_addr, &faddr.sin_addr, NULL); if (!id) { perror("id_open()"); fflush(stderr); syslog(LOG_ERR, "Error: id_open(): host=%s, error=%m", gethost(&faddr.sin_addr)); exit(1); } printf("Querying for lport %d, fport %d....\r\n", (int) ntohs(faddr.sin_port), (int) ntohs(laddr.sin_port)); fflush(stdout); if (id_query(id, ntohs(faddr.sin_port), ntohs(laddr.sin_port), 0) < 0) { perror("id_query()"); fflush(stderr); syslog(LOG_ERR, "Error: id_query(): host=%s, error=%m", gethost(&faddr.sin_addr)); exit(1); } printf("Reading response data...\r\n"); fflush(stdout); res = id_parse(id, NULL, &lport, &fport, &identifier, &opsys, &charset); switch (res) { default: perror("id_parse()"); syslog(LOG_ERR, "Error: id_parse(): host=%s, error=%m", gethost(&faddr.sin_addr)); break; case -2: syslog(LOG_ERR, "Error: id_parse(): host=%s, Parse Error: %s", gethost(&faddr.sin_addr), identifier ? identifier : ""); if (identifier) printf("Parse error on reply:\n \"%s\"\n", identifier); else printf("Unidentifiable parse error on reply.\n"); break; case -3: syslog(LOG_ERR, "Error: id_parse(): host=%s, Illegal reply type: %s", gethost(&faddr.sin_addr), identifier); printf("Parse error in reply: Illegal reply type: %s\n", identifier); break; case 0: syslog(LOG_ERR, "Error: id_parse(): host=%s, NotReady", gethost(&faddr.sin_addr)); puts("Not ready. This should not happen...\r"); break; case 2: syslog(LOG_INFO, "Reply: Error: host=%s, error=%s", gethost(&faddr.sin_addr), identifier); printf("Error response is:\r\n"); printf(" Lport........ %d\r\n", lport); printf(" Fport........ %d\r\n", fport); printf(" Error........ %s\r\n", identifier); break; case 1: if (charset) syslog(LOG_INFO, "Reply: Userid: host=%s, opsys=%s, charset=%s, userid=%s", gethost(&faddr.sin_addr), opsys, charset, identifier); else syslog(LOG_INFO, "Reply: Userid: host=%s, opsys=%s, userid=%s", gethost(&faddr.sin_addr), opsys, identifier); printf("Userid response is:\r\n"); printf(" Lport........ %d\r\n", lport); printf(" Fport........ %d\r\n", fport); printf(" Opsys........ %s\r\n", opsys); printf(" Charset...... %s\r\n", charset ? charset : ""); printf(" Identifier... %s\r\n", identifier); if (id_query(id, ntohs(faddr.sin_port), ntohs(laddr.sin_port), 0) >= 0) { if (id_parse(id, NULL, &lport, &fport, &identifier, &opsys, &charset) == 1) printf(" Multiquery... Enabled\r\n"); } } fflush(stdout); sleep(1); exit(0); } socks4-server-4.3.beta2.orig/libident/ident.3100644 7657 764 13232 5606334271 17410 0ustar martinedv.\" Pär Emanuelsson 1993-03-28 .ds : \h'\w'u'u/5'\z"\h'-\w'e'u/5' .TH IDENT 3N "4 April 1993" "Lysator ACS" .SH NAME ident_lookup, ident_id, ident_free, id_open, id_close, id_query, id_parse, id_fileno \- query remote IDENT server .SH SYNOPSIS .nf .B #include .LP .I High-level calls .LP .B IDENT *ident_lookup(int fd, int timeout) .LP .B char *ident_id(int fd, int timeout) .LP .B void ident_free(IDENT *id) .LP .I Low-level calls .LP .B id_t *id_open(laddr, faddr, timeout) .B struct in_addr *laddr, *faddr; .B struct timeval *timeout; .LP .B int id_close(id) .B id_t *id; .LP .B id_query(id, lport, fport, timeout) .B id_t *id; .B int lport, fport; .B struct timeval *timeout; .LP .B int id_parse(id, timeout, lport, fport, identifier, .B opsys, charset) .B id_t *id; .B struct timeval *timeout; .B int *lport, *fport; .B char **identifier, **opsys, **charset; .LP .B int id_fileno(id) .B id_t *id; .fi .SH DESCRIPTION .LP .B ident_lookup tries to connect to a remote .B IDENT server to establish the identity of the peer connected on .I fd, which should be a socket file descriptor. .I timeout is the longest permissible time to block waiting for an answer, and is given in seconds. A value of 0 (zero) means wait indefinitely (which in the most extreme case will normally be until the underlying network times out). .B ident_lookup returns a pointer to an .I IDENT struct, which has the following contents: .RS .LP .nf .ft B typedef struct { int lport; /* Local port */ int fport; /* Far (remote) port */ char *identifier; /* Normally user name */ char *opsys; /* OS */ char *charset; /* Charset (what did you expect?) */ } IDENT; .ft R .fi .RE .LP For a full description of the different fields, refer to .I RFC-1413. .LP All data returned by .B ident_lookup (including the .SM IDENT struct) points to malloc'd data, which can be freed with a call to .B ident_free. .B ident_lookup returns 0 on error or timeout. Presently, this should normally be taken to mean that the remote site is not running an .SM IDENT server, but it might naturally be caused by other network related problems as well. .B Note that all fields of the .SM IDENT struct need not necessarily be set. .LP .B ident_id takes the same parameters as .B ident_lookup but only returns a pointer to a malloc'd area containing the .I identifier string, which is probably the most wanted data from the .SM IDENT query. .LP .B ident_free frees all data areas associated with the .SM IDENT struct pointed to by .I id, including the struct itself. .LP .ce .I Low-level calls .LP The low-level calls can be used when greater flexibility is needed. For example, if non-blocking I/O is needed, or multiple queries to the same host are to be made. .LP .B id_open opens a connection to the remote .SM IDENT server referred to by .I faddr. The timeout is specified by .I timeout. A null-pointer means wait indefinitely, while a pointer to a zero-valued .I timeval struct sets non-blocking I/O, in the same way as for .B select(2). .B id_open returns a pointer to an .B id_t datum, which is an opaque structure to be used as future reference to the opened connection. When using non-blocking I/O it might however be useful to access the underlying socket file descriptior, which can be gotten at through the .B id_fileno macro described below. .LP .B id_close closes the connection opened with .B id_open and frees all data associated with .I id. .LP .B id_query sends off a query to a remote .SM IDENT server. .I lport and .I fport are sent to the server to identify the connection for which identification is needed. .I timeout is given as for .B id_open. If successful, .B id_query returns the number of bytes sent to the remote server. If not, -1 is returned and .B errno is set. .LP .B id_parse parses the reply to a query sent off by .B id_query and returns information to the locations pointed to by .I lport, fport, identifier, opsys and .I charset. For string data .I (identifier, opsys and .I charset) pointers to malloc'd space are returned. .LP .B id_parse returns: .RS .TP 1 If completely successful. .TP -3 Illegal reply type from remote server. .I identifier is set to the illegal reply. .TP -2 Cannot parse the reply from the server. .I identifier is normally set to the illegal reply. .TP -1 On general errors or timeout. .TP 0 When non-blocking mode is set and .B id_parse has not finished parsing the reply from the remote server. .TP 2 Indicates the query/reply were successful, but the remote server experienced some error. .I identifier is set to the error message from the remote server. .RE .LP For all errors, .I errno is set as appropriate. .LP .B id_fileno is a macro that takes an .B id_t handle and returns the actual socket file descriptor used for the connection to the remote server. .SH ERRORS .TP 15 ETIMEDOUT The call timed out and non-blocking I/O was not set. .SH EXAMPLES .LP Here's an example how to handle the reply from id_reply() in the case that non-blocking I/O is set. Note that id_reply() will return 0 as long as it's not finished parsing a reply. .LP .RS .nf .nj int rcode; ... idp = id_open(...) ... while ((rcode = id_parse(idp, timeout, &lport, &fport, &id, &op, &cs)) == 0) ; if (rcode < 0) { if (rcode == ETIMEDOUT) foo(); /* Lookup timed out */ else bar(); /* Fatal error */ } else if (rcode == 1) { /* Valid USERID protocol reply */ } else if (rcode == 2) { /* Protocol ERROR reply */ } .fi .RE .SH SEE ALSO RFC-1413, socket(2), select(2) .SH AUTHORS Peter Eriksson .I .br P\*:ar Emanuelsson .I .SH BUGS For .B ident_lookup and .B ident_id the blocking time in extreme cases might be as much as three times the value given in the .I timeout parameter. socks4-server-4.3.beta2.orig/libident/ident.c100644 7657 764 4743 5606334271 17457 0ustar martinedv/* ** ident.c High-level calls to the ident lib ** ** Author: Pär Emanuelsson */ #include #include #include #include #include #include #include #include #include "ident.h" #if defined(AIX_PS2) || defined(ultrix) extern char *strdup(char *); #endif /* Do a complete ident query and return result */ IDENT *ident_lookup #ifdef __STDC__ (int fd, int timeout) #else (fd, timeout) int fd; int timeout; #endif { struct sockaddr_in localaddr, remoteaddr; int len, res; ident_t *id; struct timeval timout; IDENT *ident=0; len = sizeof(remoteaddr); if (getpeername(fd, (struct sockaddr *)&remoteaddr, &len) < 0) return 0; len = sizeof(localaddr); if (getsockname(fd, (struct sockaddr *)&localaddr, &len) < 0) return 0; timout.tv_sec = timeout; timout.tv_usec = 0; if (timeout) id = id_open(&localaddr.sin_addr, &remoteaddr.sin_addr, &timout); else id = id_open(&localaddr.sin_addr, &remoteaddr.sin_addr, (struct timeval *)0); if (!id) { errno = EINVAL; return 0; } if (timeout) res = id_query(id, ntohs(remoteaddr.sin_port), ntohs(localaddr.sin_port), &timout); else res = id_query(id, ntohs(remoteaddr.sin_port), ntohs(localaddr.sin_port), (struct timeval *) 0); if (res < 0) { id_close(id); return 0; } ident = (IDENT *) malloc(sizeof(IDENT)); if (!ident) { id_close(id); return 0; } if (timeout) res = id_parse(id, &timout, &ident->lport, &ident->fport, &ident->identifier, &ident->opsys, &ident->charset); else res = id_parse(id, (struct timeval *) 0, &ident->lport, &ident->fport, &ident->identifier, &ident->opsys, &ident->charset); if (res != 1) { free(ident); id_close(id); return 0; } id_close(id); return ident; /* At last! */ } char *ident_id #ifdef __STDC__ (int fd, int timeout) #else (fd, timeout) int fd; int timeout; #endif { IDENT *ident; char *id=0; ident = ident_lookup(fd, timeout); if (ident && ident->identifier && *ident->identifier) id = strdup(ident->identifier); ident_free(ident); return id; } void ident_free #ifdef __STDC__ (IDENT *id) #else (id) IDENT *id; #endif { if (!id) return; if (id->identifier) free(id->identifier); if (id->opsys) free(id->opsys); if (id->charset) free(id->charset); free(id); } socks4-server-4.3.beta2.orig/libident/ident.h100644 7657 764 3530 5606334267 17462 0ustar martinedv/* ** ident.h ** ** Author: Peter Eriksson ** Intruder: Pär Emanuelsson */ #ifndef __IDENT_H__ #define __IDENT_H__ #ifdef __P # undef __P #endif #ifdef __STDC__ # define __P(AL) AL #else # define __P(AL) () #endif /* * Sigh, GCC v2 complains when using undefined struct tags * in function prototypes... */ #if defined(__GNUC__) && !defined(IPPROTO_IP) # define __STRUCT_IN_ADDR_P void * #else # define __STRUCT_IN_ADDR_P struct in_addr * #endif #if defined(__GNUC__) && !defined(DST_NONE) # define __STRUCT_TIMEVAL_P void * #else # define __STRUCT_TIMEVAL_P struct timeval * #endif #ifndef IDBUFSIZE # define IDBUFSIZE 2048 #endif #ifndef IDPORT # define IDPORT 113 #endif typedef struct { int fd; char buf[IDBUFSIZE]; } ident_t; typedef struct { int lport; /* Local port */ int fport; /* Far (remote) port */ char *identifier; /* Normally user name */ char *opsys; /* OS */ char *charset; /* Charset (what did you expect?) */ } IDENT; /* For higher-level routines */ /* Low-level calls and macros */ #define id_fileno(ID) ((ID)->fd) extern ident_t * id_open __P((__STRUCT_IN_ADDR_P laddr, __STRUCT_IN_ADDR_P faddr, __STRUCT_TIMEVAL_P timeout)); extern int id_close __P((ident_t *id)); extern int id_query __P((ident_t *id, int lport, int fport, __STRUCT_TIMEVAL_P timeout)); extern int id_parse __P((ident_t *id, __STRUCT_TIMEVAL_P timeout, int *lport, int *fport, char **identifier, char **opsys, char **charset)); /* High-level calls */ extern IDENT *ident_lookup __P((int fd, int timeout)); extern char *ident_id __P((int fd, int timeout)); void ident_free __P((IDENT *id)); #endif socks4-server-4.3.beta2.orig/libident/lookup-tester.c100644 7657 764 2212 5606334271 21156 0ustar martinedv/* ** lookup-tester.c Tests the high-level ident calls. ** ** Author: Pär Emanuelsson , 28 March 1993 */ #include #include #include #include "ident.h" main(argc,argv) int argc; char *argv[]; { IDENT *ident; char *user; chdir("/tmp"); puts("Welcome to the other IDENT server tester, version 1.0\r\n\r"); puts("Testing ident_lookup...\r\n\r"); fflush(stdout); ident = ident_lookup(fileno(stdin), 30); if (!ident) perror("ident"); else { printf("IDENT response is:\r\n"); printf(" Lport........ %d\r\n", ident->lport); printf(" Fport........ %d\r\n", ident->fport); printf(" Opsys........ %s\r\n", ident->opsys); printf(" Charset...... %s\r\n", ident->charset ? ident->charset : ""); printf(" Identifier... %s\r\n", ident->identifier); } ident_free(ident); puts("\r\nTesting ident_id...\r\n\r"); fflush(stdout); user = ident_id(fileno(stdin), 30); if (user) printf("IDENT response is identifier = %s\r\n", user); else puts("IDENT lookup failed!\r"); fflush(stdout); sleep(1); exit(0); } socks4-server-4.3.beta2.orig/mkfc/ 40755 7657 764 0 6157332564 15236 5ustar martinedvsocks4-server-4.3.beta2.orig/mkfc/Makefile100644 7657 764 2132 6144762336 16771 0ustar martinedv# Do not do 'make' in this directory. Go to the top # directory and do 'make MKFC' or 'make install.mkfc' #======================================= CFLAGS = -I../include $(OPTIMIZE) $(OTHER_CFLAGS) PROGS = make_socksfc make_sockdfc make_sockdfr \ dump_socksfc dump_sockdfc dump_sockdfr all: echocwd $(PROGS) make_socksfc: make_socksfc.o $(SOCKS_LIB) $(CC) $(CFLAGS) -o $@ make_socksfc.o $(SOCKS_LIB) $(RESOLV_LIB) make_sockdfc: make_sockdfc.o $(SOCKS_LIB) $(CC) $(CFLAGS) -o $@ make_sockdfc.o $(SOCKS_LIB) $(RESOLV_LIB) make_sockdfr: make_sockdfr.o $(SOCKS_LIB) $(CC) $(CFLAGS) -o $@ make_sockdfr.o $(SOCKS_LIB) $(RESOLV_LIB) dump_socksfc: dump_socksfc.o $(SOCKS_LIB) $(CC) $(CFLAGS) -o $@ dump_socksfc.o $(SOCKS_LIB) $(RESOLV_LIB) dump_sockdfc: dump_sockdfc.o $(SOCKS_LIB) $(CC) $(CFLAGS) -o $@ dump_sockdfc.o $(SOCKS_LIB) $(RESOLV_LIB) dump_sockdfr: dump_sockdfr.o $(SOCKS_LIB) $(CC) $(CFLAGS) -o $@ dump_sockdfr.o $(SOCKS_LIB) $(RESOLV_LIB) install: echocwd $(PROGS) for i in $(PROGS); do \ $(INSTALL) -m 100 $$i $(MKFC_DIR) ;\ done clean: echocwd rm -rf $(PROGS) *.o core echocwd: @pwd socks4-server-4.3.beta2.orig/mkfc/dump_sockdfc.c100644 7657 764 720 6057723276 20122 0ustar martinedv/* dump_sockdfc */ #include #include #include #include #include #include "socks.h" /* output sent to stderr */ main(argc, argv) int argc; char **argv; { int useSyslog = 0; struct config *cfAddr = NULL; int Ncf = 0; char *cfstrings = NULL; char *file = SOCKD_FC; if (argc == 2) file = *++argv; socks_rdfz(file, &cfAddr, &Ncf, &cfstrings, useSyslog); sockd_dumpcf(cfAddr, Ncf, useSyslog); } socks4-server-4.3.beta2.orig/mkfc/dump_sockdfr.c100644 7657 764 731 6057723317 20137 0ustar martinedv/* dump_sockdfr */ #include #include #include #include #include #include "socks.h" /* output sent to stderr */ main(argc, argv) int argc; char **argv; { int useSyslog = 0; struct config *rtAddr = NULL; int Nrt = 0; char *rtstrings = NULL; char *file = SOCKD_FROUTE_FILE; if (argc == 2) file = *++argv; socks_rdfz(file, &rtAddr, &Nrt, &rtstrings, useSyslog); sockd_dumprt(rtAddr, Nrt, useSyslog); } socks4-server-4.3.beta2.orig/mkfc/dump_socksfc.c100644 7657 764 720 6057723330 20130 0ustar martinedv/* dump_socksfc */ #include #include #include #include #include #include "socks.h" /* output sent to stderr */ main(argc, argv) int argc; char **argv; { int useSyslog = 0; struct config *cfAddr = NULL; int Ncf = 0; char *cfstrings = NULL; char *file = SOCKS_FC; if (argc == 2) file = *++argv; socks_rdfz(file, &cfAddr, &Ncf, &cfstrings, useSyslog); socks_dumpcf(cfAddr, Ncf, useSyslog); } socks4-server-4.3.beta2.orig/mkfc/make_sockdfc.c100644 7657 764 1153 6057711166 20106 0ustar martinedv/* make_sockdfc */ #include #include #include "socks.h" char *infile = SOCKD_CONF, *outfile = SOCKD_FC; main(argc, argv) int argc; char **argv; { struct config *confAddr = NULL; int Nconf = 0; char *ptr1 = NULL, *ptr2 = NULL; int useSyslog = 0; if ((argc == 2) || (argc == 3)) infile = *++argv; if (argc == 3) outfile = *++argv; if (sockd_rdconf(infile, &confAddr, &Nconf, &ptr1, &ptr2, useSyslog) == -1) { fprintf(stderr, "File %s not found\n", infile); exit(1); } socks_wrfz(outfile, confAddr, Nconf, useSyslog); printf("Frozen configuration written to %s\n", outfile); } socks4-server-4.3.beta2.orig/mkfc/make_sockdfr.c100644 7657 764 1110 6057711135 20112 0ustar martinedv/* make_sockdfr */ #include #include #include "socks.h" char *infile = SOCKD_ROUTE_FILE, *outfile = SOCKD_FROUTE_FILE; main(argc, argv) int argc; char **argv; { struct config *confAddr = NULL; int Nconf = 0; int useSyslog = 0; if ((argc == 2) || (argc == 3)) infile = *++argv; if (argc == 3) outfile = *++argv; if (sockd_rdroute(infile, &confAddr, &Nconf, useSyslog) == -1) { fprintf(stderr, "File %s not found\n", infile); exit(1); } socks_wrfz(outfile, confAddr, Nconf, useSyslog); printf("Frozen route file written to %s\n", outfile); } socks4-server-4.3.beta2.orig/mkfc/make_socksfc.c100644 7657 764 1073 6057711370 20123 0ustar martinedv/* make_socksfc */ #include #include #include "socks.h" char *infile = SOCKS_CONF, *outfile = SOCKS_FC; main(argc, argv) int argc; char **argv; { struct config *confAddr = NULL; int Nconf = 0; int useSyslog = 0; if ((argc == 2) || (argc == 3)) infile = *++argv; if (argc == 3) outfile = *++argv; if (socks_rdconf(infile, &confAddr, &Nconf, useSyslog) == -1) { fprintf(stderr, "File %s not found\n", infile); exit(1); } socks_wrfz(outfile, confAddr, Nconf, useSyslog); printf("Frozen configuration written to %s\n", outfile); } socks4-server-4.3.beta2.orig/rfinger/ 40755 7657 764 0 6157332563 15751 5ustar martinedvsocks4-server-4.3.beta2.orig/rfinger/Makefile100644 7657 764 1762 6020677344 17512 0ustar martinedv# DO NOT start 'make' in this directory. Go to the top # directory of the SOCKS package and do it from there! #============================================================================== OBJ = finger.o SRC = finger.c CFLAGS = -I../include $(OPTIMIZE) $(OTHER_CFLAGS) $(SOCKS) all: echocwd rfinger rwhois rfinger: $(OBJ) $(SOCKS_LIB) ../include/socks.h ../Makefile $(CC) $(CFLAGS) -o $@ $(OBJ) $(SOCKS_LIB) $(RESOLV_LIB) rwhois: $(SRC) $(SOCKS_LIB) ../include/socks.h ../Makefile $(CC) $(WHOIS_SERVER) $(CFLAGS) -o $@ $(SRC) $(SOCKS_LIB) $(RESOLV_LIB) install: echocwd rfinger rwhois $(INSTALL) -m 111 rfinger $(CLIENTS_BIN_DIR) $(INSTALL) -m 111 rwhois $(CLIENTS_BIN_DIR) install.man: echocwd $(INSTALL) -m 444 ../doc/socks_clients.1 $(MAN_DEST_DIR)/man1 $(INSTALL) -m 444 ../doc/socks.conf.5 $(MAN_DEST_DIR)/man5 $(INSTALL) -m 444 ../doc/rfinger.1 $(MAN_DEST_DIR)/man1 $(INSTALL) -m 444 ../doc/rwhois.1 $(MAN_DEST_DIR)/man1 clean: echocwd rm -f $(OBJ) rwhois rfinger core echocwd: @pwd socks4-server-4.3.beta2.orig/rfinger/finger.c100644 7657 764 6020 6144443662 17461 0ustar martinedv/* finger */ #include #include #include #include #include #include #include #include #if defined(ISC) #include #endif /* #if defined(ISC) */ #include "socks.h" extern int errno; extern char *strrchr(); char *Progname; extern char *getenv(); int main(argc, argv) int argc; char **argv; { char buf[1024]; unsigned long l; struct sockaddr_in sin; struct hostent *hp; struct servent *sp; int c, v, n, i, ind; int s; FILE *in; char *cp; #ifdef WHOIS_SERVER char *service = "whois", *host = WHOIS_SERVER; #else char *service = "finger", *host = "localhost"; #endif struct in_addr dstaddr[21]; #ifdef LINUX int optind = 1; #else extern int optind; #endif extern char *optarg; if ((Progname = strrchr(argv[0], '/')) == NULL) Progname = argv[0]; else Progname++; #if defined(connect) SOCKSinit(Progname); #endif #ifdef WHOIS_SERVER while ((i = getopt(argc,argv,"h:")) != EOF) { switch (i) { case 'h': host = optarg; break; default: fprintf(stderr,"Usage: %s [-h host] name\n", Progname); exit(1); } } #endif *(cp = buf) = '\0'; for (i = optind; i < argc; i++) { strcat(cp, " "); cp++; if (strcmp(argv[i], "-l")) { strcat(cp, argv[i]); cp += strlen(argv[i]); } else { strcat(cp, "/W "); cp += 3; } } #ifndef WHOIS_SERVER if ((cp = strrchr(buf, '@')) != NULL) { *cp = '\0'; host = cp + 1; } else { if ((cp = getenv("ORIG_FINGER")) == NULL) cp = ORIG_FINGER; execvp(cp, argv); fprintf(stderr, "Unable to run %s\n", cp); exit(1); } #endif sin.sin_family = AF_INET; if ((sp = getservbyname(service, "tcp")) == NULL) { if ((v = atoi(service)) == 0) { fprintf(stderr, "%s: unknown service '%s'\n", Progname, service); exit(1); } sin.sin_port = htons((short) v); } else { sin.sin_port = sp->s_port; } if ((hp = gethostbyname(host)) == NULL) { if ((l = inet_addr(host)) == -1) { fprintf(stderr, "%s: unknown host '%s'\n", Progname, host); exit(1); } /* you are out of luck if your system doesn't use 2's complement in integer representation */ sin.sin_addr.s_addr = l ; } else { for (i = 0; (i < 20) && *hp->h_addr_list; i++, hp->h_addr_list++) bcopy(*hp->h_addr_list, &(dstaddr[i].s_addr), hp->h_length); dstaddr[i].s_addr = 0; i = 0; sin.sin_addr.s_addr = dstaddr[i++].s_addr; } if ((s = socket(AF_INET, SOCK_STREAM, 0)) < 0) { fprintf(stderr, "%s: ", Progname); perror("socket"); exit(1); } while (connect(s, &sin, sizeof(sin)) < 0) { if ((errno == ETIMEDOUT) && (hp != NULL) && ((sin.sin_addr.s_addr = dstaddr[i++].s_addr) != 0)) { continue; } fprintf(stderr, "%s: ", Progname); perror("connect"); exit(1); } cp = buf; if (*cp = ' ') cp++; strcat(cp, "\r\n"); if (write(s,cp,strlen(cp)) < 0) { fprintf(stderr, "%s: ", Progname); perror("write"); } while ((n = read(s, buf, sizeof(buf) - 1)) > 0) { write(1, buf, n); } close(s); } socks4-server-4.3.beta2.orig/rftp/ 40755 7657 764 0 6157332563 15270 5ustar martinedvsocks4-server-4.3.beta2.orig/rftp/Makefile100644 7657 764 1637 6144777443 17042 0ustar martinedv# DO NOT start 'make' in this directory. Go to the top # directory of the SOCKS package and do it from there! #============================================================================== #NO_PASV=-DNO_PASV PROG= rftp SRCS= cmds.c cmdtab.c ftp.c glob.c main.c ruserpass.c domacro.c OBJS= cmds.o cmdtab.o ftp.o glob.o main.o ruserpass.o domacro.o CFLAGS = -I../include $(OPTIMIZE) $(OTHER_CFLAGS) $(SOCKS) $(NO_PASV) all: echocwd rftp rftp: $(OBJS) $(SOCKS_LIB) ../include/socks.h ../Makefile $(CC) $(CFLAGS) -o $@ $(OBJS) $(SOCKS_LIB) $(RESOLV_LIB) install: echocwd rftp $(INSTALL) -m 111 rftp $(CLIENTS_BIN_DIR) install.man: echocwd $(INSTALL) -m 444 ../doc/socks_clients.1 $(MAN_DEST_DIR)/man1 $(INSTALL) -m 444 ../doc/socks.conf.5 $(MAN_DEST_DIR)/man5 $(INSTALL) -m 444 ../doc/rftp.1 $(MAN_DEST_DIR)/man1 $(INSTALL) -m 444 ftp.1 $(MAN_DEST_DIR)/man1 clean: echocwd rm -f $(OBJS) core $(PROG) echocwd: @pwd socks4-server-4.3.beta2.orig/rftp/cmds.c100644 7657 764 120466 6072365607 16531 0ustar martinedv/* * Copyright (c) 1985, 1989 Regents of the University of California. * All rights reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions * are met: * 1. Redistributions of source code must retain the above copyright * notice, this list of conditions and the following disclaimer. * 2. Redistributions in binary form must reproduce the above copyright * notice, this list of conditions and the following disclaimer in the * documentation and/or other materials provided with the distribution. * 3. All advertising materials mentioning features or use of this software * must display the following acknowledgement: * This product includes software developed by the University of * California, Berkeley and its contributors. * 4. Neither the name of the University nor the names of its contributors * may be used to endorse or promote products derived from this software * without specific prior written permission. * * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF * SUCH DAMAGE. */ #ifndef lint static char sccsid[] = "@(#)cmds.c 5.26 (Berkeley) 3/5/91"; #endif /* not lint */ /* * FTP User Program -- Command Routines. */ #if defined(ISC) #include #endif /* #if defined(ISC) */ #include #include #include #include #if defined(ISC) #include #define MAXPATHLEN PATH_MAX #endif /* #if defined(ISC) */ #include /* >>> Anthony Shipman, als@cpsg.com.au */ #if defined(hpux) || defined(SOLARIS) || defined(SCO) || defined(_SEQUENT_) # include # define GETCWD #else extern char *getwd(); #endif /* <<< Anthony Shipman, als@cpsg.com.au */ #include #include #include #include #include #include #include #include "ftp_var.h" #include "pathnames.h" extern char *globerr; extern char **ftpglob(); extern char *home; extern char *remglob(); extern char *getenv(); extern char *index(); extern char *rindex(); extern char *strerror(); extern int errno; extern off_t restart_point; extern char reply_string[]; char *mname; jmp_buf jabort; char *dotrans(), *domap(); /* * `Another' gets another argument, and stores the new argc and argv. * It reverts to the top level (via main.c's intr()) on EOF/error. * * Returns false if no new arguments have been added. */ another(pargc, pargv, prompt) int *pargc; char ***pargv; char *prompt; { int len = strlen(line), ret; extern sig_t intr(); if (len >= sizeof(line) - 3) { printf("sorry, arguments too long\n"); intr(); } printf("(%s) ", prompt); line[len++] = ' '; if (fgets(&line[len], sizeof(line) - len, stdin) == NULL) intr(); len += strlen(&line[len]); if (len > 0 && line[len - 1] == '\n') line[len - 1] = '\0'; makeargv(); ret = margc > *pargc; *pargc = margc; *pargv = margv; return (ret); } /* * Connect to peer server and * auto-login, if possible. */ setpeer(argc, argv) int argc; char *argv[]; { char *host, *hookup(); short port; if (connected) { printf("Already connected to %s, use close first.\n", hostname); code = -1; return; } if (argc < 2) (void) another(&argc, &argv, "to"); if (argc < 2 || argc > 3) { printf("usage: %s host-name [port]\n", argv[0]); code = -1; return; } /* port = sp->s_port; */ port = ftp_s_port; if (argc > 2) { port = atoi(argv[2]); if (port <= 0) { printf("%s: bad port number-- %s\n", argv[1], argv[2]); printf ("usage: %s host-name [port]\n", argv[0]); code = -1; return; } port = htons(port); } host = hookup(argv[1], port); if (host) { int overbose; connected = 1; /* * Set up defaults for FTP. */ (void) strcpy(typename, "ascii"), type = TYPE_A; curtype = TYPE_A; (void) strcpy(formname, "non-print"), form = FORM_N; (void) strcpy(modename, "stream"), mode = MODE_S; (void) strcpy(structname, "file"), stru = STRU_F; (void) strcpy(bytename, "8"), bytesize = 8; if (autologin) (void) login(argv[1]); #if defined(unix) && NBBY == 8 /* * this ifdef is to keep someone form "porting" this to an incompatible * system and not checking this out. This way they have to think about it. */ overbose = verbose; if (debug == 0) verbose = -1; if (command("SYST") == COMPLETE && overbose) { register char *cp, c; cp = index(reply_string+4, ' '); if (cp == NULL) cp = index(reply_string+4, '\r'); if (cp) { if (cp[-1] == '.') cp--; c = *cp; *cp = '\0'; } printf("Remote system type is %s.\n", reply_string+4); if (cp) *cp = c; } if (!strncmp(reply_string, "215 UNIX Type: L8", 17)) { if (proxy) unix_proxy = 1; else unix_server = 1; /* * Set type to 0 (not specified by user), * meaning binary by default, but don't bother * telling server. We can use binary * for text files unless changed by the user. */ type = 0; (void) strcpy(typename, "binary"); if (overbose) printf("Using %s mode to transfer files.\n", typename); } else { if (proxy) unix_proxy = 0; else unix_server = 0; if (overbose && !strncmp(reply_string, "215 TOPS20", 10)) printf( "Remember to set tenex mode when transfering binary files from this machine.\n"); } verbose = overbose; #endif /* unix */ } } struct types { char *t_name; char *t_mode; int t_type; char *t_arg; } types[] = { { "ascii", "A", TYPE_A, 0 }, { "binary", "I", TYPE_I, 0 }, { "image", "I", TYPE_I, 0 }, { "ebcdic", "E", TYPE_E, 0 }, { "tenex", "L", TYPE_L, bytename }, 0 }; /* * Set transfer type. */ settype(argc, argv) int argc; char *argv[]; { register struct types *p; int comret; if (argc > 2) { char *sep; printf("usage: %s [", argv[0]); sep = " "; for (p = types; p->t_name; p++) { printf("%s%s", sep, p->t_name); sep = " | "; } printf(" ]\n"); code = -1; return; } if (argc < 2) { printf("Using %s mode to transfer files.\n", typename); code = 0; return; } for (p = types; p->t_name; p++) if (strcmp(argv[1], p->t_name) == 0) break; if (p->t_name == 0) { printf("%s: unknown mode\n", argv[1]); code = -1; return; } if ((p->t_arg != NULL) && (*(p->t_arg) != '\0')) comret = command ("TYPE %s %s", p->t_mode, p->t_arg); else comret = command("TYPE %s", p->t_mode); if (comret == COMPLETE) { (void) strcpy(typename, p->t_name); curtype = type = p->t_type; } } /* * Internal form of settype; changes current type in use with server * without changing our notion of the type for data transfers. * Used to change to and from ascii for listings. */ changetype(newtype, show) int newtype, show; { register struct types *p; int comret, oldverbose = verbose; if (newtype == 0) newtype = TYPE_I; if (newtype == curtype) return; if (debug == 0 && show == 0) verbose = 0; for (p = types; p->t_name; p++) if (newtype == p->t_type) break; if (p->t_name == 0) { printf("ftp: internal error: unknown type %d\n", newtype); return; } if (newtype == TYPE_L && bytename[0] != '\0') comret = command("TYPE %s %s", p->t_mode, bytename); else comret = command("TYPE %s", p->t_mode); if (comret == COMPLETE) curtype = newtype; verbose = oldverbose; } char *stype[] = { "type", "", 0 }; /* * Set binary transfer type. */ /*VARARGS*/ setbinary() { stype[1] = "binary"; settype(2, stype); } /* * Set ascii transfer type. */ /*VARARGS*/ setascii() { stype[1] = "ascii"; settype(2, stype); } /* * Set tenex transfer type. */ /*VARARGS*/ settenex() { stype[1] = "tenex"; settype(2, stype); } /* * Set file transfer mode. */ /*ARGSUSED*/ setmode(argc, argv) int argc; char *argv[]; { printf("We only support %s mode, sorry.\n", modename); code = -1; } /* * Set file transfer format. */ /*ARGSUSED*/ setform(argc, argv) int argc; char *argv[]; { printf("We only support %s format, sorry.\n", formname); code = -1; } /* * Set file transfer structure. */ /*ARGSUSED*/ setstruct(argc, argv) int argc; char *argv[]; { printf("We only support %s structure, sorry.\n", structname); code = -1; } /* * Send a single file. */ put(argc, argv) int argc; char *argv[]; { char *cmd; int loc = 0; char *oldargv1, *oldargv2; if (argc == 2) { argc++; argv[2] = argv[1]; loc++; } if (argc < 2 && !another(&argc, &argv, "local-file")) goto usage; if (argc < 3 && !another(&argc, &argv, "remote-file")) { usage: printf("usage: %s local-file remote-file\n", argv[0]); code = -1; return; } oldargv1 = argv[1]; oldargv2 = argv[2]; if (!globulize(&argv[1])) { code = -1; return; } /* * If "globulize" modifies argv[1], and argv[2] is a copy of * the old argv[1], make it a copy of the new argv[1]. */ if (argv[1] != oldargv1 && argv[2] == oldargv1) { argv[2] = argv[1]; } cmd = (argv[0][0] == 'a') ? "APPE" : ((sunique) ? "STOU" : "STOR"); if (loc && ntflag) { argv[2] = dotrans(argv[2]); } if (loc && mapflag) { argv[2] = domap(argv[2]); } sendrequest(cmd, argv[1], argv[2], argv[1] != oldargv1 || argv[2] != oldargv2); } /* * Send multiple files. */ mput(argc, argv) int argc; char **argv; { extern jmp_buf jabort; register int i; sig_t oldintr; int ointer; char *tp; void mabort(); if (argc < 2 && !another(&argc, &argv, "local-files")) { printf("usage: %s local-files\n", argv[0]); code = -1; return; } mname = argv[0]; mflag = 1; oldintr = signal(SIGINT, mabort); (void) setjmp(jabort); if (proxy) { char *cp, *tp2, tmpbuf[MAXPATHLEN]; while ((cp = remglob(argv,0)) != NULL) { if (*cp == 0) { mflag = 0; continue; } if (mflag && confirm(argv[0], cp)) { tp = cp; if (mcase) { while (*tp && !islower(*tp)) { tp++; } if (!*tp) { tp = cp; tp2 = tmpbuf; while ((*tp2 = *tp) != '\0') { if (isupper(*tp2)) { *tp2 = 'a' + *tp2 - 'A'; } tp++; tp2++; } } tp = tmpbuf; } if (ntflag) { tp = dotrans(tp); } if (mapflag) { tp = domap(tp); } sendrequest((sunique) ? "STOU" : "STOR", cp, tp, cp != tp || !interactive); if (!mflag && fromatty) { ointer = interactive; interactive = 1; if (confirm("Continue with","mput")) { mflag++; } interactive = ointer; } } } (void) signal(SIGINT, oldintr); mflag = 0; return; } for (i = 1; i < argc; i++) { register char **cpp, **gargs; if (!doglob) { if (mflag && confirm(argv[0], argv[i])) { tp = (ntflag) ? dotrans(argv[i]) : argv[i]; tp = (mapflag) ? domap(tp) : tp; sendrequest((sunique) ? "STOU" : "STOR", argv[i], tp, tp != argv[i] || !interactive); if (!mflag && fromatty) { ointer = interactive; interactive = 1; if (confirm("Continue with","mput")) { mflag++; } interactive = ointer; } } continue; } gargs = ftpglob(argv[i]); if (globerr != NULL) { printf("%s\n", globerr); if (gargs) { blkfree(gargs); free((char *)gargs); } continue; } for (cpp = gargs; cpp && *cpp != NULL; cpp++) { if (mflag && confirm(argv[0], *cpp)) { tp = (ntflag) ? dotrans(*cpp) : *cpp; tp = (mapflag) ? domap(tp) : tp; sendrequest((sunique) ? "STOU" : "STOR", *cpp, tp, *cpp != tp || !interactive); if (!mflag && fromatty) { ointer = interactive; interactive = 1; if (confirm("Continue with","mput")) { mflag++; } interactive = ointer; } } } if (gargs != NULL) { blkfree(gargs); free((char *)gargs); } } (void) signal(SIGINT, oldintr); mflag = 0; } reget(argc, argv) int argc; char *argv[]; { (void) getit(argc, argv, 1, "r+w"); } get(argc, argv) int argc; char *argv[]; { (void) getit(argc, argv, 0, restart_point ? "r+w" : "w" ); } /* * Receive one file. */ getit(argc, argv, restartit, mode) int argc; char *argv[]; char *mode; { int loc = 0; char *oldargv1, *oldargv2; if (argc == 2) { argc++; argv[2] = argv[1]; loc++; } if (argc < 2 && !another(&argc, &argv, "remote-file")) goto usage; if (argc < 3 && !another(&argc, &argv, "local-file")) { usage: printf("usage: %s remote-file [ local-file ]\n", argv[0]); code = -1; return (0); } oldargv1 = argv[1]; oldargv2 = argv[2]; if (!globulize(&argv[2])) { code = -1; return (0); } if (loc && mcase) { char *tp = argv[1], *tp2, tmpbuf[MAXPATHLEN]; while (*tp && !islower(*tp)) { tp++; } if (!*tp) { tp = argv[2]; tp2 = tmpbuf; while ((*tp2 = *tp) != '\0') { if (isupper(*tp2)) { *tp2 = 'a' + *tp2 - 'A'; } tp++; tp2++; } argv[2] = tmpbuf; } } if (loc && ntflag) argv[2] = dotrans(argv[2]); if (loc && mapflag) argv[2] = domap(argv[2]); if (restartit) { struct stat stbuf; int ret; ret = stat(argv[2], &stbuf); if (restartit == 1) { if (ret < 0) { fprintf(stderr, "local: %s: %s\n", argv[2], strerror(errno)); return (0); } restart_point = stbuf.st_size; } else { if (ret == 0) { int overbose; overbose = verbose; if (debug == 0) verbose = -1; if (command("MDTM %s", argv[1]) == COMPLETE) { int yy, mo, day, hour, min, sec; struct tm *tm; verbose = overbose; sscanf(reply_string, "%*s %04d%02d%02d%02d%02d%02d", &yy, &mo, &day, &hour, &min, &sec); tm = gmtime(&stbuf.st_mtime); tm->tm_mon++; if (tm->tm_year > yy%100) return (1); else if (tm->tm_year == yy%100) { if (tm->tm_mon > mo) return (1); } else if (tm->tm_mon == mo) { if (tm->tm_mday > day) return (1); } else if (tm->tm_mday == day) { if (tm->tm_hour > hour) return (1); } else if (tm->tm_hour == hour) { if (tm->tm_min > min) return (1); } else if (tm->tm_min == min) { if (tm->tm_sec > sec) return (1); } } else { printf("%s\n", reply_string); verbose = overbose; return (0); } } } } recvrequest("RETR", argv[2], argv[1], mode, argv[1] != oldargv1 || argv[2] != oldargv2); restart_point = 0; return (0); } void mabort() { int ointer; extern jmp_buf jabort; printf("\n"); (void) fflush(stdout); if (mflag && fromatty) { ointer = interactive; interactive = 1; if (confirm("Continue with", mname)) { interactive = ointer; longjmp(jabort,0); } interactive = ointer; } mflag = 0; longjmp(jabort,0); } /* * Get multiple files. */ mget(argc, argv) int argc; char **argv; { extern jmp_buf jabort; sig_t oldintr; int ointer; char *cp, *tp, *tp2, tmpbuf[MAXPATHLEN]; void mabort(); if (argc < 2 && !another(&argc, &argv, "remote-files")) { printf("usage: %s remote-files\n", argv[0]); code = -1; return; } mname = argv[0]; mflag = 1; oldintr = signal(SIGINT,mabort); (void) setjmp(jabort); while ((cp = remglob(argv,proxy)) != NULL) { if (*cp == '\0') { mflag = 0; continue; } if (mflag && confirm(argv[0], cp)) { tp = cp; if (mcase) { while (*tp && !islower(*tp)) { tp++; } if (!*tp) { tp = cp; tp2 = tmpbuf; while ((*tp2 = *tp) != '\0') { if (isupper(*tp2)) { *tp2 = 'a' + *tp2 - 'A'; } tp++; tp2++; } } tp = tmpbuf; } if (ntflag) { tp = dotrans(tp); } if (mapflag) { tp = domap(tp); } recvrequest("RETR", tp, cp, "w", tp != cp || !interactive); if (!mflag && fromatty) { ointer = interactive; interactive = 1; if (confirm("Continue with","mget")) { mflag++; } interactive = ointer; } } } (void) signal(SIGINT,oldintr); mflag = 0; } char * remglob(argv,doswitch) char *argv[]; int doswitch; { char temp[16]; static char buf[MAXPATHLEN]; static FILE *ftemp = NULL; static char **args; int oldverbose, oldhash; char *cp, *mode; if (!mflag) { if (!doglob) { args = NULL; } else { if (ftemp) { (void) fclose(ftemp); ftemp = NULL; } } return(NULL); } if (!doglob) { if (args == NULL) args = argv; if ((cp = *++args) == NULL) args = NULL; return (cp); } if (ftemp == NULL) { (void) strcpy(temp, _PATH_TMP); (void) mktemp(temp); oldverbose = verbose, verbose = 0; oldhash = hash, hash = 0; if (doswitch) { pswitch(!proxy); } for (mode = "w"; *++argv != NULL; mode = "a") recvrequest ("NLST", temp, *argv, mode, 0); if (doswitch) { pswitch(!proxy); } verbose = oldverbose; hash = oldhash; ftemp = fopen(temp, "r"); (void) unlink(temp); if (ftemp == NULL) { printf("can't find list of remote files, oops\n"); return (NULL); } } if (fgets(buf, sizeof (buf), ftemp) == NULL) { (void) fclose(ftemp), ftemp = NULL; return (NULL); } if ((cp = index(buf, '\n')) != NULL) *cp = '\0'; return (buf); } char * onoff(bool) int bool; { return (bool ? "on" : "off"); } /* * Show status. */ /*ARGSUSED*/ status(argc, argv) int argc; char *argv[]; { int i; if (connected) printf("Connected to %s.\n", hostname); else printf("Not connected.\n"); if (!proxy) { pswitch(1); if (connected) { printf("Connected for proxy commands to %s.\n", hostname); } else { printf("No proxy connection.\n"); } pswitch(0); } printf("Mode: %s; Type: %s; Form: %s; Structure: %s\n", modename, typename, formname, structname); printf("Verbose: %s; Bell: %s; Prompting: %s; Globbing: %s\n", onoff(verbose), onoff(bell), onoff(interactive), onoff(doglob)); printf("Store unique: %s; Receive unique: %s\n", onoff(sunique), onoff(runique)); printf("Case: %s; CR stripping: %s\n",onoff(mcase),onoff(crflag)); if (ntflag) { printf("Ntrans: (in) %s (out) %s\n", ntin,ntout); } else { printf("Ntrans: off\n"); } if (mapflag) { printf("Nmap: (in) %s (out) %s\n", mapin, mapout); } else { printf("Nmap: off\n"); } printf("Hash mark printing: %s; Use of PORT cmds: %s\n", onoff(hash), onoff(sendport)); if (macnum > 0) { printf("Macros:\n"); for (i=0; i 1) { val = atoi(argv[1]); if (val < 0) { printf("%s: bad debugging value.\n", argv[1]); code = -1; return; } } else val = !debug; debug = val; if (debug) options |= SO_DEBUG; else options &= ~SO_DEBUG; printf("Debugging %s (debug=%d).\n", onoff(debug), debug); code = debug > 0; } /* * Set current working directory * on remote machine. */ cd(argc, argv) int argc; char *argv[]; { if (argc < 2 && !another(&argc, &argv, "remote-directory")) { printf("usage: %s remote-directory\n", argv[0]); code = -1; return; } if (command("CWD %s", argv[1]) == ERROR && code == 500) { if (verbose) printf("CWD command not recognized, trying XCWD\n"); (void) command("XCWD %s", argv[1]); } } /* * Set current working directory * on local machine. */ lcd(argc, argv) int argc; char *argv[]; { char buf[MAXPATHLEN]; #ifndef GETCWD extern char *getwd(); #endif if (argc < 2) argc++, argv[1] = home; if (argc != 2) { printf("usage: %s local-directory\n", argv[0]); code = -1; return; } if (!globulize(&argv[1])) { code = -1; return; } if (chdir(argv[1]) < 0) { fprintf(stderr, "local: %s: %s\n", argv[1], strerror(errno)); code = -1; return; } #ifdef GETCWD printf("Local directory now %s\n", getcwd(buf, MAXPATHLEN-1)); #else printf("Local directory now %s\n", getwd(buf)); #endif code = 0; } /* * Delete a single file. */ delete(argc, argv) int argc; char *argv[]; { if (argc < 2 && !another(&argc, &argv, "remote-file")) { printf("usage: %s remote-file\n", argv[0]); code = -1; return; } (void) command("DELE %s", argv[1]); } /* * Delete multiple files. */ mdelete(argc, argv) int argc; char **argv; { extern jmp_buf jabort; sig_t oldintr; int ointer; char *cp; void mabort(); if (argc < 2 && !another(&argc, &argv, "remote-files")) { printf("usage: %s remote-files\n", argv[0]); code = -1; return; } mname = argv[0]; mflag = 1; oldintr = signal(SIGINT, mabort); (void) setjmp(jabort); while ((cp = remglob(argv,0)) != NULL) { if (*cp == '\0') { mflag = 0; continue; } if (mflag && confirm(argv[0], cp)) { (void) command("DELE %s", cp); if (!mflag && fromatty) { ointer = interactive; interactive = 1; if (confirm("Continue with", "mdelete")) { mflag++; } interactive = ointer; } } } (void) signal(SIGINT, oldintr); mflag = 0; } /* * Rename a remote file. */ renamefile(argc, argv) int argc; char *argv[]; { if (argc < 2 && !another(&argc, &argv, "from-name")) goto usage; if (argc < 3 && !another(&argc, &argv, "to-name")) { usage: printf("%s from-name to-name\n", argv[0]); code = -1; return; } if (command("RNFR %s", argv[1]) == CONTINUE) (void) command("RNTO %s", argv[2]); } /* * Get a directory listing * of remote files. */ ls(argc, argv) int argc; char *argv[]; { char *cmd; if (argc < 2) argc++, argv[1] = NULL; if (argc < 3) argc++, argv[2] = "-"; if (argc > 3) { printf("usage: %s remote-directory local-file\n", argv[0]); code = -1; return; } cmd = argv[0][0] == 'n' ? "NLST" : "LIST"; if (strcmp(argv[2], "-") && !globulize(&argv[2])) { code = -1; return; } if (strcmp(argv[2], "-") && *argv[2] != '|') if (!globulize(&argv[2]) || !confirm("output to local-file:", argv[2])) { code = -1; return; } recvrequest(cmd, argv[2], argv[1], "w", 0); } /* * Get a directory listing * of multiple remote files. */ mls(argc, argv) int argc; char **argv; { extern jmp_buf jabort; sig_t oldintr; int ointer, i; char *cmd, mode[1], *dest; void mabort(); if (argc < 2 && !another(&argc, &argv, "remote-files")) goto usage; if (argc < 3 && !another(&argc, &argv, "local-file")) { usage: printf("usage: %s remote-files local-file\n", argv[0]); code = -1; return; } dest = argv[argc - 1]; argv[argc - 1] = NULL; if (strcmp(dest, "-") && *dest != '|') if (!globulize(&dest) || !confirm("output to local-file:", dest)) { code = -1; return; } cmd = argv[0][1] == 'l' ? "NLST" : "LIST"; mname = argv[0]; mflag = 1; oldintr = signal(SIGINT, mabort); (void) setjmp(jabort); for (i = 1; mflag && i < argc-1; ++i) { *mode = (i == 1) ? 'w' : 'a'; recvrequest(cmd, dest, argv[i], mode, 0); if (!mflag && fromatty) { ointer = interactive; interactive = 1; if (confirm("Continue with", argv[0])) { mflag ++; } interactive = ointer; } } (void) signal(SIGINT, oldintr); mflag = 0; } /* * Do a shell escape */ /*ARGSUSED*/ shell(argc, argv) int argc; char **argv; { int pid; sig_t old1, old2; char shellnam[40], *shell, *namep; #if defined(SOLARIS) || defined(__alpha) || defined(SCO) || defined(ISC) int status; #else union wait status; #endif old1 = signal (SIGINT, SIG_IGN); old2 = signal (SIGQUIT, SIG_IGN); if ((pid = fork()) == 0) { for (pid = 3; pid < 20; pid++) (void) close(pid); (void) signal(SIGINT, SIG_DFL); (void) signal(SIGQUIT, SIG_DFL); shell = getenv("SHELL"); if (shell == NULL) shell = _PATH_BSHELL; namep = rindex(shell,'/'); if (namep == NULL) namep = shell; (void) strcpy(shellnam,"-"); (void) strcat(shellnam, ++namep); if (strcmp(namep, "sh") != 0) shellnam[0] = '+'; if (debug) { printf ("%s\n", shell); (void) fflush (stdout); } if (argc > 1) { execl(shell,shellnam,"-c",altarg,(char *)0); } else { execl(shell,shellnam,(char *)0); } perror(shell); code = -1; exit(1); } if (pid > 0) #if defined(SOLARIS) || defined(__alpha) while (wait(&status) != pid) ; #else while (wait((int *)&status) != pid) ; #endif (void) signal(SIGINT, old1); (void) signal(SIGQUIT, old2); if (pid == -1) { perror("Try again later"); code = -1; } else { code = 0; } return (0); } /* * Send new user information (re-login) */ user(argc, argv) int argc; char **argv; { char acct[80], *getpass(); int n, aflag = 0; if (argc < 2) (void) another(&argc, &argv, "username"); if (argc < 2 || argc > 4) { printf("usage: %s username [password] [account]\n", argv[0]); code = -1; return (0); } n = command("USER %s", argv[1]); if (n == CONTINUE) { if (argc < 3 ){ if (strcmp(argv[1], "anonymous") == 0) { printf("Password: "); (void) fflush(stdout); (void) fgets(acct, sizeof(acct) - 1, stdin); acct[strlen(acct) - 1] = '\0'; argv[2] = acct; } else argv[2] = getpass("Password: "); argc++; } n = command("PASS %s", argv[2]); } if (n == CONTINUE) { if (argc < 4) { printf("Account: "); (void) fflush(stdout); (void) fgets(acct, sizeof(acct) - 1, stdin); acct[strlen(acct) - 1] = '\0'; argv[3] = acct; argc++; } n = command("ACCT %s", argv[3]); aflag++; } if (n != COMPLETE) { fprintf(stdout, "Login failed.\n"); return (0); } if (!aflag && argc == 4) { (void) command("ACCT %s", argv[3]); } return (1); } /* * Print working directory. */ /*VARARGS*/ pwd() { int oldverbose = verbose; /* * If we aren't verbose, this doesn't do anything! */ verbose = 1; if (command("PWD") == ERROR && code == 500) { printf("PWD command not recognized, trying XPWD\n"); (void) command("XPWD"); } verbose = oldverbose; } /* * Make a directory. */ makedir(argc, argv) int argc; char *argv[]; { if (argc < 2 && !another(&argc, &argv, "directory-name")) { printf("usage: %s directory-name\n", argv[0]); code = -1; return; } if (command("MKD %s", argv[1]) == ERROR && code == 500) { if (verbose) printf("MKD command not recognized, trying XMKD\n"); (void) command("XMKD %s", argv[1]); } } /* * Remove a directory. */ removedir(argc, argv) int argc; char *argv[]; { if (argc < 2 && !another(&argc, &argv, "directory-name")) { printf("usage: %s directory-name\n", argv[0]); code = -1; return; } if (command("RMD %s", argv[1]) == ERROR && code == 500) { if (verbose) printf("RMD command not recognized, trying XRMD\n"); (void) command("XRMD %s", argv[1]); } } /* * Send a line, verbatim, to the remote machine. */ quote(argc, argv) int argc; char *argv[]; { if (argc < 2 && !another(&argc, &argv, "command line to send")) { printf("usage: %s line-to-send\n", argv[0]); code = -1; return; } quote1("", argc, argv); } /* * Send a SITE command to the remote machine. The line * is sent verbatim to the remote machine, except that the * word "SITE" is added at the front. */ site(argc, argv) int argc; char *argv[]; { if (argc < 2 && !another(&argc, &argv, "arguments to SITE command")) { printf("usage: %s line-to-send\n", argv[0]); code = -1; return; } quote1("SITE ", argc, argv); } /* * Turn argv[1..argc) into a space-separated string, then prepend initial text. * Send the result as a one-line command and get response. */ quote1(initial, argc, argv) char *initial; int argc; char **argv; { register int i, len; char buf[BUFSIZ]; /* must be >= sizeof(line) */ (void) strcpy(buf, initial); if (argc > 1) { len = strlen(buf); len += strlen(strcpy(&buf[len], argv[1])); for (i = 2; i < argc; i++) { buf[len++] = ' '; len += strlen(strcpy(&buf[len], argv[i])); } } if (command(buf) == PRELIM) { while (getreply(0) == PRELIM); } } do_chmod(argc, argv) int argc; char *argv[]; { if (argc < 2 && !another(&argc, &argv, "mode")) goto usage; if (argc < 3 && !another(&argc, &argv, "file-name")) { usage: printf("usage: %s mode file-name\n", argv[0]); code = -1; return; } (void) command("SITE CHMOD %s %s", argv[1], argv[2]); } do_umask(argc, argv) int argc; char *argv[]; { int oldverbose = verbose; verbose = 1; (void) command(argc == 1 ? "SITE UMASK" : "SITE UMASK %s", argv[1]); verbose = oldverbose; } idle(argc, argv) int argc; char *argv[]; { int oldverbose = verbose; verbose = 1; (void) command(argc == 1 ? "SITE IDLE" : "SITE IDLE %s", argv[1]); verbose = oldverbose; } /* * Ask the other side for help. */ rmthelp(argc, argv) int argc; char *argv[]; { int oldverbose = verbose; verbose = 1; (void) command(argc == 1 ? "HELP" : "HELP %s", argv[1]); verbose = oldverbose; } /* * Terminate session and exit. */ /*VARARGS*/ quit() { if (connected) disconnect(); pswitch(1); if (connected) { disconnect(); } exit(0); } /* * Terminate session, but don't exit. */ disconnect() { extern FILE *cout; extern int data; if (!connected) return; (void) command("QUIT"); if (cout) { (void) fclose(cout); } cout = NULL; connected = 0; data = -1; if (!proxy) { macnum = 0; } } confirm(cmd, file) char *cmd, *file; { char line[BUFSIZ]; if (!interactive) return (1); printf("%s %s? ", cmd, file); (void) fflush(stdout); if (fgets(line, sizeof line, stdin) == NULL) return (0); return (*line != 'n' && *line != 'N'); } fatal(msg) char *msg; { fprintf(stderr, "ftp: %s\n", msg); exit(1); } /* * Glob a local file name specification with * the expectation of a single return value. * Can't control multiple values being expanded * from the expression, we return only the first. */ globulize(cpp) char **cpp; { char **globbed; if (!doglob) return (1); globbed = ftpglob(*cpp); if (globerr != NULL) { printf("%s: %s\n", *cpp, globerr); if (globbed) { blkfree(globbed); free((char *)globbed); } return (0); } if (globbed) { *cpp = *globbed++; /* don't waste too much memory */ if (*globbed) { blkfree(globbed); free((char *)globbed); } } return (1); } account(argc,argv) int argc; char **argv; { char acct[50], *getpass(), *ap; if (argc > 1) { ++argv; --argc; (void) strncpy(acct,*argv,49); acct[49] = '\0'; while (argc > 1) { --argc; ++argv; (void) strncat(acct,*argv, 49-strlen(acct)); } ap = acct; } else { ap = getpass("Account:"); } (void) command("ACCT %s", ap); } jmp_buf abortprox; void proxabort() { extern int proxy; if (!proxy) { pswitch(1); } if (connected) { proxflag = 1; } else { proxflag = 0; } pswitch(0); longjmp(abortprox,1); } doproxy(argc,argv) int argc; char *argv[]; { extern struct cmd cmdtab[]; extern jmp_buf abortprox; register struct cmd *c; struct cmd *getcmd(); sig_t oldintr; void proxabort(); if (argc < 2 && !another(&argc, &argv, "command")) { printf("usage: %s command\n", argv[0]); code = -1; return; } c = getcmd(argv[1]); if (c == (struct cmd *) -1) { printf("?Ambiguous command\n"); (void) fflush(stdout); code = -1; return; } if (c == 0) { printf("?Invalid command\n"); (void) fflush(stdout); code = -1; return; } if (!c->c_proxy) { printf("?Invalid proxy command\n"); (void) fflush(stdout); code = -1; return; } if (setjmp(abortprox)) { code = -1; return; } oldintr = signal(SIGINT, proxabort); pswitch(1); if (c->c_conn && !connected) { printf("Not connected\n"); (void) fflush(stdout); pswitch(0); (void) signal(SIGINT, oldintr); code = -1; return; } (*c->c_handler)(argc-1, argv+1); if (connected) { proxflag = 1; } else { proxflag = 0; } pswitch(0); (void) signal(SIGINT, oldintr); } setcase() { mcase = !mcase; printf("Case mapping %s.\n", onoff(mcase)); code = mcase; } setcr() { crflag = !crflag; printf("Carriage Return stripping %s.\n", onoff(crflag)); code = crflag; } setntrans(argc,argv) int argc; char *argv[]; { if (argc == 1) { ntflag = 0; printf("Ntrans off.\n"); code = ntflag; return; } ntflag++; code = ntflag; (void) strncpy(ntin, argv[1], 16); ntin[16] = '\0'; if (argc == 2) { ntout[0] = '\0'; return; } (void) strncpy(ntout, argv[2], 16); ntout[16] = '\0'; } char * dotrans(name) char *name; { static char new[MAXPATHLEN]; char *cp1, *cp2 = new; register int i, ostop, found; for (ostop = 0; *(ntout + ostop) && ostop < 16; ostop++); for (cp1 = name; *cp1; cp1++) { found = 0; for (i = 0; *(ntin + i) && i < 16; i++) { if (*cp1 == *(ntin + i)) { found++; if (i < ostop) { *cp2++ = *(ntout + i); } break; } } if (!found) { *cp2++ = *cp1; } } *cp2 = '\0'; return(new); } setnmap(argc, argv) int argc; char *argv[]; { char *cp; if (argc == 1) { mapflag = 0; printf("Nmap off.\n"); code = mapflag; return; } if (argc < 3 && !another(&argc, &argv, "mapout")) { printf("Usage: %s [mapin mapout]\n",argv[0]); code = -1; return; } mapflag = 1; code = 1; cp = index(altarg, ' '); if (proxy) { while(*++cp == ' '); altarg = cp; cp = index(altarg, ' '); } *cp = '\0'; (void) strncpy(mapin, altarg, MAXPATHLEN - 1); while (*++cp == ' '); (void) strncpy(mapout, cp, MAXPATHLEN - 1); } char * domap(name) char *name; { static char new[MAXPATHLEN]; register char *cp1 = name, *cp2 = mapin; char *tp[9], *te[9]; int i, toks[9], toknum = 0, match = 1; for (i=0; i < 9; ++i) { toks[i] = 0; } while (match && *cp1 && *cp2) { switch (*cp2) { case '\\': if (*++cp2 != *cp1) { match = 0; } break; case '$': if (*(cp2+1) >= '1' && (*cp2+1) <= '9') { if (*cp1 != *(++cp2+1)) { toks[toknum = *cp2 - '1']++; tp[toknum] = cp1; while (*++cp1 && *(cp2+1) != *cp1); te[toknum] = cp1; } cp2++; break; } /* FALLTHROUGH */ default: if (*cp2 != *cp1) { match = 0; } break; } if (match && *cp1) { cp1++; } if (match && *cp2) { cp2++; } } if (!match && *cp1) /* last token mismatch */ { toks[toknum] = 0; } cp1 = new; *cp1 = '\0'; cp2 = mapout; while (*cp2) { match = 0; switch (*cp2) { case '\\': if (*(cp2 + 1)) { *cp1++ = *++cp2; } break; case '[': LOOP: if (*++cp2 == '$' && isdigit(*(cp2+1))) { if (*++cp2 == '0') { char *cp3 = name; while (*cp3) { *cp1++ = *cp3++; } match = 1; } else if (toks[toknum = *cp2 - '1']) { char *cp3 = tp[toknum]; while (cp3 != te[toknum]) { *cp1++ = *cp3++; } match = 1; } } else { while (*cp2 && *cp2 != ',' && *cp2 != ']') { if (*cp2 == '\\') { cp2++; } else if (*cp2 == '$' && isdigit(*(cp2+1))) { if (*++cp2 == '0') { char *cp3 = name; while (*cp3) { *cp1++ = *cp3++; } } else if (toks[toknum = *cp2 - '1']) { char *cp3=tp[toknum]; while (cp3 != te[toknum]) { *cp1++ = *cp3++; } } } else if (*cp2) { *cp1++ = *cp2++; } } if (!*cp2) { printf("nmap: unbalanced brackets\n"); return(name); } match = 1; cp2--; } if (match) { while (*++cp2 && *cp2 != ']') { if (*cp2 == '\\' && *(cp2 + 1)) { cp2++; } } if (!*cp2) { printf("nmap: unbalanced brackets\n"); return(name); } break; } switch (*++cp2) { case ',': goto LOOP; case ']': break; default: cp2--; goto LOOP; } break; case '$': if (isdigit(*(cp2 + 1))) { if (*++cp2 == '0') { char *cp3 = name; while (*cp3) { *cp1++ = *cp3++; } } else if (toks[toknum = *cp2 - '1']) { char *cp3 = tp[toknum]; while (cp3 != te[toknum]) { *cp1++ = *cp3++; } } break; } /* intentional drop through */ default: *cp1++ = *cp2; break; } cp2++; } *cp1 = '\0'; if (!*new) { return(name); } return(new); } setsunique() { sunique = !sunique; printf("Store unique %s.\n", onoff(sunique)); code = sunique; } setrunique() { runique = !runique; printf("Receive unique %s.\n", onoff(runique)); code = runique; } /* change directory to perent directory */ cdup() { if (command("CDUP") == ERROR && code == 500) { if (verbose) printf("CDUP command not recognized, trying XCUP\n"); (void) command("XCUP"); } } /* restart transfer at specific point */ restart(argc, argv) int argc; char *argv[]; { extern long atol(); if (argc != 2) printf("restart: offset not specified\n"); else { restart_point = atol(argv[1]); printf("restarting at %ld. %s\n", restart_point, "execute get, put or append to initiate transfer"); } } /* show remote system type */ syst() { (void) command("SYST"); } macdef(argc, argv) int argc; char *argv[]; { char *tmp; int c; if (macnum == 16) { printf("Limit of 16 macros have already been defined\n"); code = -1; return; } if (argc < 2 && !another(&argc, &argv, "macro name")) { printf("Usage: %s macro_name\n",argv[0]); code = -1; return; } if (interactive) { printf("Enter macro line by line, terminating it with a null line\n"); } (void) strncpy(macros[macnum].mac_name, argv[1], 8); if (macnum == 0) { macros[macnum].mac_start = macbuf; } else { macros[macnum].mac_start = macros[macnum - 1].mac_end + 1; } tmp = macros[macnum].mac_start; while (tmp != macbuf+4096) { if ((c = getchar()) == EOF) { printf("macdef:end of file encountered\n"); code = -1; return; } if ((*tmp = c) == '\n') { if (tmp == macros[macnum].mac_start) { macros[macnum++].mac_end = tmp; code = 0; return; } if (*(tmp-1) == '\0') { macros[macnum++].mac_end = tmp - 1; code = 0; return; } *tmp = '\0'; } tmp++; } while (1) { while ((c = getchar()) != '\n' && c != EOF) /* LOOP */; if (c == EOF || getchar() == '\n') { printf("Macro not defined - 4k buffer exceeded\n"); code = -1; return; } } } /* * get size of file on remote machine */ sizecmd(argc, argv) int argc; char *argv[]; { if (argc < 2 && !another(&argc, &argv, "filename")) { printf("usage: %s filename\n", argv[0]); code = -1; return; } (void) command("SIZE %s", argv[1]); } /* * get last modification time of file on remote machine */ modtime(argc, argv) int argc; char *argv[]; { int overbose; if (argc < 2 && !another(&argc, &argv, "filename")) { printf("usage: %s filename\n", argv[0]); code = -1; return; } overbose = verbose; if (debug == 0) verbose = -1; if (command("MDTM %s", argv[1]) == COMPLETE) { int yy, mo, day, hour, min, sec; sscanf(reply_string, "%*s %04d%02d%02d%02d%02d%02d", &yy, &mo, &day, &hour, &min, &sec); /* might want to print this in local time */ printf("%s\t%02d/%02d/%04d %02d:%02d:%02d GMT\n", argv[1], mo, day, yy, hour, min, sec); } else printf("%s\n", reply_string); verbose = overbose; } /* * show status on reomte machine */ rmtstatus(argc, argv) int argc; char *argv[]; { (void) command(argc > 1 ? "STAT %s" : "STAT" , argv[1]); } /* * get file if modtime is more recent than current file */ newer(argc, argv) int argc; char *argv[]; { if (getit(argc, argv, -1, "w")) printf("Local file \"%s\" is newer than remote file \"%s\"\n", argv[1], argv[2]); } socks4-server-4.3.beta2.orig/rftp/cmdtab.c100644 7657 764 22112 5606334273 16777 0ustar martinedv/* * Copyright (c) 1985, 1989 Regents of the University of California. * All rights reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions * are met: * 1. Redistributions of source code must retain the above copyright * notice, this list of conditions and the following disclaimer. * 2. Redistributions in binary form must reproduce the above copyright * notice, this list of conditions and the following disclaimer in the * documentation and/or other materials provided with the distribution. * 3. All advertising materials mentioning features or use of this software * must display the following acknowledgement: * This product includes software developed by the University of * California, Berkeley and its contributors. * 4. Neither the name of the University nor the names of its contributors * may be used to endorse or promote products derived from this software * without specific prior written permission. * * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF * SUCH DAMAGE. */ #ifndef lint static char sccsid[] = "@(#)cmdtab.c 5.10 (Berkeley) 6/1/90"; #endif /* not lint */ #include "ftp_var.h" /* * User FTP -- Command Tables. */ int setascii(), setbell(), setbinary(), setdebug(), setform(); int setglob(), sethash(), setmode(), setpeer(), setport(); int setprompt(), setstruct(); int settenex(), settrace(), settype(), setverbose(); int disconnect(), restart(), reget(), syst(); int cd(), lcd(), delete(), mdelete(), user(); int ls(), mls(), get(), mget(), help(), append(), put(), mput(); int quit(), renamefile(), status(); int quote(), rmthelp(), shell(), site(); int pwd(), makedir(), removedir(), setcr(); int account(), doproxy(), reset(), setcase(), setntrans(), setnmap(); int setsunique(), setrunique(), cdup(), macdef(), domacro(); int sizecmd(), modtime(), newer(), rmtstatus(); int do_chmod(), do_umask(), idle(); char accounthelp[] = "send account command to remote server"; char appendhelp[] = "append to a file"; char asciihelp[] = "set ascii transfer type"; char beephelp[] = "beep when command completed"; char binaryhelp[] = "set binary transfer type"; char casehelp[] = "toggle mget upper/lower case id mapping"; char cdhelp[] = "change remote working directory"; char cduphelp[] = "change remote working directory to parent directory"; char chmodhelp[] = "change file permissions of remote file"; char connecthelp[] = "connect to remote tftp"; char crhelp[] = "toggle carriage return stripping on ascii gets"; char deletehelp[] = "delete remote file"; char debughelp[] = "toggle/set debugging mode"; char dirhelp[] = "list contents of remote directory"; char disconhelp[] = "terminate ftp session"; char domachelp[] = "execute macro"; char formhelp[] = "set file transfer format"; char globhelp[] = "toggle metacharacter expansion of local file names"; char hashhelp[] = "toggle printing `#' for each buffer transferred"; char helphelp[] = "print local help information"; char idlehelp[] = "get (set) idle timer on remote side"; char lcdhelp[] = "change local working directory"; char lshelp[] = "list contents of remote directory"; char macdefhelp[] = "define a macro"; char mdeletehelp[] = "delete multiple files"; char mdirhelp[] = "list contents of multiple remote directories"; char mgethelp[] = "get multiple files"; char mkdirhelp[] = "make directory on the remote machine"; char mlshelp[] = "list contents of multiple remote directories"; char modtimehelp[] = "show last modification time of remote file"; char modehelp[] = "set file transfer mode"; char mputhelp[] = "send multiple files"; char newerhelp[] = "get file if remote file is newer than local file "; char nlisthelp[] = "nlist contents of remote directory"; char nmaphelp[] = "set templates for default file name mapping"; char ntranshelp[] = "set translation table for default file name mapping"; char porthelp[] = "toggle use of PORT cmd for each data connection"; char prompthelp[] = "force interactive prompting on multiple commands"; char proxyhelp[] = "issue command on alternate connection"; char pwdhelp[] = "print working directory on remote machine"; char quithelp[] = "terminate ftp session and exit"; char quotehelp[] = "send arbitrary ftp command"; char receivehelp[] = "receive file"; char regethelp[] = "get file restarting at end of local file"; char remotehelp[] = "get help from remote server"; char renamehelp[] = "rename file"; char restarthelp[]= "restart file transfer at bytecount"; char rmdirhelp[] = "remove directory on the remote machine"; char rmtstatushelp[]="show status of remote machine"; char runiquehelp[] = "toggle store unique for local files"; char resethelp[] = "clear queued command replies"; char sendhelp[] = "send one file"; char sitehelp[] = "send site specific command to remote server\n\t\tTry \"rhelp site\" or \"site help\" for more information"; char shellhelp[] = "escape to the shell"; char sizecmdhelp[] = "show size of remote file"; char statushelp[] = "show current status"; char structhelp[] = "set file transfer structure"; char suniquehelp[] = "toggle store unique on remote machine"; char systemhelp[] = "show remote system type"; char tenexhelp[] = "set tenex file transfer type"; char tracehelp[] = "toggle packet tracing"; char typehelp[] = "set file transfer type"; char umaskhelp[] = "get (set) umask on remote side"; char userhelp[] = "send new user information"; char verbosehelp[] = "toggle verbose mode"; struct cmd cmdtab[] = { { "!", shellhelp, 0, 0, 0, shell }, { "$", domachelp, 1, 0, 0, domacro }, { "account", accounthelp, 0, 1, 1, account}, { "append", appendhelp, 1, 1, 1, put }, { "ascii", asciihelp, 0, 1, 1, setascii }, { "bell", beephelp, 0, 0, 0, setbell }, { "binary", binaryhelp, 0, 1, 1, setbinary }, { "bye", quithelp, 0, 0, 0, quit }, { "case", casehelp, 0, 0, 1, setcase }, { "cd", cdhelp, 0, 1, 1, cd }, { "cdup", cduphelp, 0, 1, 1, cdup }, { "chmod", chmodhelp, 0, 1, 1, do_chmod }, { "close", disconhelp, 0, 1, 1, disconnect }, { "cr", crhelp, 0, 0, 0, setcr }, { "delete", deletehelp, 0, 1, 1, delete }, { "debug", debughelp, 0, 0, 0, setdebug }, { "dir", dirhelp, 1, 1, 1, ls }, { "disconnect", disconhelp, 0, 1, 1, disconnect }, { "form", formhelp, 0, 1, 1, setform }, { "get", receivehelp, 1, 1, 1, get }, { "glob", globhelp, 0, 0, 0, setglob }, { "hash", hashhelp, 0, 0, 0, sethash }, { "help", helphelp, 0, 0, 1, help }, { "idle", idlehelp, 0, 1, 1, idle }, { "image", binaryhelp, 0, 1, 1, setbinary }, { "lcd", lcdhelp, 0, 0, 0, lcd }, { "ls", lshelp, 1, 1, 1, ls }, { "macdef", macdefhelp, 0, 0, 0, macdef }, { "mdelete", mdeletehelp, 1, 1, 1, mdelete }, { "mdir", mdirhelp, 1, 1, 1, mls }, { "mget", mgethelp, 1, 1, 1, mget }, { "mkdir", mkdirhelp, 0, 1, 1, makedir }, { "mls", mlshelp, 1, 1, 1, mls }, { "mode", modehelp, 0, 1, 1, setmode }, { "modtime", modtimehelp, 0, 1, 1, modtime }, { "mput", mputhelp, 1, 1, 1, mput }, { "newer", newerhelp, 1, 1, 1, newer }, { "nmap", nmaphelp, 0, 0, 1, setnmap }, { "nlist", nlisthelp, 1, 1, 1, ls }, { "ntrans", ntranshelp, 0, 0, 1, setntrans }, { "open", connecthelp, 0, 0, 1, setpeer }, { "prompt", prompthelp, 0, 0, 0, setprompt }, { "proxy", proxyhelp, 0, 0, 1, doproxy }, { "sendport", porthelp, 0, 0, 0, setport }, { "put", sendhelp, 1, 1, 1, put }, { "pwd", pwdhelp, 0, 1, 1, pwd }, { "quit", quithelp, 0, 0, 0, quit }, { "quote", quotehelp, 1, 1, 1, quote }, { "recv", receivehelp, 1, 1, 1, get }, { "reget", regethelp, 1, 1, 1, reget }, { "rstatus", rmtstatushelp, 0, 1, 1, rmtstatus }, { "rhelp", remotehelp, 0, 1, 1, rmthelp }, { "rename", renamehelp, 0, 1, 1, renamefile }, { "reset", resethelp, 0, 1, 1, reset }, { "restart", restarthelp, 1, 1, 1, restart }, { "rmdir", rmdirhelp, 0, 1, 1, removedir }, { "runique", runiquehelp, 0, 0, 1, setrunique }, { "send", sendhelp, 1, 1, 1, put }, { "site", sitehelp, 0, 1, 1, site }, { "size", sizecmdhelp, 1, 1, 1, sizecmd }, { "status", statushelp, 0, 0, 1, status }, { "struct", structhelp, 0, 1, 1, setstruct }, { "system", systemhelp, 0, 1, 1, syst }, { "sunique", suniquehelp, 0, 0, 1, setsunique }, { "tenex", tenexhelp, 0, 1, 1, settenex }, { "trace", tracehelp, 0, 0, 0, settrace }, { "type", typehelp, 0, 1, 1, settype }, { "user", userhelp, 0, 1, 1, user }, { "umask", umaskhelp, 0, 1, 1, do_umask }, { "verbose", verbosehelp, 0, 0, 0, setverbose }, { "?", helphelp, 0, 0, 1, help }, { 0 }, }; int NCMDS = (sizeof (cmdtab) / sizeof (cmdtab[0])) - 1; socks4-server-4.3.beta2.orig/rftp/domacro.c100644 7657 764 10173 5626201362 17167 0ustar martinedv/* * Copyright (c) 1985 Regents of the University of California. * All rights reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions * are met: * 1. Redistributions of source code must retain the above copyright * notice, this list of conditions and the following disclaimer. * 2. Redistributions in binary form must reproduce the above copyright * notice, this list of conditions and the following disclaimer in the * documentation and/or other materials provided with the distribution. * 3. All advertising materials mentioning features or use of this software * must display the following acknowledgement: * This product includes software developed by the University of * California, Berkeley and its contributors. * 4. Neither the name of the University nor the names of its contributors * may be used to endorse or promote products derived from this software * without specific prior written permission. * * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF * SUCH DAMAGE. */ #ifndef lint static char sccsid[] = "@(#)domacro.c 1.8 (Berkeley) 9/28/90"; #endif /* not lint */ #include "ftp_var.h" #include #include #include #include #ifdef LINUX #include #else # if !defined(SCO) && !defined(_SEQUENT_) && !defined(ISC) #include # endif #endif domacro(argc, argv) int argc; char *argv[]; { register int i, j; register char *cp1, *cp2; int count = 2, loopflg = 0; char line2[200]; extern char **glob(), *globerr; struct cmd *getcmd(), *c; extern struct cmd cmdtab[]; if (argc < 2 && !another(&argc, &argv, "macro name")) { printf("Usage: %s macro_name.\n", argv[0]); code = -1; return; } for (i = 0; i < macnum; ++i) { if (!strncmp(argv[1], macros[i].mac_name, 9)) { break; } } if (i == macnum) { printf("'%s' macro not found.\n", argv[1]); code = -1; return; } (void) strcpy(line2, line); TOP: cp1 = macros[i].mac_start; while (cp1 != macros[i].mac_end) { while (isspace(*cp1)) { cp1++; } cp2 = line; while (*cp1 != '\0') { switch(*cp1) { case '\\': *cp2++ = *++cp1; break; case '$': if (isdigit(*(cp1+1))) { j = 0; while (isdigit(*++cp1)) { j = 10*j + *cp1 - '0'; } cp1--; if (argc - 2 >= j) { (void) strcpy(cp2, argv[j+1]); cp2 += strlen(argv[j+1]); } break; } if (*(cp1+1) == 'i') { loopflg = 1; cp1++; if (count < argc) { (void) strcpy(cp2, argv[count]); cp2 += strlen(argv[count]); } break; } /* intentional drop through */ default: *cp2++ = *cp1; break; } if (*cp1 != '\0') { cp1++; } } *cp2 = '\0'; makeargv(); c = getcmd(margv[0]); if (c == (struct cmd *)-1) { printf("?Ambiguous command\n"); code = -1; } else if (c == 0) { printf("?Invalid command\n"); code = -1; } else if (c->c_conn && !connected) { printf("Not connected.\n"); code = -1; } else { if (verbose) { printf("%s\n",line); } (*c->c_handler)(margc, margv); if (bell && c->c_bell) { (void) putchar('\007'); } (void) strcpy(line, line2); makeargv(); argc = margc; argv = margv; } if (cp1 != macros[i].mac_end) { cp1++; } } if (loopflg && ++count < argc) { goto TOP; } } socks4-server-4.3.beta2.orig/rftp/ftp.1100644 7657 764 70676 5606334273 16276 0ustar martinedv.\" Copyright (c) 1985, 1989, 1990 The Regents of the University of California. .\" All rights reserved. .\" .\" Redistribution and use in source and binary forms, with or without .\" modification, are permitted provided that the following conditions .\" are met: .\" 1. Redistributions of source code must retain the above copyright .\" notice, this list of conditions and the following disclaimer. .\" 2. Redistributions in binary form must reproduce the above copyright .\" notice, this list of conditions and the following disclaimer in the .\" documentation and/or other materials provided with the distribution. .\" 3. All advertising materials mentioning features or use of this software .\" must display the following acknowledgement: .\" This product includes software developed by the University of .\" California, Berkeley and its contributors. .\" 4. Neither the name of the University nor the names of its contributors .\" may be used to endorse or promote products derived from this software .\" without specific prior written permission. .\" .\" THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND .\" ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE .\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE .\" ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE .\" FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL .\" DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS .\" OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) .\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT .\" LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY .\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF .\" SUCH DAMAGE. .\" .\" @(#)ftp.1 6.18 (Berkeley) 7/30/91 .\" .Dd July 30, 1991 .Dt FTP 1 .Os BSD 4.2 .Sh NAME .Nm ftp .Nd .Tn ARPANET file transfer program .Sh SYNOPSIS .Nm ftp .Op Fl v .Op Fl d .Op Fl i .Op Fl n .Op Fl g .Op Ar host .Sh DESCRIPTION .Nm Ftp is the user interface to the .Tn ARPANET standard File Transfer Protocol. The program allows a user to transfer files to and from a remote network site. .Pp Options may be specified at the command line, or to the command interpreter. .Bl -tag -width flag .It Fl v Verbose option forces .Nm ftp to show all responses from the remote server, as well as report on data transfer statistics. .It Fl n Restrains .Nm ftp from attempting \*(Lqauto-login\*(Rq upon initial connection. If auto-login is enabled, .Nm ftp will check the .Pa .netrc (see below) file in the user's home directory for an entry describing an account on the remote machine. If no entry exists, .Nm ftp will prompt for the remote machine login name (default is the user identity on the local machine), and, if necessary, prompt for a password and an account with which to login. .It Fl i Turns off interactive prompting during multiple file transfers. .It Fl d Enables debugging. .It Fl g Disables file name globbing. .El .Pp The client host with which .Nm ftp is to communicate may be specified on the command line. If this is done, .Nm ftp will immediately attempt to establish a connection to an .Tn FTP server on that host; otherwise, .Nm ftp will enter its command interpreter and await instructions from the user. When .Nm ftp is awaiting commands from the user the prompt .Ql ftp> is provided to the user. The following commands are recognized by .Nm ftp : .Bl -tag -width Fl .It Ic \&! Op Ar command Op Ar args Invoke an interactive shell on the local machine. If there are arguments, the first is taken to be a command to execute directly, with the rest of the arguments as its arguments. .It Ic \&$ Ar macro-name Op Ar args Execute the macro .Ar macro-name that was defined with the .Ic macdef command. Arguments are passed to the macro unglobbed. .It Ic account Op Ar passwd Supply a supplemental password required by a remote system for access to resources once a login has been successfully completed. If no argument is included, the user will be prompted for an account password in a non-echoing input mode. .It Ic append Ar local-file Op Ar remote-file Append a local file to a file on the remote machine. If .Ar remote-file is left unspecified, the local file name is used in naming the remote file after being altered by any .Ic ntrans or .Ic nmap setting. File transfer uses the current settings for .Ic type , .Ic format , .Ic mode , and .Ic structure . .It Ic ascii Set the file transfer .Ic type to network .Tn ASCII . This is the default type. .It Ic bell Arrange that a bell be sounded after each file transfer command is completed. .It Ic binary Set the file transfer .Ic type to support binary image transfer. .It Ic bye Terminate the .Tn FTP session with the remote server and exit .Nm ftp . An end of file will also terminate the session and exit. .It Ic case Toggle remote computer file name case mapping during .Ic mget commands. When .Ic case is on (default is off), remote computer file names with all letters in upper case are written in the local directory with the letters mapped to lower case. .It Ic \&cd Ar remote-directory Change the working directory on the remote machine to .Ar remote-directory . .It Ic cdup Change the remote machine working directory to the parent of the current remote machine working directory. .It Ic chmod Ar mode file-name Change the permission modes of the file .Ar file-name on the remote sytem to .Ar mode . .It Ic close Terminate the .Tn FTP session with the remote server, and return to the command interpreter. Any defined macros are erased. .It Ic \&cr Toggle carriage return stripping during ascii type file retrieval. Records are denoted by a carriage return/linefeed sequence during ascii type file transfer. When .Ic \&cr is on (the default), carriage returns are stripped from this sequence to conform with the .Ux single linefeed record delimiter. Records on .Pf non\- Ns Ux remote systems may contain single linefeeds; when an ascii type transfer is made, these linefeeds may be distinguished from a record delimiter only when .Ic \&cr is off. .It Ic delete Ar remote-file Delete the file .Ar remote-file on the remote machine. .It Ic debug Op Ar debug-value Toggle debugging mode. If an optional .Ar debug-value is specified it is used to set the debugging level. When debugging is on, .Nm ftp prints each command sent to the remote machine, preceded by the string .Ql \-\-> .It Xo .Ic dir .Op Ar remote-directory .Op Ar local-file .Xc Print a listing of the directory contents in the directory, .Ar remote-directory , and, optionally, placing the output in .Ar local-file . If interactive prompting is on, .Nm ftp will prompt the user to verify that the last argument is indeed the target local file for receiving .Ic dir output. If no directory is specified, the current working directory on the remote machine is used. If no local file is specified, or .Ar local-file is .Fl , output comes to the terminal. .It Ic disconnect A synonym for .Ar close . .It Ic form Ar format Set the file transfer .Ic form to .Ar format . The default format is \*(Lqfile\*(Rq. .It Ic get Ar remote-file Op Ar local-file Retrieve the .Ar remote-file and store it on the local machine. If the local file name is not specified, it is given the same name it has on the remote machine, subject to alteration by the current .Ic case , .Ic ntrans , and .Ic nmap settings. The current settings for .Ic type , .Ic form , .Ic mode , and .Ic structure are used while transferring the file. .It Ic glob Toggle filename expansion for .Ic mdelete , .Ic mget and .Ic mput . If globbing is turned off with .Ic glob , the file name arguments are taken literally and not expanded. Globbing for .Ic mput is done as in .Xr csh 1 . For .Ic mdelete and .Ic mget , each remote file name is expanded separately on the remote machine and the lists are not merged. Expansion of a directory name is likely to be different from expansion of the name of an ordinary file: the exact result depends on the foreign operating system and ftp server, and can be previewed by doing .Ql mls remote-files \- Note: .Ic mget and .Ic mput are not meant to transfer entire directory subtrees of files. That can be done by transferring a .Xr tar 1 archive of the subtree (in binary mode). .It Ic hash Toggle hash-sign (``#'') printing for each data block transferred. The size of a data block is 1024 bytes. .It Ic help Op Ar command Print an informative message about the meaning of .Ar command . If no argument is given, .Nm ftp prints a list of the known commands. .It Ic idle Op Ar seconds Set the inactivity timer on the remote server to .Ar seconds seconds. If .Ar seconds is ommitted, the current inactivity timer is printed. .It Ic lcd Op Ar directory Change the working directory on the local machine. If no .Ar directory is specified, the user's home directory is used. .It Xo .Ic \&ls .Op Ar remote-directory .Op Ar local-file .Xc Print a listing of the contents of a directory on the remote machine. The listing includes any system-dependent information that the server chooses to include; for example, most .Ux systems will produce output from the command .Ql ls \-l . (See also .Ic nlist . ) If .Ar remote-directory is left unspecified, the current working directory is used. If interactive prompting is on, .Nm ftp will prompt the user to verify that the last argument is indeed the target local file for receiving .Ic \&ls output. If no local file is specified, or if .Ar local-file is .Sq Fl , the output is sent to the terminal. .It Ic macdefNs Ar macro-name Define a macro. Subsequent lines are stored as the macro .Ar macro-name ; a null line (consecutive newline characters in a file or carriage returns from the terminal) terminates macro input mode. There is a limit of 16 macros and 4096 total characters in all defined macros. Macros remain defined until a .Ic close command is executed. The macro processor interprets `$' and `\e' as special characters. A `$' followed by a number (or numbers) is replaced by the corresponding argument on the macro invocation command line. A `$' followed by an `i' signals that macro processor that the executing macro is to be looped. On the first pass `$i' is replaced by the first argument on the macro invocation command line, on the second pass it is replaced by the second argument, and so on. A `\e' followed by any character is replaced by that character. Use the `\e' to prevent special treatment of the `$'. .It Ic mdelete Op Ar remote-files Delete the .Ar remote-files on the remote machine. .It Ic mdir Ar remote-files local-file Like .Ic dir , except multiple remote files may be specified. If interactive prompting is on, .Nm ftp will prompt the user to verify that the last argument is indeed the target local file for receiving .Ic mdir output. .It Ic mget Ar remote-files Expand the .Ar remote-files on the remote machine and do a .Ic get for each file name thus produced. See .Ic glob for details on the filename expansion. Resulting file names will then be processed according to .Ic case , .Ic ntrans , and .Ic nmap settings. Files are transferred into the local working directory, which can be changed with .Ql lcd directory ; new local directories can be created with .Ql "\&! mkdir directory" . .It Ic mkdir Ar directory-name Make a directory on the remote machine. .It Ic mls Ar remote-files local-file Like .Ic nlist , except multiple remote files may be specified, and the .Ar local-file must be specified. If interactive prompting is on, .Nm ftp will prompt the user to verify that the last argument is indeed the target local file for receiving .Ic mls output. .It Ic mode Op Ar mode-name Set the file transfer .Ic mode to .Ar mode-name . The default mode is \*(Lqstream\*(Rq mode. .It Ic modtime Ar file-name Show the last modification time of the file on the remote machine. .It Ic mput Ar local-files Expand wild cards in the list of local files given as arguments and do a .Ic put for each file in the resulting list. See .Ic glob for details of filename expansion. Resulting file names will then be processed according to .Ic ntrans and .Ic nmap settings. .It Ic newer Ar file-name Get the file only if the modification time of the remote file is more recent that the file on the current system. If the file does not exist on the current system, the remote file is considered .Ic newer . Otherwise, this command is identical to .Ar get . .It Xo .Ic nlist .Op Ar remote-directory .Op Ar local-file .Xc Print a list of the files in a directory on the remote machine. If .Ar remote-directory is left unspecified, the current working directory is used. If interactive prompting is on, .Nm ftp will prompt the user to verify that the last argument is indeed the target local file for receiving .Ic nlist output. If no local file is specified, or if .Ar local-file is .Fl , the output is sent to the terminal. .It Ic nmap Op Ar inpattern outpattern Set or unset the filename mapping mechanism. If no arguments are specified, the filename mapping mechanism is unset. If arguments are specified, remote filenames are mapped during .Ic mput commands and .Ic put commands issued without a specified remote target filename. If arguments are specified, local filenames are mapped during .Ic mget commands and .Ic get commands issued without a specified local target filename. This command is useful when connecting to a .No non\- Ns Ux remote computer with different file naming conventions or practices. The mapping follows the pattern set by .Ar inpattern and .Ar outpattern . .Op Ar Inpattern is a template for incoming filenames (which may have already been processed according to the .Ic ntrans and .Ic case settings). Variable templating is accomplished by including the sequences `$1', `$2', ..., `$9' in .Ar inpattern . Use `\\' to prevent this special treatment of the `$' character. All other characters are treated literally, and are used to determine the .Ic nmap .Op Ar inpattern variable values. For example, given .Ar inpattern $1.$2 and the remote file name "mydata.data", $1 would have the value "mydata", and $2 would have the value "data". The .Ar outpattern determines the resulting mapped filename. The sequences `$1', `$2', ...., `$9' are replaced by any value resulting from the .Ar inpattern template. The sequence `$0' is replace by the original filename. Additionally, the sequence .Ql Op Ar seq1 , Ar seq2 is replaced by .Op Ar seq1 if .Ar seq1 is not a null string; otherwise it is replaced by .Ar seq2 . For example, the command .Pp .Bd -literal -offset indent -compact nmap $1.$2.$3 [$1,$2].[$2,file] .Ed .Pp would yield the output filename "myfile.data" for input filenames "myfile.data" and "myfile.data.old", "myfile.file" for the input filename "myfile", and "myfile.myfile" for the input filename ".myfile". Spaces may be included in .Ar outpattern , as in the example: `nmap $1 sed "s/ *$//" > $1' . Use the `\e' character to prevent special treatment of the `$','[','[', and `,' characters. .It Ic ntrans Op Ar inchars Op Ar outchars Set or unset the filename character translation mechanism. If no arguments are specified, the filename character translation mechanism is unset. If arguments are specified, characters in remote filenames are translated during .Ic mput commands and .Ic put commands issued without a specified remote target filename. If arguments are specified, characters in local filenames are translated during .Ic mget commands and .Ic get commands issued without a specified local target filename. This command is useful when connecting to a .No non\- Ns Ux remote computer with different file naming conventions or practices. Characters in a filename matching a character in .Ar inchars are replaced with the corresponding character in .Ar outchars . If the character's position in .Ar inchars is longer than the length of .Ar outchars , the character is deleted from the file name. .It Ic open Ar host Op Ar port Establish a connection to the specified .Ar host .Tn FTP server. An optional port number may be supplied, in which case, .Nm ftp will attempt to contact an .Tn FTP server at that port. If the .Ic auto-login option is on (default), .Nm ftp will also attempt to automatically log the user in to the .Tn FTP server (see below). .It Ic prompt Toggle interactive prompting. Interactive prompting occurs during multiple file transfers to allow the user to selectively retrieve or store files. If prompting is turned off (default is on), any .Ic mget or .Ic mput will transfer all files, and any .Ic mdelete will delete all files. .It Ic proxy Ar ftp-command Execute an ftp command on a secondary control connection. This command allows simultaneous connection to two remote ftp servers for transferring files between the two servers. The first .Ic proxy command should be an .Ic open , to establish the secondary control connection. Enter the command "proxy ?" to see other ftp commands executable on the secondary connection. The following commands behave differently when prefaced by .Ic proxy : .Ic open will not define new macros during the auto-login process, .Ic close will not erase existing macro definitions, .Ic get and .Ic mget transfer files from the host on the primary control connection to the host on the secondary control connection, and .Ic put , .Ic mput , and .Ic append transfer files from the host on the secondary control connection to the host on the primary control connection. Third party file transfers depend upon support of the ftp protocol .Dv PASV command by the server on the secondary control connection. .It Ic put Ar local-file Op Ar remote-file Store a local file on the remote machine. If .Ar remote-file is left unspecified, the local file name is used after processing according to any .Ic ntrans or .Ic nmap settings in naming the remote file. File transfer uses the current settings for .Ic type , .Ic format , .Ic mode , and .Ic structure . .It Ic pwd Print the name of the current working directory on the remote machine. .It Ic quit A synonym for .Ic bye . .It Ic quote Ar arg1 arg2 ... The arguments specified are sent, verbatim, to the remote .Tn FTP server. .It Ic recv Ar remote-file Op Ar local-file A synonym for get. .It Ic reget Ar remote-file Op Ar local-file Reget acts like get, except that if .Ar local-file exists and is smaller than .Ar remote-file , .Ar local-file is presumed to be a partially transferred copy of .Ar remote-file and the transfer is continued from the apparent point of failure. This command is useful when transferring very large files over networks that are prone to dropping connections. .It Ic remotehelp Op Ar command-name Request help from the remote .Tn FTP server. If a .Ar command-name is specified it is supplied to the server as well. .It Ic remotestatus Op Ar file-name With no arguments, show status of remote machine. If .Ar file-name is specified, show status of .Ar file-name on remote machine. .It Xo .Ic rename .Op Ar from .Op Ar to .Xc Rename the file .Ar from on the remote machine, to the file .Ar to . .It Ic reset Clear reply queue. This command re-synchronizes command/reply sequencing with the remote ftp server. Resynchronization may be necessary following a violation of the ftp protocol by the remote server. .It Ic restart Ar marker Restart the immediately following .Ic get or .Ic put at the indicated .Ar marker . On .Ux systems, marker is usually a byte offset into the file. .It Ic rmdir Ar directory-name Delete a directory on the remote machine. .It Ic runique Toggle storing of files on the local system with unique filenames. If a file already exists with a name equal to the target local filename for a .Ic get or .Ic mget command, a ".1" is appended to the name. If the resulting name matches another existing file, a ".2" is appended to the original name. If this process continues up to ".99", an error message is printed, and the transfer does not take place. The generated unique filename will be reported. Note that .Ic runique will not affect local files generated from a shell command (see below). The default value is off. .It Ic send Ar local-file Op Ar remote-file A synonym for put. .It Ic sendport Toggle the use of .Dv PORT commands. By default, .Nm ftp will attempt to use a .Dv PORT command when establishing a connection for each data transfer. The use of .Dv PORT commands can prevent delays when performing multiple file transfers. If the .Dv PORT command fails, .Nm ftp will use the default data port. When the use of .Dv PORT commands is disabled, no attempt will be made to use .Dv PORT commands for each data transfer. This is useful for certain .Tn FTP implementations which do ignore .Dv PORT commands but, incorrectly, indicate they've been accepted. .It Ic site Ar arg1 arg2 ... The arguments specified are sent, verbatim, to the remote .Tn FTP server as a .Dv SITE command. .It Ic size Ar file-name Return size of .Ar file-name on remote machine. .It Ic status Show the current status of .Nm ftp . .It Ic struct Op Ar struct-name Set the file transfer .Ar structure to .Ar struct-name . By default \*(Lqstream\*(Rq structure is used. .It Ic sunique Toggle storing of files on remote machine under unique file names. Remote ftp server must support ftp protocol .Dv STOU command for successful completion. The remote server will report unique name. Default value is off. .It Ic system Show the type of operating system running on the remote machine. .It Ic tenex Set the file transfer type to that needed to talk to .Tn TENEX machines. .It Ic trace Toggle packet tracing. .It Ic type Op Ar type-name Set the file transfer .Ic type to .Ar type-name . If no type is specified, the current type is printed. The default type is network .Tn ASCII . .It Ic umask Op Ar newmask Set the default umask on the remote server to .Ar newmask . If .Ar newmask is ommitted, the current umask is printed. .It Xo .Ic user Ar user-name .Op Ar password .Op Ar account .Xc Identify yourself to the remote .Tn FTP server. If the .Ar password is not specified and the server requires it, .Nm ftp will prompt the user for it (after disabling local echo). If an .Ar account field is not specified, and the .Tn FTP server requires it, the user will be prompted for it. If an .Ar account field is specified, an account command will be relayed to the remote server after the login sequence is completed if the remote server did not require it for logging in. Unless .Nm ftp is invoked with \*(Lqauto-login\*(Rq disabled, this process is done automatically on initial connection to the .Tn FTP server. .It Ic verbose Toggle verbose mode. In verbose mode, all responses from the .Tn FTP server are displayed to the user. In addition, if verbose is on, when a file transfer completes, statistics regarding the efficiency of the transfer are reported. By default, verbose is on. .It Ic ? Op Ar command A synonym for help. .El .Pp Command arguments which have embedded spaces may be quoted with quote `"' marks. .Sh ABORTING A FILE TRANSFER To abort a file transfer, use the terminal interrupt key (usually Ctrl-C). Sending transfers will be immediately halted. Receiving transfers will be halted by sending a ftp protocol .Dv ABOR command to the remote server, and discarding any further data received. The speed at which this is accomplished depends upon the remote server's support for .Dv ABOR processing. If the remote server does not support the .Dv ABOR command, an .Ql ftp> prompt will not appear until the remote server has completed sending the requested file. .Pp The terminal interrupt key sequence will be ignored when .Nm ftp has completed any local processing and is awaiting a reply from the remote server. A long delay in this mode may result from the ABOR processing described above, or from unexpected behavior by the remote server, including violations of the ftp protocol. If the delay results from unexpected remote server behavior, the local .Nm ftp program must be killed by hand. .Sh FILE NAMING CONVENTIONS Files specified as arguments to .Nm ftp commands are processed according to the following rules. .Bl -enum .It If the file name .Sq Fl is specified, the .Ar stdin (for reading) or .Ar stdout (for writing) is used. .It If the first character of the file name is .Sq \&| , the remainder of the argument is interpreted as a shell command. .Nm Ftp then forks a shell, using .Xr popen 3 with the argument supplied, and reads (writes) from the stdout (stdin). If the shell command includes spaces, the argument must be quoted; e.g. \*(Lq" ls -lt"\*(Rq. A particularly useful example of this mechanism is: \*(Lqdir more\*(Rq. .It Failing the above checks, if ``globbing'' is enabled, local file names are expanded according to the rules used in the .Xr csh 1 ; c.f. the .Ic glob command. If the .Nm ftp command expects a single local file (.e.g. .Ic put ) , only the first filename generated by the "globbing" operation is used. .It For .Ic mget commands and .Ic get commands with unspecified local file names, the local filename is the remote filename, which may be altered by a .Ic case , .Ic ntrans , or .Ic nmap setting. The resulting filename may then be altered if .Ic runique is on. .It For .Ic mput commands and .Ic put commands with unspecified remote file names, the remote filename is the local filename, which may be altered by a .Ic ntrans or .Ic nmap setting. The resulting filename may then be altered by the remote server if .Ic sunique is on. .El .Sh FILE TRANSFER PARAMETERS The FTP specification specifies many parameters which may affect a file transfer. The .Ic type may be one of \*(Lqascii\*(Rq, \*(Lqimage\*(Rq (binary), \*(Lqebcdic\*(Rq, and \*(Lqlocal byte size\*(Rq (for .Tn PDP Ns -10's and .Tn PDP Ns -20's mostly). .Nm Ftp supports the ascii and image types of file transfer, plus local byte size 8 for .Ic tenex mode transfers. .Pp .Nm Ftp supports only the default values for the remaining file transfer parameters: .Ic mode , .Ic form , and .Ic struct . .Sh THE .netrc FILE The .Pa .netrc file contains login and initialization information used by the auto-login process. It resides in the user's home directory. The following tokens are recognized; they may be separated by spaces, tabs, or new-lines: .Bl -tag -width password .It Ic machine Ar name Identify a remote machine .Ar name . The auto-login process searches the .Pa .netrc file for a .Ic machine token that matches the remote machine specified on the .Nm ftp command line or as an .Ic open command argument. Once a match is made, the subsequent .Pa .netrc tokens are processed, stopping when the end of file is reached or another .Ic machine or a .Ic default token is encountered. .It Ic default This is the same as .Ic machine .Ar name except that .Ic default matches any name. There can be only one .Ic default token, and it must be after all .Ic machine tokens. This is normally used as: .Pp .Dl default login anonymous password user@site .Pp thereby giving the user .Ar automatic anonymous ftp login to machines not specified in .Pa .netrc . This can be overridden by using the .Fl n flag to disable auto-login. .It Ic login Ar name Identify a user on the remote machine. If this token is present, the auto-login process will initiate a login using the specified .Ar name . .It Ic password Ar string Supply a password. If this token is present, the auto-login process will supply the specified string if the remote server requires a password as part of the login process. Note that if this token is present in the .Pa .netrc file for any user other than .Ar anonymous , .Nm ftp will abort the auto-login process if the .Pa .netrc is readable by anyone besides the user. .It Ic account Ar string Supply an additional account password. If this token is present, the auto-login process will supply the specified string if the remote server requires an additional account password, or the auto-login process will initiate an .Dv ACCT command if it does not. .It Ic macdef Ar name Define a macro. This token functions like the .Nm ftp .Ic macdef command functions. A macro is defined with the specified name; its contents begin with the next .Pa .netrc line and continue until a null line (consecutive new-line characters) is encountered. If a macro named .Ic init is defined, it is automatically executed as the last step in the auto-login process. .El .Sh ENVIRONMENT .Nm Ftp utilizes the following environment variables. .Bl -tag -width Fl .It Ev HOME For default location of a .Pa .netrc file, if one exists. .It Ev SHELL For default shell. .El .Sh SEE ALSO .Xr ftpd 8 .Sh HISTORY The .Nm ftp command appeared in .Bx 4.2 . .Sh BUGS Correct execution of many commands depends upon proper behavior by the remote server. .Pp An error in the treatment of carriage returns in the .Bx 4.2 ascii-mode transfer code has been corrected. This correction may result in incorrect transfers of binary files to and from .Bx 4.2 servers using the ascii type. Avoid this problem by using the binary image type. socks4-server-4.3.beta2.orig/rftp/ftp.c100644 7657 764 106017 6144444002 16353 0ustar martinedv/* * Copyright (c) 1985, 1989 Regents of the University of California. * All rights reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions * are met: * 1. Redistributions of source code must retain the above copyright * notice, this list of conditions and the following disclaimer. * 2. Redistributions in binary form must reproduce the above copyright * notice, this list of conditions and the following disclaimer in the * documentation and/or other materials provided with the distribution. * 3. All advertising materials mentioning features or use of this software * must display the following acknowledgement: * This product includes software developed by the University of * California, Berkeley and its contributors. * 4. Neither the name of the University nor the names of its contributors * may be used to endorse or promote products derived from this software * without specific prior written permission. * * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF * SUCH DAMAGE. */ #ifndef lint static char sccsid[] = "@(#)ftp.c 5.38 (Berkeley) 4/22/91"; #endif /* not lint */ #include #include #include #include #include #include #include #ifndef LINUX #include #endif #include #include #include #include #include #include #include #include #include #include #ifdef __STDC__ #include #else #include #define USE_VARARGS #endif #ifdef FASCIST #include #endif #include "ftp_var.h" #if defined(AIX) || defined(DGUX) #undef IP_TOS #endif #ifdef SOLARIS /* for bcopy(), bzero() and bcmp() */ #include #define bcopy(b1,b2,len) memmove(b2, b1, (size_t)(len)) #define bzero(b,len) memset(b, 0, (size_t)(len)) #define bcmp(b1,b2,len) memcmp(b1, b2, (size_t)(len)) #endif struct sockaddr_in hisctladdr; struct sockaddr_in data_addr; int data = -1; int abrtflag = 0; int ptflag = 0; struct sockaddr_in myctladdr; uid_t getuid(); sig_t lostpeer(); off_t restart_point = 0; int pasvmode = 0; extern char *strerror(); extern int connected, errno; FILE *cin, *cout; FILE *dataconn(); #if !defined(SVR3) && !defined(BIND_RESOLVER) && !defined(LINUX) #if !defined(BSD) || (BSD - 43 <= 0) char *h_errlist[] = { "Error 0", "Unknown host", /* 1 HOST_NOT_FOUND */ "Host name lookup failure", /* 2 TRY_AGAIN */ "Unknown server error", /* 3 NO_RECOVERY */ "No address associated with name", /* 4 NO_ADDRESS */ }; int h_nerr = { sizeof(h_errlist)/sizeof(h_errlist[0]) }; int h_errno; /* In some version of SunOS this is necessary */ /* * herror -- * print the error indicated by the h_errno value. */ #if defined(AIX_PS2) || defined(BIND_RESOLVER) void herror(s) const char *s; #else /* #if AIX_PS2 not defined */ herror(s) char *s; #endif /* #if defined(AIX_PS2) || defined(BIND_RESOLVER) */ { if (s && *s) { fprintf(stderr, "%s: ", s); } if ((h_errno < 0) || (h_errno >= h_nerr)) { fprintf(stderr, "Unknown error\n"); } else if (h_errno == 0) { #if defined(sun) fprintf(stderr, "Host unknown\n"); #endif /* defined(sun) */ } else { fprintf(stderr, "%s\n", h_errlist[h_errno]); } } #endif /* !define(BSD) || (BSD - 43 <= 0) */ #endif /* !defined(SVR3) && !defined(BIND_RESOLVER) && !defined(LINUX) */ char * hookup(host, port) char *host; int port; { register struct hostent *hp = 0; int s, len, tos; static char hostnamebuf[80]; bzero((char *)&hisctladdr, sizeof (hisctladdr)); hisctladdr.sin_addr.s_addr = inet_addr(host); if (hisctladdr.sin_addr.s_addr != -1) { hisctladdr.sin_family = AF_INET; (void) strncpy(hostnamebuf, host, sizeof(hostnamebuf)); } else { hp = gethostbyname(host); if (hp == NULL) { fprintf(stderr, "ftp: %s: ", host); herror((char *)NULL); code = -1; return((char *) 0); } hisctladdr.sin_family = hp->h_addrtype; bcopy(hp->h_addr_list[0], (caddr_t)&hisctladdr.sin_addr, hp->h_length); (void) strncpy(hostnamebuf, hp->h_name, sizeof(hostnamebuf)); } hostname = hostnamebuf; s = socket(hisctladdr.sin_family, SOCK_STREAM, 0); if (s < 0) { perror("ftp: socket"); code = -1; return (0); } hisctladdr.sin_port = port; while (connect(s, (struct sockaddr *)&hisctladdr, sizeof (hisctladdr)) < 0) { if (hp && hp->h_addr_list[1]) { int oerrno = errno; extern char *inet_ntoa(); fprintf(stderr, "ftp: connect to address %s: ", inet_ntoa(hisctladdr.sin_addr)); errno = oerrno; perror((char *) 0); hp->h_addr_list++; bcopy(hp->h_addr_list[0], (caddr_t)&hisctladdr.sin_addr, hp->h_length); fprintf(stdout, "Trying %s...\n", inet_ntoa(hisctladdr.sin_addr)); (void) close(s); s = socket(hisctladdr.sin_family, SOCK_STREAM, 0); if (s < 0) { perror("ftp: socket"); code = -1; return (0); } continue; } perror("ftp: connect"); code = -1; goto bad; } len = sizeof (myctladdr); if (getsockname(s, (struct sockaddr *)&myctladdr, &len) < 0) { perror("ftp: getsockname"); code = -1; goto bad; } #if defined(IP_TOS) && defined(IPTOS_LOWDELAY) tos = IPTOS_LOWDELAY; if (setsockopt(s, IPPROTO_IP, IP_TOS, (char *)&tos, sizeof(int)) < 0) perror("ftp: setsockopt TOS (ignored)"); #endif cin = fdopen(s, "r"); #if defined(ISC) || defined(__alpha) || defined(SCO) cout = fdopen(dup(s), "w"); #else cout = fdopen(s, "w"); #endif if (cin == NULL || cout == NULL) { fprintf(stderr, "ftp: fdopen failed.\n"); if (cin) (void) fclose(cin); if (cout) (void) fclose(cout); code = -1; goto bad; } if (verbose) printf("Connected to %s.\n", hostname); if (getreply(0) > 2) { /* read startup message from server */ if (cin) (void) fclose(cin); if (cout) (void) fclose(cout); code = -1; goto bad; } #ifdef SO_OOBINLINE { int on = 1; if (setsockopt(s, SOL_SOCKET, SO_OOBINLINE, (char *)&on, sizeof(on)) < 0 && debug) { perror("ftp: setsockopt"); } } #endif /* SO_OOBINLINE */ return (hostname); bad: (void) close(s); return ((char *)0); } login(host) char *host; { char tmp[80]; char *user, *pass, *acct, *getlogin(), *getpass(); int n, aflag = 0; user = pass = acct = 0; if (ruserpass(host, &user, &pass, &acct) < 0) { code = -1; return(0); } while (user == NULL) { char *myname = getlogin(); if (myname == NULL) { struct passwd *pp = getpwuid(getuid()); if (pp != NULL) myname = pp->pw_name; } if (myname) printf("Name (%s:%s): ", host, myname); else printf("Name (%s): ", host); (void) fgets(tmp, sizeof(tmp) - 1, stdin); tmp[strlen(tmp) - 1] = '\0'; if (*tmp == '\0') user = myname; else user = tmp; } n = command("USER %s", user); if (n == CONTINUE) { if (pass == NULL) { if (strcmp(user, "anonymous") == 0) { printf("Password: "); (void) fflush(stdout); (void) fgets(tmp, sizeof(tmp) - 1, stdin); tmp[strlen(tmp) - 1] = '\0'; pass = tmp; } else pass = getpass("Password:"); } n = command("PASS %s", pass); } if (n == CONTINUE) { aflag++; acct = getpass("Account:"); n = command("ACCT %s", acct); } if (n != COMPLETE) { fprintf(stderr, "Login failed.\n"); return (0); } if (!aflag && acct != NULL) (void) command("ACCT %s", acct); if (proxy) return(1); for (n = 0; n < macnum; ++n) { if (!strcmp("init", macros[n].mac_name)) { (void) strcpy(line, "$init"); makeargv(); domacro(margc, margv); break; } } return (1); } void cmdabort() { extern jmp_buf ptabort; printf("\n"); (void) fflush(stdout); abrtflag++; if (ptflag) longjmp(ptabort,1); } /*VARARGS*/ #ifdef USE_VARARGS int command(va_alist) va_dcl #else int command(char *fmt, ...) #endif { va_list ap; #ifdef USE_VARARGS char *fmt; #endif int r; sig_t oldintr; void cmdabort(); abrtflag = 0; if (debug) { printf("---> "); #ifdef USE_VARARGS va_start(ap); fmt = va_arg(ap, char *); #else va_start(ap, fmt); #endif if (strncmp("PASS ", fmt, 5) == 0) printf("PASS XXXX"); else vfprintf(stdout, fmt, ap); va_end(ap); printf("\n"); (void) fflush(stdout); } if (cout == NULL) { perror ("No control connection for command"); code = -1; return (0); } oldintr = signal(SIGINT, cmdabort); #ifdef USE_VARARGS va_start(ap); fmt = va_arg(ap, char *); #else va_start(ap, fmt); #endif vfprintf(cout, fmt, ap); va_end(ap); fprintf(cout, "\r\n"); (void) fflush(cout); cpend = 1; r = getreply(!strcmp(fmt, "QUIT")); if (abrtflag && oldintr != SIG_IGN) (*oldintr)(SIGINT); (void) signal(SIGINT, oldintr); return(r); } char reply_string[BUFSIZ]; /* last line of previous reply */ #include getreply(expecteof) int expecteof; { register int c, n; register int dig; register char *cp; int originalcode = 0, continuation = 0; sig_t oldintr; int pflag = 0; char *pt = pasv; void cmdabort(); oldintr = signal(SIGINT, cmdabort); for (;;) { dig = n = code = 0; cp = reply_string; while ((c = getc(cin)) != '\n') { if (c == IAC) { /* handle telnet commands */ switch (c = getc(cin)) { case WILL: case WONT: c = getc(cin); fprintf(cout, "%c%c%c", IAC, DONT, c); (void) fflush(cout); break; case DO: case DONT: c = getc(cin); fprintf(cout, "%c%c%c", IAC, WONT, c); (void) fflush(cout); break; default: break; } continue; } dig++; if (c == EOF) { if (expecteof) { (void) signal(SIGINT,oldintr); code = 221; return (0); } lostpeer(); if (verbose) { printf("421 Service not available, remote server has closed connection\n"); (void) fflush(stdout); } code = 421; return(4); } if (c != '\r' && (verbose > 0 || (verbose > -1 && n == '5' && dig > 4))) { if (proxflag && (dig == 1 || dig == 5 && verbose == 0)) printf("%s:",hostname); (void) putchar(c); } if (dig < 4 && isdigit(c)) code = code * 10 + (c - '0'); if (!pflag && code == 227) pflag = 1; if (dig > 4 && pflag == 1 && isdigit(c)) pflag = 2; if (pflag == 2) { if (c != '\r' && c != ')') *pt++ = c; else { *pt = '\0'; pflag = 3; } } if (dig == 4 && c == '-') { if (continuation) code = 0; continuation++; } if (n == 0) n = c; if (cp < &reply_string[sizeof(reply_string) - 1]) *cp++ = c; } if (verbose > 0 || verbose > -1 && n == '5') { (void) putchar(c); (void) fflush (stdout); } if (continuation && code != originalcode) { if (originalcode == 0) originalcode = code; continue; } *cp = '\0'; if (n != '1') cpend = 0; (void) signal(SIGINT,oldintr); if (code == 421 || originalcode == 421) lostpeer(); if (abrtflag && oldintr != cmdabort && oldintr != SIG_IGN) (*oldintr)(SIGINT); return (n - '0'); } } empty(mask, sec) struct fd_set *mask; int sec; { struct timeval t; t.tv_sec = (long) sec; t.tv_usec = 0; return(select(32, mask, (struct fd_set *) 0, (struct fd_set *) 0, &t)); } jmp_buf sendabort; void abortsend() { mflag = 0; abrtflag = 0; printf("\nsend aborted\nwaiting for remote to finish abort\n"); (void) fflush(stdout); longjmp(sendabort, 1); } #define HASHBYTES 1024 sendrequest(cmd, local, remote, printnames) char *cmd, *local, *remote; int printnames; { struct stat st; struct timeval start, stop; register int c, d; FILE *fin, *dout = 0, *popen(); int (*closefunc)(), pclose(), fclose(); sig_t oldintr, oldintp; long bytes = 0, hashbytes = HASHBYTES; char *lmode, buf[BUFSIZ], *bufp; void abortsend(); if (verbose && printnames) { if (local && *local != '-') printf("local: %s ", local); if (remote) printf("remote: %s\n", remote); } if (proxy) { proxtrans(cmd, local, remote); return; } if (curtype != type) changetype(type, 0); closefunc = NULL; oldintr = NULL; oldintp = NULL; lmode = "w"; if (setjmp(sendabort)) { while (cpend) { (void) getreply(0); } if (data >= 0) { (void) close(data); data = -1; } if (oldintr) (void) signal(SIGINT,oldintr); if (oldintp) (void) signal(SIGPIPE,oldintp); code = -1; return; } oldintr = signal(SIGINT, abortsend); if (strcmp(local, "-") == 0) fin = stdin; else if (*local == '|') { oldintp = signal(SIGPIPE,SIG_IGN); fin = popen(local + 1, "r"); if (fin == NULL) { perror(local + 1); (void) signal(SIGINT, oldintr); (void) signal(SIGPIPE, oldintp); code = -1; return; } closefunc = pclose; } else { fin = fopen(local, "r"); if (fin == NULL) { fprintf(stderr, "local: %s: %s\n", local, strerror(errno)); (void) signal(SIGINT, oldintr); code = -1; return; } closefunc = fclose; if (fstat(fileno(fin), &st) < 0 || (st.st_mode&S_IFMT) != S_IFREG) { fprintf(stdout, "%s: not a plain file.\n", local); (void) signal(SIGINT, oldintr); fclose(fin); code = -1; return; } } if (initconn()) { (void) signal(SIGINT, oldintr); if (oldintp) (void) signal(SIGPIPE, oldintp); code = -1; if (closefunc != NULL) (*closefunc)(fin); return; } if (setjmp(sendabort)) goto abort; if (restart_point && (strcmp(cmd, "STOR") == 0 || strcmp(cmd, "APPE") == 0)) { if (fseek(fin, (long) restart_point, 0) < 0) { fprintf(stderr, "local: %s: %s\n", local, strerror(errno)); restart_point = 0; if (closefunc != NULL) (*closefunc)(fin); return; } if (command("REST %ld", (long) restart_point) != CONTINUE) { restart_point = 0; if (closefunc != NULL) (*closefunc)(fin); return; } restart_point = 0; lmode = "r+w"; } if (remote) { if (command("%s %s", cmd, remote) != PRELIM) { (void) signal(SIGINT, oldintr); if (oldintp) (void) signal(SIGPIPE, oldintp); if (closefunc != NULL) (*closefunc)(fin); return; } } else if (command("%s", cmd) != PRELIM) { (void) signal(SIGINT, oldintr); if (oldintp) (void) signal(SIGPIPE, oldintp); if (closefunc != NULL) (*closefunc)(fin); return; } dout = dataconn(lmode); if (dout == NULL) goto abort; (void) gettimeofday(&start, (struct timezone *)0); oldintp = signal(SIGPIPE, SIG_IGN); switch (curtype) { case TYPE_I: case TYPE_L: errno = d = 0; while ((c = read(fileno(fin), buf, sizeof (buf))) > 0) { bytes += c; for (bufp = buf; c > 0; c -= d, bufp += d) if ((d = write(fileno(dout), bufp, c)) <= 0) break; if (hash) { while (bytes >= hashbytes) { (void) putchar('#'); hashbytes += HASHBYTES; } (void) fflush(stdout); } } if (hash && bytes > 0) { if (bytes < HASHBYTES) (void) putchar('#'); (void) putchar('\n'); (void) fflush(stdout); } if (c < 0) fprintf(stderr, "local: %s: %s\n", local, strerror(errno)); if (d < 0) { if (errno != EPIPE) perror("netout"); bytes = -1; } break; case TYPE_A: while ((c = getc(fin)) != EOF) { if (c == '\n') { while (hash && (bytes >= hashbytes)) { (void) putchar('#'); (void) fflush(stdout); hashbytes += HASHBYTES; } if (ferror(dout)) break; (void) putc('\r', dout); bytes++; } (void) putc(c, dout); bytes++; /* if (c == '\r') { */ /* (void) putc('\0', dout); /* this violates rfc */ /* bytes++; */ /* } */ } if (hash) { if (bytes < hashbytes) (void) putchar('#'); (void) putchar('\n'); (void) fflush(stdout); } if (ferror(fin)) fprintf(stderr, "local: %s: %s\n", local, strerror(errno)); if (ferror(dout)) { if (errno != EPIPE) perror("netout"); bytes = -1; } break; } (void) gettimeofday(&stop, (struct timezone *)0); if (closefunc != NULL) (*closefunc)(fin); (void) fclose(dout); (void) getreply(0); (void) signal(SIGINT, oldintr); if (oldintp) (void) signal(SIGPIPE, oldintp); if (bytes > 0) { #ifdef FASCIST syslog(LOG_NOTICE, "Sent local file %s as %s -- %d bytes", local, remote, bytes); #endif ptransfer("sent", bytes, &start, &stop); } return; abort: (void) gettimeofday(&stop, (struct timezone *)0); (void) signal(SIGINT, oldintr); if (oldintp) (void) signal(SIGPIPE, oldintp); if (!cpend) { code = -1; return; } if (data >= 0) { (void) close(data); data = -1; } if (dout) (void) fclose(dout); (void) getreply(0); code = -1; if (closefunc != NULL && fin != NULL) (*closefunc)(fin); if (bytes > 0) { #ifdef FASCIST syslog(LOG_NOTICE, "Sent local file %s as %s -- %d bytes", local, remote, bytes); #endif ptransfer("sent", bytes, &start, &stop); } } jmp_buf recvabort; void abortrecv() { mflag = 0; abrtflag = 0; printf("\nreceive aborted\nwaiting for remote to finish abort\n"); (void) fflush(stdout); longjmp(recvabort, 1); } recvrequest(cmd, local, remote, lmode, printnames) char *cmd, *local, *remote, *lmode; { FILE *fout, *din = 0, *popen(); int (*closefunc)(), pclose(), fclose(); sig_t oldintr, oldintp; int is_retr, tcrflag, bare_lfs = 0; char *gunique(); static int bufsize; static char *buf; long bytes = 0, hashbytes = HASHBYTES; register int c, d; struct timeval start, stop; struct stat st; off_t lseek(); void abortrecv(); char *malloc(); is_retr = strcmp(cmd, "RETR") == 0; if (is_retr && verbose && printnames) { if (local && *local != '-') printf("local: %s ", local); if (remote) printf("remote: %s\n", remote); } if (proxy && is_retr) { proxtrans(cmd, local, remote); return; } closefunc = NULL; oldintr = NULL; oldintp = NULL; tcrflag = !crflag && is_retr; if (setjmp(recvabort)) { while (cpend) { (void) getreply(0); } if (data >= 0) { (void) close(data); data = -1; } if (oldintr) (void) signal(SIGINT, oldintr); code = -1; return; } oldintr = signal(SIGINT, abortrecv); if (strcmp(local, "-") && *local != '|') { if (access(local, 2) < 0) { char *dir = rindex(local, '/'); if (errno != ENOENT && errno != EACCES) { fprintf(stderr, "local: %s: %s\n", local, strerror(errno)); (void) signal(SIGINT, oldintr); code = -1; return; } if (dir != NULL) *dir = 0; d = access(dir ? local : ".", 2); if (dir != NULL) *dir = '/'; if (d < 0) { fprintf(stderr, "local: %s: %s\n", local, strerror(errno)); (void) signal(SIGINT, oldintr); code = -1; return; } if (!runique && errno == EACCES && chmod(local, 0600) < 0) { fprintf(stderr, "local: %s: %s\n", local, strerror(errno)); (void) signal(SIGINT, oldintr); (void) signal(SIGINT, oldintr); code = -1; return; } if (runique && errno == EACCES && (local = gunique(local)) == NULL) { (void) signal(SIGINT, oldintr); code = -1; return; } } else if (runique && (local = gunique(local)) == NULL) { (void) signal(SIGINT, oldintr); code = -1; return; } } if (!is_retr) { if (curtype != TYPE_A) changetype(TYPE_A, 0); } else if (curtype != type) changetype(type, 0); if (initconn()) { (void) signal(SIGINT, oldintr); code = -1; return; } if (setjmp(recvabort)) goto abort; if (is_retr && restart_point && command("REST %ld", (long) restart_point) != CONTINUE) return; if (remote) { if (command("%s %s", cmd, remote) != PRELIM) { (void) signal(SIGINT, oldintr); return; } } else { if (command("%s", cmd) != PRELIM) { (void) signal(SIGINT, oldintr); return; } } din = dataconn("r"); if (din == NULL) goto abort; if (strcmp(local, "-") == 0) fout = stdout; else if (*local == '|') { oldintp = signal(SIGPIPE, SIG_IGN); fout = popen(local + 1, "w"); if (fout == NULL) { perror(local+1); goto abort; } closefunc = pclose; } else { fout = fopen(local, lmode); if (fout == NULL) { fprintf(stderr, "local: %s: %s\n", local, strerror(errno)); goto abort; } closefunc = fclose; } #ifdef SVR3 if (BUFSIZ > bufsize) { #else if (fstat(fileno(fout), &st) < 0 || st.st_blksize == 0) st.st_blksize = BUFSIZ; if (st.st_blksize > bufsize) { #endif if (buf) (void) free(buf); #ifdef SVR3 buf = malloc((unsigned) BUFSIZ); #else buf = malloc((unsigned)st.st_blksize); #endif if (buf == NULL) { perror("malloc"); bufsize = 0; goto abort; } #ifdef SVR3 bufsize = BUFSIZ; #else bufsize = st.st_blksize; #endif } (void) gettimeofday(&start, (struct timezone *)0); switch (curtype) { case TYPE_I: case TYPE_L: if (restart_point && #if defined(SEEK_SET) lseek(fileno(fout), (long) restart_point, SEEK_SET) < 0) { #else lseek(fileno(fout), (long) restart_point, L_SET) < 0) { #endif fprintf(stderr, "local: %s: %s\n", local, strerror(errno)); if (closefunc != NULL) (*closefunc)(fout); return; } errno = d = 0; while ((c = read(fileno(din), buf, bufsize)) > 0) { if ((d = write(fileno(fout), buf, c)) != c) break; bytes += c; if (hash) { while (bytes >= hashbytes) { (void) putchar('#'); hashbytes += HASHBYTES; } (void) fflush(stdout); } } if (hash && bytes > 0) { if (bytes < HASHBYTES) (void) putchar('#'); (void) putchar('\n'); (void) fflush(stdout); } if (c < 0) { if (errno != EPIPE) perror("netin"); bytes = -1; } if (d < c) { if (d < 0) fprintf(stderr, "local: %s: %s\n", local, strerror(errno)); else fprintf(stderr, "%s: short write\n", local); } break; case TYPE_A: if (restart_point) { register int i, n, ch; #if defined(SEEK_SET) if (fseek(fout, 0L, SEEK_SET) < 0) #else if (fseek(fout, 0L, L_SET) < 0) #endif goto done; n = restart_point; for (i = 0; i++ < n;) { if ((ch = getc(fout)) == EOF) goto done; if (ch == '\n') i++; } #if defined(SEEK_CUR) if (fseek(fout, 0L, SEEK_CUR) < 0) { #else if (fseek(fout, 0L, L_INCR) < 0) { #endif done: fprintf(stderr, "local: %s: %s\n", local, strerror(errno)); if (closefunc != NULL) (*closefunc)(fout); return; } } while ((c = getc(din)) != EOF) { if (c == '\n') bare_lfs++; while (c == '\r') { while (hash && (bytes >= hashbytes)) { (void) putchar('#'); (void) fflush(stdout); hashbytes += HASHBYTES; } bytes++; if ((c = getc(din)) != '\n' || tcrflag) { if (ferror(fout)) goto break2; (void) putc('\r', fout); if (c == '\0') { bytes++; goto contin2; } if (c == EOF) goto contin2; } } (void) putc(c, fout); bytes++; contin2: ; } break2: if (bare_lfs) { printf("WARNING! %d bare linefeeds received in ASCII mode\n", bare_lfs); printf("File may not have transferred correctly.\n"); } if (hash) { if (bytes < hashbytes) (void) putchar('#'); (void) putchar('\n'); (void) fflush(stdout); } if (ferror(din)) { if (errno != EPIPE) perror("netin"); bytes = -1; } if (ferror(fout)) fprintf(stderr, "local: %s: %s\n", local, strerror(errno)); break; } if (closefunc != NULL) (*closefunc)(fout); (void) signal(SIGINT, oldintr); if (oldintp) (void) signal(SIGPIPE, oldintp); (void) gettimeofday(&stop, (struct timezone *)0); (void) fclose(din); (void) getreply(0); if (bytes > 0 && is_retr) { #ifdef FASCIST syslog(LOG_NOTICE, "Received remote file %s as %s -- %d bytes", remote, local, bytes); #endif ptransfer("received", bytes, &start, &stop); } return; abort: /* abort using RFC959 recommended IP,SYNC sequence */ (void) gettimeofday(&stop, (struct timezone *)0); if (oldintp) (void) signal(SIGPIPE, oldintr); (void) signal(SIGINT, SIG_IGN); if (!cpend) { code = -1; (void) signal(SIGINT, oldintr); return; } abort_remote(din); code = -1; if (data >= 0) { (void) close(data); data = -1; } if (closefunc != NULL && fout != NULL) (*closefunc)(fout); if (din) (void) fclose(din); if (bytes > 0) { #ifdef FASCIST syslog(LOG_NOTICE, "Received remote file %s as %s -- %d bytes", remote, local, bytes); #endif ptransfer("received", bytes, &start, &stop); } (void) signal(SIGINT, oldintr); } /* * Need to start a listen on the data channel before we send the command, * otherwise the server's connect may fail. */ initconn() { register char *p, *a; int result, len, tmpno = 0; int on = 1; #if !defined(NO_PASV) unsigned int h0, h1, h2, h3, p0, p1; unsigned int ipaddr; unsigned short ipport; data = socket(AF_INET, SOCK_STREAM, 0); if (data < 0) { perror("ftp: socket"); return (1); } if (options & SO_DEBUG && setsockopt(data, SOL_SOCKET, SO_DEBUG, (char *)&on, sizeof (on)) < 0) perror("ftp: setsockopt (ignored)"); if ((command("PASV") == COMPLETE) && (sscanf(pasv, "%d,%d,%d,%d,%d,%d", &h0, &h1, &h2, &h3, &p0, &p1) == 6)) { ipaddr = (((h0 << 8) + h1 << 8) + h2 << 8) + h3; ipport = (p0 << 8) + p1; data_addr.sin_family = AF_INET; data_addr.sin_addr.s_addr = htonl(ipaddr); data_addr.sin_port = htons(ipport); if (connect(data, (struct sockaddr *)&data_addr, sizeof(data_addr)) != -1) { #if defined(IP_TOS) && defined(IPTOS_THROUGHPUT) on = IPTOS_THROUGHPUT; if (setsockopt(data, IPPROTO_IP, IP_TOS, (char *)&on, sizeof(int)) < 0) perror("ftp: setsockopt TOS (ignored)"); #endif pasvmode = 1; return 0; } } #endif /* #if !defined(NO_PASV) */ #if defined(NO_RBIND) printf("Attempt to set this FTP server in PASV mode failed\n"); close(data); return 1; #else /* NO_RBIND not defined */ noport: pasvmode = 0; data_addr = myctladdr; if (sendport) data_addr.sin_port = 0; /* let system pick one */ if (data != -1) (void) close(data); data = socket(AF_INET, SOCK_STREAM, 0); if (data < 0) { perror("ftp: socket"); if (tmpno) sendport = 1; return (1); } if (!sendport) if (setsockopt(data, SOL_SOCKET, SO_REUSEADDR, (char *)&on, sizeof (on)) < 0) { perror("ftp: setsockopt (reuse address)"); goto bad; } if (bind(data, (struct sockaddr *)&data_addr, sizeof(data_addr)) < 0) { perror("ftp: bind"); goto bad; } if (options & SO_DEBUG && setsockopt(data, SOL_SOCKET, SO_DEBUG, (char *)&on, sizeof (on)) < 0) perror("ftp: setsockopt (ignored)"); len = sizeof (data_addr); if (getsockname(data, (struct sockaddr *)&data_addr, &len) < 0) { perror("ftp: getsockname"); goto bad; } if (listen(data, 1) < 0) perror("ftp: listen"); if (sendport) { a = (char *)&data_addr.sin_addr; p = (char *)&data_addr.sin_port; #define UC(b) (((int)b)&0xff) result = command("PORT %d,%d,%d,%d,%d,%d", UC(a[0]), UC(a[1]), UC(a[2]), UC(a[3]), UC(p[0]), UC(p[1])); if (result == ERROR && sendport == -1) { sendport = 0; tmpno = 1; goto noport; } return (result != COMPLETE); } if (tmpno) sendport = 1; #if defined(IP_TOS) && defined(IPTOS_THROUGHPUT) on = IPTOS_THROUGHPUT; if (setsockopt(data, IPPROTO_IP, IP_TOS, (char *)&on, sizeof(int)) < 0) perror("ftp: setsockopt TOS (ignored)"); #endif return (0); bad: (void) close(data), data = -1; if (tmpno) sendport = 1; return (1); #endif /* #if !defined(NO_RBIND) */ } FILE * dataconn(lmode) char *lmode; { struct sockaddr_in from; int s, fromlen = sizeof (from), tos; if (pasvmode == 1) return fdopen(data, lmode); s = accept(data, (struct sockaddr *) &from, &fromlen); if (s < 0) { perror("ftp: accept"); (void) close(data), data = -1; return (NULL); } (void) close(data); data = s; #if defined(IP_TOS) && defined(IPTOS_THROUGHPUT) tos = IPTOS_THROUGHPUT; if (setsockopt(s, IPPROTO_IP, IP_TOS, (char *)&tos, sizeof(int)) < 0) perror("ftp: setsockopt TOS (ignored)"); #endif return (fdopen(data, lmode)); } ptransfer(direction, bytes, t0, t1) char *direction; long bytes; struct timeval *t0, *t1; { struct timeval td; float s, bs; if (verbose) { tvsub(&td, t1, t0); s = td.tv_sec + (td.tv_usec / 1000000.); #define nz(x) ((x) == 0 ? 1 : (x)) bs = bytes / nz(s); printf("%ld bytes %s in %.2g seconds (%.2g Kbytes/s)\n", bytes, direction, s, bs / 1024.); } } /*tvadd(tsum, t0) struct timeval *tsum, *t0; { tsum->tv_sec += t0->tv_sec; tsum->tv_usec += t0->tv_usec; if (tsum->tv_usec > 1000000) tsum->tv_sec++, tsum->tv_usec -= 1000000; } */ tvsub(tdiff, t1, t0) struct timeval *tdiff, *t1, *t0; { tdiff->tv_sec = t1->tv_sec - t0->tv_sec; tdiff->tv_usec = t1->tv_usec - t0->tv_usec; if (tdiff->tv_usec < 0) tdiff->tv_sec--, tdiff->tv_usec += 1000000; } void psabort() { extern int abrtflag; abrtflag++; } pswitch(flag) int flag; { extern int proxy, abrtflag; sig_t oldintr; static struct comvars { int connect; char name[MAXHOSTNAMELEN]; struct sockaddr_in mctl; struct sockaddr_in hctl; FILE *in; FILE *out; int tpe; int curtpe; int cpnd; int sunqe; int runqe; int mcse; int ntflg; char nti[17]; char nto[17]; int mapflg; char mi[MAXPATHLEN]; char mo[MAXPATHLEN]; } proxstruct, tmpstruct; struct comvars *ip, *op; abrtflag = 0; oldintr = signal(SIGINT, psabort); if (flag) { if (proxy) return; ip = &tmpstruct; op = &proxstruct; proxy++; } else { if (!proxy) return; ip = &proxstruct; op = &tmpstruct; proxy = 0; } ip->connect = connected; connected = op->connect; if (hostname) { (void) strncpy(ip->name, hostname, sizeof(ip->name) - 1); ip->name[strlen(ip->name)] = '\0'; } else ip->name[0] = 0; hostname = op->name; ip->hctl = hisctladdr; hisctladdr = op->hctl; ip->mctl = myctladdr; myctladdr = op->mctl; ip->in = cin; cin = op->in; ip->out = cout; cout = op->out; ip->tpe = type; type = op->tpe; ip->curtpe = curtype; curtype = op->curtpe; ip->cpnd = cpend; cpend = op->cpnd; ip->sunqe = sunique; sunique = op->sunqe; ip->runqe = runique; runique = op->runqe; ip->mcse = mcase; mcase = op->mcse; ip->ntflg = ntflag; ntflag = op->ntflg; (void) strncpy(ip->nti, ntin, 16); (ip->nti)[strlen(ip->nti)] = '\0'; (void) strcpy(ntin, op->nti); (void) strncpy(ip->nto, ntout, 16); (ip->nto)[strlen(ip->nto)] = '\0'; (void) strcpy(ntout, op->nto); ip->mapflg = mapflag; mapflag = op->mapflg; (void) strncpy(ip->mi, mapin, MAXPATHLEN - 1); (ip->mi)[strlen(ip->mi)] = '\0'; (void) strcpy(mapin, op->mi); (void) strncpy(ip->mo, mapout, MAXPATHLEN - 1); (ip->mo)[strlen(ip->mo)] = '\0'; (void) strcpy(mapout, op->mo); (void) signal(SIGINT, oldintr); if (abrtflag) { abrtflag = 0; (*oldintr)(SIGINT); } } jmp_buf ptabort; int ptabflg; void abortpt() { printf("\n"); (void) fflush(stdout); ptabflg++; mflag = 0; abrtflag = 0; longjmp(ptabort, 1); } proxtrans(cmd, local, remote) char *cmd, *local, *remote; { sig_t oldintr; int secndflag = 0, prox_type, nfnd; extern jmp_buf ptabort; char *cmd2; struct fd_set mask; void abortpt(); if (strcmp(cmd, "RETR")) cmd2 = "RETR"; else cmd2 = runique ? "STOU" : "STOR"; if ((prox_type = type) == 0) { if (unix_server && unix_proxy) prox_type = TYPE_I; else prox_type = TYPE_A; } if (curtype != prox_type) changetype(prox_type, 1); if (command("PASV") != COMPLETE) { printf("proxy server does not support third party transfers.\n"); return; } pswitch(0); if (!connected) { printf("No primary connection\n"); pswitch(1); code = -1; return; } if (curtype != prox_type) changetype(prox_type, 1); if (command("PORT %s", pasv) != COMPLETE) { pswitch(1); return; } if (setjmp(ptabort)) goto abort; oldintr = signal(SIGINT, abortpt); if (command("%s %s", cmd, remote) != PRELIM) { (void) signal(SIGINT, oldintr); pswitch(1); return; } sleep(2); pswitch(1); secndflag++; if (command("%s %s", cmd2, local) != PRELIM) goto abort; ptflag++; (void) getreply(0); pswitch(0); (void) getreply(0); (void) signal(SIGINT, oldintr); pswitch(1); ptflag = 0; printf("local: %s remote: %s\n", local, remote); return; abort: (void) signal(SIGINT, SIG_IGN); ptflag = 0; if (strcmp(cmd, "RETR") && !proxy) pswitch(1); else if (!strcmp(cmd, "RETR") && proxy) pswitch(0); if (!cpend && !secndflag) { /* only here if cmd = "STOR" (proxy=1) */ if (command("%s %s", cmd2, local) != PRELIM) { pswitch(0); if (cpend) abort_remote((FILE *) NULL); } pswitch(1); if (ptabflg) code = -1; (void) signal(SIGINT, oldintr); return; } if (cpend) abort_remote((FILE *) NULL); pswitch(!proxy); if (!cpend && !secndflag) { /* only if cmd = "RETR" (proxy=1) */ if (command("%s %s", cmd2, local) != PRELIM) { pswitch(0); if (cpend) abort_remote((FILE *) NULL); pswitch(1); if (ptabflg) code = -1; (void) signal(SIGINT, oldintr); return; } } if (cpend) abort_remote((FILE *) NULL); pswitch(!proxy); if (cpend) { FD_ZERO(&mask); FD_SET(fileno(cin), &mask); if ((nfnd = empty(&mask, 10)) <= 0) { if (nfnd < 0) { perror("abort"); } if (ptabflg) code = -1; lostpeer(); } (void) getreply(0); (void) getreply(0); } if (proxy) pswitch(0); pswitch(1); if (ptabflg) code = -1; (void) signal(SIGINT, oldintr); } reset() { struct fd_set mask; int nfnd = 1; FD_ZERO(&mask); while (nfnd > 0) { FD_SET(fileno(cin), &mask); if ((nfnd = empty(&mask,0)) < 0) { perror("reset"); code = -1; lostpeer(); } else if (nfnd) { (void) getreply(0); } } } char * gunique(local) char *local; { static char new[MAXPATHLEN]; char *cp = rindex(local, '/'); int d, count=0; char ext = '1'; if (cp) *cp = '\0'; d = access(cp ? local : ".", 2); if (cp) *cp = '/'; if (d < 0) { fprintf(stderr, "local: %s: %s\n", local, strerror(errno)); return((char *) 0); } (void) strcpy(new, local); cp = new + strlen(new); *cp++ = '.'; while (!d) { if (++count == 100) { printf("runique: can't find unique file name.\n"); return((char *) 0); } *cp++ = ext; *cp = '\0'; if (ext == '9') ext = '0'; else ext++; if ((d = access(new, 0)) < 0) break; if (ext != '0') cp--; else if (*(cp - 2) == '.') *(cp - 1) = '1'; else { *(cp - 2) = *(cp - 2) + 1; cp--; } } return(new); } abort_remote(din) FILE *din; { char buf[BUFSIZ]; int nfnd; struct fd_set mask; /* * send IAC in urgent mode instead of DM because 4.3BSD places oob mark * after urgent byte rather than before as is protocol now */ sprintf(buf, "%c%c%c", IAC, IP, IAC); if (send(fileno(cout), buf, 3, MSG_OOB) != 3) perror("abort"); fprintf(cout,"%cABOR\r\n", DM); (void) fflush(cout); FD_ZERO(&mask); FD_SET(fileno(cin), &mask); if (din) { FD_SET(fileno(din), &mask); } if ((nfnd = empty(&mask, 10)) <= 0) { if (nfnd < 0) { perror("abort"); } if (ptabflg) code = -1; lostpeer(); } if (din && FD_ISSET(fileno(din), &mask)) { while (read(fileno(din), buf, BUFSIZ) > 0) /* LOOP */; } if (getreply(0) == ERROR && code == 552) { /* 552 needed for nic style abort */ (void) getreply(0); } (void) getreply(0); } socks4-server-4.3.beta2.orig/rftp/ftp_var.h100644 7657 764 13522 5626200760 17213 0ustar martinedv/* * Copyright (c) 1985, 1989 Regents of the University of California. * All rights reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions * are met: * 1. Redistributions of source code must retain the above copyright * notice, this list of conditions and the following disclaimer. * 2. Redistributions in binary form must reproduce the above copyright * notice, this list of conditions and the following disclaimer in the * documentation and/or other materials provided with the distribution. * 3. All advertising materials mentioning features or use of this software * must display the following acknowledgement: * This product includes software developed by the University of * California, Berkeley and its contributors. * 4. Neither the name of the University nor the names of its contributors * may be used to endorse or promote products derived from this software * without specific prior written permission. * * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF * SUCH DAMAGE. * * @(#)ftp_var.h 5.9 (Berkeley) 6/1/90 */ /* * FTP global variables. */ /* * Options and other state info. */ int trace; /* trace packets exchanged */ int hash; /* print # for each buffer transferred */ int sendport; /* use PORT cmd for each data connection */ int verbose; /* print messages coming back from server */ int connected; /* connected to server */ int fromatty; /* input is from a terminal */ int interactive; /* interactively prompt on m* cmds */ int debug; /* debugging level */ int bell; /* ring bell on cmd completion */ int doglob; /* glob local file names */ int autologin; /* establish user account on connection */ int proxy; /* proxy server connection active */ int proxflag; /* proxy connection exists */ int sunique; /* store files on server with unique name */ int runique; /* store local files with unique name */ int mcase; /* map upper to lower case for mget names */ int ntflag; /* use ntin ntout tables for name translation */ int mapflag; /* use mapin mapout templates on file names */ int code; /* return/reply code for ftp command */ int crflag; /* if 1, strip car. rets. on ascii gets */ char pasv[64]; /* passive port for proxy data connection */ char *altarg; /* argv[1] with no shell-like preprocessing */ char ntin[17]; /* input translation table */ char ntout[17]; /* output translation table */ #include #if defined(ISC) #include #define MAXPATHLEN PATH_MAX #endif /* #if defined(ISC) */ #ifdef SCO #include /* Must be a #*%$ SCO system */ #endif char mapin[MAXPATHLEN]; /* input map template */ char mapout[MAXPATHLEN]; /* output map template */ char typename[32]; /* name of file transfer type */ int type; /* requested file transfer type */ int curtype; /* current file transfer type */ char structname[32]; /* name of file transfer structure */ int stru; /* file transfer structure */ char formname[32]; /* name of file transfer format */ int form; /* file transfer format */ char modename[32]; /* name of file transfer mode */ int mode; /* file transfer mode */ char bytename[32]; /* local byte size in ascii */ int bytesize; /* local byte size in binary */ char *hostname; /* name of host connected to */ int unix_server; /* server is unix, can use binary for ascii */ int unix_proxy; /* proxy is unix, can use binary for ascii */ struct servent *sp; /* service spec for tcp/ftp */ /* >>> YDL */ int ftp_s_port; /* save ftp's sp->s_port value here */ /* <<< YDL */ #include jmp_buf toplevel; /* non-local goto stuff for cmd scanner */ char line[200]; /* input line buffer */ char *stringbase; /* current scan point in line buffer */ char argbuf[200]; /* argument storage buffer */ char *argbase; /* current storage point in arg buffer */ int margc; /* count of arguments on input line */ char *margv[20]; /* args parsed from input line */ int cpend; /* flag: if != 0, then pending server reply */ int mflag; /* flag: if != 0, then active multi command */ int options; /* used during socket creation */ /* * Format of command table. */ struct cmd { char *c_name; /* name of command */ char *c_help; /* help string */ char c_bell; /* give bell when command completes */ char c_conn; /* must be connected to use command */ char c_proxy; /* proxy server may execute */ int (*c_handler)(); /* function to call */ }; struct macel { char mac_name[9]; /* macro name */ char *mac_start; /* start of macro in macbuf */ char *mac_end; /* end of macro in macbuf */ }; int macnum; /* number of defined macros */ struct macel macros[16]; char macbuf[4096]; extern char *tail(); extern char *index(); extern char *rindex(); extern char *remglob(); extern int errno; extern char *mktemp(); extern char *strncpy(); extern char *strncat(); extern char *strcat(); extern char *strcpy(); #if defined (COMPAT) || defined (ultrix) || defined(SCO) typedef void (*sig_t)(); static char *strerror(errnum) { extern int sys_nerr; extern char *sys_errlist[]; return (errnum < sys_nerr && errnum >= 0 ? sys_errlist[errno] : "UNDEFINED"); } #endif socks4-server-4.3.beta2.orig/rftp/glob.c100644 7657 764 27536 6143500754 16503 0ustar martinedv/* * Copyright (c) 1980 Regents of the University of California. * All rights reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions * are met: * 1. Redistributions of source code must retain the above copyright * notice, this list of conditions and the following disclaimer. * 2. Redistributions in binary form must reproduce the above copyright * notice, this list of conditions and the following disclaimer in the * documentation and/or other materials provided with the distribution. * 3. All advertising materials mentioning features or use of this software * must display the following acknowledgement: * This product includes software developed by the University of * California, Berkeley and its contributors. * 4. Neither the name of the University nor the names of its contributors * may be used to endorse or promote products derived from this software * without specific prior written permission. * * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF * SUCH DAMAGE. */ #ifndef lint static char sccsid[] = "@(#)glob.c 5.9 (Berkeley) 2/25/91"; #endif /* not lint */ /* * C-shell glob for random programs. */ #if defined(hpux) || defined(SOLARIS) || defined(SCO) #undef COMPAT #endif #include #include /* #if defined(COMPAT) && !defined(sgi) && !defined(sun) && !defined(AIX) && !defined(LINUX) && !defined(__alpha) */ #if defined(ISC) #include #include #else #include #endif #ifdef LINUX #include #endif #include #include #include #if !defined(COMPAT) || defined(sun) #include #endif #include #define QUOTE 0200 #define TRIM 0177 #define eq(a,b) (strcmp(a, b)==0) #if defined(i386) && !defined(SCO) #define NCARGS 256 #endif #define GAVSIZ (NCARGS/6) #define isdir(d) ((d.st_mode & S_IFMT) == S_IFDIR) static char **gargv; /* Pointer to the (stack) arglist */ static int gargc; /* Number args in gargv */ static int gnleft; static short gflag; static int tglob(); char **ftpglob(); char *globerr; char *home; extern int errno; static char *strspl(), *strend(); char **copyblk(); static void acollect(), addpath(), collect(), expand(), Gcat(); static void ginit(), matchdir(), rscan(), sort(); static int amatch(), execbrc(), match(); static int globcnt; char *globchars = "`{[*?"; static char *gpath, *gpathp, *lastgpathp; static int globbed; static char *entp; static char **sortbas; char ** ftpglob(v) register char *v; { char agpath[BUFSIZ]; char *agargv[GAVSIZ]; char *vv[2]; vv[0] = v; vv[1] = 0; gflag = 0; rscan(vv, tglob); if (gflag == 0) return (copyblk(vv)); globerr = 0; gpath = agpath; gpathp = gpath; *gpathp = 0; lastgpathp = &gpath[sizeof agpath - 2]; ginit(agargv); globcnt = 0; collect(v); if (globcnt == 0 && (gflag&1)) { blkfree(gargv), gargv = 0; return (0); } else return (gargv = copyblk(gargv)); } static void ginit(agargv) char **agargv; { agargv[0] = 0; gargv = agargv; sortbas = agargv; gargc = 0; gnleft = NCARGS - 4; } static void collect(as) register char *as; { if (eq(as, "{") || eq(as, "{}")) { Gcat(as, ""); sort(); } else acollect(as); } static void acollect(as) register char *as; { register int ogargc = gargc; gpathp = gpath; *gpathp = 0; globbed = 0; expand(as); if (gargc != ogargc) sort(); } static void sort() { register char **p1, **p2, *c; char **Gvp = &gargv[gargc]; p1 = sortbas; while (p1 < Gvp-1) { p2 = p1; while (++p2 < Gvp) if (strcmp(*p1, *p2) > 0) c = *p1, *p1 = *p2, *p2 = c; p1++; } sortbas = Gvp; } static void expand(as) char *as; { register char *cs; register char *sgpathp, *oldcs; struct stat stb; sgpathp = gpathp; cs = as; if (*cs == '~' && gpathp == gpath) { addpath('~'); for (cs++; letter(*cs) || digit(*cs) || *cs == '-';) addpath(*cs++); if (!*cs || *cs == '/') { if (gpathp != gpath + 1) { *gpathp = 0; if (gethdir(gpath + 1)) globerr = "Unknown user name after ~"; (void) strcpy(gpath, gpath + 1); } else (void) strcpy(gpath, home); gpathp = strend(gpath); } } while (!any(*cs, globchars)) { if (*cs == 0) { if (!globbed) Gcat(gpath, ""); else if (stat(gpath, &stb) >= 0) { Gcat(gpath, ""); globcnt++; } goto endit; } addpath(*cs++); } oldcs = cs; while (cs > as && *cs != '/') cs--, gpathp--; if (*cs == '/') cs++, gpathp++; *gpathp = 0; if (*oldcs == '{') { (void) execbrc(cs, ((char *)0)); return; } matchdir(cs); endit: gpathp = sgpathp; *gpathp = 0; } static void matchdir(pattern) char *pattern; { struct stat stb; register struct dirent *dp; DIR *dirp; dirp = opendir(*gpath ? gpath : "."); dirp = opendir(gpath); if (dirp == NULL) { if (globbed) return; goto patherr2; } if (fstat(dirp->dd_fd, &stb) < 0) goto patherr1; if (!isdir(stb)) { errno = ENOTDIR; goto patherr1; } while ((dp = readdir(dirp)) != NULL) { if (dp->d_ino == 0) continue; if (match(dp->d_name, pattern)) { Gcat(gpath, dp->d_name); globcnt++; } } closedir(dirp); return; patherr1: closedir(dirp); patherr2: globerr = "Bad directory components"; } static int execbrc(p, s) char *p, *s; { char restbuf[BUFSIZ + 2]; register char *pe, *pm, *pl; int brclev = 0; char *lm, savec, *sgpathp; for (lm = restbuf; *p != '{'; *lm++ = *p++) continue; for (pe = ++p; *pe; pe++) switch (*pe) { case '{': brclev++; continue; case '}': if (brclev == 0) goto pend; brclev--; continue; case '[': for (pe++; *pe && *pe != ']'; pe++) continue; continue; } pend: brclev = 0; for (pl = pm = p; pm <= pe; pm++) switch (*pm & (QUOTE|TRIM)) { case '{': brclev++; continue; case '}': if (brclev) { brclev--; continue; } goto doit; case ','|QUOTE: case ',': if (brclev) continue; doit: savec = *pm; *pm = 0; (void) strcpy(lm, pl); (void) strcat(restbuf, pe + 1); *pm = savec; if (s == 0) { sgpathp = gpathp; expand(restbuf); gpathp = sgpathp; *gpathp = 0; } else if (amatch(s, restbuf)) return (1); sort(); pl = pm + 1; if (brclev) return (0); continue; case '[': for (pm++; *pm && *pm != ']'; pm++) continue; if (!*pm) pm--; continue; } if (brclev) goto doit; return (0); } static int match(s, p) char *s, *p; { register int c; register char *sentp; char sglobbed = globbed; if (*s == '.' && *p != '.') return (0); sentp = entp; entp = s; c = amatch(s, p); entp = sentp; globbed = sglobbed; return (c); } static int amatch(s, p) register char *s, *p; { register int scc; int ok, lc; char *sgpathp; struct stat stb; int c, cc; globbed = 1; for (;;) { scc = *s++ & TRIM; switch (c = *p++) { case '{': return (execbrc(p - 1, s - 1)); case '[': ok = 0; lc = 077777; while (cc = *p++) { if (cc == ']') { if (ok) break; return (0); } if (cc == '-') { if (lc <= scc && scc <= *p++) ok++; } else if (scc == (lc = cc)) ok++; } if (cc == 0) if (ok) p--; else return 0; continue; case '*': if (!*p) return (1); if (*p == '/') { p++; goto slash; } s--; do { if (amatch(s, p)) return (1); } while (*s++); return (0); case 0: return (scc == 0); default: if (c != scc) return (0); continue; case '?': if (scc == 0) return (0); continue; case '/': if (scc) return (0); slash: s = entp; sgpathp = gpathp; while (*s) addpath(*s++); addpath('/'); if (stat(gpath, &stb) == 0 && isdir(stb)) if (*p == 0) { Gcat(gpath, ""); globcnt++; } else expand(p); gpathp = sgpathp; *gpathp = 0; return (0); } } } static Gmatch(s, p) register char *s, *p; { register int scc; int ok, lc; int c, cc; for (;;) { scc = *s++ & TRIM; switch (c = *p++) { case '[': ok = 0; lc = 077777; while (cc = *p++) { if (cc == ']') { if (ok) break; return (0); } if (cc == '-') { if (lc <= scc && scc <= *p++) ok++; } else if (scc == (lc = cc)) ok++; } if (cc == 0) if (ok) p--; else return 0; continue; case '*': if (!*p) return (1); for (s--; *s; s++) if (Gmatch(s, p)) return (1); return (0); case 0: return (scc == 0); default: if ((c & TRIM) != scc) return (0); continue; case '?': if (scc == 0) return (0); continue; } } } static void Gcat(s1, s2) register char *s1, *s2; { register int len = strlen(s1) + strlen(s2) + 1; if (len >= gnleft || gargc >= GAVSIZ - 1) globerr = "Arguments too long"; else { gargc++; gnleft -= len; gargv[gargc] = 0; gargv[gargc - 1] = strspl(s1, s2); } } static void addpath(c) char c; { if (gpathp >= lastgpathp) globerr = "Pathname too long"; else { *gpathp++ = c; *gpathp = 0; } } static void rscan(t, f) register char **t; int (*f)(); { register char *p, c; while (p = *t++) { if (f == tglob) if (*p == '~') gflag |= 2; else if (eq(p, "{") || eq(p, "{}")) continue; while (c = *p++) (*f)(c); } } /* static scan(t, f) register char **t; int (*f)(); { register char *p, c; while (p = *t++) while (c = *p) *p++ = (*f)(c); } */ static tglob(c) register char c; { if (any(c, globchars)) gflag |= c == '{' ? 2 : 1; return (c); } /* static trim(c) char c; { return (c & TRIM); } */ letter(c) register char c; { return (c >= 'a' && c <= 'z' || c >= 'A' && c <= 'Z' || c == '_'); } digit(c) register char c; { return (c >= '0' && c <= '9'); } any(c, s) register int c; register char *s; { while (*s) if (*s++ == c) return(1); return(0); } blklen(av) register char **av; { register int i = 0; while (*av++) i++; return (i); } char ** blkcpy(oav, bv) char **oav; register char **bv; { register char **av = oav; while (*av++ = *bv++) continue; return (oav); } blkfree(av0) char **av0; { register char **av = av0; #ifdef sgi /* if gflag is 0, we did not malloc() the space! */ if (!gflag) return; #endif while (*av) free(*av++); } static char * strspl(cp, dp) register char *cp, *dp; { #if defined(sgi) || defined(__alpha) register char *ep = (char *)malloc((unsigned)(strlen(cp) + strlen(dp) + 1)); #else register char *ep = malloc((unsigned)(strlen(cp) + strlen(dp) + 1)); #endif if (ep == (char *)0) fatal("Out of memory"); (void) strcpy(ep, cp); (void) strcat(ep, dp); return (ep); } char ** copyblk(v) register char **v; { register char **nv = (char **)malloc((unsigned)((blklen(v) + 1) * sizeof(char **))); if (nv == (char **)0) fatal("Out of memory"); return (blkcpy(nv, v)); } static char * strend(cp) register char *cp; { while (*cp) cp++; return (cp); } /* * Extract a home directory from the password file * The argument points to a buffer where the name of the * user whose home directory is sought is currently. * We write the home directory of the user back there. */ gethdir(home) char *home; { register struct passwd *pp = getpwnam(home); if (!pp || home + strlen(pp->pw_dir) >= lastgpathp) return (1); (void) strcpy(home, pp->pw_dir); return (0); } socks4-server-4.3.beta2.orig/rftp/main.c100644 7657 764 23647 6020734607 16503 0ustar martinedv/* * Copyright (c) 1985, 1989 Regents of the University of California. * All rights reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions * are met: * 1. Redistributions of source code must retain the above copyright * notice, this list of conditions and the following disclaimer. * 2. Redistributions in binary form must reproduce the above copyright * notice, this list of conditions and the following disclaimer in the * documentation and/or other materials provided with the distribution. * 3. All advertising materials mentioning features or use of this software * must display the following acknowledgement: * This product includes software developed by the University of * California, Berkeley and its contributors. * 4. Neither the name of the University nor the names of its contributors * may be used to endorse or promote products derived from this software * without specific prior written permission. * * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF * SUCH DAMAGE. */ #ifndef lint char copyright[] = "@(#) Copyright (c) 1985, 1989 Regents of the University of California.\n\ All rights reserved.\n"; #endif /* not lint */ #ifndef lint static char sccsid[] = "@(#)main.c 5.18 (Berkeley) 3/1/91"; #endif /* not lint */ /* * FTP User Program -- Command Interface. */ #include "ftp_var.h" #include #include #include #include #include #include #include #include #include #include uid_t getuid(); void intr(), lostpeer(); extern char *home; char *getlogin(); main(argc, argv) char *argv[]; { register char *cp; int top; struct passwd *pw = NULL; char homedir[MAXPATHLEN]; #if defined(connect) SOCKSinit(argv[0]); #endif #ifdef FASCIST fprintf(stderr,"***NOTE: Names of all files transferred will be recorded! \n"); #endif sp = getservbyname("ftp", "tcp"); if (sp == 0) { fprintf(stderr, "ftp: ftp/tcp: unknown service\n"); exit(1); } /* save ftp's s_port value so it won't be clobbered by */ /* by another call to getserbyname() */ ftp_s_port = sp->s_port; doglob = 1; interactive = 1; autologin = 1; argc--, argv++; while (argc > 0 && **argv == '-') { for (cp = *argv + 1; *cp; cp++) switch (*cp) { case 'd': options |= SO_DEBUG; debug++; break; case 'v': verbose++; break; case 't': trace++; break; case 'i': interactive = 0; break; case 'n': autologin = 0; break; case 'g': doglob = 0; break; default: fprintf(stdout, "ftp: %c: unknown option\n", *cp); exit(1); } argc--, argv++; } fromatty = isatty(fileno(stdin)); if (fromatty) verbose++; cpend = 0; /* no pending replies */ proxy = 0; /* proxy not active */ crflag = 1; /* strip c.r. on ascii gets */ sendport = -1; /* not using ports */ /* * Set up the home directory in case we're globbing. */ cp = getlogin(); if (cp != NULL) { pw = getpwnam(cp); } if (pw == NULL) pw = getpwuid(getuid()); if (pw != NULL) { home = homedir; (void) strcpy(home, pw->pw_dir); } if (argc > 0) { if (setjmp(toplevel)) exit(0); (void) signal(SIGINT, intr); (void) signal(SIGPIPE, lostpeer); setpeer(argc + 1, argv - 1); } top = setjmp(toplevel) == 0; if (top) { (void) signal(SIGINT, intr); (void) signal(SIGPIPE, lostpeer); } for (;;) { cmdscanner(top); top = 1; } } void intr() { longjmp(toplevel, 1); } void lostpeer() { extern FILE *cout; extern int data; if (connected) { if (cout != NULL) { (void) shutdown(fileno(cout), 1+1); (void) fclose(cout); cout = NULL; } if (data >= 0) { (void) shutdown(data, 1+1); (void) close(data); data = -1; } connected = 0; } pswitch(1); if (connected) { if (cout != NULL) { (void) shutdown(fileno(cout), 1+1); (void) fclose(cout); cout = NULL; } connected = 0; } proxflag = 0; pswitch(0); } /*char * tail(filename) char *filename; { register char *s; while (*filename) { s = rindex(filename, '/'); if (s == NULL) break; if (s[1]) return (s + 1); *s = '\0'; } return (filename); } */ /* * Command parser. */ cmdscanner(top) int top; { register struct cmd *c; register int l; struct cmd *getcmd(); extern int help(); if (!top) (void) putchar('\n'); for (;;) { if (fromatty) { printf("ftp> "); (void) fflush(stdout); } if (fgets(line, sizeof line, stdin) == NULL) quit(); l = strlen(line); if (l == 0) break; if (line[--l] == '\n') { if (l == 0) break; line[l] = '\0'; } else if (l == sizeof(line) - 2) { printf("sorry, input line too long\n"); while ((l = getchar()) != '\n' && l != EOF) /* void */; break; } /* else it was a line without a newline */ makeargv(); if (margc == 0) { continue; } c = getcmd(margv[0]); if (c == (struct cmd *)-1) { printf("?Ambiguous command\n"); continue; } if (c == 0) { printf("?Invalid command\n"); continue; } if (c->c_conn && !connected) { printf("Not connected.\n"); continue; } (*c->c_handler)(margc, margv); if (bell && c->c_bell) (void) putchar('\007'); if (c->c_handler != help) break; } (void) signal(SIGINT, intr); (void) signal(SIGPIPE, lostpeer); } struct cmd * getcmd(name) register char *name; { extern struct cmd cmdtab[]; register char *p, *q; register struct cmd *c, *found; register int nmatches, longest; longest = 0; nmatches = 0; found = 0; for (c = cmdtab; p = c->c_name; c++) { for (q = name; *q == *p++; q++) if (*q == 0) /* exact match? */ return (c); if (!*q) { /* the name was a prefix */ if (q - name > longest) { longest = q - name; nmatches = 1; found = c; } else if (q - name == longest) nmatches++; } } if (nmatches > 1) return ((struct cmd *)-1); return (found); } /* * Slice a string up into argc/argv. */ int slrflag; makeargv() { char **argp; char *slurpstring(); margc = 0; argp = margv; stringbase = line; /* scan from first of buffer */ argbase = argbuf; /* store from first of buffer */ slrflag = 0; while (*argp++ = slurpstring()) margc++; } /* * Parse string into argbuf; * implemented with FSM to * handle quoting and strings */ char * slurpstring() { int got_one = 0; register char *sb = stringbase; register char *ap = argbase; char *tmp = argbase; /* will return this if token found */ if (*sb == '!' || *sb == '$') { /* recognize ! as a token for shell */ switch (slrflag) { /* and $ as token for macro invoke */ case 0: slrflag++; stringbase++; return ((*sb == '!') ? "!" : "$"); /* NOTREACHED */ case 1: slrflag++; altarg = stringbase; break; default: break; } } S0: switch (*sb) { case '\0': goto OUT; case ' ': case '\t': sb++; goto S0; default: switch (slrflag) { case 0: slrflag++; break; case 1: slrflag++; altarg = sb; break; default: break; } goto S1; } S1: switch (*sb) { case ' ': case '\t': case '\0': goto OUT; /* end of token */ case '\\': sb++; goto S2; /* slurp next character */ case '"': sb++; goto S3; /* slurp quoted string */ default: *ap++ = *sb++; /* add character to token */ got_one = 1; goto S1; } S2: switch (*sb) { case '\0': goto OUT; default: *ap++ = *sb++; got_one = 1; goto S1; } S3: switch (*sb) { case '\0': goto OUT; case '"': sb++; goto S1; default: *ap++ = *sb++; got_one = 1; goto S3; } OUT: if (got_one) *ap++ = '\0'; argbase = ap; /* update storage pointer */ stringbase = sb; /* update scan pointer */ if (got_one) { return(tmp); } switch (slrflag) { case 0: slrflag++; break; case 1: slrflag++; altarg = (char *) 0; break; default: break; } return((char *)0); } #define HELPINDENT (sizeof ("directory")) /* * Help command. * Call each command handler with argc == 0 and argv[0] == name. */ help(argc, argv) int argc; char *argv[]; { extern struct cmd cmdtab[]; register struct cmd *c; if (argc == 1) { register int i, j, w, k; int columns, width = 0, lines; extern int NCMDS; printf("Commands may be abbreviated. Commands are:\n\n"); for (c = cmdtab; c < &cmdtab[NCMDS]; c++) { int len = strlen(c->c_name); if (len > width) width = len; } width = (width + 8) &~ 7; columns = 80 / width; if (columns == 0) columns = 1; lines = (NCMDS + columns - 1) / columns; for (i = 0; i < lines; i++) { for (j = 0; j < columns; j++) { c = cmdtab + j * lines + i; if (c->c_name && (!proxy || c->c_proxy)) { printf("%s", c->c_name); } else if (c->c_name) { for (k=0; k < strlen(c->c_name); k++) { (void) putchar(' '); } } if (c + lines >= &cmdtab[NCMDS]) { printf("\n"); break; } w = strlen(c->c_name); while (w < width) { w = (w + 8) &~ 7; (void) putchar('\t'); } } } return; } while (--argc > 0) { register char *arg; arg = *++argv; c = getcmd(arg); if (c == (struct cmd *)-1) printf("?Ambiguous help command %s\n", arg); else if (c == (struct cmd *)0) printf("?Invalid help command %s\n", arg); else printf("%-*s\t%s\n", HELPINDENT, c->c_name, c->c_help); } } socks4-server-4.3.beta2.orig/rftp/pathnames.h100644 7657 764 3772 5716466024 17527 0ustar martinedv/* * Copyright (c) 1989 The Regents of the University of California. * All rights reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions * are met: * 1. Redistributions of source code must retain the above copyright * notice, this list of conditions and the following disclaimer. * 2. Redistributions in binary form must reproduce the above copyright * notice, this list of conditions and the following disclaimer in the * documentation and/or other materials provided with the distribution. * 3. All advertising materials mentioning features or use of this software * must display the following acknowledgement: * This product includes software developed by the University of * California, Berkeley and its contributors. * 4. Neither the name of the University nor the names of its contributors * may be used to endorse or promote products derived from this software * without specific prior written permission. * * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF * SUCH DAMAGE. * * @(#)pathnames.h 5.2 (Berkeley) 6/1/90 */ #if defined (COMPAT) || defined(ultrix) || defined(SCO) #define _PATH_BSHELL "/bin/sh" #else #include #endif #undef _PATH_TMP #define _PATH_TMP "/tmp/ftpXXXXXX" socks4-server-4.3.beta2.orig/rftp/ruserpass.c100644 7657 764 16344 5606334275 17610 0ustar martinedv/* * Copyright (c) 1985 Regents of the University of California. * All rights reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions * are met: * 1. Redistributions of source code must retain the above copyright * notice, this list of conditions and the following disclaimer. * 2. Redistributions in binary form must reproduce the above copyright * notice, this list of conditions and the following disclaimer in the * documentation and/or other materials provided with the distribution. * 3. All advertising materials mentioning features or use of this software * must display the following acknowledgement: * This product includes software developed by the University of * California, Berkeley and its contributors. * 4. Neither the name of the University nor the names of its contributors * may be used to endorse or promote products derived from this software * without specific prior written permission. * * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF * SUCH DAMAGE. */ #ifndef lint static char sccsid[] = "@(#)ruserpass.c 5.3 (Berkeley) 3/1/91"; #endif /* not lint */ #include #include #include #include #include #include #include "ftp_var.h" #if defined(AIX_PS2) #include "../rtelnet/libtelnet/strcasecmp.c" #endif #ifndef MAXHOSTNAMELEN #define MAXHOSTNAMELEN 64 #endif char *renvlook(), *malloc(), *index(), *getenv(), *getpass(), *getlogin(); char *strcpy(); struct utmp *getutmp(); static FILE *cfile; #define DEFAULT 1 #define LOGIN 2 #define PASSWD 3 #define ACCOUNT 4 #define MACDEF 5 #define ID 10 #define MACH 11 static char tokval[100]; static struct toktab { char *tokstr; int tval; } toktab[]= { "default", DEFAULT, "login", LOGIN, "password", PASSWD, "passwd", PASSWD, "account", ACCOUNT, "machine", MACH, "macdef", MACDEF, 0, 0 }; ruserpass(host, aname, apass, aacct) char *host, **aname, **apass, **aacct; { char *hdir, buf[BUFSIZ], *tmp; char myname[MAXHOSTNAMELEN], *mydomain; int t, i, c, usedefault = 0; struct stat stb; static int token(); hdir = getenv("HOME"); if (hdir == NULL) hdir = "."; (void) sprintf(buf, "%s/.netrc", hdir); cfile = fopen(buf, "r"); if (cfile == NULL) { if (errno != ENOENT) perror(buf); return(0); } if (gethostname(myname, sizeof(myname)) < 0) myname[0] = '\0'; if ((mydomain = index(myname, '.')) == NULL) mydomain = ""; next: while ((t = token())) switch(t) { case DEFAULT: usedefault = 1; /* FALL THROUGH */ case MACH: if (!usedefault) { if (token() != ID) continue; /* * Allow match either for user's input host name * or official hostname. Also allow match of * incompletely-specified host in local domain. */ if (strcasecmp(host, tokval) == 0) goto match; if (strcasecmp(hostname, tokval) == 0) goto match; if ((tmp = index(hostname, '.')) != NULL && strcasecmp(tmp, mydomain) == 0 && strncasecmp(hostname, tokval, tmp-hostname) == 0 && tokval[tmp - hostname] == '\0') goto match; if ((tmp = index(host, '.')) != NULL && strcasecmp(tmp, mydomain) == 0 && strncasecmp(host, tokval, tmp - host) == 0 && tokval[tmp - host] == '\0') goto match; continue; } match: while ((t = token()) && t != MACH && t != DEFAULT) switch(t) { case LOGIN: if (token()) if (*aname == 0) { *aname = malloc((unsigned) strlen(tokval) + 1); (void) strcpy(*aname, tokval); } else { if (strcmp(*aname, tokval)) goto next; } break; case PASSWD: if (strcmp(*aname, "anonymous") && fstat(fileno(cfile), &stb) >= 0 && (stb.st_mode & 077) != 0) { fprintf(stderr, "Error - .netrc file not correct mode.\n"); fprintf(stderr, "Remove password or correct mode.\n"); goto bad; } if (token() && *apass == 0) { *apass = malloc((unsigned) strlen(tokval) + 1); (void) strcpy(*apass, tokval); } break; case ACCOUNT: if (fstat(fileno(cfile), &stb) >= 0 && (stb.st_mode & 077) != 0) { fprintf(stderr, "Error - .netrc file not correct mode.\n"); fprintf(stderr, "Remove account or correct mode.\n"); goto bad; } if (token() && *aacct == 0) { *aacct = malloc((unsigned) strlen(tokval) + 1); (void) strcpy(*aacct, tokval); } break; case MACDEF: if (proxy) { (void) fclose(cfile); return(0); } while ((c=getc(cfile)) != EOF && c == ' ' || c == '\t'); if (c == EOF || c == '\n') { printf("Missing macdef name argument.\n"); goto bad; } if (macnum == 16) { printf("Limit of 16 macros have already been defined\n"); goto bad; } tmp = macros[macnum].mac_name; *tmp++ = c; for (i=0; i < 8 && (c=getc(cfile)) != EOF && !isspace(c); ++i) { *tmp++ = c; } if (c == EOF) { printf("Macro definition missing null line terminator.\n"); goto bad; } *tmp = '\0'; if (c != '\n') { while ((c=getc(cfile)) != EOF && c != '\n'); } if (c == EOF) { printf("Macro definition missing null line terminator.\n"); goto bad; } if (macnum == 0) { macros[macnum].mac_start = macbuf; } else { macros[macnum].mac_start = macros[macnum-1].mac_end + 1; } tmp = macros[macnum].mac_start; while (tmp != macbuf + 4096) { if ((c=getc(cfile)) == EOF) { printf("Macro definition missing null line terminator.\n"); goto bad; } *tmp = c; if (*tmp == '\n') { if (*(tmp-1) == '\0') { macros[macnum++].mac_end = tmp - 1; break; } *tmp = '\0'; } tmp++; } if (tmp == macbuf + 4096) { printf("4K macro buffer exceeded\n"); goto bad; } break; default: fprintf(stderr, "Unknown .netrc keyword %s\n", tokval); break; } goto done; } done: (void) fclose(cfile); return(0); bad: (void) fclose(cfile); return(-1); } static token() { char *cp; int c; struct toktab *t; if (feof(cfile)) return (0); while ((c = getc(cfile)) != EOF && (c == '\n' || c == '\t' || c == ' ' || c == ',')) continue; if (c == EOF) return (0); cp = tokval; if (c == '"') { while ((c = getc(cfile)) != EOF && c != '"') { if (c == '\\') c = getc(cfile); *cp++ = c; } } else { *cp++ = c; while ((c = getc(cfile)) != EOF && c != '\n' && c != '\t' && c != ' ' && c != ',') { if (c == '\\') c = getc(cfile); *cp++ = c; } } *cp = 0; if (tokval[0] == 0) return (0); for (t = toktab; t->tokstr; t++) if (!strcmp(t->tokstr, tokval)) return (t->tval); return (ID); } socks4-server-4.3.beta2.orig/rtelnet/ 40755 7657 764 0 6157332563 15772 5ustar martinedvsocks4-server-4.3.beta2.orig/rtelnet/Config.generic100640 7657 764 40051 5606334314 20640 0ustar martinedv# # Copyright (c) 1991 The Regents of the University of California. # All rights reserved. # # Redistribution and use in source and binary forms are permitted provided # that: (1) source distributions retain this entire copyright notice and # comment, and (2) distributions including binaries display the following # acknowledgement: ``This product includes software developed by the # University of California, Berkeley and its contributors'' in the # documentation or other materials provided with the distribution and in # all advertising materials mentioning features or use of this software. # Neither the name of the University nor the names of its contributors may # be used to endorse or promote products derived from this software without # specific prior written permission. # THIS SOFTWARE IS PROVIDED ``AS IS'' AND WITHOUT ANY EXPRESS OR IMPLIED # WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED WARRANTIES OF # MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. # # @(#)Config.generic 5.5 (Berkeley) 3/1/91 # # This is the configuration file for building all of # telnet/telnetd/libtelnet. If you want to add your # own local configuration for a specific machine that # is already listed here, it is best to create a new # file called "Config.local", and put the definitions # there. If you are adding definitions for a new system # type, you can add them here. In this case, please send # the new definition, and any changes you have to make to # the code, back to "dab@cray.com" so that your changes # can be put into the next release. # # Each definition must have the form: # # : # make -f Makefile.generic ${WHAT} \ # # DEFINES= # # Variables to be defined when actually compiling the source. Defined # as: DEFINES="-D -D ... -D" # # TELNET/TELNETD CONFIGURATION # # LINEMODE Turns on support in telnetd for the linemode option. # (Linemode is always on in the client). # # KLUDGELINEMODE Define this to get the kludged up version of linemode # that was in 4.3BSD. This is a good thing to have # around for talking to older systems. This has no # effect on telnetd if LINEMODE has not been defined. # # DIAGNOSTICS Turns on diagnostic code in telnetd; adds extra # logic and checks, and debuging output if started # with the -D option. # # NO_URGENT Define this if you don't want telnetd to send # IAC DM in urgent mode when the pty output queue # is flushed. # # GENERATE_GA Turns on code to allow the generation of Go Ahead(GA) # if the server is WONT SGA. This code is imprecise, # it generates the GA when two seconds have elapsed # and no input or output has occurred. # # AUTHENTICATE Enable the AUTHENTICATE option. # # ENCRYPT Enable the ENCRYPT option. # # KRB4 Enable Kerberos Version 4 Authentication code # in libtelnet/libtelnet.a # # KRB5 Enable Kerberos Version 5 Authentication code # in libtelnet/libtelnet.a # # SIMPLE_AUTH # # DES_ENCRYPT Enable DES encryption/decryption, requires # getting a the initial key from Kerberos. This # works with both Kerberos Version 4 and 5. # # LOCAL SYSYTEM PARAMATERS # # TERMCAP Define this if your system is termcap based, # otherwise a terminfo based system is assumed. # # SYSV_TERMIO Use the System V termio structure. (implies USE_TERMIO) # # NO_CC_T Define this if your termio.h file does not have # a typedef for cc_t. # # USE_TERMIO Define this if you have the POSIX termios structures. # This code works under the BSD 4.4 terminal driver. # # HAS_GETTOS Define this if you have the setsockopt() option for # setting the IP Type Of Service bits, (IP_TOS) and # you have the gettosbyname() function. # # NEWINIT Turns on the new init code for UNICOS systems. # # STREAMS This system needs for # (Sun 4.0.3) # # FILIO_H This system should use instead # of (Sun 4.0.3) # # HAVE_fd_set This system has a typedef for fd_set, but does # not have FDSET() defined. # # NO_STRING_H If you don't have , but have # # NO_LOGIN_P If /bin/login doesn't understand the "-p" # (preserve environment) option. # # STREAMS If the system has streams; causes # to be included instead of # # MUST_ALIGN If !KRB & !HAVE_KRB4_DES_LIB and your words # must be word aligned. # LIB_OBJ= # This is a list of object files that are needed but are not in # the standard C library. # # strcasecmp.o If you don't have strncasecmp(3) # strdup.o If you don't have strdup(3) # setenv.o If you don't have setenv(3) and unsetenv(3) # setsid.o If you don't have the POSIX setsid() call # strerror.o If you don't have strerror(3) # strftime.o If you don't have strftime(3) # getopt.o If you don't have getopt(3) # herror.o If you don't have herror(3) # gettytab.o If you can get gettytab.c from getty source. # getent.o If you can't get gettytab.c # kerberos.o If you have Kerberos Version 4 # kerberos5.o If you have Kerberos Version 5 # mem.o If you don't have mem*(3) routines. # LIB_SRC= # This is a list of source modules for specificed in LIB_OBJ. # This information is used by make for checking dependencies. # LIBS= # This is a list of libraries to be included. This will always # include the telnet library, and will also include either -lcurses # or -ltermcap, -lutil for 4.4bsd, and -lnet for UNICOS5.0 and earlier. # Also -lkrb & -ldes if Kerberos. # LIBPATH= # This is a list of the paths to all the libraries listed in LIBS. # This information is used by make for checking dependencies. # Don't forget libc.a # VPATH= # Directory where gettytab.c can be found, if you have it. # LIBEXEC= # Directory where the telnetd executable should be installed. # LCCFLAGS= # Local flags for ${CC} (like -O) # AR= # Name of "ar" program, usually just "ar". # ARFLAGS # Flags to pass to ${AR} # RANLIB # Name of "ranlib" program, set it to "NONE" if you don't # have a "ranlib". all: @echo "you must specify what type of system you are on," @echo "or modify the makefile for your system." @echo "Known system types are:" @echo " 4.4bsd 4.3reno 4.3tahoe 4.3bsd" @echo " unicos5.0 unicos5.1 unicos6.0 unicos6.1 unicos7.0" @echo " sun3.5 sun4.0 sun4.0.3c sun4.1" @echo " dynix3.0.12 dynix3.0.17" @echo " ultrix3.1 ultrix4.0" @echo " next1.0" 4.4bsd 4.3reno: make -f Makefile.generic ${WHAT} \ LIBS="-lutil -ltermcap ../libtelnet/libtelnet.a" \ LIBPATH="/lib/libc.a /usr/lib/libtermcap.a \ ../libtelnet/libtelnet.a" \ DEST=${DESTDIR}/usr/bin \ DEFINES="-DLINEMODE -DTERMCAP -DKLUDGELINEMODE \ -DUSE_TERMIO -DDIAGNOSTICS" \ INCLUDES="-I.." \ LIB_OBJ="gettytab.o" \ LIB_SRC="gettytab.c" \ AR=ar ARFLAGS=cq RANLIB=ranlib \ VPATH=/usr/src/libexec/getty \ LIBEXEC=${DESTDIR}/usr/libexec \ CC="${CC}" LCCFLAGS="-O" 4.3tahoe: @echo $@ is untested... it may or may not work..." make -f Makefile.generic ${WHAT} \ LIBS="-ltermcap ../libtelnet/libtelnet.a" \ LIBPATH="/lib/libc.a /usr/lib/libtermcap.a \ ../libtelnet/libtelnet.a" \ DEST=${DESTDIR}/usr/bin \ DEFINES="-DTERMCAP -DKLUDGELINEMODE \ -DDIAGNOSTICS" \ INCLUDES="-I.." \ LIB_OBJ="strdup.o setsid.o strftime.o gettytab.o" \ LIB_SRC="strdup.c setsid.c strftime.c gettytab.c" \ AR=ar ARFLAGS=cq RANLIB=ranlib \ VPATH=/usr/src/etc/getty \ LIBEXEC=${DESTDIR}/etc \ CC="${CC}" LCCFLAGS="-O" 4.3bsd: @echo $@ is untested... it may or may not work..." make -f Makefile.generic ${WHAT} \ LIBS="-ltermcap ../libtelnet/libtelnet.a" \ LIBPATH="/lib/libc.a /usr/lib/libtermcap.a \ ../libtelnet/libtelnet.a" \ DEST=${DESTDIR}/usr/bin \ DEFINES="-DTERMCAP -DKLUDGELINEMODE \ -DDIAGNOSTICS" \ INCLUDES="-I.." \ LIB_OBJ="strdup.o setsid.o strftime.o \ gettytab.o getopt.o herror.o" \ LIB_SRC="strdup.c setsid.c strftime.c \ gettytab.c getopt.c herror.c" \ AR=ar ARFLAGS=cq RANLIB=ranlib \ VPATH=/usr/src/etc/getty \ LIBEXEC=${DESTDIR}/etc \ CC="${CC}" LCCFLAGS="-O" unicos7.0: make -f Makefile.generic ${WHAT} \ LIBS="-lcurses -L../libtelnet -ltelnet -lkrb -ldes" \ LIBPATH="/lib/libc.a /usr/lib/libcurses.a \ ../libtelnet/libtelnet.a \ /usr/lib/libkrb.a /usr/lib/libdes.a" \ DEST=${DESTDIR}/usr/ucb \ DEFINES="-Dvfork=fork -Dsignal=bsdsignal \ -DLINEMODE -DKLUDGELINEMODE \ -DSYSV_TERMIO -DHAS_GETTOS \ -DAUTHENTICATE -DENCRYPT -DKRB4 \ -DDIAGNOSTICS" \ AR=bld ARFLAGS=cq RANLIB=NONE \ LIBEXEC=${DESTDIR}/etc \ INCLUDES="-I.." \ LIB_OBJ="getent.o" \ LIB_SRC="getent.c" \ CC="${CC}" LCCFLAGS="-O" unicos6.0 unicos6.1: make -f Makefile.generic ${WHAT} \ LIBS="-lcurses -L../libtelnet -ltelnet" \ LIBPATH="/lib/libc.a /usr/lib/libcurses.a \ ../libtelnet/libtelnet.a" \ DEST=${DESTDIR}/usr/ucb \ DEFINES="-Dvfork=fork -Dsignal=bsdsignal \ -DKLUDGELINEMODE -DUSE_TERMIO -DHAS_GETTOS \ -DLINEMODE -DSYSV_TERMIO -DNEWINIT \ -DNO_LOGIN_F -DNO_LOGIN_P \ -DAUTHENTICATE -DENCRYPT \ -DDIAGNOSTICS" \ AR=bld ARFLAGS=cq RANLIB=NONE \ LIBEXEC=${DESTDIR}/etc \ INCLUDES="-I.." \ LIB_OBJ="getent.o" \ LIB_SRC="getent.c" \ CC="${CC}" LCCFLAGS="-O" unicos5.1: make -f Makefile.generic ${WHAT} \ LIBS="-lnet -lcurses -L../libtelnet -ltelnet" \ LIBPATH="/lib/libc.a /usr/lib/libcurses.a \ ../libtelnet/libtelnet.a" \ DEST=${DESTDIR}/usr/ucb \ DEFINES="-Dvfork=fork -Dsignal=sigset \ -DKLUDGELINEMODE -DSYSV_TERMIO -DNO_CC_T \ -DUNICOS5 -DLINEMODE -DSYSV_TERMIO \ -DNEWINIT -DNO_LOGIN_F -DNO_LOGIN_P \ -DAUTHENTICATE -DENCRYPT \ -DDIAGNOSTICS" \ INCLUDES="-I.." \ LIB_OBJ="getent.o strerror.o setsid.o strftime.o" \ LIB_SRC="getent.c strerror.c setsid.c strftime.c" \ AR=bld ARFLAGS=cq RANLIB=NONE \ LIBEXEC=${DESTDIR}/etc \ CC="${CC}" LCCFLAGS="-O" unicos5.0: make -f Makefile.generic ${WHAT} \ LIBS="-lnet -lcurses -L../libtelnet -ltelnet" \ LIBPATH="/lib/libc.a /usr/lib/libcurses.a \ ../libtelnet/libtelnet.a" \ DEST=${DESTDIR}/usr/ucb \ DEFINES="-Dvfork=fork -Dsignal=sigset \ -DKLUDGELINEMODE -DSYSV_TERMIO -DNO_CC_T \ -DUNICOS5 -DUNICOS50 -DLINEMODE -DSYSV_TERMIO \ -DNEWINIT -DNO_LOGIN_F -DNO_LOGIN_P \ -DAUTHENTICATE -DENCRYPT \ -DDIAGNOSTICS" \ INCLUDES="-I.." \ LIB_OBJ="getent.o strerror.o setsid.o strftime.o" \ LIB_SRC="getent.c strerror.c setsid.c strftime.c" \ AR=bld ARFLAGS=cq RANLIB=NONE \ LIBEXEC=${DESTDIR}/etc \ CC="${CC}" LCCFLAGS="-O" sun3.5: make -f Makefile.generic ${WHAT} \ LIBS="-ltermcap ../libtelnet/libtelnet.a" \ LIBPATH="/lib/libc.a /usr/lib/libtermcap.a \ ../libtelnet/libtelnet.a" \ DEST=${DESTDIR}/usr/ucb \ DEFINES="-DTERMCAP -DKLUDGELINEMODE \ -DHAVE_fd_set \ -DDIAGNOSTICS \ -DNO_LOGIN_P" \ INCLUDES="-I.." \ LIB_OBJ="getent.o strdup.o strerror.o setsid.o \ setenv.o strftime.o strcasecmp.o herror.o" \ LIB_SRC="getent.c strdup.c strerror.c setsid.c \ setenv.c strftime.c strcasecmp.c herror.c" \ AR=ar ARFLAGS=cq RANLIB=ranlib \ LIBEXEC=${DESTDIR}/usr/etc/in.telnetd \ CC="${CC}" LCCFLAGS="-O" sun4.0.3c sun4.0: @echo $@ is untested... it may or may not work..." make -f Makefile.generic ${WHAT} \ LIBS="-ltermcap ../libtelnet/libtelnet.a" \ LIBPATH="/lib/libc.a /usr/lib/libtermcap.a \ ../libtelnet/libtelnet.a" \ DEST=${DESTDIR}/usr/ucb \ DEFINES="-DFILIO_H -DTERMCAP -DUSE_TERMIO -DNO_CC_T \ -DKLUDGELINEMODE \ -DSTREAMS -DDIAGNOSTICS \ " \ INCLUDES="-I.." \ LIB_OBJ="getent.o strerror.o setsid.o setenv.o \ strcasecmp.o strftime.o herror.o" \ LIB_SRC="getent.c strerror.c setsid.c setenv.c \ strcasecmp.c strftime.c herror.c" \ AR=ar ARFLAGS=cq RANLIB=ranlib \ LIBEXEC=${DESTDIR}/usr/etc/in.telnetd \ CC="${CC}" LCCFLAGS="-O" sun4.1: make -f Makefile.generic ${WHAT} \ LIBS="-ltermcap ../libtelnet/libtelnet.a" \ LIBPATH="/lib/libc.a /usr/lib/libtermcap.a \ ../libtelnet/libtelnet.a" \ DEST=${DESTDIR}/usr/ucb \ DEFINES="-DFILIO_H -DTERMCAP -DUSE_TERMIO \ -DKLUDGELINEMODE -DSTREAMS \ -DAUTHENTICATE -DENCRYPT \ -DDIAGNOSTICS " \ INCLUDES="-I.." \ LIB_OBJ="getent.o strerror.o setenv.o herror.o" \ LIB_SRC="getent.c strerror.c setenv.c herror.c" \ AR=ar ARFLAGS=cq RANLIB=ranlib \ LIBEXEC=${DESTDIR}/usr/etc/in.telnetd \ CC="${CC}" LCCFLAGS="-O" dynix3.0.12: @echo $@ is untested... it may or may not work..." make -f Makefile.generic ${WHAT} \ LIBS="-ltermcap ../libtelnet/libtelnet.a" \ LIBPATH="/lib/libc.a /usr/lib/libtermcap.a \ ../libtelnet/libtelnet.a" \ DEST=${DESTDIR}/usr/ucb \ DEFINES="-DTERMCAP -DKLUDGELINEMODE \ -DDIAGNOSTICS -DNO_STRING_H " \ INCLUDES="-I.." \ LIB_OBJ="getent.o strchr.o strrchr.o strdup.o strerror.o \ setsid.o setenv.o strcasecmp.o strftime.o getopt.o \ mem.o" \ LIB_SRC="getent.c strchr.c strrchr.c strdup.c strerror.c \ setsid.c setenv.c strcasecmp.c strftime.c getopt.c \ mem.o" \ AR=ar ARFLAGS=cq RANLIB=ranlib \ LIBEXEC=${DESTDIR}/usr/etc \ CC="${CC}" LCCFLAGS="-O" dynix3.0.17: make -f Makefile.generic ${WHAT} \ LIBS="-ltermcap ../libtelnet/libtelnet.a -lseq" \ LIBPATH="/lib/libc.a /usr/lib/libtermcap.a \ ../libtelnet/libtelnet.a /usr/lib/libseq.a" \ DEST=${DESTDIR}/usr/ucb \ DEFINES="-DTERMCAP -DKLUDGELINEMODE \ -DDIAGNOSTICS -DNO_STRING_H \ " \ INCLUDES="-I.." \ LIB_OBJ="getent.o strchr.o strrchr.o strdup.o strerror.o \ setsid.o strftime.o mem.o" \ LIB_SRC="getent.c strchr.c strrchr.c strdup.c strerror.c \ setsid.c strftime.c mem.c" \ AR=ar ARFLAGS=cq RANLIB=ranlib \ LIBEXEC=${DESTDIR}/usr/etc \ CC="${CC}" LCCFLAGS="-O" ultrix3.1: make -f Makefile.generic ${WHAT} \ LIBS="-ltermcap ../libtelnet/libtelnet.a" \ LIBPATH="/lib/libc.a /usr/lib/libtermcap.a \ ../libtelnet/libtelnet.a" \ DEST=${DESTDIR}/usr/ucb \ DEFINES="-DTERMCAP -DKLUDGELINEMODE \ -DDIAGNOSTICS -DUSE_TERMIO \ -YPOSIX" \ INCLUDES="-I.." \ LIB_OBJ="getent.o strdup.o strerror.o setenv.o \ strftime.o herror.o" \ LIB_SRC="getent.c strdup.c strerror.c setenv.c \ strftime.c herror.c" \ AR=ar ARFLAGS=cq RANLIB=ranlib \ LIBEXEC=${DESTDIR}/usr/etc \ CC="${CC}" LCCFLAGS="-O" ultrix4.0: make -f Makefile.generic ${WHAT} \ LIBS="-ltermcap ../libtelnet/libtelnet.a" \ LIBPATH="/lib/libc.a /usr/lib/libtermcap.a \ ../libtelnet/libtelnet.a" \ DEST=${DESTDIR}/usr/ucb \ DEFINES="-DUSE_TERMIO -DTERMCAP \ -DKLUDGELINEMODE -DDIAGNOSTICS " \ INCLUDES="-I.." \ LIB_OBJ="getent.o strdup.o strerror.o setsid.o \ setenv.o strftime.o" \ LIB_SRC="getent.c strdup.c strerror.c setsid.c \ setenv.c strftime.c" \ AR=ar ARFLAGS=cq RANLIB=ranlib \ LIBEXEC=${DESTDIR}/usr/etc \ CC="${CC}" LCCFLAGS="-O" next1.0: @echo $@ is untested... it may or may not work..." make -f Makefile.generic ${WHAT} \ LIBS="../libtelnet/libtelnet.a -ltermcap -lsys_s" \ LIBPATH="/lib/libc.a /lib/libsys_s.a /usr/lib/libtermcap.a \ ../libtelnet/libtelnet.a" \ DEST=${DESTDIR}/usr/ucb \ DEFINES="-bsd -DTERMCAP -DKLUDGELINEMODE \ -DDIAGNOSTICS -DNO_STRING_H \ -Dgetenv=getenv_" \ INCLUDES="-I.." \ LIB_OBJ="strdup.o setenv.o setsid.o strftime.o \ strcasecmp.o gettytab.o" \ LIB_SRC=s"trdup.c setenv.c setsid.c strftime.c \ strcasecmp.c gettytab.c" \ CC="${CC}" LCCFLAGS="-O" \ VPATH=../../getty \ AR=ar ARFLAGS=cq RANLIB=ranlib \ LIBEXEC=${DESTDIR}/usr/etc # # For the convex, make symbolic links to the tc[sg]getattr.c routines, # because we are using posix stuff, but not the posix library... # Pass the stuff to Makefile.generic by passing the object/source names # in through LIB_OBJ and LIB_SRC # convex: @echo $@ is untested... it may or may not work..." ln -s ../../rel_usr/src/lib/libc/posix/tcsetattr.c tcsetattr.c ln -s ../../rel_usr/src/lib/libc/posix/tcgetattr.c tcgetattr.c make -f Makefile.generic ${WHAT} \ LIBS="-ltermcap ../libtelnet/libtelnet.a" \ LIBPATH="../libtelnet/libtelnet.a" \ AR=ar ARFLAGS=cq RANLIB=ranlib \ LIBEXEC=${DESTDIR}/usr/etc/in.telnetd \ CC="${CC}" LCCFLAGS="-g ${OPTLEV} -Dconvex" \ DEFINES="-DUSE_TERMIO -DLINEMODE -DDIAGNOSTICS" \ INCLUDES="-I.." \ LIB_OBJ="getent.o setsid.o strftime.o \ tcsetattr.o tcgetattr.o" \ LIB_SRC="getent.c setsid.c strftime.c \ tcsetattr.c tcgetattr.c" clean cleandir: make -f Makefile.generic $@ socks4-server-4.3.beta2.orig/rtelnet/Config.local100640 7657 764 72317 6144767063 20341 0ustar martinedv# # Copyright (c) 1991 The Regents of the University of California. # All rights reserved. # # Redistribution and use in source and binary forms are permitted provided # that: (1) source distributions retain this entire copyright notice and # comment, and (2) distributions including binaries display the following # acknowledgement: ``This product includes software developed by the # University of California, Berkeley and its contributors'' in the # documentation or other materials provided with the distribution and in # all advertising materials mentioning features or use of this software. # Neither the name of the University nor the names of its contributors may # be used to endorse or promote products derived from this software without # specific prior written permission. # THIS SOFTWARE IS PROVIDED ``AS IS'' AND WITHOUT ANY EXPRESS OR IMPLIED # WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED WARRANTIES OF # MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. # # @(#)Config.generic 5.5 (Berkeley) 3/1/91 # # This is the configuration file for building all of # telnet/telnetd/libtelnet. If you want to add your # own local configuration for a specific machine that # is already listed here, it is best to create a new # file called "Config.local", and put the definitions # there. If you are adding definitions for a new system # type, you can add them here. In this case, please send # the new definition, and any changes you have to make to # the code, back to "dab@cray.com" so that your changes # can be put into the next release. # # Each definition must have the form: # # : # make -f Makefile.generic ${WHAT} \ # # DEFINES= # # Variables to be defined when actually compiling the source. Defined # as: DEFINES="-D -D ... -D" # # TELNET/TELNETD CONFIGURATION # # LINEMODE Turns on support in telnetd for the linemode option. # (Linemode is always on in the client). # # KLUDGELINEMODE Define this to get the kludged up version of linemode # that was in 4.3BSD. This is a good thing to have # around for talking to older systems. This has no # effect on telnetd if LINEMODE has not been defined. # # DIAGNOSTICS Turns on diagnostic code in telnetd; adds extra # logic and checks, and debuging output if started # with the -D option. # # NO_URGENT Define this if you don't want telnetd to send # IAC DM in urgent mode when the pty output queue # is flushed. # # GENERATE_GA Turns on code to allow the generation of Go Ahead(GA) # if the server is WONT SGA. This code is imprecise, # it generates the GA when two seconds have elapsed # and no input or output has occurred. # # AUTHENTICATE Enable the AUTHENTICATE option. # # ENCRYPT Enable the ENCRYPT option. # # KRB4 Enable Kerberos Version 4 Authentication code # in libtelnet/libtelnet.a # # KRB5 Enable Kerberos Version 5 Authentication code # in libtelnet/libtelnet.a # # SIMPLE_AUTH # # DES_ENCRYPT Enable DES encryption/decryption, requires # getting a the initial key from Kerberos. This # works with both Kerberos Version 4 and 5. # # LOCAL SYSYTEM PARAMATERS # # TERMCAP Define this if your system is termcap based, # otherwise a terminfo based system is assumed. # # SYSV_TERMIO Use the System V termio structure. (implies USE_TERMIO) # # NO_CC_T Define this if your termio.h file does not have # a typedef for cc_t. # # USE_TERMIO Define this if you have the POSIX termios structures. # This code works under the BSD 4.4 terminal driver. # # HAS_GETTOS Define this if you have the setsockopt() option for # setting the IP Type Of Service bits, (IP_TOS) and # you have the gettosbyname() function. # # NEWINIT Turns on the new init code for UNICOS systems. # # STREAMS This system needs for # (Sun 4.0.3) # # FILIO_H This system should use instead # of (Sun 4.0.3) # # HAVE_fd_set This system has a typedef for fd_set, but does # not have FDSET() defined. # # NO_STRING_H If you don't have , but have # # NO_LOGIN_P If /bin/login doesn't understand the "-p" # (preserve environment) option. # # STREAMS If the system has streams; causes # to be included instead of # # MUST_ALIGN If !KRB & !HAVE_KRB4_DES_LIB and your words # must be word aligned. # LIB_OBJ= # This is a list of object files that are needed but are not in # the standard C library. # # strcasecmp.o If you don't have strncasecmp(3) # strdup.o If you don't have strdup(3) # setenv.o If you don't have setenv(3) and unsetenv(3) # setsid.o If you don't have the POSIX setsid() call # strerror.o If you don't have strerror(3) # strftime.o If you don't have strftime(3) # getopt.o If you don't have getopt(3) # herror.o If you don't have herror(3) # gettytab.o If you can get gettytab.c from getty source. # getent.o If you can't get gettytab.c # kerberos.o If you have Kerberos Version 4 # kerberos5.o If you have Kerberos Version 5 # mem.o If you don't have mem*(3) routines. # LIB_SRC= # This is a list of source modules for specificed in LIB_OBJ. # This information is used by make for checking dependencies. # LIBS= # This is a list of libraries to be included. This will always # include the telnet library, and will also include either -lcurses # or -ltermcap, -lutil for 4.4bsd, and -lnet for UNICOS5.0 and earlier. # Also -lkrb & -ldes if Kerberos. # LIBPATH= # This is a list of the paths to all the libraries listed in LIBS. # This information is used by make for checking dependencies. # Don't forget libc.a # VPATH= # Directory where gettytab.c can be found, if you have it. # LIBEXEC= # Directory where the telnetd executable should be installed. # LCCFLAGS= # Local flags for ${CC} (like -O) # AR= # Name of "ar" program, usually just "ar". # ARFLAGS # Flags to pass to ${AR} # RANLIB # Name of "ranlib" program, set it to "NONE" if you don't # have a "ranlib". #========================================================== # SOCKS specific stuff: SOCKS=-DSOCKS # or #SOCKS=-Dconnect=Rconnect -Dgetsockname=Rgetsockname -Dlisten=Rlisten -Daccept=Raccept -Drcmd=Rrcmd -Dbind=Rbind -Dselect=Rselect # NOTE: This file is actually used from the subdirectories BELOW, # therefore we need an extra ../ in the path: SOCKS_LIB=../../lib/libsocks.a # Define RESOLV_LIB if your system (e.g., SunOS before 4.1.1) # doesn't search resolver library automatically. # Leave it undefined otherwise. # If your compiler or loader complains about _res_init being # an undefined symbol, then you must define RESOLV_LIB. #RESOLV_LIB= -lresolv #============================================================= all: @echo "you must specify what type of system you are on," @echo "or modify the makefile for your system." @echo "Known system types are:" @echo " 4.4bsd 4.3reno 4.3tahoe 4.3bsd" @echo " unicos5.0 unicos5.1 unicos6.0 unicos6.1 unicos7.0" @echo " sun3.5 sun4.0 sun4.0.3c sun4.1 sun5.2 solaris2.2" @echo " dynix3.0.12 dynix3.0.17" @echo " ultrix3.1 ultrix4.0" @echo " next1.0" @echo " convex" @echo " irix4 irix5" @echo " hpux9" @echo " aix3.2 aix_ps2" @echo " aix_ps2" @echo " netbsd0.9" @echo " freeBSD1.1" @echo " dgux5.4" @echo " alphaOSF osf1.3" @echo " linux" @echo " UnixWare" @echo " uts2.1 ust4" @echo " sco" @echo " bsdi" @echo " isc" @echo " newsos4" 4.4bsd 4.3reno: ${MAKE} -f Makefile.generic ${WHAT} \ LIBS="${SOCKS_LIB} -lutil -ltermcap ../libtelnet/libtelnet.a ${RESOLV_LIB}" \ LIBPATH="/lib/libc.a /usr/lib/libtermcap.a \ ../libtelnet/libtelnet.a" \ DEST=${DESTDIR}/usr/bin \ DEFINES="-DLINEMODE -DTERMCAP -DKLUDGELINEMODE \ -DUSE_TERMIO $(SOCKS) -DDIAGNOSTICS" \ INCLUDES="-I.. -I../../include" \ LIB_OBJ="gettytab.o" \ LIB_SRC="gettytab.c" \ AR=ar ARFLAGS=cq RANLIB=ranlib \ VPATH=/usr/src/libexec/getty \ LIBEXEC=${DESTDIR}/usr/libexec \ CC="${CC}" LCCFLAGS="$(OPTIMIZE)" 4.3tahoe: @echo $@ is untested... it may or may not work..." ${MAKE} -f Makefile.generic ${WHAT} \ LIBS="${SOCKS_LIB} -ltermcap ../libtelnet/libtelnet.a ${RESOLV_LIB}" \ LIBPATH="/lib/libc.a /usr/lib/libtermcap.a \ ../libtelnet/libtelnet.a" \ DEST=${DESTDIR}/usr/bin \ DEFINES="-DTERMCAP -DKLUDGELINEMODE \ $(SOCKS) -DDIAGNOSTICS" \ INCLUDES="-I.. -I../../include" \ LIB_OBJ="strdup.o setsid.o strftime.o gettytab.o" \ LIB_SRC="strdup.c setsid.c strftime.c gettytab.c" \ AR=ar ARFLAGS=cq RANLIB=ranlib \ VPATH=/usr/src/etc/getty \ LIBEXEC=${DESTDIR}/etc \ CC="${CC}" LCCFLAGS="$(OPTIMIZE)" 4.3bsd: @echo $@ is untested... it may or may not work..." ${MAKE} -f Makefile.generic ${WHAT} \ LIBS="${SOCKS_LIB} -ltermcap ../libtelnet/libtelnet.a ${RESOLV_LIB}" \ LIBPATH="/lib/libc.a /usr/lib/libtermcap.a \ ../libtelnet/libtelnet.a" \ DEST=${DESTDIR}/usr/bin \ DEFINES="-DTERMCAP -DKLUDGELINEMODE \ $(SOCKS) -DDIAGNOSTICS" \ INCLUDES="-I.. -I../../include" \ LIB_OBJ="strdup.o setsid.o strftime.o \ gettytab.o getopt.o herror.o" \ LIB_SRC="strdup.c setsid.c strftime.c \ gettytab.c getopt.c herror.c" \ AR=ar ARFLAGS=cq RANLIB=ranlib \ VPATH=/usr/src/etc/getty \ LIBEXEC=${DESTDIR}/etc \ CC="${CC}" LCCFLAGS="$(OPTIMIZE)" unicos7.0: ${MAKE} -f Makefile.generic ${WHAT} \ LIBS="${SOCKS_LIB} -lcurses -L../libtelnet -ltelnet -lkrb -ldes ${RESOLV_LIB}" \ LIBPATH="/lib/libc.a /usr/lib/libcurses.a \ ../libtelnet/libtelnet.a \ /usr/lib/libkrb.a /usr/lib/libdes.a" \ DEST=${DESTDIR}/usr/ucb \ DEFINES="-Dvfork=fork -Dsignal=bsdsignal \ -DLINEMODE -DKLUDGELINEMODE \ -DSYSV_TERMIO -DHAS_GETTOS \ -DAUTHENTICATE -DENCRYPT -DKRB4 \ $(SOCKS) -DDIAGNOSTICS" \ AR=bld ARFLAGS=cq RANLIB=NONE \ LIBEXEC=${DESTDIR}/etc \ INCLUDES="-I.. -I../../include" \ LIB_OBJ="getent.o" \ LIB_SRC="getent.c" \ CC="${CC}" LCCFLAGS="$(OPTIMIZE)" unicos6.0 unicos6.1: ${MAKE} -f Makefile.generic ${WHAT} \ LIBS="${SOCKS_LIB} -lcurses -L../libtelnet -ltelnet ${RESOLV_LIB}" \ LIBPATH="/lib/libc.a /usr/lib/libcurses.a \ ../libtelnet/libtelnet.a" \ DEST=${DESTDIR}/usr/ucb \ DEFINES="-Dvfork=fork -Dsignal=bsdsignal \ -DKLUDGELINEMODE -DUSE_TERMIO -DHAS_GETTOS \ -DLINEMODE -DSYSV_TERMIO -DNEWINIT \ -DNO_LOGIN_F -DNO_LOGIN_P \ -DAUTHENTICATE -DENCRYPT \ $(SOCKS) -DDIAGNOSTICS" \ AR=bld ARFLAGS=cq RANLIB=NONE \ LIBEXEC=${DESTDIR}/etc \ INCLUDES="-I.. -I../../include" \ LIB_OBJ="getent.o" \ LIB_SRC="getent.c" \ CC="${CC}" LCCFLAGS="$(OPTIMIZE)" unicos5.1: ${MAKE} -f Makefile.generic ${WHAT} \ LIBS="${SOCKS_LIB} -lnet -lcurses -L../libtelnet -ltelnet ${RESOLV_LIB}" \ LIBPATH="/lib/libc.a /usr/lib/libcurses.a \ ../libtelnet/libtelnet.a" \ DEST=${DESTDIR}/usr/ucb \ DEFINES="-Dvfork=fork -Dsignal=sigset \ -DKLUDGELINEMODE -DSYSV_TERMIO -DNO_CC_T \ -DUNICOS5 -DLINEMODE -DSYSV_TERMIO \ -DNEWINIT -DNO_LOGIN_F -DNO_LOGIN_P \ -DAUTHENTICATE -DENCRYPT \ $(SOCKS) -DDIAGNOSTICS" \ INCLUDES="-I.. -I../../include" \ LIB_OBJ="getent.o strerror.o setsid.o strftime.o" \ LIB_SRC="getent.c strerror.c setsid.c strftime.c" \ AR=bld ARFLAGS=cq RANLIB=NONE \ LIBEXEC=${DESTDIR}/etc \ CC="${CC}" LCCFLAGS="$(OPTIMIZE)" unicos5.0: ${MAKE} -f Makefile.generic ${WHAT} \ LIBS="${SOCKS_LIB} -lnet -lcurses -L../libtelnet -ltelnet ${RESOLV_LIB}" \ LIBPATH="/lib/libc.a /usr/lib/libcurses.a \ ../libtelnet/libtelnet.a" \ DEST=${DESTDIR}/usr/ucb \ DEFINES="-Dvfork=fork -Dsignal=sigset \ -DKLUDGELINEMODE -DSYSV_TERMIO -DNO_CC_T \ -DUNICOS5 -DUNICOS50 -DLINEMODE -DSYSV_TERMIO \ -DNEWINIT -DNO_LOGIN_F -DNO_LOGIN_P \ -DAUTHENTICATE -DENCRYPT \ $(SOCKS) -DDIAGNOSTICS" \ INCLUDES="-I.. -I../../include" \ LIB_OBJ="getent.o strerror.o setsid.o strftime.o" \ LIB_SRC="getent.c strerror.c setsid.c strftime.c" \ AR=bld ARFLAGS=cq RANLIB=NONE \ LIBEXEC=${DESTDIR}/etc \ CC="${CC}" LCCFLAGS="$(OPTIMIZE)" sun3.5: ${MAKE} -f Makefile.generic ${WHAT} \ LIBS="${SOCKS_LIB} -ltermcap ../libtelnet/libtelnet.a ${RESOLV_LIB}" \ LIBPATH="/lib/libc.a /usr/lib/libtermcap.a \ ../libtelnet/libtelnet.a" \ DEST=${DESTDIR}/usr/ucb \ DEFINES="-DTERMCAP -DKLUDGELINEMODE \ -DHAVE_fd_set \ -DDIAGNOSTICS \ $(SOCKS) -DNO_LOGIN_P" \ INCLUDES="-I.. -I../../include" \ LIB_OBJ="getent.o strdup.o strerror.o setsid.o \ setenv.o strftime.o strcasecmp.o herror.o" \ LIB_SRC="getent.c strdup.c strerror.c setsid.c \ setenv.c strftime.c strcasecmp.c herror.c" \ AR=ar ARFLAGS=cq RANLIB=ranlib \ LIBEXEC=${DESTDIR}/usr/etc/in.telnetd \ CC="${CC}" LCCFLAGS="$(OPTIMIZE)" sun4.0.3c sun4.0: @echo $@ is untested... it may or may not work..." ${MAKE} -f Makefile.generic ${WHAT} \ LIBS="${SOCKS_LIB} -ltermcap ../libtelnet/libtelnet.a ${RESOLV_LIB}" \ LIBPATH="/lib/libc.a /usr/lib/libtermcap.a \ ../libtelnet/libtelnet.a" \ DEST=${DESTDIR}/usr/ucb \ DEFINES="-DFILIO_H -DTERMCAP -DUSE_TERMIO -DNO_CC_T \ -DKLUDGELINEMODE \ -DSTREAMS -DDIAGNOSTICS \ $(SOCKS) " \ INCLUDES="-I.. -I../../include" \ LIB_OBJ="getent.o strerror.o setsid.o setenv.o \ strcasecmp.o strftime.o herror.o" \ LIB_SRC="getent.c strerror.c setsid.c setenv.c \ strcasecmp.c strftime.c herror.c" \ AR=ar ARFLAGS=cq RANLIB=ranlib \ LIBEXEC=${DESTDIR}/usr/etc/in.telnetd \ CC="${CC}" LCCFLAGS="$(OPTIMIZE)" sun4.1: ${MAKE} -f Makefile.generic ${WHAT} \ LIBS="${SOCKS_LIB} -ltermcap ../libtelnet/libtelnet.a ${RESOLV_LIB}" \ LIBPATH="/lib/libc.a /usr/lib/libtermcap.a \ ../libtelnet/libtelnet.a" \ DEST=${DESTDIR}/usr/ucb \ DEFINES="-DFILIO_H -DTERMCAP -DUSE_TERMIO \ -DKLUDGELINEMODE -DSTREAMS \ -DAUTHENTICATE \ $(SOCKS) -DDIAGNOSTICS " \ INCLUDES="-I.. -I../../include" \ LIB_OBJ="getent.o strerror.o setenv.o herror.o" \ LIB_SRC="getent.c strerror.c setenv.c herror.c" \ AR=ar ARFLAGS=cq RANLIB=ranlib \ LIBEXEC=${DESTDIR}/usr/etc/in.telnetd \ CC="${CC}" LCCFLAGS="$(OPTIMIZE)" newsos4: ${MAKE} -f Makefile.generic ${WHAT} \ LIBS="${SOCKS_LIB} -ltermcap ../libtelnet/libtelnet.a ${RESOLV_LIB}" \ LIBPATH="/lib/libc.a /usr/lib/libtermcap.a \ ../libtelnet/libtelnet.a" \ DEST=${DESTDIR}/usr/ucb \ DEFINES="-DTERMCAP -DKLUDGELINEMODE \ -DAUTHENTICATE \ $(SOCKS) -DDIAGNOSTICS " \ INCLUDES="-I.. -I../../include" \ LIB_OBJ="getent.o herror.o" \ LIB_SRC="getent.c herror.c" \ AR=ar ARFLAGS=cq RANLIB=ranlib \ LIBEXEC=${DESTDIR}/usr/etc \ CC="${CC}" LCCFLAGS="$(OPTIMIZE)" dynix3.0.12: @echo $@ is untested... it may or may not work..." ${MAKE} -f Makefile.generic ${WHAT} \ LIBS="${SOCKS_LIB} -ltermcap ../libtelnet/libtelnet.a ${RESOLV_LIB}" \ LIBPATH="/lib/libc.a /usr/lib/libtermcap.a \ ../libtelnet/libtelnet.a" \ DEST=${DESTDIR}/usr/ucb \ DEFINES="-DTERMCAP -DKLUDGELINEMODE \ $(SOCKS) -DDIAGNOSTICS -DNO_STRING_H " \ INCLUDES="-I.. -I../../include" \ LIB_OBJ="getent.o strchr.o strrchr.o strdup.o strerror.o \ setsid.o setenv.o strcasecmp.o strftime.o getopt.o \ mem.o" \ LIB_SRC="getent.c strchr.c strrchr.c strdup.c strerror.c \ setsid.c setenv.c strcasecmp.c strftime.c getopt.c \ mem.o" \ AR=ar ARFLAGS=cq RANLIB=ranlib \ LIBEXEC=${DESTDIR}/usr/etc \ CC="${CC}" LCCFLAGS="$(OPTIMIZE)" dynix3.0.17: ${MAKE} -f Makefile.generic ${WHAT} \ LIBS="${SOCKS_LIB} -ltermcap ../libtelnet/libtelnet.a -lseq ${RESOLV_LIB}" \ LIBPATH="/lib/libc.a /usr/lib/libtermcap.a \ ../libtelnet/libtelnet.a /usr/lib/libseq.a" \ DEST=${DESTDIR}/usr/ucb \ DEFINES="-DTERMCAP -DKLUDGELINEMODE \ -DDIAGNOSTICS -DNO_STRING_H \ $(SOCKS) " \ INCLUDES="-I.. -I../../include" \ LIB_OBJ="getent.o strchr.o strrchr.o strdup.o strerror.o \ setsid.o strftime.o mem.o" \ LIB_SRC="getent.c strchr.c strrchr.c strdup.c strerror.c \ setsid.c strftime.c mem.c" \ AR=ar ARFLAGS=cq RANLIB=ranlib \ LIBEXEC=${DESTDIR}/usr/etc \ CC="${CC}" LCCFLAGS="$(OPTIMIZE)" ultrix3.1: ${MAKE} -f Makefile.generic ${WHAT} \ LIBS="${SOCKS_LIB} -ltermcap ../libtelnet/libtelnet.a ${RESOLV_LIB}" \ LIBPATH="/lib/libc.a /usr/lib/libtermcap.a \ ../libtelnet/libtelnet.a" \ DEST=${DESTDIR}/usr/ucb \ DEFINES="-DTERMCAP -DKLUDGELINEMODE \ -DDIAGNOSTICS -DUSE_TERMIO \ $(SOCKS) -YPOSIX" \ INCLUDES="-I.. -I../../include" \ LIB_OBJ="getent.o strdup.o strerror.o setenv.o \ strftime.o herror.o" \ LIB_SRC="getent.c strdup.c strerror.c setenv.c \ strftime.c herror.c" \ AR=ar ARFLAGS=cq RANLIB=ranlib \ LIBEXEC=${DESTDIR}/usr/etc \ CC="${CC}" LCCFLAGS="$(OPTIMIZE)" ultrix4.0: ${MAKE} -f Makefile.generic ${WHAT} \ LIBS="${SOCKS_LIB} -ltermcap ../libtelnet/libtelnet.a ${RESOLV_LIB}" \ LIBPATH="/lib/libc.a /usr/lib/libtermcap.a \ ../libtelnet/libtelnet.a" \ DEST=${DESTDIR}/usr/ucb \ DEFINES="-DUSE_TERMIO $(SOCKS) -DTERMCAP \ -DKLUDGELINEMODE -DDIAGNOSTICS " \ INCLUDES="-I.. -I../../include" \ LIB_OBJ="getent.o strdup.o strerror.o setsid.o \ setenv.o strftime.o" \ LIB_SRC="getent.c strdup.c strerror.c setsid.c \ setenv.c strftime.c" \ AR=ar ARFLAGS=cq RANLIB=ranlib \ LIBEXEC=${DESTDIR}/usr/etc \ CC="${CC}" LCCFLAGS="$(OPTIMIZE)" next1.0: @echo $@ is untested... it may or may not work..." ${MAKE} -f Makefile.generic ${WHAT} \ LIBS="${SOCKS_LIB} ../libtelnet/libtelnet.a -ltermcap -lsys_s ${RESOLV_LIB}" \ LIBPATH="/lib/libc.a /lib/libsys_s.a /usr/lib/libtermcap.a \ ../libtelnet/libtelnet.a" \ DEST=${DESTDIR}/usr/ucb \ DEFINES="-bsd -DTERMCAP -DKLUDGELINEMODE \ -DDIAGNOSTICS -DNO_STRING_H \ $(SOCKS) -Dgetenv=getenv_" \ INCLUDES="-I.. -I../../include" \ LIB_OBJ="strdup.o setenv.o setsid.o strftime.o \ strcasecmp.o gettytab.o" \ LIB_SRC=s"trdup.c setenv.c setsid.c strftime.c \ strcasecmp.c gettytab.c" \ CC="${CC}" LCCFLAGS="$(OPTIMIZE)" \ VPATH=../../getty \ AR=ar ARFLAGS=cq RANLIB=ranlib \ LIBEXEC=${DESTDIR}/usr/etc # # For the convex, make symbolic links to the tc[sg]getattr.c routines, # because we are using posix stuff, but not the posix library... # Pass the stuff to Makefile.generic by passing the object/source names # in through LIB_OBJ and LIB_SRC # convex: @echo $@ is untested... it may or may not work..." ln -s ../../rel_usr/src/lib/libc/posix/tcsetattr.c tcsetattr.c ln -s ../../rel_usr/src/lib/libc/posix/tcgetattr.c tcgetattr.c ${MAKE} -f Makefile.generic ${WHAT} \ LIBS="${SOCKS_LIB} -ltermcap ../libtelnet/libtelnet.a ${RESOLV_LIB}" \ LIBPATH="../libtelnet/libtelnet.a" \ AR=ar ARFLAGS=cq RANLIB=ranlib \ LIBEXEC=${DESTDIR}/usr/etc/in.telnetd \ CC="${CC}" LCCFLAGS="-g ${OPTLEV} -Dconvex" \ DEFINES="-DUSE_TERMIO -DLINEMODE $(SOCKS) -DDIAGNOSTICS" \ INCLUDES="-I.. -I../../include" \ LIB_OBJ="getent.o setsid.o strftime.o \ tcsetattr.o tcgetattr.o" \ LIB_SRC="getent.c setsid.c strftime.c \ tcsetattr.c tcgetattr.c" # >>> Ian Dunkin irix4: ${MAKE} -f Makefile.generic ${WHAT} \ LIBS="${SOCKS_LIB} -lcurses ../libtelnet/libtelnet.a -lsun" \ LIBPATH="/usr/lib/libc.a /usr/lib/libcurses.a \ ../libtelnet/libtelnet.a" \ DEST=${DESTDIR}/usr/ucb \ DEFINES="-Dvfork=fork -DSYSV_TERMIO \ -DKLUDGELINEMODE -DSTREAMS \ -DAUTHENTICATE \ -DDIAGNOSTICS $(SOCKS) " \ INCLUDES="-I.. -I../../include" \ LIB_OBJ="getent.o strerror.o setenv.o" \ LIB_SRC="getent.c strerror.c setenv.c" \ AR=ar ARFLAGS=cq RANLIB=NONE \ LIBEXEC=${DESTDIR}/usr/etc/in.telnetd \ CC="${CC} -cckr" LCCFLAGS="$(OPTIMIZE)" irix5: ${MAKE} -f Makefile.generic ${WHAT} \ LIBS="${SOCKS_LIB} -lcurses ../libtelnet/libtelnet.a" \ LIBPATH="../libtelnet/libtelnet.a" \ DEST=${DESTDIR}/usr/ucb \ DEFINES="-Dvfork=fork -DSYSV_TERMIO \ -DKLUDGELINEMODE -DSTREAMS \ -DAUTHENTICATE \ -DDIAGNOSTICS $(SOCKS) " \ INCLUDES="-I.." \ LIB_OBJ="getent.o strerror.o setenv.o" \ LIB_SRC="getent.c strerror.c setenv.c" \ AR=ar ARFLAGS=cq RANLIB=NONE \ LIBEXEC=${DESTDIR}/usr/etc/in.telnetd \ CC="${CC} -cckr" LCCFLAGS="$(OPTIMIZE)" # <<< Ian Dunkin # >>> Ken Shackelford # hpux9: ${MAKE} -f Makefile.generic ${WHAT} \ LIBS="${SOCKS_LIB} -ltermlib -L../libtelnet -ltelnet ${RESOLV_LIB}" \ LIBPATH="/lib/libc.a /usr/lib/libtermlib.a \ ../libtelnet/libtelnet.a" \ DEST=${DESTDIR}/usr/ucb \ DEFINES="-DKLUDGELINEMODE -DSYSV_TERMIO \ -Dhpux -DLINEMODE -DSTREAMS -DNO_LOGIN_P \ -DAUTHENTICATE $(SOCKS) -DDIAGNOSTICS" \ INCLUDES="-I.. -I../../include" \ LIB_OBJ="strcasecmp.o setenv.o getent.o" \ LIB_SRC="strcasecmp.c setenv.c getent.c" \ AR=ar ARFLAGS=cq RANLIB=NONE \ LIBEXEC=${DESTDIR}/etc \ CC="${CC}" LCCFLAGS="$(OPTIMIZE)" aix3.2: ${MAKE} -f Makefile.generic ${WHAT} \ LIBS="${SOCKS_LIB} -ltermcap -L../libtelnet -ltelnet -lbsd ${RESOLV_LIB}" \ LIBPATH="/lib/libc.a /usr/lib/libtermcap.a \ ../libtelnet/libtelnet.a" \ DEST=${DESTDIR}/usr/ucb \ DEFINES="-DKLUDGELINEMODE -DTERMCAP \ -Dunix -DLINEMODE -DSTREAMS \ -DAUTHENTICATE -DDIAGNOSTICS \ -DAIX -D_BSD -D_NONSTD_TYPES \ $(SOCKS) -D_NO_PROTO" \ INCLUDES="-I.. -I../../include" \ LIB_OBJ="setenv.o getent.o" \ LIB_SRC="setenv.c getent.c" \ AR=ar ARFLAGS=cq RANLIB=NONE \ LIBEXEC=${DESTDIR}/etc \ CC="${CC}" LCCFLAGS="$(OPTIMIZE)" alphaOSF: ${MAKE} -f Makefile.generic ${WHAT} \ LIBS="${SOCKS_LIB} -ltermlib ../libtelnet/libtelnet.a ${RESOLV_L IB} -lm" \ LIBPATH="/lib/libc.a /usr/lib/libtermlib.a \ ../libtelnet/libtelnet.a" \ DEFINES="-DLINEMODE -DTERMCAP $(SOCKS) \ -DKLUDGELINEMODE -DAUTHENTICATE -DDIAGNOSTICS " \ INCLUDES="-I.. -I../../include" \ LIB_OBJ="getent.o" \ LIB_SRC="getent.c" \ AR=ar ARFLAGS=cq RANLIB=ranlib \ LIBEXEC=${DESTDIR}/usr/etc \ CC="${CC}" LCCFLAGS="$(OPTIMIZE)" # <<< Ken Shackelford # <<< Craig Metz aix_ps2: ${MAKE} -f Makefile.generic ${WHAT} \ LIBS="${SOCKS_LIB} -ltermcap -L../libtelnet -ltelnet -lbsd ${RESOLV_LIB}" \ LIBPATH="/lib/libc.a /usr/lib/libtermcap.a \ ../libtelnet/libtelnet.a" \ DEST=${DESTDIR}/usr/ucb \ DEFINES="-DKLUDGELINEMODE -DTERMCAP \ -Dunix -DLINEMODE -DSTREAMS \ -DAUTHENTICATE -DDIAGNOSTICS \ -DAIX -D_BSD -D_NONSTD_TYPES \ $(SOCKS) \ -D_NO_PROTO -DAIX_PS2" \ INCLUDES="-I.. -I/usr/local/include" \ LIB_OBJ="setenv.o getent.o strcasecmp.o herror.o strdup.o" \ LIB_SRC="setenv.c getent.c strcasecmp.o herror.o strdup.o" \ AR=ar ARFLAGS=cq RANLIB=NONE \ LIBEXEC=${DESTDIR}/etc \ CC="${CC}" LCCFLAGS="$(OPTIMIZE)" # <<< Craig Metz # >>> Alain Mellan osf1.3: ${MAKE} -f Makefile.generic ${WHAT} \ LIBS="${SOCKS_LIB} -ltermlib ../libtelnet/libtelnet.a ${RESOLV_L IB} -lm" \ LIBPATH="/lib/libc.a /usr/lib/libtermlib.a \ ../libtelnet/libtelnet.a" \ DEFINES="-DLINEMODE -DTERMCAP \ -DKLUDGELINEMODE -DAUTHENTICATE -DDIAGNOSTICS " \ INCLUDES="-I.." \ LIB_OBJ="getent.o" \ LIB_SRC="getent.c" \ AR=ar ARFLAGS=cq RANLIB=ranlib \ LIBEXEC=${DESTDIR}/usr/etc \ CC="${CC}" LCCFLAGS="$(OPTIMIZE)" # <<< Alain Mellan solaris2.2 sun5.2: ${MAKE} -f Makefile.generic ${WHAT} \ LIBS="${SOCKS_LIB} -L../libtelnet -ltelnet ${RESOLV_LIB} -ltermlib" \ LIBPATH="/lib/libc.a \ ../libtelnet/libtelnet.a" \ DEST=${DESTDIR}/usr/ucb \ DEFINES="-DKLUDGELINEMODE -DSVR4 -DSYSV -DSYSV_TERMIO \ -DSOLARIS -DSTREAMS -DNO_LOGIN_P -DLINEMODE \ -Dindex=strchr -Drindex=strrchr $(SOCKS) " \ INCLUDES="-I.. -I../../include" \ LIB_OBJ="herror.o setenv.o getent.o" \ LIB_SRC="herror.c setenv.c getent.c" \ AR=ar ARFLAGS=cq RANLIB=NONE \ LIBEXEC=${DESTDIR}/etc \ CC="${CC}" LCCFLAGS="-g" # >>> curnutt@Stoner.COM (A. Bryan Curnutt) netbsd0.9: make -f Makefile.generic ${WHAT} \ LIBS="${SOCKS_LIB} -lutil -ltermcap ../libtelnet/libtelnet.a $(RESOLV_LIB)" \ LIBPATH="/usr/lib/libc.a /usr/lib/libtermcap.a \ ../libtelnet/libtelnet.a" \ DEST=${DESTDIR}/usr/bin \ DEFINES="-DLINEMODE -DTERMCAP -DKLUDGELINEMODE \ -DUSE_TERMIO -DDIAGNOSTICS $(SOCKS) " \ INCLUDES="-I.. -I../../include" \ LIB_OBJ="gettytab.o" \ LIB_SRC="gettytab.c" \ AR=ar ARFLAGS=cq RANLIB=ranlib \ VPATH=/usr/src/libexec/getty \ LIBEXEC=${DESTDIR}/usr/libexec \ CC="${CC}" LCCFLAGS="$(OPTIMIZE)" freebsd1.1: make -f Makefile.generic ${WHAT} \ LIBS="${SOCKS_LIB} -lutil -ltermcap ../libtelnet/libtelnet.a $(RESOLV_LIB)" \ LIBPATH="/usr/lib/libc.a /usr/lib/libtermcap.a \ ../libtelnet/libtelnet.a" \ DEST=${DESTDIR}/usr/bin \ DEFINES="-DLINEMODE -DTERMCAP -DKLUDGELINEMODE \ -DUSE_TERMIO -DDIAGNOSTICS $(SOCKS) " \ INCLUDES="-I.. -I../../include" \ AR=ar ARFLAGS=cq RANLIB=ranlib \ VPATH=/usr/src/libexec/getty \ LIBEXEC=${DESTDIR}/usr/libexec \ CC="${CC}" LCCFLAGS="$(OPTIMIZE)" # DG/UX 5.4 dgux5.4: ${MAKE} -f Makefile.generic ${WHAT} \ LIBS="${SOCKS_LIB} -lcurses -lnsl -lc \ ../libtelnet/libtelnet.a" \ LIBPATH="/usr/sde/m88kdgux/usr/lib/libc.a /usr/lib/libcurses.a \ /usr/lib/libnsl.a \ ../libtelnet/libtelnet.a" \ DEST=${DESTDIR}/usr/bin \ DEFINES="-DUSE_TERMIO \ -DKLUDGELINEMODE -DSTREAMS \ -DAUTHENTICATE \ -DDIAGNOSTICS $(SOCKS) " \ INCLUDES="-I.. -I../../include" \ AR=ar ARFLAGS=cq RANLIB=NONE \ LIBEXEC=${DESTDIR}/usr/bin/telnetd \ CC="${CC}" LCCFLAGS="$(OPTIMIZE)" # <<< curnutt@Stoner.COM (A. Bryan Curnutt) # >>> Cornell Kinderknecht linux: ${MAKE} -f Makefile.generic ${WHAT} \ LIBS="${SOCKS_LIB} ../libtelnet/libtelnet.a ${RESOLV_LIB} \ -ltermcap -lbsd" \ LIBPATH="/usr/lib/libc.a /usr/lib/libtermcap.a \ ../libtelnet/libtelnet.a /usr/lib/libbsd.a" \ DEST=${DESTDIR}/usr/ucb \ DEFINES="-DLINUX \ -DTERMCAP -DUSE_TERMIO $(SOCKS) \ -DDIAGNOSTICS -DKLUDGELINEMODE" \ INCLUDES="-include /usr/include/bsd/bsd.h -I.. -I../../include -I/usr/include/bsd" \ LIB_OBJ="getent.o" \ LIB_SRC="getent.c" \ AR=ar ARFLAGS=rc RANLIB=ranlib \ LIBEXEC=${DESTDIR}/usr/etc/in.telnetd \ CC="${CC}" LCCFLAGS="-g" # <<< Cornell Kinderknecht # >>> Pax@metrolink.com UnixWare: make -f Makefile.generic ${WHAT} \ LIBS="${SOCKS_LIB} -L../libtelnet -ltelnet ${RESOLV_LIB} -ltermlib -lc -L/usr/ucblib -lucb" \ LIBPATH="/usr/ccs/lib/libc.a \ ../libtelnet/libtelnet.a" \ DEST=${DESTDIR}/usr/ucb \ DEFINES="-DSOLARIS -DFILIO_H -DUSE_TERMIO \ -DKLUDGELINEMODE -DSTREAMS \ -DDIAGNOSTICS $(SOCKS) " \ INCLUDES="-I.. -I../../include" \ LIB_OBJ="getent.o strerror.o setenv.o herror.o" \ LIB_SRC="getent.c strerror.c setenv.c herror.c" \ AR=ar ARFLAGS=cq RANLIB=ranlib \ LIBEXEC=${DESTDIR}/usr/etc/in.telnetd \ CC="${CC}" LCCFLAGS="$(OPTIMIZE)" # <<< Pax@metrolink.com # >>> fadden@uts.amdahl.com (Andy McFadden) # ATM: Amdahl UTS2.1 uts2.1: ${MAKE} -f Makefile.generic ${WHAT} \ LIBS="${SOCKS_LIB} -lcurses -lsocket -la -lc \ -lbsd ../libtelnet/libtelnet.a" \ LIBPATH="/lib/libc.a /usr/lib/libcurses.a \ /usr/lib/libsocket.a \ /usr/lib/liba.a \ /usr/lib/libbsd.a \ ../libtelnet/libtelnet.a" \ DEST=${DESTDIR}/usr/ucb \ DEFINES=" -DKLUDGELINEMODE -DSTREAMS \ -DAUTHENTICATE \ -DSYSV_TERMIO -DUSE_TERMIO -DTERMCAP \ -DDIAGNOSTICS $(SOCKS) " \ INCLUDES="-I.. -I../../include" \ LIB_OBJ="herror.o" \ LIB_SRC="herror.c" \ AR=ar ARFLAGS=cq RANLIB=NONE \ LIBEXEC=${DESTDIR}/usr/etc/in.telnetd \ CC="${CC} $(EFT)" LCCFLAGS="$(OPTIMIZE)" # ATM: Amdahl UTS4.x uts4: ${MAKE} -f Makefile.generic ${WHAT} \ LIBS="${SOCKS_LIB} -lcurses -lsocket -lnsl -lresolv -lc \ -L/usr/ucblib -lucb ../libtelnet/libtelnet.a" \ LIBPATH="/usr/ccs/lib/libc.a /usr/ccs/lib/libcurses.a \ /usr/lib/libsocket.a \ /usr/lib/libnsl.a \ /usr/lib/libresolv.a \ /usr/ucblib/libucb.a \ ../libtelnet/libtelnet.a" \ DEST=${DESTDIR}/usr/ucb \ DEFINES="-DSYSV_TERMIO \ -DFILIO_H \ -DKLUDGELINEMODE -DSTREAMS \ -DAUTHENTICATE \ -DDIAGNOSTICS $(SOCKS) " \ INCLUDES="-I.. -I../../include" \ AR=ar ARFLAGS=cq RANLIB=NONE \ LIBEXEC=${DESTDIR}/usr/etc/in.telnetd \ CC="${CC}" LCCFLAGS="$(OPTIMIZE)" # <<< fadden@uts.amdahl.com (Andy McFadden) # >>> chris.riney@tandy.com sco: make -f Makefile.generic ${WHAT} \ LIBS="${SOCKS_LIB} -L../libtelnet -ltelnet ${RESOLV_LIB} -ltermlib" \ LIBPATH="/lib/libc.a \ ../libtelnet/libtelnet.a" \ DEST=${DESTDIR}/usr/ucb \ DEFINES="-DSCO -DSVR3 -DTERMCAP -DUSE_TERMIO \ -DKLUDGELINEMODE -DSTREAMS \ -DAUTHENTICATE -DENCRYPT \ -DDIAGNOSTICS $(SOCKS) " \ INCLUDES="-I.. -I../../include" \ LIB_OBJ="" \ LIB_SRC="" \ AR=ar ARFLAGS=rc RANLIB=echo \ LIBEXEC=${DESTDIR}/usr/etc/in.telnetd \ CC="${CC}" LCCFLAGS="$(OPTIMIZE)" bsdi: ${MAKE} -f Makefile.generic ${WHAT} \ LIBS="${SOCKS_LIB} -ltermcap ../libtelnet/libtelnet.a \ ${RESOLV_LV_LIB}" \ LIBPATH="/lib/libc.a /usr/lib/libtermcap.a \ ../libtelnet/libtelnet.a" \ DEST=${DESTDIR}/usr/bin \ DEFINES="-DTERMCAP -DKLUDGELINEMODE \ -DUSE_TERMIO -DDIAGNOSTICS $(SOCKS) " \ INCLUDES="-I.. -I../../include" \ AR=ar ARFLAGS=cq RANLIB=ranlib \ LIBEXEC=${DESTDIR}/etc \ CC="${CC}" LCCFLAGS="$(OPTIMIZE)" # <<< chris.riney@tandy.com # >>>Larry Jones isc: $(MAKE) -f Makefile.generic ${WHAT} \ LIBS="${SOCKS_LIB} -lcurses ../libtelnet/libtelnet.a \ ${RESOLV_LIB}" \ LIBPATH="../libtelnet/libtelnet.a" \ DEST=${DESTDIR}/usr/local/bin \ DEFINES="-Dvfork=fork -DSYSV_TERMIO \ -DNO_CC_T -DSVR3 -DISC \ -DKLUDGELINEMODE -DSTREAMS \ -DAUTHENTICATE \ -DDIAGNOSTICS ${SOCKS}" \ INCLUDES="-I.. -I../../include" \ LIB_OBJ="" \ LIB_SRC="" \ AR=ar ARFLAGS=rc RANLIB=NONE \ LIBEXEC=${DESTDIR}/usr/local/bin \ CC="${CC}" LCCFLAGS="$(OPTIMIZE)" # <<< Larry Jones clean cleandir: make -f Makefile.generic $@ socks4-server-4.3.beta2.orig/rtelnet/Makefile100640 7657 764 2264 6020677057 17526 0ustar martinedv# DO NOT start 'make' in this directory. Go to the top # directory of the SOCKS package and do it from there! #======================================================= all: echocwd cd libtelnet; $(MAKE) $(OS) CC="$(CC)" OTHER_CFLAGS="$(OTHER_CFLAGS)" SOCKS="$(SOCKS)" SOCKS_LIB=$(SOCKS_LIB) RESOLV_LIB="$(RESOLV_LIB)" OPTIMIZE="$(OPTIMIZE)" cd telnet; $(MAKE) $(OS) CC="$(CC)" OTHER_CFLAGS="$(OTHER_CFLAGS)" SOCKS="$(SOCKS)" SOCKS_LIB=$(SOCKS_LIB) RESOLV_LIB="$(RESOLV_LIB)" OPTIMIZE="$(OPTIMIZE)" install: echocwd rtelnet $(INSTALL) -s -o bin -g bin -m 111 rtelnet $(CLIENTS_BIN_DIR) install.man: echocwd $(INSTALL) -m 444 ../doc/socks_clients.1 $(MAN_DEST_DIR)/man1 $(INSTALL) -m 444 ../doc/socks.conf.5 $(MAN_DEST_DIR)/man5 $(INSTALL) -m 444 ../doc/rtelnet.1 $(MAN_DEST_DIR)/man1 $(INSTALL) -m 444 telnet/telnet.1 $(MAN_DEST_DIR)/man1 clean: echocwd rm -f rtelnet cd libtelnet; $(MAKE) -f Makefile.generic clean cd telnet; $(MAKE) -f Makefile.generic clean echocwd: @pwd .DEFAULT: cd libtelnet; $(MAKE) $(OS) WHAT=$(WHAT) CC="$(CC)" SOCKS_LIB=$(SOCKS_LIB) RESOLV_LIB="$(RESOLV_LIB)" cd telnet; $(MAKE) $(OS) WHAT=$(WHAT) CC="$(CC)" SOCKS_LIB=$(SOCKS_LIB) RESOLV_LIB="$(RESOLV_LIB)" socks4-server-4.3.beta2.orig/rtelnet/README100640 7657 764 50466 5606334315 16771 0ustar martinedv This is a distribution of both client and server telnet. These programs have been compiled on: telnet telnetd BSD 4.3 Reno X X UNICOS 5.1 X X UNICOS 6.0 X X UNICOS 6.1 X X UNICOS 7.0 X X SunOs 3.5 X X (no linemode in server) SunOs 4.1 X X (no linemode in server) DYNIX V3.0.17.9 X X (no linemode in server) Ultrix 3.1 X X (no linemode in server) Ultrix 4.0 X X (no linemode in server) In addition, previous versions have been compiled on the following machines, but were not available for testing this version. telnet telnetd Next1.0 X X UNICOS 5.0 X X SunOs 4.0.3c X X (no linemode in server) BSD 4.3 X X (no linemode in server) DYNIX V3.0.12 X X (no linemode in server) Februrary 22, 1991: Features: This version of telnet/telnetd has support for both the AUTHENTICATION and ENCRYPTION options. The AUTHENTICATION option is fairly well defined, and an option number has been assigned to it. The ENCRYPTION option is still in a state of flux; an option number has been assigned to, but it is still subject to change. The code is provided in this release for experimental and testing purposes. The telnet "send" command can now be used to send do/dont/will/wont commands, with any telnet option name. The rules for when do/dont/will/wont are sent are still followed, so just because the user requests that one of these be sent doesn't mean that it will be sent... The telnet "getstatus" command no longer requires that option printing be enabled to see the response to the "DO STATUS" command. A -n flag has been added to telnetd to disable keepalives. A new telnet command, "auth" has been added (if AUTHENTICATE is defined). It has four sub-commands, "status", "disable", "enable" and "help". A new telnet command, "encrypt" has been added (if ENCRYPT is defined). It has many sub-commands: "enable", "type", "start", "stop", "input", "-input", "output", "-output", "status", and "help". The LOGOUT option is now supported by both telnet and telnetd, a new command, "logout", was added to support this. Several new toggle options were added: "autoencrypt", "autodecrypt", "autologin", "authdebug", "encdebug", "skiprc", "verbose_encrypt" An "rlogin" interface has been added. If the program is named "rlogin", or the "-r" flag is given, then an rlogin type of interface will be used. ~. Terminates the session ~ Suspend the session ~^] Escape to telnet command mode ~~ Pass through the ~. BUG: If you type the rlogin escape character in the middle of a line while in rlogin mode, you cannot erase it or any characters before it. Hopefully this can be fixed in a future release... General changes: A "libtelnet.a" has now been created. This libraray contains code that is common to both telnet and telnetd. This is also where library routines that are needed, but are not in the standard C library, are placed. The makefiles have been re-done. All of the site specific configuration information has now been put into a single "Config.generic" file, in the top level directory. Changing this one file will take care of all three subdirectories. Also, to add a new/local definition, a "Config.local" file may be created at the top level; if that file exists, the subdirectories will use that file instead of "Config.generic". Many 1-2 line functions in commands.c have been removed, and just inserted in-line, or replaced with a macro. Bug Fixes: The non-termio code in both telnet and telnetd was setting/clearing CTLECH in the sg_flags word. This was incorrect, and has been changed to set/clear the LCTLECH bit in the local mode word. The SRCRT #define has been removed. If IP_OPTIONS and IPPROTO_IP are defined on the system, then the source route code is automatically enabled. The NO_GETTYTAB #define has been removed; there is a compatability routine that can be built into libtelnet to achive the same results. The server, telnetd, has been switched to use getopt() for parsing the argument list. The code for getting the input/output speeds via cfgetispeed()/cfgetospeed() was still not quite right in telnet. Posix says if the ispeed is 0, then it is really equal to the ospeed. The suboption processing code in telnet now has explicit checks to make sure that we received the entire suboption (telnetd was already doing this). The telnet code for processing the terminal type could cause a core dump if an existing connection was closed, and a new connection opened without exiting telnet. Telnetd was doing a TCSADRAIN when setting the new terminal settings; This is not good, because it means that the tcsetattr() will hang waiting for output to drain, and telnetd is the only one that will drain the output... The fix is to use TCSANOW which does not wait. Telnetd was improperly setting/clearing the ISTRIP flag in the c_lflag field, it should be using the c_iflag field. When the child process of telnetd was opening the slave side of the pty, it was re-setting the EXTPROC bit too early, and some of the other initialization code was wiping it out. This would cause telnetd to go out of linemode and into single character mode. One instance of leaving linemode in telnetd forgot to send a WILL ECHO to the client, the net result would be that the user would see double character echo. If the MODE was being changed several times very quickly, telnetd could get out of sync with the state changes and the returning acks; and wind up being left in the wrong state. September 14, 1990: Switch the client to use getopt() for parsing the argument list. The 4.3Reno getopt.c is included for systems that don't have getopt(). Use the posix _POSIX_VDISABLE value for what value to use when disabling special characters. If this is undefined, it defaults to 0x3ff. For non-termio systems, TIOCSETP was being used to change the state of the terminal. This causes the input queue to be flushed, which we don't want. This is now changed to TIOCSETN. Take out the "#ifdef notdef" around the code in the server that generates a "sync" when the pty oputput is flushed. The potential problem is that some older telnet clients may go into an infinate loop when they receive a "sync", if so, the server can be compiled with "NO_URGENT" defined. Fix the client where it was setting/clearing the OPOST bit in the c_lflag field, not the c_oflag field. Fix the client where it was setting/clearing the ISTRIP bit in the c_lflag field, not the c_iflag field. (On 4.3Reno, this is the ECHOPRT bit in the c_lflag field.) The client also had its interpretation of WILL BINARY and DO BINARY reversed. Fix a bug in client that would cause a core dump when attempting to remove the last environment variable. In the client, there were a few places were switch() was being passed a character, and if it was a negative value, it could get sign extended, and not match the 8 bit case statements. The fix is to and the switch value with 0xff. Add a couple more printoption() calls in the client, I don't think there are any more places were a telnet command can be received and not printed out when "options" is on. A new flag has been added to the client, "-a". Currently, this just causes the USER name to be sent across, in the future this may be used to signify that automatic authentication is requested. The USER variable is now only sent by the client if the "-a" or "-l user" options are explicity used, or if the user explicitly asks for the "USER" environment variable to be exported. In the server, if it receives the "USER" environment variable, it won't print out the banner message, so that only "Password:" will be printed. This makes the symantics more like rlogin, and should be more familiar to the user. (People are not used to getting a banner message, and then getting just a "Password:" prompt.) Re-vamp the code for starting up the child login process. The code was getting ugly, and it was hard to tell what was really going on. What we do now is after the fork(), in the child: 1) make sure we have no controlling tty 2) open and initialize the tty 3) do a setsid()/setpgrp() 4) makes the tty our controlling tty. On some systems, #2 makes the tty our controlling tty, and #4 is a no-op. The parent process does a gets rid of any controlling tty after the child is fork()ed. Use the strdup() library routine in telnet, instead of the local savestr() routine. If you don't have strdup(), you need to define NO_STRDUP. Add support for ^T (SIGINFO/VSTATUS), found in the 4.3Reno distribution. This maps to the AYT character. You need a 4-line bugfix in the kernel to get this to work properly: > *** tty_pty.c.ORG Tue Sep 11 09:41:53 1990 > --- tty_pty.c Tue Sep 11 17:48:03 1990 > *************** > *** 609,613 **** > if ((tp->t_lflag&NOFLSH) == 0) > ttyflush(tp, FREAD|FWRITE); > ! pgsignal(tp->t_pgrp, *(unsigned int *)data); > return(0); > } > --- 609,616 ---- > if ((tp->t_lflag&NOFLSH) == 0) > ttyflush(tp, FREAD|FWRITE); > ! pgsignal(tp->t_pgrp, *(unsigned int *)data, 1); > ! if ((*(unsigned int *)data == SIGINFO) && > ! ((tp->t_lflag&NOKERNINFO) == 0)) > ! ttyinfo(tp); > return(0); > } The client is now smarter when setting the telnet escape character; it only sets it to one of VEOL and VEOL2 if one of them is undefined, and the other one is not already defined to the telnet escape character. Handle TERMIOS systems that have seperate input and output line speed settings imbedded in the flags. Many other minor bug fixes. June 20, 1990: Re-organize makefiles and source tree. The telnet/Source directory is now gone, and all the source that was in telnet/Source is now just in the telnet directory. Seperate makefile for each system are now gone. There are two makefiles, Makefile and Makefile.generic. The "Makefile" has the definitions for the various system, and "Makefile.generic" does all the work. There is a variable called "WHAT" that is used to specify what to make. For example, in the telnet directory, you might say: make 4.4bsd WHAT=clean to clean out the directory. Add support for the ENVIRON and XDISPLOC options. In order for the server to work, login has to have the "-p" option to preserve environment variables. Add the SOFT_TAB and LIT_ECHO modes in the LINEMODE support. Add the "-l user" option to command line and open command (This is passed through the ENVIRON option). Add the "-e" command line option, for setting the escape character. Add the "-D", diagnostic, option to the server. This allows the server to print out debug information, which is very useful when trying to debug a telnet that doesn't have any debugging ability. Turn off the literal next character when not in LINEMODE. Don't recognize ^Y locally, just pass it through. Make minor modifications for Sun4.0 and Sun4.1 Add support for both FORW1 and FORW2 characters. The telnet escpape character is set to whichever of the two is not being used. If both are in use, the escape character is not set, so when in linemode the user will have to follow the escape character with a or libtelnet/Makefile.4.4: telnet/Makefile.4.4: telnetd/Makefile.4.4: These are the makefiles that can be used on a 4.3Reno system when this software is installed in /usr/src/lib/libtelnet, /usr/src/libexec/telnetd, and /usr/src/usr.bin/telnet. The following TELNET options are supported: LINEMODE: The LINEMODE option is supported as per RFC1116. The FORWARDMASK option is not currently supported. BINARY: The client has the ability to turn on/off the BINARY option in each direction. Turning on BINARY from server to client causes the LITOUT bit to get set in the terminal driver on both ends, turning on BINARY from the client to the server causes the PASS8 bit to get set in the terminal driver on both ends. TERMINAL-TYPE: This is supported as per RFC1091. On the server side, when a terminal type is received, termcap/terminfo is consulted to determine if it is a known terminal type. It keeps requesting terminal types until it gets one that it recongnizes, or hits the end of the list. The server side looks up the entry in the termcap/terminfo data base, and generates a list of names which it then passes one at a time to each request for a terminal type, duplicating the last entry in the list before cycling back to the beginning. NAWS: The Negotiate about Window Size, as per RFC 1073. TERMINAL-SPEED: Implemented as per RFC 1079 TOGGLE-FLOW-CONTROL: Implemented as per RFC 1080 TIMING-MARK: As per RFC 860 SGA: As per RFC 858 ECHO: As per RFC 857 LOGOUT: As per RFC 727 STATUS: The server will send its current status upon request. It does not ask for the clients status. The client will request the servers current status from the "send getstatus" command. ENVIRON: This option is currently being defined by the IETF Telnet Working Group, and an RFC has not yet been issued, but should be in the near future... X-DISPLAY-LOCATION: This functionality can be done through the ENVIRON option, it is added here for completeness. AUTHENTICATION: This option is currently being defined by the IETF Telnet Working Group, and an RFC has not yet been issued. The basic framework is pretty much decided, but the definitions for the specific authentication schemes is still in a state of flux. ENCRYPT: This option is currently being defined by the IETF Telnet Working Group, and an RFC has not yet been issued. The draft RFC is still in a state of flux, so this code may change in the future. socks4-server-4.3.beta2.orig/rtelnet/arpa/ 40755 7657 764 0 5767344117 16721 5ustar martinedvsocks4-server-4.3.beta2.orig/rtelnet/arpa/telnet.h100640 7657 764 21701 5606334276 20474 0ustar martinedv/* * Copyright (c) 1983 Regents of the University of California. * All rights reserved. * * Redistribution and use in source and binary forms are permitted provided * that: (1) source distributions retain this entire copyright notice and * comment, and (2) distributions including binaries display the following * acknowledgement: ``This product includes software developed by the * University of California, Berkeley and its contributors'' in the * documentation or other materials provided with the distribution and in * all advertising materials mentioning features or use of this software. * Neither the name of the University nor the names of its contributors may * be used to endorse or promote products derived from this software without * specific prior written permission. * THIS SOFTWARE IS PROVIDED ``AS IS'' AND WITHOUT ANY EXPRESS OR IMPLIED * WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED WARRANTIES OF * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. * * @(#)telnet.h 5.12 (Berkeley) 3/5/91 */ /* * Definitions for the TELNET protocol. */ #define IAC 255 /* interpret as command: */ #define DONT 254 /* you are not to use option */ #define DO 253 /* please, you use option */ #define WONT 252 /* I won't use option */ #define WILL 251 /* I will use option */ #define SB 250 /* interpret as subnegotiation */ #define GA 249 /* you may reverse the line */ #define EL 248 /* erase the current line */ #define EC 247 /* erase the current character */ #define AYT 246 /* are you there */ #define AO 245 /* abort output--but let prog finish */ #define IP 244 /* interrupt process--permanently */ #define BREAK 243 /* break */ #define DM 242 /* data mark--for connect. cleaning */ #define NOP 241 /* nop */ #define SE 240 /* end sub negotiation */ #define EOR 239 /* end of record (transparent mode) */ #define ABORT 238 /* Abort process */ #define SUSP 237 /* Suspend process */ #define xEOF 236 /* End of file: EOF is already used... */ #define SYNCH 242 /* for telfunc calls */ #ifdef TELCMDS char *telcmds[] = { "EOF", "SUSP", "ABORT", "EOR", "SE", "NOP", "DMARK", "BRK", "IP", "AO", "AYT", "EC", "EL", "GA", "SB", "WILL", "WONT", "DO", "DONT", "IAC", 0, }; #else extern char *telcmds[]; #endif #define TELCMD_FIRST xEOF #define TELCMD_LAST IAC #define TELCMD_OK(x) ((x) <= TELCMD_LAST && (x) >= TELCMD_FIRST) #define TELCMD(x) telcmds[(x)-TELCMD_FIRST] /* telnet options */ #define TELOPT_BINARY 0 /* 8-bit data path */ #define TELOPT_ECHO 1 /* echo */ #define TELOPT_RCP 2 /* prepare to reconnect */ #define TELOPT_SGA 3 /* suppress go ahead */ #define TELOPT_NAMS 4 /* approximate message size */ #define TELOPT_STATUS 5 /* give status */ #define TELOPT_TM 6 /* timing mark */ #define TELOPT_RCTE 7 /* remote controlled transmission and echo */ #define TELOPT_NAOL 8 /* negotiate about output line width */ #define TELOPT_NAOP 9 /* negotiate about output page size */ #define TELOPT_NAOCRD 10 /* negotiate about CR disposition */ #define TELOPT_NAOHTS 11 /* negotiate about horizontal tabstops */ #define TELOPT_NAOHTD 12 /* negotiate about horizontal tab disposition */ #define TELOPT_NAOFFD 13 /* negotiate about formfeed disposition */ #define TELOPT_NAOVTS 14 /* negotiate about vertical tab stops */ #define TELOPT_NAOVTD 15 /* negotiate about vertical tab disposition */ #define TELOPT_NAOLFD 16 /* negotiate about output LF disposition */ #define TELOPT_XASCII 17 /* extended ascic character set */ #define TELOPT_LOGOUT 18 /* force logout */ #define TELOPT_BM 19 /* byte macro */ #define TELOPT_DET 20 /* data entry terminal */ #define TELOPT_SUPDUP 21 /* supdup protocol */ #define TELOPT_SUPDUPOUTPUT 22 /* supdup output */ #define TELOPT_SNDLOC 23 /* send location */ #define TELOPT_TTYPE 24 /* terminal type */ #define TELOPT_EOR 25 /* end or record */ #define TELOPT_TUID 26 /* TACACS user identification */ #define TELOPT_OUTMRK 27 /* output marking */ #define TELOPT_TTYLOC 28 /* terminal location number */ #define TELOPT_3270REGIME 29 /* 3270 regime */ #define TELOPT_X3PAD 30 /* X.3 PAD */ #define TELOPT_NAWS 31 /* window size */ #define TELOPT_TSPEED 32 /* terminal speed */ #define TELOPT_LFLOW 33 /* remote flow control */ #define TELOPT_LINEMODE 34 /* Linemode option */ #define TELOPT_XDISPLOC 35 /* X Display Location */ #define TELOPT_ENVIRON 36 /* Environment variables */ #define TELOPT_AUTHENTICATION 37/* Authenticate */ #define TELOPT_ENCRYPT 38 /* Encryption option */ #define TELOPT_EXOPL 255 /* extended-options-list */ #define NTELOPTS (1+TELOPT_ENCRYPT) #ifdef TELOPTS char *telopts[NTELOPTS+1] = { "BINARY", "ECHO", "RCP", "SUPPRESS GO AHEAD", "NAME", "STATUS", "TIMING MARK", "RCTE", "NAOL", "NAOP", "NAOCRD", "NAOHTS", "NAOHTD", "NAOFFD", "NAOVTS", "NAOVTD", "NAOLFD", "EXTEND ASCII", "LOGOUT", "BYTE MACRO", "DATA ENTRY TERMINAL", "SUPDUP", "SUPDUP OUTPUT", "SEND LOCATION", "TERMINAL TYPE", "END OF RECORD", "TACACS UID", "OUTPUT MARKING", "TTYLOC", "3270 REGIME", "X.3 PAD", "NAWS", "TSPEED", "LFLOW", "LINEMODE", "XDISPLOC", "ENVIRON", "AUTHENTICATION", "ENCRYPT", 0, }; #define TELOPT_FIRST TELOPT_BINARY #define TELOPT_LAST TELOPT_ENCRYPT #define TELOPT_OK(x) ((x) <= TELOPT_LAST && (x) >= TELOPT_FIRST) #define TELOPT(x) telopts[(x)-TELOPT_FIRST] #endif /* sub-option qualifiers */ #define TELQUAL_IS 0 /* option is... */ #define TELQUAL_SEND 1 /* send option */ #define TELQUAL_INFO 2 /* ENVIRON: informational version of IS */ #define TELQUAL_REPLY 2 /* AUTHENTICATION: client version of IS */ #define TELQUAL_NAME 3 /* AUTHENTICATION: client version of IS */ /* * LINEMODE suboptions */ #define LM_MODE 1 #define LM_FORWARDMASK 2 #define LM_SLC 3 #define MODE_EDIT 0x01 #define MODE_TRAPSIG 0x02 #define MODE_ACK 0x04 #define MODE_SOFT_TAB 0x08 #define MODE_LIT_ECHO 0x10 #define MODE_MASK 0x1f /* Not part of protocol, but needed to simplify things... */ #define MODE_FLOW 0x0100 #define MODE_ECHO 0x0200 #define MODE_INBIN 0x0400 #define MODE_OUTBIN 0x0800 #define MODE_FORCE 0x1000 #define SLC_SYNCH 1 #define SLC_BRK 2 #define SLC_IP 3 #define SLC_AO 4 #define SLC_AYT 5 #define SLC_EOR 6 #define SLC_ABORT 7 #define SLC_EOF 8 #define SLC_SUSP 9 #define SLC_EC 10 #define SLC_EL 11 #define SLC_EW 12 #define SLC_RP 13 #define SLC_LNEXT 14 #define SLC_XON 15 #define SLC_XOFF 16 #define SLC_FORW1 17 #define SLC_FORW2 18 #define NSLC 18 /* * For backwards compatability, we define SLC_NAMES to be the * list of names if SLC_NAMES is not defined. */ #define SLC_NAMELIST "0", "SYNCH", "BRK", "IP", "AO", "AYT", "EOR", \ "ABORT", "EOF", "SUSP", "EC", "EL", "EW", "RP", \ "LNEXT", "XON", "XOFF", "FORW1", "FORW2", 0, #ifdef SLC_NAMES char *slc_names[] = { SLC_NAMELIST }; #else extern char *slc_names[]; #define SLC_NAMES SLC_NAMELIST #endif #define SLC_NAME_OK(x) ((x) >= 0 && (x) < NSLC) #define SLC_NAME(x) slc_names[x] #define SLC_NOSUPPORT 0 #define SLC_CANTCHANGE 1 #define SLC_VARIABLE 2 #define SLC_DEFAULT 3 #define SLC_LEVELBITS 0x03 #define SLC_FUNC 0 #define SLC_FLAGS 1 #define SLC_VALUE 2 #define SLC_ACK 0x80 #define SLC_FLUSHIN 0x40 #define SLC_FLUSHOUT 0x20 #define ENV_VALUE 0 #define ENV_VAR 1 #define ENV_ESC 2 /* * AUTHENTICATION suboptions */ /* * Who is authenticating who ... */ #define AUTH_WHO_CLIENT 0 /* Client authenticating server */ #define AUTH_WHO_SERVER 1 /* Server authenticating client */ #define AUTH_WHO_MASK 1 /* * amount of authentication done */ #define AUTH_HOW_ONE_WAY 0 #define AUTH_HOW_MUTUAL 2 #define AUTH_HOW_MASK 2 #define AUTHTYPE_NULL 0 #define AUTHTYPE_KERBEROS_V4 1 #define AUTHTYPE_KERBEROS_V5 2 #define AUTHTYPE_SPX 3 #define AUTHTYPE_MINK 4 #define AUTHTYPE_CNT 5 #define AUTHTYPE_TEST 99 #ifdef AUTH_NAMES char *authtype_names[] = { "NULL", "KERBEROS_V4", "KERBEROS_V5", "SPX", "MINK", 0, }; #else extern char *authtype_names[]; #endif #define AUTHTYPE_NAME_OK(x) ((x) >= 0 && (x) < AUTHTYPE_CNT) #define AUTHTYPE_NAME(x) authtype_names[x] /* * ENCRYPTion suboptions */ #define ENCRYPT_IS 0 /* I pick encryption type ... */ #define ENCRYPT_SUPPORT 1 /* I support encryption types ... */ #define ENCRYPT_REPLY 2 /* Initial setup response */ #define ENCRYPT_START 3 /* Am starting to send encrypted */ #define ENCRYPT_END 4 /* Am ending encrypted */ #define ENCRYPT_REQSTART 5 /* Request you start encrypting */ #define ENCRYPT_REQEND 6 /* Request you send encrypting */ #define ENCRYPT_ENC_KEYID 7 #define ENCRYPT_DEC_KEYID 8 #define ENCRYPT_CNT 9 #define ENCTYPE_ANY 0 #define ENCTYPE_DES_CFB64 1 #define ENCTYPE_DES_OFB64 2 #define ENCTYPE_CNT 3 #ifdef ENCRYPT_NAMES char *encrypt_names[] = { "IS", "SUPPORT", "REPLY", "START", "END", "REQUEST-START", "REQUEST-END", "ENC-KEYID", "DEC-KEYID", 0, }; char *enctype_names[] = { "ANY", "DES_CFB64", "DES_OFB64", 0, }; #else extern char *encrypt_names[]; extern char *enctype_names[]; #endif #define ENCRYPT_NAME_OK(x) ((x) >= 0 && (x) < ENCRYPT_CNT) #define ENCRYPT_NAME(x) encrypt_names[x] #define ENCTYPE_NAME_OK(x) ((x) >= 0 && (x) < ENCTYPE_CNT) #define ENCTYPE_NAME(x) enctype_names[x] socks4-server-4.3.beta2.orig/rtelnet/kern.diff100640 7657 764 17203 5606334315 17672 0ustar martinedv*** h/ioctl.h.old Tue May 23 14:50:42 1989 --- h/ioctl.h Tue Aug 29 18:24:49 1989 *************** *** 214,219 **** --- 214,220 ---- #define TIOCPKT_START 0x08 /* start output */ #define TIOCPKT_NOSTOP 0x10 /* no more ^S, ^Q */ #define TIOCPKT_DOSTOP 0x20 /* now do ^S ^Q */ + #define TIOCPKT_IOCTL 0x40 /* state change of pty driver */ #define TIOCSTOP _IO('t', 111) /* stop output, like ^S */ #define TIOCSTART _IO('t', 110) /* start output, like ^Q */ #define TIOCMSET _IOW('t', 109, int) /* set all modem bits */ *************** *** 226,231 **** --- 227,235 ---- #define TIOCUCNTL _IOW('t', 102, int) /* pty: set/clr usr cntl mode */ #define UIOCCMD(n) _IO('u', n) /* usr cntl op "n" */ #define TIOCCONS _IO('t', 98) /* become virtual console */ + #define TIOCEXT _IOW('t', 97, int) /* pty: external processing */ + #define TIOCGSTATE _IOR('t', 96, int) /* pty: get internal state */ + #define TIOCSIG _IO('t', 95) /* pty: generate signal */ #define OTTYDISC 0 /* old, v7 std tty driver */ #define NETLDISC 1 /* line discip for berk net */ *** h/tty.h.old Tue May 23 14:51:01 1989 --- h/tty.h Wed Aug 23 11:30:40 1989 *************** *** 70,75 **** --- 70,76 ---- struct ttychars t_chars; /* tty */ struct winsize t_winsize; /* window size */ /* be careful of tchars & co. */ + #ifndef NO_T_CHARS_DEFINES #define t_erase t_chars.tc_erase #define t_kill t_chars.tc_kill #define t_intrc t_chars.tc_intrc *************** *** 84,89 **** --- 85,91 ---- #define t_flushc t_chars.tc_flushc #define t_werasc t_chars.tc_werasc #define t_lnextc t_chars.tc_lnextc + #endif }; #define TTIPRI 28 *************** *** 124,129 **** --- 126,132 ---- #define TS_LNCH 0x080000 /* next character is literal */ #define TS_TYPEN 0x100000 /* retyping suspended input (PENDIN) */ #define TS_CNTTB 0x200000 /* counting tab width; leave FLUSHO alone */ + #define TS_EXTPROC 0x400000 /* external processing of data */ #define TS_LOCAL (TS_BKSL|TS_QUOT|TS_ERASE|TS_LNCH|TS_TYPEN|TS_CNTTB) *** sys/tty.c.old Tue May 23 14:52:28 1989 --- sys/tty.c Thu Aug 24 09:31:49 1989 *************** *** 275,280 **** --- 275,285 ---- */ switch (com) { + /* get internal state - needed for TS_EXTPROC bit */ + case TIOCGSTATE: + *(int *)data = tp->t_state; + break; + /* get discipline number */ case TIOCGETD: *(int *)data = tp->t_line; *************** *** 752,757 **** --- 757,763 ---- */ if ((tp->t_state&TS_TYPEN) == 0 && (t_flags&PASS8) == 0) c &= 0177; + if ((tp->t_state&TS_EXTPROC) == 0) { /* * Check for literal nexting very first */ *************** *** 834,839 **** --- 840,846 ---- else if (c == '\\') tp->t_state |= TS_BKSL; } + } /* * Cbreak mode, don't process line editing *************** *** 851,856 **** --- 858,864 ---- goto endcase; } + if ((tp->t_state&TS_EXTPROC) == 0) { /* * From here on down cooked mode character * processing takes place. *************** *** 911,916 **** --- 919,925 ---- goto endcase; } } + } /* * Check for input buffer overflow *************** *** 933,938 **** --- 942,948 ---- } else if (tp->t_rocount++ == 0) tp->t_rocol = tp->t_col; tp->t_state &= ~TS_QUOT; + if ((tp->t_state&TS_EXTPROC) == 0) { if (c == '\\') tp->t_state |= TS_QUOT; if (tp->t_state&TS_ERASE) { *************** *** 948,953 **** --- 958,964 ---- i--; } } + } } endcase: /* *************** *** 998,1005 **** return (-1); /* * Turn tabs to spaces as required */ ! if (c == '\t' && (tp->t_flags&TBDELAY) == XTABS) { register int s; c = 8 - (tp->t_col&7); --- 1009,1022 ---- return (-1); /* * Turn tabs to spaces as required + * + * Special case if we have external processing, we don't + * do the tab expansion because we'll probably get it + * wrong. If tab expansion needs to be done, let it + * happen externally. */ ! if ((tp->t_state&TS_EXTPROC) == 0 && ! c == '\t' && (tp->t_flags&TBDELAY) == XTABS) { register int s; c = 8 - (tp->t_col&7); *************** *** 1497,1503 **** int s; char *nextc(); ! if ((tp->t_flags&ECHO) == 0) return; tp->t_flags &= ~FLUSHO; c &= 0377; --- 1514,1520 ---- int s; char *nextc(); ! if ((tp->t_flags&ECHO) == 0 || (tp->t_state&TS_EXTPROC)) return; tp->t_flags &= ~FLUSHO; c &= 0377; *************** *** 1618,1624 **** if ((tp->t_state&TS_CNTTB) == 0) tp->t_flags &= ~FLUSHO; ! if ((tp->t_flags&ECHO) == 0) return; c &= 0377; if (tp->t_flags&RAW) { --- 1635,1641 ---- if ((tp->t_state&TS_CNTTB) == 0) tp->t_flags &= ~FLUSHO; ! if ((tp->t_flags&ECHO) == 0 || (tp->t_state&TS_EXTPROC)) return; c &= 0377; if (tp->t_flags&RAW) { *** sys/tty_pty.c.old Tue May 23 14:52:43 1989 --- sys/tty_pty.c Tue Aug 29 18:48:36 1989 *************** *** 208,213 **** --- 208,214 ---- return (EIO); tp->t_oproc = ptsstart; (void)(*linesw[tp->t_line].l_modem)(tp, 1); + tp->t_state &= ~TS_EXTPROC; pti = &pt_ioctl[minor(dev)]; pti->pt_flags = 0; pti->pt_send = 0; *************** *** 247,252 **** --- 248,275 ---- error = ureadc((int)pti->pt_send, uio); if (error) return (error); + if (pti->pt_send & TIOCPKT_IOCTL) { + struct xx { + struct sgttyb a; + struct tchars b; + struct ltchars c; + int d; + int e; + } cb; + cb.a.sg_ispeed = tp->t_ispeed; + cb.a.sg_ospeed = tp->t_ospeed; + cb.a.sg_erase = tp->t_erase; + cb.a.sg_kill = tp->t_kill; + cb.a.sg_flags = tp->t_flags; + bcopy((caddr_t)&tp->t_intrc, + (caddr_t)&cb.b, sizeof(cb.b)); + bcopy((caddr_t)&tp->t_suspc, + (caddr_t)&cb.c, sizeof(cb.c)); + cb.d = tp->t_state; + cb.e = ((unsigned)tp->t_flags)>>16; + cc = MIN(uio->uio_resid, sizeof(cb)); + uiomove(&cb, cc, UIO_READ, uio); + } pti->pt_send = 0; return (0); } *************** *** 483,488 **** --- 506,533 ---- * IF CONTROLLER STTY THEN MUST FLUSH TO PREVENT A HANG. * ttywflush(tp) will hang if there are characters in the outq. */ + if (cmd == TIOCEXT) { + /* + * When the TS_EXTPROC bit is being toggled, we need + * to send an TIOCPKT_IOCTL if the packet driver + * is turned on. + */ + if (*(int *)data) { + if (pti->pt_flags & PF_PKT) { + pti->pt_send |= TIOCPKT_IOCTL; + ptcwakeup(tp); + } + tp->t_state |= TS_EXTPROC; + } else { + if ((tp->t_state & TS_EXTPROC) && + (pti->pt_flags & PF_PKT)) { + pti->pt_send |= TIOCPKT_IOCTL; + ptcwakeup(tp); + } + tp->t_state &= ~TS_EXTPROC; + } + return (0); + } else if (cdevsw[major(dev)].d_open == ptcopen) switch (cmd) { *************** *** 525,530 **** --- 570,583 ---- while (getc(&tp->t_outq) >= 0) ; break; + + case TIOCSIG: + if (*(unsigned int *)data >= NSIG) + return(EINVAL); + if ((tp->t_flags&NOFLSH) == 0) + ttyflush(tp, FREAD|FWRITE); + gsignal(tp->t_pgrp, *(unsigned int *)data); + return(0); } error = ttioctl(tp, cmd, data, flag); /* *************** *** 549,554 **** --- 602,624 ---- return (0); } error = ENOTTY; + } + /* + * If external processing and packet mode send ioctl packet. + */ + if ((tp->t_state & TS_EXTPROC) && (pti->pt_flags & PF_PKT)) { + switch(cmd) { + case TIOCSETP: + case TIOCSETN: + case TIOCSETC: + case TIOCSLTC: + case TIOCLBIS: + case TIOCLBIC: + case TIOCLSET: + pti->pt_send |= TIOCPKT_IOCTL; + default: + break; + } } stop = (tp->t_flags & RAW) == 0 && tp->t_stopc == CTRL('s') && tp->t_startc == CTRL('q'); socks4-server-4.3.beta2.orig/rtelnet/libtelnet/ 40755 7657 764 0 6157332564 17755 5ustar martinedvsocks4-server-4.3.beta2.orig/rtelnet/libtelnet/Makefile100640 7657 764 5217 5606334276 21513 0ustar martinedv# # Copyright (c) 1991 The Regents of the University of California. # All rights reserved. # # Redistribution and use in source and binary forms are permitted provided # that: (1) source distributions retain this entire copyright notice and # comment, and (2) distributions including binaries display the following # acknowledgement: ``This product includes software developed by the # University of California, Berkeley and its contributors'' in the # documentation or other materials provided with the distribution and in # all advertising materials mentioning features or use of this software. # Neither the name of the University nor the names of its contributors may # be used to endorse or promote products derived from this software without # specific prior written permission. # THIS SOFTWARE IS PROVIDED ``AS IS'' AND WITHOUT ANY EXPRESS OR IMPLIED # WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED WARRANTIES OF # MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. # # @(#)Makefile 5.5 (Berkeley) 3/1/91 # # # Everything happens in ../Makefile.config and Makefile.generic # SOCKS=-DSOCKS # or #SOCKS=-Dconnect=Rconnect -Dgetsockname=Rgetsockname -Dlisten=Rlisten -Daccept=Raccept -Drcmd=Rrcmd -Dbind=Rbind -Dselect=Rselect SOCKS_LIB=../../lib/libsocks.a #RESOLV_LIB=-lresolv all: @-if [ -f ../Config.local ]; \ then \ echo ${MAKE} -f ../Config.local WHAT=${WHAT} CC="${CC}" \ OPTIMIZE="${OPTIMIZE}" SOCKS="${SOCKS}" \ SOCKS_LIB=${SOCKS_LIB} RESOLV_LIB="${RESOLV_LIB}" ;\ ${MAKE} -f ../Config.local WHAT=${WHAT} CC="${CC}" \ OPTIMIZE="${OPTIMIZE}" SOCKS="${SOCKS}" \ SOCKS_LIB=${SOCKS_LIB} RESOLV_LIB="${RESOLV_LIB}" ;\ else \ echo ${MAKE} -f ../Config.generic WHAT=${WHAT} CC="${CC}" \ OPTIMIZE="${OPTIMIZE}" SOCKS="${SOCKS}" \ SOCKS_LIB=${SOCKS_LIB} RESOLV_LIB="${RESOLV_LIB}" ;\ ${MAKE} -f ../Config.generic WHAT=${WHAT} CC="${CC}" \ OPTIMIZE="${OPTIMIZE}" SOCKS="${SOCKS}" \ SOCKS_LIB=${SOCKS_LIB} RESOLV_LIB="${RESOLV_LIB}" ;\ fi .DEFAULT: @-if [ -f ../Config.local ]; \ then \ echo ${MAKE} -f ../Config.local WHAT=${WHAT} CC="${CC}" \ OPTIMIZE="${OPTIMIZE}" SOCKS="${SOCKS}" \ SOCKS_LIB=${SOCKS_LIB} RESOLV_LIB="${RESOLV_LIB}" $@;\ ${MAKE} -f ../Config.local WHAT=${WHAT} CC="${CC}" \ OPTIMIZE="${OPTIMIZE}" SOCKS="${SOCKS}" \ SOCKS_LIB=${SOCKS_LIB} RESOLV_LIB="${RESOLV_LIB}" $@;\ else \ echo ${MAKE} -f ../Config.generic WHAT=${WHAT} CC="${CC}" \ OPTIMIZE="${OPTIMIZE}" SOCKS="${SOCKS}" \ SOCKS_LIB=${SOCKS_LIB} RESOLV_LIB="${RESOLV_LIB}" $@;\ ${MAKE} -f ../Config.generic WHAT=${WHAT} CC="${CC}" \ OPTIMIZE="${OPTIMIZE}" SOCKS="${SOCKS}" \ SOCKS_LIB=${SOCKS_LIB} RESOLV_LIB="${RESOLV_LIB}" $@;\ fi socks4-server-4.3.beta2.orig/rtelnet/libtelnet/Makefile.4.4100640 7657 764 662 5606334277 21777 0ustar martinedv# # Copyright (c) 1991 The Regents of the University of California. # All rights reserved. # # %sccs.include.redist.sh # # @(#)Makefile 5.3 (Berkeley) 3/22/91 # LIB= telnet SRCS= auth.c encrypt.c genget.c getent.c gettytab.c misc.c SRCS+= kerberos.c enc_des.c #SRCS+= kerberos5.c CFLAGS+= -DENCRYPT -DAUTHENTICATE CFLAGS+= -DKRB4 -DDES_ENCRYPT -I/usr/include/kerberosIV .PATH: ${.CURDIR}/../../libexec/getty .include socks4-server-4.3.beta2.orig/rtelnet/libtelnet/Makefile.generic100640 7657 764 3731 5606334276 23125 0ustar martinedv# # Copyright (c) 1991 The Regents of the University of California. # All rights reserved. # # Redistribution and use in source and binary forms are permitted provided # that: (1) source distributions retain this entire copyright notice and # comment, and (2) distributions including binaries display the following # acknowledgement: ``This product includes software developed by the # University of California, Berkeley and its contributors'' in the # documentation or other materials provided with the distribution and in # all advertising materials mentioning features or use of this software. # Neither the name of the University nor the names of its contributors may # be used to endorse or promote products derived from this software without # specific prior written permission. # THIS SOFTWARE IS PROVIDED ``AS IS'' AND WITHOUT ANY EXPRESS OR IMPLIED # WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED WARRANTIES OF # MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. # # @(#)Makefile.generic 5.5 (Berkeley) 3/1/91 # LIB= libtelnet.a SRCS= auth.c encrypt.c genget.c \ misc.c enc_des.c \ setenv.c getent.c strdup.c strcasecmp.c \ strchr.c strrchr.c strftime.c strerror.c \ ${LIB_SRC} OBJS= auth.o encrypt.o genget.o \ misc.o enc_des.o \ ${LIB_OBJ} TELNET_H= ../arpa/telnet.h CFLAGS= ${LCCFLAGS} ${DEFINES} ${INCLUDES} ${LIB}: ${OBJS} rm -f ${LIB} # ${AR} ${ARFLAGS} ${LIB} `lorder ${OBJS} | tsort` ${AR} ${ARFLAGS} ${LIB} ${OBJS} @if [ ${RANLIB} != NONE ]; \ then echo ${RANLIB} ${LIB}; ${RANLIB} ${LIB}; fi clean cleandir: rm -f *.o ${LIB} core a.out auth.o: ${TELNET_H} auth.o: encrypt.h auth.o: auth.h auth.o: misc-proto.h encrypt.o: ${TELNET_H} encrypt.o: encrypt.h encrypt.o: misc.h kerberos.o: ${TELNET_H} kerberos.o: encrypt.h kerberos.o: auth.h kerberos.o: misc.h kerberos5.o: ${TELNET_H} kerberos5.o: encrypt.h kerberos5.o: auth.h kerberos5.o: misc.h misc.o: misc.h enc_des.o: ${TELNET_H} enc_des.o: encrypt.h enc_des.o: key-proto.h enc_des.o: misc-proto.h socks4-server-4.3.beta2.orig/rtelnet/libtelnet/auth-proto.h100640 7657 764 6465 5606334277 22335 0ustar martinedv/*- * Copyright (c) 1991 The Regents of the University of California. * All rights reserved. * * Redistribution and use in source and binary forms are permitted provided * that: (1) source distributions retain this entire copyright notice and * comment, and (2) distributions including binaries display the following * acknowledgement: ``This product includes software developed by the * University of California, Berkeley and its contributors'' in the * documentation or other materials provided with the distribution and in * all advertising materials mentioning features or use of this software. * Neither the name of the University nor the names of its contributors may * be used to endorse or promote products derived from this software without * specific prior written permission. * THIS SOFTWARE IS PROVIDED ``AS IS'' AND WITHOUT ANY EXPRESS OR IMPLIED * WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED WARRANTIES OF * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. * * @(#)auth-proto.h 5.1 (Berkeley) 2/28/91 */ /* * Copyright (C) 1990 by the Massachusetts Institute of Technology * * Export of this software from the United States of America is assumed * to require a specific license from the United States Government. * It is the responsibility of any person or organization contemplating * export to obtain such a license before exporting. * * WITHIN THAT CONSTRAINT, permission to use, copy, modify, and * distribute this software and its documentation for any purpose and * without fee is hereby granted, provided that the above copyright * notice appear in all copies and that both that copyright notice and * this permission notice appear in supporting documentation, and that * the name of M.I.T. not be used in advertising or publicity pertaining * to distribution of the software without specific, written prior * permission. M.I.T. makes no representations about the suitability of * this software for any purpose. It is provided "as is" without express * or implied warranty. */ #if !defined(P) #ifdef __STDC__ #define P(x) x #else #define P(x) () #endif #endif #if defined(AUTHENTICATE) Authenticator *findauthenticator P((int, int)); void auth_init P((char *, int)); int auth_cmd P((int, char **)); void auth_request P((void)); void auth_send P((unsigned char *, int)); void auth_send_retry P((void)); void auth_is P((unsigned char *, int)); void auth_reply P((unsigned char *, int)); void auth_finished P((Authenticator *, int)); int auth_wait P((char *)); void auth_disable_name P((char *)); void auth_gen_printsub P((unsigned char *, int, unsigned char *, int)); #ifdef KRB4 int kerberos4_init P((Authenticator *, int)); int kerberos4_send P((Authenticator *)); void kerberos4_is P((Authenticator *, unsigned char *, int)); void kerberos4_reply P((Authenticator *, unsigned char *, int)); int kerberos4_status P((Authenticator *, char *, int)); void kerberos4_printsub P((unsigned char *, int, unsigned char *, int)); #endif #ifdef KRB5 int kerberos5_init P((Authenticator *, int)); int kerberos5_send P((Authenticator *)); void kerberos5_is P((Authenticator *, unsigned char *, int)); void kerberos5_reply P((Authenticator *, unsigned char *, int)); int kerberos5_status P((Authenticator *, char *, int)); void kerberos5_printsub P((unsigned char *, int, unsigned char *, int)); #endif #endif socks4-server-4.3.beta2.orig/rtelnet/libtelnet/auth.c100640 7657 764 31545 5606334277 21204 0ustar martinedv/* * Copyright (c) 1991 The Regents of the University of California. * All rights reserved. * * Redistribution and use in source and binary forms are permitted provided * that: (1) source distributions retain this entire copyright notice and * comment, and (2) distributions including binaries display the following * acknowledgement: ``This product includes software developed by the * University of California, Berkeley and its contributors'' in the * documentation or other materials provided with the distribution and in * all advertising materials mentioning features or use of this software. * Neither the name of the University nor the names of its contributors may * be used to endorse or promote products derived from this software without * specific prior written permission. * THIS SOFTWARE IS PROVIDED ``AS IS'' AND WITHOUT ANY EXPRESS OR IMPLIED * WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED WARRANTIES OF * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. */ #ifndef lint static char sccsid[] = "@(#)auth.c 5.1 (Berkeley) 2/28/91"; #endif /* not lint */ /* * Copyright (C) 1990 by the Massachusetts Institute of Technology * * Export of this software from the United States of America is assumed * to require a specific license from the United States Government. * It is the responsibility of any person or organization contemplating * export to obtain such a license before exporting. * * WITHIN THAT CONSTRAINT, permission to use, copy, modify, and * distribute this software and its documentation for any purpose and * without fee is hereby granted, provided that the above copyright * notice appear in all copies and that both that copyright notice and * this permission notice appear in supporting documentation, and that * the name of M.I.T. not be used in advertising or publicity pertaining * to distribution of the software without specific, written prior * permission. M.I.T. makes no representations about the suitability of * this software for any purpose. It is provided "as is" without express * or implied warranty. */ #if defined(AUTHENTICATE) #include #include #include #define AUTH_NAMES #include #ifdef __STDC__ #include #endif #ifdef NO_STRING_H #include #else #include #endif #include "encrypt.h" #include "auth.h" #include "misc-proto.h" #include "auth-proto.h" #if defined(SOLARIS) /* for bcopy() and bzero() */ #include "bstring.h" #endif #define typemask(x) (1<<((x)-1)) int auth_debug_mode = 0; static char *Name = "Noname"; static int Server = 0; static Authenticator *authenticated = 0; static int authenticating = 0; static int validuser = 0; static unsigned char _auth_send_data[256]; static unsigned char *auth_send_data; static int auth_send_cnt = 0; /* * Authentication types supported. Plese note that these are stored * in priority order, i.e. try the first one first. */ Authenticator authenticators[] = { #ifdef KRB5 { AUTHTYPE_KERBEROS_V5, AUTH_WHO_CLIENT|AUTH_HOW_MUTUAL, kerberos5_init, kerberos5_send, kerberos5_is, kerberos5_reply, kerberos5_status, kerberos5_printsub }, { AUTHTYPE_KERBEROS_V5, AUTH_WHO_CLIENT|AUTH_HOW_ONE_WAY, kerberos5_init, kerberos5_send, kerberos5_is, kerberos5_reply, kerberos5_status, kerberos5_printsub }, #endif #ifdef KRB4 { AUTHTYPE_KERBEROS_V4, AUTH_WHO_CLIENT|AUTH_HOW_MUTUAL, kerberos4_init, kerberos4_send, kerberos4_is, kerberos4_reply, kerberos4_status, kerberos4_printsub }, { AUTHTYPE_KERBEROS_V4, AUTH_WHO_CLIENT|AUTH_HOW_ONE_WAY, kerberos4_init, kerberos4_send, kerberos4_is, kerberos4_reply, kerberos4_status, kerberos4_printsub }, #endif { 0, }, }; static Authenticator NoAuth = { 0 }; static int i_support = 0; static int i_wont_support = 0; Authenticator * findauthenticator(type, way) int type; int way; { Authenticator *ap = authenticators; while (ap->type && (ap->type != type || ap->way != way)) ++ap; return(ap->type ? ap : 0); } void auth_init(name, server) char *name; int server; { Authenticator *ap = authenticators; Server = server; Name = name; i_support = 0; authenticated = 0; authenticating = 0; while (ap->type) { if (!ap->init || (*ap->init)(ap, server)) { i_support |= typemask(ap->type); if (auth_debug_mode) printf(">>>%s: I support auth type %d %d\r\n", Name, ap->type, ap->way); } ++ap; } } void auth_disable_name(name) char *name; { int x; for (x = 0; x < AUTHTYPE_CNT; ++x) { if (!strcasecmp(name, AUTHTYPE_NAME(x))) { i_wont_support |= typemask(x); break; } } } int getauthmask(type, maskp) char *type; int *maskp; { register int x; if (strcasecmp(type, AUTHTYPE_NAME(0))) { *maskp = -1; return(1); } for (x = 1; x < AUTHTYPE_CNT; ++x) { if (!strcasecmp(type, AUTHTYPE_NAME(x))) { *maskp = typemask(x); return(1); } } return(0); } int auth_enable(type) int type; { return(auth_onoff(type, 1)); } int auth_disable(type) int type; { return(auth_onoff(type, 0)); } int auth_onoff(type, on) char *type; int on; { int mask = -1; Authenticator *ap; if (!strcasecmp(type, "?") || !strcasecmp(type, "help")) { printf("auth %s 'type'\n", on ? "enable" : "disable"); printf("Where 'type' is one of:\n"); printf("\t%s\n", AUTHTYPE_NAME(0)); for (ap = authenticators; ap->type; ap++) printf("\t%s\n", AUTHTYPE_NAME(ap->type)); return(0); } if (!getauthmask(type, &mask)) { printf("%s: invalid authentication type\n", type); return(0); } mask = getauthmask(type, &mask); if (on) i_wont_support &= ~mask; else i_wont_support |= mask; return(1); } int auth_togdebug(on) int on; { if (on < 0) auth_debug_mode ^= 1; else auth_debug_mode = on; printf("auth debugging %s\n", auth_debug_mode ? "enabled" : "disabled"); return(1); } int auth_status() { Authenticator *ap; if (i_wont_support == -1) printf("Authentication disabled\n"); else printf("Authentication enabled\n"); for (ap = authenticators; ap->type; ap++) printf("%s: %s\n", AUTHTYPE_NAME(ap->type), (i_wont_support & typemask(ap->type)) ? "disabled" : "enabled"); return(1); } /* * This routine is called by the server to start authentication * negotiation. */ void auth_request() { static unsigned char str_request[64] = { IAC, SB, TELOPT_AUTHENTICATION, TELQUAL_SEND, }; Authenticator *ap = authenticators; unsigned char *e = str_request + 4; if (!authenticating) { authenticating = 1; while (ap->type) { if (i_support & ~i_wont_support & typemask(ap->type)) { if (auth_debug_mode) { printf(">>>%s: Sending type %d %d\r\n", Name, ap->type, ap->way); } *e++ = ap->type; *e++ = ap->way; } ++ap; } *e++ = IAC; *e++ = SE; net_write(str_request, e - str_request); printsub('>', &str_request[2], e - str_request - 2); } } /* * This is called when an AUTH SEND is received. * It should never arrive on the server side (as only the server can * send an AUTH SEND). * You should probably respond to it if you can... * * If you want to respond to the types out of order (i.e. even * if he sends LOGIN KERBEROS and you support both, you respond * with KERBEROS instead of LOGIN (which is against what the * protocol says)) you will have to hack this code... */ void auth_send(data, cnt) unsigned char *data; int cnt; { Authenticator *ap; static unsigned char str_none[] = { IAC, SB, TELOPT_AUTHENTICATION, TELQUAL_IS, AUTHTYPE_NULL, 0, IAC, SE }; if (Server) { if (auth_debug_mode) { printf(">>>%s: auth_send called!\r\n", Name); } return; } if (auth_debug_mode) { printf(">>>%s: auth_send got:", Name); printd(data, cnt); printf("\r\n"); } /* * Save the data, if it is new, so that we can continue looking * at it if the authorization we try doesn't work */ if (data < _auth_send_data || data > _auth_send_data + sizeof(_auth_send_data)) { auth_send_cnt = cnt > sizeof(_auth_send_data) ? sizeof(_auth_send_data) : cnt; bcopy((void *)data, (void *)_auth_send_data, auth_send_cnt); auth_send_data = _auth_send_data; } else { /* * This is probably a no-op, but we just make sure */ auth_send_data = data; auth_send_cnt = cnt; } while ((auth_send_cnt -= 2) >= 0) { if (auth_debug_mode) printf(">>>%s: He supports %d\r\n", Name, *auth_send_data); if ((i_support & ~i_wont_support) & typemask(*auth_send_data)) { ap = findauthenticator(auth_send_data[0], auth_send_data[1]); if (!ap) { printf("Internal state error: cannot find authentication type %d a second time\r\n", *auth_send_data); } else if (ap->send) { if (auth_debug_mode) printf(">>>%s: Trying %d %d\r\n", Name, auth_send_data[0], auth_send_data[1]); if ((*ap->send)(ap)) { /* * Okay, we found one we like * and did it. * we can go home now. */ if (auth_debug_mode) printf(">>>%s: Using type %d\r\n", Name, *auth_send_data); auth_send_data += 2; return; } } /* else * just continue on and look for the * next one if we didn't do anything. */ } auth_send_data += 2; } net_write(str_none, sizeof(str_none)); printsub('>', &str_none[2], sizeof(str_none) - 2); if (auth_debug_mode) printf(">>>%s: Sent failure message\r\n", Name); auth_finished(0, AUTH_REJECT); } void auth_send_retry() { /* * if auth_send_cnt <= 0 then auth_send will end up rejecting * the authentication and informing the other side of this. */ auth_send(auth_send_data, auth_send_cnt); } void auth_is(data, cnt) unsigned char *data; int cnt; { Authenticator *ap; if (cnt < 2) return; if (data[0] == AUTHTYPE_NULL) { auth_finished(0, AUTH_REJECT); return; } if (ap = findauthenticator(data[0], data[1])) { if (ap->is) (*ap->is)(ap, data+2, cnt-2); } else if (auth_debug_mode) printf(">>>%s: Invalid authentication in IS: %d\r\n", Name, *data); } void auth_reply(data, cnt) unsigned char *data; int cnt; { Authenticator *ap; if (cnt < 2) return; if (ap = findauthenticator(data[0], data[1])) { if (ap->reply) (*ap->reply)(ap, data+2, cnt-2); } else if (auth_debug_mode) printf(">>>%s: Invalid authentication in SEND: %d\r\n", Name, *data); } void auth_name(data, cnt) unsigned char *data; int cnt; { Authenticator *ap; unsigned char savename[256]; if (cnt < 1) { if (auth_debug_mode) printf(">>>%s: Empty name in NAME\r\n", Name); return; } if (cnt > sizeof(savename) - 1) { if (auth_debug_mode) printf(">>>%s: Name in NAME (%d) exceeds %d length\r\n", Name, cnt, sizeof(savename)-1); return; } bcopy((void *)data, (void *)savename, cnt); savename[cnt] = '\0'; /* Null terminate */ if (auth_debug_mode) printf(">>>%s: Got NAME [%s]\r\n", Name, savename); auth_encrypt_user(savename); } int auth_sendname(cp, len) unsigned char *cp; int len; { static unsigned char str_request[256+6] = { IAC, SB, TELOPT_AUTHENTICATION, TELQUAL_NAME, }; register unsigned char *e = str_request + 4; register unsigned char *ee = &str_request[sizeof(str_request)-2]; while (--len >= 0) { if ((*e++ = *cp++) == IAC) *e++ = IAC; if (e >= ee) return(0); } *e++ = IAC; *e++ = SE; net_write(str_request, e - str_request); printsub('>', &str_request[2], e - &str_request[2]); return(1); } void auth_finished(ap, result) Authenticator *ap; int result; { if (!(authenticated = ap)) authenticated = &NoAuth; validuser = result; } /* ARGSUSED */ static void auth_intr(sig) int sig; { auth_finished(0, AUTH_REJECT); } int auth_wait(name) char *name; { if (auth_debug_mode) printf(">>>%s: in auth_wait.\r\n", Name); if (Server && !authenticating) return(0); (void) signal(SIGALRM, auth_intr); alarm(30); while (!authenticated) if (telnet_spin()) break; alarm(0); (void) signal(SIGALRM, SIG_DFL); /* * Now check to see if the user is valid or not */ if (!authenticated || authenticated == &NoAuth) return(AUTH_REJECT); if (validuser == AUTH_VALID) validuser = AUTH_USER; if (authenticated->status) validuser = (*authenticated->status)(authenticated, name, validuser); return(validuser); } void auth_debug(mode) int mode; { auth_debug_mode = mode; } void auth_printsub(data, cnt, buf, buflen) unsigned char *data, *buf; int cnt, buflen; { Authenticator *ap; if ((ap = findauthenticator(data[1], data[2])) && ap->printsub) (*ap->printsub)(data, cnt, buf, buflen); else auth_gen_printsub(data, cnt, buf, buflen); } void auth_gen_printsub(data, cnt, buf, buflen) unsigned char *data, *buf; int cnt, buflen; { register unsigned char *cp; unsigned char tbuf[16]; cnt -= 3; data += 3; buf[buflen-1] = '\0'; buf[buflen-2] = '*'; buflen -= 2; for (; cnt > 0; cnt--, data++) { sprintf((char *)tbuf, " %d", *data); for (cp = tbuf; *cp && buflen > 0; --buflen) *buf++ = *cp++; if (buflen <= 0) return; } *buf = '\0'; } #endif socks4-server-4.3.beta2.orig/rtelnet/libtelnet/auth.h100640 7657 764 5461 5606334277 21167 0ustar martinedv/*- * Copyright (c) 1991 The Regents of the University of California. * All rights reserved. * * Redistribution and use in source and binary forms are permitted provided * that: (1) source distributions retain this entire copyright notice and * comment, and (2) distributions including binaries display the following * acknowledgement: ``This product includes software developed by the * University of California, Berkeley and its contributors'' in the * documentation or other materials provided with the distribution and in * all advertising materials mentioning features or use of this software. * Neither the name of the University nor the names of its contributors may * be used to endorse or promote products derived from this software without * specific prior written permission. * THIS SOFTWARE IS PROVIDED ``AS IS'' AND WITHOUT ANY EXPRESS OR IMPLIED * WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED WARRANTIES OF * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. * * @(#)auth.h 5.1 (Berkeley) 2/28/91 */ /* * Copyright (C) 1990 by the Massachusetts Institute of Technology * * Export of this software from the United States of America is assumed * to require a specific license from the United States Government. * It is the responsibility of any person or organization contemplating * export to obtain such a license before exporting. * * WITHIN THAT CONSTRAINT, permission to use, copy, modify, and * distribute this software and its documentation for any purpose and * without fee is hereby granted, provided that the above copyright * notice appear in all copies and that both that copyright notice and * this permission notice appear in supporting documentation, and that * the name of M.I.T. not be used in advertising or publicity pertaining * to distribution of the software without specific, written prior * permission. M.I.T. makes no representations about the suitability of * this software for any purpose. It is provided "as is" without express * or implied warranty. */ #ifndef __AUTH__ #define __AUTH__ #define AUTH_REJECT 0 /* Rejected */ #define AUTH_UNKNOWN 1 /* We don't know who he is, but he's okay */ #define AUTH_OTHER 2 /* We know him, but not his name */ #define AUTH_USER 3 /* We know he name */ #define AUTH_VALID 4 /* We know him, and he needs no password */ #if !defined(P) #ifdef __STDC__ #define P(x) x #else #define P(x) () #endif #endif typedef struct XauthP { int type; int way; int (*init) P((struct XauthP *, int)); int (*send) P((struct XauthP *)); void (*is) P((struct XauthP *, unsigned char *, int)); void (*reply) P((struct XauthP *, unsigned char *, int)); int (*status) P((struct XauthP *, char *, int)); void (*printsub) P((unsigned char *, int, unsigned char *, int)); } Authenticator; #include "auth-proto.h" extern auth_debug_mode; #endif socks4-server-4.3.beta2.orig/rtelnet/libtelnet/enc-proto.h100640 7657 764 4132 6157326147 22125 0ustar martinedv/*- * Copyright (c) 1991 The Regents of the University of California. * All rights reserved. * * Redistribution and use in source and binary forms are permitted provided * that: (1) source distributions retain this entire copyright notice and * comment, and (2) distributions including binaries display the following * acknowledgement: ``This product includes software developed by the * University of California, Berkeley and its contributors'' in the * documentation or other materials provided with the distribution and in * all advertising materials mentioning features or use of this software. * Neither the name of the University nor the names of its contributors may * be used to endorse or promote products derived from this software without * specific prior written permission. * THIS SOFTWARE IS PROVIDED ``AS IS'' AND WITHOUT ANY EXPRESS OR IMPLIED * WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED WARRANTIES OF * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. * * @(#)enc-proto.h 5.1 (Berkeley) 2/28/91 */ /* * Copyright (C) 1990 by the Massachusetts Institute of Technology * * Export of this software from the United States of America is assumed * to require a specific license from the United States Government. * It is the responsibility of any person or organization contemplating * export to obtain such a license before exporting. * * WITHIN THAT CONSTRAINT, permission to use, copy, modify, and * distribute this software and its documentation for any purpose and * without fee is hereby granted, provided that the above copyright * notice appear in all copies and that both that copyright notice and * this permission notice appear in supporting documentation, and that * the name of M.I.T. not be used in advertising or publicity pertaining * to distribution of the software without specific, written prior * permission. M.I.T. makes no representations about the suitability of * this software for any purpose. It is provided "as is" without express * or implied warranty. */ #if !defined(P) #ifdef __STDC__ #define P(x) x #else #define P(x) () #endif #endif socks4-server-4.3.beta2.orig/rtelnet/libtelnet/enc_des.c100640 7657 764 4074 6157326440 21613 0ustar martinedv/*- * Copyright (c) 1991 The Regents of the University of California. * All rights reserved. * * Redistribution and use in source and binary forms are permitted provided * that: (1) source distributions retain this entire copyright notice and * comment, and (2) distributions including binaries display the following * acknowledgement: ``This product includes software developed by the * University of California, Berkeley and its contributors'' in the * documentation or other materials provided with the distribution and in * all advertising materials mentioning features or use of this software. * Neither the name of the University nor the names of its contributors may * be used to endorse or promote products derived from this software without * specific prior written permission. * THIS SOFTWARE IS PROVIDED ``AS IS'' AND WITHOUT ANY EXPRESS OR IMPLIED * WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED WARRANTIES OF * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. */ #ifndef lint static char sccsid[] = "@(#)krb_des.c 5.1 (Berkeley) 2/28/91"; #endif /* not lint */ /* * Copyright (C) 1990 by the Massachusetts Institute of Technology * * Export of this software from the United States of America is assumed * to require a specific license from the United States Government. * It is the responsibility of any person or organization contemplating * export to obtain such a license before exporting. * * WITHIN THAT CONSTRAINT, permission to use, copy, modify, and * distribute this software and its documentation for any purpose and * without fee is hereby granted, provided that the above copyright * notice appear in all copies and that both that copyright notice and * this permission notice appear in supporting documentation, and that * the name of M.I.T. not be used in advertising or publicity pertaining * to distribution of the software without specific, written prior * permission. M.I.T. makes no representations about the suitability of * this software for any purpose. It is provided "as is" without express * or implied warranty. */ socks4-server-4.3.beta2.orig/rtelnet/libtelnet/encrypt.c100640 7657 764 4075 6157326544 21705 0ustar martinedv/*- * Copyright (c) 1991 The Regents of the University of California. * All rights reserved. * * Redistribution and use in source and binary forms are permitted provided * that: (1) source distributions retain this entire copyright notice and * comment, and (2) distributions including binaries display the following * acknowledgement: ``This product includes software developed by the * University of California, Berkeley and its contributors'' in the * documentation or other materials provided with the distribution and in * all advertising materials mentioning features or use of this software. * Neither the name of the University nor the names of its contributors may * be used to endorse or promote products derived from this software without * specific prior written permission. * THIS SOFTWARE IS PROVIDED ``AS IS'' AND WITHOUT ANY EXPRESS OR IMPLIED * WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED WARRANTIES OF * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. */ #ifndef lint static char sccsid[] = "@(#)encrypt.c 5.1 (Berkeley) 2/28/91"; #endif /* not lint */ /* * Copyright (C) 1990 by the Massachusetts Institute of Technology * * Export of this software from the United States of America is assumed * to require a specific license from the United States Government. * It is the responsibility of any person or organization contemplating * export to obtain such a license before exporting. * * WITHIN THAT CONSTRAINT, permission to use, copy, modify, and * distribute this software and its documentation for any purpose and * without fee is hereby granted, provided that the above copyright * notice appear in all copies and that both that copyright notice and * this permission notice appear in supporting documentation, and that * the name of M.I.T. not be used in advertising or publicity pertaining * to distribution of the software without specific, written prior * permission. M.I.T. makes no representations about the suitability of * this software for any purpose. It is provided "as is" without express * or implied warranty. */ socks4-server-4.3.beta2.orig/rtelnet/libtelnet/encrypt.h100640 7657 764 6220 5606334300 21667 0ustar martinedv/*- * Copyright (c) 1991 The Regents of the University of California. * All rights reserved. * * Redistribution and use in source and binary forms are permitted provided * that: (1) source distributions retain this entire copyright notice and * comment, and (2) distributions including binaries display the following * acknowledgement: ``This product includes software developed by the * University of California, Berkeley and its contributors'' in the * documentation or other materials provided with the distribution and in * all advertising materials mentioning features or use of this software. * Neither the name of the University nor the names of its contributors may * be used to endorse or promote products derived from this software without * specific prior written permission. * THIS SOFTWARE IS PROVIDED ``AS IS'' AND WITHOUT ANY EXPRESS OR IMPLIED * WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED WARRANTIES OF * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. * * @(#)encrypt.h 5.1 (Berkeley) 2/28/91 */ /* * Copyright (C) 1990 by the Massachusetts Institute of Technology * * Export of this software from the United States of America is assumed * to require a specific license from the United States Government. * It is the responsibility of any person or organization contemplating * export to obtain such a license before exporting. * * WITHIN THAT CONSTRAINT, permission to use, copy, modify, and * distribute this software and its documentation for any purpose and * without fee is hereby granted, provided that the above copyright * notice appear in all copies and that both that copyright notice and * this permission notice appear in supporting documentation, and that * the name of M.I.T. not be used in advertising or publicity pertaining * to distribution of the software without specific, written prior * permission. M.I.T. makes no representations about the suitability of * this software for any purpose. It is provided "as is" without express * or implied warranty. */ #ifndef __ENCRYPT__ #define __ENCRYPT__ #define DIR_DECRYPT 1 #define DIR_ENCRYPT 2 typedef unsigned char Block[8]; typedef unsigned char *BlockT; typedef struct { Block _; } Schedule[16]; #define VALIDKEY(key) ( key[0] | key[1] | key[2] | key[3] | \ key[4] | key[5] | key[6] | key[7]) #define SAMEKEY(k1, k2) (!bcmp((void *)k1, (void *)k2, sizeof(Block))) typedef struct { short type; int length; unsigned char *data; } Session_Key; #if !defined(P) #ifdef __STDC__ #define P(x) x #else #define P(x) () #endif #endif typedef struct { char *name; int type; void (*output) P((unsigned char *, int)); int (*input) P((int)); void (*init) P((int)); int (*start) P((int, int)); int (*is) P((unsigned char *, int)); int (*reply) P((unsigned char *, int)); void (*session) P((Session_Key *, int)); int (*keyid) P((int, unsigned char *, int *)); void (*printsub) P((unsigned char *, int, unsigned char *, int)); } Encryptions; #define SK_DES 1 /* Matched Kerberos v5 KEYTYPE_DES */ #include "enc-proto.h" extern int encrypt_debug_mode; extern int (*decrypt_input) P((int)); extern void (*encrypt_output) P((unsigned char *, int)); #endif socks4-server-4.3.beta2.orig/rtelnet/libtelnet/genget.c100640 7657 764 4574 5606334300 21461 0ustar martinedv/*- * Copyright (c) 1991 The Regents of the University of California. * All rights reserved. * * Redistribution and use in source and binary forms are permitted provided * that: (1) source distributions retain this entire copyright notice and * comment, and (2) distributions including binaries display the following * acknowledgement: ``This product includes software developed by the * University of California, Berkeley and its contributors'' in the * documentation or other materials provided with the distribution and in * all advertising materials mentioning features or use of this software. * Neither the name of the University nor the names of its contributors may * be used to endorse or promote products derived from this software without * specific prior written permission. * THIS SOFTWARE IS PROVIDED ``AS IS'' AND WITHOUT ANY EXPRESS OR IMPLIED * WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED WARRANTIES OF * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. */ #ifndef lint static char sccsid[] = "@(#)genget.c 5.1 (Berkeley) 2/28/91"; #endif /* not lint */ #include #define LOWER(x) (isupper(x) ? tolower(x) : (x)) /* * The prefix function returns 0 if *s1 is not a prefix * of *s2. If *s1 exactly matches *s2, the negative of * the length is returned. If *s1 is a prefix of *s2, * the length of *s1 is returned. */ int isprefix(s1, s2) register char *s1, *s2; { register int n = 0; char *os1; register char c1, c2; if (*s1 == '\0') return(-1); os1 = s1; c1 = *s1; c2 = *s2; while (LOWER(c1) == LOWER(c2)) { if (c1 == '\0') break; c1 = *++s1; c2 = *++s2; } return(*s1 ? 0 : (*s2 ? (s1 - os1) : (os1 - s1))); } static char *ambiguous; /* special return value for command routines */ char ** genget(name, table, stlen) char *name; /* name to match */ char **table; /* name entry in table */ int stlen; { register char **c, **found; register int n; if (name == 0) return 0; found = 0; for (c = table; *c != 0; c = (char **)((char *)c + stlen)) { if ((n = isprefix(name, *c)) == 0) continue; if (n < 0) /* exact match */ return(c); if (found) return(&ambiguous); found = c; } return(found); } /* * Function call version of Ambiguous() */ int Ambiguous(s) char *s; { return((char **)s == &ambiguous); } socks4-server-4.3.beta2.orig/rtelnet/libtelnet/getent.c100640 7657 764 4304 5606334301 21466 0ustar martinedv/*- * Copyright (c) 1991 The Regents of the University of California. * All rights reserved. * * Redistribution and use in source and binary forms are permitted provided * that: (1) source distributions retain this entire copyright notice and * comment, and (2) distributions including binaries display the following * acknowledgement: ``This product includes software developed by the * University of California, Berkeley and its contributors'' in the * documentation or other materials provided with the distribution and in * all advertising materials mentioning features or use of this software. * Neither the name of the University nor the names of its contributors may * be used to endorse or promote products derived from this software without * specific prior written permission. * THIS SOFTWARE IS PROVIDED ``AS IS'' AND WITHOUT ANY EXPRESS OR IMPLIED * WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED WARRANTIES OF * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. */ #ifndef lint static char sccsid[] = "@(#)getent.c 5.1 (Berkeley) 2/28/91"; #endif /* not lint */ /* * Copyright (c) 1991 Regents of the University of California. * All rights reserved. * * Redistribution and use in source and binary forms are permitted provided * that: (1) source distributions retain this entire copyright notice and * comment, and (2) distributions including binaries display the following * acknowledgement: ``This product includes software developed by the * University of California, Berkeley and its contributors'' in the * documentation or other materials provided with the distribution and in * all advertising materials mentioning features or use of this software. * Neither the name of the University nor the names of its contributors may * be used to endorse or promote products derived from this software without * specific prior written permission. * THIS SOFTWARE IS PROVIDED ``AS IS'' AND WITHOUT ANY EXPRESS OR IMPLIED * WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED WARRANTIES OF * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. */ /*ARGSUSED*/ getent(cp, name) char *cp, *name; { return(0); } /*ARGSUSED*/ char * getstr(cp, cpp) char *cp, **cpp; { return(0); } socks4-server-4.3.beta2.orig/rtelnet/libtelnet/getopt.c100640 7657 764 5630 5606334301 21505 0ustar martinedv/* * Copyright (c) 1987 Regents of the University of California. * All rights reserved. * * Redistribution and use in source and binary forms are permitted * provided that: (1) source distributions retain this entire copyright * notice and comment, and (2) distributions including binaries display * the following acknowledgement: ``This product includes software * developed by the University of California, Berkeley and its contributors'' * in the documentation or other materials provided with the distribution * and in all advertising materials mentioning features or use of this * software. Neither the name of the University nor the names of its * contributors may be used to endorse or promote products derived * from this software without specific prior written permission. * THIS SOFTWARE IS PROVIDED ``AS IS'' AND WITHOUT ANY EXPRESS OR * IMPLIED WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. */ #if defined(LIBC_SCCS) && !defined(lint) static char sccsid[] = "@(#)getopt.c 4.12 (Berkeley) 6/1/90"; #endif /* LIBC_SCCS and not lint */ #include /* * get option letter from argument vector */ int opterr = 1, /* if error message should be printed */ optind = 1, /* index into parent argv vector */ optopt; /* character checked for validity */ char *optarg; /* argument associated with option */ #define BADCH (int)'?' #define EMSG "" getopt(nargc, nargv, ostr) int nargc; char **nargv, *ostr; { static char *place = EMSG; /* option letter processing */ register char *oli; /* option letter list index */ char *p, *index(), *rindex(); if (!*place) { /* update scanning pointer */ if (optind >= nargc || *(place = nargv[optind]) != '-') { place = EMSG; return(EOF); } if (place[1] && *++place == '-') { /* found "--" */ ++optind; place = EMSG; return(EOF); } } /* option letter okay? */ if ((optopt = (int)*place++) == (int)':' || !(oli = index(ostr, optopt))) { /* * if the user didn't specify '-' as an option, * assume it means EOF. */ if (optopt == (int)'-') return(EOF); if (!*place) ++optind; if (opterr) { if (!(p = rindex(*nargv, '/'))) p = *nargv; else ++p; (void)fprintf(stderr, "%s: illegal option -- %c\n", p, optopt); } return(BADCH); } if (*++oli != ':') { /* don't need argument */ optarg = NULL; if (!*place) ++optind; } else { /* need an argument */ if (*place) /* no white space */ optarg = place; else if (nargc <= ++optind) { /* no arg */ place = EMSG; if (!(p = rindex(*nargv, '/'))) p = *nargv; else ++p; if (opterr) (void)fprintf(stderr, "%s: option requires an argument -- %c\n", p, optopt); return(BADCH); } else /* white space */ optarg = nargv[optind]; place = EMSG; ++optind; } return(optopt); /* dump back option letter */ } socks4-server-4.3.beta2.orig/rtelnet/libtelnet/herror.c100640 7657 764 3361 5606334301 21503 0ustar martinedv/* * Copyright (c) 1988, 1990 Regents of the University of California. * All rights reserved. * * Redistribution and use in source and binary forms are permitted provided * that: (1) source distributions retain this entire copyright notice and * comment, and (2) distributions including binaries display the following * acknowledgement: ``This product includes software developed by the * University of California, Berkeley and its contributors'' in the * documentation or other materials provided with the distribution and in * all advertising materials mentioning features or use of this software. * Neither the name of the University nor the names of its contributors may * be used to endorse or promote products derived from this software without * specific prior written permission. * THIS SOFTWARE IS PROVIDED ``AS IS'' AND WITHOUT ANY EXPRESS OR IMPLIED * WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED WARRANTIES OF * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. */ #include char *h_errlist[] = { "Error 0", "Unknown host", /* 1 HOST_NOT_FOUND */ "Host name lookup failure", /* 2 TRY_AGAIN */ "Unknown server error", /* 3 NO_RECOVERY */ "No address associated with name", /* 4 NO_ADDRESS */ }; int h_nerr = { sizeof(h_errlist)/sizeof(h_errlist[0]) }; int h_errno; /* In some version of SunOS this is necessary */ /* * herror -- * print the error indicated by the h_errno value. */ herror(s) char *s; { if (s && *s) { fprintf(stderr, "%s: ", s); } if ((h_errno < 0) || (h_errno >= h_nerr)) { fprintf(stderr, "Unknown error\n"); } else if (h_errno == 0) { #if defined(sun) fprintf(stderr, "Host unknown\n"); #endif /* defined(sun) */ } else { fprintf(stderr, "%s\n", h_errlist[h_errno]); } } socks4-server-4.3.beta2.orig/rtelnet/libtelnet/kerberos.c100640 7657 764 30576 6157326770 22063 0ustar martinedv/*- * Copyright (c) 1991 The Regents of the University of California. * All rights reserved. * * Redistribution and use in source and binary forms are permitted provided * that: (1) source distributions retain this entire copyright notice and * comment, and (2) distributions including binaries display the following * acknowledgement: ``This product includes software developed by the * University of California, Berkeley and its contributors'' in the * documentation or other materials provided with the distribution and in * all advertising materials mentioning features or use of this software. * Neither the name of the University nor the names of its contributors may * be used to endorse or promote products derived from this software without * specific prior written permission. * THIS SOFTWARE IS PROVIDED ``AS IS'' AND WITHOUT ANY EXPRESS OR IMPLIED * WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED WARRANTIES OF * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. */ #ifndef lint static char sccsid[] = "@(#)kerberos.c 5.1 (Berkeley) 2/28/91"; #endif /* not lint */ /* * Copyright (C) 1990 by the Massachusetts Institute of Technology * * Export of this software from the United States of America is assumed * to require a specific license from the United States Government. * It is the responsibility of any person or organization contemplating * export to obtain such a license before exporting. * * WITHIN THAT CONSTRAINT, permission to use, copy, modify, and * distribute this software and its documentation for any purpose and * without fee is hereby granted, provided that the above copyright * notice appear in all copies and that both that copyright notice and * this permission notice appear in supporting documentation, and that * the name of M.I.T. not be used in advertising or publicity pertaining * to distribution of the software without specific, written prior * permission. M.I.T. makes no representations about the suitability of * this software for any purpose. It is provided "as is" without express * or implied warranty. */ #ifdef KRB4 #include #include #include #include /* BSD wont include this in krb.h, so we do it here */ #include #if defined(__NEED_ENCRYPT__) && !defined(ENCRYPT) #define ENCRYPT #undef __NEED_ENCRYPT__ #endif #ifdef __STDC__ #include #endif #ifdef NO_STRING_H #include #else #include #endif #include "encrypt.h" #include "auth.h" #include "misc.h" #ifdef SOLARIS /* for bcopy() and bzero() */ #include "bstring.h" #endif int cksum P((unsigned char *, int)); int krb_mk_req P((KTEXT, char *, char *, char *, u_long)); int krb_rd_req P((KTEXT, char *, char *, u_long, AUTH_DAT *, char *)); int krb_kntoln P((AUTH_DAT *, char *)); int krb_get_cred P((char *, char *, char *, CREDENTIALS *)); int krb_get_lrealm P((char *, int)); int kuserok P((AUTH_DAT *, char *)); extern auth_debug_mode; static unsigned char str_data[1024] = { IAC, SB, TELOPT_AUTHENTICATION, 0, AUTHTYPE_KERBEROS_V4, }; static unsigned char str_name[1024] = { IAC, SB, TELOPT_AUTHENTICATION, TELQUAL_NAME, }; #define KRB_AUTH 0 /* Authentication data follows */ #define KRB_REJECT 1 /* Rejected (reason might follow) */ #define KRB_ACCEPT 2 /* Accepted */ #define KRB_CHALLANGE 3 /* Challange for mutual auth. */ #define KRB_RESPONSE 4 /* Response for mutual auth. */ static KTEXT_ST auth; static char name[ANAME_SZ]; static AUTH_DAT adat = { 0 }; static Schedule sched; static Block challange = { 0 }; static int Data(ap, type, d, c) Authenticator *ap; int type; void *d; int c; { unsigned char *p = str_data + 4; unsigned char *cd = (unsigned char *)d; if (c == -1) c = strlen((char *)cd); if (auth_debug_mode) { printf("%s:%d: [%d] (%d)", str_data[3] == TELQUAL_IS ? ">>>IS" : ">>>REPLY", str_data[3], type, c); printd(d, c); printf("\r\n"); } *p++ = ap->type; *p++ = ap->way; *p++ = type; while (c-- > 0) { if ((*p++ = *cd++) == IAC) *p++ = IAC; } *p++ = IAC; *p++ = SE; if (str_data[3] == TELQUAL_IS) printsub('>', &str_data[2], p - (&str_data[2])); return(net_write(str_data, p - str_data)); } int kerberos4_init(ap, server) Authenticator *ap; int server; { if (server) str_data[3] = TELQUAL_REPLY; else str_data[3] = TELQUAL_IS; return(1); } char dst_realm_buf[REALM_SZ], *dest_realm = NULL; int dst_realm_sz = REALM_SZ; int kerberos4_send(ap) Authenticator *ap; { KTEXT_ST auth; Block enckey; char instance[INST_SZ]; char *realm; char *krb_realmofhost(); char *krb_get_phost(); CREDENTIALS cred; int r; if (!UserNameRequested) { if (auth_debug_mode) { printf("Kerberos V4: no user name supplied\r\n"); } return(0); } bzero(instance, sizeof(instance)); if (realm = krb_get_phost(RemoteHostName)) strncpy(instance, realm, sizeof(instance)); instance[sizeof(instance)-1] = '\0'; realm = dest_realm ? dest_realm : krb_realmofhost(RemoteHostName); if (!realm) { if (auth_debug_mode) { printf("Kerberos V4: no realm for %s\r\n", RemoteHostName); } return(0); } if (r = krb_mk_req(&auth, "rcmd", instance, realm, 0L)) { if (auth_debug_mode) { printf("mk_req failed: %s\r\n", krb_err_txt[r]); } return(0); } if (r = krb_get_cred("rcmd", instance, realm, &cred)) { if (auth_debug_mode) { printf("get_cred failed: %s\r\n", krb_err_txt[r]); } return(0); } if (!auth_sendname(UserNameRequested, strlen(UserNameRequested))) { if (auth_debug_mode) printf("Not enough room for user name\r\n"); return(0); } if (auth_debug_mode) printf("Sent %d bytes of authentication data\r\n", auth.length); if (!Data(ap, KRB_AUTH, (void *)auth.dat, auth.length)) { if (auth_debug_mode) printf("Not enough room for authentication data\r\n"); return(0); } /* * If we are doing mutual authentication, get set up to send * the challange, and verify it when the response comes back. */ if ((ap->way & AUTH_HOW_MASK) == AUTH_HOW_MUTUAL) { register int i; des_key_sched(cred.session, sched); des_set_random_generator_seed(cred.session); des_new_random_key(challange); des_ecb_encrypt(challange, session_key, sched, 1); /* * Increment the challange by 1, and encrypt it for * later comparison. */ for (i = 7; i >= 0; --i) { register int x; x = (unsigned int)challange[i] + 1; challange[i] = x; /* ignore overflow */ if (x < 256) /* if no overflow, all done */ break; } des_ecb_encrypt(challange, challange, sched, 1); } if (auth_debug_mode) { printf("CK: %d:", cksum(auth.dat, auth.length)); printd(auth.dat, auth.length); printf("\r\n"); printf("Sent Kerberos V4 credentials to server\r\n"); } return(1); } void kerberos4_is(ap, data, cnt) Authenticator *ap; unsigned char *data; int cnt; { Session_Key skey; Block datablock; char realm[REALM_SZ]; char instance[INST_SZ]; int r; if (cnt-- < 1) return; switch (*data++) { case KRB_AUTH: if (krb_get_lrealm(realm, 1) != KSUCCESS) { Data(ap, KRB_REJECT, (void *)"No local V4 Realm.", -1); auth_finished(ap, AUTH_REJECT); if (auth_debug_mode) printf("No local realm\r\n"); return; } bcopy((void *)data, (void *)auth.dat, auth.length = cnt); if (auth_debug_mode) { printf("Got %d bytes of authentication data\r\n", cnt); printf("CK: %d:", cksum(auth.dat, auth.length)); printd(auth.dat, auth.length); printf("\r\n"); } instance[0] = '*'; instance[1] = 0; if (r = krb_rd_req(&auth, "rcmd", instance, 0, &adat, "")) { if (auth_debug_mode) printf("Kerberos failed him as %s\r\n", name); Data(ap, KRB_REJECT, (void *)krb_err_txt[r], -1); auth_finished(ap, AUTH_REJECT); return; } bcopy((void *)adat.session, (void *)session_key, sizeof(Block)); krb_kntoln(&adat, name); Data(ap, KRB_ACCEPT, (void *)0, 0); auth_finished(ap, AUTH_USER); if (auth_debug_mode) { printf("Kerberos accepting him as %s\r\n", name); } break; case KRB_CHALLANGE: if (!VALIDKEY(session_key)) { /* * We don't have a valid session key, so just * send back a response with an empty session * key. */ Data(ap, KRB_RESPONSE, (void *)0, 0); break; } des_key_sched(session_key, sched); bcopy((void *)data, (void *)datablock, sizeof(Block)); /* * Take the received encrypted challange, and encrypt * it again to get a unique session_key for the * ENCRYPT option. */ des_ecb_encrypt(datablock, session_key, sched, 1); skey.type = SK_DES; skey.length = 8; skey.data = session_key; encrypt_session_key(&skey, 1); /* * Now decrypt the received encrypted challange, * increment by one, re-encrypt it and send it back. */ des_ecb_encrypt(datablock, challange, sched, 0); for (r = 7; r >= 0; r++) { register int t; t = (unsigned int)challange[r] + 1; challange[r] = t; /* ignore overflow */ if (t < 256) /* if no overflow, all done */ break; } des_ecb_encrypt(challange, challange, sched, 1); Data(ap, KRB_RESPONSE, (void *)challange, sizeof(challange)); break; default: if (auth_debug_mode) printf("Unknown Kerberos option %d\r\n", data[-1]); Data(ap, KRB_REJECT, 0, 0); break; } } void kerberos4_reply(ap, data, cnt) Authenticator *ap; unsigned char *data; int cnt; { Session_Key skey; if (cnt-- < 1) return; switch (*data++) { case KRB_REJECT: if (cnt > 0) { printf("[ Kerberos V4 refuses authentication because %.*s ]\r\n", cnt, data); } else printf("[ Kerberos V4 refuses authentication ]\r\n"); auth_send_retry(); return; case KRB_ACCEPT: printf("[ Kerberos V4 accepts you ]\n"); if ((ap->way & AUTH_HOW_MASK) == AUTH_HOW_MUTUAL) { /* * Send over the encrypted challange. */ Data(ap, KRB_CHALLANGE, (void *)session_key, sizeof(session_key)); return; } auth_finished(ap, AUTH_USER); return; case KRB_RESPONSE: /* * Verify that the response to the challange is correct. */ if ((cnt != sizeof(Block)) || (0 != memcmp((void *)data, (void *)challange, sizeof(challange)))) { printf("[ Kerberos V4 challange failed!!! ]\r\n"); auth_send_retry(); return; } printf("[ Kerberos V4 challange successful ]\r\n"); auth_finished(ap, AUTH_USER); break; default: if (auth_debug_mode) printf("Unknown Kerberos option %d\r\n", data[-1]); return; } } int kerberos4_status(ap, name, level) Authenticator *ap; char *name; int level; { if (level < AUTH_USER) return(level); if (UserNameRequested && !kuserok(&adat, UserNameRequested)) { strcpy(name, UserNameRequested); return(AUTH_VALID); } else return(AUTH_USER); } #define BUMP(buf, len) while (*(buf)) {++(buf), --(len);} #define ADDC(buf, len, c) if ((len) > 0) {*(buf)++ = (c); --(len);} void kerberos4_printsub(data, cnt, buf, buflen) unsigned char *data, *buf; int cnt, buflen; { char lbuf[32]; register int i; buf[buflen-1] = '\0'; /* make sure its NULL terminated */ buflen -= 1; switch(data[3]) { case KRB_REJECT: /* Rejected (reason might follow) */ strncpy((char *)buf, " REJECT ", buflen); goto common; case KRB_ACCEPT: /* Accepted (name might follow) */ strncpy((char *)buf, " ACCEPT ", buflen); common: BUMP(buf, buflen); if (cnt <= 4) break; ADDC(buf, buflen, '"'); for (i = 4; i < cnt; i++) ADDC(buf, buflen, data[i]); ADDC(buf, buflen, '"'); ADDC(buf, buflen, '\0'); break; case KRB_AUTH: /* Authentication data follows */ strncpy((char *)buf, " AUTH", buflen); goto common2; case KRB_CHALLANGE: strncpy((char *)buf, " CHALLANGE", buflen); goto common2; case KRB_RESPONSE: strncpy((char *)buf, " RESPONSE", buflen); goto common2; default: sprintf(lbuf, " %d (unknown)", data[3]); strncpy((char *)buf, lbuf, buflen); common2: BUMP(buf, buflen); for (i = 4; i < cnt; i++) { sprintf(lbuf, " %d", data[i]); strncpy((char *)buf, lbuf, buflen); BUMP(buf, buflen); } break; } } int cksum(d, n) unsigned char *d; int n; { int ck = 0; switch (n&03) while (n > 0) { case 0: ck ^= *d++ << 24; --n; case 3: ck ^= *d++ << 16; --n; case 2: ck ^= *d++ << 8; --n; case 1: ck ^= *d++; --n; } return(ck); } #endif #ifdef notdef prkey(msg, key) char *msg; unsigned char *key; { register int i; printf("%s:", msg); for (i = 0; i < 8; i++) printf(" %3d", key[i]); printf("\r\n"); } #endif socks4-server-4.3.beta2.orig/rtelnet/libtelnet/kerberos5.c100640 7657 764 33542 6157327054 22140 0ustar martinedv/*- * Copyright (c) 1991 The Regents of the University of California. * All rights reserved. * * Redistribution and use in source and binary forms are permitted provided * that: (1) source distributions retain this entire copyright notice and * comment, and (2) distributions including binaries display the following * acknowledgement: ``This product includes software developed by the * University of California, Berkeley and its contributors'' in the * documentation or other materials provided with the distribution and in * all advertising materials mentioning features or use of this software. * Neither the name of the University nor the names of its contributors may * be used to endorse or promote products derived from this software without * specific prior written permission. * THIS SOFTWARE IS PROVIDED ``AS IS'' AND WITHOUT ANY EXPRESS OR IMPLIED * WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED WARRANTIES OF * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. */ #ifndef lint static char sccsid[] = "@(#)kerberos5.c 5.1 (Berkeley) 2/28/91"; #endif /* not lint */ /* * Copyright (C) 1990 by the Massachusetts Institute of Technology * * Export of this software from the United States of America is assumed * to require a specific license from the United States Government. * It is the responsibility of any person or organization contemplating * export to obtain such a license before exporting. * * WITHIN THAT CONSTRAINT, permission to use, copy, modify, and * distribute this software and its documentation for any purpose and * without fee is hereby granted, provided that the above copyright * notice appear in all copies and that both that copyright notice and * this permission notice appear in supporting documentation, and that * the name of M.I.T. not be used in advertising or publicity pertaining * to distribution of the software without specific, written prior * permission. M.I.T. makes no representations about the suitability of * this software for any purpose. It is provided "as is" without express * or implied warranty. */ #ifdef KRB5 #include #include #include #include #include #include #include #ifdef __STDC__ #include #endif #ifdef NO_STRING_H #include #else #include #endif #include "encrypt.h" #include "auth.h" #include "misc.h" #ifdef SOLARIS /* for bcopy() and bzero() */ #include "bstring.h" #endif extern auth_debug_mode; char *malloc(); static unsigned char str_data[1024] = { IAC, SB, TELOPT_AUTHENTICATION, 0, AUTHTYPE_KERBEROS_V5, }; static unsigned char str_name[1024] = { IAC, SB, TELOPT_AUTHENTICATION, TELQUAL_NAME, }; #define KRB_AUTH 0 /* Authentication data follows */ #define KRB_REJECT 1 /* Rejected (reason might follow) */ #define KRB_ACCEPT 2 /* Accepted */ #define KRB_CHALLANGE 3 /* Challange for mutual auth. */ #define KRB_RESPONSE 4 /* Response for mutual auth. */ static krb5_data auth; /* telnetd gets session key from here */ static krb5_tkt_authent *authdat = NULL; static Schedule sched; static Block challange; static int Data(ap, type, d, c) Authenticator *ap; int type; void *d; int c; { unsigned char *p = str_data + 4; unsigned char *cd = (unsigned char *)d; if (c == -1) c = strlen((char *)cd); if (auth_debug_mode) { printf("%s:%d: [%d] (%d)", str_data[3] == TELQUAL_IS ? ">>>IS" : ">>>REPLY", str_data[3], type, c); printd(d, c); printf("\r\n"); } *p++ = ap->type; *p++ = ap->way; *p++ = type; while (c-- > 0) { if ((*p++ = *cd++) == IAC) *p++ = IAC; } *p++ = IAC; *p++ = SE; if (str_data[3] == TELQUAL_IS) printsub('>', &str_data[2], p - &str_data[2]); return(net_write(str_data, p - str_data)); } int kerberos5_init(ap, server) Authenticator *ap; int server; { if (server) str_data[3] = TELQUAL_REPLY; else str_data[3] = TELQUAL_IS; krb5_init_ets(); return(1); } int kerberos5_send(ap) Authenticator *ap; { char **realms; char *name; char *p1, *p2; krb5_checksum ksum; krb5_octet sum[CRC32_CKSUM_LENGTH]; krb5_data *server[4]; krb5_data srvdata[3]; krb5_error_code r; krb5_ccache ccache; krb5_creds creds; /* telnet gets session key from here */ extern krb5_flags krb5_kdc_default_options; ksum.checksum_type = CKSUMTYPE_CRC32; ksum.contents = sum; ksum.length = sizeof(sum); bzero((void *)sum, sizeof(sum)); if (!UserNameRequested) { if (auth_debug_mode) { printf("Kerberos V5: no user name supplied\r\n"); } return(0); } if (r = krb5_cc_default(&ccache)) { if (auth_debug_mode) { printf("Kerberos V5: could not get default ccache\r\n"); } return(0); } if ((name = malloc(strlen(RemoteHostName)+1)) == NULL) { if (auth_debug_mode) printf("Out of memory for hostname in Kerberos V5\r\n"); return(0); } if (r = krb5_get_host_realm(RemoteHostName, &realms)) { if (auth_debug_mode) printf("Kerberos V5: no realm for %s\r\n", RemoteHostName); free(name); return(0); } p1 = RemoteHostName; p2 = name; while (*p2 = *p1++) { if (isupper(*p2)) *p2 |= 040; ++p2; } srvdata[0].data = realms[0]; srvdata[0].length = strlen(realms[0]); srvdata[1].data = "rcmd"; srvdata[1].length = 4; srvdata[2].data = name; srvdata[2].length = p2 - name; server[0] = &srvdata[0]; server[1] = &srvdata[1]; server[2] = &srvdata[2]; server[3] = 0; bzero((char *)&creds, sizeof(creds)); creds.server = (krb5_principal)server; if (r = krb5_cc_get_principal(ccache, &creds.client)) { if (auth_debug_mode) { printf("Keberos V5: failure on principal (%d)\r\n", error_message(r)); } free(name); krb5_free_host_realm(realms); return(0); } if (r = krb5_get_credentials(krb5_kdc_default_options, ccache, &creds)) { if (auth_debug_mode) { printf("Keberos V5: failure on credentials(%d)\r\n",r); } free(name); krb5_free_host_realm(realms); return(0); } r = krb5_mk_req_extended(0, &ksum, &creds.times, krb5_kdc_default_options, ccache, &creds, 0, &auth); free(name); krb5_free_host_realm(realms); if (r) { if (auth_debug_mode) { printf("Keberos V5: mk_req failed\r\n"); } return(0); } if (!auth_sendname(UserNameRequested, strlen(UserNameRequested))) { if (auth_debug_mode) printf("Not enough room for user name\r\n"); return(0); } if (!Data(ap, KRB_AUTH, auth.data, auth.length)) { if (auth_debug_mode) printf("Not enough room for authentication data\r\n"); return(0); } /* * If we are doing mutual authentication, get set up to send * the challange, and verify it when the response comes back. */ if (((ap->way & AUTH_HOW_MASK) == AUTH_HOW_MUTUAL) && (creds.keyblock.keytype == KEYTYPE_DES)) { register int i; des_key_sched(creds.keyblock.contents, sched); des_set_random_generator_seed(creds.keyblock.contents); des_new_random_key(challange); des_ecb_encrypt(challange, session_key, sched, 1); /* * Increment the challange by 1, and encrypt it for * later comparison. */ for (i = 7; i >= 0; --i) { register int x; x = (unsigned int)challange[i] + 1; challange[i] = x; /* ignore overflow */ if (x < 256) /* if no overflow, all done */ break; } des_ecb_encrypt(challange, challange, sched, 1); } if (auth_debug_mode) { printf("Sent Kerberos V5 credentials to server\r\n"); } return(1); } void kerberos5_is(ap, data, cnt) Authenticator *ap; unsigned char *data; int cnt; { int r; struct hostent *hp; char *p1, *p2; static char *realm = NULL; Block datablock; krb5_data *server[4]; krb5_data srvdata[3]; Session_Key skey; char *name; char *getenv(); if (cnt-- < 1) return; switch (*data++) { case KRB_AUTH: auth.data = (char *)data; auth.length = cnt; if (!(hp = gethostbyname(LocalHostName))) { if (auth_debug_mode) printf("Cannot resolve local host name\r\n"); Data(ap, KRB_REJECT, "Unknown local hostname.", -1); auth_finished(ap, AUTH_REJECT); return; } if (!realm && (krb5_get_default_realm(&realm))) { if (auth_debug_mode) printf("Could not get defualt realm\r\n"); Data(ap, KRB_REJECT, "Could not get default realm.", -1); auth_finished(ap, AUTH_REJECT); return; } if ((name = malloc(strlen(hp->h_name)+1)) == NULL) { if (auth_debug_mode) printf("Out of memory for hostname in Kerberos V5\r\n"); Data(ap, KRB_REJECT, "Out of memory.", -1); auth_finished(ap, AUTH_REJECT); return; } p1 = hp->h_name; p2 = name; while (*p2 = *p1++) { if (isupper(*p2)) *p2 |= 040; ++p2; } srvdata[0].data = realm; srvdata[0].length = strlen(realm); srvdata[1].data = "rcmd"; srvdata[1].length = 4; srvdata[2].data = name; srvdata[2].length = p2 - name; server[0] = &srvdata[0]; server[1] = &srvdata[1]; server[2] = &srvdata[2]; server[3] = 0; if (authdat) krb5_free_tkt_authent(authdat); if (r = krb5_rd_req_simple(&auth, server, 0, &authdat)) { char errbuf[128]; authdat = 0; (void) strcpy(errbuf, "Read req failed: "); (void) strcat(errbuf, error_message(r)); Data(ap, KRB_REJECT, errbuf, -1); if (auth_debug_mode) printf("%s\r\n", errbuf); return; } free(name); if (krb5_unparse_name(authdat->ticket->enc_part2 ->client, &name)) name = 0; Data(ap, KRB_ACCEPT, name, name ? -1 : 0); if (auth_debug_mode) { printf("Kerberos5 accepting him as ``%s''\r\n", name ? name : ""); } auth_finished(ap, AUTH_USER); if (authdat->ticket->enc_part2->session->keytype != KEYTYPE_DES) break; bcopy((void *)authdat->ticket->enc_part2->session->contents, (void *)session_key, sizeof(Block)); break; case KRB_CHALLANGE: if (!VALIDKEY(session_key)) { /* * We don't have a valid session key, so just * send back a response with an empty session * key. */ Data(ap, KRB_RESPONSE, (void *)0, 0); break; } des_key_sched(session_key, sched); bcopy((void *)data, (void *)datablock, sizeof(Block)); /* * Take the received encrypted challange, and encrypt * it again to get a unique session_key for the * ENCRYPT option. */ des_ecb_encrypt(datablock, session_key, sched, 1); skey.type = SK_DES; skey.length = 8; skey.data = session_key; encrypt_session_key(&skey, 1); /* * Now decrypt the received encrypted challange, * increment by one, re-encrypt it and send it back. */ des_ecb_encrypt(datablock, challange, sched, 0); for (r = 7; r >= 0; r++) { register int t; t = (unsigned int)challange[r] + 1; challange[r] = t; /* ignore overflow */ if (t < 256) /* if no overflow, all done */ break; } des_ecb_encrypt(challange, challange, sched, 1); Data(ap, KRB_RESPONSE, (void *)challange, sizeof(challange)); break; default: if (auth_debug_mode) printf("Unknown Kerberos option %d\r\n", data[-1]); Data(ap, KRB_REJECT, 0, 0); break; } } void kerberos5_reply(ap, data, cnt) Authenticator *ap; unsigned char *data; int cnt; { Session_Key skey; if (cnt-- < 1) return; switch (*data++) { case KRB_REJECT: if (cnt > 0) { printf("[ Kerberos V5 refuses authentication because %.*s ]\r\n", cnt, data); } else printf("[ Kerberos V5 refuses authentication ]\r\n"); auth_send_retry(); return; case KRB_ACCEPT: printf("[ Kerberos V5 accepts you ]\n", cnt, data); if ((ap->way & AUTH_HOW_MASK) == AUTH_HOW_MUTUAL) { /* * Send over the encrypted challange. */ Data(ap, KRB_CHALLANGE, (void *)session_key, sizeof(session_key)); return; } auth_finished(ap, AUTH_USER); return; case KRB_RESPONSE: /* * Verify that the response to the challange is correct. */ if ((cnt != sizeof(Block)) || (0 != memcmp((void *)data, (void *)challange, sizeof(challange)))) { printf("[ Kerberos V5 challange failed!!! ]\r\n"); auth_send_retry(); return; } printf("[ Kerberos V5 challange successful ]\r\n"); auth_finished(ap, AUTH_USER); break; default: if (auth_debug_mode) printf("Unknown Kerberos option %d\r\n", data[-1]); return; } } int kerberos5_status(ap, name, level) Authenticator *ap; char *name; int level; { if (level < AUTH_USER) return(level); if (UserNameRequested && krb5_kuserok(authdat->ticket->enc_part2->client, UserNameRequested)) { strcpy(name, UserNameRequested); return(AUTH_VALID); } else return(AUTH_USER); } #define BUMP(buf, len) while (*(buf)) {++(buf), --(len);} #define ADDC(buf, len, c) if ((len) > 0) {*(buf)++ = (c); --(len);} void kerberos5_printsub(data, cnt, buf, buflen) unsigned char *data, *buf; int cnt, buflen; { char lbuf[32]; register int i; buf[buflen-1] = '\0'; /* make sure its NULL terminated */ buflen -= 1; switch(data[3]) { case KRB_REJECT: /* Rejected (reason might follow) */ strncpy((char *)buf, " REJECT ", buflen); goto common; case KRB_ACCEPT: /* Accepted (name might follow) */ strncpy((char *)buf, " ACCEPT ", buflen); common: BUMP(buf, buflen); if (cnt <= 4) break; ADDC(buf, buflen, '"'); for (i = 4; i < cnt; i++) ADDC(buf, buflen, data[i]); ADDC(buf, buflen, '"'); ADDC(buf, buflen, '\0'); break; case KRB_AUTH: /* Authentication data follows */ strncpy((char *)buf, " AUTH", buflen); goto common2; case KRB_CHALLANGE: strncpy((char *)buf, " CHALLANGE", buflen); goto common2; case KRB_RESPONSE: strncpy((char *)buf, " RESPONSE", buflen); goto common2; default: sprintf(lbuf, " %d (unknown)", data[3]); strncpy((char *)buf, lbuf, buflen); common2: BUMP(buf, buflen); for (i = 4; i < cnt; i++) { sprintf(lbuf, " %d", data[i]); strncpy((char *)buf, lbuf, buflen); BUMP(buf, buflen); } break; } } #endif socks4-server-4.3.beta2.orig/rtelnet/libtelnet/key-proto.h100640 7657 764 4460 5606334302 22142 0ustar martinedv/*- * Copyright (c) 1991 The Regents of the University of California. * All rights reserved. * * Redistribution and use in source and binary forms are permitted provided * that: (1) source distributions retain this entire copyright notice and * comment, and (2) distributions including binaries display the following * acknowledgement: ``This product includes software developed by the * University of California, Berkeley and its contributors'' in the * documentation or other materials provided with the distribution and in * all advertising materials mentioning features or use of this software. * Neither the name of the University nor the names of its contributors may * be used to endorse or promote products derived from this software without * specific prior written permission. * THIS SOFTWARE IS PROVIDED ``AS IS'' AND WITHOUT ANY EXPRESS OR IMPLIED * WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED WARRANTIES OF * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. * * @(#)key-proto.h 5.1 (Berkeley) 2/28/91 */ /* * Copyright (C) 1990 by the Massachusetts Institute of Technology * * Export of this software from the United States of America is assumed * to require a specific license from the United States Government. * It is the responsibility of any person or organization contemplating * export to obtain such a license before exporting. * * WITHIN THAT CONSTRAINT, permission to use, copy, modify, and * distribute this software and its documentation for any purpose and * without fee is hereby granted, provided that the above copyright * notice appear in all copies and that both that copyright notice and * this permission notice appear in supporting documentation, and that * the name of M.I.T. not be used in advertising or publicity pertaining * to distribution of the software without specific, written prior * permission. M.I.T. makes no representations about the suitability of * this software for any purpose. It is provided "as is" without express * or implied warranty. */ #ifndef __KEY_PROTO__ #define __KEY_PROTO__ #if !defined(P) #ifdef __STDC__ #define P(x) x #else #define P(x) () #endif #endif int key_file_exists P((void)); void key_lookup P((unsigned char *, Block)); void key_stream_init P((Block, Block, int)); unsigned char key_stream P((int, int)); #endif socks4-server-4.3.beta2.orig/rtelnet/libtelnet/mem.c100640 7657 764 4434 5606334302 20763 0ustar martinedv/*- * Copyright (c) 1990 The Regents of the University of California. * All rights reserved. * * This code is derived from software contributed to Berkeley by * Chris Torek. * * Redistribution and use in source and binary forms are permitted * provided that: (1) source distributions retain this entire copyright * notice and comment, and (2) distributions including binaries display * the following acknowledgement: ``This product includes software * developed by the University of California, Berkeley and its contributors'' * in the documentation or other materials provided with the distribution * and in all advertising materials mentioning features or use of this * software. Neither the name of the University nor the names of its * contributors may be used to endorse or promote products derived * from this software without specific prior written permission. * THIS SOFTWARE IS PROVIDED ``AS IS'' AND WITHOUT ANY EXPRESS OR * IMPLIED WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. */ #if defined(LIBC_SCCS) && !defined(lint) static char sccsid[] = "@(#)memcmp.c 5.5 (Berkeley) 5/15/90"; static char sccsid[] = "@(#)memcpy.c 5.6 (Berkeley) 5/15/90"; static char sccsid[] = "@(#)memmove.c 5.2 (Berkeley) 5/15/90"; static char sccsid[] = "@(#)memset.c 5.5 (Berkeley) 5/15/90"; #endif /* LIBC_SCCS and not lint */ #ifndef __STDC__ #define const #endif typedef int size_t; /* * Compare memory regions. */ int memcmp(s1, s2, n) const void *s1, *s2; size_t n; { if (n != 0) { register const unsigned char *p1 = (unsigned char *)s1, *p2 = (unsigned char *)s2; do { if (*p1++ != *p2++) return (*--p1 - *--p2); } while (--n != 0); } return (0); } /* * Copy a block of memory. */ void * memcpy(dst, src, n) void *dst; const void *src; size_t n; { bcopy((const char *)src, (char *)dst, n); return(dst); } /* * Copy a block of memory, handling overlap. */ void * memmove(dst, src, length) void *dst; const void *src; register size_t length; { bcopy((const char *)src, (char *)dst, length); return(dst); } void * memset(dst, c, n) void *dst; register int c; register size_t n; { if (n != 0) { register char *d = (char *)dst; do *d++ = c; while (--n != 0); } return (dst); } socks4-server-4.3.beta2.orig/rtelnet/libtelnet/misc-proto.h100640 7657 764 5005 5606334302 22301 0ustar martinedv/*- * Copyright (c) 1991 The Regents of the University of California. * All rights reserved. * * Redistribution and use in source and binary forms are permitted provided * that: (1) source distributions retain this entire copyright notice and * comment, and (2) distributions including binaries display the following * acknowledgement: ``This product includes software developed by the * University of California, Berkeley and its contributors'' in the * documentation or other materials provided with the distribution and in * all advertising materials mentioning features or use of this software. * Neither the name of the University nor the names of its contributors may * be used to endorse or promote products derived from this software without * specific prior written permission. * THIS SOFTWARE IS PROVIDED ``AS IS'' AND WITHOUT ANY EXPRESS OR IMPLIED * WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED WARRANTIES OF * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. * * @(#)misc-proto.h 5.1 (Berkeley) 2/28/91 */ /* * Copyright (C) 1990 by the Massachusetts Institute of Technology * * Export of this software from the United States of America is assumed * to require a specific license from the United States Government. * It is the responsibility of any person or organization contemplating * export to obtain such a license before exporting. * * WITHIN THAT CONSTRAINT, permission to use, copy, modify, and * distribute this software and its documentation for any purpose and * without fee is hereby granted, provided that the above copyright * notice appear in all copies and that both that copyright notice and * this permission notice appear in supporting documentation, and that * the name of M.I.T. not be used in advertising or publicity pertaining * to distribution of the software without specific, written prior * permission. M.I.T. makes no representations about the suitability of * this software for any purpose. It is provided "as is" without express * or implied warranty. */ #ifndef __MISC_PROTO__ #define __MISC_PROTO__ #if !defined(P) #ifdef __STDC__ #define P(x) x #else #define P(x) () #endif #endif void auth_encrypt_init P((char *, char *, char *, int)); void auth_encrypt_connect P((int)); void printd P((unsigned char *, int)); /* * These functions are imported from the application */ int net_write P((unsigned char *, int)); void net_encrypt P((void)); int telnet_spin P((void)); char *telnet_getenv P((char *)); char *telnet_gets P((char *, char *, int, int)); #endif socks4-server-4.3.beta2.orig/rtelnet/libtelnet/misc.c100640 7657 764 5522 6157327132 21144 0ustar martinedv/*- * Copyright (c) 1991 The Regents of the University of California. * All rights reserved. * * Redistribution and use in source and binary forms are permitted provided * that: (1) source distributions retain this entire copyright notice and * comment, and (2) distributions including binaries display the following * acknowledgement: ``This product includes software developed by the * University of California, Berkeley and its contributors'' in the * documentation or other materials provided with the distribution and in * all advertising materials mentioning features or use of this software. * Neither the name of the University nor the names of its contributors may * be used to endorse or promote products derived from this software without * specific prior written permission. * THIS SOFTWARE IS PROVIDED ``AS IS'' AND WITHOUT ANY EXPRESS OR IMPLIED * WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED WARRANTIES OF * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. */ #ifndef lint static char sccsid[] = "@(#)misc.c 5.1 (Berkeley) 2/28/91"; #endif /* not lint */ /* * Copyright (c) 1988, 1990 Regents of the University of California. * All rights reserved. * * Redistribution and use in source and binary forms are permitted provided * that: (1) source distributions retain this entire copyright notice and * comment, and (2) distributions including binaries display the following * acknowledgement: ``This product includes software developed by the * University of California, Berkeley and its contributors'' in the * documentation or other materials provided with the distribution and in * all advertising materials mentioning features or use of this software. * Neither the name of the University nor the names of its contributors may * be used to endorse or promote products derived from this software without * specific prior written permission. * THIS SOFTWARE IS PROVIDED ``AS IS'' AND WITHOUT ANY EXPRESS OR IMPLIED * WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED WARRANTIES OF * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. */ #include "misc.h" char *RemoteHostName; char *LocalHostName; char *UserNameRequested = 0; int ConnectedCount = 0; void auth_encrypt_init(local, remote, name, server) char *local; char *remote; char *name; int server; { RemoteHostName = remote; LocalHostName = local; #if defined(AUTHENTICATE) auth_init(name, server); #endif if (UserNameRequested) { free(UserNameRequested); UserNameRequested = 0; } } void auth_encrypt_user(name) char *name; { extern char *strdup(); if (UserNameRequested) free(UserNameRequested); UserNameRequested = name ? strdup(name) : 0; } void auth_encrypt_connect(cnt) int cnt; { } void printd(data, cnt) unsigned char *data; int cnt; { if (cnt > 16) cnt = 16; while (cnt-- > 0) { printf(" %02x", *data); ++data; } } socks4-server-4.3.beta2.orig/rtelnet/libtelnet/misc.h100640 7657 764 2277 5606334302 21150 0ustar martinedv/*- * Copyright (c) 1991 The Regents of the University of California. * All rights reserved. * * Redistribution and use in source and binary forms are permitted provided * that: (1) source distributions retain this entire copyright notice and * comment, and (2) distributions including binaries display the following * acknowledgement: ``This product includes software developed by the * University of California, Berkeley and its contributors'' in the * documentation or other materials provided with the distribution and in * all advertising materials mentioning features or use of this software. * Neither the name of the University nor the names of its contributors may * be used to endorse or promote products derived from this software without * specific prior written permission. * THIS SOFTWARE IS PROVIDED ``AS IS'' AND WITHOUT ANY EXPRESS OR IMPLIED * WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED WARRANTIES OF * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. * * @(#)misc.h 5.1 (Berkeley) 2/28/91 */ extern char *UserNameRequested; extern char *LocalHostName; extern char *RemoteHostName; extern int ConnectedCount; extern int ReservedPort; #include "misc-proto.h" socks4-server-4.3.beta2.orig/rtelnet/libtelnet/setenv.c100640 7657 764 7251 5606334303 21512 0ustar martinedv/* * Copyright (c) 1987 Regents of the University of California. * All rights reserved. * * Redistribution and use in source and binary forms are permitted * provided that the above copyright notice and this paragraph are * duplicated in all such forms and that any documentation, * advertising materials, and other materials related to such * distribution and use acknowledge that the software was developed * by the University of California, Berkeley. The name of the * University may not be used to endorse or promote products derived * from this software without specific prior written permission. * THIS SOFTWARE IS PROVIDED ``AS IS'' AND WITHOUT ANY EXPRESS OR * IMPLIED WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED * WARRANTIES OF MERCHANTIBILITY AND FITNESS FOR A PARTICULAR PURPOSE. */ #if defined(LIBC_SCCS) && !defined(lint) static char sccsid1[] = "@(#)setenv.c 5.3 (Berkeley) 5/16/90"; static char sccsid2[] = "@(#)getenv.c 5.6 (Berkeley) 5/16/90"; #endif /* LIBC_SCCS and not lint */ #if defined(SOLARIS) /* for bcopy() and bzero() */ #include "bstring.h" #endif /* * setenv -- * Set the value of the environmental variable "name" to be * "value". If rewrite is set, replace any current value. */ setenv(name, value, rewrite) register char *name, *value; int rewrite; { extern char **environ, *malloc(); static int alloced; /* if allocated space before */ register char *C; int l_value, offset; static char *_findenv(); if (*value == '=') /* no `=' in value */ ++value; l_value = strlen(value); if ((C = _findenv(name, &offset))) { /* find if already exists */ if (!rewrite) return(0); if (strlen(C) >= l_value) { /* old larger; copy over */ while (*C++ = *value++); return(0); } } else { /* create new slot */ register int cnt; register char **P; for (P = environ, cnt = 0; *P; ++P, ++cnt); if (alloced) { /* just increase size */ environ = (char **)realloc((char *)environ, (sizeof(char *) * (cnt + 2))); if (!environ) return(-1); } else { /* get new space */ alloced = 1; /* copy old entries into it */ P = (char **)malloc((sizeof(char *) * (cnt + 2))); if (!P) return(-1); bcopy(environ, P, cnt * sizeof(char *)); environ = P; } environ[cnt + 1] = 0; offset = cnt; } for (C = name; *C && *C != '='; ++C); /* no `=' in name */ if (!(environ[offset] = /* name + `=' + value */ malloc(((int)(C - name) + l_value + 2)))) return(-1); for (C = environ[offset]; (*C = *name++) && *C != '='; ++C); for (*C++ = '='; *C++ = *value++;); return(0); } /* * unsetenv(name) -- * Delete environmental variable "name". */ void unsetenv(name) char *name; { extern char **environ; register char **P; int offset; static char *_findenv(); while (_findenv(name, &offset)) /* if set multiple times */ for (P = &environ[offset];; ++P) if (!(*P = *(P + 1))) break; } /* * getenv -- * Returns ptr to value associated with name, if any, else NULL. */ char * getenv(name) char *name; { int offset; static char *_findenv(); return(_findenv(name, &offset)); } /* * _findenv -- * Returns pointer to value associated with name, if any, else NULL. * Sets offset to be the offset of the name/value combination in the * environmental array, for use by setenv(3) and unsetenv(3). * Explicitly removes '=' in argument name. */ static char * _findenv(name, offset) register char *name; int *offset; { extern char **environ; register int len; register char **P, *C; for (C = name, len = 0; *C && *C != '='; ++C, ++len); for (P = environ; *P; ++P) if (!strncmp(*P, name, len)) if (*(C = *P + len) == '=') { *offset = P - environ; return(++C); } return(0); } socks4-server-4.3.beta2.orig/rtelnet/libtelnet/setsid.c100640 7657 764 2441 5606334303 21475 0ustar martinedv/*- * Copyright (c) 1991 The Regents of the University of California. * All rights reserved. * * Redistribution and use in source and binary forms are permitted provided * that: (1) source distributions retain this entire copyright notice and * comment, and (2) distributions including binaries display the following * acknowledgement: ``This product includes software developed by the * University of California, Berkeley and its contributors'' in the * documentation or other materials provided with the distribution and in * all advertising materials mentioning features or use of this software. * Neither the name of the University nor the names of its contributors may * be used to endorse or promote products derived from this software without * specific prior written permission. * THIS SOFTWARE IS PROVIDED ``AS IS'' AND WITHOUT ANY EXPRESS OR IMPLIED * WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED WARRANTIES OF * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. */ #ifndef lint static char sccsid[] = "@(#)setsid.c 5.1 (Berkeley) 2/28/91"; #endif /* not lint */ /* * Emulate the functionality of setsid(), called when forking * and execing the new process. */ extern char *line; setsid() { #ifndef convex if (setpgrp(0, 0) < 0) return(-1); #endif return(0); } socks4-server-4.3.beta2.orig/rtelnet/libtelnet/strcasecmp.c100640 7657 764 7645 5606334303 22361 0ustar martinedv/* * Copyright (c) 1987 Regents of the University of California. * All rights reserved. * * Redistribution and use in source and binary forms are permitted * provided that: (1) source distributions retain this entire copyright * notice and comment, and (2) distributions including binaries display * the following acknowledgement: ``This product includes software * developed by the University of California, Berkeley and its contributors'' * in the documentation or other materials provided with the distribution * and in all advertising materials mentioning features or use of this * software. Neither the name of the University nor the names of its * contributors may be used to endorse or promote products derived * from this software without specific prior written permission. * THIS SOFTWARE IS PROVIDED ``AS IS'' AND WITHOUT ANY EXPRESS OR * IMPLIED WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. */ #if defined(LIBC_SCCS) && !defined(lint) static char sccsid[] = "@(#)strcasecmp.c 5.9 (Berkeley) 6/1/90"; #endif /* LIBC_SCCS and not lint */ typedef unsigned char u_char; /* * This array is designed for mapping upper and lower case letter * together for a case independent comparison. The mappings are * based upon ascii character sequences. */ static u_char charmap[] = { '\000', '\001', '\002', '\003', '\004', '\005', '\006', '\007', '\010', '\011', '\012', '\013', '\014', '\015', '\016', '\017', '\020', '\021', '\022', '\023', '\024', '\025', '\026', '\027', '\030', '\031', '\032', '\033', '\034', '\035', '\036', '\037', '\040', '\041', '\042', '\043', '\044', '\045', '\046', '\047', '\050', '\051', '\052', '\053', '\054', '\055', '\056', '\057', '\060', '\061', '\062', '\063', '\064', '\065', '\066', '\067', '\070', '\071', '\072', '\073', '\074', '\075', '\076', '\077', '\100', '\141', '\142', '\143', '\144', '\145', '\146', '\147', '\150', '\151', '\152', '\153', '\154', '\155', '\156', '\157', '\160', '\161', '\162', '\163', '\164', '\165', '\166', '\167', '\170', '\171', '\172', '\133', '\134', '\135', '\136', '\137', '\140', '\141', '\142', '\143', '\144', '\145', '\146', '\147', '\150', '\151', '\152', '\153', '\154', '\155', '\156', '\157', '\160', '\161', '\162', '\163', '\164', '\165', '\166', '\167', '\170', '\171', '\172', '\173', '\174', '\175', '\176', '\177', '\200', '\201', '\202', '\203', '\204', '\205', '\206', '\207', '\210', '\211', '\212', '\213', '\214', '\215', '\216', '\217', '\220', '\221', '\222', '\223', '\224', '\225', '\226', '\227', '\230', '\231', '\232', '\233', '\234', '\235', '\236', '\237', '\240', '\241', '\242', '\243', '\244', '\245', '\246', '\247', '\250', '\251', '\252', '\253', '\254', '\255', '\256', '\257', '\260', '\261', '\262', '\263', '\264', '\265', '\266', '\267', '\270', '\271', '\272', '\273', '\274', '\275', '\276', '\277', '\300', '\301', '\302', '\303', '\304', '\305', '\306', '\307', '\310', '\311', '\312', '\313', '\314', '\315', '\316', '\317', '\320', '\321', '\322', '\323', '\324', '\325', '\326', '\327', '\330', '\331', '\332', '\333', '\334', '\335', '\336', '\337', '\340', '\341', '\342', '\343', '\344', '\345', '\346', '\347', '\350', '\351', '\352', '\353', '\354', '\355', '\356', '\357', '\360', '\361', '\362', '\363', '\364', '\365', '\366', '\367', '\370', '\371', '\372', '\373', '\374', '\375', '\376', '\377', }; int strcasecmp(s1, s2) char *s1, *s2; { register u_char *cm = charmap, *us1 = (u_char *)s1, *us2 = (u_char *)s2; while (cm[*us1] == cm[*us2++]) if (*us1++ == '\0') return (0); return (cm[*us1] - cm[*--us2]); } int strncasecmp(s1, s2, n) char *s1, *s2; register int n; { if (n != 0) { register u_char *cm = charmap, *us1 = (u_char *)s1, *us2 = (u_char *)s2; do { if (cm[*us1] != cm[*us2++]) return (cm[*us1] - cm[*--us2]); if (*us1++ == '\0') break; } while (--n != 0); } return (0); } socks4-server-4.3.beta2.orig/rtelnet/libtelnet/strchr.c100640 7657 764 2112 5606334303 21502 0ustar martinedv/* * Copyright (c) 1988 Regents of the University of California. * All rights reserved. * * Redistribution and use in source and binary forms are permitted * provided that the above copyright notice and this paragraph are * duplicated in all such forms and that any documentation, * advertising materials, and other materials related to such * distribution and use acknowledge that the software was developed * by the University of California, Berkeley. The name of the * University may not be used to endorse or promote products derived * from this software without specific prior written permission. * THIS SOFTWARE IS PROVIDED ``AS IS'' AND WITHOUT ANY EXPRESS OR * IMPLIED WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED * WARRANTIES OF MERCHANTIBILITY AND FITNESS FOR A PARTICULAR PURPOSE. */ #if defined(LIBC_SCCS) && !defined(lint) static char sccsid[] = "@(#)strchr.c 5.5 (Berkeley) 5/15/90"; #endif /* LIBC_SCCS and not lint */ #ifdef NO_STRING_H #include #else #include #endif char * strchr(p, ch) char *p, ch; { return(index(p, ch)); } socks4-server-4.3.beta2.orig/rtelnet/libtelnet/strdup.c100640 7657 764 2744 5606334303 21531 0ustar martinedv/* * Copyright (c) 1988 The Regents of the University of California. * All rights reserved. * * Redistribution and use in source and binary forms are permitted * provided that: (1) source distributions retain this entire copyright * notice and comment, and (2) distributions including binaries display * the following acknowledgement: ``This product includes software * developed by the University of California, Berkeley and its contributors'' * in the documentation or other materials provided with the distribution * and in all advertising materials mentioning features or use of this * software. Neither the name of the University nor the names of its * contributors may be used to endorse or promote products derived * from this software without specific prior written permission. * THIS SOFTWARE IS PROVIDED ``AS IS'' AND WITHOUT ANY EXPRESS OR * IMPLIED WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. */ #if defined(LIBC_SCCS) && !defined(lint) static char sccsid[] = "@(#)strdup.c 5.3 (Berkeley) 6/1/90"; #endif /* LIBC_SCCS and not lint */ #include #ifdef NO_STRING_H #include #else #include #endif #ifdef SOLARIS /* for bcopy() and bzero() */ #include "bstring.h" #endif char * strdup(str) char *str; { int len; char *copy, *malloc(); len = strlen(str) + 1; if (!(copy = malloc((u_int)len))) return((char *)0); bcopy(str, copy, len); return(copy); } socks4-server-4.3.beta2.orig/rtelnet/libtelnet/strerror.c100640 7657 764 2733 5606334303 22070 0ustar martinedv/* * Copyright (c) 1988 Regents of the University of California. * All rights reserved. * * Redistribution and use in source and binary forms are permitted provided * that: (1) source distributions retain this entire copyright notice and * comment, and (2) distributions including binaries display the following * acknowledgement: ``This product includes software developed by the * University of California, Berkeley and its contributors'' in the * documentation or other materials provided with the distribution and in * all advertising materials mentioning features or use of this software. * Neither the name of the University nor the names of its contributors may * be used to endorse or promote products derived from this software without * specific prior written permission. * THIS SOFTWARE IS PROVIDED ``AS IS'' AND WITHOUT ANY EXPRESS OR IMPLIED * WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED WARRANTIES OF * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. */ #if defined(LIBC_SCCS) && !defined(lint) static char sccsid[] = "@(#)strerror.c 5.4 (Berkeley) 6/24/90"; #endif /* LIBC_SCCS and not lint */ #ifdef NO_STRING_H #include #else #include #endif char * strerror(errnum) int errnum; { extern int sys_nerr; extern char *sys_errlist[]; static char ebuf[40]; /* 64-bit number + slop */ if ((unsigned int)errnum < sys_nerr) return(sys_errlist[errnum]); (void)sprintf(ebuf, "Unknown error: %d", errnum); return(ebuf); } socks4-server-4.3.beta2.orig/rtelnet/libtelnet/strftime.c100640 7657 764 13132 5606334304 22057 0ustar martinedv/* * Copyright (c) 1989 The Regents of the University of California. * All rights reserved. * * Redistribution and use in source and binary forms are permitted * provided that: (1) source distributions retain this entire copyright * notice and comment, and (2) distributions including binaries display * the following acknowledgement: ``This product includes software * developed by the University of California, Berkeley and its contributors'' * in the documentation or other materials provided with the distribution * and in all advertising materials mentioning features or use of this * software. Neither the name of the University nor the names of its * contributors may be used to endorse or promote products derived * from this software without specific prior written permission. * THIS SOFTWARE IS PROVIDED ``AS IS'' AND WITHOUT ANY EXPRESS OR * IMPLIED WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. */ #if defined(LIBC_SCCS) && !defined(lint) static char sccsid[] = "@(#)strftime.c 5.8 (Berkeley) 6/1/90"; #endif /* LIBC_SCCS and not lint */ #include #include #define TM_YEAR_BASE 1900 /* from */ #ifdef NO_STRING_H #include #else #include #endif static char *afmt[] = { "Sun", "Mon", "Tue", "Wed", "Thu", "Fri", "Sat", }; static char *Afmt[] = { "Sunday", "Monday", "Tuesday", "Wednesday", "Thursday", "Friday", "Saturday", }; static char *bfmt[] = { "Jan", "Feb", "Mar", "Apr", "May", "Jun", "Jul", "Aug", "Sep", "Oct", "Nov", "Dec", }; static char *Bfmt[] = { "January", "February", "March", "April", "May", "June", "July", "August", "September", "October", "November", "December", }; static size_t gsize; static char *pt; size_t strftime(s, maxsize, format, t) char *s; char *format; size_t maxsize; struct tm *t; { size_t _fmt(); pt = s; if ((gsize = maxsize) < 1) return(0); if (_fmt(format, t)) { *pt = '\0'; return(maxsize - gsize); } return(0); } static size_t _fmt(format, t) register char *format; struct tm *t; { for (; *format; ++format) { if (*format == '%') switch(*++format) { case '\0': --format; break; case 'A': if (t->tm_wday < 0 || t->tm_wday > 6) return(0); if (!_add(Afmt[t->tm_wday])) return(0); continue; case 'a': if (t->tm_wday < 0 || t->tm_wday > 6) return(0); if (!_add(afmt[t->tm_wday])) return(0); continue; case 'B': if (t->tm_mon < 0 || t->tm_mon > 11) return(0); if (!_add(Bfmt[t->tm_mon])) return(0); continue; case 'b': case 'h': if (t->tm_mon < 0 || t->tm_mon > 11) return(0); if (!_add(bfmt[t->tm_mon])) return(0); continue; case 'C': if (!_fmt("%a %b %e %H:%M:%S %Y", t)) return(0); continue; case 'c': if (!_fmt("%m/%d/%y %H:%M:%S", t)) return(0); continue; case 'e': if (!_conv(t->tm_mday, 2, ' ')) return(0); continue; case 'D': if (!_fmt("%m/%d/%y", t)) return(0); continue; case 'd': if (!_conv(t->tm_mday, 2, '0')) return(0); continue; case 'H': if (!_conv(t->tm_hour, 2, '0')) return(0); continue; case 'I': if (!_conv(t->tm_hour % 12 ? t->tm_hour % 12 : 12, 2, '0')) return(0); continue; case 'j': if (!_conv(t->tm_yday + 1, 3, '0')) return(0); continue; case 'k': if (!_conv(t->tm_hour, 2, ' ')) return(0); continue; case 'l': if (!_conv(t->tm_hour % 12 ? t->tm_hour % 12 : 12, 2, ' ')) return(0); continue; case 'M': if (!_conv(t->tm_min, 2, '0')) return(0); continue; case 'm': if (!_conv(t->tm_mon + 1, 2, '0')) return(0); continue; case 'n': if (!_add("\n")) return(0); continue; case 'p': if (!_add(t->tm_hour >= 12 ? "PM" : "AM")) return(0); continue; case 'R': if (!_fmt("%H:%M", t)) return(0); continue; case 'r': if (!_fmt("%I:%M:%S %p", t)) return(0); continue; case 'S': if (!_conv(t->tm_sec, 2, '0')) return(0); continue; case 'T': case 'X': if (!_fmt("%H:%M:%S", t)) return(0); continue; case 't': if (!_add("\t")) return(0); continue; case 'U': if (!_conv((t->tm_yday + 7 - t->tm_wday) / 7, 2, '0')) return(0); continue; case 'W': if (!_conv((t->tm_yday + 7 - (t->tm_wday ? (t->tm_wday - 1) : 6)) / 7, 2, '0')) return(0); continue; case 'w': if (!_conv(t->tm_wday, 1, '0')) return(0); continue; case 'x': if (!_fmt("%m/%d/%y", t)) return(0); continue; case 'y': if (!_conv((t->tm_year + TM_YEAR_BASE) % 100, 2, '0')) return(0); continue; case 'Y': if (!_conv(t->tm_year + TM_YEAR_BASE, 4, '0')) return(0); continue; #ifdef notdef case 'Z': if (!t->tm_zone || !_add(t->tm_zone)) return(0); continue; #endif case '%': /* * X311J/88-090 (4.12.3.5): if conversion char is * undefined, behavior is undefined. Print out the * character itself as printf(3) does. */ default: break; } if (!gsize--) return(0); *pt++ = *format; } return(gsize); } static _conv(n, digits, pad) int n, digits; char pad; { static char buf[10]; register char *p; for (p = buf + sizeof(buf) - 2; n > 0 && p > buf; n /= 10, --digits) *p-- = n % 10 + '0'; while (p > buf && digits-- > 0) *p-- = pad; return(_add(++p)); } static _add(str) register char *str; { for (;; ++pt, --gsize) { if (!gsize) return(0); if (!(*pt = *str++)) return(1); } } socks4-server-4.3.beta2.orig/rtelnet/libtelnet/strrchr.c100640 7657 764 2115 5606334304 21670 0ustar martinedv/* * Copyright (c) 1988 Regents of the University of California. * All rights reserved. * * Redistribution and use in source and binary forms are permitted * provided that the above copyright notice and this paragraph are * duplicated in all such forms and that any documentation, * advertising materials, and other materials related to such * distribution and use acknowledge that the software was developed * by the University of California, Berkeley. The name of the * University may not be used to endorse or promote products derived * from this software without specific prior written permission. * THIS SOFTWARE IS PROVIDED ``AS IS'' AND WITHOUT ANY EXPRESS OR * IMPLIED WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED * WARRANTIES OF MERCHANTIBILITY AND FITNESS FOR A PARTICULAR PURPOSE. */ #if defined(LIBC_SCCS) && !defined(lint) static char sccsid[] = "@(#)strrchr.c 5.6 (Berkeley) 5/17/90"; #endif /* LIBC_SCCS and not lint */ #ifdef NO_STRING_H #include #else #include #endif char * strrchr(p, ch) char *p, ch; { return(rindex(p, ch)); } socks4-server-4.3.beta2.orig/rtelnet/stty.diff100640 7657 764 2727 5606334315 17723 0ustar martinedv*** stty.c.old Tue May 23 13:54:29 1989 --- stty.c Wed Aug 23 13:42:32 1989 *************** *** 20,25 **** --- 20,28 ---- #include #include + #include + #define NO_T_CHARS_DEFINES + #include struct { *************** *** 145,150 **** --- 148,156 ---- struct winsize win; int lmode; int oldisc, ldisc; + #ifdef TIOCGSTATE + int extproc; + #endif struct special { char *name; *************** *** 188,193 **** --- 194,203 ---- ioctl(1, TIOCLGET, &lmode); ioctl(1, TIOCGLTC, <c); ioctl(1, TIOCGWINSZ, &win); + #ifdef TIOCGSTATE + ioctl(1, TIOCGSTATE, &extproc); + extproc &= TS_EXTPROC; + #endif if(argc == 1) { prmodes(0); exit(0); *************** *** 292,297 **** --- 302,316 ---- printf("%d %d\n", win.ws_row, win.ws_col); exit(0); } + #if defined(TIOCEXT) + if (eq("extproc") || eq("-extproc")) { + if (**argv == '-') + extproc = 0; + else + extproc = 1; + ioctl(1, TIOCEXT, &extproc); + } + #endif for(i=0; speeds[i].string; i++) if(eq(speeds[i].string)) { mode.sg_ispeed = mode.sg_ospeed = speeds[i].speed; *************** *** 438,443 **** --- 457,468 ---- lpit(LPENDIN, "-pendin "); lpit(LDECCTQ, "-decctlq "); lpit(LNOFLSH, "-noflsh "); + #ifdef TIOCGSTATE + if (all==2||extproc) { + fprintf(stderr,"-extproc"+(extproc!=0)); + any++; + } + #endif if (any || nothing) fprintf(stderr,"\n"); } else if (!all) socks4-server-4.3.beta2.orig/rtelnet/telnet/ 40755 7657 764 0 6157343251 17261 5ustar martinedvsocks4-server-4.3.beta2.orig/rtelnet/telnet/Makefile100640 7657 764 5217 5606334304 21014 0ustar martinedv# # Copyright (c) 1991 The Regents of the University of California. # All rights reserved. # # Redistribution and use in source and binary forms are permitted provided # that: (1) source distributions retain this entire copyright notice and # comment, and (2) distributions including binaries display the following # acknowledgement: ``This product includes software developed by the # University of California, Berkeley and its contributors'' in the # documentation or other materials provided with the distribution and in # all advertising materials mentioning features or use of this software. # Neither the name of the University nor the names of its contributors may # be used to endorse or promote products derived from this software without # specific prior written permission. # THIS SOFTWARE IS PROVIDED ``AS IS'' AND WITHOUT ANY EXPRESS OR IMPLIED # WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED WARRANTIES OF # MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. # # @(#)Makefile 5.5 (Berkeley) 3/1/91 # # # Everything happens in ../Makefile.config and Makefile.generic # SOCKS=-DSOCKS # or #SOCKS=-Dconnect=Rconnect -Dgetsockname=Rgetsockname -Dlisten=Rlisten -Daccept=Raccept -Drcmd=Rrcmd -Dbind=Rbind -Dselect=Rselect SOCKS_LIB=../../lib/libsocks.a #RESOLV_LIB=-lresolv all: @-if [ -f ../Config.local ]; \ then \ echo ${MAKE} -f ../Config.local WHAT=${WHAT} CC="${CC}" \ OPTIMIZE="${OPTIMIZE}" SOCKS="${SOCKS}" \ SOCKS_LIB=${SOCKS_LIB} RESOLV_LIB="${RESOLV_LIB}" ;\ ${MAKE} -f ../Config.local WHAT=${WHAT} CC="${CC}" \ OPTIMIZE="${OPTIMIZE}" SOCKS="${SOCKS}" \ SOCKS_LIB=${SOCKS_LIB} RESOLV_LIB="${RESOLV_LIB}" ;\ else \ echo ${MAKE} -f ../Config.generic WHAT=${WHAT} CC="${CC}" \ OPTIMIZE="${OPTIMIZE}" SOCKS="${SOCKS}" \ SOCKS_LIB=${SOCKS_LIB} RESOLV_LIB="${RESOLV_LIB}" ;\ ${MAKE} -f ../Config.generic WHAT=${WHAT} CC="${CC}" \ OPTIMIZE="${OPTIMIZE}" SOCKS="${SOCKS}" \ SOCKS_LIB=${SOCKS_LIB} RESOLV_LIB="${RESOLV_LIB}" ;\ fi .DEFAULT: @-if [ -f ../Config.local ]; \ then \ echo ${MAKE} -f ../Config.local WHAT=${WHAT} CC="${CC}" \ OPTIMIZE="${OPTIMIZE}" SOCKS="${SOCKS}" \ SOCKS_LIB=${SOCKS_LIB} RESOLV_LIB="${RESOLV_LIB}" $@;\ ${MAKE} -f ../Config.local WHAT=${WHAT} CC="${CC}" \ OPTIMIZE="${OPTIMIZE}" SOCKS="${SOCKS}" \ SOCKS_LIB=${SOCKS_LIB} RESOLV_LIB="${RESOLV_LIB}" $@;\ else \ echo ${MAKE} -f ../Config.generic WHAT=${WHAT} CC="${CC}" \ OPTIMIZE="${OPTIMIZE}" SOCKS="${SOCKS}" \ SOCKS_LIB=${SOCKS_LIB} RESOLV_LIB="${RESOLV_LIB}" $@;\ ${MAKE} -f ../Config.generic WHAT=${WHAT} CC="${CC}" \ OPTIMIZE="${OPTIMIZE}" SOCKS="${SOCKS}" \ SOCKS_LIB=${SOCKS_LIB} RESOLV_LIB="${RESOLV_LIB}" $@;\ fi socks4-server-4.3.beta2.orig/rtelnet/telnet/Makefile.4.4100640 7657 764 2521 5606334304 21313 0ustar martinedv# # Copyright (c) 1990 The Regents of the University of California. # All rights reserved. # # Redistribution and use in source and binary forms are permitted provided # that: (1) source distributions retain this entire copyright notice and # comment, and (2) distributions including binaries display the following # acknowledgement: ``This product includes software developed by the # University of California, Berkeley and its contributors'' in the # documentation or other materials provided with the distribution and in # all advertising materials mentioning features or use of this software. # Neither the name of the University nor the names of its contributors may # be used to endorse or promote products derived from this software without # specific prior written permission. # THIS SOFTWARE IS PROVIDED ``AS IS'' AND WITHOUT ANY EXPRESS OR IMPLIED # WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED WARRANTIES OF # MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. # # @(#)Makefile 5.6 (Berkeley) 3/5/91 # PROG= telnet CFLAGS+=-DTERMCAP -DKLUDGELINEMODE -DUSE_TERMIO -DAUTHENTICATE -DENCRYPT CFLAGS+=-I${.CURDIR}/../../lib CFLAGS+= -DKRB4 LDADD= -ltermcap -ltelnet LDADD+= -lkrb -ldes DPADD= ${LIBTERMCAP} SRCS= authenc.c commands.c main.c network.c ring.c sys_bsd.c telnet.c \ terminal.c tn3270.c utilities.c .include socks4-server-4.3.beta2.orig/rtelnet/telnet/Makefile.generic100640 7657 764 5715 5606334305 22433 0ustar martinedv# # Copyright (c) 1991 The Regents of the University of California. # All rights reserved. # # Redistribution and use in source and binary forms are permitted provided # that: (1) source distributions retain this entire copyright notice and # comment, and (2) distributions including binaries display the following # acknowledgement: ``This product includes software developed by the # University of California, Berkeley and its contributors'' in the # documentation or other materials provided with the distribution and in # all advertising materials mentioning features or use of this software. # Neither the name of the University nor the names of its contributors may # be used to endorse or promote products derived from this software without # specific prior written permission. # THIS SOFTWARE IS PROVIDED ``AS IS'' AND WITHOUT ANY EXPRESS OR IMPLIED # WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED WARRANTIES OF # MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. # # @(#)Makefile.generic 5.5 (Berkeley) 3/1/91 # # Directory into which rtelnet program will be installed: BIN_DEST_DIR=/usr/local/bin # Directory into which rtelnet's man page file will be installed: MAN_DEST_DIR=/usr/local/man/man1 #============================================================= INCLUDES= -I.. -I../../include ARPA_TELNET= ../arpa/telnet.h SRCS= commands.c main.c network.c ring.c \ sys_bsd.c telnet.c terminal.c \ utilities.c ${GETOPT_SRC} CFLAGS= ${LCCFLAGS} ${INCLUDES} ${DEFINES} ALLHC= ${SRCS} \ defines.h externs.h fdset.h general.h \ ring.h types.h OBJS= authenc.o commands.o main.o network.o ring.o sys_bsd.o \ telnet.o terminal.o utilities.o ${GETOPT_OBJ} MAN= telnet.0 # # These next three lines are not needed in 4.4BSD # .SUFFIXES: .0 .1 .1.0: nroff -man -h $< > $@ all: ../rtelnet ../rtelnet: ${OBJS} ${LIBPATH} ${CC} -o $@ ${CFLAGS} ${OBJS} ${LIBS} clean: FRC rm -f ${OBJS} core errs l.errs ../rtelnet cleandir: clean rm -f ${MAN} tags .depend clist: FRC ${SRCS} @for i in ${SRCS} ; \ do (echo ${DIRPATH}$$i); done hclist: FRC ${ALLHC} @for i in ${ALLHC} ; \ do (echo ${DIRPATH}$$i); done depend: FRC ${SRCS} mkdep ${CFLAGS} `make clist` install: ${MAN} FRC install -s -o bin -g bin -m 111 ../rtelnet ${BIN_DEST_DIR} install -c -o bin -g bin -m 444 rtelnet.1 ${MAN_DEST_DIR} lint: FRC ${SRCS} lint ${CFLAGS} `make clist` tags: FRC ${SRCS} ctags `make hclist` FRC: authenc.o: defines.h externs.h general.h ring.h types.h ${ARPA_TELNET} commands.o: defines.h externs.h general.h ring.h types.h ${ARPA_TELNET} main.o: defines.h externs.h ring.h network.o: defines.h externs.h fdset.h ring.h ${ARPA_TELNET} ring.o: general.h ring.h sys_bsd.o: defines.h externs.h fdset.h ring.h types.h ${ARPA_TELNET} telnet.o: defines.h externs.h general.h ring.h types.h ${ARPA_TELNET} terminal.o: externs.h ring.h types.h ${ARPA_TELNET} tn3270.o: defines.h externs.h fdset.h general.h ring.h ${ARPA_TELNET} utilities.o: defines.h externs.h fdset.h general.h ring.h ${ARPA_TELNET} socks4-server-4.3.beta2.orig/rtelnet/telnet/authenc.c100640 7657 764 4144 6157327247 21157 0ustar martinedv/*- * Copyright (c) 1991 The Regents of the University of California. * All rights reserved. * * Redistribution and use in source and binary forms are permitted provided * that: (1) source distributions retain this entire copyright notice and * comment, and (2) distributions including binaries display the following * acknowledgement: ``This product includes software developed by the * University of California, Berkeley and its contributors'' in the * documentation or other materials provided with the distribution and in * all advertising materials mentioning features or use of this software. * Neither the name of the University nor the names of its contributors may * be used to endorse or promote products derived from this software without * specific prior written permission. * THIS SOFTWARE IS PROVIDED ``AS IS'' AND WITHOUT ANY EXPRESS OR IMPLIED * WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED WARRANTIES OF * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. */ #ifndef lint static char sccsid[] = "@(#)authenc.c 5.1 (Berkeley) 3/1/91"; #endif /* not lint */ #if defined(AUTHENTICATE) #include #include #include #include #include "general.h" #include "ring.h" #include "externs.h" #include "defines.h" #include "types.h" int net_write(str, len) unsigned char *str; int len; { if (NETROOM() > len) { ring_supply_data(&netoring, str, len); if (str[0] == IAC && str[1] == SE) printsub('>', &str[2], len-2); return(len); } return(0); } void net_encrypt() { } int telnet_spin() { return(-1); } char * telnet_getenv(val) char *val; { return((char *)env_getvalue((unsigned char *)val)); } char * telnet_gets(prompt, result, length, echo) char *prompt; char *result; int length; int echo; { extern char *getpass(); extern int globalmode; int om = globalmode; char *res; TerminalNewMode(-1); if (echo) { printf("%s", prompt); res = fgets(result, length, stdin); } else if (res = getpass(prompt)) { strncpy(result, res, length); res = result; } TerminalNewMode(om); return(res); } #endif socks4-server-4.3.beta2.orig/rtelnet/telnet/commands.c100640 7657 764 171642 6157343250 21371 0ustar martinedv/* Copyright (c) 1988, 1990 Regents of the University of California. * All rights reserved. * * Redistribution and use in source and binary forms are permitted provided * that: (1) source distributions retain this entire copyright notice and * comment, and (2) distributions including binaries display the following * acknowledgement: ``This product includes software developed by the * University of California, Berkeley and its contributors'' in the * documentation or other materials provided with the distribution and in * all advertising materials mentioning features or use of this software. * Neither the name of the University nor the names of its contributors may * be used to endorse or promote products derived from this software without * specific prior written permission. * THIS SOFTWARE IS PROVIDED ``AS IS'' AND WITHOUT ANY EXPRESS OR IMPLIED * WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED WARRANTIES OF * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. */ #ifndef lint static char sccsid[] = "@(#)commands.c 5.4 (Berkeley) 3/1/91"; #endif /* not lint */ #if defined(unix) #include #if defined(CRAY) || defined(SCO) || defined(ISC) #include #endif #include #else #include #endif /* defined(unix) */ #include #include #ifdef CRAY #include #endif /* CRAY */ #include #include #include #include #ifdef __STDC__ #include #else #include #define USE_VARARGS #endif #include #if defined(ISC) #include #endif /* #if defined(ISC) */ #include #include "general.h" #include "ring.h" #include "externs.h" #include "defines.h" #include "types.h" #ifndef LINUX #ifndef CRAY #include # if (defined(vax) || defined(tahoe) || defined(hp300)) && !defined(ultrix) # include # endif /* vax */ #endif /* CRAY */ #include #endif /* LINUX */ #if defined(SOLARIS) || defined(_SEQUENT_) #include "bstring.h" #endif #if defined(AIX) || defined(DGUX) #undef IP_TOS #endif #ifndef MAXHOSTNAMELEN #define MAXHOSTNAMELEN 64 #endif /* #ifndef MAXHOSTNAMELEN */ #ifdef __alpha typedef unsigned int u_int32; #else typedef unsigned long u_int32; #endif /* >>> H.Naef, nexos ag */ #if !defined(INADDR_NONE) #define INADDR_NONE (u_int32) 0xffffffff #endif /* !defined(INADDR_NONE) */ /* <<< H.Naef, nexos ag */ #if defined(IPPROTO_IP) && defined(IP_TOS) int tos = -1; #endif /* defined(IPPROTO_IP) && defined(IP_TOS) */ char *hostname; static char _hostname[MAXHOSTNAMELEN]; extern char *getenv(); #ifdef SOLARIS extern void send_will(); extern void send_wont(); extern void send_do(); extern void send_dont(); #endif extern int isprefix(); extern char **genget(); extern int Ambiguous(); typedef struct { char *name; /* command name */ char *help; /* help string (NULL for no help) */ int (*handler)(); /* routine which executes command */ int needconnect; /* Do we need to be connected to execute? */ } Command; static char line[256]; static char saveline[256]; static int margc; static char *margv[20]; static void makeargv() { register char *cp, *cp2, c; register char **argp = margv; margc = 0; cp = line; if (*cp == '!') { /* Special case shell escape */ strcpy(saveline, line); /* save for shell command */ *argp++ = "!"; /* No room in string to get this */ margc++; cp++; } while (c = *cp) { register int inquote = 0; while (isspace(c)) c = *++cp; if (c == '\0') break; *argp++ = cp; margc += 1; for (cp2 = cp; c != '\0'; c = *++cp) { if (inquote) { if (c == inquote) { inquote = 0; continue; } } else { if (c == '\\') { if ((c = *++cp) == '\0') break; } else if (c == '"') { inquote = '"'; continue; } else if (c == '\'') { inquote = '\''; continue; } else if (isspace(c)) break; } *cp2++ = c; } *cp2 = '\0'; if (c == '\0') break; cp++; } *argp++ = 0; } /* /* * Call routine with argc, argv set from args (terminated by 0). */ typedef int (*intrtn_t)(); /*VARARGS1*/ static #ifdef USE_VARARGS call(va_alist) va_dcl #else call(intrtn_t routine, ...) #endif { va_list ap; #ifdef USE_VARARGS intrtn_t routine; #endif char *args[100]; int argno = 0; #ifdef USE_VARARGS va_start(ap); routine = (va_arg(ap, intrtn_t)); #else va_start(ap, routine); #endif while ((args[argno++] = va_arg(ap, char *)) != 0) { ; } va_end(ap); return (*routine)(argno-1, args); } /* * Make a character string into a number. * * Todo: 1. Could take random integers (12, 0x12, 012, 0b1). */ static special(s) register char *s; { register char c; char b; switch (*s) { case '^': b = *++s; if (b == '?') { c = b | 0x40; /* DEL */ } else { c = b & 0x1f; } break; default: c = *s; break; } return c; } /* * Construct a control character sequence * for a special character. */ static char * control(c) register cc_t c; { static char buf[5]; /* * The only way I could get the Sun 3.5 compiler * to shut up about * if ((unsigned int)c >= 0x80) * was to assign "c" to an unsigned int variable... * Arggg.... */ register unsigned int uic = (unsigned int)c; if (uic == 0x7f) return ("^?"); if (c == (cc_t)_POSIX_VDISABLE) { return "off"; } if (uic >= 0x80) { buf[0] = '\\'; buf[1] = ((c>>6)&07) + '0'; buf[2] = ((c>>3)&07) + '0'; buf[3] = (c&07) + '0'; buf[4] = 0; } else if (uic >= 0x20) { buf[0] = c; buf[1] = 0; } else { buf[0] = '^'; buf[1] = '@'+c; buf[2] = 0; } return (buf); } /* * The following are data structures and routines for * the "send" command. * */ struct sendlist { char *name; /* How user refers to it (case independent) */ char *help; /* Help information (0 ==> no help) */ int needconnect; /* Need to be connected */ int narg; /* Number of arguments */ int (*handler)(); /* Routine to perform (for special ops) */ int nbyte; /* Number of bytes to send this command */ int what; /* Character to be sent (<0 ==> special) */ }; extern int send_esc P((void)), send_help P((void)), send_docmd P((char *)), send_dontcmd P((char *)), send_willcmd P((char *)), send_wontcmd P((char *)); static struct sendlist Sendlist[] = { { "ao", "Send Telnet Abort output", 1, 0, 0, 2, AO }, { "ayt", "Send Telnet 'Are You There'", 1, 0, 0, 2, AYT }, { "brk", "Send Telnet Break", 1, 0, 0, 2, BREAK }, { "break", 0, 1, 0, 0, 2, BREAK }, { "ec", "Send Telnet Erase Character", 1, 0, 0, 2, EC }, { "el", "Send Telnet Erase Line", 1, 0, 0, 2, EL }, { "escape", "Send current escape character", 1, 0, send_esc, 1, 0 }, { "ga", "Send Telnet 'Go Ahead' sequence", 1, 0, 0, 2, GA }, { "ip", "Send Telnet Interrupt Process", 1, 0, 0, 2, IP }, { "intp", 0, 1, 0, 0, 2, IP }, { "interrupt", 0, 1, 0, 0, 2, IP }, { "intr", 0, 1, 0, 0, 2, IP }, { "nop", "Send Telnet 'No operation'", 1, 0, 0, 2, NOP }, { "eor", "Send Telnet 'End of Record'", 1, 0, 0, 2, EOR }, { "abort", "Send Telnet 'Abort Process'", 1, 0, 0, 2, ABORT }, { "susp", "Send Telnet 'Suspend Process'", 1, 0, 0, 2, SUSP }, { "eof", "Send Telnet End of File Character", 1, 0, 0, 2, xEOF }, { "synch", "Perform Telnet 'Synch operation'", 1, 0, dosynch, 2, 0 }, { "getstatus", "Send request for STATUS", 1, 0, get_status, 6, 0 }, { "?", "Display send options", 0, 0, send_help, 0, 0 }, { "help", 0, 0, 0, send_help, 0, 0 }, { "do", 0, 0, 1, send_docmd, 3, 0 }, { "dont", 0, 0, 1, send_dontcmd, 3, 0 }, { "will", 0, 0, 1, send_willcmd, 3, 0 }, { "wont", 0, 0, 1, send_wontcmd, 3, 0 }, { 0 } }; #define GETSEND(name) ((struct sendlist *) genget(name, (char **) Sendlist, \ sizeof(struct sendlist))) static int sendcmd(argc, argv) int argc; char **argv; { int what; /* what we are sending this time */ int count; /* how many bytes we are going to need to send */ int i; int question = 0; /* was at least one argument a question */ struct sendlist *s; /* pointer to current command */ int success = 0; int needconnect = 0; if (argc < 2) { printf("need at least one argument for 'send' command\n"); printf("'send ?' for help\n"); return 0; } /* * First, validate all the send arguments. * In addition, we see how much space we are going to need, and * whether or not we will be doing a "SYNCH" operation (which * flushes the network queue). */ count = 0; for (i = 1; i < argc; i++) { s = GETSEND(argv[i]); if (s == 0) { printf("Unknown send argument '%s'\n'send ?' for help.\n", argv[i]); return 0; } else if (Ambiguous(s)) { printf("Ambiguous send argument '%s'\n'send ?' for help.\n", argv[i]); return 0; } if (i + s->narg >= argc) { fprintf(stderr, "Need %d argument%s to 'send %s' command. 'send %s ?' for help.\n", s->narg, s->narg == 1 ? "" : "s", s->name, s->name); return 0; } count += s->nbyte; if (s->handler == send_help) { send_help(); return 0; } i += s->narg; needconnect += s->needconnect; } if (!connected && needconnect) { printf("?Need to be connected first.\n"); printf("'send ?' for help\n"); return 0; } /* Now, do we have enough room? */ if (NETROOM() < count) { printf("There is not enough room in the buffer TO the network\n"); printf("to process your request. Nothing will be done.\n"); printf("('send synch' will throw away most data in the network\n"); printf("buffer, if this might help.)\n"); return 0; } /* OK, they are all OK, now go through again and actually send */ count = 0; for (i = 1; i < argc; i++) { if ((s = GETSEND(argv[i])) == 0) { fprintf(stderr, "Telnet 'send' error - argument disappeared!\n"); (void) quit(); /*NOTREACHED*/ } if (s->handler) { count++; success += (*s->handler)((s->narg > 0) ? argv[i+1] : 0, (s->narg > 1) ? argv[i+2] : 0); i += s->narg; } else { #ifdef LINUX NET2ADD(IAC, s->what); printoption("SENT", IAC, s->what); #else NET2ADD(IAC, what); printoption("SENT", IAC, what); #endif } } return (count == success); } static int send_esc() { NETADD(escape); return 1; } static int send_docmd(name) char *name; { #ifndef SOLARIS void send_do(); #endif return(send_tncmd(send_do, "do", name)); } static int send_dontcmd(name) char *name; { #ifndef SOLARIS void send_dont(); #endif return(send_tncmd(send_dont, "dont", name)); } static int send_willcmd(name) char *name; { #ifndef SOLARIS void send_will(); #endif return(send_tncmd(send_will, "will", name)); } static int send_wontcmd(name) char *name; { #ifndef SOLARIS void send_wont(); #endif return(send_tncmd(send_wont, "wont", name)); } int send_tncmd(func, cmd, name) void (*func)(); char *cmd, *name; { char **cpp; extern char *telopts[]; if (isprefix(name, "help") || isprefix(name, "?")) { register int col, len; printf("Usage: send %s