From dbf6e091ed4ae19139176c3ab27497653769cb8f Mon Sep 17 00:00:00 2001 From: Dmitriy Date: Sat, 31 Oct 2026 12:30:50 +0300 Subject: [PATCH 1/2] fix: select the available BlueZ adapter for presence --- crates/syauth-presenced/src/runtime.rs | 4 +- crates/syauth-transport/src/peripheral.rs | 20 ++++++ deploy/fedora/syauth.spec | 5 +- deploy/version.env | 2 +- docs/reference/configuration.md | 6 ++ specs/bugs/BUG-20261031-1221.md | 76 +++++++++++++++++++++++ 6 files changed, 109 insertions(+), 4 deletions(-) create mode 100644 specs/bugs/BUG-20261031-1221.md diff --git a/crates/syauth-presenced/src/runtime.rs b/crates/syauth-presenced/src/runtime.rs index 1a54fd1..1a5b061 100644 --- a/crates/syauth-presenced/src/runtime.rs +++ b/crates/syauth-presenced/src/runtime.rs @@ -15,7 +15,7 @@ use std::{ }; use syauth_core::{Bond, BondStatus, BondStore, bond_key_from_pubkeys, peer_id_from_pubkey}; -use syauth_transport::{BOND_KEY_BYTES, DEFAULT_ADAPTER_NAME, FakePeripheral, Peripheral, PersistentPeripheral}; +use syauth_transport::{BOND_KEY_BYTES, FakePeripheral, Peripheral, PersistentPeripheral}; use tokio::{ signal::unix::{SignalKind, signal}, sync::mpsc, @@ -329,7 +329,7 @@ async fn maybe_spawn_orchestrator( // spin up on the next reload. type PairEventRx = tokio::sync::mpsc::Receiver<([u8; 32], [u8; 32])>; let (peripheral, pair_events): (Arc, Option) = match config.peripheral_mode { - PeripheralMode::Real => match PersistentPeripheral::new(DEFAULT_ADAPTER_NAME).await { + PeripheralMode::Real => match PersistentPeripheral::new_default().await { Ok((p, rx)) => (p, Some(rx)), Err(err) => { warn_no_orchestrator(&format!("BlueZ adapter open failed: {err}")); diff --git a/crates/syauth-transport/src/peripheral.rs b/crates/syauth-transport/src/peripheral.rs index 2d35106..d54b77d 100644 --- a/crates/syauth-transport/src/peripheral.rs +++ b/crates/syauth-transport/src/peripheral.rs @@ -336,6 +336,17 @@ pub struct PersistentPeripheral { } impl PersistentPeripheral { + /// Open the available BlueZ default adapter, including renumbered controllers. + pub async fn new_default() -> Result<(Arc, mpsc::Receiver<([u8; PAIR_PUBKEY_LEN], [u8; PAIR_PUBKEY_LEN])>), PeripheralError> { + let session = bluer::Session::new().await.map_err(|err| PeripheralError::Backend { + reason: format!("default adapter session: {err}"), + })?; + let adapter = session.default_adapter().await.map_err(|err| PeripheralError::Backend { + reason: format!("default adapter selection: {err}"), + })?; + Self::new(adapter.name()).await + } + /// Construct a `PersistentPeripheral` bound to `adapter_id`. /// /// Opens the BlueZ adapter, powers it on, and registers an empty @@ -1248,4 +1259,13 @@ mod tests { other => panic!("expected PeerAlreadyAdded, got {other:?}"), } } + + #[tokio::test] + #[ignore = "requires live BlueZ; temporarily registers a GATT application"] + async fn persistent_peripheral_opens_default_bluez_adapter() { + let session = bluer::Session::new().await.expect("system bus"); + let expected = session.default_adapter().await.expect("available adapter"); + let (peripheral, _events) = PersistentPeripheral::new_default().await.expect("open default adapter"); + assert_eq!(peripheral.adapter.name(), expected.name()); + } } diff --git a/deploy/fedora/syauth.spec b/deploy/fedora/syauth.spec index 45d4a1d..f034290 100644 --- a/deploy/fedora/syauth.spec +++ b/deploy/fedora/syauth.spec @@ -13,7 +13,7 @@ # or via `make rpm` (which gates on `which mock`). %global package_version 0.1.0 -%global rpm_release 4 +%global rpm_release 5 %global debug_package %{nil} %global min_fedora 39 @@ -163,6 +163,9 @@ fi %{_mandir}/man8/syauth.8.gz %changelog +* Sat Oct 31 2026 syauth contributors - 0.1.0-5 +- Select the available BlueZ default adapter when starting the presence daemon. + * Tue Oct 20 2026 syauth contributors - 0.1.0-4 - Publish native Linux packages, a signed Android APK, and release checksums. - Add package-manager installation and published documentation. diff --git a/deploy/version.env b/deploy/version.env index 7c6f983..6158d2c 100644 --- a/deploy/version.env +++ b/deploy/version.env @@ -15,7 +15,7 @@ PACKAGE_VERSION=0.1.0 # RPM release counter (the `-1` in `syauth-0.1.0-1.fc39.x86_64.rpm`). # Bump only if a respin is needed without changing the source version. -RPM_RELEASE=4 +RPM_RELEASE=5 # Debian revision (the `-1` in `syauth_0.1.0-1_amd64.deb`). Same rule # as RPM_RELEASE. diff --git a/docs/reference/configuration.md b/docs/reference/configuration.md index 699064b..49a8d9b 100644 --- a/docs/reference/configuration.md +++ b/docs/reference/configuration.md @@ -2,6 +2,12 @@ This page describes the active daemon and PAM configuration. It does not replace the design specification or change the service's authentication policy. +The presence daemon selects BlueZ's available default Bluetooth adapter at +startup. It does not assume the controller is named `hci0`; reinitialized +controllers can appear as `hci1` or later. After controller removal, restarting +the daemon selects the currently available adapter. An RPC status of `up` alone +does not establish that the desktop is advertising or the phone is subscribed. + ## Files and ownership | Path | Owner / use | diff --git a/specs/bugs/BUG-20261031-1221.md b/specs/bugs/BUG-20261031-1221.md new file mode 100644 index 0000000..629f19e --- /dev/null +++ b/specs/bugs/BUG-20261031-1221.md @@ -0,0 +1,76 @@ +# BUG-20261031-1221: Phone discovery fails after Bluetooth adapter renumbering + +## Summary + +The phone cannot discover the desktop because syauth retains an absent `hci0` +while BlueZ exposes the working controller as `hci1`. + +## Reproduction + +- Method: live host and radio regression in sibling syauth. +- Commands: `bluetoothctl list`, `bluetoothctl show`, + `journalctl --user -u syauth-presenced.service -n 25 --no-pager`. +- Evidence: powered controller `50:BB:B5:B9:93:AB`, zero active advertisements; + repeated `rotation failed ... advertise: the target object was either not + present or removed`. BlueZ audio logs use `hci0` on October 27 and `hci1` on + October 29–30. +- An approved daemon restart at 12:21:07 produced `orchestrator not started; + daemon will serve socket only ... adapter set_powered: the target object was + either not present or removed`. The status RPC still reported `state: up`. + +## Expected + +The daemon selects an adapter present in BlueZ and advertises the existing +bond's rotating UUID so the phone reconnects without pairing again. + +## Actual + +The process and RPC socket remain available with no usable Bluetooth transport. +Enabling Bluetooth on the phone cannot recreate the desktop advertisement. + +## Root Cause + +Sibling syauth's `crates/syauth-presenced/src/runtime.rs` initializes +`PersistentPeripheral::new(DEFAULT_ADAPTER_NAME)` with the constant `hci0`. +The named bluer adapter handle does not check object existence until a property +operation. Controller renumbering invalidates the retained handle, and even a +restart repeats the absent adapter selection. + +## Fix + +Select BlueZ's available default adapter for daemon startup. Preserve explicit +adapter selection for callers that request a particular controller. Runtime +recovery after another controller removal remains a separate acceptance concern. + +## Traceability + +- Radio regression: sibling `crates/syauth-transport/src/peripheral.rs`: + `persistent_peripheral_opens_default_bluez_adapter` (explicitly gated). +- Implementation: sibling transport constructor and presenced runtime. +- Before the change, the live regression failed with `adapter set_powered: the + target object was either not present or removed`. After selecting the BlueZ + default, the same regression passed against the current controller. +- The release binary was exercised for 15 seconds on an isolated socket and + pidfile with the existing bond store. At 12:26:41 it registered GATT and + advertised the rotating UUID; `bluetoothctl show` reported one active + advertisement. At 12:26:53 it logged `phone subscribed via standard + notifications`. The probe drained cleanly on SIGTERM. +- syauth workspace: 474 passing test results, zero failures, 10 ignored; + real-radio regression also passed explicitly. Native package source tests: + 14 passed. Clippy and formatting pass. The complete lint target fails at + dependency advisories for basic-toml, ctutils, and Tokio. +- Native RPM `syauth-0.1.0-5.fc44.x86_64` was built from bounded working-tree + source and installed with DNF. The managed service restarted at 12:29:06, + advertised at 12:29:08, and logged a fresh phone subscription at 12:29:10. + `rpm -V syauth` passes; the saved bond-file SHA-256 remains unchanged and + the bond directory retains its user ownership and private modes. +- `timeout 25 sudo -k /usr/bin/true` returned zero. The daemon logged + `outcome=ok` for the 12:29:27.913–12:29:30.386 challenge, and PAM logged + `unlock success reason=granted`. End-to-end phone approval took 2.473 seconds. + A preliminary `sudo -k -n` check refused authentication without invoking the + phone; the actual verification used a PTY and fresh authentication. +- sy workspace: 1,740 passing test results, zero failures, 12 ignored. + `make lint`, `make lint-spark`, and `make test-spark` pass; the bridge has + 18 passing tests. The syauth dependency-audit failures above remain open. +- This repair selects an available controller on startup; it does not add + automatic transport reconstruction after a later controller removal. From bc8370275555cf67dd166cfcd28ea63c59242ade Mon Sep 17 00:00:00 2001 From: Dmitriy Date: Sat, 31 Oct 2026 12:37:27 +0300 Subject: [PATCH 2/2] fix(ci): update vulnerable dependencies and track build parser advisory --- Cargo.lock | 26 +++++++++++++------------- deny.toml | 1 + specs/bugs/BUG-20261031-1221.md | 19 +++++++++++++++++++ 3 files changed, 33 insertions(+), 13 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 77d4d4c..adf5b9c 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -58,7 +58,7 @@ version = "1.1.5" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "40c48f72fd53cd289104fc64099abca73db4166ad86ea0b4341abe65af83dadc" dependencies = [ - "windows-sys 0.61.2", + "windows-sys 0.60.2", ] [[package]] @@ -69,7 +69,7 @@ checksum = "291e6a250ff86cd4a820112fb8898808a366d8f9f58ce16d1f538353ad55747d" dependencies = [ "anstyle", "once_cell_polyfill", - "windows-sys 0.61.2", + "windows-sys 0.60.2", ] [[package]] @@ -542,9 +542,9 @@ dependencies = [ [[package]] name = "ctutils" -version = "0.4.2" +version = "0.4.4" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7d5515a3834141de9eafb9717ad39eea8247b5674e6066c404e8c4b365d2a29e" +checksum = "12218662ccac37d9714f2191252553d67585b97df8c839cbe49e0bde278dc865" dependencies = [ "cmov", ] @@ -796,7 +796,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "39cab71617ae0d63f51a36d69f866391735b51691dbda63cf6f96d042b63efeb" dependencies = [ "libc", - "windows-sys 0.61.2", + "windows-sys 0.60.2", ] [[package]] @@ -1402,7 +1402,7 @@ version = "0.50.3" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "7957b9740744892f114936ab4a57b3f487491bbeafaf8083688b16841a4240e5" dependencies = [ - "windows-sys 0.61.2", + "windows-sys 0.60.2", ] [[package]] @@ -1859,7 +1859,7 @@ dependencies = [ "errno", "libc", "linux-raw-sys", - "windows-sys 0.61.2", + "windows-sys 0.60.2", ] [[package]] @@ -2120,7 +2120,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "3a766e1110788c36f4fa1c2b71b387a7815aa65f88ce0229841826633d93723e" dependencies = [ "libc", - "windows-sys 0.61.2", + "windows-sys 0.60.2", ] [[package]] @@ -2365,7 +2365,7 @@ dependencies = [ "getrandom 0.4.2", "once_cell", "rustix", - "windows-sys 0.61.2", + "windows-sys 0.60.2", ] [[package]] @@ -2447,9 +2447,9 @@ dependencies = [ [[package]] name = "tokio" -version = "1.52.3" +version = "1.53.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "8fc7f01b389ac15039e4dc9531aa973a135d7a4135281b12d7c1bc79fd57fffe" +checksum = "ce3335fa71841cda333a58d7615b03901380ecf09d59b3296d21f8bbac0dde4e" dependencies = [ "bytes", "libc", @@ -2640,7 +2640,7 @@ checksum = "f2f6fb2847f6742cd76af783a2a2c49e9375d0a111c7bef6f71cd9e738c72d6e" dependencies = [ "memoffset", "tempfile", - "windows-sys 0.61.2", + "windows-sys 0.60.2", ] [[package]] @@ -2959,7 +2959,7 @@ version = "0.1.11" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "c2a7b1c03c876122aa43f3020e6c3c3ee5c05081c9a00739faf7503aeba10d22" dependencies = [ - "windows-sys 0.61.2", + "windows-sys 0.60.2", ] [[package]] diff --git a/deny.toml b/deny.toml index 3a47ee6..a311175 100644 --- a/deny.toml +++ b/deny.toml @@ -39,6 +39,7 @@ ignore = [ { id = "RUSTSEC-2026-0370", reason = "zvariant is required by secret-service 5; zbus 6 migration is unreleased" }, { id = "RUSTSEC-2026-0371", reason = "zbus_names is required by secret-service 5; zbus 6 migration is unreleased" }, { id = "RUSTSEC-2026-0372", reason = "zvariant_derive is required by secret-service 5; zbus 6 migration is unreleased" }, + { id = "RUSTSEC-2026-0374", reason = "Build-only Askama configuration parser, still required by current UniFFI; no patched release exists. Track replacement in BUG-20261031-1221." }, ] # --------------------------------------------------------------------------- diff --git a/specs/bugs/BUG-20261031-1221.md b/specs/bugs/BUG-20261031-1221.md index 629f19e..6f6b375 100644 --- a/specs/bugs/BUG-20261031-1221.md +++ b/specs/bugs/BUG-20261031-1221.md @@ -74,3 +74,22 @@ recovery after another controller removal remains a separate acceptance concern. 18 passing tests. The syauth dependency-audit failures above remain open. - This repair selects an available controller on startup; it does not add automatic transport reconstruction after a later controller removal. + +## CI follow-up + +The PR lint job reproduced RustSec failures for `ctutils` 0.4.2, Tokio 1.52.3, +and the unmaintained `basic-toml` parser. Upgrade the first two to patched +releases 0.4.4 and 1.53.3, respectively. + +`basic-toml` has no patched release. It is used by Askama to parse template +configuration during UniFFI scaffolding generation, outside the authentication +runtime. Dependency resolution also confirmed that UniFFI 0.32.2 still requires +it through Askama 0.16.1. Keep the existing UniFFI runtime/generator pairing and +record a narrow exception for informational advisory RUSTSEC-2026-0374. Remove +that exception when the supported generator uses a maintained TOML parser. +The vulnerability advisories are resolved by the lockfile updates. + +Verification: the complete `make lint` target passes, including Clippy, +formatting, scope discipline, and `cargo deny check`; `make test` passes in the +isolated PR worktree. The original host deployment above predates these +dependency updates.