From e4ea0cd4cad0f54ab3bc311c3b35bc4bb61bf8d4 Mon Sep 17 00:00:00 2001 From: Benedikt Peetz Date: Mon, 9 Nov 2026 16:33:34 +0100 Subject: pkgs/rollup: Check if the `--to` directory is actually writable Otherwise we would create the patches, but fail to apply them. The issue is that we already moved the tag forward, so the user now needs to manually create the patches again (after exiting the sandbox). --- pkgs/by-name/ro/rollup/src/main.rs | 25 ++++++++++++++++++++++++- 1 file changed, 24 insertions(+), 1 deletion(-) (limited to 'pkgs/by-name') 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, 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(()) +} -- cgit v1.3.1