Compare commits

..
Author SHA1 Message Date
Kevin Yue 861997395e nlb improvment 2026-06-27 13:13:00 +08:00
Kevin Yue ea0270780a fix: improve nlb handling 2026-06-26 21:23:42 +08:00
Kevin Yue 0283f0147c fix: esp gcm algo [codex] 2026-06-26 16:06:27 +08:00
Kevin Yue d637542ddd fix: esp gcm algo 2026-06-26 09:26:44 +08:00
Kevin Yue b5ea3c9c22 Bump openconnect: fix ESP-GCM nonce for GlobalProtect gateways
Use IV||seq GCM nonce matching official PanGPS instead of RFC4106
salt||IV, which caused ESP probes to be silently dropped on
aes-256-gcm gateways.
2026-06-26 08:46:07 +08:00
Kevin Yue bdaea1b247 Bump openconnect submodule for ESP-GCM wire header fix
Updates to a669448a: GCM packets now use the RFC4106 8-byte IV on the
wire instead of the 16-byte CBC layout, which was preventing probe
replies and ESP session establishment on GCM gateways.
2026-06-26 07:30:09 +08:00
Kevin Yue 5274fd6282 Bump openconnect submodule for RFC4106 GCM ESP fix
Updates the fork to ae767195, which builds the GCM nonce as salt||IV
per RFC4106 and uses only the cipher key bytes for AES-GCM init. This
fixes ESP session establishment on existing gateways that negotiate
aes-256-gcm after the NLB branch started advertising GCM in getconfig.
2026-06-25 23:50:16 +08:00
Kevin Yue 2b916ef9a0 Migrate OpenConnect patches into GitHub submodule fork
Point openconnect at yuezk/openconnect globalprotect (d5c1925f) with GP
patches 0001-0019 baked in. Point libxml2 at github.com/GNOME/libxml2
keeping the v2.9.9 pin. Remove compile-time patch application from
build.rs and delete deps/patches/.
2026-06-25 22:59:33 +08:00
Kevin Yue 2e0320de5a Fix malformed NLB patch 0012 for CI patch application
Regenerate patch 0012 as a proper git diff against the post-0011 tree.
The previous version used zeroed index headers and a truncated
fake-gp-server.py context line, causing patch(1) to fail in LIBXML2_STATIC
builds.
2026-06-25 22:34:53 +08:00
Kevin Yue 6c31d2fbe7 Fix NLB prepare opaque-key wipe after tunnel-opaque decrypt
gp_nlb_clear_decrypted_opaque zeroed opaque_key after enc-hs-key
decipherment, causing gpst_nlb_prepare to fail when both blobs were
present. Clear opaque_key only at prepare start and replace unused
decrypted_opaque storage with an opaque_body_ready flag.
2026-06-25 21:02:45 +08:00
Kevin Yue 73d900f9b3 Cleanup NLB dead auth fields and tighten error handling
Remove unused hdr_auth/opaque_auth_ready state left after hs-key-only
envelope auth, trigger ESP/SSL reconnect on opaque refresh failure,
and log outbound NLB encap failures at ERR level.
2026-06-25 20:57:49 +08:00
Kevin Yue c93c9ec67f Harden NLB crypto and envelope authentication
Fail prepare when opaque decrypt or hs-key setup is incomplete, require
hs-key for all envelope sign/verify, reject TLS 1.3 for blob decrypt,
fix GnuTLS AES-192 CBC selection, and replace the opaque-auth test with
real HMAC-SHA1 vector checks.
2026-06-25 20:53:55 +08:00
Kevin Yue ebd5e69260 Add NLB troubleshooting logs for gateway testing
Log opaque crypto readiness, envelope sign/verify details with hex
dumps, and richer invalid-packet diagnostics to help debug NLB ESP
envelope auth against live gateways.
2026-06-25 20:43:36 +08:00
Kevin Yue 085d812db5 Wire NLB tunnel-opaque auth into ESP envelope (Phase 6)
Extract 6-byte auth material from decrypted tunnel-opaque, populate
wire sequence and HMAC-SHA1 header tags using hs-key, and verify on
inbound NLB ESP envelopes.
2026-06-25 20:34:15 +08:00
Kevin Yue fe26d2f338 Implement exact PanGPS do_ssl_decrypt NLB blob decipherment
Reverse-engineer PanGPS 6.3.3.1 decrypt_data: derive TLS 1.2 server
write key/IV via key expansion, AES-CBC decrypt ciphertext after the
28-byte cleartext blob prefix, and decrypt tunnel-opaque with the
decrypted enc-hs-key using the same TLS IV.
2026-06-25 19:41:05 +08:00
Kevin Yue 2fa8912d9e Add ESP GCM and NLB enc-hs-key handling (Phase 7)
Implement RFC4106 AES-GCM ESP for GlobalProtect gateways (gnutls and
OpenSSL backends), recognize aes128gcm8/12/16 ICV sizes, and add NLB
enc-hs-key blob parsing with TLS 1.2 session-key decipherment to
decrypt tunnel-opaque payloads.
2026-06-25 19:19:44 +08:00
Kevin Yue a5027d4ff5 Add GlobalProtect NLB integration (Phase 6)
Expose NLB session metadata through the Rust FFI, extend fake-gp-server
with NLB mode for integration testing, wire NLB unit tests into
Makefile.am, recognize AES-GCM algorithm strings in check_enc_algo,
and add gp-nlb-auth-and-config to verify getconfig parsing.
2026-06-25 18:51:42 +08:00
Kevin Yue 5fcef8c5ba Add GlobalProtect NLB lifecycle (Phase 5)
Refresh tunnel-opaque via targeted getconfig.esp when valid-period nears
expiry, without disturbing ESP keys or routes. Send periodic NLB ESP
keepalives on established sessions and reset keepalive state after refresh.
2026-06-25 18:41:22 +08:00
Kevin Yue 81ccdc6358 Add GlobalProtect NLB SSL failover (Phase 4)
Extend gpst_connect for NLB gateways: send install=yes with preferred IPs,
parse the 110...START_TUNNEL line protocol response, update tunnel VIP,
and install a split-include route for the inner gateway IP.
2026-06-25 18:36:39 +08:00
Kevin Yue e05b8fb358 Add GlobalProtect NLB ESP envelope (Phase 3)
Implement the 16-byte NLB UDP wrapper around ESP ciphertext per PanGPS
6.3.3.1 RE: encap/decap in gpst_nlb.c, recv/send hooks in esp.c for
PROTO_GPST, 56-byte NLB probe payloads, and keepalive-before-data on the
first ESP probe exchange.
2026-06-25 18:32:14 +08:00
Kevin Yue 8343d743e0 Add GlobalProtect NLB module skeleton (Phase 2)
Introduce gpst_nlb.c with PanGPS 6.3.3.1 RE notes, base64 opaque blob
decoding, NLB SSL response parsing, and stub ESP encap/decap hooks.
Wire gpst_nlb_prepare into setup and add an SSL parse regression test.
2026-06-25 18:24:11 +08:00
Kevin Yue 79110bbcd8 Add GlobalProtect NLB config parsing (Phase 1)
Parse hs-key, enc-hs-key, tunnel-opaque, and related NLB fields from
getconfig.esp XML into vpninfo, align getconfig request parameters with
the official client, and expose diagnostic APIs for NLB detection.
2026-06-25 18:20:06 +08:00
Kevin Yue 494e4a5331 fix: replace passwd with OTP on gateway MFA retry
Gateway login OTP retries were appending a second passwd form field
instead of replacing the credential password. That regressed in 2.6.0
when login params moved from a HashMap to a Vec and could cause MFA
submissions to fail with HTTP 512 (fix #626).

Bump version to 2.6.4.
2026-06-25 14:41:42 +08:00
Kevin Yue b5b71df6e6 doc: update OpenBSD/FreeBSD instructions 2026-06-24 12:53:05 +08:00
Kevin Yue 49f410e63b Merge branch 'fix/nixos-desktop-launch-path' 2026-06-24 12:52:20 +08:00
Kevin Yue 225acf13aa fix: use stable NixOS desktop launcher path 2026-06-24 09:26:07 +08:00
Kevin Yueandgithub-actions[bot] 61d2b702c0 chore: update flake hashes for v2.6.3 (#631)
Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com>
2026-06-23 23:12:52 +08:00
github-actions[bot] 3276ac0f9a chore: update flake hashes for v2.6.3 (#630) [no ci] 2026-06-23 21:57:51 +08:00
Kevin Yue 0b037e158c chore: prepare 2.6.3 release
- Fix NixOS GUI authorization after package updates.

- Treat Ctrl+C initiated OpenConnect disconnect as a successful shutdown.

- Update snapshot flake hash automation for prebuilt Nix packages.

- Bump gp workspace version and changelog to 2.6.3.
2026-06-23 20:06:04 +08:00
Kevin Yue 10e94e0b81 fix: use minimal Rust PPA build deps 2026-06-22 23:46:06 +08:00
github-actions[bot] 0f76539075 chore: update flake hashes for v2.6.2 (#628)
Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com>
2026-06-22 23:08:15 +08:00
Kevin Yue f9b8c55924 Merge branch 'release/2.6.2' 2026-06-22 22:50:48 +08:00
github-actions[bot] b3f4ba0a32 chore: update flake hashes for v2.6.1 (#625) 2026-06-22 14:33:21 +08:00
28 changed files with 402 additions and 623 deletions

No files matched your search

+8 -3
View File
@@ -6,6 +6,9 @@ on:
version: version:
description: "Release version. Defaults to Cargo.toml workspace version." description: "Release version. Defaults to Cargo.toml workspace version."
required: false required: false
release_tag:
description: "GitHub release tag to fetch assets from. Defaults to v<version>; use snapshot for snapshot assets."
required: false
permissions: permissions:
contents: write contents: write
@@ -24,11 +27,12 @@ jobs:
- name: Update flake hashes - name: Update flake hashes
env: env:
RELEASE_VERSION: ${{ inputs.version }} RELEASE_VERSION: ${{ inputs.version }}
RELEASE_TAG: ${{ inputs.release_tag }}
run: | run: |
if [[ -n "$RELEASE_VERSION" ]]; then if [[ -n "$RELEASE_VERSION" ]]; then
scripts/update-flake-hashes.sh "$RELEASE_VERSION" scripts/update-flake-hashes.sh "$RELEASE_VERSION" "$RELEASE_TAG"
else else
scripts/update-flake-hashes.sh scripts/update-flake-hashes.sh "" "$RELEASE_TAG"
fi fi
- name: Upload updated flake - name: Upload updated flake
@@ -112,4 +116,5 @@ jobs:
env: env:
GH_TOKEN: ${{ github.token }} GH_TOKEN: ${{ github.token }}
RELEASE_VERSION: ${{ inputs.version }} RELEASE_VERSION: ${{ inputs.version }}
run: scripts/open-flake-hashes-pr.sh "$RELEASE_VERSION" RELEASE_TAG: ${{ inputs.release_tag }}
run: scripts/open-flake-hashes-pr.sh "$RELEASE_VERSION" "$RELEASE_TAG"
+3 -2
View File
@@ -1,6 +1,7 @@
[submodule "crates/openconnect/deps/openconnect"] [submodule "crates/openconnect/deps/openconnect"]
path = crates/openconnect/deps/openconnect path = crates/openconnect/deps/openconnect
url = https://gitlab.com/openconnect/openconnect.git url = https://github.com/yuezk/openconnect.git
branch = globalprotect
[submodule "crates/openconnect/deps/libxml2"] [submodule "crates/openconnect/deps/libxml2"]
path = crates/openconnect/deps/libxml2 path = crates/openconnect/deps/libxml2
url = https://gitlab.gnome.org/GNOME/libxml2.git url = https://github.com/GNOME/libxml2.git
Generated
+8 -8
View File
@@ -214,7 +214,7 @@ checksum = "1505bd5d3d116872e7271a6d4e16d81d0c8570876c8de68093a09ac269d8aac0"
[[package]] [[package]]
name = "auth" name = "auth"
version = "2.6.2" version = "2.6.4"
dependencies = [ dependencies = [
"anyhow", "anyhow",
"block2", "block2",
@@ -705,7 +705,7 @@ dependencies = [
[[package]] [[package]]
name = "common" name = "common"
version = "2.6.2" version = "2.6.4"
[[package]] [[package]]
name = "compile-time" name = "compile-time"
@@ -1732,7 +1732,7 @@ dependencies = [
[[package]] [[package]]
name = "gpapi" name = "gpapi"
version = "2.6.2" version = "2.6.4"
dependencies = [ dependencies = [
"anyhow", "anyhow",
"base64 0.22.1", "base64 0.22.1",
@@ -1776,7 +1776,7 @@ dependencies = [
[[package]] [[package]]
name = "gpauth" name = "gpauth"
version = "2.6.2" version = "2.6.4"
dependencies = [ dependencies = [
"anyhow", "anyhow",
"auth", "auth",
@@ -1796,7 +1796,7 @@ dependencies = [
[[package]] [[package]]
name = "gpclient" name = "gpclient"
version = "2.6.2" version = "2.6.4"
dependencies = [ dependencies = [
"anyhow", "anyhow",
"askama", "askama",
@@ -1825,7 +1825,7 @@ dependencies = [
[[package]] [[package]]
name = "gpgui-helper" name = "gpgui-helper"
version = "2.6.2" version = "2.6.4"
dependencies = [ dependencies = [
"anyhow", "anyhow",
"clap", "clap",
@@ -1843,7 +1843,7 @@ dependencies = [
[[package]] [[package]]
name = "gpservice" name = "gpservice"
version = "2.6.2" version = "2.6.4"
dependencies = [ dependencies = [
"anyhow", "anyhow",
"axum", "axum",
@@ -3191,7 +3191,7 @@ dependencies = [
[[package]] [[package]]
name = "openconnect" name = "openconnect"
version = "2.6.2" version = "2.6.4"
dependencies = [ dependencies = [
"autotools", "autotools",
"cc", "cc",
+1 -1
View File
@@ -11,7 +11,7 @@ members = [
[workspace.package] [workspace.package]
rust-version = "1.89" rust-version = "1.89"
version = "2.6.2" version = "2.6.4"
authors = ["Kevin Yue <[email protected]>"] authors = ["Kevin Yue <[email protected]>"]
homepage = "https://github.com/yuezk/GlobalProtect-openconnect" homepage = "https://github.com/yuezk/GlobalProtect-openconnect"
edition = "2024" edition = "2024"
+21 -1
View File
@@ -72,7 +72,7 @@ For browser-based authentication with the CLI:
**Method 1:** Using sudo with environment preservation: **Method 1:** Using sudo with environment preservation:
```bash ```bash
sudo -E gpclient connect --browser <portal> sudo gpclient connect --browser <portal>
``` ```
**Method 2:** Using authentication piping: **Method 2:** Using authentication piping:
@@ -200,6 +200,26 @@ sudo apk add --allow-untrusted globalprotect-openconnect-*.apk
The package uses Alpine's native musl build. Make sure the `community` repository is enabled so GUI dependencies such as `webkit2gtk-4.1`, `libsecret`, and `libayatana-appindicator` can be resolved. GUI-launched connections use polkit, and VPN tunnel creation requires `/dev/net/tun`. The package uses Alpine's native musl build. Make sure the `community` repository is enabled so GUI dependencies such as `webkit2gtk-4.1`, `libsecret`, and `libayatana-appindicator` can be resolved. GUI-launched connections use polkit, and VPN tunnel creation requires `/dev/net/tun`.
### FreeBSD
Download the latest FreeBSD package from the [releases](https://github.com/yuezk/GlobalProtect-openconnect/releases) page, then install:
```bash
sudo pkg install ./globalprotect-openconnect-*-freebsd-*.pkg
```
To build from source, see [Building from Source on FreeBSD and OpenBSD](./docs/bsd-source-build.md).
### OpenBSD
Download the latest OpenBSD package from the [releases](https://github.com/yuezk/GlobalProtect-openconnect/releases) page, then install:
```bash
doas pkg_add -D unsigned ./globalprotect-openconnect-*-openbsd-*.tgz
```
To build from source, see [Building from Source on FreeBSD and OpenBSD](./docs/bsd-source-build.md).
### Gentoo ### Gentoo
Available via the `guru` and `lamdness` overlays: Available via the `guru` and `lamdness` overlays:
+33 -6
View File
@@ -28,6 +28,8 @@ use crate::{
use super::{ConnectHandler, args::cookie_cache_path}; use super::{ConnectHandler, args::cookie_cache_path};
const OPENCONNECT_INTERRUPTED_EXIT_CODE: i32 = -4;
struct GatewayLoginSession { struct GatewayLoginSession {
cookie: String, cookie: String,
extension_auth: SessionExtensionAuth, extension_auth: SessionExtensionAuth,
@@ -372,10 +374,13 @@ impl ConnectHandler<'_> {
let session_ctx_on_connect = Arc::clone(&session_ctx); let session_ctx_on_connect = Arc::clone(&session_ctx);
let tunnel_established = Arc::new(AtomicBool::new(false)); let tunnel_established = Arc::new(AtomicBool::new(false));
let tunnel_established_on_connect = Arc::clone(&tunnel_established); let tunnel_established_on_connect = Arc::clone(&tunnel_established);
let disconnect_requested = Arc::new(AtomicBool::new(false));
let disconnect_requested_on_signal = Arc::clone(&disconnect_requested);
tokio::spawn(async move { tokio::spawn(async move {
shutdown_signal().await; shutdown_signal().await;
info!("Received the interrupt signal, disconnecting..."); info!("Received the interrupt signal, disconnecting...");
disconnect_requested_on_signal.store(true, Ordering::SeqCst);
vpn_clone.disconnect(); vpn_clone.disconnect();
}); });
@@ -403,7 +408,8 @@ impl ConnectHandler<'_> {
fs::remove_file(GP_CLIENT_LOCK_FILE).map_err(|err| GatewayConnectError::after_tunnel(err.into()))?; fs::remove_file(GP_CLIENT_LOCK_FILE).map_err(|err| GatewayConnectError::after_tunnel(err.into()))?;
} }
classify_openconnect_result(connect_result, tunnel_established) let disconnect_requested = disconnect_requested.load(Ordering::SeqCst);
classify_openconnect_result(connect_result, tunnel_established, disconnect_requested)
} }
fn determine_hip_script(&self) -> (bool, Option<String>) { fn determine_hip_script(&self) -> (bool, Option<String>) {
@@ -427,11 +433,19 @@ impl ConnectHandler<'_> {
} }
} }
fn classify_openconnect_result(exit_code: i32, tunnel_established: bool) -> Result<(), GatewayConnectError> { fn classify_openconnect_result(
exit_code: i32,
tunnel_established: bool,
disconnect_requested: bool,
) -> Result<(), GatewayConnectError> {
if exit_code == 0 { if exit_code == 0 {
return Ok(()); return Ok(());
} }
if disconnect_requested && exit_code == OPENCONNECT_INTERRUPTED_EXIT_CODE {
return Ok(());
}
let error = anyhow::anyhow!("OpenConnect exited with status {}", exit_code); let error = anyhow::anyhow!("OpenConnect exited with status {}", exit_code);
if tunnel_established { if tunnel_established {
Err(GatewayConnectError::after_tunnel(error)) Err(GatewayConnectError::after_tunnel(error))
@@ -477,20 +491,33 @@ mod tests {
#[test] #[test]
fn openconnect_success_is_not_a_gateway_failure() { fn openconnect_success_is_not_a_gateway_failure() {
assert!(classify_openconnect_result(0, false).is_ok()); assert!(classify_openconnect_result(0, false, false).is_ok());
assert!(classify_openconnect_result(0, true).is_ok()); assert!(classify_openconnect_result(0, true, false).is_ok());
} }
#[test] #[test]
fn openconnect_failure_before_callback_is_retryable_gateway_failure() { fn openconnect_failure_before_callback_is_retryable_gateway_failure() {
let err = classify_openconnect_result(1, false).expect_err("nonzero exit should fail"); let err = classify_openconnect_result(1, false, false).expect_err("nonzero exit should fail");
assert!(err.is_before_tunnel()); assert!(err.is_before_tunnel());
} }
#[test] #[test]
fn openconnect_failure_after_callback_is_terminal_gateway_failure() { fn openconnect_failure_after_callback_is_terminal_gateway_failure() {
let err = classify_openconnect_result(1, true).expect_err("nonzero exit should fail"); let err = classify_openconnect_result(1, true, false).expect_err("nonzero exit should fail");
assert!(!err.is_before_tunnel());
}
#[test]
fn interrupted_exit_after_requested_disconnect_is_success() {
assert!(classify_openconnect_result(OPENCONNECT_INTERRUPTED_EXIT_CODE, true, true).is_ok());
}
#[test]
fn interrupted_exit_without_requested_disconnect_is_failure() {
let err = classify_openconnect_result(OPENCONNECT_INTERRUPTED_EXIT_CODE, true, false)
.expect_err("unexpected interrupt should fail");
assert!(!err.is_before_tunnel()); assert!(!err.is_before_tunnel());
} }
+2
View File
@@ -213,6 +213,7 @@ mod tests {
prior_secs: 1_800, prior_secs: 1_800,
message: "Session expires soon".to_string(), message: "Session expires soon".to_string(),
}), }),
..Default::default()
}, },
true, true,
); );
@@ -233,6 +234,7 @@ mod tests {
prior_secs: 1_800, prior_secs: 1_800,
message: "Session expires soon".to_string(), message: "Session expires soon".to_string(),
}), }),
..Default::default()
}, },
false, false,
); );
+14
View File
@@ -1,5 +1,19 @@
# Changelog # Changelog
## 2.6.4
### Fixed
- Fixed gateway login MFA OTP retries sending duplicate `passwd` form fields, which could cause authentication to fail with HTTP 512 after 2.6.0 (fix [#626](https://github.com/yuezk/GlobalProtect-openconnect/issues/626)).
## 2.6.3
### Fixed
- Fixed NixOS GUI launch authorization after package updates.
- Fixed disconnect handling so a normal Ctrl+C logout no longer reports an error.
- Fixed snapshot flake hash update automation for prebuilt Nix packages.
## 2.6.2 ## 2.6.2
### Fixed ### Fixed
+44 -1
View File
@@ -39,7 +39,7 @@ pub(crate) fn build(input: &GatewayLoginInput) -> RequestParams {
input.gp_params.input_str().unwrap_or_default().into(), input.gp_params.input_str().unwrap_or_default().into(),
)); ));
if let Some(otp) = input.gp_params.otp() { if let Some(otp) = input.gp_params.otp() {
body.push(("passwd".into(), otp.into())); set_body_param(&mut body, "passwd", otp);
} }
if let Some(os_version) = input.gp_params.os_version() { if let Some(os_version) = input.gp_params.os_version() {
body.push(("os-version".into(), os_version.into())); body.push(("os-version".into(), os_version.into()));
@@ -99,6 +99,15 @@ pub(crate) fn build(input: &GatewayLoginInput) -> RequestParams {
RequestParams { body, query: vec![] } RequestParams { body, query: vec![] }
} }
fn set_body_param(body: &mut Vec<(String, String)>, key: &str, value: impl Into<String>) {
let value = value.into();
if let Some(pos) = body.iter().position(|(k, _)| k == key) {
body[pos].1 = value;
} else {
body.push((key.to_string(), value));
}
}
/// Resolve the gateway server to an IPv4 address if the profile requires it. /// Resolve the gateway server to an IPv4 address if the profile requires it.
/// ///
/// Falls back to the original gateway host if resolution fails. /// Falls back to the original gateway host if resolution fails.
@@ -153,6 +162,40 @@ mod tests {
Credential::Password(PasswordCredential::new("alice", "secret")) Credential::Password(PasswordCredential::new("alice", "secret"))
} }
fn passwd_values(body: &[(String, String)]) -> Vec<&str> {
body
.iter()
.filter(|(k, _)| k == "passwd")
.map(|(_, v)| v.as_str())
.collect()
}
#[test]
fn otp_retry_replaces_passwd_instead_of_appending_duplicate() {
let mut gp_params = make_gp_params();
gp_params.set_input_str("challenge-token");
gp_params.set_otp("123456");
let cred = make_credential();
let input = GatewayLoginInput {
gp_params: &gp_params,
cred: &cred,
gateway_host: "vpn.example.com",
context: None,
client_ip: None,
extend_lifetime: false,
};
let result = build(&input);
assert_eq!(passwd_values(&result.body), vec!["123456"]);
let encoded = serde_urlencoded::to_string(&result.body).expect("form body should encode");
assert_eq!(encoded.matches("passwd=").count(), 1);
assert!(encoded.contains("passwd=123456"));
assert!(!encoded.contains("passwd=secret"));
}
#[test] #[test]
fn build_without_context_includes_identity_fields() { fn build_without_context_includes_identity_fields() {
let profile = test_profile(ClientOs::Linux); let profile = test_profile(ClientOs::Linux);
+3 -37
View File
@@ -1,34 +1,4 @@
use std::{env, path::PathBuf, process::Command}; use std::{env, path::PathBuf};
fn apply_patches(patches_dir: &PathBuf, build_src: &PathBuf) {
let patches = std::fs::read_dir(patches_dir)
.expect("Failed to read patches directory")
.filter_map(|entry| entry.ok())
.filter(|entry| entry.path().extension().and_then(|s| s.to_str()) == Some("patch"))
.map(|entry| entry.path())
.collect::<Vec<_>>();
// Sort patches to ensure they are applied in order
let mut patches = patches;
patches.sort();
for patch in patches {
println!("cargo:rerun-if-changed={}", patch.display());
println!("Applying patch: {}", patch.display());
let status = Command::new("patch")
.arg("-p1") // Strip one level of path (standard for git diffs)
.arg("-i") // Input file
.arg(&patch)
.current_dir(build_src) // Run INSIDE the copied dir
.status()
.expect("Failed to execute patch command");
if !status.success() {
panic!("Failed to apply patch file: {}", patch.display());
}
}
}
fn build_libxml2(deps_dir: &PathBuf, out_dir: &PathBuf) -> PathBuf { fn build_libxml2(deps_dir: &PathBuf, out_dir: &PathBuf) -> PathBuf {
let libxml2_dir = deps_dir.join("libxml2"); let libxml2_dir = deps_dir.join("libxml2");
@@ -91,12 +61,11 @@ fn build_libxml2(deps_dir: &PathBuf, out_dir: &PathBuf) -> PathBuf {
fn build_openconnect(deps_dir: &PathBuf, out_dir: &PathBuf) -> PathBuf { fn build_openconnect(deps_dir: &PathBuf, out_dir: &PathBuf) -> PathBuf {
let openconnect_dir = deps_dir.join("openconnect"); let openconnect_dir = deps_dir.join("openconnect");
let patches_dir = deps_dir.join("patches");
// The temporary location where we will build // The temporary location where we will build
let build_src = out_dir.join("openconnect_build"); let build_src = out_dir.join("openconnect_build");
// Track changes so cargo rebuilds if patch or submodule changes // Track changes so cargo rebuilds if submodule changes
println!("cargo:rerun-if-changed={}", openconnect_dir.display()); println!("cargo:rerun-if-changed={}", openconnect_dir.display());
// Prepare the build directory // Prepare the build directory
@@ -114,9 +83,6 @@ fn build_openconnect(deps_dir: &PathBuf, out_dir: &PathBuf) -> PathBuf {
fs_extra::dir::copy(&openconnect_dir, &build_src, &options).expect("Failed to copy C source code to OUT_DIR"); fs_extra::dir::copy(&openconnect_dir, &build_src, &options).expect("Failed to copy C source code to OUT_DIR");
// Apply all patches from the patches directory
apply_patches(&patches_dir, &build_src);
// Build the OpenConnect library using autotools // Build the OpenConnect library using autotools
// We explicitly enable static and disable shared to ensure we get a .a file. // We explicitly enable static and disable shared to ensure we get a .a file.
// .reconf("-ivf") is CRITICAL for git submodules because 'configure' // .reconf("-ivf") is CRITICAL for git submodules because 'configure'
@@ -215,4 +181,4 @@ fn main() {
.include("src/ffi") .include("src/ffi")
.include(&oc_dst.join("include")) .include(&oc_dst.join("include"))
.compile("vpn"); .compile("vpn");
} }
@@ -1,114 +0,0 @@
From a8d5ec198ca9ae47a0e6b4f1ea244d2738acf055 Mon Sep 17 00:00:00 2001
From: Kevin Yue <[email protected]>
Date: Sun, 14 Dec 2025 17:10:02 +0800
Subject: [PATCH 1/4] Add support for GlobalProtect app version handling
- Introduced `gp_app_version` field in `openconnect_info` structure.
- Implemented `openconnect_set_gp_app_version` and `openconnect_get_gp_app_version` functions.
- Updated `gpst_get_config` to use the app version in requests.
- Free `gp_app_version` in `openconnect_vpninfo_free` to prevent memory leaks.
---
gpst.c | 8 +++++---
library.c | 15 +++++++++++++++
openconnect-internal.h | 4 ++++
openconnect.h | 2 ++
4 files changed, 26 insertions(+), 3 deletions(-)
diff --git a/gpst.c b/gpst.c
index 244aaf04..5c24bbd2 100644
--- a/gpst.c
+++ b/gpst.c
@@ -650,8 +650,11 @@ static int gpst_get_config(struct openconnect_info *vpninfo)
/* submit getconfig request */
+ const char *app_version = openconnect_get_gp_app_version(vpninfo);
+ vpn_progress(vpninfo, PRG_DEBUG, _("Using GlobalProtect app version: %s\n"), app_version);
+
buf_append(request_body, "client-type=1&protocol-version=p1&internal=no");
- append_opt(request_body, "app-version", vpninfo->csd_ticket ? : "6.3.0-33");
+ append_opt(request_body, "app-version", app_version);
append_opt(request_body, "ipv6-support", vpninfo->disable_ipv6 ? "no" : "yes");
append_opt(request_body, "clientos", gpst_os_name(vpninfo));
append_opt(request_body, "os-version", vpninfo->platname);
@@ -1040,8 +1043,7 @@ static int run_hip_script(struct openconnect_info *vpninfo)
* accept new ones.
*/
unsetenv("APP_VERSION");
- if (vpninfo->csd_ticket)
- if (setenv("APP_VERSION", vpninfo->csd_ticket, 1))
+ if (setenv("APP_VERSION", openconnect_get_gp_app_version(vpninfo), 1))
goto out;
execv(hip_argv[0], (char **)hip_argv);
diff --git a/library.c b/library.c
index b5e74e9b..18334c76 100644
--- a/library.c
+++ b/library.c
@@ -896,6 +896,7 @@ void openconnect_vpninfo_free(struct openconnect_info *vpninfo)
free(vpninfo->localname);
free(vpninfo->useragent);
+ free(vpninfo->gp_app_version);
free(vpninfo->authgroup);
#ifdef HAVE_LIBSTOKEN
if (vpninfo->stoken_pin)
@@ -1019,6 +1020,20 @@ int openconnect_set_useragent(struct openconnect_info *vpninfo,
return 0;
}
+int openconnect_set_gp_app_version(struct openconnect_info *vpninfo,
+ const char *gp_app_version)
+{
+ UTF8CHECK(gp_app_version);
+
+ STRDUP(vpninfo->gp_app_version, gp_app_version);
+ return 0;
+}
+
+const char *openconnect_get_gp_app_version(struct openconnect_info *vpninfo)
+{
+ return vpninfo->csd_ticket ?: (vpninfo->gp_app_version ?: "6.3.0-33");
+}
+
int openconnect_set_urlpath(struct openconnect_info *vpninfo,
const char *urlpath)
{
diff --git a/openconnect-internal.h b/openconnect-internal.h
index abf45bbd..988f85f0 100644
--- a/openconnect-internal.h
+++ b/openconnect-internal.h
@@ -786,6 +786,7 @@ struct openconnect_info {
int is_dyndns; /* Attempt to redo DNS lookup on each CSTP reconnect */
char *useragent;
char *version_string;
+ char *gp_app_version;
const char *quit_reason;
const char *delay_tunnel_reason; /* If non-null, provides a reason why protocol is not yet ready for tunnel setup */
@@ -1677,6 +1678,9 @@ void openconnect_set_juniper(struct openconnect_info *vpninfo);
/* hpke.c */
int handle_external_browser(struct openconnect_info *vpninfo);
+/* Get the app version */
+const char *openconnect_get_gp_app_version(struct openconnect_info *vpninfo);
+
/* version.c */
extern const char openconnect_version_str[];
diff --git a/openconnect.h b/openconnect.h
index 136f181a..7d4f3399 100644
--- a/openconnect.h
+++ b/openconnect.h
@@ -470,6 +470,8 @@ int openconnect_set_http_proxy(struct openconnect_info *vpninfo,
int openconnect_set_useragent(struct openconnect_info *vpninfo,
const char *useragent);
+int openconnect_set_gp_app_version(struct openconnect_info *vpninfo,
+ const char *gp_app_version);
int openconnect_passphrase_from_fsid(struct openconnect_info *vpninfo);
int openconnect_obtain_cookie(struct openconnect_info *vpninfo);
int openconnect_init_ssl(void);
--
2.50.1 (Apple Git-155)
@@ -1,32 +0,0 @@
From 8591eba702f52dae335601c997271786be50dff7 Mon Sep 17 00:00:00 2001
From: Kevin Yue <[email protected]>
Date: Sun, 14 Dec 2025 17:10:52 +0800
Subject: [PATCH 2/4] Update user agent for common headers in GlobalProtect
authentication
---
auth-globalprotect.c | 7 -------
1 file changed, 7 deletions(-)
diff --git a/auth-globalprotect.c b/auth-globalprotect.c
index 8d094273..27e41c2b 100644
--- a/auth-globalprotect.c
+++ b/auth-globalprotect.c
@@ -34,14 +34,7 @@ struct login_context {
void gpst_common_headers(struct openconnect_info *vpninfo,
struct oc_text_buf *buf)
{
- char *orig_ua = vpninfo->useragent;
-
- /* XX: more recent servers don't appear to require this specific UA value,
- * but we don't have any good way to detect them.
- */
- vpninfo->useragent = (char *)"PAN GlobalProtect";
http_common_headers(vpninfo, buf);
- vpninfo->useragent = orig_ua;
}
/* Translate platform names (derived from AnyConnect) into the values
--
2.50.1 (Apple Git-155)
@@ -1,121 +0,0 @@
From dda2aceca7e614af65b968e632065ef223cb6612 Mon Sep 17 00:00:00 2001
From: Kevin Yue <[email protected]>
Date: Sun, 14 Dec 2025 17:14:08 +0800
Subject: [PATCH 3/4] Add support for OS version handling in GlobalProtect
authentication
---
auth-globalprotect.c | 2 +-
gpst.c | 4 ++--
library.c | 15 +++++++++++++++
openconnect-internal.h | 4 ++++
openconnect.h | 3 +++
5 files changed, 25 insertions(+), 3 deletions(-)
diff --git a/auth-globalprotect.c b/auth-globalprotect.c
index 27e41c2b..59d6de3b 100644
--- a/auth-globalprotect.c
+++ b/auth-globalprotect.c
@@ -731,7 +731,7 @@ static int gpst_login(struct openconnect_info *vpninfo, int portal, struct login
buf_append(request_body, "jnlpReady=jnlpReady&ok=Login&direct=yes&clientVer=4100&prot=https:&internal=no");
append_opt(request_body, "ipv6-support", vpninfo->disable_ipv6 ? "no" : "yes");
append_opt(request_body, "clientos", gpst_os_name(vpninfo));
- append_opt(request_body, "os-version", vpninfo->platname);
+ append_opt(request_body, "os-version", openconnect_get_gp_os_version(vpninfo));
append_opt(request_body, "server", vpninfo->hostname);
append_opt(request_body, "computer", vpninfo->localname);
if (ctx->portal_userauthcookie)
diff --git a/gpst.c b/gpst.c
index 5c24bbd2..0373fce0 100644
--- a/gpst.c
+++ b/gpst.c
@@ -657,7 +657,7 @@ static int gpst_get_config(struct openconnect_info *vpninfo)
append_opt(request_body, "app-version", app_version);
append_opt(request_body, "ipv6-support", vpninfo->disable_ipv6 ? "no" : "yes");
append_opt(request_body, "clientos", gpst_os_name(vpninfo));
- append_opt(request_body, "os-version", vpninfo->platname);
+ append_opt(request_body, "os-version", openconnect_get_gp_os_version(vpninfo));
append_opt(request_body, "hmac-algo", "sha1,md5,sha256");
append_opt(request_body, "enc-algo", "aes-128-cbc,aes-256-cbc");
if (old_addr || old_addr6) {
@@ -1044,7 +1044,7 @@ static int run_hip_script(struct openconnect_info *vpninfo)
*/
unsetenv("APP_VERSION");
if (setenv("APP_VERSION", openconnect_get_gp_app_version(vpninfo), 1))
- goto out;
+ goto out;
execv(hip_argv[0], (char **)hip_argv);
diff --git a/library.c b/library.c
index 18334c76..e2169054 100644
--- a/library.c
+++ b/library.c
@@ -897,6 +897,7 @@ void openconnect_vpninfo_free(struct openconnect_info *vpninfo)
free(vpninfo->localname);
free(vpninfo->useragent);
free(vpninfo->gp_app_version);
+ free(vpninfo->gp_os_version);
free(vpninfo->authgroup);
#ifdef HAVE_LIBSTOKEN
if (vpninfo->stoken_pin)
@@ -1034,6 +1035,20 @@ const char *openconnect_get_gp_app_version(struct openconnect_info *vpninfo)
return vpninfo->csd_ticket ?: (vpninfo->gp_app_version ?: "6.3.0-33");
}
+int openconnect_set_gp_os_version(struct openconnect_info *vpninfo,
+ const char *gp_os_version)
+{
+ UTF8CHECK(gp_os_version);
+
+ STRDUP(vpninfo->gp_os_version, gp_os_version);
+ return 0;
+}
+
+const char *openconnect_get_gp_os_version(struct openconnect_info *vpninfo)
+{
+ return vpninfo->gp_os_version ?: vpninfo->platname;
+}
+
int openconnect_set_urlpath(struct openconnect_info *vpninfo,
const char *urlpath)
{
diff --git a/openconnect-internal.h b/openconnect-internal.h
index 988f85f0..5c8d2909 100644
--- a/openconnect-internal.h
+++ b/openconnect-internal.h
@@ -787,6 +787,7 @@ struct openconnect_info {
char *useragent;
char *version_string;
char *gp_app_version;
+ char *gp_os_version;
const char *quit_reason;
const char *delay_tunnel_reason; /* If non-null, provides a reason why protocol is not yet ready for tunnel setup */
@@ -1681,6 +1682,9 @@ int handle_external_browser(struct openconnect_info *vpninfo);
/* Get the app version */
const char *openconnect_get_gp_app_version(struct openconnect_info *vpninfo);
+/* Get the OS version string for GP */
+const char *openconnect_get_gp_os_version(struct openconnect_info *vpninfo);
+
/* version.c */
extern const char openconnect_version_str[];
diff --git a/openconnect.h b/openconnect.h
index 7d4f3399..aa96a53b 100644
--- a/openconnect.h
+++ b/openconnect.h
@@ -472,6 +472,9 @@ int openconnect_set_useragent(struct openconnect_info *vpninfo,
int openconnect_set_gp_app_version(struct openconnect_info *vpninfo,
const char *gp_app_version);
+int openconnect_set_gp_os_version(struct openconnect_info *vpninfo,
+ const char *gp_os_version);
+
int openconnect_passphrase_from_fsid(struct openconnect_info *vpninfo);
int openconnect_obtain_cookie(struct openconnect_info *vpninfo);
int openconnect_init_ssl(void);
--
2.50.1 (Apple Git-155)
@@ -1,39 +0,0 @@
From 3915a51c81831a1a9b087d82f0c760365682f23b Mon Sep 17 00:00:00 2001
From: Kevin Yue <[email protected]>
Date: Mon, 15 Dec 2025 19:20:44 +0800
Subject: [PATCH 4/4] Add client version and OS information to HIP script
arguments
---
gpst.c | 8 ++++++--
1 file changed, 6 insertions(+), 2 deletions(-)
diff --git a/gpst.c b/gpst.c
index 0373fce0..d04c42c2 100644
--- a/gpst.c
+++ b/gpst.c
@@ -1013,6 +1013,12 @@ static int run_hip_script(struct openconnect_info *vpninfo)
exit(1);
hip_argv[i++] = openconnect_utf8_to_legacy(vpninfo, vpninfo->csd_wrapper);
+ hip_argv[i++] = "--client-version";
+ hip_argv[i++] = openconnect_get_gp_app_version(vpninfo);
+ hip_argv[i++] = "--client-os";
+ hip_argv[i++] = gpst_os_name(vpninfo);
+ hip_argv[i++] = "--os-version";
+ hip_argv[i++] = openconnect_get_gp_os_version(vpninfo);
hip_argv[i++] = "--cookie";
hip_argv[i++] = vpninfo->cookie;
if (vpninfo->ip_info.addr) {
@@ -1025,8 +1031,6 @@ static int run_hip_script(struct openconnect_info *vpninfo)
}
hip_argv[i++] = "--md5";
hip_argv[i++] = vpninfo->csd_token;
- hip_argv[i++] = "--client-os";
- hip_argv[i++] = gpst_os_name(vpninfo);
hip_argv[i++] = NULL;
/* XX: Sending the above parameters as --long-options was a mistake that was
--
2.50.1 (Apple Git-155)
@@ -1,124 +0,0 @@
diff --git a/gpst.c b/gpst.c
index 244aaf04..78c16d1c 100644
--- a/gpst.c
+++ b/gpst.c
@@ -438,8 +438,19 @@ static int gpst_parse_config_xml(struct openconnect_info *vpninfo, xmlNode *xml_
new_ip_info.netmask = add_option_steal(&new_opts, "netmask", &s);
} else if (!xmlnode_get_val(xml_node, "mtu", &s))
new_ip_info.mtu = atoi(s);
- else if (!xmlnode_get_val(xml_node, "lifetime", &s))
+ else if (!xmlnode_get_val(xml_node, "lifetime", &s)) {
+ vpninfo->gp_session_lifetime = atoi(s);
vpninfo->auth_expiration = time(NULL) + atol(s);
+ } else if (!xmlnode_get_val(xml_node, "user-expires", &s) ||
+ !xmlnode_get_val(xml_node, "user_expires", &s)) {
+ vpninfo->gp_user_expires = atol(s);
+ } else if (!xmlnode_get_val(xml_node, "lifetime-notify-prior", &s)) {
+ vpninfo->gp_lifetime_notify_prior = atoi(s);
+ } else if (!xmlnode_get_val(xml_node, "lifetime-notify-message", &s)) {
+ free(vpninfo->gp_lifetime_notify_message);
+ vpninfo->gp_lifetime_notify_message = s;
+ s = NULL;
+ }
else if (!xmlnode_get_val(xml_node, "quarantine", &s)) {
if (strcmp(s, "no"))
vpn_progress(vpninfo, PRG_DEBUG,
diff --git a/libopenconnect.map.in b/libopenconnect.map.in
index f036c071..44110486 100644
--- a/libopenconnect.map.in
+++ b/libopenconnect.map.in
@@ -113,6 +113,10 @@ OPENCONNECT_5_7 {
openconnect_set_cookie;
openconnect_set_allow_insecure_crypto;
openconnect_get_auth_expiration;
+ openconnect_get_gp_session_lifetime;
+ openconnect_get_gp_user_expires;
+ openconnect_get_gp_lifetime_notify_prior;
+ openconnect_get_gp_lifetime_notify_message;
openconnect_disable_dtls;
openconnect_get_connect_url;
openconnect_set_webview_callback;
diff --git a/libopenconnect5.symbols b/libopenconnect5.symbols
index 7cb04d05..2c7af781 100644
--- a/libopenconnect5.symbols
+++ b/libopenconnect5.symbols
@@ -94,6 +94,10 @@ libopenconnect.so.5 libopenconnect5 #MINVER#
openconnect_set_cookie@OPENCONNECT_5_7 8.20
openconnect_set_allow_insecure_crypto@OPENCONNECT_5_7 8.20
openconnect_get_auth_expiration@OPENCONNECT_5_7 8.20
+ openconnect_get_gp_session_lifetime@OPENCONNECT_5_7 8.20
+ openconnect_get_gp_user_expires@OPENCONNECT_5_7 8.20
+ openconnect_get_gp_lifetime_notify_prior@OPENCONNECT_5_7 8.20
+ openconnect_get_gp_lifetime_notify_message@OPENCONNECT_5_7 8.20
openconnect_disable_dtls@OPENCONNECT_5_7 8.20
openconnect_get_connect_url@OPENCONNECT_5_7 8.20
openconnect_set_webview_callback@OPENCONNECT_5_7 8.20
diff --git a/library.c b/library.c
index b5e74e9b..03f47004 100644
--- a/library.c
+++ b/library.c
@@ -838,6 +838,7 @@ void openconnect_vpninfo_free(struct openconnect_info *vpninfo)
free(vpninfo->dtls_cipher);
free(vpninfo->peer_cert_hash);
free(vpninfo->ciphersuite_config);
+ free(vpninfo->gp_lifetime_notify_message);
#if defined(OPENCONNECT_OPENSSL)
free(vpninfo->cstp_cipher);
#if defined(HAVE_BIO_METH_FREE)
@@ -1137,6 +1138,26 @@ time_t openconnect_get_auth_expiration(struct openconnect_info *vpninfo)
return vpninfo->auth_expiration;
}
+int openconnect_get_gp_session_lifetime(struct openconnect_info *vpninfo)
+{
+ return vpninfo->gp_session_lifetime;
+}
+
+time_t openconnect_get_gp_user_expires(struct openconnect_info *vpninfo)
+{
+ return vpninfo->gp_user_expires;
+}
+
+int openconnect_get_gp_lifetime_notify_prior(struct openconnect_info *vpninfo)
+{
+ return vpninfo->gp_lifetime_notify_prior;
+}
+
+const char *openconnect_get_gp_lifetime_notify_message(struct openconnect_info *vpninfo)
+{
+ return vpninfo->gp_lifetime_notify_message;
+}
+
int openconnect_get_ip_info(struct openconnect_info *vpninfo,
const struct oc_ip_info **info,
const struct oc_vpn_option **cstp_options,
diff --git a/openconnect-internal.h b/openconnect-internal.h
index abf45bbd..dd5507ca 100644
--- a/openconnect-internal.h
+++ b/openconnect-internal.h
@@ -647,6 +647,10 @@ struct openconnect_info {
int dtls_attempt_period;
int udp_probes_sent;
time_t auth_expiration;
+ int gp_session_lifetime;
+ time_t gp_user_expires;
+ int gp_lifetime_notify_prior;
+ char *gp_lifetime_notify_message;
time_t new_dtls_started;
#if defined(OPENCONNECT_OPENSSL)
SSL_CTX *dtls_ctx;
diff --git a/openconnect.h b/openconnect.h
index 136f181a..febf15cc 100644
--- a/openconnect.h
+++ b/openconnect.h
@@ -655,6 +655,10 @@ void openconnect_set_dpd(struct openconnect_info *, int min_seconds);
void openconnect_set_trojan_interval(struct openconnect_info *, int seconds);
int openconnect_get_idle_timeout(struct openconnect_info *);
time_t openconnect_get_auth_expiration(struct openconnect_info *);
+int openconnect_get_gp_session_lifetime(struct openconnect_info *);
+time_t openconnect_get_gp_user_expires(struct openconnect_info *);
+int openconnect_get_gp_lifetime_notify_prior(struct openconnect_info *);
+const char *openconnect_get_gp_lifetime_notify_message(struct openconnect_info *);
/* The returned structures are owned by the library and may be freed/replaced
due to rekey or reconnect. Assume that once the mainloop starts, the
@@ -1,101 +0,0 @@
From 78078b21f53801b31fef352ec0de40d319edcae9 Mon Sep 17 00:00:00 2001
From: Kevin Yue <[email protected]>
Date: Sat, 13 Jun 2026 12:00:00 +0800
Subject: [PATCH 6/6] Add host ID to GlobalProtect HIP script arguments
---
gpst.c | 4 ++++
library.c | 15 +++++++++++++++
openconnect-internal.h | 4 ++++
openconnect.h | 3 +++
4 files changed, 26 insertions(+)
diff --git a/gpst.c b/gpst.c
index 78c16d1c..f1e1f6bb 100644
--- a/gpst.c
+++ b/gpst.c
@@ -1019,6 +1019,10 @@ static int run_hip_script(struct openconnect_info *vpninfo)
hip_argv[i++] = "--client-os";
hip_argv[i++] = gpst_os_name(vpninfo);
hip_argv[i++] = "--os-version";
hip_argv[i++] = openconnect_get_gp_os_version(vpninfo);
+ if (openconnect_get_gp_host_id(vpninfo)) {
+ hip_argv[i++] = "--host-id";
+ hip_argv[i++] = openconnect_get_gp_host_id(vpninfo);
+ }
hip_argv[i++] = "--cookie";
hip_argv[i++] = vpninfo->cookie;
if (vpninfo->ip_info.addr) {
diff --git a/library.c b/library.c
index 03f47004..9e585119 100644
--- a/library.c
+++ b/library.c
@@ -900,6 +900,7 @@ void openconnect_vpninfo_free(struct openconnect_info *vpninfo)
free(vpninfo->useragent);
free(vpninfo->gp_app_version);
free(vpninfo->gp_os_version);
+ free(vpninfo->gp_host_id);
free(vpninfo->authgroup);
#ifdef HAVE_LIBSTOKEN
if (vpninfo->stoken_pin)
@@ -1049,6 +1050,20 @@ const char *openconnect_get_gp_os_version(struct openconnect_info *vpninfo)
return vpninfo->gp_os_version ?: vpninfo->platname;
}
+int openconnect_set_gp_host_id(struct openconnect_info *vpninfo,
+ const char *gp_host_id)
+{
+ UTF8CHECK(gp_host_id);
+
+ STRDUP(vpninfo->gp_host_id, gp_host_id);
+ return 0;
+}
+
+const char *openconnect_get_gp_host_id(struct openconnect_info *vpninfo)
+{
+ return vpninfo->gp_host_id;
+}
+
int openconnect_set_urlpath(struct openconnect_info *vpninfo,
const char *urlpath)
{
diff --git a/openconnect-internal.h b/openconnect-internal.h
index a7e80659..76034fbd 100644
--- a/openconnect-internal.h
+++ b/openconnect-internal.h
@@ -788,6 +788,7 @@ struct openconnect_info {
char *version_string;
char *gp_app_version;
char *gp_os_version;
+ char *gp_host_id;
const char *quit_reason;
const char *delay_tunnel_reason; /* If non-null, provides a reason why protocol is not yet ready for tunnel setup */
@@ -1684,6 +1685,9 @@ const char *openconnect_get_gp_app_version(struct openconnect_info *vpninfo);
/* Get the OS version string for GP */
const char *openconnect_get_gp_os_version(struct openconnect_info *vpninfo);
+/* Get the host ID string for GP */
+const char *openconnect_get_gp_host_id(struct openconnect_info *vpninfo);
+
/* version.c */
extern const char openconnect_version_str[];
diff --git a/openconnect.h b/openconnect.h
index 40de2811..3c65c090 100644
--- a/openconnect.h
+++ b/openconnect.h
@@ -472,8 +472,11 @@ int openconnect_set_useragent(struct openconnect_info *vpninfo,
int openconnect_set_gp_app_version(struct openconnect_info *vpninfo,
const char *gp_app_version);
int openconnect_set_gp_os_version(struct openconnect_info *vpninfo,
const char *gp_os_version);
+int openconnect_set_gp_host_id(struct openconnect_info *vpninfo,
+ const char *gp_host_id);
+
int openconnect_passphrase_from_fsid(struct openconnect_info *vpninfo);
int openconnect_obtain_cookie(struct openconnect_info *vpninfo);
int openconnect_init_ssl(void);
--
2.50.1 (Apple Git-155)
@@ -1,15 +0,0 @@
diff --git a/gpst.c b/gpst.c
index 244aaf04..fb8d945d 100644
--- a/gpst.c
+++ b/gpst.c
@@ -669,6 +669,10 @@ static int gpst_get_config(struct openconnect_info *vpninfo)
result = do_https_request(vpninfo, "POST", "application/x-www-form-urlencoded", request_body, &xml_buf, NULL, HTTP_NO_FLAGS);
free(vpninfo->urlpath);
vpninfo->urlpath = orig_path;
+ if (result >= 0 && xml_buf)
+ vpn_progress(vpninfo, PRG_DEBUG,
+ "GlobalProtect getconfig.esp response:\n%s\n",
+ xml_buf);
/* parse getconfig result */
if (result >= 0)
+2
View File
@@ -47,6 +47,8 @@ pub(crate) struct VpnSessionInfoRaw {
pub user_expires: c_long, pub user_expires: c_long,
pub lifetime_warning_prior: c_int, pub lifetime_warning_prior: c_int,
pub lifetime_warning_message: *const c_char, pub lifetime_warning_message: *const c_char,
pub nlb_enabled: c_int,
pub nlb_connected_gw_ip: *const c_char,
} }
#[link(name = "vpn")] #[link(name = "vpn")]
+3
View File
@@ -59,6 +59,9 @@ static void setup_tun_handler(void *_vpninfo)
openconnect_get_gp_lifetime_notify_prior(_vpninfo), openconnect_get_gp_lifetime_notify_prior(_vpninfo),
.lifetime_warning_message = .lifetime_warning_message =
openconnect_get_gp_lifetime_notify_message(_vpninfo), openconnect_get_gp_lifetime_notify_message(_vpninfo),
.nlb_enabled = openconnect_get_gp_nlb_enabled(_vpninfo),
.nlb_connected_gw_ip =
openconnect_get_gp_nlb_connected_gw_ip(_vpninfo),
}; };
on_vpn_connected(g_cmd_pipe_fd, &session_info, g_user_data); on_vpn_connected(g_cmd_pipe_fd, &session_info, g_user_data);
} }
+2
View File
@@ -9,6 +9,8 @@ typedef struct vpn_session_info {
long user_expires; long user_expires;
int lifetime_warning_prior; int lifetime_warning_prior;
const char *lifetime_warning_message; const char *lifetime_warning_message;
int nlb_enabled;
const char *nlb_connected_gw_ip;
} vpn_session_info; } vpn_session_info;
typedef void (*vpn_connected_callback)(int cmd_pipe_fd, typedef void (*vpn_connected_callback)(int cmd_pipe_fd,
+11
View File
@@ -16,6 +16,8 @@ pub struct VpnSessionInfo {
pub lifetime_secs: Option<u32>, pub lifetime_secs: Option<u32>,
pub user_expires: Option<u32>, pub user_expires: Option<u32>,
pub lifetime_warning: Option<VpnSessionWarning>, pub lifetime_warning: Option<VpnSessionWarning>,
pub nlb_enabled: bool,
pub nlb_connected_gw_ip: Option<String>,
} }
#[derive(Debug, Clone, PartialEq, Eq)] #[derive(Debug, Clone, PartialEq, Eq)]
@@ -41,6 +43,8 @@ pub(crate) fn session_info_from_raw(raw: *const ffi::VpnSessionInfoRaw) -> VpnSe
(Some(prior_secs), Some(message)) => Some(VpnSessionWarning { prior_secs, message }), (Some(prior_secs), Some(message)) => Some(VpnSessionWarning { prior_secs, message }),
_ => None, _ => None,
}, },
nlb_enabled: raw.nlb_enabled != 0,
nlb_connected_gw_ip: unsafe { optional_c_string(raw.nlb_connected_gw_ip) },
} }
} }
@@ -426,12 +430,15 @@ mod tests {
#[test] #[test]
fn maps_session_info_from_callback_payload() { fn maps_session_info_from_callback_payload() {
let message = CString::new("Session expires soon").unwrap(); let message = CString::new("Session expires soon").unwrap();
let connected_gw = CString::new("10.1.2.3").unwrap();
let raw = ffi::VpnSessionInfoRaw { let raw = ffi::VpnSessionInfoRaw {
auth_expiration: 0, auth_expiration: 0,
lifetime_secs: 43_200, lifetime_secs: 43_200,
user_expires: 1_776_828_409, user_expires: 1_776_828_409,
lifetime_warning_prior: 1_800, lifetime_warning_prior: 1_800,
lifetime_warning_message: message.as_ptr(), lifetime_warning_message: message.as_ptr(),
nlb_enabled: 1,
nlb_connected_gw_ip: connected_gw.as_ptr(),
}; };
let info = session_info_from_raw(&raw); let info = session_info_from_raw(&raw);
@@ -445,6 +452,8 @@ mod tests {
message: "Session expires soon".to_string(), message: "Session expires soon".to_string(),
}) })
); );
assert!(info.nlb_enabled);
assert_eq!(info.nlb_connected_gw_ip.as_deref(), Some("10.1.2.3"));
} }
#[test] #[test]
@@ -455,6 +464,8 @@ mod tests {
user_expires: 0, user_expires: 0,
lifetime_warning_prior: 0, lifetime_warning_prior: 0,
lifetime_warning_message: std::ptr::null(), lifetime_warning_message: std::ptr::null(),
nlb_enabled: 0,
nlb_connected_gw_ip: std::ptr::null(),
}; };
let info = session_info_from_raw(&raw); let info = session_info_from_raw(&raw);
+91
View File
@@ -0,0 +1,91 @@
# Building from Source on FreeBSD and OpenBSD
This guide builds the open-source components from the `GlobalProtect-openconnect` repository on FreeBSD or OpenBSD.
## Workspace
Clone `GlobalProtect-openconnect`:
```sh
mkdir gp-build
cd gp-build
git clone --recurse-submodules https://github.com/yuezk/GlobalProtect-openconnect.git gp
```
## FreeBSD
Install build and runtime dependencies:
```sh
sudo pkg install git rust libiconv gettext-tools autoconf automake libtool patch \
gmake pkgconf libxml2 gnutls p11-kit nettle gmp gnome-keyring \
libayatana-appindicator polkit webkit2-gtk_41
```
Build and install:
```sh
cd gp
cargo build --release --workspace
sudo gmake install-bsd
```
Verify the installed binaries:
```sh
gpclient --version
gpauth --version
```
## OpenBSD
Install build and runtime dependencies:
```sh
doas pkg_add git rust libiconv gettext-tools autoconf-2.72 automake-1.17 \
libtool patch gmake pkgconf libxml gnutls p11-kit nettle gmp \
gnome-keyring polkit webkitgtk41
```
Use the installed Autoconf and Automake versions:
```sh
export AUTOCONF_VERSION=2.72
export AUTOMAKE_VERSION=1.17
```
If your shell cannot resolve the versioned tools automatically, add the usual unversioned command links:
```sh
doas ln -sf /usr/local/bin/autoreconf-2.72 /usr/local/bin/autoreconf
doas ln -sf /usr/local/bin/autoconf-2.72 /usr/local/bin/autoconf
doas ln -sf /usr/local/bin/autoheader-2.72 /usr/local/bin/autoheader
doas ln -sf /usr/local/bin/autom4te-2.72 /usr/local/bin/autom4te
doas ln -sf /usr/local/bin/aclocal-1.17 /usr/local/bin/aclocal
doas ln -sf /usr/local/bin/automake-1.17 /usr/local/bin/automake
```
Build and install:
```sh
cd gp
cargo build --release --workspace
doas gmake install-bsd
```
Verify the installed binaries:
```sh
gpclient --version
gpauth --version
```
## Verify
After installation, check the CLI help:
```sh
gpclient --help
```
+34 -10
View File
@@ -26,6 +26,7 @@
cargoToml = builtins.fromTOML (builtins.readFile ./Cargo.toml); cargoToml = builtins.fromTOML (builtins.readFile ./Cargo.toml);
pname = "globalprotect-openconnect"; pname = "globalprotect-openconnect";
version = cargoToml.workspace.package.version; version = cargoToml.workspace.package.version;
releaseTag = "v2.6.4";
toolchain = pkgs.rust-bin.fromRustupToolchainFile ./rust-toolchain.toml; toolchain = pkgs.rust-bin.fromRustupToolchainFile ./rust-toolchain.toml;
@@ -35,29 +36,29 @@
}; };
src = pkgs.fetchzip { src = pkgs.fetchzip {
url = "https://github.com/yuezk/GlobalProtect-openconnect/releases/download/v${version}/globalprotect-openconnect-${version}.tar.gz"; url = "https://github.com/yuezk/GlobalProtect-openconnect/releases/download/${releaseTag}/globalprotect-openconnect-${version}.tar.gz";
hash = "sha256-Ejvb//r6tE6yMwNwUJq5Z0r57K0IHKFN1YVaXnvpGIs="; hash = "sha256-cp7KRUwVJsyg8m7O70k/uo6WwLqCPbFCnWtXzHn1GgU=";
}; };
cpu = pkgs.stdenv.hostPlatform.parsed.cpu.name; cpu = pkgs.stdenv.hostPlatform.parsed.cpu.name;
gpguiHashes = { gpguiHashes = {
x86_64 = "sha256-jLMErGlfbzhRk8onqqiRXOMeNhdFWBZGOqPPEh9vLyM="; x86_64 = "sha256-7va5dBhmamOqJYbsHUtjWYFnoM8q5ZshB2CyK0NW6fE=";
aarch64 = "sha256-YSjn2oxDaKTtdfK7rsmuMZfD9n1bitVbScIW0fyedXI="; aarch64 = "sha256-uBzBKx39te5R4PloDusjSjUf1Y2iF/xO4dXUX2K4P8o=";
}; };
gpgui = pkgs.fetchzip { gpgui = pkgs.fetchzip {
url = "https://github.com/yuezk/GlobalProtect-openconnect/releases/download/v${version}/gpgui_${cpu}.bin.tar.xz"; url = "https://github.com/yuezk/GlobalProtect-openconnect/releases/download/${releaseTag}/gpgui_${cpu}.bin.tar.xz";
hash = gpguiHashes.${cpu}; hash = gpguiHashes.${cpu};
}; };
binaryHashes = { binaryHashes = {
x86_64 = "sha256-atZRM7v5areQTDkrJrOczSz0tc3P6aGU+BE4VblNE08="; x86_64 = "sha256-AqF+mwxmXxF/dFxmMXbtT2PONVArKKfMpwmX+3cYr5o=";
aarch64 = "sha256-ENE0fHlLSt493QIlotaIMf11MszJszl4ZZAsYWuFJeE="; aarch64 = "sha256-Ul77xppKrrQQDRl/zKjrrj2+8CRjrMagJbLqmDlfz9U=";
}; };
binaryPackage = pkgs.fetchzip { binaryPackage = pkgs.fetchzip {
url = "https://github.com/yuezk/GlobalProtect-openconnect/releases/download/v${version}/globalprotect-openconnect_${version}_${cpu}.bin.tar.xz"; url = "https://github.com/yuezk/GlobalProtect-openconnect/releases/download/${releaseTag}/globalprotect-openconnect_${version}_${cpu}.bin.tar.xz";
hash = binaryHashes.${cpu}; hash = binaryHashes.${cpu};
}; };
@@ -90,7 +91,7 @@
rewriteSourceInstallPaths = '' rewriteSourceInstallPaths = ''
substituteInPlace $out/share/applications/gpgui.desktop \ substituteInPlace $out/share/applications/gpgui.desktop \
--replace-fail /usr/bin/gpclient $out/bin/gpclient --replace-fail /usr/bin/gpclient /run/current-system/sw/bin/gpclient
substituteInPlace $out/libexec/gpclient/hipreport.sh \ substituteInPlace $out/libexec/gpclient/hipreport.sh \
--replace-fail /usr/bin/gpclient $out/bin/gpclient --replace-fail /usr/bin/gpclient $out/bin/gpclient
@@ -106,7 +107,7 @@
rewriteHostInstallPaths = '' rewriteHostInstallPaths = ''
substituteInPlace $out/share/applications/gpgui.desktop \ substituteInPlace $out/share/applications/gpgui.desktop \
--replace-fail /usr/bin/gpclient $out/bin/gpclient --replace-fail /usr/bin/gpclient /run/current-system/sw/bin/gpclient
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
@@ -117,6 +118,22 @@
fi fi
''; '';
installNixosPolkitRule = ''
chmod u+w $out/share $out/share/polkit-1 2>/dev/null || true
install -d $out/share/polkit-1/rules.d
cat > $out/share/polkit-1/rules.d/49-gpgui.rules <<EOF
polkit.addRule(function(action, subject) {
if (
action.id == "org.freedesktop.policykit.exec" &&
action.lookup("program") == "$out/bin/gpservice" &&
subject.active
) {
return polkit.Result.YES;
}
});
EOF
'';
fromSource = naersk'.buildPackage { fromSource = naersk'.buildPackage {
inherit pname version src; inherit pname version src;
@@ -168,6 +185,7 @@
cp -r packaging/files/usr/libexec $out/libexec cp -r packaging/files/usr/libexec $out/libexec
${rewriteSourceInstallPaths} ${rewriteSourceInstallPaths}
${installNixosPolkitRule}
''; '';
}; };
@@ -197,6 +215,8 @@
cp -r artifacts/usr/lib $out/lib cp -r artifacts/usr/lib $out/lib
fi fi
install -Dm755 ${gpgui}/gpgui $out/bin/gpgui
runHook postInstall runHook postInstall
''; '';
}; };
@@ -218,6 +238,9 @@
"--bind-try" "--bind-try"
"/run/wrappers" "/run/wrappers"
"/run/wrappers" "/run/wrappers"
"--ro-bind-try"
"/etc/gpgui"
"/etc/gpgui"
]; ];
}; };
@@ -327,6 +350,7 @@
fi fi
${rewriteHostInstallPaths} ${rewriteHostInstallPaths}
${installNixosPolkitRule}
runHook postInstall runHook postInstall
''; '';
+2 -1
View File
@@ -23,7 +23,8 @@ Build-Depends: debhelper (>= 9),
libayatana-appindicator3-1, libayatana-appindicator3-1,
gnome-keyring, gnome-keyring,
libwebkit2gtk-4.1-dev, libwebkit2gtk-4.1-dev,
rust-@RUST_VERSION@-all cargo-@RUST_VERSION@,
rustc-@RUST_VERSION@
Homepage: https://github.com/yuezk/GlobalProtect-openconnect Homepage: https://github.com/yuezk/GlobalProtect-openconnect
Package: globalprotect-openconnect Package: globalprotect-openconnect
+74
View File
@@ -0,0 +1,74 @@
# GlobalProtect-openconnect Docker image
This image provides the GlobalProtect-openconnect command-line tools on Alpine Linux. It includes:
- `gpclient` - connect to and disconnect from GlobalProtect VPN portals and gateways
- `gpauth` - complete authentication separately and pipe the result into `gpclient`
The image does not include embedded webview authentication, `gpgui-helper`, or the graphical `gpgui` application.
## Pull
```bash
docker pull yuezk/globalprotect-openconnect:<version>
```
Release images are tagged as `vX.Y.Z`, `X.Y.Z`, and `latest`.
## Usage
VPN tunnel creation requires access to `/dev/net/tun` and the `NET_ADMIN` capability:
```bash
docker run --rm -it --cap-add=NET_ADMIN --device=/dev/net/tun \
yuezk/globalprotect-openconnect:<version> \
connect <portal> --cookie-on-stdin
```
For browser authentication in a headless environment, use remote browser authentication:
```bash
docker run --rm -it --cap-add=NET_ADMIN --device=/dev/net/tun \
yuezk/globalprotect-openconnect:<version> \
connect <portal> --browser remote
```
On a Linux host, add host networking if the VPN routes should affect the host network namespace:
```bash
docker run --rm -it --network host --cap-add=NET_ADMIN --device=/dev/net/tun \
yuezk/globalprotect-openconnect:<version> \
connect <portal> --browser remote
```
Without `--network host`, the VPN connection stays inside the container network namespace. Docker Desktop on macOS and Windows does not make the host use the VPN through `--network host`; run `gpclient` on the host or use a container gateway setup for host traffic.
You can also run `gpauth` separately and pipe its remote-browser output into `gpclient`:
```bash
docker run --rm -it --entrypoint gpauth yuezk/globalprotect-openconnect:<version> \
<portal> --browser remote 2>/dev/null \
| docker run --rm -i --cap-add=NET_ADMIN --device=/dev/net/tun \
yuezk/globalprotect-openconnect:<version> \
connect <portal> --cookie-on-stdin
```
## Common commands
Show top-level help:
```bash
docker run --rm yuezk/globalprotect-openconnect:<version> --help
```
Show help for a command:
```bash
docker run --rm yuezk/globalprotect-openconnect:<version> help connect
```
## Project
GlobalProtect-openconnect is a modern GlobalProtect VPN client for Linux, built on OpenConnect with support for SSO, non-SSO, FIDO2, client certificate authentication, multiple portals and gateways, and direct gateway connections.
Source: https://github.com/yuezk/GlobalProtect-openconnect
+28 -2
View File
@@ -3,6 +3,7 @@
set -euo pipefail set -euo pipefail
release_version="${1:-}" release_version="${1:-}"
release_tag="${2:-}"
if git diff --quiet -- flake.nix; then if git diff --quiet -- flake.nix; then
echo "flake.nix hashes are already up to date" echo "flake.nix hashes are already up to date"
@@ -14,16 +15,41 @@ if [[ -z "$release_version" ]]; then
fi fi
version="${release_version#v}" version="${release_version#v}"
branch="chore/update-flake-hashes-v${version}" if [[ -z "$release_tag" ]]; then
release_tag="v$version"
fi
branch_suffix="v${version}"
title="chore: update flake hashes for v${version}" title="chore: update flake hashes for v${version}"
body="Updates the Nix flake fetchzip hashes for v${version} release assets." body="Updates the Nix flake fetchzip hashes for v${version} release assets."
if [[ "$release_tag" != "v$version" ]]; then
branch_suffix="${branch_suffix}-${release_tag}"
title="chore: update flake hashes for v${version} from ${release_tag}"
body="Updates the Nix flake fetchzip hashes for v${version} using ${release_tag} release assets."
fi
git config user.name "github-actions[bot]" git config user.name "github-actions[bot]"
git config user.email "41898282+github-actions[bot]@users.noreply.github.com" git config user.email "41898282+github-actions[bot]@users.noreply.github.com"
if [[ "$release_tag" == "snapshot" ]]; then
source_branch="${GITHUB_REF_NAME:-$(git branch --show-current)}"
source_branch_slug="$(printf '%s' "$source_branch" | sed -E 's#[/[:space:]]+#-#g; s#[^A-Za-z0-9._-]##g; s#^-+##; s#-+$##')"
branch="chore/flake-${source_branch_slug}"
git switch -C "$branch"
git add flake.nix
git commit -m "$title"
git push --force origin "$branch"
echo "Updated snapshot flake hashes on branch $branch from $source_branch; skipping PR creation"
exit 0
fi
branch="chore/update-flake-hashes-${branch_suffix}"
git switch -C "$branch" git switch -C "$branch"
git add flake.nix git add flake.nix
git commit -m "$title" git commit -m "$title"
git push --force-with-lease origin "$branch" git push --force origin "$branch"
if gh pr view "$branch" --json number > /tmp/flake-pr.json 2> /dev/null; then if gh pr view "$branch" --json number > /tmp/flake-pr.json 2> /dev/null; then
pr_number="$(jq -r '.number' /tmp/flake-pr.json)" pr_number="$(jq -r '.number' /tmp/flake-pr.json)"
+17 -4
View File
@@ -9,10 +9,11 @@ PROJECT_DIR="$(dirname "$SCRIPT_DIR")"
FLAKE_FILE="$PROJECT_DIR/flake.nix" FLAKE_FILE="$PROJECT_DIR/flake.nix"
usage() { usage() {
echo "Usage: $0 [version]" echo "Usage: $0 [version] [release-tag]"
echo echo
echo "Updates flake.nix fetchzip hashes from the published GitHub release assets." echo "Updates flake.nix fetchzip hashes from the published GitHub release assets."
echo "When version is omitted, the workspace package version from Cargo.toml is used." echo "When version is omitted, the workspace package version from Cargo.toml is used."
echo "When release-tag is omitted, v<version> is used. Use snapshot to test snapshot assets."
} }
if [[ "${1:-}" == "-h" || "${1:-}" == "--help" ]]; then if [[ "${1:-}" == "-h" || "${1:-}" == "--help" ]]; then
@@ -35,12 +36,21 @@ if [[ -z "$version" ]]; then
version="$(grep '^version' "$PROJECT_DIR/Cargo.toml" | head -1 | sed 's/version *= *"\(.*\)"/\1/')" version="$(grep '^version' "$PROJECT_DIR/Cargo.toml" | head -1 | sed 's/version *= *"\(.*\)"/\1/')"
fi fi
version="${version#v}" version="${version#v}"
release_tag="${2:-}"
if [[ -z "$release_tag" ]]; then
release_tag="v$version"
fi
if [[ -z "$version" ]]; then if [[ -z "$version" ]]; then
echo "Could not determine release version" >&2 echo "Could not determine release version" >&2
exit 1 exit 1
fi fi
if [[ -z "$release_tag" ]]; then
echo "Could not determine release tag" >&2
exit 1
fi
prefetch_hash() { prefetch_hash() {
local url="$1" local url="$1"
local attempt local attempt
@@ -67,7 +77,7 @@ prefetch_hash() {
release_url() { release_url() {
local asset="$1" local asset="$1"
echo "https://github.com/$REPO/releases/download/v$version/$asset" echo "https://github.com/$REPO/releases/download/$release_tag/$asset"
} }
source_hash="$(prefetch_hash "$(release_url "globalprotect-openconnect-$version.tar.gz")")" source_hash="$(prefetch_hash "$(release_url "globalprotect-openconnect-$version.tar.gz")")"
@@ -81,8 +91,10 @@ GPGUI_X86_64_HASH="$gpgui_x86_64_hash" \
GPGUI_AARCH64_HASH="$gpgui_aarch64_hash" \ GPGUI_AARCH64_HASH="$gpgui_aarch64_hash" \
BINARY_X86_64_HASH="$binary_x86_64_hash" \ BINARY_X86_64_HASH="$binary_x86_64_hash" \
BINARY_AARCH64_HASH="$binary_aarch64_hash" \ BINARY_AARCH64_HASH="$binary_aarch64_hash" \
RELEASE_TAG="$release_tag" \
perl -0pi -e ' perl -0pi -e '
s|(url = "https://github\.com/yuezk/GlobalProtect-openconnect/releases/download/v\$\{version\}/globalprotect-openconnect-\$\{version\}\.tar\.gz";\n\s*hash = ")[^"]+(";)|$1 . $ENV{"SOURCE_HASH"} . $2|e; s|(releaseTag = ")[^"]+(";)|$1 . $ENV{"RELEASE_TAG"} . $2|e;
s|(url = "https://github\.com/yuezk/GlobalProtect-openconnect/releases/download/\$\{releaseTag\}/globalprotect-openconnect-\$\{version\}\.tar\.gz";\n\s*hash = ")[^"]+(";)|$1 . $ENV{"SOURCE_HASH"} . $2|e;
s|(gpguiHashes = \{\n\s*x86_64 = ")[^"]+(";)|$1 . $ENV{"GPGUI_X86_64_HASH"} . $2|e; s|(gpguiHashes = \{\n\s*x86_64 = ")[^"]+(";)|$1 . $ENV{"GPGUI_X86_64_HASH"} . $2|e;
s|(gpguiHashes = \{\n\s*x86_64 = "[^"]+";\n\s*aarch64 = ")[^"]+(";)|$1 . $ENV{"GPGUI_AARCH64_HASH"} . $2|e; s|(gpguiHashes = \{\n\s*x86_64 = "[^"]+";\n\s*aarch64 = ")[^"]+(";)|$1 . $ENV{"GPGUI_AARCH64_HASH"} . $2|e;
s|(binaryHashes = \{\n\s*x86_64 = ")[^"]+(";)|$1 . $ENV{"BINARY_X86_64_HASH"} . $2|e; s|(binaryHashes = \{\n\s*x86_64 = ")[^"]+(";)|$1 . $ENV{"BINARY_X86_64_HASH"} . $2|e;
@@ -94,5 +106,6 @@ grep -F "$gpgui_x86_64_hash" "$FLAKE_FILE" > /dev/null
grep -F "$gpgui_aarch64_hash" "$FLAKE_FILE" > /dev/null grep -F "$gpgui_aarch64_hash" "$FLAKE_FILE" > /dev/null
grep -F "$binary_x86_64_hash" "$FLAKE_FILE" > /dev/null grep -F "$binary_x86_64_hash" "$FLAKE_FILE" > /dev/null
grep -F "$binary_aarch64_hash" "$FLAKE_FILE" > /dev/null grep -F "$binary_aarch64_hash" "$FLAKE_FILE" > /dev/null
grep -F "releaseTag = \"$release_tag\";" "$FLAKE_FILE" > /dev/null
echo "Updated flake.nix hashes for v$version" echo "Updated flake.nix hashes for v$version assets from $release_tag"