From cf09de8b9f35921fc4ec3336d82fc0748eef1fbd Mon Sep 17 00:00:00 2001 From: Packit Date: Aug 20 2020 13:34:21 +0000 Subject: Apply patch 0004-pkcstok_migrate-Remove-the-token-s-shared-memory-seg.patch patch_name: 0004-pkcstok_migrate-Remove-the-token-s-shared-memory-seg.patch location_in_specfile: 9 present_in_specfile: true --- diff --git a/usr/sbin/pkcstok_migrate/pkcstok_migrate.c b/usr/sbin/pkcstok_migrate/pkcstok_migrate.c index 136c010..46e5e57 100644 --- a/usr/sbin/pkcstok_migrate/pkcstok_migrate.c +++ b/usr/sbin/pkcstok_migrate/pkcstok_migrate.c @@ -31,6 +31,7 @@ #include #include #include +#include #include #include "sw_crypt.h" @@ -2109,6 +2110,36 @@ done: } /** + * Removes the token_s shared memory from /dev/shm + */ +static CK_RV remove_shared_memory(char *location) +{ + char shm_name[PATH_MAX]; + int i, k, rc; + + i = k = 0; + shm_name[k++] = '/'; + if (location[i] == '/') + i++; + + for (; location[i]; i++, k++) { + if (location[i] == '/') + shm_name[k] = '.'; + else + shm_name[k] = location[i]; + } + shm_name[k] = '\0'; + + rc = shm_unlink(shm_name); + if (rc != 0) { + warnx("shm_unlink(%s) failed, errno=%s", shm_name, strerror(errno)); + return CKR_FUNCTION_FAILED; + } + + return CKR_OK; +} + +/** * Copy a file given by name from a src folder to a dst folder. */ static CK_RV file_copy(char *dst, const char *src, const char *name) @@ -2718,6 +2749,13 @@ int main(int argc, char **argv) goto done; } + /* Remove the token's shared memory */ + ret = remove_shared_memory(data_store); + if (ret != CKR_OK) { + warnx("Failed to remove token's shared memory."); + goto done; + } + /* Now insert new 'tokversion=3.12' parm in opencryptoki.conf */ ret = update_opencryptoki_conf(slot_id, conf_dir); if (ret != CKR_OK) { diff --git a/usr/sbin/pkcstok_migrate/pkcstok_migrate.mk b/usr/sbin/pkcstok_migrate/pkcstok_migrate.mk index dc4582e..028a383 100644 --- a/usr/sbin/pkcstok_migrate/pkcstok_migrate.mk +++ b/usr/sbin/pkcstok_migrate/pkcstok_migrate.mk @@ -6,7 +6,7 @@ noinst_HEADERS += usr/include/local_types.h noinst_HEADERS += usr/lib/common/h_extern.h noinst_HEADERS += usr/lib/common/pkcs_utils.h -usr_sbin_pkcstok_migrate_pkcstok_migrate_LDFLAGS = -lcrypto -ldl +usr_sbin_pkcstok_migrate_pkcstok_migrate_LDFLAGS = -lcrypto -ldl -lrt usr_sbin_pkcstok_migrate_pkcstok_migrate_CFLAGS = \ -DSTDLL_NAME=\"pkcstok_migrate\" \