Skip to content

Commit

Permalink
fix: executing with sudo
Browse files Browse the repository at this point in the history
  • Loading branch information
raphaelcoeffic committed Nov 30, 2024
1 parent f5f7a9e commit 81670e2
Showing 1 changed file with 2 additions and 1 deletion.
3 changes: 2 additions & 1 deletion src/bin/dive.rs
Original file line number Diff line number Diff line change
Expand Up @@ -85,6 +85,7 @@ fn reexec_with_sudo(
let self_exe = read_link("/proc/self/exe")?;
let loglevel = std::env::var("LOGLEVEL").unwrap_or_default();
Err(Command::new("sudo")
.arg("_WITH_SUDO=1")
.args([
format!("LOGLEVEL={}", loglevel),
format!("{}={}", ENV_LEAD_PID, lead_pid),
Expand All @@ -97,7 +98,7 @@ fn reexec_with_sudo(
}

fn runs_with_sudo() -> bool {
std::env::var("SUDO_UID").is_ok()
std::env::var("_WITH_SUDO").is_ok()
}

fn prepare_shell_environment(
Expand Down

0 comments on commit 81670e2

Please sign in to comment.