diff options
author | Emmanuel Vasilakis <mrzammler@mm.st> | 2022-08-04 17:37:14 +0300 |
---|---|---|
committer | GitHub <noreply@github.com> | 2022-08-04 17:37:14 +0300 |
commit | 43cf17af1d60f3bb198f72d444d8f840bc90a3a0 (patch) | |
tree | 4ee335fe94e30eba76ee2847ef7458d5c98b04c4 /collectors/diskspace.plugin/plugin_diskspace.c | |
parent | f28e071580a28e64e4ab4d8e3f5b91bbb8781f36 (diff) |
Check for protected when excluding mounts (#13479)
* check for protected when excluding mounts
* change flag name
* added more mounts to systemd protected
* link to issue comment
Diffstat (limited to 'collectors/diskspace.plugin/plugin_diskspace.c')
-rw-r--r-- | collectors/diskspace.plugin/plugin_diskspace.c | 27 |
1 files changed, 3 insertions, 24 deletions
diff --git a/collectors/diskspace.plugin/plugin_diskspace.c b/collectors/diskspace.plugin/plugin_diskspace.c index fcf64f3e6f..5bdf8bc61f 100644 --- a/collectors/diskspace.plugin/plugin_diskspace.c +++ b/collectors/diskspace.plugin/plugin_diskspace.c @@ -101,28 +101,6 @@ int mount_point_cleanup_cb(const char *name, void *entry, void *data) { return mount_point_cleanup(name, (struct mount_point_metadata *)entry, 0); } -// for the full list of protected mount points look at -// https://github.com/systemd/systemd/blob/1eb3ef78b4df28a9e9f464714208f2682f957e36/src/core/namespace.c#L142-L149 -// https://github.com/systemd/systemd/blob/1eb3ef78b4df28a9e9f464714208f2682f957e36/src/core/namespace.c#L180-L194 -static const char *systemd_protected_mount_points[] = { - "/home", - "/root", - "/usr", - "/boot", - "/efi", - "/etc", - NULL -}; - -int mount_point_is_protected(char *mount_point) -{ - for (size_t i = 0; systemd_protected_mount_points[i] != NULL; i++) - if (!strcmp(mount_point, systemd_protected_mount_points[i])) - return 1; - - return 0; -} - // a copy of basic mountinfo fields struct basic_mountinfo { char *persistent_id; @@ -452,7 +430,7 @@ static inline void do_disk_space_stats(struct mountinfo *mi, int update_every) { if (unlikely( mi->flags & MOUNTINFO_READONLY && - !mount_point_is_protected(mi->mount_point) && + !(mi->flags & MOUNTINFO_IS_IN_SYSD_PROTECTED_LIST) && !m->collected && m->do_space != CONFIG_BOOLEAN_YES && m->do_inodes != CONFIG_BOOLEAN_YES)) @@ -687,7 +665,8 @@ void *diskspace_main(void *ptr) { continue; // exclude mounts made by ProtectHome and ProtectSystem systemd hardening options - if(mi->flags & MOUNTINFO_READONLY && !strcmp(mi->root, mi->mount_point)) + // https://github.com/netdata/netdata/issues/11498#issuecomment-950982878 + if(mi->flags & MOUNTINFO_READONLY && mi->flags & MOUNTINFO_IS_IN_SYSD_PROTECTED_LIST && !strcmp(mi->root, mi->mount_point)) continue; worker_is_busy(WORKER_JOB_MOUNTPOINT); |