Skip to content

Commit 31eeae9

Browse files
committed
Only absolutize exe if abs path refers to a file and is executable
Fixes #670
1 parent f593f4c commit 31eeae9

File tree

1 file changed

+15
-1
lines changed
  • app/buck2_forkserver/src

1 file changed

+15
-1
lines changed

app/buck2_forkserver/src/run.rs

+15-1
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@ pub mod process_group;
1212
pub mod status_decoder;
1313

1414
use std::borrow::Cow;
15+
use std::fs;
1516
use std::path::Path;
1617
use std::pin::Pin;
1718
use std::process::Command;
@@ -353,7 +354,20 @@ pub fn maybe_absolutize_exe<'a>(
353354

354355
let abs = spawned_process_cwd.join(exe);
355356
if fs_util::try_exists(&abs).context("Error absolute-izing executable")? {
356-
return Ok(abs.into_path_buf().into());
357+
let metadata = fs::metadata(&abs).context("Error getting metadata for path")?;
358+
if metadata.is_file() {
359+
#[cfg(unix)]
360+
{
361+
use std::os::unix::fs::PermissionsExt;
362+
if metadata.permissions().mode() & 0o111 != 0 {
363+
return Ok(abs.into_path_buf().into());
364+
}
365+
}
366+
#[cfg(not(unix))]
367+
{
368+
return Ok(abs.into_path_buf().into());
369+
}
370+
}
357371
}
358372

359373
Ok(exe.into())

0 commit comments

Comments
 (0)