Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Added doas functionality #1270

Open
wants to merge 9 commits into
base: master
Choose a base branch
from
Open
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
03/11/24 adding doas
max2000warlord committed Nov 3, 2024
commit 9574e848c952de8791bad473708260cc75d1d093
19 changes: 18 additions & 1 deletion src/exec.rs
Original file line number Diff line number Diff line change
@@ -105,6 +105,23 @@ pub fn spawn_sudo(sudo: String, flags: Vec<String>) -> Result<()> {
Ok(())
}

fn update_sudo(sudo: &str, flags: &[String]) -> Result<()> {
let mut cmd = Command::new(sudo);
cmd.args(flags);
let status = command_status(&mut cmd)?;
status.success()?;
Ok(())
}

fn sudo_loop(sudo: &str, flags: &[String]) {
loop {
thread::sleep(Duration::from_secs(250));
if let Err(e) = update_sudo(sudo, flags) {
eprintln!("Failed to update sudo: {}", e);
}
}
}

fn command_status(cmd: &mut Command) -> Result<Status> {
debug!("running command: {:?}", cmd);
let term = &*CAUGHT_SIGNAL;
@@ -114,7 +131,7 @@ fn command_status(cmd: &mut Command) -> Result<Status> {
let ret = cmd
.status()
.map(|s| Status(s.code().unwrap_or(1)))
.context(|| command_err(cmd)());
.context(|| command_err(cmd).to_string());

DEFAULT_SIGNALS.store(true, Ordering::Relaxed);