Skip to content

fix(linux): install the udev rule under /usr/lib, not /etc - #1626

Open
4ni1ak wants to merge 3 commits into
AprilNEA:masterfrom
4ni1ak:fix/udev-rules-path
Open

4ni1ak wants to merge 3 commits into
AprilNEA:masterfrom
4ni1ak:fix/udev-rules-path

Conversation

@4ni1ak

@4ni1ak 4ni1ak commented Sep 29, 2026 •

Copy link
Copy Markdown
Contributor

Summary

The Debian package (nfpm.yaml) and the manual install.sh both installed 70-openlogi.rules to /etc/udev/rules.d, which is meant for administrator overrides, not for files a package ships. pacman's udev-reload hook (35-systemd-udev-reload.hook) only watches /usr/lib/udev/rules.d. So the AUR openlogi-bin package, which is built from the same .deb, installed a rule that nothing reloaded. The device-permission grants did not apply until a manual udevadm control --reload-rules or a reboot.

udev reads a file in /etc in place of the same name under /usr/lib, so a copy left in /etc would hide the packaged rule. The installer and the in-app grant now account for that.

Changes

  • packaging/linux/nfpm.yaml: dst moves to /usr/lib/udev/rules.d/70-openlogi.rules.
  • packaging/linux/install.sh:
    • Installs the rule to the same path, and its --help listing matches.
    • Installs the /usr/lib rule first, then handles an existing /etc copy:
      • removes it only when it is byte-identical to the bundled rule and no package owns it;
      • otherwise keeps it and warns that it takes precedence.
  • packaging/linux/uninstall.sh: removes the rule from the new path, and from the old /etc path if a previous install.sh run left one there.
  • crates/openlogi-permissions (udev.rs), the in-app grant:
    • It still writes to /etc/udev/rules.d, because /usr may be read-only.
    • It skips the write when /usr/lib already holds identical rules and /etc has no copy. Before this, it wrote a second copy that hid the packaged rule after every later upgrade.
    • A stale /etc copy is still refreshed, so the grant can repair it. A test covers all three cases.
  • packaging/linux/udev/70-openlogi.rules and docs/INSTALL-linux.md: the manual-install instructions match the new path.
  • packaging/linux/package.nix already installed to $out/lib/udev/rules.d. All three install paths now agree.

The install.sh migration and the in-app skip come from @felipe-NR's follow-up commit, kept with its authorship. On top of it, a stale /etc copy is refreshed instead of left in place.

Testing

Rebased onto current master. Full local gate on the final tree:

  • cargo fmt --all -- --check
  • cargo clippy --workspace --all-targets -- -D warnings
  • cargo test --workspace: 4751 passed, 0 failed
  • cargo doc for the non-GUI crates with RUSTDOCFLAGS="-D warnings"
  • shfmt -d packaging/linux/install.sh

Not run locally: shellcheck, typos, cargo-deny and the Nix checks, because those tools are not installed on this host. The nfpm package build was not run either.

Not runtime-tested on hardware: I did not install a .deb or AUR package to confirm that the rule now reloads without a manual udevadm call on a pacman system. To test it, install the package on Arch and check that the mouse is accessible without a reload or reboot.

Fixes #1545

@4ni1ak
4ni1ak requested a review from AprilNEA as a code owner September 29, 2026 21:31
@greptile-apps

greptile-apps Bot commented Sep 29, 2026 •

Copy link
Copy Markdown

RetriggerView in GreptileConfidence Score: 4/5

[Medium impact] The changes affect Linux device permissions across package installs and the app’s permission grant.

The code addresses both numbered findings, but the required guide update must land before merging.

Findings

  1. P1 Required guides omit the change ▶

Summary

Moves packaged and source-installed udev rules to /usr/lib/udev/rules.d.

  • Linux package and source installs put the udev rule under /usr/lib.
  • The permission grant avoids shadowing package rules with an unnecessary copy.

Reviews (3) · Last reviewed commit: "fix(linux): refresh a stale /etc copy of..." · Reviewed by Greptile

Comment thread packaging/linux/uninstall.sh Resolved
Comment thread packaging/linux/install.sh Resolved
@4ni1ak
4ni1ak force-pushed the fix/udev-rules-path branch from 459aeb3 to 4e2ff8e Compare October 2, 2026 21:57
@4ni1ak

4ni1ak commented Oct 2, 2026

Copy link
Copy Markdown
Contributor Author

Rebased onto current master (install.sh was rewritten into a verified-release installer since I opened this — the udev path was still the old /etc one there too) and addressed both findings:

  • Uninstall deletes packaged rule: uninstall.sh now checks package ownership (dpkg -S / rpm -qf / pacman -Qo) before removing either udev-rule path, and skips a package-owned file with a message instead.
  • Old rules shadow new rules: install.sh's --from-source path now migrates a stale /etc copy from a pre-fix run of itself before installing to /usr/lib — udev prefers /etc, so an un-migrated copy would otherwise permanently shadow the corrected rule. Same package-ownership check gates it, so an installed package's file is left alone.

install-smoke.sh still passes with the updated path assertion; shellcheck/shfmt clean on all three touched scripts.

