Compare commits

...
9 Commits
Author SHA1 Message Date
Kevin Yue 90faa58811 chore: prepare 3.0.3 release 2026-10-12 13:44:27 +08:00
Kevin Yue 93504eaec2 fix: improve authentication recovery and diagnostics
Recognize real GTK Wayland crash messages and keep remote
authentication prompts readable. Preserve device identifiers
without initializing OpenSSL, validate diagnostic executable
paths, and improve release automation.

Fixes #669
2026-10-12 13:37:15 +08:00
Ihar Hrachyshka d73b712dd3 chore: add make install-gpclient target (#672)
This is useful in build environments where gpclient is a separate
artifact from other binaries (this is the case in nixpkgs).
2026-10-12 10:53:37 +08:00
Finley Holt be111a671a fix(cli): let gpauth read the pasted callback with --browser remote (#671) 2026-10-12 10:36:38 +08:00
Ihar HrachyshkaandKevin Yue f9965f8a35 macOS: make openconnect relocatable; drive installation through make install (#668)
Co-authored-by: Kevin Yue <[email protected]>
2026-10-12 10:12:17 +08:00
Kevin Yue f7649898fd fix(ci): honor build-only for manually dispatched tag refs 2026-10-12 01:14:30 +08:00
github-actions[bot] e6910060df chore: update flake hashes for v3.0.2 (#667)
Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com>
2026-10-12 01:07:34 +08:00
Kevin Yue f41a429a5e Merge release 3.0.2 2026-10-12 00:28:04 +08:00
github-actions[bot] f0292a9292 chore: update flake hashes for v3.0.1 (#665)
Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com>
2026-10-11 00:44:28 +08:00
32 changed files with 890 additions and 225 deletions

No files matched your search

+2 -2
View File
@@ -786,7 +786,7 @@ jobs:
${{ matrix.workspace }}/gp/.build/${{ matrix.artifact_dir }}/artifacts/*
gh-release:
if: ${{ always() && ((github.event_name == 'workflow_dispatch' && !inputs.build_only) || startsWith(github.ref, 'refs/tags/')) }}
if: ${{ always() && ((github.event_name == 'workflow_dispatch' && !inputs.build_only) || (github.event_name == 'push' && startsWith(github.ref, 'refs/tags/'))) }}
runs-on: ubuntu-latest
permissions:
actions: read
@@ -942,7 +942,7 @@ jobs:
needs:
- test-gp
- build-docker-image
if: ${{ (github.event_name == 'workflow_dispatch' && !inputs.build_only) || startsWith(github.ref, 'refs/tags/') }}
if: ${{ (github.event_name == 'workflow_dispatch' && !inputs.build_only) || (github.event_name == 'push' && startsWith(github.ref, 'refs/tags/')) }}
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v6
+1
View File
@@ -185,6 +185,7 @@ jobs:
revision: ${{ inputs.revision }}
- name: Wait for Launchpad builds and public package indexes
if: ${{ inputs.verify_only }}
env:
TAG: ${{ inputs.tag }}
REVISION: ${{ inputs.revision }}
+22
View File
@@ -257,6 +257,8 @@ jobs:
- build
runs-on: ubuntu-latest
if: ${{ inputs.gh-release }}
outputs:
stable_version: ${{ steps.stable-release.outputs.version }}
permissions:
actions: read
contents: read
@@ -318,3 +320,23 @@ jobs:
else
gh-release/gp/scripts/upload-release-assets.sh "${{ inputs.tag }}" "${files[@]}"
fi
- name: Resolve stable release version
id: stable-release
env:
TAG: ${{ inputs.tag }}
run: |
if [[ "$TAG" =~ ^v([0-9]+\.[0-9]+\.[0-9]+)$ ]]; then
echo "version=${BASH_REMATCH[1]}" >> "$GITHUB_OUTPUT"
fi
update-flake-hashes:
needs: gh-release
if: ${{ inputs.release-binary && inputs.arch == 'all' && needs.gh-release.outputs.stable_version != '' }}
permissions:
contents: write
pull-requests: write
uses: ./.github/workflows/update-flake-hashes.yaml
with:
version: ${{ needs.gh-release.outputs.stable_version }}
release_tag: ${{ inputs.tag }}
@@ -1,6 +1,14 @@
name: Update flake hashes
on:
workflow_call:
inputs:
version:
required: true
type: string
release_tag:
required: true
type: string
workflow_dispatch:
inputs:
version:
Generated
+12 -10
View File
@@ -214,7 +214,7 @@ checksum = "1505bd5d3d116872e7271a6d4e16d81d0c8570876c8de68093a09ac269d8aac0"
[[package]]
name = "auth"
version = "3.0.2"
version = "3.0.3"
dependencies = [
"anyhow",
"block2",
@@ -423,7 +423,7 @@ dependencies = [
[[package]]
name = "browser-launcher"
version = "3.0.2"
version = "3.0.3"
dependencies = [
"anyhow",
"log",
@@ -719,7 +719,7 @@ dependencies = [
[[package]]
name = "common"
version = "3.0.2"
version = "3.0.3"
dependencies = [
"tempfile",
]
@@ -1831,7 +1831,7 @@ dependencies = [
[[package]]
name = "gpapi"
version = "3.0.2"
version = "3.0.3"
dependencies = [
"anyhow",
"base64 0.22.1",
@@ -1861,6 +1861,7 @@ dependencies = [
"serde",
"serde_json",
"serde_urlencoded",
"sha2",
"sha256",
"snow",
"socket2",
@@ -1882,7 +1883,7 @@ dependencies = [
[[package]]
name = "gpauth"
version = "3.0.2"
version = "3.0.3"
dependencies = [
"anyhow",
"auth",
@@ -1901,7 +1902,7 @@ dependencies = [
[[package]]
name = "gpclient"
version = "3.0.2"
version = "3.0.3"
dependencies = [
"anyhow",
"clap",
@@ -1927,7 +1928,7 @@ dependencies = [
[[package]]
name = "gpgui-helper"
version = "3.0.2"
version = "3.0.3"
dependencies = [
"anyhow",
"clap",
@@ -1948,7 +1949,7 @@ dependencies = [
[[package]]
name = "gphip"
version = "3.0.2"
version = "3.0.3"
dependencies = [
"anyhow",
"askama",
@@ -1965,7 +1966,7 @@ dependencies = [
[[package]]
name = "gpservice"
version = "3.0.2"
version = "3.0.3"
dependencies = [
"anyhow",
"axum",
@@ -3386,7 +3387,7 @@ dependencies = [
[[package]]
name = "openconnect"
version = "3.0.2"
version = "3.0.3"
dependencies = [
"autotools",
"cc",
@@ -3395,6 +3396,7 @@ dependencies = [
"libc",
"log",
"pkg-config",
"tempfile",
]
[[package]]
+1 -1
View File
@@ -11,7 +11,7 @@ members = [
[workspace.package]
rust-version = "1.91"
version = "3.0.2"
version = "3.0.3"
authors = ["Kevin Yue <[email protected]>"]
homepage = "https://github.com/yuezk/GlobalProtect-openconnect"
edition = "2024"
+114 -105
View File
@@ -3,6 +3,8 @@ SHELL := /bin/sh
INCLUDE_GUI ?= 0
CARGO ?= cargo
CARGO_TARGET_DIR ?= target
CARGO_RELEASE_DIR ?= $(CARGO_TARGET_DIR)/$(if $(CARGO_BUILD_TARGET),$(CARGO_BUILD_TARGET)/)release
DISABLE_RUST_TOOLCHAIN ?= 0
RUST_VERSION ?= 1.91
IGNORE_RUST_VERSION ?= 0
@@ -33,7 +35,14 @@ BUILD_GUI_HELPER ?= 1
# Indicates whether to build embedded webview auth support into gpauth
BUILD_WEBVIEW_AUTH ?= 1
ifeq ($(shell uname -s),Linux)
PREFIX ?= /usr
GPGUI_BINARY ?= $(wildcard .build/gpgui/gpgui_*/gpgui)
else ifeq ($(shell uname -s)-$(shell uname -m),Darwin-arm64)
PREFIX ?= /opt/homebrew
else
PREFIX ?= /usr/local
endif
BSD_FLAVOR ?= $(shell uname -s | tr '[:upper:]' '[:lower:]')
GPGUI_BINARY ?= ../gpgui/target/release/gpgui
@@ -139,86 +148,74 @@ clean:
rm -rf .vendor
rm -rf apps/gpgui-helper/node_modules
install:
@echo "Installing $(PKG_NAME)..."
ifeq ($(shell uname -s),Darwin)
install: install-macos
install-gpclient: install-gpclient-macos
else ifneq ($(filter FreeBSD OpenBSD,$(shell uname -s)),)
install: install-bsd
install-gpclient: install-gpclient-unix
else
install: install-linux
install-gpclient: install-gpclient-unix
endif
install -Dm755 target/release/gpclient $(DESTDIR)/usr/bin/gpclient
install -Dm755 target/release/gpauth $(DESTDIR)/usr/bin/gpauth
install -Dm755 target/release/gpservice $(DESTDIR)/usr/bin/gpservice
install -Dm755 target/release/gp-hip-script-installer $(DESTDIR)/usr/libexec/gpclient/gp-hip-script-installer
install -Dm755 target/release/gp-vpnc-script-installer $(DESTDIR)/usr/libexec/gpclient/gp-vpnc-script-installer
install-gpclient-unix:
install -d "$(DESTDIR)$(PREFIX)/bin" "$(DESTDIR)$(PREFIX)/libexec/gpclient"
install -m 755 "$(CARGO_RELEASE_DIR)/gpclient" "$(DESTDIR)$(PREFIX)/bin/"
install -m 755 packaging/files/usr/libexec/gpclient/vpnc-script "$(DESTDIR)$(PREFIX)/libexec/gpclient/"
# Install the GUI components if BUILD_GUI_HELPER is set to 1
if [ $(BUILD_GUI_HELPER) -eq 1 ]; then \
install -Dm755 target/release/gpgui-helper $(DESTDIR)/usr/bin/gpgui-helper; \
install-gpclient-macos:
install -d "$(DESTDIR)$(PREFIX)/bin" "$(DESTDIR)$(PREFIX)/lib/gpclient" "$(DESTDIR)$(PREFIX)/libexec/gpclient"
install -m 755 "$(CARGO_RELEASE_DIR)/gpclient" "$(DESTDIR)$(PREFIX)/bin/"
set -e; library=$$(sh scripts/macos-openconnect-library.sh "$(CARGO_RELEASE_DIR)/gpclient"); \
install -m 755 "$$library" "$(DESTDIR)$(PREFIX)/lib/gpclient/"; \
install_name_tool -delete_rpath "$$(dirname "$$library")" "$(DESTDIR)$(PREFIX)/bin/gpclient"; \
codesign --force --sign - "$(DESTDIR)$(PREFIX)/bin/gpclient"
install -m 755 packaging/files/usr/libexec/gpclient/vpnc-script "$(DESTDIR)$(PREFIX)/libexec/gpclient/"
install-macos: install-gpclient-macos
install -m 755 "$(CARGO_RELEASE_DIR)/gpauth" "$(DESTDIR)$(PREFIX)/bin/"
# Common executable and icon installation uses portable install options on Linux/BSD.
install-unix: install-gpclient-unix
set -e; for binary in gpauth gpservice; do \
install -m 755 "$(CARGO_RELEASE_DIR)/$$binary" "$(DESTDIR)$(PREFIX)/bin/"; \
done
set -e; for binary in gp-hip-script-installer gp-vpnc-script-installer; do \
install -m 755 "$(CARGO_RELEASE_DIR)/$$binary" "$(DESTDIR)$(PREFIX)/libexec/gpclient/"; \
done
set -e; if [ "$(BUILD_GUI_HELPER)" = "1" ]; then \
install -m 755 "$(CARGO_RELEASE_DIR)/gpgui-helper" "$(DESTDIR)$(PREFIX)/bin/"; \
fi
if [ -f .build/gpgui/gpgui_*/gpgui ]; then \
install -Dm755 .build/gpgui/gpgui_*/gpgui $(DESTDIR)/usr/bin/gpgui; \
set -e; if [ -f "$(GPGUI_BINARY)" ]; then \
install -m 755 "$(GPGUI_BINARY)" "$(DESTDIR)$(PREFIX)/bin/gpgui"; \
fi
set -e; for file in packaging/files/usr/share/icons/hicolor/*/apps/gpgui.* \
packaging/files/usr/share/icons/hicolor/scalable/status/gpgui-*.svg; do \
destination="$(DESTDIR)$(PREFIX)/$${file#packaging/files/usr/}"; \
install -d "$$(dirname "$$destination")"; \
install -m 644 "$$file" "$$destination"; \
done
install -Dm755 packaging/files/usr/libexec/gpclient/vpnc-script $(DESTDIR)/usr/libexec/gpclient/vpnc-script
install-linux: install-unix
@echo "Installing Linux integration under $(PREFIX)..."
set -e; for file in share/applications/gpgui.desktop \
share/polkit-1/actions/com.yuezk.gpgui.policy \
lib/NetworkManager/dispatcher.d/pre-down.d/gpclient.down \
lib/NetworkManager/dispatcher.d/gpclient-nm-hook; do \
mode=644; case "$$file" in lib/*) mode=755 ;; esac; \
destination="$(DESTDIR)$(PREFIX)/$$file"; \
install -d "$$(dirname "$$destination")"; \
install -m "$$mode" "packaging/files/usr/$$file" "$$destination"; \
done
sh scripts/relocate-install-paths.sh "$(PREFIX)" /usr "$(DESTDIR)$(PREFIX)"
# Install the disconnect hooks
install -Dm755 packaging/files/usr/lib/NetworkManager/dispatcher.d/pre-down.d/gpclient.down $(DESTDIR)/usr/lib/NetworkManager/dispatcher.d/pre-down.d/gpclient.down
install -Dm755 packaging/files/usr/lib/NetworkManager/dispatcher.d/gpclient-nm-hook $(DESTDIR)/usr/lib/NetworkManager/dispatcher.d/gpclient-nm-hook
install -Dm644 packaging/files/usr/share/applications/gpgui.desktop $(DESTDIR)/usr/share/applications/gpgui.desktop
install -Dm644 packaging/files/usr/share/icons/hicolor/scalable/apps/gpgui.svg $(DESTDIR)/usr/share/icons/hicolor/scalable/apps/gpgui.svg
install -Dm644 packaging/files/usr/share/icons/hicolor/32x32/apps/gpgui.png $(DESTDIR)/usr/share/icons/hicolor/32x32/apps/gpgui.png
install -Dm644 packaging/files/usr/share/icons/hicolor/128x128/apps/gpgui.png $(DESTDIR)/usr/share/icons/hicolor/128x128/apps/gpgui.png
install -Dm644 packaging/files/usr/share/icons/hicolor/256x256/apps/gpgui.png $(DESTDIR)/usr/share/icons/hicolor/256x256/apps/gpgui.png
install -Dm644 packaging/files/usr/share/icons/hicolor/256x256@2/apps/gpgui.png $(DESTDIR)/usr/share/icons/hicolor/256x256@2/apps/gpgui.png
install -Dm644 packaging/files/usr/share/icons/hicolor/scalable/status/gpgui-connected-symbolic.svg $(DESTDIR)/usr/share/icons/hicolor/scalable/status/gpgui-connected-symbolic.svg
install -Dm644 packaging/files/usr/share/icons/hicolor/scalable/status/gpgui-disconnected-symbolic.svg $(DESTDIR)/usr/share/icons/hicolor/scalable/status/gpgui-disconnected-symbolic.svg
install -Dm644 packaging/files/usr/share/icons/hicolor/scalable/status/gpgui-connecting-1-symbolic.svg $(DESTDIR)/usr/share/icons/hicolor/scalable/status/gpgui-connecting-1-symbolic.svg
install -Dm644 packaging/files/usr/share/icons/hicolor/scalable/status/gpgui-connecting-2-symbolic.svg $(DESTDIR)/usr/share/icons/hicolor/scalable/status/gpgui-connecting-2-symbolic.svg
install -Dm644 packaging/files/usr/share/icons/hicolor/scalable/status/gpgui-connecting-3-symbolic.svg $(DESTDIR)/usr/share/icons/hicolor/scalable/status/gpgui-connecting-3-symbolic.svg
install -Dm644 packaging/files/usr/share/icons/hicolor/scalable/status/gpgui-connecting-4-symbolic.svg $(DESTDIR)/usr/share/icons/hicolor/scalable/status/gpgui-connecting-4-symbolic.svg
install -Dm644 packaging/files/usr/share/polkit-1/actions/com.yuezk.gpgui.policy $(DESTDIR)/usr/share/polkit-1/actions/com.yuezk.gpgui.policy
install-bsd:
@echo "Installing $(PKG_NAME) for BSD under $(PREFIX)..."
install -d $(DESTDIR)$(PREFIX)/bin
install -m 755 target/release/gpclient $(DESTDIR)$(PREFIX)/bin/gpclient
install -m 755 target/release/gpauth $(DESTDIR)$(PREFIX)/bin/gpauth
install -m 755 target/release/gpservice $(DESTDIR)$(PREFIX)/bin/gpservice
if [ "$(BUILD_GUI_HELPER)" = "1" ]; then \
install -m 755 target/release/gpgui-helper $(DESTDIR)$(PREFIX)/bin/gpgui-helper; \
fi
if [ -x "$(GPGUI_BINARY)" ]; then \
install -m 755 "$(GPGUI_BINARY)" $(DESTDIR)$(PREFIX)/bin/gpgui; \
fi
install -d $(DESTDIR)$(PREFIX)/libexec/gpclient
install -m 755 target/release/gp-hip-script-installer $(DESTDIR)$(PREFIX)/libexec/gpclient/gp-hip-script-installer
install -m 755 target/release/gp-vpnc-script-installer $(DESTDIR)$(PREFIX)/libexec/gpclient/gp-vpnc-script-installer
install -m 755 packaging/files/usr/libexec/gpclient/vpnc-script $(DESTDIR)$(PREFIX)/libexec/gpclient/vpnc-script
install -d $(DESTDIR)$(PREFIX)/share/applications
install -m 644 packaging/bsd/gpgui.desktop $(DESTDIR)$(PREFIX)/share/applications/gpgui.desktop
install -d $(DESTDIR)$(PREFIX)/share/icons/hicolor/scalable/apps
install -d $(DESTDIR)$(PREFIX)/share/icons/hicolor/32x32/apps
install -d $(DESTDIR)$(PREFIX)/share/icons/hicolor/128x128/apps
install -d $(DESTDIR)$(PREFIX)/share/icons/hicolor/256x256/apps
install -d $(DESTDIR)$(PREFIX)/share/icons/hicolor/256x256@2/apps
install -d $(DESTDIR)$(PREFIX)/share/icons/hicolor/scalable/status
install -m 644 packaging/files/usr/share/icons/hicolor/scalable/apps/gpgui.svg $(DESTDIR)$(PREFIX)/share/icons/hicolor/scalable/apps/gpgui.svg
install -m 644 packaging/files/usr/share/icons/hicolor/32x32/apps/gpgui.png $(DESTDIR)$(PREFIX)/share/icons/hicolor/32x32/apps/gpgui.png
install -m 644 packaging/files/usr/share/icons/hicolor/128x128/apps/gpgui.png $(DESTDIR)$(PREFIX)/share/icons/hicolor/128x128/apps/gpgui.png
install -m 644 packaging/files/usr/share/icons/hicolor/256x256/apps/gpgui.png $(DESTDIR)$(PREFIX)/share/icons/hicolor/256x256/apps/gpgui.png
install -m 644 packaging/files/usr/share/icons/hicolor/256x256@2/apps/gpgui.png $(DESTDIR)$(PREFIX)/share/icons/hicolor/256x256@2/apps/gpgui.png
install -m 644 packaging/files/usr/share/icons/hicolor/scalable/status/gpgui-connected-symbolic.svg $(DESTDIR)$(PREFIX)/share/icons/hicolor/scalable/status/gpgui-connected-symbolic.svg
install -m 644 packaging/files/usr/share/icons/hicolor/scalable/status/gpgui-disconnected-symbolic.svg $(DESTDIR)$(PREFIX)/share/icons/hicolor/scalable/status/gpgui-disconnected-symbolic.svg
install -m 644 packaging/files/usr/share/icons/hicolor/scalable/status/gpgui-connecting-1-symbolic.svg $(DESTDIR)$(PREFIX)/share/icons/hicolor/scalable/status/gpgui-connecting-1-symbolic.svg
install -m 644 packaging/files/usr/share/icons/hicolor/scalable/status/gpgui-connecting-2-symbolic.svg $(DESTDIR)$(PREFIX)/share/icons/hicolor/scalable/status/gpgui-connecting-2-symbolic.svg
install -m 644 packaging/files/usr/share/icons/hicolor/scalable/status/gpgui-connecting-3-symbolic.svg $(DESTDIR)$(PREFIX)/share/icons/hicolor/scalable/status/gpgui-connecting-3-symbolic.svg
install -m 644 packaging/files/usr/share/icons/hicolor/scalable/status/gpgui-connecting-4-symbolic.svg $(DESTDIR)$(PREFIX)/share/icons/hicolor/scalable/status/gpgui-connecting-4-symbolic.svg
install -d $(DESTDIR)$(PREFIX)/share/polkit-1/actions
install -m 644 packaging/bsd/com.yuezk.gpgui.policy $(DESTDIR)$(PREFIX)/share/polkit-1/actions/com.yuezk.gpgui.policy
install-bsd: install-unix
@echo "Installing BSD integration under $(PREFIX)..."
install -d "$(DESTDIR)$(PREFIX)/share/applications" "$(DESTDIR)$(PREFIX)/share/polkit-1/actions"
install -m 644 packaging/bsd/gpgui.desktop "$(DESTDIR)$(PREFIX)/share/applications/"
install -m 644 packaging/bsd/com.yuezk.gpgui.policy "$(DESTDIR)$(PREFIX)/share/polkit-1/actions/"
sh scripts/relocate-install-paths.sh "$(PREFIX)" /usr/local "$(DESTDIR)$(PREFIX)"
clean-bsd-package:
rm -rf .build/$(BSD_FLAVOR)
@@ -290,42 +287,54 @@ package-openbsd: clean-bsd-package
.build/openbsd/artifacts/$(PKG_NAME)-$(VERSION)-openbsd-$$openbsd_arch.tgz
$(MAKE) bsd-gpgui-tarball BSD_FLAVOR=openbsd GPGUI_BINARY="$(GPGUI_BINARY)"
uninstall:
@echo "Uninstalling $(PKG_NAME)..."
ifeq ($(shell uname -s),Darwin)
uninstall: uninstall-macos
else ifneq ($(filter FreeBSD OpenBSD,$(shell uname -s)),)
uninstall: uninstall-bsd
else
uninstall: uninstall-linux
endif
rm -f $(DESTDIR)/usr/bin/gpclient
rm -f $(DESTDIR)/usr/bin/gpauth
rm -f $(DESTDIR)/usr/bin/gpservice
rm -f $(DESTDIR)/usr/libexec/gpclient/gp-hip-script-installer
rm -f $(DESTDIR)/usr/bin/gpgui-helper
rm -f $(DESTDIR)/usr/bin/gpgui
.PHONY: install install-gpclient install-macos install-unix install-linux install-bsd \
install-gpclient-macos install-gpclient-unix \
uninstall uninstall-macos uninstall-unix uninstall-linux uninstall-bsd
rm -f $(DESTDIR)/usr/libexec/gpclient/vpnc-script
rm -f $(DESTDIR)/usr/libexec/gpclient/gp-vpnc-script-installer
uninstall-macos:
@echo "Uninstalling $(PKG_NAME) for macOS under $(PREFIX)..."
rm -f "$(DESTDIR)$(PREFIX)/bin/gpclient" "$(DESTDIR)$(PREFIX)/bin/gpauth" \
"$(DESTDIR)$(PREFIX)/libexec/gpclient/vpnc-script" \
"$(DESTDIR)$(PREFIX)/lib/gpclient/"libopenconnect.*.dylib
rmdir "$(DESTDIR)$(PREFIX)/lib/gpclient" "$(DESTDIR)$(PREFIX)/libexec/gpclient" 2>/dev/null || true
rm -f $(DESTDIR)/usr/lib/NetworkManager/dispatcher.d/pre-down.d/gpclient.down
rm -f $(DESTDIR)/usr/lib/NetworkManager/dispatcher.d/gpclient-nm-hook
uninstall-unix:
@echo "Uninstalling $(PKG_NAME) under $(PREFIX)..."
set -e; for binary in gpclient gpauth gpservice gpgui-helper gpgui; do \
rm -f "$(DESTDIR)$(PREFIX)/bin/$$binary"; \
done
set -e; for file in gp-hip-script-installer gp-vpnc-script-installer vpnc-script; do \
rm -f "$(DESTDIR)$(PREFIX)/libexec/gpclient/$$file"; \
done
set -e; for file in packaging/files/usr/share/icons/hicolor/*/apps/gpgui.* \
packaging/files/usr/share/icons/hicolor/scalable/status/gpgui-*.svg; do \
rm -f "$(DESTDIR)$(PREFIX)/$${file#packaging/files/usr/}"; \
done
rm -f "$(DESTDIR)$(PREFIX)/share/applications/gpgui.desktop" \
"$(DESTDIR)$(PREFIX)/share/polkit-1/actions/com.yuezk.gpgui.policy"
rmdir "$(DESTDIR)$(PREFIX)/libexec/gpclient" 2>/dev/null || true
rm -f $(DESTDIR)/usr/share/applications/gpgui.desktop
rm -f $(DESTDIR)/usr/share/icons/hicolor/scalable/apps/gpgui.svg
rm -f $(DESTDIR)/usr/share/icons/hicolor/32x32/apps/gpgui.png
rm -f $(DESTDIR)/usr/share/icons/hicolor/128x128/apps/gpgui.png
rm -f $(DESTDIR)/usr/share/icons/hicolor/256x256/apps/gpgui.png
rm -f $(DESTDIR)/usr/share/icons/hicolor/256x256@2/apps/gpgui.png
rm -f $(DESTDIR)/usr/share/icons/hicolor/scalable/status/gpgui-connected-symbolic.svg
rm -f $(DESTDIR)/usr/share/icons/hicolor/scalable/status/gpgui-disconnected-symbolic.svg
rm -f $(DESTDIR)/usr/share/icons/hicolor/scalable/status/gpgui-connecting-1-symbolic.svg
rm -f $(DESTDIR)/usr/share/icons/hicolor/scalable/status/gpgui-connecting-2-symbolic.svg
rm -f $(DESTDIR)/usr/share/icons/hicolor/scalable/status/gpgui-connecting-3-symbolic.svg
rm -f $(DESTDIR)/usr/share/icons/hicolor/scalable/status/gpgui-connecting-4-symbolic.svg
rm -f $(DESTDIR)/usr/share/polkit-1/actions/com.yuezk.gpgui.policy
uninstall-linux: uninstall-unix
rm -f "$(DESTDIR)$(PREFIX)/lib/NetworkManager/dispatcher.d/pre-down.d/gpclient.down" \
"$(DESTDIR)$(PREFIX)/lib/NetworkManager/dispatcher.d/gpclient-nm-hook"
rm -f "$(DESTDIR)/var/lib/gpclient/gpgui" \
"$(DESTDIR)/var/lib/gpclient/scripts/vpnc-script" \
"$(DESTDIR)/var/lib/gpclient/scripts/vpnc-script.metadata"
rmdir "$(DESTDIR)/var/lib/gpclient/scripts" "$(DESTDIR)/var/lib/gpclient" 2>/dev/null || true
rm -f $(DESTDIR)/var/lib/gpclient/gpgui \
$(DESTDIR)/var/lib/gpclient/scripts/vpnc-script \
$(DESTDIR)/var/lib/gpclient/scripts/vpnc-script.metadata || \
echo "Warning: failed to remove gpclient runtime files" >&2
rmdir $(DESTDIR)/var/lib/gpclient/scripts 2>/dev/null || true
rmdir $(DESTDIR)/var/lib/gpclient 2>/dev/null || true
uninstall-bsd: uninstall-unix
rm -f "$(DESTDIR)/usr/local/libexec/gpclient/gpgui" \
"$(DESTDIR)/var/db/gpclient/scripts/vpnc-script" \
"$(DESTDIR)/var/db/gpclient/scripts/vpnc-script.metadata"
rmdir "$(DESTDIR)/var/db/gpclient/scripts" "$(DESTDIR)/var/db/gpclient" 2>/dev/null || true
clean-debian:
rm -rf .build/deb
+9
View File
@@ -4,6 +4,15 @@ const UNKNOWN_COMMIT: &str = "unknown";
const DISPLAY_COMMIT_LEN: usize = 9;
fn main() {
// Installed OpenConnect lives in the private ../lib/gpclient directory.
// Build executables also locate their exact Cargo library; installers remove that rpath.
#[cfg(target_os = "macos")]
{
println!("cargo:rustc-link-arg=-Wl,-rpath,@executable_path/../lib/gpclient");
let library_dir = env::var("DEP_OPENCONNECT_LIB_DIR").expect("OpenConnect exports its build library directory");
println!("cargo:rustc-link-arg=-Wl,-rpath,{library_dir}");
}
println!("cargo:rerun-if-env-changed=SOURCE_GIT_COMMIT");
println!("cargo:rerun-if-env-changed=GPCLIENT_GIT_COMMIT");
println!("cargo:rerun-if-env-changed=GITHUB_SHA");
+146
View File
@@ -372,3 +372,149 @@ async fn exhausted_auth_recovery_is_terminal_before_portal_gateway_fallback() {
assert_eq!(handler.auth_attempt_fixture.borrow().observed.len(), 2);
assert_eq!(worker.await.unwrap().len(), 2);
}
#[cfg(all(
feature = "webview-auth",
any(target_os = "linux", target_os = "freebsd", target_os = "openbsd")
))]
mod gtk_retry {
use super::*;
#[tokio::test]
async fn real_gtk_crash_retries_bundled_authenticator() {
// Environment overrides belong to a separate test process, never the parallel test runner.
if let Some(directory) = std::env::var_os("GP_TEST_GTK_AUTH_DIR") {
verify_real_authenticator_retry(std::path::Path::new(&directory)).await;
} else {
run_real_authenticator_retry(false);
}
}
#[cfg(target_os = "linux")]
#[test]
#[ignore = "requires non-interactive sudo authorization and a running Wayland desktop session"]
fn sudo_gtk_crash_retries_after_restoring_desktop_environment() {
run_real_authenticator_retry(true);
}
fn run_real_authenticator_retry(sudo: bool) {
use std::{fs, os::unix::fs::PermissionsExt, process::Command};
let directory = tempfile::tempdir().unwrap();
let executable = directory.path().join("gpauth");
// Fixtures contain only dummy data and must remain accessible after a root test drops privileges.
fs::set_permissions(directory.path(), fs::Permissions::from_mode(0o755)).unwrap();
let attempts_path = directory.path().join("attempts");
fs::write(&attempts_path, "").unwrap();
fs::set_permissions(&attempts_path, fs::Permissions::from_mode(0o666)).unwrap();
fs::write(&executable, r#"#!/bin/sh
set -eu
request=
while [ "$#" -gt 0 ]; do
if [ "$1" = '--saml-request' ]; then
shift
request=$1
fi
shift
done
printf '%s|%s|%s|%s\n' "$(id -u)" "${WAYLAND_DISPLAY:-}" "${WEBKIT_DISABLE_DMABUF_RENDERER-unset}" "$request" >> "$GP_TEST_GTK_AUTH_DIR/attempts"
if [ "$request" = 'old' ]; then
printf 'Gdk-Message: 10:49:22.617: Error 71 (Protocol error) dispatching to Wayland display.\n' >&2
exit 1
fi
[ "$request" = 'new' ] && [ "${WEBKIT_DISABLE_DMABUF_RENDERER:-}" = '1' ] || exit 2
printf '%s\n' '{"success":{"username":"alice","preloginCookie":"new-cookie"}}'
"#).unwrap();
fs::set_permissions(&executable, fs::Permissions::from_mode(0o755)).unwrap();
let mut command = if sudo {
assert_ne!(
uzers::get_effective_uid(),
0,
"run this test as the Wayland desktop user"
);
let mut command = Command::new("sudo");
command.args([
"-n",
"env",
"-u",
"WAYLAND_DISPLAY",
"-u",
"DISPLAY",
"-u",
"XDG_SESSION_TYPE",
"-u",
"WEBKIT_DISABLE_DMABUF_RENDERER",
]);
command.arg("GP_TEST_EXPECT_ROOT=1");
command
} else {
let mut command = Command::new("env");
command.arg("-u").arg("WEBKIT_DISABLE_DMABUF_RENDERER");
command.arg("WAYLAND_DISPLAY=wayland-test");
command
};
command.arg(format!("GP_AUTH_BINARY={}", executable.display()));
command.arg(format!("GP_TEST_GTK_AUTH_DIR={}", directory.path().display()));
command.arg(std::env::current_exe().unwrap()).args([
"--exact",
"connect::flow_tests::gtk_retry::real_gtk_crash_retries_bundled_authenticator",
"--nocapture",
]);
let output = command.output().unwrap();
assert!(
output.status.success(),
"retry subprocess failed: {}\n{}",
String::from_utf8_lossy(&output.stdout),
String::from_utf8_lossy(&output.stderr)
);
let expected_uid = gpapi::process::users::get_non_root_user().unwrap().uid().to_string();
let attempts = fs::read_to_string(attempts_path).unwrap();
let attempts: Vec<Vec<&str>> = attempts.lines().map(|line| line.split('|').collect()).collect();
assert_eq!(attempts.len(), 2, "expected exactly one retry");
for attempt in &attempts {
assert_eq!(attempt[0], expected_uid, "authenticator must run as the desktop user");
assert!(!attempt[1].is_empty(), "authenticator must receive WAYLAND_DISPLAY");
}
assert_eq!(&attempts[0][2..], ["unset", "old"]);
assert_eq!(&attempts[1][2..], ["1", "new"]);
}
async fn verify_real_authenticator_retry(directory: &std::path::Path) {
use gpapi::credential::Credential;
if std::env::var_os("GP_TEST_EXPECT_ROOT").is_some() {
assert_eq!(uzers::get_effective_uid(), 0);
assert!(std::env::var_os("SUDO_UID").is_some());
assert!(std::env::var_os("WAYLAND_DISPLAY").is_none());
}
let (origin, worker) = gateway(vec![
("200 OK", saml_prelogin_response("old-region", "b2xk")),
("200 OK", saml_prelogin_response("new-region", "bmV3")),
])
.await;
let args = TestArgs::parse_from(["test", &origin]).connect;
let lock = directory.join("client.pid");
let verbose = gpapi::clap::InfoLevelVerbosity::new(0, 0);
let shared = SharedArgs {
fix_openssl: false,
ignore_tls_errors: true,
lock_file: &lock,
verbose: &verbose,
log_format: LogFormat::Text,
};
let handler = ConnectHandler::new(&args, &shared);
let original = handler.refresh_auth_prelogin(&origin, false, false).await.unwrap();
let (replacement, credential) = handler
.obtain_credential_with_recovery(original, &origin, false)
.await
.unwrap();
assert_eq!(replacement.region(), "new-region");
assert!(matches!(credential, Credential::Prelogin(ref value) if value.prelogin_cookie() == Some("new-cookie")));
assert_eq!(
worker.await.unwrap().len(),
2,
"recovery must fetch fresh prelogin data"
);
}
}
+8 -1
View File
@@ -9,7 +9,7 @@ fn executable(dir: &std::path::Path, name: &str, body: &str) {
}
#[tokio::test]
async fn embedded_collector_finishes_without_recursing_or_exposing_private_environment() {
async fn embedded_collector_reports_missing_helpers_without_recursing_or_exposing_private_environment() {
let dir = tempfile::tempdir().unwrap();
let bin = dir.path().join("bin");
std::fs::create_dir(&bin).unwrap();
@@ -33,6 +33,8 @@ async fn embedded_collector_finishes_without_recursing_or_exposing_private_envir
.args(["--fix-openssl", "diagnostics", "--json", "--output"])
.arg(&report_file)
.env("PATH", format!("{}:/usr/bin:/bin", bin.display()))
.env("GP_AUTH_BINARY", dir.path().join("missing-gpauth"))
.env("GP_GUI_BINARY", dir.path().join("missing-gpgui"))
.env("GP_DIAGNOSTICS_PRIVATE_TOKEN", "secret-value-must-not-appear")
.env("XDG_CURRENT_DESKTOP", "TestDesktop\nInjected: secret")
.stdin(Stdio::null())
@@ -50,6 +52,11 @@ async fn embedded_collector_finishes_without_recursing_or_exposing_private_envir
let report: serde_json::Value = serde_json::from_str(&text).unwrap();
assert_eq!(report["schema_version"], 1);
assert_eq!(report["fields"]["os"]["value"], "Linux");
assert_eq!(report["fields"]["gpclient_path"]["status"], "ok");
for field in ["gpauth_path", "gpauth_version", "gpgui_path", "gpgui_version"] {
assert_eq!(report["fields"][field]["status"], "unavailable");
assert!(report["fields"][field]["value"].is_null());
}
assert!(
report["fields"]["gpclient_version"]["value"]
.as_str()
+9
View File
@@ -4,6 +4,15 @@ const UNKNOWN_COMMIT: &str = "unknown";
const DISPLAY_COMMIT_LEN: usize = 9;
fn main() {
// Installed OpenConnect lives in the private ../lib/gpclient directory.
// Build executables also locate their exact Cargo library; installers remove that rpath.
#[cfg(target_os = "macos")]
{
println!("cargo:rustc-link-arg=-Wl,-rpath,@executable_path/../lib/gpclient");
let library_dir = env::var("DEP_OPENCONNECT_LIB_DIR").expect("OpenConnect exports its build library directory");
println!("cargo:rustc-link-arg=-Wl,-rpath,{library_dir}");
}
println!("cargo:rerun-if-env-changed=GPSERVICE_GIT_COMMIT");
println!("cargo:rerun-if-env-changed=SOURCE_GIT_COMMIT");
println!("cargo:rerun-if-env-changed=GITHUB_SHA");
+10
View File
@@ -1,5 +1,15 @@
# Changelog
## 3.0.3
### Fixed
- Improved Wayland crash recovery on Linux and BSD.
- Fixed pasted callbacks and prompts for remote browser sign-in.
- Fixed legacy TLS configuration while preserving device identities.
- Fixed diagnostics when optional tools are unavailable.
- Fixed bundled macOS library paths and polished release notes in About.
## 3.0.2
### Added
+3 -3
View File
@@ -14,7 +14,9 @@ impl AuthServer {
let server = Server::http(addr).map_err(|err| anyhow::anyhow!(err))?;
let auth_id = Uuid::new_v4().to_string();
Ok(Self { server, auth_id })
let auth_server = Self { server, auth_id };
info!("auth server started at: {}", auth_server.auth_url());
Ok(auth_server)
}
pub fn auth_url(&self) -> String {
@@ -22,8 +24,6 @@ impl AuthServer {
}
pub fn serve_request(&self, auth_request: &str) {
info!("auth server started at: {}", self.auth_url());
for req in self.server.incoming_requests() {
info!("received request, method: {}, url: {}", req.method(), req.url());
+9 -2
View File
@@ -1,4 +1,7 @@
use std::net::{IpAddr, SocketAddr};
use std::{
io::Write,
net::{IpAddr, SocketAddr},
};
use browser_launcher::Browser as LaunchBrowser;
use gpapi::auth::SamlAuthData;
@@ -34,7 +37,7 @@ impl<'a> BrowserAuthenticator<'a> {
let auth_url = auth_server.auth_url();
let auth_request = self.auth_request.to_string();
tokio::spawn(async move {
let auth_server_task = tokio::task::spawn_blocking(move || {
auth_server.serve_request(&auth_request);
});
@@ -55,6 +58,7 @@ Note that the URL is only valid for a single use.
"#,
auth_url
);
auth_server_task.await?;
return read_auth_data_from_stdin();
}
@@ -95,6 +99,9 @@ async fn detect_local_ip() -> anyhow::Result<IpAddr> {
}
fn read_auth_data_from_stdin() -> anyhow::Result<SamlAuthData> {
eprint!("\nAuthentication callback (paste and press Enter): ");
std::io::stderr().flush()?;
let mut data = String::new();
std::io::stdin().read_line(&mut data)?;
+23
View File
@@ -93,6 +93,12 @@ fn sibling_binary_for_executable(executable: &Path, binary_name: &str) -> Option
if is_file(&binary) {
return Some(binary);
}
if matches!(binary_name, "gp-vpnc-script-installer" | "gp-hip-script-installer") {
let binary = bin_dir.parent()?.join("libexec/gpclient").join(binary_name);
if is_file(&binary) {
return Some(binary);
}
}
#[cfg(target_os = "macos")]
if let Some(binary) = macos::helper_path(&executable, binary_name)
&& is_file(&binary)
@@ -121,6 +127,23 @@ fn is_file(path: &Path) -> bool {
mod tests {
use super::*;
#[test]
fn script_installers_follow_the_installed_prefix() {
let directory = tempfile::tempdir().unwrap();
let bin = directory.path().join("bin");
let libexec = directory.path().join("libexec/gpclient");
std::fs::create_dir_all(&bin).unwrap();
std::fs::create_dir_all(&libexec).unwrap();
std::fs::write(bin.join("gpclient"), "").unwrap();
for name in ["gp-vpnc-script-installer", "gp-hip-script-installer"] {
std::fs::write(libexec.join(name), "").unwrap();
assert_eq!(
sibling_binary_for_executable(&bin.join("gpclient"), name),
Some(libexec.canonicalize().unwrap().join(name))
);
}
}
#[test]
#[cfg(target_os = "macos")]
fn desktop_resolves_helpers_in_the_actual_app_bundle_layout() {
+1
View File
@@ -34,6 +34,7 @@ uzers.workspace = true
serde_urlencoded.workspace = true
md5.workspace = true
sha256.workspace = true
sha2 = "0.10"
uuid = { workspace = true, features = ["v4", "v5", "serde"] }
chrono.workspace = true
humantime.workspace = true
+28 -2
View File
@@ -1,6 +1,7 @@
//! Neutral device-anchor transport model and deterministic derivation.
use base64::{Engine, engine::general_purpose::URL_SAFE_NO_PAD};
use serde::{Deserialize, Serialize};
use sha2::{Digest, Sha256};
use std::fmt;
#[derive(Debug, Clone, Copy, PartialEq, Eq, Serialize, Deserialize)]
@@ -68,7 +69,7 @@ impl DeviceAnchor {
let mut input = domain.to_vec();
input.extend_from_slice(seed.as_ref());
Self {
hardware_id: URL_SAFE_NO_PAD.encode(openssl::sha::sha256(&input)),
hardware_id: URL_SAFE_NO_PAD.encode(Sha256::digest(&input)),
source,
}
}
@@ -78,11 +79,36 @@ impl DeviceAnchor {
mod tests {
use super::*;
#[test]
fn preserves_existing_hardware_ids_for_all_sources() {
let cases: [(AnchorSource, &[u8], &str); 3] = [
(
AnchorSource::UnixMac,
&[0, 17, 34, 51, 68, 85],
"UWDOx4AVJEuCAYfJBaPioyGtRfAkJBhMYSi8LuFsE1A",
),
(
AnchorSource::UnixRandom,
&[0, 17, 34, 51, 68, 85],
"fYXFpivIFuD9Z4I6qSNxUIMTljeLvw4xuqXgg0VJAu0",
),
(
AnchorSource::MacosIokit,
b"12345678-1234-5678-9abc-def012345678",
"K1KMtAwiOiXKQvQuRmTDKPA6-ZPF5QKUWZzmvRzeP34",
),
];
for (source, seed, expected) in cases {
let anchor = DeviceAnchor::derive(source, seed);
assert_eq!(anchor.hardware_id, expected, "{source:?}");
assert!(anchor.validate());
}
}
#[test]
fn hashes_original_seed_order_with_stable_domain_separation() {
let mac = DeviceAnchor::derive(AnchorSource::UnixMac, [0, 17, 34, 51, 68, 85]);
assert!(mac.validate());
assert_eq!(mac.hardware_id, "UWDOx4AVJEuCAYfJBaPioyGtRfAkJBhMYSi8LuFsE1A");
assert_ne!(
mac.hardware_id,
DeviceAnchor::derive(AnchorSource::UnixMac, [85, 68, 51, 34, 17, 0]).hardware_id
+24 -3
View File
@@ -12,7 +12,10 @@ use tokio_util::sync::CancellationToken;
use crate::auth::AuthWindowTheme;
use crate::{auth::SamlAuthResult, credential::Credential, log_format::LogFormat, os_profile::OsProfile};
use super::{command_runner::run_observed, command_traits::CommandExt};
use super::{
command_runner::{ChildInput, run_observed},
command_traits::CommandExt,
};
use super::rendering_recovery::{RenderingCrash, StderrDiagnostic, eligible, is_crash_exit};
@@ -300,6 +303,7 @@ impl<'a> SamlAuthLauncher<'a> {
if embedded && bundled && self.dmabuf_disabled {
command.env("WEBKIT_DISABLE_DMABUF_RENDERER", "1");
}
let stdin = auth_stdin(self.browser);
let cancellation = self.cancellation.clone();
let output = tokio::task::spawn_blocking(move || {
let check = || {
@@ -319,7 +323,7 @@ impl<'a> SamlAuthLauncher<'a> {
Some(MAX_AUTH_RESULT_BYTES),
&mut |bytes| diagnostic.push(bytes),
&mut std::io::stderr(),
None,
stdin,
)?;
Ok::<_, std::io::Error>((output.output, diagnostic.matched()))
})
@@ -339,6 +343,14 @@ impl<'a> SamlAuthLauncher<'a> {
}
}
/// `gpauth --browser remote` reads the pasted `globalprotectcallback:` data from the user's terminal.
fn auth_stdin(browser: Option<&str>) -> ChildInput<'static> {
match browser {
Some(browser) if browser.eq_ignore_ascii_case("remote") => ChildInput::Terminal,
_ => ChildInput::Null,
}
}
fn is_bundled_authenticator(program: &Path, bundled: &Path) -> bool {
match (program.canonicalize(), bundled.canonicalize()) {
(Ok(program), Ok(bundled)) => program == bundled,
@@ -449,6 +461,15 @@ mod tests {
assert_eq!(launcher.browser_listen, Some(listen_ip));
}
#[test]
fn only_a_remote_browser_reads_the_terminal() {
assert!(matches!(auth_stdin(Some("remote")), ChildInput::Terminal));
assert!(matches!(auth_stdin(Some("REMOTE")), ChildInput::Terminal));
assert!(matches!(auth_stdin(Some("firefox")), ChildInput::Null));
assert!(matches!(auth_stdin(None), ChildInput::Null));
}
#[test]
fn failed_authenticator_discards_partial_or_valid_stdout_before_decoding() {
use std::os::unix::process::ExitStatusExt;
@@ -489,7 +510,7 @@ mod tests {
let executable = directory.path().join("auth-fixture");
std::fs::write(
&executable,
"#!/bin/sh\nprintf 'Gdk-Message: Error 71 (Protocol error) dispatching to Wayland display\\n' >&2\nexit 71\n",
"#!/bin/sh\nprintf 'Gdk-Message: Error 71 (Protocol error) dispatching to Wayland display.\\n' >&2\nexit 1\n",
)
.unwrap();
// The launcher drops root privileges in CI; its child must be able to
+88 -24
View File
@@ -14,13 +14,21 @@ use nix::{
use super::collection::CollectionControl;
/// What the child reads on stdin.
pub(crate) enum ChildInput<'a> {
Null,
Frame(&'a [u8]),
/// The caller's own stdin, for a child that prompts the user.
Terminal,
}
/// Owns and reaps the command's process group. Its async caller must cancel and await this worker.
pub(crate) fn run_controlled(
command: Command,
control: &dyn CollectionControl,
output_limit: usize,
) -> io::Result<Output> {
run(command, control, Some(output_limit), None, None).map(|observed| observed.output)
run(command, control, Some(output_limit), None, ChildInput::Null).map(|observed| observed.output)
}
#[derive(Debug)]
@@ -35,15 +43,9 @@ pub(crate) fn run_observed(
output_limit: Option<usize>,
observer: &mut dyn FnMut(&[u8]),
stderr_sink: &mut dyn Write,
stdin_frame: Option<&[u8]>,
stdin: ChildInput<'_>,
) -> io::Result<ObservedOutput> {
run(
command,
control,
output_limit,
Some((observer, stderr_sink)),
stdin_frame,
)
run(command, control, output_limit, Some((observer, stderr_sink)), stdin)
}
fn nonblocking(fd: &impl std::os::fd::AsFd) -> io::Result<()> {
@@ -61,26 +63,31 @@ fn run(
control: &dyn CollectionControl,
output_limit: Option<usize>,
mut observation: Option<(&mut dyn FnMut(&[u8]), &mut dyn Write)>,
stdin_frame: Option<&[u8]>,
stdin: ChildInput<'_>,
) -> io::Result<ObservedOutput> {
control.check()?;
command
.stdout(if output_limit.is_some() {
Stdio::piped()
} else {
Stdio::inherit()
})
.process_group(0);
command.stdin(if stdin_frame.is_some() {
command.stdout(if output_limit.is_some() {
Stdio::piped()
} else {
Stdio::null()
Stdio::inherit()
});
// A child in a process group of its own is a background job, so reading the terminal would stop it with SIGTTIN.
let own_group = !matches!(stdin, ChildInput::Terminal);
if own_group {
command.process_group(0);
}
let (stdio, stdin_frame) = match stdin {
ChildInput::Null => (Stdio::null(), None),
ChildInput::Frame(frame) => (Stdio::piped(), Some(frame)),
ChildInput::Terminal => (Stdio::inherit(), None),
};
command.stdin(stdio);
if observation.is_some() {
command.stderr(Stdio::piped());
}
let mut child = ControlledChild {
process: command.spawn()?,
own_group,
stopped: false,
};
let mut stdout = child.process.stdout.take();
@@ -187,13 +194,18 @@ fn run(
struct ControlledChild {
process: Child,
own_group: bool,
stopped: bool,
}
impl ControlledChild {
fn stop_helpers(&mut self) {
if !self.stopped {
let _ = killpg(Pid::from_raw(self.process.id() as i32), Signal::SIGKILL);
if self.own_group {
let _ = killpg(Pid::from_raw(self.process.id() as i32), Signal::SIGKILL);
} else {
let _ = self.process.kill();
}
self.stopped = true;
}
}
@@ -223,7 +235,7 @@ mod tests {
Some(1024),
&mut |bytes| seen.extend_from_slice(bytes),
&mut sink,
None,
ChildInput::Null,
)
.unwrap();
assert!(!output.output.status.success());
@@ -244,7 +256,15 @@ mod tests {
Ok(())
}
};
let error = run_observed(command, &control, Some(1024), &mut |_| {}, &mut io::sink(), None).unwrap_err();
let error = run_observed(
command,
&control,
Some(1024),
&mut |_| {},
&mut io::sink(),
ChildInput::Null,
)
.unwrap_err();
assert_eq!(error.kind(), io::ErrorKind::Interrupted);
assert!(start.elapsed() < Duration::from_secs(2));
}
@@ -259,7 +279,7 @@ mod tests {
None,
&mut |_| {},
&mut io::sink(),
Some(&vec![0; 128 * 1024]),
ChildInput::Frame(&vec![0; 128 * 1024]),
)
.unwrap();
assert_eq!(observed.output.status.code(), Some(2));
@@ -284,7 +304,51 @@ mod tests {
None,
&mut |_| {},
&mut io::sink(),
Some(&vec![0; 128 * 1024]),
ChildInput::Frame(&vec![0; 128 * 1024]),
)
.unwrap_err();
assert_eq!(error.kind(), io::ErrorKind::Interrupted);
assert!(start.elapsed() < Duration::from_secs(2));
}
#[cfg(target_os = "linux")]
#[test]
fn terminal_input_shares_the_callers_stdin_and_process_group() {
let mut command = Command::new("sh");
command.args(["-c", "readlink /proc/$$/fd/0; cut -d' ' -f5 /proc/$$/stat"]);
let observed = run_observed(
command,
&|| Ok(()),
Some(1024),
&mut |_| {},
&mut io::sink(),
ChildInput::Terminal,
)
.unwrap();
let stdout = String::from_utf8(observed.output.stdout).unwrap();
let stdin = std::fs::read_link("/proc/self/fd/0").unwrap();
assert_eq!(stdout, format!("{}\n{}\n", stdin.display(), nix::unistd::getpgrp()));
}
#[test]
fn cancellation_kills_a_terminal_child() {
let mut command = Command::new("sleep");
command.arg("30");
let start = Instant::now();
let control = || {
if start.elapsed() > Duration::from_millis(100) {
Err(io::Error::new(io::ErrorKind::Interrupted, "cancelled"))
} else {
Ok(())
}
};
let error = run_observed(
command,
&control,
None,
&mut |_| {},
&mut io::sink(),
ChildInput::Terminal,
)
.unwrap_err();
assert_eq!(error.kind(), io::ErrorKind::Interrupted);
+2 -2
View File
@@ -1,5 +1,5 @@
use super::{
command_runner::run_observed,
command_runner::{ChildInput, run_observed},
rendering_recovery::{RenderingCrash, StderrDiagnostic, eligible_with_inheritance, is_crash_exit},
};
use crate::service::transport::SessionCredential;
@@ -55,7 +55,7 @@ pub(super) async fn launch_desktop_child(
None,
&mut |bytes| diagnostic.push(bytes),
&mut sink,
Some(&frame),
ChildInput::Frame(&frame),
)?;
let output = observed.output;
if is_crash_exit(output.status) && retry_eligible && diagnostic.matched() {
@@ -110,7 +110,7 @@ mod tests {
let path = fixture(
&dir,
&credential,
"printf '(gpgui-helper:42): Gdk-Message: 12:00:00: Error 71 (Protocol error) dispatching to Wayland display\\n' >&2; exit 71",
"printf '(gpgui-helper:42): Gdk-Message: 12:00:00: Error 71 (Protocol error) dispatching to Wayland display.\\n' >&2; exit 1",
);
let mut envs = HashMap::from([("WAYLAND_DISPLAY".into(), "wayland-0".into())]);
for override_value in [None, Some(""), Some("0"), Some("1")] {
+41 -4
View File
@@ -97,14 +97,15 @@ impl StderrDiagnostic {
}
fn check_line(&mut self) {
let line = self.line.as_slice();
let line = self.line.trim_ascii_end();
let message = line.strip_suffix(b".").unwrap_or(line);
if !self.overflow
&& (line.starts_with(b"Gdk-Message:")
|| line.starts_with(b"(gpgui:")
|| line.starts_with(b"(gpauth:")
|| line.starts_with(b"(gpgui-helper:"))
&& line.windows(b"Gdk-Message:".len()).any(|part| part == b"Gdk-Message:")
&& line.strip_suffix(b"\r").unwrap_or(line).ends_with(DIAGNOSTIC)
&& message.ends_with(DIAGNOSTIC)
{
self.matched = true;
}
@@ -123,13 +124,49 @@ mod tests {
#[test]
fn recognizes_split_diagnostic_without_matching_quoted_warning() {
let mut observer = StderrDiagnostic::default();
observer.push(b"warning: Gdk-Message: Error 71 (Protocol error) dispatching to Wayland display\n");
observer.push(b"warning: Gdk-Message: Error 71 (Protocol error) dispatching to Wayland display.\n");
assert!(!observer.matched());
observer.push(b"Gdk-Message: 12:00:00: Error 71 (Protocol error) dispat");
observer.push(b"ching to Wayland display\n");
observer.push(b"ching to Wayland display.\n");
assert!(observer.matched());
}
#[test]
fn recognizes_real_gtk_diagnostic_with_prefix_and_line_endings() {
for prefix in [
"Gdk-Message:",
"(gpauth:42): Gdk-Message:",
"(gpgui:42): Gdk-Message:",
"(gpgui-helper:42): Gdk-Message:",
] {
for punctuation in ["", "."] {
for ending in ["\n", "\r\n", "", " \t\n"] {
let line = format!(
"{prefix} 10:49:22.617: Error 71 (Protocol error) dispatching to Wayland display{punctuation}{ending}"
);
let mut observer = StderrDiagnostic::default();
for chunk in line.as_bytes().chunks(7) {
observer.push(chunk);
}
assert!(observer.matched(), "unrecognized GTK diagnostic: {line:?}");
}
}
}
}
#[test]
fn rejects_quoted_or_extended_gtk_diagnostic() {
for line in [
"warning: Gdk-Message: Error 71 (Protocol error) dispatching to Wayland display.\n",
"Gdk-Message: Error 71 (Protocol error) dispatching to Wayland display. Retry suggested\n",
"Gdk-Message: Error 70 (Communication error) dispatching to Wayland display.\n",
] {
let mut observer = StderrDiagnostic::default();
observer.push(line.as_bytes());
assert!(!observer.matched(), "incorrectly recognized: {line:?}");
}
}
#[test]
fn oversized_lines_do_not_grow_or_match() {
let mut observer = StderrDiagnostic::default();
+3
View File
@@ -15,3 +15,6 @@ cc = "1"
autotools = "0.2"
pkg-config = "0.3"
fs_extra = "1"
[dev-dependencies]
tempfile = "3"
+21
View File
@@ -137,6 +137,27 @@ fn build_openconnect(deps_dir: &PathBuf, out_dir: &PathBuf) -> PathBuf {
let lib_dir = dst.join("lib");
let include_dir = dst.join("include");
#[cfg(target_os = "macos")]
{
// Do not embed Cargo's temporary build directory in consumers of this library.
let library = std::fs::canonicalize(lib_dir.join("libopenconnect.dylib")).unwrap();
let library_name = library.file_name().unwrap().to_str().unwrap();
let status = std::process::Command::new("install_name_tool")
.arg("-id")
.arg(format!("@rpath/{library_name}"))
.arg(&library)
.status()
.expect("Failed to update the OpenConnect dylib install name");
assert!(status.success(), "Failed to update the OpenConnect dylib install name");
let status = std::process::Command::new("codesign")
.args(["--force", "--sign", "-"])
.arg(&library)
.status()
.expect("Failed to sign the OpenConnect dylib");
assert!(status.success(), "Failed to sign the OpenConnect dylib");
println!("cargo:lib_dir={}", lib_dir.display());
}
println!("cargo:rustc-link-search=native={}", lib_dir.display());
#[cfg(target_os = "macos")]
+34
View File
@@ -34,9 +34,23 @@ pub fn find_vpnc_script() -> Option<String> {
if let Some(path) = std::env::var_os("GP_VPNC_SCRIPT").filter(|path| !path.is_empty()) {
return configured_script(Path::new(&path));
}
if let Ok(executable) = std::env::current_exe()
&& let Some(script) = installed_vpnc_script(&executable)
{
return Some(script);
}
find_executable(VPNC_SCRIPT_LOCATIONS).map(str::to_owned)
}
fn installed_vpnc_script(executable: &Path) -> Option<String> {
let executable = executable.canonicalize().ok()?;
let bin = executable.parent()?;
if bin.file_name()? != "bin" {
return None;
}
configured_script(&bin.parent()?.join("libexec/gpclient/vpnc-script"))
}
fn configured_script(path: &Path) -> Option<String> {
if path.is_absolute() && path.is_file() && path.is_executable() {
return path.to_str().map(str::to_owned);
@@ -62,6 +76,26 @@ pub fn check_executable(file: &str) -> Result<(), io::Error> {
mod tests {
use super::*;
#[test]
fn installed_script_follows_the_executable_prefix_through_symlinks() {
let dir = tempfile::tempdir().unwrap();
let bin = dir.path().join("prefix/bin");
let libexec = dir.path().join("prefix/libexec/gpclient");
std::fs::create_dir_all(&bin).unwrap();
std::fs::create_dir_all(&libexec).unwrap();
std::fs::write(bin.join("gpclient"), "").unwrap();
let script = libexec.join("vpnc-script");
std::fs::write(&script, "#!/bin/sh\n").unwrap();
use std::os::unix::fs::PermissionsExt;
std::fs::set_permissions(&script, std::fs::Permissions::from_mode(0o755)).unwrap();
let link = dir.path().join("gpclient-link");
std::os::unix::fs::symlink(bin.join("gpclient"), &link).unwrap();
assert_eq!(
installed_vpnc_script(&link),
Some(script.canonicalize().unwrap().to_str().unwrap().to_owned())
);
}
#[test]
fn configured_script_requires_an_absolute_executable_path() {
assert_eq!(configured_script(Path::new("/bin/sh")), Some("/bin/sh".to_owned()));
+1 -1
View File
@@ -31,7 +31,7 @@ gpclient diagnostics --json --output diagnostics.json
The collector refuses to overwrite an existing file. Choose another filename or
remove the previous report yourself before collecting again.
This command is being added after 3.0.1. If your installed version says the
This command is available in 3.0.2 and later. If your installed version says the
command is unknown, use the standalone script below. You do not need to upgrade
before reporting a problem.
+15 -63
View File
@@ -29,8 +29,8 @@
cargoToml = builtins.fromTOML (builtins.readFile ./Cargo.toml);
pname = "globalprotect-openconnect";
version = cargoToml.workspace.package.version;
releaseTag = "v3.0.1";
releaseVersion = "3.0.1";
releaseTag = "v3.0.2";
releaseVersion = "3.0.2";
toolchain = pkgs.rust-bin.fromRustupToolchainFile ./rust-toolchain.toml;
@@ -55,8 +55,8 @@
cpu = pkgs.stdenv.hostPlatform.parsed.cpu.name;
gpguiHashes = {
x86_64 = "sha256-lc05BKc0lu0qoZWmOPakjxXmenv1XoiQCOMIh5KE8A8=";
aarch64 = "sha256-bnmGQ82GJbS0z8yelMeOxzwSNV92iVk8hGEUUd4jkFA=";
x86_64 = "sha256-ncJ6xAk8nUgMc5ELoCXtrN25XbSjs25jo4w5oBF+9f0=";
aarch64 = "sha256-SGQc4unT9thXQb8cFwVffNXobo9Gjy3NoDqyAkBiUy8=";
};
gpguiArchive = pkgs.fetchurl {
@@ -70,8 +70,8 @@
};
binaryHashes = {
x86_64 = "sha256-/nKUzhlIdlgK2Xpv2nCQ/tuwUCTYuoSSft7sCc/M7U0=";
aarch64 = "sha256-pDJvHT8p6fMFtSyJypr/3wL/OPHK/TSL7HMt63nP5oQ=";
x86_64 = "sha256-1TNt/NJ8rD143ivbqUFpacLV6YpihhVDVt8Do74QIxs=";
aarch64 = "sha256-TP7nLG++vsRPpq/GL/07avCjZYFRM20TKnpfpMtfMBI=";
};
binaryArchive = pkgs.fetchurl {
@@ -118,6 +118,7 @@
[
libxml2
zlib
openssl
lz4
gnutls
p11-kit
@@ -130,30 +131,10 @@
libsoup_3
webkitgtk_4_1
glib-networking
openssl
libsecret
libayatana-appindicator
];
rewriteSourceInstallPaths = lib.optionalString pkgs.stdenv.isLinux ''
substituteInPlace $out/share/applications/gpgui.desktop \
--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 \
--replace-fail /usr/libexec/gpclient/gp-vpnc-script-installer $out/libexec/gpclient/gp-vpnc-script-installer
if [ -f $out/libexec/gpclient/gp-hip-script-installer ]; then
substituteInPlace $out/share/polkit-1/actions/com.yuezk.gpgui.policy \
--replace-fail /usr/libexec/gpclient/gp-hip-script-installer $out/libexec/gpclient/gp-hip-script-installer
fi
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
@@ -182,6 +163,9 @@
# Must be set to true to avoid issues with the Tauri build process
singleStep = true;
# The Makefile installs executables together with their supporting files.
copyBins = false;
cargoBuildOptions =
old:
old
@@ -202,6 +186,9 @@
libtool
pkg-config
]
++ lib.optionals stdenv.isDarwin [
darwin.sigtool
]
++ lib.optionals stdenv.isLinux [
autoPatchelfHook
wrapGAppsHook4
@@ -211,49 +198,14 @@
preFixup = nativeRuntimeWrapping;
overrideMain =
{ ... }:
{
postPatch = ''
substituteInPlace crates/openconnect/src/vpn_utils.rs \
--replace-fail /usr/libexec/gpclient/vpnc-script $out/libexec/gpclient/vpnc-script
substituteInPlace crates/common/src/constants.rs \
--replace-fail /usr/bin/gpclient $out/bin/gpclient \
--replace-fail /usr/bin/gpauth $out/bin/gpauth \
--replace-fail /opt/homebrew/ $out/
''
+ lib.optionalString pkgs.stdenv.isLinux ''
substituteInPlace crates/common/src/constants.rs \
--replace-fail /usr/bin/gpservice $out/bin/gpservice \
--replace-fail /usr/bin/gpgui-helper $out/bin/gpgui-helper \
--replace-fail /usr/bin/gpgui $out/bin/gpgui
substituteInPlace crates/common/src/constants.rs \
--replace-fail /usr/libexec/gpclient/gp-hip-script-installer $out/libexec/gpclient/gp-hip-script-installer
'';
};
postInstall = ''
cp -r packaging/files/usr/libexec $out/libexec
make install PREFIX="$out" ${lib.optionalString pkgs.stdenv.isLinux ''GPGUI_BINARY="${gui}/gpgui"''}
''
+ lib.optionalString pkgs.stdenv.isLinux ''
for installer in gp-vpnc-script-installer gp-hip-script-installer; do
install -Dm755 "$out/bin/$installer" "$out/libexec/gpclient/$installer"
done
# Copy the prebuilt gpgui binary to the output bin directory
cp ${gui}/gpgui $out/bin/gpgui
chmod +x $out/bin/gpgui
cp -r packaging/files/usr/share $out/share
cp -r packaging/files/usr/lib $out/lib
${installNixosPolkitRule}
''
+ ''
${rewriteVpncScriptToolPaths}
${rewriteSourceInstallPaths}
'';
}) {};
@@ -288,7 +240,7 @@
install -Dm755 ${gui}/gpgui $out/bin/gpgui
${rewriteVpncScriptToolPaths}
${rewriteSourceInstallPaths}
sh ${./scripts/relocate-install-paths.sh} "$out" /usr "$out"
${installNixosPolkitRule}
runHook postInstall
+5 -1
View File
@@ -130,13 +130,17 @@ if [ "$os" = Darwin ]; then
[ -n "$auth_path" ] || { [ ! -x "$bundle/Helpers/gpauth" ] || auth_path=$bundle/Helpers/gpauth; }
[ -n "$gui_path" ] || { [ ! -d "$bundle" ] || { gui_path=$bundle/MacOS/gpgui; gui_bundle=$bundle; }; }
fi
is_executable_file() { [ -f "$1" ] && [ -x "$1" ]; }
is_executable_file "$client_path" || client_path=
is_executable_file "$auth_path" || auth_path=
is_executable_file "$gui_path" || gui_path=
for component in gpclient gpauth gpgui; do
case "$component" in gpclient) location=$client_path ;; gpauth) location=$auth_path ;; gpgui) location=$gui_path ;; esac
if [ -n "$location" ]; then emit "${component}_path" ok "$location"; else emit "${component}_path" unavailable ''; fi
done
if [ -n "$client_version" ]; then emit gpclient_version ok "$client_version"; elif [ -n "$client_path" ]; then field_probe gpclient_version "$client_path" --version; else emit gpclient_version unavailable ''; fi
if [ -n "$auth_path" ]; then field_probe gpauth_version "$auth_path" --version; else emit gpauth_version unavailable ''; fi
if [ "$os" = Darwin ] && [ -n "$gui_bundle" ]; then
if [ "$os" = Darwin ] && [ -n "$gui_path" ] && [ -n "$gui_bundle" ]; then
field_probe gpgui_version /usr/libexec/PlistBuddy -c 'Print :CFBundleShortVersionString' "$gui_bundle/Info.plist"
else
emit gpgui_version unavailable ''
+18
View File
@@ -0,0 +1,18 @@
#!/bin/sh
# Resolve the library used by this build, rather than choosing a stale Cargo output.
set -eu
binary=$1
library=$(otool -L "$binary" | awk '/^[[:space:]]+@rpath\/libopenconnect\..*\.dylib / { sub("@rpath/", "", $1); print $1 }')
test -n "$library" || { echo "No OpenConnect dependency in $binary" >&2; exit 1; }
rpaths=$(otool -l "$binary" | awk '/cmd LC_RPATH/ { rpath=1; next } rpath && $1 == "path" { sub(/^[[:space:]]*path /, ""); sub(/ \(offset [0-9]+\)$/, ""); print; rpath=0 }')
while IFS= read -r directory; do
case "$directory" in /*) ;; *) continue ;; esac
if [ -f "$directory/$library" ]; then
printf '%s\n' "$directory/$library"
exit 0
fi
done <<EOF
$rpaths
EOF
echo "Cannot resolve the OpenConnect build library for $binary" >&2
exit 1
+38
View File
@@ -0,0 +1,38 @@
#!/bin/sh
# Integration files use the runtime prefix, never the packaging staging directory.
set -eu
prefix=$1
source_prefix=$2
directory=$3
escape_replacement() {
printf '%s' "$1" | sed 's/[\\&|]/\\&/g'
}
# Each integration format has its own quoting rules.
desktop_prefix=$(printf '%s' "$prefix" | sed -e 's/\\/\\\\\\\\/g' -e 's/["`$]/\\\\&/g' -e 's/%/%%/g')
desktop_command=$(escape_replacement "\"$desktop_prefix/bin/gpclient\"")
shell_prefix=$(printf '%s' "$prefix" | sed "s/'/'\\\\''/g")
shell_command=$(escape_replacement "'$shell_prefix/bin/gpclient'")
xml_prefix=$(printf '%s' "$prefix" | sed -e 's/\&/\&amp;/g' -e 's/</\&lt;/g' -e 's/>/\&gt;/g')
xml_replacement=$(escape_replacement "$xml_prefix")
temporary=$(mktemp)
trap 'rm -f "$temporary"' EXIT HUP INT TERM
for file in share/applications/gpgui.desktop \
share/polkit-1/actions/com.yuezk.gpgui.policy \
lib/NetworkManager/dispatcher.d/pre-down.d/gpclient.down \
lib/NetworkManager/dispatcher.d/gpclient-nm-hook; do
path="$directory/$file"
[ -f "$path" ] || continue
case "$file" in
share/applications/*)
sed "s|$source_prefix/bin/gpclient|$desktop_command|g" "$path" > "$temporary" ;;
share/polkit-1/*)
sed -e "s|$source_prefix/bin/|$xml_replacement/bin/|g" \
-e "s|$source_prefix/libexec/gpclient/|$xml_replacement/libexec/gpclient/|g" \
"$path" > "$temporary" ;;
lib/*)
sed "s|$source_prefix/bin/gpclient|$shell_command|g" "$path" > "$temporary" ;;
esac
mode=644
case "$file" in lib/*) mode=755 ;; esac
install -m "$mode" "$temporary" "$path"
done
+19
View File
@@ -95,6 +95,8 @@ cat > "$fixtures/bin/pkg_info" <<'MOCK'
printf '%s\n' 'webkitgtk41-2.52.6 WebKitGTK browser engine' 'gtk+3-3.24.52 GTK3 toolkit' 'sway-1.11 Wayland compositor' 'private-package-1.0 Do not collect'
MOCK
chmod +x "$fixtures/bin/"*
mkdir "$fixtures/home[regex]"
ln -s "$fixtures/bin/gpclient" "$fixtures/home[regex]/gpclient"
run() {
env PATH="$fixtures/bin" HOME="$fixtures/home[regex]" TMPDIR="$fixtures" \
TEST_OS="$1" TEST_PROBE="${2:-}" TEST_CHILD_PID="$fixtures/child.pid" \
@@ -132,6 +134,23 @@ assert_contains "gpgui_path: ok: $fixtures/bin/gpgui"
assert_contains 'gpgui_version: unavailable:'
[ ! -e "$fixtures/gui-launched" ]
printf '%s\n' 'PASS: nonbundle GUI path never borrows another installed app version'
mkdir "$fixtures/not-a-file"
printf '#!/bin/sh\nexit 0\n' > "$fixtures/not-executable"
chmod 644 "$fixtures/not-executable"
ln -s "$fixtures/missing" "$fixtures/broken-link"
for os in Linux FreeBSD OpenBSD Darwin; do
for invalid in missing not-a-file not-executable broken-link; do
env PATH="$fixtures/bin" TEST_OS="$os" TEST_GUI_MARKER="$fixtures/gui-launched" \
sh "$collector" --client-path "$fixtures/$invalid" \
--auth-path "$fixtures/$invalid" --gui-path "$fixtures/$invalid" > "$fixtures/report"
for component in gpclient gpauth gpgui; do
assert_contains "${component}_path: unavailable:"
assert_contains "${component}_version: unavailable:"
done
done
done
[ ! -e "$fixtures/gui-launched" ]
printf '%s\n' 'PASS: missing files, directories, nonexecutables and broken links are unavailable on all platforms'
# Successful probes must cancel their watchdog before doing any process-tree
# traversal. A slow snapshot used to let a finished probe become timed_out.
mv "$fixtures/bin/ps" "$fixtures/real-ps"
+174
View File
@@ -0,0 +1,174 @@
#!/bin/sh
set -eu
root=$(CDPATH= cd -- "$(dirname "$0")/../.." && pwd)
cd "$root"
temp=$(mktemp -d)
trap 'rm -rf "$temp"' EXIT HUP INT TERM
mkdir -p "$temp/release"
for binary in gpclient gpauth gpservice gpgui gpgui-helper gp-vpnc-script-installer gp-hip-script-installer; do
printf '#!/bin/sh\nexit 0\n' > "$temp/release/$binary"
chmod 755 "$temp/release/$binary"
done
mkdir -p "$temp/client-release"
cp "$temp/release/gpclient" "$temp/client-release/"
make install-gpclient-unix PREFIX='/custom/gp install' DESTDIR="$temp/client-stage" \
CARGO_RELEASE_DIR="$temp/client-release" > "$temp/client.log"
installed="$temp/client-stage/custom/gp install"
test -x "$installed/bin/gpclient"
test -x "$installed/libexec/gpclient/vpnc-script"
test "$(find "$installed" -type f | wc -l | tr -d ' ')" = 2
for platform in linux bsd; do
stage="$temp/$platform-stage"
make "install-$platform" PREFIX=/custom/gp DESTDIR="$stage" \
CARGO_RELEASE_DIR="$temp/release" GPGUI_BINARY="$temp/release/gpgui" > "$temp/$platform.log"
installed="$stage/custom/gp"
test -x "$installed/bin/gpclient"
test -x "$installed/libexec/gpclient/gp-vpnc-script-installer"
grep -q 'Exec="/custom/gp/bin/gpclient" ' "$installed/share/applications/gpgui.desktop"
grep -q '>/custom/gp/bin/gpservice<' "$installed/share/polkit-1/actions/com.yuezk.gpgui.policy"
grep -q '>/custom/gp/libexec/gpclient/gp-hip-script-installer<' "$installed/share/polkit-1/actions/com.yuezk.gpgui.policy"
! grep -F "$stage" "$installed/share/applications/gpgui.desktop"
if [ "$platform" = bsd ]; then
test ! -d "$installed/lib/NetworkManager"
else
test -x "$installed/lib/NetworkManager/dispatcher.d/pre-down.d/gpclient.down"
fi
runtime="$stage/var/lib/gpclient"
if [ "$platform" = bsd ]; then
runtime="$stage/var/db/gpclient"
mkdir -p "$stage/usr/local/libexec/gpclient"
cp "$temp/release/gpgui" "$stage/usr/local/libexec/gpclient/gpgui"
else
mkdir -p "$runtime"
cp "$temp/release/gpgui" "$runtime/gpgui"
fi
mkdir -p "$runtime/scripts"
touch "$runtime/scripts/vpnc-script" "$runtime/scripts/vpnc-script.metadata"
find "$stage" -type f > "$temp/$platform-installed-files"
touch "$installed/bin/unrelated" "$installed/libexec/gpclient/unrelated" "$runtime/scripts/unrelated"
# Repeat removal to cover an already-uninstalled or partial installation.
for attempt in 1 2; do
make "uninstall-$platform" PREFIX=/custom/gp DESTDIR="$stage" > "$temp/$platform-uninstall.log"
done
while IFS= read -r file; do test ! -e "$file"; done < "$temp/$platform-installed-files"
test -f "$installed/bin/unrelated"
test -f "$installed/libexec/gpclient/unrelated"
test -f "$runtime/scripts/unrelated"
done
mv "$temp/release/gpclient" "$temp/release/gpclient.saved"
if make install-linux PREFIX=/custom/gp DESTDIR="$temp/missing-client-stage" \
CARGO_RELEASE_DIR="$temp/release" > "$temp/missing-client.log" 2>&1; then
echo 'FAIL: installation succeeded without gpclient' >&2
exit 1
fi
test ! -e "$temp/missing-client-stage/custom/gp/bin/gpauth"
mv "$temp/release/gpclient.saved" "$temp/release/gpclient"
make install-linux PREFIX='/custom/gp install' DESTDIR="$temp/spaces-stage" \
CARGO_RELEASE_DIR="$temp/release" GPGUI_BINARY="$temp/release/gpgui" > "$temp/spaces-install.log"
find "$temp/spaces-stage" -type f > "$temp/spaces-installed-files"
make uninstall-linux PREFIX='/custom/gp install' DESTDIR="$temp/spaces-stage" > "$temp/spaces-uninstall.log"
while IFS= read -r file; do test ! -e "$file"; done < "$temp/spaces-installed-files"
# Execute generated commands against a harmless CLI fixture at a spaced prefix.
integration="$temp/integration prefix"
mkdir -p "$integration/bin" "$integration/share/applications" "$integration/lib/NetworkManager/dispatcher.d/pre-down.d"
printf '#!/bin/sh\nprintf "%%s\\n" "$@"\n' > "$integration/bin/gpclient"
chmod 755 "$integration/bin/gpclient"
cp packaging/files/usr/share/applications/gpgui.desktop "$integration/share/applications/"
cp packaging/files/usr/lib/NetworkManager/dispatcher.d/pre-down.d/gpclient.down "$integration/lib/NetworkManager/dispatcher.d/pre-down.d/"
sh scripts/relocate-install-paths.sh "$integration" /usr "$integration"
desktop_command=$(sed -n 's/^Exec=//p' "$integration/share/applications/gpgui.desktop")
test "$desktop_command" = "\"$integration/bin/gpclient\" launch-gui %u"
test "$(sh -c "$desktop_command")" = "$(printf 'launch-gui\n%%u')"
test "$(sh "$integration/lib/NetworkManager/dispatcher.d/pre-down.d/gpclient.down")" = "$(printf 'disconnect\n--wait\n3')"
mkdir -p "$temp/tools"
for os in FreeBSD OpenBSD; do
printf '#!/bin/sh\ncase "$1" in -s) echo %s ;; -m) echo amd64 ;; esac\n' "$os" > "$temp/tools/uname"
chmod 755 "$temp/tools/uname"
PATH="$temp/tools:$PATH" make -n install PREFIX=/custom/gp \
CARGO_RELEASE_DIR="$temp/release" BUILD_GUI_HELPER=0 GPGUI_BINARY= > "$temp/$os.log"
grep -q 'Installing BSD integration' "$temp/$os.log"
! grep -q 'Installing Linux integration' "$temp/$os.log"
PATH="$temp/tools:$PATH" make -n uninstall > "$temp/$os-uninstall.log"
grep -q '/usr/local/bin/' "$temp/$os-uninstall.log"
grep -q '/var/db/gpclient/' "$temp/$os-uninstall.log"
! grep -q 'NetworkManager' "$temp/$os-uninstall.log"
done
for platform in Linux Darwin-arm64 Darwin-x86_64; do
os=Darwin
arch=${platform#Darwin-}
prefix=/usr/local
case "$platform" in
Linux) os=Linux; arch=x86_64; prefix=/usr ;;
Darwin-arm64) prefix=/opt/homebrew ;;
esac
printf '#!/bin/sh\ncase "$1" in -s) echo %s ;; -m) echo %s ;; esac\n' "$os" "$arch" > "$temp/tools/uname"
PATH="$temp/tools:$PATH" make -n uninstall > "$temp/$platform-uninstall.log"
grep -q "$prefix/bin/" "$temp/$platform-uninstall.log"
if [ "$os" = Darwin ]; then
grep -q "$prefix/lib/gpclient/" "$temp/$platform-uninstall.log"
! grep -q 'NetworkManager\|/var/lib/gpclient' "$temp/$platform-uninstall.log"
else
grep -q '/var/lib/gpclient/' "$temp/$platform-uninstall.log"
fi
done
if [ "$(uname -s)" = Darwin ]; then
mkdir -p "$temp/build-library" "$temp/unreferenced-library" "$temp/App/Contents/Helpers"
printf 'int fixture(void) { return 0; }\n' > "$temp/lib.c"
printf 'extern int fixture(void); int main(void) { return fixture(); }\n' > "$temp/main.c"
library="$temp/build-library/libopenconnect.5.dylib"
cc -dynamiclib "$temp/lib.c" -Wl,-install_name,@rpath/libopenconnect.5.dylib -o "$library"
printf 'int main(void) { return 0; }\n' > "$temp/no-library.c"
cc "$temp/no-library.c" -o "$temp/release/gpclient"
if make install-macos PREFIX=/custom/gp DESTDIR="$temp/no-library-stage" \
CARGO_RELEASE_DIR="$temp/release" > "$temp/no-library.log" 2>&1; then
echo 'FAIL: macOS installation succeeded without an OpenConnect dependency' >&2
exit 1
fi
test ! -e "$temp/no-library-stage/custom/gp/libexec/gpclient/vpnc-script"
cc "$temp/main.c" "$library" -Wl,-rpath,@executable_path/../lib/gpclient \
-Wl,-rpath,"$temp/build-library" -o "$temp/release/gpclient"
printf 'stale library must never be selected\n' > "$temp/unreferenced-library/libopenconnect.5.dylib"
test "$(sh scripts/macos-openconnect-library.sh "$temp/release/gpclient")" = "$library"
cp "$temp/release/gpclient" "$temp/client-release/"
make install-gpclient PREFIX='/custom/gp install' DESTDIR="$temp/macos-client-stage" \
CARGO_RELEASE_DIR="$temp/client-release" > "$temp/macos-client.log"
installed="$temp/macos-client-stage/custom/gp install"
test -x "$installed/bin/gpclient"
test -x "$installed/libexec/gpclient/vpnc-script"
test -f "$installed/lib/gpclient/libopenconnect.5.dylib"
test "$(find "$installed" -type f | wc -l | tr -d ' ')" = 3
installed="$temp/macos-stage/custom/gp"
mkdir -p "$installed/lib" "$temp/homebrew-cellar"
printf 'Homebrew-owned library\n' > "$temp/homebrew-cellar/libopenconnect.5.dylib"
ln -s "$temp/homebrew-cellar/libopenconnect.5.dylib" "$installed/lib/libopenconnect.5.dylib"
make install-macos PREFIX=/custom/gp DESTDIR="$temp/macos-stage" \
CARGO_RELEASE_DIR="$temp/release" > "$temp/macos.log"
test -f "$installed/lib/gpclient/libopenconnect.5.dylib"
test -L "$installed/lib/libopenconnect.5.dylib"
test "$(cat "$temp/homebrew-cellar/libopenconnect.5.dylib")" = 'Homebrew-owned library'
! otool -l "$temp/macos-stage/custom/gp/bin/gpclient" | grep -F "$temp/build-library"
cp "$temp/release/gpclient" "$temp/App/Contents/Helpers/gpclient"
install_name_tool -delete_rpath "$temp/build-library" "$temp/App/Contents/Helpers/gpclient"
dylibbundler --overwrite-dir --bundle-deps --search-path "$temp/build-library" \
--install-path @executable_path/../Frameworks --dest-dir "$temp/App/Contents/Frameworks" \
--fix-file "$temp/App/Contents/Helpers/gpclient" > "$temp/bundle.log"
codesign --force --sign - "$temp/App/Contents/Frameworks/libopenconnect.5.dylib"
codesign --force --sign - "$temp/App/Contents/Helpers/gpclient"
mv "$temp/build-library" "$temp/removed-build-library"
"$temp/macos-stage/custom/gp/bin/gpclient"
"$temp/macos-client-stage/custom/gp install/bin/gpclient"
"$temp/App/Contents/Helpers/gpclient"
touch "$installed/lib/gpclient/unrelated" "$installed/libexec/gpclient/unrelated"
for attempt in 1 2; do
make uninstall PREFIX=/custom/gp DESTDIR="$temp/macos-stage" > "$temp/macos-uninstall.log"
done
test ! -e "$installed/bin/gpclient"
test ! -e "$installed/bin/gpauth"
test ! -e "$installed/lib/gpclient/libopenconnect.5.dylib"
test ! -e "$installed/libexec/gpclient/vpnc-script"
test -f "$installed/lib/gpclient/unrelated"
test -f "$installed/libexec/gpclient/unrelated"
test -L "$installed/lib/libopenconnect.5.dylib"
test "$(cat "$temp/homebrew-cellar/libopenconnect.5.dylib")" = 'Homebrew-owned library'
fi
echo 'PASS: install/uninstall paths, unrelated-file preservation, and native macOS library relocation'