mirror of
https://github.com/yuezk/GlobalProtect-openconnect.git
synced 2026-11-18 22:16:18 -05:00
fix(nix): authorize desktop service outside the FHS sandbox
This commit is contained in:
4 files changed
+52
No files matched your search
@@ -88,6 +88,9 @@ jobs:
|
||||
test -x result/bin/gpgui-helper
|
||||
test -x result/bin/gpgui
|
||||
|
||||
- name: Verify desktop authorization runs on the host
|
||||
run: bash scripts/tests/nix-desktop-authorization.sh result
|
||||
|
||||
nixos-module:
|
||||
name: nixos-module (${{ matrix.platform.system }}, ${{ matrix.nixpkgs }})
|
||||
strategy:
|
||||
|
||||
@@ -122,6 +122,9 @@ jobs:
|
||||
exit 1
|
||||
fi
|
||||
|
||||
- name: Verify desktop authorization runs on the host
|
||||
run: bash scripts/tests/nix-desktop-authorization.sh result
|
||||
|
||||
open-pull-request:
|
||||
needs:
|
||||
- validate-nix-prebuilt
|
||||
|
||||
@@ -401,6 +401,11 @@
|
||||
export GP_SERVICE_BINARY='@gpservice_public@'
|
||||
export GP_AUTH_BINARY='@gpauth_public@'
|
||||
export GP_GUI_BINARY='${hostGuiLauncher}'
|
||||
if [ "''${1:-}" = "launch-gui" ]; then
|
||||
# Authorization must run before entering Bubblewrap, which disables setuid elevation.
|
||||
export PATH=/run/wrappers/bin:$PATH
|
||||
exec '${prebuiltFiles}/bin/gpclient' "$@"
|
||||
fi
|
||||
exec '${prebuiltCommands.gpclient}/bin/gpclient' "$@"
|
||||
EOF
|
||||
substituteInPlace $out/bin/gpclient \
|
||||
|
||||
@@ -0,0 +1,41 @@
|
||||
#!/usr/bin/env bash
|
||||
set -euo pipefail
|
||||
|
||||
package_path="$(readlink -f "${1:-result}")"
|
||||
test_workspace="$(mktemp -d)"
|
||||
trap 'rm -rf "$test_workspace"' EXIT
|
||||
|
||||
# This probe runs on CI without a system Polkit wrapper and never authorizes a service.
|
||||
if [ -x /run/wrappers/bin/pkexec ]; then
|
||||
echo "Run this probe on a host without /run/wrappers/bin/pkexec" >&2
|
||||
exit 1
|
||||
fi
|
||||
|
||||
mkdir -p "$test_workspace/bin"
|
||||
cat > "$test_workspace/bin/pkexec" <<'EOF'
|
||||
#!/usr/bin/env bash
|
||||
set -euo pipefail
|
||||
test "$#" -eq 4
|
||||
test "$1" = --user
|
||||
test "$2" = root
|
||||
test "$3" = "$GP_TEST_SERVICE_BINARY"
|
||||
test "$4" = --desktop-credentials
|
||||
if ! grep -Eq '^NoNewPrivs:[[:space:]]+0$' /proc/self/status; then
|
||||
echo "Authorization was attempted inside a sandbox" >&2
|
||||
exit 1
|
||||
fi
|
||||
echo "Authorization reached the host without NoNewPrivs" >&2
|
||||
exit 126
|
||||
EOF
|
||||
chmod +x "$test_workspace/bin/pkexec"
|
||||
|
||||
if PATH="$test_workspace/bin:$PATH" \
|
||||
XDG_DATA_HOME="$test_workspace/data" \
|
||||
GP_TEST_SERVICE_BINARY="$package_path/bin/gpservice" \
|
||||
"$package_path/bin/gpclient" launch-gui --minimized; then
|
||||
echo "The desktop launcher ignored the authorization rejection" >&2
|
||||
exit 1
|
||||
fi
|
||||
|
||||
grep -Fx 'Authorization reached the host without NoNewPrivs' \
|
||||
"$test_workspace/data/gpclient/gpclient.log"
|
||||
Reference in new issue
Block a user