Skip to content

Commit 5ec99fe

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

File tree

1 file changed

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

1 file changed

+14
-1
lines changed

app/buck2_forkserver/src/run.rs

+14-1
Original file line numberDiff line numberDiff line change
@@ -353,7 +353,20 @@ pub fn maybe_absolutize_exe<'a>(
353353

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

359372
Ok(exe.into())

0 commit comments

Comments
 (0)