feat: install trusted VPN scripts

This commit is contained in:
Kevin Yue committed 2026-07-30 15:00:24 +08:00
1 parent 2c29dda2ac
commit fd9b48cd90
23 files changed
+454 -11

No files matched your search

+3
View File
@@ -145,6 +145,7 @@ install:
install -Dm755 target/release/gpclient $(DESTDIR)/usr/bin/gpclient install -Dm755 target/release/gpclient $(DESTDIR)/usr/bin/gpclient
install -Dm755 target/release/gpauth $(DESTDIR)/usr/bin/gpauth install -Dm755 target/release/gpauth $(DESTDIR)/usr/bin/gpauth
install -Dm755 target/release/gpservice $(DESTDIR)/usr/bin/gpservice install -Dm755 target/release/gpservice $(DESTDIR)/usr/bin/gpservice
install -Dm755 target/release/gp-vpnc-script-installer $(DESTDIR)/usr/libexec/gpclient/gp-vpnc-script-installer
# Install the GUI components if BUILD_GUI_HELPER is set to 1 # Install the GUI components if BUILD_GUI_HELPER is set to 1
if [ $(BUILD_GUI_HELPER) -eq 1 ]; then \ if [ $(BUILD_GUI_HELPER) -eq 1 ]; then \
@@ -188,6 +189,7 @@ install-bsd:
fi fi
install -d $(DESTDIR)$(PREFIX)/libexec/gpclient install -d $(DESTDIR)$(PREFIX)/libexec/gpclient
install -m 755 target/release/gp-vpnc-script-installer $(DESTDIR)$(PREFIX)/libexec/gpclient/gp-vpnc-script-installer
install -m 755 packaging/files/usr/libexec/gpclient/vpnc-script $(DESTDIR)$(PREFIX)/libexec/gpclient/vpnc-script install -m 755 packaging/files/usr/libexec/gpclient/vpnc-script $(DESTDIR)$(PREFIX)/libexec/gpclient/vpnc-script
install -m 755 packaging/files/usr/libexec/gpclient/hipreport.sh $(DESTDIR)$(PREFIX)/libexec/gpclient/hipreport.sh install -m 755 packaging/files/usr/libexec/gpclient/hipreport.sh $(DESTDIR)$(PREFIX)/libexec/gpclient/hipreport.sh
@@ -276,6 +278,7 @@ uninstall:
rm -f $(DESTDIR)/usr/libexec/gpclient/vpnc-script rm -f $(DESTDIR)/usr/libexec/gpclient/vpnc-script
rm -f $(DESTDIR)/usr/libexec/gpclient/hipreport.sh rm -f $(DESTDIR)/usr/libexec/gpclient/hipreport.sh
rm -f $(DESTDIR)/usr/libexec/gpclient/gp-vpnc-script-installer
rm -f $(DESTDIR)/usr/lib/NetworkManager/dispatcher.d/pre-down.d/gpclient.down rm -f $(DESTDIR)/usr/lib/NetworkManager/dispatcher.d/pre-down.d/gpclient.down
rm -f $(DESTDIR)/usr/lib/NetworkManager/dispatcher.d/gpclient-nm-hook rm -f $(DESTDIR)/usr/lib/NetworkManager/dispatcher.d/gpclient-nm-hook
@@ -0,0 +1,10 @@
#[cfg(any(target_os = "linux", target_os = "freebsd", target_os = "openbsd"))]
#[path = "privileged_unix.rs"]
mod platform;
#[cfg(not(any(target_os = "linux", target_os = "freebsd", target_os = "openbsd")))]
#[path = "unsupported.rs"]
mod platform;
fn main() {
platform::run();
}
@@ -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);
}
}
@@ -0,0 +1,4 @@
pub(super) fn run() {
eprintln!("The VPNC script installer is only available on Linux, FreeBSD, and OpenBSD");
std::process::exit(1);
}
+2 -1
View File
@@ -102,6 +102,7 @@ impl Cli {
let gui_restart_requested = Arc::new(AtomicBool::new(false)); let gui_restart_requested = Arc::new(AtomicBool::new(false));
let registry = Arc::new(SessionRegistry::new(Uuid::new_v4())); let registry = Arc::new(SessionRegistry::new(Uuid::new_v4()));
let externally_brokered = self.externally_brokered(); let externally_brokered = self.externally_brokered();
let trusted_csd_uid = crate::runtime_user::trusted_csd_uid()?;
let brokered_scripts_dir = if externally_brokered { let brokered_scripts_dir = if externally_brokered {
let executable = std::env::current_exe().context("Failed to locate the gpservice executable")?; let executable = std::env::current_exe().context("Failed to locate the gpservice executable")?;
let contents_dir = executable let contents_dir = executable
@@ -120,7 +121,7 @@ impl Cli {
brokered_scripts_dir, brokered_scripts_dir,
)); ));
let mut vpn_task = VpnTask::new(ws_req_rx, vpn_state_tx, externally_brokered); let mut vpn_task = VpnTask::new(ws_req_rx, vpn_state_tx, externally_brokered, trusted_csd_uid);
let idle_vpn_state_rx = vpn_state_rx.clone(); let idle_vpn_state_rx = vpn_state_rx.clone();
let ws_server = WsServer::new( let ws_server = WsServer::new(
env!("CARGO_PKG_VERSION"), env!("CARGO_PKG_VERSION"),
+2
View File
@@ -0,0 +1,2 @@
#[cfg(any(target_os = "linux", target_os = "freebsd", target_os = "openbsd"))]
pub mod vpnc_script;
+2
View File
@@ -8,7 +8,9 @@ mod handlers;
mod macos_broker; mod macos_broker;
mod request_dispatcher; mod request_dispatcher;
mod routes; mod routes;
mod runtime_user;
mod session_registry; mod session_registry;
mod vpn_script;
mod vpn_task; mod vpn_task;
mod ws_connection; mod ws_connection;
mod ws_server; mod ws_server;
@@ -0,0 +1,3 @@
pub(crate) fn trusted_csd_uid() -> anyhow::Result<Option<u32>> {
Ok(None)
}
+8
View File
@@ -0,0 +1,8 @@
#[cfg(any(target_os = "linux", target_os = "freebsd", target_os = "openbsd"))]
#[path = "privileged_unix.rs"]
mod platform;
#[cfg(not(any(target_os = "linux", target_os = "freebsd", target_os = "openbsd")))]
#[path = "default.rs"]
mod platform;
pub(crate) use platform::trusted_csd_uid;
@@ -0,0 +1,7 @@
pub(crate) fn trusted_csd_uid() -> anyhow::Result<Option<u32>> {
let uid = gpapi::process::users::get_non_root_user()?.uid();
if uid == 0 {
anyhow::bail!("The HIP script user must not be root");
}
Ok(Some(uid))
}
+6
View File
@@ -0,0 +1,6 @@
use gpapi::service::request::ConnectArgs;
use openconnect::{Vpn, VpnBuilder};
pub(crate) fn builder(server: &str, cookie: &str, args: &ConnectArgs) -> anyhow::Result<VpnBuilder> {
Ok(Vpn::builder(server, cookie).script_path(args.vpnc_script()))
}
+10
View File
@@ -0,0 +1,10 @@
#[cfg(any(target_os = "linux", target_os = "freebsd", target_os = "openbsd"))]
#[path = "privileged_unix.rs"]
mod platform;
#[cfg(not(any(target_os = "linux", target_os = "freebsd", target_os = "openbsd")))]
#[path = "default.rs"]
mod platform;
#[cfg(any(target_os = "linux", target_os = "freebsd", target_os = "openbsd", test))]
mod selection;
pub(crate) use platform::builder;
@@ -0,0 +1,15 @@
use gpapi::service::request::ConnectArgs;
use openconnect::{Vpn, VpnBuilder};
use super::selection::{ScriptSource, select};
pub(crate) fn builder(server: &str, cookie: &str, args: &ConnectArgs) -> anyhow::Result<VpnBuilder> {
let installed = gpservice::vpnc_script::installed_script()?;
match select(installed.as_deref(), args.vpnc_script()) {
ScriptSource::Installed(path) => {
Ok(Vpn::builder(server, cookie).script_path(Some(path.to_string_lossy().into_owned())))
}
ScriptSource::Legacy(script) => Ok(Vpn::builder(server, cookie).script(Some(script.to_owned()))),
ScriptSource::Default => Ok(Vpn::builder(server, cookie).script_path(None)),
}
}
@@ -0,0 +1,41 @@
use std::path::Path;
#[derive(Debug, PartialEq, Eq)]
pub(super) enum ScriptSource<'a> {
Installed(&'a Path),
Legacy(&'a str),
Default,
}
pub(super) fn select<'a>(installed: Option<&'a Path>, legacy: Option<&'a str>) -> ScriptSource<'a> {
if let Some(path) = installed {
return ScriptSource::Installed(path);
}
if let Some(script) = legacy {
return ScriptSource::Legacy(script);
}
ScriptSource::Default
}
#[cfg(test)]
mod tests {
use super::*;
#[test]
fn installed_script_takes_precedence_over_legacy() {
let installed = Path::new("/var/lib/gpclient/scripts/vpnc-script");
assert_eq!(
select(Some(installed), Some("legacy-command")),
ScriptSource::Installed(installed)
);
}
#[test]
fn legacy_script_is_used_before_default() {
assert_eq!(
select(None, Some("legacy-command")),
ScriptSource::Legacy("legacy-command")
);
assert_eq!(select(None, None), ScriptSource::Default);
}
}
+40 -8
View File
@@ -19,16 +19,18 @@ pub(crate) struct VpnTaskContext {
vpn_state_tx: Arc<watch::Sender<VpnState>>, vpn_state_tx: Arc<watch::Sender<VpnState>>,
disconnect_rx: RwLock<Option<oneshot::Receiver<()>>>, disconnect_rx: RwLock<Option<oneshot::Receiver<()>>>,
brokered_macos: bool, brokered_macos: bool,
trusted_csd_uid: Option<u32>,
identity_files: Arc<RwLock<Vec<tempfile::NamedTempFile>>>, identity_files: Arc<RwLock<Vec<tempfile::NamedTempFile>>>,
} }
impl VpnTaskContext { impl VpnTaskContext {
pub fn new(vpn_state_tx: watch::Sender<VpnState>, brokered_macos: bool) -> Self { pub fn new(vpn_state_tx: watch::Sender<VpnState>, brokered_macos: bool, trusted_csd_uid: Option<u32>) -> Self {
Self { Self {
vpn_handle: Default::default(), vpn_handle: Default::default(),
vpn_state_tx: Arc::new(vpn_state_tx), vpn_state_tx: Arc::new(vpn_state_tx),
disconnect_rx: Default::default(), disconnect_rx: Default::default(),
brokered_macos, brokered_macos,
trusted_csd_uid,
identity_files: Default::default(), identity_files: Default::default(),
} }
} }
@@ -53,11 +55,21 @@ impl VpnTaskContext {
} }
}; };
let allow_extend_session = args.allow_extend_session(); let allow_extend_session = args.allow_extend_session();
let mut vpn_builder = Vpn::builder(req.gateway().server(), args.cookie()); let vpn_builder = match crate::vpn_script::builder(req.gateway().server(), args.cookie(), args) {
vpn_builder = if self.brokered_macos { Ok(builder) => builder,
vpn_builder.script_path(args.vpnc_script()) Err(err) => {
} else { warn!("Failed to select the VPNC script: {err}");
vpn_builder.script(args.vpnc_script()) vpn_state_tx.send(VpnState::Disconnected).ok();
return;
}
};
let csd_uid = match resolve_csd_uid(self.trusted_csd_uid, args.csd_uid(), args.hip()) {
Ok(uid) => uid,
Err(err) => {
warn!("Failed to select the HIP script user: {err}");
vpn_state_tx.send(VpnState::Disconnected).ok();
return;
}
}; };
let vpn = match vpn_builder let vpn = match vpn_builder
.user_agent(args.user_agent()) .user_agent(args.user_agent())
@@ -69,7 +81,7 @@ impl VpnTaskContext {
.sslkey(identity.sslkey.clone()) .sslkey(identity.sslkey.clone())
.key_password(args.key_password()) .key_password(args.key_password())
.hip(args.hip()) .hip(args.hip())
.csd_uid(args.csd_uid()) .csd_uid(csd_uid)
.csd_wrapper(args.csd_wrapper()) .csd_wrapper(args.csd_wrapper())
.reconnect_timeout(args.reconnect_timeout()) .reconnect_timeout(args.reconnect_timeout())
.mtu(args.mtu()) .mtu(args.mtu())
@@ -162,8 +174,9 @@ impl VpnTask {
ws_req_rx: mpsc::Receiver<WsRequest>, ws_req_rx: mpsc::Receiver<WsRequest>,
vpn_state_tx: watch::Sender<VpnState>, vpn_state_tx: watch::Sender<VpnState>,
brokered_macos: bool, brokered_macos: bool,
trusted_csd_uid: Option<u32>,
) -> Self { ) -> Self {
let ctx = Arc::new(VpnTaskContext::new(vpn_state_tx, brokered_macos)); let ctx = Arc::new(VpnTaskContext::new(vpn_state_tx, brokered_macos, trusted_csd_uid));
let cancel_token = CancellationToken::new(); let cancel_token = CancellationToken::new();
Self { Self {
@@ -204,6 +217,14 @@ impl VpnTask {
} }
} }
fn resolve_csd_uid(trusted_uid: Option<u32>, requested_uid: u32, hip_enabled: bool) -> anyhow::Result<u32> {
let uid = trusted_uid.unwrap_or(requested_uid);
if hip_enabled && uid == 0 {
anyhow::bail!("HIP scripts must not run as root");
}
Ok(uid)
}
struct PreparedIdentity { struct PreparedIdentity {
certificate: Option<String>, certificate: Option<String>,
sslkey: Option<String>, sslkey: Option<String>,
@@ -278,6 +299,17 @@ async fn process_ws_req(req: WsRequest, ctx: Arc<VpnTaskContext>) {
mod tests { mod tests {
use super::*; use super::*;
#[test]
fn trusted_csd_uid_overrides_request_uid() {
assert_eq!(resolve_csd_uid(Some(1000), 0, true).unwrap(), 1000);
}
#[test]
fn root_csd_uid_is_rejected_when_hip_is_enabled() {
assert!(resolve_csd_uid(None, 0, true).is_err());
assert_eq!(resolve_csd_uid(None, 0, false).unwrap(), 0);
}
#[test] #[test]
fn maps_openconnect_session_metadata_to_service_session_info() { fn maps_openconnect_session_metadata_to_service_session_info() {
let info = SessionInfo::from_vpn_session_fields( let info = SessionInfo::from_vpn_session_fields(
+216
View File
@@ -0,0 +1,216 @@
use std::{
fs::{self, File, Metadata, Permissions},
io::{self, Read, Write},
os::unix::fs::{MetadataExt, PermissionsExt},
path::{Path, PathBuf},
};
use anyhow::{Context, bail};
use common::constants::{INSTALLED_VPNC_SCRIPT, MAX_VPNC_SCRIPT_SIZE};
use tempfile::NamedTempFile;
const DIRECTORY_MODE: u32 = 0o755;
const SCRIPT_MODE: u32 = 0o755;
const ROOT_UID: u32 = 0;
pub fn installed_script() -> anyhow::Result<Option<PathBuf>> {
let path = PathBuf::from(INSTALLED_VPNC_SCRIPT);
match fs::symlink_metadata(&path) {
Ok(metadata) => {
validate_script_metadata(&path, &metadata, ROOT_UID)?;
let directory = path.parent().context("Installed VPNC script has no parent directory")?;
validate_directory(directory, ROOT_UID)?;
validate_directory(
directory
.parent()
.context("Installed VPNC script directory has no parent directory")?,
ROOT_UID,
)?;
Ok(Some(path))
}
Err(err) if err.kind() == io::ErrorKind::NotFound => Ok(None),
Err(err) => Err(err).context("Failed to inspect the installed VPNC script"),
}
}
pub fn install(input: impl Read) -> anyhow::Result<()> {
let target = Path::new(INSTALLED_VPNC_SCRIPT);
let directory = target
.parent()
.context("Installed VPNC script has no parent directory")?;
let state_directory = directory
.parent()
.context("Installed VPNC script directory has no parent directory")?;
let state_parent = state_directory
.parent()
.context("VPNC script state directory has no parent directory")?;
validate_directory(state_parent, ROOT_UID)?;
ensure_directory(state_directory, ROOT_UID)?;
ensure_directory(directory, ROOT_UID)?;
install_at(input, target, ROOT_UID)
}
pub fn remove() -> anyhow::Result<()> {
if installed_script()?.is_none() {
return Ok(());
}
remove_at(Path::new(INSTALLED_VPNC_SCRIPT), ROOT_UID)
}
fn install_at(mut input: impl Read, target: &Path, owner_uid: u32) -> anyhow::Result<()> {
let directory = target
.parent()
.context("Installed VPNC script has no parent directory")?;
ensure_directory(directory, owner_uid)?;
if let Ok(metadata) = fs::symlink_metadata(target) {
validate_script_metadata(target, &metadata, owner_uid)?;
}
let mut contents = Vec::new();
input
.by_ref()
.take(MAX_VPNC_SCRIPT_SIZE as u64 + 1)
.read_to_end(&mut contents)
.context("Failed to read the VPNC script")?;
if contents.is_empty() {
bail!("VPNC script is empty");
}
if contents.len() > MAX_VPNC_SCRIPT_SIZE {
bail!("VPNC script exceeds the {} byte limit", MAX_VPNC_SCRIPT_SIZE);
}
let mut staged = NamedTempFile::new_in(directory).context("Failed to stage the VPNC script")?;
staged
.as_file()
.set_permissions(Permissions::from_mode(SCRIPT_MODE))
.context("Failed to set VPNC script permissions")?;
staged.write_all(&contents).context("Failed to write the VPNC script")?;
staged.as_file().sync_all().context("Failed to sync the VPNC script")?;
staged
.persist(target)
.map_err(|err| err.error)
.context("Failed to install the VPNC script")?;
sync_directory(directory)?;
let metadata = fs::symlink_metadata(target).context("Failed to inspect the installed VPNC script")?;
validate_script_metadata(target, &metadata, owner_uid)
}
fn remove_at(target: &Path, owner_uid: u32) -> anyhow::Result<()> {
let directory = target
.parent()
.context("Installed VPNC script has no parent directory")?;
validate_directory(directory, owner_uid)?;
match fs::symlink_metadata(target) {
Ok(metadata) => {
validate_script_metadata(target, &metadata, owner_uid)?;
fs::remove_file(target).context("Failed to remove the installed VPNC script")?;
sync_directory(directory)
}
Err(err) if err.kind() == io::ErrorKind::NotFound => Ok(()),
Err(err) => Err(err).context("Failed to inspect the installed VPNC script"),
}
}
fn ensure_directory(directory: &Path, owner_uid: u32) -> anyhow::Result<()> {
match fs::symlink_metadata(directory) {
Ok(_) => validate_directory(directory, owner_uid),
Err(err) if err.kind() == io::ErrorKind::NotFound => {
if let Some(parent) = directory.parent() {
ensure_directory(parent, owner_uid)?;
}
fs::create_dir(directory).context("Failed to create the VPNC script directory")?;
fs::set_permissions(directory, Permissions::from_mode(DIRECTORY_MODE))
.context("Failed to set VPNC script directory permissions")?;
validate_directory(directory, owner_uid)
}
Err(err) => Err(err).context("Failed to inspect the VPNC script directory"),
}
}
fn validate_directory(path: &Path, owner_uid: u32) -> anyhow::Result<()> {
let metadata = fs::symlink_metadata(path)
.with_context(|| format!("Failed to inspect VPNC script directory {}", path.display()))?;
if metadata.file_type().is_symlink() || !metadata.is_dir() {
bail!("VPNC script directory {} is not a real directory", path.display());
}
validate_ownership_and_mode(path, &metadata, owner_uid)
}
fn validate_script_metadata(path: &Path, metadata: &Metadata, owner_uid: u32) -> anyhow::Result<()> {
if metadata.file_type().is_symlink() || !metadata.is_file() {
bail!("Installed VPNC script {} is not a regular file", path.display());
}
validate_ownership_and_mode(path, metadata, owner_uid)?;
if metadata.mode() & 0o111 == 0 {
bail!("Installed VPNC script {} is not executable", path.display());
}
Ok(())
}
fn validate_ownership_and_mode(path: &Path, metadata: &Metadata, owner_uid: u32) -> anyhow::Result<()> {
if metadata.uid() != owner_uid {
bail!("{} must be owned by uid {}", path.display(), owner_uid);
}
if metadata.mode() & 0o022 != 0 {
bail!("{} must not be writable by group or other users", path.display());
}
Ok(())
}
fn sync_directory(directory: &Path) -> anyhow::Result<()> {
File::open(directory)
.and_then(|file| file.sync_all())
.context("Failed to sync the VPNC script directory")
}
#[cfg(test)]
mod tests {
use super::*;
#[test]
fn installs_and_removes_script_atomically() {
let temp = tempfile::tempdir().unwrap();
let metadata = fs::symlink_metadata(temp.path()).unwrap();
let owner_uid = metadata.uid();
let directory = temp.path().join("scripts");
let target = directory.join("vpnc-script");
install_at("#!/bin/sh\nexit 0\n".as_bytes(), &target, owner_uid).unwrap();
let metadata = fs::symlink_metadata(&target).unwrap();
assert!(metadata.is_file());
assert_eq!(metadata.mode() & 0o777, SCRIPT_MODE);
remove_at(&target, owner_uid).unwrap();
assert!(!target.exists());
}
#[test]
fn rejects_oversized_script() {
let temp = tempfile::tempdir().unwrap();
let metadata = fs::symlink_metadata(temp.path()).unwrap();
let owner_uid = metadata.uid();
let target = temp.path().join("scripts/vpnc-script");
let input = vec![b'x'; MAX_VPNC_SCRIPT_SIZE + 1];
assert!(install_at(input.as_slice(), &target, owner_uid).is_err());
assert!(!target.exists());
}
#[test]
fn rejects_symlink_target() {
use std::os::unix::fs::symlink;
let temp = tempfile::tempdir().unwrap();
let metadata = fs::symlink_metadata(temp.path()).unwrap();
let owner_uid = metadata.uid();
let directory = temp.path().join("scripts");
fs::create_dir(&directory).unwrap();
let target = directory.join("vpnc-script");
symlink("/bin/sh", &target).unwrap();
assert!(install_at("exit 0\n".as_bytes(), &target, owner_uid).is_err());
}
}
+11
View File
@@ -3,6 +3,8 @@ use std::{
path::{Path, PathBuf}, path::{Path, PathBuf},
}; };
#[cfg(any(target_os = "linux", target_os = "freebsd", target_os = "openbsd"))]
use crate::constants::GP_VPNC_SCRIPT_INSTALLER_BINARY;
use crate::constants::{GP_AUTH_BINARY, GP_CLIENT_BINARY, GP_GUI_BINARY, GP_GUI_HELPER_BINARY, GP_SERVICE_BINARY}; use crate::constants::{GP_AUTH_BINARY, GP_CLIENT_BINARY, GP_GUI_BINARY, GP_GUI_HELPER_BINARY, GP_SERVICE_BINARY};
pub fn gpclient() -> PathBuf { pub fn gpclient() -> PathBuf {
@@ -13,6 +15,15 @@ pub fn gpservice() -> PathBuf {
resolve("GP_SERVICE_BINARY", "gpservice", GP_SERVICE_BINARY) resolve("GP_SERVICE_BINARY", "gpservice", GP_SERVICE_BINARY)
} }
#[cfg(any(target_os = "linux", target_os = "freebsd", target_os = "openbsd"))]
pub fn gp_vpnc_script_installer() -> PathBuf {
resolve(
"GP_VPNC_SCRIPT_INSTALLER_BINARY",
"gp-vpnc-script-installer",
GP_VPNC_SCRIPT_INSTALLER_BINARY,
)
}
pub fn gpauth() -> PathBuf { pub fn gpauth() -> PathBuf {
resolve("GP_AUTH_BINARY", "gpauth", GP_AUTH_BINARY) resolve("GP_AUTH_BINARY", "gpauth", GP_AUTH_BINARY)
} }
+9
View File
@@ -3,6 +3,15 @@ pub const GP_CLIENT_VERSION_LINUX: &str = "6.3.3-619";
pub const GP_CLIENT_VERSION_WINDOWS: &str = "6.3.3-650"; pub const GP_CLIENT_VERSION_WINDOWS: &str = "6.3.3-650";
pub const GP_CLIENT_VERSION_MACOS: &str = "6.3.3-915"; pub const GP_CLIENT_VERSION_MACOS: &str = "6.3.3-915";
pub const GP_SERVICE_LOCK_FILE: &str = "/var/run/gpservice.lock"; pub const GP_SERVICE_LOCK_FILE: &str = "/var/run/gpservice.lock";
#[cfg(target_os = "linux")]
pub const GP_VPNC_SCRIPT_INSTALLER_BINARY: &str = "/usr/libexec/gpclient/gp-vpnc-script-installer";
#[cfg(target_os = "linux")]
pub const INSTALLED_VPNC_SCRIPT: &str = "/var/lib/gpclient/scripts/vpnc-script";
#[cfg(any(target_os = "freebsd", target_os = "openbsd"))]
pub const GP_VPNC_SCRIPT_INSTALLER_BINARY: &str = "/usr/local/libexec/gpclient/gp-vpnc-script-installer";
#[cfg(any(target_os = "freebsd", target_os = "openbsd"))]
pub const INSTALLED_VPNC_SCRIPT: &str = "/var/db/gpclient/scripts/vpnc-script";
pub const MAX_VPNC_SCRIPT_SIZE: usize = 1024 * 1024;
pub const GP_CALLBACK_PORT_FILENAME: &str = "gpcallback.port"; pub const GP_CALLBACK_PORT_FILENAME: &str = "gpcallback.port";
// Release binaries - macOS (Apple Silicon Homebrew) // Release binaries - macOS (Apple Silicon Homebrew)
+5 -2
View File
@@ -101,7 +101,8 @@
--replace-fail /usr/bin/gpauth /run/current-system/sw/bin/gpauth --replace-fail /usr/bin/gpauth /run/current-system/sw/bin/gpauth
substituteInPlace $out/share/polkit-1/actions/com.yuezk.gpgui.policy \ substituteInPlace $out/share/polkit-1/actions/com.yuezk.gpgui.policy \
--replace-fail /usr/bin/gpservice $out/bin/gpservice --replace-fail /usr/bin/gpservice $out/bin/gpservice \
--replace-fail /usr/libexec/gpclient/gp-vpnc-script-installer $out/bin/gp-vpnc-script-installer
if [ -f $out/lib/NetworkManager/dispatcher.d/pre-down.d/gpclient.down ]; then if [ -f $out/lib/NetworkManager/dispatcher.d/pre-down.d/gpclient.down ]; then
substituteInPlace $out/lib/NetworkManager/dispatcher.d/pre-down.d/gpclient.down \ substituteInPlace $out/lib/NetworkManager/dispatcher.d/pre-down.d/gpclient.down \
@@ -117,7 +118,8 @@
--replace-fail /usr/bin/gpauth /run/current-system/sw/bin/gpauth --replace-fail /usr/bin/gpauth /run/current-system/sw/bin/gpauth
substituteInPlace $out/share/polkit-1/actions/com.yuezk.gpgui.policy \ substituteInPlace $out/share/polkit-1/actions/com.yuezk.gpgui.policy \
--replace-fail /usr/bin/gpservice $out/bin/gpservice --replace-fail /usr/bin/gpservice $out/bin/gpservice \
--replace-fail /usr/libexec/gpclient/gp-vpnc-script-installer ${prebuiltFiles}/libexec/gpclient/gp-vpnc-script-installer
if [ -f $out/lib/NetworkManager/dispatcher.d/pre-down.d/gpclient.down ]; then if [ -f $out/lib/NetworkManager/dispatcher.d/pre-down.d/gpclient.down ]; then
substituteInPlace $out/lib/NetworkManager/dispatcher.d/pre-down.d/gpclient.down \ substituteInPlace $out/lib/NetworkManager/dispatcher.d/pre-down.d/gpclient.down \
@@ -254,6 +256,7 @@
runScript = "/usr/bin/${binaryName}"; runScript = "/usr/bin/${binaryName}";
profile = '' profile = ''
export PATH=/run/wrappers/bin:$PATH export PATH=/run/wrappers/bin:$PATH
export GP_VPNC_SCRIPT_INSTALLER_BINARY='${prebuiltFiles}/libexec/gpclient/gp-vpnc-script-installer'
''; '';
extraBwrapArgs = [ extraBwrapArgs = [
"--bind-try" "--bind-try"
+2
View File
@@ -12,6 +12,7 @@ install:
install -Dm755 artifacts/usr/libexec/gpclient/vpnc-script $(DESTDIR)/usr/libexec/gpclient/vpnc-script install -Dm755 artifacts/usr/libexec/gpclient/vpnc-script $(DESTDIR)/usr/libexec/gpclient/vpnc-script
install -Dm755 artifacts/usr/libexec/gpclient/hipreport.sh $(DESTDIR)/usr/libexec/gpclient/hipreport.sh install -Dm755 artifacts/usr/libexec/gpclient/hipreport.sh $(DESTDIR)/usr/libexec/gpclient/hipreport.sh
install -Dm755 artifacts/usr/libexec/gpclient/gp-vpnc-script-installer $(DESTDIR)/usr/libexec/gpclient/gp-vpnc-script-installer
# Install the disconnect hooks # Install the disconnect hooks
install -Dm755 artifacts/usr/lib/NetworkManager/dispatcher.d/pre-down.d/gpclient.down $(DESTDIR)/usr/lib/NetworkManager/dispatcher.d/pre-down.d/gpclient.down install -Dm755 artifacts/usr/lib/NetworkManager/dispatcher.d/pre-down.d/gpclient.down $(DESTDIR)/usr/lib/NetworkManager/dispatcher.d/pre-down.d/gpclient.down
@@ -37,6 +38,7 @@ uninstall:
rm -f $(DESTDIR)/usr/libexec/gpclient/vpnc-script rm -f $(DESTDIR)/usr/libexec/gpclient/vpnc-script
rm -f $(DESTDIR)/usr/libexec/gpclient/hipreport.sh rm -f $(DESTDIR)/usr/libexec/gpclient/hipreport.sh
rm -f $(DESTDIR)/usr/libexec/gpclient/gp-vpnc-script-installer
rm -f $(DESTDIR)/usr/lib/NetworkManager/dispatcher.d/pre-down.d/gpclient.down rm -f $(DESTDIR)/usr/lib/NetworkManager/dispatcher.d/pre-down.d/gpclient.down
rm -f $(DESTDIR)/usr/lib/NetworkManager/dispatcher.d/gpclient-nm-hook rm -f $(DESTDIR)/usr/lib/NetworkManager/dispatcher.d/gpclient-nm-hook
+11
View File
@@ -15,4 +15,15 @@
<annotate key="org.freedesktop.policykit.exec.path">/usr/local/bin/gpservice</annotate> <annotate key="org.freedesktop.policykit.exec.path">/usr/local/bin/gpservice</annotate>
<annotate key="org.freedesktop.policykit.exec.allow_gui">true</annotate> <annotate key="org.freedesktop.policykit.exec.allow_gui">true</annotate>
</action> </action>
<action id="com.yuezk.gpgui.manage-vpnc-script">
<description>Manage the system-wide GP Connect VPN script</description>
<message>Administrator authentication is required to manage the system-wide VPN script</message>
<defaults>
<allow_any>auth_admin</allow_any>
<allow_inactive>auth_admin</allow_inactive>
<allow_active>auth_admin</allow_active>
</defaults>
<annotate key="org.freedesktop.policykit.exec.path">/usr/local/libexec/gpclient/gp-vpnc-script-installer</annotate>
<annotate key="org.freedesktop.policykit.exec.allow_gui">true</annotate>
</action>
</policyconfig> </policyconfig>
@@ -15,4 +15,15 @@
<annotate key="org.freedesktop.policykit.exec.path">/usr/bin/gpservice</annotate> <annotate key="org.freedesktop.policykit.exec.path">/usr/bin/gpservice</annotate>
<annotate key="org.freedesktop.policykit.exec.allow_gui">true</annotate> <annotate key="org.freedesktop.policykit.exec.allow_gui">true</annotate>
</action> </action>
<action id="com.yuezk.gpgui.manage-vpnc-script">
<description>Manage the system-wide GP Connect VPN script</description>
<message>Administrator authentication is required to manage the system-wide VPN script</message>
<defaults>
<allow_any>auth_admin</allow_any>
<allow_inactive>auth_admin</allow_inactive>
<allow_active>auth_admin</allow_active>
</defaults>
<annotate key="org.freedesktop.policykit.exec.path">/usr/libexec/gpclient/gp-vpnc-script-installer</annotate>
<annotate key="org.freedesktop.policykit.exec.allow_gui">true</annotate>
</action>
</policyconfig> </policyconfig>
@@ -64,6 +64,7 @@ make build
%{_bindir}/* %{_bindir}/*
%{_libexecdir}/gpclient/vpnc-script %{_libexecdir}/gpclient/vpnc-script
%{_libexecdir}/gpclient/hipreport.sh %{_libexecdir}/gpclient/hipreport.sh
%{_libexecdir}/gpclient/gp-vpnc-script-installer
%{_datadir}/applications/gpgui.desktop %{_datadir}/applications/gpgui.desktop
%{_datadir}/applications/gpauth.desktop %{_datadir}/applications/gpauth.desktop
%{_datadir}/icons/hicolor/32x32/apps/gpgui.png %{_datadir}/icons/hicolor/32x32/apps/gpgui.png