disable_sandbox option for global configuration

This commit is contained in:
Xavier Moffett 2024-09-10 20:05:17 -04:00
parent 4fb2ac7ef8
commit 9e4537fded
Signed by: Sapphirus
GPG key ID: A6C061B2CEA1A7AC
3 changed files with 11 additions and 1 deletions

View file

@ -17,4 +17,5 @@ alpm:
sig_level_local: Optional
#parallel_downloads: 5
#check_space: true
#download_timeout: true"
#download_timeout: true
#disable_sandbox: false

View file

@ -103,6 +103,8 @@ pub struct AlpmConfiguration {
check_space: bool,
#[serde(default = "default_true")]
download_timeout: bool,
#[serde(default)]
disable_sandbox: bool,
}
impl Configuration {
@ -146,6 +148,7 @@ impl AlpmConfiguration {
parallel_downloads: parallel_downloads(),
check_space: true,
download_timeout: true,
disable_sandbox: false,
}
}
@ -165,6 +168,10 @@ impl AlpmConfiguration {
self.check_space
}
pub fn disable_sandbox(&self) -> bool {
self.disable_sandbox
}
pub fn held(&self) -> Vec<&str> {
self.hold_pkg.iter().map(|a| a.as_ref()).collect()
}

View file

@ -196,6 +196,7 @@ pub fn instantiate_alpm_agent(config: &Global, remotes: &AlpmConfigData) -> Alpm
let mut handle = Alpm::new("/mnt/fs", "/mnt/fs/var/lib/pacman/").unwrap();
let hook_dirs = vec!["/mnt/fs/usr/share/libalpm/hooks/", "/mnt/fs/etc/pacman.d/hooks/"];
handle.set_disable_sandbox(config.alpm().disable_sandbox());
handle.set_logfile("/mnt/share/pacwrap.log").unwrap();
handle.set_hookdirs(hook_dirs.iter()).unwrap();
handle.set_cachedirs(vec!["/mnt/share/cache"].iter()).unwrap();
@ -215,6 +216,7 @@ pub fn instantiate_alpm(inshandle: &ContainerHandle) -> Alpm {
fn alpm_handle(insvars: &ContainerVariables, db_path: String, remotes: &AlpmConfigData) -> Alpm {
let mut handle = Alpm::new(insvars.root(), &db_path).unwrap();
handle.set_disable_sandbox(CONFIG.alpm().disable_sandbox());
handle.set_cachedirs(vec![format!("{}/pkg", *CACHE_DIR)].iter()).unwrap();
handle.set_gpgdir(format!("{}/pacman/gnupg", *DATA_DIR)).unwrap();
handle.set_logfile(format!("{}/pacwrap.log", *DATA_DIR)).unwrap();