Skip to content
Merged
Show file tree
Hide file tree
Changes from 3 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 9 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ More views: [Discover](screenshots/discover.png),
- Dependency-aware previews before anything is applied; mixed changes are
reviewed and applied one step at a time
- Per-package progress, copyable logs and detailed history
- Discover catalog of 174 applications in 13 sections, limited to what your
- Discover catalog of 254 applications in 13 sections, limited to what your
enabled repositories provide (can be hidden)
- Adaptive layout: sidebar, package table and inspector on desktop; bottom
navigation and a separate details page in narrow windows
Expand Down Expand Up @@ -91,6 +91,14 @@ helper fixture and never changes host packages. `scripts/debug-run.sh` runs a
debug build with full logging and core dumps; `CAERUS_TRACE_STARTUP=1` logs
startup milestones.

To verify Discover candidates against Void's official binary repository, run
`python3 scripts/check-discover-void.py --desktop-files PACKAGE...`.
The checker ignores configured third-party repositories, fetches metadata in
memory, and reports package versions and desktop filenames as JSON. Use
`--output PATH` to save the report. Results apply to the host XBPS architecture;
other architectures may provide a different set of packages. No packages are
installed or repository configuration changed.

## License

GPL-3.0-or-later — see [LICENSE](LICENSE).
21 changes: 20 additions & 1 deletion caerus-helper/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -539,6 +539,7 @@ fn stream_key_msgs<R: Read + Send + 'static>(src: R, tx: mpsc::Sender<KeyMsg>) {
fn run_sync_pinned(fingerprint: &str) -> Option<i32> {
let mut child = Command::new("xbps-install")
.arg("-S")
.env("LC_ALL", "C")
.stdout(Stdio::piped())
.stderr(Stdio::piped())
.stdin(Stdio::piped())
Expand All @@ -562,7 +563,7 @@ fn run_sync_pinned(fingerprint: &str) -> Option<i32> {
let _ = io::stdout().flush();
}
KeyMsg::Prompt => {
let ok = seen.as_deref() == Some(fingerprint);
let ok = consume_fingerprint(&mut seen, fingerprint);
if !ok {
mismatch = true;
println!("LOG refusing to import a key whose fingerprint is not {fingerprint}");
Expand All @@ -582,6 +583,11 @@ fn run_sync_pinned(fingerprint: &str) -> Option<i32> {
}
}

// A fingerprint authorizes one prompt only, never a later repository's key.
fn consume_fingerprint(seen: &mut Option<String>, expected: &str) -> bool {
seen.take().as_deref() == Some(expected)
}

fn handle_sync_trust(rest: &str) {
let fp = rest.trim().to_ascii_lowercase();
if !is_valid_fingerprint(&fp) {
Expand Down Expand Up @@ -1060,6 +1066,19 @@ mod tests {
assert!(!is_valid_fingerprint("--foo"));
}

#[test]
fn each_key_prompt_requires_a_fresh_matching_fingerprint() {
let expected = "3d:22:2e:eb:26:a5:15:a8:e3:91:c9:eb:97:4e:c6:94";
let mut seen = Some(expected.to_string());
assert!(consume_fingerprint(&mut seen, expected));
assert!(!consume_fingerprint(&mut seen, expected));
seen = Some("another key".to_string());
assert!(!consume_fingerprint(&mut seen, expected));
assert!(seen.is_none());
seen = Some(expected.to_string());
assert!(consume_fingerprint(&mut seen, expected));
}

#[test]
fn every_pkg_verb_has_an_argv() {
for (verb, _) in PKG_VERBS {
Expand Down
27 changes: 26 additions & 1 deletion caerus/src/backend/transaction.rs
Original file line number Diff line number Diff line change
Expand Up @@ -272,7 +272,8 @@ impl Transaction {
let tx_err = line_tx;
let err_handle = thread::spawn(move || {
for line in BufReader::new(stderr).lines().map_while(Result::ok) {
if tx_err.send(line).is_err() {
// Authentication/helper diagnostics are never protocol messages.
if tx_err.send(diagnostic_line(&line)).is_err() {
break;
}
}
Expand Down Expand Up @@ -492,11 +493,35 @@ fn command_is_safe(command: &str) -> bool {
!command.chars().any(char::is_control)
}

fn diagnostic_line(line: &str) -> String {
format!("LOG {line}")
}

#[cfg(test)]
mod tests {
use super::*;
use std::os::unix::fs::MetadataExt;

#[test]
fn stderr_cannot_complete_or_advance_a_batch() {
let txn = Transaction::without_poll();
txn.inner.state.set(TxnState::Busy);
let result = Rc::new(Cell::new(None));
let callback = result.clone();
txn.inner.batches.borrow_mut().push_back(Batch {
commands: VecDeque::from(["REMOVE next".into()]),
on_finished: Some(Box::new(move |ok| callback.set(Some(ok)))),
});
for line in ["OK", "READY", "ERROR diagnostic", "EVENT 1\\tfinished\\t1"] {
txn.handle_line(&diagnostic_line(line));
}
assert_eq!(result.get(), None);
assert_eq!(txn.inner.state.get(), TxnState::Busy);
assert_eq!(txn.inner.batches.borrow()[0].commands.len(), 1);
txn.fail_all_batches();
assert_eq!(result.get(), Some(false));
}

/// Scratch directory under the system temp dir, removed on drop.
struct Scratch(PathBuf);

Expand Down
12 changes: 10 additions & 2 deletions caerus/src/ui/apply_dialog.rs
Original file line number Diff line number Diff line change
Expand Up @@ -421,7 +421,10 @@ pub fn smoke_test_transaction_history() {
}
use std::os::unix::fs::PermissionsExt;
let root = std::env::temp_dir().join(format!("caerus-ui-transaction-{}", std::process::id()));
std::fs::create_dir_all(&root).unwrap();
// The helper trust check rejects group-writable ancestors; do not depend
// on the caller's umask or reuse a directory left by another process.
std::fs::create_dir(&root).unwrap();
std::fs::set_permissions(&root, std::fs::Permissions::from_mode(0o700)).unwrap();
let launcher = root.join("pkexec");
std::fs::write(&launcher, "#!/bin/sh\nexec \"$@\"\n").unwrap();
std::fs::set_permissions(&launcher, std::fs::Permissions::from_mode(0o755)).unwrap();
Expand Down Expand Up @@ -497,7 +500,12 @@ done
std::fs::remove_dir_all(root).unwrap();
assert_eq!(finished.get(), Some(false));
assert_eq!(entries.len(), 1);
assert!(entries[0].changes.contains("foo · Completed"));
assert!(
entries[0].changes.contains("foo · Completed"),
"fixture changes: {}; log: {}",
entries[0].changes,
entries[0].log
);
assert!(entries[0].changes.contains("bar · Not processed"));
assert!(entries[0]
.changes
Expand Down
Loading
Loading