mirror of
https://github.com/yuezk/GlobalProtect-openconnect.git
synced 2026-11-19 06:26:14 -05:00
Compare commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
90faa58811 | ||
|
|
93504eaec2 | ||
|
|
d73b712dd3 | ||
|
|
be111a671a | ||
|
|
f9965f8a35 | ||
|
|
f7649898fd | ||
|
|
e6910060df | ||
|
|
f41a429a5e | ||
|
|
f0292a9292 |
No files matched your search
@@ -786,7 +786,7 @@ jobs:
|
|||||||
${{ matrix.workspace }}/gp/.build/${{ matrix.artifact_dir }}/artifacts/*
|
${{ matrix.workspace }}/gp/.build/${{ matrix.artifact_dir }}/artifacts/*
|
||||||
|
|
||||||
gh-release:
|
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
|
runs-on: ubuntu-latest
|
||||||
permissions:
|
permissions:
|
||||||
actions: read
|
actions: read
|
||||||
@@ -942,7 +942,7 @@ jobs:
|
|||||||
needs:
|
needs:
|
||||||
- test-gp
|
- test-gp
|
||||||
- build-docker-image
|
- 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
|
runs-on: ubuntu-latest
|
||||||
steps:
|
steps:
|
||||||
- uses: actions/checkout@v6
|
- uses: actions/checkout@v6
|
||||||
|
|||||||
@@ -185,6 +185,7 @@ jobs:
|
|||||||
revision: ${{ inputs.revision }}
|
revision: ${{ inputs.revision }}
|
||||||
|
|
||||||
- name: Wait for Launchpad builds and public package indexes
|
- name: Wait for Launchpad builds and public package indexes
|
||||||
|
if: ${{ inputs.verify_only }}
|
||||||
env:
|
env:
|
||||||
TAG: ${{ inputs.tag }}
|
TAG: ${{ inputs.tag }}
|
||||||
REVISION: ${{ inputs.revision }}
|
REVISION: ${{ inputs.revision }}
|
||||||
|
|||||||
@@ -257,6 +257,8 @@ jobs:
|
|||||||
- build
|
- build
|
||||||
runs-on: ubuntu-latest
|
runs-on: ubuntu-latest
|
||||||
if: ${{ inputs.gh-release }}
|
if: ${{ inputs.gh-release }}
|
||||||
|
outputs:
|
||||||
|
stable_version: ${{ steps.stable-release.outputs.version }}
|
||||||
permissions:
|
permissions:
|
||||||
actions: read
|
actions: read
|
||||||
contents: read
|
contents: read
|
||||||
@@ -318,3 +320,23 @@ jobs:
|
|||||||
else
|
else
|
||||||
gh-release/gp/scripts/upload-release-assets.sh "${{ inputs.tag }}" "${files[@]}"
|
gh-release/gp/scripts/upload-release-assets.sh "${{ inputs.tag }}" "${files[@]}"
|
||||||
fi
|
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
|
name: Update flake hashes
|
||||||
|
|
||||||
on:
|
on:
|
||||||
|
workflow_call:
|
||||||
|
inputs:
|
||||||
|
version:
|
||||||
|
required: true
|
||||||
|
type: string
|
||||||
|
release_tag:
|
||||||
|
required: true
|
||||||
|
type: string
|
||||||
workflow_dispatch:
|
workflow_dispatch:
|
||||||
inputs:
|
inputs:
|
||||||
version:
|
version:
|
||||||
|
|||||||
Generated
+12
-10
@@ -214,7 +214,7 @@ checksum = "1505bd5d3d116872e7271a6d4e16d81d0c8570876c8de68093a09ac269d8aac0"
|
|||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "auth"
|
name = "auth"
|
||||||
version = "3.0.2"
|
version = "3.0.3"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"anyhow",
|
"anyhow",
|
||||||
"block2",
|
"block2",
|
||||||
@@ -423,7 +423,7 @@ dependencies = [
|
|||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "browser-launcher"
|
name = "browser-launcher"
|
||||||
version = "3.0.2"
|
version = "3.0.3"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"anyhow",
|
"anyhow",
|
||||||
"log",
|
"log",
|
||||||
@@ -719,7 +719,7 @@ dependencies = [
|
|||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "common"
|
name = "common"
|
||||||
version = "3.0.2"
|
version = "3.0.3"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"tempfile",
|
"tempfile",
|
||||||
]
|
]
|
||||||
@@ -1831,7 +1831,7 @@ dependencies = [
|
|||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "gpapi"
|
name = "gpapi"
|
||||||
version = "3.0.2"
|
version = "3.0.3"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"anyhow",
|
"anyhow",
|
||||||
"base64 0.22.1",
|
"base64 0.22.1",
|
||||||
@@ -1861,6 +1861,7 @@ dependencies = [
|
|||||||
"serde",
|
"serde",
|
||||||
"serde_json",
|
"serde_json",
|
||||||
"serde_urlencoded",
|
"serde_urlencoded",
|
||||||
|
"sha2",
|
||||||
"sha256",
|
"sha256",
|
||||||
"snow",
|
"snow",
|
||||||
"socket2",
|
"socket2",
|
||||||
@@ -1882,7 +1883,7 @@ dependencies = [
|
|||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "gpauth"
|
name = "gpauth"
|
||||||
version = "3.0.2"
|
version = "3.0.3"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"anyhow",
|
"anyhow",
|
||||||
"auth",
|
"auth",
|
||||||
@@ -1901,7 +1902,7 @@ dependencies = [
|
|||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "gpclient"
|
name = "gpclient"
|
||||||
version = "3.0.2"
|
version = "3.0.3"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"anyhow",
|
"anyhow",
|
||||||
"clap",
|
"clap",
|
||||||
@@ -1927,7 +1928,7 @@ dependencies = [
|
|||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "gpgui-helper"
|
name = "gpgui-helper"
|
||||||
version = "3.0.2"
|
version = "3.0.3"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"anyhow",
|
"anyhow",
|
||||||
"clap",
|
"clap",
|
||||||
@@ -1948,7 +1949,7 @@ dependencies = [
|
|||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "gphip"
|
name = "gphip"
|
||||||
version = "3.0.2"
|
version = "3.0.3"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"anyhow",
|
"anyhow",
|
||||||
"askama",
|
"askama",
|
||||||
@@ -1965,7 +1966,7 @@ dependencies = [
|
|||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "gpservice"
|
name = "gpservice"
|
||||||
version = "3.0.2"
|
version = "3.0.3"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"anyhow",
|
"anyhow",
|
||||||
"axum",
|
"axum",
|
||||||
@@ -3386,7 +3387,7 @@ dependencies = [
|
|||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "openconnect"
|
name = "openconnect"
|
||||||
version = "3.0.2"
|
version = "3.0.3"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"autotools",
|
"autotools",
|
||||||
"cc",
|
"cc",
|
||||||
@@ -3395,6 +3396,7 @@ dependencies = [
|
|||||||
"libc",
|
"libc",
|
||||||
"log",
|
"log",
|
||||||
"pkg-config",
|
"pkg-config",
|
||||||
|
"tempfile",
|
||||||
]
|
]
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
|
|||||||
+1
-1
@@ -11,7 +11,7 @@ members = [
|
|||||||
|
|
||||||
[workspace.package]
|
[workspace.package]
|
||||||
rust-version = "1.91"
|
rust-version = "1.91"
|
||||||
version = "3.0.2"
|
version = "3.0.3"
|
||||||
authors = ["Kevin Yue <[email protected]>"]
|
authors = ["Kevin Yue <[email protected]>"]
|
||||||
homepage = "https://github.com/yuezk/GlobalProtect-openconnect"
|
homepage = "https://github.com/yuezk/GlobalProtect-openconnect"
|
||||||
edition = "2024"
|
edition = "2024"
|
||||||
|
|||||||
@@ -3,6 +3,8 @@ SHELL := /bin/sh
|
|||||||
|
|
||||||
INCLUDE_GUI ?= 0
|
INCLUDE_GUI ?= 0
|
||||||
CARGO ?= cargo
|
CARGO ?= cargo
|
||||||
|
CARGO_TARGET_DIR ?= target
|
||||||
|
CARGO_RELEASE_DIR ?= $(CARGO_TARGET_DIR)/$(if $(CARGO_BUILD_TARGET),$(CARGO_BUILD_TARGET)/)release
|
||||||
DISABLE_RUST_TOOLCHAIN ?= 0
|
DISABLE_RUST_TOOLCHAIN ?= 0
|
||||||
RUST_VERSION ?= 1.91
|
RUST_VERSION ?= 1.91
|
||||||
IGNORE_RUST_VERSION ?= 0
|
IGNORE_RUST_VERSION ?= 0
|
||||||
@@ -33,7 +35,14 @@ BUILD_GUI_HELPER ?= 1
|
|||||||
|
|
||||||
# Indicates whether to build embedded webview auth support into gpauth
|
# Indicates whether to build embedded webview auth support into gpauth
|
||||||
BUILD_WEBVIEW_AUTH ?= 1
|
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
|
PREFIX ?= /usr/local
|
||||||
|
endif
|
||||||
BSD_FLAVOR ?= $(shell uname -s | tr '[:upper:]' '[:lower:]')
|
BSD_FLAVOR ?= $(shell uname -s | tr '[:upper:]' '[:lower:]')
|
||||||
GPGUI_BINARY ?= ../gpgui/target/release/gpgui
|
GPGUI_BINARY ?= ../gpgui/target/release/gpgui
|
||||||
|
|
||||||
@@ -139,86 +148,74 @@ clean:
|
|||||||
rm -rf .vendor
|
rm -rf .vendor
|
||||||
rm -rf apps/gpgui-helper/node_modules
|
rm -rf apps/gpgui-helper/node_modules
|
||||||
|
|
||||||
install:
|
ifeq ($(shell uname -s),Darwin)
|
||||||
@echo "Installing $(PKG_NAME)..."
|
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-gpclient-unix:
|
||||||
install -Dm755 target/release/gpauth $(DESTDIR)/usr/bin/gpauth
|
install -d "$(DESTDIR)$(PREFIX)/bin" "$(DESTDIR)$(PREFIX)/libexec/gpclient"
|
||||||
install -Dm755 target/release/gpservice $(DESTDIR)/usr/bin/gpservice
|
install -m 755 "$(CARGO_RELEASE_DIR)/gpclient" "$(DESTDIR)$(PREFIX)/bin/"
|
||||||
install -Dm755 target/release/gp-hip-script-installer $(DESTDIR)/usr/libexec/gpclient/gp-hip-script-installer
|
install -m 755 packaging/files/usr/libexec/gpclient/vpnc-script "$(DESTDIR)$(PREFIX)/libexec/gpclient/"
|
||||||
install -Dm755 target/release/gp-vpnc-script-installer $(DESTDIR)/usr/libexec/gpclient/gp-vpnc-script-installer
|
|
||||||
|
|
||||||
# Install the GUI components if BUILD_GUI_HELPER is set to 1
|
install-gpclient-macos:
|
||||||
if [ $(BUILD_GUI_HELPER) -eq 1 ]; then \
|
install -d "$(DESTDIR)$(PREFIX)/bin" "$(DESTDIR)$(PREFIX)/lib/gpclient" "$(DESTDIR)$(PREFIX)/libexec/gpclient"
|
||||||
install -Dm755 target/release/gpgui-helper $(DESTDIR)/usr/bin/gpgui-helper; \
|
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
|
fi
|
||||||
|
set -e; if [ -f "$(GPGUI_BINARY)" ]; then \
|
||||||
if [ -f .build/gpgui/gpgui_*/gpgui ]; then \
|
install -m 755 "$(GPGUI_BINARY)" "$(DESTDIR)$(PREFIX)/bin/gpgui"; \
|
||||||
install -Dm755 .build/gpgui/gpgui_*/gpgui $(DESTDIR)/usr/bin/gpgui; \
|
|
||||||
fi
|
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-bsd: install-unix
|
||||||
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
|
@echo "Installing BSD integration under $(PREFIX)..."
|
||||||
install -Dm755 packaging/files/usr/lib/NetworkManager/dispatcher.d/gpclient-nm-hook $(DESTDIR)/usr/lib/NetworkManager/dispatcher.d/gpclient-nm-hook
|
install -d "$(DESTDIR)$(PREFIX)/share/applications" "$(DESTDIR)$(PREFIX)/share/polkit-1/actions"
|
||||||
|
install -m 644 packaging/bsd/gpgui.desktop "$(DESTDIR)$(PREFIX)/share/applications/"
|
||||||
install -Dm644 packaging/files/usr/share/applications/gpgui.desktop $(DESTDIR)/usr/share/applications/gpgui.desktop
|
install -m 644 packaging/bsd/com.yuezk.gpgui.policy "$(DESTDIR)$(PREFIX)/share/polkit-1/actions/"
|
||||||
install -Dm644 packaging/files/usr/share/icons/hicolor/scalable/apps/gpgui.svg $(DESTDIR)/usr/share/icons/hicolor/scalable/apps/gpgui.svg
|
sh scripts/relocate-install-paths.sh "$(PREFIX)" /usr/local "$(DESTDIR)$(PREFIX)"
|
||||||
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
|
|
||||||
|
|
||||||
clean-bsd-package:
|
clean-bsd-package:
|
||||||
rm -rf .build/$(BSD_FLAVOR)
|
rm -rf .build/$(BSD_FLAVOR)
|
||||||
@@ -290,42 +287,54 @@ package-openbsd: clean-bsd-package
|
|||||||
.build/openbsd/artifacts/$(PKG_NAME)-$(VERSION)-openbsd-$$openbsd_arch.tgz
|
.build/openbsd/artifacts/$(PKG_NAME)-$(VERSION)-openbsd-$$openbsd_arch.tgz
|
||||||
$(MAKE) bsd-gpgui-tarball BSD_FLAVOR=openbsd GPGUI_BINARY="$(GPGUI_BINARY)"
|
$(MAKE) bsd-gpgui-tarball BSD_FLAVOR=openbsd GPGUI_BINARY="$(GPGUI_BINARY)"
|
||||||
|
|
||||||
uninstall:
|
ifeq ($(shell uname -s),Darwin)
|
||||||
@echo "Uninstalling $(PKG_NAME)..."
|
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
|
.PHONY: install install-gpclient install-macos install-unix install-linux install-bsd \
|
||||||
rm -f $(DESTDIR)/usr/bin/gpauth
|
install-gpclient-macos install-gpclient-unix \
|
||||||
rm -f $(DESTDIR)/usr/bin/gpservice
|
uninstall uninstall-macos uninstall-unix uninstall-linux uninstall-bsd
|
||||||
rm -f $(DESTDIR)/usr/libexec/gpclient/gp-hip-script-installer
|
|
||||||
rm -f $(DESTDIR)/usr/bin/gpgui-helper
|
|
||||||
rm -f $(DESTDIR)/usr/bin/gpgui
|
|
||||||
|
|
||||||
rm -f $(DESTDIR)/usr/libexec/gpclient/vpnc-script
|
uninstall-macos:
|
||||||
rm -f $(DESTDIR)/usr/libexec/gpclient/gp-vpnc-script-installer
|
@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
|
uninstall-unix:
|
||||||
rm -f $(DESTDIR)/usr/lib/NetworkManager/dispatcher.d/gpclient-nm-hook
|
@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
|
uninstall-linux: uninstall-unix
|
||||||
rm -f $(DESTDIR)/usr/share/icons/hicolor/scalable/apps/gpgui.svg
|
rm -f "$(DESTDIR)$(PREFIX)/lib/NetworkManager/dispatcher.d/pre-down.d/gpclient.down" \
|
||||||
rm -f $(DESTDIR)/usr/share/icons/hicolor/32x32/apps/gpgui.png
|
"$(DESTDIR)$(PREFIX)/lib/NetworkManager/dispatcher.d/gpclient-nm-hook"
|
||||||
rm -f $(DESTDIR)/usr/share/icons/hicolor/128x128/apps/gpgui.png
|
rm -f "$(DESTDIR)/var/lib/gpclient/gpgui" \
|
||||||
rm -f $(DESTDIR)/usr/share/icons/hicolor/256x256/apps/gpgui.png
|
"$(DESTDIR)/var/lib/gpclient/scripts/vpnc-script" \
|
||||||
rm -f $(DESTDIR)/usr/share/icons/hicolor/256x256@2/apps/gpgui.png
|
"$(DESTDIR)/var/lib/gpclient/scripts/vpnc-script.metadata"
|
||||||
rm -f $(DESTDIR)/usr/share/icons/hicolor/scalable/status/gpgui-connected-symbolic.svg
|
rmdir "$(DESTDIR)/var/lib/gpclient/scripts" "$(DESTDIR)/var/lib/gpclient" 2>/dev/null || true
|
||||||
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
|
|
||||||
|
|
||||||
rm -f $(DESTDIR)/var/lib/gpclient/gpgui \
|
uninstall-bsd: uninstall-unix
|
||||||
$(DESTDIR)/var/lib/gpclient/scripts/vpnc-script \
|
rm -f "$(DESTDIR)/usr/local/libexec/gpclient/gpgui" \
|
||||||
$(DESTDIR)/var/lib/gpclient/scripts/vpnc-script.metadata || \
|
"$(DESTDIR)/var/db/gpclient/scripts/vpnc-script" \
|
||||||
echo "Warning: failed to remove gpclient runtime files" >&2
|
"$(DESTDIR)/var/db/gpclient/scripts/vpnc-script.metadata"
|
||||||
rmdir $(DESTDIR)/var/lib/gpclient/scripts 2>/dev/null || true
|
rmdir "$(DESTDIR)/var/db/gpclient/scripts" "$(DESTDIR)/var/db/gpclient" 2>/dev/null || true
|
||||||
rmdir $(DESTDIR)/var/lib/gpclient 2>/dev/null || true
|
|
||||||
|
|
||||||
clean-debian:
|
clean-debian:
|
||||||
rm -rf .build/deb
|
rm -rf .build/deb
|
||||||
|
|||||||
@@ -4,6 +4,15 @@ const UNKNOWN_COMMIT: &str = "unknown";
|
|||||||
const DISPLAY_COMMIT_LEN: usize = 9;
|
const DISPLAY_COMMIT_LEN: usize = 9;
|
||||||
|
|
||||||
fn main() {
|
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=SOURCE_GIT_COMMIT");
|
||||||
println!("cargo:rerun-if-env-changed=GPCLIENT_GIT_COMMIT");
|
println!("cargo:rerun-if-env-changed=GPCLIENT_GIT_COMMIT");
|
||||||
println!("cargo:rerun-if-env-changed=GITHUB_SHA");
|
println!("cargo:rerun-if-env-changed=GITHUB_SHA");
|
||||||
|
|||||||
@@ -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!(handler.auth_attempt_fixture.borrow().observed.len(), 2);
|
||||||
assert_eq!(worker.await.unwrap().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"
|
||||||
|
);
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -9,7 +9,7 @@ fn executable(dir: &std::path::Path, name: &str, body: &str) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
#[tokio::test]
|
#[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 dir = tempfile::tempdir().unwrap();
|
||||||
let bin = dir.path().join("bin");
|
let bin = dir.path().join("bin");
|
||||||
std::fs::create_dir(&bin).unwrap();
|
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"])
|
.args(["--fix-openssl", "diagnostics", "--json", "--output"])
|
||||||
.arg(&report_file)
|
.arg(&report_file)
|
||||||
.env("PATH", format!("{}:/usr/bin:/bin", bin.display()))
|
.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("GP_DIAGNOSTICS_PRIVATE_TOKEN", "secret-value-must-not-appear")
|
||||||
.env("XDG_CURRENT_DESKTOP", "TestDesktop\nInjected: secret")
|
.env("XDG_CURRENT_DESKTOP", "TestDesktop\nInjected: secret")
|
||||||
.stdin(Stdio::null())
|
.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();
|
let report: serde_json::Value = serde_json::from_str(&text).unwrap();
|
||||||
assert_eq!(report["schema_version"], 1);
|
assert_eq!(report["schema_version"], 1);
|
||||||
assert_eq!(report["fields"]["os"]["value"], "Linux");
|
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!(
|
assert!(
|
||||||
report["fields"]["gpclient_version"]["value"]
|
report["fields"]["gpclient_version"]["value"]
|
||||||
.as_str()
|
.as_str()
|
||||||
|
|||||||
@@ -4,6 +4,15 @@ const UNKNOWN_COMMIT: &str = "unknown";
|
|||||||
const DISPLAY_COMMIT_LEN: usize = 9;
|
const DISPLAY_COMMIT_LEN: usize = 9;
|
||||||
|
|
||||||
fn main() {
|
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=GPSERVICE_GIT_COMMIT");
|
||||||
println!("cargo:rerun-if-env-changed=SOURCE_GIT_COMMIT");
|
println!("cargo:rerun-if-env-changed=SOURCE_GIT_COMMIT");
|
||||||
println!("cargo:rerun-if-env-changed=GITHUB_SHA");
|
println!("cargo:rerun-if-env-changed=GITHUB_SHA");
|
||||||
|
|||||||
@@ -1,5 +1,15 @@
|
|||||||
# Changelog
|
# 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
|
## 3.0.2
|
||||||
|
|
||||||
### Added
|
### Added
|
||||||
|
|||||||
@@ -14,7 +14,9 @@ impl AuthServer {
|
|||||||
let server = Server::http(addr).map_err(|err| anyhow::anyhow!(err))?;
|
let server = Server::http(addr).map_err(|err| anyhow::anyhow!(err))?;
|
||||||
let auth_id = Uuid::new_v4().to_string();
|
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 {
|
pub fn auth_url(&self) -> String {
|
||||||
@@ -22,8 +24,6 @@ impl AuthServer {
|
|||||||
}
|
}
|
||||||
|
|
||||||
pub fn serve_request(&self, auth_request: &str) {
|
pub fn serve_request(&self, auth_request: &str) {
|
||||||
info!("auth server started at: {}", self.auth_url());
|
|
||||||
|
|
||||||
for req in self.server.incoming_requests() {
|
for req in self.server.incoming_requests() {
|
||||||
info!("received request, method: {}, url: {}", req.method(), req.url());
|
info!("received request, method: {}, url: {}", req.method(), req.url());
|
||||||
|
|
||||||
|
|||||||
@@ -1,4 +1,7 @@
|
|||||||
use std::net::{IpAddr, SocketAddr};
|
use std::{
|
||||||
|
io::Write,
|
||||||
|
net::{IpAddr, SocketAddr},
|
||||||
|
};
|
||||||
|
|
||||||
use browser_launcher::Browser as LaunchBrowser;
|
use browser_launcher::Browser as LaunchBrowser;
|
||||||
use gpapi::auth::SamlAuthData;
|
use gpapi::auth::SamlAuthData;
|
||||||
@@ -34,7 +37,7 @@ impl<'a> BrowserAuthenticator<'a> {
|
|||||||
let auth_url = auth_server.auth_url();
|
let auth_url = auth_server.auth_url();
|
||||||
|
|
||||||
let auth_request = self.auth_request.to_string();
|
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);
|
auth_server.serve_request(&auth_request);
|
||||||
});
|
});
|
||||||
|
|
||||||
@@ -55,6 +58,7 @@ Note that the URL is only valid for a single use.
|
|||||||
"#,
|
"#,
|
||||||
auth_url
|
auth_url
|
||||||
);
|
);
|
||||||
|
auth_server_task.await?;
|
||||||
return read_auth_data_from_stdin();
|
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> {
|
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();
|
let mut data = String::new();
|
||||||
std::io::stdin().read_line(&mut data)?;
|
std::io::stdin().read_line(&mut data)?;
|
||||||
|
|
||||||
|
|||||||
@@ -93,6 +93,12 @@ fn sibling_binary_for_executable(executable: &Path, binary_name: &str) -> Option
|
|||||||
if is_file(&binary) {
|
if is_file(&binary) {
|
||||||
return Some(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")]
|
#[cfg(target_os = "macos")]
|
||||||
if let Some(binary) = macos::helper_path(&executable, binary_name)
|
if let Some(binary) = macos::helper_path(&executable, binary_name)
|
||||||
&& is_file(&binary)
|
&& is_file(&binary)
|
||||||
@@ -121,6 +127,23 @@ fn is_file(path: &Path) -> bool {
|
|||||||
mod tests {
|
mod tests {
|
||||||
use super::*;
|
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]
|
#[test]
|
||||||
#[cfg(target_os = "macos")]
|
#[cfg(target_os = "macos")]
|
||||||
fn desktop_resolves_helpers_in_the_actual_app_bundle_layout() {
|
fn desktop_resolves_helpers_in_the_actual_app_bundle_layout() {
|
||||||
|
|||||||
@@ -34,6 +34,7 @@ uzers.workspace = true
|
|||||||
serde_urlencoded.workspace = true
|
serde_urlencoded.workspace = true
|
||||||
md5.workspace = true
|
md5.workspace = true
|
||||||
sha256.workspace = true
|
sha256.workspace = true
|
||||||
|
sha2 = "0.10"
|
||||||
uuid = { workspace = true, features = ["v4", "v5", "serde"] }
|
uuid = { workspace = true, features = ["v4", "v5", "serde"] }
|
||||||
chrono.workspace = true
|
chrono.workspace = true
|
||||||
humantime.workspace = true
|
humantime.workspace = true
|
||||||
|
|||||||
@@ -1,6 +1,7 @@
|
|||||||
//! Neutral device-anchor transport model and deterministic derivation.
|
//! Neutral device-anchor transport model and deterministic derivation.
|
||||||
use base64::{Engine, engine::general_purpose::URL_SAFE_NO_PAD};
|
use base64::{Engine, engine::general_purpose::URL_SAFE_NO_PAD};
|
||||||
use serde::{Deserialize, Serialize};
|
use serde::{Deserialize, Serialize};
|
||||||
|
use sha2::{Digest, Sha256};
|
||||||
use std::fmt;
|
use std::fmt;
|
||||||
|
|
||||||
#[derive(Debug, Clone, Copy, PartialEq, Eq, Serialize, Deserialize)]
|
#[derive(Debug, Clone, Copy, PartialEq, Eq, Serialize, Deserialize)]
|
||||||
@@ -68,7 +69,7 @@ impl DeviceAnchor {
|
|||||||
let mut input = domain.to_vec();
|
let mut input = domain.to_vec();
|
||||||
input.extend_from_slice(seed.as_ref());
|
input.extend_from_slice(seed.as_ref());
|
||||||
Self {
|
Self {
|
||||||
hardware_id: URL_SAFE_NO_PAD.encode(openssl::sha::sha256(&input)),
|
hardware_id: URL_SAFE_NO_PAD.encode(Sha256::digest(&input)),
|
||||||
source,
|
source,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -78,11 +79,36 @@ impl DeviceAnchor {
|
|||||||
mod tests {
|
mod tests {
|
||||||
use super::*;
|
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]
|
#[test]
|
||||||
fn hashes_original_seed_order_with_stable_domain_separation() {
|
fn hashes_original_seed_order_with_stable_domain_separation() {
|
||||||
let mac = DeviceAnchor::derive(AnchorSource::UnixMac, [0, 17, 34, 51, 68, 85]);
|
let mac = DeviceAnchor::derive(AnchorSource::UnixMac, [0, 17, 34, 51, 68, 85]);
|
||||||
assert!(mac.validate());
|
assert!(mac.validate());
|
||||||
assert_eq!(mac.hardware_id, "UWDOx4AVJEuCAYfJBaPioyGtRfAkJBhMYSi8LuFsE1A");
|
|
||||||
assert_ne!(
|
assert_ne!(
|
||||||
mac.hardware_id,
|
mac.hardware_id,
|
||||||
DeviceAnchor::derive(AnchorSource::UnixMac, [85, 68, 51, 34, 17, 0]).hardware_id
|
DeviceAnchor::derive(AnchorSource::UnixMac, [85, 68, 51, 34, 17, 0]).hardware_id
|
||||||
|
|||||||
@@ -12,7 +12,10 @@ use tokio_util::sync::CancellationToken;
|
|||||||
use crate::auth::AuthWindowTheme;
|
use crate::auth::AuthWindowTheme;
|
||||||
use crate::{auth::SamlAuthResult, credential::Credential, log_format::LogFormat, os_profile::OsProfile};
|
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};
|
use super::rendering_recovery::{RenderingCrash, StderrDiagnostic, eligible, is_crash_exit};
|
||||||
|
|
||||||
@@ -300,6 +303,7 @@ impl<'a> SamlAuthLauncher<'a> {
|
|||||||
if embedded && bundled && self.dmabuf_disabled {
|
if embedded && bundled && self.dmabuf_disabled {
|
||||||
command.env("WEBKIT_DISABLE_DMABUF_RENDERER", "1");
|
command.env("WEBKIT_DISABLE_DMABUF_RENDERER", "1");
|
||||||
}
|
}
|
||||||
|
let stdin = auth_stdin(self.browser);
|
||||||
let cancellation = self.cancellation.clone();
|
let cancellation = self.cancellation.clone();
|
||||||
let output = tokio::task::spawn_blocking(move || {
|
let output = tokio::task::spawn_blocking(move || {
|
||||||
let check = || {
|
let check = || {
|
||||||
@@ -319,7 +323,7 @@ impl<'a> SamlAuthLauncher<'a> {
|
|||||||
Some(MAX_AUTH_RESULT_BYTES),
|
Some(MAX_AUTH_RESULT_BYTES),
|
||||||
&mut |bytes| diagnostic.push(bytes),
|
&mut |bytes| diagnostic.push(bytes),
|
||||||
&mut std::io::stderr(),
|
&mut std::io::stderr(),
|
||||||
None,
|
stdin,
|
||||||
)?;
|
)?;
|
||||||
Ok::<_, std::io::Error>((output.output, diagnostic.matched()))
|
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 {
|
fn is_bundled_authenticator(program: &Path, bundled: &Path) -> bool {
|
||||||
match (program.canonicalize(), bundled.canonicalize()) {
|
match (program.canonicalize(), bundled.canonicalize()) {
|
||||||
(Ok(program), Ok(bundled)) => program == bundled,
|
(Ok(program), Ok(bundled)) => program == bundled,
|
||||||
@@ -449,6 +461,15 @@ mod tests {
|
|||||||
|
|
||||||
assert_eq!(launcher.browser_listen, Some(listen_ip));
|
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]
|
#[test]
|
||||||
fn failed_authenticator_discards_partial_or_valid_stdout_before_decoding() {
|
fn failed_authenticator_discards_partial_or_valid_stdout_before_decoding() {
|
||||||
use std::os::unix::process::ExitStatusExt;
|
use std::os::unix::process::ExitStatusExt;
|
||||||
@@ -489,7 +510,7 @@ mod tests {
|
|||||||
let executable = directory.path().join("auth-fixture");
|
let executable = directory.path().join("auth-fixture");
|
||||||
std::fs::write(
|
std::fs::write(
|
||||||
&executable,
|
&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();
|
.unwrap();
|
||||||
// The launcher drops root privileges in CI; its child must be able to
|
// The launcher drops root privileges in CI; its child must be able to
|
||||||
|
|||||||
@@ -14,13 +14,21 @@ use nix::{
|
|||||||
|
|
||||||
use super::collection::CollectionControl;
|
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.
|
/// Owns and reaps the command's process group. Its async caller must cancel and await this worker.
|
||||||
pub(crate) fn run_controlled(
|
pub(crate) fn run_controlled(
|
||||||
command: Command,
|
command: Command,
|
||||||
control: &dyn CollectionControl,
|
control: &dyn CollectionControl,
|
||||||
output_limit: usize,
|
output_limit: usize,
|
||||||
) -> io::Result<Output> {
|
) -> 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)]
|
#[derive(Debug)]
|
||||||
@@ -35,15 +43,9 @@ pub(crate) fn run_observed(
|
|||||||
output_limit: Option<usize>,
|
output_limit: Option<usize>,
|
||||||
observer: &mut dyn FnMut(&[u8]),
|
observer: &mut dyn FnMut(&[u8]),
|
||||||
stderr_sink: &mut dyn Write,
|
stderr_sink: &mut dyn Write,
|
||||||
stdin_frame: Option<&[u8]>,
|
stdin: ChildInput<'_>,
|
||||||
) -> io::Result<ObservedOutput> {
|
) -> io::Result<ObservedOutput> {
|
||||||
run(
|
run(command, control, output_limit, Some((observer, stderr_sink)), stdin)
|
||||||
command,
|
|
||||||
control,
|
|
||||||
output_limit,
|
|
||||||
Some((observer, stderr_sink)),
|
|
||||||
stdin_frame,
|
|
||||||
)
|
|
||||||
}
|
}
|
||||||
|
|
||||||
fn nonblocking(fd: &impl std::os::fd::AsFd) -> io::Result<()> {
|
fn nonblocking(fd: &impl std::os::fd::AsFd) -> io::Result<()> {
|
||||||
@@ -61,26 +63,31 @@ fn run(
|
|||||||
control: &dyn CollectionControl,
|
control: &dyn CollectionControl,
|
||||||
output_limit: Option<usize>,
|
output_limit: Option<usize>,
|
||||||
mut observation: Option<(&mut dyn FnMut(&[u8]), &mut dyn Write)>,
|
mut observation: Option<(&mut dyn FnMut(&[u8]), &mut dyn Write)>,
|
||||||
stdin_frame: Option<&[u8]>,
|
stdin: ChildInput<'_>,
|
||||||
) -> io::Result<ObservedOutput> {
|
) -> io::Result<ObservedOutput> {
|
||||||
control.check()?;
|
control.check()?;
|
||||||
command
|
command.stdout(if output_limit.is_some() {
|
||||||
.stdout(if output_limit.is_some() {
|
|
||||||
Stdio::piped()
|
Stdio::piped()
|
||||||
} else {
|
} else {
|
||||||
Stdio::inherit()
|
Stdio::inherit()
|
||||||
})
|
|
||||||
.process_group(0);
|
|
||||||
command.stdin(if stdin_frame.is_some() {
|
|
||||||
Stdio::piped()
|
|
||||||
} else {
|
|
||||||
Stdio::null()
|
|
||||||
});
|
});
|
||||||
|
// 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() {
|
if observation.is_some() {
|
||||||
command.stderr(Stdio::piped());
|
command.stderr(Stdio::piped());
|
||||||
}
|
}
|
||||||
let mut child = ControlledChild {
|
let mut child = ControlledChild {
|
||||||
process: command.spawn()?,
|
process: command.spawn()?,
|
||||||
|
own_group,
|
||||||
stopped: false,
|
stopped: false,
|
||||||
};
|
};
|
||||||
let mut stdout = child.process.stdout.take();
|
let mut stdout = child.process.stdout.take();
|
||||||
@@ -187,13 +194,18 @@ fn run(
|
|||||||
|
|
||||||
struct ControlledChild {
|
struct ControlledChild {
|
||||||
process: Child,
|
process: Child,
|
||||||
|
own_group: bool,
|
||||||
stopped: bool,
|
stopped: bool,
|
||||||
}
|
}
|
||||||
|
|
||||||
impl ControlledChild {
|
impl ControlledChild {
|
||||||
fn stop_helpers(&mut self) {
|
fn stop_helpers(&mut self) {
|
||||||
if !self.stopped {
|
if !self.stopped {
|
||||||
|
if self.own_group {
|
||||||
let _ = killpg(Pid::from_raw(self.process.id() as i32), Signal::SIGKILL);
|
let _ = killpg(Pid::from_raw(self.process.id() as i32), Signal::SIGKILL);
|
||||||
|
} else {
|
||||||
|
let _ = self.process.kill();
|
||||||
|
}
|
||||||
self.stopped = true;
|
self.stopped = true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -223,7 +235,7 @@ mod tests {
|
|||||||
Some(1024),
|
Some(1024),
|
||||||
&mut |bytes| seen.extend_from_slice(bytes),
|
&mut |bytes| seen.extend_from_slice(bytes),
|
||||||
&mut sink,
|
&mut sink,
|
||||||
None,
|
ChildInput::Null,
|
||||||
)
|
)
|
||||||
.unwrap();
|
.unwrap();
|
||||||
assert!(!output.output.status.success());
|
assert!(!output.output.status.success());
|
||||||
@@ -244,7 +256,15 @@ mod tests {
|
|||||||
Ok(())
|
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_eq!(error.kind(), io::ErrorKind::Interrupted);
|
||||||
assert!(start.elapsed() < Duration::from_secs(2));
|
assert!(start.elapsed() < Duration::from_secs(2));
|
||||||
}
|
}
|
||||||
@@ -259,7 +279,7 @@ mod tests {
|
|||||||
None,
|
None,
|
||||||
&mut |_| {},
|
&mut |_| {},
|
||||||
&mut io::sink(),
|
&mut io::sink(),
|
||||||
Some(&vec![0; 128 * 1024]),
|
ChildInput::Frame(&vec![0; 128 * 1024]),
|
||||||
)
|
)
|
||||||
.unwrap();
|
.unwrap();
|
||||||
assert_eq!(observed.output.status.code(), Some(2));
|
assert_eq!(observed.output.status.code(), Some(2));
|
||||||
@@ -284,7 +304,51 @@ mod tests {
|
|||||||
None,
|
None,
|
||||||
&mut |_| {},
|
&mut |_| {},
|
||||||
&mut io::sink(),
|
&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();
|
.unwrap_err();
|
||||||
assert_eq!(error.kind(), io::ErrorKind::Interrupted);
|
assert_eq!(error.kind(), io::ErrorKind::Interrupted);
|
||||||
|
|||||||
@@ -1,5 +1,5 @@
|
|||||||
use super::{
|
use super::{
|
||||||
command_runner::run_observed,
|
command_runner::{ChildInput, run_observed},
|
||||||
rendering_recovery::{RenderingCrash, StderrDiagnostic, eligible_with_inheritance, is_crash_exit},
|
rendering_recovery::{RenderingCrash, StderrDiagnostic, eligible_with_inheritance, is_crash_exit},
|
||||||
};
|
};
|
||||||
use crate::service::transport::SessionCredential;
|
use crate::service::transport::SessionCredential;
|
||||||
@@ -55,7 +55,7 @@ pub(super) async fn launch_desktop_child(
|
|||||||
None,
|
None,
|
||||||
&mut |bytes| diagnostic.push(bytes),
|
&mut |bytes| diagnostic.push(bytes),
|
||||||
&mut sink,
|
&mut sink,
|
||||||
Some(&frame),
|
ChildInput::Frame(&frame),
|
||||||
)?;
|
)?;
|
||||||
let output = observed.output;
|
let output = observed.output;
|
||||||
if is_crash_exit(output.status) && retry_eligible && diagnostic.matched() {
|
if is_crash_exit(output.status) && retry_eligible && diagnostic.matched() {
|
||||||
|
|||||||
@@ -110,7 +110,7 @@ mod tests {
|
|||||||
let path = fixture(
|
let path = fixture(
|
||||||
&dir,
|
&dir,
|
||||||
&credential,
|
&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())]);
|
let mut envs = HashMap::from([("WAYLAND_DISPLAY".into(), "wayland-0".into())]);
|
||||||
for override_value in [None, Some(""), Some("0"), Some("1")] {
|
for override_value in [None, Some(""), Some("0"), Some("1")] {
|
||||||
|
|||||||
@@ -97,14 +97,15 @@ impl StderrDiagnostic {
|
|||||||
}
|
}
|
||||||
|
|
||||||
fn check_line(&mut self) {
|
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
|
if !self.overflow
|
||||||
&& (line.starts_with(b"Gdk-Message:")
|
&& (line.starts_with(b"Gdk-Message:")
|
||||||
|| line.starts_with(b"(gpgui:")
|
|| line.starts_with(b"(gpgui:")
|
||||||
|| line.starts_with(b"(gpauth:")
|
|| line.starts_with(b"(gpauth:")
|
||||||
|| line.starts_with(b"(gpgui-helper:"))
|
|| line.starts_with(b"(gpgui-helper:"))
|
||||||
&& line.windows(b"Gdk-Message:".len()).any(|part| part == b"Gdk-Message:")
|
&& 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;
|
self.matched = true;
|
||||||
}
|
}
|
||||||
@@ -123,13 +124,49 @@ mod tests {
|
|||||||
#[test]
|
#[test]
|
||||||
fn recognizes_split_diagnostic_without_matching_quoted_warning() {
|
fn recognizes_split_diagnostic_without_matching_quoted_warning() {
|
||||||
let mut observer = StderrDiagnostic::default();
|
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());
|
assert!(!observer.matched());
|
||||||
observer.push(b"Gdk-Message: 12:00:00: Error 71 (Protocol error) dispat");
|
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());
|
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]
|
#[test]
|
||||||
fn oversized_lines_do_not_grow_or_match() {
|
fn oversized_lines_do_not_grow_or_match() {
|
||||||
let mut observer = StderrDiagnostic::default();
|
let mut observer = StderrDiagnostic::default();
|
||||||
|
|||||||
@@ -15,3 +15,6 @@ cc = "1"
|
|||||||
autotools = "0.2"
|
autotools = "0.2"
|
||||||
pkg-config = "0.3"
|
pkg-config = "0.3"
|
||||||
fs_extra = "1"
|
fs_extra = "1"
|
||||||
|
|
||||||
|
[dev-dependencies]
|
||||||
|
tempfile = "3"
|
||||||
@@ -137,6 +137,27 @@ fn build_openconnect(deps_dir: &PathBuf, out_dir: &PathBuf) -> PathBuf {
|
|||||||
let lib_dir = dst.join("lib");
|
let lib_dir = dst.join("lib");
|
||||||
let include_dir = dst.join("include");
|
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());
|
println!("cargo:rustc-link-search=native={}", lib_dir.display());
|
||||||
|
|
||||||
#[cfg(target_os = "macos")]
|
#[cfg(target_os = "macos")]
|
||||||
|
|||||||
@@ -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()) {
|
if let Some(path) = std::env::var_os("GP_VPNC_SCRIPT").filter(|path| !path.is_empty()) {
|
||||||
return configured_script(Path::new(&path));
|
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)
|
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> {
|
fn configured_script(path: &Path) -> Option<String> {
|
||||||
if path.is_absolute() && path.is_file() && path.is_executable() {
|
if path.is_absolute() && path.is_file() && path.is_executable() {
|
||||||
return path.to_str().map(str::to_owned);
|
return path.to_str().map(str::to_owned);
|
||||||
@@ -62,6 +76,26 @@ pub fn check_executable(file: &str) -> Result<(), io::Error> {
|
|||||||
mod tests {
|
mod tests {
|
||||||
use super::*;
|
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]
|
#[test]
|
||||||
fn configured_script_requires_an_absolute_executable_path() {
|
fn configured_script_requires_an_absolute_executable_path() {
|
||||||
assert_eq!(configured_script(Path::new("/bin/sh")), Some("/bin/sh".to_owned()));
|
assert_eq!(configured_script(Path::new("/bin/sh")), Some("/bin/sh".to_owned()));
|
||||||
|
|||||||
+1
-1
@@ -31,7 +31,7 @@ gpclient diagnostics --json --output diagnostics.json
|
|||||||
The collector refuses to overwrite an existing file. Choose another filename or
|
The collector refuses to overwrite an existing file. Choose another filename or
|
||||||
remove the previous report yourself before collecting again.
|
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
|
command is unknown, use the standalone script below. You do not need to upgrade
|
||||||
before reporting a problem.
|
before reporting a problem.
|
||||||
|
|
||||||
|
|||||||
@@ -29,8 +29,8 @@
|
|||||||
cargoToml = builtins.fromTOML (builtins.readFile ./Cargo.toml);
|
cargoToml = builtins.fromTOML (builtins.readFile ./Cargo.toml);
|
||||||
pname = "globalprotect-openconnect";
|
pname = "globalprotect-openconnect";
|
||||||
version = cargoToml.workspace.package.version;
|
version = cargoToml.workspace.package.version;
|
||||||
releaseTag = "v3.0.1";
|
releaseTag = "v3.0.2";
|
||||||
releaseVersion = "3.0.1";
|
releaseVersion = "3.0.2";
|
||||||
|
|
||||||
toolchain = pkgs.rust-bin.fromRustupToolchainFile ./rust-toolchain.toml;
|
toolchain = pkgs.rust-bin.fromRustupToolchainFile ./rust-toolchain.toml;
|
||||||
|
|
||||||
@@ -55,8 +55,8 @@
|
|||||||
cpu = pkgs.stdenv.hostPlatform.parsed.cpu.name;
|
cpu = pkgs.stdenv.hostPlatform.parsed.cpu.name;
|
||||||
|
|
||||||
gpguiHashes = {
|
gpguiHashes = {
|
||||||
x86_64 = "sha256-lc05BKc0lu0qoZWmOPakjxXmenv1XoiQCOMIh5KE8A8=";
|
x86_64 = "sha256-ncJ6xAk8nUgMc5ELoCXtrN25XbSjs25jo4w5oBF+9f0=";
|
||||||
aarch64 = "sha256-bnmGQ82GJbS0z8yelMeOxzwSNV92iVk8hGEUUd4jkFA=";
|
aarch64 = "sha256-SGQc4unT9thXQb8cFwVffNXobo9Gjy3NoDqyAkBiUy8=";
|
||||||
};
|
};
|
||||||
|
|
||||||
gpguiArchive = pkgs.fetchurl {
|
gpguiArchive = pkgs.fetchurl {
|
||||||
@@ -70,8 +70,8 @@
|
|||||||
};
|
};
|
||||||
|
|
||||||
binaryHashes = {
|
binaryHashes = {
|
||||||
x86_64 = "sha256-/nKUzhlIdlgK2Xpv2nCQ/tuwUCTYuoSSft7sCc/M7U0=";
|
x86_64 = "sha256-1TNt/NJ8rD143ivbqUFpacLV6YpihhVDVt8Do74QIxs=";
|
||||||
aarch64 = "sha256-pDJvHT8p6fMFtSyJypr/3wL/OPHK/TSL7HMt63nP5oQ=";
|
aarch64 = "sha256-TP7nLG++vsRPpq/GL/07avCjZYFRM20TKnpfpMtfMBI=";
|
||||||
};
|
};
|
||||||
|
|
||||||
binaryArchive = pkgs.fetchurl {
|
binaryArchive = pkgs.fetchurl {
|
||||||
@@ -118,6 +118,7 @@
|
|||||||
[
|
[
|
||||||
libxml2
|
libxml2
|
||||||
zlib
|
zlib
|
||||||
|
openssl
|
||||||
lz4
|
lz4
|
||||||
gnutls
|
gnutls
|
||||||
p11-kit
|
p11-kit
|
||||||
@@ -130,30 +131,10 @@
|
|||||||
libsoup_3
|
libsoup_3
|
||||||
webkitgtk_4_1
|
webkitgtk_4_1
|
||||||
glib-networking
|
glib-networking
|
||||||
openssl
|
|
||||||
libsecret
|
libsecret
|
||||||
libayatana-appindicator
|
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 = ''
|
installNixosPolkitRule = ''
|
||||||
chmod u+w $out/share $out/share/polkit-1 2>/dev/null || true
|
chmod u+w $out/share $out/share/polkit-1 2>/dev/null || true
|
||||||
install -d $out/share/polkit-1/rules.d
|
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
|
# Must be set to true to avoid issues with the Tauri build process
|
||||||
singleStep = true;
|
singleStep = true;
|
||||||
|
|
||||||
|
# The Makefile installs executables together with their supporting files.
|
||||||
|
copyBins = false;
|
||||||
|
|
||||||
cargoBuildOptions =
|
cargoBuildOptions =
|
||||||
old:
|
old:
|
||||||
old
|
old
|
||||||
@@ -202,6 +186,9 @@
|
|||||||
libtool
|
libtool
|
||||||
pkg-config
|
pkg-config
|
||||||
]
|
]
|
||||||
|
++ lib.optionals stdenv.isDarwin [
|
||||||
|
darwin.sigtool
|
||||||
|
]
|
||||||
++ lib.optionals stdenv.isLinux [
|
++ lib.optionals stdenv.isLinux [
|
||||||
autoPatchelfHook
|
autoPatchelfHook
|
||||||
wrapGAppsHook4
|
wrapGAppsHook4
|
||||||
@@ -211,49 +198,14 @@
|
|||||||
|
|
||||||
preFixup = nativeRuntimeWrapping;
|
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 = ''
|
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 ''
|
+ 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}
|
${installNixosPolkitRule}
|
||||||
''
|
''
|
||||||
+ ''
|
+ ''
|
||||||
${rewriteVpncScriptToolPaths}
|
${rewriteVpncScriptToolPaths}
|
||||||
${rewriteSourceInstallPaths}
|
|
||||||
'';
|
'';
|
||||||
}) {};
|
}) {};
|
||||||
|
|
||||||
@@ -288,7 +240,7 @@
|
|||||||
install -Dm755 ${gui}/gpgui $out/bin/gpgui
|
install -Dm755 ${gui}/gpgui $out/bin/gpgui
|
||||||
|
|
||||||
${rewriteVpncScriptToolPaths}
|
${rewriteVpncScriptToolPaths}
|
||||||
${rewriteSourceInstallPaths}
|
sh ${./scripts/relocate-install-paths.sh} "$out" /usr "$out"
|
||||||
${installNixosPolkitRule}
|
${installNixosPolkitRule}
|
||||||
|
|
||||||
runHook postInstall
|
runHook postInstall
|
||||||
|
|||||||
@@ -130,13 +130,17 @@ if [ "$os" = Darwin ]; then
|
|||||||
[ -n "$auth_path" ] || { [ ! -x "$bundle/Helpers/gpauth" ] || auth_path=$bundle/Helpers/gpauth; }
|
[ -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; }; }
|
[ -n "$gui_path" ] || { [ ! -d "$bundle" ] || { gui_path=$bundle/MacOS/gpgui; gui_bundle=$bundle; }; }
|
||||||
fi
|
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
|
for component in gpclient gpauth gpgui; do
|
||||||
case "$component" in gpclient) location=$client_path ;; gpauth) location=$auth_path ;; gpgui) location=$gui_path ;; esac
|
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
|
if [ -n "$location" ]; then emit "${component}_path" ok "$location"; else emit "${component}_path" unavailable ''; fi
|
||||||
done
|
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 "$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 [ -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"
|
field_probe gpgui_version /usr/libexec/PlistBuddy -c 'Print :CFBundleShortVersionString' "$gui_bundle/Info.plist"
|
||||||
else
|
else
|
||||||
emit gpgui_version unavailable ''
|
emit gpgui_version unavailable ''
|
||||||
|
|||||||
@@ -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
|
||||||
@@ -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/\&/\&/g' -e 's/</\</g' -e 's/>/\>/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
|
||||||
@@ -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'
|
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
|
MOCK
|
||||||
chmod +x "$fixtures/bin/"*
|
chmod +x "$fixtures/bin/"*
|
||||||
|
mkdir "$fixtures/home[regex]"
|
||||||
|
ln -s "$fixtures/bin/gpclient" "$fixtures/home[regex]/gpclient"
|
||||||
run() {
|
run() {
|
||||||
env PATH="$fixtures/bin" HOME="$fixtures/home[regex]" TMPDIR="$fixtures" \
|
env PATH="$fixtures/bin" HOME="$fixtures/home[regex]" TMPDIR="$fixtures" \
|
||||||
TEST_OS="$1" TEST_PROBE="${2:-}" TEST_CHILD_PID="$fixtures/child.pid" \
|
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:'
|
assert_contains 'gpgui_version: unavailable:'
|
||||||
[ ! -e "$fixtures/gui-launched" ]
|
[ ! -e "$fixtures/gui-launched" ]
|
||||||
printf '%s\n' 'PASS: nonbundle GUI path never borrows another installed app version'
|
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
|
# Successful probes must cancel their watchdog before doing any process-tree
|
||||||
# traversal. A slow snapshot used to let a finished probe become timed_out.
|
# traversal. A slow snapshot used to let a finished probe become timed_out.
|
||||||
mv "$fixtures/bin/ps" "$fixtures/real-ps"
|
mv "$fixtures/bin/ps" "$fixtures/real-ps"
|
||||||
|
|||||||
@@ -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'
|
||||||
Reference in new issue
Block a user