gsauthof / dracut-sshd

Provide SSH access to initramfs early user space on Fedora and other systems that use Dracut

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Better way to detect systemd-network presence

ibukanov opened this issue · comments

The depends function checks for presence of systemd-networkd using:

 -L /etc/systemd/system/multi-user.target.wants/systemd-networkd.service

This misses the case when systemd-networkd is enabled via drop-in config file in multi-user.target.d or via a systemd generator with a link under /run/systemd.

The code should instead use systemctl -q is-enabled systemd-networkd or perhaps just check for the presence of systemd-networkd binary.

Using systemctl -q is-enabled is a good idea.

Just checking for the systemd-networkd binary is problematic because of cases where the binary is available but unused. Then it would just increase the size of the initramfs since root configures initrd network by other means (e.g. via the ifcfg module).

Looking at the code I'm unsure if the network dependency is a good choice. I mean perhaps systemd-networkd is disabled but root still wants to use systemd-networkd in early-boot. In that case the network dependency would superfluously increase the initramfs size, too.

If systemd-networkd is enabled then the systemd-networkd dependency probably makes sense in most cases. But perhaps there is a minority case where early boot should still use a different network method.

Perhaps it would make sense to just remove those dependencies and let the user decide what to include for networking during early userspace?

Removing dependencies suits me better. I have an installation script that writes /etc/dracut.conf.d where I can include the necessary dependencies. On the other hand it implies an extra configuration step during install for people who do have systemd-networkd running.

So as a conservative change I suggest to check for systemctl -q is-active systemd-networkd (not is-enabled as that may not cover all cases of systemd-networkd activation).

Ok, I've removed the dependency logic now.