diff --git a/0006-return-zero-in-case-test-key-is-enrolled.patch b/0006-return-zero-in-case-test-key-is-enrolled.patch new file mode 100644 index 0000000..74f65a9 --- /dev/null +++ b/0006-return-zero-in-case-test-key-is-enrolled.patch @@ -0,0 +1,40 @@ +From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001 +From: Leo Sandoval +Date: Fri, 27 Jun 2025 17:28:58 -0600 +Subject: [PATCH] return zero in case --test-key is enrolled + +Otherwise it returns non-zero even if key is enrolled, indicating a +negative result. + +With this change, the --test-key return code would be following + + [root@localhost ~]# mokutil --test-key sb_cert.cer + sb_cert.cer is already enrolled + [root@localhost ~]# echo $? + 0 + +instead of + + [root@localhost ~]# mokutil --test-key sb_cert.cer + sb_cert.cer is already enrolled + [root@localhost ~]# echo $? + 1 + +Signed-off-by: Leo Sandoval +--- + src/mokutil.c | 2 +- + 1 file changed, 1 insertion(+), 1 deletion(-) + +diff --git a/src/mokutil.c b/src/mokutil.c +index 918ca06..368524b 100644 +--- a/src/mokutil.c ++++ b/src/mokutil.c +@@ -1590,7 +1590,7 @@ test_key (const MokRequest req, const char *key_file) + ret = 1; + } else { + print_skip_message (key_file, key, read_size, req); +- ret = 1; ++ ret = 0; + } + + error: diff --git a/mokutil.patches b/mokutil.patches index 11c7a76..8c0c3e0 100644 --- a/mokutil.patches +++ b/mokutil.patches @@ -2,4 +2,5 @@ Patch0001: 0001-mokutil.c-show-help-if-no-args-or-help-even-on-unsup.patch Patch0002: 0002-mokutil-fix-a-typo-mock.patch Patch0003: 0003-mokutil-remove-unused-int_to_b64.patch Patch0004: 0004-mokutil.c-on-test-key-return-non-zero-if-test-key-is.patch -Patch0005: 0005-mokutil-introduce-is-sb-enabled-parameter.patch \ No newline at end of file +Patch0005: 0005-mokutil-introduce-is-sb-enabled-parameter.patch +Patch0006: 0006-return-zero-in-case-test-key-is-enrolled.patch \ No newline at end of file diff --git a/mokutil.spec b/mokutil.spec index c602908..0888dae 100644 --- a/mokutil.spec +++ b/mokutil.spec @@ -1,6 +1,6 @@ Name: mokutil Version: 0.7.2 -Release: 2%{?dist} +Release: 3%{?dist} Epoch: 2 Summary: Tool to manage UEFI Secure Boot MoK Keys License: GPL-3.0-or-later @@ -47,6 +47,10 @@ mokutil provides a tool to manage keys for Secure Boot through the MoK %{_datadir}/bash-completion/completions/mokutil %changelog +* Fri Jun 27 2025 Leo Sandoval - 0.7.2-3 +- Return zero in case --test-key is enrolled +- Resolves: #RHEL-90836 + * Mon May 12 2025 Leo Sandoval - 0.7.2-2 - Rebase several patches from upstream which: - Introduce --is-sb-enabled parameter and better return codes