summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorAlexandre Derumier <aderumier@odiso.com>2023-11-18 15:13:14 +0100
committerThomas Lamprecht <t.lamprecht@proxmox.com>2023-11-18 16:00:10 +0100
commit39062bc53a95ef5a0e45171e61aa5df3e52ca898 (patch)
tree15a663a9547d3561d5c6b0e67a5d90311cc49b9b /src
parenta26a43bf9766f2b8142a25aecc8841ec336e7d98 (diff)
dhcp : dnsmasq: generate dbus policy
Signed-off-by: Alexandre Derumier <aderumier@odiso.com>
Diffstat (limited to 'src')
-rw-r--r--src/PVE/Network/SDN/Dhcp/Dnsmasq.pm26
1 files changed, 26 insertions, 0 deletions
diff --git a/src/PVE/Network/SDN/Dhcp/Dnsmasq.pm b/src/PVE/Network/SDN/Dhcp/Dnsmasq.pm
index 0dd6436..7b54532 100644
--- a/src/PVE/Network/SDN/Dhcp/Dnsmasq.pm
+++ b/src/PVE/Network/SDN/Dhcp/Dnsmasq.pm
@@ -151,6 +151,31 @@ sub configure_range {
sub before_configure {
my ($class, $dhcpid) = @_;
+ my $dbus_config = <<DBUSCFG;
+<!DOCTYPE busconfig PUBLIC
+ "-//freedesktop//DTD D-BUS Bus Configuration 1.0//EN"
+ "http://www.freedesktop.org/standards/dbus/1.0/busconfig.dtd">
+<busconfig>
+ <policy user="root">
+ <allow own="uk.org.thekelleys.dnsmasq.$dhcpid"/>
+ <allow send_destination="uk.org.thekelleys.dnsmasq.$dhcpid"/>
+ </policy>
+ <policy user="dnsmasq">
+ <allow own="uk.org.thekelleys.dnsmasq.$dhcpid"/>
+ <allow send_destination="uk.org.thekelleys.dnsmasq.$dhcpid"/>
+ </policy>
+ <policy context="default">
+ <deny own="uk.org.thekelleys.dnsmasq.$dhcpid"/>
+ <deny send_destination="uk.org.thekelleys.dnsmasq.$dhcpid"/>
+ </policy>
+</busconfig>
+DBUSCFG
+
+ PVE::Tools::file_set_contents(
+ "/etc/dbus-1/system.d/dnsmasq.$dhcpid.conf",
+ $dbus_config
+ );
+
my $config_directory = "$DNSMASQ_CONFIG_ROOT/$dhcpid";
mkdir($config_directory, 755) if !-d $config_directory;
@@ -201,6 +226,7 @@ sub after_configure {
my $service_name = "dnsmasq\@$dhcpid";
+ PVE::Tools::run_command(['systemctl', 'reload', 'dbus']);
PVE::Tools::run_command(['systemctl', 'enable', $service_name]);
PVE::Tools::run_command(['systemctl', 'restart', $service_name]);
}