fix: populate ldns submodule and add autotools to LDNS build stage

- Re-cloned zonemaster-ldns with --recurse-submodules so the bundled
  ldns C library source (including Changelog and configure.ac) is present
- Added autoconf, automake, libtool to Dockerfile.backend ldns-build stage
  so libtoolize + autoreconf can generate ldns/configure during make

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
2026-04-21 08:33:38 +02:00
parent 8d4eaa1489
commit eaaa8f6a11
541 changed files with 138189 additions and 0 deletions

View File

@@ -0,0 +1,45 @@
# Standard installation pathnames
# See the file LICENSE for the license
SHELL = @SHELL@
VERSION = @PACKAGE_VERSION@
basesrcdir = $(shell basename `pwd`)
srcdir = @srcdir@
prefix = @prefix@
exec_prefix = @exec_prefix@
bindir = @bindir@
mandir = @mandir@
datarootdir = @datarootdir@
CC = @CC@
CFLAGS = @CFLAGS@
CPPFLAGS = @CPPFLAGS@ @LIBSSL_CPPFLAGS@ -I../..
LDFLAGS = @LDFLAGS@ @LIBSSL_LDFLAGS@ -L../../.libs
LIBS = @LIBS@ @LIBSSL_SSL_LIBS@ -lldns
COMPILE = $(CC) $(CPPFLAGS) $(CFLAGS)
LINK = $(CC) $(CFLAGS) $(LDFLAGS)
HEADER = config.h
TESTS = 16-unit-tests-edns
.PHONY: all clean realclean
%.o:
$(COMPILE) -c $(srcdir)/$*.c
all: $(TESTS)
16-unit-tests-edns: 16-unit-tests-edns.o
$(LINK) -o $@ $+ $(LIBS)
clean:
rm -f *.o
rm -f $(TESTS)
rm -f lua-rns
realclean: clean
rm -rf autom4te.cache/
rm -f config.log config.status aclocal.m4 config.h.in configure Makefile
rm -f config.h
confclean: clean
rm -rf config.log config.status config.h Makefile

View File

