Skip to content

Commit

Permalink
Add check that slots have at least one instance
Browse files Browse the repository at this point in the history
  • Loading branch information
sosthene-nitrokey committed Sep 5, 2024
1 parent fe24604 commit 289ebd5
Showing 1 changed file with 7 additions and 1 deletion.
8 changes: 7 additions & 1 deletion pkcs11/src/config/initialization.rs
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,8 @@ pub enum InitializationError {
NoCerts,
#[error("No operator or administrator for slot: {0}")]
NoUser(String),
#[error("No instance given for a slot")]
NoInstance,
}

pub fn initialize_with_configs(
Expand Down Expand Up @@ -288,7 +290,11 @@ fn slot_from_config(slot: &SlotConfig) -> Result<Slot, InitializationError> {
};
Ok(api_config)
})
.collect::<Result<_, InitializationError>>()?;
.collect::<Result<Arc<_>, InitializationError>>()?;
if instances.is_empty() {
error!("Slot without any instance configured");
return Err(InitializationError::NoInstance);
}

Ok(Slot {
_description: slot.description.clone(),
Expand Down

0 comments on commit 289ebd5

Please sign in to comment.