From 93504eaec24951f10b80da2c06c04ea30156123f Mon Sep 17 00:00:00 2001 From: Kevin Yue Date: Mon, 12 Oct 2026 13:37:15 +0800 Subject: [PATCH] fix: improve authentication recovery and diagnostics Recognize real GTK Wayland crash messages and keep remote authentication prompts readable. Preserve device identifiers without initializing OpenSSL, validate diagnostic executable paths, and improve release automation. Fixes #669 --- .github/workflows/publish-ppa.yaml | 1 + .github/workflows/release.yaml | 22 +++ .github/workflows/update-flake-hashes.yaml | 8 + Cargo.lock | 1 + apps/gpclient/src/connect/flow_tests.rs | 146 ++++++++++++++++++ apps/gpclient/tests/diagnostics.rs | 9 +- crates/auth/src/browser/auth_server.rs | 6 +- crates/auth/src/browser/browser_auth.rs | 11 +- crates/gpapi/Cargo.toml | 1 + crates/gpapi/src/device_anchor/mod.rs | 30 +++- crates/gpapi/src/process/auth_launcher.rs | 2 +- .../gpapi/src/process/gui_helper_launcher.rs | 2 +- .../gpapi/src/process/rendering_recovery.rs | 45 +++++- scripts/collect-diagnostics.sh | 6 +- scripts/tests/diagnostics.sh | 19 +++ 15 files changed, 294 insertions(+), 15 deletions(-) diff --git a/.github/workflows/publish-ppa.yaml b/.github/workflows/publish-ppa.yaml index 8097296..d228509 100644 --- a/.github/workflows/publish-ppa.yaml +++ b/.github/workflows/publish-ppa.yaml @@ -185,6 +185,7 @@ jobs: revision: ${{ inputs.revision }} - name: Wait for Launchpad builds and public package indexes + if: ${{ inputs.verify_only }} env: TAG: ${{ inputs.tag }} REVISION: ${{ inputs.revision }} diff --git a/.github/workflows/release.yaml b/.github/workflows/release.yaml index 0fdcd93..b8af008 100644 --- a/.github/workflows/release.yaml +++ b/.github/workflows/release.yaml @@ -257,6 +257,8 @@ jobs: - build runs-on: ubuntu-latest if: ${{ inputs.gh-release }} + outputs: + stable_version: ${{ steps.stable-release.outputs.version }} permissions: actions: read contents: read @@ -318,3 +320,23 @@ jobs: else gh-release/gp/scripts/upload-release-assets.sh "${{ inputs.tag }}" "${files[@]}" fi + + - name: Resolve stable release version + id: stable-release + env: + TAG: ${{ inputs.tag }} + run: | + if [[ "$TAG" =~ ^v([0-9]+\.[0-9]+\.[0-9]+)$ ]]; then + echo "version=${BASH_REMATCH[1]}" >> "$GITHUB_OUTPUT" + fi + + update-flake-hashes: + needs: gh-release + if: ${{ inputs.release-binary && inputs.arch == 'all' && needs.gh-release.outputs.stable_version != '' }} + permissions: + contents: write + pull-requests: write + uses: ./.github/workflows/update-flake-hashes.yaml + with: + version: ${{ needs.gh-release.outputs.stable_version }} + release_tag: ${{ inputs.tag }} diff --git a/.github/workflows/update-flake-hashes.yaml b/.github/workflows/update-flake-hashes.yaml index 93845b3..b6bbcb1 100644 --- a/.github/workflows/update-flake-hashes.yaml +++ b/.github/workflows/update-flake-hashes.yaml @@ -1,6 +1,14 @@ name: Update flake hashes on: + workflow_call: + inputs: + version: + required: true + type: string + release_tag: + required: true + type: string workflow_dispatch: inputs: version: diff --git a/Cargo.lock b/Cargo.lock index e9dca1c..9c48d19 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -1861,6 +1861,7 @@ dependencies = [ "serde", "serde_json", "serde_urlencoded", + "sha2", "sha256", "snow", "socket2", diff --git a/apps/gpclient/src/connect/flow_tests.rs b/apps/gpclient/src/connect/flow_tests.rs index dcf3d19..0bd79b9 100644 --- a/apps/gpclient/src/connect/flow_tests.rs +++ b/apps/gpclient/src/connect/flow_tests.rs @@ -372,3 +372,149 @@ async fn exhausted_auth_recovery_is_terminal_before_portal_gateway_fallback() { assert_eq!(handler.auth_attempt_fixture.borrow().observed.len(), 2); assert_eq!(worker.await.unwrap().len(), 2); } + +#[cfg(all( + feature = "webview-auth", + any(target_os = "linux", target_os = "freebsd", target_os = "openbsd") +))] +mod gtk_retry { + use super::*; + + #[tokio::test] + async fn real_gtk_crash_retries_bundled_authenticator() { + // Environment overrides belong to a separate test process, never the parallel test runner. + if let Some(directory) = std::env::var_os("GP_TEST_GTK_AUTH_DIR") { + verify_real_authenticator_retry(std::path::Path::new(&directory)).await; + } else { + run_real_authenticator_retry(false); + } + } + + #[cfg(target_os = "linux")] + #[test] + #[ignore = "requires non-interactive sudo authorization and a running Wayland desktop session"] + fn sudo_gtk_crash_retries_after_restoring_desktop_environment() { + run_real_authenticator_retry(true); + } + + fn run_real_authenticator_retry(sudo: bool) { + use std::{fs, os::unix::fs::PermissionsExt, process::Command}; + + let directory = tempfile::tempdir().unwrap(); + let executable = directory.path().join("gpauth"); + // Fixtures contain only dummy data and must remain accessible after a root test drops privileges. + fs::set_permissions(directory.path(), fs::Permissions::from_mode(0o755)).unwrap(); + let attempts_path = directory.path().join("attempts"); + fs::write(&attempts_path, "").unwrap(); + fs::set_permissions(&attempts_path, fs::Permissions::from_mode(0o666)).unwrap(); + fs::write(&executable, r#"#!/bin/sh +set -eu +request= +while [ "$#" -gt 0 ]; do + if [ "$1" = '--saml-request' ]; then + shift + request=$1 + fi + shift +done +printf '%s|%s|%s|%s\n' "$(id -u)" "${WAYLAND_DISPLAY:-}" "${WEBKIT_DISABLE_DMABUF_RENDERER-unset}" "$request" >> "$GP_TEST_GTK_AUTH_DIR/attempts" +if [ "$request" = 'old' ]; then + printf 'Gdk-Message: 10:49:22.617: Error 71 (Protocol error) dispatching to Wayland display.\n' >&2 + exit 1 +fi +[ "$request" = 'new' ] && [ "${WEBKIT_DISABLE_DMABUF_RENDERER:-}" = '1' ] || exit 2 +printf '%s\n' '{"success":{"username":"alice","preloginCookie":"new-cookie"}}' +"#).unwrap(); + fs::set_permissions(&executable, fs::Permissions::from_mode(0o755)).unwrap(); + + let mut command = if sudo { + assert_ne!( + uzers::get_effective_uid(), + 0, + "run this test as the Wayland desktop user" + ); + let mut command = Command::new("sudo"); + command.args([ + "-n", + "env", + "-u", + "WAYLAND_DISPLAY", + "-u", + "DISPLAY", + "-u", + "XDG_SESSION_TYPE", + "-u", + "WEBKIT_DISABLE_DMABUF_RENDERER", + ]); + command.arg("GP_TEST_EXPECT_ROOT=1"); + command + } else { + let mut command = Command::new("env"); + command.arg("-u").arg("WEBKIT_DISABLE_DMABUF_RENDERER"); + command.arg("WAYLAND_DISPLAY=wayland-test"); + command + }; + command.arg(format!("GP_AUTH_BINARY={}", executable.display())); + command.arg(format!("GP_TEST_GTK_AUTH_DIR={}", directory.path().display())); + command.arg(std::env::current_exe().unwrap()).args([ + "--exact", + "connect::flow_tests::gtk_retry::real_gtk_crash_retries_bundled_authenticator", + "--nocapture", + ]); + let output = command.output().unwrap(); + assert!( + output.status.success(), + "retry subprocess failed: {}\n{}", + String::from_utf8_lossy(&output.stdout), + String::from_utf8_lossy(&output.stderr) + ); + let expected_uid = gpapi::process::users::get_non_root_user().unwrap().uid().to_string(); + let attempts = fs::read_to_string(attempts_path).unwrap(); + let attempts: Vec> = 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" + ); + } +} diff --git a/apps/gpclient/tests/diagnostics.rs b/apps/gpclient/tests/diagnostics.rs index ff25a5a..d953e8a 100644 --- a/apps/gpclient/tests/diagnostics.rs +++ b/apps/gpclient/tests/diagnostics.rs @@ -9,7 +9,7 @@ fn executable(dir: &std::path::Path, name: &str, body: &str) { } #[tokio::test] -async fn embedded_collector_finishes_without_recursing_or_exposing_private_environment() { +async fn embedded_collector_reports_missing_helpers_without_recursing_or_exposing_private_environment() { let dir = tempfile::tempdir().unwrap(); let bin = dir.path().join("bin"); std::fs::create_dir(&bin).unwrap(); @@ -33,6 +33,8 @@ async fn embedded_collector_finishes_without_recursing_or_exposing_private_envir .args(["--fix-openssl", "diagnostics", "--json", "--output"]) .arg(&report_file) .env("PATH", format!("{}:/usr/bin:/bin", bin.display())) + .env("GP_AUTH_BINARY", dir.path().join("missing-gpauth")) + .env("GP_GUI_BINARY", dir.path().join("missing-gpgui")) .env("GP_DIAGNOSTICS_PRIVATE_TOKEN", "secret-value-must-not-appear") .env("XDG_CURRENT_DESKTOP", "TestDesktop\nInjected: secret") .stdin(Stdio::null()) @@ -50,6 +52,11 @@ async fn embedded_collector_finishes_without_recursing_or_exposing_private_envir let report: serde_json::Value = serde_json::from_str(&text).unwrap(); assert_eq!(report["schema_version"], 1); assert_eq!(report["fields"]["os"]["value"], "Linux"); + assert_eq!(report["fields"]["gpclient_path"]["status"], "ok"); + for field in ["gpauth_path", "gpauth_version", "gpgui_path", "gpgui_version"] { + assert_eq!(report["fields"][field]["status"], "unavailable"); + assert!(report["fields"][field]["value"].is_null()); + } assert!( report["fields"]["gpclient_version"]["value"] .as_str() diff --git a/crates/auth/src/browser/auth_server.rs b/crates/auth/src/browser/auth_server.rs index cff76a4..5d95f2f 100644 --- a/crates/auth/src/browser/auth_server.rs +++ b/crates/auth/src/browser/auth_server.rs @@ -14,7 +14,9 @@ impl AuthServer { let server = Server::http(addr).map_err(|err| anyhow::anyhow!(err))?; let auth_id = Uuid::new_v4().to_string(); - Ok(Self { server, auth_id }) + let auth_server = Self { server, auth_id }; + info!("auth server started at: {}", auth_server.auth_url()); + Ok(auth_server) } pub fn auth_url(&self) -> String { @@ -22,8 +24,6 @@ impl AuthServer { } pub fn serve_request(&self, auth_request: &str) { - info!("auth server started at: {}", self.auth_url()); - for req in self.server.incoming_requests() { info!("received request, method: {}, url: {}", req.method(), req.url()); diff --git a/crates/auth/src/browser/browser_auth.rs b/crates/auth/src/browser/browser_auth.rs index 089d4df..7ea360c 100644 --- a/crates/auth/src/browser/browser_auth.rs +++ b/crates/auth/src/browser/browser_auth.rs @@ -1,4 +1,7 @@ -use std::net::{IpAddr, SocketAddr}; +use std::{ + io::Write, + net::{IpAddr, SocketAddr}, +}; use browser_launcher::Browser as LaunchBrowser; use gpapi::auth::SamlAuthData; @@ -34,7 +37,7 @@ impl<'a> BrowserAuthenticator<'a> { let auth_url = auth_server.auth_url(); let auth_request = self.auth_request.to_string(); - tokio::spawn(async move { + let auth_server_task = tokio::task::spawn_blocking(move || { auth_server.serve_request(&auth_request); }); @@ -55,6 +58,7 @@ Note that the URL is only valid for a single use. "#, auth_url ); + auth_server_task.await?; return read_auth_data_from_stdin(); } @@ -95,6 +99,9 @@ async fn detect_local_ip() -> anyhow::Result { } fn read_auth_data_from_stdin() -> anyhow::Result { + eprint!("\nAuthentication callback (paste and press Enter): "); + std::io::stderr().flush()?; + let mut data = String::new(); std::io::stdin().read_line(&mut data)?; diff --git a/crates/gpapi/Cargo.toml b/crates/gpapi/Cargo.toml index 4b7271c..de64aa9 100644 --- a/crates/gpapi/Cargo.toml +++ b/crates/gpapi/Cargo.toml @@ -34,6 +34,7 @@ uzers.workspace = true serde_urlencoded.workspace = true md5.workspace = true sha256.workspace = true +sha2 = "0.10" uuid = { workspace = true, features = ["v4", "v5", "serde"] } chrono.workspace = true humantime.workspace = true diff --git a/crates/gpapi/src/device_anchor/mod.rs b/crates/gpapi/src/device_anchor/mod.rs index 012f42e..89e3bed 100644 --- a/crates/gpapi/src/device_anchor/mod.rs +++ b/crates/gpapi/src/device_anchor/mod.rs @@ -1,6 +1,7 @@ //! Neutral device-anchor transport model and deterministic derivation. use base64::{Engine, engine::general_purpose::URL_SAFE_NO_PAD}; use serde::{Deserialize, Serialize}; +use sha2::{Digest, Sha256}; use std::fmt; #[derive(Debug, Clone, Copy, PartialEq, Eq, Serialize, Deserialize)] @@ -68,7 +69,7 @@ impl DeviceAnchor { let mut input = domain.to_vec(); input.extend_from_slice(seed.as_ref()); Self { - hardware_id: URL_SAFE_NO_PAD.encode(openssl::sha::sha256(&input)), + hardware_id: URL_SAFE_NO_PAD.encode(Sha256::digest(&input)), source, } } @@ -78,11 +79,36 @@ impl DeviceAnchor { mod tests { use super::*; + #[test] + fn preserves_existing_hardware_ids_for_all_sources() { + let cases: [(AnchorSource, &[u8], &str); 3] = [ + ( + AnchorSource::UnixMac, + &[0, 17, 34, 51, 68, 85], + "UWDOx4AVJEuCAYfJBaPioyGtRfAkJBhMYSi8LuFsE1A", + ), + ( + AnchorSource::UnixRandom, + &[0, 17, 34, 51, 68, 85], + "fYXFpivIFuD9Z4I6qSNxUIMTljeLvw4xuqXgg0VJAu0", + ), + ( + AnchorSource::MacosIokit, + b"12345678-1234-5678-9abc-def012345678", + "K1KMtAwiOiXKQvQuRmTDKPA6-ZPF5QKUWZzmvRzeP34", + ), + ]; + for (source, seed, expected) in cases { + let anchor = DeviceAnchor::derive(source, seed); + assert_eq!(anchor.hardware_id, expected, "{source:?}"); + assert!(anchor.validate()); + } + } + #[test] fn hashes_original_seed_order_with_stable_domain_separation() { let mac = DeviceAnchor::derive(AnchorSource::UnixMac, [0, 17, 34, 51, 68, 85]); assert!(mac.validate()); - assert_eq!(mac.hardware_id, "UWDOx4AVJEuCAYfJBaPioyGtRfAkJBhMYSi8LuFsE1A"); assert_ne!( mac.hardware_id, DeviceAnchor::derive(AnchorSource::UnixMac, [85, 68, 51, 34, 17, 0]).hardware_id diff --git a/crates/gpapi/src/process/auth_launcher.rs b/crates/gpapi/src/process/auth_launcher.rs index d4aa227..8481082 100644 --- a/crates/gpapi/src/process/auth_launcher.rs +++ b/crates/gpapi/src/process/auth_launcher.rs @@ -510,7 +510,7 @@ mod tests { let executable = directory.path().join("auth-fixture"); std::fs::write( &executable, - "#!/bin/sh\nprintf 'Gdk-Message: Error 71 (Protocol error) dispatching to Wayland display\\n' >&2\nexit 71\n", + "#!/bin/sh\nprintf 'Gdk-Message: Error 71 (Protocol error) dispatching to Wayland display.\\n' >&2\nexit 1\n", ) .unwrap(); // The launcher drops root privileges in CI; its child must be able to diff --git a/crates/gpapi/src/process/gui_helper_launcher.rs b/crates/gpapi/src/process/gui_helper_launcher.rs index a47650a..93ffb54 100644 --- a/crates/gpapi/src/process/gui_helper_launcher.rs +++ b/crates/gpapi/src/process/gui_helper_launcher.rs @@ -110,7 +110,7 @@ mod tests { let path = fixture( &dir, &credential, - "printf '(gpgui-helper:42): Gdk-Message: 12:00:00: Error 71 (Protocol error) dispatching to Wayland display\\n' >&2; exit 71", + "printf '(gpgui-helper:42): Gdk-Message: 12:00:00: Error 71 (Protocol error) dispatching to Wayland display.\\n' >&2; exit 1", ); let mut envs = HashMap::from([("WAYLAND_DISPLAY".into(), "wayland-0".into())]); for override_value in [None, Some(""), Some("0"), Some("1")] { diff --git a/crates/gpapi/src/process/rendering_recovery.rs b/crates/gpapi/src/process/rendering_recovery.rs index bda3d57..a7e5cd1 100644 --- a/crates/gpapi/src/process/rendering_recovery.rs +++ b/crates/gpapi/src/process/rendering_recovery.rs @@ -97,14 +97,15 @@ impl StderrDiagnostic { } fn check_line(&mut self) { - let line = self.line.as_slice(); + let line = self.line.trim_ascii_end(); + let message = line.strip_suffix(b".").unwrap_or(line); if !self.overflow && (line.starts_with(b"Gdk-Message:") || line.starts_with(b"(gpgui:") || line.starts_with(b"(gpauth:") || line.starts_with(b"(gpgui-helper:")) && line.windows(b"Gdk-Message:".len()).any(|part| part == b"Gdk-Message:") - && line.strip_suffix(b"\r").unwrap_or(line).ends_with(DIAGNOSTIC) + && message.ends_with(DIAGNOSTIC) { self.matched = true; } @@ -123,13 +124,49 @@ mod tests { #[test] fn recognizes_split_diagnostic_without_matching_quoted_warning() { let mut observer = StderrDiagnostic::default(); - observer.push(b"warning: Gdk-Message: Error 71 (Protocol error) dispatching to Wayland display\n"); + observer.push(b"warning: Gdk-Message: Error 71 (Protocol error) dispatching to Wayland display.\n"); assert!(!observer.matched()); observer.push(b"Gdk-Message: 12:00:00: Error 71 (Protocol error) dispat"); - observer.push(b"ching to Wayland display\n"); + observer.push(b"ching to Wayland display.\n"); assert!(observer.matched()); } + #[test] + fn recognizes_real_gtk_diagnostic_with_prefix_and_line_endings() { + for prefix in [ + "Gdk-Message:", + "(gpauth:42): Gdk-Message:", + "(gpgui:42): Gdk-Message:", + "(gpgui-helper:42): Gdk-Message:", + ] { + for punctuation in ["", "."] { + for ending in ["\n", "\r\n", "", " \t\n"] { + let line = format!( + "{prefix} 10:49:22.617: Error 71 (Protocol error) dispatching to Wayland display{punctuation}{ending}" + ); + let mut observer = StderrDiagnostic::default(); + for chunk in line.as_bytes().chunks(7) { + observer.push(chunk); + } + assert!(observer.matched(), "unrecognized GTK diagnostic: {line:?}"); + } + } + } + } + + #[test] + fn rejects_quoted_or_extended_gtk_diagnostic() { + for line in [ + "warning: Gdk-Message: Error 71 (Protocol error) dispatching to Wayland display.\n", + "Gdk-Message: Error 71 (Protocol error) dispatching to Wayland display. Retry suggested\n", + "Gdk-Message: Error 70 (Communication error) dispatching to Wayland display.\n", + ] { + let mut observer = StderrDiagnostic::default(); + observer.push(line.as_bytes()); + assert!(!observer.matched(), "incorrectly recognized: {line:?}"); + } + } + #[test] fn oversized_lines_do_not_grow_or_match() { let mut observer = StderrDiagnostic::default(); diff --git a/scripts/collect-diagnostics.sh b/scripts/collect-diagnostics.sh index 44e895c..3da9ccb 100644 --- a/scripts/collect-diagnostics.sh +++ b/scripts/collect-diagnostics.sh @@ -130,13 +130,17 @@ if [ "$os" = Darwin ]; then [ -n "$auth_path" ] || { [ ! -x "$bundle/Helpers/gpauth" ] || auth_path=$bundle/Helpers/gpauth; } [ -n "$gui_path" ] || { [ ! -d "$bundle" ] || { gui_path=$bundle/MacOS/gpgui; gui_bundle=$bundle; }; } fi +is_executable_file() { [ -f "$1" ] && [ -x "$1" ]; } +is_executable_file "$client_path" || client_path= +is_executable_file "$auth_path" || auth_path= +is_executable_file "$gui_path" || gui_path= for component in gpclient gpauth gpgui; do case "$component" in gpclient) location=$client_path ;; gpauth) location=$auth_path ;; gpgui) location=$gui_path ;; esac if [ -n "$location" ]; then emit "${component}_path" ok "$location"; else emit "${component}_path" unavailable ''; fi done if [ -n "$client_version" ]; then emit gpclient_version ok "$client_version"; elif [ -n "$client_path" ]; then field_probe gpclient_version "$client_path" --version; else emit gpclient_version unavailable ''; fi if [ -n "$auth_path" ]; then field_probe gpauth_version "$auth_path" --version; else emit gpauth_version unavailable ''; fi -if [ "$os" = Darwin ] && [ -n "$gui_bundle" ]; then +if [ "$os" = Darwin ] && [ -n "$gui_path" ] && [ -n "$gui_bundle" ]; then field_probe gpgui_version /usr/libexec/PlistBuddy -c 'Print :CFBundleShortVersionString' "$gui_bundle/Info.plist" else emit gpgui_version unavailable '' diff --git a/scripts/tests/diagnostics.sh b/scripts/tests/diagnostics.sh index 29e1a21..72be9dc 100644 --- a/scripts/tests/diagnostics.sh +++ b/scripts/tests/diagnostics.sh @@ -95,6 +95,8 @@ cat > "$fixtures/bin/pkg_info" <<'MOCK' printf '%s\n' 'webkitgtk41-2.52.6 WebKitGTK browser engine' 'gtk+3-3.24.52 GTK3 toolkit' 'sway-1.11 Wayland compositor' 'private-package-1.0 Do not collect' MOCK chmod +x "$fixtures/bin/"* +mkdir "$fixtures/home[regex]" +ln -s "$fixtures/bin/gpclient" "$fixtures/home[regex]/gpclient" run() { env PATH="$fixtures/bin" HOME="$fixtures/home[regex]" TMPDIR="$fixtures" \ TEST_OS="$1" TEST_PROBE="${2:-}" TEST_CHILD_PID="$fixtures/child.pid" \ @@ -132,6 +134,23 @@ assert_contains "gpgui_path: ok: $fixtures/bin/gpgui" assert_contains 'gpgui_version: unavailable:' [ ! -e "$fixtures/gui-launched" ] printf '%s\n' 'PASS: nonbundle GUI path never borrows another installed app version' +mkdir "$fixtures/not-a-file" +printf '#!/bin/sh\nexit 0\n' > "$fixtures/not-executable" +chmod 644 "$fixtures/not-executable" +ln -s "$fixtures/missing" "$fixtures/broken-link" +for os in Linux FreeBSD OpenBSD Darwin; do + for invalid in missing not-a-file not-executable broken-link; do + env PATH="$fixtures/bin" TEST_OS="$os" TEST_GUI_MARKER="$fixtures/gui-launched" \ + sh "$collector" --client-path "$fixtures/$invalid" \ + --auth-path "$fixtures/$invalid" --gui-path "$fixtures/$invalid" > "$fixtures/report" + for component in gpclient gpauth gpgui; do + assert_contains "${component}_path: unavailable:" + assert_contains "${component}_version: unavailable:" + done + done +done +[ ! -e "$fixtures/gui-launched" ] +printf '%s\n' 'PASS: missing files, directories, nonexecutables and broken links are unavailable on all platforms' # Successful probes must cancel their watchdog before doing any process-tree # traversal. A slow snapshot used to let a finished probe become timed_out. mv "$fixtures/bin/ps" "$fixtures/real-ps"