Skip to content

Commit 82d7354

Browse files
committed
ostree-ext: Replace config loading with a stub if we detect mock
Workaround for rpm-software-management/mock#1613 (comment) Signed-off-by: Colin Walters <[email protected]>
1 parent 8abee04 commit 82d7354

File tree

1 file changed

+15
-1
lines changed

1 file changed

+15
-1
lines changed

crates/ostree-ext/src/globals.rs

Lines changed: 15 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -81,8 +81,22 @@ impl ConfigPaths {
8181

8282
/// Return the path to the global container authentication file, if it exists.
8383
pub fn get_global_authfile(root: &Dir) -> Result<Option<(Utf8PathBuf, File)>> {
84-
let root = &RootDir::new(root, ".")?;
84+
// Workaround for https://github.com/rpm-software-management/mock/pull/1613#issuecomment-3421908652
85+
#[cfg(test)]
86+
{
87+
if matches!(
88+
(
89+
std::env::var("HOSTNAME").ok().as_deref(),
90+
std::env::var("container").ok().as_deref()
91+
),
92+
(Some("mock"), Some("systemd-nspawn"))
93+
) {
94+
return Ok(None);
95+
}
96+
}
97+
8598
let am_uid0 = rustix::process::getuid() == rustix::process::Uid::ROOT;
99+
let root = &RootDir::new(root, ".")?;
86100
get_global_authfile_impl(root, am_uid0)
87101
}
88102

0 commit comments

Comments
 (0)