Skip to content

Commit ef092a3

Browse files
committed
fix(ipmi_exporter): Fix privilege escalation when running in local mode
Signed-off-by: Kaloyan Kotlarski <[email protected]>
1 parent 281b190 commit ef092a3

File tree

3 files changed

+20
-1
lines changed

3 files changed

+20
-1
lines changed

roles/ipmi_exporter/defaults/main.yml

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,15 @@ ipmi_exporter_modules:
1313
- chassis
1414
- sel
1515

16+
ipmi_exporter_sudo_commands:
17+
- /usr/sbin/ipmimonitoring
18+
- /usr/sbin/ipmi-sensors
19+
- /usr/sbin/ipmi-dcmi
20+
- /usr/sbin/ipmi-raw
21+
- /usr/sbin/bmc-info
22+
- /usr/sbin/ipmi-chassis
23+
- /usr/sbin/ipmi-sel
24+
1625
ipmi_exporter_web_listen_address: "0.0.0.0:9290"
1726

1827
ipmi_exporter_tls_server_config: {}

roles/ipmi_exporter/tasks/configure.yml

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -30,3 +30,14 @@
3030
- ipmi_exporter
3131
- configure
3232
- ipmi_exporter_configure
33+
34+
- name: Create sudoers file to allow passwordless IPMI commands
35+
ansible.builtin.copy:
36+
dest: "/etc/sudoers.d/{{ ipmi_exporter_system_user }}"
37+
content: |
38+
{{ ipmi_exporter_system_user }} ALL=(ALL) NOPASSWD: {{ ipmi_exporter_sudo_commands | join(', ') }}
39+
owner: root
40+
group: root
41+
mode: '0440'
42+
become: true
43+
when: ipmi_exporter_system_user is defined

roles/ipmi_exporter/templates/ipmi_exporter.service.j2

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,6 @@ RestartSec=1
2323
StartLimitInterval=0
2424

2525
ProtectHome=yes
26-
NoNewPrivileges=yes
2726

2827
{% if (ansible_facts.packages.systemd | first).version is version('232', '>=') %}
2928
ProtectSystem=strict

0 commit comments

Comments
 (0)