@@ -0,0 +1,273 @@
#include "config.h"
#include <ldns/ldns.h>
static int
check_option_entries(ldns_edns_option *edns, ldns_edns_option_code code,
size_t size, uint8_t *hex_data)
{
size_t i;
uint8_t *edns_data;
ldns_buffer *buf;
if (ldns_edns_get_size(edns) != size) {
printf("Error: EDNS size is incorrect\n");
return 0;
}
if (ldns_edns_get_code(edns) != code) {
printf("Error: EDNS code is incorrect\n");
return 0;
}
edns_data = ldns_edns_get_data(edns);
if (!(edns_data)) {
printf("Error: EDNS data is not returned\n");
return 0;
}
for (i = 0; i < size; i++) {
if (edns_data[i] != hex_data[i]) {
printf("Error: EDNS data is incorrect\n");
return 0;
}
}
buf = ldns_edns_get_wireformat_buffer(edns);
if (ldns_buffer_read_u16(buf) != code) {
ldns_buffer_free(buf);
printf("Error: EDNS type is incorrect\n");
return 0;
}
if (ldns_buffer_read_u16(buf) != size) {
ldns_buffer_free(buf);
printf("Error: EDNS length is incorrect\n");
return 0;
}
for (i = 0; i < size; i++) {
if (ldns_buffer_read_u8_at(buf, i+4) != hex_data[i]) {
printf("Error: EDNS data is incorrect: %d, %d\n",
ldns_buffer_read_u8_at(buf, i+4), hex_data[i]);
ldns_buffer_free(buf);
return 0;
}
}
ldns_buffer_free(buf);
return 1;
}
static int
check_option(void)
{
ldns_edns_option *edns;
ldns_edns_option *clone;
uint8_t *data = LDNS_XMALLOC(uint8_t, 4);
uint8_t hex_data[] = {74, 65, 73, 74};
/* Fill the data with "test" in hex */
data[0] = hex_data[0];
data[1] = hex_data[1];
data[2] = hex_data[2];
data[3] = hex_data[3];
edns = ldns_edns_new(LDNS_EDNS_EDE, 4, data);
if (!(check_option_entries(edns, LDNS_EDNS_EDE, 4, hex_data))) {
return 0;
}
ldns_edns_deep_free(edns);
edns = ldns_edns_new_from_data(LDNS_EDNS_EDE, 4, hex_data);
if (!(check_option_entries(edns, LDNS_EDNS_EDE, 4, hex_data))) {
return 0;
}
clone = ldns_edns_clone(edns);
if (!(check_option_entries(clone, LDNS_EDNS_EDE, 4, hex_data))) {
return 0;
}
ldns_edns_deep_free(edns);
ldns_edns_deep_free(clone);
return 1;
}
static int check_option_list_entries(ldns_edns_option_list *list,
ldns_edns_option *option, size_t count, ldns_edns_option_code code, size_t size,
uint8_t *hex_data)
{
size_t c = ldns_edns_option_list_get_count(list);
if (c != count) {
printf("Error: EDNS list count is incorrect\n");
return 0;
}
if (!(option)) {
printf("Error: EDNS list option setter doesn't return option\n");
return 0;
}
if (!(check_option_entries(option, code, size, hex_data))) {
printf("Error: EDNS list option is incorrect\n");
return 0;
}
return 1;
}
static int
check_option_list(void)
{
size_t size, i;
ldns_edns_option_list* list;
ldns_edns_option_list* clone;
ldns_edns_option *option;
ldns_edns_option *copy;
ldns_edns_option *pop;
ldns_buffer *buf;
uint8_t hex_data[] = {74, 65, 73, 74};
uint8_t hex_data2[] = {74, 65, 73, 74, 74};
list = ldns_edns_option_list_new(); // don't verify, this function asserts
/* Add first option */
option = ldns_edns_new_from_data(LDNS_EDNS_EDE, 4, hex_data);
if (ldns_edns_option_list_get_count(list)) {
printf("Error: EDNS list count is incorrect after init\n");
return 0;
}
ldns_edns_option_list_push(list, option);
copy = ldns_edns_option_list_get_option(list, 0);
if (!(check_option_list_entries(list, copy, 1, LDNS_EDNS_EDE, 4, hex_data))) {
printf("Error: EDNS list entries are incorrect\n");
return 0;
}
size = ldns_edns_option_list_get_options_size(list);
if (size != 8) { // size of the data + 4 for the code and size
printf("Error: EDNS list total option size is incorrect\n");
return 0;
}
/* Add second option */
option = ldns_edns_new_from_data(LDNS_EDNS_PADDING, 5, hex_data2);
ldns_edns_option_list_push(list, option);
if (!(check_option_list_entries(list, option, 2, LDNS_EDNS_PADDING, 5, hex_data2))) {
printf("Error: EDNS list entries are incorrect\n");
return 0;
}
buf = ldns_edns_option_list2wireformat_buffer(list);
if (!(buf)) {
printf("Error: EDNS list entries list2wireformat buffer is NULL\n");
return 0;
}
/* Verify the wireformat options with the hex data */
ldns_buffer_skip(buf, 4);
for (i = 0; i < 4; i++) {
if (ldns_buffer_read_u8(buf) != hex_data[i]) {
printf("Error: EDNS data is incorrect: %d, %d\n",
ldns_buffer_read_u8_at(buf, i), hex_data[i]);
ldns_buffer_free(buf);
return 0;
}
}
ldns_buffer_skip(buf, 4);
for (i = 0; i < 5; i++) {
if (ldns_buffer_read_u8(buf) != hex_data2[i]) {
printf("Error: EDNS data is incorrect: %d, %d\n",
ldns_buffer_read_u8_at(buf, i), hex_data2[i]);
ldns_buffer_free(buf);
return 0;
}
}
ldns_buffer_free(buf);
buf = NULL;
/* Replace the first option with a copy of the second */
option = ldns_edns_new_from_data(LDNS_EDNS_PADDING, 5, hex_data2);
pop = ldns_edns_option_list_set_option(list, option, 0);
if (!(check_option_list_entries(list, pop, 2, LDNS_EDNS_EDE, 4, hex_data))) {
printf("Error: EDNS list entries are incorrect\n");
return 0;
}
ldns_edns_deep_free(pop);
/* Remove one option from the list */
pop = ldns_edns_option_list_pop(list);
if (!(check_option_list_entries(list, option, 1, LDNS_EDNS_PADDING, 5, hex_data2))) {
printf("Error: EDNS list entries are incorrect\n");
return 0;
}
ldns_edns_deep_free(pop);
/* Clone the list */
clone = ldns_edns_option_list_clone(list);
if (!(clone)) {
printf("Error: EDNS list clone does not exist\n");
return 0;
}
if (!(check_option_list_entries(clone, option, 1, LDNS_EDNS_PADDING, 5, hex_data2))) {
printf("Error: EDNS list entries are incorrect\n");
ldns_edns_option_list_deep_free(clone);
return 0;
}
/* Remove final entry from cloned list */
pop = ldns_edns_option_list_pop(list);
ldns_edns_deep_free(pop);
if (ldns_edns_option_list_get_count(clone) == 0) {
printf("Error: EDNS list entries are incorrect at zero\n");
return 0;
}
ldns_edns_option_list_deep_free(clone);
ldns_edns_option_list_deep_free(list);
return 1;
}
int main(void)
{
int result = EXIT_SUCCESS;
if (!check_option()) {
printf("check_option() failed.\n");
result = EXIT_FAILURE;
}
if (!check_option_list()) {
printf("check_option_list() failed.\n");
result = EXIT_FAILURE;
}
exit(result);
}

