Skip to content

Commit

Permalink
systemd: drop ncat dependency
Browse files Browse the repository at this point in the history
When using systemd, i.e., clevis-luks-askpass, we use ncat to send
the decrypted password to the systemd socket as per systemd's password
agents specification [1].

However, systemd itself has a utility that does exactly that,
systemd-reply-password.

In this commit we drop the ncat dependency and instead use
systemd-reply-password in clevis-luks-askpass.

[1] https://systemd.io/PASSWORD_AGENTS/
  • Loading branch information
sergio-correia committed Dec 3, 2020
1 parent 2ea5106 commit 9cdd041
Show file tree
Hide file tree
Showing 4 changed files with 20 additions and 6 deletions.
1 change: 0 additions & 1 deletion INSTALL.md
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,6 @@ following sections describe them for the supported platforms.
* [tang](https://github.com/latchset/tang)
* [curl](https://github.com/curl/curl)
* [tpm2-tools](https://github.com/tpm2-software/tpm2-tools)
* [ncat](https://nmap.org/ncat/) (for clevis-luks-askpass)

### Fedora

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ while true; do
fi

uuid="$(cryptsetup luksUUID "${d}")"
if ! printf '+%s' "${pt}" | ncat -U -u --send-only "${s}"; then
if ! printf '%s' "${pt}" | @SYSTEMD_REPLY_PASS@ 1 "${s}"; then
echo "Unable to unlock ${d} (UUID=${uuid}) with recovered passphrase" >&2
continue
fi
Expand Down
4 changes: 2 additions & 2 deletions src/luks/systemd/dracut/clevis/module-setup.sh.in
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@ install() {

inst_multiple \
/etc/services \
@SYSTEMD_REPLY_PASS@ \
@libexecdir@/clevis-luks-askpass \
clevis-luks-common-functions \
grep sed cut \
Expand All @@ -45,8 +46,7 @@ install() {
luksmeta \
clevis \
mktemp \
jose \
ncat
jose

dracut_need_initqueue
}
19 changes: 17 additions & 2 deletions src/luks/systemd/meson.build
Original file line number Diff line number Diff line change
@@ -1,6 +1,15 @@
systemd = dependency('systemd', required: false)

if systemd.found()
sd_reply_pass = find_program(
join_paths(get_option('prefix'), get_option('libdir'), 'systemd', 'systemd-reply-password'),
join_paths(get_option('prefix'), 'lib', 'systemd', 'systemd-reply-password'),
join_paths('/', 'usr', get_option('libdir'), 'systemd', 'systemd-reply-password'),
join_paths('/', 'usr', 'lib', 'systemd', 'systemd-reply-password'),
required: false
)

if systemd.found() and sd_reply_pass.found()
data.set('SYSTEMD_REPLY_PASS', sd_reply_pass.path())
subdir('dracut')

unitdir = systemd.get_pkgconfig_variable('systemdsystemunitdir')
Expand All @@ -12,8 +21,14 @@ if systemd.found()
configuration: data,
)

configure_file(
input: 'clevis-luks-askpass.in',
output: 'clevis-luks-askpass',
install_dir: libexecdir,
configuration: data
)

install_data('clevis-luks-askpass.path', install_dir: unitdir)
install_data('clevis-luks-askpass', install_dir: libexecdir)
else
warning('Will not install systemd support due to missing dependencies!')
endif

0 comments on commit 9cdd041

Please sign in to comment.