File ocki-3.15.1-pkcstok_migrate-Quote-strings-with-spaces-in-opencry.patch of Package openCryptoki.23571

From 5824364d995e5d2418f885ee57e377e11d1b3302 Mon Sep 17 00:00:00 2001
From: Ingo Franzki <ifranzki@linux.ibm.com>
Date: Wed, 7 Jul 2021 13:44:46 +0200
Subject: [PATCH] pkcstok_migrate: Quote strings with spaces in
 opencryptoki.conf

When modifying opencryptoki.conf during token migration, put quotes
around strings that contain spaces, e.g. for the slot description and
manufacturer.

Signed-off-by: Ingo Franzki <ifranzki@linux.ibm.com>
---
 usr/sbin/pkcstok_migrate/pkcstok_migrate.c | 5 ++++-
 1 file changed, 4 insertions(+), 1 deletion(-)

diff --git a/usr/sbin/pkcstok_migrate/pkcstok_migrate.c b/usr/sbin/pkcstok_migrate/pkcstok_migrate.c
index 94fd1196..3df1596e 100644
--- a/usr/sbin/pkcstok_migrate/pkcstok_migrate.c
+++ b/usr/sbin/pkcstok_migrate/pkcstok_migrate.c
@@ -2100,7 +2100,10 @@ static int parseupdate_key_str(void *private, int tok, const char *val)
 {
 	struct parseupdate *u = (struct parseupdate *)private;
 
-    if (tok != KW_TOKVERSION)
+    if (tok != KW_HWVERSION && tok != KW_FWVERSION &&
+        strchr(val, ' ') != NULL)
+        fprintf(u->f, "  %s = \"%s\"", keyword_token_to_str(tok), val);
+    else if (tok != KW_TOKVERSION)
         fprintf(u->f, "  %s = %s", keyword_token_to_str(tok), val);
     return 0;
 }
-- 
2.26.2

openSUSE Build Service is sponsored by