fix(linux): read protected CUPS PPD via PolicyKit
Some checks failed
Desktop Release / Bootstrap updater signing key (push) Has been cancelled
Desktop Release / Windows x64 NSIS (push) Has been cancelled
Desktop Release / Linux x64 DEB + AppImage (push) Has been cancelled
Desktop Release / Publish public desktop release (push) Has been cancelled

This commit is contained in:
Admin 2026-09-24 04:22:02 +00:00
parent b5e24721ff
commit 2633736fb5
5 changed files with 33 additions and 6 deletions

View File

@ -1,6 +1,6 @@
{
"name": "@fieldlens/print",
"version": "0.1.8",
"version": "0.1.9",
"private": true,
"type": "module",
"scripts": {

View File

@ -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"

View File

@ -537,8 +537,35 @@ fn build_fieldlens_ppd(target_printer: &str) -> Result<PathBuf> {
));
}
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"))

View File

@ -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",

View File

@ -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