Skip to content

Commit

Permalink
lichen_cli: Require root to run
Browse files Browse the repository at this point in the history
Signed-off-by: Ikey Doherty <[email protected]>
  • Loading branch information
ikeycode committed Aug 1, 2024
1 parent 0cf636c commit ee8f814
Show file tree
Hide file tree
Showing 3 changed files with 29 additions and 2 deletions.
23 changes: 21 additions & 2 deletions Cargo.lock

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

1 change: 1 addition & 0 deletions lichen_cli/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -13,3 +13,4 @@ futures.workspace = true
tokio.workspace = true
installer = { path = "../crates/installer" }
console = "0.15.8"
nix = "0.29"
7 changes: 7 additions & 0 deletions lichen_cli/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -11,11 +11,13 @@ use std::{
time::Duration,
};

use color_eyre::eyre::bail;
use console::{set_colors_enabled, style};
use crossterm::style::Stylize;
use dialoguer::theme::ColorfulTheme;
use indicatif::ProgressStyle;
use installer::{selections, steps::Context, systemd, Account, BootPartition, Installer, Locale, SystemPartition};
use nix::libc::geteuid;
use tokio::io::AsyncWriteExt;
use tokio::process::Command;

Expand Down Expand Up @@ -151,6 +153,11 @@ async fn main() -> color_eyre::Result<()> {
color_eyre::install().unwrap();
set_colors_enabled(true);

let euid = unsafe { geteuid() };
if euid != 0 {
bail!("lichen must be run as root. Re-run with sudo")
}

// Test selection management, force GNOME
let selections = selections::Manager::new().with_groups([
selections::Group::from_str(include_str!("../../selections/base.json"))?,
Expand Down

0 comments on commit ee8f814

Please sign in to comment.