You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
refactor(file-ownership): use os.stat() instead of shelling out, extend default file list and modernize code
- Replace shell exec of `stat` with os.stat() + pwd/grp for better performance and robustness
- Extend default file list with CIS benchmark-relevant files (login.defs, sudoers, sysctl, systemd, PAM, etc.)
- Convert to f-strings, remove pylint directives, extract check_file() function
- Update README with structured overview and accurate documentation
Copy file name to clipboardExpand all lines: CHANGELOG.md
+1Lines changed: 1 addition & 0 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -64,6 +64,7 @@ Monitoring Plugins:
64
64
* all plugins: ignore unknown arguments instead of generating an error (this helps with updating Icinga and Nagios service definitions considerably)
65
65
* by-ssh, by-winrm, disk-usage, example, file-ownership, fs-ro, infomaniak-events, journald-query, logfile, matomo-reporting, mysql-logfile, php-status, pip-updates, systemd-unit: fix `append` parameters so that user-specified values replace defaults instead of being appended to them ([#540](https://github.com/Linuxfabrik/monitoring-plugins/issues/540))
66
66
* file-count: stopping when number of files actually exceed thresholds, therefore dramatically faster for large directories
67
+
* file-ownership: use `os.stat()` instead of shelling out to `stat`, improving performance and robustness
67
68
* nextcloud-version: modernize code
68
69
* php-status: always assume http://localhost/monitoring.php and, if not found, be tolerant
69
70
* redis-status, valkey-status: modernize code and unify both plugins again after [PR #954](https://github.com/Linuxfabrik/monitoring-plugins/pull/954)
Copy file name to clipboardExpand all lines: check-plugins/file-ownership/README.md
+80-41Lines changed: 80 additions & 41 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -2,10 +2,30 @@
2
2
3
3
## Overview
4
4
5
-
Checks the ownership (owner and group, both have to be names) of a list of files, and also (and always) most of the files defined in the CIS Security Benchmarks. Depending on the file and user (e.g. running as 'icinga') sudo (sudoers) is needed.
5
+
Checks the ownership (owner and group) of a list of files against expected values. The default file list covers most files defined in the CIS Security Benchmarks for RHEL, Debian, Ubuntu and Fedora, plus several application-specific paths. Files that do not exist on the system are silently skipped.
6
+
7
+
Alerting Logic:
8
+
9
+
* WARN if any file's owner or group does not match the expected value.
10
+
11
+
Data Collection:
12
+
13
+
* Uses `os.stat()` to read file ownership directly, without shelling out to external commands.
14
+
* Resolves numeric UIDs/GIDs to names. If a UID/GID has no corresponding name, the numeric value is displayed.
15
+
16
+
Compatibility:
17
+
18
+
* Linux only. Not compiled for Windows.
19
+
* Depending on the file and user (e.g. running as `icinga`), sudo (sudoers) may be needed.
20
+
21
+
Important Notes:
22
+
23
+
* If `--filename` is specified, only the user-supplied files are checked. The default list is not used.
24
+
* The following CIS-recommended files are excluded from the defaults because their ownership differs across RHEL, Debian, Ubuntu and SLES: `/etc/gshadow`, `/etc/gshadow-`, `/etc/shadow`, `/etc/shadow-`. To check these, supply them via `--filename` with suitable values.
According to CIS the below mentioned files should also be checked by default, but we don't, because their owners differ on RHEL/CentOS, Debian/Ubuntu and SLES:
44
-
45
-
* /etc/gshadow
46
-
* /etc/gshadow-
47
-
* /etc/shadow
48
-
* /etc/shadow-
49
-
50
-
If you also want to check for those ones, simply configure them in the monitoring software and supply the parameter `--filename` with suitable values.
0 commit comments