From df85cb578bee97bf04ebf16e26f9c9d2c15a0e43 Mon Sep 17 00:00:00 2001 From: Ian Jackson Date: Sat, 25 Jul 2020 23:50:34 +0100 Subject: [PATCH] wip auth --- src/cmdlistener.rs | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/src/cmdlistener.rs b/src/cmdlistener.rs index 86e269f0..5b4444ca 100644 --- a/src/cmdlistener.rs +++ b/src/cmdlistener.rs @@ -71,6 +71,8 @@ fn decode_process_inner(s: &str)-> MgmtResponse { const USERLIST : &str = "/etc/userlist"; +struct Authorized; + fn authorize_scope(cs: &CommandStream, wanted: &ManagementScope) { type AS = AuthorizedScope; @@ -82,7 +84,7 @@ fn authorize_scope(cs: &CommandStream, wanted: &ManagementScope) { let our_euid = unsafe { libc::getuid() }; let ok = cs.authorized_uid(our_euid)?; AS((ok,), - ManagementScope:::XXX) + ManagementScope::XXX) }; y.into() }, @@ -91,7 +93,7 @@ fn authorize_scope(cs: &CommandStream, wanted: &ManagementScope) { Authorized<(Passwd,uid_t)>, // caller_has Authorized, // in_userlist: )> = { - let pwent = Passwd::from_name(user)?: + let pwent = Passwd::from_name(user)?; let caller_has = cs.authorized_uid(pwent.uid)?; let found = (||{ let allowed = File::open(USERLIST)?; @@ -109,13 +111,13 @@ fn authorize_scope(cs: &CommandStream, wanted: &ManagementScope) { #[throws(ME)] fn execute(cs: &mut CommandStream, cmd: MgmtCommand) -> MgmtResponse { - use MgmgError::*; + use MgmtError::*; match cmd { Noop { } => Fine { }, Scope(wanted_scope) => { - let (_: AuthorizedConclusion, authorized: ManagementScope) = + let (_, authorized) : (AuthorizedConclusion, ManagementScope) = authorize_scope(cs, &wanted_scope)?; cs.scope = authorized; Fine { } -- 2.30.2