chiark / gitweb /
reorg nfc
authorIan Jackson <ijackson@chiark.greenend.org.uk>
Sun, 26 Jul 2020 01:24:31 +0000 (02:24 +0100)
committerIan Jackson <ijackson@chiark.greenend.org.uk>
Sun, 26 Jul 2020 01:24:31 +0000 (02:24 +0100)
src/cmdlistener.rs
src/imports.rs

index f6b9d280fcef0bc61d1f12657e6763b731d5a9bf..a925e4897f68dcd1b6327e509af1b176a801cdfb 100644 (file)
@@ -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<A> (PhantomData<A>);
-//struct AuthorisedScope<A> (Authorised<A>, ManagementScope);
-struct AuthorisedSatisfactory (ManagementScope);
-use libc::uid_t;
-
-impl AuthorisedSatisfactory {
-  fn into_inner(self) -> ManagementScope { self.0 }
-}
-
-impl<T> Authorised<T> {
-  fn authorise() -> Authorised<T> { Authorised(PhantomData) }
-}
-
-impl<T> From<(Authorised<T>, ManagementScope)> for AuthorisedSatisfactory {
-  fn from((_,s): (Authorised<T>, ManagementScope)) -> Self { Self(s) }
-}
-impl<T,U> From<((Authorised<T>, Authorised<U>), ManagementScope)> for AuthorisedSatisfactory {
-  fn from(((..),s): ((Authorised<T>, Authorised<U>), ManagementScope)) -> Self { Self(s) }
-}
-
-impl From<anyhow::Error> for AuthorisationError {
-  fn from(a: anyhow::Error) -> AuthorisationError {
-    AuthorisationError(format!("{}",a))
-  }
-}
-impl From<ConnectionEuidDiscoverEerror> for AuthorisationError {
-  fn from(e: ConnectionEuidDiscoverEerror) -> AuthorisationError {
-    AuthorisationError(format!("{}",e))
-  }
-}
-
 impl CommandStream<'_> {
   #[throws(AuthorisationError)]
   fn authorised_uid(&self, wanted: Option<uid_t>, 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<A> (PhantomData<A>);
+  //struct AuthorisedScope<A> (Authorised<A>, ManagementScope);
+  pub struct AuthorisedSatisfactory (ManagementScope);
+
+  impl AuthorisedSatisfactory {
+    pub fn into_inner(self) -> ManagementScope { self.0 }
+  }
+
+  impl<T> Authorised<T> {
+    pub fn authorise() -> Authorised<T> { Authorised(PhantomData) }
+  }
+
+  impl<T> From<(Authorised<T>, ManagementScope)> for AuthorisedSatisfactory {
+    fn from((_,s): (Authorised<T>, ManagementScope)) -> Self { Self(s) }
+  }
+  impl<T,U> From<((Authorised<T>, Authorised<U>), ManagementScope)> for AuthorisedSatisfactory {
+    fn from(((..),s): ((Authorised<T>, Authorised<U>), ManagementScope)) -> Self { Self(s) }
+  }
+
+  impl From<anyhow::Error> for AuthorisationError {
+    fn from(a: anyhow::Error) -> AuthorisationError {
+      AuthorisationError(format!("{}",a))
+    }
+  }
+  impl From<ConnectionEuidDiscoverEerror> for AuthorisationError {
+    fn from(e: ConnectionEuidDiscoverEerror) -> AuthorisationError {
+      AuthorisationError(format!("{}",e))
+    }
+  }
+}
index f54925aa6a3dd9b96afd3268805dddbdd50ff813..8476e920b6e4b474fb597b7c6bdb153162609ae4 100644 (file)
@@ -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;