Blame SOURCES/0009-feat-rename-the-test-pin-to-null-pin.patch

9742fa
From 87d690e41621878f70a3f6f3305dd23746d1b857 Mon Sep 17 00:00:00 2001
9742fa
From: Antonio Murdaca <runcom@linux.com>
9742fa
Date: Wed, 1 Dec 2021 14:17:53 +0100
9742fa
Subject: [PATCH 9/9] feat: rename the test pin to null pin
9742fa
9742fa
Signed-off-by: Antonio Murdaca <runcom@linux.com>
9742fa
---
9742fa
 src/initramfs-tools/hooks/clevis.in           |  1 +
9742fa
 .../dracut/clevis-pin-null/meson.build        | 14 ++++++++++
9742fa
 .../dracut/clevis-pin-null/module-setup.sh.in | 28 +++++++++++++++++++
9742fa
 src/luks/systemd/dracut/meson.build           |  1 +
9742fa
 ...levis-decrypt-test => clevis-decrypt-null} |  4 +--
9742fa
 ...levis-encrypt-test => clevis-encrypt-null} |  4 +--
9742fa
 src/pins/sss/meson.build                      |  5 +++-
9742fa
 src/pins/sss/{pin-test => pin-null}           |  4 +--
9742fa
 src/pins/sss/pin-sss                          | 12 ++++----
9742fa
 9 files changed, 60 insertions(+), 13 deletions(-)
9742fa
 create mode 100644 src/luks/systemd/dracut/clevis-pin-null/meson.build
9742fa
 create mode 100755 src/luks/systemd/dracut/clevis-pin-null/module-setup.sh.in
9742fa
 rename src/pins/sss/{clevis-decrypt-test => clevis-decrypt-null} (88%)
9742fa
 rename src/pins/sss/{clevis-encrypt-test => clevis-encrypt-null} (90%)
9742fa
 rename src/pins/sss/{pin-test => pin-null} (53%)
9742fa
9742fa
diff --git a/src/initramfs-tools/hooks/clevis.in b/src/initramfs-tools/hooks/clevis.in
9742fa
index cc3b492..448ba96 100755
9742fa
--- a/src/initramfs-tools/hooks/clevis.in
9742fa
+++ b/src/initramfs-tools/hooks/clevis.in
9742fa
@@ -58,6 +58,7 @@ fi
9742fa
 
9742fa
 copy_exec @bindir@/clevis-decrypt-tang || die 1 "@bindir@/clevis-decrypt-tang not found"
9742fa
 copy_exec @bindir@/clevis-decrypt-sss || die 1 "@bindir@/clevis-decrypt-sss not found"
9742fa
+copy_exec @bindir@/clevis-decrypt-null || die 1 "@bindir@/clevis-decrypt-null not found"
9742fa
 copy_exec @bindir@/clevis-decrypt || die 1 "@bindir@/clevis-decrypt not found"
9742fa
 copy_exec @bindir@/clevis-luks-common-functions || die 1 "@bindir@/clevis-luks-common-functions not found"
9742fa
 copy_exec @bindir@/clevis-luks-list || die 1 "@bindir@/clevis-luks-list not found"
9742fa
diff --git a/src/luks/systemd/dracut/clevis-pin-null/meson.build b/src/luks/systemd/dracut/clevis-pin-null/meson.build
9742fa
new file mode 100644
9742fa
index 0000000..107e3ba
9742fa
--- /dev/null
9742fa
+++ b/src/luks/systemd/dracut/clevis-pin-null/meson.build
9742fa
@@ -0,0 +1,14 @@
9742fa
+dracut = dependency('dracut', required: false)
9742fa
+
9742fa
+if dracut.found()
9742fa
+  dracutdir = dracut.get_pkgconfig_variable('dracutmodulesdir') + '/60' + meson.project_name() + '-pin-null'
9742fa
+
9742fa
+  configure_file(
9742fa
+    input: 'module-setup.sh.in',
9742fa
+    output: 'module-setup.sh',
9742fa
+    install_dir: dracutdir,
9742fa
+    configuration: data,
9742fa
+  )
9742fa
+else
9742fa
+  warning('Will not install dracut module clevis-pin-null due to missing dependencies!')
9742fa
+endif
9742fa
diff --git a/src/luks/systemd/dracut/clevis-pin-null/module-setup.sh.in b/src/luks/systemd/dracut/clevis-pin-null/module-setup.sh.in
9742fa
new file mode 100755
9742fa
index 0000000..6a16078
9742fa
--- /dev/null
9742fa
+++ b/src/luks/systemd/dracut/clevis-pin-null/module-setup.sh.in
9742fa
@@ -0,0 +1,28 @@
9742fa
+#!/bin/bash
9742fa
+# vim: set tabstop=8 shiftwidth=4 softtabstop=4 expandtab smarttab colorcolumn=80:
9742fa
+#
9742fa
+# Copyright (c) 2016 Red Hat, Inc.
9742fa
+# Author: Nathaniel McCallum <npmccallum@redhat.com>
9742fa
+#
9742fa
+# This program is free software: you can redistribute it and/or modify
9742fa
+# it under the terms of the GNU General Public License as published by
9742fa
+# the Free Software Foundation, either version 3 of the License, or
9742fa
+# (at your option) any later version.
9742fa
+#
9742fa
+# This program is distributed in the hope that it will be useful,
9742fa
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
9742fa
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
9742fa
+# GNU General Public License for more details.
9742fa
+#
9742fa
+# You should have received a copy of the GNU General Public License
9742fa
+# along with this program.  If not, see <http://www.gnu.org/licenses/>.
9742fa
+#
9742fa
+
9742fa
+depends() {
9742fa
+    echo clevis
9742fa
+    return 0
9742fa
+}
9742fa
+
9742fa
+install() {
9742fa
+    inst clevis-decrypt-null
9742fa
+}
9742fa
diff --git a/src/luks/systemd/dracut/meson.build b/src/luks/systemd/dracut/meson.build
9742fa
index fdb264b..7ad5b14 100644
9742fa
--- a/src/luks/systemd/dracut/meson.build
9742fa
+++ b/src/luks/systemd/dracut/meson.build
9742fa
@@ -2,3 +2,4 @@ subdir('clevis')
9742fa
 subdir('clevis-pin-tang')
