-
Notifications
You must be signed in to change notification settings - Fork 41
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
shadow-rs does not report error with git "dubious ownership" fatal error #177
Comments
@taoky Has the git2 feature in shadow-rs been enabled? |
This bug is also reproducible with [dependencies]
shadow-rs = { version = "0.32.0", features = ["git2"] }
[build-dependencies]
shadow-rs = { version = "0.32.0", features = ["git2"] } |
@taoky Please provide git version,like this: ➜ ~ git -v
git version 2.40.1
➜ ~
|
I'm testing with git in Debian 12: $ git --version
git version 2.39.2 libgit2 is libgit2-1.5 (1.5.1+ds-1+deb12u1). |
Thx @taoky .It's bug. In shadow-rs ,current only capture Out stdout. but stderr not processed, we also need optimize it and needs to be exposed. With the Command Output struct: #[derive(PartialEq, Eq, Clone)]
#[stable(feature = "process", since = "1.0.0")]
pub struct Output {
/// The status (exit code) of the process.
#[stable(feature = "process", since = "1.0.0")]
pub status: ExitStatus,
/// The data that the process wrote to stdout.
#[stable(feature = "process", since = "1.0.0")]
pub stdout: Vec<u8>,
/// The data that the process wrote to stderr.
#[stable(feature = "process", since = "1.0.0")]
pub stderr: Vec<u8>,
} In shadow-rs source code with git comannd exec: fn exec(&self, args: &[&str]) -> Option<String> {
Command::new("git")
.current_dir(self.path)
.args(args)
.output()
.map(|x| {
+ String::from_utf8(x.stdout) //Missing handling of the x.stderr
.map(|x| x.trim().to_string())
.ok()
})
.unwrap_or(None)
}
|
Since CVE-2022-24765, new git version adds an ownership check functionality, and if git owner != current uid,
git
command would report such error:However, shadow-rs would silently ignore the error, and returns empty values for git-related consts.
Reproduce:
Initialize an empty project, with a non-root user and files in "Setup" in shadow-rs README (shadow-rs 0.32.0)
Add
println!("{}", build::CLAP_LONG_VERSION);
inmain()
git init
andgit commit -a
Build with same non-root user:
Use
su
to change user to root (Don't usesudo
asgit
would try check this withSUDO_USER
env).git status
in root would report this fatal error.cargo clean
and build with root:This could make it hard to debug when building Rust projects with Docker (by default it uses root inside container), especially in CI environment (to be frankly this spent me an afternoon to find the bug).
The text was updated successfully, but these errors were encountered: