Skip to content

Commit

Permalink
Only absolutize exe if abs path refers to a file and is executable
Browse files Browse the repository at this point in the history
Fixes #670
  • Loading branch information
avdv committed Jun 4, 2024
1 parent f593f4c commit 5ec99fe
Showing 1 changed file with 14 additions and 1 deletion.
15 changes: 14 additions & 1 deletion app/buck2_forkserver/src/run.rs
Original file line number Diff line number Diff line change
Expand Up @@ -353,7 +353,20 @@ pub fn maybe_absolutize_exe<'a>(

let abs = spawned_process_cwd.join(exe);
if fs_util::try_exists(&abs).context("Error absolute-izing executable")? {
return Ok(abs.into_path_buf().into());
let metadata = fs::metadata(&abs).context("Error getting metadata for path")?;
if metadata.is_file() {
#[cfg(unix)]
{
use std::os::unix::fs::PermissionsExt;
if metadata.permissions().mode() & 0o111 != 0 {
return Ok(abs.into_path_buf().into());
}
}
#[cfg(not(unix))]
{
return Ok(abs.into_path_buf().into());
}
}
}

Ok(exe.into())
Expand Down

0 comments on commit 5ec99fe

Please sign in to comment.