fix(linux): stop the agent when the package is removed - #762
Open
AalmanSadath wants to merge 2 commits into
Open
fix(linux): stop the agent when the package is removed#762AalmanSadath wants to merge 2 commits into
AalmanSadath wants to merge 2 commits into
Conversation
`postremove.sh` only reloaded udev rules, so removing the .deb or .rpm deleted the binaries and left the agent running. The unit stayed enabled too, which means it also came back on the next login. A stranded agent is not merely untidy. It keeps HID++ sessions open on the same /dev/hidraw* nodes as whatever OpenLogi the user is running now, and those devices admit one owner at a time — the same contention the issue template's pre-flight checklist warns about for Logi Options+. Devices then go missing or come back misdetected, with nothing pointing at a package that is no longer installed. When the survivor belongs to the same install as the new client it also keeps the singleton lock and the IPC socket. uninstall.sh has done this correctly all along; only the packaged path was missing it. The awkward part is that the agent is a per-user service while this script runs as root under the package manager, so there is no single session to address. Walk /run/user instead and disable the unit for each logged-in user. `disable --now` rather than `stop`, because the unit is Restart=on-failure and the agent may have written its own copy to $XDG_CONFIG_HOME/systemd/user/ for launch-at-login; both share a unit name, so one disable covers whichever is active and drops the symlink that would restart it. An agent the desktop app spawned is not under systemd at all, so that pass cannot reach it. Match those on their executable path, which keeps a Flatpak, a source build, or a /usr/local install untouched. Both managers also run this on upgrade, spelled differently: dpkg passes "remove"/"purge"/"upgrade", rpm passes the number of instances left behind. Act only on the removal forms, so an update no longer silently turns autostart off.
Greptile SummaryThe PR updates Linux package removal to disable active per-user agent units and terminate GUI-spawned packaged agents, while preserving agents during package upgrades.
Confidence Score: 5/5The PR appears safe to merge. No blocking failure remains from the previous review findings.
|
| Filename | Overview |
|---|---|
| packaging/linux/nfpm-scripts/postremove.sh | Adds removal-only cleanup for systemd-managed and GUI-spawned packaged agents; the two previously discussed enablement concerns are fixed or invalid at the current head. |
Reviews (2): Last reviewed commit: "docs(linux): record what postremove deli..." | Re-trigger Greptile
Comment-only. Two points a reviewer raised, kept next to the code so the next reader does not have to rediscover them. Removing the unit file before this script runs does not defeat the disable: systemd matches .wants symlinks by unit name rather than by reading [Install], so a dangling symlink is still cleaned up. A logged-out user without linger keeps a dangling symlink until the package is reinstalled, and that is deliberate. Root has no route into their systemd instance, and the standard tooling does not attempt one either, so the residue is inert rather than worth chasing through home directories.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Removing the .deb or .rpm deleted the binaries but left the background agent running, and left its user unit enabled so it returned on the next login. postremove.sh only reloaded udev rules.
A stranded agent isn't just untidy: it keeps HID++ sessions open on the same /dev/hidraw* nodes as whatever OpenLogi is running now, and those devices admit one owner at a time — the same contention the issue template's pre-flight checklist warns about for Logi Options+. Devices then go missing or come back misdetected, with nothing pointing at a package the user already removed. When the survivor belongs to the same install as the new client, it also keeps the singleton lock and the IPC socket.
packaging/linux/uninstall.sh has always done this correctly; only the packaged path was missing it.
Related: #673 is the same family on Windows (a leftover agent holding a lock the current client can't use), following #621/#644 for the overlay.
Changes
packaging/linux/nfpm-scripts/postremove.sh
Testing