mirror of
https://github.com/yuezk/GlobalProtect-openconnect.git
synced 2026-11-18 14:06:14 -05:00
Compare commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
e98fd7894a | ||
|
|
6f860d3dff | ||
|
|
5902bee5ff | ||
|
|
494e4a5331 | ||
|
|
b5b71df6e6 | ||
|
|
49f410e63b | ||
|
|
225acf13aa | ||
|
|
61d2b702c0 | ||
|
|
3276ac0f9a | ||
|
|
0b037e158c | ||
|
|
10e94e0b81 | ||
|
|
0f76539075 | ||
|
|
f9b8c55924 | ||
|
|
a708ce0115 | ||
|
|
b3f4ba0a32 | ||
|
|
02cf4a0b26 | ||
|
|
370189cbee | ||
|
|
6746cf64c3 | ||
|
|
40739739b5 | ||
|
|
dc7a200b93 | ||
|
|
f49b6471f3 | ||
|
|
4da922aa3b | ||
|
|
ecc9c9f09c | ||
|
|
b32002710b | ||
|
|
7b6d20a003 | ||
|
|
d27029fad8 | ||
|
|
1b488ba696 | ||
|
|
f78f7c9bc8 | ||
|
|
7e11693ce3 | ||
|
|
c601fa9aa2 | ||
|
|
536a43773f | ||
|
|
ae4cbedd3b | ||
|
|
fe55d11fc4 | ||
|
|
34f1feaf43 | ||
|
|
f640b4d325 |
No files matched your search
@@ -130,6 +130,7 @@ jobs:
|
||||
if-no-files-found: error
|
||||
|
||||
build-gp:
|
||||
if: ${{ !startsWith(github.ref, 'refs/tags/') }}
|
||||
needs:
|
||||
- tarball
|
||||
strategy:
|
||||
@@ -153,19 +154,17 @@ jobs:
|
||||
with:
|
||||
name: artifact-source
|
||||
path: build-gp-${{ matrix.package }}
|
||||
- name: Docker Login
|
||||
run: echo ${{ secrets.DOCKER_HUB_TOKEN }} | docker login -u ${{ secrets.DOCKER_HUB_USERNAME }} --password-stdin
|
||||
- name: Build ${{ matrix.package }} package in Docker
|
||||
# LIBXML2_STATIC is needed to avoid the dynamic linking issue on different distros
|
||||
run: |
|
||||
docker run --pull=always --rm \
|
||||
docker run --rm \
|
||||
-e COREPACK_INTEGRITY_KEYS=0 \
|
||||
-e LIBXML2_STATIC=1 \
|
||||
-v $(pwd)/build-gp-${{ matrix.package }}:/workspace \
|
||||
yuezk/gpdev:${{ matrix.package }}-builder-tauri2
|
||||
- name: Install ${{ matrix.package }} package in Docker
|
||||
run: |
|
||||
docker run --pull=always --rm \
|
||||
docker run --rm \
|
||||
-e COREPACK_INTEGRITY_KEYS=0 \
|
||||
-e GPGUI_INSTALLED=0 \
|
||||
-v $(pwd)/build-gp-${{ matrix.package }}:/workspace \
|
||||
@@ -182,6 +181,7 @@ jobs:
|
||||
build-gp-${{ matrix.package }}/artifacts/*
|
||||
|
||||
build-docker-image:
|
||||
if: ${{ !startsWith(github.ref, 'refs/tags/') }}
|
||||
strategy:
|
||||
fail-fast: false
|
||||
matrix:
|
||||
@@ -282,18 +282,16 @@ jobs:
|
||||
run: |
|
||||
cd gpgui-source
|
||||
tar -czf gpgui.tar.gz gpgui gp
|
||||
- name: Docker Login
|
||||
run: echo ${{ secrets.DOCKER_HUB_TOKEN }} | docker login -u ${{ secrets.DOCKER_HUB_USERNAME }} --password-stdin
|
||||
- name: Build gpgui in Docker
|
||||
run: |
|
||||
docker run --pull=always --rm \
|
||||
docker run --rm \
|
||||
-e COREPACK_INTEGRITY_KEYS=0 \
|
||||
-v $(pwd)/gpgui-source:/workspace yuezk/gpdev:${{ matrix.libc.builder }}
|
||||
- name: Install gpgui in Docker
|
||||
run: |
|
||||
cd gpgui-source
|
||||
tar -xJf *.bin.tar.xz
|
||||
docker run --pull=always --rm \
|
||||
docker run --rm \
|
||||
-e COREPACK_INTEGRITY_KEYS=0 \
|
||||
-v $(pwd):/workspace yuezk/gpdev:${{ matrix.libc.builder }} \
|
||||
bash -c "cd /workspace/gpgui_*/ && ./gpgui --version"
|
||||
@@ -423,7 +421,7 @@ jobs:
|
||||
if: ${{ matrix.os == 'freebsd' }}
|
||||
uses: vmactions/freebsd-vm@v1
|
||||
with:
|
||||
release: "14.3"
|
||||
release: "14.4"
|
||||
arch: ${{ matrix.arch }}
|
||||
usesh: true
|
||||
prepare: |
|
||||
@@ -548,6 +546,7 @@ jobs:
|
||||
env:
|
||||
NEEDS_JSON: ${{ toJson(needs) }}
|
||||
BSD_MATRIX_ENABLED: ${{ needs.setup-bsd-matrix.outputs.enabled }}
|
||||
IS_TAG: ${{ startsWith(github.ref, 'refs/tags/') }}
|
||||
run: |
|
||||
python3 - <<'PY'
|
||||
import json
|
||||
@@ -556,12 +555,15 @@ jobs:
|
||||
|
||||
needs = json.loads(os.environ["NEEDS_JSON"])
|
||||
bsd_matrix_enabled = os.environ["BSD_MATRIX_ENABLED"] == "true"
|
||||
is_tag = os.environ["IS_TAG"] == "true"
|
||||
failed = []
|
||||
|
||||
for name, data in needs.items():
|
||||
result = data["result"]
|
||||
if result in {"failure", "cancelled"}:
|
||||
failed.append(f"{name}: {result}")
|
||||
elif name in {"build-gp", "build-docker-image"} and result == "skipped" and is_tag:
|
||||
continue
|
||||
elif name in {"build-gpgui-frontend", "build-bsd"} and result == "skipped" and not bsd_matrix_enabled:
|
||||
continue
|
||||
elif result == "skipped":
|
||||
|
||||
@@ -137,7 +137,7 @@ jobs:
|
||||
sed -i "s/DISABLE_RUST_TOOLCHAIN = 0/DISABLE_RUST_TOOLCHAIN = 1/g" .build/debian/rules
|
||||
|
||||
- name: Publish to PPA
|
||||
uses: yuezk/publish-ppa-package@gp
|
||||
uses: yuezk/publish-ppa-package@main
|
||||
with:
|
||||
repository: "yuezk/globalprotect-openconnect"
|
||||
gpg_private_key: ${{ secrets.PPA_GPG_PRIVATE_KEY }}
|
||||
|
||||
@@ -116,12 +116,10 @@ jobs:
|
||||
--pattern '*[^offline].tar.gz' \
|
||||
--dir build-${{ matrix.package }}
|
||||
|
||||
- name: Docker Login
|
||||
run: echo ${{ secrets.DOCKER_HUB_TOKEN }} | docker login -u ${{ secrets.DOCKER_HUB_USERNAME }} --password-stdin
|
||||
- name: Build ${{ matrix.package }} package in Docker
|
||||
# LIBXML2_STATIC is needed to avoid the dynamic linking issue on different distros
|
||||
run: |
|
||||
docker run --pull=always --rm \
|
||||
docker run --rm \
|
||||
-v $(pwd)/build-${{ matrix.package }}:/workspace \
|
||||
-e COREPACK_INTEGRITY_KEYS=0 \
|
||||
-e LIBXML2_STATIC=1 \
|
||||
@@ -130,7 +128,7 @@ jobs:
|
||||
|
||||
- name: Install ${{ matrix.package }} package in Docker
|
||||
run: |
|
||||
docker run --pull=always --rm \
|
||||
docker run --rm \
|
||||
-e COREPACK_INTEGRITY_KEYS=0 \
|
||||
-v $(pwd)/build-${{ matrix.package }}:/workspace \
|
||||
yuezk/gpdev:${{ matrix.package }}-builder-tauri2 \
|
||||
@@ -274,6 +272,13 @@ jobs:
|
||||
uses: actions/download-artifact@v8
|
||||
with:
|
||||
path: gh-release
|
||||
- name: Generate release notes
|
||||
id: release-notes
|
||||
run: |
|
||||
cd gh-release/gp
|
||||
mkdir -p .build
|
||||
scripts/release-notes.sh "${{ inputs.tag }}" > .build/release-notes.md
|
||||
echo "path=$GITHUB_WORKSPACE/gh-release/gp/.build/release-notes.md" >> "$GITHUB_OUTPUT"
|
||||
- name: Rename APK artifacts
|
||||
run: |
|
||||
shopt -s nullglob
|
||||
@@ -314,4 +319,5 @@ jobs:
|
||||
prerelease: ${{ contains(github.ref, 'snapshot') }}
|
||||
fail_on_unmatched_files: true
|
||||
tag_name: ${{ inputs.tag }}
|
||||
body_path: ${{ steps.release-notes.outputs.path }}
|
||||
files: ${{ steps.release-assets.outputs.files }}
|
||||
@@ -6,9 +6,9 @@ on:
|
||||
version:
|
||||
description: "Release version. Defaults to Cargo.toml workspace version."
|
||||
required: false
|
||||
release:
|
||||
types:
|
||||
- published
|
||||
release_tag:
|
||||
description: "GitHub release tag to fetch assets from. Defaults to v<version>; use snapshot for snapshot assets."
|
||||
required: false
|
||||
|
||||
permissions:
|
||||
contents: write
|
||||
@@ -26,44 +26,95 @@ jobs:
|
||||
|
||||
- name: Update flake hashes
|
||||
env:
|
||||
RELEASE_VERSION: ${{ github.event.release.tag_name || inputs.version }}
|
||||
RELEASE_VERSION: ${{ inputs.version }}
|
||||
RELEASE_TAG: ${{ inputs.release_tag }}
|
||||
run: |
|
||||
if [[ -n "$RELEASE_VERSION" ]]; then
|
||||
scripts/update-flake-hashes.sh "$RELEASE_VERSION"
|
||||
scripts/update-flake-hashes.sh "$RELEASE_VERSION" "$RELEASE_TAG"
|
||||
else
|
||||
scripts/update-flake-hashes.sh
|
||||
scripts/update-flake-hashes.sh "" "$RELEASE_TAG"
|
||||
fi
|
||||
|
||||
- name: Upload updated flake
|
||||
uses: actions/upload-artifact@v7
|
||||
with:
|
||||
name: updated-flake
|
||||
path: flake.nix
|
||||
if-no-files-found: error
|
||||
|
||||
validate-nix-prebuilt:
|
||||
needs:
|
||||
- update-flake-hashes
|
||||
strategy:
|
||||
fail-fast: false
|
||||
matrix:
|
||||
include:
|
||||
- runner: ubuntu-latest
|
||||
nixpkgs: nixos-25.11
|
||||
- runner: ubuntu-latest
|
||||
nixpkgs: nixos-26.05
|
||||
- runner: ubuntu-24.04-arm
|
||||
nixpkgs: nixos-25.11
|
||||
- runner: ubuntu-24.04-arm
|
||||
nixpkgs: nixos-26.05
|
||||
name: validate-nix-prebuilt (${{ matrix.nixpkgs }}, ${{ matrix.runner }})
|
||||
runs-on: ${{ matrix.runner }}
|
||||
steps:
|
||||
- name: Checkout GlobalProtect-openconnect
|
||||
uses: actions/checkout@v6
|
||||
with:
|
||||
submodules: recursive
|
||||
|
||||
- name: Download updated flake
|
||||
uses: actions/download-artifact@v8
|
||||
with:
|
||||
name: updated-flake
|
||||
path: .
|
||||
|
||||
- name: Install Nix
|
||||
uses: cachix/install-nix-action@v31
|
||||
|
||||
- name: Build prebuilt Nix package
|
||||
run: |
|
||||
nix build .#prebuilt \
|
||||
--override-input nixpkgs "github:NixOS/nixpkgs/${{ matrix.nixpkgs }}" \
|
||||
--extra-experimental-features "nix-command flakes" \
|
||||
--print-build-logs
|
||||
|
||||
- name: Inspect prebuilt Nix package
|
||||
run: |
|
||||
test -x result/bin/gpclient
|
||||
test -x result/bin/gpauth
|
||||
test -x result/bin/gpservice
|
||||
test -x result/bin/gpgui-helper
|
||||
test -x result/bin/gpgui
|
||||
test ! -L result/bin/gpservice
|
||||
head -n1 result/bin/gpclient | grep '^#!'
|
||||
head -n1 result/bin/gpservice | grep '^#!'
|
||||
grep -q '/run/wrappers/bin/pkexec' result/bin/gpclient
|
||||
grep -q 'gpservice_public=.*/bin/gpservice' result/bin/gpclient
|
||||
grep -q 'exec .*/bin/gpservice' result/bin/gpservice
|
||||
! grep -q '@gpservice_public@\|@gpservice_fhs@\|\$out/bin/gpservice' result/bin/gpclient result/bin/gpservice
|
||||
|
||||
! grep -R '/usr/bin/gp' result/share
|
||||
|
||||
open-pull-request:
|
||||
needs:
|
||||
- validate-nix-prebuilt
|
||||
runs-on: ubuntu-latest
|
||||
steps:
|
||||
- name: Checkout GlobalProtect-openconnect
|
||||
uses: actions/checkout@v6
|
||||
|
||||
- name: Download updated flake
|
||||
uses: actions/download-artifact@v8
|
||||
with:
|
||||
name: updated-flake
|
||||
path: .
|
||||
|
||||
- name: Open pull request
|
||||
env:
|
||||
GH_TOKEN: ${{ github.token }}
|
||||
RELEASE_VERSION: ${{ github.event.release.tag_name || inputs.version }}
|
||||
run: |
|
||||
if git diff --quiet -- flake.nix; then
|
||||
echo "flake.nix hashes are already up to date"
|
||||
exit 0
|
||||
fi
|
||||
|
||||
version="${RELEASE_VERSION:-$(grep '^version' Cargo.toml | head -1 | sed 's/version *= *"\(.*\)"/\1/')}"
|
||||
version="${version#v}"
|
||||
branch="chore/update-flake-hashes-v${version}"
|
||||
|
||||
git config user.name "github-actions[bot]"
|
||||
git config user.email "41898282+github-actions[bot]@users.noreply.github.com"
|
||||
git switch -c "$branch"
|
||||
git add flake.nix
|
||||
git commit -m "chore: update flake hashes for v${version}"
|
||||
git push --force-with-lease origin "$branch"
|
||||
|
||||
if gh pr view "$branch" --json number > /tmp/flake-pr.json 2> /dev/null; then
|
||||
pr_number="$(jq -r '.number' /tmp/flake-pr.json)"
|
||||
gh pr edit "$pr_number" \
|
||||
--title "chore: update flake hashes for v${version}" \
|
||||
--body "Updates the Nix flake fetchzip hashes for v${version} release assets."
|
||||
else
|
||||
gh pr create \
|
||||
--title "chore: update flake hashes for v${version}" \
|
||||
--body "Updates the Nix flake fetchzip hashes for v${version} release assets." \
|
||||
--base main \
|
||||
--head "$branch"
|
||||
fi
|
||||
RELEASE_VERSION: ${{ inputs.version }}
|
||||
RELEASE_TAG: ${{ inputs.release_tag }}
|
||||
run: scripts/open-flake-hashes-pr.sh "$RELEASE_VERSION" "$RELEASE_TAG"
|
||||
Generated
+8
-8
@@ -214,7 +214,7 @@ checksum = "1505bd5d3d116872e7271a6d4e16d81d0c8570876c8de68093a09ac269d8aac0"
|
||||
|
||||
[[package]]
|
||||
name = "auth"
|
||||
version = "2.6.0"
|
||||
version = "2.6.5"
|
||||
dependencies = [
|
||||
"anyhow",
|
||||
"block2",
|
||||
@@ -705,7 +705,7 @@ dependencies = [
|
||||
|
||||
[[package]]
|
||||
name = "common"
|
||||
version = "2.6.0"
|
||||
version = "2.6.5"
|
||||
|
||||
[[package]]
|
||||
name = "compile-time"
|
||||
@@ -1732,7 +1732,7 @@ dependencies = [
|
||||
|
||||
[[package]]
|
||||
name = "gpapi"
|
||||
version = "2.6.0"
|
||||
version = "2.6.5"
|
||||
dependencies = [
|
||||
"anyhow",
|
||||
"base64 0.22.1",
|
||||
@@ -1776,7 +1776,7 @@ dependencies = [
|
||||
|
||||
[[package]]
|
||||
name = "gpauth"
|
||||
version = "2.6.0"
|
||||
version = "2.6.5"
|
||||
dependencies = [
|
||||
"anyhow",
|
||||
"auth",
|
||||
@@ -1796,7 +1796,7 @@ dependencies = [
|
||||
|
||||
[[package]]
|
||||
name = "gpclient"
|
||||
version = "2.6.0"
|
||||
version = "2.6.5"
|
||||
dependencies = [
|
||||
"anyhow",
|
||||
"askama",
|
||||
@@ -1825,7 +1825,7 @@ dependencies = [
|
||||
|
||||
[[package]]
|
||||
name = "gpgui-helper"
|
||||
version = "2.6.0"
|
||||
version = "2.6.5"
|
||||
dependencies = [
|
||||
"anyhow",
|
||||
"clap",
|
||||
@@ -1843,7 +1843,7 @@ dependencies = [
|
||||
|
||||
[[package]]
|
||||
name = "gpservice"
|
||||
version = "2.6.0"
|
||||
version = "2.6.5"
|
||||
dependencies = [
|
||||
"anyhow",
|
||||
"axum",
|
||||
@@ -3191,7 +3191,7 @@ dependencies = [
|
||||
|
||||
[[package]]
|
||||
name = "openconnect"
|
||||
version = "2.6.0"
|
||||
version = "2.6.5"
|
||||
dependencies = [
|
||||
"autotools",
|
||||
"cc",
|
||||
|
||||
+1
-1
@@ -11,7 +11,7 @@ members = [
|
||||
|
||||
[workspace.package]
|
||||
rust-version = "1.89"
|
||||
version = "2.6.0"
|
||||
version = "2.6.5"
|
||||
authors = ["Kevin Yue <[email protected]>"]
|
||||
homepage = "https://github.com/yuezk/GlobalProtect-openconnect"
|
||||
edition = "2024"
|
||||
|
||||
@@ -72,7 +72,7 @@ For browser-based authentication with the CLI:
|
||||
|
||||
**Method 1:** Using sudo with environment preservation:
|
||||
```bash
|
||||
sudo -E gpclient connect --browser <portal>
|
||||
sudo gpclient connect --browser <portal>
|
||||
```
|
||||
|
||||
**Method 2:** Using authentication piping:
|
||||
@@ -81,6 +81,8 @@ gpauth <portal> --browser 2>/dev/null | sudo gpclient connect <portal> --cookie-
|
||||
```
|
||||
|
||||
**Browser Options:**
|
||||
- Use `--browser` to auto-select Chrome, Firefox, then the system default browser
|
||||
- Use `--browser default` to use the system default browser
|
||||
- Use `--browser <browser>` to specify a browser (e.g., `firefox`, `chrome`)
|
||||
- Use `--browser remote` for headless servers – this provides a URL you can access from another machine to complete authentication
|
||||
|
||||
@@ -198,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`.
|
||||
|
||||
### 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
|
||||
|
||||
Available via the `guru` and `lamdness` overlays:
|
||||
@@ -214,45 +236,51 @@ This repository includes a flake for NixOS integration.
|
||||
|
||||
#### Installation Steps
|
||||
|
||||
1. Add the flake to your `flake.nix`:
|
||||
Add the flake input and package to your `flake.nix`:
|
||||
|
||||
```nix
|
||||
{
|
||||
inputs = {
|
||||
# ... other inputs
|
||||
globalprotect-openconnect.url = "github:yuezk/GlobalProtect-openconnect";
|
||||
```nix
|
||||
{
|
||||
inputs = {
|
||||
# ... other inputs
|
||||
globalprotect-openconnect.url = "github:yuezk/GlobalProtect-openconnect";
|
||||
};
|
||||
|
||||
outputs = { self, nixpkgs, globalprotect-openconnect, ... }:
|
||||
let
|
||||
system = "x86_64-linux"; # or "aarch64-linux" for ARM64
|
||||
hostname = "<your-host>";
|
||||
in {
|
||||
nixosConfigurations.${hostname} = nixpkgs.lib.nixosSystem {
|
||||
inherit system;
|
||||
|
||||
modules = [
|
||||
./configuration.nix
|
||||
{
|
||||
services.ayatana-indicators.enable = true;
|
||||
|
||||
environment.systemPackages = [
|
||||
globalprotect-openconnect.packages.${system}.default
|
||||
nixpkgs.legacyPackages.${system}.gnomeExtensions.appindicator
|
||||
];
|
||||
}
|
||||
];
|
||||
};
|
||||
};
|
||||
}
|
||||
```
|
||||
|
||||
outputs = { nixpkgs, ... }@inputs: {
|
||||
nixosConfigurations.<your-host> = nixpkgs.lib.nixosSystem {
|
||||
specialArgs = { inherit inputs; };
|
||||
modules = [
|
||||
./configuration.nix
|
||||
];
|
||||
};
|
||||
};
|
||||
}
|
||||
```
|
||||
Apply:
|
||||
|
||||
2. Add the package to your `configuration.nix`:
|
||||
```bash
|
||||
sudo nixos-rebuild switch
|
||||
loginctl terminate-user "$USER"
|
||||
```
|
||||
|
||||
```nix
|
||||
{ pkgs, inputs, ... }:
|
||||
After logging back in to GNOME, enable AppIndicator support if needed:
|
||||
|
||||
{
|
||||
# ... other configurations
|
||||
environment.systemPackages = with pkgs; [
|
||||
# ... other packages
|
||||
inputs.globalprotect-openconnect.packages.${pkgs.stdenv.hostPlatform.system}.default
|
||||
];
|
||||
}
|
||||
```
|
||||
|
||||
3. Apply the changes:
|
||||
|
||||
```bash
|
||||
sudo nixos-rebuild switch
|
||||
```
|
||||
```bash
|
||||
gnome-extensions enable [email protected]
|
||||
```
|
||||
|
||||
### Official Docker Image
|
||||
|
||||
|
||||
+55
-3
@@ -57,6 +57,19 @@ struct Cli {
|
||||
#[arg(long, help = "Override the GlobalProtect client version reported to the server")]
|
||||
client_version: Option<String>,
|
||||
|
||||
#[arg(
|
||||
short,
|
||||
long,
|
||||
help = "Use SSL client certificate file in pkcs#8 (.pem) or pkcs#12 (.p12, .pfx) format"
|
||||
)]
|
||||
certificate: Option<String>,
|
||||
|
||||
#[arg(short = 'k', long, help = "Use SSL private key file in pkcs#8 (.pem) format")]
|
||||
sslkey: Option<String>,
|
||||
|
||||
#[arg(short = 'p', long, help = "The key passphrase of the private key")]
|
||||
key_password: Option<String>,
|
||||
|
||||
#[arg(long, help = "Get around the OpenSSL `unsafe legacy renegotiation` error")]
|
||||
fix_openssl: bool,
|
||||
|
||||
@@ -69,8 +82,8 @@ struct Cli {
|
||||
|
||||
#[arg(
|
||||
long,
|
||||
help = "The browser to use for authentication, e.g., `default`, `firefox`, `chrome`, `chromium`, or the path to the browser executable",
|
||||
default_missing_value = "default",
|
||||
help = "Use external browser authentication. With no value, auto-select Chrome, Firefox, then system default. Use `default` for the system default browser.",
|
||||
default_missing_value = "auto",
|
||||
num_args=0..=1
|
||||
)]
|
||||
browser: Option<String>,
|
||||
@@ -128,7 +141,7 @@ impl Cli {
|
||||
|
||||
let auth_request = match self.saml_request.as_deref() {
|
||||
Some(auth_request) => auth_request.to_string(),
|
||||
None => auth_prelogin(&server, &gp_params, self.external_browser_requested()).await?,
|
||||
None => auth_prelogin(&server, &gp_params, self.external_browser_requested(), self.gateway).await?,
|
||||
};
|
||||
|
||||
#[cfg(feature = "webview-auth")]
|
||||
@@ -161,6 +174,9 @@ impl Cli {
|
||||
fn build_gp_params(&self) -> GpParams {
|
||||
GpParams::builder(self.build_os_profile())
|
||||
.ignore_tls_errors(self.ignore_tls_errors)
|
||||
.certificate(self.certificate.clone())
|
||||
.sslkey(self.sslkey.clone())
|
||||
.key_password(self.key_password.clone())
|
||||
.is_gateway(self.gateway)
|
||||
.build()
|
||||
}
|
||||
@@ -250,6 +266,23 @@ mod tests {
|
||||
assert!(cli.external_browser_requested());
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn browser_without_value_uses_auto_mode() {
|
||||
let cli = Cli::try_parse_from(["gpauth", "portal.example.com", "--browser"]).expect("gpauth args should parse");
|
||||
|
||||
assert_eq!(cli.browser.as_deref(), Some("auto"));
|
||||
assert!(cli.external_browser_requested());
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn browser_default_keeps_system_default_mode() {
|
||||
let cli =
|
||||
Cli::try_parse_from(["gpauth", "portal.example.com", "--browser", "default"]).expect("gpauth args should parse");
|
||||
|
||||
assert_eq!(cli.browser.as_deref(), Some("default"));
|
||||
assert!(cli.external_browser_requested());
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn client_version_arg_sets_profile_client_version() {
|
||||
let cli = Cli::try_parse_from(["gpauth", "portal.example.com", "--client-version", "legacy-client"])
|
||||
@@ -259,4 +292,23 @@ mod tests {
|
||||
assert_eq!(profile.client_version(), "legacy-client");
|
||||
assert!(profile.user_agent().contains("legacy-client"));
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn client_certificate_args_parse() {
|
||||
let cli = Cli::try_parse_from([
|
||||
"gpauth",
|
||||
"portal.example.com",
|
||||
"--certificate",
|
||||
"/tmp/client.pem",
|
||||
"--sslkey",
|
||||
"/tmp/client.key",
|
||||
"--key-password",
|
||||
"secret",
|
||||
])
|
||||
.expect("gpauth args should parse");
|
||||
|
||||
assert_eq!(cli.certificate.as_deref(), Some("/tmp/client.pem"));
|
||||
assert_eq!(cli.sslkey.as_deref(), Some("/tmp/client.key"));
|
||||
assert_eq!(cli.key_password.as_deref(), Some("secret"));
|
||||
}
|
||||
}
|
||||
@@ -141,8 +141,8 @@ pub(crate) struct ConnectArgs {
|
||||
|
||||
#[arg(
|
||||
long,
|
||||
help = "Use the specified browser to authenticate, e.g., `default`, `firefox`, `chrome`, `chromium`, `remote`.\nOr the path to the browser executable.\nUse 'remote' for headless servers.",
|
||||
default_missing_value = "default",
|
||||
help = "Use external browser authentication. With no value, auto-select Chrome, Firefox, then system default. Use `default` for the system default browser or `remote` for headless servers.",
|
||||
default_missing_value = "auto",
|
||||
num_args=0..=1
|
||||
)]
|
||||
pub(super) browser: Option<String>,
|
||||
@@ -243,6 +243,26 @@ mod tests {
|
||||
assert_eq!(cli.args.gateway.as_deref(), Some("gw1"));
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn browser_without_value_uses_auto_mode() {
|
||||
use clap::Parser;
|
||||
|
||||
let cli = ConnectArgsTestCli::try_parse_from(["test", "portal.example.com", "--browser"])
|
||||
.expect("--browser without value should parse");
|
||||
|
||||
assert_eq!(cli.args.browser.as_deref(), Some("auto"));
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn browser_default_keeps_system_default_mode() {
|
||||
use clap::Parser;
|
||||
|
||||
let cli = ConnectArgsTestCli::try_parse_from(["test", "portal.example.com", "--browser", "default"])
|
||||
.expect("--browser default should parse");
|
||||
|
||||
assert_eq!(cli.args.browser.as_deref(), Some("default"));
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn os_defaults_to_runtime_os() {
|
||||
use clap::Parser;
|
||||
|
||||
@@ -48,7 +48,7 @@ impl ConnectHandler<'_> {
|
||||
&self,
|
||||
prelogin: &Prelogin,
|
||||
server: &str,
|
||||
portal_default_browser_enabled: bool,
|
||||
gateway_browser_auth_allowed: bool,
|
||||
) -> anyhow::Result<Credential> {
|
||||
if should_read_stdin_credential(self.args.cookie_on_stdin, self.args.as_gateway, prelogin.is_gateway()) {
|
||||
return self.read_cookie_from_stdin();
|
||||
@@ -58,10 +58,10 @@ impl ConnectHandler<'_> {
|
||||
|
||||
match prelogin {
|
||||
Prelogin::Saml(prelogin) => {
|
||||
let external_browser_supported = default_browser_auth_allowed(
|
||||
let external_browser_supported = can_use_external_browser_auth(
|
||||
prelogin.support_default_browser(),
|
||||
is_gateway,
|
||||
portal_default_browser_enabled,
|
||||
gateway_browser_auth_allowed,
|
||||
);
|
||||
let browser = if external_browser_supported {
|
||||
self.args.browser.as_deref()
|
||||
@@ -74,12 +74,16 @@ impl ConnectHandler<'_> {
|
||||
};
|
||||
let verbose = self.shared_args.verbose.to_verbose_arg();
|
||||
let os_profile = self.os_profile.borrow().clone();
|
||||
let key_password = self.latest_key_password.borrow().clone();
|
||||
let auth_launcher = SamlAuthLauncher::new(server)
|
||||
.gateway(is_gateway)
|
||||
.saml_request(prelogin.saml_request())
|
||||
.os_profile(&os_profile)
|
||||
.fix_openssl(self.shared_args.fix_openssl)
|
||||
.ignore_tls_errors(self.shared_args.ignore_tls_errors)
|
||||
.certificate(self.args.certificate.as_deref())
|
||||
.sslkey(self.args.sslkey.as_deref())
|
||||
.key_password(key_password.as_deref())
|
||||
.browser(browser)
|
||||
.verbose(verbose);
|
||||
|
||||
@@ -184,12 +188,12 @@ fn should_read_stdin_credential(cookie_on_stdin: bool, as_gateway: bool, prelogi
|
||||
cookie_on_stdin && (!prelogin_is_gateway || as_gateway)
|
||||
}
|
||||
|
||||
fn default_browser_auth_allowed(
|
||||
fn can_use_external_browser_auth(
|
||||
saml_support_default_browser: bool,
|
||||
is_gateway: bool,
|
||||
portal_default_browser_enabled: bool,
|
||||
gateway_browser_auth_allowed: bool,
|
||||
) -> bool {
|
||||
saml_support_default_browser && (!is_gateway || portal_default_browser_enabled)
|
||||
saml_support_default_browser && (!is_gateway || gateway_browser_auth_allowed)
|
||||
}
|
||||
|
||||
fn log_stdin_host_id(host_id: Option<&str>) {
|
||||
@@ -250,18 +254,18 @@ mod tests {
|
||||
|
||||
#[test]
|
||||
fn portal_saml_can_use_default_browser_when_supported() {
|
||||
assert!(default_browser_auth_allowed(true, false, false));
|
||||
assert!(can_use_external_browser_auth(true, false, false));
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn gateway_saml_requires_portal_default_browser_policy() {
|
||||
assert!(!default_browser_auth_allowed(true, true, false));
|
||||
assert!(default_browser_auth_allowed(true, true, true));
|
||||
fn gateway_saml_requires_gateway_browser_auth_allowance() {
|
||||
assert!(!can_use_external_browser_auth(true, true, false));
|
||||
assert!(can_use_external_browser_auth(true, true, true));
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn default_browser_auth_requires_saml_support() {
|
||||
assert!(!default_browser_auth_allowed(false, false, true));
|
||||
assert!(!default_browser_auth_allowed(false, true, true));
|
||||
assert!(!can_use_external_browser_auth(false, false, true));
|
||||
assert!(!can_use_external_browser_auth(false, true, true));
|
||||
}
|
||||
}
|
||||
@@ -28,6 +28,8 @@ use crate::{
|
||||
|
||||
use super::{ConnectHandler, args::cookie_cache_path};
|
||||
|
||||
const OPENCONNECT_INTERRUPTED_EXIT_CODE: i32 = -4;
|
||||
|
||||
struct GatewayLoginSession {
|
||||
cookie: String,
|
||||
extension_auth: SessionExtensionAuth,
|
||||
@@ -139,8 +141,11 @@ impl ConnectHandler<'_> {
|
||||
let mut gp_params = self.build_gp_params();
|
||||
gp_params.set_is_gateway(true);
|
||||
|
||||
let prelogin = prelogin(gateway, &gp_params, self.prelogin_options(false)).await?;
|
||||
let cred = self.obtain_credential(&prelogin, gateway, false).await?;
|
||||
let gateway_browser_auth_allowed = true;
|
||||
let prelogin = prelogin(gateway, &gp_params, self.direct_gateway_prelogin_options()).await?;
|
||||
let cred = self
|
||||
.obtain_credential(&prelogin, gateway, gateway_browser_auth_allowed)
|
||||
.await?;
|
||||
|
||||
let login_session = self
|
||||
.login_gateway(gateway, &cred, &gp_params, gateway_context.as_ref())
|
||||
@@ -174,21 +179,18 @@ impl ConnectHandler<'_> {
|
||||
gateway: &str,
|
||||
portal_cred: &AuthCookieCredential,
|
||||
allow_extend_session: bool,
|
||||
portal_default_browser_enabled: bool,
|
||||
portal_config_default_browser: bool,
|
||||
gateway_context: GatewayLoginContext,
|
||||
) -> Result<(), GatewayConnectError> {
|
||||
info!("Connecting to gateway with portal-cookie first, gateway prelogin fallback...");
|
||||
|
||||
let mut gp_params = self.build_gp_params();
|
||||
gp_params.set_is_gateway(true);
|
||||
let gateway_browser_auth_allowed = self.gateway_browser_auth_allowed(portal_config_default_browser);
|
||||
|
||||
let gateway_prelogin = prelogin(
|
||||
gateway,
|
||||
&gp_params,
|
||||
self.prelogin_options(portal_default_browser_enabled),
|
||||
)
|
||||
.await
|
||||
.map_err(GatewayConnectError::before_tunnel)?;
|
||||
let gateway_prelogin = prelogin(gateway, &gp_params, self.prelogin_options(gateway_browser_auth_allowed))
|
||||
.await
|
||||
.map_err(GatewayConnectError::before_tunnel)?;
|
||||
|
||||
if portal_cred.can_authenticate_gateway() {
|
||||
let portal_cred_for_login: Credential = portal_cred.into();
|
||||
@@ -219,7 +221,7 @@ impl ConnectHandler<'_> {
|
||||
}
|
||||
|
||||
let gateway_cred = match self
|
||||
.obtain_credential(&gateway_prelogin, gateway, portal_default_browser_enabled)
|
||||
.obtain_credential(&gateway_prelogin, gateway, gateway_browser_auth_allowed)
|
||||
.await
|
||||
{
|
||||
Ok(cred) => cred,
|
||||
@@ -372,10 +374,13 @@ impl ConnectHandler<'_> {
|
||||
let session_ctx_on_connect = Arc::clone(&session_ctx);
|
||||
let tunnel_established = Arc::new(AtomicBool::new(false));
|
||||
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 {
|
||||
shutdown_signal().await;
|
||||
info!("Received the interrupt signal, disconnecting...");
|
||||
disconnect_requested_on_signal.store(true, Ordering::SeqCst);
|
||||
vpn_clone.disconnect();
|
||||
});
|
||||
|
||||
@@ -403,7 +408,8 @@ impl ConnectHandler<'_> {
|
||||
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>) {
|
||||
@@ -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 {
|
||||
return Ok(());
|
||||
}
|
||||
|
||||
if disconnect_requested && exit_code == OPENCONNECT_INTERRUPTED_EXIT_CODE {
|
||||
return Ok(());
|
||||
}
|
||||
|
||||
let error = anyhow::anyhow!("OpenConnect exited with status {}", exit_code);
|
||||
if tunnel_established {
|
||||
Err(GatewayConnectError::after_tunnel(error))
|
||||
@@ -477,20 +491,33 @@ mod tests {
|
||||
|
||||
#[test]
|
||||
fn openconnect_success_is_not_a_gateway_failure() {
|
||||
assert!(classify_openconnect_result(0, false).is_ok());
|
||||
assert!(classify_openconnect_result(0, true).is_ok());
|
||||
assert!(classify_openconnect_result(0, false, false).is_ok());
|
||||
assert!(classify_openconnect_result(0, true, false).is_ok());
|
||||
}
|
||||
|
||||
#[test]
|
||||
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());
|
||||
}
|
||||
|
||||
#[test]
|
||||
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());
|
||||
}
|
||||
|
||||
@@ -65,10 +65,18 @@ impl<'a> ConnectHandler<'a> {
|
||||
builder.build()
|
||||
}
|
||||
|
||||
pub(super) fn prelogin_options(&self, portal_default_browser_enabled: bool) -> PreloginOptions {
|
||||
pub(super) fn prelogin_options(&self, gateway_browser_auth_allowed: bool) -> PreloginOptions {
|
||||
PreloginOptions::default()
|
||||
.external_browser_requested(self.external_browser_requested())
|
||||
.portal_default_browser_enabled(portal_default_browser_enabled)
|
||||
.gateway_external_browser_allowed(gateway_browser_auth_allowed)
|
||||
}
|
||||
|
||||
pub(super) fn direct_gateway_prelogin_options(&self) -> PreloginOptions {
|
||||
self.prelogin_options(true)
|
||||
}
|
||||
|
||||
pub(super) fn gateway_browser_auth_allowed(&self, portal_config_default_browser: bool) -> bool {
|
||||
gateway_browser_auth_allowed(portal_config_default_browser, self.external_browser_requested())
|
||||
}
|
||||
|
||||
fn external_browser_requested(&self) -> bool {
|
||||
@@ -169,7 +177,8 @@ impl<'a> ConnectHandler<'a> {
|
||||
None => portal_config.auth_cookie().clone(),
|
||||
};
|
||||
let allow_extend_session = portal_config.allow_extend_session().unwrap_or(false);
|
||||
let portal_default_browser_enabled = portal_config.default_browser().unwrap_or(false);
|
||||
let portal_config_default_browser = portal_config.default_browser().unwrap_or(false);
|
||||
info!("Portal config default-browser: {}", portal_config_default_browser);
|
||||
|
||||
if self.args.auto_gateway {
|
||||
let gateways = portal_config.gateways();
|
||||
@@ -194,7 +203,7 @@ impl<'a> ConnectHandler<'a> {
|
||||
gateway.server(),
|
||||
&auth_cookie,
|
||||
allow_extend_session,
|
||||
portal_default_browser_enabled,
|
||||
portal_config_default_browser,
|
||||
gateway_context,
|
||||
)
|
||||
.await
|
||||
@@ -259,7 +268,7 @@ impl<'a> ConnectHandler<'a> {
|
||||
gateway,
|
||||
&auth_cookie,
|
||||
allow_extend_session,
|
||||
portal_default_browser_enabled,
|
||||
portal_config_default_browser,
|
||||
gateway_context,
|
||||
)
|
||||
.await
|
||||
@@ -279,3 +288,27 @@ impl<'a> ConnectHandler<'a> {
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
fn gateway_browser_auth_allowed(portal_config_default_browser: bool, external_browser_requested: bool) -> bool {
|
||||
portal_config_default_browser || external_browser_requested
|
||||
}
|
||||
|
||||
#[cfg(test)]
|
||||
mod tests {
|
||||
use super::gateway_browser_auth_allowed;
|
||||
|
||||
#[test]
|
||||
fn gateway_browser_auth_is_allowed_by_portal_config() {
|
||||
assert!(gateway_browser_auth_allowed(true, false));
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn gateway_browser_auth_is_allowed_by_explicit_browser_request() {
|
||||
assert!(gateway_browser_auth_allowed(false, true));
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn gateway_browser_auth_is_disabled_without_portal_config_or_user_request() {
|
||||
assert!(!gateway_browser_auth_allowed(false, false));
|
||||
}
|
||||
}
|
||||
@@ -3,7 +3,6 @@ use std::{
|
||||
io::BufReader,
|
||||
ops::ControlFlow,
|
||||
os::unix::fs::PermissionsExt,
|
||||
path::PathBuf,
|
||||
sync::Arc,
|
||||
};
|
||||
|
||||
@@ -17,7 +16,7 @@ use axum::{
|
||||
http::StatusCode,
|
||||
response::IntoResponse,
|
||||
};
|
||||
use common::constants::GP_GUI_BINARY;
|
||||
use common::binary_paths;
|
||||
use futures::{SinkExt, StreamExt};
|
||||
use gpapi::{
|
||||
service::{event::WsEvent, request::UpdateGuiRequest},
|
||||
@@ -67,8 +66,8 @@ pub async fn update_gui(State(ctx): State<Arc<WsServerContext>>, body: Bytes) ->
|
||||
|
||||
// Unpack GPGUI archive, gpgui_2.0.0_{arch}.bin.tar.xz and install it
|
||||
async fn install_gui(src: &str) -> anyhow::Result<()> {
|
||||
let path = PathBuf::from(GP_GUI_BINARY);
|
||||
let Some(dir) = path.parent() else {
|
||||
let target = binary_paths::gpgui();
|
||||
let Some(dir) = target.parent() else {
|
||||
bail!("Failed to get parent directory of GUI binary");
|
||||
};
|
||||
|
||||
@@ -81,13 +80,13 @@ async fn install_gui(src: &str) -> anyhow::Result<()> {
|
||||
|
||||
for entry in ar.entries()? {
|
||||
let mut entry = entry?;
|
||||
let path = entry.path()?;
|
||||
let entry_path = entry.path()?;
|
||||
|
||||
if let Some(name) = path.file_name() {
|
||||
if let Some(name) = entry_path.file_name() {
|
||||
let name = name.to_string_lossy();
|
||||
|
||||
if name == "gpgui" {
|
||||
let mut file = File::create(GP_GUI_BINARY)?;
|
||||
let mut file = File::create(&target)?;
|
||||
std::io::copy(&mut entry, &mut file)?;
|
||||
break;
|
||||
}
|
||||
@@ -95,7 +94,7 @@ async fn install_gui(src: &str) -> anyhow::Result<()> {
|
||||
}
|
||||
|
||||
// Make the binary executable
|
||||
fs::set_permissions(GP_GUI_BINARY, Permissions::from_mode(0o755)).await?;
|
||||
fs::set_permissions(target, Permissions::from_mode(0o755)).await?;
|
||||
|
||||
Ok(())
|
||||
}
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
use std::sync::Arc;
|
||||
|
||||
use axum::extract::ws::Message;
|
||||
use common::constants::GP_AUTH_BINARY;
|
||||
use common::binary_paths;
|
||||
use gpapi::{
|
||||
os_profile::HostIdentity,
|
||||
service::{
|
||||
@@ -73,7 +73,7 @@ impl WsServerContext {
|
||||
vpn_state: self.vpn_state_rx.borrow().clone(),
|
||||
vpnc_script: find_vpnc_script().map(|s| s.to_owned()),
|
||||
csd_wrapper: find_csd_wrapper().map(|s| s.to_owned()),
|
||||
auth_executable: GP_AUTH_BINARY.to_owned(),
|
||||
auth_executable: binary_paths::gpauth().to_string_lossy().into_owned(),
|
||||
host_info,
|
||||
};
|
||||
|
||||
|
||||
@@ -1,5 +1,50 @@
|
||||
# Changelog
|
||||
|
||||
## 2.6.5
|
||||
|
||||
### Fixed
|
||||
|
||||
- Fixed duplicate tray icons caused by both Tauri configuration and application code creating a tray icon (fix [#464](https://github.com/yuezk/GlobalProtect-openconnect/issues/464)).
|
||||
- Fixed a potential crash when VPN progress messages contain printf-style format specifiers.
|
||||
|
||||
## 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
|
||||
|
||||
### Fixed
|
||||
|
||||
- Fixed gateway fallback browser authentication when external browser authentication is explicitly requested.
|
||||
- Added logging for portal config default-browser behavior.
|
||||
- Added GUI managed configuration support with `gpgui.conf`, including reset to managed config.
|
||||
- Improved GUI config directory migration and managed license auto activation.
|
||||
|
||||
## 2.6.1
|
||||
|
||||
### Changed
|
||||
|
||||
- Improved external browser authentication so `--browser` chooses Chrome first, then Firefox, then the system default browser.
|
||||
- Improved NixOS prebuilt package integration for launching helper binaries and desktop services.
|
||||
- Updated the release process to publish GitHub release notes from the changelog.
|
||||
|
||||
### Fixed
|
||||
|
||||
- Fixed NixOS GUI launch failures caused by package-local binary paths.
|
||||
- Fixed NixOS tray icon setup documentation for GNOME desktops.
|
||||
- Fixed browser authentication for portals that require a client certificate.
|
||||
- Fixed release automation so Nix flake hash updates are run manually after release assets are available.
|
||||
|
||||
## 2.6.0
|
||||
|
||||
### Added
|
||||
|
||||
@@ -11,6 +11,7 @@ use tokio::{
|
||||
use crate::browser::auth_server::AuthServer;
|
||||
|
||||
pub enum Browser<'a> {
|
||||
Auto,
|
||||
Default,
|
||||
Chrome,
|
||||
Firefox,
|
||||
@@ -21,6 +22,7 @@ pub enum Browser<'a> {
|
||||
impl<'a> Browser<'a> {
|
||||
pub fn from_str(browser: &'a str) -> Self {
|
||||
match browser.to_lowercase().as_str() {
|
||||
"auto" => Browser::Auto,
|
||||
"default" => Browser::Default,
|
||||
"chrome" => Browser::Chrome,
|
||||
"firefox" => Browser::Firefox,
|
||||
@@ -31,6 +33,7 @@ impl<'a> Browser<'a> {
|
||||
|
||||
fn as_str(&self) -> &str {
|
||||
match self {
|
||||
Browser::Auto => "auto",
|
||||
Browser::Default => "default",
|
||||
Browser::Chrome => "chrome",
|
||||
Browser::Firefox => "firefox",
|
||||
@@ -87,6 +90,15 @@ Note that the URL is only valid for a single use.
|
||||
info!("Launching the default browser...");
|
||||
webbrowser::open(&auth_url)?;
|
||||
}
|
||||
Browser::Auto => {
|
||||
if let Some(app) = find_auto_browser_path() {
|
||||
info!("Launching browser: {}", app);
|
||||
open::with_detached(&auth_url, app)?;
|
||||
} else {
|
||||
info!("No preferred browser found; launching the default browser...");
|
||||
webbrowser::open(&auth_url)?;
|
||||
}
|
||||
}
|
||||
_ => {
|
||||
let app = find_browser_path(&self.browser);
|
||||
|
||||
@@ -124,19 +136,25 @@ async fn detect_local_ip() -> anyhow::Result<String> {
|
||||
|
||||
fn find_browser_path(browser: &Browser) -> String {
|
||||
match browser {
|
||||
Browser::Chrome => {
|
||||
const CHROME_VARIANTS: &[&str] = &["google-chrome-stable", "google-chrome", "chromium"];
|
||||
|
||||
CHROME_VARIANTS
|
||||
.iter()
|
||||
.find_map(|&browser_name| which::which(browser_name).ok())
|
||||
.map(|path| path.to_string_lossy().to_string())
|
||||
.unwrap_or_else(|| browser.as_str().to_string())
|
||||
}
|
||||
Browser::Chrome => find_chrome_path().unwrap_or_else(|| browser.as_str().to_string()),
|
||||
_ => browser.as_str().to_string(),
|
||||
}
|
||||
}
|
||||
|
||||
fn find_auto_browser_path() -> Option<String> {
|
||||
find_chrome_path().or_else(|| find_program_path("firefox"))
|
||||
}
|
||||
|
||||
fn find_chrome_path() -> Option<String> {
|
||||
["google-chrome-stable", "google-chrome", "chromium"]
|
||||
.iter()
|
||||
.find_map(|browser_name| find_program_path(browser_name))
|
||||
}
|
||||
|
||||
fn find_program_path(name: &str) -> Option<String> {
|
||||
which::which(name).ok().map(|path| path.to_string_lossy().to_string())
|
||||
}
|
||||
|
||||
async fn wait_auth_data() -> anyhow::Result<SamlAuthData> {
|
||||
// Start a local server to receive the browser authentication data
|
||||
let listener = TcpListener::bind("127.0.0.1:0").await?;
|
||||
@@ -176,3 +194,14 @@ fn read_auth_data_from_stdin() -> anyhow::Result<SamlAuthData> {
|
||||
let auth_data = SamlAuthData::from_gpcallback(data.trim())?;
|
||||
Ok(auth_data)
|
||||
}
|
||||
|
||||
#[cfg(test)]
|
||||
mod tests {
|
||||
use super::*;
|
||||
|
||||
#[test]
|
||||
fn browser_auto_is_distinct_from_system_default() {
|
||||
assert!(matches!(Browser::from_str("auto"), Browser::Auto));
|
||||
assert!(matches!(Browser::from_str("default"), Browser::Default));
|
||||
}
|
||||
}
|
||||
@@ -19,10 +19,11 @@ pub async fn auth_prelogin(
|
||||
server: &str,
|
||||
gp_params: &GpParams,
|
||||
external_browser_requested: bool,
|
||||
gateway_external_browser_allowed: bool,
|
||||
) -> anyhow::Result<String> {
|
||||
// gpauth only performs the initial portal/gateway prelogin. Portal policy is
|
||||
// not available here, so gateway prelogin stays on the embedded value.
|
||||
let options = PreloginOptions::default().external_browser_requested(external_browser_requested);
|
||||
let options = PreloginOptions::default()
|
||||
.external_browser_requested(external_browser_requested)
|
||||
.gateway_external_browser_allowed(gateway_external_browser_allowed);
|
||||
match prelogin(server, gp_params, options).await? {
|
||||
Prelogin::Saml(prelogin) => Ok(prelogin.saml_request().to_string()),
|
||||
Prelogin::Standard(_) => bail!("Received non-SAML prelogin response"),
|
||||
|
||||
@@ -184,7 +184,7 @@ impl<'a> WebviewAuthenticator<'a> {
|
||||
|
||||
let auth_request = match self.auth_request {
|
||||
Some(auth_request) => auth_request.to_string(),
|
||||
None => auth_prelogin(&self.server, &self.gp_params, false).await?,
|
||||
None => auth_prelogin(&self.server, &self.gp_params, false, false).await?,
|
||||
};
|
||||
|
||||
let (tx, rx) = oneshot::channel::<anyhow::Result<()>>();
|
||||
@@ -257,7 +257,7 @@ impl<'a> WebviewAuthenticator<'a> {
|
||||
document.body.appendChild(loading);
|
||||
"#)?;
|
||||
|
||||
let auth_request = auth_prelogin(&self.server, &self.gp_params, false).await?;
|
||||
let auth_request = auth_prelogin(&self.server, &self.gp_params, false, false).await?;
|
||||
|
||||
let (tx, rx) = oneshot::channel::<anyhow::Result<()>>();
|
||||
let webview_user_agent = self.webview_user_agent.clone();
|
||||
|
||||
@@ -0,0 +1,58 @@
|
||||
use std::{
|
||||
env,
|
||||
path::{Path, PathBuf},
|
||||
};
|
||||
|
||||
use crate::constants::{GP_AUTH_BINARY, GP_CLIENT_BINARY, GP_GUI_BINARY, GP_GUI_HELPER_BINARY, GP_SERVICE_BINARY};
|
||||
|
||||
pub fn gpclient() -> PathBuf {
|
||||
resolve("GP_CLIENT_BINARY", "gpclient", GP_CLIENT_BINARY)
|
||||
}
|
||||
|
||||
pub fn gpservice() -> PathBuf {
|
||||
resolve("GP_SERVICE_BINARY", "gpservice", GP_SERVICE_BINARY)
|
||||
}
|
||||
|
||||
pub fn gpauth() -> PathBuf {
|
||||
resolve("GP_AUTH_BINARY", "gpauth", GP_AUTH_BINARY)
|
||||
}
|
||||
|
||||
pub fn gpgui() -> PathBuf {
|
||||
resolve("GP_GUI_BINARY", "gpgui", GP_GUI_BINARY)
|
||||
}
|
||||
|
||||
pub fn gpgui_helper() -> PathBuf {
|
||||
resolve("GP_GUI_HELPER_BINARY", "gpgui-helper", GP_GUI_HELPER_BINARY)
|
||||
}
|
||||
|
||||
fn resolve(env_key: &str, binary_name: &str, default_path: &str) -> PathBuf {
|
||||
env::var_os(env_key)
|
||||
.filter(|value| !value.is_empty())
|
||||
.map(PathBuf::from)
|
||||
.or_else(|| sibling_binary(binary_name))
|
||||
.unwrap_or_else(|| PathBuf::from(default_path))
|
||||
}
|
||||
|
||||
fn sibling_binary(binary_name: &str) -> Option<PathBuf> {
|
||||
let current_exe = env::current_exe().ok()?;
|
||||
let bin_dir = current_exe.parent()?;
|
||||
let binary = bin_dir.join(binary_name);
|
||||
|
||||
is_file(&binary).then_some(binary)
|
||||
}
|
||||
|
||||
fn is_file(path: &Path) -> bool {
|
||||
path.is_file()
|
||||
}
|
||||
|
||||
#[cfg(test)]
|
||||
mod tests {
|
||||
use super::*;
|
||||
|
||||
#[test]
|
||||
fn default_path_is_used_when_no_sibling_exists() {
|
||||
let path = resolve("GP_TEST_BINARY", "missing-gp-test-binary", "/usr/bin/gp-test");
|
||||
|
||||
assert_eq!(path, PathBuf::from("/usr/bin/gp-test"));
|
||||
}
|
||||
}
|
||||
@@ -1 +1,2 @@
|
||||
pub mod binary_paths;
|
||||
pub mod constants;
|
||||
@@ -39,7 +39,7 @@ pub(crate) fn build(input: &GatewayLoginInput) -> RequestParams {
|
||||
input.gp_params.input_str().unwrap_or_default().into(),
|
||||
));
|
||||
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() {
|
||||
body.push(("os-version".into(), os_version.into()));
|
||||
@@ -99,6 +99,15 @@ pub(crate) fn build(input: &GatewayLoginInput) -> RequestParams {
|
||||
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.
|
||||
///
|
||||
/// Falls back to the original gateway host if resolution fails.
|
||||
@@ -153,6 +162,40 @@ mod tests {
|
||||
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]
|
||||
fn build_without_context_includes_identity_fields() {
|
||||
let profile = test_profile(ClientOs::Linux);
|
||||
|
||||
@@ -90,7 +90,7 @@ impl Prelogin {
|
||||
#[derive(Debug, Clone, Copy, Default)]
|
||||
pub struct PreloginOptions {
|
||||
external_browser_requested: bool,
|
||||
portal_default_browser_enabled: bool,
|
||||
gateway_external_browser_allowed: bool,
|
||||
}
|
||||
|
||||
impl PreloginOptions {
|
||||
@@ -99,13 +99,13 @@ impl PreloginOptions {
|
||||
self
|
||||
}
|
||||
|
||||
pub fn portal_default_browser_enabled(mut self, portal_default_browser_enabled: bool) -> Self {
|
||||
self.portal_default_browser_enabled = portal_default_browser_enabled;
|
||||
pub fn gateway_external_browser_allowed(mut self, gateway_external_browser_allowed: bool) -> Self {
|
||||
self.gateway_external_browser_allowed = gateway_external_browser_allowed;
|
||||
self
|
||||
}
|
||||
|
||||
fn browser_mode(self, is_gateway: bool) -> PreloginBrowserMode {
|
||||
if self.external_browser_requested && (!is_gateway || self.portal_default_browser_enabled) {
|
||||
if self.external_browser_requested && (!is_gateway || self.gateway_external_browser_allowed) {
|
||||
PreloginBrowserMode::External
|
||||
} else {
|
||||
PreloginBrowserMode::Embedded
|
||||
@@ -307,12 +307,12 @@ mod tests {
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn browser_mode_requires_portal_policy_for_gateway_external() {
|
||||
fn browser_mode_requires_gateway_external_browser_allowed_for_gateway_external() {
|
||||
let options = PreloginOptions::default().external_browser_requested(true);
|
||||
|
||||
assert_eq!(options.browser_mode(true), PreloginBrowserMode::Embedded);
|
||||
|
||||
let options = options.portal_default_browser_enabled(true);
|
||||
let options = options.gateway_external_browser_allowed(true);
|
||||
|
||||
assert_eq!(options.browser_mode(true), PreloginBrowserMode::External);
|
||||
}
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
use std::process::Stdio;
|
||||
use std::{path::PathBuf, process::Stdio};
|
||||
|
||||
use anyhow::bail;
|
||||
use common::constants::GP_AUTH_BINARY;
|
||||
use common::binary_paths;
|
||||
use tokio::process::Command;
|
||||
|
||||
use crate::{auth::SamlAuthResult, credential::Credential, os_profile::OsProfile};
|
||||
@@ -16,6 +16,9 @@ pub struct SamlAuthLauncher<'a> {
|
||||
os: Option<&'a str>,
|
||||
host_id: Option<&'a str>,
|
||||
client_version: Option<&'a str>,
|
||||
certificate: Option<&'a str>,
|
||||
sslkey: Option<&'a str>,
|
||||
key_password: Option<&'a str>,
|
||||
fix_openssl: bool,
|
||||
ignore_tls_errors: bool,
|
||||
#[cfg(feature = "webview-auth")]
|
||||
@@ -38,6 +41,9 @@ impl<'a> SamlAuthLauncher<'a> {
|
||||
os: None,
|
||||
host_id: None,
|
||||
client_version: None,
|
||||
certificate: None,
|
||||
sslkey: None,
|
||||
key_password: None,
|
||||
fix_openssl: false,
|
||||
ignore_tls_errors: false,
|
||||
#[cfg(feature = "webview-auth")]
|
||||
@@ -83,6 +89,21 @@ impl<'a> SamlAuthLauncher<'a> {
|
||||
self
|
||||
}
|
||||
|
||||
pub fn certificate(mut self, certificate: Option<&'a str>) -> Self {
|
||||
self.certificate = certificate;
|
||||
self
|
||||
}
|
||||
|
||||
pub fn sslkey(mut self, sslkey: Option<&'a str>) -> Self {
|
||||
self.sslkey = sslkey;
|
||||
self
|
||||
}
|
||||
|
||||
pub fn key_password(mut self, key_password: Option<&'a str>) -> Self {
|
||||
self.key_password = key_password;
|
||||
self
|
||||
}
|
||||
|
||||
#[cfg(feature = "webview-auth")]
|
||||
pub fn hidpi(mut self, hidpi: bool) -> Self {
|
||||
self.hidpi = hidpi;
|
||||
@@ -113,8 +134,11 @@ impl<'a> SamlAuthLauncher<'a> {
|
||||
|
||||
/// Launch the authenticator binary as the current user or SUDO_USER if available.
|
||||
pub async fn launch(self) -> anyhow::Result<Credential> {
|
||||
let program = self.auth_executable.unwrap_or(GP_AUTH_BINARY);
|
||||
let mut auth_cmd = Command::new(program);
|
||||
let program = self
|
||||
.auth_executable
|
||||
.map(PathBuf::from)
|
||||
.unwrap_or_else(binary_paths::gpauth);
|
||||
let mut auth_cmd = Command::new(&program);
|
||||
auth_cmd.arg(self.server);
|
||||
|
||||
if self.gateway {
|
||||
@@ -145,6 +169,18 @@ impl<'a> SamlAuthLauncher<'a> {
|
||||
auth_cmd.arg("--ignore-tls-errors");
|
||||
}
|
||||
|
||||
if let Some(certificate) = self.certificate {
|
||||
auth_cmd.arg("--certificate").arg(certificate);
|
||||
}
|
||||
|
||||
if let Some(sslkey) = self.sslkey {
|
||||
auth_cmd.arg("--sslkey").arg(sslkey);
|
||||
}
|
||||
|
||||
if let Some(key_password) = self.key_password {
|
||||
auth_cmd.arg("--key-password").arg(key_password);
|
||||
}
|
||||
|
||||
#[cfg(feature = "webview-auth")]
|
||||
{
|
||||
if self.hidpi {
|
||||
@@ -174,7 +210,7 @@ impl<'a> SamlAuthLauncher<'a> {
|
||||
let child = match child {
|
||||
Ok(child) => child,
|
||||
Err(err) => {
|
||||
bail!("Failed to spawn {}: {}", program, err);
|
||||
bail!("Failed to spawn {}: {}", program.display(), err);
|
||||
}
|
||||
};
|
||||
|
||||
@@ -219,4 +255,16 @@ mod tests {
|
||||
|
||||
assert_eq!(launcher.client_version, Some("6.0.0"));
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn client_certificate_options_are_stored() {
|
||||
let launcher = SamlAuthLauncher::new("portal.example.com")
|
||||
.certificate(Some("/tmp/client.pem"))
|
||||
.sslkey(Some("/tmp/client.key"))
|
||||
.key_password(Some("secret"));
|
||||
|
||||
assert_eq!(launcher.certificate, Some("/tmp/client.pem"));
|
||||
assert_eq!(launcher.sslkey, Some("/tmp/client.key"));
|
||||
assert_eq!(launcher.key_password, Some("secret"));
|
||||
}
|
||||
}
|
||||
@@ -33,41 +33,28 @@ mod platform {
|
||||
let session_env = collect(user_id);
|
||||
|
||||
for key in DESKTOP_SESSION_ENV {
|
||||
if let Some(value) = env_value(key).or_else(|| session_env.get(*key).cloned()) {
|
||||
if let Some(value) = desktop_env_value(&session_env, key) {
|
||||
command.env(key, value);
|
||||
}
|
||||
}
|
||||
|
||||
let runtime_dir = env_value("XDG_RUNTIME_DIR")
|
||||
.or_else(|| session_env.get("XDG_RUNTIME_DIR").cloned())
|
||||
.unwrap_or_else(|| format!("/run/user/{user_id}"));
|
||||
let runtime_dir =
|
||||
desktop_env_value(&session_env, "XDG_RUNTIME_DIR").unwrap_or_else(|| format!("/run/user/{user_id}"));
|
||||
command.env("XDG_RUNTIME_DIR", &runtime_dir);
|
||||
|
||||
if env_value("DBUS_SESSION_BUS_ADDRESS")
|
||||
.or_else(|| session_env.get("DBUS_SESSION_BUS_ADDRESS").cloned())
|
||||
.is_none()
|
||||
{
|
||||
if desktop_env_value(&session_env, "DBUS_SESSION_BUS_ADDRESS").is_none() {
|
||||
command.env("DBUS_SESSION_BUS_ADDRESS", format!("unix:path={runtime_dir}/bus"));
|
||||
}
|
||||
|
||||
if env_value("XDG_DATA_HOME")
|
||||
.or_else(|| session_env.get("XDG_DATA_HOME").cloned())
|
||||
.is_none()
|
||||
{
|
||||
if desktop_env_value(&session_env, "XDG_DATA_HOME").is_none() {
|
||||
command.env("XDG_DATA_HOME", home_dir.join(".local/share"));
|
||||
}
|
||||
|
||||
if env_value("XDG_CONFIG_HOME")
|
||||
.or_else(|| session_env.get("XDG_CONFIG_HOME").cloned())
|
||||
.is_none()
|
||||
{
|
||||
if desktop_env_value(&session_env, "XDG_CONFIG_HOME").is_none() {
|
||||
command.env("XDG_CONFIG_HOME", home_dir.join(".config"));
|
||||
}
|
||||
|
||||
if env_value("XDG_DATA_DIRS")
|
||||
.or_else(|| session_env.get("XDG_DATA_DIRS").cloned())
|
||||
.is_none()
|
||||
{
|
||||
if desktop_env_value(&session_env, "XDG_DATA_DIRS").is_none() {
|
||||
command.env("XDG_DATA_DIRS", default_xdg_data_dirs());
|
||||
}
|
||||
}
|
||||
@@ -160,6 +147,10 @@ mod platform {
|
||||
non_empty(env::var(key).ok())
|
||||
}
|
||||
|
||||
fn desktop_env_value(session_env: &HashMap<String, String>, key: &str) -> Option<String> {
|
||||
session_env.get(key).cloned().or_else(|| env_value(key))
|
||||
}
|
||||
|
||||
fn non_empty(value: Option<String>) -> Option<String> {
|
||||
value.filter(|value| !value.trim().is_empty())
|
||||
}
|
||||
@@ -203,6 +194,16 @@ mod platform {
|
||||
assert_eq!(non_empty(Some(" ".to_string())), None);
|
||||
assert_eq!(non_empty(Some("value".to_string())), Some("value".to_string()));
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn desktop_env_value_prefers_collected_user_session() {
|
||||
let env = HashMap::from([("XDG_DATA_DIRS".to_string(), "/run/current-system/sw/share".to_string())]);
|
||||
|
||||
assert_eq!(
|
||||
desktop_env_value(&env, "XDG_DATA_DIRS"),
|
||||
Some("/run/current-system/sw/share".to_string())
|
||||
);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
use std::{collections::HashMap, path::PathBuf, process::Stdio};
|
||||
|
||||
use anyhow::bail;
|
||||
use common::constants::GP_GUI_HELPER_BINARY;
|
||||
use common::binary_paths;
|
||||
use log::info;
|
||||
use tokio::{io::AsyncWriteExt, process::Command};
|
||||
|
||||
@@ -17,7 +17,7 @@ pub struct GuiHelperLauncher<'a> {
|
||||
impl<'a> GuiHelperLauncher<'a> {
|
||||
pub fn new(api_key: &'a [u8]) -> Self {
|
||||
Self {
|
||||
program: GP_GUI_HELPER_BINARY.into(),
|
||||
program: binary_paths::gpgui_helper(),
|
||||
envs: None,
|
||||
api_key,
|
||||
gui_version: None,
|
||||
|
||||
@@ -5,7 +5,7 @@ use std::{
|
||||
};
|
||||
|
||||
use anyhow::bail;
|
||||
use common::constants::GP_GUI_BINARY;
|
||||
use common::binary_paths;
|
||||
use log::info;
|
||||
use tokio::{io::AsyncWriteExt, process::Command};
|
||||
|
||||
@@ -25,7 +25,7 @@ impl<'a> GuiLauncher<'a> {
|
||||
pub fn new(version: &'a str, api_key: &'a [u8]) -> Self {
|
||||
Self {
|
||||
version,
|
||||
program: GP_GUI_BINARY.into(),
|
||||
program: binary_paths::gpgui(),
|
||||
api_key,
|
||||
minimized: false,
|
||||
envs: None,
|
||||
|
||||
@@ -4,7 +4,7 @@ use std::{
|
||||
process::{ExitStatus, Stdio},
|
||||
};
|
||||
|
||||
use common::constants::GP_SERVICE_BINARY;
|
||||
use common::binary_paths;
|
||||
use tokio::process::Command;
|
||||
|
||||
use super::command_traits::CommandExt;
|
||||
@@ -26,7 +26,7 @@ impl Default for ServiceLauncher<'_> {
|
||||
impl<'a> ServiceLauncher<'a> {
|
||||
pub fn new() -> Self {
|
||||
Self {
|
||||
program: GP_SERVICE_BINARY.into(),
|
||||
program: binary_paths::gpservice(),
|
||||
minimized: false,
|
||||
env_file: None,
|
||||
log_file: None,
|
||||
|
||||
@@ -41,7 +41,7 @@ index 03f47004..9e585119 100644
|
||||
@@ -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)
|
||||
+{
|
||||
@@ -68,19 +68,19 @@ index a7e80659..76034fbd 100644
|
||||
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
|
||||
@@ -93,9 +93,9 @@ index 40de2811..3c65c090 100644
|
||||
+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)
|
||||
@@ -35,7 +35,7 @@ static void print_progress(__attribute__((unused)) void *_vpninfo, int level,
|
||||
if (message == NULL) {
|
||||
ERROR("Failed to format log message");
|
||||
} else {
|
||||
LOG(level, message);
|
||||
vpn_log(level, message);
|
||||
free(message);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -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
|
||||
```
|
||||
@@ -21,10 +21,12 @@
|
||||
inherit system;
|
||||
overlays = [ (import rust-overlay) ];
|
||||
};
|
||||
inherit (pkgs) lib;
|
||||
|
||||
cargoToml = builtins.fromTOML (builtins.readFile ./Cargo.toml);
|
||||
pname = "globalprotect-openconnect";
|
||||
version = cargoToml.workspace.package.version;
|
||||
releaseTag = "v2.6.5";
|
||||
|
||||
toolchain = pkgs.rust-bin.fromRustupToolchainFile ./rust-toolchain.toml;
|
||||
|
||||
@@ -34,47 +36,111 @@
|
||||
};
|
||||
|
||||
src = pkgs.fetchzip {
|
||||
url = "https://github.com/yuezk/GlobalProtect-openconnect/releases/download/v${version}/globalprotect-openconnect-${version}.tar.gz";
|
||||
hash = "sha256-NS3tIZxkT9A4eqmfkcl29bHHJrrgVs/XSQBOz99cP30=";
|
||||
url = "https://github.com/yuezk/GlobalProtect-openconnect/releases/download/${releaseTag}/globalprotect-openconnect-${version}.tar.gz";
|
||||
hash = "sha256-cp7KRUwVJsyg8m7O70k/uo6WwLqCPbFCnWtXzHn1GgU=";
|
||||
};
|
||||
|
||||
cpu = pkgs.stdenv.hostPlatform.parsed.cpu.name;
|
||||
|
||||
gpgui = pkgs.fetchzip {
|
||||
url = "https://github.com/yuezk/GlobalProtect-openconnect/releases/download/v${version}/gpgui_${cpu}.bin.tar.xz";
|
||||
hash = {
|
||||
x86_64 = "sha256-1XBdrKJOhSViZOgfqohZjdzV6qzx/qpy0yhkbZ8DumA=";
|
||||
aarch64 = "sha256-humujgf/M31SkBABc14g/ujjacGHxqElzNuCClhTAfA=";
|
||||
}.${cpu};
|
||||
gpguiHashes = {
|
||||
x86_64 = "sha256-7va5dBhmamOqJYbsHUtjWYFnoM8q5ZshB2CyK0NW6fE=";
|
||||
aarch64 = "sha256-uBzBKx39te5R4PloDusjSjUf1Y2iF/xO4dXUX2K4P8o=";
|
||||
};
|
||||
in
|
||||
{
|
||||
# For `nix build`
|
||||
packages.default = naersk'.buildPackage {
|
||||
|
||||
gpgui = pkgs.fetchzip {
|
||||
url = "https://github.com/yuezk/GlobalProtect-openconnect/releases/download/${releaseTag}/gpgui_${cpu}.bin.tar.xz";
|
||||
hash = gpguiHashes.${cpu};
|
||||
};
|
||||
|
||||
binaryHashes = {
|
||||
x86_64 = "sha256-AqF+mwxmXxF/dFxmMXbtT2PONVArKKfMpwmX+3cYr5o=";
|
||||
aarch64 = "sha256-Ul77xppKrrQQDRl/zKjrrj2+8CRjrMagJbLqmDlfz9U=";
|
||||
};
|
||||
|
||||
binaryPackage = pkgs.fetchzip {
|
||||
url = "https://github.com/yuezk/GlobalProtect-openconnect/releases/download/${releaseTag}/globalprotect-openconnect_${version}_${cpu}.bin.tar.xz";
|
||||
hash = binaryHashes.${cpu};
|
||||
};
|
||||
|
||||
linuxRuntimeDependencies = with pkgs; [
|
||||
glib-networking
|
||||
libayatana-appindicator
|
||||
];
|
||||
|
||||
linuxBuildInputs =
|
||||
with pkgs;
|
||||
[
|
||||
libxml2
|
||||
zlib
|
||||
lz4
|
||||
gnutls
|
||||
p11-kit
|
||||
nettle
|
||||
gmp
|
||||
]
|
||||
++ lib.optionals stdenv.isLinux [
|
||||
glib
|
||||
gtk3
|
||||
libsoup_3
|
||||
webkitgtk_4_1
|
||||
glib-networking
|
||||
openssl
|
||||
libsecret
|
||||
libayatana-appindicator
|
||||
];
|
||||
|
||||
rewriteSourceInstallPaths = ''
|
||||
substituteInPlace $out/share/applications/gpgui.desktop \
|
||||
--replace-fail /usr/bin/gpclient /run/current-system/sw/bin/gpclient
|
||||
|
||||
substituteInPlace $out/libexec/gpclient/hipreport.sh \
|
||||
--replace-fail /usr/bin/gpclient $out/bin/gpclient
|
||||
|
||||
substituteInPlace $out/share/polkit-1/actions/com.yuezk.gpgui.policy \
|
||||
--replace-fail /usr/bin/gpservice $out/bin/gpservice
|
||||
|
||||
if [ -f $out/lib/NetworkManager/dispatcher.d/pre-down.d/gpclient.down ]; then
|
||||
substituteInPlace $out/lib/NetworkManager/dispatcher.d/pre-down.d/gpclient.down \
|
||||
--replace-fail /usr/bin/gpclient $out/bin/gpclient
|
||||
fi
|
||||
'';
|
||||
|
||||
rewriteHostInstallPaths = ''
|
||||
substituteInPlace $out/share/applications/gpgui.desktop \
|
||||
--replace-fail /usr/bin/gpclient /run/current-system/sw/bin/gpclient
|
||||
|
||||
substituteInPlace $out/share/polkit-1/actions/com.yuezk.gpgui.policy \
|
||||
--replace-fail /usr/bin/gpservice $out/bin/gpservice
|
||||
|
||||
if [ -f $out/lib/NetworkManager/dispatcher.d/pre-down.d/gpclient.down ]; then
|
||||
substituteInPlace $out/lib/NetworkManager/dispatcher.d/pre-down.d/gpclient.down \
|
||||
--replace-fail /usr/bin/gpclient $out/bin/gpclient
|
||||
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 {
|
||||
inherit pname version src;
|
||||
|
||||
# Must be set to true to avoid issues with the Tauri build process
|
||||
singleStep = true;
|
||||
|
||||
buildInputs =
|
||||
with pkgs;
|
||||
[
|
||||
libxml2
|
||||
zlib
|
||||
lz4
|
||||
gnutls
|
||||
p11-kit
|
||||
nettle
|
||||
gmp
|
||||
]
|
||||
++ lib.optionals stdenv.isLinux [
|
||||
glib
|
||||
gtk3
|
||||
libsoup_3
|
||||
webkitgtk_4_1
|
||||
glib-networking
|
||||
openssl
|
||||
];
|
||||
buildInputs = linuxBuildInputs;
|
||||
|
||||
nativeBuildInputs =
|
||||
with pkgs;
|
||||
@@ -89,13 +155,7 @@
|
||||
wrapGAppsHook4
|
||||
];
|
||||
|
||||
runtimeDependencies =
|
||||
with pkgs;
|
||||
[ ]
|
||||
++ lib.optionals stdenv.isLinux [
|
||||
libappindicator-gtk3
|
||||
glib-networking
|
||||
];
|
||||
runtimeDependencies = lib.optionals pkgs.stdenv.isLinux linuxRuntimeDependencies;
|
||||
|
||||
overrideMain =
|
||||
{ ... }:
|
||||
@@ -124,23 +184,192 @@
|
||||
cp -r packaging/files/usr/lib $out/lib
|
||||
cp -r packaging/files/usr/libexec $out/libexec
|
||||
|
||||
# Change the `/usr/bin/gpclient` path in the desktop file
|
||||
substituteInPlace $out/share/applications/gpgui.desktop \
|
||||
--replace-fail /usr/bin/gpclient $out/bin/gpclient
|
||||
|
||||
substituteInPlace $out/lib/NetworkManager/dispatcher.d/pre-down.d/gpclient.down \
|
||||
--replace-fail /usr/bin/gpclient $out/bin/gpclient
|
||||
|
||||
substituteInPlace $out/libexec/gpclient/hipreport.sh \
|
||||
--replace-fail /usr/bin/gpclient $out/bin/gpclient
|
||||
|
||||
# Change the `/usr/bin/gpservice` path in the polkit policy file
|
||||
substituteInPlace $out/share/polkit-1/actions/com.yuezk.gpgui.policy \
|
||||
--replace-fail /usr/bin/gpservice $out/bin/gpservice
|
||||
|
||||
${rewriteSourceInstallPaths}
|
||||
${installNixosPolkitRule}
|
||||
'';
|
||||
};
|
||||
|
||||
prebuiltFiles = pkgs.stdenv.mkDerivation {
|
||||
inherit pname version;
|
||||
|
||||
src = binaryPackage;
|
||||
dontBuild = true;
|
||||
|
||||
nativeBuildInputs = with pkgs; [
|
||||
autoPatchelfHook
|
||||
wrapGAppsHook4
|
||||
];
|
||||
|
||||
buildInputs = linuxBuildInputs;
|
||||
runtimeDependencies = linuxRuntimeDependencies;
|
||||
|
||||
installPhase = ''
|
||||
runHook preInstall
|
||||
|
||||
mkdir -p $out
|
||||
cp -r artifacts/usr/bin $out/bin
|
||||
cp -r artifacts/usr/libexec $out/libexec
|
||||
cp -r artifacts/usr/share $out/share
|
||||
|
||||
if [ -d artifacts/usr/lib ]; then
|
||||
cp -r artifacts/usr/lib $out/lib
|
||||
fi
|
||||
|
||||
install -Dm755 ${gpgui}/gpgui $out/bin/gpgui
|
||||
|
||||
runHook postInstall
|
||||
'';
|
||||
};
|
||||
|
||||
prebuiltCommand =
|
||||
binaryName:
|
||||
pkgs.buildFHSEnv {
|
||||
name = binaryName;
|
||||
targetPkgs =
|
||||
pkgs:
|
||||
[ prebuiltFiles ]
|
||||
++ linuxBuildInputs
|
||||
++ linuxRuntimeDependencies;
|
||||
runScript = "/usr/bin/${binaryName}";
|
||||
profile = ''
|
||||
export PATH=/run/wrappers/bin:$PATH
|
||||
'';
|
||||
extraBwrapArgs = [
|
||||
"--bind-try"
|
||||
"/run/wrappers"
|
||||
"/run/wrappers"
|
||||
"--ro-bind-try"
|
||||
"/etc/gpgui"
|
||||
"/etc/gpgui"
|
||||
];
|
||||
};
|
||||
|
||||
prebuiltCommands = {
|
||||
gpclient = prebuiltCommand "gpclient";
|
||||
gpservice = prebuiltCommand "gpservice";
|
||||
gpauth = prebuiltCommand "gpauth";
|
||||
gpgui = prebuiltCommand "gpgui";
|
||||
gpgui-helper = prebuiltCommand "gpgui-helper";
|
||||
};
|
||||
|
||||
prebuilt = pkgs.stdenv.mkDerivation {
|
||||
inherit pname version;
|
||||
|
||||
dontUnpack = true;
|
||||
|
||||
installPhase = ''
|
||||
runHook preInstall
|
||||
|
||||
mkdir -p $out/bin
|
||||
cat > $out/bin/gpclient <<'EOF'
|
||||
#!${pkgs.runtimeShell}
|
||||
set -eu
|
||||
|
||||
gpclient_fhs='${prebuiltCommands.gpclient}/bin/gpclient'
|
||||
gpservice_public='@gpservice_public@'
|
||||
|
||||
if [ "''${1:-}" = "launch-gui" ]; then
|
||||
shift
|
||||
|
||||
auth_data=
|
||||
minimized=
|
||||
for arg in "$@"; do
|
||||
case "$arg" in
|
||||
--minimized)
|
||||
minimized=--minimized
|
||||
;;
|
||||
--*)
|
||||
;;
|
||||
*)
|
||||
auth_data=$arg
|
||||
;;
|
||||
esac
|
||||
done
|
||||
|
||||
if [ -z "$auth_data" ]; then
|
||||
if [ -n "''${XDG_DATA_HOME:-}" ]; then
|
||||
data_home=$XDG_DATA_HOME
|
||||
elif [ -n "''${HOME:-}" ]; then
|
||||
data_home=$HOME/.local/share
|
||||
else
|
||||
data_home=/tmp
|
||||
fi
|
||||
|
||||
log_dir="$data_home/gpclient"
|
||||
mkdir -p "$log_dir"
|
||||
log_file="$log_dir/gpclient.log"
|
||||
env_file=$(mktemp)
|
||||
|
||||
env > "$env_file"
|
||||
printf 'GP_LOG_FILE=%s\n' "$log_file" >> "$env_file"
|
||||
|
||||
pkexec_bin=/run/wrappers/bin/pkexec
|
||||
if [ ! -x "$pkexec_bin" ]; then
|
||||
pkexec_bin=pkexec
|
||||
fi
|
||||
|
||||
set +e
|
||||
if [ -n "$minimized" ]; then
|
||||
"$pkexec_bin" --user root "$gpservice_public" --minimized --env-file "$env_file" 2>"$log_file"
|
||||
else
|
||||
"$pkexec_bin" --user root "$gpservice_public" --env-file "$env_file" 2>"$log_file"
|
||||
fi
|
||||
status=$?
|
||||
set -e
|
||||
rm -f "$env_file"
|
||||
exit "$status"
|
||||
fi
|
||||
|
||||
set -- launch-gui "$@"
|
||||
fi
|
||||
|
||||
exec "$gpclient_fhs" "$@"
|
||||
EOF
|
||||
substituteInPlace $out/bin/gpclient \
|
||||
--replace-fail '@gpservice_public@' "$out/bin/gpservice"
|
||||
chmod +x $out/bin/gpclient
|
||||
|
||||
cat > $out/bin/gpservice <<'EOF'
|
||||
#!${pkgs.runtimeShell}
|
||||
set -eu
|
||||
exec '@gpservice_fhs@' "$@"
|
||||
EOF
|
||||
substituteInPlace $out/bin/gpservice \
|
||||
--replace-fail '@gpservice_fhs@' '${prebuiltCommands.gpservice}/bin/gpservice'
|
||||
chmod +x $out/bin/gpservice
|
||||
|
||||
ln -s ${prebuiltCommands.gpauth}/bin/gpauth $out/bin/gpauth
|
||||
ln -s ${prebuiltCommands.gpgui}/bin/gpgui $out/bin/gpgui
|
||||
ln -s ${prebuiltCommands."gpgui-helper"}/bin/gpgui-helper $out/bin/gpgui-helper
|
||||
|
||||
cp -r ${prebuiltFiles}/libexec $out/libexec
|
||||
cp -r ${prebuiltFiles}/share $out/share
|
||||
|
||||
if [ -d ${prebuiltFiles}/lib ]; then
|
||||
cp -r ${prebuiltFiles}/lib $out/lib
|
||||
fi
|
||||
|
||||
${rewriteHostInstallPaths}
|
||||
${installNixosPolkitRule}
|
||||
|
||||
runHook postInstall
|
||||
'';
|
||||
};
|
||||
in
|
||||
{
|
||||
# For `nix build`
|
||||
packages =
|
||||
{
|
||||
fromSource = fromSource;
|
||||
}
|
||||
// lib.optionalAttrs pkgs.stdenv.isLinux {
|
||||
default = prebuilt;
|
||||
prebuilt = prebuilt;
|
||||
}
|
||||
// lib.optionalAttrs (!pkgs.stdenv.isLinux) {
|
||||
default = fromSource;
|
||||
};
|
||||
|
||||
apps.default = {
|
||||
type = "app";
|
||||
program = "${self.packages.${system}.default}/bin/gpclient";
|
||||
|
||||
@@ -23,7 +23,8 @@ Build-Depends: debhelper (>= 9),
|
||||
libayatana-appindicator3-1,
|
||||
gnome-keyring,
|
||||
libwebkit2gtk-4.1-dev,
|
||||
rust-@RUST_VERSION@-all
|
||||
cargo-@RUST_VERSION@,
|
||||
rustc-@RUST_VERSION@
|
||||
Homepage: https://github.com/yuezk/GlobalProtect-openconnect
|
||||
|
||||
Package: globalprotect-openconnect
|
||||
|
||||
@@ -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
|
||||
@@ -9,9 +9,6 @@ REPO="yuezk/GlobalProtect-openconnect"
|
||||
TAG=${1:-}
|
||||
|
||||
SCRIPT_DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" &> /dev/null && pwd )"
|
||||
PROJECT_DIR="$(dirname "$SCRIPT_DIR")"
|
||||
|
||||
RELEASE_NOTES="Release $TAG"
|
||||
|
||||
if [ -z "$TAG" ]; then
|
||||
echo "Usage: ./scripts/gh-release.sh <tag>"
|
||||
@@ -36,8 +33,6 @@ release_assets() {
|
||||
# For snapshot release, we don't create a release, just clear the existing assets and upload new ones.
|
||||
# This is to avoid notification spam.
|
||||
release_snapshot() {
|
||||
RELEASE_NOTES='**!!! DO NOT USE THIS RELEASE IN PRODUCTION !!!**'
|
||||
|
||||
while IFS= read -r asset; do
|
||||
if [ -n "$asset" ]; then
|
||||
gh -R "$REPO" release delete-asset "$TAG" "$asset" --yes
|
||||
@@ -55,11 +50,15 @@ release_tag() {
|
||||
gh -R "$REPO" release delete "$TAG" --yes --cleanup-tag || true
|
||||
|
||||
echo "Creating release..."
|
||||
local release_notes_file
|
||||
release_notes_file="$(mktemp)"
|
||||
"$SCRIPT_DIR/release-notes.sh" "$TAG" > "$release_notes_file"
|
||||
|
||||
# Upload source tarballs, GUI components, and BSD packages. Other Linux
|
||||
# packages are built in `release.yml` from the standalone source tarball.
|
||||
gh -R "$REPO" release create "$TAG" \
|
||||
--title "$TAG" \
|
||||
--notes "$RELEASE_NOTES"
|
||||
--notes-file "$release_notes_file"
|
||||
|
||||
mapfile -t files < <(release_assets)
|
||||
upload_files "${files[@]}"
|
||||
|
||||
Executable
+59
@@ -0,0 +1,59 @@
|
||||
#!/usr/bin/env bash
|
||||
|
||||
set -euo pipefail
|
||||
|
||||
release_version="${1:-}"
|
||||
release_tag="${2:-}"
|
||||
|
||||
if git diff --quiet -- flake.nix; then
|
||||
echo "flake.nix hashes are already up to date"
|
||||
exit 0
|
||||
fi
|
||||
|
||||
if [[ -z "$release_version" ]]; then
|
||||
release_version="$(grep '^version' Cargo.toml | head -1 | sed 's/version *= *"\(.*\)"/\1/')"
|
||||
fi
|
||||
|
||||
version="${release_version#v}"
|
||||
if [[ -z "$release_tag" ]]; then
|
||||
release_tag="v$version"
|
||||
fi
|
||||
|
||||
branch_suffix="v${version}"
|
||||
title="chore: update flake hashes for v${version}"
|
||||
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.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 add flake.nix
|
||||
git commit -m "$title"
|
||||
git push --force origin "$branch"
|
||||
|
||||
if gh pr view "$branch" --json number > /tmp/flake-pr.json 2> /dev/null; then
|
||||
pr_number="$(jq -r '.number' /tmp/flake-pr.json)"
|
||||
gh pr edit "$pr_number" --title "$title" --body "$body"
|
||||
else
|
||||
gh pr create --title "$title" --body "$body" --base main --head "$branch"
|
||||
fi
|
||||
Executable
+32
@@ -0,0 +1,32 @@
|
||||
#!/usr/bin/env bash
|
||||
|
||||
set -euo pipefail
|
||||
|
||||
tag="${1:-}"
|
||||
|
||||
if [[ -z "$tag" ]]; then
|
||||
echo "Usage: $0 <tag>" >&2
|
||||
exit 1
|
||||
fi
|
||||
|
||||
version="${tag#v}"
|
||||
script_dir="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
|
||||
changelog="$script_dir/../changelog.md"
|
||||
|
||||
awk -v version="$version" '
|
||||
$0 == "## " version {
|
||||
found = 1
|
||||
next
|
||||
}
|
||||
found && /^## / {
|
||||
exit
|
||||
}
|
||||
found {
|
||||
print
|
||||
}
|
||||
END {
|
||||
if (!found) {
|
||||
exit 1
|
||||
}
|
||||
}
|
||||
' "$changelog"
|
||||
@@ -9,10 +9,11 @@ PROJECT_DIR="$(dirname "$SCRIPT_DIR")"
|
||||
FLAKE_FILE="$PROJECT_DIR/flake.nix"
|
||||
|
||||
usage() {
|
||||
echo "Usage: $0 [version]"
|
||||
echo "Usage: $0 [version] [release-tag]"
|
||||
echo
|
||||
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 release-tag is omitted, v<version> is used. Use snapshot to test snapshot assets."
|
||||
}
|
||||
|
||||
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/')"
|
||||
fi
|
||||
version="${version#v}"
|
||||
release_tag="${2:-}"
|
||||
if [[ -z "$release_tag" ]]; then
|
||||
release_tag="v$version"
|
||||
fi
|
||||
|
||||
if [[ -z "$version" ]]; then
|
||||
echo "Could not determine release version" >&2
|
||||
exit 1
|
||||
fi
|
||||
|
||||
if [[ -z "$release_tag" ]]; then
|
||||
echo "Could not determine release tag" >&2
|
||||
exit 1
|
||||
fi
|
||||
|
||||
prefetch_hash() {
|
||||
local url="$1"
|
||||
local attempt
|
||||
@@ -67,24 +77,35 @@ prefetch_hash() {
|
||||
|
||||
release_url() {
|
||||
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")")"
|
||||
gpgui_x86_64_hash="$(prefetch_hash "$(release_url "gpgui_x86_64.bin.tar.xz")")"
|
||||
gpgui_aarch64_hash="$(prefetch_hash "$(release_url "gpgui_aarch64.bin.tar.xz")")"
|
||||
binary_x86_64_hash="$(prefetch_hash "$(release_url "globalprotect-openconnect_${version}_x86_64.bin.tar.xz")")"
|
||||
binary_aarch64_hash="$(prefetch_hash "$(release_url "globalprotect-openconnect_${version}_aarch64.bin.tar.xz")")"
|
||||
|
||||
SOURCE_HASH="$source_hash" \
|
||||
GPGUI_X86_64_HASH="$gpgui_x86_64_hash" \
|
||||
GPGUI_AARCH64_HASH="$gpgui_aarch64_hash" \
|
||||
BINARY_X86_64_HASH="$binary_x86_64_hash" \
|
||||
BINARY_AARCH64_HASH="$binary_aarch64_hash" \
|
||||
RELEASE_TAG="$release_tag" \
|
||||
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|(x86_64 = ")[^"]+(";)|$1 . $ENV{"GPGUI_X86_64_HASH"} . $2|e;
|
||||
s|(aarch64 = ")[^"]+(";)|$1 . $ENV{"GPGUI_AARCH64_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 = "[^"]+";\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 = "[^"]+";\n\s*aarch64 = ")[^"]+(";)|$1 . $ENV{"BINARY_AARCH64_HASH"} . $2|e;
|
||||
' "$FLAKE_FILE"
|
||||
|
||||
grep -F "$source_hash" "$FLAKE_FILE" > /dev/null
|
||||
grep -F "$gpgui_x86_64_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_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"
|
||||
Reference in new issue
Block a user