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

pull/103/head
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> { 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 { let command = opt.command.unwrap_or(Command::Show {
short: false, short: false,
tree: false, tree: false,
interface: None, interface: None,
}); });
if unsafe { libc::getuid() } != 0 && !matches!(command, Command::Completions { .. }) {
return Err("innernet must run as root.".into());
}
match command { match command {
Command::Install { Command::Install {
invite, invite,

View File

@ -227,7 +227,7 @@ async fn main() -> Result<(), Box<dyn std::error::Error>> {
pretty_env_logger::init(); pretty_env_logger::init();
let opt = Opt::from_args(); 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()); return Err("innernet-server must run as root.".into());
} }