Skip to content

fix: auto-reconnect to usbguard-dbus after restart; polkit dialog no longer breaks on re-setup#4

Merged
SolverNA merged 2 commits into
masterfrom
copilot/fix-installation-errors
Apr 23, 2026
Merged

fix: auto-reconnect to usbguard-dbus after restart; polkit dialog no longer breaks on re-setup#4
SolverNA merged 2 commits into
masterfrom
copilot/fix-installation-errors

Conversation

Copilot AI commented Apr 23, 2026

Copy link
Copy Markdown
Contributor

Re-running sudo make setup-usbguard (or reinstalling without uninstalling first) calls systemctl restart usbguard-dbus, which gives the daemon a new unique D-Bus name. The Python daemon's connect_to_signal match rule was pinned to the old name — silently receiving nothing, killing the polkit dialog permanently until the user service was manually restarted.

Changes

  • src/usb-auth-guard — reconnect on org.usbguard1 owner changes via bus.watch_name_owner:
    • On disappear: mark state['iface'] = None
    • On reappear: re-create proxy and re-call connect_to_signal against the new unique name
    • Replaced lazy startup check with explicit get_name_owner() for fast-fail if usbguard-dbus is not running
def on_usbguard_name_changed(new_owner):
    if new_owner and state['iface'] is None:
        subscribe()          # fresh proxy → valid match rule against new unique name
    elif not new_owner and state['iface'] is not None:
        state['iface'] = None  # mark stale, await reappear

bus.watch_name_owner('org.usbguard1', on_usbguard_name_changed)
  • Makefile setup-usbguard — after restarting usbguard services, runs systemctl --user -M <uid>@ restart usb-auth-guard for all logged-in users as a belt-and-suspenders recovery path for daemons running the pre-fix binary.

Copilot AI and others added 2 commits April 23, 2026 00:38
… add setup-usbguard step

Agent-Logs-Url: https://github.com/SolverNA/usb-auth-guard/sessions/abb2673f-ff57-4942-a925-10083ac77a59

Co-authored-by: SolverNA <213126079+SolverNA@users.noreply.github.com>
@SolverNA SolverNA marked this pull request as ready for review April 23, 2026 01:02
@SolverNA SolverNA merged commit ee5c93f into master Apr 23, 2026
1 check passed
@SolverNA SolverNA deleted the copilot/fix-installation-errors branch April 23, 2026 01:02
SolverNA added a commit that referenced this pull request Apr 24, 2026
fix: auto-reconnect to usbguard-dbus after restart; polkit dialog no longer breaks on re-setup
SolverNA added a commit that referenced this pull request Apr 24, 2026
fix: auto-reconnect to usbguard-dbus after restart; polkit dialog no longer breaks on re-setup
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants