diff --git a/src/commands.rs b/src/commands.rs index 491fb51..499b8a9 100644 --- a/src/commands.rs +++ b/src/commands.rs @@ -14,8 +14,8 @@ pub mod local; pub enum CommandError { #[error("Certificate not found: {0}")] CertNotFound(Fingerprint), - #[error("List of domains is empty")] - DomainListEmpty, + #[error("Certificate not usable: {0}")] + CertNotUsable(Fingerprint), } pub async fn dispatch(cli: CliArgs, config: HuskConfigContainer) -> Result<()> { diff --git a/src/commands/introducer/add.rs b/src/commands/introducer/add.rs index 2ce7dd3..695a712 100644 --- a/src/commands/introducer/add.rs +++ b/src/commands/introducer/add.rs @@ -1,3 +1,5 @@ +//! introducer add subcommand + use anyhow::Result; use sequoia_cert_store::Store; use sequoia_openpgp::cert::ValidCert; @@ -32,7 +34,7 @@ pub async fn dispatch(cmd: IntroducerAddCommand, config: HuskConfigContainer) -> if let Some(cert) = certs.first() { Introducer::create(&context, cert, cmd.domains)?; } else { - return Err(CommandError::CertNotFound(fpr).into()); + return Err(CommandError::CertNotUsable(fpr).into()); } Ok(()) diff --git a/src/commands/introducer/remove.rs b/src/commands/introducer/remove.rs index be283e4..fc21717 100644 --- a/src/commands/introducer/remove.rs +++ b/src/commands/introducer/remove.rs @@ -1,3 +1,5 @@ +//! introducer remove subcommand + use anyhow::Result; use sequoia_openpgp::{Fingerprint, KeyHandle}; @@ -35,7 +37,7 @@ pub async fn dispatch(cmd: IntroducerRemoveCommand, config: HuskConfigContainer) if let Some(cert) = certs.first() { Introducer::remove(&context, cert, cmd.demote)?; } else { - return Err(CommandError::CertNotFound(fpr).into()); + return Err(CommandError::CertNotUsable(fpr).into()); } diff --git a/src/main.rs b/src/main.rs index b1df41c..2f8666d 100644 --- a/src/main.rs +++ b/src/main.rs @@ -1,6 +1,4 @@ -// -// Husk milter -// +//! Husk milter use std::process; use std::sync::{Arc, Mutex}; diff --git a/src/types/errors.rs b/src/types/errors.rs index 5e1f66d..8e270d4 100644 --- a/src/types/errors.rs +++ b/src/types/errors.rs @@ -1,4 +1,4 @@ -//! Error typ +//! Husk Error type use thiserror::Error; diff --git a/src/types/introducer.rs b/src/types/introducer.rs index 17e71de..aa20538 100644 --- a/src/types/introducer.rs +++ b/src/types/introducer.rs @@ -6,7 +6,6 @@ use sequoia_wot as wot; use wot::{CertSynopsis, Certification}; use sequoia_openpgp::{cert::ValidCert, policy::StandardPolicy}; use sequoia_openpgp::Cert; -use sequoia_openpgp::Fingerprint; use crate::types::husk_context::HuskContext; use crate::common::crypto; @@ -15,14 +14,6 @@ use crate::common::crypto; pub enum IntroducerError { #[error("Unsuitable certificate")] UnsuitableCertificate, - #[error("Unlimited introducer")] - UnlimitedIntroducer, - #[error("Invalid domain name: '{0}'")] - InvalidDomainName(String), - #[error("Certificate {0} contains no usable user id")] - NoUserIDs(Fingerprint), - #[error("Local trust root is damanged")] - RootDamaged, } #[derive(Debug, Clone)] @@ -33,6 +24,10 @@ pub struct Introducer { impl Introducer { + /// Can this introducer potentially introduce `email`? + /// + /// This check matches the email with the list of domains of the + /// introducer. pub fn can_introduce(&self, email: &str) -> bool { if let Some(regexset) = self.certification.regular_expressions() { if regexset.matches_everything() {