From f6e8e8acf41092e9cc191d8c82d5776ed959e803 Mon Sep 17 00:00:00 2001 From: Dylan Turner Date: Mon, 6 Mar 2023 12:03:06 -0600 Subject: [PATCH] pkgs: set file permissions post-install Currently 755 (probably always going to be that tbh) Signed-off-by: Dylan Turner --- src/pkg.rs | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/src/pkg.rs b/src/pkg.rs index f22d801..488fd83 100644 --- a/src/pkg.rs +++ b/src/pkg.rs @@ -7,12 +7,12 @@ use std::{ path::Path, fs::{ - File, create_dir_all, read_to_string, remove_file + File, create_dir_all, read_to_string, remove_file, Permissions }, io::{ Write, copy }, process::{ Stdio, Command - } + }, os::unix::fs::PermissionsExt }; use dirs::home_dir; use reqwest::blocking::get; @@ -29,6 +29,7 @@ use version_compare::{ const PKG_LIST_URL: &'static str = "https://raw.githubusercontent.com/blueOkiris/aip-man-pkg-list/main/pkgs.json"; pub const APP_DIR: &'static str = "Applications"; +pub const PERMISSION: u32 = 0o755; // -rwxr-xr-x. /// Structure used to parse JSON info from package list. #[derive(Clone, Debug, Serialize, Deserialize)] @@ -77,6 +78,10 @@ impl Package { "{}/{}-{}.AppImage", app_dir.as_os_str().to_str().unwrap(), self.name, self.version )).expect("Failed to save file"); copy(&mut pkg_file, &mut out).expect("Failed to write package content to file"); + + // Set executable flag + out.set_permissions(Permissions::from_mode(PERMISSION)) + .expect("Failed to set package permissions."); } pub fn remove(&self) {