mirror of
https://github.com/yuezk/GlobalProtect-openconnect.git
synced 2026-11-19 06:26:14 -05:00
Compare commits
28
Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
861997395e | ||
|
|
ea0270780a | ||
|
|
0283f0147c | ||
|
|
d637542ddd | ||
|
|
b5ea3c9c22 | ||
|
|
bdaea1b247 | ||
|
|
5274fd6282 | ||
|
|
2b916ef9a0 | ||
|
|
2e0320de5a | ||
|
|
6c31d2fbe7 | ||
|
|
73d900f9b3 | ||
|
|
c93c9ec67f | ||
|
|
ebd5e69260 | ||
|
|
085d812db5 | ||
|
|
fe26d2f338 | ||
|
|
2fa8912d9e | ||
|
|
a5027d4ff5 | ||
|
|
5fcef8c5ba | ||
|
|
81ccdc6358 | ||
|
|
e05b8fb358 | ||
|
|
8343d743e0 | ||
|
|
79110bbcd8 | ||
|
|
494e4a5331 | ||
|
|
b5b71df6e6 | ||
|
|
49f410e63b | ||
|
|
225acf13aa | ||
|
|
61d2b702c0 | ||
|
|
3276ac0f9a |
No files matched your search
+3
-2
@@ -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
@@ -214,7 +214,7 @@ checksum = "1505bd5d3d116872e7271a6d4e16d81d0c8570876c8de68093a09ac269d8aac0"
|
|||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "auth"
|
name = "auth"
|
||||||
version = "2.6.3"
|
version = "2.6.4"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"anyhow",
|
"anyhow",
|
||||||
"block2",
|
"block2",
|
||||||
@@ -705,7 +705,7 @@ dependencies = [
|
|||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "common"
|
name = "common"
|
||||||
version = "2.6.3"
|
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.3"
|
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.3"
|
version = "2.6.4"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"anyhow",
|
"anyhow",
|
||||||
"auth",
|
"auth",
|
||||||
@@ -1796,7 +1796,7 @@ dependencies = [
|
|||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "gpclient"
|
name = "gpclient"
|
||||||
version = "2.6.3"
|
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.3"
|
version = "2.6.4"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"anyhow",
|
"anyhow",
|
||||||
"clap",
|
"clap",
|
||||||
@@ -1843,7 +1843,7 @@ dependencies = [
|
|||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "gpservice"
|
name = "gpservice"
|
||||||
version = "2.6.3"
|
version = "2.6.4"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"anyhow",
|
"anyhow",
|
||||||
"axum",
|
"axum",
|
||||||
@@ -3191,7 +3191,7 @@ dependencies = [
|
|||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "openconnect"
|
name = "openconnect"
|
||||||
version = "2.6.3"
|
version = "2.6.4"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"autotools",
|
"autotools",
|
||||||
"cc",
|
"cc",
|
||||||
|
|||||||
+1
-1
@@ -11,7 +11,7 @@ members = [
|
|||||||
|
|
||||||
[workspace.package]
|
[workspace.package]
|
||||||
rust-version = "1.89"
|
rust-version = "1.89"
|
||||||
version = "2.6.3"
|
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"
|
||||||
|
|||||||
@@ -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:
|
||||||
|
|||||||
@@ -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,
|
||||||
);
|
);
|
||||||
|
|||||||
@@ -1,5 +1,11 @@
|
|||||||
# 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
|
## 2.6.3
|
||||||
|
|
||||||
### Fixed
|
### Fixed
|
||||||
|
|||||||
@@ -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);
|
||||||
|
|||||||
@@ -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'
|
||||||
|
|||||||
Submodule crates/openconnect/deps/openconnect updated: 0dcdff87db...f165d393c4.
-114
@@ -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)
|
|
||||||
|
|
||||||
-32
@@ -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)
|
|
||||||
|
|
||||||
-121
@@ -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)
|
|
||||||
|
|
||||||
-39
@@ -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)
|
|
||||||
@@ -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")]
|
||||||
|
|||||||
@@ -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);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -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,
|
||||||
|
|||||||
@@ -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);
|
||||||
|
|||||||
@@ -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
|
||||||
|
```
|
||||||
@@ -26,7 +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 = "snapshot";
|
releaseTag = "v2.6.4";
|
||||||
|
|
||||||
toolchain = pkgs.rust-bin.fromRustupToolchainFile ./rust-toolchain.toml;
|
toolchain = pkgs.rust-bin.fromRustupToolchainFile ./rust-toolchain.toml;
|
||||||
|
|
||||||
@@ -37,14 +37,14 @@
|
|||||||
|
|
||||||
src = pkgs.fetchzip {
|
src = pkgs.fetchzip {
|
||||||
url = "https://github.com/yuezk/GlobalProtect-openconnect/releases/download/${releaseTag}/globalprotect-openconnect-${version}.tar.gz";
|
url = "https://github.com/yuezk/GlobalProtect-openconnect/releases/download/${releaseTag}/globalprotect-openconnect-${version}.tar.gz";
|
||||||
hash = "sha256-fBoOcUPaiylhJc3P3x0cdmvUQwYO2e1xIPvq4NZ6hLc=";
|
hash = "sha256-cp7KRUwVJsyg8m7O70k/uo6WwLqCPbFCnWtXzHn1GgU=";
|
||||||
};
|
};
|
||||||
|
|
||||||
cpu = pkgs.stdenv.hostPlatform.parsed.cpu.name;
|
cpu = pkgs.stdenv.hostPlatform.parsed.cpu.name;
|
||||||
|
|
||||||
gpguiHashes = {
|
gpguiHashes = {
|
||||||
x86_64 = "sha256-orhK5844Cebc+IKtYBdc1OekkvJJv1suBzc0n3TNn8g=";
|
x86_64 = "sha256-7va5dBhmamOqJYbsHUtjWYFnoM8q5ZshB2CyK0NW6fE=";
|
||||||
aarch64 = "sha256-Lvdefh/ddk1TlWmVTluHFNZQbVAJrSkuYyzzDHcyIm0=";
|
aarch64 = "sha256-uBzBKx39te5R4PloDusjSjUf1Y2iF/xO4dXUX2K4P8o=";
|
||||||
};
|
};
|
||||||
|
|
||||||
gpgui = pkgs.fetchzip {
|
gpgui = pkgs.fetchzip {
|
||||||
@@ -53,8 +53,8 @@
|
|||||||
};
|
};
|
||||||
|
|
||||||
binaryHashes = {
|
binaryHashes = {
|
||||||
x86_64 = "sha256-/lvi+xF3xR8urBMkBI0R6aVSs34msarzTpkebH17TeU=";
|
x86_64 = "sha256-AqF+mwxmXxF/dFxmMXbtT2PONVArKKfMpwmX+3cYr5o=";
|
||||||
aarch64 = "sha256-hMV4xTMC1k3klX5BBRw2ThvjYDDYZkFEld+rDMfd3qU=";
|
aarch64 = "sha256-Ul77xppKrrQQDRl/zKjrrj2+8CRjrMagJbLqmDlfz9U=";
|
||||||
};
|
};
|
||||||
|
|
||||||
binaryPackage = pkgs.fetchzip {
|
binaryPackage = pkgs.fetchzip {
|
||||||
@@ -91,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
|
||||||
@@ -107,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
|
||||||
|
|||||||
@@ -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
|
||||||
Reference in new issue
Block a user