From e2b4e76d81198809beca0d3e3603618339649189 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Old=C5=99ich=20Jedli=C4=8Dka?= Date: Wed, 4 Dec 2024 03:16:03 +0100 Subject: [PATCH] luks: check if keyutils are usable before running tests MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit The command fails in Docker or otherwise limited environments, so skip the test when it is not usable. Signed-off-by: Oldřich Jedlička --- src/luks/tests/meson.build | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/src/luks/tests/meson.build b/src/luks/tests/meson.build index cd217396..928bf4d5 100644 --- a/src/luks/tests/meson.build +++ b/src/luks/tests/meson.build @@ -8,8 +8,14 @@ cryptsetup = find_program('cryptsetup', required: true) # Use keyctl to check an existing token id can be created from # kernel keyring password keyutils = find_program('keyctl', required: false) +keyutils_usable = false if keyutils.found() - message('keyutils installed') + keyutils_usable = run_command(keyutils, 'session', '-', '/bin/true', capture: false, check: false).returncode() == 0 + if keyutils_usable + message('keyutils installed') + else + warning('keyutils installed, but running fails (are you inside Docker?), unable to test existing token id binding') + endif else warning('keyutils not installed, unable to test existing token id binding') endif @@ -82,7 +88,7 @@ if luksmeta_data.get('OLD_CRYPTSETUP') == '0' test('unbind-unbound-slot-luks2', find_program('unbind-unbound-slot-luks2'), env: env) test('unbind-luks2', find_program('unbind-luks2'), env: env, timeout: 60) - if keyutils.found() and luksmeta_data.get('OLD_CRYPTSETUP_EXISTING_TOKEN_ID') == '0' + if keyutils.found() and keyutils_usable and luksmeta_data.get('OLD_CRYPTSETUP_EXISTING_TOKEN_ID') == '0' test('bind-luks2-ext-token', find_program('bind-luks2-ext-token'), env: env, timeout: 60) endif