Skip to content

Commit eaa155a

Browse files
committed
ostree-ext: Add .context for some more errors
This suddenly started in our RPM (COPR/mock) builds, my suspicion is that seccomp got turned on inadvertently, but let's add some error context here on general principle. ``` thread 'boundimage::tests::test_parse_spec_dir' panicked at crates/lib/src/boundimage.rs:290:49: called `Result::unwrap()` on an `Err` value: Querying bound images Caused by: Function not implemented (os error 38) note: run with `RUST_BACKTRACE=1` environment variable to display a backtrace ``` Signed-off-by: Colin Walters <[email protected]>
1 parent 02ecf37 commit eaa155a

File tree

1 file changed

+16
-4
lines changed

1 file changed

+16
-4
lines changed

crates/ostree-ext/src/globals.rs

Lines changed: 16 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,11 @@
11
//! Module containing access to global state.
22
33
use super::Result;
4+
use anyhow::Context;
45
use camino::{Utf8Path, Utf8PathBuf};
56
use cap_std_ext::cap_std::fs::Dir;
67
use cap_std_ext::RootDir;
8+
use fn_error_context::context;
79
use ostree::glib;
810
use std::fs::File;
911
use std::sync::OnceLock;
@@ -61,17 +63,26 @@ impl ConfigPaths {
6163
let p = p.as_ref();
6264
let mut runtime = self.runtime.clone();
6365
runtime.push(p);
64-
if let Some(f) = root.open_optional(&runtime)? {
66+
if let Some(f) = root
67+
.open_optional(&runtime)
68+
.context("Opening runtime auth file")?
69+
{
6570
return Ok(Some((runtime, f)));
6671
}
6772
let mut persistent = self.persistent.clone();
6873
persistent.push(p);
69-
if let Some(f) = root.open_optional(&persistent)? {
74+
if let Some(f) = root
75+
.open_optional(&persistent)
76+
.context("Opening persistent auth file")?
77+
{
7078
return Ok(Some((persistent, f)));
7179
}
7280
if let Some(mut system) = self.system.clone() {
7381
system.push(p);
74-
if let Some(f) = root.open_optional(&system)? {
82+
if let Some(f) = root
83+
.open_optional(&system)
84+
.context("Opening system auth file")?
85+
{
7586
return Ok(Some((system, f)));
7687
}
7788
}
@@ -80,8 +91,9 @@ impl ConfigPaths {
8091
}
8192

8293
/// Return the path to the global container authentication file, if it exists.
94+
#[context("Loading global authfile")]
8395
pub fn get_global_authfile(root: &Dir) -> Result<Option<(Utf8PathBuf, File)>> {
84-
let root = &RootDir::new(root, ".")?;
96+
let root = &RootDir::new(root, ".").context("Opening RootDir")?;
8597
let am_uid0 = rustix::process::getuid() == rustix::process::Uid::ROOT;
8698
get_global_authfile_impl(root, am_uid0)
8799
}

0 commit comments

Comments
 (0)