From 96129ccaabd9c9dc92ab661bf49dc98718c6f404 Mon Sep 17 00:00:00 2001 From: Franco Fichtner Date: Fri, 24 Mar 2023 14:59:38 +0100 Subject: [PATCH] dns/bind: add glue to operate as standalone DNS for core --- dns/bind/Makefile | 2 +- dns/bind/src/etc/inc/plugins.inc.d/bind.inc | 88 +++++++++++++-------- 2 files changed, 54 insertions(+), 36 deletions(-) diff --git a/dns/bind/Makefile b/dns/bind/Makefile index a4b384481..77b4de062 100644 --- a/dns/bind/Makefile +++ b/dns/bind/Makefile @@ -1,6 +1,6 @@ PLUGIN_NAME= bind PLUGIN_VERSION= 1.26 -PLUGIN_REVISION= 1 +PLUGIN_REVISION= 2 PLUGIN_COMMENT= BIND domain name service PLUGIN_DEPENDS= bind918 PLUGIN_MAINTAINER= m.muenz@gmail.com diff --git a/dns/bind/src/etc/inc/plugins.inc.d/bind.inc b/dns/bind/src/etc/inc/plugins.inc.d/bind.inc index 2b050aa2b..e2047e7f6 100644 --- a/dns/bind/src/etc/inc/plugins.inc.d/bind.inc +++ b/dns/bind/src/etc/inc/plugins.inc.d/bind.inc @@ -1,30 +1,30 @@ - All rights reserved. - - Redistribution and use in source and binary forms, with or without - modification, are permitted provided that the following conditions are met: - - 1. Redistributions of source code must retain the above copyright notice, - this list of conditions and the following disclaimer. - - 2. Redistributions in binary form must reproduce the above copyright - notice, this list of conditions and the following disclaimer in the - documentation and/or other materials provided with the distribution. - - THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, - INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY - AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE - AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, - OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF - SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS - INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN - CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) - ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE - POSSIBILITY OF SUCH DAMAGE. -*/ + * Copyright (C) 2018 Michael Muenz + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are met: + * + * 1. Redistributions of source code must retain the above copyright notice, + * this list of conditions and the following disclaimer. + * + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, + * INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY + * AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE + * AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, + * OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF + * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS + * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN + * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) + * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE + * POSSIBILITY OF SUCH DAMAGE. + */ function bind_enabled() { @@ -32,34 +32,52 @@ function bind_enabled() return (string)$model->enabled == '1'; } +function bind_configure() +{ + return [ + 'dns' => ['bind_configure_do'], + ]; +} + function bind_services() { - $services = array(); + $services = []; if (!bind_enabled()) { return $services; } - $services[] = array( + $model = new \OPNsense\Bind\General(); + + $services[] = [ 'description' => gettext('BIND Daemon'), - 'configd' => array( - 'restart' => array('bind restart'), - 'start' => array('bind start'), - 'stop' => array('bind stop'), - ), + 'ports' => [(string)$model->port], + 'configd' => [ + 'restart' => ['bind restart'], + 'start' => ['bind start'], + 'stop' => ['bind stop'], + ], + 'pidfile' => '/var/run/named/pid', 'name' => 'named', - 'pidfile' => '/var/run/named/pid' - ); + ]; return $services; } function bind_xmlrpc_sync() { - $result = array(); + $result = []; + $result['id'] = 'bind'; $result['section'] = 'OPNsense.bind'; $result['description'] = gettext('BIND domain name service'); $result['services'] = ['named']; - return array($result); + + return [$result]; +} + +function bind_configure_do($verbose) +{ + configd_run('template reload OPNsense/Bind'); + configd_run('bind restart'); }