mirror of
https://github.com/yuezk/GlobalProtect-openconnect.git
synced 2026-11-18 22:16:18 -05:00
fix(nixos): enable the privileged pkexec wrapper
This commit is contained in:
4 files changed
+28
-7
No files matched your search
@@ -257,6 +257,7 @@ Add the flake input and NixOS module to your `flake.nix`:
|
||||
|
||||
The module builds the package with your NixOS configuration's `pkgs`, so the
|
||||
GlobalProtect GUI and the system use the same Nixpkgs dependency versions.
|
||||
It also enables Polkit and its setuid `pkexec` wrapper for privileged operations.
|
||||
|
||||
```nix
|
||||
{
|
||||
|
||||
@@ -304,6 +304,7 @@
|
||||
{
|
||||
config,
|
||||
lib,
|
||||
options,
|
||||
pkgs,
|
||||
...
|
||||
}:
|
||||
@@ -326,6 +327,11 @@
|
||||
config = lib.mkIf cfg.enable {
|
||||
environment.systemPackages = [ cfg.package ];
|
||||
services.ayatana-indicators.enable = lib.mkDefault true;
|
||||
security.polkit = {
|
||||
enable = true;
|
||||
} // lib.optionalAttrs (options.security.polkit ? enablePkexecWrapper) {
|
||||
enablePkexecWrapper = true;
|
||||
};
|
||||
};
|
||||
};
|
||||
in
|
||||
|
||||
+13
-2
@@ -41,7 +41,18 @@ in {
|
||||
prebuilt = prebuiltPackage;
|
||||
module = assert builtins.elem modulePackage hostSystem.config.environment.systemPackages;
|
||||
assert hostSystem.config.services.ayatana-indicators.enable;
|
||||
assert hostSystem.config.security.polkit.enable;
|
||||
assert hostSystem.config.security.wrappers.pkexec.enable;
|
||||
assert hostSystem.config.security.wrappers.pkexec.setuid;
|
||||
modulePackage;
|
||||
runtime-source = import ./tests/native-runtime.nix { inherit pkgs; package = sourcePackage; };
|
||||
runtime-prebuilt = import ./tests/native-runtime.nix { inherit pkgs; package = prebuiltPackage; };
|
||||
runtime-source = import ./tests/native-runtime.nix {
|
||||
inherit pkgs;
|
||||
package = sourcePackage;
|
||||
module = gp.nixosModules.default;
|
||||
};
|
||||
runtime-prebuilt = import ./tests/native-runtime.nix {
|
||||
inherit pkgs;
|
||||
package = prebuiltPackage;
|
||||
module = gp.nixosModules.default;
|
||||
};
|
||||
}
|
||||
@@ -1,4 +1,4 @@
|
||||
{ pkgs, package }:
|
||||
{ pkgs, package, module }:
|
||||
let
|
||||
guiProbe = pkgs.writeScript "gpgui-runtime-probe" ''
|
||||
#!${pkgs.python3}/bin/python3
|
||||
@@ -32,9 +32,10 @@ in
|
||||
pkgs.testers.runNixOSTest {
|
||||
name = "gp-native-runtime-${package.pname}";
|
||||
nodes.machine = {
|
||||
environment.systemPackages = [ package hostCollector ];
|
||||
imports = [ module ];
|
||||
programs.globalprotect-openconnect = { enable = true; inherit package; };
|
||||
environment.systemPackages = [ hostCollector ];
|
||||
users.users.alice = { isNormalUser = true; uid = 1000; };
|
||||
security.polkit.enable = true;
|
||||
security.polkit.extraConfig = ''
|
||||
polkit.addRule(function(action, subject) {
|
||||
if (subject.user == "alice" && (
|
||||
@@ -50,6 +51,7 @@ pkgs.testers.runNixOSTest {
|
||||
import base64
|
||||
import json
|
||||
import shlex
|
||||
from datetime import timedelta
|
||||
|
||||
machine.start()
|
||||
machine.wait_for_unit("polkit.service")
|
||||
@@ -62,11 +64,12 @@ pkgs.testers.runNixOSTest {
|
||||
command = "GP_GUI_BINARY=${guiProbe} " + package + "/bin/gpclient --lock-file /tmp/gp-client.lock launch-gui"
|
||||
as_alice(command + " > /tmp/gp-client-output 2>&1 & echo $! > /tmp/gp-client-pid")
|
||||
try:
|
||||
machine.wait_until_succeeds("test -s /tmp/gp-gui-ready", timeout=30)
|
||||
finally:
|
||||
machine.wait_until_succeeds("test -s /tmp/gp-gui-ready", timeout=timedelta(seconds=30))
|
||||
except Exception:
|
||||
print(machine.succeed("cat /tmp/gp-client-output"))
|
||||
print(machine.succeed("cat /home/alice/.local/share/gpclient/gpclient.log 2>/dev/null || true"))
|
||||
print(machine.succeed("journalctl -u polkit --no-pager"))
|
||||
raise
|
||||
service_pid = machine.succeed("cut -d: -f1 /var/run/gpservice.lock").strip()
|
||||
machine.succeed("test $(stat -c %u /proc/" + service_pid + ") = 0")
|
||||
as_alice("kill -TERM $(cat /tmp/gp-client-pid)")
|
||||
|
||||
Reference in new issue
Block a user