Skip to content

Commit 1f56ec8

Browse files
committed
Require root
1 parent 2c74064 commit 1f56ec8

2 files changed

Lines changed: 8 additions & 1 deletion

File tree

Cargo.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ tar = "0.4.44"
1616
tokio = { version = "1", features = ["full"] }
1717
tokio-util = { version = "0.7" }
1818
tokio-stream = { version = "0.1", features = ["io-util", "net"] }
19-
nix = { version= "0.31", features = ["sched"] }
19+
nix = { version= "0.31", features = ["sched", "user"] }
2020
futures = "0.3"
2121
async-trait = "0.1"
2222
clap = { version = "4.5", features = ["derive"] }

src/main.rs

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,8 +16,10 @@ use std::{
1616
fs,
1717
fs::File,
1818
path::{Path, PathBuf},
19+
process,
1920
};
2021
use tokio::task::JoinHandle;
22+
use nix::unistd::Uid;
2123

2224
static SPARKLE: Emoji = Emoji("✨", "[*]");
2325

@@ -71,6 +73,11 @@ enum Commands {
7173
async fn main() -> Result<()> {
7274
env_logger::init();
7375

76+
if !Uid::effective().is_root() {
77+
println!("{}", style("This tool must be run as root").red().bold());
78+
process::exit(1);
79+
}
80+
7481
let cli = Cli::parse();
7582
match cli.command {
7683
Commands::Preinstall {

0 commit comments

Comments
 (0)