mirror of
https://github.com/yuezk/GlobalProtect-openconnect.git
synced 2026-11-18 22:16:18 -05:00
fix: enhance Linux serial number resolution and add unit tests
This commit is contained in:
2 files changed
+33
-4
No files matched your search
@@ -27,6 +27,7 @@ A modern GlobalProtect VPN client for Linux, built on OpenConnect with full supp
|
||||
- [Other Distributions](#other-distributions)
|
||||
- [Building from Source](#building-from-source)
|
||||
- [Frequently Asked Questions](#frequently-asked-questions)
|
||||
- [NetworkManager Integration](#networkmanager-integration)
|
||||
- [License](#license)
|
||||
|
||||
## Features
|
||||
@@ -284,7 +285,7 @@ gnome-extensions enable [email protected]
|
||||
|
||||
### Official Docker Image
|
||||
|
||||
The official Docker image provides the CLI tools on Alpine Linux:
|
||||
The [official Docker image](https://hub.docker.com/r/yuezk/globalprotect-openconnect) provides the CLI tools on Alpine Linux:
|
||||
|
||||
```bash
|
||||
docker pull yuezk/globalprotect-openconnect:<version>
|
||||
@@ -468,6 +469,11 @@ sudo -E gpclient connect <portal>
|
||||
|
||||
See related issue: [#316](https://github.com/yuezk/GlobalProtect-openconnect/issues/316)
|
||||
|
||||
## NetworkManager Integration
|
||||
|
||||
- [WMP/GlobalProtect-SAML-NetworkManager](https://github.com/WMP/GlobalProtect-SAML-NetworkManager) – NetworkManager VPN plugin with SAML/SSO support for GNOME and KDE Plasma
|
||||
- [jdpipe/networkmanager-gpclient](https://github.com/jdpipe/networkmanager-gpclient) – NetworkManager VPN plugin that uses `gpclient`
|
||||
|
||||
## Licensing
|
||||
|
||||
### Trial and Pricing
|
||||
|
||||
@@ -362,6 +362,7 @@ mod platform {
|
||||
mod platform {
|
||||
use super::{
|
||||
ClientOs, NativeHostIdentitySnapshot, derive_uuid_from_seed, fallback_hostname, primary_mac_colon, resolve_host_id,
|
||||
serial_number,
|
||||
};
|
||||
use log::debug;
|
||||
|
||||
@@ -429,9 +430,17 @@ mod platform {
|
||||
}
|
||||
|
||||
fn collect_linux_serial_number() -> Option<String> {
|
||||
["/sys/class/dmi/id/product_serial", "/sys/class/dmi/id/product_uuid"]
|
||||
.iter()
|
||||
.find_map(|path| read_linux_identity_file(path))
|
||||
resolve_linux_serial_number(
|
||||
read_linux_identity_file("/sys/class/dmi/id/product_serial"),
|
||||
collect_linux_product_uuid,
|
||||
)
|
||||
}
|
||||
|
||||
fn resolve_linux_serial_number(
|
||||
product_serial: Option<String>,
|
||||
product_uuid: impl FnOnce() -> Option<String>,
|
||||
) -> Option<String> {
|
||||
product_serial.or_else(|| product_uuid().and_then(|uuid| serial_number::vmware_from_uuid(&uuid)))
|
||||
}
|
||||
|
||||
#[cfg(test)]
|
||||
@@ -446,6 +455,20 @@ mod platform {
|
||||
);
|
||||
assert_eq!(normalize_uuid("not-a-uuid"), None);
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn linux_serial_number_preserves_product_serial_and_formats_uuid_fallback() {
|
||||
let uuid = Some("5a784d56-6461-19ac-9ea9-d36a3b9c6cef".to_string());
|
||||
|
||||
assert_eq!(
|
||||
resolve_linux_serial_number(Some("product-serial".to_string()), || uuid.clone()),
|
||||
Some("product-serial".to_string())
|
||||
);
|
||||
assert_eq!(
|
||||
resolve_linux_serial_number(None, || uuid),
|
||||
Some("VMware-56 4d 78 5a 61 64 ac 19-9e a9 d3 6a 3b 9c 6c ef".to_string())
|
||||
);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in new issue
Block a user