diff options
author | Philip Hands <phil@hands.com> | 1998-05-01 09:24:49 +0100 |
---|---|---|
committer | Dmitry Bogatov <KAction@debian.org> | 2018-11-29 05:18:27 +0000 |
commit | d8b11a9d5de0d037ac13d39c22608fe1f56fbaa0 (patch) | |
tree | 3079b405d59e9b6788879945a3746ae327e1342a | |
parent | 78fbb41eaf3abb208abe6acfb06db005adeadf35 (diff) |
Import Debian changes 0.80-3
ucspi-tcp (0.80-3) unstable; urgency=low
* fix the distribution, from non-free, to unstable
ucspi-tcp (0.80-2) non-free; urgency=low
* tidy up rules file, so no hand editing of .changes is needed to exclude
the non-distributable binary file
* get rid of dependancy on debmake
ucspi-tcp (0.80-1) non-free; urgency=low
* new package
* includes tcpserver with RBL support (see: http://www.qmail.org/rbl/)
-rw-r--r-- | addcr.1 | 21 | ||||
-rw-r--r-- | conf-bin | 2 | ||||
-rw-r--r-- | conf-cc | 2 | ||||
-rw-r--r-- | conf-ld | 2 | ||||
-rw-r--r-- | conf-man | 2 | ||||
-rw-r--r-- | debian/README-src | 9 | ||||
-rw-r--r-- | debian/build-PACKAGE | 195 | ||||
-rw-r--r-- | debian/changelog | 25 | ||||
-rw-r--r-- | debian/control | 31 | ||||
-rw-r--r-- | debian/control.real | 62 | ||||
-rw-r--r-- | debian/copyright | 48 | ||||
-rw-r--r-- | debian/postrm | 6 | ||||
-rw-r--r-- | debian/preinst | 6 | ||||
-rwxr-xr-x | debian/rules | 115 | ||||
-rw-r--r-- | debian/src.postinst | 12 | ||||
-rw-r--r-- | delcr.1 | 21 | ||||
-rw-r--r-- | dns.c | 72 | ||||
-rw-r--r-- | tcpserver.1 | 12 | ||||
-rw-r--r-- | tcpserver.c | 17 |
19 files changed, 649 insertions, 11 deletions
@@ -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>. + @@ -1,3 +1,3 @@ -/usr/local/bin +/usr/bin Programs will be installed in this directory. @@ -1,3 +1,3 @@ -cc -O2 +cc -O2 -g This will be used to compile .c files. @@ -1,3 +1,3 @@ -cc -s +cc This will be used to link .o files into an executable. @@ -1,4 +1,4 @@ -/usr/local/man +/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 diff --git a/debian/README-src b/debian/README-src new file mode 100644 index 0000000..2d69751 --- /dev/null +++ b/debian/README-src @@ -0,0 +1,9 @@ +This is a feeble little package that just contains a script to unpack +and build #PACKAGE# from source, so that we don't violate Dan Bernstein's +`no binary distribution, without approval' restriction. + +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> diff --git a/debian/build-PACKAGE b/debian/build-PACKAGE new file mode 100644 index 0000000..94fa949 --- /dev/null +++ b/debian/build-PACKAGE @@ -0,0 +1,195 @@ +#!/bin/bash -e +# +# build-<package> +# +# $Id: build-PACKAGE,v 1.5 1998/05/01 08:35:36 phil Exp $ +# +# Written by Philip Hands <phil@hands.com> +# Copyright (C) 1998 Free Software Foundation, Inc. +# Copying: GPL + +# ask_user --- function prompts the user with y/n style prompt +# +# It's behaviour is controlled via the parameters: +# 1 - the initial prompt +# 2 - default return value (set to 0, 1 or "none") +# 3 - the patern match for acceptable Yes responses +# 4 - the patern match for acceptable No responses +# 5 - the error prompt, displayed when the user fails to provide valid input +# +# e.g. ask_user "Foo, or Bar [fb] " none '[fF]*' '[bB]*' "try again" + +ask_user() { + P=${1:-'Should I do this ? [yN] '} + D=${2:-1} + Y=${3:-'[yY]*'} + N=${4:-'[nN]*'} + E=${5:-'\nPlease enter either y)es or n)o, followed by <RETURN>\n'} + + while true ; do + echo -ne "$P" + read response + case "$response" in + ${Y} ) return 0 ;; + ${N} ) return 1 ;; + "" ) [ "$D" = 0 -o "$D" = 1 ] && return $D ;; + esac + echo -e $E + done +} + +package=${0##*build-} +NEWDIR=/tmp/$package + +cat <<!END! + +This script unpacks the ${package} source into a directory, and +compiles it to produce a binary ${package}*.deb file. + +The directory where this is done will end up containing the source +and package files for the $package binary package, along with a +directory containing the unpacked source. + +!END! + +line=kjfdsh +read -e -p "Enter a directory where you would like to do this [$NEWDIR] " line +NEWDIR="${line:-$NEWDIR}" + +if test -d $NEWDIR +then + ask_user "$NEWDIR already exists, should I use it anyway ? [yN] " || { + echo -e "\nPlease fix it and run $0 again\n" + exit 1 + } +else + mkdir $NEWDIR +fi + +cd $NEWDIR +dpkg-source -x /usr/src/${package}-src/${package}_*.dsc +cd ${package}-* + +CANBEROOT=no +SU="" +if [ 0 = `id -u` ] +then + BUILDROOT="" + CANBEROOT=yes +else + hash fakeroot 2>/dev/null && HAVE_FAKEROOT=fakeroot || HAVE_FAKEROOT="" + hash sudo 2>/dev/null && HAVE_SUDO=sudo || HAVE_SUDO="" + if [ -n "$HAVE_FAKEROOT" -a -n "$HAVE_SUDO" ] + then + echo "" + if ask_user "Should I use sudo or fakeroot to build the package ? [sF] " 1 '[sS]*' '[fF]*' "\nPlease enter either s)udo or f)akeroot, followed by <RETURN>\n" + then + BUILDROOT=sudo + else + BUILDROOT=fakeroot + fi + elif [ -n "$HAVE_FAKEROOT" -o -n "$HAVE_SUDO" ] + then + BUILDROOT="${HAVE_FAKEROOT:-$HAVE_SUDO}" + else + # sanity check, dependencies should provide one of them + echo "" + echo 'oops! you have not installed fakeroot or sudo!' + echo "" + exit 1 + fi + + if [ -n "$HAVE_SUDO" ] + then + cat<<!END! + +In addition to building the package, there are certain other actions that +you may want me to do (i.e. installing the new package) that need real root +access. If you want, I can a achieve this by use of sudo. + +In each case, you will be prompted before I attempt one of these actions + +!END! + if ask_user "Should I use sudo to gain real root access when required ? [Yn] " 0 + then + SU=sudo + CANBEROOT=yes + fi + fi +fi + +echo "" +cd $NEWDIR +dpkg-source -x /usr/src/${package}-src/${package}*.dsc +cd ${package}-* + +echo "" +echo "Binary package $package will be compiled now" +echo "This can take long time, depending on your machine" +echo "" +echo -n "Press ENTER to continue..." +read blah + +$BUILDROOT debian/rules binary-arch + +cd .. + +if [ -f ${package}*.deb ] +then + echo "" + echo "It seems that all went ok" + echo "" +else + echo "" + echo "Some error happened, stopping here." + echo "" + exit 1 +fi + +if ask_user "Do you want to remove all files in $NEWDIR,\nexcept `echo ${package}*.deb` now? [Yn] " 0 +then + [ "$BUILDROOT" = sudo ] && ROOT4RM=sudo + echo -n "Removing files... " + $ROOT4RM rm -rf ./${package}-*/ + $ROOT4RM rm -f ./${package}*{.dsc,.diff.gz,.orig.tar.gz} + echo "done" +fi + +echo "" + +if [ "$CANBEROOT" = yes ] +then + if ask_user "Do you want to install `echo ${package}*.deb` now? [Yn] " 0 + then + $SU dpkg --install ${package}*.deb || true + fi +else + echo "`echo ${package}*.deb` is in $NEWDIR" + echo "You have to execute the following to install it, being root:" + echo "" + echo " dpkg --install `echo ${package}*.deb`" +fi + +echo "" + +if [ "$CANBEROOT" = yes ] +then + if ask_user "Do you want to purge ${package}-src now? [yN] " 1 + then + $SU dpkg --purge ${package}-src || true + fi +else + echo "" + echo "You can now remove package ${package}-src running as root" + echo "" + echo " dpkg --remove ${package}-src" +fi + +echo "" +echo "Remember that you can install `echo ${package}*.deb`" +echo "on other computers so you don't need to compile it again." +echo "" +echo 'Good luck!' +echo "" + +exit 0 diff --git a/debian/changelog b/debian/changelog new file mode 100644 index 0000000..851cd0b --- /dev/null +++ b/debian/changelog @@ -0,0 +1,25 @@ +ucspi-tcp (0.80-3) unstable; urgency=low + + * fix the distribution, from non-free, to unstable + + -- Philip Hands <phil@hands.com> Fri, 1 May 1998 09:24:49 +0100 + +ucspi-tcp (0.80-2) non-free; urgency=low + + * tidy up rules file, so no hand editing of .changes is needed to exclude + the non-distributable binary file + * get rid of dependancy on debmake + + -- Philip Hands <phil@hands.com> Fri, 20 Mar 1998 12:01:47 +0000 + +ucspi-tcp (0.80-1) non-free; urgency=low + + * new package + * includes tcpserver with RBL support (see: http://www.qmail.org/rbl/) + + -- Philip Hands <phil@hands.com> Sat, 14 Mar 1998 11:43:56 +0000 + +Local variables: +mode: debian-changelog +add-log-mailing-address: "phil@hands.com" +End: diff --git a/debian/control b/debian/control new file mode 100644 index 0000000..97987c8 --- /dev/null +++ b/debian/control @@ -0,0 +1,31 @@ +Source: ucspi-tcp +Section: non-free/net +Priority: optional +Maintainer: Philip Hands <phil@hands.com> +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 +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 + inetd. + . + Real-time Blocking List support is also included in tcpserver, so + you can run qmail-smtpd with it and avoid a lot of SPAM. + . + tcpclient and tcpserver conform to UCSPI, the UNIX Client-Server + Program Interface, using the TCP protocol. + . + Dan Bernstein (ucspi-tcp's author) only gives permission for his code + to be distributed in source form, or binary by approval. This package + has been put together to allow people to easily build a binary + package for themselves, from source. + . + If there is a package called ucspi-tcp available, then Dan has approved the + binary version of the package for distribution, so you might as well install + that and save yourself some effort. diff --git a/debian/control.real b/debian/control.real new file mode 100644 index 0000000..086cf9b --- /dev/null +++ b/debian/control.real @@ -0,0 +1,62 @@ +Source: ucspi-tcp +Section: non-free/net +Priority: optional +Maintainer: Philip Hands <phil@hands.com> +Standards-Version: 2.4.0.0 + +Package: ucspi-tcp +Architecture: any +Depends: ${shlibs:Depends} +Description: tools for building TCP client-server applications. + 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 + inetd. + . + Real-time Blocking List support is also included in tcpserver, so + you can run qmail-smtpd with it and avoid a lot of SPAM. + . + tcpclient and tcpserver conform to UCSPI, the UNIX Client-Server + Program Interface, using the TCP protocol. + . + Note that this package cannot be distributed it in + binary form without Dan Bernstein's permission. + +Package: ucspi-tcp-misc +Architecture: all +Depends: ucspi-tcp, multitee +Description: misc tools using ucspi tcpclient + Includes the following shell scripts: who@, date@, finger@, + tcpcat and mconnect. All of them use tcpclient for building tcp + conections. + . + Note that this package cannot be distributed it in + binary form without Dan Bernstein's permission. + +Package: ucspi-tcp-src +Architecture: all +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 + inetd. + . + Real-time Blocking List support is also included in tcpserver, so + you can run qmail-smtpd with it and avoid a lot of SPAM. + . + tcpclient and tcpserver conform to UCSPI, the UNIX Client-Server + Program Interface, using the TCP protocol. + . + Dan Bernstein (ucspi-tcp's author) only gives permission for his code + to be distributed in source form, or binary by approval. This package + has been put together to allow people to easily build a binary + package for themselves, from source. + . + If there is a package called ucspi-tcp available, then Dan has approved the + binary version of the package for distribution, so you might as well install + that and save yourself some effort. diff --git a/debian/copyright b/debian/copyright new file mode 100644 index 0000000..ffec82d --- /dev/null +++ b/debian/copyright @@ -0,0 +1,48 @@ +This is the Debian GNU/Linux version of ucspi-tcp, a set of +command-line tools for building TCP client-server applications, +packaged by Philip Hands <phil@hands.com> with help from +Roberto Lumbreras <rover@debian.org>. + +This package provides "tcpserver-rbl", which includes RBL support. +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 + +Changes for Debian: + * added Debian GNU/Linux package maintenance system files + * added manual pages for addcr/delcr + +Copyrights +---------- + +* ucspi-tcp: +Copyright (C) 1998 D. J. Bernstein <djb@pobox.com> + +* modifications for Debian: + Copyright (C) 1998 Software in the Public Interest <http://www.debian.org> + + +License +------- + +* ucspi-tcp: + +Like any other piece of software (and information generally), ucspi-tcp +comes with NO WARRANTY. + +Dan Bernstein grants any use of ucspi-tcp, including patching and +distributing diffs; but he doesn't allow binary distributions +without his approval. See http://pobox.com/~djb/softwarelaw.html + +* Modifications for Debian: + +GPL. + +A copy of the GNU General Public License is available as +`/usr/doc/copyright/GPL' in the Debian GNU/Linux distribution or on +the World Wide Web at `http://www.gnu.org/copyleft/gpl.html'. You can +also obtain it by writing to the Free Software Foundation, Inc., 59 +Temple Place - Suite 330, Boston, MA 02111-1307, USA diff --git a/debian/postrm b/debian/postrm new file mode 100644 index 0000000..7c4528e --- /dev/null +++ b/debian/postrm @@ -0,0 +1,6 @@ +#!/bin/sh + +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 diff --git a/debian/preinst b/debian/preinst new file mode 100644 index 0000000..3fff412 --- /dev/null +++ b/debian/preinst @@ -0,0 +1,6 @@ +#!/bin/sh + +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 diff --git a/debian/rules b/debian/rules new file mode 100755 index 0000000..84dfad9 --- /dev/null +++ b/debian/rules @@ -0,0 +1,115 @@ +#!/usr/bin/make -f +# +# Copyright (C) 1998 Software in the Public Interest <www.debian.org> + +SHELL = /bin/bash + +BINS = tcpserver tcpclient tcprules addcr delcr + +SHBINS = who@ date@ finger@ tcpcat mconnect + +MAN1 = tcpclient.1 tcpserver.1 tcprules.1 addcr.1 delcr.1 + +MAN5 = tcp-environ.5 + +DOCS = BLURB README TCP THANKS TODO UCSPI + +PACKAGE = $(shell perl -e 'print <> =~ /(\S*)\s/' debian/changelog) +PKG_VER = $(shell perl -e 'print <> =~ /\((.*)\)/' debian/changelog) +PKG_UPVER = $(shell perl -e 'print <> =~ /\((.*)-[^-]*\)/' debian/changelog) + +TMPSRC = debian/tmp-src + +build: + $(MAKE) + touch build + +clean: checkdir debian/control + rm -f build debian/files debian/substvars + rm -f $(BINS) $(SHBINS) + rm -f *.o *.a *.0 + 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 + 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 \ + -name TAGS -o -name core \) -exec rm -f {} \; + +binary-indep: checkroot build + rm -rf debian/misc + install -d -m 0755 debian/misc/{DEBIAN,usr/{bin,doc}} + install -m 0755 $(SHBINS) debian/misc/usr/bin/ + ln -s ucspi-tcp debian/misc/usr/doc/ucspi-tcp-misc + + dpkg-gencontrol -pucspi-tcp-misc -Pdebian/misc -cdebian/control.real + chown -R root.root debian/misc + dpkg --build debian/misc .. + +binary-arch: checkroot build + rm -rf debian/tmp + install -d -m 0755 debian/tmp/{DEBIAN,usr/{bin,man/man{1,5},doc/ucspi-tcp}} + 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/ + gzip -9fr debian/tmp/usr/doc/ debian/tmp/usr/man/ + install -m 0644 debian/copyright debian/tmp/usr/doc/ucspi-tcp/copyright + install -p -m 0755 debian/postrm debian/preinst debian/tmp/DEBIAN + + dpkg-shlibdeps $(BINS) + dpkg-gencontrol -pucspi-tcp -cdebian/control.real + chown -R root.root debian/tmp + dpkg --build debian/tmp .. + +binary-src: checkroot checkdir debian/control ../$(PACKAGE)_$(PKG_UPVER).orig.tar.gz \ +../$(PACKAGE)_$(PKG_VER).dsc ../$(PACKAGE)_$(PKG_VER).diff.gz + -rm -rf $(TMPSRC) debian/files + + install -d $(TMPSRC)/DEBIAN \ + $(TMPSRC)/usr/bin \ + $(TMPSRC)/usr/src/$(PACKAGE)-src \ + $(TMPSRC)/usr/doc/$(PACKAGE)-src + install -m 755 debian/build-PACKAGE $(TMPSRC)/usr/bin/build-$(PACKAGE) + install -m 0644 ../$(PACKAGE)_$(PKG_UPVER).orig.tar.gz \ + ../$(PACKAGE)_$(PKG_VER).dsc \ + ../$(PACKAGE)_$(PKG_VER).diff.gz \ + $(TMPSRC)/usr/src/$(PACKAGE)-src/ + sed -e "s/#PACKAGE#/$(PACKAGE)/" debian/src.postinst > $(TMPSRC)/DEBIAN/postinst + chmod 755 $(TMPSRC)/DEBIAN/postinst + sed -e "s/#PACKAGE#/$(PACKAGE)/" debian/README-src > $(TMPSRC)/usr/doc/$(PACKAGE)-src/README.Debian + install -m 0644 debian/changelog $(TMPSRC)/usr/doc/$(PACKAGE)-src/changelog.Debian + chmod 644 $(TMPSRC)/usr/doc/$(PACKAGE)-src/changelog.Debian + gzip -9fr $(TMPSRC)/usr/doc/ + install -m 0644 debian/copyright $(TMPSRC)/usr/doc/$(PACKAGE)-src/ + + dpkg-gencontrol -p$(PACKAGE)-src -P$(TMPSRC) + chown -R root.root $(TMPSRC) + dpkg --build $(TMPSRC) .. + +debian/control: debian/control.real + test -f debian/control.real && sed -e "/^Package: $(PACKAGE)-src$$/b" -e "/^Package: /,/^$$/d" debian/control.real > debian/control + +../$(PACKAGE)_$(PKG_UPVER).orig.tar.gz: + @{ echo "Error: $@ missing"; exit 1; } + +../$(PACKAGE)_$(PKG_VER).dsc ../$(PACKAGE)_$(PKG_VER).diff.gz: debian/rules + debian/rules clean + cd ..; dpkg-source -b $(PACKAGE)-$(PKG_UPVER) + +binary: binary-indep binary-arch binary-src + +source diff: + @echo >&2 'source and diff are obsolete - use dpkg-source -b'; false + +checkdir: + @test -f tcpserver.c -a -f debian/rules + +checkroot: checkdir + @test 0 = `id -u` || { echo "Error: not super-user"; exit 1; } + +.PHONY: binary binary-arch binary-indep clean checkroot checkdir + diff --git a/debian/src.postinst b/debian/src.postinst new file mode 100644 index 0000000..e7cbd04 --- /dev/null +++ b/debian/src.postinst @@ -0,0 +1,12 @@ +#!/bin/sh -e + +echo "" +echo "To build #PACKAGE# binary package, you have to run" +echo "" +echo " build-#PACKAGE#" +echo "" + +echo -n "Press ENTER to continue..." +read blah + +exit 0 @@ -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>. + @@ -104,6 +104,43 @@ 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; { @@ -219,9 +256,10 @@ stralloc *sa; #define FMT_IAA 40 -static int iaafmt(s,ip) +static int iaafmt(s,ip,dom) char *s; struct ip_address *ip; +const char *dom; { unsigned int i; unsigned int len; @@ -233,7 +271,7 @@ struct ip_address *ip; 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,".in-addr.arpa."); len += i; if (s) s += i; + i = fmt_str(s,dom); len += i; if (s) s += i; return len; } @@ -243,8 +281,8 @@ struct ip_address *ip; { int r; - if (!stralloc_ready(sa,iaafmt((char *) 0,ip))) return DNS_MEM; - sa->len = iaafmt(sa->s,ip); + if (!stralloc_ready(sa,iaafmt((char *) 0,ip,".in-addr.arpa."))) return DNS_MEM; + sa->len = iaafmt(sa->s,ip,".in-addr.arpa."); switch(resolve(sa,T_PTR)) { case DNS_MEM: return DNS_MEM; @@ -263,6 +301,32 @@ 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; diff --git a/tcpserver.1 b/tcpserver.1 index 77000d6..0f5ee5e 100644 --- a/tcpserver.1 +++ b/tcpserver.1 @@ -4,7 +4,7 @@ tcpserver \- accept incoming TCP connections .SH SYNOPSIS .B tcpserver [ -.B \-qQvdDoOpPhHrR1 +.B \-qQvdDoOpPhHrRsS1 ] [ .B \-c\fIlimit @@ -206,6 +206,16 @@ 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 diff --git a/tcpserver.c b/tcpserver.c index 3aa6f4e..02fff20 100644 --- a/tcpserver.c +++ b/tcpserver.c @@ -45,7 +45,7 @@ void usage() { if (verbosity) strerr_warn1("\ tcpserver: usage: \ -tcpserver [ -qQvdDoOpPhHrR1 ] \ +tcpserver [ -qQvdDoOpPhHrRsS1 ] \ [ -xrules.cdb ] \ [ -bbacklog ] [ -climit ] [ -ttimeout ] [ -llocalname ] [ -ggid ] [ -uuid ] \ host port program",0); @@ -69,6 +69,7 @@ char *s; char strnum[FMT_ULONG]; char strnum2[FMT_ULONG]; stralloc tmp = {0}; +stralloc tmp1 = {0}; ipalloc ia = {0}; unsigned long numchildren = 0; @@ -224,6 +225,7 @@ 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; @@ -246,7 +248,7 @@ char **argv; struct servent *se; int j; - while ((opt = getopt(argc,argv,"dDvqQhHrR1x:t:u:g:l:b:c:pPoO")) != opteof) + while ((opt = getopt(argc,argv,"dDvqQhHrRsS1x:t:u:g:l:b:c:pPoO")) != opteof) switch(opt) { case 'b': scan_ulong(optarg,&backlog); break; case 'c': scan_ulong(optarg,&limit); break; @@ -264,6 +266,8 @@ 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; @@ -448,6 +452,15 @@ 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) |