From: Ian Jackson Date: Tue, 4 May 2021 00:19:59 +0000 (+0100) Subject: bundles: Move authproof into open_by_name X-Git-Tag: otter-0.6.0~409 X-Git-Url: https://www.chiark.greenend.org.uk/ucgi/~ianmdlvl/git?a=commitdiff_plain;h=b6d69aeef44b9a8ee6cce5da3ef72dfe0890bb03;p=otter.git bundles: Move authproof into open_by_name Signed-off-by: Ian Jackson --- 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)]