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
This commit is contained in:
Kevin Yue committed 2026-10-12 13:37:15 +08:00
1 parent d73b712dd3
commit 93504eaec2
15 files changed
+294 -15

No files matched your search

+1
View File
@@ -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 }}
+22
View File
@@ -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
+1
View File
@@ -1861,6 +1861,7 @@ dependencies = [
"serde", "serde",
"serde_json", "serde_json",
"serde_urlencoded", "serde_urlencoded",
"sha2",
"sha256", "sha256",
"snow", "snow",
"socket2", "socket2",
+146
View File
@@ -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"
);
}
}
+8 -1
View File
@@ -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()
+3 -3
View File
@@ -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());
+9 -2
View File
@@ -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)?;
+1
View File
@@ -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
+28 -2
View File
@@ -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
+1 -1
View File
@@ -510,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
@@ -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")] {
+41 -4
View File
@@ -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();
+5 -1
View File
@@ -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 ''
+19
View File
@@ -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"