From b6d69aeef44b9a8ee6cce5da3ef72dfe0890bb03 Mon Sep 17 00:00:00 2001 From: Ian Jackson Date: Tue, 4 May 2021 01:19:59 +0100 Subject: [PATCH] bundles: Move authproof into open_by_name Signed-off-by: Ian Jackson --- daemon/cmdlistener.rs | 5 ++--- src/bundles.rs | 11 +++++++++-- 2 files changed, 11 insertions(+), 5 deletions(-) diff --git a/daemon/cmdlistener.rs b/daemon/cmdlistener.rs index 40479d0f..231bf66d 100644 --- a/daemon/cmdlistener.rs +++ b/daemon/cmdlistener.rs @@ -253,10 +253,9 @@ fn execute_and_respond(cs: &mut CommandStreamData, cmd: MgmtCommand, let ag = AccountsGuard::lock(); let gref = Instance::lookup_by_name_unauth(&game)?; let mut igu = gref.lock()?; - let (ig, auth) = cs.check_acl(&ag, &mut igu, PCH::Instance, + let (ig, _) = cs.check_acl(&ag, &mut igu, PCH::Instance, TP_ACCESS_BUNDLES)?; - let f = id.open(&ig.name,auth.bundles())? - .ok_or_else(|| ME::BundleNotFound)?; + let f = id.open(&ig)?.ok_or_else(|| ME::BundleNotFound)?; bulk_download = Some(Box::new(f)); Fine } diff --git a/src/bundles.rs b/src/bundles.rs index 57db87fd..4d412011 100644 --- a/src/bundles.rs +++ b/src/bundles.rs @@ -122,8 +122,8 @@ impl Id { } #[throws(IE)] - pub fn open(&self, instance_name: &InstanceName, - _: Authorisation) -> Option { + pub fn open_by_name(&self, instance_name: &InstanceName, + _: Authorisation) -> Option { let path = self.path(instance_name); match File::open(&path) { Ok(f) => Some(f), @@ -133,6 +133,13 @@ impl Id { ), } } + + #[throws(IE)] + pub fn open(&self, instance: &Instance) -> Option { + let name = &*instance.name; + let auth = Authorisation::authorised(name).bundles(); + self.open_by_name(name, auth)? + } } #[derive(Debug,Copy,Clone,Error)] -- 2.30.2