zkey: Add initramfs hook

Add hook script to allow zkey utilities to be used in initramfs.

Closes: https://github.com/ibm-s390-linux/s390-tools/pull/42
Signed-off-by: Dimitri John Ledkov <xnox@ubuntu.com>
Reviewd-by Ingo Franzki <ifranzki@linux.ibm.com>
[hoeppner@linux.ibm.com: removed / in Makefile and updated commit message]
Signed-off-by: Jan Höppner <hoeppner@linux.ibm.com>
This commit is contained in:
Dimitri John Ledkov
2018-10-02 15:29:09 +01:00
committed by Jan Höppner
parent b01ef782f0
commit 3669fd4d8a
3 changed files with 67 additions and 0 deletions

View File

@@ -104,6 +104,7 @@ zkey-cryptsetup: zkey-cryptsetup.o pkey.o cca.o ep11.o utils.o $(libs)
install-common:
$(INSTALL) -d -m 755 $(DESTDIR)$(USRBINDIR)
$(INSTALL) -d -m 755 $(DESTDIR)$(MANDIR)/man1
$(MAKE) -C initramfs install
install-zkey: zkey
$(INSTALL) -g $(GROUP) -o $(OWNER) -m 755 zkey $(DESTDIR)$(USRBINDIR)

21
zkey/initramfs/Makefile Normal file
View File

@@ -0,0 +1,21 @@
# Common definitions
include ../../common.mak
INITRAMFSDIR := /usr/share/initramfs-tools
HOOKDIR := $(INITRAMFSDIR)/hooks
INITTOP := $(INITRAMFSDIR)/scripts/init-top
# HAVE_INITRAMFS
#
# This install time parameter determines whether the zkey initramfs support is
# installed (HAVE_INITRAMFS=1) or not (default). When installed, the module
# performs the following functions when mkinitramfs is run:
#
# - install a hook to include zkey related utilities and zkey repository in
# the initramfs
#
ifeq ($(HAVE_INITRAMFS),1)
install:
$(INSTALL) -m 755 -d $(DESTDIR)$(HOOKDIR) $(DESTDIR)$(INITTOP)
$(INSTALL) -m 755 hooks/s390-tools-zkey $(DESTDIR)$(HOOKDIR)
endif

View File

@@ -0,0 +1,45 @@
#!/bin/sh
#
# Copyright IBM Corp. 2022
# Copyright Canonical Ltd 2018
#
# s390-tools is free software; you can redistribute it and/or modify
# it under the terms of the MIT license. See LICENSE for details.
#
# hooks/s390-tools-zkey
# This hook script adds zkey related utilities and zkey repository
# in the initramfs
#
# Needs to run after udev or resulting udev rules could be overwritten
PREREQ="udev"
prereqs()
{
echo "$PREREQ"
}
case $1 in
prereqs)
prereqs
exit 0
;;
esac
. /usr/share/initramfs-tools/hook-functions
# Add zcrypt modules
zdev_modules="pkey paes_s390 zcrypt zcrypt_cex2a zcrypt_cex4 zcrypt_pcixcc"
for x in $zdev_modules ; do
manual_add_modules ${x}
done
# copy utils
copy_exec /sbin/chzcrypt
copy_exec /sbin/lszcrypt
copy_exec /usr/bin/zkey
copy_exec /usr/bin/zkey-cryptsetup
mkdir -p "${DESTDIR}/etc"
cp -a /etc/zkey "${DESTDIR}/etc/"