From: Ian Jackson Date: Sun, 26 Jul 2020 01:24:31 +0000 (+0100) Subject: reorg nfc X-Git-Tag: otter-0.2.0~1251 X-Git-Url: https://www.chiark.greenend.org.uk/ucgi/~ianmdlvl/git?a=commitdiff_plain;h=7cf6dd6fbfc648558d5309bbfd13f297de419d56;p=otter.git reorg nfc --- diff --git a/src/cmdlistener.rs b/src/cmdlistener.rs index f6b9d280..a925e489 100644 --- a/src/cmdlistener.rs +++ b/src/cmdlistener.rs @@ -76,41 +76,6 @@ fn decode_process_inner(cs: &mut CommandStream, s: &str)-> MgmtResponse { const USERLIST : &str = "/etc/userlist"; -#[derive(Error,Debug)] -#[error("internal AuthorisationError {0}")] -struct AuthorisationError(String); - -struct Authorised (PhantomData); -//struct AuthorisedScope (Authorised, ManagementScope); -struct AuthorisedSatisfactory (ManagementScope); -use libc::uid_t; - -impl AuthorisedSatisfactory { - fn into_inner(self) -> ManagementScope { self.0 } -} - -impl Authorised { - fn authorise() -> Authorised { Authorised(PhantomData) } -} - -impl From<(Authorised, ManagementScope)> for AuthorisedSatisfactory { - fn from((_,s): (Authorised, ManagementScope)) -> Self { Self(s) } -} -impl From<((Authorised, Authorised), ManagementScope)> for AuthorisedSatisfactory { - fn from(((..),s): ((Authorised, Authorised), ManagementScope)) -> Self { Self(s) } -} - -impl From for AuthorisationError { - fn from(a: anyhow::Error) -> AuthorisationError { - AuthorisationError(format!("{}",a)) - } -} -impl From for AuthorisationError { - fn from(e: ConnectionEuidDiscoverEerror) -> AuthorisationError { - AuthorisationError(format!("{}",e)) - } -} - impl CommandStream<'_> { #[throws(AuthorisationError)] fn authorised_uid(&self, wanted: Option, xinfo: Option<&str>) @@ -318,3 +283,44 @@ impl CommandListener { }); } } + +use authproofs::*; +use authproofs::AuthorisationError; + +mod authproofs { + use crate::imports::*; + + #[derive(Error,Debug)] + #[error("internal AuthorisationError {0}")] + pub struct AuthorisationError(pub String); + + pub struct Authorised (PhantomData); + //struct AuthorisedScope (Authorised, ManagementScope); + pub struct AuthorisedSatisfactory (ManagementScope); + + impl AuthorisedSatisfactory { + pub fn into_inner(self) -> ManagementScope { self.0 } + } + + impl Authorised { + pub fn authorise() -> Authorised { Authorised(PhantomData) } + } + + impl From<(Authorised, ManagementScope)> for AuthorisedSatisfactory { + fn from((_,s): (Authorised, ManagementScope)) -> Self { Self(s) } + } + impl From<((Authorised, Authorised), ManagementScope)> for AuthorisedSatisfactory { + fn from(((..),s): ((Authorised, Authorised), ManagementScope)) -> Self { Self(s) } + } + + impl From for AuthorisationError { + fn from(a: anyhow::Error) -> AuthorisationError { + AuthorisationError(format!("{}",a)) + } + } + impl From for AuthorisationError { + fn from(e: ConnectionEuidDiscoverEerror) -> AuthorisationError { + AuthorisationError(format!("{}",e)) + } + } +} diff --git a/src/imports.rs b/src/imports.rs index f54925aa..8476e920 100644 --- a/src/imports.rs +++ b/src/imports.rs @@ -64,6 +64,8 @@ pub use crate::commands::*; pub use crate::slotmap_slot_idx::*; pub use crate::cmdlistener::*; +pub use libc::uid_t; + pub type E = anyhow::Error; pub type AE = anyhow::Error;