Skip to content

Commit

Permalink
chore: remove root check
Browse files Browse the repository at this point in the history
  • Loading branch information
fioncat committed Dec 4, 2024
1 parent c7061ac commit 9ca4849
Show file tree
Hide file tree
Showing 4 changed files with 1 addition and 37 deletions.
19 changes: 0 additions & 19 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 0 additions & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,6 @@ dialoguer = "0.11.0"
file-lock = "2.1.11"
glob = "0.3.1"
libc = "0.2.167"
nix = { version = "0.29.0", features = ["user"] }
num_cpus = "1.16.0"
open = "5.3.1"
pad = "0.1.6"
Expand Down
1 change: 0 additions & 1 deletion src/errors.rs
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
use std::fmt::{self, Display, Formatter};

pub const CODE_STDERR_REDIRECT: i32 = 10;
pub const CODE_ROOT_PRIVILEGES: i32 = 11;
pub const CODE_PARSE_COMMAND_LINE_ARGS: i32 = 12;
pub const CODE_LOAD_CONFIG: i32 = 13;
pub const CODE_COMMAND_FAILED: i32 = 14;
Expand Down
17 changes: 1 addition & 16 deletions src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,6 @@ use std::process;
use anyhow::Result;
use clap::error::ErrorKind as ArgsErrorKind;
use clap::Parser;
use nix::unistd;

use crate::cmd::{App, Run};
use crate::config::Config;
Expand Down Expand Up @@ -50,7 +49,7 @@ fn wrap_result<T>(result: Result<T>, message: &str, error_code: i32) -> T {
}

fn main() {
let mut args: Vec<OsString> = env::args_os().collect();
let args: Vec<OsString> = env::args_os().collect();
let allow_non_tty = args
.get(1)
.is_some_and(|arg| arg.to_str().is_some_and(is_embed_command));
Expand All @@ -66,20 +65,6 @@ fn main() {
// It is safe to set this since all the colored texts will be printed to stderr.
console::set_colors_enabled(true);

// TODO: Support Windows
if unistd::getuid().is_root() {
match args.iter().position(|arg| arg == "--allow-root-privieges") {
Some(pos) => {
warn!("Launching roxide with root privileges can destroy your system, it is strongly not recommended to do this");
args.remove(pos);
}
None => {
error!("Launching roxide with root privileges is not allowed (HINT: You can add `--allow-root-privieges` to omit this check)");
process::exit(errors::CODE_ROOT_PRIVILEGES);
}
}
}

let app = match App::try_parse_from(args) {
Ok(app) => app,
Err(err) => {
Expand Down

0 comments on commit 9ca4849

Please sign in to comment.