@cryptotaxi247 / netdata-1 / commits / 1c3b11715

Fix user and group handling in DEB packages. (#15166)

* Fix user and group handling in DEB packages. * Actually apply correct ownership. But use the list of files in the package as provided by dpkg to do it instead of blindly modifying everything under /usr/libexec/netdata.

Austin S. Hemmelgarn committed Jun 8, 2023 at 13:05 UTC 1c3b11715e44855d6f2486d61769d820fb6ae50b
18 files changed +247 -72
contrib/debian/control
+41 -41
@@ -44,34 +44,29 @@ Depends: openssl,
44 netdata-plugin-chartsd,
45 netdata-plugin-slabinfo,
46 netdata-plugin-perf
47 +Pre-Depends: adduser,
48 + dpkg (>= 1.17.14),
49 + libcap2-bin (>=1:2.0),
50 + lsb-base (>= 3.1-23.2)
51 Conflicts: netdata-core,
52 netdata-plugins-bash,
53 netdata-plugins-python,
50 - netdata-web
54 + netdata-web,
55 + netdata-base
56 Suggests: netdata-plugin-cups,
57 netdata-plugin-freeipmi
53 -Pre-Depends: dpkg (>= 1.17.14)
58 Description: real-time charts for system monitoring
59 Netdata is a daemon that collects data in realtime (per second)
60 and presents a web site to view and analyze them. The presentation
61 is also real-time and full of interactive charts that precisely
62 render all collected values.
63
60 -Package: netdata-base
61 -Architecture: all
62 -Pre-Depends: adduser,
63 - dpkg (>= 1.17.14),
64 - libcap2-bin (>=1:2.0),
65 - lsb-base (>= 3.1-23.2),
66 - ${misc:Depends},
67 -Description: Base system configuration for Netdata packages
68 - This package handles setup of users and groups for Netdata and it’s plugins.
69 -
64 Package: netdata-plugin-cups
65 Architecture: any
66 Depends: cups,
67 ${shlibs:Depends},
74 -Pre-Depends: netdata-base (= ${source:Version})
68 + netdata (= ${source:Version})
69 +Pre-Depends: adduser
70 Description: The CUPS metrics collection plugin for the Netdata Agent
71 This plugin allows the Netdata Agent to collect metrics from the Common
72 UNIX Printing System.
@@ -79,16 +74,18 @@ Description: The CUPS metrics collection plugin for the Netdata Agent
74 Package: netdata-plugin-freeipmi
75 Architecture: any
76 Depends: freeipmi,
82 - ${shlibs:Depends}
83 -Pre-Depends: netdata-base (= ${source:Version})
77 + ${shlibs:Depends},
78 + netdata (= ${source:Version})
79 +Pre-Depends: adduser
80 Description: The FreeIPMI metrics collection plugin for the Netdata Agent
81 This plugin allows the Netdata Agent to collect metrics from hardware
82 using FreeIPMI.
83
84 Package: netdata-plugin-nfacct
85 Architecture: any
90 -Depends: ${shlibs:Depends}
91 -Pre-Depends: netdata-base (= ${source:Version})
86 +Depends: ${shlibs:Depends},
87 + netdata (= ${source:Version})
88 +Pre-Depends: adduser
89 Conflicts: netdata (<< ${source:Version})
90 Description: The NFACCT metrics collection plugin for the Netdata Agent
91 This plugin allows the Netdata Agent to collect metrics from the firewall
@@ -96,8 +93,9 @@ Description: The NFACCT metrics collection plugin for the Netdata Agent
93
94 Package: netdata-plugin-chartsd
95 Architecture: all
99 -Depends: bash
100 -Pre-Depends: netdata-base (= ${source:Version})
96 +Depends: bash,
97 + netdata (= ${source:Version})
98 +Pre-Depends: adduser
99 Conflicts: netdata (<< ${source:Version})
100 Suggests: apcupsd, nut, iw, sudo
101 Description: The charts.d metrics collection plugin for the Netdata Agent
@@ -107,10 +105,11 @@ Description: The charts.d metrics collection plugin for the Netdata Agent
105
106 Package: netdata-plugin-ebpf
107 Architecture: amd64
110 -Depends: ${shlibs:Depends}
111 -Pre-Depends: netdata-base (= ${source:Version})
112 -Recommends: netdata-ebpf-code-legacy (= ${source:Version}),
113 - netdata-plugin-apps (= ${source:Version})
108 +Depends: ${shlibs:Depends},
109 + netdata (= ${source:Version}),
110 + netdata-ebpf-code-legacy (= ${source:Version})
111 +Pre-Depends: adduser
112 +Recommends: netdata-plugin-apps (= ${source:Version})
113 Conflicts: netdata (<< ${source:Version})
114 Description: The eBPF metrics collection plugin for the Netdata Agent
115 This plugin allows the Netdata Agent to use eBPF code to collect more
@@ -118,8 +117,8 @@ Description: The eBPF metrics collection plugin for the Netdata Agent
117
118 Package: netdata-ebpf-code-legacy
119 Architecture: amd64
121 -Pre-Depends: netdata-base (= ${source:Version})
120 Depends: netdata-plugin-ebpf (= ${source:Version})
121 +Pre-Depends: adduser
122 Conflicts: netdata (<< ${source:Version})
123 Description: Compiled eBPF legacy code for the Netdata eBPF plugin
124 This package provides the pre-compiled eBPF legacy code for use by
@@ -129,8 +128,9 @@ Description: Compiled eBPF legacy code for the Netdata eBPF plugin
128
129 Package: netdata-plugin-pythond
130 Architecture: all
132 -Depends: ${shlibs:Depends}
133 -Pre-Depends: netdata-base (= ${source:Version})
131 +Depends: ${shlibs:Depends},
132 + netdata (= ${source:Version})
133 +Pre-Depends: adduser
134 Suggests: sudo
135 Conflicts: netdata (<< ${source:Version})
136 Description: The python.d metrics collection plugin for the Netdata Agent
@@ -140,9 +140,9 @@ Description: The python.d metrics collection plugin for the Netdata Agent
140
141 Package: netdata-plugin-go
142 Architecture: any
143 -Depends: ${shlibs:Depends}
144 -Pre-Depends: libcap2-bin,
145 - netdata-base (= ${source:Version})
143 +Depends: ${shlibs:Depends},
144 + netdata (= ${source:Version})
145 +Pre-Depends: libcap2-bin, adduser
146 Suggests: nvme-cli, sudo
147 Conflicts: netdata (<< ${source:Version})
148 Description: The go.d metrics collection plugin for the Netdata Agent
@@ -153,9 +153,9 @@ Description: The go.d metrics collection plugin for the Netdata Agent
153
154 Package: netdata-plugin-apps
155 Architecture: any
156 -Depends: ${shlibs:Depends}
157 -Pre-Depends: libcap2-bin,
158 - netdata-base (= ${source:Version})
156 +Depends: ${shlibs:Depends},
157 + netdata (= ${source:Version})
158 +Pre-Depends: libcap2-bin, adduser
159 Conflicts: netdata (<< ${source:Version})
160 Description: The per-application metrics collection plugin for the Netdata Agent
161 This plugin allows the Netdata Agent to collect per-application and
@@ -163,9 +163,9 @@ Description: The per-application metrics collection plugin for the Netdata Agent
163
164 Package: netdata-plugin-slabinfo
165 Architecture: any
166 -Depends: ${shlibs:Depends}
167 -Pre-Depends: libcap2-bin,
168 - netdata-base (= ${source:Version})
166 +Depends: ${shlibs:Depends},
167 + netdata (= ${source:Version})
168 +Pre-Depends: libcap2-bin, adduser
169 Conflicts: netdata (<< ${source:Version})
170 Description: The slabinfo metrics collector for the Netdata Agent
171 This plugin allows the Netdata Agent to collect perfromance and
@@ -173,9 +173,9 @@ Description: The slabinfo metrics collector for the Netdata Agent
173
174 Package: netdata-plugin-perf
175 Architecture: any
176 -Depends: ${shlibs:Depends}
177 -Pre-Depends: libcap2-bin,
178 - netdata-base (= ${source:Version})
176 +Depends: ${shlibs:Depends},
177 + netdata (= ${source:Version})
178 +Pre-Depends: libcap2-bin, adduser
179 Conflicts: netdata (<< ${source:Version})
180 Description: The perf metrics collector for the Netdata Agent
181 This plugin allows the Netdata to collect metrics from the Linux perf
@@ -183,9 +183,9 @@ Description: The perf metrics collector for the Netdata Agent
183
184 Package: netdata-plugin-debugfs
185 Architecture: any
186 -Depends: ${shlibs:Debends}
187 -Pre-Depends: libcap2-bin,
188 - netdata-base (= ${source:Version})
186 +Depends: ${shlibs:Debends},
187 + netdata (= ${source:Version})
188 +Pre-Depends: libcap2-bin, adduser
189 Conflicts: netdata (<< ${source:Version})
190 Description: The debugfs metrics collector for the Netdata Agent
191 This plugin allows the Netdata Agent to collect Linux kernel metrics
contrib/debian/netdata-base.postinst deleted
-30
@@ -1,30 +0,0 @@
1 -#!/bin/sh
2 -
3 -set -e
4 -
5 -case "$1" in
6 - configure|reconfigure)
7 - if ! getent group netdata > /dev/null; then
8 - addgroup --quiet --system netdata
9 - fi
10 -
11 - if ! getent passwd netdata > /dev/null; then
12 - adduser --quiet --system --ingroup netdata --home /var/lib/netdata --no-create-home netdata
13 - fi
14 -
15 - for item in docker nginx varnish haproxy adm nsd proxy squid ceph nobody I2C; do
16 - if getent group $item > /dev/null 2>&1; then
17 - usermod -a -G $item netdata
18 - fi
19 - done
20 - # Netdata must be able to read /etc/pve/qemu-server/* and /etc/pve/lxc/*
21 - # for reading VMs/containers names, CPU and memory limits on Proxmox.
22 - if [ -d "/etc/pve" ] && getent group "www-data" > /dev/null 2>&1; then
23 - usermod -a -G www-data netdata
24 - fi
25 - ;;
26 -esac
27 -
28 -##DEBHELPER##
29 -
30 -exit 0
contrib/debian/netdata-ebpf-code-legacy.postinst new
+13
@@ -0,0 +1,13 @@
1 +#!/bin/sh
2 +
3 +set -e
4 +
5 +case "$1" in
6 + configure|reconfigure)
7 + grep /usr/libexec/netdata /var/lib/dpkg/info/netdata-ebpf-code-legacy.list | xargs -n 30 chown root:netdata
8 + ;;
9 +esac
10 +
11 +#DEBHELPER#
12 +
13 +exit 0
contrib/debian/netdata-ebpf-code-legacy.preinst new
+13
@@ -0,0 +1,13 @@
1 +#!/bin/sh
2 +
3 +set -e
4 +
5 +case "$1" in
6 + install)
7 + if ! getent group netdata > /dev/null; then
8 + addgroup --quiet --system netdata
9 + fi
10 + ;;
11 +esac
12 +
13 +#DEBHELPER#
contrib/debian/netdata-plugin-apps.preinst new
+13
@@ -0,0 +1,13 @@
1 +#!/bin/sh
2 +
3 +set -e
4 +
5 +case "$1" in
6 + install)
7 + if ! getent group netdata > /dev/null; then
8 + addgroup --quiet --system netdata
9 + fi
10 + ;;
11 +esac
12 +
13 +#DEBHELPER#
contrib/debian/netdata-plugin-chartsd.postinst new
+13
@@ -0,0 +1,13 @@
1 +#!/bin/sh
2 +
3 +set -e
4 +
5 +case "$1" in
6 + configure|reconfigure)
7 + grep /usr/libexec/netdata /var/lib/dpkg/info/netdata-plugin-chartsd.list | xargs -n 30 chown root:netdata
8 + ;;
9 +esac
10 +
11 +#DEBHELPER#
12 +
13 +exit 0
contrib/debian/netdata-plugin-chartsd.preinst new
+13
@@ -0,0 +1,13 @@
1 +#!/bin/sh
2 +
3 +set -e
4 +
5 +case "$1" in
6 + install)
7 + if ! getent group netdata > /dev/null; then
8 + addgroup --quiet --system netdata
9 + fi
10 + ;;
11 +esac
12 +
13 +#DEBHELPER#
contrib/debian/netdata-plugin-debugfs.preinst new
+13
@@ -0,0 +1,13 @@
1 +#!/bin/sh
2 +
3 +set -e
4 +
5 +case "$1" in
6 + install)
7 + if ! getent group netdata > /dev/null; then
8 + addgroup --quiet --system netdata
9 + fi
10 + ;;
11 +esac
12 +
13 +#DEBHELPER#
contrib/debian/netdata-plugin-ebpf.preinst new
+13
@@ -0,0 +1,13 @@
1 +#!/bin/sh
2 +
3 +set -e
4 +
5 +case "$1" in
6 + install)
7 + if ! getent group netdata > /dev/null; then
8 + addgroup --quiet --system netdata
9 + fi
10 + ;;
11 +esac
12 +
13 +#DEBHELPER#
contrib/debian/netdata-plugin-freeipmi.preinst new
+13
@@ -0,0 +1,13 @@
1 +#!/bin/sh
2 +
3 +set -e
4 +
5 +case "$1" in
6 + install)
7 + if ! getent group netdata > /dev/null; then
8 + addgroup --quiet --system netdata
9 + fi
10 + ;;
11 +esac
12 +
13 +#DEBHELPER#
contrib/debian/netdata-plugin-go.preinst new
+13
@@ -0,0 +1,13 @@
1 +#!/bin/sh
2 +
3 +set -e
4 +
5 +case "$1" in
6 + install)
7 + if ! getent group netdata > /dev/null; then
8 + addgroup --quiet --system netdata
9 + fi
10 + ;;
11 +esac
12 +
13 +#DEBHELPER#
contrib/debian/netdata-plugin-nfacct.preinst new
+13
@@ -0,0 +1,13 @@
1 +#!/bin/sh
2 +
3 +set -e
4 +
5 +case "$1" in
6 + install)
7 + if ! getent group netdata > /dev/null; then
8 + addgroup --quiet --system netdata
9 + fi
10 + ;;
11 +esac
12 +
13 +#DEBHELPER#
contrib/debian/netdata-plugin-perf.preinst new
+13
@@ -0,0 +1,13 @@
1 +#!/bin/sh
2 +
3 +set -e
4 +
5 +case "$1" in
6 + install)
7 + if ! getent group netdata > /dev/null; then
8 + addgroup --quiet --system netdata
9 + fi
10 + ;;
11 +esac
12 +
13 +#DEBHELPER#
contrib/debian/netdata-plugin-pythond.postinst new
+13
@@ -0,0 +1,13 @@
1 +#!/bin/sh
2 +
3 +set -e
4 +
5 +case "$1" in
6 + configure|reconfigure)
7 + grep /usr/libexec/netdata /var/lib/dpkg/info/netdata-plugin-pythond.list | xargs -n 30 chown root:netdata
8 + ;;
9 +esac
10 +
11 +#DEBHELPER#
12 +
13 +exit 0
contrib/debian/netdata-plugin-pythond.preinst new
+13
@@ -0,0 +1,13 @@
1 +#!/bin/sh
2 +
3 +set -e
4 +
5 +case "$1" in
6 + install)
7 + if ! getent group netdata > /dev/null; then
8 + addgroup --quiet --system netdata
9 + fi
10 + ;;
11 +esac
12 +
13 +#DEBHELPER#
contrib/debian/netdata-plugin-slabinfo.preinst new
+13
@@ -0,0 +1,13 @@
1 +#!/bin/sh
2 +
3 +set -e
4 +
5 +case "$1" in
6 + install)
7 + if ! getent group netdata > /dev/null; then
8 + addgroup --quiet --system netdata
9 + fi
10 + ;;
11 +esac
12 +
13 +#DEBHELPER#
contrib/debian/netdata.postinst
+1 -1
@@ -39,7 +39,7 @@ case "$1" in
39
40 dpkg-statoverride --force --update --add root netdata 0775 /var/lib/netdata/registry > /dev/null 2>&1
41
42 - chown -R root:netdata /usr/libexec/netdata/plugins.d
42 + grep /usr/libexec/netdata /var/lib/dpkg/info/netdata.list | xargs -n 30 chown root:netdata
43
44 chmod 4750 /usr/libexec/netdata/plugins.d/cgroup-network
45
contrib/debian/netdata.preinst
+23
@@ -15,4 +15,27 @@ dpkg-maintscript-helper dir_to_symlink \
15 dpkg-maintscript-helper dir_to_symlink \
16 /var/lib/netdata/www/static /usr/share/netdata/www/static 1.18.1~ netdata -- "$@"
17
18 +case "$1" in
19 + install)
20 + if ! getent group netdata > /dev/null; then
21 + addgroup --quiet --system netdata
22 + fi
23 +
24 + if ! getent passwd netdata > /dev/null; then
25 + adduser --quiet --system --ingroup netdata --home /var/lib/netdata --no-create-home netdata
26 + fi
27 +
28 + for item in docker nginx varnish haproxy adm nsd proxy squid ceph nobody I2C; do
29 + if getent group $item > /dev/null 2>&1; then
30 + usermod -a -G $item netdata
31 + fi
32 + done
33 + # Netdata must be able to read /etc/pve/qemu-server/* and /etc/pve/lxc/*
34 + # for reading VMs/containers names, CPU and memory limits on Proxmox.
35 + if [ -d "/etc/pve" ] && getent group "www-data" > /dev/null 2>&1; then
36 + usermod -a -G www-data netdata
37 + fi
38 + ;;
39 +esac
40 +
41 #DEBHELPER#