# This file is a rewrote of 'bind.exlib' <https://gitlab.exherbo.org/exherbo/arbor/-/blob/895c462a12394ab984bdcd2808745023826300db/packages/net-dns/bind/bind.exlib> originally licensed under GPLv2 <https://www.gnu.org/licenses/old-licenses/gpl-2.0.en.html> with copyright:
# - Copyright 2008-2016 Wulf C. Krueger <philantrop@exherbo.org>
# Changes made to this file in relation to mentioned original file are licensed under:
# Copyright (C) All rights reserved by Jacob Hrbek identified by GPG identifier assigned to the electronic mail <kreyren@rixotstudio.cz> according to the keyserver <https://keys.openpgp.org> in 19/10/2020-EU 13:30:08 CEST
# shellcheck shell=sh # Written to comply with POXIS IEEE 1003.1-2017
# shellcheck disable=SC2034 # FIXME(Krey): Provide source directory to metadata variables
# FIXME-QA(Krey): This outputs 'Kernel Linux is not implemeted...'
case "$PALUDIS_LANG" in
cs-*) die fixme "Downstream pro kernel '$(uname -s)' není implementován pro balíček '$PC/$PN-$PV::$PO' fáze '${FUNCNAME:-bind_pkg_postinst}'" ;;
en-*|*) die fixme "Downstream for kernel '$(uname -s)' is not implemented to handle '${FUNCNAME:-bind_pkg_postinst}' phase of package $PC/$PN-$PV::$PO"
esac
fi
# FIXME(Krey)
! option dane || printf 'FIXME: %s\n' "Option 'dane' is not yet implemented.."
}
bind_src_prepare() {
default
# FIXME(Krey): Report what upstream?
# TODO: Report upstream
edo sed -i "/AC_PATH_PROG(AR/d" configure.ac
edo sed -i 's/"nm"/"'$(exhost --tool-prefix)'nm"/' util/mksymtbl.pl
eautoconf
}
bind_src_configure() {
# DNM(Krey): What the fuck
myoption() {
if option ${2}; then
echo "--${1}-${3:-$(optionfmt ${2} )}=yes"
else
echo "--${1}-${3:-$(optionfmt ${2} )}=no"
fi
}
# DNM(Krey): paludis_pipe_command returned error 'E' with text 'OPTIONQ ID net-dns/bind-9.16.7:0::arbor has no choice named 'postgresql''
# DNM(Krey): Add more options
# - Should be resolved by adding 'postgresql' in MY_OPTIONS
# --enable-isc-spnego: Bundled kerberos parts
econf \
--includedir="/usr/$(exhost --target)/include" \
--localstatedir=/var \
--sysconfdir="$PALUDIS_BIND_CONFDIR" \
--enable-auto-validation \
--enable-buffer-useinline \
--enable-dnsrps \
--enable-dnsrps-dl \
--enable-isc-spnego=no \
--enable-largefile=yes \
--disable-dnstap \
--disable-fips-mode \
--disable-static \
--with-dlz-filesystem=yes \
--with-dlz-odbc=no \
--with-dlz-stub=yes \
--with-json-c \
--with-libtool=yes \
--with-libxml2=yes \
--with-openssl="/usr/$(exhost --target)" \
--with-pkcs11=no \
--with-zlib \
--without-cmocka \
--without-lmdb \
--without-python \
$(option_enable caps linux-caps) \
$(option_enable geoip) \
$(myoption with berkdb dlz-bdb) \
$(myoption with geoip maxminddb) \
$(myoption with idn libidn2) \
$(myoption with kerberos gssapi) \
$(myoption with ldap dlz-ldap) \
$(myoption with mysql dlz-mysql) \
$(myoption with postgresql dlz-postgres)
}
# Note to self or anyone who's going to work on bind: It will fail with a cryptic
# error ("RUNTIME_CHECK(dst_initialized == isc_boolean_true) failed") if you try
# to disable pkcs11 with either of the following switches:
# --with-pkcs11=no \
# --without-pkcs11 \
# *Not* using any switches turns pkcs11 off, though... Upstreams...
bind_src_install() {
default
# FIXME-QA(Krey): Check if this is needed as previous version was using /var/bind which is wrong
#remove conflicts with bind-tools
local BIND_TOOL BIND_TOOLS=( delv.1 dig.1 host.1 nslookup.1 nsupdate.1 dnssec-keygen.8 )
for BIND_TOOL in "${BIND_TOOLS[@]}"; do
edo rm "${IMAGE}"/usr/$(exhost --target)/bin/${BIND_TOOL%.*}
edo rm "${IMAGE}"/usr/share/man/man${BIND_TOOL#*.}/${BIND_TOOL}
-A "${PALUDIS_BIND_CONFGEN_ALGORITHM:-hmac-sha512}" \
-b "${PALUDIS_BIND_CONFGEN_KEYSIZE:-512}" \
-u "${PALUDIS_BIND_USER:-bind}" \
-p "${PALUDIS_BIND_PORT:-953}" \
> "${IMAGE}/$PALUDIS_BIND_CONFDIR/rndc.conf"
} || die 1 "Unable to generate file '${IMAGE}/$PALUDIS_BIND_CONFDIR/rndc.conf' using command '$RNDC_CONFGEN'"
}
# NOTE(Krey): Remove rndc.key file if it exists as we are uding rndc.conf which conflicts with each other
[ ! -f "${IMAGE}/$PALUDIS_BIND_CONFDIR/rndc.key" ] || { ${RM:-rm} "${IMAGE}/$PALUDIS_BIND_CONFDIR/rndc.key" || die 1 "Unable to remove file '${IMAGE}/$PALUDIS_BIND_CONFDIR/rndc.key'" ;}
# NOTE(Krey): We need the rndc-key defined in named.conf which makes it bad idea to expose named.conf for the users so this is a method to make that sane
// To allow zone transfer i.e. used to transfer the zone to secondary DNS
allow-transfer {
${PALUDIS_BIND_ALLOWED_TRANSFER:-127.0.0.1;}
};
// FIXME-DOCS: Info
update-policy local;
};
CONFIG
# Make sure that expected directories are available
[ -d "${IMAGE}/$PALUDIS_BIND_KEYDIR/$domain" ] || { ${MKDIR:-mkdir} --parents "${IMAGE}/$PALUDIS_BIND_KEYDIR/$domain" || die 1 "Unable to create a new directory in '${IMAGE}/$PALUDIS_BIND_KEYDIR/$domain'" ;}
[ -d "${IMAGE}/$PALUDIS_BIND_ZONEFILE_DIR/$domain" ] || { ${MKDIR:-mkdir} --parents "${IMAGE}/$PALUDIS_BIND_ZONEFILE_DIR/$domain" || die 1 "Unable to create a new directory in '${IMAGE}/$PALUDIS_BIND_ZONEFILE_DIR/$domain'";}
# FIXME-QA(Krey): This may fail to show the IP Adresses
# - 'ip -j a | jq ...'
# - 'curl ifconfig.me'
# - 'ifconfig | <regex-here>'
# - 'ip a | <regex-here>'
for ip in ${PALUDIS_HOST_IP:-$(hostname --all-ip-addresses 2>/dev/null)}; do
case "$ip" in
*.*.*.*) # IPv4
# NOTE(Krey): On 9.16.7 using '@' causes 'not at top of zone' unless the file is openned in vim changed to '$domain' and/or after changed back to '@' -> Assuming possible upstream bug
${PRINTF:-printf} '%s\n' "$domain IN A $ip" >> "${IMAGE}/$PALUDIS_BIND_ZONEFILE_DIR/$domain/$domain" ;;
*::*:*:*:*) # IPv6
${PRINTF:-printf} '%s\n' "@ IN AAAA $ip" >> "${IMAGE}/$PALUDIS_BIND_ZONEFILE_DIR/$domain/$domain" ;;
*) die bug "Case statement processing defaults for IP adresses triggered bug trap for '$ip', report downstream"
esac
done
# DNM(Krey): Used for testing
PALUDIS_BIND_NAMESERVER_IP="89.176.197.177"
# Create the A/AAAA record for nameserver
case "${PALUDIS_BIND_NAMESERVER_IP:-$(${PRINTF:-printf} '%s\n' "$PALUDIS_HOST_IP" | ${GREP:-grep} -o "^.* " | ${SED:-sed} "s/\ //")}" in
*.*.*.*) # IPv4
${PRINTF:-printf} "ns.$PALUDIS_HOSTNAME.$domain. IN A %s\n" "$PALUDIS_BIND_NAMESERVER_IP" >> "${IMAGE}/$PALUDIS_BIND_ZONEFILE_DIR/$domain/$domain" ;;
*::*:*:*:*) # IPv6
${PRINTF:-printf} "ns.$PALUDIS_HOSTNAME.$domain. IN AAAA %s\n" "$PALUDIS_BIND_NAMESERVER_IP" >> "${IMAGE}/$PALUDIS_BIND_ZONEFILE_DIR/$domain/$domain" ;;
*) die unable-to-create-nameserver-record "Unexpected IP '${PALUDIS_BIND_NAMESERVER_IP:-$(${PRINTF:-printf} '%s\n' "$PALUDIS_HOST_IP" | ${GREP:-grep} -o "^.* " | ${SED:-sed} "s/\ //")}' has been provided in logic that creates the A/AAAA record"
esac
# Set up Keys
# FIXME-QA(Krey): Command 'dnssec-keygen' doesn not support non-shorthands for arguments, submit patch upstream to improve readability
if option dnssec; then
# Create key directory
[ -d "${IMAGE}/$PALUDIS_BIND_KEYDIR/$domain" ] || { ${MKDIR:-mkdir} --parent "${IMAGE}/$PALUDIS_BIND_KEYDIR/$domain" || die false "Unable to create a new directory in '${IMAGE}/$PALUDIS_BIND_KEYDIR/$domain'" ;}
# Use command 'dnssec-keygen' from compiled target unless set by the end-user
${DNSSEC_KEYGEN:-dnssec-keygen} -a "${PALUDIS_BIND_PREFFERED_KEYGEN_ALGORITHM_KSK:-ECDSAP384SHA384}" -f KSK -c IN -L "${PALUDIS_BIND_KSK_MINTTL:-300}" -K "${IMAGE}/$PALUDIS_BIND_KEYDIR/$domain" "$domain" || die false "Unable to generate Key-Signing Key (KSK)"
# Generate Zone-Signing Key (ZSK)
${DNSSEC_KEYGEN:-dnssec-keygen} -a "${PALUDIS_BIND_PREFFERED_KEYGEN_ALGORITHM_ZSK:-ECDSAP384SHA384}" -n ZONE -c IN -L "${PALUDIS_BIND_ZSK_MINTTL:-300}" -K "${IMAGE}/$PALUDIS_BIND_KEYDIR/$domain" "$domain" || die false "Unable to generate Zone-Signing Key (ZSK)"
${PRINF:-printf} '%s\n' ";; Include keys as suggested in https://downloads.isc.org/isc/bind9/$PV/doc/arm/html/advanced.html#generating-keys" >> "${IMAGE}/$PALUDIS_BIND_ZONEFILE_DIR/$domain/$domain"
# shellcheck disable=SC2010 # Krey: Do not use 'ls \ grep' use glob expansion is invalid here as we are working with ls output
for keyfile in $(${LS:-ls} "${IMAGE}/$PALUDIS_BIND_KEYDIR/$domain" | ${GREP:-grep} ".*\.key$" | ${TR:-tr} '\n' ' '); do
# FIXME-QA(Krey): This should be probably part of post-install tests
case "$PALUDIS_BIND_CHECK_ZONEFILE" in
check)
$NAMED_CHECKZONE "$domain" "${IMAGE}/$PALUDIS_BIND_ZONEFILE_DIR/$domain/$domain" || die false "Command '$NAMED_CHECKZONE' returned non-true while checking zone-file for zone '$domain' located at '${IMAGE}/$PALUDIS_BIND_ZONEFILE_DIR/$domain/$domain'"
;;
"" | "skip" | *) einfo "Variable 'PALUDIS_BIND_CHECK_ZONEFILE' is storing value '$PALUDIS_BIND_CHECK_ZONEFILE', skipping checking zone files.."
esac
# Use command 'dnssec-signzone' from compiled target unless set by the end-user