Some cleanups
- Remove unused errors. - Add doc comments.
This commit is contained in:
+2
-2
@@ -14,8 +14,8 @@ pub mod local;
|
|||||||
pub enum CommandError {
|
pub enum CommandError {
|
||||||
#[error("Certificate not found: {0}")]
|
#[error("Certificate not found: {0}")]
|
||||||
CertNotFound(Fingerprint),
|
CertNotFound(Fingerprint),
|
||||||
#[error("List of domains is empty")]
|
#[error("Certificate not usable: {0}")]
|
||||||
DomainListEmpty,
|
CertNotUsable(Fingerprint),
|
||||||
}
|
}
|
||||||
|
|
||||||
pub async fn dispatch(cli: CliArgs, config: HuskConfigContainer) -> Result<()> {
|
pub async fn dispatch(cli: CliArgs, config: HuskConfigContainer) -> Result<()> {
|
||||||
|
|||||||
@@ -1,3 +1,5 @@
|
|||||||
|
//! introducer add subcommand
|
||||||
|
|
||||||
use anyhow::Result;
|
use anyhow::Result;
|
||||||
use sequoia_cert_store::Store;
|
use sequoia_cert_store::Store;
|
||||||
use sequoia_openpgp::cert::ValidCert;
|
use sequoia_openpgp::cert::ValidCert;
|
||||||
@@ -32,7 +34,7 @@ pub async fn dispatch(cmd: IntroducerAddCommand, config: HuskConfigContainer) ->
|
|||||||
if let Some(cert) = certs.first() {
|
if let Some(cert) = certs.first() {
|
||||||
Introducer::create(&context, cert, cmd.domains)?;
|
Introducer::create(&context, cert, cmd.domains)?;
|
||||||
} else {
|
} else {
|
||||||
return Err(CommandError::CertNotFound(fpr).into());
|
return Err(CommandError::CertNotUsable(fpr).into());
|
||||||
}
|
}
|
||||||
|
|
||||||
Ok(())
|
Ok(())
|
||||||
|
|||||||
@@ -1,3 +1,5 @@
|
|||||||
|
//! introducer remove subcommand
|
||||||
|
|
||||||
use anyhow::Result;
|
use anyhow::Result;
|
||||||
|
|
||||||
use sequoia_openpgp::{Fingerprint, KeyHandle};
|
use sequoia_openpgp::{Fingerprint, KeyHandle};
|
||||||
@@ -35,7 +37,7 @@ pub async fn dispatch(cmd: IntroducerRemoveCommand, config: HuskConfigContainer)
|
|||||||
if let Some(cert) = certs.first() {
|
if let Some(cert) = certs.first() {
|
||||||
Introducer::remove(&context, cert, cmd.demote)?;
|
Introducer::remove(&context, cert, cmd.demote)?;
|
||||||
} else {
|
} else {
|
||||||
return Err(CommandError::CertNotFound(fpr).into());
|
return Err(CommandError::CertNotUsable(fpr).into());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
+1
-3
@@ -1,6 +1,4 @@
|
|||||||
//
|
//! Husk milter
|
||||||
// Husk milter
|
|
||||||
//
|
|
||||||
|
|
||||||
use std::process;
|
use std::process;
|
||||||
use std::sync::{Arc, Mutex};
|
use std::sync::{Arc, Mutex};
|
||||||
|
|||||||
+1
-1
@@ -1,4 +1,4 @@
|
|||||||
//! Error typ
|
//! Husk Error type
|
||||||
|
|
||||||
use thiserror::Error;
|
use thiserror::Error;
|
||||||
|
|
||||||
|
|||||||
@@ -6,7 +6,6 @@ use sequoia_wot as wot;
|
|||||||
use wot::{CertSynopsis, Certification};
|
use wot::{CertSynopsis, Certification};
|
||||||
use sequoia_openpgp::{cert::ValidCert, policy::StandardPolicy};
|
use sequoia_openpgp::{cert::ValidCert, policy::StandardPolicy};
|
||||||
use sequoia_openpgp::Cert;
|
use sequoia_openpgp::Cert;
|
||||||
use sequoia_openpgp::Fingerprint;
|
|
||||||
|
|
||||||
use crate::types::husk_context::HuskContext;
|
use crate::types::husk_context::HuskContext;
|
||||||
use crate::common::crypto;
|
use crate::common::crypto;
|
||||||
@@ -15,14 +14,6 @@ use crate::common::crypto;
|
|||||||
pub enum IntroducerError {
|
pub enum IntroducerError {
|
||||||
#[error("Unsuitable certificate")]
|
#[error("Unsuitable certificate")]
|
||||||
UnsuitableCertificate,
|
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)]
|
#[derive(Debug, Clone)]
|
||||||
@@ -33,6 +24,10 @@ pub struct Introducer {
|
|||||||
|
|
||||||
impl 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 {
|
pub fn can_introduce(&self, email: &str) -> bool {
|
||||||
if let Some(regexset) = self.certification.regular_expressions() {
|
if let Some(regexset) = self.certification.regular_expressions() {
|
||||||
if regexset.matches_everything() {
|
if regexset.matches_everything() {
|
||||||
|
|||||||
Reference in New Issue
Block a user