client, server: don't require root for completions command

This commit is contained in:
Jake McGinty 2021-06-01 00:18:56 +09:00
parent 5570580b78
commit 042881cc7d
2 changed files with 5 additions and 5 deletions

View file

@ -992,16 +992,16 @@ fn main() {
}
fn run(opt: Opts) -> Result<(), Error> {
if unsafe { libc::getuid() } != 0 {
return Err("innernet must run as root.".into());
}
let command = opt.command.unwrap_or(Command::Show {
short: false,
tree: false,
interface: None,
});
if unsafe { libc::getuid() } != 0 && !matches!(command, Command::Completions { .. }) {
return Err("innernet must run as root.".into());
}
match command {
Command::Install {
invite,

View file

@ -227,7 +227,7 @@ async fn main() -> Result<(), Box<dyn std::error::Error>> {
pretty_env_logger::init();
let opt = Opt::from_args();
if unsafe { libc::getuid() } != 0 {
if unsafe { libc::getuid() } != 0 && !matches!(opt.command, Command::Completions { .. }) {
return Err("innernet-server must run as root.".into());
}