From 641bb5a5831c7948249f685bbbe450e6664a59ff Mon Sep 17 00:00:00 2001 From: Micah Abbott Date: Fri, 10 Nov 2023 16:30:32 -0500 Subject: [PATCH] containerenv: small error message fix This tweaks the error message when `.containerenv` cannot be found so that a fully-qualified path is included in the error. Previously, the error message would just show `run/.containerenv` as the path to the file, which is not entirely clear. I tried to change the `const PATH` to be an absolute path, but doing so breaks the ability for `open_optional()` to open the file successfully; returns an error `a path led outside of the filesystem`. Signed-off-by: Micah Abbott --- lib/src/containerenv.rs | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/lib/src/containerenv.rs b/lib/src/containerenv.rs index 4b4956fab..537c97d9b 100644 --- a/lib/src/containerenv.rs +++ b/lib/src/containerenv.rs @@ -7,6 +7,7 @@ use cap_std_ext::cap_std::fs::Dir; use cap_std_ext::prelude::CapStdExtDirExt; use fn_error_context::context; +/// Path is relative to container rootfs (assumed to be /) const PATH: &str = "run/.containerenv"; #[derive(Debug, Default)] @@ -25,7 +26,9 @@ pub(crate) fn get_container_execution_info(rootfs: &Dir) -> Result BufReader::new(f), None => { - anyhow::bail!("This command must be executed inside a podman container (missing {PATH}") + anyhow::bail!( + "This command must be executed inside a podman container (missing /{PATH})" + ) } }; let mut r = ContainerExecutionInfo::default();