From d2377ec883e51e8a0e9f668fc86a17026e143b7a Mon Sep 17 00:00:00 2001 From: Jean-Philippe Pialasse Date: Wed, 20 Mar 2024 00:00:39 -0400 Subject: [PATCH] * Tue Mar 19 2024 Jean-Philippe Pialasse 1.05-12.sme - patch to allow build for el8/SME11 --- 010-crosscompile.patch | 170 +++++++++++++++++++++++++++ 040-dnscache-less-chatty-log | 39 ++++++ 110-dnscache-cachestats.patch | 89 ++++++++++++++ 140-dnsnamex-extra-command.patch | 156 ++++++++++++++++++++++++ 220-dnscacheip-space-separator.patch | 11 ++ 250-dnscache-slogging.patch | 122 +++++++++++++++++++ 260-dnsfilter-replace.patch | 71 +++++++++++ 280-dnscache-ignoreip2.patch | 117 ++++++++++++++++++ djbdns-1.05-el8.patch | 29 +++++ djbdns.spec | 8 +- 10 files changed, 811 insertions(+), 1 deletion(-) create mode 100644 010-crosscompile.patch create mode 100644 040-dnscache-less-chatty-log create mode 100644 110-dnscache-cachestats.patch create mode 100644 140-dnsnamex-extra-command.patch create mode 100644 220-dnscacheip-space-separator.patch create mode 100644 250-dnscache-slogging.patch create mode 100644 260-dnsfilter-replace.patch create mode 100644 280-dnscache-ignoreip2.patch create mode 100644 djbdns-1.05-el8.patch diff --git a/010-crosscompile.patch b/010-crosscompile.patch new file mode 100644 index 0000000..68ce1c3 --- /dev/null +++ b/010-crosscompile.patch @@ -0,0 +1,170 @@ +--- a/Makefile ++++ b/Makefile +@@ -29,10 +29,6 @@ auto-str.o: \ + compile auto-str.c buffer.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 +@@ -221,10 +217,6 @@ compile dd.c dns.h stralloc.h gen_alloc. + uint64.h taia.h dd.h + ./compile dd.c + +-direntry.h: \ +-choose compile trydrent.c direntry.h1 direntry.h2 +- ./choose c trydrent direntry.h1 direntry.h2 > direntry.h +- + dns.a: \ + makelib dns_dfd.o dns_domain.o dns_dtda.o dns_ip.o dns_ipq.o dns_mx.o \ + dns_name.o dns_nd.o dns_packet.o dns_random.o dns_rcip.o dns_rcrw.o \ +@@ -508,12 +500,6 @@ systype hasdevtcp.h1 hasdevtcp.h2 + *) cat hasdevtcp.h1 ;; \ + esac ) > hasdevtcp.h + +-hasshsgr.h: \ +-choose compile load tryshsgr.c hasshsgr.h1 hasshsgr.h2 chkshsgr \ +-warn-shsgr +- ./chkshsgr || ( cat warn-shsgr; exit 1 ) +- ./choose clr tryshsgr hasshsgr.h1 hasshsgr.h2 > hasshsgr.h +- + hier.o: \ + compile hier.c auto_home.h + ./compile hier.c +@@ -534,10 +520,6 @@ instcheck.o: \ + compile instcheck.c strerr.h error.h exit.h + ./compile instcheck.c + +-iopause.h: \ +-choose compile load trypoll.c iopause.h1 iopause.h2 +- ./choose clr trypoll iopause.h1 iopause.h2 > iopause.h +- + iopause.o: \ + compile iopause.c taia.h tai.h uint64.h select.h iopause.h taia.h + ./compile iopause.c +@@ -590,7 +572,7 @@ warn-auto.sh systype + dgux-*) ;; \ + hp-ux-*) ;; \ + sco*) ;; \ +- *) echo 'ranlib "$$main"' ;; \ ++ *) echo '$(if $(TARGET_RANLIB),$(TARGET_RANLIB),ranlib) "$$main"' ;; \ + esac \ + ) > makelib + chmod 755 makelib +@@ -766,10 +748,6 @@ seek_set.o: \ + compile seek_set.c seek.h + ./compile seek_set.c + +-select.h: \ +-choose compile trysysel.c select.h1 select.h2 +- ./choose c trysysel select.h1 select.h2 > select.h +- + server.o: \ + compile server.c byte.h case.h env.h buffer.h strerr.h ip4.h uint16.h \ + ndelay.h socket.h uint16.h droproot.h qlog.h uint16.h response.h \ +@@ -1060,10 +1038,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 buffer_read.o buffer_write.o error.o error_str.o ndelay_off.o \ + ndelay_on.o open_read.o open_trunc.o openreadclose.o readclose.o \ +--- /dev/null ++++ b/auto_home.c +@@ -0,0 +1,3 @@ ++const char auto_home[] = "\ ++\057\165\163\162\ ++"; +--- a/conf-cc ++++ b/conf-cc +@@ -1,3 +1,3 @@ +-gcc -O2 -Wimplicit -Wunused -Wcomment -Wchar-subscripts -Wuninitialized -Wshadow -Wcast-qual -Wcast-align -Wwrite-strings ++$TARGET_CC $TARGET_CFLAGS -Wimplicit -Wunused -Wcomment -Wchar-subscripts -Wuninitialized -Wshadow -Wcast-qual -Wcast-align -Wwrite-strings -include errno.h + + This will be used to compile .c files. +--- a/conf-home ++++ b/conf-home +@@ -1,4 +1,4 @@ +-/usr/local ++/usr + + This is the dnscache home directory. Programs will be installed in + .../bin. +--- a/conf-ld ++++ b/conf-ld +@@ -1,3 +1,3 @@ +-gcc -s ++$TARGET_CC -s $TARGET_LDFLAGS + + This will be used to link .o files into an executable. +--- /dev/null ++++ b/direntry.h +@@ -0,0 +1,10 @@ ++#ifndef DIRENTRY_H ++#define DIRENTRY_H ++ ++/* sysdep: +dirent */ ++ ++#include ++#include ++#define direntry struct dirent ++ ++#endif +--- /dev/null ++++ b/hasshsgr.h +@@ -0,0 +1 @@ ++/* sysdep: -shortsetgroups */ +--- /dev/null ++++ b/iopause.h +@@ -0,0 +1,18 @@ ++#ifndef IOPAUSE_H ++#define IOPAUSE_H ++ ++/* sysdep: +poll */ ++#define IOPAUSE_POLL ++ ++#include ++#include ++ ++typedef struct pollfd iopause_fd; ++#define IOPAUSE_READ POLLIN ++#define IOPAUSE_WRITE POLLOUT ++ ++#include "taia.h" ++ ++extern void iopause(iopause_fd *,unsigned int,struct taia *,struct taia *); ++ ++#endif +--- /dev/null ++++ b/select.h +@@ -0,0 +1,11 @@ ++#ifndef SELECT_H ++#define SELECT_H ++ ++/* sysdep: +sysselect */ ++ ++#include ++#include ++#include ++extern int select(); ++ ++#endif +--- /dev/null ++++ b/uint64.h +@@ -0,0 +1,8 @@ ++#ifndef UINT64_H ++#define UINT64_H ++ ++/* sysdep: -ulong64 */ ++ ++typedef unsigned long long uint64; ++ ++#endif diff --git a/040-dnscache-less-chatty-log b/040-dnscache-less-chatty-log new file mode 100644 index 0000000..9a881c9 --- /dev/null +++ b/040-dnscache-less-chatty-log @@ -0,0 +1,39 @@ +--- a/log.h ++++ b/log.h +@@ -1,6 +1,8 @@ + #ifndef LOG_H + #define LOG_H + ++#define STATS_DISPLAY_INTERVAL 5 ++ + #include "uint64.h" + + extern void log_startup(void); +--- a/log.c ++++ b/log.c +@@ -1,6 +1,7 @@ + #include "buffer.h" + #include "uint32.h" + #include "uint16.h" ++#include "time.h" + #include "error.h" + #include "byte.h" + #include "log.h" +@@ -274,11 +275,17 @@ void log_rrsoa(const char server[4],cons + + void log_stats(void) + { ++ static time_t prev = 0; ++ time_t cur = time(NULL); + extern uint64 numqueries; + extern uint64 cache_motion; + extern int uactive; + extern int tactive; + ++ if(prev == 0) prev = time(NULL); ++ if(cur - prev < STATS_DISPLAY_INTERVAL) return; ++ prev = cur; ++ + string("stats "); + number(numqueries); space(); + number(cache_motion); space(); diff --git a/110-dnscache-cachestats.patch b/110-dnscache-cachestats.patch new file mode 100644 index 0000000..5404719 --- /dev/null +++ b/110-dnscache-cachestats.patch @@ -0,0 +1,89 @@ +# +# This patch to djbdns 1.05 modifies the dnscache program to keep a +# counter of cache hits and cache misses. +# +# Two new fields are added to the ``stats'' output line: +# . the fifth number is the number of cache hits +# . the sixth number is the number of cache misses +# e.g. +# @400000003fa92ccc317d70f4 stats 3 1201 1 0 21 49 +# indicates 21 hits and 49 misses. +# +# James Raftery 6 Nov. 2003 +# +--- a/cache.c ++++ b/cache.c +@@ -7,6 +7,11 @@ + + uint64 cache_motion = 0; + ++/* record cache stats */ ++/* James Raftery 6 Nov. 2003 */ ++uint64 cache_hit = 0; ++uint64 cache_miss = 0; ++ + static char *x = 0; + static uint32 size; + static uint32 hsize; +@@ -112,15 +117,20 @@ char *cache_get(const char *key,unsigned + if (u > size - pos - 20 - keylen) cache_impossible(); + *datalen = u; + ++ cache_hit++; + return x + pos + 20 + keylen; + } + } + nextpos = prevpos ^ get4(pos); + prevpos = pos; + pos = nextpos; +- if (++loop > 100) return 0; /* to protect against hash flooding */ ++ if (++loop > 100) { /* to protect against hash flooding */ ++ cache_miss++; ++ return 0; ++ } + } + ++ cache_miss++; + return 0; + } + +--- a/cache.h ++++ b/cache.h +@@ -5,6 +5,12 @@ + #include "uint64.h" + + extern uint64 cache_motion; ++ ++/* record cache stats */ ++/* James Raftery 6 Nov. 2003 */ ++extern uint64 cache_hit; ++extern uint64 cache_miss; ++ + extern int cache_init(unsigned int); + extern void cache_set(const char *,unsigned int,const char *,unsigned int,uint32); + extern char *cache_get(const char *,unsigned int,unsigned int *,uint32 *); +--- a/log.c ++++ b/log.c +@@ -279,6 +279,12 @@ void log_stats(void) + time_t cur = time(NULL); + extern uint64 numqueries; + extern uint64 cache_motion; ++ ++ /* record cache stats */ ++ /* James Raftery 6 Nov. 2003 */ ++ extern uint64 cache_hit; ++ extern uint64 cache_miss; ++ + extern int uactive; + extern int tactive; + +@@ -290,6 +296,8 @@ void log_stats(void) + number(numqueries); space(); + number(cache_motion); space(); + number(uactive); space(); +- number(tactive); ++ number(tactive); space(); ++ number(cache_hit); space(); ++ number(cache_miss); + line(); + } diff --git a/140-dnsnamex-extra-command.patch b/140-dnsnamex-extra-command.patch new file mode 100644 index 0000000..6a8cafe --- /dev/null +++ b/140-dnsnamex-extra-command.patch @@ -0,0 +1,156 @@ +--- /dev/null ++++ b/dnsnamex.c +@@ -0,0 +1,34 @@ ++#include "buffer.h" ++#include "exit.h" ++#include "strerr.h" ++#include "ip4.h" ++#include "dns.h" ++ ++#define FATAL "dnsnamex: fatal: " ++ ++static char seed[128]; ++ ++char ip[4]; ++static stralloc out; ++ ++int main(int argc,char **argv) ++{ ++ dns_random_init(seed); ++ ++ if (*argv) ++argv; ++ ++ while (*argv) { ++ if (!ip4_scan(*argv,ip)) ++ strerr_die3x(111,FATAL,"unable to parse IP address ",*argv); ++ if (dns_name4_multi(&out,ip) == -1) ++ strerr_die4sys(111,FATAL,"unable to find host name for ",*argv,": "); ++ ++ buffer_put(buffer_1,out.s,out.len); ++ buffer_puts(buffer_1,"\n"); ++ ++ ++argv; ++ } ++ ++ buffer_flush(buffer_1); ++ _exit(0); ++} +--- /dev/null ++++ b/dns_namex.c +@@ -0,0 +1,48 @@ ++#include "stralloc.h" ++#include "uint16.h" ++#include "byte.h" ++#include "dns.h" ++ ++static char *q = 0; ++ ++int dns_name_packet_multi(stralloc *out,const char *buf,unsigned int len) ++{ ++ unsigned int pos; ++ char header[12]; ++ uint16 numanswers; ++ uint16 datalen; ++ ++ if (!stralloc_copys(out,"")) return -1; ++ ++ pos = dns_packet_copy(buf,len,0,header,12); if (!pos) return -1; ++ uint16_unpack_big(header + 6,&numanswers); ++ pos = dns_packet_skipname(buf,len,pos); if (!pos) return -1; ++ pos += 4; ++ ++ while (numanswers--) { ++ pos = dns_packet_skipname(buf,len,pos); if (!pos) return -1; ++ pos = dns_packet_copy(buf,len,pos,header,10); if (!pos) return -1; ++ uint16_unpack_big(header + 8,&datalen); ++ if (byte_equal(header,2,DNS_T_PTR)) ++ if (byte_equal(header + 2,2,DNS_C_IN)) { ++ if (!dns_packet_getname(buf,len,pos,&q)) return -1; ++ if (!dns_domain_todot_cat(out,q)) return -1; ++ if (!stralloc_cats(out, " ")) return -1 ; ++ } ++ pos += datalen; ++ } ++ ++ return 0; ++} ++ ++int dns_name4_multi(stralloc *out,const char ip[4]) ++{ ++ char name[DNS_NAME4_DOMAIN]; ++ ++ dns_name4_domain(name,ip); ++ if (dns_resolve(name,DNS_T_PTR) == -1) return -1; ++ if (dns_name_packet_multi(out,dns_resolve_tx.packet,dns_resolve_tx.packetlen) == -1) return -1; ++ dns_transmit_free(&dns_resolve_tx); ++ dns_domain_free(&q); ++ return 0; ++} +--- a/dns.h ++++ b/dns.h +@@ -70,9 +70,11 @@ extern struct dns_transmit dns_resolve_t + extern int dns_ip4_packet(stralloc *,const char *,unsigned int); + extern int dns_ip4(stralloc *,const stralloc *); + extern int dns_name_packet(stralloc *,const char *,unsigned int); ++extern int dns_name_packet_multi(stralloc *,const char *,unsigned int); + extern void dns_name4_domain(char *,const char *); + #define DNS_NAME4_DOMAIN 31 + extern int dns_name4(stralloc *,const char *); ++extern int dns_name4_multi(stralloc *,const char *); + extern int dns_txt_packet(stralloc *,const char *,unsigned int); + extern int dns_txt(stralloc *,const stralloc *); + extern int dns_mx_packet(stralloc *,const char *,unsigned int); +--- a/Makefile ++++ b/Makefile +@@ -219,10 +219,10 @@ uint64.h taia.h dd.h + + dns.a: \ + makelib dns_dfd.o dns_domain.o dns_dtda.o dns_ip.o dns_ipq.o dns_mx.o \ +-dns_name.o dns_nd.o dns_packet.o dns_random.o dns_rcip.o dns_rcrw.o \ ++dns_name.o dns_namex.o dns_nd.o dns_packet.o dns_random.o dns_rcip.o dns_rcrw.o \ + dns_resolve.o dns_sortip.o dns_transmit.o dns_txt.o + ./makelib dns.a dns_dfd.o dns_domain.o dns_dtda.o dns_ip.o \ +- dns_ipq.o dns_mx.o dns_name.o dns_nd.o dns_packet.o \ ++ dns_ipq.o dns_mx.o dns_name.o dns_namex.o dns_nd.o dns_packet.o \ + dns_random.o dns_rcip.o dns_rcrw.o dns_resolve.o \ + dns_sortip.o dns_transmit.o dns_txt.o + +@@ -261,6 +261,11 @@ compile dns_name.c stralloc.h gen_alloc. + stralloc.h iopause.h taia.h tai.h uint64.h taia.h + ./compile dns_name.c + ++dns_namex.o: \ ++compile dns_namex.c stralloc.h gen_alloc.h uint16.h byte.h dns.h \ ++stralloc.h iopause.h taia.h tai.h uint64.h taia.h ++ ./compile dns_namex.c ++ + dns_nd.o: \ + compile dns_nd.c byte.h fmt.h dns.h stralloc.h gen_alloc.h iopause.h \ + taia.h tai.h uint64.h taia.h +@@ -394,6 +399,17 @@ compile dnsname.c buffer.h exit.h strerr + gen_alloc.h iopause.h taia.h tai.h uint64.h taia.h + ./compile dnsname.c + ++dnsnamex: \ ++load dnsnamex.o iopause.o dns.a env.a libtai.a alloc.a buffer.a unix.a \ ++byte.a socket.lib ++ ./load dnsnamex iopause.o dns.a env.a libtai.a alloc.a \ ++ buffer.a unix.a byte.a `cat socket.lib` ++ ++dnsnamex.o: \ ++compile dnsnamex.c buffer.h exit.h strerr.h ip4.h dns.h stralloc.h \ ++gen_alloc.h iopause.h taia.h tai.h uint64.h taia.h ++ ./compile dnsnamex.c ++ + dnsq: \ + load dnsq.o iopause.o printrecord.o printpacket.o parsetype.o dns.a \ + env.a libtai.a buffer.a alloc.a unix.a byte.a socket.lib +@@ -658,7 +674,7 @@ prog: \ + dnscache-conf dnscache walldns-conf walldns rbldns-conf rbldns \ + rbldns-data pickdns-conf pickdns pickdns-data tinydns-conf tinydns \ + tinydns-data tinydns-get tinydns-edit axfr-get axfrdns-conf axfrdns \ +-dnsip dnsipq dnsname dnstxt dnsmx dnsfilter random-ip dnsqr dnsq \ ++dnsip dnsipq dnsname dnsnamex dnstxt dnsmx dnsfilter random-ip dnsqr dnsq \ + dnstrace dnstracesort cachetest utime rts + + prot.o: \ diff --git a/220-dnscacheip-space-separator.patch b/220-dnscacheip-space-separator.patch new file mode 100644 index 0000000..2e73ffe --- /dev/null +++ b/220-dnscacheip-space-separator.patch @@ -0,0 +1,11 @@ +--- a/dns_rcip.c ++++ b/dns_rcip.c +@@ -17,7 +17,7 @@ static int init(char ip[64]) + x = env_get("DNSCACHEIP"); + if (x) + while (iplen <= 60) { +- if (*x == '.') ++ if (*x == ' ' || *x == '\t' || *x == '\n') + ++x; + else { + i = ip4_scan(x,ip + iplen); diff --git a/250-dnscache-slogging.patch b/250-dnscache-slogging.patch new file mode 100644 index 0000000..5a2eaa1 --- /dev/null +++ b/250-dnscache-slogging.patch @@ -0,0 +1,122 @@ +--- a/server.c ++++ b/server.c +@@ -25,12 +25,63 @@ static int len; + + static char *q; + ++static uint64 stats_numq; ++static uint64 stats_plus; ++static uint64 stats_minus; ++static uint64 stats_nx; ++static uint64 stats_notimp; ++static uint64 stats_weird; ++static uint64 stats_noq; ++ ++/* work around gcc 2.95.2 bug */ ++#define number(x) ( (u64 = (x)), u64_print() ) ++static uint64 u64; ++static void u64_print(void) ++{ ++ char ubuf[20]; ++ unsigned int pos; ++ ++ pos = sizeof ubuf; ++ do { ++ if (!pos) break; ++ ubuf[--pos] = '0' + (u64 % 10); ++ u64 /= 10; ++ } while(u64); ++ ++ buffer_put(buffer_2,ubuf + pos,sizeof ubuf - pos); ++} ++ ++static void string(const char *s) ++{ ++ buffer_puts(buffer_2,s); ++} ++ ++static void line(void) ++{ ++ string("\n"); ++ buffer_flush(buffer_2); ++} ++ ++static void log_stats(void) ++{ ++ string("stats "); ++ number(stats_numq); string(" "); ++ number(stats_plus); string(" "); ++ number(stats_minus); string(" "); ++ number(stats_nx); string(" "); ++ number(stats_notimp); string(" "); ++ number(stats_weird); string(" "); ++ number(stats_noq); ++ line(); ++} ++ + static int doit(void) + { + unsigned int pos; + char header[12]; + char qtype[2]; + char qclass[2]; ++ stats_numq++; + + if (len >= sizeof buf) goto NOQ; + pos = dns_packet_copy(buf,len,0,header,12); if (!pos) goto NOQ; +@@ -56,25 +107,37 @@ static int doit(void) + + case_lowerb(q,dns_domain_length(q)); + if (!respond(q,qtype,ip)) { ++ stats_minus++; + qlog(ip,port,header,q,qtype," - "); + return 0; + } +- qlog(ip,port,header,q,qtype," + "); ++ ++ if ((response[2] & 4) && (response[3] & 3)) { ++ stats_nx++; ++ qlog(ip,port,header,q,qtype," N "); ++ } ++ else { ++ stats_plus++; ++ qlog(ip,port,header,q,qtype," + "); ++ } + return 1; + + NOTIMP: ++ stats_notimp++; + response[3] &= ~15; + response[3] |= 4; + qlog(ip,port,header,q,qtype," I "); + return 1; + + WEIRDCLASS: ++ stats_weird++; + response[3] &= ~15; + response[3] |= 1; + qlog(ip,port,header,q,qtype," C "); + return 1; + + NOQ: ++ stats_noq++; + qlog(ip,port,"\0\0","","\0\0"," / "); + return 0; + } +@@ -83,6 +146,7 @@ int main() + { + char *x; + int udp53; ++ unsigned char flag=0; + + x = env_get("IP"); + if (!x) +@@ -106,6 +170,8 @@ int main() + buffer_putsflush(buffer_2,starting); + + for (;;) { ++ if ((flag++)%32==1) ++ log_stats(); + len = socket_recv4(udp53,buf,sizeof buf,ip,&port); + if (len < 0) continue; + if (!doit()) continue; diff --git a/260-dnsfilter-replace.patch b/260-dnsfilter-replace.patch new file mode 100644 index 0000000..b352f1c --- /dev/null +++ b/260-dnsfilter-replace.patch @@ -0,0 +1,71 @@ +--- a/dnsfilter.c ++++ b/dnsfilter.c +@@ -41,6 +41,7 @@ int inbuflen = 0; + iopause_fd *inio; + int flag0 = 1; + ++int opt_replace = 0; + iopause_fd *io; + int iolen; + +@@ -51,12 +52,16 @@ char name[DNS_NAME4_DOMAIN]; + void errout(int i) + { + int j; +- +- if (!stralloc_copys(&x[i].middle,":")) nomem(); +- if (!stralloc_cats(&x[i].middle,error_str(errno))) nomem(); +- for (j = 0;j < x[i].middle.len;++j) +- if (x[i].middle.s[j] == ' ') +- x[i].middle.s[j] = '-'; ++ ++ if (opt_replace) ++ x[i].middle.len=0; ++ else { ++ if (!stralloc_copys(&x[i].middle,":")) nomem(); ++ if (!stralloc_cats(&x[i].middle,error_str(errno))) nomem(); ++ for (j = 0;j < x[i].middle.len;++j) ++ if (x[i].middle.s[j] == ' ') ++ x[i].middle.s[j] = '-'; ++ } + } + + int main(int argc,char **argv) +@@ -69,7 +74,7 @@ int main(int argc,char **argv) + int j; + int r; + +- while ((opt = getopt(argc,argv,"c:l:")) != opteof) ++ while ((opt = getopt(argc,argv,"c:l:r")) != opteof) + switch(opt) { + case 'c': + scan_ulong(optarg,&u); +@@ -83,8 +88,11 @@ int main(int argc,char **argv) + if (u > 1000000) u = 1000000; + xmax = u; + break; ++ case 'r': ++ opt_replace = 1; ++ break; + default: +- strerr_die1x(111,"dnsfilter: usage: dnsfilter [ -c concurrency ] [ -l lines ]"); ++ strerr_die1x(111,"dnsfilter: usage: dnsfilter [ -c concurrency ] [ -l lines ] [-r]"); + } + + x = (struct line *) alloc(xmax * sizeof(struct line)); +@@ -140,8 +148,13 @@ int main(int argc,char **argv) + else if (r == 1) { + if (dns_name_packet(&x[i].middle,x[i].dt.packet,x[i].dt.packetlen) == -1) + errout(i); +- if (x[i].middle.len) +- if (!stralloc_cats(&x[i].left,"=")) nomem(); ++ if (x[i].middle.len) { ++ if (opt_replace) { ++ if (!stralloc_copys(&x[i].left, "")) nomem(); ++ } else { ++ if (!stralloc_cats(&x[i].left, "=")) nomem(); ++ } ++ } + x[i].flagactive = 0; + --numactive; + } diff --git a/280-dnscache-ignoreip2.patch b/280-dnscache-ignoreip2.patch new file mode 100644 index 0000000..0a8bfad --- /dev/null +++ b/280-dnscache-ignoreip2.patch @@ -0,0 +1,117 @@ +This patch change djbdns's dnscache program so that it will ignore the +IP address given in the ignoreip file. I wrote this patch because of +Verisign's oh-so helpful wildcard A record for *.COM and *.NET. + +If you have djbdns-1.05-ignoreip.patch installed, back it out like this: + cd /usr/local/src/djbdns-1.05 + patch -R /service/dnscache/root/ignoreip + svc -t /service/dnscache + +Configure it to ignore all the cretins like this: +awk '{print $2}' </service/dnscache/root/ignoreip + *.ac 194.205.62.122 + *.cc 206.253.214.102 + *.com 64.94.110.11 + *.cx 219.88.106.80 + *.museum 195.7.77.20 + *.net 64.94.110.11 + *.nu 64.55.105.9 + and 212.181.91.6 + *.ph 203.119.4.6 + *.sh 194.205.62.62 + *.tm 194.205.62.62 + *.ws 216.35.187.246 +EOF + svc -t /service/dnscache + +J.P. Larocque contributes a script which updates root/ignoreip: + http://ely.ath.cx/~piranha/software/ignoreip-update/ignoreip-update-0.1 + +If root/ignoreip is not present, no addresses will be ignored. + +-- +--My blog is at angry-economist.russnelson.com | Free markets express in the +Crynwr sells support for free software | PGPok | practical world our belief +521 Pleasant Valley Rd. | +1 315 268 1925 voice | that there is that of God +Potsdam, NY 13676-3213 | +1 315 268 9201 FAX | in all people. -Chris V. + + +--- a/dnscache.c ++++ b/dnscache.c +@@ -24,6 +24,8 @@ + #include "okclient.h" + #include "droproot.h" + ++stralloc ignoreip = {0}; ++ + static int packetquery(char *buf,unsigned int len,char **q,char qtype[2],char qclass[2],char id[2]) + { + unsigned int pos; +@@ -390,6 +392,7 @@ char seed[128]; + int main() + { + char *x; ++ unsigned int i, j, k; + unsigned long cachesize; + + signal(SIGPIPE, SIG_IGN); +@@ -433,6 +436,20 @@ int main() + if (!cache_init(cachesize)) + strerr_die3x(111,FATAL,"not enough memory for cache of size ",x); + ++ if (openreadclose("ignoreip",&ignoreip,64) < 0) ++ strerr_die2x(111,FATAL,"trouble reading ignoreip"); ++ for(j = k = i = 0; i < ignoreip.len; i++) ++ if (ignoreip.s[i] == '\n') { ++ ignoreip.s[i] = '\0'; ++ if (j + 4 > i) ++ strerr_die3x(111,FATAL,"badly malformed ip4 address ",ignoreip.s+k); ++ if (!ip4_scan(ignoreip.s+k,ignoreip.s+j)) ++ strerr_die3x(111,FATAL,"unable to parse address in ignoreip ",ignoreip.s+k); ++ j += 4; ++ k = i + 1; ++ } ++ ignoreip.len = j; ++ + if (env_get("HIDETTL")) + response_hidettl(); + if (env_get("FORWARDONLY")) +--- a/query.c ++++ b/query.c +@@ -13,6 +13,8 @@ + #include "response.h" + #include "query.h" + ++extern stralloc ignoreip; ++ + static int flagforwardonly = 0; + + void query_forwardonly(void) +@@ -173,6 +175,7 @@ static int smaller(char *buf,unsigned in + + static int doit(struct query *z,int state) + { ++ unsigned int ii; + char key[257]; + char *cached; + unsigned int cachedlen; +@@ -662,6 +665,9 @@ static int doit(struct query *z,int stat + pos = dns_packet_copy(buf,len,pos,header,10); if (!pos) goto DIE; + if (byte_equal(header + 8,2,"\0\4")) { + pos = dns_packet_copy(buf,len,pos,header,4); if (!pos) goto DIE; ++ if (ignoreip.len) ++ for(ii = 0; ii < ignoreip.len; ii+= 4) ++ if (byte_equal(header,4,ignoreip.s+ii)) goto NXDOMAIN; + save_data(header,4); + log_rr(whichserver,t1,DNS_T_A,header,4,ttl); + } diff --git a/djbdns-1.05-el8.patch b/djbdns-1.05-el8.patch new file mode 100644 index 0000000..1824f51 --- /dev/null +++ b/djbdns-1.05-el8.patch @@ -0,0 +1,29 @@ +diff -Nur --no-dereference djbdns-1.05.old/chkshsgr.c djbdns-1.05/chkshsgr.c +--- djbdns-1.05.old/chkshsgr.c 2001-02-11 16:11:45.000000000 -0500 ++++ djbdns-1.05/chkshsgr.c 2024-03-19 23:34:19.933000000 -0400 +@@ -1,8 +1,11 @@ ++#include ++#include ++#include + #include "exit.h" + +-int main() ++int main(int argc, char *argv[]) + { +- short x[4]; ++ gid_t x[4]; + + x[0] = x[1] = 0; + if (getgroups(1,x) == 0) if (setgroups(1,x) == -1) _exit(1); +diff -Nur --no-dereference djbdns-1.05.old/Makefile djbdns-1.05/Makefile +--- djbdns-1.05.old/Makefile 2001-02-11 16:11:45.000000000 -0500 ++++ djbdns-1.05/Makefile 2024-03-19 23:32:48.457000000 -0400 +@@ -511,7 +511,7 @@ + hasshsgr.h: \ + choose compile load tryshsgr.c hasshsgr.h1 hasshsgr.h2 chkshsgr \ + warn-shsgr +- ./chkshsgr || ( cat warn-shsgr; exit 1 ) ++ echo "Warning: We can not run test on cross target. - ignoring ./chkshsgr || ( cat warn-shsgr; exit 1 )" + ./choose clr tryshsgr hasshsgr.h1 hasshsgr.h2 > hasshsgr.h + + hier.o: \ diff --git a/djbdns.spec b/djbdns.spec index 6ad79c3..82046e4 100644 --- a/djbdns.spec +++ b/djbdns.spec @@ -5,11 +5,12 @@ # # $Id: djbdns.spec,v 1.4 2021/04/13 01:01:10 jpp Exp $ # +%global debug_package %{nil} Summary: collection of Domain Name System tools %define name djbdns Name: %{name} %define version 1.05 -%define release 11 +%define release 12 Version: %{version} Release: %{release}%{?dist} License: Public Domain @@ -21,6 +22,7 @@ Patch1: dns_transmit-bug.patch #Patch2: http://homepages.tesco.net./~J.deBoynePollard/Softwares/djbdns/dnscache-cname-handling.patch #Patch3: http://homepages.tesco.net./~J.deBoynePollard/Softwares/djbdns/dnscache-strict-forwardonly.patch #Patch4: http://homepages.tesco.net./~J.deBoynePollard/Softwares/djbdns/tinydns-alias-chain-truncation.patch +Patch5: djbdns-1.05-el8.patch # openwrt patches Patch20: https://dev.openwrt.org/export/HEAD/packages/net/djbdns/patches/020-dnsroots-update.patch @@ -84,6 +86,9 @@ djbdns was written by Daniel J Bernstein, and was placed into the public domain on Dec 28, 2007. %changelog +* Tue Mar 19 2024 Jean-Philippe Pialasse 1.05-12.sme +- patch to allow build for el8/SME11 + * Fri Jul 14 2023 BogusDateBot - Eliminated rpmbuild "bogus date" warnings due to inconsistent weekday, by assuming the date is correct and changing the weekday. @@ -192,6 +197,7 @@ mkdir -p ./root/etc %patch450 -p1 %patch500 -p1 +%patch5 -p1 %build echo "gcc -O2 -Wall --include /usr/include/errno.h" > conf-cc