summaryrefslogtreecommitdiff
path: root/src/main.rs
diff options
context:
space:
mode:
Diffstat (limited to 'src/main.rs')
-rw-r--r--src/main.rs15
1 files changed, 11 insertions, 4 deletions
diff --git a/src/main.rs b/src/main.rs
index cca85de..56df611 100644
--- a/src/main.rs
+++ b/src/main.rs
@@ -8,10 +8,11 @@ mod persist;
mod secure;
-const ERROR_ARGS: u8 = 1;
-const ERROR_CONFIG: u8 = 2;
-const ERROR_NOT_AUTHORIZED: u8 = 3;
-const ERROR_AUTH_FAILED: u8 = 4;
+const ERROR_ARGS: u8 = 1;
+const ERROR_CONFIG: u8 = 2;
+const ERROR_NOT_AUTHORIZED: u8 = 3;
+const ERROR_AUTH_FAILED: u8 = 4;
+const ERROR_ELEVATE_PRIVILEGES: u8 = 5;
fn main() -> ExitCode {
@@ -69,6 +70,12 @@ fn main() -> ExitCode {
return ExitCode::from(ERROR_AUTH_FAILED);
}
+ // elevate privileges
+ if nix::unistd::setuid(configs[auth].privlaged_uid).is_err() {
+ eprintln!("Failed to elevate privileges.");
+ return ExitCode::from(ERROR_ELEVATE_PRIVILEGES);
+ };
+
// execute the passed command
let start = 1 + flags.arg_count;
let err = exec::execvp(&args[start], &args[start..]);