9742fa
 subdir('clevis-pin-tpm2')
9742fa
 subdir('clevis-pin-sss')
9742fa
+subdir('clevis-pin-null')
9742fa
diff --git a/src/pins/sss/clevis-decrypt-test b/src/pins/sss/clevis-decrypt-null
9742fa
similarity index 88%
9742fa
rename from src/pins/sss/clevis-decrypt-test
9742fa
rename to src/pins/sss/clevis-decrypt-null
9742fa
index f0e9249..a6217ed 100755
9742fa
--- a/src/pins/sss/clevis-decrypt-test
9742fa
+++ b/src/pins/sss/clevis-decrypt-null
9742fa
@@ -22,11 +22,11 @@
9742fa
 
9742fa
 read -r -d . hdr
9742fa
 
9742fa
-if [ "$(jose fmt -q "$hdr" -SyOg clevis -g pin -u-)" != "test" ]; then
9742fa
+if [ "$(jose fmt -q "$hdr" -SyOg clevis -g pin -u-)" != "null" ]; then
9742fa
     echo "JWE pin mismatch!" >&2
9742fa
     exit 1
9742fa
 fi
9742fa
 
9742fa
-jwk="$(jose fmt -q "$hdr" -SyOg clevis -g test -g jwk -Oo-)" || exit 1
9742fa
+jwk="$(jose fmt -q "$hdr" -SyOg clevis -g null -g jwk -Oo-)" || exit 1
9742fa
 
9742fa
 exec jose jwe dec -k- -i- < <(echo -n "$jwk$hdr."; /bin/cat)
9742fa
diff --git a/src/pins/sss/clevis-encrypt-test b/src/pins/sss/clevis-encrypt-null
9742fa
similarity index 90%
9742fa
rename from src/pins/sss/clevis-encrypt-test
9742fa
rename to src/pins/sss/clevis-encrypt-null
9742fa
index bd2d6ec..af182a5 100755
9742fa
--- a/src/pins/sss/clevis-encrypt-test
9742fa
+++ b/src/pins/sss/clevis-encrypt-null
9742fa
@@ -26,10 +26,10 @@ if ! cfg="$(jose fmt -j "$1" -Oo- 2>/dev/null)"; then
9742fa
 fi
9742fa
 
9742fa
 jwk="$(jose jwk gen -i '{"alg":"A256GCM"}')"
9742fa
-jwe='{"protected":{"clevis":{"pin":"test","test":{}}}}'
9742fa
+jwe='{"protected":{"clevis":{"pin":"null","null":{}}}}'
9742fa
 
9742fa
 if ! jose fmt -j "$cfg" -g fail -T; then
9742fa
-    jwe="$(jose fmt -j "$jwe" -Og protected -g clevis -g test -j "$jwk" -Os jwk -UUUUo-)"
9742fa
+    jwe="$(jose fmt -j "$jwe" -Og protected -g clevis -g null -j "$jwk" -Os jwk -UUUUo-)"
9742fa
 fi
9742fa
 
9742fa
 exec jose jwe enc -i- -k- -I- -c < <(echo -n "$jwe$jwk"; /bin/cat)
