mirror of
https://github.com/yuezk/GlobalProtect-openconnect.git
synced 2026-11-18 06:06:13 -05:00
Compare commits
22
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 |
No files matched your search
+3
-2
@@ -1,6 +1,7 @@
|
||||
[submodule "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"]
|
||||
path = crates/openconnect/deps/libxml2
|
||||
url = https://gitlab.gnome.org/GNOME/libxml2.git
|
||||
url = https://github.com/GNOME/libxml2.git
|
||||
@@ -213,6 +213,7 @@ mod tests {
|
||||
prior_secs: 1_800,
|
||||
message: "Session expires soon".to_string(),
|
||||
}),
|
||||
..Default::default()
|
||||
},
|
||||
true,
|
||||
);
|
||||
@@ -233,6 +234,7 @@ mod tests {
|
||||
prior_secs: 1_800,
|
||||
message: "Session expires soon".to_string(),
|
||||
}),
|
||||
..Default::default()
|
||||
},
|
||||
false,
|
||||
);
|
||||
|
||||
@@ -1,34 +1,4 @@
|
||||
use std::{env, path::PathBuf, process::Command};
|
||||
|
||||
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());
|
||||
}
|
||||
}
|
||||
}
|
||||
use std::{env, path::PathBuf};
|
||||
|
||||
fn build_libxml2(deps_dir: &PathBuf, out_dir: &PathBuf) -> PathBuf {
|
||||
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 {
|
||||
let openconnect_dir = deps_dir.join("openconnect");
|
||||
let patches_dir = deps_dir.join("patches");
|
||||
|
||||
// The temporary location where we will 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());
|
||||
|
||||
// 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");
|
||||
|
||||
// Apply all patches from the patches directory
|
||||
apply_patches(&patches_dir, &build_src);
|
||||
|
||||
// Build the OpenConnect library using autotools
|
||||
// We explicitly enable static and disable shared to ensure we get a .a file.
|
||||
// .reconf("-ivf") is CRITICAL for git submodules because 'configure'
|
||||
@@ -215,4 +181,4 @@ fn main() {
|
||||
.include("src/ffi")
|
||||
.include(&oc_dst.join("include"))
|
||||
.compile("vpn");
|
||||
}
|
||||
}
|
||||
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 lifetime_warning_prior: c_int,
|
||||
pub lifetime_warning_message: *const c_char,
|
||||
pub nlb_enabled: c_int,
|
||||
pub nlb_connected_gw_ip: *const c_char,
|
||||
}
|
||||
|
||||
#[link(name = "vpn")]
|
||||
|
||||
@@ -59,6 +59,9 @@ static void setup_tun_handler(void *_vpninfo)
|
||||
openconnect_get_gp_lifetime_notify_prior(_vpninfo),
|
||||
.lifetime_warning_message =
|
||||
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);
|
||||
}
|
||||
|
||||
@@ -9,6 +9,8 @@ typedef struct vpn_session_info {
|
||||
long user_expires;
|
||||
int lifetime_warning_prior;
|
||||
const char *lifetime_warning_message;
|
||||
int nlb_enabled;
|
||||
const char *nlb_connected_gw_ip;
|
||||
} vpn_session_info;
|
||||
|
||||
typedef void (*vpn_connected_callback)(int cmd_pipe_fd,
|
||||
|
||||
@@ -16,6 +16,8 @@ pub struct VpnSessionInfo {
|
||||
pub lifetime_secs: Option<u32>,
|
||||
pub user_expires: Option<u32>,
|
||||
pub lifetime_warning: Option<VpnSessionWarning>,
|
||||
pub nlb_enabled: bool,
|
||||
pub nlb_connected_gw_ip: Option<String>,
|
||||
}
|
||||
|
||||
#[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 }),
|
||||
_ => 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]
|
||||
fn maps_session_info_from_callback_payload() {
|
||||
let message = CString::new("Session expires soon").unwrap();
|
||||
let connected_gw = CString::new("10.1.2.3").unwrap();
|
||||
let raw = ffi::VpnSessionInfoRaw {
|
||||
auth_expiration: 0,
|
||||
lifetime_secs: 43_200,
|
||||
user_expires: 1_776_828_409,
|
||||
lifetime_warning_prior: 1_800,
|
||||
lifetime_warning_message: message.as_ptr(),
|
||||
nlb_enabled: 1,
|
||||
nlb_connected_gw_ip: connected_gw.as_ptr(),
|
||||
};
|
||||
|
||||
let info = session_info_from_raw(&raw);
|
||||
@@ -445,6 +452,8 @@ mod tests {
|
||||
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]
|
||||
@@ -455,6 +464,8 @@ mod tests {
|
||||
user_expires: 0,
|
||||
lifetime_warning_prior: 0,
|
||||
lifetime_warning_message: std::ptr::null(),
|
||||
nlb_enabled: 0,
|
||||
nlb_connected_gw_ip: std::ptr::null(),
|
||||
};
|
||||
|
||||
let info = session_info_from_raw(&raw);
|
||||
|
||||
Reference in new issue
Block a user