mirror of
https://github.com/yuezk/GlobalProtect-openconnect.git
synced 2026-11-19 06:26:14 -05:00
Main changes: - Refactor connect/auth flows around a single OS profile and host identity model, including gateway fallback and cookie-on-stdin handling. - Align request parameters, HIP host-id propagation, SAML webview user-agent behavior, and portal default-browser handling with observed official client behavior. - Add opt-in cookie cache support and Microsoft Defender HIP reporting while keeping host-id validation explicit. - Add BSD build, packaging, release artifact, and provenance support with FreeBSD/OpenBSD path and dependency cleanup. - Update NixOS install documentation and dependency compatibility fixes.
69 lines
2.0 KiB
Rust
69 lines
2.0 KiB
Rust
use std::{io, path::Path};
|
|
|
|
use is_executable::IsExecutable;
|
|
|
|
const VPNC_SCRIPT_LOCATIONS: &[&str] = &[
|
|
"/usr/local/libexec/gpclient/vpnc-script",
|
|
"/usr/libexec/gpclient/vpnc-script",
|
|
"/usr/lib/gpclient/vpnc-script",
|
|
"/usr/local/share/vpnc-scripts/vpnc-script",
|
|
"/usr/local/sbin/vpnc-script",
|
|
"/usr/share/vpnc-scripts/vpnc-script",
|
|
"/usr/sbin/vpnc-script",
|
|
"/etc/vpnc/vpnc-script",
|
|
"/etc/openconnect/vpnc-script",
|
|
"/usr/libexec/vpnc-scripts/vpnc-script",
|
|
#[cfg(all(target_os = "macos", target_arch = "aarch64"))]
|
|
"/opt/homebrew/etc/vpnc/vpnc-script",
|
|
#[cfg(all(target_os = "macos", target_arch = "x86_64"))]
|
|
"/usr/local/etc/vpnc/vpnc-script",
|
|
];
|
|
|
|
const CSD_WRAPPER_LOCATIONS: &[&str] = &[
|
|
"/usr/local/libexec/gpclient/hipreport.sh",
|
|
"/usr/libexec/gpclient/hipreport.sh",
|
|
#[cfg(target_arch = "x86_64")]
|
|
"/usr/lib/x86_64-linux-gnu/openconnect/hipreport.sh",
|
|
#[cfg(target_arch = "aarch64")]
|
|
"/usr/lib/aarch64-linux-gnu/openconnect/hipreport.sh",
|
|
"/usr/lib/openconnect/hipreport.sh",
|
|
"/usr/libexec/openconnect/hipreport.sh",
|
|
#[cfg(all(target_os = "macos", target_arch = "aarch64"))]
|
|
"/opt/homebrew/opt/openconnect/libexec/openconnect/hipreport.sh",
|
|
#[cfg(all(target_os = "macos", target_arch = "x86_64"))]
|
|
"/usr/local/opt/openconnect/libexec/openconnect/hipreport.sh",
|
|
];
|
|
|
|
fn find_executable(locations: &[&'static str]) -> Option<&'static str> {
|
|
for location in locations.iter() {
|
|
let path = Path::new(location);
|
|
if path.is_executable() {
|
|
return Some(*location);
|
|
}
|
|
}
|
|
|
|
None
|
|
}
|
|
|
|
pub fn find_vpnc_script() -> Option<&'static str> {
|
|
find_executable(VPNC_SCRIPT_LOCATIONS)
|
|
}
|
|
|
|
pub fn find_csd_wrapper() -> Option<&'static str> {
|
|
find_executable(CSD_WRAPPER_LOCATIONS)
|
|
}
|
|
|
|
/// If file exists, check if it is executable
|
|
pub fn check_executable(file: &str) -> Result<(), io::Error> {
|
|
let path = Path::new(file);
|
|
|
|
if path.exists() && !path.is_executable() {
|
|
return Err(io::Error::new(
|
|
io::ErrorKind::PermissionDenied,
|
|
format!("{} is not executable", file),
|
|
));
|
|
}
|
|
|
|
Ok(())
|
|
}
|