40
%global __cmake_builddir %{__builddir}
41
%endif
42
43
+# Determine requirements for account handling.
44
+# openSUSE and RHEL/OEL 8 need Provides for user/group accounts explicitly
45
+# spelled out, other platforms do not.
46
+%if 0%{?suse_version}
47
+%global _have_sysuser 1
48
+%global _need_explicit_user_provides 1
49
+%else
50
+%if 0%{?centos_ver} >= 10 || 0%{?oraclelinux} >= 10 || 0%{?fedora} >= 43
51
+%global _have_sysuser 1
52
+%global _need_explicit_user_provides 0
53
+%else
54
+%global _have_sysuser 0
55
+%global _need_explicit_user_provides 0
56
+%endif
57
+%endif
58
+
59
# Disable eBPF for architectures other than x86
60
%ifarch x86_64 i386
61
%global _have_ebpf 1
72
%define _libexecdir /usr/libexec
73
%define _libdir /usr/lib
74
59
-%{!?_systemd_util_dir:%global _systemd_util_dir /usr/lib/systemd}
60
-
61
-# Fedora doesn’t define this, but other distros do
75
+%{!?_sysusersdir:%global _sysusersdir %{_libdir}/sysusers.d}
76
+%{!?_systemd_util_dir:%global _systemd_util_dir %{_libdir}/systemd}
77
%{!?_presetdir:%global _presetdir %{_libdir}/systemd/system-preset}
78
79
# Redefine centos_ver to standardize on a single macro
230
BuildRequires: systemd
231
%endif
232
218
-# Core requirements for the install to succeed
219
-Requires(pre): /usr/sbin/groupadd
220
-Requires(pre): /usr/sbin/useradd
221
-
222
-%if 0%{?suse_version} || 0%{?fedora}
223
-Provides: user(netdata)
224
-Provides: group(netdata)
225
-%endif
226
-
233
# #####################################################################
234
# External plugin package dependencies
235
# #####################################################################
237
# to support weak dependencies. Explicitly requiring our default plugins
238
# makes it impossible to properly test the packages prior to upload,
239
# so we just skip depending on them on CentOS 7.
240
+%if ! %{_have_sysuser}
241
+Requires(pre): %{name}-user >= %{version}
242
+%endif
243
Requires: %{name}-dashboard
244
%if 0%{?_have_ebpf}
245
Requires: %{name}-plugin-ebpf = %{version}
522
install -m 644 -p "system/systemd/50-%{name}.preset" "${RPM_BUILD_ROOT}%{_presetdir}/50-%{name}.preset"
523
install -m 755 -d "${RPM_BUILD_ROOT}%{_systemd_util_dir}/journald@%{name}.conf.d"
524
install -m 644 -p "system/systemd/journald@%{name}.conf" "${RPM_BUILD_ROOT}%{_systemd_util_dir}/journald@%{name}.conf.d/%{name}.conf"
516
-
517
-%pre
518
-
519
-if ! getent group %{name} > /dev/null; then
520
- groupadd --system %{name}
521
-fi
522
-
523
-if ! getent passwd %{name} > /dev/null; then
524
- useradd --system -g %{name} --home %{contentdir} --no-create-home -s /sbin/nologin -c "Netdata pseudo user" %{name}
525
-fi
526
-
527
-# I am not sure that the corresponding group names are exactly the same as in Debian, but we should start somewhere, shouldn't we?
528
-for item in docker nginx varnish haproxy adm nsd proxy squid ceph nobody I2C; do
529
- if getent group $item > /dev/null 2>&1; then
530
- usermod -a -G ${item} %{name}
531
- fi
532
-done
525
+install -m 755 -d "${RPM_BUILD_ROOT}%{_sysusersdir}"
526
+install -m 644 -p "%{__cmake_builddir}/system/systemd/sysusers/%{name}.conf" "${RPM_BUILD_ROOT}%{_sysusersdir}/%{name}.conf"
527
528
%post
529
%if 0%{?suse_version}
699
# Network viewer belongs to a different sub-package
700
%exclude %{_libexecdir}/%{name}/plugins.d/network-viewer.plugin
701
702
+%exclude %{_sysusersdir}/%{name}.conf
703
+
704
# CUPS belongs to a different sub package
705
%if %{_have_cups}
706
%exclude %{_libexecdir}/%{name}/plugins.d/cups.plugin
709
Summary: The CUPS metrics collection plugin for the Netdata Agent
710
Group: Applications/System
711
Requires: %{name} = %{version}
712
+%if ! %{_have_sysuser}
713
+Requires(pre): %{name}-user >= %{version}
714
+%endif
715
716
%description plugin-cups
717
This plugin allows the Netdata Agent to collect metrics from the Common UNIX Printing System.
718
720
-%pre plugin-cups
721
-
722
-if ! getent group %{name} > /dev/null; then
723
- groupadd --system %{name}
724
-fi
725
-
719
%files plugin-cups
720
%attr(0750,root,netdata) %{_libexecdir}/%{name}/plugins.d/cups.plugin
721
%endif
726
Group: Applications/System
727
Requires: freeipmi
728
Requires: %{name} = %{version}
729
+%if ! %{_have_sysuser}
730
+Requires(pre): %{name}-user >= %{version}
731
+%endif
732
733
%description plugin-freeipmi
734
This plugin allows the Netdata Agent to collect metrics from hardware using FreeIPMI.
735
740
-%pre plugin-freeipmi
741
-
742
-if ! getent group %{name} > /dev/null; then
743
- groupadd --system %{name}
744
-fi
745
-
736
%files plugin-freeipmi
737
%attr(4750,root,netdata) %{_libexecdir}/%{name}/plugins.d/freeipmi.plugin
738
%endif
743
Group: Applications/System
744
Requires: %{name} = %{version}
745
Conflicts: %{name} < %{version}
746
+%if ! %{_have_sysuser}
747
+Requires(pre): %{name}-user >= %{version}
748
+%endif
749
750
%description plugin-nfacct
751
This plugin allows the Netdata Agent to collect metrics from the firewall using NFACCT objects.
752
760
-%pre plugin-nfacct
761
-
762
-if ! getent group %{name} > /dev/null; then
763
- groupadd --system %{name}
764
-fi
765
-
753
%files plugin-nfacct
754
%attr(4750,root,netdata) %{_libexecdir}/%{name}/plugins.d/nfacct.plugin
755
%endif
765
Suggests: iw
766
Suggests: sudo
767
%endif
768
+%if ! %{_have_sysuser}
769
+Requires(pre): %{name}-user >= %{version}
770
+%endif
771
772
%description plugin-chartsd
773
This plugin adds a selection of additional collectors written in shell script to the Netdata Agent.
774
It includes collectors for APCUPSD, LibreSWAN, OpenSIPS, and Wireless access point statistics.
775
786
-%pre plugin-chartsd
787
-
788
-if ! getent group %{name} > /dev/null; then
789
- groupadd --system %{name}
790
-fi
791
-
776
%files plugin-chartsd
777
%defattr(0750,root,netdata,0750)
778
%{_libexecdir}/%{name}/plugins.d/charts.d.plugin
795
Requires: %{name}-plugin-apps = %{version}
796
Requires: %{name}-ebpf-legacy-code >= %{version}
797
%endif
798
+%if ! %{_have_sysuser}
799
+Requires(pre): %{name}-user >= %{version}
800
+%endif
801
802
%description plugin-ebpf
803
This plugin allows the Netdata Agent to use eBPF code to collect more detailed kernel-level metrics for the system.
804
818
-%pre plugin-ebpf
819
-
820
-if ! getent group %{name} > /dev/null; then
821
- groupadd --system %{name}
822
-fi
823
-
805
%files plugin-ebpf
806
%defattr(4750,root,netdata,4750)
807
%{_libexecdir}/%{name}/plugins.d/ebpf.plugin
814
Group: Applications/System
815
Requires: %{name}-plugin-ebpf = %{version}
816
Conflicts: %{name} < %{version}
817
+%if ! %{_have_sysuser}
818
+Requires(pre): %{name}-user >= %{version}
819
+%endif
820
821
%description ebpf-legacy-code
822
This package provides the pre-compiled eBPF legacy code for use by the Netdata eBPF plugin.
823
This code is only needed when using the eBPF plugin with kernel versions before 5.10.
824
841
-%pre ebpf-legacy-code
842
-
843
-if ! getent group %{name} > /dev/null; then
844
- groupadd --system %{name}
845
-fi
846
-
825
%files ebpf-legacy-code
826
%defattr(0640,root,netdata,0640)
827
%{_libexecdir}/%{name}/plugins.d/ebpf.d/*.o
841
%if 0%{?centos_ver} != 7
842
Suggests: sudo
843
%endif
844
+%if ! %{_have_sysuser}
845
+Requires(pre): %{name}-user >= %{version}
846
+%endif
847
848
%description plugin-pythond
849
This plugin adds a selection of additional collectors written in Python to the Netdata Agent.
850
Many of the collectors provided by this package are also available in netdata-plugin-go. In msot cases, you probably
851
want to use those versions instead of the Python versions.
852
872
-%pre plugin-pythond
873
-
874
-if ! getent group %{name} > /dev/null; then
875
- groupadd --system %{name}
876
-fi
877
-
853
%files plugin-pythond
854
%defattr(0750,root,netdata,0750)
855
%{_libexecdir}/%{name}/plugins.d/python.d.plugin
867
Suggests: nvme-cli
868
Suggests: sudo
869
%endif
870
+%if ! %{_have_sysuser}
871
+Requires(pre): %{name}-user >= %{version}
872
+%endif
873
874
%description plugin-go
875
This plugin adds a selection of additional collectors written in Go to the Netdata Agent
876
A significant percentage of the application specific collectors provided by Netdata are part of this plugin,
877
so most users will want it installed.
878
901
-%pre plugin-go
902
-
903
-if ! getent group %{name} > /dev/null; then
904
- groupadd --system %{name}
905
-fi
906
-
879
%files plugin-go
880
%defattr(0750,root,netdata,0750)
881
# CAP_NET_ADMIN needed for WireGuard collector
893
Requires: %{name}-plugin-ibm-libs = %{version}
894
Requires: unixODBC
895
Conflicts: %{name} < %{version}
896
+%if ! %{_have_sysuser}
897
+Requires(pre): %{name}-user >= %{version}
898
+%else
899
+Requires(pre): user(%{name})
900
+Requires(pre): group(%{name})
901
+%endif
902
AutoReqProv: no
903
904
%description plugin-ibm
905
This plugin adds IBM ecosystem collectors (AS/400, DB2, MQ, WebSphere) to the Netdata Agent.
906
Database collectors (AS/400, DB2) use unixODBC exclusively and require appropriate ODBC drivers.
907
930
-%pre plugin-ibm
931
-
932
-if ! getent group %{name} > /dev/null; then
933
- groupadd --system %{name}
934
-fi
935
-
908
%files plugin-ibm
909
%defattr(0750,root,netdata,0750)
910
%{_libexecdir}/%{name}/plugins.d/ibm.d.plugin
917
Group: Applications/System
918
Requires: %{name} = %{version}
919
Conflicts: %{name} < %{version}
920
+%if ! %{_have_sysuser}
921
+%if ! %{_have_sysuser}
922
+Requires(pre): %{name}-user >= %{version}
923
+%endif
924
+%else
925
+Requires(pre): user(%{name})
926
+Requires(pre): group(%{name})
927
+%endif
928
AutoReqProv: no
929
930
%description plugin-ibm-libs
931
This package provides the IBM MQ client libraries needed by Netdata IBM
932
ecosystem metrics collection plugin.
933
954
-%pre plugin-ibm-libs
955
-
956
-if ! getent group %{name} > /dev/null; then
957
- groupadd --system %{name}
958
-fi
959
-
934
%files plugin-ibm-libs
935
%defattr(0750,root,netdata,0750)
936
%{_libdir}/%{name}/ibm-mqclient/bin/amqcgskv32
3031
Group: Applications/System
3032
Requires: %{name} = %{version}
3033
Conflicts: %{name} < %{version}
3034
+%if ! %{_have_sysuser}
3035
+Requires(pre): %{name}-user >= %{version}
3036
+%endif
3037
3038
%description plugin-apps
3039
This plugin allows the Netdata Agent to collect per-application and per-user metrics without using cgroups.
3040
3064
-%pre plugin-apps
3065
-
3066
-if ! getent group %{name} > /dev/null; then
3067
- groupadd --system %{name}
3068
-fi
3069
-
3041
%files plugin-apps
3042
%defattr(0750,root,netdata,0750)
3043
# CAP_DAC_READ_SEARCH and CAP_SYS_PTRACE needed for data collection by the plugin.
3050
Group: Applications/System
3051
Requires: %{name} = %{version}
3052
Conflicts: %{name} < %{version}
3053
+%if ! %{_have_sysuser}
3054
+Requires(pre): %{name}-user >= %{version}
3055
+%endif
3056
3057
%description plugin-slabinfo
3058
This plugin allows the Netdata Agent to collect perfromance and utilization metrics for the Linux kernel’s SLAB allocator.
3059
3086
-%pre plugin-slabinfo
3087
-
3088
-if ! getent group %{name} > /dev/null; then
3089
- groupadd --system %{name}
3090
-fi
3091
-
3060
%files plugin-slabinfo
3061
%defattr(0750,root,netdata,0750)
3062
# CAP_DAC_READ_SEARCH needed to access the files the plugin reads to collect data.
3067
Group: Applications/System
3068
Requires: %{name} = %{version}
3069
Conflicts: %{name} < %{version}
3070
+%if ! %{_have_sysuser}
3071
+Requires(pre): %{name}-user >= %{version}
3072
+%endif
3073
3074
%description plugin-perf
3075
This plugin allows the Netdata to collect metrics from the Linux perf subsystem.
3076
3106
-%pre plugin-perf
3107
-
3108
-if ! getent group %{name} > /dev/null; then
3109
- groupadd --system %{name}
3110
-fi
3111
-
3077
%files plugin-perf
3078
%defattr(0750,root,netdata,0750)
3079
# Either CAP_SYS_ADMIN or CAP_PERFMON needed for data collection
3089
Group: Applications/System
3090
Requires: %{name} = %{version}
3091
Conflicts: %{name} < %{version}
3092
+%if ! %{_have_sysuser}
3093
+Requires(pre): %{name}-user >= %{version}
3094
+%endif
3095
3096
%description plugin-debugfs
3097
This plugin allows the Netdata Agent to collect Linux kernel metrics exposed through debugfs.
3098
3131
-%pre plugin-debugfs
3132
-
3133
-if ! getent group %{name} > /dev/null; then
3134
- groupadd --system %{name}
3135
-fi
3136
-
3099
%files plugin-debugfs
3100
%defattr(0750,root,netdata,0750)
3101
# CAP_DAC_READ_SEARCH required for data collection.
3106
Group: Applications/System
3107
Requires: %{name} = %{version}
3108
Conflicts: %{name} < %{version}
3109
+%if ! %{_have_sysuser}
3110
+Requires(pre): %{name}-user >= %{version}
3111
+%endif
3112
3113
%description plugin-systemd-journal
3114
This plugin allows the Netdata Agent to present entries from the systemd
3115
journal on Netdata Cloud or the local Agent Dashboard.
3116
3152
-%pre plugin-systemd-journal
3153
-
3154
-if ! getent group %{name} > /dev/null; then
3155
- groupadd --system %{name}
3156
-fi
3157
-
3117
%files plugin-systemd-journal
3118
%defattr(0750,root,netdata,0750)
3119
# CAP_DAC_READ_SEARCH required for data collection.
3125
Group: Applications/System
3126
Requires: %{name} = %{version}
3127
Conflicts: %{name} < %{version}
3128
+%if ! %{_have_sysuser}
3129
+Requires(pre): %{name}-user >= %{version}
3130
+%endif
3131
3132
%description plugin-systemd-units
3133
This plugin allows Netdata to collect metrics about systemd units.
3134
3173
-%pre plugin-systemd-units
3174
-if ! getent group %{name} > /dev/null; then
3175
- groupadd --system %{name}
3176
-fi
3177
-
3135
%files plugin-systemd-units
3136
%defattr(0750,root,netdata,0750)
3137
%{_libexecdir}/%{name}/plugins.d/systemd-units.plugin
3143
Group: Applications/System
3144
Requires: %{name} = %{version}
3145
Conflicts: %{name} < %{version}
3146
+%if ! %{_have_sysuser}
3147
+Requires(pre): %{name}-user >= %{version}
3148
+%endif
3149
3150
%description plugin-xenstat
3151
This plugin allows Netdata to collect metrics from the Xen Hypervisor.
3152
3193
-%pre plugin-xenstat
3194
-if ! getent group %{name} > /dev/null; then
3195
- groupadd --system %{name}
3196
-fi
3197
-
3153
%files plugin-xenstat
3154
%defattr(0750,root,netdata,0750)
3155
# SUID needed for data collection
3168
Requires: %{name}-plugin-ebpf = %{version}
3169
%endif
3170
%endif
3171
+%if ! %{_have_sysuser}
3172
+Requires(pre): %{name}-user >= %{version}
3173
+%endif
3174
3175
%description plugin-network-viewer
3176
This plugin allows the Netdata Agent to provide network connection
3177
mapping functionality for use in netdata Cloud.
3178
3221
-%pre plugin-network-viewer
3222
-if ! getent group %{name} > /dev/null; then
3223
- groupadd --system %{name}
3224
-fi
3225
-
3179
%files plugin-network-viewer
3180
%defattr(0750,root,netdata,0750)
3181
# CAP_SYS_ADMIN, CAP_SYS_PTRACE and CAP_DAC_READ_SEARCH needed for data collection.
3186
Group: Applications/System
3187
Requires: %{name} >= %{version}
3188
Conflicts: %{name} < %{version}
3189
+%if ! %{_have_sysuser}
3190
+Requires(pre): %{name}-user >= %{version}
3191
+%endif
3192
3193
%description dashboard
3194
This allows access to the dashboard on the local node without internet access.
3195
3240
-%pre dashboard
3241
-if ! getent group %{name} > /dev/null; then
3242
- groupadd --system %{name}
3243
-fi
3244
-
3196
%files dashboard
3197
%defattr(0644,root,root,0755)
3198
%{_datadir}/%{name}/web
3203
Group: Applications/System
3204
Requires: %{name} >= %{version}
3205
Conflicts: %{name} < %{version}
3206
+%if ! %{_have_sysuser}
3207
+Requires(pre): %{name}-user >= %{version}
3208
+%endif
3209
3210
%description plugin-otel
3211
This plugin allows the Netdata Agent to collect metrics and logs via the
3212
OpenTelemetry gRPC protocol, providing integration with modern observability
3213
stacks.
3214
3261
-%pre plugin-otel
3262
-if ! getent group %{name} > /dev/null; then
3263
- groupadd --system %{name}
3264
-fi
3265
-
3215
%files plugin-otel
3216
%defattr(0750,root,netdata,0750)
3217
%attr(0750,root,netdata) %{_libexecdir}/%{name}/plugins.d/otel-plugin
3218
%endif
3219
3220
+%package user
3221
+Summary: User and group accounts for the Netdata Agent
3222
+Group: Applications/System
3223
+%if ! %{_have_sysuser}
3224
+Requires: /usr/sbin/useradd
3225
+Requires: /usr/sbin/groupadd
3226
+%else
3227
+Requires: systemd
3228
+%endif
3229
+%if %{_need_explicit_user_provides}
3230
+Provides: user(netdata)
3231
+Provides: group(netdata)
3232
+%endif
3233
+
3234
+%description user
3235
+ This package provides the netdata user and group that are used by the Netdata Agent.
3236
+
3237
+%post user
3238
+%if %{_need_explicit_user_provides} || ! %{_have_sysuser}
3239
+if command -v systemd-sysusers >/dev/null 2>&1; then
3240
+ systemd-sysusers %{_sysusersdir}/%{name}.conf
3241
+else
3242
+ if ! getent group %{name} > /dev/null; then
3243
+ groupadd --system %{name}
3244
+ fi
3245
+
3246
+ if ! getent passwd %{name} > /dev/null; then
3247
+ useradd --system -g %{name} --home %{contentdir} --no-create-home -s /sbin/nologin -c "Netdata pseudo user" %{name}
3248
+ fi
3249
+fi
3250
+%endif
3251
+
3252
+for item in docker ceph I2C; do
3253
+ if getent group $item > /dev/null 2>&1; then
3254
+ usermod -a -G ${item} %{name}
3255
+ fi
3256
+done
3257
+
3258
+%files user
3259
+%defattr(0644,root,root,0755)
3260
+%attr(0644,root,root) %{_sysusersdir}/%{name}.conf
3261
+
3262
%changelog
3263
+* Tue Nov 11 2025 Austin Hemmelgarn <austin@netdata.cloud> 0.0.0-37
3264
+- Update to use sysusers infrastructure when available.
3265
* Fri Oct 24 2025 Austin Hemmelgarn <austin@netdata.cloud> 0.0.0-36
3266
- Add proper cleanup of auto-update configuration on uninstall
3267
* Tue Sep 30 2025 Austin Hemmelgarn <austin@netdata.cloud> 0.0.0-35