Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 9ee0664b authored by Treehugger Robot's avatar Treehugger Robot Committed by Gerrit Code Review
Browse files

Merge "Add root check to aflags" into main

parents e7a2e599 5223a708
Loading
Loading
Loading
Loading
+5 −3
Original line number Diff line number Diff line
@@ -233,8 +233,6 @@ fn format_flag_row(flag: &Flag, info: &PaddingInfo) -> String {
}

fn set_flag(qualified_name: &str, value: &str) -> Result<()> {
    ensure!(nix::unistd::Uid::current().is_root(), "must be root to mutate flags");

    let flags_binding = DeviceConfigSource::list_flags()?;
    let flag = flags_binding.iter().find(|f| f.qualified_name() == qualified_name).ok_or(
        anyhow!("no aconfig flag '{qualified_name}'. Does the flag have an .aconfig definition?"),
@@ -282,7 +280,9 @@ fn list(source_type: FlagSourceType, container: Option<String>) -> Result<String
    Ok(result)
}

fn main() {
fn main() -> Result<()> {
    ensure!(nix::unistd::Uid::current().is_root(), "must be root");

    let cli = Cli::parse();
    let output = match cli.command {
        Command::List { use_new_storage: true, container } => {
@@ -299,6 +299,8 @@ fn main() {
        Ok(None) => (),
        Err(message) => println!("Error: {message}"),
    }

    Ok(())
}

#[cfg(test)]