From 672d17136b039a26ae0c47c10105371d9ad4c87a Mon Sep 17 00:00:00 2001 From: Valentin Haudiquet Date: Fri, 2 Oct 2026 12:26:46 +0200 Subject: [PATCH] deb: run the user probes through sh with stderr dropped A missing build user is the expected state in every fresh ephemeral chroot: without the redirect the id failures leak into the build log as errors on every run. --- src/deb/local.rs | 22 ++++++++++------------ 1 file changed, 10 insertions(+), 12 deletions(-) diff --git a/src/deb/local.rs b/src/deb/local.rs index 19c369b..7c0b116 100644 --- a/src/deb/local.rs +++ b/src/deb/local.rs @@ -107,12 +107,15 @@ fn ensure_build_user( workroot: &Path, ccache_dir: Option<&str>, ) -> Result<(String, String), Box> { - let probe = ctx - .command("id") - .arg("-u") - .arg(BUILD_USER) - .output() - .map_err(|e| format!("cannot look up {BUILD_USER}: {e}"))?; + // Through sh with the stderr dropped: a missing user is the expected + // state in a fresh chroot, not a message the build log needs. + let id_of = |ctx: &Arc, what: &str| { + ctx.command("sh") + .arg("-c") + .arg(format!("id {what} {BUILD_USER} 2>/dev/null")) + .output() + }; + let probe = id_of(ctx, "-u").map_err(|e| format!("cannot look up {BUILD_USER}: {e}"))?; let fresh = !probe.status.success(); if fresh { create_build_user(ctx)?; @@ -120,12 +123,7 @@ fn ensure_build_user( let mut ids = (String::new(), String::new()); for (flag, slot) in [("-u", 0), ("-g", 1)] { - let output = ctx - .command("id") - .arg(flag) - .arg(BUILD_USER) - .output() - .map_err(|e| format!("cannot look up {BUILD_USER}: {e}"))?; + let output = id_of(ctx, flag).map_err(|e| format!("cannot look up {BUILD_USER}: {e}"))?; if !output.status.success() { return Err(format!("cannot resolve the ids of '{BUILD_USER}'").into()); }