From de23c02c7c1b74e09b306da4052e08ff3d5f0007 Mon Sep 17 00:00:00 2001 From: Sander Kromwijk Date: Tue, 16 Feb 2021 06:08:33 -0500 Subject: [PATCH] Revert "Support svr host (#1853)" (#1860) This reverts commit ef8a6793f431d931cd7422951530955aa615ac11. --- dnsmasq/CHANGELOG.md | 4 -- dnsmasq/DOCS.md | 30 --------------- dnsmasq/Dockerfile | 4 +- dnsmasq/apparmor.txt | 38 +++++++------------ dnsmasq/build.json | 10 ++--- dnsmasq/config.json | 15 +------- dnsmasq/data/dnsmasq.conf | 7 ++++ dnsmasq/data/run.sh | 31 +++++++++++++++ dnsmasq/rootfs/etc/cont-init.d/config.sh | 12 ------ dnsmasq/rootfs/etc/services.d/dnsmasq/finish | 8 ---- dnsmasq/rootfs/etc/services.d/dnsmasq/run | 7 ---- .../rootfs/usr/share/tempio/dnsmasq.config | 30 --------------- 12 files changed, 62 insertions(+), 134 deletions(-) create mode 100644 dnsmasq/data/dnsmasq.conf create mode 100755 dnsmasq/data/run.sh delete mode 100644 dnsmasq/rootfs/etc/cont-init.d/config.sh delete mode 100644 dnsmasq/rootfs/etc/services.d/dnsmasq/finish delete mode 100644 dnsmasq/rootfs/etc/services.d/dnsmasq/run delete mode 100644 dnsmasq/rootfs/usr/share/tempio/dnsmasq.config diff --git a/dnsmasq/CHANGELOG.md b/dnsmasq/CHANGELOG.md index 8334af4..3c67c5e 100644 --- a/dnsmasq/CHANGELOG.md +++ b/dnsmasq/CHANGELOG.md @@ -1,9 +1,5 @@ # Changelog -## 1.4 - -- Adds support for srv-host records - ## 1.3 - Rewrites add-on onto Bashio diff --git a/dnsmasq/DOCS.md b/dnsmasq/DOCS.md index fb604bb..ac3f7da 100644 --- a/dnsmasq/DOCS.md +++ b/dnsmasq/DOCS.md @@ -32,12 +32,6 @@ forwards: hosts: - host: home.mydomain.io ip: 192.168.1.10 -services: - - srv: _ldap._tcp.pdc._msdcs.mydomain.io - host: dc.mydomain.io - port: 389 - priority: 0 - weight: 100 ``` ### Option: `defaults` (required) @@ -82,30 +76,6 @@ The hostname or domainname to resolve locally. The IP address Dnsmasq should respond with in its DNS answer. -### Option: `services` (optional) - -This option allows you to provide srv-host records. - -#### Option: `services.srv` - -The service to resolve. - -#### Option: `services.host` - -The host that contain the service. - -#### Option: `services.port` - -The port number for the service. - -#### Option: `services.priority` - -The priority for the service. - -#### Option: `services.weight` - -The weight for the service. - ## Support Got questions? diff --git a/dnsmasq/Dockerfile b/dnsmasq/Dockerfile index c2a5747..2eb264b 100644 --- a/dnsmasq/Dockerfile +++ b/dnsmasq/Dockerfile @@ -8,5 +8,7 @@ ENV LANG C.UTF-8 RUN apk add --no-cache dnsmasq # Copy data -COPY rootfs / +COPY data/run.sh / +COPY data/dnsmasq.conf /etc/ +CMD [ "/run.sh" ] diff --git a/dnsmasq/apparmor.txt b/dnsmasq/apparmor.txt index dd924ca..47e961f 100644 --- a/dnsmasq/apparmor.txt +++ b/dnsmasq/apparmor.txt @@ -2,27 +2,6 @@ profile dnsmasq flags=(attach_disconnected,mediate_deleted) { #include - - /usr/lib/bashio/bashio ix, - - # S6-Overlay - /bin/** ix, - /usr/bin/** ix, - /usr/lib/bashio/** ix, - /etc/s6/** ix, - /run/s6/** ix, - /etc/services.d/** rwix, - /etc/cont-init.d/** rwix, - /etc/cont-finish.d/** rwix - - # Data access - /data/** rw, - - /usr/sbin/dnsmasq cx, -} - -profile /usr/sbin/dnsmasq flags=(attach_disconnected,mediate_deleted) { - #include #include capability net_bind_service, @@ -32,9 +11,20 @@ profile /usr/sbin/dnsmasq flags=(attach_disconnected,mediate_deleted) { network inet raw, network inet6 raw, + /bin/busybox ix, + /bin/bash ix, + /usr/bin/jq ix, + /usr/sbin/dnsmasq ix, + /etc/dnsmasq.conf rw, - /run/*dnsmasq*.pid w, - /run/dnsmasq/ r, - /run/dnsmasq/* rw, + /{,var/}run/*dnsmasq*.pid w, + /{,var/}run/dnsmasq/ r, + /{,var/}run/dnsmasq/* rw, + + /usr/lib/bashio/bashio ix, + /dev/tty rw, /tmp/* rw, + + /run.sh rix, + /data/** r, } diff --git a/dnsmasq/build.json b/dnsmasq/build.json index 9ff70b4..bbf7ade 100644 --- a/dnsmasq/build.json +++ b/dnsmasq/build.json @@ -1,9 +1,9 @@ { "build_from": { - "aarch64": "homeassistant/aarch64-base:3.13", - "amd64": "homeassistant/amd64-base:3.13", - "armhf": "homeassistant/armhf-base:3.13", - "armv7": "homeassistant/armv7-base:3.13", - "i386": "homeassistant/i386-base:3.13" + "aarch64": "homeassistant/aarch64-base:3.10", + "amd64": "homeassistant/amd64-base:3.10", + "armhf": "homeassistant/armhf-base:3.10", + "armv7": "homeassistant/armv7-base:3.10", + "i386": "homeassistant/i386-base:3.10" } } diff --git a/dnsmasq/config.json b/dnsmasq/config.json index 62b176a..f3b2b73 100644 --- a/dnsmasq/config.json +++ b/dnsmasq/config.json @@ -1,13 +1,12 @@ { "name": "Dnsmasq", - "version": "1.4", + "version": "1.3", "slug": "dnsmasq", "description": "A simple DNS server", "url": "https://github.com/home-assistant/hassio-addons/tree/master/dnsmasq", "arch": ["armhf", "armv7", "aarch64", "amd64", "i386"], "advanced": true, "startup": "system", - "init": false, "ports": { "53/tcp": 53, "53/udp": 53 @@ -15,8 +14,7 @@ "options": { "defaults": ["8.8.8.8", "8.8.4.4"], "forwards": [], - "hosts": [], - "services": [] + "hosts": [] }, "schema": { "defaults": ["str"], @@ -31,15 +29,6 @@ "host": "str", "ip": "str" } - ], - "services": [ - { - "srv": "str", - "host": "str", - "port": "str", - "priority": "int", - "weight": "int" - } ] }, "image": "homeassistant/{arch}-addon-dnsmasq" diff --git a/dnsmasq/data/dnsmasq.conf b/dnsmasq/data/dnsmasq.conf new file mode 100644 index 0000000..ffd98e9 --- /dev/null +++ b/dnsmasq/data/dnsmasq.conf @@ -0,0 +1,7 @@ +no-resolv +no-hosts +keep-in-foreground +log-queries +log-facility=- +no-poll +user=root diff --git a/dnsmasq/data/run.sh b/dnsmasq/data/run.sh new file mode 100755 index 0000000..1f5f9e2 --- /dev/null +++ b/dnsmasq/data/run.sh @@ -0,0 +1,31 @@ +#!/usr/bin/env bashio +set -e + +CONFIG="/etc/dnsmasq.conf" + +bashio::log.info "Configuring dnsmasq..." + +# Add default forward servers +for server in $(bashio::config 'defaults'); do + echo "server=${server}" >> "${CONFIG}" +done + +# Create domain forwards +for forward in $(bashio::config 'forwards|keys'); do + DOMAIN=$(bashio::config "forwards[${forward}].domain") + SERVER=$(bashio::config "forwards[${forward}].server") + + echo "server=/${DOMAIN}/${SERVER}" >> "${CONFIG}" +done + +# Create static hosts +for host in $(bashio::config 'hosts|keys'); do + HOST=$(bashio::config "hosts[${host}].host") + IP=$(bashio::config "hosts[${host}].ip") + + echo "address=/${HOST}/${IP}" >> "${CONFIG}" +done + +# Run dnsmasq +bashio::log.info "Starting dnsmasq..." +exec dnsmasq -C "${CONFIG}" -z < /dev/null diff --git a/dnsmasq/rootfs/etc/cont-init.d/config.sh b/dnsmasq/rootfs/etc/cont-init.d/config.sh deleted file mode 100644 index 24d3e00..0000000 --- a/dnsmasq/rootfs/etc/cont-init.d/config.sh +++ /dev/null @@ -1,12 +0,0 @@ -#!/usr/bin/with-contenv bashio -# ============================================================================== -# DNSMASQ config -# ============================================================================== - -CONFIG="/etc/dnsmasq.conf" -bashio::log.info "Configuring dnsmasq..." -tempio \ - -conf /data/options.json \ - -template /usr/share/tempio/dnsmasq.config \ - -out "${CONFIG}" - diff --git a/dnsmasq/rootfs/etc/services.d/dnsmasq/finish b/dnsmasq/rootfs/etc/services.d/dnsmasq/finish deleted file mode 100644 index 2d2d9e5..0000000 --- a/dnsmasq/rootfs/etc/services.d/dnsmasq/finish +++ /dev/null @@ -1,8 +0,0 @@ -#!/usr/bin/execlineb -S0 -# ============================================================================== -# Take down the S6 supervision tree when dnsmasq fails -# ============================================================================== -if { s6-test ${1} -ne 0 } -if { s6-test ${1} -ne 256 } - -s6-svscanctl -t /var/run/s6/services diff --git a/dnsmasq/rootfs/etc/services.d/dnsmasq/run b/dnsmasq/rootfs/etc/services.d/dnsmasq/run deleted file mode 100644 index 028a429..0000000 --- a/dnsmasq/rootfs/etc/services.d/dnsmasq/run +++ /dev/null @@ -1,7 +0,0 @@ -#!/usr/bin/with-contenv bashio -CONFIG="/etc/dnsmasq.conf" - -# Run dnsmasq -bashio::log.info "Starting dnsmasq..." -exec dnsmasq -C "${CONFIG}" -z < /dev/null - diff --git a/dnsmasq/rootfs/usr/share/tempio/dnsmasq.config b/dnsmasq/rootfs/usr/share/tempio/dnsmasq.config deleted file mode 100644 index 36d416a..0000000 --- a/dnsmasq/rootfs/usr/share/tempio/dnsmasq.config +++ /dev/null @@ -1,30 +0,0 @@ -# Automatically generated do not edit - -no-resolv -no-hosts -keep-in-foreground -log-queries -log-facility=- -no-poll -user=root - -# Default forward servers -{{ range .defaults }} -server={{ . }} -{{ end }} - -# Domain forwards -{{ range .forwards }} -server=/{{ .domain }}/{{ .server }} -{{ end }} - -# Static hosts -{{ range .hosts }} -address=/{{ .host }}/{{ .ip }} -{{ end }} - -# Static srv-hosts -{{ range .services }} -srv-host={{ .srv }},{{ .host }},{{ .port }},{{ .priority }},{{ .weight }} -{{ end }} -