From c466d0df78bdac942e3e319e6a7aa6d5d54f2684 Mon Sep 17 00:00:00 2001 From: Simo Sorce Date: Thu, 12 Dec 2024 14:26:52 -0500 Subject: [PATCH] nssdb: Properly set PIN initialization flag Signed-off-by: Simo Sorce --- src/storage/nssdb/mod.rs | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/src/storage/nssdb/mod.rs b/src/storage/nssdb/mod.rs index 76ed48f..63993d9 100644 --- a/src/storage/nssdb/mod.rs +++ b/src/storage/nssdb/mod.rs @@ -151,6 +151,14 @@ impl NSSStorage { if self.config.password_required { info.flags |= CKF_LOGIN_REQUIRED; } + match self.fetch_password() { + Ok(_) => info.flags |= CKF_USER_PIN_INITIALIZED, + Err(e) => { + if e.rv() != CKR_USER_PIN_NOT_INITIALIZED { + return Err(e); + } + } + } Ok(info) } @@ -803,6 +811,10 @@ impl Storage for NSSStorage { if ret != CKR_OK { return Err(ret)?; } + /* ensure we drop the lock here, otherwise we deadlock inside + * get_token_info() where we try to acquire it again to search + * the database. */ + drop(conn); self.get_token_info() }