[packages/ucspi-tcp] - rediff mysql patch - add fixes from Gentoo
baggins
baggins at pld-linux.org
Tue Aug 25 23:47:59 CEST 2026
commit 0ad53dce2acded3e4702b4c7356c64246daa5d8d
Author: Jan Rękorajski <baggins at pld-linux.org>
Date: Tue Aug 25 23:46:15 2026 +0200
- rediff mysql patch
- add fixes from Gentoo
ar-ranlib.patch | 27 ++
bigendian.patch | 18 ++
implicit-int-ipv6.patch | 11 +
protos-ipv6.patch | 89 ++++++
protos.patch | 555 +++++++++++++++++++++++++++++++++++
protype-alloc.patch | 34 +++
rblsmtpd-ignore-on-RELAYCLIENT.patch | 25 ++
tcprules.patch | 16 +
ucspi-tcp-0.88-mysql.patch | 361 +++++++++++++++++++++++
ucspi-tcp-0.88-mysql.patch.pld | 422 --------------------------
ucspi-tcp.spec | 35 ++-
uint-headers.patch | 133 +++++++++
12 files changed, 1298 insertions(+), 428 deletions(-)
---
diff --git a/ucspi-tcp.spec b/ucspi-tcp.spec
index 4ea03b5..e5a7dda 100644
--- a/ucspi-tcp.spec
+++ b/ucspi-tcp.spec
@@ -15,9 +15,21 @@ Source0: https://cr.yp.to/ucspi-tcp/%{name}-%{version}.tar.gz
Source1: ftp://ftp.innominate.org/pub/pape/djb/%{name}-%{version}-man.tar.gz
# Source1-md5: 693be34da89cd5244cef8ae30b4dc6a4
Source2: daemontools-tcprules
-Patch0: %{name}-%{version}-mysql.patch.pld
-Patch1: %{name}-glibc.patch
-Patch2: http://lamer.maexotic.de/maex/creative/software/ucspi-tcp/0.88-recordio/recordio.diff
+Patch0: http://lamer.maexotic.de/maex/creative/software/ucspi-tcp/0.88-recordio/recordio.diff
+Patch1: http://www.fefe.de/ucspi/ucspi-tcp-0.88-ipv6.diff20.bz2
+Patch2: http://qmail.org/ucspi-rss.diff
+Patch3: %{name}-%{version}-mysql.patch
+Patch4: %{name}-glibc.patch
+Patch5: protos.patch
+Patch6: protos-ipv6.patch
+Patch7: tcprules.patch
+Patch8: bigendian.patch
+Patch9: implicit-int-ipv6.patch
+Patch10: rblsmtpd-ignore-on-RELAYCLIENT.patch
+Patch12: uint-headers.patch
+Patch13: ar-ranlib.patch
+Patch14: implicit-int.patch
+Patch15: protype-alloc.patch
URL: https://cr.yp.to/ucspi-tcp.html
%{?with_mysql:BuildRequires: mysql-devel}
# make and stat from coreutils are for building tcprules
@@ -40,12 +52,23 @@ inetd z małymi dodatkami.
%prep
%setup -q -a1
%{__mv} ucspi-tcp-%{version}-man man
-%{?with_mysql:%patch -P0 -p0}
-%patch -P1 -p0
+%patch -P1 -p1
%patch -P2 -p1
+%{?with_mysql:%patch -P3 -p1}
+%patch -P4 -p0
+%patch -P5 -p1
+%patch -P6 -p1
+%patch -P7 -p1
+%patch -P8 -p1
+%patch -P9 -p1
+%patch -P10 -p1
+%patch -P12 -p1
+%patch -P13 -p1
+%patch -P14 -p1
+%patch -P15 -p1
%build
-echo "%{__cc} %{rpmcflags} %{?with_mysql:-I%{_includedir}/mysql}" > conf-cc
+echo "%{__cc} %{rpmcflags} -std=gnu17 %{?with_mysql:-I%{_includedir}/mysql}" > conf-cc
echo "%{_prefix}" > conf-home
%{__make}
diff --git a/ar-ranlib.patch b/ar-ranlib.patch
new file mode 100644
index 0000000..e6c8ba3
--- /dev/null
+++ b/ar-ranlib.patch
@@ -0,0 +1,27 @@
+--- a/Makefile
++++ b/Makefile
+@@ -394,12 +394,14 @@
+ ) > load
+ chmod 755 load
+
++AR ?= ar
++RANLIB ?= ranlib
+ makelib: \
+ warn-auto.sh systype
+ ( cat warn-auto.sh; \
+ echo 'main="$$1"; shift'; \
+ echo 'rm -f "$$main"'; \
+- echo 'ar cr "$$main" $${1+"$$@"}'; \
++ echo '$(AR) cr "$$main" $${1+"$$@"}'; \
+ case "`cat systype`" in \
+ sunos-5.*) ;; \
+ unix_sv*) ;; \
+@@ -408,7 +410,7 @@
+ dgux-*) ;; \
+ hp-ux-*) ;; \
+ sco*) ;; \
+- *) echo 'ranlib "$$main"' ;; \
++ *) echo '$(RANLIB) "$$main"' ;; \
+ esac \
+ ) > makelib
+ chmod 755 makelib
diff --git a/bigendian.patch b/bigendian.patch
new file mode 100644
index 0000000..c5884b8
--- /dev/null
+++ b/bigendian.patch
@@ -0,0 +1,18 @@
+https://bugs.gentoo.org/18892
+
+patch by Michael Hanselmann <hansmi at gentoo.org>
+
+--- a/tcpserver.c
++++ b/tcpserver.c
+@@ -422,7 +422,11 @@
+ se = getservbyname(x,"tcp");
+ if (!se)
+ strerr_die3x(111,FATAL,"unable to figure out port number for ",x);
++#if __BYTE_ORDER == __BIG_ENDIAN || BYTE_ORDER == BIG_ENDIAN
++ localport = ntohs(se->s_port);
++#else
+ uint16_unpack_big((char*)&se->s_port,&localport);
++#endif
+ }
+
+ if (!*argv) usage();
diff --git a/implicit-int-ipv6.patch b/implicit-int-ipv6.patch
new file mode 100644
index 0000000..aee400d
--- /dev/null
+++ b/implicit-int-ipv6.patch
@@ -0,0 +1,11 @@
+--- a/tryip6.c
++++ b/tryip6.c
+@@ -2,7 +2,7 @@
+ #include <sys/socket.h>
+ #include <netinet/in.h>
+
+-main() {
++int main() {
+ struct sockaddr_in6 sa;
+ sa.sin6_family = PF_INET6;
+ }
diff --git a/protos-ipv6.patch b/protos-ipv6.patch
new file mode 100644
index 0000000..7faa512
--- /dev/null
+++ b/protos-ipv6.patch
@@ -0,0 +1,89 @@
+rely on standard POSIX headers to fix globs of warnings
+
+requires 0.88-protos.patch first
+
+--- a/FILES
++++ b/FILES
+@@ -222,7 +222,6 @@ dns_nd6.c
+ dns_sortip6.c
+ fmt_xlong.c
+ ip6_fmt.c
+-ip6_scan.c
+ scan_0x.c
+ socket_accept6.c
+ socket_bind6.c
+--- a/TARGETS
++++ b/TARGETS
+@@ -177,7 +177,6 @@ dns_nd6.o
+ dns_sortip6.o
+ fmt_xlong.o
+ ip6_fmt.o
+-ip6_scan.o
+ scan_0x.o
+ socket_accept6.o
+ socket_bind6.o
+--- a/ip6.h
++++ b/ip6.h
+@@ -4,10 +4,10 @@
+ #include "byte.h"
+
+ extern unsigned int scan_ip6(const char *src,char *ip);
+-extern unsigned int fmt_ip6(char *dest,const char *ip);
++extern unsigned int ip6_fmt(char *dest,char ip[16]);
+
+ extern unsigned int scan_ip6_flat(const char *src,char *);
+-extern unsigned int fmt_ip6_flat(char *dest,const char *);
++extern unsigned int ip6_fmt_flat(char *dest,char[16]);
+
+ /*
+ ip6 address syntax: (h = hex digit), no leading '0' required
+--- a/remoteinfo6.c
++++ b/remoteinfo6.c
+@@ -1,3 +1,4 @@
++#include <unistd.h>
+ #include "fmt.h"
+ #include "buffer.h"
+ #include "socket.h"
+@@ -5,11 +6,12 @@
+ #include "iopause.h"
+ #include "timeoutconn.h"
+ #include "remoteinfo.h"
++#include "readwrite.h"
+
+ static struct taia now;
+ static struct taia deadline;
+
+-static int mywrite(int fd,char *buf,int len)
++static ssize_t mywrite(int fd,char *buf,int len)
+ {
+ iopause_fd x;
+
+@@ -27,7 +29,7 @@ static int mywrite(int fd,char *buf,int len)
+ return write(fd,buf,len);
+ }
+
+-static int myread(int fd,char *buf,int len)
++static ssize_t myread(int fd,char *buf,int len)
+ {
+ iopause_fd x;
+
+--- a/socket_tcp6.c
++++ b/socket_tcp6.c
+@@ -3,6 +3,7 @@
+ #include <sys/socket.h>
+ #include <netinet/in.h>
+ #include <errno.h>
++#include <unistd.h>
+ #include "ndelay.h"
+ #include "socket.h"
+ #include "haveip6.h"
+--- a/dns.h
++++ b/dns.h
+@@ -87,6 +87,7 @@ extern int dns_ip4_qualify(stralloc *,stralloc *,const stralloc *);
+ extern int dns_ip6_qualify_rules(stralloc *,stralloc *,const stralloc *,const stralloc *);
+ extern int dns_ip6_qualify(stralloc *,stralloc *,const stralloc *);
+
++extern int dns_name6(stralloc *,char [16]);
+ extern int dns_name6_domain(char *,char *);
+ #define DNS_NAME6_DOMAIN (4*16+11)
+
diff --git a/protos.patch b/protos.patch
new file mode 100644
index 0000000..552448f
--- /dev/null
+++ b/protos.patch
@@ -0,0 +1,555 @@
+rely on standard POSIX headers to fix globs of warnings
+
+--- a/tcprulescheck.c
++++ b/tcprulescheck.c
+@@ -1,3 +1,5 @@
++#include <unistd.h>
++
+ #include "byte.h"
+ #include "buffer.h"
+ #include "strerr.h"
+--- a/buffer.c
++++ b/buffer.c
+@@ -1,6 +1,6 @@
+ #include "buffer.h"
+
+-void buffer_init(buffer *s,int (*op)(),int fd,char *buf,unsigned int len)
++void buffer_init(buffer *s,ssize_t (*op)(),int fd,char *buf,unsigned int len)
+ {
+ s->x = buf;
+ s->fd = fd;
+--- a/buffer.h
++++ b/buffer.h
+@@ -1,6 +1,8 @@
+ #ifndef BUFFER_H
+ #define BUFFER_H
+
++#include <sys/types.h>
++
+ typedef struct buffer {
+ char *x;
+ unsigned int p;
+@@ -13,7 +15,7 @@ typedef struct buffer {
+ #define BUFFER_INSIZE 8192
+ #define BUFFER_OUTSIZE 8192
+
+-extern void buffer_init(buffer *,int (*)(),int,char *,unsigned int);
++extern void buffer_init(buffer *,ssize_t (*)(),int,char *,unsigned int);
+
+ extern int buffer_flush(buffer *);
+ extern int buffer_put(buffer *,char *,unsigned int);
+--- a/exit.h
++++ b/exit.h
+@@ -1,6 +1,6 @@
+ #ifndef EXIT_H
+ #define EXIT_H
+
+-extern void _exit();
++#include <unistd.h>
+
+ #endif
+--- a/install.c
++++ b/install.c
+@@ -1,3 +1,4 @@
++#include <sys/stat.h>
+ #include "buffer.h"
+ #include "strerr.h"
+ #include "error.h"
+--- a/readwrite.h
++++ b/readwrite.h
+@@ -1,7 +1,6 @@
+ #ifndef READWRITE_H
+ #define READWRITE_H
+
+-extern int read();
+-extern int write();
++#include <unistd.h>
+
+ #endif
+
+--- a/auto-str.c
++++ b/auto-str.c
+@@ -5,6 +5,7 @@
+ char bspace[256];
+ buffer b = BUFFER_INIT(write,1,bspace,sizeof bspace);
+
++#define puts _puts
+ void puts(char *s)
+ {
+ if (buffer_puts(&b,s) == -1) _exit(111);
+--- a/buffer.h
++++ b/buffer.h
+@@ -8,7 +8,7 @@ typedef struct buffer {
+ unsigned int p;
+ unsigned int n;
+ int fd;
+- int (*op)();
++ ssize_t (*op)();
+ } buffer;
+
+ #define BUFFER_INIT(op,fd,buf,len) { (buf), 0, (len), (fd), (op) }
+--- a/fd_copy.c
++++ b/fd_copy.c
+@@ -1,4 +1,5 @@
+ #include <fcntl.h>
++#include <unistd.h>
+ #include "fd.h"
+
+ int fd_copy(int to,int from)
+--- a/fd_move.c
++++ b/fd_move.c
+@@ -1,3 +1,4 @@
++#include <unistd.h>
+ #include "fd.h"
+
+ int fd_move(int to,int from)
+--- a/socket_tcp.c
++++ b/socket_tcp.c
+@@ -1,3 +1,4 @@
++#include <unistd.h>
+ #include <sys/types.h>
+ #include <sys/param.h>
+ #include <sys/socket.h>
+--- a/chkshsgr.c
++++ b/chkshsgr.c
+@@ -1,8 +1,9 @@
++#include <grp.h>
+ #include "exit.h"
+
+ main()
+ {
+- short x[4];
++ gid_t x[4];
+
+ x[0] = x[1] = 0;
+ if (getgroups(1,x) == 0) if (setgroups(1,x) == -1) _exit(1);
+--- a/prot.c
++++ b/prot.c
+@@ -1,10 +1,10 @@
+ #include "hasshsgr.h"
+ #include "prot.h"
+
+-int prot_gid(int gid)
++int prot_gid(gid_t gid)
+ {
+ #ifdef HASSHORTSETGROUPS
+- short x[2];
++ gid_t x[2];
+ x[0] = gid; x[1] = 73; /* catch errors */
+ if (setgroups(1,x) == -1) return -1;
+ #else
+@@ -13,7 +13,7 @@ int prot_gid(int gid)
+ return setgid(gid); /* _should_ be redundant, but on some systems it isn't */
+ }
+
+-int prot_uid(int uid)
++int prot_uid(uid_t uid)
+ {
+ return setuid(uid);
+ }
+--- a/prot.h
++++ b/prot.h
+@@ -1,7 +1,10 @@
+ #ifndef PROT_H
+ #define PROT_H
+
+-extern int prot_gid(int);
+-extern int prot_uid(int);
++#include <unistd.h>
++#include <grp.h>
++
++extern int prot_gid(gid_t);
++extern int prot_uid(uid_t);
+
+ #endif
+--- a/fixcrio.c
++++ b/fixcrio.c
+@@ -6,6 +6,7 @@
+ #include "exit.h"
+ #include "iopause.h"
+ #include "pathexec.h"
++#include "fd.h"
+
+ #define FATAL "fixcrio: fatal: "
+
+--- a/hier.c
++++ b/hier.c
+@@ -1,5 +1,9 @@
+ #include "auto_home.h"
+
++extern void h(char *, int, int, int);
++extern void d(char *, char *, int, int, int);
++extern void c(char *, char *, char *, int, int, int);
++
+ void hier()
+ {
+ h(auto_home,-1,-1,02755);
+--- a/mconnect-io.c
++++ b/mconnect-io.c
+@@ -1,3 +1,4 @@
++#include <signal.h>
+ #include "sig.h"
+ #include "wait.h"
+ #include "fork.h"
+@@ -12,7 +13,7 @@ buffer bout;
+ char inbuf[512];
+ buffer bin;
+
+-int myread(int fd,char *buf,int len)
++ssize_t myread(int fd,char *buf,int len)
+ {
+ buffer_flush(&bout);
+ return read(fd,buf,len);
+--- a/tcprules.c
++++ b/tcprules.c
+@@ -1,3 +1,4 @@
++#include <stdio.h>
+ #include "strerr.h"
+ #include "stralloc.h"
+ #include "getln.h"
+@@ -6,6 +7,8 @@
+ #include "fmt.h"
+ #include "byte.h"
+ #include "cdb_make.h"
++#include "open.h"
++#include "scan.h"
+
+ #define FATAL "tcprules: fatal: "
+
+--- a/pathexec_run.c
++++ b/pathexec_run.c
+@@ -1,3 +1,4 @@
++#include <unistd.h>
+ #include "error.h"
+ #include "stralloc.h"
+ #include "str.h"
+--- a/recordio.c
++++ b/recordio.c
+@@ -8,6 +8,7 @@
+ #include "fmt.h"
+ #include "iopause.h"
+ #include "pathexec.h"
++#include "fd.h"
+
+ #define FATAL "recordio: fatal: "
+
+--- a/seek_set.c
++++ b/seek_set.c
+@@ -1,7 +1,6 @@
++#include <unistd.h>
+ #include <sys/types.h>
+ #include "seek.h"
+
+-#define SET 0 /* sigh */
+-
+ int seek_set(int fd,seek_pos pos)
+-{ if (lseek(fd,(off_t) pos,SET) == -1) return -1; return 0; }
++{ if (lseek(fd,(off_t) pos,SEEK_SET) == -1) return -1; return 0; }
+--- a/socket_udp.c
++++ b/socket_udp.c
+@@ -2,6 +2,7 @@
+ #include <sys/param.h>
+ #include <sys/socket.h>
+ #include <netinet/in.h>
++#include <unistd.h>
+ #include "ndelay.h"
+ #include "socket.h"
+
+--- a/tcprulescheck.c
++++ b/tcprulescheck.c
+@@ -5,6 +5,7 @@
+ #include "strerr.h"
+ #include "env.h"
+ #include "rules.h"
++#include "open.h"
+
+ void found(char *data,unsigned int datalen)
+ {
+
+the prototypes are added near the top to avoid conflicts w/ipv6 patch
+
+--- a/socket.h
++++ b/socket.h
+@@ -3,6 +3,9 @@
+ #ifndef SOCKET_H
+ #define SOCKET_H
+
++extern int socket_tcpnodelay(int);
++extern int socket_ipoptionskill(int);
++
+ #include "uint16.h"
+ #include "uint32.h"
+
+--- a/remoteinfo.c
++++ b/remoteinfo.c
+@@ -1,3 +1,4 @@
++#include <unistd.h>
+ #include "fmt.h"
+ #include "buffer.h"
+ #include "socket.h"
+@@ -5,11 +6,12 @@
+ #include "iopause.h"
+ #include "timeoutconn.h"
+ #include "remoteinfo.h"
++#include "readwrite.h"
+
+ static struct taia now;
+ static struct taia deadline;
+
+-static int mywrite(int fd,char *buf,int len)
++static ssize_t mywrite(int fd,char *buf,int len)
+ {
+ iopause_fd x;
+
+@@ -27,7 +29,7 @@ static int mywrite(int fd,char *buf,int len)
+ return write(fd,buf,len);
+ }
+
+-static int myread(int fd,char *buf,int len)
++static ssize_t myread(int fd,char *buf,int len)
+ {
+ iopause_fd x;
+
+--- a/alloc.c
++++ b/alloc.c
+@@ -1,7 +1,5 @@
+ #include "alloc.h"
+ #include "error.h"
+-extern char *malloc();
+-extern void free();
+
+ #define ALIGNMENT 16 /* XXX: assuming that this alignment is enough */
+ #define SPACE 2048 /* must be multiple of ALIGNMENT */
+--- a/alloc.h
++++ b/alloc.h
+@@ -1,8 +1,10 @@
+ #ifndef ALLOC_H
+ #define ALLOC_H
+
+-extern /*@null@*//*@out@*/char *alloc();
+-extern void alloc_free();
++#include <stdlib.h>
++
++extern /*@null@*//*@out@*/char *alloc(unsigned int);
++extern void alloc_free(char *);
+ extern int alloc_re();
+
+ #endif
+--- a/buffer_0.c
++++ b/buffer_0.c
+@@ -1,7 +1,7 @@
+ #include "readwrite.h"
+ #include "buffer.h"
+
+-int buffer_0_read(fd,buf,len) int fd; char *buf; int len;
++ssize_t buffer_0_read(fd,buf,len) int fd; char *buf; int len;
+ {
+ if (buffer_flush(buffer_1) == -1) return -1;
+ return read(fd,buf,len);
+--- a/buffer_get.c
++++ b/buffer_get.c
+@@ -2,7 +2,7 @@
+ #include "byte.h"
+ #include "error.h"
+
+-static int oneread(int (*op)(),int fd,char *buf,unsigned int len)
++static int oneread(ssize_t (*op)(),int fd,char *buf,unsigned int len)
+ {
+ int r;
+
+--- a/buffer_put.c
++++ b/buffer_put.c
+@@ -3,7 +3,7 @@
+ #include "byte.h"
+ #include "error.h"
+
+-static int allwrite(int (*op)(),int fd,char *buf,unsigned int len)
++static int allwrite(ssize_t (*op)(),int fd,char *buf,unsigned int len)
+ {
+ int w;
+
+--- a/case.h
++++ b/case.h
+@@ -4,7 +4,7 @@
+ extern void case_lowers(char *);
+ extern void case_lowerb(char *,unsigned int);
+ extern int case_diffs(char *,char *);
+-extern int case_diffb(char *,unsigned int,char *);
++extern int case_diffb(const char *,unsigned int,const char *);
+ extern int case_starts(char *,char *);
+ extern int case_startb(char *,unsigned int,char *);
+
+--- a/case_diffb.c
++++ b/case_diffb.c
+@@ -1,6 +1,6 @@
+ #include "case.h"
+
+-int case_diffb(register char *s,register unsigned int len,register char *t)
++int case_diffb(register const char *s,register unsigned int len,const register char *t)
+ {
+ register unsigned char x;
+ register unsigned char y;
+--- a/open.h
++++ b/open.h
+@@ -1,10 +1,10 @@
+ #ifndef OPEN_H
+ #define OPEN_H
+
+-extern int open_read(char *);
+-extern int open_excl(char *);
+-extern int open_append(char *);
+-extern int open_trunc(char *);
+-extern int open_write(char *);
++extern int open_read(const char *);
++extern int open_excl(const char *);
++extern int open_append(const char *);
++extern int open_trunc(const char *);
++extern int open_write(const char *);
+
+ #endif
+--- a/open_read.c
++++ b/open_read.c
+@@ -2,5 +2,5 @@
+ #include <fcntl.h>
+ #include "open.h"
+
+-int open_read(char *fn)
++int open_read(const char *fn)
+ { return open(fn,O_RDONLY | O_NDELAY); }
+--- a/open_trunc.c
++++ b/open_trunc.c
+@@ -2,5 +2,5 @@
+ #include <fcntl.h>
+ #include "open.h"
+
+-int open_trunc(char *fn)
++int open_trunc(const char *fn)
+ { return open(fn,O_WRONLY | O_NDELAY | O_TRUNC | O_CREAT,0644); }
+--- a/open_write.c
++++ b/open_write.c
+@@ -2,5 +2,5 @@
+ #include <fcntl.h>
+ #include "open.h"
+
+-int open_write(char *fn)
++int open_write(const char *fn)
+ { return open(fn,O_WRONLY | O_NDELAY); }
+--- a/openreadclose.c
++++ b/openreadclose.c
+@@ -3,7 +3,7 @@
+ #include "readclose.h"
+ #include "openreadclose.h"
+
+-int openreadclose(char *fn,stralloc *sa,unsigned int bufsize)
++int openreadclose(const char *fn,stralloc *sa,unsigned int bufsize)
+ {
+ int fd;
+ fd = open_read(fn);
+--- a/openreadclose.h
++++ b/openreadclose.h
+@@ -3,6 +3,6 @@
+
+ #include "stralloc.h"
+
+-extern int openreadclose(char *,stralloc *,unsigned int);
++extern int openreadclose(const char *,stralloc *,unsigned int);
+
+ #endif
+--- a/stralloc.h
++++ b/stralloc.h
+@@ -7,7 +7,7 @@ GEN_ALLOC_typedef(stralloc,char,s,len,a)
+
+ extern int stralloc_ready(stralloc *,unsigned int);
+ extern int stralloc_readyplus(stralloc *,unsigned int);
+-extern int stralloc_copy(stralloc *,stralloc *);
++extern int stralloc_copy(stralloc *,const stralloc *);
+ extern int stralloc_cat(stralloc *,stralloc *);
+ extern int stralloc_copys(stralloc *,const char *);
+ extern int stralloc_cats(stralloc *,const char *);
+--- a/stralloc_copy.c
++++ b/stralloc_copy.c
+@@ -1,7 +1,7 @@
+ #include "byte.h"
+ #include "stralloc.h"
+
+-int stralloc_copy(stralloc *sato,stralloc *safrom)
++int stralloc_copy(stralloc *sato,const stralloc *safrom)
+ {
+ return stralloc_copyb(sato,safrom->s,safrom->len);
+ }
+--- a/taia.h
++++ b/taia.h
+@@ -19,7 +19,7 @@ extern double taia_frac(struct taia *);
+ extern void taia_add(struct taia *,struct taia *,struct taia *);
+ extern void taia_sub(struct taia *,struct taia *,struct taia *);
+ extern void taia_half(struct taia *,struct taia *);
+-extern int taia_less(struct taia *,struct taia *);
++extern int taia_less(const struct taia *,const struct taia *);
+
+ #define TAIA_PACK 16
+ extern void taia_pack(char *,struct taia *);
+--- a/taia_less.c
++++ b/taia_less.c
+@@ -2,7 +2,7 @@
+
+ /* XXX: breaks tai encapsulation */
+
+-int taia_less(struct taia *t,struct taia *u)
++int taia_less(const struct taia *t,const struct taia *u)
+ {
+ if (t->sec.x < u->sec.x) return 1;
+ if (t->sec.x > u->sec.x) return 0;
+--- a/uint32.h1
++++ b/uint32.h1
+@@ -5,7 +5,7 @@ typedef unsigned int uint32;
+
+ extern void uint32_pack(char *,uint32);
+ extern void uint32_pack_big(char *,uint32);
+-extern void uint32_unpack(char *,uint32 *);
+-extern void uint32_unpack_big(char *,uint32 *);
++extern void uint32_unpack(const char *,uint32 *);
++extern void uint32_unpack_big(const char *,uint32 *);
+
+ #endif
+--- a/uint32.h2
++++ b/uint32.h2
+@@ -5,7 +5,7 @@ typedef unsigned long uint32;
+
+ extern void uint32_pack(char *,uint32);
+ extern void uint32_pack_big(char *,uint32);
+-extern void uint32_unpack(char *,uint32 *);
+-extern void uint32_unpack_big(char *,uint32 *);
++extern void uint32_unpack(const char *,uint32 *);
++extern void uint32_unpack_big(const char *,uint32 *);
+
+ #endif
+--- a/uint32_unpack.c
++++ b/uint32_unpack.c
+@@ -1,6 +1,6 @@
+ #include "uint32.h"
+
+-void uint32_unpack(char s[4],uint32 *u)
++void uint32_unpack(const char s[4],uint32 *u)
+ {
+ uint32 result;
+
+@@ -15,7 +15,7 @@ void uint32_unpack(char s[4],uint32 *u)
+ *u = result;
+ }
+
+-void uint32_unpack_big(char s[4],uint32 *u)
++void uint32_unpack_big(const char s[4],uint32 *u)
+ {
+ uint32 result;
+
+--- ucspi-tcp-0.88/tcpserver.c~ 2026-08-25 01:44:47.000000000 +0200
++++ ucspi-tcp-0.88/tcpserver.c 2026-08-25 01:45:52.599936547 +0200
+@@ -1,6 +1,8 @@
+ #include <sys/types.h>
+ #include <sys/param.h>
+ #include <netdb.h>
++#include <stdio.h>
++#include <string.h>
+ #include "uint16.h"
+ #include "str.h"
+ #include "byte.h"
diff --git a/protype-alloc.patch b/protype-alloc.patch
new file mode 100644
index 0000000..5463f43
--- /dev/null
+++ b/protype-alloc.patch
@@ -0,0 +1,34 @@
+https://bugs.gentoo.org/919874
+fix -Wincompatible-pointer-types
+ error: passing argument 1 of 'alloc_free' from incompatible pointer type [-Wincompatible-pointer-types]
+ 66 | alloc_free(e);
+ | ^
+ | |
+ | char **
+
+diff --git a/alloc.c b/alloc.c
+index b7a3e67..4e258f4 100644
+--- a/alloc.c
++++ b/alloc.c
+@@ -21,7 +21,7 @@ unsigned int n;
+ }
+
+ void alloc_free(x)
+-char *x;
++void *x;
+ {
+ if (x >= space)
+ if (x < space + SPACE)
+diff --git a/alloc.h b/alloc.h
+index 24ef27e..680848e 100644
+--- a/alloc.h
++++ b/alloc.h
+@@ -4,7 +4,7 @@
+ #include <stdlib.h>
+
+ extern /*@null@*//*@out@*/char *alloc(unsigned int);
+-extern void alloc_free(char *);
++extern void alloc_free(void *);
+ extern int alloc_re();
+
+ #endif
diff --git a/rblsmtpd-ignore-on-RELAYCLIENT.patch b/rblsmtpd-ignore-on-RELAYCLIENT.patch
new file mode 100644
index 0000000..ccf6341
--- /dev/null
+++ b/rblsmtpd-ignore-on-RELAYCLIENT.patch
@@ -0,0 +1,25 @@
+--- a/rblsmtpd.c
++++ b/rblsmtpd.c
+@@ -195,6 +195,7 @@
+ {
+ int flagwantdefaultrbl = 1;
+ char *x;
++ char *y;
+ int opt;
+
+ ip_init();
+@@ -213,6 +214,13 @@
+ }
+ }
+
++ y = env_get("RELAYCLIENT");
++ if (y) {
++ if (!*y) {
++ decision = 1;
++ }
++ }
++
+ while ((opt = getopt(argc,argv,"bBcCt:r:a:")) != opteof)
+ switch(opt) {
+ case 'b': flagrblbounce = 1; break;
+
diff --git a/tcprules.patch b/tcprules.patch
new file mode 100644
index 0000000..2986fde
--- /dev/null
+++ b/tcprules.patch
@@ -0,0 +1,16 @@
+https://bugs.gentoo.org/90679
+
+patch by Michael Hanselmann <hansmi at gentoo.org>
+
+--- a/tcprules.c
++++ b/tcprules.c
+@@ -127,6 +127,9 @@
+ for (;;) {
+ int tmp;
+ tmp = byte_chr(x + colon,len - colon,':');
++ if (colon == 0 && tmp == len) {
++ strerr_die2x(111, FATAL, "Unable to find colon on non-empty line.");
++ }
+ colon += tmp;
+ if (colon == len) continue;
+ if (byte_equal(x+colon+1,4,"deny") || byte_equal(x+colon+1,5,"allow")) break;
diff --git a/ucspi-tcp-0.88-mysql.patch b/ucspi-tcp-0.88-mysql.patch
new file mode 100644
index 0000000..04a59a3
--- /dev/null
+++ b/ucspi-tcp-0.88-mysql.patch
@@ -0,0 +1,361 @@
+diff -urN ucspi-tcp-0.88/conf-cc ucspi-tcp-0.88.mysql/conf-cc
+--- ucspi-tcp-0.88/conf-cc 2000-03-18 16:18:42.000000000 +0100
++++ ucspi-tcp-0.88.mysql/conf-cc 2026-08-25 01:15:06.494920350 +0200
+@@ -1,3 +1,3 @@
+-gcc -O2
++gcc -O2 -I/usr/local/include/mysql
+
+ This will be used to compile .c files.
+diff -urN ucspi-tcp-0.88/conf-ld ucspi-tcp-0.88.mysql/conf-ld
+--- ucspi-tcp-0.88/conf-ld 2000-03-18 16:18:42.000000000 +0100
++++ ucspi-tcp-0.88.mysql/conf-ld 2026-08-25 01:15:06.494867580 +0200
+@@ -1,3 +1,3 @@
+-gcc -s
++gcc -s -I/usr/local/include/mysql -L/usr/local/lib/mysql -lmysqlclient
+
+ This will be used to link .o files into an executable.
+diff -urN ucspi-tcp-0.88/db.c ucspi-tcp-0.88.mysql/db.c
+--- ucspi-tcp-0.88/db.c 1970-01-01 01:00:00.000000000 +0100
++++ ucspi-tcp-0.88.mysql/db.c 2026-08-25 01:15:06.494677430 +0200
+@@ -0,0 +1,123 @@
++#include <stdio.h>
++#include <string.h>
++#include <unistd.h>
++#include <strings.h>
++#include <mysql.h>
++#include "db.h"
++
++/*
++server sql.mailserver.com
++port 3306
++database vpopmail
++table relay
++user vpopmail
++pass secret
++time 1800
++*/
++#define MAX_QUERY_STRING 160
++
++MYSQL *dbh=NULL;
++
++char db_database[256];
++char db_host[256];
++char db_table[256];
++char db_user[256];
++char db_password[256];
++int db_port=-1;
++int pop_timeout;
++
++extern int verbosity;
++
++int open_db(char *database, char *host, int port, char *username, char *password)
++{
++ MYSQL *tmp;
++
++ if (dbh != NULL) {
++ mysql_close(dbh);
++ dbh = NULL;
++ }
++ dbh = (MYSQL *)mysql_init(NULL);
++ if (dbh == NULL)
++ {
++ fprintf(stderr,"MYSQL Init Error:\n");
++ return -1;
++ }
++
++ tmp = mysql_real_connect(dbh, host, username, password, database, port, NULL,0);
++
++ if (!tmp)
++ {
++ fprintf(stderr,"MYSQL Error: %s\n",mysql_error(dbh));
++ return -1;
++ }
++
++ return 0;
++}
++
++int check_db(char *remoteip) {
++ char query[MAX_QUERY_STRING];
++ int num_rows = 0;
++ int ret = -1;
++ MYSQL_RES *res;
++
++ snprintf(query,MAX_QUERY_STRING,"SELECT timestamp FROM %s WHERE remote_ip='%s' AND timestamp>(UNIX_TIMESTAMP()-%d)", db_table, remoteip, pop_timeout);
++
++ ret = mysql_query(dbh,query);
++ res = mysql_store_result(dbh);
++ num_rows = mysql_affected_rows(dbh);
++ mysql_free_result(res);
++
++ if (ret) {
++ char err_str[256];
++
++ snprintf(err_str,255,"-%s-",mysql_error(dbh));
++ fprintf(stderr,"%s",err_str);
++ if(strstr("server has gone away",err_str)) {
++ db_close();
++ db_ping();
++
++ ret = mysql_query(dbh,query);
++ if (ret) {
++ return -1;
++ }
++ } else {
++ db_close();
++ db_ping();
++
++ ret = mysql_query(dbh,query);
++ if (ret) {
++ return -1;
++ }
++ }
++ }
++ if (verbosity >= 3) {
++ fprintf(stderr,"QUERY(err:%d/rows:%d): %s\n",ret,num_rows,query); /* */
++ }
++
++ if(num_rows>0) {
++ return 0;
++ } else {
++ return 1;
++ }
++}
++
++void db_close()
++{
++ mysql_close(dbh);
++ dbh=NULL;
++
++ if (verbosity >= 2) {
++ fprintf(stderr,"db_close() called!\n");
++ }
++}
++
++void db_ping()
++{
++ if(dbh==NULL || mysql_ping(dbh)) {
++ if (verbosity >= 2) {
++ fprintf(stderr,"db_ping() is re-calling open_db!\n");
++ }
++ open_db(db_database,db_host,db_port,db_user,db_password);
++ }
++}
++
+diff -urN ucspi-tcp-0.88/db.h ucspi-tcp-0.88.mysql/db.h
+--- ucspi-tcp-0.88/db.h 1970-01-01 01:00:00.000000000 +0100
++++ ucspi-tcp-0.88.mysql/db.h 2026-08-25 01:15:06.494718439 +0200
+@@ -0,0 +1,17 @@
++#ifndef _DB_
++#define _DB_
++
++extern char db_database[256];
++extern char db_host[256];
++extern char db_table[256];
++extern char db_user[256];
++extern char db_password[256];
++extern int db_port;
++extern int pop_timeout;
++
++int open_db(char *database, char *host, int port, char *username, char *password);
++int check_db(char *remoteip);
++void db_ping();
++void db_close();
++
++#endif
+diff -urN ucspi-tcp-0.88/Makefile ucspi-tcp-0.88.mysql/Makefile
+--- ucspi-tcp-0.88/Makefile 2000-03-18 16:18:42.000000000 +0100
++++ ucspi-tcp-0.88.mysql/Makefile 2026-08-25 01:15:06.494785099 +0200
+@@ -513,6 +513,10 @@
+ rules.h stralloc.h
+ ./compile rules.c
+
++db.o: \
++compile db.c db.h
++ ./compile db.c
++
+ scan_ulong.o: \
+ compile scan_ulong.c scan.h
+ ./compile scan_ulong.c
+@@ -742,18 +746,18 @@
+ ./compile tcprulescheck.c
+
+ tcpserver: \
+-load tcpserver.o rules.o remoteinfo6.o timeoutconn6.o cdb.a dns.a \
++load tcpserver.o rules.o db.o remoteinfo6.o timeoutconn6.o cdb.a dns.a \
+ time.a unix.a byte.a socket.lib
+- ./load tcpserver rules.o remoteinfo6.o timeoutconn6.o cdb.a \
++ ./load tcpserver rules.o db.o remoteinfo6.o timeoutconn6.o cdb.a \
+ dns.a time.a unix.a byte.a `cat socket.lib`
+
+ tcpserver.o: \
+ compile tcpserver.c uint16.h str.h byte.h fmt.h scan.h ip4.h fd.h \
+ exit.h env.h prot.h open.h wait.h readwrite.h stralloc.h gen_alloc.h \
+ alloc.h buffer.h error.h strerr.h sgetopt.h subgetopt.h pathexec.h \
+ socket.h uint16.h ndelay.h remoteinfo.h stralloc.h uint16.h rules.h \
+ stralloc.h sig.h dns.h stralloc.h iopause.h taia.h tai.h uint64.h \
+-taia.h uint32.h
++taia.h uint32.h db.h
+ ./compile tcpserver.c
+
+ time.a: \
+diff -urN ucspi-tcp-0.88/tcpserver.c ucspi-tcp-0.88.mysql/tcpserver.c
+--- ucspi-tcp-0.88/tcpserver.c 2000-03-18 16:18:42.000000000 +0100
++++ ucspi-tcp-0.88.mysql/tcpserver.c 2026-08-25 01:15:06.494546139 +0200
+@@ -25,13 +26,15 @@
+ #include "ndelay.h"
+ #include "remoteinfo.h"
+ #include "rules.h"
++#include "db.h"
+ #include "sig.h"
+ #include "dns.h"
+
+ int forcev6 = 0;
+ int verbosity = 1;
+ int flagkillopts = 1;
+ int flagdelay = 1;
++int usemysql = 0;
+ char *banner = "";
+ int flagremoteinfo = 1;
+ int flagremotehost = 1;
+@@ -109,6 +112,10 @@
+ {
+ strerr_die4sys(111,DROP,"unable to read ",fnrules,": ");
+ }
++void drop_db(void)
++{
++ strerr_die4sys(111,DROP,"unable to verify DB ",db_database,": ");
++}
+
+ void found(char *data,unsigned int datalen)
+ {
+@@ -198,8 +205,18 @@
+ env("TCPREMOTEINFO",flagremoteinfo ? tcpremoteinfo.s : 0);
+ env("TCP6REMOTEINFO",flagremoteinfo ? tcpremoteinfo.s : 0);
+
+- if (fnrules) {
++ if(usemysql) {
++ if(flagdeny==2) {
++ /* drop_db(); */
++ } else if(!flagdeny) {
++ env("RELAYCLIENT","");
++ }
++ flagdeny=0;
++ }
++
++ if(fnrules) {
+ int fdrules;
++
+ fdrules = open_read(fnrules);
+ if (fdrules == -1) {
+ if (errno != error_noent) drop_rules();
+@@ -240,7 +257,7 @@
+ {
+ strerr_warn1("\
+ tcpserver: usage: tcpserver \
+-[ -461UXpPhHrRoOdDqQv ] \
++[ -461UXpPhHrRoOdDqQvS ] \
+ [ -c limit ] \
+ [ -x rules.cdb ] \
+ [ -B banner ] \
+@@ -300,7 +317,7 @@
+ int s;
+ int t;
+
+- while ((opt = getopt(argc,argv,"46dDvqQhHrR1UXx:t:u:g:l:b:B:c:I:pPoO")) != opteof)
++ while ((opt = getopt(argc,argv,"46dDvqQhHrR1UXSx:t:u:g:l:b:B:c:I:pPoO")) != opteof)
+ switch(opt) {
+ case 'b': scan_ulong(optarg,&backlog); break;
+ case 'c': scan_ulong(optarg,&limit); break;
+@@ -327,6 +344,7 @@
+ case '4': noipv6 = 1; break;
+ case '6': forcev6 = 1; break;
+ case 'l': localhost = optarg; break;
++ case 'S': usemysql = 1; break;
+ default: usage();
+ }
+ argc -= optind;
+@@ -398,6 +416,7 @@
+ for (;;) {
+ while (numchildren >= limit) sig_pause();
+
++ flagdeny=0;
+ sig_unblock(sig_child);
+ t = socket_accept6(s,remoteip,&remoteport,&netif);
+ sig_block(sig_child);
+@@ -405,6 +424,76 @@
+ if (t == -1) continue;
+ ++numchildren; printstatus();
+
++ if(usemysql) {
++ int ret;
++
++ remoteipstr[ip4_fmt(remoteipstr,remoteip)] = 0;
++
++ if(db_port==-1) {
++ FILE *fp;
++
++ if(fp=fopen("/var/qmail/control/sql","r")) {
++ char line[256];
++ char tag[256];
++ char value[256];
++
++ while(fgets(line,256,fp)) {
++ char *comment;
++
++ if(comment=strchr(line,'#')) {
++ *comment='\0';
++ }
++ if(sscanf(line,"%s\t%s\n", tag, value) != 2) continue;
++ /* fprintf(stderr,"Warning: got Line: [%s]\n",line); */
++
++ /*
++ server sql.domain.com
++ port 3306
++ database vpopmail
++ table relay
++ user vpopmail
++ pass secret
++ time 1800
++ */
++ if(!strcasecmp(tag,"server")) {
++ strcpy(db_host,value);
++ } else if(!strcasecmp(tag,"port")) {
++ db_port = atoi(value);
++ } else if(!strcasecmp(tag,"database")) {
++ strcpy(db_database,value);
++ } else if(!strcasecmp(tag,"table")) {
++ strcpy(db_table,value);
++ } else if(!strcasecmp(tag,"user")) {
++ strcpy(db_user,value);
++ } else if(!strcasecmp(tag,"pass")) {
++ strcpy(db_password,value);
++ } else if(!strcasecmp(tag,"time")) {
++ pop_timeout=atoi(value);
++ } else {
++ fprintf(stderr,"Warning: Bad sql: TAG: [%s] VALUE: [%s]\n",tag,value);
++ }
++ }
++ }
++ if(db_port==-1) {
++ fprintf(stderr,"Error: Failed to read /var/qmail/control/sql\n");
++ db_port==-2;
++ } else {
++ fclose(fp);
++ }
++ if (verbosity >= 2) {
++ fprintf(stderr,"db_port set to: [%d]\n", db_port);
++ }
++ }
++ if(db_port>=0) {
++ db_ping();
++ if((ret=check_db(remoteipstr))==-1) {
++ flagdeny=2;
++ } else if(ret) {
++ flagdeny=1;
++ }
++ }
++ }
++
+ switch(fork()) {
+ case 0:
+ close(s);
diff --git a/ucspi-tcp-0.88-mysql.patch.pld b/ucspi-tcp-0.88-mysql.patch.pld
deleted file mode 100644
index ffc15f4..0000000
--- a/ucspi-tcp-0.88-mysql.patch.pld
+++ /dev/null
@@ -1,422 +0,0 @@
-*** tcpserver.c.orig Wed Mar 14 10:21:33 2001
---- tcpserver.c Fri Mar 16 13:53:52 2001
-***************
-*** 1,3 ****
---- 1,4 ----
-+ #include <stdio.h>
- #include <sys/types.h>
- #include <sys/param.h>
- #include <netdb.h>
-***************
-*** 25,36 ****
---- 26,39 ----
- #include "ndelay.h"
- #include "remoteinfo.h"
- #include "rules.h"
-+ #include "db.h"
- #include "sig.h"
- #include "dns.h"
-
- int verbosity = 1;
- int flagkillopts = 1;
- int flagdelay = 1;
-+ int usemysql = 0;
- char *banner = "";
- int flagremoteinfo = 1;
- int flagremotehost = 1;
-***************
-*** 109,114 ****
---- 112,121 ----
- {
- strerr_die4sys(111,DROP,"unable to read ",fnrules,": ");
- }
-+ void drop_db(void)
-+ {
-+ strerr_die4sys(111,DROP,"unable to verify DB ",db_database,": ");
-+ }
-
- void found(char *data,unsigned int datalen)
- {
-***************
-*** 198,205 ****
- }
- env("TCPREMOTEINFO",flagremoteinfo ? tcpremoteinfo.s : 0);
-
-! if (fnrules) {
- int fdrules;
- fdrules = open_read(fnrules);
- if (fdrules == -1) {
- if (errno != error_noent) drop_rules();
---- 205,222 ----
- }
- env("TCPREMOTEINFO",flagremoteinfo ? tcpremoteinfo.s : 0);
-
-! if(usemysql) {
-! if(flagdeny==2) {
-! /* drop_db(); */
-! } else if(!flagdeny) {
-! env("RELAYCLIENT","");
-! }
-! flagdeny=0;
-! }
-!
-! if(fnrules) {
- int fdrules;
-+
- fdrules = open_read(fnrules);
- if (fdrules == -1) {
- if (errno != error_noent) drop_rules();
-***************
-*** 240,246 ****
- {
- strerr_warn1("\
- tcpserver: usage: tcpserver \
-! [ -1UXpPhHrRoOdDqQv ] \
- [ -c limit ] \
- [ -x rules.cdb ] \
- [ -B banner ] \
---- 257,263 ----
- {
- strerr_warn1("\
- tcpserver: usage: tcpserver \
-! [ -1UXpPhHrRoOdDqQvS ] \
- [ -c limit ] \
- [ -x rules.cdb ] \
- [ -B banner ] \
-***************
-*** 300,306 ****
- int s;
- int t;
-
-! while ((opt = getopt(argc,argv,"dDvqQhHrR1UXx: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;
---- 317,323 ----
- int s;
- int t;
-
-! while ((opt = getopt(argc,argv,"dDvqQhHrR1UXSx: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;
-***************
-*** 327,332 ****
---- 344,350 ----
- case 'g': scan_ulong(optarg,&gid); break;
- case '1': flag1 = 1; break;
- case 'l': localhost = optarg; break;
-+ case 'S': usemysql = 1; break;
- default: usage();
- }
- argc -= optind;
-***************
-*** 398,403 ****
---- 416,422 ----
- for (;;) {
- while (numchildren >= limit) sig_pause();
-
-+ flagdeny=0;
- sig_unblock(sig_child);
- t = socket_accept4(s,remoteip,&remoteport);
- sig_block(sig_child);
-***************
-*** 405,410 ****
---- 424,499 ----
- if (t == -1) continue;
- ++numchildren; printstatus();
-
-+ if(usemysql) {
-+ int ret;
-+
-+ remoteipstr[ip4_fmt(remoteipstr,remoteip)] = 0;
-+
-+ if(db_port==-1) {
-+ FILE *fp;
-+
-+ if(fp=fopen("/var/qmail/control/sql","r")) {
-+ char line[256];
-+ char tag[256];
-+ char value[256];
-+
-+ while(fgets(line,256,fp)) {
-+ char *comment;
-+
-+ if(comment=strchr(line,'#')) {
-+ *comment='\0';
-+ }
-+ if(sscanf(line,"%s\t%s\n", tag, value) != 2) continue;
-+ /* fprintf(stderr,"Warning: got Line: [%s]\n",line); */
-+
-+ /*
-+ server sql.domain.com
-+ port 3306
-+ database vpopmail
-+ table relay
-+ user vpopmail
-+ pass secret
-+ time 1800
-+ */
-+ if(!strcasecmp(tag,"server")) {
-+ strcpy(db_host,value);
-+ } else if(!strcasecmp(tag,"port")) {
-+ db_port = atoi(value);
-+ } else if(!strcasecmp(tag,"database")) {
-+ strcpy(db_database,value);
-+ } else if(!strcasecmp(tag,"table")) {
-+ strcpy(db_table,value);
-+ } else if(!strcasecmp(tag,"user")) {
-+ strcpy(db_user,value);
-+ } else if(!strcasecmp(tag,"pass")) {
-+ strcpy(db_password,value);
-+ } else if(!strcasecmp(tag,"time")) {
-+ pop_timeout=atoi(value);
-+ } else {
-+ fprintf(stderr,"Warning: Bad sql: TAG: [%s] VALUE: [%s]\n",tag,value);
-+ }
-+ }
-+ }
-+ if(db_port==-1) {
-+ fprintf(stderr,"Error: Failed to read /var/qmail/control/sql\n");
-+ db_port==-2;
-+ } else {
-+ fclose(fp);
-+ }
-+ if (verbosity >= 2) {
-+ fprintf(stderr,"db_port set to: [%d]\n", db_port);
-+ }
-+ }
-+ if(db_port>=0) {
-+ db_ping();
-+ if((ret=check_db(remoteipstr))==-1) {
-+ flagdeny=2;
-+ } else if(ret) {
-+ flagdeny=1;
-+ }
-+ }
-+ }
-+
- switch(fork()) {
- case 0:
- close(s);
-*** db.c.orig Fri Mar 16 13:20:22 2001
---- db.c Wed Mar 14 15:13:05 2001
-***************
-*** 0 ****
---- 1,122 ----
-+ #include <stdio.h>
-+ #include <unistd.h>
-+ #include <strings.h>
-+ #include <mysql.h>
-+ #include "db.h"
-+
-+ /*
-+ server sql.mailserver.com
-+ port 3306
-+ database vpopmail
-+ table relay
-+ user vpopmail
-+ pass secret
-+ time 1800
-+ */
-+ #define MAX_QUERY_STRING 160
-+
-+ MYSQL *dbh=NULL;
-+
-+ char db_database[256];
-+ char db_host[256];
-+ char db_table[256];
-+ char db_user[256];
-+ char db_password[256];
-+ int db_port=-1;
-+ int pop_timeout;
-+
-+ extern int verbosity;
-+
-+ int open_db(char *database, char *host, int port, char *username, char *password)
-+ {
-+ MYSQL *tmp;
-+
-+ if (dbh != NULL) {
-+ mysql_close(dbh);
-+ dbh = NULL;
-+ }
-+ dbh = (MYSQL *)mysql_init(NULL);
-+ if (dbh == NULL)
-+ {
-+ fprintf(stderr,"MYSQL Init Error:\n");
-+ return -1;
-+ }
-+
-+ tmp = mysql_real_connect(dbh, host, username, password, database, port, NULL,0);
-+
-+ if (!tmp)
-+ {
-+ fprintf(stderr,"MYSQL Error: %s\n",mysql_error(dbh));
-+ return -1;
-+ }
-+
-+ return 0;
-+ }
-+
-+ int check_db(char *remoteip) {
-+ char query[MAX_QUERY_STRING];
-+ int num_rows = 0;
-+ int ret = -1;
-+ MYSQL_RES *res;
-+
-+ snprintf(query,MAX_QUERY_STRING,"SELECT timestamp FROM %s WHERE remote_ip='%s' AND timestamp>(UNIX_TIMESTAMP()-%d)", db_table, remoteip, pop_timeout);
-+
-+ ret = mysql_query(dbh,query);
-+ res = mysql_store_result(dbh);
-+ num_rows = mysql_affected_rows(dbh);
-+ mysql_free_result(res);
-+
-+ if (ret) {
-+ char err_str[256];
-+
-+ snprintf(err_str,255,"-%s-",mysql_error(dbh));
-+ fprintf(stderr,"%s",err_str);
-+ if(strstr("server has gone away",err_str)) {
-+ db_close();
-+ db_ping();
-+
-+ ret = mysql_query(dbh,query);
-+ if (ret) {
-+ return -1;
-+ }
-+ } else {
-+ db_close();
-+ db_ping();
-+
-+ ret = mysql_query(dbh,query);
-+ if (ret) {
-+ return -1;
-+ }
-+ }
-+ }
-+ if (verbosity >= 3) {
-+ fprintf(stderr,"QUERY(err:%d/rows:%d): %s\n",ret,num_rows,query); /* */
-+ }
-+
-+ if(num_rows>0) {
-+ return 0;
-+ } else {
-+ return 1;
-+ }
-+ }
-+
-+ void db_close()
-+ {
-+ mysql_close(dbh);
-+ dbh=NULL;
-+
-+ if (verbosity >= 2) {
-+ fprintf(stderr,"db_close() called!\n");
-+ }
-+ }
-+
-+ void db_ping()
-+ {
-+ if(dbh==NULL || mysql_ping(dbh)) {
-+ if (verbosity >= 2) {
-+ fprintf(stderr,"db_ping() is re-calling open_db!\n");
-+ }
-+ open_db(db_database,db_host,db_port,db_user,db_password);
-+ }
-+ }
-+
-*** db.h.orig Fri Mar 16 13:20:54 2001
---- db.h Thu Feb 22 11:35:17 2001
-***************
-*** 0 ****
---- 1,17 ----
-+ #ifndef _DB_
-+ #define _DB_
-+
-+ extern char db_database[256];
-+ extern char db_host[256];
-+ extern char db_table[256];
-+ extern char db_user[256];
-+ extern char db_password[256];
-+ extern int db_port;
-+ extern int pop_timeout;
-+
-+ int open_db(char *database, char *host, int port, char *username, char *password);
-+ int check_db(char *remoteip);
-+ void db_ping();
-+ void db_close();
-+
-+ #endif
-*** Makefile.orig Fri Mar 16 13:16:37 2001
---- Makefile Thu Feb 22 11:28:23 2001
-***************
-*** 513,518 ****
---- 513,522 ----
- rules.h stralloc.h
- ./compile rules.c
-
-+ db.o: \
-+ compile db.c db.h
-+ ./compile db.c
-+
- scan_ulong.o: \
- compile scan_ulong.c scan.h
- ./compile scan_ulong.c
-***************
-*** 742,757 ****
- ./compile tcprulescheck.c
-
- tcpserver: \
-! load tcpserver.o rules.o remoteinfo.o timeoutconn.o cdb.a dns.a \
- time.a unix.a byte.a socket.lib
-! ./load tcpserver rules.o remoteinfo.o timeoutconn.o cdb.a \
- dns.a time.a unix.a byte.a `cat socket.lib`
-
- tcpserver.o: \
- compile tcpserver.c uint16.h str.h byte.h fmt.h scan.h ip4.h fd.h \
- exit.h env.h prot.h open.h wait.h readwrite.h stralloc.h gen_alloc.h \
- alloc.h buffer.h error.h strerr.h sgetopt.h subgetopt.h pathexec.h \
-! socket.h uint16.h ndelay.h remoteinfo.h stralloc.h uint16.h rules.h \
- stralloc.h sig.h dns.h stralloc.h iopause.h taia.h tai.h uint64.h \
- taia.h
- ./compile tcpserver.c
---- 746,761 ----
- ./compile tcprulescheck.c
-
- tcpserver: \
-! load tcpserver.o rules.o db.o remoteinfo.o timeoutconn.o cdb.a dns.a \
- time.a unix.a byte.a socket.lib
-! ./load tcpserver rules.o db.o remoteinfo.o timeoutconn.o cdb.a \
- dns.a time.a unix.a byte.a `cat socket.lib`
-
- tcpserver.o: \
- compile tcpserver.c uint16.h str.h byte.h fmt.h scan.h ip4.h fd.h \
- exit.h env.h prot.h open.h wait.h readwrite.h stralloc.h gen_alloc.h \
- alloc.h buffer.h error.h strerr.h sgetopt.h subgetopt.h pathexec.h \
-! socket.h uint16.h ndelay.h remoteinfo.h stralloc.h uint16.h rules.h db.h \
- stralloc.h sig.h dns.h stralloc.h iopause.h taia.h tai.h uint64.h \
- taia.h
- ./compile tcpserver.c
-*** conf-ld.orig Fri Mar 16 13:46:36 2001
---- conf-ld Fri Mar 16 13:46:43 2001
-***************
-*** 1,3 ****
-! gcc -s
-
- This will be used to link .o files into an executable.
---- 1,3 ----
-! gcc -s -I/usr/local/include/mysql -L/usr/local/lib/mysql -lmysqlclient
-
- This will be used to link .o files into an executable.
-*** conf-cc.orig Fri Mar 16 13:47:31 2001
---- conf-cc Fri Mar 16 13:47:37 2001
-***************
-*** 1,3 ****
-! gcc -O2
-
- This will be used to compile .c files.
---- 1,3 ----
-! gcc -O2 -I/usr/local/include/mysql
-
- This will be used to compile .c files.
diff --git a/uint-headers.patch b/uint-headers.patch
new file mode 100644
index 0000000..3b637f5
--- /dev/null
+++ b/uint-headers.patch
@@ -0,0 +1,133 @@
+use stdint.h rather than hand guessing the underlying size
+
+--- a/tryulong32.c
++++ /dev/null
+@@ -1,11 +0,0 @@
+-main()
+-{
+- unsigned long u;
+- u = 1;
+- u += u; u += u; u += u; u += u; u += u; u += u; u += u; u += u;
+- u += u; u += u; u += u; u += u; u += u; u += u; u += u; u += u;
+- u += u; u += u; u += u; u += u; u += u; u += u; u += u; u += u;
+- u += u; u += u; u += u; u += u; u += u; u += u; u += u; u += u;
+- if (!u) _exit(0);
+- _exit(1);
+-}
+--- a/tryulong64.c
++++ /dev/null
+@@ -1,11 +0,0 @@
+-main()
+-{
+- unsigned long u;
+- u = 1;
+- u += u; u += u; u += u; u += u; u += u; u += u; u += u; u += u;
+- u += u; u += u; u += u; u += u; u += u; u += u; u += u; u += u;
+- u += u; u += u; u += u; u += u; u += u; u += u; u += u; u += u;
+- u += u; u += u; u += u; u += u; u += u; u += u; u += u; u += u;
+- if (!u) _exit(1);
+- _exit(0);
+-}
+--- a/uint32.h1
++++ /dev/null
+@@ -1,11 +0,0 @@
+-#ifndef UINT32_H
+-#define UINT32_H
+-
+-typedef unsigned int uint32;
+-
+-extern void uint32_pack(char *,uint32);
+-extern void uint32_pack_big(char *,uint32);
+-extern void uint32_unpack(const char *,uint32 *);
+-extern void uint32_unpack_big(const char *,uint32 *);
+-
+-#endif
+--- a/uint32.h2
++++ /dev/null
+@@ -1,11 +0,0 @@
+-#ifndef UINT32_H
+-#define UINT32_H
+-
+-typedef unsigned long uint32;
+-
+-extern void uint32_pack(char *,uint32);
+-extern void uint32_pack_big(char *,uint32);
+-extern void uint32_unpack(const char *,uint32 *);
+-extern void uint32_unpack_big(const char *,uint32 *);
+-
+-#endif
+--- a/uint64.h1
++++ /dev/null
+@@ -1,8 +0,0 @@
+-#ifndef UINT64_H
+-#define UINT64_H
+-
+-/* sysdep: -ulong64 */
+-
+-typedef unsigned long long uint64;
+-
+-#endif
+--- a/uint64.h2
++++ /dev/null
+@@ -1,8 +0,0 @@
+-#ifndef UINT64_H
+-#define UINT64_H
+-
+-/* sysdep: +ulong64 */
+-
+-typedef unsigned long uint64;
+-
+-#endif
+--- /dev/null
++++ b/uint32.h
+@@ -0,0 +1,12 @@
++#ifndef UINT32_H
++#define UINT32_H
++
++#include <stdint.h>
++typedef uint32_t uint32;
++
++extern void uint32_pack(char *,uint32);
++extern void uint32_pack_big(char *,uint32);
++extern void uint32_unpack(const char *,uint32 *);
++extern void uint32_unpack_big(const char *,uint32 *);
++
++#endif
+--- /dev/null
++++ b/uint64.h
+@@ -0,0 +1,8 @@
++#ifndef UINT64_H
++#define UINT64_H
++
++#include <stdint.h>
++
++typedef uint64_t uint64;
++
++#endif
+--- a/Makefile
++++ b/Makefile
+@@ -788,13 +788,6 @@ uint16_unpack.o: \
+ compile uint16_unpack.c uint16.h
+ ./compile uint16_unpack.c
+
+-uint32.h: \
+-tryulong32.c compile load uint32.h1 uint32.h2
+- ( ( ./compile tryulong32.c && ./load tryulong32 && \
+- ./tryulong32 ) >/dev/null 2>&1 \
+- && cat uint32.h2 || cat uint32.h1 ) > uint32.h
+- rm -f tryulong32.o tryulong32
+-
+ uint32_pack.o: \
+ compile uint32_pack.c uint32.h
+ ./compile uint32_pack.c
+@@ -803,10 +796,6 @@ uint32_unpack.o: \
+ compile uint32_unpack.c uint32.h
+ ./compile uint32_unpack.c
+
+-uint64.h: \
+-choose compile load tryulong64.c uint64.h1 uint64.h2
+- ./choose clr tryulong64 uint64.h1 uint64.h2 > uint64.h
+-
+ unix.a: \
+ makelib alloc.o alloc_re.o buffer.o buffer_0.o buffer_1.o buffer_2.o \
+ buffer_copy.o buffer_get.o buffer_put.o env.o error.o error_str.o \
================================================================
---- gitweb:
http://git.pld-linux.org/gitweb.cgi/packages/ucspi-tcp.git/commitdiff/e449606ceb36b37dfd6eb7f84c6b4020e910bb68
More information about the pld-cvs-commit
mailing list