/mandos/trunk

To get this branch, use:
bzr branch http://term.recompile.se/loggerhead/mandos/trunk

« back to all changes in this revision

Viewing changes to dracut-module/cmdline-mandos-systemd.sh

  • Committer: Teddy Hogeborn
  • Date: 2026-05-01 23:11:34 UTC
  • Revision ID: teddy@recompile.se-20260501231134-n6lmxgis6xy0x9rp
Fix kernel command line option "mandos=connect:<ip>:<port>" with dracut

When using dracut, the kernel command line option
"mandos=connect:<ip>:<port>" is ignored entirely.  Fix this.

* Makefile (install-client-nokey, uninstall-client): Install (and
  uninstall) "dracut-module/cmdline-mandos-systemd.sh".
* debian/mandos-client.lintian-overrides (mandos-client binary): Added
  "executable-in-usr-lib
  [usr/lib/dracut/modules.d/90mandos/cmdline-mandos-systemd.sh]"
* dracut-module/ask-password-mandos.service ([Service]/ExecStart):
  Append "$MANDOS_CLIENT_CONNECT".
* dracut-module/cmdline-mandos-systemd.sh: New file.
* dracut-module/cmdline-mandos.sh: If the "mandos=connect:<ip>:<port>"
  kernel command line option is used, append suitable options to
  /etc/mandos/plugin-runner.conf.
* dracut-module/module-setup.sh: Install dracut "cmdline" hook
  "cmdline-mandos-systemd.sh".

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
#!/bin/sh
 
2
#
 
3
# This file should be present in the root file system directory
 
4
# /usr/lib/dracut/modules.d/90mandos.  When dracut creates the
 
5
# initramfs image, dracut will run the "module-setup.sh" file in the
 
6
# same directory, which (when using the "systemd" dracut module) will
 
7
# copy this file ("cmdline-mandos-systemd.sh") into the initramfs as
 
8
# "/lib/dracut/hooks/cmdline/20-cmdline-mandos-systemd.sh".
 
9
 
10
# Despite the above #!/bin/sh line and the executable flag, this file
 
11
# is not executed; this file is sourced by the /init script in the
 
12
# initramfs image created by dracut.
 
13
 
 
14
type getarg > /dev/null 2>&1 || . /lib/dracut-lib.sh
 
15
 
 
16
if getargbool 1 mandos && [ -e /lib/dracut-crypt-lib.sh ]; then
 
17
    if mandos=$(getarg mandos); then
 
18
        case "$mandos" in
 
19
            connect:*) mandos_connect="${mandos#connect:}" ;;
 
20
        esac
 
21
        if [ -n "$mandos_connect" ]; then
 
22
            # systemd >= 254
 
23
            # systemctl edit --runtime ask-password-mandos.service --stdin <<-EOF
 
24
            # ...
 
25
            # EOF
 
26
            mkdir --parents /run/systemd/system/ask-password-mandos.service.d
 
27
            cat > /run/systemd/system/ask-password-mandos.service.d/connect.conf <<-EOF
 
28
                [Service]
 
29
                Environment="MANDOS_CLIENT_CONNECT=--connect=$mandos_connect"
 
30
                EOF
 
31
            systemctl daemon-reload
 
32
        fi
 
33
    fi
 
34
fi