Skip to content

Commit

Permalink
dracut-sshd-networkmanager subpackage
Browse files Browse the repository at this point in the history
  99sshd-auto-networkmanager adjusts nm-initrd.service to run for dracut-sshd.
- If config is lacking auto DHCP ethernet in the same manner as rootfs NetworkManager.
- Clean network teardown prior to switchroot avoids conflicts and gives OS full control.
- Settings could be overriden by copying ifcfg or nmconnection settings into the initrd.

Fixes: Issues gsauthof#63 gsauthof#68
Signed-off-by: Warren Togami <[email protected]>
  • Loading branch information
wtogami authored and psgreco committed Jun 17, 2023
1 parent 51f2ee7 commit a6e0712
Show file tree
Hide file tree
Showing 2 changed files with 45 additions and 0 deletions.
26 changes: 26 additions & 0 deletions 99sshd-networkmanager/module-setup.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
#!/bin/bash

# 2023, Warren Togami <[email protected]>
# SPDX-License-Identifier: GPL-3.0-or-later

# called by dracut
check() {
require_binaries sshd || return 1
# 0 enables by default, 255 only on request
return 0
}

# called by dracut
depends() {
return 0
}

# called by dracut
install() {
# allow NetworkManager to auto configure "Wired connection #" DHCP connections for Ethernet interfaces
rm -f "$initdir/usr/lib/NetworkManager/conf.d/initrd-no-auto-default.conf"

# tell Networkmanager to run
echo "rd.neednet" >> "${initdir}/etc/cmdline.d/50neednet.conf"
return 0
}
19 changes: 19 additions & 0 deletions dracut-sshd.spec
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,21 @@ initramfs. It allows for remote unlocking of a fully encrypted
root filesystem and remote access to the Dracut emergency shell
(i.e. early userspace).

%package networkmanager
Summary: Enables NetworkManager for sshd during initramfs
Requires: dracut-sshd
Requires: NetworkManager

%description networkmanager
This module enables dracut network-manager settings for dracut-sshd.

- If no configuration is provided it uses DHCP to bring up ethernet
in the same manner as rootfs NetworkManager.
- Cleanly tears down networking prior to switchroot to avoid conflicts
thereby allowing the OS full control of networking config.
- Network settings could be overriden by copying ifcfg or nmconnection
settings into the initrd. e.g. static IP's

%prep
{{{ git_dir_setup_macro }}}

Expand All @@ -30,6 +45,7 @@ root filesystem and remote access to the Dracut emergency shell
mkdir -p %{buildroot}/usr/lib/dracut/modules.d
cp -r 46sshd %{buildroot}/usr/lib/dracut/modules.d/
cp -r 99sshd-shadow-fixup %{buildroot}/usr/lib/dracut/modules.d/
cp -r 99sshd-networkmanager %{buildroot}/usr/lib/dracut/modules.d/

%files
%dir /usr/lib/dracut/modules.d/46sshd/
Expand All @@ -43,6 +59,9 @@ cp -r 99sshd-shadow-fixup %{buildroot}/usr/lib/dracut/modules.d/
%doc example/20-wired.network
%doc example/90-networkd.conf

%files networkmanager
/usr/lib/dracut/modules.d/99sshd-networkmanager/module-setup.sh

%changelog
* Sat May 27 2023 Georg Sauthoff <[email protected]> - 0.6.5-1
- eliminate tmpfiles and fix Debian/Ubuntu support
Expand Down

0 comments on commit a6e0712

Please sign in to comment.