Compare commits

...

2 Commits

Author SHA1 Message Date
ea3c67934f Remove LICENSE file 2024-04-04 14:22:26 +01:00
d2377ec883 * Tue Mar 19 2024 Jean-Philippe Pialasse <jpp@koozali.org> 1.05-12.sme
- patch to allow build for el8/SME11
2024-03-20 00:00:39 -04:00
11 changed files with 811 additions and 74 deletions

170
010-crosscompile.patch Normal file
View File

@ -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 <sys/types.h>
+#include <dirent.h>
+#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 <sys/types.h>
+#include <poll.h>
+
+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 <sys/types.h>
+#include <sys/time.h>
+#include <sys/select.h>
+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

View File

@ -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();

View File

@ -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 <james@now.ie> 6 Nov. 2003
#
--- a/cache.c
+++ b/cache.c
@@ -7,6 +7,11 @@
uint64 cache_motion = 0;
+/* record cache stats */
+/* James Raftery <james@now.ie> 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 <james@now.ie> 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 <james@now.ie> 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();
}

View File

@ -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: \

View File

@ -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);

122
250-dnscache-slogging.patch Normal file
View File

@ -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;

View File

@ -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;
}

View File

@ -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 <djbdns-1.05-ignoreip.patch
Install the patch like this:
cd /usr/local/src/djbdns-1.05
patch <djbdns-1.05-ignoreip2.patch
svc -d /service/dnscache
make setup check
svc -u /service/dnscache
Configure it to ignore Verisign's wildcard record like this:
echo 64.94.110.11 >/service/dnscache/root/ignoreip
svc -t /service/dnscache
Configure it to ignore all the cretins like this:
awk '{print $2}' <<EOF >/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);
}

73
LICENSE
View File

@ -1,73 +0,0 @@
Apache License
Version 2.0, January 2004
http://www.apache.org/licenses/
TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
1. Definitions.
"License" shall mean the terms and conditions for use, reproduction, and distribution as defined by Sections 1 through 9 of this document.
"Licensor" shall mean the copyright owner or entity authorized by the copyright owner that is granting the License.
"Legal Entity" shall mean the union of the acting entity and all other entities that control, are controlled by, or are under common control with that entity. For the purposes of this definition, "control" means (i) the power, direct or indirect, to cause the direction or management of such entity, whether by contract or otherwise, or (ii) ownership of fifty percent (50%) or more of the outstanding shares, or (iii) beneficial ownership of such entity.
"You" (or "Your") shall mean an individual or Legal Entity exercising permissions granted by this License.
"Source" form shall mean the preferred form for making modifications, including but not limited to software source code, documentation source, and configuration files.
"Object" form shall mean any form resulting from mechanical transformation or translation of a Source form, including but not limited to compiled object code, generated documentation, and conversions to other media types.
"Work" shall mean the work of authorship, whether in Source or Object form, made available under the License, as indicated by a copyright notice that is included in or attached to the work (an example is provided in the Appendix below).
"Derivative Works" shall mean any work, whether in Source or Object form, that is based on (or derived from) the Work and for which the editorial revisions, annotations, elaborations, or other modifications represent, as a whole, an original work of authorship. For the purposes of this License, Derivative Works shall not include works that remain separable from, or merely link (or bind by name) to the interfaces of, the Work and Derivative Works thereof.
"Contribution" shall mean any work of authorship, including the original version of the Work and any modifications or additions to that Work or Derivative Works thereof, that is intentionally submitted to Licensor for inclusion in the Work by the copyright owner or by an individual or Legal Entity authorized to submit on behalf of the copyright owner. For the purposes of this definition, "submitted" means any form of electronic, verbal, or written communication sent to the Licensor or its representatives, including but not limited to communication on electronic mailing lists, source code control systems, and issue tracking systems that are managed by, or on behalf of, the Licensor for the purpose of discussing and improving the Work, but excluding communication that is conspicuously marked or otherwise designated in writing by the copyright owner as "Not a Contribution."
"Contributor" shall mean Licensor and any individual or Legal Entity on behalf of whom a Contribution has been received by Licensor and subsequently incorporated within the Work.
2. Grant of Copyright License. Subject to the terms and conditions of this License, each Contributor hereby grants to You a perpetual, worldwide, non-exclusive, no-charge, royalty-free, irrevocable copyright license to reproduce, prepare Derivative Works of, publicly display, publicly perform, sublicense, and distribute the Work and such Derivative Works in Source or Object form.
3. Grant of Patent License. Subject to the terms and conditions of this License, each Contributor hereby grants to You a perpetual, worldwide, non-exclusive, no-charge, royalty-free, irrevocable (except as stated in this section) patent license to make, have made, use, offer to sell, sell, import, and otherwise transfer the Work, where such license applies only to those patent claims licensable by such Contributor that are necessarily infringed by their Contribution(s) alone or by combination of their Contribution(s) with the Work to which such Contribution(s) was submitted. If You institute patent litigation against any entity (including a cross-claim or counterclaim in a lawsuit) alleging that the Work or a Contribution incorporated within the Work constitutes direct or contributory patent infringement, then any patent licenses granted to You under this License for that Work shall terminate as of the date such litigation is filed.
4. Redistribution. You may reproduce and distribute copies of the Work or Derivative Works thereof in any medium, with or without modifications, and in Source or Object form, provided that You meet the following conditions:
(a) You must give any other recipients of the Work or Derivative Works a copy of this License; and
(b) You must cause any modified files to carry prominent notices stating that You changed the files; and
(c) You must retain, in the Source form of any Derivative Works that You distribute, all copyright, patent, trademark, and attribution notices from the Source form of the Work, excluding those notices that do not pertain to any part of the Derivative Works; and
(d) If the Work includes a "NOTICE" text file as part of its distribution, then any Derivative Works that You distribute must include a readable copy of the attribution notices contained within such NOTICE file, excluding those notices that do not pertain to any part of the Derivative Works, in at least one of the following places: within a NOTICE text file distributed as part of the Derivative Works; within the Source form or documentation, if provided along with the Derivative Works; or, within a display generated by the Derivative Works, if and wherever such third-party notices normally appear. The contents of the NOTICE file are for informational purposes only and do not modify the License. You may add Your own attribution notices within Derivative Works that You distribute, alongside or as an addendum to the NOTICE text from the Work, provided that such additional attribution notices cannot be construed as modifying the License.
You may add Your own copyright statement to Your modifications and may provide additional or different license terms and conditions for use, reproduction, or distribution of Your modifications, or for any such Derivative Works as a whole, provided Your use, reproduction, and distribution of the Work otherwise complies with the conditions stated in this License.
5. Submission of Contributions. Unless You explicitly state otherwise, any Contribution intentionally submitted for inclusion in the Work by You to the Licensor shall be under the terms and conditions of this License, without any additional terms or conditions. Notwithstanding the above, nothing herein shall supersede or modify the terms of any separate license agreement you may have executed with Licensor regarding such Contributions.
6. Trademarks. This License does not grant permission to use the trade names, trademarks, service marks, or product names of the Licensor, except as required for reasonable and customary use in describing the origin of the Work and reproducing the content of the NOTICE file.
7. Disclaimer of Warranty. Unless required by applicable law or agreed to in writing, Licensor provides the Work (and each Contributor provides its Contributions) on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied, including, without limitation, any warranties or conditions of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A PARTICULAR PURPOSE. You are solely responsible for determining the appropriateness of using or redistributing the Work and assume any risks associated with Your exercise of permissions under this License.
8. Limitation of Liability. In no event and under no legal theory, whether in tort (including negligence), contract, or otherwise, unless required by applicable law (such as deliberate and grossly negligent acts) or agreed to in writing, shall any Contributor be liable to You for damages, including any direct, indirect, special, incidental, or consequential damages of any character arising as a result of this License or out of the use or inability to use the Work (including but not limited to damages for loss of goodwill, work stoppage, computer failure or malfunction, or any and all other commercial damages or losses), even if such Contributor has been advised of the possibility of such damages.
9. Accepting Warranty or Additional Liability. While redistributing the Work or Derivative Works thereof, You may choose to offer, and charge a fee for, acceptance of support, warranty, indemnity, or other liability obligations and/or rights consistent with this License. However, in accepting such obligations, You may act only on Your own behalf and on Your sole responsibility, not on behalf of any other Contributor, and only if You agree to indemnify, defend, and hold each Contributor harmless for any liability incurred by, or claims asserted against, such Contributor by reason of your accepting any such warranty or additional liability.
END OF TERMS AND CONDITIONS
APPENDIX: How to apply the Apache License to your work.
To apply the Apache License to your work, attach the following boilerplate notice, with the fields enclosed by brackets "[]" replaced with your own identifying information. (Don't include the brackets!) The text should be enclosed in the appropriate comment syntax for the file format. We also recommend that a file or class name and description of purpose be included on the same "printed page" as the copyright notice for easier identification within third-party archives.
Copyright [yyyy] [name of copyright owner]
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.

29
djbdns-1.05-el8.patch Normal file
View File

@ -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 <sys/types.h>
+#include <stdlib.h>
+#include <grp.h>
#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: \

View File

@ -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 <jpp@koozali.org> 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