Comment thread packaging/linux/install.sh Resolved
Comment thread packaging/linux/install.sh Resolved
@davidbudnick davidbudnick added platform: linux Linux-specific issue type: packaging Release packaging, signing, notarization, or artifacts labels Oct 9, 2026
@AprilNEA AprilNEA added the needs: decision Needs a maintainer/product decision label Nov 7, 2026 — with Manus Connector
@felipe-NR

Copy link
Copy Markdown

Thanks @4ni1ak for picking this up. I ran into #1545 on Arch with openlogi-bin and built on top of this branch to cover what is still open here:

  1. Both Greptile findings still apply at 4e2ff8e. The follow-up installs the /usr/lib rule first, then removes the /etc copy only when it is byte-identical to the bundled rule and no package owns it. Any other file there is kept, with a warning that it takes precedence.
  2. The in-app "grant access" path (install_rules in crates/openlogi-permissions/src/udev.rs) still writes to /etc/udev/rules.d, and its identical-file check looks only there. With the packages on /usr/lib, pressing the button on a package install writes a second copy into /etc, which then overrides the packaged rule on every later upgrade. The follow-up skips that write when /usr/lib already holds identical rules, and adds a test for it.

Commit: felipe-NR@c1b713e. Shellcheck, shfmt, the install smoke test and the openlogi-permissions tests and Clippy pass on it. Not runtime-tested on hardware.

It can be cherry-picked onto this branch, or go up as a separate PR on top of this one, whichever fits better. Fine to disregard if a different approach is preferred.

4ni1ak and others added 3 commits November 12, 2026 15:41
The Debian package (nfpm.yaml) and install.sh's --from-source path both
installed 70-openlogi.rules to /etc/udev/rules.d — reserved for
admin-authored local overrides, not files a package or installer ships.
Debian's dpkg triggers reload rules there too, but pacman's udev-reload
hook (35-systemd-udev-reload.hook) only watches /usr/lib/udev/rules.d, so
the AUR openlogi-bin package (built from the same .deb) installed a rule
nothing reloaded — the device-permission grants silently didn't apply
until a manual `udevadm control --reload-rules` or a reboot.

Move both to /usr/lib/udev/rules.d, matching what packaging/linux/package.nix
already does for the Nix build.

Also, since both install paths now converge on one file that either a
package or this installer can own:
- install.sh migrates a stale /etc copy left by a pre-fix run of itself —
  udev prefers /etc over /usr/lib, so an un-migrated one would silently
  shadow the corrected rule forever. Skipped when a package (dpkg/rpm/
  pacman) owns that path instead, so an installed package's own file is
  never touched by the source installer.
- uninstall.sh checks the same package-ownership before removing either
  the current or the pre-migration path, so a package coexisting with a
  source install keeps its own file.

Updates the install-smoke.sh assertion for the new path.

Fixes AprilNEA#1545
install.sh now installs the /usr/lib rule before it touches the old /etc
copy, and removes that copy only when it is byte-identical to the bundled
rule and no package owns it. Any other file there is an administrator's
override: it is kept, with a warning that it takes precedence.

The in-app installer still writes to /etc/udev/rules.d, since /usr may be
read-only, but now skips the write when the package already installed
identical rules under /usr/lib. Before, it wrote a second copy into /etc
that overrode the packaged rule on every later upgrade.
…p grant

The in-app grant skipped its write whenever the package already installed
identical rules under /usr/lib. A different copy left in /etc/udev/rules.d
by an earlier grant then kept shadowing the packaged rules, and the grant
could no longer fix it. Skip the write only when /etc holds no copy.
@4ni1ak
4ni1ak force-pushed the fix/udev-rules-path branch from 4e2ff8e to a2fcc1d Compare November 12, 2026 12:50
@4ni1ak
4ni1ak requested a review from davidbudnick as a code owner November 12, 2026 12:50
Comment thread docs/INSTALL-linux.md

```sh
sudo cp packaging/linux/udev/70-openlogi.rules /etc/udev/rules.d/
sudo cp packaging/linux/udev/70-openlogi.rules /usr/lib/udev/rules.d/

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P1 Required guides omit the change

Blocking. The command at docs/INSTALL-linux.md:238 changes where users install the rule, but none of docs/CONFIGURATION.md, docs/USAGE.md, or docs/DECISIONS.md changes. The repository requires user-visible behavior changes to be documented in one of those guides. Add a short entry explaining the new location and how an existing /etc copy takes precedence.

Rule Used: Severity: medium. A user-visible behaviour change or a known limitation left by a fix (state lost on restart, a race window not covered, Ctrl-C skipping a hand-back) is stated in docs/CONFIGURATION.md, docs/USAGE.md, or docs/DECISIONS.md in the... (source)

Note: If this suggestion doesn't match your team's coding style, reply to this and let me know. I'll remember it for next time!

@davidbudnick davidbudnick added the area: hid HID device discovery, permissions, reads, or writes label Nov 30, 2026

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

area: hid HID device discovery, permissions, reads, or writes needs: decision Needs a maintainer/product decision platform: linux Linux-specific issue type: packaging Release packaging, signing, notarization, or artifacts

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[Bug]: Udev rules are installed in the wrong path

5 participants