View File

@@ -0,0 +1,96 @@
# -*- Autoconf -*-
# Process this file with autoconf to produce a configure script.
AC_PREREQ(2.57)
AC_INIT(drill, 1.1.0, dns-team@nlnetlabs.nl, ldns-team)
AC_CONFIG_SRCDIR([13-unit-tests-base.c])
AC_AIX
# Checks for programs.
AC_PROG_CC
AC_PROG_MAKE_SET
# Checks for libraries.
# Checks for header files.
#AC_HEADER_STDC
#AC_HEADER_SYS_WAIT
# do the very minimum - we can always extend this
AC_CHECK_HEADERS([getopt.h stdlib.h stdio.h assert.h netinet/in.hctype.h time.h])
AC_CHECK_HEADERS(sys/param.h sys/mount.h,,,
[
[
#if HAVE_SYS_PARAM_H
# include <sys/param.h>
#endif
]
])
# ssl dir if needed
AC_ARG_WITH(ssl, AC_HELP_STRING([--with-ssl=PATH], [set ssl library directory]),
[
CPPFLAGS="$CPPFLAGS -I$withval/include"
LDFLAGS="$LDFLAGS -L$withval -L$withval/lib"
])
# check for ldns
AC_ARG_WITH(ldns,
AC_HELP_STRING([--with-ldns=PATH specify prefix of path of ldns library to use])
,
[
specialldnsdir="$withval"
CPPFLAGS="$CPPFLAGS -I$withval/include"
LDFLAGS="$LDFLAGS -L$withval/lib"
]
)
AC_CHECK_LIB(ldns, ldns_rr_new,, [
AC_MSG_ERROR([Can't find ldns library])
]
)
AC_CHECK_HEADER(ldns/ldns.h,, [
AC_MSG_ERROR([Can't find ldns headers])
]
)
AH_BOTTOM([
#include <stdio.h>
#include <string.h>
#include <unistd.h>
#include <assert.h>
#if STDC_HEADERS
#include <stdlib.h>
#include <stddef.h>
#endif
#ifdef HAVE_STDINT_H
#include <stdint.h>
#endif
#ifdef HAVE_SYS_SOCKET_H
#include <sys/socket.h>
#endif
#ifdef HAVE_NETINET_IN_H
#include <netinet/in.h>
#endif
#ifdef HAVE_ARPA_INET_H
#include <arpa/inet.h>
#endif
#ifdef HAVE_TIME_H
#include <time.h>
#endif
])
#AC_CHECK_FUNCS([mkdir rmdir strchr strrchr strstr])
#AC_DEFINE_UNQUOTED(SYSCONFDIR, "$sysconfdir")
AC_CONFIG_FILES([13-unit-tests-base.Makefile])
AC_CONFIG_HEADER([config.h])
AC_OUTPUT

View File

@@ -0,0 +1,16 @@
BaseName: 16-unit-tests-edns
Version: 1.0
Description: Run EDNS unit tests on base 32 / 64 converters and sha1/sha2 functions
CreationDate: Wed Mar 15 10:15:57 CET 2006
Maintainer: Tom Carpay
Category:
Component:
CmdDepends:
Depends:
Help:
Pre: 16-unit-tests-edns.pre
Post:
Test: 16-unit-tests-edns.test
AuxFiles: 16-unit-tests-edns.Makefile.in 16-unit-tests-edns.configure.ac 16-unit-tests-edns.c
Passed:
Failure:

View File

@@ -0,0 +1,45 @@
# #-- 16-unit-tests-edns.pre--#
# source the master var file when it's there
[ -f ../.tpkg.var.master ] && source ../.tpkg.var.master
# use .tpkg.var.test for in test variable passing
[ -f .tpkg.var.test ] && source .tpkg.var.test
# svnserve resets the path, you may need to adjust it, like this:
export PATH=$PATH:/usr/sbin:/sbin:/usr/local/bin:/usr/local/sbin:.
conf=`which autoconf` ||\
conf=`which autoconf-2.59` ||\
conf=`which autoconf-2.61` ||\
conf=`which autoconf259`
hdr=`which autoheader` ||\
hdr=`which autoheader-2.59` ||\
hdr=`which autoheader-2.61` ||\
hdr=`which autoheader259`
mk=`which gmake` ||\
mk=`which make`
echo "autoconf: $conf"
echo "autoheader: $hdr"
echo "make: $mk"
opts=`../../config.status --config`
echo options: $opts
if [ ! $mk ] || [ ! $conf ] || [ ! $hdr ] ; then
echo "Error, one or more build tools not found, aborting"
exit 1
fi;
ssl=``
if [[ "$OSTYPE" == "darwin"* && -d "/opt/homebrew/Cellar/openssl@1.1" ]]; then
ssl=/opt/homebrew/Cellar/openssl@1.1/1.1.1n/
fi;
#$conf 13-unit-tests-base.configure.ac > configure && \
#chmod +x configure && \
#$hdr 13-unit-tests-base.configure.ac &&\
#eval ./configure --with-ldns=../../ with-ssl=$ssl "$opts" && \
../../config.status --file 16-unit-tests-edns.Makefile
$mk -f 16-unit-tests-edns.Makefile

View File

@@ -0,0 +1,14 @@
# #-- 16-unit-tests-edns.test --#
# source the master var file when it's there
[ -f ../.tpkg.var.master ] && source ../.tpkg.var.master
# use .tpkg.var.test for in test variable passing
[ -f .tpkg.var.test ] && source .tpkg.var.test
# svnserve resets the path, you may need to adjust it, like this:
#PATH=$PATH:/usr/sbin:/sbin:/usr/local/bin:/usr/local/sbin:.
export LD_LIBRARY_PATH="../../lib:$LD_LIBRARY_PATH"
export DYLD_LIBRARY_PATH="../../lib:$DYLD_LIBRARY_PATH"
# run the test
./16-unit-tests-edns
exit $?