A native webfishing installer for macos

1.4.1 - No sudo at start

- Sudo is no longer needed to run the entire program and will only be required to sign

+32 -13
+32 -13
src/main.rs
··· 9 use std::fs::File; 10 use std::io::{Read, Write}; 11 use std::path::Path; 12 - use std::process::Command; 13 use std::time::Duration; 14 use steamlocate::SteamDir; 15 use sudo::RunningAs; ··· 137 .expect("Could not copy webfishing.app"); 138 } 139 140 #[tokio::main] 141 async fn main() { 142 - if sudo::check() != RunningAs::Root { 143 - println!("You need to be root to run this program"); 144 } 145 - sudo::escalate_if_needed().expect("Could not escalate"); 146 147 set_current_dir( 148 current_exe() ··· 223 .write(bytes) 224 .expect("Could not write to webfishing.pck"); 225 226 - Command::new("xattr") 227 - .arg("-cr") 228 - .arg("build/webfishing.app") 229 - .output() 230 - .expect("Could not execute xattr"); 231 232 - println!("Webfishing is in the build folder !"); 233 234 - Text::new("Press Enter to quit") 235 - .prompt() 236 - .expect("Could not confirm to quit"); 237 }
··· 9 use std::fs::File; 10 use std::io::{Read, Write}; 11 use std::path::Path; 12 + use std::process::{exit, Command}; 13 use std::time::Duration; 14 use steamlocate::SteamDir; 15 use sudo::RunningAs; ··· 137 .expect("Could not copy webfishing.app"); 138 } 139 140 + fn sign_webfishing() { 141 + Command::new("xattr") 142 + .arg("-cr") 143 + .arg("build/webfishing.app") 144 + .output() 145 + .expect("Could not execute xattr"); 146 + 147 + Command::new("rm") 148 + .arg("build/signing-step") 149 + .output() 150 + .expect("Could not remove signing-step file"); 151 + 152 + println!("Webfishing is in the build folder !"); 153 + 154 + Text::new("Press Enter to quit") 155 + .prompt() 156 + .expect("Could not confirm to quit"); 157 + 158 + 159 + } 160 + 161 #[tokio::main] 162 async fn main() { 163 + if sudo::check() == RunningAs::Root && Path::new("build/signing-step").exists() { 164 + sign_webfishing(); 165 + exit(0); 166 } 167 168 set_current_dir( 169 current_exe() ··· 244 .write(bytes) 245 .expect("Could not write to webfishing.pck"); 246 247 + File::create("build/signing-step").expect("Could not create signing step file"); 248 249 + if sudo::check() != RunningAs::Root { 250 + println!("In order to sign the app, you need to be root"); 251 + sudo::escalate_if_needed().expect("Could not escalate"); 252 + exit(1); 253 + } 254 255 + sign_webfishing(); 256 }