security.sh: ensure a user keyring is linked into the session keyring
PATCH 1/1 security.sh: ensure a user keyring is linked into the session keyring
The restraint test harness is started via a systemd unit file. In this environment, there is no user keyring linked into the session keyring:
# keyctl show Session Keyring 406647380 --alswrv 0 0 keyring: _ses 148623625 ----s-rv 0 0 \_ user: invocation_id
As a result, the security.sh test fails. The logs show:
++ keyctl show
++ grep -Eo '_uid.[0-9]+'
++ head -1
++ cut -d. -f2-
+ uid=
+ '[' '' -ne 0 ']'/root/rpmbuild/BUILD/ndctl-71.1/test/security.sh: line 245: [: : integer expression expected
and:
+ keyctl search @u encrypted nvdimm:cdab-0a-07e0-feffffffkeyctl_search: Required key not available
+ keyctl search @u user nvdimm-masterkeyctl_search: Required key not available
++ hostname
+ '[' -f /etc/ndctl/keys/nvdimm_cdab-0a-07e0-feffffff_storageqe-40.sqe.lab.eng.bos.redhat.com.blob ']'
+ setup_keys
+ '[' '!' -d /etc/ndctl/keys ']'
+ '[' -f /etc/ndctl/keys/nvdimm-master.blob ']'
+ '[' -f /etc/ndctl/keys/tpm.handle ']'
+ dd if=/dev/urandom bs=1 count=32
+ keyctl padd user nvdimm-master @u
++ keyctl search @u user nvdimm-master
+ keyctl pipe 416513477keyctl_read_alloc: Permission denied
++ err 47
+++ basename /root/rpmbuild/BUILD/ndctl-71.1/test/security.sh
++ echo test/security.sh: failed at line 47
++ '[' -n '' ']'
++ exit 1
To fix this, create a new session keyring and link in the user keyring from within the script.
test/security.sh +3 -0
@@ -43,6 +43,9 @@ setup_keys() backup_handle=1 fi + # Make sure there is a session and a user keyring linked into it + keyctl new_session + keyctl link @u @s dd if=/dev/urandom bs=1 count=32 2>/dev/null | keyctl padd user "$masterkey" @u keyctl pipe "$(keyctl search @u user $masterkey)" > "$masterpath" }
Quoted 41 lines · Jeff Moyer
The restraint test harness is started via a systemd unit file. In this environment, there is no user keyring linked into the session keyring:
# keyctl show Session Keyring 406647380 --alswrv 0 0 keyring: _ses 148623625 ----s-rv 0 0 \_ user: invocation_idAs a result, the
security.shtest fails. The logs show:++ keyctl show
++ grep -Eo '_uid.[0-9]+'
++ head -1
++ cut -d. -f2-
+ uid=
+ '[' '' -ne 0 ']'/root/rpmbuild/BUILD/ndctl-71.1/test/security.sh: line 245: [: : integer expression expectedand:
+ keyctl search @u encrypted nvdimm:cdab-0a-07e0-feffffff
keyctl_search: Required key not available
+ keyctl search @u user nvdimm-masterkeyctl_search: Required key not available
++ hostname
+ '[' -f/etc/ndctl/keys/nvdimm_cdab-0a-07e0-feffffff_storageqe-40.sqe.lab.eng.bos.redhat.com.blob']'
+setup_keys
+ '[' '!' -d/etc/ndctl/keys']'
+ '[' -f/etc/ndctl/keys/nvdimm-master.blob']'
+ '[' -f/etc/ndctl/keys/tpm.handle']'
+ dd if=/dev/urandom bs=1 count=32
+ keyctl padd user nvdimm-master @u
++ keyctl search @u user nvdimm-master
+ keyctl pipe 416513477keyctl_read_alloc: Permission denied
++ err 47
+++ basename/root/rpmbuild/BUILD/ndctl-71.1/test/security.sh
++ echotest/security.sh: failed at line 47
++ '[' -n '' ']'
++ exit 1
Quoted 4 lines
To fix this, create a new session keyring and link in the user keyring from within the script.
Signed-off-by Jeff Moyer <[email protected]>
Thanks Jeff!
Quoted 17 lines
test/security.sh +3
-0@@ -43,6 +43,9 @@ setup_keys() backup_handle=1 fi + # Make sure there is a session and a user keyring linked into it + keyctl new_session + keyctl link @u @s dd if=/dev/urandom bs=1 count=32 2>/dev/null | keyctl padd user "$masterkey" @u keyctl pipe "$(keyctl search @u user $masterkey)" > "$masterpath" }