Skip to content

fix(smartctl_exporter): add kernel capabilities#711

Open
volker-raschek wants to merge 1 commit intoprometheus-community:mainfrom
volker-raschek:fix/smartctl_exporter/kernel_capabilities
Open

fix(smartctl_exporter): add kernel capabilities#711
volker-raschek wants to merge 1 commit intoprometheus-community:mainfrom
volker-raschek:fix/smartctl_exporter/kernel_capabilities

Conversation

@volker-raschek
Copy link
Copy Markdown

@volker-raschek volker-raschek commented Jan 11, 2026

The following patch adds the capabilities that the binary needs to access the disks without root privileges.

The capabilities were determined using the following command. The process ID 1259363 is that of smartctl_exporter when it was previously executed as root.

$ capsh --decode=$(grep CapBnd /proc/1259363/status | cut -f 2)
0x0000000000020004=cap_dac_read_search,cap_sys_rawio

The capabilities CAP_DAC_READ_SEARCH and CAP_SYS_RAWIO were added to the systemd unit, taking into account the systemd version.

With this patch can be smartctl_exporter successfully started.

A similar patch for the prometheus-smartctl-exporter has already been accepted for the Arch Linux package.

https://gitlab.archlinux.org/archlinux/packaging/packages/prometheus-smartctl-exporter/-/commit/b872776265474e9bd8b69ff128c002cf4b005f44

The following patch adds the capabilities that the binary needs to access the
disks without root privileges.

The capabilities were determined using the following command. The process ID
`1259363` is that of `smartctl_exporter` when it was previously executed as
root.

```bash
$ capsh --decode=$(grep CapBnd /proc/1259363/status | cut -f 2)
0x0000000000020004=cap_dac_read_search,cap_sys_rawio
```

The capabilities `CAP_DAC_READ_SEARCH` and `CAP_SYS_RAWIO` were added to the
systemd unit, taking into account the systemd version.

With this patch can be smartctl_exporter successfully started.

Signed-off-by: Markus Pesch <markus.pesch@cryptic.systems>
@gardar gardar force-pushed the fix/smartctl_exporter/kernel_capabilities branch from 2ff4b78 to d8ad9a2 Compare March 6, 2026 15:50
@github-actions github-actions bot added bugfix and removed bugfix labels Mar 6, 2026
@gardar
Copy link
Copy Markdown
Member

gardar commented Mar 6, 2026

Could the capabilities be set on the binary itself like we do with the blackbox_exporter and smokeping_prober instead of doing it in the systemd service?

For reference: #729

Edit: I just remembered that I actually was working on a similar implementation here: https://github.com/prometheus-community/ansible/pull/629/changes#diff-94cc2fd2f52225dbe9db6ef1b16a27190ebc7a485c246bf013c1d0d6e9d86ebbR38

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

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants