mirror of
https://github.com/yuezk/GlobalProtect-openconnect.git
synced 2026-11-21 15:26:13 -05:00
feat: install trusted VPN scripts
This commit is contained in:
23 files changed
+454
-11
No files matched your search
@@ -0,0 +1,35 @@
|
||||
use std::io;
|
||||
|
||||
use anyhow::bail;
|
||||
use clap::{Parser, Subcommand};
|
||||
use nix::unistd::Uid;
|
||||
|
||||
#[derive(Parser)]
|
||||
struct Cli {
|
||||
#[command(subcommand)]
|
||||
command: Command,
|
||||
}
|
||||
|
||||
#[derive(Subcommand)]
|
||||
enum Command {
|
||||
Install,
|
||||
Remove,
|
||||
}
|
||||
|
||||
fn try_run() -> anyhow::Result<()> {
|
||||
if !Uid::effective().is_root() {
|
||||
bail!("The VPNC script installer must run as root");
|
||||
}
|
||||
|
||||
match Cli::parse().command {
|
||||
Command::Install => gpservice::vpnc_script::install(io::stdin().lock()),
|
||||
Command::Remove => gpservice::vpnc_script::remove(),
|
||||
}
|
||||
}
|
||||
|
||||
pub(super) fn run() {
|
||||
if let Err(err) = try_run() {
|
||||
eprintln!("Error: {err:#}");
|
||||
std::process::exit(1);
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user