Skip to content

Commit 80384b4

Browse files
committed
cli: Handle PermissionDenied when reading /proc/1/ns/ipc
In restricted build environments such as Tekton/Buildah containers, /proc/1/ns/ipc can be masked even when the process has CAP_SYS_ADMIN. The read_link() call fails with EACCES, which causes bootc to exit with a fatal error. Handle PermissionDenied by logging at debug level and skipping the IPC namespace join, consistent with the existing CAP_SYS_ADMIN gate. Fixes: d250000 Assisted-by: OpenCode (Claude Opus 4.6) Signed-off-by: Joseph Marrero Corchado <jmarrero@redhat.com>
1 parent 8ef2ae9 commit 80384b4

1 file changed

Lines changed: 11 additions & 1 deletion

File tree

crates/lib/src/cli.rs

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1595,6 +1595,9 @@ async fn usroverlay(access_mode: FilesystemOverlayAccessMode) -> Result<()> {
15951595
///
15961596
/// Requires `CAP_SYS_ADMIN` (needed for `setns()`); silently skipped when
15971597
/// running unprivileged (e.g. during RPM build for manpage generation).
1598+
/// Also skipped when `/proc/1/ns/ipc` is not accessible, which can happen
1599+
/// in restricted build environments (e.g. Tekton/Buildah containers) where
1600+
/// `/proc` is masked even for processes with `CAP_SYS_ADMIN`.
15981601
fn join_host_ipc_namespace() -> Result<()> {
15991602
let caps = rustix::thread::capabilities(None).context("capget")?;
16001603
if !caps
@@ -1603,7 +1606,14 @@ fn join_host_ipc_namespace() -> Result<()> {
16031606
{
16041607
return Ok(());
16051608
}
1606-
let ns_pid1 = std::fs::read_link("/proc/1/ns/ipc").context("reading /proc/1/ns/ipc")?;
1609+
let ns_pid1 = match std::fs::read_link("/proc/1/ns/ipc") {
1610+
Ok(v) => v,
1611+
Err(e) if e.kind() == std::io::ErrorKind::PermissionDenied => {
1612+
tracing::debug!("Skipping IPC namespace join: /proc/1/ns/ipc not accessible: {e}");
1613+
return Ok(());
1614+
}
1615+
Err(e) => return Err(e).context("reading /proc/1/ns/ipc"),
1616+
};
16071617
let ns_self = std::fs::read_link("/proc/self/ns/ipc").context("reading /proc/self/ns/ipc")?;
16081618
if ns_pid1 != ns_self {
16091619
let pid1ipcns = std::fs::File::open("/proc/1/ns/ipc").context("open pid1 ipcns")?;

0 commit comments

Comments
 (0)