Weblate 2 years ago
commit 1526f04d93

@ -93,3 +93,8 @@ pub fn wrap_text<S: AsRef<str>>(s: S, padding: usize) -> Vec<String> {
.map(String::from)
.collect()
}
pub fn is_run_with_root() -> bool {
let uid = unsafe { libc::geteuid() };
uid == 0
}

@ -3,8 +3,8 @@ use builder::pacman::{PacmanColor, PacmanQueryBuilder};
use clap::Parser;
use internal::commands::ShellCommand;
use internal::detect;
use internal::error::SilentUnwrap;
use internal::{detect, utils};
use crate::args::{InstallArgs, Operation, QueryArgs, RemoveArgs};
use crate::interact::page_string;
@ -32,7 +32,7 @@ use logging::init_logger;
#[tokio::main]
async fn main() {
color_eyre::install().unwrap();
if unsafe { libc::geteuid() } == 0 {
if utils::is_run_with_root() {
fl_crash!(AppExitCode::RunAsRoot, "run-as-root");
}

Loading…
Cancel
Save