Skip to content

Commit

Permalink
kata-ctl: Remove root requirement for "env"
Browse files Browse the repository at this point in the history
Remove the redundant `kata-ctl` `root` check when running the `env`
command. This check duplicated the `GuestProtection` check, and that
check is now no longer necessary anyway.

Signed-off-by: James O. D. Hunt <[email protected]>
  • Loading branch information
jodh-intel committed Dec 1, 2023
1 parent f05ada5 commit e1caca3
Showing 1 changed file with 0 additions and 5 deletions.
5 changes: 0 additions & 5 deletions src/tools/kata-ctl/src/ops/env_ops.rs
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,6 @@ use kata_sys_util::protection;
use kata_types::config::TomlConfig;

use anyhow::{anyhow, Context, Result};
use nix::unistd::Uid;
use serde::{Deserialize, Serialize};
use std::fs::File;
use std::io::{self, Write};
Expand Down Expand Up @@ -473,10 +472,6 @@ pub fn get_env_info(toml_config: &TomlConfig) -> Result<EnvInfo> {
}

pub fn handle_env(env_args: EnvArgument) -> Result<()> {
if !Uid::effective().is_root() {
return Err(anyhow!("kata-ctl env command requires root privileges to get host information. Please run as root or use sudo"));
}

let mut file: Box<dyn Write> = if let Some(path) = env_args.file {
Box::new(
File::create(path.as_str()).with_context(|| format!("Error creating file {}", path))?,
Expand Down

0 comments on commit e1caca3

Please sign in to comment.