diff --git a/SOURCES/opencryptoki-3.18.0-fix-json-output.patch b/SOURCES/opencryptoki-3.18.0-fix-json-output.patch new file mode 100644 index 0000000..baa6ff7 --- /dev/null +++ b/SOURCES/opencryptoki-3.18.0-fix-json-output.patch @@ -0,0 +1,47 @@ +commit 1600eebb422ae2a733de3a0bd47464620e39ab0d +Author: Ingo Franzki +Date: Tue Jun 7 08:58:16 2022 +0200 + + pkcsstats: Fix JSON output in case of errors + + Produce correct JSON output, even if an error occurs during obtaining + of the statistics for a user. + + Signed-off-by: Ingo Franzki + +diff --git a/usr/sbin/pkcsstats/pkcsstats.c b/usr/sbin/pkcsstats/pkcsstats.c +index 8eb049dd..65d4833f 100644 +--- a/usr/sbin/pkcsstats/pkcsstats.c ++++ b/usr/sbin/pkcsstats/pkcsstats.c +@@ -789,7 +789,7 @@ int main(int argc, char **argv) + bool reset = false, reset_all = false; + bool delete = false, delete_all = false; + bool slot_id_specified = false; +- bool json = false; ++ bool json = false, json_started = false; + CK_SLOT_ID slot_id = 0; + void *dll = NULL; + CK_FUNCTION_LIST *func_list = NULL; +@@ -949,8 +949,11 @@ int main(int argc, char **argv) + goto done; + } + +- if (json && print_json_start() != 0) +- goto done; ++ if (json) { ++ if (print_json_start() != 0) ++ goto done; ++ json_started = true; ++ } + + dd.func_list = func_list; + dd.num_slots = num_slots; +@@ -972,7 +975,7 @@ int main(int argc, char **argv) + } + + done: +- if (rc == 0 && json) ++ if (json && json_started) + printf("\n\t]\n}\n"); + + if (slots != NULL) diff --git a/SPECS/opencryptoki.spec b/SPECS/opencryptoki.spec index 9e4948f..815a2d2 100644 --- a/SPECS/opencryptoki.spec +++ b/SPECS/opencryptoki.spec @@ -1,7 +1,7 @@ Name: opencryptoki Summary: Implementation of the PKCS#11 (Cryptoki) specification v3.0 Version: 3.18.0 -Release: 1%{?dist} +Release: 2%{?dist} License: CPL Group: System Environment/Base URL: https://github.com/opencryptoki/opencryptoki @@ -13,6 +13,7 @@ Patch1: opencryptoki-3.11.0-lockdir.patch # add missing p11sak_defined_attrs.conf Patch2: opencryptoki-3.18.0-p11sak.patch # upstream patches +Patch100: opencryptoki-3.18.0-fix-json-output.patch Requires(pre): coreutils Requires: (selinux-policy >= 3.14.3-70 if selinux-policy-targeted) @@ -346,6 +347,9 @@ fi %changelog +* Tue Jun 07 2022 Than Ngo - 3.18.0-2 +- Related: #2043854, fix json output + * Tue May 24 2022 Than Ngo - 3.18.0-1 - Resolves: #2043845, rebase to 3.18.0 - Resolves: #2043854, add crypto counters