-
Notifications
You must be signed in to change notification settings - Fork 106
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
9 changed files
with
212 additions
and
9 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
#!/bin/sh | ||
# vim: set ts=8 shiftwidth=4 softtabstop=4 expandtab smarttab colorcolumn=80: | ||
# | ||
# Copyright (c) 2024 Red Hat, Inc. | ||
# Author: Oldřich Jedlička <[email protected]> | ||
# | ||
# | ||
# This program is free software: you can redistribute it and/or modify | ||
# it under the terms of the GNU General Public License as published by | ||
# the Free Software Foundation, either version 3 of the License, or | ||
# (at your option) any later version. | ||
# | ||
# This program is distributed in the hope that it will be useful, | ||
# but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
# GNU General Public License for more details. | ||
# | ||
# You should have received a copy of the GNU General Public License | ||
# along with this program. If not, see <http://www.gnu.org/licenses/>. | ||
|
||
( | ||
set -eu | ||
. @libexecdir@/clevis-luks-tpm1-functions | ||
stop_tcsd | ||
) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
[Unit] | ||
DefaultDependencies=no | ||
|
||
[Install] | ||
# Use the default | ||
WantedBy= |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
dracut = dependency('dracut', required: false) | ||
|
||
if dracut.found() | ||
dracutdir = dracut.get_pkgconfig_variable('dracutmodulesdir') + '/60' + meson.project_name() + '-pin-tpm1' | ||
|
||
configure_file( | ||
input: 'module-setup.sh.in', | ||
output: 'module-setup.sh', | ||
install_dir: dracutdir, | ||
configuration: data, | ||
) | ||
|
||
configure_file( | ||
input: 'clevis-hook.sh.in', | ||
output: 'clevis-hook.sh', | ||
install_dir: dracutdir, | ||
configuration: data, | ||
) | ||
|
||
install_data('clevis-tcsd.conf', install_dir: dracutdir) | ||
else | ||
warning('Will not install dracut module clevis-pin-tpm2 due to missing dependencies!') | ||
endif |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,97 @@ | ||
#!/bin/bash | ||
# vim: set tabstop=8 shiftwidth=4 softtabstop=4 expandtab smarttab colorcolumn=80: | ||
# | ||
# Copyright (c) 2024 Red Hat, Inc. | ||
# Author: Oldřich Jedlička <[email protected]> | ||
# | ||
# This program is free software: you can redistribute it and/or modify | ||
# it under the terms of the GNU General Public License as published by | ||
# the Free Software Foundation, either version 3 of the License, or | ||
# (at your option) any later version. | ||
# | ||
# This program is distributed in the hope that it will be useful, | ||
# but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
# GNU General Public License for more details. | ||
# | ||
# You should have received a copy of the GNU General Public License | ||
# along with this program. If not, see <http://www.gnu.org/licenses/>. | ||
# | ||
|
||
check() { | ||
require_binaries clevis-decrypt-tpm1 tpm_version tpm_unsealdata tcsd stdbuf || return 1 | ||
if [[ $hostonly ]]; then | ||
[ -d /var/lib/tpm ] || return 1 | ||
else | ||
[ -f /usr/share/trousers/system.data.auth ] || \ | ||
[ -f /var/lib/tpm/system.data.auth ] || \ | ||
return 1 | ||
fi | ||
return 0 | ||
} | ||
|
||
depends() { | ||
echo clevis network | ||
return 0 | ||
} | ||
|
||
install() { | ||
if dracut_module_included "systemd"; then | ||
inst "$systemdsystemunitdir/tcsd.service" | ||
Check warning Code scanning / shellcheck systemdsystemunitdir is referenced but not assigned. Warning
systemdsystemunitdir is referenced but not assigned.
|
||
inst "$moddir/clevis-tcsd.conf" "$systemdsystemunitdir/tcsd.service.d/clevis-tcsd.conf" | ||
Check warning Code scanning / shellcheck moddir is referenced but not assigned. Warning
moddir is referenced but not assigned.
|
||
else | ||
inst_hook cleanup 60 "$moddir/clevis-hook.sh" | ||
inst_multiple \ | ||
awk chmod chown mkfifo mktemp ip ps stdbuf \ | ||
@libexecdir@/clevis-luks-tpm1-functions | ||
if [ -f /usr/libexec/coreutils/libstdbuf.so ]; then | ||
inst_multiple /usr/libexec/coreutils/libstdbuf.so* | ||
else | ||
inst_libdir_file 'coreutils/libstdbuf.so*' | ||
fi | ||
fi | ||
|
||
inst_multiple \ | ||
clevis-decrypt-tpm1 \ | ||
tcsd \ | ||
tpm_version \ | ||
tpm_unsealdata | ||
|
||
inst_rules 60-tpm-udev.rules | ||
|
||
if ! [[ $hostonly ]] || ! dracut_module_included "systemd"; then | ||
# /etc/hosts is installed only in host-only mode with systemd, so | ||
# we need to create our own in order to get tpm tools working. | ||
# The localhost entry is required by tpm tools. | ||
if [ ! -f "$initdir/etc/hosts" ]; then | ||
Check warning Code scanning / shellcheck initdir is referenced but not assigned. Warning
initdir is referenced but not assigned.
|
||
echo "127.0.0.1 localhost" >> "$initdir/etc/hosts" | ||
echo "::1 localhost ip6-localhost ip6-loopback" >> "$initdir/etc/hosts" | ||
echo "ff02::1 ip6-allnodes" >> "$initdir/etc/hosts" | ||
echo "ff02::2 ip6-allrouters" >> "$initdir/etc/hosts" | ||
fi | ||
fi | ||
|
||
if [[ $hostonly ]]; then | ||
inst /etc/tcsd.conf | ||
inst_multiple /var/lib/tpm/* | ||
else | ||
inst_dir /etc | ||
touch "$initdir/etc/tcsd.conf" | ||
chmod 0640 "$initdir/etc/tcsd.conf" | ||
chown root:tss "$initdir/etc/tcsd.conf" | ||
|
||
inst_dir /var/lib/tpm | ||
if [ -f /usr/share/trousers/system.data.auth ]; then | ||
inst /usr/share/trousers/system.data.auth /var/lib/tpm/system.data | ||
else | ||
inst /var/lib/tpm/system.data.auth /var/lib/tpm/system.data | ||
fi | ||
fi | ||
|
||
chown -R tss:tss "$initdir/var/lib/tpm" | ||
chmod -R u=rwX,go= "$initdir/var/lib/tpm" | ||
} | ||
|
||
installkernel() { | ||
hostonly='' instmods '=drivers/char/tpm' | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,6 @@ | ||
subdir('clevis') | ||
subdir('clevis-pin-tang') | ||
subdir('clevis-pin-tpm1') | ||
subdir('clevis-pin-tpm2') | ||
subdir('clevis-pin-sss') | ||
subdir('clevis-pin-null') |