From 2633736fb5be576b30ee85917122b65158086471 Mon Sep 17 00:00:00 2001 From: Admin Date: Thu, 24 Sep 2026 04:22:02 +0000 Subject: [PATCH] fix(linux): read protected CUPS PPD via PolicyKit --- package.json | 2 +- src-tauri/Cargo.toml | 2 +- src-tauri/src/printers.rs | 31 +++++++++++++++++++++++++++++-- src-tauri/tauri.conf.json | 2 +- src/main.ts | 2 +- 5 files changed, 33 insertions(+), 6 deletions(-) diff --git a/package.json b/package.json index 78c3531..19977de 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "@fieldlens/print", - "version": "0.1.8", + "version": "0.1.9", "private": true, "type": "module", "scripts": { diff --git a/src-tauri/Cargo.toml b/src-tauri/Cargo.toml index 57b34e8..89ebd99 100644 --- a/src-tauri/Cargo.toml +++ b/src-tauri/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "fieldlens-print" -version = "0.1.8" +version = "0.1.9" description = "FieldLens print-stream barcode capture companion" authors = ["Arrowstack"] edition = "2021" diff --git a/src-tauri/src/printers.rs b/src-tauri/src/printers.rs index 88a14ed..464b7d8 100644 --- a/src-tauri/src/printers.rs +++ b/src-tauri/src/printers.rs @@ -537,8 +537,35 @@ fn build_fieldlens_ppd(target_printer: &str) -> Result { )); } - let original = fs::read_to_string(&source) - .with_context(|| format!("read target printer PPD {}", source.display()))?; + let original = match fs::read_to_string(&source) { + Ok(contents) => contents, + Err(direct_error) => { + // CUPS commonly stores PPDs as root:lp 0640. Desktop users can + // enumerate the queue but cannot necessarily read its PPD. + // Reuse the existing PolicyKit setup flow for a read-only fallback. + let output = Command::new("pkexec") + .arg("cat") + .arg(&source) + .output() + .with_context(|| { + format!( + "read target printer PPD {} (direct read failed: {direct_error})", + source.display() + ) + })?; + + if !output.status.success() { + return Err(anyhow!( + "could not read target printer PPD {}: {}", + source.display(), + String::from_utf8_lossy(&output.stderr).trim() + )); + } + + String::from_utf8(output.stdout) + .with_context(|| format!("decode target printer PPD {}", source.display()))? + } + }; let mut cleaned = original .lines() .filter(|line| !line.contains("fieldlens-capture")) diff --git a/src-tauri/tauri.conf.json b/src-tauri/tauri.conf.json index fc44dad..dfd4896 100644 --- a/src-tauri/tauri.conf.json +++ b/src-tauri/tauri.conf.json @@ -1,7 +1,7 @@ { "$schema": "https://schema.tauri.app/config/2", "productName": "FieldLens Print", - "version": "0.1.8", + "version": "0.1.9", "identifier": "dev.arrowstack.fieldlens.print", "build": { "beforeDevCommand": "npm run dev", diff --git a/src/main.ts b/src/main.ts index 9606000..26b9dc7 100644 --- a/src/main.ts +++ b/src/main.ts @@ -85,7 +85,7 @@ let config: AppConfig let jobs: Job[] = [] let status: Status let loginTimer: number | undefined -let currentVersion = '0.1.8' +let currentVersion = '0.1.9' let bundleType: BundleType | null = null let availableUpdate: Update | null = null let availableManualUpdate: ManualUpdate | null = null