Repository navigation
fix(packaging): run maintainer scripts on rpm and fix SELinux label - #166
Merged
czerwonk merged 1 commit intoSep 1, 2026
Merged
Conversation
The scripts block was nested under overrides.deb, so RPMs shipped without
any scriptlets: the ping_exporter user was never created, the config was
never chowned and the systemd drop-ins were never installed.
Moving it up makes it apply to every format, which in turn requires the
scripts to stop being dpkg-specific:
- derive the systemd version from systemctl --version instead of
dpkg-query, so the drop-in selection works on both package managers
- accept rpm's numeric argument ("0") next to dpkg's "remove" when
deciding whether this is a removal or an upgrade
On SELinux hosts the binary additionally matches the base policy entry
for /bin/ping.*, so it lands in ping_exec_t and systemd refuses to
execute it (AVC execute_no_trans, exit 203/EXEC). postinstall now pins
/usr/bin/ping_exporter to bin_t and relabels it; postremove drops the
file context again.
Fixes czerwonk#152
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.
Fixes #152
Two separate things are wrong with the RPM, and they compound.
No scriptlets. In
.goreleaser.ymlthescripts:block sits underoverrides: deb:, so only the .deb getspostinstall/preremove/postremove. The RPM ships without any —rpm -q --scripts ping_exporteris empty, as the reporter shows. Theping_exporteruser the unit requires is never created, the config is never chowned, and the systemd drop-ins are never copied. I moved the block up one level so it applies to every format, and dropped the# TODO: create pre/post install/remove scriptsnote next torpm.That only works if the scripts stop assuming dpkg, so:
systemctl --versioninstead ofdpkg-query. Same drop-in selection as before on Debian (252 picks 233/235/242/245, 232 picks none), and it also works on RHEL.preremove/postremoveaccept rpm's numeric$1(0= uninstall) alongside dpkg'sremove. Without this both would exit early on RPM and never stop the unit or remove the user.Wrong SELinux label. This is what actually produces the
203/EXECin the issue. Missing users fail earlier, at217/USER; the audit log in the report points elsewhere:The base policy ships
/bin/ping.* system_u:object_r:ping_exec_t:s0, and/usr/bin/ping_exportermatches that regex, so the binary inheritsping_exec_t, which systemd may not execute.postinstallnow pins it tobin_tand relabels;postremovedrops the file context on uninstall. Both are guarded onselinuxenabled/semanage/restoreconexisting, so hosts without SELinux tooling are unaffected. I chosebin_tover leaving it inping_tdeliberately: the same audit log showsping_tbeing deniedlistenon a tcp_socket, so the exporter could not serve metrics even if it did start.Verified:
shellcheck -s shclean on all three scripts; the version parser checked against seven realsystemctl --versionformats (el8/el9, arch, deb11, ubuntu, 232); the$1matrix for both package managers; and a dry run ofpostinstallwithsystemctl/semanage/restoreconmocked, confirming the Debian drop-in selection is unchanged.Not verified: I have no goreleaser, nfpm or rpm locally and no enforcing RHEL host, so I could not build the packages or install one. The packaging change is the part that needs your CI.