From 85da91f69fdb5107d0e61800576b06de406c82f3 Mon Sep 17 00:00:00 2001 From: Ian Jackson Date: Fri, 21 Aug 2020 19:34:58 +0100 Subject: [PATCH] for revert: invent ServerOperatorPrivilege gold plating --- src/cmdlistener.rs | 25 ++++++++++++++++--------- 1 file changed, 16 insertions(+), 9 deletions(-) diff --git a/src/cmdlistener.rs b/src/cmdlistener.rs index 9db49c2b..e9bb38d6 100644 --- a/src/cmdlistener.rs +++ b/src/cmdlistener.rs @@ -109,22 +109,29 @@ fn authorise_scope(cs: &CommandStream, wanted: &ManagementScope) .map_err(|e| cs.map_auth_err(e))? } +struct ServerOperatorPrivilege; +#[throws(AuthorisationError)] +fn do_authorise_server(cs: &CommandStream) + -> AuthorisedSatisfactory = (T, ManagementScope); + let y : AS< + Authorised<(Passwd,uid_t)>, + > = { + let ok = cs.authorised_uid(None,None)?; + (ok, ServerOperatorPrivilege) + ) + }; + return y.into() +} + #[throws(AuthorisationError)] fn do_authorise_scope(cs: &CommandStream, wanted: &ManagementScope) -> AuthorisedSatisfactory { type AS = (T, ManagementScope); match &wanted { - ManagementScope::Server => { - let y : AS< - Authorised<(Passwd,uid_t)>, - > = { - let ok = cs.authorised_uid(None,None)?; - (ok, - ManagementScope::Server) - }; - return y.into() + do_authorise_server(cs,wanted) ManagementScope::Server }, ManagementScope::Unix { user: wanted } => { -- 2.30.2