diff options
author | Jon Marler <jmarler@debian.org> | 1999-07-06 11:58:37 +0100 |
---|---|---|
committer | Dmitry Bogatov <KAction@debian.org> | 2018-11-29 05:18:28 +0000 |
commit | 69ad798f290402999778ca0d4e147f98fe7e45e8 (patch) | |
tree | 0a764bd274d7aa43413d3751590e18429a0b96a0 | |
parent | d8b11a9d5de0d037ac13d39c22608fe1f56fbaa0 (diff) | |
parent | 35c0ccd3b0eedd2d14e26a109f5812a5c30c38aa (diff) |
Import Debian changes 0.84-1
ucspi-tcp (0.84-1) unstable; urgency=low
* New upstream release (closes: #34076)
* New maintainer
ucspi-tcp (0.80-4) unstable; urgency=low
* get rid of RBL patch, at Dan Bernstein's request
-rw-r--r-- | BIN | 11 | ||||
-rw-r--r-- | BLURB | 26 | ||||
-rw-r--r-- | CHANGES | 45 | ||||
-rw-r--r-- | FILES | 246 | ||||
-rw-r--r-- | INSTALL | 16 | ||||
-rw-r--r-- | MAN | 13 | ||||
-rw-r--r-- | Makefile | 464 | ||||
-rw-r--r-- | README | 132 | ||||
-rw-r--r-- | TARGETS | 85 | ||||
-rw-r--r-- | THANKS | 160 | ||||
-rw-r--r-- | TODO | 9 | ||||
-rw-r--r-- | VERSION | 2 | ||||
-rw-r--r-- | addcr.1 | 29 | ||||
-rw-r--r-- | addcr=x | 3 | ||||
-rw-r--r-- | alloc.3 | 62 | ||||
-rw-r--r-- | alloc=l | 2 | ||||
-rw-r--r-- | argv0.1 | 47 | ||||
-rw-r--r-- | argv0.c | 11 | ||||
-rw-r--r-- | auto-str=x | 3 | ||||
-rw-r--r-- | auto_home.h | 6 | ||||
-rw-r--r-- | case.3 | 100 | ||||
-rw-r--r-- | case=l | 1 | ||||
-rw-r--r-- | cdb.3 | 62 | ||||
-rw-r--r-- | cdb=l | 3 | ||||
-rw-r--r-- | cdbmake=l | 3 | ||||
-rw-r--r-- | conf-bin | 3 | ||||
-rw-r--r-- | conf-home | 4 | ||||
-rw-r--r-- | conf-man | 5 | ||||
-rw-r--r-- | date@.1 | 32 | ||||
-rw-r--r-- | date@.sh | 2 | ||||
-rw-r--r-- | date@=s | 0 | ||||
-rw-r--r-- | debian/README-src | 6 | ||||
-rw-r--r-- | debian/addcr.1 | 21 | ||||
-rw-r--r-- | debian/changelog | 13 | ||||
-rw-r--r-- | debian/control | 6 | ||||
-rw-r--r-- | debian/control.real | 6 | ||||
-rw-r--r-- | debian/copyright | 3 | ||||
-rw-r--r-- | debian/delcr.1 | 21 | ||||
-rw-r--r-- | debian/postrm | 2 | ||||
-rw-r--r-- | debian/preinst | 2 | ||||
-rwxr-xr-x | debian/rules | 11 | ||||
-rw-r--r-- | default.0.do | 9 | ||||
-rw-r--r-- | default.a.do | 10 | ||||
-rw-r--r-- | default.do | 77 | ||||
-rw-r--r-- | default.o.do | 15 | ||||
-rw-r--r-- | delcr.1 | 33 | ||||
-rw-r--r-- | delcr=x | 3 | ||||
-rw-r--r-- | dns.c | 96 | ||||
-rw-r--r-- | dns.lib.do | 14 | ||||
-rw-r--r-- | env.3 | 31 | ||||
-rw-r--r-- | env=l | 2 | ||||
-rw-r--r-- | error.3 | 45 | ||||
-rw-r--r-- | error=l | 2 | ||||
-rw-r--r-- | error_str.3 | 19 | ||||
-rw-r--r-- | fd=l | 2 | ||||
-rw-r--r-- | fd_copy.3 | 44 | ||||
-rw-r--r-- | fd_move.3 | 41 | ||||
-rw-r--r-- | finger@.1 | 45 | ||||
-rw-r--r-- | finger@.sh | 6 | ||||
-rw-r--r-- | finger@=s | 0 | ||||
-rw-r--r-- | fixcr.1 | 11 | ||||
-rw-r--r-- | fixcr.c | 25 | ||||
-rw-r--r-- | fs=l | 4 | ||||
-rw-r--r-- | getln.3 | 51 | ||||
-rw-r--r-- | getln2.3 | 64 | ||||
-rw-r--r-- | getln=l | 2 | ||||
-rw-r--r-- | getopt=l | 2 | ||||
-rw-r--r-- | hassgact.h.do | 7 | ||||
-rw-r--r-- | hassgprm.h.do | 7 | ||||
-rw-r--r-- | haswaitp.h.do | 7 | ||||
-rw-r--r-- | hier.c | 63 | ||||
-rw-r--r-- | http@.1 | 52 | ||||
-rw-r--r-- | http@.sh | 4 | ||||
-rw-r--r-- | install.c | 239 | ||||
-rw-r--r-- | install=x | 9 | ||||
-rw-r--r-- | instcheck.c | 108 | ||||
-rw-r--r-- | it.do | 5 | ||||
-rw-r--r-- | make-compile.sh | 1 | ||||
-rw-r--r-- | make-load.sh | 2 | ||||
-rw-r--r-- | make-makelib.sh | 16 | ||||
-rw-r--r-- | man.do | 5 | ||||
-rw-r--r-- | mconnect-io.c | 52 | ||||
-rw-r--r-- | mconnect.1 | 36 | ||||
-rw-r--r-- | mconnect.sh | 8 | ||||
-rw-r--r-- | mconnect=s | 0 | ||||
-rw-r--r-- | ndelay=l | 2 | ||||
-rw-r--r-- | open=l | 2 | ||||
-rw-r--r-- | recordio.1 | 75 | ||||
-rw-r--r-- | recordio.c | 165 | ||||
-rw-r--r-- | rts.exp | 217 | ||||
-rw-r--r-- | rts.sh | 1 | ||||
-rw-r--r-- | rts.tests | 255 | ||||
-rw-r--r-- | scan.h | 1 | ||||
-rw-r--r-- | scan_8long.c | 11 | ||||
-rw-r--r-- | seek=l | 4 | ||||
-rw-r--r-- | seek_cur.c | 7 | ||||
-rw-r--r-- | seek_end.c | 7 | ||||
-rw-r--r-- | seek_trunc.c | 5 | ||||
-rw-r--r-- | select.h.do | 6 | ||||
-rw-r--r-- | setup.do | 5 | ||||
-rw-r--r-- | sgetopt.3 | 28 | ||||
-rw-r--r-- | sig=l | 7 | ||||
-rw-r--r-- | sig_cont.c | 0 | ||||
-rw-r--r-- | sig_dfl.c | 82 | ||||
-rw-r--r-- | socket.lib.do | 8 | ||||
-rw-r--r-- | str=l | 10 | ||||
-rw-r--r-- | str_chr.c | 19 | ||||
-rw-r--r-- | stralloc.3 | 160 | ||||
-rw-r--r-- | stralloc.h | 8 | ||||
-rw-r--r-- | stralloc=l | 8 | ||||
-rw-r--r-- | stralloc_arts.c | 12 | ||||
-rw-r--r-- | strerr=l | 2 | ||||
-rw-r--r-- | subgetopt.3 | 357 | ||||
-rw-r--r-- | substdio=l | 7 | ||||
-rw-r--r-- | tcp-environ=0 | 1 | ||||
-rw-r--r-- | tcpcat.1 | 20 | ||||
-rw-r--r-- | tcpcat.sh | 2 | ||||
-rw-r--r-- | tcpcat=s | 0 | ||||
-rw-r--r-- | tcpclient.1 | 79 | ||||
-rw-r--r-- | tcpclient.c | 135 | ||||
-rw-r--r-- | tcpclient=0 | 1 | ||||
-rw-r--r-- | tcpclient=x | 21 | ||||
-rw-r--r-- | tcprules.1 | 1 | ||||
-rw-r--r-- | tcprules=0 | 1 | ||||
-rw-r--r-- | tcprules=x | 12 | ||||
-rw-r--r-- | tcprulescheck.1 | 25 | ||||
-rw-r--r-- | tcprulescheck.c | 104 | ||||
-rw-r--r-- | tcpserver.1 | 64 | ||||
-rw-r--r-- | tcpserver.c | 82 | ||||
-rw-r--r-- | tcpserver=0 | 1 | ||||
-rw-r--r-- | tcpserver=x | 25 | ||||
-rw-r--r-- | tryrsolv.c | 5 | ||||
-rw-r--r-- | uint32.h.do | 7 | ||||
-rw-r--r-- | wait.3 | 93 | ||||
-rw-r--r-- | wait=l | 1 | ||||
-rw-r--r-- | wait_pid.c | 39 | ||||
-rw-r--r-- | who@.1 | 32 | ||||
-rw-r--r-- | who@.sh | 2 | ||||
-rw-r--r-- | who@=s | 0 |
139 files changed, 3896 insertions, 1280 deletions
@@ -1,11 +0,0 @@ -d:::755::: -c:::711:/:tcpclient: -c:::711:/:tcpserver: -c:::711:/:tcprules: -c:::711:/:addcr: -c:::711:/:delcr: -c:::755:/:who@: -c:::755:/:date@: -c:::755:/:finger@: -c:::755:/:tcpcat: -c:::755:/:mconnect: @@ -1,9 +1,10 @@ -tcpclient and tcpserver are easy-to-use command-line tools for building -TCP client-server applications. tcpclient makes a TCP connection and -runs a program of your choice. tcpserver waits for incoming connections -and, for each connection, runs a program of your choice. Your program -receives environment variables showing the local and remote host names, -IP addresses, and port numbers. +tcpserver and tcpclient are easy-to-use command-line tools for building +TCP client-server applications. + + +tcpserver waits for incoming connections and, for each connection, runs +a program of your choice. Your program receives environment variables +showing the local and remote host names, IP addresses, and port numbers. tcpserver offers a concurrency limit to protect you from running out of processes and memory. When you are handling 40 (by default) simultaneous @@ -14,6 +15,17 @@ tcp-wrappers/tcpd's hosts.allow but much faster. Its access control rules are compiled into a hashed format with cdb, so it can easily deal with thousands of different hosts. -tcpclient and tcpserver conform to UCSPI, the UNIX Client-Server Program +This package includes a recordio tool that monitors all the input and +output of a server. + + +tcpclient makes a TCP connection and runs a program of your choice. It +sets up the same environment variables as tcpserver. + +This package includes several sample clients built on top of tcpclient: +who@, date@, finger@, http@, tcpcat, and mconnect. + + +tcpserver and tcpclient conform to UCSPI, the UNIX Client-Server Program Interface, using the TCP protocol. UCSPI tools are available for several different networks. @@ -1,3 +1,48 @@ +19981111 version: ucspi-tcp 0.84, beta. +19981111 code: avoided ndelay in recordio. +19981110 code: added some tcprules regression tests. +19981110 code: added tcprulescheck. +19981110 code: added tcpclient -i option. +19981110 doc: added references in tcpserver.0 and tcpclient.0. +19981110 code: rewrote recordio for instant output and other features. +19981110 code: added a few more regression tests. +19981110 code: revamped tcpclient messages. +19981110 code: revamped tcpserver messages. +19981110 doc: reorganized tcpserver.0. +19981110 doc: reorganized tcpclient.0. +19981110 code: added strport to tcpclient. +19981110 code: tcpclient now ignores port results from getpeername() + in favor of the port it tried connecting to. +19981110 code: added exec to mconnect. +19981109 doc: added http@ to BLURB. +19981108 version: ucspi-tcp 0.83, beta. +19981108 code: added a few regression tests. +19981108 code: added tcpserver -B. +19981107 code: stopped after 100 bytes in safeappend() in tcpserver. +19981107 code: added http@. +19981107 doc: cleaned up tcpclient.0. +19981107 code: added recordio. +19981107 doc: revamped BLURB. +19981107 code: added fixcr. +19981107 code: added argv0. +19981107 code: added mconnect-io. +19981107 code: moved printstatus() before fork in tcpserver. +19981107 code: unblocked SIGCHLD after setting SIGCHLD to SIG_DFL in + tcpserver, instead of before, to avoid confusion if someone + sends SIGCHLD manually. +19981107 code: eliminated numchildren in printpid() in tcpserver. +19981107 code: added printstatus() in tcpserver. +19981107 doc: added tcpcat.0, mconnect.0. +19981107 doc: added who@.0, date@.0, finger@.0. +19981107 doc: added addcr.0, delcr.0. +19981107 code: tcpclient now interprets empty host name as 0. +19981107 portability problem: OpenBSD connect() prohibits 0.0.0.0. + impact: tcpclient 0 fails. fix: interpret 0 as 127.0.0.1. + hopefully nobody needs 0 to mean primary interface. +19981107 code: switched to str_equal in tcpclient. +19981107 code: switched to strerr in tcpclient. +19981107 code: eliminated tcpclient -U; moved usage() to default. +19981107 code: switched to new install system. 19980118 ucspi-tcp 0.80, beta. 19970410 ucspi-tcp 0.73, beta. 19960922 ucspi-tcp 0.72, beta. @@ -1,68 +1,62 @@ BLURB README -INSTALL TODO THANKS CHANGES UCSPI TCP FILES -BIN -MAN VERSION SYSDEPS TARGETS Makefile -tcpclient=0 tcpclient.1 -tcpclient=x tcpclient.c -tcpserver=0 +who@.1 +who@.sh +date@.1 +date@.sh +finger@.1 +finger@.sh +http@.1 +http@.sh +tcpcat.1 +tcpcat.sh +mconnect.1 +mconnect.sh +mconnect-io.c +delcr.1 +delcr.c +addcr.1 +addcr.c +fixcr.1 +fixcr.c tcpserver.1 -tcpserver=x tcpserver.c -tcprules=0 tcprules.1 -tcprules=x tcprules.c -tcp-environ=0 +tcprulescheck.1 +tcprulescheck.c tcp-environ.5 -addcr=x -addcr.c -delcr=x -delcr.c -date@=s -date@.sh -finger@=s -finger@.sh -who@=s -who@.sh -mconnect=s -mconnect.sh -tcpcat=s -tcpcat.sh -it.do -man.do -setup.do -default.do -default.a.do -default.o.do -default.0.do +recordio.1 +recordio.c +argv0.1 +argv0.c +rts.sh +rts.tests +rts.exp conf-cc conf-ld find-systype.sh -make-compile.sh -make-load.sh -make-makelib.sh trycpp.c warn-auto.sh -conf-bin -conf-man -auto-str=x -install=x +INSTALL +hier.c +conf-home auto-str.c +auto_home.h install.c -substdio=l +instcheck.c substdio.h substdio.c substdi.c @@ -74,90 +68,103 @@ subfdout.c subfdin.c readwrite.h exit.h -error=l +strerr.h +strerr_sys.c +strerr_die.c +error.3 +error_str.3 error.h error.c error_str.c -str=l +open.h +open_read.c +open_trunc.c byte.h byte_chr.c -byte_rchr.c byte_copy.c byte_cr.c byte_diff.c +byte_rchr.c byte_zero.c str.h +str_chr.c str_cpy.c str_diff.c str_diffn.c str_len.c -sig=l -sig.h -sig_block.c -sig_catch.c -sig_dfl.c -sig_pipe.c -sig_cont.c -sig_child.c -sig_pause.c -sig_term.c -hassgact.h.do -hassgprm.h.do -trysgact.c -trysgprm.c -fd=l +alloc.3 +alloc.h +alloc.c +alloc_re.c +case.3 +case.h +case_lowers.c +cdb.3 +cdb.h +cdb_hash.c +cdb_seek.c +cdb_unpack.c +cdbmake.h +cdbmake_add.c +cdbmake_hash.c +cdbmake_pack.c +cdbmss.h +cdbmss.c +dns.h +dns.c +trylsock.c +tryrsolv.c +env.3 +env.h +env.c +envread.c fd.h +fd_copy.3 fd_copy.c +fd_move.3 fd_move.c -ip.h -ip.c -ipalloc.h -ipalloc.c -case=l -case.h -case_lowers.c -getopt=l -sgetopt.h -sgetopt.c -subgetopt.h -subgetopt.c -fs=l fmt.h fmt_str.c fmt_ulong.c scan.h scan_ulong.c -scan_8long.c -env=l -env.h -env.c -envread.c -dns.h -dns.c -dns.lib.do -socket.lib.do -tryrsolv.c -trylsock.c -timeoutread.h -timeoutread.c -timeoutwrite.h -timeoutwrite.c -timeoutconn.h -timeoutconn.c +getln.3 +getln.h +getln.c +getln2.3 +getln2.c +sgetopt.3 +sgetopt.h +sgetopt.c +subgetopt.3 +subgetopt.h +subgetopt.c +ip.h +ip.c +ipalloc.h +ipalloc.c +ndelay.h +ndelay.c +ndelay_off.c remoteinfo.h remoteinfo.c -wait=l -wait.h -wait_nohang.c -trywaitp.c -haswaitp.h.do -select.h.do +seek.h +seek_set.c select.h1 select.h2 trysysel.c -stralloc=l +sig.h +sig_block.c +sig_catch.c +sig_pause.c +sig_pipe.c +sig_child.c +sig_term.c +trysgact.c +trysgprm.c gen_alloc.h gen_allocdefs.h +stralloc.3 stralloc.h stralloc_eady.c stralloc_pend.c @@ -167,46 +174,17 @@ stralloc_opys.c stralloc_cat.c stralloc_catb.c stralloc_cats.c -stralloc_arts.c -alloc=l -alloc.h -alloc.c -alloc_re.c -ndelay=l -ndelay.h -ndelay.c -ndelay_off.c -strerr=l -strerr.h -strerr_sys.c -strerr_die.c -open=l -open.h -open_read.c -open_trunc.c -getln=l -getln.h -getln.c -getln2.c -cdb=l -cdbmake=l -cdb.h -cdb_hash.c -cdb_seek.c -cdb_unpack.c -cdbmake.h -cdbmake_add.c -cdbmake_hash.c -cdbmake_pack.c -cdbmss.h -cdbmss.c -uint32.h.do +timeoutconn.h +timeoutconn.c +timeoutread.h +timeoutread.c +timeoutwrite.h +timeoutwrite.c uint32.h1 uint32.h2 tryulong32.c -seek=l -seek.h -seek_cur.c -seek_end.c -seek_set.c -seek_trunc.c +wait.3 +wait.h +wait_nohang.c +wait_pid.c +trywaitp.c @@ -4,21 +4,17 @@ comes with NO WARRANTY. Things you have to decide before starting: -* Where programs will be installed, normally /usr/local/bin. To change -this directory, edit conf-bin now. - -* Where man pages will be installed, normally /usr/local/man. To change -this directory, edit conf-man now. +* The ucspi-tcp home directory, normally /usr/local. To change this +directory, edit conf-home now. How to install: - 1. Compile the programs: + 1. Compile the programs and create the formatted man pages: % make - 2. Create the formatted man pages, *.0: - % make man - 3. Install the programs and man pages: - # make setup + + 2. Install the programs and man pages: + # make setup check That's it! To report success: @@ -1,13 +0,0 @@ -d:::755::: -d:::755:/man1:: -d:::755:/cat1:: -d:::755:/man5:: -d:::755:/cat5:: -c:::644:/man1/:tcpclient.1: -c:::644:/cat1/:tcpclient.0: -c:::644:/man1/:tcpserver.1: -c:::644:/cat1/:tcpserver.0: -c:::644:/man1/:tcprules.1: -c:::644:/cat1/:tcprules.0: -c:::644:/man5/:tcp-environ.5: -c:::644:/cat5/:tcp-environ.0: @@ -8,10 +8,18 @@ addcr: \ load addcr.o substdio.a error.a str.a ./load addcr substdio.a error.a str.a +addcr.0: \ +addcr.1 + nroff -man addcr.1 > addcr.0 + addcr.o: \ -compile addcr.c substdio.h subfd.h exit.h +compile addcr.c substdio.h subfd.h substdio.h exit.h ./compile addcr.c +alloc.0: \ +alloc.3 + nroff -man alloc.3 > alloc.0 + alloc.a: \ makelib alloc.o alloc_re.o ./makelib alloc.a alloc.o alloc_re.o @@ -24,12 +32,33 @@ alloc_re.o: \ compile alloc_re.c alloc.h byte.h ./compile alloc_re.c -auto-ccld.sh: \ -conf-cc conf-ld warn-auto.sh - ( cat warn-auto.sh; \ - echo CC=\'`head -1 conf-cc`\'; \ - echo LD=\'`head -1 conf-ld`\' \ - ) > auto-ccld.sh +argv0: \ +load argv0.o strerr.a substdio.a error.a str.a + ./load argv0 strerr.a substdio.a error.a str.a + +argv0.0: \ +argv0.1 + nroff -man argv0.1 > argv0.0 + +argv0.o: \ +compile argv0.c strerr.h + ./compile argv0.c + +auto-str: \ +load auto-str.o substdio.a error.a str.a + ./load auto-str substdio.a error.a str.a + +auto-str.o: \ +compile auto-str.c substdio.h readwrite.h exit.h + ./compile auto-str.c + +auto_home.c: \ +auto-str conf-home + ./auto-str auto_home `head -1 conf-home` > auto_home.c + +auto_home.o: \ +compile auto_home.c + ./compile auto_home.c byte_chr.o: \ compile byte_chr.c byte.h @@ -55,6 +84,10 @@ byte_zero.o: \ compile byte_zero.c byte.h ./compile byte_zero.c +case.0: \ +case.3 + nroff -man case.3 > case.0 + case.a: \ makelib case_lowers.o ./makelib case.a case_lowers.o @@ -63,6 +96,10 @@ case_lowers.o: \ compile case_lowers.c case.h ./compile case_lowers.c +cdb.0: \ +cdb.3 + nroff -man cdb.3 > cdb.0 + cdb.a: \ makelib cdb_hash.o cdb_unpack.o cdb_seek.o ./makelib cdb.a cdb_hash.o cdb_unpack.o cdb_seek.o @@ -101,40 +138,56 @@ compile cdbmss.c readwrite.h seek.h alloc.h cdbmss.h cdbmake.h \ uint32.h substdio.h ./compile cdbmss.c +check: \ +it instcheck + ./instcheck + compile: \ -make-compile warn-auto.sh systype - ( cat warn-auto.sh; ./make-compile "`cat systype`" ) > \ - compile +warn-auto.sh conf-cc + ( cat warn-auto.sh; \ + echo exec "`head -1 conf-cc`" '-c $${1+"$$@"}' \ + ) > compile chmod 755 compile date@: \ -warn-auto.sh date@.sh conf-bin +warn-auto.sh date@.sh conf-home cat warn-auto.sh date@.sh \ - | sed s}BIN}"`head -1 conf-bin`"}g > date@ + | sed s}HOME}"`head -1 conf-home`"}g \ + > date@ chmod 755 date@ +date@.0: \ +date@.1 + nroff -man date@.1 > date@.0 + delcr: \ load delcr.o substdio.a error.a str.a ./load delcr substdio.a error.a str.a +delcr.0: \ +delcr.1 + nroff -man delcr.1 > delcr.0 + delcr.o: \ -compile delcr.c substdio.h subfd.h exit.h +compile delcr.c substdio.h subfd.h substdio.h exit.h ./compile delcr.c dns.lib: \ -tryrsolv.c compile load socket.lib dns.o ipalloc.o ip.o stralloc.a \ -alloc.a error.a fs.a str.a - ( ( ./compile tryrsolv.c && ./load tryrsolv dns.o \ - ipalloc.o ip.o stralloc.a alloc.a error.a fs.a str.a \ +tryrsolv.c compile load socket.lib + ( ( ./compile tryrsolv.c && ./load tryrsolv \ -lresolv `cat socket.lib` ) >/dev/null 2>&1 \ && echo -lresolv || exit 0 ) > dns.lib rm -f tryrsolv.o tryrsolv dns.o: \ -compile dns.c ip.h ipalloc.h gen_alloc.h fmt.h alloc.h str.h \ -stralloc.h dns.h case.h +compile dns.c ip.h ipalloc.h ip.h gen_alloc.h fmt.h alloc.h str.h \ +stralloc.h gen_alloc.h dns.h case.h ./compile dns.c +env.0: \ +env.3 + nroff -man env.3 > env.0 + env.a: \ makelib env.o envread.o ./makelib env.a env.o envread.o @@ -147,6 +200,10 @@ envread.o: \ compile envread.c env.h str.h ./compile envread.c +error.0: \ +error.3 + nroff -man error.3 > error.0 + error.a: \ makelib error.o error_str.o ./makelib error.a error.o error_str.o @@ -155,6 +212,10 @@ error.o: \ compile error.c error.h ./compile error.c +error_str.0: \ +error_str.3 + nroff -man error_str.3 > error_str.0 + error_str.o: \ compile error_str.c error.h ./compile error_str.c @@ -163,25 +224,45 @@ fd.a: \ makelib fd_copy.o fd_move.o ./makelib fd.a fd_copy.o fd_move.o +fd_copy.0: \ +fd_copy.3 + nroff -man fd_copy.3 > fd_copy.0 + fd_copy.o: \ compile fd_copy.c fd.h ./compile fd_copy.c +fd_move.0: \ +fd_move.3 + nroff -man fd_move.3 > fd_move.0 + fd_move.o: \ compile fd_move.c fd.h ./compile fd_move.c -find-systype: \ -find-systype.sh auto-ccld.sh - cat auto-ccld.sh find-systype.sh > find-systype - chmod 755 find-systype - finger@: \ -warn-auto.sh finger@.sh conf-bin +warn-auto.sh finger@.sh conf-home cat warn-auto.sh finger@.sh \ - | sed s}BIN}"`head -1 conf-bin`"}g > finger@ + | sed s}HOME}"`head -1 conf-home`"}g \ + > finger@ chmod 755 finger@ +finger@.0: \ +finger@.1 + nroff -man finger@.1 > finger@.0 + +fixcr: \ +load fixcr.o substdio.a error.a str.a + ./load fixcr substdio.a error.a str.a + +fixcr.0: \ +fixcr.1 + nroff -man fixcr.1 > fixcr.0 + +fixcr.o: \ +compile fixcr.c substdio.h subfd.h substdio.h exit.h + ./compile fixcr.c + fmt_str.o: \ compile fmt_str.c fmt.h ./compile fmt_str.c @@ -191,9 +272,12 @@ compile fmt_ulong.c fmt.h ./compile fmt_ulong.c fs.a: \ -makelib fmt_str.o fmt_ulong.o scan_ulong.o scan_8long.o - ./makelib fs.a fmt_str.o fmt_ulong.o scan_ulong.o \ - scan_8long.o +makelib fmt_str.o fmt_ulong.o scan_ulong.o + ./makelib fs.a fmt_str.o fmt_ulong.o scan_ulong.o + +getln.0: \ +getln.3 + nroff -man getln.3 > getln.0 getln.a: \ makelib getln.o getln2.o @@ -203,6 +287,10 @@ getln.o: \ compile getln.c substdio.h byte.h stralloc.h gen_alloc.h getln.h ./compile getln.c +getln2.0: \ +getln2.3 + nroff -man getln2.3 > getln2.0 + getln2.o: \ compile getln2.c substdio.h stralloc.h gen_alloc.h byte.h getln.h ./compile getln2.c @@ -232,64 +320,108 @@ trywaitp.c compile load && echo \#define HASWAITPID 1 || exit 0 ) > haswaitp.h rm -f trywaitp.o trywaitp +hier.o: \ +compile hier.c auto_home.h + ./compile hier.c + +http@: \ +warn-auto.sh http@.sh conf-home + cat warn-auto.sh http@.sh \ + | sed s}HOME}"`head -1 conf-home`"}g \ + > http@ + chmod 755 http@ + +http@.0: \ +http@.1 + nroff -man http@.1 > http@.0 + install: \ -load install.o getln.a strerr.a substdio.a stralloc.a alloc.a open.a \ -error.a str.a fs.a - ./load install getln.a strerr.a substdio.a stralloc.a \ - alloc.a open.a error.a str.a fs.a +load install.o hier.o auto_home.o strerr.a substdio.a open.a error.a \ +str.a + ./load install hier.o auto_home.o strerr.a substdio.a \ + open.a error.a str.a install.o: \ -compile install.c substdio.h stralloc.h gen_alloc.h getln.h \ -readwrite.h exit.h open.h error.h strerr.h byte.h +compile install.c substdio.h strerr.h error.h open.h readwrite.h \ +exit.h ./compile install.c +instcheck: \ +load instcheck.o hier.o auto_home.o strerr.a substdio.a error.a str.a + ./load instcheck hier.o auto_home.o strerr.a substdio.a \ + error.a str.a + +instcheck.o: \ +compile instcheck.c strerr.h error.h readwrite.h exit.h + ./compile instcheck.c + ip.o: \ compile ip.c fmt.h scan.h ip.h ./compile ip.c ipalloc.o: \ -compile ipalloc.c alloc.h gen_allocdefs.h ip.h ipalloc.h gen_alloc.h +compile ipalloc.c alloc.h gen_allocdefs.h ip.h ipalloc.h ip.h \ +gen_alloc.h ./compile ipalloc.c it: \ -tcpclient tcpserver tcprules who@ date@ finger@ tcpcat mconnect addcr \ -delcr +man prog install instcheck load: \ -make-load warn-auto.sh systype - ( cat warn-auto.sh; ./make-load "`cat systype`" ) > load +warn-auto.sh conf-ld + ( cat warn-auto.sh; \ + echo 'main="$$1"; shift'; \ + echo exec "`head -1 conf-ld`" \ + '-o "$$main" "$$main".o $${1+"$$@"}' \ + ) > load chmod 755 load -make-compile: \ -make-compile.sh auto-ccld.sh - cat auto-ccld.sh make-compile.sh > make-compile - chmod 755 make-compile - -make-load: \ -make-load.sh auto-ccld.sh - cat auto-ccld.sh make-load.sh > make-load - chmod 755 make-load - -make-makelib: \ -make-makelib.sh auto-ccld.sh - cat auto-ccld.sh make-makelib.sh > make-makelib - chmod 755 make-makelib - makelib: \ -make-makelib warn-auto.sh systype - ( cat warn-auto.sh; ./make-makelib "`cat systype`" ) > \ - makelib +warn-auto.sh systype + ( cat warn-auto.sh; \ + echo 'main="$$1"; shift'; \ + echo 'rm -f "$$main"'; \ + echo 'ar cr "$$main" $${1+"$$@"}'; \ + case "`cat systype`" in \ + sunos-5.*) ;; \ + unix_sv*) ;; \ + irix64-*) ;; \ + irix-*) ;; \ + dgux-*) ;; \ + hp-ux-*) ;; \ + sco*) ;; \ + *) echo 'ranlib "$$main"' ;; \ + esac \ + ) > makelib chmod 755 makelib man: \ -tcpclient.0 tcpserver.0 tcprules.0 tcp-environ.0 +tcpclient.0 tcpserver.0 tcprules.0 tcprulescheck.0 tcp-environ.0 \ +who@.0 date@.0 finger@.0 http@.0 tcpcat.0 mconnect.0 fixcr.0 addcr.0 \ +delcr.0 argv0.0 recordio.0 error.0 error_str.0 alloc.0 case.0 cdb.0 \ +env.0 fd_copy.0 fd_move.0 getln.0 getln2.0 sgetopt.0 subgetopt.0 \ +stralloc.0 wait.0 mconnect: \ -warn-auto.sh mconnect.sh conf-bin +warn-auto.sh mconnect.sh conf-home cat warn-auto.sh mconnect.sh \ - | sed s}BIN}"`head -1 conf-bin`"}g > mconnect + | sed s}HOME}"`head -1 conf-home`"}g \ + > mconnect chmod 755 mconnect +mconnect-io: \ +load mconnect-io.o strerr.a substdio.a error.a str.a wait.a sig.a + ./load mconnect-io strerr.a substdio.a error.a str.a \ + wait.a sig.a + +mconnect-io.o: \ +compile mconnect-io.c sig.h substdio.h strerr.h readwrite.h exit.h + ./compile mconnect-io.c + +mconnect.0: \ +mconnect.1 + nroff -man mconnect.1 > mconnect.0 + ndelay.a: \ makelib ndelay.o ndelay_off.o ./makelib ndelay.a ndelay.o ndelay_off.o @@ -314,40 +446,48 @@ open_trunc.o: \ compile open_trunc.c open.h ./compile open_trunc.c +prog: \ +tcpclient tcpserver tcprules tcprulescheck who@ date@ finger@ http@ \ +tcpcat mconnect mconnect-io fixcr addcr delcr argv0 recordio rts + +recordio: \ +load recordio.o strerr.a substdio.a error.a str.a fs.a fd.a sig.a + ./load recordio strerr.a substdio.a error.a str.a fs.a \ + fd.a sig.a + +recordio.0: \ +recordio.1 + nroff -man recordio.1 > recordio.0 + +recordio.o: \ +compile recordio.c sig.h substdio.h strerr.h str.h byte.h readwrite.h \ +exit.h fmt.h select.h + ./compile recordio.c + remoteinfo.o: \ compile remoteinfo.c byte.h substdio.h ip.h fmt.h timeoutconn.h \ timeoutread.h timeoutwrite.h remoteinfo.h ./compile remoteinfo.c -scan_8long.o: \ -compile scan_8long.c scan.h - ./compile scan_8long.c +rts: \ +warn-auto.sh rts.sh conf-home + cat warn-auto.sh rts.sh \ + | sed s}HOME}"`head -1 conf-home`"}g \ + > rts + chmod 755 rts scan_ulong.o: \ compile scan_ulong.c scan.h ./compile scan_ulong.c seek.a: \ -makelib seek_cur.o seek_end.o seek_set.o seek_trunc.o - ./makelib seek.a seek_cur.o seek_end.o seek_set.o \ - seek_trunc.o - -seek_cur.o: \ -compile seek_cur.c seek.h - ./compile seek_cur.c - -seek_end.o: \ -compile seek_end.c seek.h - ./compile seek_end.c +makelib seek_set.o + ./makelib seek.a seek_set.o seek_set.o: \ compile seek_set.c seek.h ./compile seek_set.c -seek_trunc.o: \ -compile seek_trunc.c seek.h - ./compile seek_trunc.c - select.h: \ compile trysysel.c select.h1 select.h2 ( ./compile trysysel.c >/dev/null 2>&1 \ @@ -355,19 +495,58 @@ compile trysysel.c select.h1 select.h2 rm -f trysysel.o trysysel setup: \ -it man install conf-bin conf-man BIN MAN - ./install "`head -1 conf-bin`" < BIN - ./install "`head -1 conf-man`" < MAN +it install + ./install + +sgetopt.0: \ +sgetopt.3 + nroff -man sgetopt.3 > sgetopt.0 sgetopt.o: \ -compile sgetopt.c substdio.h subfd.h sgetopt.h subgetopt.h +compile sgetopt.c substdio.h subfd.h substdio.h sgetopt.h subgetopt.h \ +subgetopt.h ./compile sgetopt.c +shar: \ +FILES BLURB README TODO THANKS CHANGES UCSPI TCP FILES VERSION \ +SYSDEPS TARGETS Makefile tcpclient.1 tcpclient.c who@.1 who@.sh \ +date@.1 date@.sh finger@.1 finger@.sh http@.1 http@.sh tcpcat.1 \ +tcpcat.sh mconnect.1 mconnect.sh mconnect-io.c delcr.1 delcr.c \ +addcr.1 addcr.c fixcr.1 fixcr.c tcpserver.1 tcpserver.c tcprules.1 \ +tcprules.c tcprulescheck.1 tcprulescheck.c tcp-environ.5 recordio.1 \ +recordio.c argv0.1 argv0.c rts.sh rts.tests rts.exp conf-cc conf-ld \ +find-systype.sh trycpp.c warn-auto.sh INSTALL hier.c conf-home \ +auto-str.c auto_home.h install.c instcheck.c substdio.h substdio.c \ +substdi.c substdo.c substdio_copy.c subfd.h subfderr.c subfdout.c \ +subfdin.c readwrite.h exit.h strerr.h strerr_sys.c strerr_die.c \ +error.3 error_str.3 error.h error.c error_str.c open.h open_read.c \ +open_trunc.c byte.h byte_chr.c byte_copy.c byte_cr.c byte_diff.c \ +byte_rchr.c byte_zero.c str.h str_chr.c str_cpy.c str_diff.c \ +str_diffn.c str_len.c alloc.3 alloc.h alloc.c alloc_re.c case.3 \ +case.h case_lowers.c cdb.3 cdb.h cdb_hash.c cdb_seek.c cdb_unpack.c \ +cdbmake.h cdbmake_add.c cdbmake_hash.c cdbmake_pack.c cdbmss.h \ +cdbmss.c dns.h dns.c trylsock.c tryrsolv.c env.3 env.h env.c \ +envread.c fd.h fd_copy.3 fd_copy.c fd_move.3 fd_move.c fmt.h \ +fmt_str.c fmt_ulong.c scan.h scan_ulong.c getln.3 getln.h getln.c \ +getln2.3 getln2.c sgetopt.3 sgetopt.h sgetopt.c subgetopt.3 \ +subgetopt.h subgetopt.c ip.h ip.c ipalloc.h ipalloc.c ndelay.h \ +ndelay.c ndelay_off.c remoteinfo.h remoteinfo.c seek.h seek_set.c \ +select.h1 select.h2 trysysel.c sig.h sig_block.c sig_catch.c \ +sig_pause.c sig_pipe.c sig_child.c sig_term.c trysgact.c trysgprm.c \ +gen_alloc.h gen_allocdefs.h stralloc.3 stralloc.h stralloc_eady.c \ +stralloc_pend.c stralloc_copy.c stralloc_opyb.c stralloc_opys.c \ +stralloc_cat.c stralloc_catb.c stralloc_cats.c timeoutconn.h \ +timeoutconn.c timeoutread.h timeoutread.c timeoutwrite.h \ +timeoutwrite.c uint32.h1 uint32.h2 tryulong32.c wait.3 wait.h \ +wait_nohang.c wait_pid.c trywaitp.c + shar -m `cat FILES` > shar + chmod 400 shar + sig.a: \ -makelib sig_block.o sig_catch.o sig_pause.o sig_dfl.o sig_pipe.o \ -sig_child.o sig_term.o +makelib sig_block.o sig_catch.o sig_pause.o sig_pipe.o sig_child.o \ +sig_term.o ./makelib sig.a sig_block.o sig_catch.o sig_pause.o \ - sig_dfl.o sig_pipe.o sig_child.o sig_term.o + sig_pipe.o sig_child.o sig_term.o sig_block.o: \ compile sig_block.c sig.h hassgprm.h @@ -381,10 +560,6 @@ sig_child.o: \ compile sig_child.c sig.h ./compile sig_child.c -sig_dfl.o: \ -compile sig_dfl.c sig.h hassgact.h hassgprm.h - ./compile sig_dfl.c - sig_pause.o: \ compile sig_pause.c sig.h hassgprm.h ./compile sig_pause.c @@ -405,11 +580,15 @@ trylsock.c compile load rm -f trylsock.o trylsock str.a: \ -makelib str_len.o str_diff.o str_diffn.o str_cpy.o byte_chr.o \ -byte_rchr.o byte_diff.o byte_copy.o byte_cr.o byte_zero.o - ./makelib str.a str_len.o str_diff.o str_diffn.o str_cpy.o \ - byte_chr.o byte_rchr.o byte_diff.o byte_copy.o byte_cr.o \ - byte_zero.o +makelib str_chr.o str_len.o str_diff.o str_diffn.o str_cpy.o \ +byte_chr.o byte_rchr.o byte_diff.o byte_copy.o byte_cr.o byte_zero.o + ./makelib str.a str_chr.o str_len.o str_diff.o str_diffn.o \ + str_cpy.o byte_chr.o byte_rchr.o byte_diff.o byte_copy.o \ + byte_cr.o byte_zero.o + +str_chr.o: \ +compile str_chr.c str.h + ./compile str_chr.c str_cpy.o: \ compile str_cpy.c str.h @@ -427,6 +606,10 @@ str_len.o: \ compile str_len.c str.h ./compile str_len.c +stralloc.0: \ +stralloc.3 + nroff -man stralloc.3 > stralloc.0 + stralloc.a: \ makelib stralloc_eady.o stralloc_pend.o stralloc_copy.o \ stralloc_opys.o stralloc_opyb.o stralloc_cat.o stralloc_cats.o \ @@ -474,7 +657,7 @@ makelib strerr_sys.o strerr_die.o ./makelib strerr.a strerr_sys.o strerr_die.o strerr_die.o: \ -compile strerr_die.c substdio.h subfd.h exit.h strerr.h +compile strerr_die.c substdio.h subfd.h substdio.h exit.h strerr.h ./compile strerr_die.c strerr_sys.o: \ @@ -482,17 +665,21 @@ compile strerr_sys.c error.h strerr.h ./compile strerr_sys.c subfderr.o: \ -compile subfderr.c readwrite.h substdio.h subfd.h +compile subfderr.c readwrite.h substdio.h subfd.h substdio.h ./compile subfderr.c subfdin.o: \ -compile subfdin.c readwrite.h substdio.h subfd.h +compile subfdin.c readwrite.h substdio.h subfd.h substdio.h ./compile subfdin.c subfdout.o: \ -compile subfdout.c readwrite.h substdio.h subfd.h +compile subfdout.c readwrite.h substdio.h subfd.h substdio.h ./compile subfdout.c +subgetopt.0: \ +subgetopt.3 + nroff -man subgetopt.3 > subgetopt.0 + subgetopt.o: \ compile subgetopt.c subgetopt.h ./compile subgetopt.c @@ -520,36 +707,46 @@ compile substdo.c substdio.h str.h byte.h error.h ./compile substdo.c systype: \ -find-systype trycpp.c - ./find-systype > systype +find-systype.sh conf-cc conf-ld trycpp.c + ( cat warn-auto.sh; \ + echo CC=\'`head -1 conf-cc`\'; \ + echo LD=\'`head -1 conf-ld`\'; \ + cat find-systype.sh; \ + ) | sh > systype tcp-environ.0: \ tcp-environ.5 nroff -man tcp-environ.5 > tcp-environ.0 tcpcat: \ -warn-auto.sh tcpcat.sh conf-bin +warn-auto.sh tcpcat.sh conf-home cat warn-auto.sh tcpcat.sh \ - | sed s}BIN}"`head -1 conf-bin`"}g > tcpcat + | sed s}HOME}"`head -1 conf-home`"}g \ + > tcpcat chmod 755 tcpcat +tcpcat.0: \ +tcpcat.1 + nroff -man tcpcat.1 > tcpcat.0 + tcpclient: \ load tcpclient.o ip.o ipalloc.o dns.o remoteinfo.o timeoutconn.o \ -timeoutread.o timeoutwrite.o stralloc.a env.a alloc.a ndelay.a \ -substdio.a error.a str.a sig.a fd.a case.a getopt.a fs.a dns.lib \ -socket.lib +timeoutread.o timeoutwrite.o getopt.a strerr.a stralloc.a env.a \ +alloc.a ndelay.a substdio.a error.a str.a sig.a fd.a case.a fs.a \ +dns.lib socket.lib ./load tcpclient ip.o ipalloc.o dns.o remoteinfo.o \ - timeoutconn.o timeoutread.o timeoutwrite.o stralloc.a env.a \ - alloc.a ndelay.a substdio.a error.a str.a sig.a fd.a case.a \ - getopt.a fs.a `cat dns.lib` `cat socket.lib` + timeoutconn.o timeoutread.o timeoutwrite.o getopt.a \ + strerr.a stralloc.a env.a alloc.a ndelay.a substdio.a \ + error.a str.a sig.a fd.a case.a fs.a `cat dns.lib` `cat \ + socket.lib` tcpclient.0: \ tcpclient.1 nroff -man tcpclient.1 > tcpclient.0 tcpclient.o: \ -compile tcpclient.c substdio.h stralloc.h gen_alloc.h str.h byte.h \ -error.h sig.h subfd.h fd.h ip.h ipalloc.h case.h sgetopt.h \ +compile tcpclient.c strerr.h stralloc.h gen_alloc.h str.h byte.h \ +sig.h fd.h ip.h ipalloc.h ip.h gen_alloc.h case.h sgetopt.h \ subgetopt.h exit.h scan.h fmt.h env.h dns.h remoteinfo.h ./compile tcpclient.c @@ -566,9 +763,25 @@ tcprules.1 tcprules.o: \ compile tcprules.c strerr.h stralloc.h gen_alloc.h getln.h substdio.h \ -subfd.h exit.h fmt.h byte.h cdbmss.h cdbmake.h uint32.h +subfd.h substdio.h exit.h fmt.h byte.h cdbmss.h cdbmake.h uint32.h \ +substdio.h ./compile tcprules.c +tcprulescheck: \ +load tcprulescheck.o cdb.a stralloc.a alloc.a strerr.a substdio.a \ +error.a str.a open.a + ./load tcprulescheck cdb.a stralloc.a alloc.a strerr.a \ + substdio.a error.a str.a open.a + +tcprulescheck.0: \ +tcprulescheck.1 + nroff -man tcprulescheck.1 > tcprulescheck.0 + +tcprulescheck.o: \ +compile tcprulescheck.c substdio.h subfd.h substdio.h strerr.h \ +stralloc.h gen_alloc.h alloc.h cdb.h uint32.h + ./compile tcprulescheck.c + tcpserver: \ load tcpserver.o ip.o ipalloc.o dns.o remoteinfo.o timeoutconn.o \ timeoutread.o timeoutwrite.o cdb.a open.a wait.a strerr.a stralloc.a \ @@ -586,9 +799,9 @@ tcpserver.1 tcpserver.o: \ compile tcpserver.c strerr.h substdio.h stralloc.h gen_alloc.h \ -alloc.h readwrite.h fd.h sig.h wait.h ip.h ipalloc.h dns.h str.h \ -case.h byte.h sgetopt.h subgetopt.h remoteinfo.h exit.h open.h scan.h \ -fmt.h env.h cdb.h uint32.h +alloc.h readwrite.h fd.h sig.h wait.h ip.h ipalloc.h ip.h gen_alloc.h \ +dns.h str.h case.h byte.h sgetopt.h subgetopt.h remoteinfo.h exit.h \ +open.h scan.h fmt.h env.h cdb.h uint32.h ./compile tcpserver.c timeoutconn.o: \ @@ -611,16 +824,29 @@ tryulong32.c compile load uint32.h1 uint32.h2 && cat uint32.h2 || cat uint32.h1 ) > uint32.h rm -f tryulong32.o tryulong32 +wait.0: \ +wait.3 + nroff -man wait.3 > wait.0 + wait.a: \ -makelib wait_nohang.o - ./makelib wait.a wait_nohang.o +makelib wait_nohang.o wait_pid.o + ./makelib wait.a wait_nohang.o wait_pid.o wait_nohang.o: \ compile wait_nohang.c haswaitp.h ./compile wait_nohang.c +wait_pid.o: \ +compile wait_pid.c error.h haswaitp.h + ./compile wait_pid.c + who@: \ -warn-auto.sh who@.sh conf-bin +warn-auto.sh who@.sh conf-home cat warn-auto.sh who@.sh \ - | sed s}BIN}"`head -1 conf-bin`"}g > who@ + | sed s}HOME}"`head -1 conf-home`"}g \ + > who@ chmod 755 who@ + +who@.0: \ +who@.1 + nroff -man who@.1 > who@.0 @@ -1,89 +1,159 @@ -ucspi-tcp 0.80, beta. -19980118 +ucspi-tcp 0.84, beta. +19981111 Copyright 1998 D. J. Bernstein, djb@pobox.com +http://pobox.com/~djb/ucspi-tcp.html -tcpclient and tcpserver are easy-to-use command-line tools for building +tcpserver and tcpclient are easy-to-use command-line tools for building TCP client-server applications. See BLURB for a more detailed advertisement. -You may distribute unmodified copies of the ucspi-tcp package. - -INSTALL says how to set up tcpclient and tcpserver. +INSTALL says how to set up tcpserver and tcpclient. -See http://pobox.com/~djb/ucspi-tcp.html for the latest information -about ucspi-tcp. See http://pobox.com/~djb/proto/ucspi.txt for general -information about UCSPI. +You may distribute unmodified copies of the ucspi-tcp package. The rest of this file is a list of systypes where various versions of ucspi-tcp have been reported to work. 0.70 was the first beta version. +0.80: aix-4-1-:-:-:0024dd0a4c00-:- (tnx MH) 0.73: aix-4-2-:-:-:000055247900-:- (tnx JLB) -0.73: bsd.os-2.0.1-:i386-:-:pentium-:- -0.73: bsd.os-2.1-:i386-:-:pentium-:- (tnx MPS) +0.80: aix-4-2-:-:-:000136094c00-:- (tnx TU) +0.80: bsd.os-2.1-:i386-:-:pentium-:- (tnx ARB) 0.73: bsd.os-3.0-:i386-:-:pentium-:- (tnx SN) +0.80: bsd.os-4.0-:i386-:-:pentium-:- (tnx SGT) 0.73: freebsd-2.1.0-release-:i386-:-:i486.dx2-:- (tnx NM) -0.73: freebsd-2.1.0-release-:i386-:-:pentium.735\90.or.815\100-:- (tnx MBS) +0.80: freebsd-2.1.0-release-:i386-:-:pentium.735\90.or.815\100-:- (tnx MBS) 0.73: freebsd-2.2-970422-releng-:i386-:-:pentium-:- (tnx TM) 0.73: freebsd-2.2-970618-releng-:i386-:-:pentium-:- (tnx LST) 0.72: freebsd-2.2-release-:i386-:-:pentium-:- (tnx frank@news=???) 0.73: freebsd-2.2-stable-:i386-:-:pentium-:- (tnx JJE) 0.73: freebsd-2.2.1-release-:i386-:-:-:- (tnx TM) -0.73: freebsd-2.2.1-release-:i386-:-:pentium-:- (tnx RWL) +0.80: freebsd-2.2.1-release-:i386-:-:pentium-:- (tnx GB) 0.73: freebsd-2.2.2-release-:i386-:-:amd.unknown-:- (tnx FN) -0.73: freebsd-2.2.2-release-:i386-:-:pentium-:- (tnx BJR) -0.73: freebsd-2.2.5-release-:i386-:-:pentium.pro-:- (tnx AI) +0.80: freebsd-2.2.2-release-:i386-:-:i486-dx-:- (tnx MM) +0.73: freebsd-2.2.2-release-:i386-:-:pentium-:- (tnx BMF) +0.80: freebsd-2.2.5-release-:i386-:-:amd.am486dx2/4.write-through-:- (tnx AT) +0.80: freebsd-2.2.5-release-:i386-:-:i486-dx-:- (tnx root@lightyear=???) +0.80: freebsd-2.2.5-release-:i386-:-:pentium-:- (tnx BJR) +0.80: freebsd-2.2.5-release-:i386-:-:pentium.pro-:- (tnx AY) +0.80: freebsd-2.2.5-stable-:i386-:-:amd.k6-:- (tnx WCH) +0.80: freebsd-2.2.5-stable-:i386-:-:pentium-:- (tnx WCH) +0.80: freebsd-2.2.6-release-:i386-:-:amd.enhanced.am486dx4.write-back-:- (tnx YT) +0.80: freebsd-2.2.6-release-:i386-:-:pentium-:- (tnx DJW) +0.80: freebsd-2.2.6-stable-:i386-:-:pentium.ii-:- (tnx JM) +0.80: freebsd-2.2.7-release-:i386-:-:i486.dx2-:- (tnx AI) +0.80: freebsd-2.2.7-release-:i386-:-:pentium.pro-:- (tnx CJ) +0.80: freebsd-2.2.7-release-:i386-:-:pentium/p54c-:- (tnx WA) 0.73: freebsd-3.0-971012-snap-:i386-:-:i486.dx2-:- (tnx AY) -0.72: freebsd-3.0-current-:i386-:-:pentium-:- (tnx black@shadow=???) +0.80: freebsd-3.0-971208-snap-:i386-:-:pentium.pro-:- (tnx AY) +0.80: freebsd-3.0-980524-snap-:i386-:-:pentium/p54c-:- (tnx DCM) +0.80: freebsd-3.0-current-:i386-:-:pentium-:- (tnx J2B) 0.72: hp-ux-b.09.00-a-:-:-:9000.360-:- (tnx VV) 0.72: hp-ux-b.10.01-a-:-:-:9000.715-:- (tnx BG) -0.72: irix-5.3-11091812-:-:-:ip22-:- (tnx PW) -0.73: irix-6.2-03131015-:-:-:ip22-:- (tnx JL) +0.80: hp-ux-b.10.20-a-:-:-:9000.712-:- (tnx VH) +0.80: irix-5.3-02091401-:-:-:ip22-:- (tnx K2K) +0.80: irix-5.3-11091812-:-:-:ip22-:- (tnx AP) +0.80: irix-6.2-03131015-:-:-:ip22-:- (tnx AK) +0.80: irix-6.3-12161207-:-:-:ip32-:- (tnx DH) +0.80: irix-6.5-05190004-:-:-:ip32-:- (tnx DS) +0.80: jcc_bsd+-1.0-jcc_bsd+.1.0.#101..wed.jun..5.14.16.28.jst.1996.-:-:-:powerpc-:- (tnx TY) 0.72: linux-1.2.13-:i386-:-:i486-:- (tnx JDM) +0.71: linux-1.2.13-:i386-:-:ppc-:- (tnx EAP) 0.73: linux-2.0.18-:i386-:-:pentium-:- (tnx JDM) 0.72: linux-2.0.21-:i386-:-:pentium-:- (tnx SJ) +0.80: linux-2.0.22-:i386-:-:pentium-:- (tnx BMS) 0.72: linux-2.0.23-:i386-:-:i486-:- (tnx J2W) 0.72: linux-2.0.24-:i386-:-:pentium-:- (tnx VV) 0.72: linux-2.0.25-:i386-:-:i486-:- (tnx FPL) 0.73: linux-2.0.25-:i386-:-:pentium-:- (tnx AW) 0.72: linux-2.0.26-:i386-:-:pentium-:- (tnx root@pointer=???) +0.80: linux-2.0.27-:i386-:-:pentium-:- (tnx MEE) 0.73: linux-2.0.27-:i386-:-:ppro-:- (tnx PMK) 0.73: linux-2.0.28-:alpha-:-:alpha-:- (tnx T2K) -0.73: linux-2.0.29-:i386-:-:i486-:- (tnx keith@gadget=???) +0.73: linux-2.0.29-:i386-:-:i486-:- (tnx JBKH) +0.72: linux-2.0.29-:i386-:-:i686-:- (tnx SR) 0.73: linux-2.0.29-:i386-:-:pentium-:- (tnx RAL) 0.73: linux-2.0.29-:i386-:-:ppro-:- (tnx GDP) 0.73: linux-2.0.30-:-:-:sparc-:- (tnx DJ) 0.73: linux-2.0.30-:i386-:-:i386-:- (tnx DMV) -0.73: linux-2.0.30-:i386-:-:pentium-:- (tnx AV) -0.73: linux-2.0.32-:i386-:-:pentium-:- (tnx AS) +0.80: linux-2.0.30-:i386-:-:i486-:- (tnx FPL) +0.80: linux-2.0.30-:i386-:-:pentium-:- +0.73: linux-2.0.30-:i386-:-:ppro-:- (tnx TG) +0.80: linux-2.0.31-:i386-:-:pentium-:- (tnx DWR) +0.80: linux-2.0.32-:i386-:-:pentium-:- (tnx AY) +0.73: linux-2.0.32-:i386-:-:ppro-:- (tnx JB) +0.80: linux-2.0.32-osfmach3-:-:-:ppc-:- (tnx CG) +0.80: linux-2.0.33-:-:-:mips-:- (tnx MBS) +0.80: linux-2.0.33-:i386-:-:i486-:- (tnx IH) +0.80: linux-2.0.33-:i386-:-:pentium-:- (tnx AJDV) +0.80: linux-2.0.33-:i386-:-:ppro-:- (tnx PRR) +0.80: linux-2.0.34-:i386-:-:i486-:- (tnx PN) +0.80: linux-2.0.34-:i386-:-:pentium-:- (tnx E2W) +0.80: linux-2.0.34-:i386-:-:ppro-:- (tnx DP) +0.80: linux-2.0.35-:i386-:-:i386-:- (tnx GH) +0.80: linux-2.0.35-:i386-:-:i486-:- (tnx HF) +0.80: linux-2.0.35-:i386-:-:pentium-:- (tnx UO) +0.80: linux-2.0.35-:i386-:-:ppro-:- (tnx SR) +0.80: linux-2.0.36-:i386-:-:pentium-:- (tnx WR) 0.73: linux-2.0.7-:i386-:-:i486-:- (tnx TLM) +0.80: linux-2.1.102-:i386-:-:pentium-:- (tnx BBBH) +0.80: linux-2.1.105-:i386-:-:pentium-:- (tnx JF) +0.80: linux-2.1.108-:alpha-:-:alpha-:- (tnx PR) 0.73: linux-2.1.30-:i386-:-:pentium-:- (tnx RAS) 0.73: linux-2.1.36-:i386-:-:pentium-:- (tnx JF) +0.80: linux-2.1.82-:i386-:-:pentium-:- (tnx AY) 0.73: netbsd-1.1-:i386-:-:pentium.(genuineintel.586-class.cpu)-:- (tnx GL) +0.80: netbsd-1.3-:i386-:-:intel.486dx2.(486-class)-:- (tnx GL) +0.80: netbsd-1.3.1-:sun3-:-:sun.3/60-:- (tnx MBS) 0.73: netbsd-1.3_alpha-:i386-:-:intel.pentium.(p54c).(586-class)-:- (tnx GL) -0.73: nextstep-3.3-:mc680x0-:-:68040-:- (tnx WEB) +0.80: netbsd-1.3h-:sparc-:-:mb86904.@.85.mhz,.on-chip.fpu-:- (tnx FN) +0.73: nextstep-3.3-:mc680x0-:-:68040-:- (tnx root@superscript=???) +0.80: nextstep-4.1-:mc680x0-:-:68040-:- (tnx FN) +0.80: openbsd-2.3-generic#6-:openbsd.i386-:-:i386-:- (tnx JM) +0.80: openbsd-2.3-work.kernel#0-:openbsd.i386-:-:i386-:- (tnx JKB) +0.80: osf1-v2.0-240-:-:-:alpha-:- (tnx JF) 0.73: osf1-v3.2-214-:-:-:alpha-:- (tnx A2P) -0.73: osf1-v4.0-564-:-:-:alpha-:- (tnx A2P) -0.73: sunos-4.1.3_u1-1-:sparc-:sun4-:sun4c-:sun4c- (tnx MBS) +0.80: osf1-v4.0-564-:-:-:alpha-:- (tnx ayamura@gw=???) +0.80: osf1-v4.0-564.32-:-:-:alpha-:- (tnx TT) +0.80: sunos-4.1.3_u1-1-:sparc-:sun4-:sun4c-:sun4c- (tnx MBS) +0.80: sunos-4.1.3_u1-1-:sparc-:sun4-:sun4m-:sun4m- (tnx ayamura@honey=???) 0.73: sunos-4.1.3_u1-4-:unknown-:sun4-:sun4m-:sun4m- (tnx J2B) 0.73: sunos-4.1.4-2-:sparc-:sun4-:sun4m-:sun4m- -0.73: sunos-5.4-generic-:sparc-:sun4-:sun4m-:sun4m- +0.72: sunos-5.4-generic-:sparc-:-:sun4m-:- (tnx MS) +0.80: sunos-5.4-generic-:sparc-:sun4-:sun4m-:sun4m- 0.72: sunos-5.4-generic_101945-32-:sparc-:sun4-:sun4m-:sun4m- (tnx RDM) +0.80: sunos-5.4-generic_101945-34-:sparc-:sun4-:sun4m-:sun4m- (tnx HU) 0.73: sunos-5.5-generic-:i386-:i86pc-:i86pc-:i86pc- (tnx PW) 0.72: sunos-5.5-generic-:sparc-:sun4-:sun4c-:sun4c- (tnx CG) -0.73: sunos-5.5-generic-:sparc-:sun4-:sun4m-:sun4m- (tnx RDM) +0.80: sunos-5.5-generic-:sparc-:sun4-:sun4m-:sun4m- (tnx KB) 0.72: sunos-5.5-generic-:sparc-:sun4-:sun4u-:sun4u- (tnx SAC) -0.72: sunos-5.5-generic_103094-03-:i386-:i86pc-:i86pc-:i86pc- (tnx root@utahdining=???) -0.73: sunos-5.5-generic_103094-07-:i386-:i86pc-:i86pc-:i86pc- (tnx MAZ) +0.80: sunos-5.5-generic_103093-06-:sparc-:sun4-:sun4m-:sun4m- (tnx TEE) +0.72: sunos-5.5-generic_103094-03-:i386-:i86pc-:i86pc-:i86pc- (tnx D2K) +0.80: sunos-5.5-generic_103094-07-:i386-:i86pc-:i86pc-:i86pc- (tnx MRG) 0.73: sunos-5.5.1-generic-:sparc-:sun4-:sun4c-:sun4c- (tnx CG) 0.73: sunos-5.5.1-generic-:sparc-:sun4-:sun4m-:sun4m- (tnx MBS) +0.80: sunos-5.5.1-generic-:sparc-:sun4-:sun4u-:sun4u- (tnx DNW) 0.73: sunos-5.5.1-generic_103640-03-:sparc-:sun4-:sun4m-:sun4m- (tnx DPS) 0.72: sunos-5.5.1-generic_103640-03-:sparc-:sun4-:sun4u-:sun4u- (tnx root@adrastea=???) +0.80: sunos-5.5.1-generic_103640-05-:sparc-:sun4-:sun4c-:sun4c- (tnx JRM) +0.80: sunos-5.5.1-generic_103640-05-:sparc-:sun4-:sun4u-:sun4u- (tnx AY) 0.73: sunos-5.5.1-generic_103640-08-:sparc-:sun4-:sun4m-:sun4m- (tnx RA) +0.73: sunos-5.5.1-generic_103640-12-:sparc-:sun4-:sun4u-:sun4u- (tnx SO) +0.80: sunos-5.5.1-generic_103640-21-:sparc-:sun4-:sun4c-:sun4c- (tnx BK) +0.80: sunos-5.5.1-generic_105428-01-:sparc-:sun4-:sun4u-:sun4u- (tnx KK) 0.72: sunos-5.5.1-generic_patch-:i386-:i86pc-:i86pc-:i86pc- (tnx D2K) 0.73: sunos-5.5.1-iss_1.0-:sparc-:sun4-:sun4u-:sun4u- (tnx LST) +0.80: sunos-5.6-generic-:i386-:i86pc-:i86pc-:i86pc- (tnx MD) 0.73: sunos-5.6-generic-:sparc-:sun4-:sun4c-:sun4c- (tnx DS) -0.73: sunos-5.6-generic-:sparc-:sun4-:sun4u-:sun4u- (tnx DV) -0.73: ultrix-4.3-0-:-:-:risc-:- (tnx bruno@cerberus=???) -0.73: unix_sv-4.2mp-2.03-:i386-:-:i386-:- (tnx HP) +0.80: sunos-5.6-generic-:sparc-:sun4-:sun4u-:sun4u- (tnx SOH) +0.80: sunos-5.6-generic_105181-03-:sparc-:sun4-:sun4u-:sun4u- (tnx SJ) +0.80: sunos-5.6-generic_105181-06-:sparc-:sun4-:sun4u-:sun4u- (tnx BOR) +0.80: sunos-5.6-generic_105181-07-:sparc-:sun4-:sun4m-:sun4m- (tnx ESM) +0.80: sunos-5.6-generic_105181-07-:sparc-:sun4-:sun4u-:sun4u- (tnx root@test5=???) +0.80: sunos-5.6-generic_105181-08-:sparc-:sun4-:sun4u-:sun4u- (tnx KE) +0.80: sunos-5.6-generic_105182-08-:i386-:i86pc-:i86pc-:i86pc- (tnx LBR) +0.73: ultrix-4.3-0-:-:-:risc-:- (tnx BW) +0.80: ultrix-4.5-0-:-:-:risc-:- (tnx LFB) +0.80: unix_sv-4.2mp-1.release.1114.02.15-:r4000-:-:r4000-:- (tnx HY) +0.80: unix_sv-4.2mp-2.03-:i386-:-:i386-:- (tnx HP) 0.73: unix_sv-4.2mp-2.1.2-:i386-:-:i386-:- (tnx RN) @@ -1,9 +1,35 @@ -auto-ccld.sh -make-load -find-systype -systype +tcpclient.0 +tcpserver.0 +tcprules.0 +tcprulescheck.0 +tcp-environ.0 +who@.0 +date@.0 +finger@.0 +http@.0 +tcpcat.0 +mconnect.0 +fixcr.0 +addcr.0 +delcr.0 +argv0.0 +recordio.0 +error.0 +error_str.0 +alloc.0 +case.0 +cdb.0 +env.0 +fd_copy.0 +fd_move.0 +getln.0 +getln2.0 +sgetopt.0 +subgetopt.0 +stralloc.0 +wait.0 +man load -make-compile compile tcpclient.o ip.o @@ -14,8 +40,14 @@ select.h timeoutconn.o timeoutread.o timeoutwrite.o -make-makelib +systype makelib +subgetopt.o +sgetopt.o +getopt.a +strerr_sys.o +strerr_die.o +strerr.a stralloc_eady.o stralloc_pend.o stralloc_copy.o @@ -45,6 +77,7 @@ substdio.a error.o error_str.o error.a +str_chr.o str_len.o str_diff.o str_diffn.o @@ -61,7 +94,6 @@ sig_block.o hassgact.h sig_catch.o sig_pause.o -sig_dfl.o sig_pipe.o sig_child.o sig_term.o @@ -71,13 +103,9 @@ fd_move.o fd.a case_lowers.o case.a -subgetopt.o -sgetopt.o -getopt.a fmt_str.o fmt_ulong.o scan_ulong.o -scan_8long.o fs.a socket.lib dns.lib @@ -93,10 +121,8 @@ open_trunc.o open.a haswaitp.h wait_nohang.o +wait_pid.o wait.a -strerr_sys.o -strerr_die.o -strerr.a tcpserver tcprules.o cdbmss.o @@ -107,27 +133,40 @@ cdbmake.a getln.o getln2.o getln.a -seek_cur.o -seek_end.o seek_set.o -seek_trunc.o seek.a tcprules +tcprulescheck.o +tcprulescheck who@ date@ finger@ +http@ tcpcat mconnect +mconnect-io.o +mconnect-io +fixcr.o +fixcr addcr.o addcr delcr.o delcr -it -tcpclient.0 -tcpserver.0 -tcprules.0 -tcp-environ.0 -man +argv0.o +argv0 +recordio.o +recordio +rts +prog install.o +hier.o +auto-str.o +auto-str +auto_home.c +auto_home.o install +instcheck.o +instcheck +it setup +check @@ -1,62 +1,122 @@ Thanks to various people for bug reports and other comments on various versions of tcpclient, tcpserver, and tcpcontrol: -RA = Russ Allbery -J2B = Jos Backus -JLB = Julie L. Baumler -HB = Harald Barth -WEB = William E. Baxter -DEB = Donald E. Blais -SAC = Shawn A. Clifford -JJE = Joshua J. Ellis -JF = Janos Farkas -CG = Chris Garrigues -BG = Bert Gijsbers -TG = Tim Goodwin -J2H = Jeff Hayward -J1H = Johan Holmberg +A2P = Andrea Paolini AI = Akihiro Iijima -DJ = Dirk Jaeckel -SJ = Sudish Joseph -PMK = Patrick M. Kane +AJDV = Albert J. deVera +AK = Ayamura Kikuchi +AP = Andrew Pam +ARB = Anand R. Buddhdev +AS = Amos Shapira +AT = Akihiro Terasaki +AV = Alex Vostrikov +AW = Arne Wichmann +AY = Araki Yasuhiro +BBBH = Bart B. B. Hanssens +BG = Bert Gijsbers +BJR = Brian J. Reichert +BK = Brendan Kehoe +BMF = Brian M. Fisk +BMS = Bradford M. Shelton +BOR = Brian O'Reilly +BW = Bruno Wolff +CG = Chris Garrigues +CJ = Chris Johnson +CW = Christian Wettergren D2K = Dax Kelson -T2K = Thomas Kuerten -GL = Giles Lean -KL = Karl Lehenbauer +DCM = Daniel C. Mahoney +DEB = Donald E. Blais +DH = Darren Hall +DJ = Dirk Jaeckel +DJW = David J. Walton +DMV = Dan M. Vogel +DNW = Dale N. Woolridge +DP = David Pool +DPS = David P. Smith +DS = Dave Sill +DV = Dirk Vluegels +DWR = Darren W. Rees +E2W = Ed Weinberg +EAP = Eric A. Perlman +ESM = Edward S. Marshall +EW = Erik Wallin +FN = Faried Nawaz FPL = Frederik P. Lindberg -SML = Stefan M. Linnemann +GB = Gerry Boudreaux +GDP = Greg D. Patterson +GH = Grant Holliday +GL = Giles Lean +HB = Harald Barth +HF = Harald Fritzsche +HP = Hitesh Patel +HU = Hirofumi Ukawa +HY = Hiroshi Yamashita +IH = Ingmar Hupp +J1H = Johan Holmberg +J2B = Jos Backus +J2H = Jeff Hayward +J2W = Jeremy Wohl +JB = John Bolhuis +JBKH = J. B. Keith Humphreys +JDM = John D. Mitchell +JF = Janos Farkas +JJE = Joshua J. Ellis +JKB = Jakub K. Boguslaw JL = Jim Littlefield -RWL = Robert W. Luce +JLB = Julie L. Baumler +JM = Jose Monteiro +JRM = Jason R. Mastaler +K2K = Kris Kennaway +KB = Keith Burdis +KE = Kenny Elliott +KK = Kikuchi Kousuke +KL = Karl Lehenbauer +LBR = Lars Balker Rasmussen +LFB = Lyndon F. Bartels +LST = Louis S. Theran +M1S = Michael Salmon +MAZ = Matthew A. Zahorik +MBS = Michael B. Scher +MD = Mark Delany +MEE = Mads E. Eilertsen +MH = Michael Hirohama +MM = Martin Mersberger +MPS = Matt P. Simerson +MRG = Michael R. Gile +MS = Mikael Suokas +NM = Nobuhiro Murata +PMK = Patrick M. Kane +PN = Petr Novotny +PR = Peter Rye +PRR = Paul R. Rotering +PW = Peter Wilkinson +RA = Russ Allbery RAL = Roberto A. Lumbreras -TM = Toshinori Maeno -TLM = Timothy L. Mayo +RAS = Richard A. Soderberg RDM = Raul D. Miller -JDM = John D. Mitchell -NM = Nobuhiro Murata -FN = Faried Nawaz RN = Russell Nelson +RWL = Robert W. Luce +SAC = Shawn A. Clifford +SGT = Stathy G. Touloumis +SJ = Sudish Joseph +SML = Stefan M. Linnemann SN = Stan Norton -A2P = Andrea Paolini -HP = Hitesh Patel -GDP = Greg D. Patterson -EAP = Eric A. Perlman -BJR = Brian J. Reichert -M1S = Michael Salmon -MBS = Mike Scher -AS = Amos Shapira -DS = Dave Sill -MPS = Matt P. Simerson -DPS = David P. Smith -RAS = Richard A. Soderberg -LST = Louis S. Theran +SO = Shin Ohira +SOH = Shinya O'Hira +SR = Sean Reifschneider +T2K = Thomas Kuerten +TEE = Thomas E. Erskine +TG = Tim Goodwin +TLM = Timothy L. Mayo +TM = Toshinori Maeno +TT = Tomoaki Terazawa +TU = Todd Underwood +TY = Tomoki Yoshioka +UO = Uwe Ohse +VH = Vern Hart VV = Vince Vielhaber -DV = Dirk Vluegels -DMV = Dan M. Vogel -AV = Alex Vostrikov -EW = Erik Wallin -CW = Christian Wettergren -AW = Arne Wichmann -PW = Peter Wilkinson -J2W = Jeremy Wohl -AY = Araki Yasuhiro -MAZ = Matthew A. Zahorik +WA = Waskita Adijarto +WCH = Wu Ching-hong +WEB = William E. Baxter +WR = Wolfgang Rufeger +YT = Yoshitatsu Takeshita @@ -1,3 +1,6 @@ -use strerr in tcpclient -maybe include multitee in package -include more clients +switch to new env, exec libraries +switch to better resolver +expand rts + +make pre-forking version of tcpserver +make DNS-free versions of tcpserver and tcpclient @@ -1 +1 @@ -ucspi-tcp 0.80 +ucspi-tcp 0.84 @@ -1,21 +1,22 @@ .TH addcr 1 .SH NAME -addcr \- copy stdin to stdout adding \\r chars after all \\n +addcr \- add a CR before each LF .SH SYNOPSIS .B addcr .SH DESCRIPTION .B addcr -reads stdin, adds \\r chars after any \\n and copies all to stdout. - -.SH DIAGNOSTICS -.PP -Returns zero on success, or 111 if an error occurred. - +inserts CR at the end of each line of input. +It does not insert CR at the end of a partial final line. +.SH COMPATIBILITY +Some vendors ship +.B unix2dos +or +.B bsd2dos +tools similar to +.BR addcr . +Those tools often blow up on long lines and nulls. +.B addcr +has no trouble with long lines and nulls. .SH "SEE ALSO" -.BR delcr (1) - -.SH AUTHOR -Written by D. J. Bernstein <djb@pobox.com>. - -Manual page added by Roberto Lumbreras <rover@debian.org>. - +delcr(1), +fixcr(1) diff --git a/addcr=x b/addcr=x deleted file mode 100644 index f3e9229..0000000 --- a/addcr=x +++ /dev/null @@ -1,3 +0,0 @@ -substdio.a -error.a -str.a @@ -0,0 +1,62 @@ +.TH alloc 3 +.SH NAME +alloc \- allocate memory +.SH SYNTAX +.B #include <alloc.h> + +char *\fBalloc\fP(\fInew\fR); + +void \fBalloc_free\fP(\fIx\fR); + +void \fBalloc_re\fP(&\fIx\fR,\fIold\fR,\fInew\fR); + +char *\fIx\fR; +.br +unsigned int \fIold\fR; +.br +unsigned int \fInew\fR; +.SH DESCRIPTION +.B alloc +allocates enough space from the heap for +.I new +bytes of data, +adequately aligned for any data type. +.I new +may be 0. +.B alloc +returns a pointer to the space. +If space is not available, +.B alloc +returns 0, +setting +.B errno +appropriately. + +.B alloc_free +returns space to the heap. + +.B alloc_re +expands the space allocated to +.I x +from +.I old +bytes to +.I new +bytes. +It allocates new space, +copies +.I old +bytes from the old space to the new space, +returns the old space to the heap, +and changes +.I x +to point to the new space. +It then returns 1. +If space is not available, +.B alloc_re +returns 0, +leaving the old space alone. +.SH "SEE ALSO" +sbrk(2), +malloc(3), +error(3) diff --git a/alloc=l b/alloc=l deleted file mode 100644 index 6dc62ab..0000000 --- a/alloc=l +++ /dev/null @@ -1,2 +0,0 @@ -alloc.o -alloc_re.o @@ -0,0 +1,47 @@ +.TH argv0 1 +.SH NAME +argv0 \- run a program with a specified 0th argument +.SH SYNOPSIS +.B argv0 +.I realname +.I zero +[ +.I arg ... +] +.SH DESCRIPTION +.B argv0 +runs +the program stored as +.I realname +on disk, +with the given +arguments. +It sets the 0th argument of +the program to +.IR zero . + +For example, + +.EX + argv0 /bin/csh -bin/csh +.EE + +runs +.B /bin/csh +with a 0th argument of +.BR -bin/csh . +.B csh +will think it is a login shell +and behave accordingly. + +.B argv0 +can be used to run some +.B inetd +wrappers under +.BR tcpserver . +.SH "SEE ALSO" +csh(1), +tcpserver(1), +execve(2), +execvp(3), +inetd(8) @@ -0,0 +1,11 @@ +#include "strerr.h" + +void main(argc,argv) +int argc; +char **argv; +{ + if (argc < 3) + strerr_die1x(100,"argv0: usage: argv0 realname program [ arg ... ]"); + execvp(argv[1],argv + 2); + strerr_die4sys(111,"argv0: fatal: ","unable to run ",argv[1],": "); +} diff --git a/auto-str=x b/auto-str=x deleted file mode 100644 index f3e9229..0000000 --- a/auto-str=x +++ /dev/null @@ -1,3 +0,0 @@ -substdio.a -error.a -str.a diff --git a/auto_home.h b/auto_home.h new file mode 100644 index 0000000..a756cd0 --- /dev/null +++ b/auto_home.h @@ -0,0 +1,6 @@ +#ifndef AUTO_HOME_H +#define AUTO_HOME_H + +extern char auto_home[]; + +#endif @@ -0,0 +1,100 @@ +.TH case 3 +.SH NAME +case \- convert ASCII uppercase bytes to lowercase +.SH SYNTAX +.B #include <case.h> + +void \fBcase_lowers\fP(\fIs\fR); +.br +void \fBcase_lowerb\fP(\fIs\fR,\fIlen\fR); + +int \fBcase_diffs\fP(\fIs\fR,\fIt\fR); +.br +int \fBcase_equals\fP(\fIs\fR,\fIt\fR); +.br +int \fBcase_starts\fP(\fIs\fR,\fIt\fR); + +int \fBcase_diffb\fP(\fIs\fR,\fIlen\fR,\fIt\fR); +.br +int \fBcase_startb\fP(\fIs\fR,\fIlen\fR,\fIt\fR); + +char *\fIs\fR; +.br +char *\fIt\fR; +.br +unsigned int \fIlen\fR; +.SH DESCRIPTION +.B case_lowers +converts each uppercase byte in the string +.I s +to lowercase. +.I s +must be 0-terminated. + +.B case_lowerb +converts each uppercase byte in the buffer +.IR s , +of length +.IR len , +to lowercase. + +.B case_diffs +lexicographically compares lowercase versions of the strings +.I s +and +.IR t . +It returns something positive, negative, or zero +when the first is larger than, smaller than, or equal to the second. +.I s +and +.I t +must be 0-terminated. + +.B case_equals +means +.BR !case_diffs . + +.B case_starts +returns 1 if a lowercase version of +.I s +starts with a lowercase version of +.IR t . +.I s +and +.I t +must be 0-terminated. + +.B case_diffb +lexicographically compares lowercase versions of the buffers +.I s +and +.IR t , +each of length +.IR len . +It returns something positive, negative, or zero +when the first is larger than, smaller than, or equal to the second. + +.B case_startb +returns 1 if a lowercase version of the buffer +.IR s , +of length +.IR len , +starts with a lowercase version of the string +.IR t . +.I t +must be 0-terminated. + +The +.B case +routines +are ASCII-specific. +They are suitable for programs that handle +case-independent networking protocols. + +All comparisons are performed on unsigned bytes. +.SH "SEE ALSO" +byte_diff(3), +byte_equal(3), +str_diff(3), +str_equal(3), +str_start(3) @@ -1 +0,0 @@ -case_lowers.o @@ -0,0 +1,62 @@ +.TH cdb 3 +.SH NAME +cdb \- read from a constant database +.SH SYNTAX +.B #include <cdb.h> + +int \fBcdb_seek(\fP\fIfd,key,len,dlen\fR\fB)\fP; + +int \fIfd\fR; +.br +char *\fIkey\fR; +.br +unsigned int \fIlen\fR; +.br +uint32 *\fIdlen\fR; +.SH DESCRIPTION +.B cdb_seek +looks up +.I key +in a constant database. +It returns 1 if +.I key +is present, +0 if +.I key +is not present, +or \-1 if there was a read error. +.I key +is an array of +.I len +characters. + +.B cdb_seek +needs an open file descriptor, +.IR fd , +pointing to the database. +If +.B cdb_seek +returns 1, +it points +.I fd +at the beginning of the data portion of the first record +indexed by +.IR key , +and it stores the data length in +.IR dlen. +.B cdb_seek +does not provide a way to read subsequent records with the same key. + +It's fine to do several +.B cdb_seek +lookups with the same open file descriptor. +Beware, however, that two simultaneous +.B cdb_seek +lookups can fail horribly; +separate processes should not share the same database descriptor. +Furthermore, any updates after the database was opened +will be invisible. +It's rarely a good idea for a long-running program +to hold a database open. +.SH "SEE ALSO" +cdbget(1) @@ -1,3 +0,0 @@ -cdb_hash.o -cdb_unpack.o -cdb_seek.o diff --git a/cdbmake=l b/cdbmake=l deleted file mode 100644 index 5747fb0..0000000 --- a/cdbmake=l +++ /dev/null @@ -1,3 +0,0 @@ -cdbmake_pack.o -cdbmake_hash.o -cdbmake_add.o diff --git a/conf-bin b/conf-bin deleted file mode 100644 index 350f016..0000000 --- a/conf-bin +++ /dev/null @@ -1,3 +0,0 @@ -/usr/bin - -Programs will be installed in this directory. diff --git a/conf-home b/conf-home new file mode 100644 index 0000000..4265705 --- /dev/null +++ b/conf-home @@ -0,0 +1,4 @@ +/usr + +This is the home directory. Programs will be installed in .../bin; man +pages will be installed in subdirectories of .../man. diff --git a/conf-man b/conf-man deleted file mode 100644 index 1c3820e..0000000 --- a/conf-man +++ /dev/null @@ -1,5 +0,0 @@ -/usr/man - -Man pages will be installed in subdirectories of this directory. An -unformatted man page foo.1 will go into .../man1/foo.1; a formatted man -page foo.0 will go into .../cat1/foo.0. @@ -0,0 +1,32 @@ +.TH date@ 1 +.SH NAME +date@ \- print the date on a host +.SH SYNTAX +.B date@ +[ +.I host +] +.SH DESCRIPTION +.B date@ +connects to TCP port 13 (Daytime) on +.I host +and prints any data it receives. +It removes CR and converts unprintable characters to a visible format. + +If +.I host +is not supplied, +.B date@ +connects to the local host. + +Some computers respond to port 13 with a human-readable date. +For example, they may be running + +.EX + tcpserver 0 13 date & +.EE +.SH "SEE ALSO" +cat(1), +delcr(1), +tcpclient(1), +tcpserver(1) @@ -1 +1 @@ -BIN/tcpclient -RHl0 -- "${1-0}" 13 sh -c 'exec BIN/delcr <&6' | cat -v +HOME/bin/tcpclient -RHl0 -- "${1-0}" 13 sh -c 'exec HOME/bin/delcr <&6' | cat -v diff --git a/date@=s b/date@=s deleted file mode 100644 index e69de29..0000000 --- a/date@=s +++ /dev/null diff --git a/debian/README-src b/debian/README-src index 2d69751..09dc364 100644 --- a/debian/README-src +++ b/debian/README-src @@ -6,4 +6,8 @@ Hopefully this will help allow a binary package to be approved, but even if it doesn't it means that Debian users can use #PACKAGE# without too much effort. -Philip Hands <phil@hands.com> +To generate the real binary package, just run: + + build-#PACKAGE# + +Jon Marler <jmarler@debian.org> diff --git a/debian/addcr.1 b/debian/addcr.1 new file mode 100644 index 0000000..51e52ea --- /dev/null +++ b/debian/addcr.1 @@ -0,0 +1,21 @@ +.TH addcr 1 +.SH NAME +addcr \- copy stdin to stdout adding \\r chars after all \\n +.SH SYNOPSIS +.B addcr +.SH DESCRIPTION +.B addcr +reads stdin, adds \\r chars after any \\n and copies all to stdout. + +.SH DIAGNOSTICS +.PP +Returns zero on success, or 111 if an error occurred. + +.SH "SEE ALSO" +.BR delcr (1) + +.SH AUTHOR +Written by D. J. Bernstein <djb@pobox.com>. + +Manual page added by Roberto Lumbreras <rover@debian.org>. + diff --git a/debian/changelog b/debian/changelog index 851cd0b..c50aa49 100644 --- a/debian/changelog +++ b/debian/changelog @@ -1,3 +1,16 @@ +ucspi-tcp (0.84-1) unstable; urgency=low + + * New upstream release (closes: #34076) + * New maintainer + + -- Jon Marler <jmarler@debian.org> Tue, 6 Jul 1999 11:58:37 +0100 + +ucspi-tcp (0.80-4) unstable; urgency=low + + * get rid of RBL patch, at Dan Bernstein's request + + -- Philip Hands <phil@hands.com> Mon, 22 Jun 1998 20:04:44 +0100 + ucspi-tcp (0.80-3) unstable; urgency=low * fix the distribution, from non-free, to unstable diff --git a/debian/control b/debian/control index 97987c8..330cd7a 100644 --- a/debian/control +++ b/debian/control @@ -1,18 +1,18 @@ Source: ucspi-tcp Section: non-free/net Priority: optional -Maintainer: Philip Hands <phil@hands.com> +Maintainer: Jon Marler <jmarler@debian.org> Standards-Version: 2.4.0.0 Package: ucspi-tcp-src Architecture: all -Depends: dpkg-dev (>= 1.4.0.20), patch (>= 2.5-0bo1), fileutils (>= 3.16-4bo1.1), fakeroot | sudo, gcc, make +Depends: dpkg-dev (>= 1.4.0.20), patch (>= 2.5-0bo1), fakeroot | sudo, gcc, make Description: Source only package for building ucspi-tcp binary package Written by Dan J. Bernstein, tcpclient and tcpserver are powerful easy-to-use command-line tools for building TCP client-server applications. tcpserver provides TCP access control features, similar to tcp-wrappers/tcpd's hosts.allow but much - faster; it can run high-availavility services much better than + faster; it can run high-availability services much better than inetd. . Real-time Blocking List support is also included in tcpserver, so diff --git a/debian/control.real b/debian/control.real index 086cf9b..bdce481 100644 --- a/debian/control.real +++ b/debian/control.real @@ -1,7 +1,7 @@ Source: ucspi-tcp Section: non-free/net Priority: optional -Maintainer: Philip Hands <phil@hands.com> +Maintainer: Jon Marler <jmarler@debian.org> Standards-Version: 2.4.0.0 Package: ucspi-tcp @@ -12,7 +12,7 @@ Description: tools for building TCP client-server applications. powerful easy-to-use command-line tools for building TCP client-server applications. tcpserver provides TCP access control features, similar to tcp-wrappers/tcpd's hosts.allow but much - faster; it can run high-availavility services much better than + faster; it can run high-availability services much better than inetd. . Real-time Blocking List support is also included in tcpserver, so @@ -43,7 +43,7 @@ Description: Source only package for building ucspi-tcp binary package powerful easy-to-use command-line tools for building TCP client-server applications. tcpserver provides TCP access control features, similar to tcp-wrappers/tcpd's hosts.allow but much - faster; it can run high-availavility services much better than + faster; it can run high-availability services much better than inetd. . Real-time Blocking List support is also included in tcpserver, so diff --git a/debian/copyright b/debian/copyright index ffec82d..090e0ca 100644 --- a/debian/copyright +++ b/debian/copyright @@ -8,8 +8,7 @@ See http://maps.vix.com/rbl/ and http://www.qmail.org/rbl/ for more information about RBL. This package was put together from sources obtained from: - ftp://koobera.math.uic.edu/pub/software/ucspi-tcp-0.80.tar.gz - http://www.qmail.org/rbl/ucspi-tcp-0.80-rbl.diffs + ftp://koobera.math.uic.edu/www/software/ucspi-tcp-0.84.tar.gz Changes for Debian: * added Debian GNU/Linux package maintenance system files diff --git a/debian/delcr.1 b/debian/delcr.1 new file mode 100644 index 0000000..29f3cf2 --- /dev/null +++ b/debian/delcr.1 @@ -0,0 +1,21 @@ +.TH delcr 1 +.SH NAME +delcr \- copy stdin to stdout deleting a \\r char before \\n from input +.SH SYNOPSIS +.B delcr +.SH DESCRIPTION +.B delcr +reads stdin, deletes \\r char before a \\n and copies the remaining to stdout. + +.SH DIAGNOSTICS +.PP +return status is zero on success, or 111 if an error occurred. + +.SH "SEE ALSO" +.BR addcr (1) + +.SH AUTHOR +Written by D. J. Bernstein <djb@pobox.com>. + +Manual page added by Roberto Lumbreras <rover@debian.org>. + diff --git a/debian/postrm b/debian/postrm index 7c4528e..f5f9b19 100644 --- a/debian/postrm +++ b/debian/postrm @@ -3,4 +3,4 @@ if [ remove = "$1" ]; then dpkg-divert --package ucspi-tcp --remove --rename \ --divert /usr/man/man5/tcp-environ.5q.gz /usr/man/man5/tcp-environ.5.gz -fi
\ No newline at end of file +fi diff --git a/debian/preinst b/debian/preinst index 3fff412..fc74082 100644 --- a/debian/preinst +++ b/debian/preinst @@ -3,4 +3,4 @@ if [ install = "$1" ]; then dpkg-divert --package ucspi-tcp --add --rename \ --divert /usr/man/man5/tcp-environ.5q.gz /usr/man/man5/tcp-environ.5.gz -fi
\ No newline at end of file +fi diff --git a/debian/rules b/debian/rules index 84dfad9..b08dad0 100755 --- a/debian/rules +++ b/debian/rules @@ -4,11 +4,11 @@ SHELL = /bin/bash -BINS = tcpserver tcpclient tcprules addcr delcr +BINS = tcpserver tcpclient tcprules tcprulescheck mconnect-io addcr delcr fixcr argv0 recordio -SHBINS = who@ date@ finger@ tcpcat mconnect +SHBINS = who@ date@ finger@ tcpcat mconnect http@ -MAN1 = tcpclient.1 tcpserver.1 tcprules.1 addcr.1 delcr.1 +MAN1 = tcpclient.1 tcpserver.1 tcprules.1 debian/addcr.1 debian/delcr.1 MAN5 = tcp-environ.5 @@ -21,6 +21,7 @@ PKG_UPVER = $(shell perl -e 'print <> =~ /\((.*)-[^-]*\)/' debian/changelog) TMPSRC = debian/tmp-src build: + echo "$$PWD/debian/tmp/usr" > conf-home-debian $(MAKE) touch build @@ -31,7 +32,8 @@ clean: checkdir debian/control rm -rf debian/tmp debian/misc $(TMPSRC) rm -f auto-ccld.sh make-load find-systype systype load \ make-compile compile select.h make-makelib makelib \ - hassgprm.h hassgact.h dns.lib uint32.h haswaitp.h + hassgprm.h hassgact.h dns.lib uint32.h haswaitp.h \ + install instcheck test.cdb auto-str rts auto_home.c find . \( -name '#*#' -o -name '*~' -o -name DEADJOE -o \ -name '*.orig' -o -name '*.rej' -o -name '*.bak' -o \ -name '.*.orig' -o -name '.*.rej' -o -name .SUMS -o \ @@ -53,6 +55,7 @@ binary-arch: checkroot build install -s -m 0755 $(BINS) debian/tmp/usr/bin/ install -m 0644 $(MAN1) debian/tmp/usr/man/man1/ install -m 0644 $(MAN5) debian/tmp/usr/man/man5/ + install -m 0644 CHANGES debian/tmp/usr/doc/ucspi-tcp/changelog install -m 0644 debian/changelog debian/tmp/usr/doc/ucspi-tcp/changelog.Debian install -m 0644 $(DOCS) debian/tmp/usr/doc/ucspi-tcp/ diff --git a/default.0.do b/default.0.do deleted file mode 100644 index e40b50c..0000000 --- a/default.0.do +++ /dev/null @@ -1,9 +0,0 @@ -if test -r "$2=0" -then - dependon "$2=0" - dependon `cat "$2=0"` - nroff -man `cat "$2=0"` - formake nroff -man `cat "$2=0"` '>' $1 -else - nosuchtarget -fi diff --git a/default.a.do b/default.a.do deleted file mode 100644 index b61fc5c..0000000 --- a/default.a.do +++ /dev/null @@ -1,10 +0,0 @@ -if test -r "$2=l" -then - dependon "$2=l" - dependon makelib `cat "$2=l"` - directtarget - formake ./makelib $1 `cat "$2=l"` - ./makelib $1 `cat "$2=l"` -else - nosuchtarget -fi diff --git a/default.do b/default.do deleted file mode 100644 index 6fe9f16..0000000 --- a/default.do +++ /dev/null @@ -1,77 +0,0 @@ -if test -r $1=x -then - dependon $1=x - libs=`grep '\.lib *$' "$1=x"` - libscat='' - for i in $libs - do - libscat="$libscat "'`'"cat $i"'`' - done - objs=`grep -v '\.lib *$' "$1=x"` - dependon load $1.o $objs $libs - directtarget - formake ./load $1 $objs "$libscat" - eval ./load $1 $objs $libscat - exit 0 -fi - -if test -r $1=s -then - dependon $1=s warn-auto.sh $1.sh conf-bin - formake cat warn-auto.sh $1.sh '\' - formake '| sed s}BIN}"`head -1 conf-bin`"}g >' $1 - formake chmod 755 $1 - cat warn-auto.sh $1.sh | sed s}BIN}"`head -1 conf-bin`"}g - chmod 755 $3 - exit 0 -fi - -case "$1" in - shar) - dependon FILES `cat FILES` - formake 'shar -m `cat FILES` > shar' - formake 'chmod 400 shar' - shar -m `cat FILES` - chmod 400 $3 - ;; - compile|load|makelib) - dependon make-$1 warn-auto.sh systype - formake "( cat warn-auto.sh; ./make-$1 "'"`cat systype`"'" ) > $1" - formake "chmod 755 $1" - cat warn-auto.sh - ./make-$1 "`cat systype`" - chmod 755 $3 - ;; - make-compile|make-load|make-makelib) - dependon $1.sh auto-ccld.sh - formake "cat auto-ccld.sh $1.sh > $1" - formake "chmod 755 $1" - cat auto-ccld.sh $1.sh - chmod 755 $3 - ;; - systype) - dependon find-systype trycpp.c - formake './find-systype > systype' - ./find-systype - ;; - find-systype) - dependon find-systype.sh auto-ccld.sh - formake 'cat auto-ccld.sh find-systype.sh > find-systype' - formake 'chmod 755 find-systype' - cat auto-ccld.sh find-systype.sh - chmod 755 $3 - ;; - auto-ccld.sh) - dependon conf-cc conf-ld warn-auto.sh - formake '( cat warn-auto.sh; \' - formake 'echo CC=\'\''`head -1 conf-cc`\'\''; \' - formake 'echo LD=\'\''`head -1 conf-ld`\'\'' \' - formake ') > auto-ccld.sh' - cat warn-auto.sh - echo CC=\'`head -1 conf-cc`\' - echo LD=\'`head -1 conf-ld`\' - ;; - *) - nosuchtarget - ;; -esac diff --git a/default.o.do b/default.o.do deleted file mode 100644 index 5d5ee1e..0000000 --- a/default.o.do +++ /dev/null @@ -1,15 +0,0 @@ -if test -r $2=m -then - dependon $2=m $2.s - directtarget - as -o $1 $2.s - formake as -o $1 $2.s - exit 0 -fi -depend -$2=m - -directtarget -dependon compile -dependcc $2.c -formake ./compile $2.c -./compile $2.c @@ -1,21 +1,30 @@ .TH delcr 1 .SH NAME -delcr \- copy stdin to stdout deleting a \\r char before \\n from input +delcr \- remove a CR before each LF .SH SYNOPSIS .B delcr .SH DESCRIPTION .B delcr -reads stdin, deletes \\r char before a \\n and copies the remaining to stdout. +removes a CR at the end of each line of input, +if a CR is present. +It also removes a CR at the end of a partial final line. -.SH DIAGNOSTICS -.PP -return status is zero on success, or 111 if an error occurred. +The pipeline -.SH "SEE ALSO" -.BR addcr (1) - -.SH AUTHOR -Written by D. J. Bernstein <djb@pobox.com>. - -Manual page added by Roberto Lumbreras <rover@debian.org>. +.EX + addcr | delcr +.EE +prints an exact copy of its input. +.SH COMPATIBILITY +Some vendors ship +.B dos2unix +or +.B dos2bsd +tools similar to +.BR delcr . +Those tools often blow up on long lines and nulls. +.B delcr +has no trouble with long lines and nulls. +.SH "SEE ALSO" +addcr(1) diff --git a/delcr=x b/delcr=x deleted file mode 100644 index f3e9229..0000000 --- a/delcr=x +++ /dev/null @@ -1,3 +0,0 @@ -substdio.a -error.a -str.a @@ -104,43 +104,6 @@ int wanttype; return 0; } -static int findstring(wanttype) -int wanttype; -{ - unsigned short rrtype; - unsigned short rrdlen; - int i; - - if (numanswers <= 0) return 2; - --numanswers; - if (responsepos == responseend) return DNS_SOFT; - - i = dn_expand(response.buf,responseend,responsepos,name,MAXDNAME); - if (i < 0) return DNS_SOFT; - responsepos += i; - - i = responseend - responsepos; - if (i < 4 + 3 * 2) return DNS_SOFT; - - rrtype = getshort(responsepos); - rrdlen = getshort(responsepos + 8); - responsepos += 10; - - if (rrtype == wanttype) - { - i = *responsepos; - if (i > MAXDNAME - 1) return DNS_SOFT; - if (responsepos + i > responseend) return DNS_SOFT; - byte_copy(name, i, responsepos+1); - name[i] = '\0'; - responsepos += rrdlen; - return 1; - } - - responsepos += rrdlen; - return 0; -} - static int findip(wanttype) int wanttype; { @@ -256,10 +219,9 @@ stralloc *sa; #define FMT_IAA 40 -static int iaafmt(s,ip,dom) +static int iaafmt(s,ip) char *s; struct ip_address *ip; -const char *dom; { unsigned int i; unsigned int len; @@ -271,7 +233,7 @@ const char *dom; i = fmt_ulong(s,(unsigned long) ip->d[1]); len += i; if (s) s += i; i = fmt_str(s,"."); len += i; if (s) s += i; i = fmt_ulong(s,(unsigned long) ip->d[0]); len += i; if (s) s += i; - i = fmt_str(s,dom); len += i; if (s) s += i; + i = fmt_str(s,".in-addr.arpa."); len += i; if (s) s += i; return len; } @@ -281,8 +243,8 @@ struct ip_address *ip; { int r; - if (!stralloc_ready(sa,iaafmt((char *) 0,ip,".in-addr.arpa."))) return DNS_MEM; - sa->len = iaafmt(sa->s,ip,".in-addr.arpa."); + if (!stralloc_ready(sa,iaafmt((char *) 0,ip))) return DNS_MEM; + sa->len = iaafmt(sa->s,ip); switch(resolve(sa,T_PTR)) { case DNS_MEM: return DNS_MEM; @@ -301,32 +263,6 @@ struct ip_address *ip; return DNS_HARD; } -int dns_maps(sa,ip) -stralloc *sa; -struct ip_address *ip; -{ - int r; - - if (!stralloc_ready(sa,iaafmt((char *) 0,ip,".rbl.maps.vix.com."))) return DNS_MEM; - sa->len = iaafmt(sa->s,ip,".rbl.maps.vix.com."); - switch(resolve(sa,T_TXT)) - { - case DNS_MEM: return DNS_MEM; - case DNS_SOFT: return DNS_SOFT; - case DNS_HARD: return DNS_HARD; - } - while ((r = findstring(T_TXT)) != 2) - { - if (r == DNS_SOFT) return DNS_SOFT; - if (r == 1) - { - if (!stralloc_copys(sa,name)) return DNS_MEM; - return 0; - } - } - return DNS_HARD; -} - static int dns_ipplus(ia,sa,pref) ipalloc *ia; stralloc *sa; @@ -335,17 +271,16 @@ int pref; int r; struct ip_mx ix; - if (sa->len && (sa->s[0] == '[')) - { - if (!stralloc_copy(&glue,sa)) return DNS_MEM; - if (!stralloc_0(&glue)) return DNS_MEM; + if (!stralloc_copy(&glue,sa)) return DNS_MEM; + if (!stralloc_0(&glue)) return DNS_MEM; + if (glue.s[0]) { ix.pref = 0; - if (!glue.s[ip_scanbracket(glue.s,&ix.ip)]) + if (!glue.s[ip_scan(glue.s,&ix.ip)] || !glue.s[ip_scanbracket(glue.s,&ix.ip)]) { if (!ipalloc_append(ia,&ix)) return DNS_MEM; return 0; } - } + } switch(resolve(sa,T_A)) { @@ -380,6 +315,7 @@ unsigned long random; { int r; struct mx { stralloc sa; unsigned short p; } *mx; + struct ip_mx ix; int nummx; int i; int j; @@ -388,18 +324,16 @@ unsigned long random; if (!ipalloc_readyplus(ia,0)) return DNS_MEM; ia->len = 0; - if (sa->len && (sa->s[0] == '[')) - { - struct ip_mx ix; - if (!stralloc_copy(&glue,sa)) return DNS_MEM; - if (!stralloc_0(&glue)) return DNS_MEM; + if (!stralloc_copy(&glue,sa)) return DNS_MEM; + if (!stralloc_0(&glue)) return DNS_MEM; + if (glue.s[0]) { ix.pref = 0; - if (!glue.s[ip_scanbracket(glue.s,&ix.ip)]) + if (!glue.s[ip_scan(glue.s,&ix.ip)] || !glue.s[ip_scanbracket(glue.s,&ix.ip)]) { if (!ipalloc_append(ia,&ix)) return DNS_MEM; return 0; } - } + } switch(resolve(sa,T_MX)) { diff --git a/dns.lib.do b/dns.lib.do deleted file mode 100644 index 2c73eab..0000000 --- a/dns.lib.do +++ /dev/null @@ -1,14 +0,0 @@ -dependon tryrsolv.c compile load socket.lib dns.o \ -ipalloc.o ip.o stralloc.a alloc.a error.a fs.a str.a - -( ./compile tryrsolv.c && ./load tryrsolv dns.o \ -ipalloc.o ip.o stralloc.a alloc.a error.a fs.a str.a \ --lresolv `cat socket.lib` ) >/dev/null 2>&1 \ -&& echo -lresolv -rm -f tryrsolv.o tryrsolv - -formake '( ( ./compile tryrsolv.c && ./load tryrsolv dns.o \' -formake 'ipalloc.o ip.o stralloc.a alloc.a error.a fs.a str.a \' -formake '-lresolv `cat socket.lib` ) >/dev/null 2>&1 \' -formake '&& echo -lresolv || exit 0 ) > dns.lib' -formake 'rm -f tryrsolv.o tryrsolv' @@ -0,0 +1,31 @@ +.TH env 3 +.SH NAME +env \- manage the environment +.SH SYNTAX +.B #include <env.h> + +char **\fBenviron\fP; + +char *\fBenv_get\fP(\fIname\fR); +.br +char *\fBenv_pick\fP(); + +char *\fIname\fR; +.SH DESCRIPTION +The environment, +.BR environ , +is a 0-terminated array of 0-terminated strings, +called environment variables. +Each environment variable is of the form +.IR name\fB=\fIvalue . + +.B env_get +returns the value of the first variable whose name is +.IR name , +or 0 if there is no such variable. + +.B env_pick +returns any variable in the environment, +or 0 if the environment is empty. +.SH "SEE ALSO" +environ(7) @@ -1,2 +0,0 @@ -env.o -envread.o @@ -0,0 +1,45 @@ +.TH error 3 +.SH NAME +error \- syscall error codes +.SH SYNTAX +.B #include <error.h> + +extern int \fBerrno\fP; + +extern int \fBerror_intr\fP; +.br +extern int \fBerror_nomem\fP; +.br +extern int \fBerror_noent\fP; +.br +extern int \fBerror_txtbsy\fP; +.br +extern int \fBerror_io\fP; +.br +extern int \fBerror_exist\fP; +.br +extern int \fBerror_timeout\fP; +.br +extern int \fBerror_inprogress\fP; +.br +extern int \fBerror_wouldblock\fP; +.br +extern int \fBerror_again\fP; +.br +extern int \fBerror_pipe\fP; +.br +extern int \fBerror_perm\fP; +.br +extern int \fBerror_acces\fP; +.SH DESCRIPTION +UNIX syscalls provide detailed error codes in the +.B errno +variable. +The +.B error +library provides portable names for a variety of possible +.B errno +values. +.SH "SEE ALSO" +error_str(3), +error_temp(3) diff --git a/error=l b/error=l deleted file mode 100644 index 2a9cb84..0000000 --- a/error=l +++ /dev/null @@ -1,2 +0,0 @@ -error.o -error_str.o diff --git a/error_str.3 b/error_str.3 new file mode 100644 index 0000000..62043c4 --- /dev/null +++ b/error_str.3 @@ -0,0 +1,19 @@ +.TH error_str 3 +.SH NAME +error_str \- names for syscall error codes +.SH SYNTAX +.B #include <error.h> + +char *\fBerror_str\fP(\fIe\fR); + +int \fIe\fR; +.SH DESCRIPTION +.B error_str +returns a printable string describing syscall error code +.IR e . +Normally +.I e +is +.BR errno . +.SH "SEE ALSO" +error(3) @@ -1,2 +0,0 @@ -fd_copy.o -fd_move.o diff --git a/fd_copy.3 b/fd_copy.3 new file mode 100644 index 0000000..758a7e7 --- /dev/null +++ b/fd_copy.3 @@ -0,0 +1,44 @@ +.TH fd_copy 3 +.SH NAME +fd_copy \- duplicate a descriptor +.SH SYNTAX +.B #include <fd.h> + +int \fBfd_copy\fP(\fIto\fR,\fIfrom\fR); + +int \fIto\fR; +.br +int \fIfrom\fR; +.SH DESCRIPTION +.B fd_copy +copies +descriptor +.I from +to descriptor +.IR to . +If +.I to +was already open, +.B fd_copy +closes it. +.B fd_copy +always leaves +.I from +intact; +if +.I to +and +.I from +are the same number, +.B fd_copy +does nothing. + +.B fd_copy +returns 0 on success, -1 on error. +.B fd_copy +does not guarantee that +.I to +will remain open, if it was open, in case of error. +.SH "SEE ALSO" +dup(2), +fd_move(3) diff --git a/fd_move.3 b/fd_move.3 new file mode 100644 index 0000000..94aa1b7 --- /dev/null +++ b/fd_move.3 @@ -0,0 +1,41 @@ +.TH fd_move 3 +.SH NAME +fd_move \- renumber a descriptor +.SH SYNTAX +.B #include <fd.h> + +int \fBfd_move\fP(\fIto\fR,\fIfrom\fR); + +int \fIto\fR; +.br +int \fIfrom\fR; +.SH DESCRIPTION +.B fd_move +moves +descriptor +.I from +to descriptor +.IR to . +If +.I to +was already open, +.B fd_move +closes it. +If the move is successful, +.B fd_move +closes +.IR from . +Exception: +if +.I to +and +.I from +are the same number, +.B fd_move +does nothing. + +.B fd_move +returns 0 on success, -1 on error. +.SH "SEE ALSO" +dup(2), +fd_copy(3) diff --git a/finger@.1 b/finger@.1 new file mode 100644 index 0000000..93b6288 --- /dev/null +++ b/finger@.1 @@ -0,0 +1,45 @@ +.TH finger@ 1 +.SH NAME +finger@ \- get user information from a host +.SH SYNTAX +.B finger@ +[ +.I host +[ +.I user +] +] +.SH DESCRIPTION +.B finger@ +connects to TCP port 79 (Finger) on +.IR host , +sends +.I user +(with an extra CR) +to +.IR host , +and prints any data it receives. +It removes CR and converts unprintable characters to a visible format. +Some computers respond to port 79 with information about +.IR user . + +If +.I user +is not supplied, +.B finger@ +sends a blank line to +.IR host . +Some computers respond with information about +all the users who are logged in. + +If +.I host +is not supplied, +.B finger@ +connects to the local host. +.SH "SEE ALSO" +addcr(1), +cat(1), +delcr(1), +finger(1), +tcpclient(1) @@ -1,4 +1,4 @@ -echo "${2-}" | BIN/tcpclient -RHl0 -- "${1-0}" 79 sh -c ' - BIN/addcr >&7 - exec BIN/delcr <&6 +echo "${2-}" | HOME/bin/tcpclient -RHl0 -- "${1-0}" 79 sh -c ' + HOME/bin/addcr >&7 + exec HOME/bin/delcr <&6 ' | cat -v diff --git a/finger@=s b/finger@=s deleted file mode 100644 index e69de29..0000000 --- a/finger@=s +++ /dev/null @@ -0,0 +1,11 @@ +.TH fixcr 1 +.SH NAME +fixcr \- make sure that there is a CR before each LF +.SH SYNOPSIS +.B fixcr +.SH DESCRIPTION +.B fixcr +inserts CR at the end of each line of input where a CR is not already present. +It does not insert CR at the end of a partial final line. +.SH "SEE ALSO" +addcr(1) @@ -0,0 +1,25 @@ +#include "substdio.h" +#include "subfd.h" +#include "exit.h" + +void main() +{ + register int n; + register char *x; + char ch; + char lastch = 0; + + for (;;) { + n = substdio_feed(subfdin); + if (n < 0) _exit(111); + if (!n) _exit(0); + x = substdio_PEEK(subfdin); + substdio_SEEK(subfdin,n); + while (n > 0) { + ch = *x++; --n; + if (ch == '\n') if (lastch != '\r') substdio_BPUTC(subfdout,"\r"[0]); + substdio_BPUTC(subfdout,ch); + lastch = ch; + } + } +} @@ -1,4 +0,0 @@ -fmt_str.o -fmt_ulong.o -scan_ulong.o -scan_8long.o @@ -0,0 +1,51 @@ +.TH getln 3 +.SH NAME +getln \- read one line of data +.SH SYNTAX +.B #include <getln.h> + +int \fBgetln\fP(&\fIss\fR,&\fIsa\fR,&\fImatch\fR,\fIsep\fR); + +substdio \fIss\fR; +.br +stralloc \fIsa\fR; +.br +int \fImatch\fR; +.br +int \fIsep\fR; +.SH DESCRIPTION +.B getln +reads a line of characters, terminated by a +.I sep +character, +from +.IR ss . +It returns the line in +.I sa +and sets +.I match +to 1. + +If +.B getln +sees end-of-input before it sees +.IR sep , +it returns the partial line in +.I sa +and sets +.I match +to 0. + +.B getln +normally returns 0. +If it runs out of memory, +or encounters an error from +.IR ss , +it returns -1, +setting +.B errno +appropriately. +.SH "SEE ALSO" +stralloc(3), +substdio(3), +getln2(3) diff --git a/getln2.3 b/getln2.3 new file mode 100644 index 0000000..f95105a --- /dev/null +++ b/getln2.3 @@ -0,0 +1,64 @@ +.TH getln2 3 +.SH NAME +getln2 \- read one line of data +.SH SYNTAX +.B #include <getln.h> + +int \fBgetln2\fP(&\fIss\fR,&\fIsa\fR,&\fIcont\fR,&\fIclen\fR,\fIsep\fR); + +substdio \fIss\fR; +.br +stralloc \fIsa\fR; +.br +char *\fIcont\fR; +.br +unsigned int \fIclen\fR; +.br +int \fIsep\fR; +.SH DESCRIPTION +.B getln2 +reads a line of characters, terminated by a +.I sep +character, +from +.IR ss . + +The line is returned in two pieces. +The first piece is stored in +.IR sa . +The second piece is +.IR cont , +a pointer to +.I clen +characters inside the +.I ss +buffer. +The second piece must be copied somewhere else +before +.I ss +is used again. + +If +.B getln2 +sees end-of-input before it sees +.IR sep , +it sets +.I clen +to 0 and does not set +.IR cont . +It puts the partial line into +.IR sa . + +.B getln2 +normally returns 0. +If it runs out of memory, +or encounters an error from +.IR ss , +it returns -1, +setting +.B errno +appropriately. +.SH "SEE ALSO" +stralloc(3), +substdio(3), +getln(3) diff --git a/getln=l b/getln=l deleted file mode 100644 index b0f37fa..0000000 --- a/getln=l +++ /dev/null @@ -1,2 +0,0 @@ -getln.o -getln2.o diff --git a/getopt=l b/getopt=l deleted file mode 100644 index a667e1e..0000000 --- a/getopt=l +++ /dev/null @@ -1,2 +0,0 @@ -subgetopt.o -sgetopt.o diff --git a/hassgact.h.do b/hassgact.h.do deleted file mode 100644 index df277d5..0000000 --- a/hassgact.h.do +++ /dev/null @@ -1,7 +0,0 @@ -dependon trysgact.c compile load -( ./compile trysgact.c && ./load trysgact ) >/dev/null 2>&1 \ -&& echo \#define HASSIGACTION 1 -rm -f trysgact.o trysgact -formake '( ( ./compile trysgact.c && ./load trysgact ) >/dev/null 2>&1 \' -formake '&& echo \#define HASSIGACTION 1 || exit 0 ) > hassgact.h' -formake 'rm -f trysgact.o trysgact' diff --git a/hassgprm.h.do b/hassgprm.h.do deleted file mode 100644 index 6ae8f47..0000000 --- a/hassgprm.h.do +++ /dev/null @@ -1,7 +0,0 @@ -dependon trysgprm.c compile load -( ./compile trysgprm.c && ./load trysgprm ) >/dev/null 2>&1 \ -&& echo \#define HASSIGPROCMASK 1 -rm -f trysgprm.o trysgprm -formake '( ( ./compile trysgprm.c && ./load trysgprm ) >/dev/null 2>&1 \' -formake '&& echo \#define HASSIGPROCMASK 1 || exit 0 ) > hassgprm.h' -formake 'rm -f trysgprm.o trysgprm' diff --git a/haswaitp.h.do b/haswaitp.h.do deleted file mode 100644 index 3cc09f5..0000000 --- a/haswaitp.h.do +++ /dev/null @@ -1,7 +0,0 @@ -dependon trywaitp.c compile load -( ./compile trywaitp.c && ./load trywaitp ) >/dev/null 2>&1 \ -&& echo \#define HASWAITPID 1 -rm -f trywaitp.o trywaitp -formake '( ( ./compile trywaitp.c && ./load trywaitp ) >/dev/null 2>&1 \' -formake '&& echo \#define HASWAITPID 1 || exit 0 ) > haswaitp.h' -formake 'rm -f trywaitp.o trywaitp' @@ -0,0 +1,63 @@ +#include "auto_home.h" + +void hier() +{ + h(auto_home,-1,-1,02755); + + d(auto_home,"bin",-1,-1,02755); + d(auto_home,"man",-1,-1,02755); + d(auto_home,"man/man1",-1,-1,02755); + d(auto_home,"man/cat1",-1,-1,02755); + d(auto_home,"man/man5",-1,-1,02755); + d(auto_home,"man/cat5",-1,-1,02755); + + c(auto_home,"bin","tcpclient",-1,-1,0711); + c(auto_home,"bin","tcpserver",-1,-1,0711); + c(auto_home,"bin","tcprules",-1,-1,0711); + c(auto_home,"bin","tcprulescheck",-1,-1,0711); + c(auto_home,"bin","fixcr",-1,-1,0711); + c(auto_home,"bin","addcr",-1,-1,0711); + c(auto_home,"bin","delcr",-1,-1,0711); + c(auto_home,"bin","who@",-1,-1,0755); + c(auto_home,"bin","date@",-1,-1,0755); + c(auto_home,"bin","finger@",-1,-1,0755); + c(auto_home,"bin","http@",-1,-1,0755); + c(auto_home,"bin","tcpcat",-1,-1,0755); + c(auto_home,"bin","mconnect",-1,-1,0755); + c(auto_home,"bin","mconnect-io",-1,-1,0711); + c(auto_home,"bin","argv0",-1,-1,0711); + c(auto_home,"bin","recordio",-1,-1,0711); + + c(auto_home,"man/man1","tcpclient.1",-1,-1,0644); + c(auto_home,"man/cat1","tcpclient.0",-1,-1,0644); + c(auto_home,"man/man1","tcpserver.1",-1,-1,0644); + c(auto_home,"man/cat1","tcpserver.0",-1,-1,0644); + c(auto_home,"man/man1","tcprules.1",-1,-1,0644); + c(auto_home,"man/cat1","tcprules.0",-1,-1,0644); + c(auto_home,"man/man1","tcprulescheck.1",-1,-1,0644); + c(auto_home,"man/cat1","tcprulescheck.0",-1,-1,0644); + c(auto_home,"man/man1","fixcr.1",-1,-1,0644); + c(auto_home,"man/cat1","fixcr.0",-1,-1,0644); + c(auto_home,"man/man1","addcr.1",-1,-1,0644); + c(auto_home,"man/cat1","addcr.0",-1,-1,0644); + c(auto_home,"man/man1","delcr.1",-1,-1,0644); + c(auto_home,"man/cat1","delcr.0",-1,-1,0644); + c(auto_home,"man/man1","who@.1",-1,-1,0644); + c(auto_home,"man/cat1","who@.0",-1,-1,0644); + c(auto_home,"man/man1","date@.1",-1,-1,0644); + c(auto_home,"man/cat1","date@.0",-1,-1,0644); + c(auto_home,"man/man1","finger@.1",-1,-1,0644); + c(auto_home,"man/cat1","finger@.0",-1,-1,0644); + c(auto_home,"man/man1","http@.1",-1,-1,0644); + c(auto_home,"man/cat1","http@.0",-1,-1,0644); + c(auto_home,"man/man1","tcpcat.1",-1,-1,0644); + c(auto_home,"man/cat1","tcpcat.0",-1,-1,0644); + c(auto_home,"man/man1","mconnect.1",-1,-1,0644); + c(auto_home,"man/cat1","mconnect.0",-1,-1,0644); + c(auto_home,"man/man1","argv0.1",-1,-1,0644); + c(auto_home,"man/cat1","argv0.0",-1,-1,0644); + c(auto_home,"man/man1","recordio.1",-1,-1,0644); + c(auto_home,"man/cat1","recordio.0",-1,-1,0644); + c(auto_home,"man/man5","tcp-environ.5",-1,-1,0644); + c(auto_home,"man/cat5","tcp-environ.0",-1,-1,0644); +} @@ -0,0 +1,52 @@ +.TH http@ 1 +.SH NAME +http@ \- get a web page from a host through HTTP +.SH SYNTAX +.B http@ +[ +.I host +[ +.I page +[ +.I port +] +] +] +.SH DESCRIPTION +.B http@ +connects to +.I port +on +.IR host , +sends +.B GET /\fIpage +(with an extra CR) +to +.IR host , +and prints any data it receives, +removing CR from the end of each line. + +If +.I port +is not supplied, +.B http@ +uses port 80 (HTTP). + +If +.I page +is not supplied, +.B http@ +sends +.B GET / +to +.IR host . + +If +.I host +is not supplied, +.B http@ +connects to the local host. +.SH "SEE ALSO" +addcr(1), +delcr(1), +tcpclient(1) diff --git a/http@.sh b/http@.sh new file mode 100644 index 0000000..59fee56 --- /dev/null +++ b/http@.sh @@ -0,0 +1,4 @@ +echo "GET /${2-}" | HOME/bin/tcpclient -RHl0 -- "${1-0}" "${3-80}" sh -c ' + HOME/bin/addcr >&7 + exec HOME/bin/delcr <&6 +' @@ -1,140 +1,149 @@ #include "substdio.h" -#include "stralloc.h" -#include "getln.h" +#include "strerr.h" +#include "error.h" +#include "open.h" #include "readwrite.h" #include "exit.h" -#include "open.h" -#include "error.h" -#include "strerr.h" -#include "byte.h" -stralloc target = {0}; -char *to; +extern void hier(); #define FATAL "install: fatal: " -void nomem() { strerr_die2x(111,FATAL,"out of memory"); } + +int fdsourcedir = -1; + +void h(home,uid,gid,mode) +char *home; +int uid; +int gid; +int mode; +{ + if (mkdir(home,0700) == -1) + if (errno != error_exist) + strerr_die4sys(111,FATAL,"unable to mkdir ",home,": "); + if (chown(home,uid,gid) == -1) + strerr_die4sys(111,FATAL,"unable to chown ",home,": "); + if (chmod(home,mode) == -1) + strerr_die4sys(111,FATAL,"unable to chmod ",home,": "); +} + +void d(home,subdir,uid,gid,mode) +char *home; +char *subdir; +int uid; +int gid; +int mode; +{ + if (chdir(home) == -1) + strerr_die4sys(111,FATAL,"unable to switch to ",home,": "); + if (mkdir(subdir,0700) == -1) + if (errno != error_exist) + strerr_die6sys(111,FATAL,"unable to mkdir ",home,"/",subdir,": "); + if (chown(subdir,uid,gid) == -1) + strerr_die6sys(111,FATAL,"unable to chown ",home,"/",subdir,": "); + if (chmod(subdir,mode) == -1) + strerr_die6sys(111,FATAL,"unable to chmod ",home,"/",subdir,": "); +} char inbuf[SUBSTDIO_INSIZE]; char outbuf[SUBSTDIO_OUTSIZE]; substdio ssin; substdio ssout; -void doit(line) -stralloc *line; +void c(home,subdir,file,uid,gid,mode) +char *home; +char *subdir; +char *file; +int uid; +int gid; +int mode; { - char *x; - unsigned int xlen; - unsigned int i; - char *type; - char *uidstr; - char *gidstr; - char *modestr; - char *mid; - char *name; - unsigned long uid; - unsigned long gid; - unsigned long mode; int fdin; int fdout; - x = line->s; xlen = line->len; - - type = x; - i = byte_chr(x,xlen,':'); if (i == xlen) return; - x[i++] = 0; x += i; xlen -= i; - - uidstr = x; - i = byte_chr(x,xlen,':'); if (i == xlen) return; - x[i++] = 0; x += i; xlen -= i; - - gidstr = x; - i = byte_chr(x,xlen,':'); if (i == xlen) return; - x[i++] = 0; x += i; xlen -= i; - - modestr = x; - i = byte_chr(x,xlen,':'); if (i == xlen) return; - x[i++] = 0; x += i; xlen -= i; - - mid = x; - i = byte_chr(x,xlen,':'); if (i == xlen) return; - x[i++] = 0; x += i; xlen -= i; - - name = x; - i = byte_chr(x,xlen,':'); if (i == xlen) return; - x[i++] = 0; x += i; xlen -= i; - - if (!stralloc_copys(&target,to)) nomem(); - if (!stralloc_cats(&target,mid)) nomem(); - if (!stralloc_cats(&target,name)) nomem(); - if (!stralloc_0(&target)) nomem(); - - uid = -1; if (*uidstr) scan_ulong(uidstr,&uid); - gid = -1; if (*gidstr) scan_ulong(gidstr,&gid); - scan_8long(modestr,&mode); - - switch(*type) { - case 'd': - if (mkdir(target.s,0700) == -1) - if (errno != error_exist) - strerr_die4sys(111,FATAL,"unable to mkdir ",target.s,": "); - break; - - case 'c': - fdin = open_read(name); - if (fdin == -1) - strerr_die4sys(111,FATAL,"unable to read ",name,": "); - substdio_fdbuf(&ssin,read,fdin,inbuf,sizeof(inbuf)); - - fdout = open_trunc(target.s); - if (fdout == -1) - strerr_die4sys(111,FATAL,"unable to write ",target.s,": "); - substdio_fdbuf(&ssout,write,fdout,outbuf,sizeof(outbuf)); - - switch(substdio_copy(&ssout,&ssin)) { - case -2: - strerr_die4sys(111,FATAL,"unable to read ",name,": "); - case -3: - strerr_die4sys(111,FATAL,"unable to write ",target.s,": "); - } - - close(fdin); - if (substdio_flush(&ssout) == -1) - strerr_die4sys(111,FATAL,"unable to write ",target.s,": "); - if (fsync(fdout) == -1) - strerr_die4sys(111,FATAL,"unable to write ",target.s,": "); - close(fdout); - break; - - default: - return; + if (fchdir(fdsourcedir) == -1) + strerr_die2sys(111,FATAL,"unable to switch back to source directory: "); + + fdin = open_read(file); + if (fdin == -1) + strerr_die4sys(111,FATAL,"unable to read ",file,": "); + substdio_fdbuf(&ssin,read,fdin,inbuf,sizeof inbuf); + + if (chdir(home) == -1) + strerr_die4sys(111,FATAL,"unable to switch to ",home,": "); + if (chdir(subdir) == -1) + strerr_die6sys(111,FATAL,"unable to switch to ",home,"/",subdir,": "); + + fdout = open_trunc(file); + if (fdout == -1) + strerr_die6sys(111,FATAL,"unable to write .../",subdir,"/",file,": "); + substdio_fdbuf(&ssout,write,fdout,outbuf,sizeof outbuf); + + switch(substdio_copy(&ssout,&ssin)) { + case -2: + strerr_die4sys(111,FATAL,"unable to read ",file,": "); + case -3: + strerr_die6sys(111,FATAL,"unable to write .../",subdir,"/",file,": "); } - if (chown(target.s,uid,gid) == -1) - strerr_die4sys(111,FATAL,"unable to chown ",target.s,": "); - if (chmod(target.s,mode) == -1) - strerr_die4sys(111,FATAL,"unable to chmod ",target.s,": "); + close(fdin); + if (substdio_flush(&ssout) == -1) + strerr_die6sys(111,FATAL,"unable to write .../",subdir,"/",file,": "); + if (fsync(fdout) == -1) + strerr_die6sys(111,FATAL,"unable to write .../",subdir,"/",file,": "); + if (close(fdout) == -1) /* NFS silliness */ + strerr_die6sys(111,FATAL,"unable to write .../",subdir,"/",file,": "); + + if (chown(file,uid,gid) == -1) + strerr_die6sys(111,FATAL,"unable to chown .../",subdir,"/",file,": "); + if (chmod(file,mode) == -1) + strerr_die6sys(111,FATAL,"unable to chmod .../",subdir,"/",file,": "); } -char buf[256]; -substdio in = SUBSTDIO_FDBUF(read,0,buf,sizeof(buf)); -stralloc line = {0}; - -void main(argc,argv) -int argc; -char **argv; +void z(home,subdir,file,len,uid,gid,mode) +char *home; +char *subdir; +char *file; +int len; +int uid; +int gid; +int mode; { - int match; + int fdout; - umask(077); + if (chdir(home) == -1) + strerr_die4sys(111,FATAL,"unable to switch to ",home,": "); + if (chdir(subdir) == -1) + strerr_die6sys(111,FATAL,"unable to switch to ",home,"/",subdir,": "); + + fdout = open_trunc(file); + if (fdout == -1) + strerr_die6sys(111,FATAL,"unable to write .../",subdir,"/",file,": "); + substdio_fdbuf(&ssout,write,fdout,outbuf,sizeof outbuf); + + while (len-- > 0) + if (substdio_put(&ssout,"",1) == -1) + strerr_die6sys(111,FATAL,"unable to write .../",subdir,"/",file,": "); + + if (substdio_flush(&ssout) == -1) + strerr_die6sys(111,FATAL,"unable to write .../",subdir,"/",file,": "); + if (fsync(fdout) == -1) + strerr_die6sys(111,FATAL,"unable to write .../",subdir,"/",file,": "); + if (close(fdout) == -1) /* NFS silliness */ + strerr_die6sys(111,FATAL,"unable to write .../",subdir,"/",file,": "); + + if (chown(file,uid,gid) == -1) + strerr_die6sys(111,FATAL,"unable to chown .../",subdir,"/",file,": "); + if (chmod(file,mode) == -1) + strerr_die6sys(111,FATAL,"unable to chmod .../",subdir,"/",file,": "); +} - to = argv[1]; - if (!to) strerr_die2x(100,FATAL,"install: usage: install dir"); +void main() +{ + fdsourcedir = open_read("."); + if (fdsourcedir == -1) + strerr_die2sys(111,FATAL,"unable to open current directory: "); - for (;;) { - if (getln(&in,&line,&match,'\n') == -1) - strerr_die2sys(111,FATAL,"unable to read input: "); - doit(&line); - if (!match) - _exit(0); - } + umask(077); + hier(); + _exit(0); } diff --git a/install=x b/install=x deleted file mode 100644 index 6dc960b..0000000 --- a/install=x +++ /dev/null @@ -1,9 +0,0 @@ -getln.a -strerr.a -substdio.a -stralloc.a -alloc.a -open.a -error.a -str.a -fs.a diff --git a/instcheck.c b/instcheck.c new file mode 100644 index 0000000..d41efda --- /dev/null +++ b/instcheck.c @@ -0,0 +1,108 @@ +#include <sys/types.h> +#include <sys/stat.h> +#include "strerr.h" +#include "error.h" +#include "readwrite.h" +#include "exit.h" + +extern void hier(); + +#define FATAL "instcheck: fatal: " +#define WARNING "instcheck: warning: " + +void perm(prefix1,prefix2,prefix3,file,type,uid,gid,mode) +char *prefix1; +char *prefix2; +char *prefix3; +char *file; +int type; +int uid; +int gid; +int mode; +{ + struct stat st; + + if (stat(file,&st) == -1) { + if (errno == error_noent) + strerr_warn6(WARNING,prefix1,prefix2,prefix3,file," does not exist",0); + else + strerr_warn4(WARNING,"unable to stat .../",file,": ",&strerr_sys); + return; + } + + if ((uid != -1) && (st.st_uid != uid)) + strerr_warn6(WARNING,prefix1,prefix2,prefix3,file," has wrong owner",0); + if ((gid != -1) && (st.st_gid != gid)) + strerr_warn6(WARNING,prefix1,prefix2,prefix3,file," has wrong group",0); + if ((st.st_mode & 07777) != mode) + strerr_warn6(WARNING,prefix1,prefix2,prefix3,file," has wrong permissions",0); + if ((st.st_mode & S_IFMT) != type) + strerr_warn6(WARNING,prefix1,prefix2,prefix3,file," has wrong type",0); +} + +void h(home,uid,gid,mode) +char *home; +int uid; +int gid; +int mode; +{ + perm("","","",home,S_IFDIR,uid,gid,mode); +} + +void d(home,subdir,uid,gid,mode) +char *home; +char *subdir; +int uid; +int gid; +int mode; +{ + if (chdir(home) == -1) + strerr_die4sys(111,FATAL,"unable to switch to ",home,": "); + perm("",home,"/",subdir,S_IFDIR,uid,gid,mode); +} + +void p(home,fifo,uid,gid,mode) +char *home; +char *fifo; +int uid; +int gid; +int mode; +{ + if (chdir(home) == -1) + strerr_die4sys(111,FATAL,"unable to switch to ",home,": "); + perm("",home,"/",fifo,S_IFIFO,uid,gid,mode); +} + +void c(home,subdir,file,uid,gid,mode) +char *home; +char *subdir; +char *file; +int uid; +int gid; +int mode; +{ + if (chdir(home) == -1) + strerr_die4sys(111,FATAL,"unable to switch to ",home,": "); + if (chdir(subdir) == -1) + strerr_die6sys(111,FATAL,"unable to switch to ",home,"/",subdir,": "); + perm(".../",subdir,"/",file,S_IFREG,uid,gid,mode); +} + +void z(home,file,len,uid,gid,mode) +char *home; +char *file; +int len; +int uid; +int gid; +int mode; +{ + if (chdir(home) == -1) + strerr_die4sys(111,FATAL,"unable to switch to ",home,": "); + perm("",home,"/",file,S_IFREG,uid,gid,mode); +} + +void main() +{ + hier(); + _exit(0); +} @@ -1,5 +0,0 @@ -dependon \ -tcpclient tcpserver tcprules \ -who@ date@ finger@ \ -tcpcat mconnect \ -addcr delcr diff --git a/make-compile.sh b/make-compile.sh deleted file mode 100644 index a1eb501..0000000 --- a/make-compile.sh +++ /dev/null @@ -1 +0,0 @@ -echo exec "$CC" -c '${1+"$@"}' diff --git a/make-load.sh b/make-load.sh deleted file mode 100644 index de07d2e..0000000 --- a/make-load.sh +++ /dev/null @@ -1,2 +0,0 @@ -echo 'main="$1"; shift' -echo exec "$LD" '-o "$main" "$main".o ${1+"$@"}' diff --git a/make-makelib.sh b/make-makelib.sh deleted file mode 100644 index d6b7c8c..0000000 --- a/make-makelib.sh +++ /dev/null @@ -1,16 +0,0 @@ -echo 'main="$1"; shift' -echo 'rm -f "$main"' -echo 'ar cr "$main" ${1+"$@"}' - -case "$1" in -sunos-5.*) ;; -unix_sv*) ;; -irix64-*) ;; -irix-*) ;; -dgux-*) ;; -hp-ux-*) ;; -sco*) ;; -*) - echo 'ranlib "$main"' - ;; -esac @@ -1,5 +0,0 @@ -dependon \ -tcpclient.0 \ -tcpserver.0 \ -tcprules.0 \ -tcp-environ.0 diff --git a/mconnect-io.c b/mconnect-io.c new file mode 100644 index 0000000..6dce003 --- /dev/null +++ b/mconnect-io.c @@ -0,0 +1,52 @@ +#include <signal.h> +#include "sig.h" +#include "substdio.h" +#include "strerr.h" +#include "readwrite.h" +#include "exit.h" + +char outbuf[512]; +substdio ssout; + +char inbuf[512]; +substdio ssin; + +int myread(fd,buf,len) int fd; char *buf; int len; +{ + substdio_flush(&ssout); + return read(fd,buf,len); +} + +void main() +{ + int pid; + int wstat; + char ch; + + sig_pipeignore(); + + pid = fork(); + if (pid == -1) strerr_die2sys(111,"mconnect-io: fatal: ","unable to fork: "); + + if (!pid) { + substdio_fdbuf(&ssin,myread,0,inbuf,sizeof inbuf); + substdio_fdbuf(&ssout,write,7,outbuf,sizeof outbuf); + + while (substdio_get(&ssin,&ch,1) == 1) { + if (ch == '\n') substdio_put(&ssout,"\r",1); + substdio_put(&ssout,&ch,1); + } + _exit(0); + } + + substdio_fdbuf(&ssin,myread,6,inbuf,sizeof inbuf); + substdio_fdbuf(&ssout,write,1,outbuf,sizeof outbuf); + + while (substdio_get(&ssin,&ch,1) == 1) + substdio_put(&ssout,&ch,1); + + kill(pid,SIGTERM); + wait_pid(&wstat,pid); + + _exit(0); +} diff --git a/mconnect.1 b/mconnect.1 new file mode 100644 index 0000000..6648367 --- /dev/null +++ b/mconnect.1 @@ -0,0 +1,36 @@ +.TH mconnect 1 +.SH NAME +mconnect \- connect to the SMTP server on a host +.SH SYNTAX +.B mconnect +[ +.I host +[ +.I port +] +] +.SH DESCRIPTION +.B mconnect +connects to +.I port +on +.IR host . +It sends its input to +.IR host , +adding a CR to each line. +Meanwhile it prints anything it receives from +.IR host . + +If +.I port +is not supplied, +.B mconnect +uses port 25 (SMTP). + +If +.I host +is not supplied, +.B mconnect +connects to the local host. +.SH "SEE ALSO" +tcpclient(1) diff --git a/mconnect.sh b/mconnect.sh index 3d137dd..9629b90 100644 --- a/mconnect.sh +++ b/mconnect.sh @@ -1,7 +1 @@ -# -# requires multitee -# -BIN/tcpclient -RHl0 -- "${1-0}" "${2-25}" sh -c ' - exec 4>&1 - multitee 0:1 6:4e0 | BIN/addcr >&7 -' | BIN/delcr +exec HOME/bin/tcpclient -RHl0 -- "${1-0}" "${2-25}" HOME/bin/mconnect-io diff --git a/mconnect=s b/mconnect=s deleted file mode 100644 index e69de29..0000000 --- a/mconnect=s +++ /dev/null diff --git a/ndelay=l b/ndelay=l deleted file mode 100644 index 322dd65..0000000 --- a/ndelay=l +++ /dev/null @@ -1,2 +0,0 @@ -ndelay.o -ndelay_off.o @@ -1,2 +0,0 @@ -open_read.o -open_trunc.o diff --git a/recordio.1 b/recordio.1 new file mode 100644 index 0000000..e056776 --- /dev/null +++ b/recordio.1 @@ -0,0 +1,75 @@ +.TH recordio 1 +.SH NAME +recordio \- record the input and output of a program +.SH SYNTAX +.B recordio +.I program +[ +.I arg ... +] +.SH DESCRIPTION +.B recordio +runs +.I program +with the given arguments. +It prints lines to stderr +showing the input and output of +.IR program . + +At the beginning of each line on stderr, +.B recordio +inserts the +.I program +process ID, +along with +.B < +for input or +.B > +for output. +At the end of each line it inserts a space, a plus sign, or [EOF]; +a space indicates that there was a newline in the input or output, +and [EOF] indicates the end of input or output. + +.B recordio +prints every packet of input and output immediately. +It does not attempt to combine packets into coherent stderr lines. +For example, + +.EX + recordio sh -c 'cat /dev/fd/8 2>&1' > /dev/null +.EE + +could produce + +.EX + 5135 > cat: /dev/fd/8: Bad file descriptor +.br + 5135 > [EOF] +.EE + +or + +.EX + 5135 > cat: + +.br + 5135 > /dev/fd/8+ +.br + 5135 > : + +.br + 5135 > Bad file descriptor +.br + 5135 > [EOF] +.EE + +.B recordio +uses several lines for long packets +to guarantee that each line is printed atomically to stderr. + +.B recordio +runs as a child of +.IR program . +It exits when it sees the end of +.IR program 's +output. +.SH "SEE ALSO" +tcpserver(1) diff --git a/recordio.c b/recordio.c new file mode 100644 index 0000000..09277d9 --- /dev/null +++ b/recordio.c @@ -0,0 +1,165 @@ +#include "sig.h" +#include "substdio.h" +#include "strerr.h" +#include "str.h" +#include "byte.h" +#include "readwrite.h" +#include "exit.h" +#include "fmt.h" +#include "select.h" + +#define FATAL "recordio: fatal: " + +char pid[FMT_ULONG + 10]; + +char recordbuf[512]; +substdio ssrecord = SUBSTDIO_FDBUF(write,2,recordbuf,sizeof recordbuf); + +void record(buf,len,direction) +char *buf; +int len; /* 1...256 */ +char *direction; +{ + int i; + + while (len) { + substdio_puts(&ssrecord,pid); + substdio_puts(&ssrecord,direction); + + i = byte_chr(buf,len,'\n'); + substdio_put(&ssrecord,buf,i); + + if (i == len) { + substdio_puts(&ssrecord,"+\n"); + substdio_flush(&ssrecord); + return; + } + + substdio_puts(&ssrecord," \n"); + substdio_flush(&ssrecord); + buf += i + 1; + len -= i + 1; + } +} + +int leftstatus = 0; +char leftbuf[256]; +int leftlen; +int leftpos; + +int rightstatus = 0; +char rightbuf[256]; +int rightlen; +int rightpos; + +void doit(fdleft,fdright) +int fdleft; /* copy from 0 to fdleft */ +int fdright; /* copy from fdright to 1 */ +{ + fd_set rfds; + fd_set wfds; + int nfds; + int r; + + nfds = 2; + if (nfds <= fdleft) nfds = fdleft + 1; + if (nfds <= fdright) nfds = fdright + 1; + /* XXX: will overflow select buf if too many fds are open */ + + for (;;) { + FD_ZERO(&rfds); + FD_ZERO(&wfds); + + if (leftstatus == 0) FD_SET(0,&rfds); + if (leftstatus == 1) FD_SET(fdleft,&wfds); + + if (rightstatus == 0) FD_SET(fdright,&rfds); + if (rightstatus == 1) FD_SET(1,&wfds); + + if (select(nfds,&rfds,&wfds,(fd_set *) 0,(struct timeval *) 0) == -1) + continue; + + if (FD_ISSET(0,&rfds)) { + r = read(0,leftbuf,sizeof leftbuf); + if (r <= 0) { + leftstatus = -1; + close(fdleft); + substdio_puts(&ssrecord,pid); + substdio_puts(&ssrecord," < [EOF]\n"); + substdio_flush(&ssrecord); + } + else { + leftstatus = 1; leftpos = 0; leftlen = r; + record(leftbuf,r," < "); + } + } + + if (FD_ISSET(fdleft,&wfds)) { + r = write(fdleft,leftbuf + leftpos,leftlen - leftpos); + if (r == -1) break; + leftpos += r; + if (leftpos == leftlen) leftstatus = 0; + } + + if (FD_ISSET(fdright,&rfds)) { + r = read(fdright,rightbuf,sizeof rightbuf); + if (r <= 0) { + substdio_puts(&ssrecord,pid); + substdio_puts(&ssrecord," > [EOF]\n"); + substdio_flush(&ssrecord); + break; + } + else { + rightstatus = 1; rightpos = 0; rightlen = r; + record(rightbuf,r," > "); + } + } + + if (FD_ISSET(1,&wfds)) { + r = write(1,rightbuf + rightpos,rightlen - rightpos); + if (r == -1) break; + rightpos += r; + if (rightpos == rightlen) rightstatus = 0; + } + } + + _exit(0); +} + +void main(argc,argv) +int argc; +char **argv; +{ + int piin[2]; + int piout[2]; + + pid[fmt_ulong(pid,(unsigned long) getpid())] = 0; + + if (argc < 2) + strerr_die1x(100,"recordio: usage: recordio program [ arg ... ]"); + + if (pipe(piin) == -1) + strerr_die2sys(111,FATAL,"unable to create pipe: "); + if (pipe(piout) == -1) + strerr_die2sys(111,FATAL,"unable to create pipe: "); + + switch(fork()) { + case -1: + strerr_die2sys(111,FATAL,"unable to fork: "); + case 0: + sig_pipeignore(); + close(piin[0]); + close(piout[1]); + doit(piin[1],piout[0]); + } + + close(piin[1]); + close(piout[0]); + if (fd_move(0,piin[0]) == -1) + strerr_die2sys(111,FATAL,"unable to move descriptors: "); + if (fd_move(1,piout[1]) == -1) + strerr_die2sys(111,FATAL,"unable to move descriptors: "); + + execvp(argv[1],argv + 1); + strerr_die4sys(111,FATAL,"unable to run ",argv[1],": "); +} @@ -0,0 +1,217 @@ +--- tcpclient prints usage message without enough arguments +tcpclient: usage: tcpclient [ -hHrRdDqQv ] [ -i localip ] [ -p localport ] [ -T timeoutconn ] [ -l localname ] [ -t timeoutinfo ] host port program +100 +--- tcpclient prints error message with unknown port name +tcpclient: fatal: unable to figure out port number for nonexistentport +111 +--- tcpclient prints error message when connection fails +tcpclient: unable to connect to 127.0.0.1 port 16: connection refused +111 +--- tcpclient -q does not print error message when connection fails +111 +--- tcpclient understands empty host name as synonym for 0 +tcpclient: unable to connect to 127.0.0.1 port 16: connection refused +111 +--- tcpclient understands unbracketed IP address +tcpclient: unable to connect to 127.0.0.1 port 16: connection refused +111 +--- tcpclient understands bracketed IP address +tcpclient: unable to connect to 127.0.0.1 port 16: connection refused +111 +--- tcpclient prints error message with unknown host name +tcpclient: fatal: unable to figure out IP address for nonexistent.local. +111 +--- tcpserver prints usage message without enough arguments +tcpserver: usage: tcpserver [ -1pPhHrRoOdDqQv ] [ -c limit ] [ -x rules.cdb ] [ -B banner ] [ -g gid ] [ -u uid ] [ -b backlog ] [ -l localname ] [ -t timeout ] host port program +100 +--- tcpserver prints error message with unknown port name +tcpserver: fatal: unable to figure out port number for nonexistentport +111 +--- tcpserver prints error message with unknown host name +tcpserver: fatal: unable to figure out IP address for nonexistent.local. +111 +--- tcpserver prints error message with non-local host name +tcpserver: fatal: unable to bind: address not available +111 +--- tcpserver sets basic environment variables +PROTO=TCP +TCPLOCALHOST=Local +TCPLOCALIP=127.0.0.1 +TCPLOCALPORT=50016 +TCPREMOTEHOST= +TCPREMOTEIP=127.0.0.1 +TCPREMOTEPORT=50017 +TCPREMOTEINFO= +0 +--- tcpclient sets basic environment variables +PROTO=TCP +TCPLOCALHOST=Local +TCPLOCALIP=127.0.0.1 +TCPLOCALPORT=50017 +TCPREMOTEHOST= +TCPREMOTEIP=127.0.0.1 +TCPREMOTEPORT=50016 +TCPREMOTEINFO= +0 +--- tcpclient -v works +tcpclient: connected to 127.0.0.1 port 50016 +ok +0 +--- tcpserver prints error message with used port +tcpserver: fatal: unable to bind: address already used +111 +--- tcpcat works; tcpserver -B works +bannerok +0 +--- mconnect works +bannerok +0 +--- tcprules prints usage message without enough arguments +tcprules: usage: tcprules rules.cdb rules.tmp +100 +--- tcprules prints error message if it cannot create tmp +tcprules: fatal: unable to create /dev/nonexistent/tmp: file does not exist +111 +--- tcprules prints error message if it cannot move tmp to cdb +tcprules: fatal: unable to move test.tmp to /dev/nonexistent/cdb: file does not exist +111 +--- tcprules creates a cdb file +0 +--- tcprulescheck sees deny +rule 1.2.3.4: +deny connection +0 +--- tcprulescheck does not apply deny to another host +default: +allow connection +0 +--- tcprules replaces a cdb file +0 +--- tcprulescheck finds rule with address and info +rule joe@127.0.0.1: +set environment variable which=first +allow connection +0 +--- tcprulescheck finds rule with address +rule 18.23.0.32: +set environment variable which=second +allow connection +0 +--- tcprulescheck finds one-dot wildcard +rule 127.: +set environment variable which=third +allow connection +0 +--- tcprulescheck finds zero-dot wildcard +rule : +set environment variable which=fourth +allow connection +0 +--- tcprules handles comments, address ranges, multiple variables +0 +rule 127.0.: +set environment variable which=first +set environment variable where=whatever +allow connection +rule 127.1.: +set environment variable which=first +set environment variable where=whatever +allow connection +rule 127.2.: +set environment variable which=first +set environment variable where=whatever +allow connection +rule 127.3.: +set environment variable which=first +set environment variable where=whatever +allow connection +rule 127.4.: +set environment variable which=first +set environment variable where=whatever +allow connection +rule 127.5.: +set environment variable which=first +set environment variable where=whatever +allow connection +default: +allow connection +default: +allow connection +default: +allow connection +default: +allow connection +default: +allow connection +--- addcr leaves an empty file alone +0 +--- addcr leaves a partial final line alone +test0 +--- addcr adds CR after the first line +test^M +0 +--- addcr adds CR after the second line +test^M +test2^M +0 +--- addcr handles nulls +t^@st^M +0 +--- delcr leaves an empty file alone +0 +--- delcr leaves a non-CR line alone +test +0 +--- delcr removes CR if a line has it +test +0 +--- delcr converts CR CR LF to CR LF +test^M +0 +--- delcr removes CR from a partial final line +test0 +--- delcr handles a non-CR partial final line +test0 +--- delcr handles nulls +t^@st +0 +--- fixcr leaves an empty file alone +0 +--- fixcr leaves a partial final line alone +test0 +--- fixcr adds CR after the first line +test^M +0 +--- fixcr adds CR after the second line +test^M +test2^M +0 +--- fixcr does not add CR if a line has it +test^M +0 +--- fixcr handles nulls +t^@st^M +0 +--- recordio works +... < test $ +... > test $ +... < [EOF]$ +... > [EOF]$ +--- recordio handles multiple-line packets +... < test $ +... < test2 $ +... > test $ +... > test2 $ +... < [EOF]$ +... > [EOF]$ +--- recordio handles partial final lines +... < test+$ +... > test+$ +... < [EOF]$ +... > [EOF]$ +--- argv0 works +zero +0 +--- argv0 requires arguments +argv0: usage: argv0 realname program [ arg ... ] +100 @@ -0,0 +1 @@ +env - PATH=".:$PATH" sh rts.tests 2>&1 | cat -v diff --git a/rts.tests b/rts.tests new file mode 100644 index 0000000..ba8477b --- /dev/null +++ b/rts.tests @@ -0,0 +1,255 @@ +# Assumes that there is no port named nonexistentport. +# Assumes that there is no listener for TCP port 16 at 127.0.0.1. +# Assumes that there is no listener for TCP port 50016 at 127.0.0.1. +# Assumes that there is no use of TCP port 50017 at 127.0.0.1. +# Assumes that DNS lookup on nonexistent.local. will give hard error. + +# Not tested: +# who@ +# date@ +# finger@ +# http@ +# tcpclient handles temporary DNS errors +# tcpserver handles temporary DNS errors +# tcpclient -i +# tcpclient -r +# tcpclient -h +# tcpclient -d +# tcpclient -D +# tcpclient -T +# tcpclient -t +# tcpserver -1 +# tcpserver -p +# tcpserver -r +# tcpserver -h +# tcpserver -o +# tcpserver -O +# tcpserver -d +# tcpserver -D +# tcpserver -v +# tcpserver -c +# tcpserver -g +# tcpserver -u +# tcpserver -b +# tcpserver -t +# tcpserver -x + + +echo '--- tcpclient prints usage message without enough arguments' +tcpclient 0 0; echo $? + +echo '--- tcpclient prints error message with unknown port name' +tcpclient 0 nonexistentport echo wrong; echo $? + +echo '--- tcpclient prints error message when connection fails' +tcpclient 0 016 echo wrong; echo $? + +echo '--- tcpclient -q does not print error message when connection fails' +tcpclient -q 0 016 echo wrong; echo $? + +echo '--- tcpclient understands empty host name as synonym for 0' +tcpclient '' 016 echo wrong; echo $? + +echo '--- tcpclient understands unbracketed IP address' +tcpclient '127.000.000.001' 016 echo wrong; echo $? + +echo '--- tcpclient understands bracketed IP address' +tcpclient '[127.000.000.001]' 016 echo wrong; echo $? + +echo '--- tcpclient prints error message with unknown host name' +tcpclient nonexistent.local. 016 echo wrong; echo $? + +echo '--- tcpserver prints usage message without enough arguments' +tcpserver 0 0; echo $? + +echo '--- tcpserver prints error message with unknown port name' +tcpserver 0 nonexistentport echo wrong; echo $? + +echo '--- tcpserver prints error message with unknown host name' +tcpserver nonexistent.local. 016 echo wrong; echo $? + +echo '--- tcpserver prints error message with non-local host name' +tcpserver 1.2.3.4 016 echo wrong; echo $? + +tcpserver -q -R -H -l Local 127.0.0.1 50016 sh -c ' + echo PROTO="$PROTO" + echo TCPLOCALHOST="$TCPLOCALHOST" + echo TCPLOCALIP="$TCPLOCALIP" + echo TCPLOCALPORT="$TCPLOCALPORT" + echo TCPREMOTEHOST="$TCPREMOTEHOST" + echo TCPREMOTEIP="$TCPREMOTEIP" + echo TCPREMOTEPORT="$TCPREMOTEPORT" + echo TCPREMOTEINFO="$TCPREMOTEINFO" +' & +pid=$! +sleep 1 #XXX + +echo '--- tcpserver sets basic environment variables' +tcpclient -p 50017 -R -H -l Local 0 50016 sh -c 'cat <&6' +echo $? + +echo '--- tcpclient sets basic environment variables' +tcpclient -p 50017 -R -H -l Local 0 50016 sh -c ' + echo PROTO="$PROTO" + echo TCPLOCALHOST="$TCPLOCALHOST" + echo TCPLOCALIP="$TCPLOCALIP" + echo TCPLOCALPORT="$TCPLOCALPORT" + echo TCPREMOTEHOST="$TCPREMOTEHOST" + echo TCPREMOTEIP="$TCPREMOTEIP" + echo TCPREMOTEPORT="$TCPREMOTEPORT" + echo TCPREMOTEINFO="$TCPREMOTEINFO" +' +echo $? + +echo '--- tcpclient -v works' +tcpclient -v -R -H -l Local 0 50016 echo ok +echo $? + +echo '--- tcpserver prints error message with used port' +tcpserver -R -H -l Local 127.0.0.1 50016 echo wrong +echo $? + +kill $pid +wait + +tcpserver -B banner -q -R -H -l Local 127.0.0.1 50016 echo ok & +pid=$! +sleep 1 #XXX + +echo '--- tcpcat works; tcpserver -B works' +tcpcat 0 50016 +echo $? + +echo '--- mconnect works' +mconnect 0 50016 </dev/null +echo $? + +kill $pid +wait + +echo '--- tcprules prints usage message without enough arguments' +tcprules test.cdb; echo $? + +echo '--- tcprules prints error message if it cannot create tmp' +echo 1.2.3.4:deny | tcprules test.cdb /dev/nonexistent/tmp; echo $? + +echo '--- tcprules prints error message if it cannot move tmp to cdb' +echo 1.2.3.4:deny | tcprules /dev/nonexistent/cdb test.tmp; echo $? + +echo '--- tcprules creates a cdb file' +echo 1.2.3.4:deny | tcprules test.cdb test.tmp; echo $? + +echo '--- tcprulescheck sees deny' +tcprulescheck test.cdb 1.2.3.4; echo $? + +echo '--- tcprulescheck does not apply deny to another host' +tcprulescheck test.cdb 1.2.3.5; echo $? + +echo '--- tcprules replaces a cdb file' +echo 'joe@127.0.0.1:allow,which=/first/ +18.23.0.32:allow,which="second" +127.:allow,which=+third+ +:allow,which==fourth=' | tcprules test.cdb test.tmp; echo $? + +echo '--- tcprulescheck finds rule with address and info' +tcprulescheck test.cdb 127.0.0.1 joe; echo $? + +echo '--- tcprulescheck finds rule with address' +tcprulescheck test.cdb 18.23.0.32 joe ; echo $? + +echo '--- tcprulescheck finds one-dot wildcard' +tcprulescheck test.cdb 127.0.0.1 bill; echo $? + +echo '--- tcprulescheck finds zero-dot wildcard' +tcprulescheck test.cdb 10.119.75.38 bill; echo $? + +echo '--- tcprules handles comments, address ranges, multiple variables' +echo '127.0-5.:allow,which=/first/,where=/whatever/ +# comment' | tcprules test.cdb test.tmp; echo $? +tcprulescheck test.cdb 127.0.0.1 +tcprulescheck test.cdb 127.1.0.1 +tcprulescheck test.cdb 127.2.0.1 +tcprulescheck test.cdb 127.3.0.1 +tcprulescheck test.cdb 127.4.0.1 +tcprulescheck test.cdb 127.5.0.1 +tcprulescheck test.cdb 127.6.0.1 +tcprulescheck test.cdb 127.7.0.1 +tcprulescheck test.cdb 127.8.0.1 +tcprulescheck test.cdb 127.9.0.1 +tcprulescheck test.cdb 127.10.0.1 + + +echo '--- addcr leaves an empty file alone' +echo -n '' | addcr; echo $? + +echo '--- addcr leaves a partial final line alone' +echo -n test | addcr; echo $? + +echo '--- addcr adds CR after the first line' +echo test | addcr; echo $? + +echo '--- addcr adds CR after the second line' +( echo test; echo test2 ) | addcr; echo $? + +echo '--- addcr handles nulls' +echo test | tr e '\0' | addcr; echo $? + +echo '--- delcr leaves an empty file alone' +echo -n '' | delcr; echo $? + +echo '--- delcr leaves a non-CR line alone' +echo test | delcr; echo $? + +echo '--- delcr removes CR if a line has it' +echo testx | tr x '\015' | delcr; echo $? + +echo '--- delcr converts CR CR LF to CR LF' +echo testxx | tr x '\015' | delcr; echo $? + +echo '--- delcr removes CR from a partial final line' +echo -n testx | tr x '\015' | delcr; echo $? + +echo '--- delcr handles a non-CR partial final line' +echo -n test | delcr; echo $? + +echo '--- delcr handles nulls' +echo test | tr e '\0' | delcr; echo $? + +echo '--- fixcr leaves an empty file alone' +echo -n '' | fixcr; echo $? + +echo '--- fixcr leaves a partial final line alone' +echo -n test | fixcr; echo $? + +echo '--- fixcr adds CR after the first line' +echo test | fixcr; echo $? + +echo '--- fixcr adds CR after the second line' +( echo test; echo test2 ) | fixcr; echo $? + +echo '--- fixcr does not add CR if a line has it' +echo testx | tr x '\015' | fixcr; echo $? + +echo '--- fixcr handles nulls' +echo test | tr e '\0' | fixcr; echo $? + +echo '--- recordio works' +( echo test; sleep 1 ) | recordio cat 2>&1 >/dev/null \ +| sed 's/^[0-9]*/.../' | sed 's/$/$/' + +echo '--- recordio handles multiple-line packets' +( echo 'test +test2'; sleep 1 ) | recordio cat 2>&1 >/dev/null \ +| sed 's/^[0-9]*/.../' | sed 's/$/$/' + +echo '--- recordio handles partial final lines' +( echo -n test; sleep 1 ) | recordio cat 2>&1 >/dev/null \ +| sed 's/^[0-9]*/.../' | sed 's/$/$/' + +echo '--- argv0 works' +argv0 sh zero -c 'echo $0'; echo $? + +echo '--- argv0 requires arguments' +argv0 sh; echo $? + +exit 0 @@ -23,5 +23,6 @@ extern unsigned int scan_strncmp(); extern unsigned int scan_memcmp(); extern unsigned int scan_long(); +extern unsigned int scan_8long(); #endif diff --git a/scan_8long.c b/scan_8long.c deleted file mode 100644 index 8b3a6df..0000000 --- a/scan_8long.c +++ /dev/null @@ -1,11 +0,0 @@ -#include "scan.h" - -unsigned int scan_8long(s,u) register char *s; register unsigned long *u; -{ - register unsigned int pos; register unsigned long result; - register unsigned long c; - pos = 0; result = 0; - while ((c = (unsigned long) (unsigned char) (s[pos] - '0')) < 8) - { result = result * 8 + c; ++pos; } - *u = result; return pos; -} @@ -1,4 +0,0 @@ -seek_cur.o -seek_end.o -seek_set.o -seek_trunc.o diff --git a/seek_cur.c b/seek_cur.c deleted file mode 100644 index c8a3ee8..0000000 --- a/seek_cur.c +++ /dev/null @@ -1,7 +0,0 @@ -#include <sys/types.h> -#include "seek.h" - -#define CUR 1 /* sigh */ - -seek_pos seek_cur(fd) int fd; -{ return lseek(fd,(off_t) 0,CUR); } diff --git a/seek_end.c b/seek_end.c deleted file mode 100644 index 8a7b3c5..0000000 --- a/seek_end.c +++ /dev/null @@ -1,7 +0,0 @@ -#include <sys/types.h> -#include "seek.h" - -#define END 2 /* sigh */ - -int seek_end(fd) int fd; -{ if (lseek(fd,(off_t) 0,END) == -1) return -1; return 0; } diff --git a/seek_trunc.c b/seek_trunc.c deleted file mode 100644 index 6a1a73e..0000000 --- a/seek_trunc.c +++ /dev/null @@ -1,5 +0,0 @@ -#include <sys/types.h> -#include "seek.h" - -int seek_trunc(fd,pos) int fd; seek_pos pos; -{ return ftruncate(fd,(off_t) pos); } diff --git a/select.h.do b/select.h.do deleted file mode 100644 index 5ab38df..0000000 --- a/select.h.do +++ /dev/null @@ -1,6 +0,0 @@ -dependon compile trysysel.c select.h1 select.h2 -./compile trysysel.c >/dev/null 2>&1 && cat select.h2 || cat select.h1 -rm -f trysysel.o -formake '( ./compile trysysel.c >/dev/null 2>&1 \' -formake '&& cat select.h2 || cat select.h1 ) > select.h' -formake 'rm -f trysysel.o trysysel' diff --git a/setup.do b/setup.do deleted file mode 100644 index d667234..0000000 --- a/setup.do +++ /dev/null @@ -1,5 +0,0 @@ -dependon it man install conf-bin conf-man BIN MAN -formake './install "`head -1 conf-bin`" < BIN' -formake './install "`head -1 conf-man`" < MAN' -./install "`head -1 conf-bin`" < BIN -./install "`head -1 conf-man`" < MAN diff --git a/sgetopt.3 b/sgetopt.3 new file mode 100644 index 0000000..bde0c2b --- /dev/null +++ b/sgetopt.3 @@ -0,0 +1,28 @@ +.TH sgetopt 3 +.SH NAME +sgetopt \- get option character from command line +.SH SYNTAX +.B #include <sgetopt.h> +.SH DESCRIPTION +The +.B sgetopt +library is just like the +.B getopt +library, +except that it prints errors using +.B substdio +rather than +.BR stdio . + +See +.B getopt(3) +for interface details. +.SH VERSION +sgetopt version 1.9, 931201. +.SH AUTHOR +Placed into the public domain by Daniel J. Bernstein. +.SH "SEE ALSO" +getopt(3), +subgetopt(3), +subfd(3), +substdio(3) @@ -1,7 +0,0 @@ -sig_block.o -sig_catch.o -sig_pause.o -sig_dfl.o -sig_pipe.o -sig_child.o -sig_term.o diff --git a/sig_cont.c b/sig_cont.c deleted file mode 100644 index e69de29..0000000 --- a/sig_cont.c +++ /dev/null diff --git a/sig_dfl.c b/sig_dfl.c deleted file mode 100644 index a92bd7b..0000000 --- a/sig_dfl.c +++ /dev/null @@ -1,82 +0,0 @@ -#include <signal.h> -#include "sig.h" -#include "hassgact.h" -#include "hassgprm.h" - -/* tnx to Chris Torek for some improvements in previous versions */ - -static int flagcont; - -static void sigcont() { flagcont = 1; } - -void sig_dfl(sig) -int sig; -{ -#ifdef HASSIGPROCMASK - sigset_t ssorig; - sigset_t ssnew; -#else - int maskorig; - int masknew; -#endif -#ifdef HASSIGACTION - struct sigaction saorig; - struct sigaction sanew; -#else - struct sigvec svorig; - struct sigvec svnew; -#endif - - if (sig == SIGCONT) return; - -#ifdef HASSIGPROCMASK - sigfillset(&ssnew); - sigprocmask(SIG_SETMASK,&ssnew,&ssorig); -#else - masknew = ~0; - maskorig = sigsetmask(masknew); -#endif - -#ifdef HASSIGACTION - sanew.sa_handler = SIG_DFL; - sanew.sa_flags = 0; - sigemptyset(&sanew.sa_mask); - sigaction(sig,&sanew,&saorig); - sanew.sa_handler = sigcont; - sigaction(SIGCONT,&sanew,(struct sigaction *) 0); -#else - svnew.sv_handler = SIG_DFL; - svnew.sv_flags = 0; - svnew.sv_mask = 0; - sigvec(sig,&svnew,&svorig); - svnew.sv_handler = sigcont; - sigvec(SIGCONT,&svnew,(struct sigvec *) 0); -#endif - - flagcont = 0; - if (kill(getpid(),sig) == 0) { -#ifdef HASSIGPROCMASK - sigdelset(&ssnew,sig); - sigdelset(&ssnew,SIGCONT); - while (!flagcont) - sigsuspend(&ssnew); -#else - masknew &= ~(1 << (sig - 1)); - masknew &= ~(1 << (SIGCONT - 1)); - while (!flagcont) - sigpause(masknew); -#endif - } - -#ifdef HASSIGACTION - sigaction(sig,&saorig,(struct sigaction *) 0); -#else - sigvec(sig,&svorig,(struct sigvec *) 0); -#endif - -#ifdef HASSIGPROCMASK - sigprocmask(SIG_SETMASK,&ssorig,(sigset_t *) 0); -#else - sigsetmask(maskorig); -#endif -} diff --git a/socket.lib.do b/socket.lib.do deleted file mode 100644 index 106c5e8..0000000 --- a/socket.lib.do +++ /dev/null @@ -1,8 +0,0 @@ -dependon trylsock.c compile load -( ./compile trylsock.c && ./load trylsock -lsocket -lnsl ) >/dev/null 2>&1 \ -&& echo -lsocket -lnsl -rm -f trylsock.o trylsock -formake '( ( ./compile trylsock.c && \' -formake './load trylsock -lsocket -lnsl ) >/dev/null 2>&1 \' -formake '&& echo -lsocket -lnsl || exit 0 ) > socket.lib' -formake 'rm -f trylsock.o trylsock' @@ -1,10 +0,0 @@ -str_len.o -str_diff.o -str_diffn.o -str_cpy.o -byte_chr.o -byte_rchr.o -byte_diff.o -byte_copy.o -byte_cr.o -byte_zero.o diff --git a/str_chr.c b/str_chr.c new file mode 100644 index 0000000..3691826 --- /dev/null +++ b/str_chr.c @@ -0,0 +1,19 @@ +#include "str.h" + +unsigned int str_chr(s,c) +register char *s; +int c; +{ + register char ch; + register char *t; + + ch = c; + t = s; + for (;;) { + if (!*t) break; if (*t == ch) break; ++t; + if (!*t) break; if (*t == ch) break; ++t; + if (!*t) break; if (*t == ch) break; ++t; + if (!*t) break; if (*t == ch) break; ++t; + } + return t - s; +} diff --git a/stralloc.3 b/stralloc.3 new file mode 100644 index 0000000..3123521 --- /dev/null +++ b/stralloc.3 @@ -0,0 +1,160 @@ +.TH stralloc 3 +.SH NAME +stralloc \- dynamically allocated strings +.SH SYNTAX +.B #include <stralloc.h> + +int \fBstralloc_ready\fP(&\fIsa\fR,\fIlen\fR); +.br +int \fBstralloc_readyplus\fP(&\fIsa\fR,\fIlen\fR); + +int \fBstralloc_copy\fP(&\fIsa\fR,&\fIsa2\fR); +.br +int \fBstralloc_copys\fP(&\fIsa\fR,\fIbuf\fR); +.br +int \fBstralloc_copyb\fP(&\fIsa\fR,\fIbuf\fR,\fIlen\fR); + +int \fBstralloc_cat\fP(&\fIsa\fR,&\fIsa2\fR); +.br +int \fBstralloc_cats\fP(&\fIsa\fR,\fIbuf\fR); +.br +int \fBstralloc_catb\fP(&\fIsa\fR,\fIbuf\fR,\fIlen\fR); + +int \fBstralloc_append\fP(&\fIsa\fR,\fIbuf\fR); +.br +int \fBstralloc_0\fP(&\fIsa\fR); + +int \fBstralloc_starts\fP(&\fIsa\fR,\fIbuf\fR); + +stralloc \fIsa\fR = {0}; +.br +stralloc \fIsa2\fR = {0}; +.br +unsigned int \fIlen\fR; +.br +char *\fIbuf\fR; +.SH DESCRIPTION +A +.B stralloc +variable holds a string in dynamically allocated space. +String length is limited only by memory. +String contents are unrestricted. + +The +.B stralloc +structure has three components: +.I sa\fB.s +is a pointer to the string, or 0 if it is not allocated; +.I sa\fB.len +is the number of bytes in the string, if it is allocated; +.I sa\fB.a +is the number of bytes allocated for the string, if it is allocated. +A +.B stralloc +variable should be initialized to {0}, +meaning unallocated. + +.B stralloc_ready +makes sure that +.I sa +has enough space allocated for +.I len +characters. +It allocates extra space if necessary. + +.B stralloc_readyplus +makes sure that +.I sa +has enough space allocated for +.I len +characters more than its current length. +If +.I sa +is unallocated, +.B stralloc_readyplus +is the same as +.BR stralloc_ready . + +.B stralloc_copy +copies +.I sa2 +to +.IR sa , +allocating space if necessary. +Here +.I sa2 +is an allocated +.B stralloc +variable. + +.B stralloc_copys +copies a 0-terminated string, +.IR buf , +to +.IR sa , +without the 0. + +.B stralloc_copyb +copies +.I len +characters from +.I buf +to +.IR sa . + +.B stralloc_cat +appends +.I sa2 +to +.IR sa , +allocating space if necessary. +If +.I sa +is unallocated, +.B stralloc_cat +is the same as +.BR stralloc_copy . + +.B stralloc_cats +and +.B stralloc_catb +are analogous to +.B stralloc_copys +and +.BR stralloc_copyb . + +.B stralloc_append +adds a single character, +.IR *buf , +to +.IR sa , +allocating space if necessary. + +.B stralloc_0 +adds a single 0 character +to +.IR sa . + +.B stralloc_starts +returns 1 if the 0-terminated string +.IR buf , +without the 0, +is a prefix of +.IR sa . +.SH "ERROR HANDLING" +If a +.B stralloc +routine runs out of memory, +it leaves +.I sa +alone and returns 0, +setting +.B errno +appropriately. +On success it returns 1; +this guarantees that +.I sa +is allocated. +.SH "SEE ALSO" +alloc(3), +error(3) @@ -18,4 +18,12 @@ extern int stralloc_starts(); #define stralloc_0(sa) stralloc_append(sa,"") +extern int stralloc_catulong0(); +extern int stralloc_catlong0(); + +#define stralloc_catlong(sa,l) (stralloc_catlong0((sa),(l),0)) +#define stralloc_catuint0(sa,i,n) (stralloc_catulong0((sa),(unsigned long) (i),(n))) +#define stralloc_catint0(sa,i,n) (stralloc_catlong0((sa),(long) (i),(n))) +#define stralloc_catint(sa,i) (stralloc_catlong0((sa),(long) (i),0)) + #endif diff --git a/stralloc=l b/stralloc=l deleted file mode 100644 index e1ebc8d..0000000 --- a/stralloc=l +++ /dev/null @@ -1,8 +0,0 @@ -stralloc_eady.o -stralloc_pend.o -stralloc_copy.o -stralloc_opys.o -stralloc_opyb.o -stralloc_cat.o -stralloc_cats.o -stralloc_catb.o diff --git a/stralloc_arts.c b/stralloc_arts.c deleted file mode 100644 index 1ccb5a4..0000000 --- a/stralloc_arts.c +++ /dev/null @@ -1,12 +0,0 @@ -#include "byte.h" -#include "str.h" -#include "stralloc.h" - -int stralloc_starts(sa,s) -stralloc *sa; -char *s; -{ - int len; - len = str_len(s); - return (sa->len >= len) && byte_equal(s,len,sa->s); -} diff --git a/strerr=l b/strerr=l deleted file mode 100644 index 5181cee..0000000 --- a/strerr=l +++ /dev/null @@ -1,2 +0,0 @@ -strerr_sys.o -strerr_die.o diff --git a/subgetopt.3 b/subgetopt.3 new file mode 100644 index 0000000..aae03aa --- /dev/null +++ b/subgetopt.3 @@ -0,0 +1,357 @@ +.TH subgetopt 3 +.SH NAME +subgetopt \- get option character from command line +.SH SYNTAX +.B #include <subgetopt.h> + +char *\fBsgoptarg\fP; +.br +int \fBsgoptind\fP; +.br +int \fBsgoptpos\fP; +.br +int \fBsgoptdone\fP; +.br +int \fBsgoptproblem\fP; + +int \fBsgopt(\fP\fIargc,argv,opts\fR\fB)\fP; + +int \fIargc\fR; +.br +char **\fIargv\fR; +.br +char *\fIopts\fR; +.SH DESCRIPTION +.B sgopt +returns the next valid command-line option character +from +.IR argv . + +Valid option characters are listed in the +.I opts +string. +.I opts +may be empty. +A character in +.I opts +may be followed by a colon, +in which case it +takes an +.I option argument\fR. +Avoid using the characters ?, :, and \- as option characters. + +Below +.I option argument +is abbreviated +as +.I optarg +and +.I command-line argument +is abbreviated as +.IR cmdarg . + +Options are listed in cmdargs which begin with +a minus sign. +Several options which do not take optargs may be combined +into one cmdarg. + +An option which takes an optarg may be handled in two ways. +If it appears at the very end of a cmdarg, +then the entire next cmdarg is the optarg. +But if there are any characters in the cmdarg +after the option character, +then those characters form the optarg. +The optarg is returned in +.BR sgoptarg . +Next time +.B sgopt +looks at the cmdarg which follows the optarg. + +If a cmdarg does not begin with a hyphen, +or if it is a lone hyphen not followed by any characters, +or if it begins with two hyphens, +then it terminates option processing, +and +.B sgopt +returns an appropriate code. +If there are two hyphens, +.B sgopt +will advance attention to the next cmdarg, +so it can be called again to read further options. +.SH "PROPER USAGE" +.B sgoptproblem +should be used only when +.B sgopt +returns ?. +.B sgoptind +and +.B sgoptpos +are defined all the time. +.B sgoptarg +is defined all the time; +it is null unless +.B sgopt +has just returned an option with optarg. + +.B sgopt +is typically used as follows. + +.EX +#include <subgetopt.h> + +main(argc,argv) int argc; char **argv; { int opt; + +while ((opt = sgopt(argc,argv,"a:s")) != sgoptdone) +.br + switch(opt) { +.br + case 'a': +.br + printf("opt a with optarg %s\\n",sgoptarg); break; +.br + case 's': +.br + printf("opt s with no optarg\\n"); break; +.br + case '?': +.br + if (argv[sgoptind] && (sgoptind < argc)) +.br + printf("illegal opt %c\\n",sgoptproblem); +.br + else +.br + printf("missing arg, opt %c\\n",sgoptproblem); +.br + exit(1); +.br + } + +argv += sgoptind; +.br +while (*argv) printf("argument %s\\n",*argv++); +.br +exit(0); +.br +} +.EE + +The end of the command line is +marked by either +.IR argc , +or a null pointer in +.IR argv , +whichever comes first. +Normally +these two markers coincide, +so it is redundant +to test for +both +.I argv\fB[sgoptind] +and +.B sgoptind < \fIargc\fR. +The above code shows both tests as an illustration. + +.B Multiple option sets: +One useful technique is to call +.B sgopt +with a primary +.I opts +until it returns EOF, +then call +.B sgopt +with a secondary +.I opts +until it returns EOF. +The user can provide primary options, then a double hyphen, +and then secondary options. +No special handling is needed if some or all of the options are +omitted. +The same technique can be used for any number of option sets +in series. + +.B Multiple command lines: +Before parsing a new +.BR argv , +make sure to +set +.B sgoptind +and +.B sgoptpos +back to +1 and 0. +.SH "PARSING STAGES" +.B sgopt +keeps track of its position in +.I argv +with +.B sgoptind +and +.BR sgoptpos , +which are initialized to 1 and 0. +It looks at +.I argv\fB[sgoptind][sgoptpos] +and following characters. + +.B sgopt +indicates +that no more options are available by +returning +.BR sgoptdone , +which is initialized to +.BR SUBGETOPTDONE , +which is defined as \-1. + +.B sgopt +begins by setting +.B optarg +to null. + +.B Ending conditions: +If +.I argv +is null, or +.B sgoptind +is larger than +.IR argc , +or the current cmdarg +.I argv\fB[sgoptind] +is null, +then +.B sgopt +returns +.BR optdone . + +.B Stage one: +If the current character +is zero, +.B sgopt +moves to the beginning of the next cmdarg. +It then checks the ending conditions again. + +.B Stage two: +If +the current position is the begining of the cmdarg, +.B sgopt +checks whether +the current character +is a minus sign. +If not it returns +.BR optdone . +It then +moves +to the next character. +If that character is zero, +.B sgopt +moves +back to the beginning of the cmdarg, +and returns +.BR sgoptdone . +If the character is a minus sign, +.B sgopt +moves to the beginning of the next cmdarg, +and returns +.BR sgoptdone . + +.B Stage three: +.B sgopt +records the current character, +.IR c , +and moves to the next character. +There are three possibilities: +(1) +.I c +is an option character without optarg in +.IR opts , +or +(2) +.I c +is an option character with optarg in +.IR opts , +or +(3) +.I c +does not appear in +.IR opts . + +(1) +If +.I c +appears as an option character without optarg in +.IR opts , +.B sgopt +returns +.IR c . + +(2) +If +.I c +appears as an option character with optarg in +.IR opts , +.B sgopt +sets +.B sgoptarg +to the current position, +and moves to the next cmdarg. +If +.B sgoptarg +is nonempty, +.B sgopt +returns +.IR c . + +Then +.B sgopt +sets +.B sgoptarg +to +the current cmdarg. +If +the current cmdarg is null, +or past +.IR argc , +.B sgopt +sets +.B sgoptproblem +to +.I c +and returns ?. +Otherwise +.B sgopt +moves to the next +argument +and returns +.IR c . + +(2) +If +.I c +does not appear in +.IR opts , +.B sgopt +sets +.B sgoptproblem +to +.I c +and returns ?. +.SH "SYNTAX NOTE" +.B sgopt +is actually a macro abbreviation for +.BR subgetopt . +The external +.B sg +variables are also macros +for +.BR subget . +These macros are defined in +.BR <subgetopt.h> , +unless +.B SUBGETOPTNOSHORT +is defined +when +.B <subgetopt.h> +is included. +.SH VERSION +subgetopt version 0.9, 931129. +.SH AUTHOR +Placed into the public domain by Daniel J. Bernstein. diff --git a/substdio=l b/substdio=l deleted file mode 100644 index 55720b5..0000000 --- a/substdio=l +++ /dev/null @@ -1,7 +0,0 @@ -substdio.o -substdi.o -substdo.o -subfderr.o -subfdout.o -subfdin.o -substdio_copy.o diff --git a/tcp-environ=0 b/tcp-environ=0 deleted file mode 100644 index da3c189..0000000 --- a/tcp-environ=0 +++ /dev/null @@ -1 +0,0 @@ -tcp-environ.5 diff --git a/tcpcat.1 b/tcpcat.1 new file mode 100644 index 0000000..4c51ed5 --- /dev/null +++ b/tcpcat.1 @@ -0,0 +1,20 @@ +.TH tcpcat 1 +.SH NAME +tcpcat \- print data from a TCP port +.SH SYNTAX +.B tcpcat +.I host +.I port +.SH DESCRIPTION +.B tcpcat +connects to +.I port +on +.I host +and prints any data it receives. + +.B tcpcat +can be used to transfer binary data. +It does no conversions. +.SH "SEE ALSO" +tcpclient(1) @@ -1 +1 @@ -exec BIN/tcpclient -RHl0 -- "${1-0}" "${2-17}" sh -c 'exec cat <&6' +exec HOME/bin/tcpclient -RHl0 -- "${1-0}" "${2-17}" sh -c 'exec cat <&6' diff --git a/tcpcat=s b/tcpcat=s deleted file mode 100644 index e69de29..0000000 --- a/tcpcat=s +++ /dev/null diff --git a/tcpclient.1 b/tcpclient.1 index 9c91902..c60ed34 100644 --- a/tcpclient.1 +++ b/tcpclient.1 @@ -4,19 +4,22 @@ tcpclient \- create an outgoing TCP connection .SH SYNOPSIS .B tcpclient [ -.B \-qQvdDhHrR +.B \-hHrRdDqQv ] [ -.B \-l\fIlocalname +.B \-i\fIlocalip ] [ -.B \-p\fIlocport +.B \-p\fIlocalport ] [ -.B \-t\fItimeoutinfo +.B \-T\fItimeoutconn ] [ -.B \-T\fItimeoutconn +.B \-l\fIlocalname +] +[ +.B \-t\fItimeoutinfo ] .I host .I port @@ -26,9 +29,8 @@ tcpclient \- create an outgoing TCP connection ] .SH DESCRIPTION .B tcpclient -is a TCP UCSPI client. -It attempts to connect to a TCP server; -if it is successful, it runs +attempts to connect to a TCP server. +If it is successful, it runs .I program with the given arguments, with descriptor 6 reading from the network @@ -55,14 +57,41 @@ as described in .B tcp-environ(5). .SH OPTIONS .TP -.B \-p\fIlocport +.B \-i\fIlocalip +Use +.I localip +as the IP address for the local side of the connection; +quit if +.I localip +is not available. +.TP +.B \-p\fIlocalport Use -.I locport -for the local side of the connection; +.I localport +as the port number for the local side of the connection; quit if -.I locport +.I localport is not available. .TP +.B \-T\fItimeoutconn +Give up on the +connection attempt +after +.I timeoutconn +seconds. Default: 60. +This timeout applies to each IP address tried. +.TP +.B \-d +(Default.) +Delay sending data for a fraction of a second whenever the +remote host is responding slowly, +to make better use of the network. +.TP +.B \-D +Never delay sending data; +enable TCP_NODELAY. +This is appropriate for interactive connections. +.TP .B \-q Quiet. Do not print any messages. @@ -74,14 +103,7 @@ Print error messages. .B \-v Verbose. Print all available messages. -.TP -.B \-T\fItimeoutconn -Give up on the -connection attempt -after -.I timeoutconn -seconds. Default: 60. -This timeout applies to each IP address tried. +.SH "DATA-GATHERING OPTIONS" .TP .B \-h (Default.) @@ -118,17 +140,12 @@ connection attempt after .I timeoutinfo seconds. Default: 26. -.TP -.B \-d -(Default.) -Delay sending data for a fraction of a second whenever the -remote host is responding slowly, -to make better use of the network. -.TP -.B \-D -Never delay sending data; -enable TCP_NODELAY. -This is appropriate for interactive connections. .SH "SEE ALSO" +date@(1), +finger@(1), +http@(1), +mconnect(1), +tcpcat(1), tcpserver(1), +who@(1), tcp-environ(5) diff --git a/tcpclient.c b/tcpclient.c index a22a20a..cd72663 100644 --- a/tcpclient.c +++ b/tcpclient.c @@ -4,13 +4,11 @@ #include <netinet/in.h> #include <netdb.h> -#include "substdio.h" +#include "strerr.h" #include "stralloc.h" #include "str.h" #include "byte.h" -#include "error.h" #include "sig.h" -#include "subfd.h" #include "fd.h" #include "ip.h" #include "ipalloc.h" @@ -23,34 +21,39 @@ #include "dns.h" #include "remoteinfo.h" -int verbosity = 1; -char temp[IPFMT + FMT_ULONG]; +#define FATAL "tcpclient: fatal: " +#define CONNECT "tcpclient: unable to connect to " -void out(s) char *s; { if (verbosity) substdio_puts(subfderr,s); } -void flush() { if (verbosity) substdio_flush(subfderr); } +int verbosity = 1; -void usage() -{ out("tcpclient: usage: \ -tcpclient [ -qQvdDrRU ] [ -plocport ] [ -llocalname ] [ -ttimeoutinfo ] \ -[ -Ttimeoutconn ] host port program\n"); flush(); _exit(100); } -void die(s) char *s; -{ out("tcpclient: fatal: "); out(s); out("\n"); flush(); _exit(111); } -void diep(s) char *s; -{ char *x = error_str(errno); - out("tcpclient: fatal: "); out(s); out(": "); - out(x); out("\n"); flush(); _exit(111); } +void die2(s,t) char *s; char *t; +{ + if (verbosity) strerr_warn3(FATAL,s,t,0); + _exit(111); +} +void diesys(s) char *s; +{ + if (verbosity) strerr_warn2(FATAL,s,&strerr_sys); + _exit(111); +} void nomem() -{ die("out of memory"); } -void warnconnect(ipr) struct ip_address *ipr; { - char *x = error_str(errno); - temp[ip_fmt(temp,ipr)] = 0; - out("tcpclient: unable to connect to "); out(temp); out(": "); - out(x); out("\n"); flush(); } -void infoconnected(ipr) struct ip_address *ipr; -{ if (verbosity < 2) return; - temp[ip_fmt(temp,ipr)] = 0; - out("tcpclient: connected to "); out(temp); out("\n"); flush(); } + if (verbosity) strerr_warn2(FATAL,"out of memory",0); + _exit(111); +} +void usage() +{ + strerr_die1x(100,"tcpclient: usage: tcpclient \ +[ -hHrRdDqQv ] \ +[ -i localip ] \ +[ -p localport ] \ +[ -T timeoutconn ] \ +[ -l localname ] \ +[ -t timeoutinfo ] \ +host port program"); +} + +char temp[IPFMT + FMT_ULONG]; int flagdelay = 1; int flagremoteinfo = 1; @@ -68,6 +71,7 @@ unsigned long portlocal; struct sockaddr_in saremote; struct ip_address ipremote; unsigned long portremote; +char strport[FMT_ULONG]; void main(argc,argv) int argc; @@ -81,9 +85,12 @@ char **argv; struct servent *se; int j; - portlocal = 0; - - while ((opt = getopt(argc,argv,"dDvqQLhHrRp:Ut:T:l:")) != opteof) + byte_zero(&salocal,sizeof(salocal)); + salocal.sin_family = AF_INET; + salocal.sin_addr.s_addr = INADDR_ANY; + salocal.sin_port = 0; + + while ((opt = getopt(argc,argv,"dDvqQhHrRi:p:t:T:l:")) != opteof) switch(opt) { case 'd': flagdelay = 1; break; case 'D': flagdelay = 0; break; @@ -95,11 +102,16 @@ char **argv; case 'h': flagremotehost = 1; break; case 'R': flagremoteinfo = 0; break; case 'r': flagremoteinfo = 1; break; - case 'p': scan_ulong(optarg,&portlocal); break; case 't': scan_ulong(optarg,&timeout); break; case 'T': scan_ulong(optarg,&timeout2); break; - case 'U': usage(); - default: _exit(100); + case 'i': + if (ip_scan(optarg,&iplocal)) byte_copy(&salocal.sin_addr,4,&iplocal); + break; + case 'p': + scan_ulong(optarg,&portlocal); + salocal.sin_port = htons((unsigned short) portlocal); + break; + default: usage(); } argc -= optind; argv += optind; @@ -116,51 +128,55 @@ char **argv; dns_init(1); - byte_zero(&salocal,sizeof(salocal)); - salocal.sin_family = AF_INET; - salocal.sin_addr.s_addr = INADDR_ANY; - salocal.sin_port = htons((unsigned short) portlocal); - byte_zero(&saremote,sizeof(saremote)); saremote.sin_family = AF_INET; - + if (!portname[scan_ulong(portname,&portremote)]) ; else { se = getservbyname(portname,"tcp"); - if (!se) die("unable to figure out port number"); + if (!se) die2("unable to figure out port number for ",portname); portremote = ntohs(se->s_port); /* i continue to be amazed at the stupidity of the s_port interface */ } + strport[fmt_ulong(strport,portremote)] = 0; - if (!str_diff(hostname,"0")) hostname = "0.0.0.0"; + if (str_equal(hostname,"")) hostname = "127.0.0.1"; + if (str_equal(hostname,"0")) hostname = "127.0.0.1"; if (!hostname[ip_scan(hostname,&ipremote)]) { s = socket(AF_INET,SOCK_STREAM,0); - if (s == -1) diep("unable to create socket"); + if (s == -1) + diesys("unable to create socket: "); if (bind(s,(struct sockaddr *) &salocal,sizeof(salocal)) == -1) - diep("unable to bind"); + diesys("unable to bind: "); if (timeoutconn(s,&ipremote,portremote,(int) timeout2) == -1) { - warnconnect(&ipremote); + temp[ip_fmt(temp,&ipremote)] = 0; + if (verbosity) strerr_warn5(CONNECT,temp," port ",strport,": ",&strerr_sys); _exit(111); } } else { if (!stralloc_copys(&tmp,hostname)) nomem(); switch(dns_ip(&ia,&tmp)) { - case DNS_SOFT: die("temporarily unable to figure out host address"); - case DNS_HARD: die("unable to figure out host address"); + case DNS_SOFT: + die2("temporarily unable to figure out IP address for ",hostname); + case DNS_HARD: + die2("unable to figure out IP address for ",hostname); case DNS_MEM: nomem(); } - if (ia.len == 0) die("no IP addresses for that host"); + if (ia.len == 0) + die2("no IP addresses for ",hostname); for (j = 0;j < ia.len;++j) { s = socket(AF_INET,SOCK_STREAM,0); - if (s == -1) diep("unable to create socket"); + if (s == -1) + diesys("unable to create socket: "); if (bind(s,(struct sockaddr *) &salocal,sizeof(salocal)) == -1) - diep("unable to bind"); + diesys("unable to bind: "); byte_copy(&ipremote,4,&ia.ix[j].ip); if (timeoutconn(s,&ipremote,portremote,(int) timeout2) == 0) break; - warnconnect(&ipremote); + temp[ip_fmt(temp,&ipremote)] = 0; + if (verbosity) strerr_warn5(CONNECT,temp," port ",strport,": ",&strerr_sys); close(s); } if (j == ia.len) _exit(111); @@ -180,7 +196,7 @@ char **argv; dummy = sizeof(salocal); if (getsockname(s,(struct sockaddr *) &salocal,&dummy) == -1) - diep("unable to get local address"); + diesys("unable to get local address: "); portlocal = ntohs(salocal.sin_port); byte_copy(&iplocal,4,&salocal.sin_addr); @@ -202,16 +218,14 @@ char **argv; dummy = sizeof(saremote); if (getpeername(s,(struct sockaddr *) &saremote,&dummy) == -1) - diep("unable to get remote address"); - portremote = ntohs(saremote.sin_port); + diesys("unable to get remote address: "); byte_copy(&ipremote,4,&saremote.sin_addr); - infoconnected(&ipremote); - - temp[fmt_ulong(temp,portremote)] = 0; - if (!env_put2("TCPREMOTEPORT",temp)) nomem(); temp[ip_fmt(temp,&ipremote)] = 0; if (!env_put2("TCPREMOTEIP",temp)) nomem(); + if (verbosity >= 2) strerr_warn4("tcpclient: connected to ",temp," port ",strport,0); + + if (!env_put2("TCPREMOTEPORT",strport)) nomem(); if (flagremotehost) switch(dns_ptr(&tmp,&ipremote)) { case DNS_MEM: nomem(); @@ -227,10 +241,11 @@ char **argv; if (!env_put2("TCPREMOTEINFO",rinfo)) nomem(); } - if (fd_move(6,s) == -1) diep("unable to set up descriptor 6"); - if (fd_copy(7,6) == -1) diep("unable to set up descriptor 7"); + if (fd_move(6,s) == -1) diesys("unable to set up descriptor 6: "); + if (fd_copy(7,6) == -1) diesys("unable to set up descriptor 7: "); sig_pipedefault(); execvp(*argv,argv); - diep("unable to execute"); + if (verbosity) strerr_warn4(FATAL,"unable to run ",*argv,": ",&strerr_sys); + _exit(111); } diff --git a/tcpclient=0 b/tcpclient=0 deleted file mode 100644 index cea39bf..0000000 --- a/tcpclient=0 +++ /dev/null @@ -1 +0,0 @@ -tcpclient.1 diff --git a/tcpclient=x b/tcpclient=x deleted file mode 100644 index 569d485..0000000 --- a/tcpclient=x +++ /dev/null @@ -1,21 +0,0 @@ -ip.o -ipalloc.o -dns.o -remoteinfo.o -timeoutconn.o -timeoutread.o -timeoutwrite.o -stralloc.a -env.a -alloc.a -ndelay.a -substdio.a -error.a -str.a -sig.a -fd.a -case.a -getopt.a -fs.a -dns.lib -socket.lib @@ -203,5 +203,6 @@ Any number of variables may be listed: 127.0.0.1:allow,RELAYCLIENT="",TCPLOCALHOST="movie.edu" .EE .SH "SEE ALSO" +tcprulescheck(1), tcpserver(1), tcp-environ(5) diff --git a/tcprules=0 b/tcprules=0 deleted file mode 100644 index e12053d..0000000 --- a/tcprules=0 +++ /dev/null @@ -1 +0,0 @@ -tcprules.1 diff --git a/tcprules=x b/tcprules=x deleted file mode 100644 index b534828..0000000 --- a/tcprules=x +++ /dev/null @@ -1,12 +0,0 @@ -cdbmss.o -cdbmake.a -getln.a -strerr.a -stralloc.a -substdio.a -alloc.a -error.a -open.a -seek.a -str.a -fs.a diff --git a/tcprulescheck.1 b/tcprulescheck.1 new file mode 100644 index 0000000..3f0de24 --- /dev/null +++ b/tcprulescheck.1 @@ -0,0 +1,25 @@ +.TH tcprulescheck 1 +.SH NAME +tcprulescheck \- try out rules for tcpserver +.SH SYNTAX +.B tcprulescheck +.I rules.cdb +.I tcpremoteip +[ +.I tcpremoteinfo +] +.SH DESCRIPTION +.B tcprulescheck +says what +.B tcpserver +will do with a connection from +IP address +.IR tcpremoteip , +following the rules compiled into +.I rules.cdb +by +.BR tcprules . +.SH "SEE ALSO" +tcprules(1), +tcpserver(1), +tcp-environ(5) diff --git a/tcprulescheck.c b/tcprulescheck.c new file mode 100644 index 0000000..2a0eb34 --- /dev/null +++ b/tcprulescheck.c @@ -0,0 +1,104 @@ +#include "substdio.h" +#include "subfd.h" +#include "strerr.h" +#include "stralloc.h" +#include "alloc.h" +#include "cdb.h" + +#define FATAL "tcprulescheck: fatal: " + +char *fnrules; +int fdrules; + +void die_usage() +{ + strerr_die1x(100,"tcprulescheck: usage: tcprulescheck rules.cdb tcpremoteip [ tcpremoteinfo ]"); +} +void die_read() +{ + strerr_die4sys(111,FATAL,"unable to read ",fnrules,": "); +} +void nomem() +{ + strerr_die2x(111,FATAL,"out of memory"); +} + +static stralloc tmp = {0}; + +void dorule() +{ + char *data; + uint32 dlen32; + unsigned int datalen; + unsigned int next0; + + switch(cdb_seek(fdrules,tmp.s,tmp.len,&dlen32)) { + case -1: die_read(); + case 0: return; + } + + datalen = dlen32; + data = alloc(datalen); + if (!data) nomem(); + if (cdb_bread(fdrules,data,datalen) != 0) die_read(); + + substdio_puts(subfdout,"rule "); + substdio_put(subfdout,tmp.s,tmp.len); + substdio_puts(subfdout,":\n"); + while ((next0 = byte_chr(data,datalen,0)) < datalen) { + switch(data[0]) { + case 'D': + substdio_puts(subfdout,"deny connection\n"); + substdio_flush(subfdout); + _exit(0); /* XXX: could still set env vars for logs */ + case '+': + substdio_puts(subfdout,"set environment variable "); + substdio_puts(subfdout,data + 1); + substdio_puts(subfdout,"\n"); + break; + } + data += next0 + 1; datalen -= next0 + 1; + } + substdio_puts(subfdout,"allow connection\n"); + substdio_flush(subfdout); + _exit(0); +} + +void main(argc,argv) +int argc; +char **argv; +{ + char *tcpremoteip; + char *tcpremoteinfo; + + fnrules = argv[1]; + if (!fnrules) die_usage(); + + tcpremoteip = argv[2]; + if (!tcpremoteip) die_usage(); + + tcpremoteinfo = argv[3]; + + fdrules = open_read(fnrules); + if (fdrules == -1) die_read(); + + if (tcpremoteinfo) { + if (!stralloc_copys(&tmp,tcpremoteinfo)) nomem(); + if (!stralloc_cats(&tmp,"@")) nomem(); + if (!stralloc_cats(&tmp,tcpremoteip)) nomem(); + dorule(); + } + + if (!stralloc_copys(&tmp,tcpremoteip)) nomem(); + dorule(); + while (tmp.len > 0) { + if (tcpremoteip[tmp.len - 1] == '.') + dorule(); + --tmp.len; + } + + dorule(); + + substdio_putsflush(subfdout,"default:\nallow connection\n"); + _exit(0); +} diff --git a/tcpserver.1 b/tcpserver.1 index 0f5ee5e..04b10f9 100644 --- a/tcpserver.1 +++ b/tcpserver.1 @@ -4,16 +4,16 @@ tcpserver \- accept incoming TCP connections .SH SYNOPSIS .B tcpserver [ -.B \-qQvdDoOpPhHrRsS1 +.B \-1pPhHrRoOdDqQv ] [ .B \-c\fIlimit ] [ -.B \-b\fIbacklog +.B \-x\fIrules.cdb ] [ -.B \-x\fIrules.cdb +.B \-B\fIbanner ] [ .B \-g\fIgid @@ -22,6 +22,9 @@ tcpserver \- accept incoming TCP connections .B \-u\fIuid ] [ +.B \-b\fIbacklog +] +[ .B \-l\fIlocalname ] [ @@ -91,6 +94,7 @@ by .BR tcprules . These rules may specify setting environment variables or rejecting connections from bad sources. + .B tcpserver does not read .I rules.cdb @@ -101,6 +105,23 @@ to change .BR tcpserver 's behavior on the fly. .TP +.B \-B\fIbanner +Write +.I banner +to the network immediately after each connection is made. +.B tcpserver +writes +.I banner +before looking up +.BR TCPREMOTEHOST , +before looking up +.BR TCPREMOTEINFO , +and before checking +.IR rules.cdb . + +This feature can be used to reduce latency in protocols +where the client waits for a greeting from the server. +.TP .B \-g\fIgid Switch group ID to .I gid @@ -119,18 +140,6 @@ must be a positive integer. After preparing to receive connections, print the local port number to standard output. .TP -.B \-q -Quiet. -Do not print any messages. -.TP -.B \-Q -(Default.) -Print error messages. -.TP -.B \-v -Verbose. -Print all available messages. -.TP .B \-b\fIbacklog Allow up to .I backlog @@ -164,6 +173,18 @@ to make better use of the network. Never delay sending data; enable TCP_NODELAY. This is appropriate for interactive connections. +.TP +.B \-q +Quiet. +Do not print any messages. +.TP +.B \-Q +(Default.) +Print error messages. +.TP +.B \-v +Verbose. +Print all available messages. .SH "DATA-GATHERING OPTIONS" .TP .B \-p @@ -206,16 +227,6 @@ Do not attempt to obtain .B TCPREMOTEINFO from the remote host. .TP -.B \-s -(Default.) -Attempt to set -.B BOUNCEMAIL -using the IP address from the RBL documented at http://maps.vix.com -.TP -.B \-S -Do not attempt to set -.B BOUNCEMAIL -.TP .B \-t\fItimeout Give up on the .B TCPREMOTEINFO @@ -224,6 +235,9 @@ after .I timeout seconds. Default: 26. .SH "SEE ALSO" +argv0(1), +fixcr(1), +recordio(1), tcpclient(1), tcprules(1), listen(2), diff --git a/tcpserver.c b/tcpserver.c index 02fff20..012dc36 100644 --- a/tcpserver.c +++ b/tcpserver.c @@ -43,11 +43,17 @@ void drop_nomem() } void usage() { - if (verbosity) strerr_warn1("\ -tcpserver: usage: \ -tcpserver [ -qQvdDoOpPhHrRsS1 ] \ -[ -xrules.cdb ] \ -[ -bbacklog ] [ -climit ] [ -ttimeout ] [ -llocalname ] [ -ggid ] [ -uuid ] \ + strerr_warn1("\ +tcpserver: usage: tcpserver \ +[ -1pPhHrRoOdDqQv ] \ +[ -c limit ] \ +[ -x rules.cdb ] \ +[ -B banner ] \ +[ -g gid ] \ +[ -u uid ] \ +[ -b backlog ] \ +[ -l localname ] \ +[ -t timeout ] \ host port program",0); _exit(100); } @@ -57,21 +63,26 @@ stralloc *sa; char *s; { char ch; - while (ch = *s++) { + int i; + + for (i = 0;i < 100;++i) { + ch = s[i]; + if (!ch) return; if (ch < 33) ch = '?'; if (ch > 126) ch = '?'; if (ch == '%') ch = '?'; /* logger stupidity */ if (ch == ':') ch = '?'; if (!stralloc_append(sa,&ch)) drop_nomem(); } + if (!stralloc_cats(sa,"...")) drop_nomem(); } char strnum[FMT_ULONG]; char strnum2[FMT_ULONG]; stralloc tmp = {0}; -stralloc tmp1 = {0}; ipalloc ia = {0}; +unsigned long limit = 40; unsigned long numchildren = 0; char tcpremoteip[IPFMT]; @@ -126,12 +137,19 @@ void printenv() strerr_warn1(tmp.s,0); } +void printstatus() +{ + if (verbosity < 2) return; + strnum[fmt_ulong(strnum,numchildren)] = 0; + strnum2[fmt_ulong(strnum2,limit)] = 0; + strerr_warn4("tcpserver: status: ",strnum,"/",strnum2,0); +} + void printpid() { if (verbosity < 2) return; strnum[fmt_ulong(strnum,(unsigned long) getpid())] = 0; - strnum2[fmt_ulong(strnum2,numchildren)] = 0; - strerr_warn6("tcpserver: pid ",strnum," num ",strnum2," from ",tcpremoteip,0); + strerr_warn4("tcpserver: pid ",strnum," from ",tcpremoteip,0); } char printbuf[16]; @@ -151,12 +169,12 @@ void sigchld() int pid; while ((pid = wait_nohang(&wstat)) > 0) { - if (numchildren) --numchildren; if (verbosity >= 2) { strnum[fmt_ulong(strnum,(unsigned long) pid)] = 0; strnum2[fmt_ulong(strnum2,(unsigned long) wstat)] = 0; strerr_warn4("tcpserver: end ",strnum," status ",strnum2,0); } + if (numchildren) --numchildren; printstatus(); } } @@ -225,7 +243,6 @@ int flagkillopts = 1; int flagdelay = 1; int flagremoteinfo = 1; int flagremotehost = 1; -int flagrbl = 1; int flagparanoid = 0; int flag1 = 0; unsigned long backlog = 20; @@ -233,7 +250,8 @@ unsigned long timeout = 26; unsigned long uid = 0; unsigned long gid = 0; char *forcelocal = 0; -unsigned long limit = 40; + +char *banner = ""; void main(argc,argv) int argc; @@ -248,11 +266,12 @@ char **argv; struct servent *se; int j; - while ((opt = getopt(argc,argv,"dDvqQhHrRsS1x:t:u:g:l:b:c:pPoO")) != opteof) + while ((opt = getopt(argc,argv,"dDvqQhHrR1x:t:u:g:l:b:B:c:pPoO")) != opteof) switch(opt) { case 'b': scan_ulong(optarg,&backlog); break; case 'c': scan_ulong(optarg,&limit); break; case 'x': fnrules = optarg; break; + case 'B': banner = optarg; break; case 'd': flagdelay = 1; break; case 'D': flagdelay = 0; break; case 'v': verbosity = 2; break; @@ -266,8 +285,6 @@ char **argv; case 'h': flagremotehost = 1; break; case 'R': flagremoteinfo = 0; break; case 'r': flagremoteinfo = 1; break; - case 'S': flagrbl = 0; break; - case 's': flagrbl = 1; break; case 't': scan_ulong(optarg,&timeout); break; case 'g': scan_ulong(optarg,&gid); break; case 'u': scan_ulong(optarg,&uid); break; @@ -298,7 +315,7 @@ char **argv; else { se = getservbyname(portname,"tcp"); if (!se) { - if (verbosity) strerr_warn3(FATAL,"unable to figure out number for port ",portname,0); + if (verbosity) strerr_warn3(FATAL,"unable to figure out port number for ",portname,0); _exit(111); } salocal.sin_port = se->s_port; @@ -313,10 +330,10 @@ char **argv; case DNS_MEM: die_nomem(); case DNS_HARD: - if (verbosity) strerr_warn3(FATAL,"unable to figure out address for host ",hostname,0); + if (verbosity) strerr_warn3(FATAL,"unable to figure out IP address for ",hostname,0); _exit(111); case DNS_SOFT: - if (verbosity) strerr_warn3(FATAL,"temporarily unable to figure out address for host ",hostname,0); + if (verbosity) strerr_warn3(FATAL,"temporarily unable to figure out IP address for ",hostname,0); _exit(111); } if (!ia.len) { @@ -390,13 +407,13 @@ char **argv; byte_copy(&ipremote,4,&saremote.sin_addr); sig_childblock(); + + ++numchildren; printstatus(); switch(fork()) { - default: - ++numchildren; - break; case -1: if (verbosity) strerr_warn2(DROP,"unable to fork: ",&strerr_sys); + --numchildren; printstatus(); break; case 0: tcpremoteip[ip_fmt(tcpremoteip,&ipremote)] = 0; @@ -412,10 +429,20 @@ char **argv; setsockopt(t,IPPROTO_TCP,1,&opt,sizeof(opt)); /* 1 == TCP_NODELAY */ /* if it fails, bummer */ } + + if (*banner) { + substdio ss; + char ssbuf[1]; + substdio_fdbuf(&ss,write,t,ssbuf,sizeof ssbuf); + if (substdio_putsflush(&ss,banner) == -1) { + if (verbosity) strerr_warn2(DROP,"unable to print banner: ",&strerr_sys); + _exit(111); + } + } dummy = sizeof(salocal); if (getsockname(t,(struct sockaddr *) &salocal,&dummy) == -1) { - if (verbosity) strerr_warn2(DROP,"unable to get local address",&strerr_sys); + if (verbosity) strerr_warn2(DROP,"unable to get local address: ",&strerr_sys); _exit(111); } byte_copy(&iplocal,4,&salocal.sin_addr); @@ -452,15 +479,6 @@ char **argv; case_lowers(tmp.s); if (!env_put2("TCPREMOTEHOST",tmp.s)) drop_nomem(); } - if (flagrbl) - switch(dns_maps(&tmp,&ipremote)) { - case DNS_MEM: drop_nomem(); - case 0: - if (!stralloc_copys(&tmp1, "553 ")) drop_nomem(); - if (!stralloc_cat(&tmp1, &tmp)) drop_nomem(); - if (!stralloc_0(&tmp1)) drop_nomem(); - if (!env_put2("BOUNCEMAIL",tmp1.s)) drop_nomem(); - } if (flagremoteinfo) { tcpremoteinfo = remoteinfo_get(&ipremote,portremote,&iplocal,portlocal,(int) timeout); if (tcpremoteinfo) @@ -475,8 +493,8 @@ char **argv; if (verbosity) strerr_warn2(DROP,"unable to set up descriptors: ",&strerr_sys); _exit(111); } - sig_childunblock(); sig_childdefault(); + sig_childunblock(); sig_termdefault(); sig_pipedefault(); execvp(*argv,argv); diff --git a/tcpserver=0 b/tcpserver=0 deleted file mode 100644 index 6dc8469..0000000 --- a/tcpserver=0 +++ /dev/null @@ -1 +0,0 @@ -tcpserver.1 diff --git a/tcpserver=x b/tcpserver=x deleted file mode 100644 index c1eaae9..0000000 --- a/tcpserver=x +++ /dev/null @@ -1,25 +0,0 @@ -ip.o -ipalloc.o -dns.o -remoteinfo.o -timeoutconn.o -timeoutread.o -timeoutwrite.o -cdb.a -open.a -wait.a -strerr.a -stralloc.a -env.a -ndelay.a -alloc.a -getopt.a -substdio.a -error.a -str.a -sig.a -fd.a -case.a -fs.a -dns.lib -socket.lib @@ -1,4 +1,7 @@ main() { - ; + dn_expand(); + res_init(); + res_query(); + res_search(); } diff --git a/uint32.h.do b/uint32.h.do deleted file mode 100644 index b87401d..0000000 --- a/uint32.h.do +++ /dev/null @@ -1,7 +0,0 @@ -dependon tryulong32.c compile load uint32.h1 uint32.h2 -( ./compile tryulong32.c && ./load tryulong32 && ./tryulong32 ) >/dev/null 2>&1 \ -&& cat uint32.h2 || cat uint32.h1 -rm -f tryulong32.o tryulong32 -formake '( ( ./compile tryulong32.c && ./load tryulong32 && ./tryulong32 ) >/dev/null 2>&1 \' -formake '&& cat uint32.h2 || cat uint32.h1 ) > uint32.h' -formake 'rm -f tryulong32.o tryulong32' @@ -0,0 +1,93 @@ +.TH wait 3 +.SH NAME +wait \- check child process status +.SH SYNTAX +.B #include <wait.h> + +int \fBwait_nohang\fP(&\fIwstat\fR); +.br +int \fBwait_stop\fP(&\fIwstat\fR); +.br +int \fBwait_stopnohang\fP(&\fIwstat\fR); +.br +int \fBwait_pid\fP(&\fIwstat\fR,\fIpid\fR); + +int \fBwait_exitcode\fP(\fIwstat\fR); +.br +int \fBwait_crashed\fP(\fIwstat\fR); +.br +int \fBwait_stopped\fP(\fIwstat\fR); +.br +int \fBwait_stopsig\fP(\fIwstat\fR); + +int \fIpid\fR; +.br +int \fIwstat\fR; +.SH DESCRIPTION +.B wait_nohang +looks for zombies (child processes that have exited). +If it sees a zombie, +it eliminates the zombie, +puts the zombie's exit status into +.IR wstat , +and returns the zombie's process ID. +If there are several zombies, +.B wait_nohang +picks one. +If there are children but no zombies, +.B wait_nohang +returns 0. +If there are no children, +.B wait_nohang +returns -1, +setting +.B errno +appropriately. + +.B wait_stopnohang +is similar to +.BR wait_nohang , +but it also looks for children that have stopped. + +.B wait_stop +is similar to +.BR wait_stopnohang , +but if there are children it will pause waiting for one of them +to stop or exit. + +.B wait_pid +waits for child process +.I pid +to exit. +It eliminates any zombie that shows up in the meantime, +discarding the exit status. + +.B wait_stop +and +.B wait_pid +retry upon +.BR error_intr . +.SH "STATUS PARSING" +If the child stopped, +.B wait_stopped +is nonzero; +.B wait_stopsig +is the signal that caused the child to stop. + +If the child exited by crashing, +.B wait_stopped +is zero; +.B wait_crashed +is nonzero. + +If the child exited normally, +.B wait_stopped +is zero; +.B wait_crashed +is zero; +and +.B wait_exitcode +is the child's exit code. +.SH "SEE ALSO" +wait(2), +error(3) @@ -1 +0,0 @@ -wait_nohang.o diff --git a/wait_pid.c b/wait_pid.c new file mode 100644 index 0000000..d7a7e84 --- /dev/null +++ b/wait_pid.c @@ -0,0 +1,39 @@ +#include <sys/types.h> +#include <sys/wait.h> +#include "error.h" +#include "haswaitp.h" + +#ifdef HASWAITPID + +int wait_pid(wstat,pid) int *wstat; int pid; +{ + int r; + + do + r = waitpid(pid,wstat,0); + while ((r == -1) && (errno == error_intr)); + return r; +} + +#else + +/* XXX untested */ +/* XXX breaks down with more than two children */ +static int oldpid = 0; +static int oldwstat; /* defined if(oldpid) */ + +int wait_pid(wstat,pid) int *wstat; int pid; +{ + int r; + + if (pid == oldpid) { *wstat = oldwstat; oldpid = 0; return pid; } + + do { + r = wait(wstat); + if ((r != pid) && (r != -1)) { oldwstat = *wstat; oldpid = r; continue; } + } + while ((r == -1) && (errno == error_intr)); + return r; +} + +#endif @@ -0,0 +1,32 @@ +.TH who@ 1 +.SH NAME +who@ \- print list of active users on a host +.SH SYNTAX +.B who@ +[ +.I host +] +.SH DESCRIPTION +.B who@ +connects to TCP port 11 (Systat) on +.I host +and prints any data it receives. +It removes CR and converts unprintable characters to a visible format. + +If +.I host +is not supplied, +.B who@ +connects to the local host. + +Some computers respond to port 11 with a list of active users. +For example, they may be running + +.EX + tcpserver 0 11 who & +.EE +.SH "SEE ALSO" +cat(1), +delcr(1), +tcpclient(1), +tcpserver(1) @@ -1 +1 @@ -BIN/tcpclient -RHl0 -- "${1-0}" 11 sh -c 'exec BIN/delcr <&6' | cat -v +HOME/bin/tcpclient -RHl0 -- "${1-0}" 11 sh -c 'exec HOME/bin/delcr <&6' | cat -v |