9742fa
diff --git a/src/pins/sss/meson.build b/src/pins/sss/meson.build
9742fa
index 7f20eea..2a5295a 100644
9742fa
--- a/src/pins/sss/meson.build
9742fa
+++ b/src/pins/sss/meson.build
9742fa
@@ -28,8 +28,11 @@ if jansson.found() and libcrypto.found()
9742fa
     separator: ':'
9742fa
   )
9742fa
 
9742fa
+  bins += join_paths(meson.current_source_dir(), 'clevis-encrypt-null')
9742fa
+  bins += join_paths(meson.current_source_dir(), 'clevis-decrypt-null')
9742fa
+
9742fa
   test('pin-sss', find_program(join_paths(src, 'pin-sss')), env: env)
9742fa
-  test('pin-test', find_program(join_paths(src, 'pin-test')), env: env)
9742fa
+  test('pin-null', find_program(join_paths(src, 'pin-null')), env: env)
9742fa
 else
9742fa
   warning('Will not install sss pin due to missing dependencies!')
9742fa
 endif
9742fa
diff --git a/src/pins/sss/pin-test b/src/pins/sss/pin-null
9742fa
similarity index 53%
9742fa
rename from src/pins/sss/pin-test
9742fa
rename to src/pins/sss/pin-null
9742fa
index 50c8c67..b14ac63 100755
9742fa
--- a/src/pins/sss/pin-test
9742fa
+++ b/src/pins/sss/pin-null
9742fa
@@ -2,9 +2,9 @@
9742fa
 
9742fa
 trap 'exit' ERR
9742fa
 
9742fa
-e="$(echo -n hi | clevis encrypt test '{}')"
9742fa
+e="$(echo -n hi | clevis encrypt null '{}')"
9742fa
 d="$(echo -n "$e" | clevis decrypt)"
9742fa
 test "$d" == "hi"
9742fa
 
9742fa
-e="$(echo -n hi | clevis encrypt test '{"fail":true}')"
9742fa
+e="$(echo -n hi | clevis encrypt null '{"fail":true}')"
9742fa
 ! echo "$e" | clevis decrypt
9742fa
diff --git a/src/pins/sss/pin-sss b/src/pins/sss/pin-sss
9742fa
index 5c0b8cf..24da052 100755
9742fa
--- a/src/pins/sss/pin-sss
9742fa
+++ b/src/pins/sss/pin-sss
9742fa
@@ -1,24 +1,24 @@
9742fa
 #!/bin/bash -ex
9742fa
 
9742fa
-e="$(echo hi | clevis encrypt sss '{"t":1,"pins":{"test":[{},{}]}}')"
9742fa
+e="$(echo hi | clevis encrypt sss '{"t":1,"pins":{"null":[{},{}]}}')"
9742fa
 d="$(echo "$e" | clevis decrypt)"
9742fa
 test "$d" == "hi"
9742fa
 
9742fa
-e="$(echo hi | clevis encrypt sss '{"t":1,"pins":{"test":[{},{"fail":true}]}}')"
9742fa
+e="$(echo hi | clevis encrypt sss '{"t":1,"pins":{"null":[{},{"fail":true}]}}')"
9742fa
 d="$(echo "$e" | clevis decrypt)"
9742fa
 test "$d" == "hi"
9742fa
 
9742fa
-e="$(echo hi | clevis encrypt sss '{"t":1,"pins":{"test":[{"fail":true},{"fail":true}]}}')"
9742fa
+e="$(echo hi | clevis encrypt sss '{"t":1,"pins":{"null":[{"fail":true},{"fail":true}]}}')"
9742fa
 ! echo "$e" | clevis decrypt
9742fa
 
9742fa
-e="$(echo hi | clevis encrypt sss '{"t":2,"pins":{"test":[{},{}]}}')"
9742fa
+e="$(echo hi | clevis encrypt sss '{"t":2,"pins":{"null":[{},{}]}}')"
9742fa
 d="$(echo "$e" | clevis decrypt)"
9742fa
 test "$d" == "hi"
9742fa
 
9742fa
-e="$(echo hi | clevis encrypt sss '{"t":2,"pins":{"test":[{},{"fail":true}]}}')"
9742fa
+e="$(echo hi | clevis encrypt sss '{"t":2,"pins":{"null":[{},{"fail":true}]}}')"
9742fa
 ! echo "$e" | clevis decrypt
9742fa
 
9742fa
-e="$(echo hi | clevis encrypt sss '{"t":2,"pins":{"test":[{"fail":true},{"fail":true}]}}')"
9742fa
+e="$(echo hi | clevis encrypt sss '{"t":2,"pins":{"null":[{"fail":true},{"fail":true}]}}')"
9742fa
 ! echo "$e" | clevis decrypt
9742fa
 
9742fa
 ! e="$(echo hi | clevis encrypt sss '{"t":1,"pins":{"tang":[{"url":"foo bar"}]}}')"
9742fa
-- 
9742fa
2.33.1
9742fa