diff options
| -rw-r--r-- | pkgs/by-name/ro/rollup/src/main.rs | 25 |
1 files changed, 24 insertions, 1 deletions
diff --git a/pkgs/by-name/ro/rollup/src/main.rs b/pkgs/by-name/ro/rollup/src/main.rs index 12cf7dd9..069ed59b 100644 --- a/pkgs/by-name/ro/rollup/src/main.rs +++ b/pkgs/by-name/ro/rollup/src/main.rs @@ -2,7 +2,7 @@ use std::{ env::current_dir, fs, io::Write, - path::PathBuf, + path::{Path, PathBuf}, process::{Command, Stdio}, }; @@ -285,3 +285,26 @@ fn apply_patches(patch_files: Vec<PathBuf>, to: PathBuf, debug_parse: bool) -> R Ok(()) } + +fn check_to(to: &Path) -> Result<()> { + let to = to.join(".git"); + + // NOTE: We cannot just try to stat() the path, because landlock might be in use and does not + // currently deny that (tracked in: https://github.com/landlock-lsm/linux/issues/52) <2026-11-09> + // So we instead try to list it. + let is_listable = { + let dir_entries = fs::read_dir(&to).with_context(|| { + format!( + "Failed check regarding `--to` directory (`{}`) readability. Are you in a sandbox?", + to.display() + ) + })?; + dir_entries.count() > 0 + }; + + if !is_listable { + bail!("To directory (`{}`) is not readable", to.display()); + } + + Ok(()) +} |
