Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Bug: Disabled DHCP interfaces are enabled on dhcpd.conf (patch provided) #1903

Open
patphobos opened this issue Oct 30, 2019 · 1 comment · May be fixed by #1905

Comments

@patphobos
Copy link

@patphobos patphobos commented Oct 30, 2019

Hi,

this is a patch to only generate configuration of enabled dhcp interfaces.
because pre-configured interfaces with ranges configured are inserted in dhcpd.conf even if the interface is marked has "disabled".

patch for : /usr/share/perl5/EBox/DHCP.pm

--- EBoxOrig/DHCP.pm    2018-09-05 11:12:04.000000000 +0200
+++ EBoxPatched/DHCP.pm 2019-10-30 17:43:10.768880250 +0100
@@ -737,6 +737,16 @@
     return $model->addresses($iface, $readOnly);
 }

+sub dhcpEnabled
+{
+    my ($self, $iface) = @_;
+
+    my $ifaceModel = $self->model('Interfaces');
+    my $ifaceRow = $ifaceModel->findRow(iface => $iface);
+    return $ifaceRow->valueByName('enabled');
+}
+
+
 # Group: Static or class methods

 # Method: ConfDir
@@ -1187,6 +1197,8 @@
             my $address = $net->ifaceAddress($iface);
             my $netmask = $net->ifaceNetmask($iface);
             my $network = ip_network($address, $netmask);
+
+            $iflist{$iface}->{'enabled'} = $self->dhcpEnabled($iface);

             $iflist{$iface}->{'net'} = $network;
             $iflist{$iface}->{'address'} = $address;

patch for dhcpd.conf.mas :

--- orig/dhcpd.conf.mas        2018-09-05 11:12:04.000000000 +0200
+++ patched/dhcpd.conf.mas        2019-10-30 17:41:09.252997815 +0100
@@ -71,7 +71,7 @@
 <%perl>
             # Write configuration if there are any range or fixed addresses
             my $ifaceToWrite = 0;
-            if (exists $ifaces{$iface}) {
+            if (exists $ifaces{$iface} && $ifaces{$iface}->{enabled}) {
                 if (@{$ifaces{$iface}->{ranges}} > 0) {
                     $ifaceToWrite = 1;
                 } elsif  (values %{$ifaces{$iface}->{fixed}} > 0 ) {
@patphobos patphobos changed the title Disabled DHCP interfaces are enabled on dhcpd.conf (patch provided) Bug: Disabled DHCP interfaces are enabled on dhcpd.conf (patch provided) Oct 30, 2019
@Neustradamus

This comment has been minimized.

Copy link

@Neustradamus Neustradamus commented Nov 2, 2019

@brunolorente: Have you seen this ticket and the PR?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
2 participants
You can’t perform that action at this time.