HenriWahl / dhcpy6d

MAC address aware DHCPv6 server written in Python
https://dhcpy6d.de
GNU General Public License v2.0
94 stars 27 forks source link

dhcpy6d terminates when using store_config = file and file specified in store_file_config is empty #44

Closed FelixJacobi closed 2 years ago

FelixJacobi commented 2 years ago

Hi,

I am using store_config = file to for static IP address assignments. After upgrading to Debian Bullseye which also upgraded dhcpy6d, dhcpy6d crashes directly after start:

felix.mein-iserv.de ~ # /usr/sbin/dhcpy6d --config /etc/dhcpy6d.conf

Configuration database is not connected!

It seems that this issues is related to the fact that the specified store_file_config is empty a ka without any sections:

felix.mein-iserv.de ~ # grep store_file_config /etc/dhcpy6d.conf
store_file_config = /var/lib/iserv/ipv6-support/dhcpy6d/clients.conf
felix.mein-iserv.de ~ # cat /var/lib/iserv/ipv6-support/dhcpy6d/clients.conf
felix.mein-iserv.de ~ # 

I would expect this to be a legal configuration, as the clients.conf in my case is written from an external database and there are currently no fixed addresses to assign.

I guess that the only issue is, that self.connected = True is placed inside the for loop: https://github.com/HenriWahl/dhcpy6d/blob/28216575367aab22deb8477cb4b2ddeb1a21b59e/dhcpy6d/storage/textfile.py#L117. If I am correct, the issue can be fixed by moving the statement behind the for loop. It was a few years ago since I worked the dhcpy6d source code, so I am not sure if this would cause problems. If not, I would create a PR.

Thank you for your time.

Regards, Felix

HenriWahl commented 2 years ago

You are right - the line 117 just should get outside the for loop by using one indent less.

FelixJacobi commented 2 years ago

See https://github.com/HenriWahl/dhcpy6d/pull/46.