From 87f91e3c131ddeed8785806841d5c22924f1d68c Mon Sep 17 00:00:00 2001 From: "github-actions[bot]" <41898282+github-actions[bot]@users.noreply.github.com> Date: Mon, 31 Aug 2026 17:09:02 +0000 Subject: [PATCH 1/5] fix(nix): align prebuilt runtime dependencies (#651) Use raw release-asset hashes, keep the Nixpkgs lock current, and validate the prebuilt package across supported Nixpkgs branches and architectures. [skip ci] --- .github/workflows/update-flake-hashes.yaml | 33 ++++++++++++++---- README.md | 5 ++- flake.lock | 6 ++-- flake.nix | 40 +++++++++++++++++----- scripts/open-flake-hashes-pr.sh | 16 ++++----- scripts/update-flake-hashes.sh | 5 ++- 6 files changed, 74 insertions(+), 31 deletions(-) diff --git a/.github/workflows/update-flake-hashes.yaml b/.github/workflows/update-flake-hashes.yaml index a8fdaf4..c76d68a 100644 --- a/.github/workflows/update-flake-hashes.yaml +++ b/.github/workflows/update-flake-hashes.yaml @@ -24,6 +24,11 @@ jobs: - name: Install Nix uses: cachix/install-nix-action@v31 + - name: Update Nixpkgs lock + run: | + nix flake update nixpkgs \ + --extra-experimental-features "nix-command flakes" + - name: Update flake hashes env: RELEASE_VERSION: ${{ inputs.version }} @@ -39,7 +44,9 @@ jobs: uses: actions/upload-artifact@v7 with: name: updated-flake - path: flake.nix + path: | + flake.nix + flake.lock if-no-files-found: error validate-nix-prebuilt: @@ -49,21 +56,25 @@ jobs: fail-fast: false matrix: include: + - runner: ubuntu-latest + nixpkgs: locked - runner: ubuntu-latest nixpkgs: nixos-25.11 - runner: ubuntu-latest nixpkgs: nixos-26.05 + - runner: ubuntu-latest + nixpkgs: nixpkgs-unstable - runner: ubuntu-24.04-arm nixpkgs: nixos-25.11 - runner: ubuntu-24.04-arm nixpkgs: nixos-26.05 + - runner: ubuntu-24.04-arm + nixpkgs: nixpkgs-unstable name: validate-nix-prebuilt (${{ matrix.nixpkgs }}, ${{ matrix.runner }}) runs-on: ${{ matrix.runner }} steps: - name: Checkout GlobalProtect-openconnect uses: actions/checkout@v6 - with: - submodules: recursive - name: Download updated flake uses: actions/download-artifact@v8 @@ -75,11 +86,19 @@ jobs: uses: cachix/install-nix-action@v31 - name: Build prebuilt Nix package + env: + NIXPKGS: ${{ matrix.nixpkgs }} run: | - nix build .#prebuilt \ - --override-input nixpkgs "github:NixOS/nixpkgs/${{ matrix.nixpkgs }}" \ - --extra-experimental-features "nix-command flakes" \ - --print-build-logs + if [[ "$NIXPKGS" == "locked" ]]; then + nix build .#prebuilt \ + --extra-experimental-features "nix-command flakes" \ + --print-build-logs + else + nix build .#prebuilt \ + --override-input nixpkgs "github:NixOS/nixpkgs/$NIXPKGS" \ + --extra-experimental-features "nix-command flakes" \ + --print-build-logs + fi - name: Inspect prebuilt Nix package run: | diff --git a/README.md b/README.md index 9a50da2..62fd02f 100644 --- a/README.md +++ b/README.md @@ -246,7 +246,10 @@ Add the flake input and package to your `flake.nix`: { inputs = { # ... other inputs - globalprotect-openconnect.url = "github:yuezk/GlobalProtect-openconnect"; + globalprotect-openconnect = { + url = "github:yuezk/GlobalProtect-openconnect"; + inputs.nixpkgs.follows = "nixpkgs"; + }; }; outputs = { self, nixpkgs, globalprotect-openconnect, ... }: diff --git a/flake.lock b/flake.lock index c2a0cf8..609bb07 100644 --- a/flake.lock +++ b/flake.lock @@ -63,11 +63,11 @@ }, "nixpkgs": { "locked": { - "lastModified": 1766410818, - "narHash": "sha256-ruVneSx6wFy5PMw1ow3BE+znl653TJ6+eeNUj4B/9y8=", + "lastModified": 1787964612, + "narHash": "sha256-0N9nghg3nwzX6b6qc77EzjR9cu/Z+UR66FlfsCqiURs=", "owner": "NixOS", "repo": "nixpkgs", - "rev": "3a7affa77a5a539afa1c7859e2c31abdb1aeadf3", + "rev": "e8be7818e19ada32105a8af937a6a473b38167ca", "type": "github" }, "original": { diff --git a/flake.nix b/flake.nix index 7d151c0..ba2e2b8 100644 --- a/flake.nix +++ b/flake.nix @@ -41,33 +41,55 @@ rustc = toolchain; }; - src = pkgs.fetchzip { + unpackReleaseAsset = + { name, archive }: + pkgs.runCommand name { nativeBuildInputs = [ pkgs.libarchive ]; } '' + mkdir -p "$out" + bsdtar --extract --file ${archive} --directory "$out" --strip-components 1 + ''; + + sourceArchive = pkgs.fetchurl { url = "https://github.com/yuezk/GlobalProtect-openconnect/releases/download/${releaseTag}/globalprotect-openconnect-${version}.tar.gz"; - hash = "sha256-T4jze6/25YTsfuQdcuDfz3kX/ooDB1T0hnWsEBu4xMQ="; + hash = "sha256-VFWbF2BfJ9CtXkjQjkgmBGCZnYgB5ZLctqcqUKuhswg="; + }; + + src = unpackReleaseAsset { + name = "globalprotect-openconnect-${version}-source"; + archive = sourceArchive; }; cpu = pkgs.stdenv.hostPlatform.parsed.cpu.name; gpguiHashes = { - x86_64 = "sha256-wPLsH/b/ZSo2pA/kU1HUGiQ98k8xSihyxGyf5o6tvyU="; - aarch64 = "sha256-WFyPhGD9fLAVYGeMSrMcZhSdfM99uVmWPrH68O+4BfE="; + x86_64 = "sha256-uVn3hJkKrjKz3mzRamxFu+0rE7OjLtMlT16d14XPcq4="; + aarch64 = "sha256-g4HKQwFAM4YCP+Afew1AhzC1wPrCS8ICw3GeA7KIeFU="; }; - gpgui = pkgs.fetchzip { + gpguiArchive = pkgs.fetchurl { url = "https://github.com/yuezk/GlobalProtect-openconnect/releases/download/${releaseTag}/gpgui_${cpu}.bin.tar.xz"; hash = gpguiHashes.${cpu}; }; - binaryHashes = { - x86_64 = "sha256-spaKxruu15ro5lir14nAfy8MPXNQhaoCXcG4PDZ9lfM="; - aarch64 = "sha256-iu/zE4B4gjk1I5PQY0m/59ZoJ/k5focT0CxYYlJi7+A="; + gpgui = unpackReleaseAsset { + name = "gpgui-${version}-${cpu}"; + archive = gpguiArchive; }; - binaryPackage = pkgs.fetchzip { + binaryHashes = { + x86_64 = "sha256-jgHZC00q+2GnO18/aPGONDCz2CeiF/e1DucefSacv2w="; + aarch64 = "sha256-FDCZN0bmKWKjPiF9wkRaqMUu0PfSVHDUveJVFts25qg="; + }; + + binaryArchive = pkgs.fetchurl { url = "https://github.com/yuezk/GlobalProtect-openconnect/releases/download/${releaseTag}/globalprotect-openconnect_${version}_${cpu}.bin.tar.xz"; hash = binaryHashes.${cpu}; }; + binaryPackage = unpackReleaseAsset { + name = "globalprotect-openconnect-${version}-${cpu}-binary"; + archive = binaryArchive; + }; + linuxRuntimeDependencies = with pkgs; [ glib-networking libayatana-appindicator diff --git a/scripts/open-flake-hashes-pr.sh b/scripts/open-flake-hashes-pr.sh index a9053d8..4463c83 100755 --- a/scripts/open-flake-hashes-pr.sh +++ b/scripts/open-flake-hashes-pr.sh @@ -5,8 +5,8 @@ set -euo pipefail release_version="${1:-}" release_tag="${2:-}" -if git diff --quiet -- flake.nix; then - echo "flake.nix hashes are already up to date" +if git diff --quiet -- flake.nix flake.lock; then + echo "flake hashes and lock are already up to date" exit 0 fi @@ -21,12 +21,12 @@ fi branch_suffix="v${version}" title="chore: update flake hashes for v${version}" -body="Updates the Nix flake fetchzip hashes for v${version} release assets." +body="Updates the Nix flake fetchurl hashes for v${version} release assets and refreshes the Nixpkgs lock." if [[ "$release_tag" != "v$version" ]]; then branch_suffix="${branch_suffix}-${release_tag}" title="chore: update flake hashes for v${version} from ${release_tag}" - body="Updates the Nix flake fetchzip hashes for v${version} using ${release_tag} release assets." + body="Updates the Nix flake fetchurl hashes for v${version} using ${release_tag} release assets and refreshes the Nixpkgs lock." fi git config user.name "github-actions[bot]" @@ -37,7 +37,7 @@ if [[ "$release_tag" == "snapshot" ]]; then source_branch_slug="$(printf '%s' "$source_branch" | sed -E 's#[/[:space:]]+#-#g; s#[^A-Za-z0-9._-]##g; s#^-+##; s#-+$##')" branch="chore/flake-${source_branch_slug}" git switch -C "$branch" - git add flake.nix + git add flake.nix flake.lock git commit -m "$title" git push --force origin "$branch" echo "Updated snapshot flake hashes on branch $branch from $source_branch; skipping PR creation" @@ -47,12 +47,12 @@ fi branch="chore/update-flake-hashes-${branch_suffix}" git switch -C "$branch" -git add flake.nix +git add flake.nix flake.lock git commit -m "$title" git push --force origin "$branch" -if gh pr view "$branch" --json number > /tmp/flake-pr.json 2> /dev/null; then - pr_number="$(jq -r '.number' /tmp/flake-pr.json)" +pr_number="$(gh pr list --head "$branch" --state open --json number --jq '.[0].number')" +if [[ -n "$pr_number" ]]; then gh pr edit "$pr_number" --title "$title" --body "$body" else gh pr create --title "$title" --body "$body" --base main --head "$branch" diff --git a/scripts/update-flake-hashes.sh b/scripts/update-flake-hashes.sh index b34b962..0e643d3 100755 --- a/scripts/update-flake-hashes.sh +++ b/scripts/update-flake-hashes.sh @@ -11,7 +11,7 @@ FLAKE_FILE="$PROJECT_DIR/flake.nix" usage() { echo "Usage: $0 [version] [release-tag]" echo - echo "Updates flake.nix fetchzip hashes from the published GitHub release assets." + echo "Updates flake.nix fetchurl hashes from the published GitHub release assets." echo "When version is omitted, the workspace package version from Cargo.toml is used." echo "When release-tag is omitted, v is used. Use snapshot to test snapshot assets." } @@ -22,7 +22,7 @@ if [[ "${1:-}" == "-h" || "${1:-}" == "--help" ]]; then fi if ! command -v nix > /dev/null; then - echo "nix is required to calculate unpacked fetchzip hashes" >&2 + echo "nix is required to calculate release asset hashes" >&2 exit 1 fi @@ -61,7 +61,6 @@ prefetch_hash() { store prefetch-file \ --hash-type sha256 \ --json \ - --unpack \ "$url" \ | jq -r '.hash'; then return 0 From 8eb4d48887d298e5fb5566db2f7ffc458458cef7 Mon Sep 17 00:00:00 2001 From: Kevin Yue Date: Tue, 1 Sep 2026 01:47:01 +0000 Subject: [PATCH 2/5] feat: add host-aligned NixOS module (#652) Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com> --- .github/workflows/nix.yaml | 118 +++++++++++++++++++++ .github/workflows/update-flake-hashes.yaml | 24 ++--- .gitignore | 1 + README.md | 14 +-- flake.nix | 57 ++++++++-- 5 files changed, 186 insertions(+), 28 deletions(-) create mode 100644 .github/workflows/nix.yaml diff --git a/.github/workflows/nix.yaml b/.github/workflows/nix.yaml new file mode 100644 index 0000000..06d28b6 --- /dev/null +++ b/.github/workflows/nix.yaml @@ -0,0 +1,118 @@ +name: Nix + +on: + pull_request: + paths: + - "flake.nix" + - "flake.lock" + - "nix/**" + - ".github/workflows/nix.yaml" + push: + branches: + - main + paths: + - "flake.nix" + - "flake.lock" + - "nix/**" + - ".github/workflows/nix.yaml" + +permissions: + contents: read + +jobs: + standalone-package: + name: standalone-package (${{ matrix.platform.system }}) + strategy: + fail-fast: false + matrix: + platform: + - runner: ubuntu-latest + system: x86_64-linux + - runner: ubuntu-24.04-arm + system: aarch64-linux + runs-on: ${{ matrix.platform.runner }} + steps: + - name: Checkout GlobalProtect-openconnect + uses: actions/checkout@v6 + + - name: Install Nix + uses: cachix/install-nix-action@v31 + + - name: Build standalone prebuilt package + run: | + nix build .#prebuilt \ + --extra-experimental-features "nix-command flakes" \ + --print-build-logs + + - name: Inspect prebuilt package + run: | + test -x result/bin/gpclient + test -x result/bin/gpauth + test -x result/bin/gpservice + test -x result/bin/gpgui-helper + test -x result/bin/gpgui + + nixos-module: + name: nixos-module (${{ matrix.platform.system }}, ${{ matrix.nixpkgs }}) + strategy: + fail-fast: false + matrix: + platform: + - runner: ubuntu-latest + system: x86_64-linux + - runner: ubuntu-24.04-arm + system: aarch64-linux + nixpkgs: + - nixos-25.11 + - nixos-26.05 + - nixpkgs-unstable + runs-on: ${{ matrix.platform.runner }} + steps: + - name: Checkout GlobalProtect-openconnect + uses: actions/checkout@v6 + + - name: Install Nix + uses: cachix/install-nix-action@v31 + + - name: Build package through host NixOS module + env: + NIXPKGS_URL: github:NixOS/nixpkgs/${{ matrix.nixpkgs }} + NIX_SYSTEM: ${{ matrix.platform.system }} + run: | + nix build \ + --impure \ + --extra-experimental-features "nix-command flakes" \ + --print-build-logs \ + --expr ' + let + gp = builtins.getFlake (toString ./.); + hostNixpkgs = + builtins.getFlake (builtins.getEnv "NIXPKGS_URL"); + + hostSystem = hostNixpkgs.lib.nixosSystem { + system = builtins.getEnv "NIX_SYSTEM"; + modules = [ + gp.nixosModules.default + { + programs.globalprotect-openconnect.enable = true; + system.stateVersion = "25.11"; + } + ]; + }; + + package = + hostSystem.config.programs.globalprotect-openconnect.package; + in + assert builtins.elem package + hostSystem.config.environment.systemPackages; + assert hostSystem.config.services.ayatana-indicators.enable; + package + ' + + - name: Inspect module package + run: | + test -x result/bin/gpclient + test -x result/bin/gpauth + test -x result/bin/gpservice + test -x result/bin/gpgui-helper + test -x result/bin/gpgui diff --git a/.github/workflows/update-flake-hashes.yaml b/.github/workflows/update-flake-hashes.yaml index c76d68a..ad6c1d0 100644 --- a/.github/workflows/update-flake-hashes.yaml +++ b/.github/workflows/update-flake-hashes.yaml @@ -55,21 +55,17 @@ jobs: strategy: fail-fast: false matrix: - include: - - runner: ubuntu-latest + runner: + - ubuntu-latest + - ubuntu-24.04-arm + nixpkgs: + - locked + - nixos-25.11 + - nixos-26.05 + - nixpkgs-unstable + exclude: + - runner: ubuntu-24.04-arm nixpkgs: locked - - runner: ubuntu-latest - nixpkgs: nixos-25.11 - - runner: ubuntu-latest - nixpkgs: nixos-26.05 - - runner: ubuntu-latest - nixpkgs: nixpkgs-unstable - - runner: ubuntu-24.04-arm - nixpkgs: nixos-25.11 - - runner: ubuntu-24.04-arm - nixpkgs: nixos-26.05 - - runner: ubuntu-24.04-arm - nixpkgs: nixpkgs-unstable name: validate-nix-prebuilt (${{ matrix.nixpkgs }}, ${{ matrix.runner }}) runs-on: ${{ matrix.runner }} steps: diff --git a/.gitignore b/.gitignore index f64b65f..6d553be 100644 --- a/.gitignore +++ b/.gitignore @@ -1,4 +1,5 @@ .idea +.DS_Store /target .pnpm-store .env diff --git a/README.md b/README.md index 62fd02f..5166236 100644 --- a/README.md +++ b/README.md @@ -240,16 +240,16 @@ This repository includes a flake for NixOS integration. #### Installation Steps -Add the flake input and package to your `flake.nix`: +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. ```nix { inputs = { # ... other inputs - globalprotect-openconnect = { - url = "github:yuezk/GlobalProtect-openconnect"; - inputs.nixpkgs.follows = "nixpkgs"; - }; + globalprotect-openconnect.url = "github:yuezk/GlobalProtect-openconnect"; }; outputs = { self, nixpkgs, globalprotect-openconnect, ... }: @@ -262,11 +262,11 @@ Add the flake input and package to your `flake.nix`: modules = [ ./configuration.nix + globalprotect-openconnect.nixosModules.default { - services.ayatana-indicators.enable = true; + programs.globalprotect-openconnect.enable = true; environment.systemPackages = [ - globalprotect-openconnect.packages.${system}.default nixpkgs.legacyPackages.${system}.gnomeExtensions.appindicator ]; } diff --git a/flake.nix b/flake.nix index ba2e2b8..9274861 100644 --- a/flake.nix +++ b/flake.nix @@ -20,13 +20,10 @@ nixpkgs, rust-overlay, }: - flake-utils.lib.eachDefaultSystem ( - system: + let + mkPackageSet = + pkgs: let - pkgs = (import nixpkgs) { - inherit system; - overlays = [ (import rust-overlay) ]; - }; inherit (pkgs) lib; cargoToml = builtins.fromTOML (builtins.readFile ./Cargo.toml); @@ -399,6 +396,49 @@ ''; }; in + { + inherit fromSource prebuilt; + }; + + nixosModule = + { + config, + lib, + pkgs, + ... + }: + let + cfg = config.programs.globalprotect-openconnect; + in + { + options.programs.globalprotect-openconnect = { + enable = lib.mkEnableOption "GlobalProtect-openconnect"; + + package = lib.mkOption { + type = lib.types.package; + # Use the NixOS module's package set so WebKit and graphics + # dependencies match the rest of the system. + default = (mkPackageSet pkgs).prebuilt; + description = "GlobalProtect-openconnect package to install."; + }; + }; + + config = lib.mkIf cfg.enable { + environment.systemPackages = [ cfg.package ]; + services.ayatana-indicators.enable = lib.mkDefault true; + }; + }; + in + (flake-utils.lib.eachDefaultSystem ( + system: + let + pkgs = (import nixpkgs) { + inherit system; + overlays = [ (import rust-overlay) ]; + }; + inherit (pkgs) lib; + inherit (mkPackageSet pkgs) fromSource prebuilt; + in { # For `nix build` packages = { @@ -425,5 +465,8 @@ ]; }; } - ); + )) + // { + nixosModules.default = nixosModule; + }; } From 0e1aedce8274126e97d753900ad0176426f33123 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Andr=C3=A9s?= Date: Tue, 1 Sep 2026 09:03:16 +0200 Subject: [PATCH 3/5] feat: add HIP support for Linux ClamAV (anti-malvare) and UFW (firewall) (#650) Co-authored-by: J. Andres Guerrero Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com> --- apps/gpclient/src/hip.rs | 145 +++++++++++++++++++++++++ apps/gpclient/templates/hip_report.xml | 23 +++- 2 files changed, 164 insertions(+), 4 deletions(-) diff --git a/apps/gpclient/src/hip.rs b/apps/gpclient/src/hip.rs index 08b9f8f..3c9ddd2 100644 --- a/apps/gpclient/src/hip.rs +++ b/apps/gpclient/src/hip.rs @@ -40,6 +40,19 @@ struct RealTimeProtection { value: bool, } +#[derive(Debug, Clone)] +struct UfwInfo { + version: String, + is_enabled: bool, +} + +#[derive(Debug, Clone)] +struct ClamAvInfo { + version: String, + definitions_version: Option, + real_time_protection: bool, +} + /// Host information for HIP reporting struct HostInfo { /// Common for all OSes, e.g., "Apple", "Microsoft", "Linux" @@ -55,6 +68,8 @@ struct HostInfo { domain: String, network_interfaces: Vec, defender: Option, + clamav: Option, + ufw: Option, } impl HostInfo { @@ -286,6 +301,8 @@ impl<'p, 'a> HostInfoCollector<'p, 'a> { domain: self.domain_for_profile(), network_interfaces: interfaces, defender: self.defender_for_profile(), + clamav: self.clamav_for_profile(), + ufw: self.ufw_for_profile(), } } @@ -339,6 +356,108 @@ impl<'p, 'a> HostInfoCollector<'p, 'a> { ClientOs::Mac | ClientOs::Windows => None, } } + + fn clamav_for_profile(&self) -> Option { + match self.profile.client_os() { + ClientOs::Linux => detect_clamav(), + ClientOs::Mac | ClientOs::Windows => None, + } + } + + fn ufw_for_profile(&self) -> Option { + match self.profile.client_os() { + ClientOs::Linux => detect_ufw(), + ClientOs::Mac | ClientOs::Windows => None, + } + } +} + +fn detect_clamav() -> Option { + let version_out = Command::new("clamscan").arg("--version").output().ok()?; + if !version_out.status.success() { + debug!("clamscan not found or failed"); + return None; + } + + let version_str = String::from_utf8(version_out.stdout).ok()?; + let (version, definitions_version) = parse_clamav_version(&version_str)?; + + let rtp_out = Command::new("systemctl") + .args(["is-active", "clamav-onaccess.service"]) + .output() + .ok()?; + + let real_time_protection = rtp_out.status.success(); + + Some(ClamAvInfo { + version, + definitions_version, + real_time_protection, + }) +} + +fn detect_ufw() -> Option { + let version_out = Command::new("ufw").arg("version").output().ok()?; + if !version_out.status.success() { + debug!("ufw not found or failed"); + return None; + } + + let version_str = String::from_utf8(version_out.stdout).ok()?; + let version = parse_ufw_version(&version_str)?; + + let status_out = Command::new("ufw").arg("status").env("LC_ALL", "C").output().ok()?; + if !status_out.status.success() { + log::warn!("ufw status failed"); + return None; + } + + let status_str = String::from_utf8(status_out.stdout).ok()?; + let is_enabled = parse_ufw_status(&status_str)?; + + Some(UfwInfo { version, is_enabled }) +} + +fn parse_clamav_version(output: &str) -> Option<(String, Option)> { + let mut output_parts = output.split_whitespace(); + if output_parts.next()? != "ClamAV" { + return None; + } + + let mut version_parts = output_parts.next()?.split('/'); + let version = version_parts.next()?; + if version.is_empty() { + return None; + } + + let definitions_version = version_parts + .next() + .filter(|definitions_version| !definitions_version.is_empty()) + .map(str::to_string); + + Some((version.to_string(), definitions_version)) +} + +fn parse_ufw_version(output: &str) -> Option { + let mut output_parts = output.split_whitespace(); + if output_parts.next()? != "ufw" { + return None; + } + + output_parts.next().map(str::to_string) +} + +fn parse_ufw_status(output: &str) -> Option { + let status = output + .lines() + .find_map(|line| line.trim().strip_prefix("Status:"))? + .trim(); + + match status { + "active" => Some(true), + "inactive" => Some(false), + _ => None, + } } fn detect_microsoft_defender_blocking() -> Option { @@ -577,4 +696,30 @@ mod tests { fn rejects_invalid_microsoft_defender_health_json() { assert!(parse_defender_info("{}").is_none()); } + + #[test] + fn parses_clamav_version() { + let version = + parse_clamav_version("ClamAV 1.4.3/27562/Sun Aug 31 10:23:42 2026").expect("ClamAV version should parse"); + + assert_eq!(version, ("1.4.3".to_string(), Some("27562".to_string()))); + } + + #[test] + fn parses_clamav_version_without_definitions_version() { + assert_eq!(parse_clamav_version("ClamAV 1.4.3"), Some(("1.4.3".to_string(), None))); + } + + #[test] + fn parses_ufw_version() { + assert_eq!(parse_ufw_version("ufw 0.36.2\n"), Some("0.36.2".to_string())); + assert_eq!(parse_ufw_version("unexpected output\n"), None); + } + + #[test] + fn parses_ufw_status() { + assert_eq!(parse_ufw_status("Status: active\n"), Some(true)); + assert_eq!(parse_ufw_status("Status: inactive\n"), Some(false)); + assert_eq!(parse_ufw_status("Status: unknown\n"), None); + } } diff --git a/apps/gpclient/templates/hip_report.xml b/apps/gpclient/templates/hip_report.xml index d4501e9..82a0051 100644 --- a/apps/gpclient/templates/hip_report.xml +++ b/apps/gpclient/templates/hip_report.xml @@ -218,8 +218,8 @@ {% elif host_info.os_vendor == "Linux" -%} - {% if let Some(defender) = &host_info.defender -%} + {% if let Some(defender) = &host_info.defender %} @@ -228,10 +228,17 @@ n/a - - {% else -%} - {% endif -%} + {% if let Some(clamav) = &host_info.clamav %} + + + + {% if clamav.real_time_protection %}yes{% else %}no{% endif %} + n/a + + + {% endif -%} + @@ -254,6 +261,14 @@ + {% if let Some(ufw) = &host_info.ufw %} + + + + {% if ufw.is_enabled %}yes{% else %}no{% endif %} + + + {% endif -%} From 32bac9b6756e84c3561f95241beb88857be94783 Mon Sep 17 00:00:00 2001 From: Kevin Yue Date: Tue, 1 Sep 2026 07:32:16 +0000 Subject: [PATCH 4/5] fix: run UFW status with required privileges (#655) Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com> --- Cargo.lock | 1 + apps/gpclient/Cargo.toml | 1 + apps/gpclient/src/hip.rs | 43 ++++++++++++++++++++++++++++++++++++++-- 3 files changed, 43 insertions(+), 2 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 176aa5c..c356a94 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -1819,6 +1819,7 @@ dependencies = [ "tempfile", "tokio", "uuid", + "uzers", "whoami", "xmltree", ] diff --git a/apps/gpclient/Cargo.toml b/apps/gpclient/Cargo.toml index 6ff57a8..2f30f52 100644 --- a/apps/gpclient/Cargo.toml +++ b/apps/gpclient/Cargo.toml @@ -31,6 +31,7 @@ compile-time.workspace = true netdev.workspace = true xmltree.workspace = true uuid = { workspace = true, features = ["v5"] } +uzers.workspace = true [features] default = ["webview-auth"] diff --git a/apps/gpclient/src/hip.rs b/apps/gpclient/src/hip.rs index 3c9ddd2..286d571 100644 --- a/apps/gpclient/src/hip.rs +++ b/apps/gpclient/src/hip.rs @@ -406,9 +406,14 @@ fn detect_ufw() -> Option { let version_str = String::from_utf8(version_out.stdout).ok()?; let version = parse_ufw_version(&version_str)?; - let status_out = Command::new("ufw").arg("status").env("LC_ALL", "C").output().ok()?; + let is_root = uzers::get_effective_uid() == 0; + let status_out = ufw_status_command(is_root).output().ok()?; if !status_out.status.success() { - log::warn!("ufw status failed"); + if is_root { + log::warn!("ufw status failed while running as root"); + } else { + log::warn!("sudo -n ufw status failed. You may need to configure sudoers to allow execution without a password."); + } return None; } @@ -418,6 +423,19 @@ fn detect_ufw() -> Option { Some(UfwInfo { version, is_enabled }) } +fn ufw_status_command(is_root: bool) -> Command { + let mut command = if is_root { + Command::new("ufw") + } else { + let mut command = Command::new("sudo"); + command.args(["-n", "ufw"]); + command + }; + + command.arg("status").env("LC_ALL", "C"); + command +} + fn parse_clamav_version(output: &str) -> Option<(String, Option)> { let mut output_parts = output.split_whitespace(); if output_parts.next()? != "ClamAV" { @@ -557,6 +575,7 @@ fn derive_windows_network_name(host_id: &str, iface: &NetworkInterface) -> Strin mod tests { use super::*; use gpapi::os_profile::runtime_client_os; + use std::ffi::OsStr; fn make_hip_args(client_os: Os) -> HipArgs { HipArgs { @@ -722,4 +741,24 @@ mod tests { assert_eq!(parse_ufw_status("Status: inactive\n"), Some(false)); assert_eq!(parse_ufw_status("Status: unknown\n"), None); } + + #[test] + fn runs_ufw_status_directly_as_root() { + let command = ufw_status_command(true); + + assert_eq!(command.get_program(), OsStr::new("ufw")); + assert!(command.get_args().eq(["status"].into_iter().map(OsStr::new))); + } + + #[test] + fn runs_ufw_status_through_non_interactive_sudo_as_non_root() { + let command = ufw_status_command(false); + + assert_eq!(command.get_program(), OsStr::new("sudo")); + assert!( + command + .get_args() + .eq(["-n", "ufw", "status"].into_iter().map(OsStr::new)) + ); + } } From 3882e29b0e93ed5727e71119983c79c8104dd251 Mon Sep 17 00:00:00 2001 From: Kevin Yue Date: Tue, 1 Sep 2026 07:33:15 +0000 Subject: [PATCH 5/5] fix(nix): resolve systemd DNS tools (#654) Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com> --- flake.nix | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/flake.nix b/flake.nix index 9274861..8fc8f18 100644 --- a/flake.nix +++ b/flake.nix @@ -92,6 +92,12 @@ libayatana-appindicator ]; + rewriteVpncScriptToolPaths = lib.optionalString pkgs.stdenv.isLinux '' + substituteInPlace $out/libexec/gpclient/vpnc-script \ + --replace-fail /usr/bin/resolvectl ${pkgs.systemd}/bin/resolvectl \ + --replace-fail /usr/bin/busctl ${pkgs.systemd}/bin/busctl + ''; + linuxBuildInputs = with pkgs; [ @@ -229,6 +235,7 @@ ${installNixosPolkitRule} '' + '' + ${rewriteVpncScriptToolPaths} ${rewriteSourceInstallPaths} ''; }; @@ -261,6 +268,8 @@ install -Dm755 ${gpgui}/gpgui $out/bin/gpgui + ${rewriteVpncScriptToolPaths} + runHook postInstall ''; };