From 3c6966fe123093d4c05c001d698f4fe8d42fbaab Mon Sep 17 00:00:00 2001 From: benyamin-codez <115509179+benyamin-codez@users.noreply.github.com> Date: Tue, 19 Aug 2025 23:41:33 +1000 Subject: [PATCH] dns/bind: Make builtin ACLs available Makes the builtin ACLs (none, any. localhost and localnets) available for selection: 1. Created new custom field types: * AclField extending ArrayField * AclModelRelationField extending ModelRelationField * AclNetField extending NetworkField 2. Adds builtin ACLs as child nodes to ACL list via new AclField field type 3. Removes builtin name RegEx constraint from name field in Acl model 4. Ensures "any" and "none" builtins cannot be part of an ACL multi-select via new AclModelRelationField field type 5. Ensures network validation is skipped for builtin ACLs via new AclNetField field type 6. Updates the General and Domain models to use AclModelRelationField 7. Updates general.volt to: * Disable command buttons for builtin ACLs * Ensure the builtin ACLs are added to config.xml 8. Updates named.conf to exclude builtin ACLs from custom name list 9. Bumps model versions: * Acl to v1.0.1 * General to v1.0.13 * Domain to v1.1.3 Signed-off-by: benyamin-codez <115509179+benyamin-codez@users.noreply.github.com> --- .../OPNsense/Bind/Api/AclController.php | 6 +- .../mvc/app/models/OPNsense/Bind/Acl.xml | 10 +- .../mvc/app/models/OPNsense/Bind/Domain.xml | 6 +- .../OPNsense/Bind/FieldTypes/AclField.php | 163 +++++++++++++ .../Bind/FieldTypes/AclModelRelationField.php | 216 ++++++++++++++++++ .../OPNsense/Bind/FieldTypes/AclNetField.php | 64 ++++++ .../mvc/app/models/OPNsense/Bind/General.xml | 8 +- .../mvc/app/views/OPNsense/Bind/general.volt | 21 +- .../templates/OPNsense/Bind/named.conf | 2 + 9 files changed, 482 insertions(+), 14 deletions(-) create mode 100644 dns/bind/src/opnsense/mvc/app/models/OPNsense/Bind/FieldTypes/AclField.php create mode 100644 dns/bind/src/opnsense/mvc/app/models/OPNsense/Bind/FieldTypes/AclModelRelationField.php create mode 100644 dns/bind/src/opnsense/mvc/app/models/OPNsense/Bind/FieldTypes/AclNetField.php diff --git a/dns/bind/src/opnsense/mvc/app/controllers/OPNsense/Bind/Api/AclController.php b/dns/bind/src/opnsense/mvc/app/controllers/OPNsense/Bind/Api/AclController.php index b7a213ef0e..20d6ab6a91 100644 --- a/dns/bind/src/opnsense/mvc/app/controllers/OPNsense/Bind/Api/AclController.php +++ b/dns/bind/src/opnsense/mvc/app/controllers/OPNsense/Bind/Api/AclController.php @@ -52,7 +52,11 @@ public function addAclAction() public function delAclAction($uuid) { - return $this->delBase('acls.acl', $uuid); + $del_tgt = $this->getBase('acl', 'acls.acl', $uuid); + # skip if builtins... + if (!($del_tgt['acl']['name'] == 'any' || $del_tgt['acl']['name'] == 'localnets' || $del_tgt['acl']['name'] == 'localhost' || $del_tgt['acl']['name'] == 'none')) { + return $this->delBase('acls.acl', $uuid); + } } public function setAclAction($uuid) diff --git a/dns/bind/src/opnsense/mvc/app/models/OPNsense/Bind/Acl.xml b/dns/bind/src/opnsense/mvc/app/models/OPNsense/Bind/Acl.xml index a628f28a5f..1684a7e916 100644 --- a/dns/bind/src/opnsense/mvc/app/models/OPNsense/Bind/Acl.xml +++ b/dns/bind/src/opnsense/mvc/app/models/OPNsense/Bind/Acl.xml @@ -1,18 +1,18 @@ //OPNsense/bind/acl BIND ACL configuration - 1.0.0 + 1.0.1 - + 1 Y Y - /^(?!any$|localhost$|localnets$|none$)[0-9a-zA-Z_\-]{1,32}$/u - Should be a string between 1 and 32 characters. Allowed characters are 0-9, a-z, A-Z, _ and -. Built-in ACL names must not be used: any, localhost, localnets, none. + /^[0-9a-zA-Z_\-]{1,32}$/u + Should be a string between 1 and 32 characters. Allowed characters are 0-9, a-z, A-Z, _ and -. An ACL with this name already exists. @@ -20,7 +20,7 @@ - + Y Y diff --git a/dns/bind/src/opnsense/mvc/app/models/OPNsense/Bind/Domain.xml b/dns/bind/src/opnsense/mvc/app/models/OPNsense/Bind/Domain.xml index 6743b66ae4..58022083bb 100644 --- a/dns/bind/src/opnsense/mvc/app/models/OPNsense/Bind/Domain.xml +++ b/dns/bind/src/opnsense/mvc/app/models/OPNsense/Bind/Domain.xml @@ -1,7 +1,7 @@ //OPNsense/bind/domain BIND domain configuration - 1.1.2 + 1.1.3 @@ -42,7 +42,7 @@ Y - +