Browse Source

TT#157800 run rtpengine as non-root

*) Create dedicated rtpengine user in postinst and remove it in postrm.

*) Use RuntimeDirectory= systemd unit config.

*) Use dedicated user for /proc interface and set file umask to hide it
from other users.

*) Set owner and permissions on default directories used for call recording.

Change-Id: I8e225b36d065d46da2489fb8286916371950f490
pull/1439/head
Richard Fuchs 4 years ago
parent
commit
30c2de8e0f
7 changed files with 55 additions and 10 deletions
  1. +4
    -3
      debian/ngcp-rtpengine-daemon.default
  2. +6
    -0
      debian/ngcp-rtpengine-daemon.postinst
  3. +13
    -0
      debian/ngcp-rtpengine-daemon.postrm
  4. +9
    -4
      debian/ngcp-rtpengine-daemon.service
  5. +1
    -1
      debian/ngcp-rtpengine-recording-daemon.default
  6. +16
    -0
      debian/ngcp-rtpengine-recording-daemon.postinst
  7. +6
    -2
      debian/ngcp-rtpengine-recording-daemon.service

+ 4
- 3
debian/ngcp-rtpengine-daemon.default View File

@ -1,6 +1,7 @@
CONFIG_FILE=/etc/rtpengine/rtpengine.conf
# CONFIG_SECTION=rtpengine
PIDFILE=/run/ngcp-rtpengine-daemon.pid
PIDFILE=/run/rtpengine/ngcp-rtpengine-daemon.pid
MANAGE_IPTABLES=yes
#SET_USER=root
#SET_GROUP=root # GROUP only needs to be set if USER is not set or if the user isn't in the group
SET_USER=rtpengine
#SET_GROUP=rtpengine # GROUP only needs to be set if USER is not set or if the user isn't in the group
SET_MASK=0x7

+ 6
- 0
debian/ngcp-rtpengine-daemon.postinst View File

@ -32,6 +32,12 @@ else
fi
fi
if [ "$1" = configure ]; then
adduser --system --home /nonexistent --gecos rtpengine \
--no-create-home --disabled-password \
--group --quiet rtpengine || true
fi
#DEBHELPER#
exit 0


+ 13
- 0
debian/ngcp-rtpengine-daemon.postrm View File

@ -0,0 +1,13 @@
#!/bin/sh
set -e
if [ "$1" = purge ]; then
deluser --quiet --system rtpengine > /dev/null || true
delgroup --quiet --system rtpengine > /dev/null || true
fi
#DEBHELPER#
exit 0

+ 9
- 4
debian/ngcp-rtpengine-daemon.service View File

@ -7,10 +7,15 @@ Requires=network-online.target
[Service]
Type=notify
EnvironmentFile=/etc/default/ngcp-rtpengine-daemon
PIDFile=/run/ngcp-rtpengine-daemon.pid
ExecStartPre=/usr/sbin/ngcp-rtpengine-iptables-setup start
ExecStart=/usr/sbin/rtpengine -f -E --no-log-timestamps --pidfile /run/ngcp-rtpengine-daemon.pid --config-file /etc/rtpengine/rtpengine.conf
ExecStopPost=/usr/sbin/ngcp-rtpengine-iptables-setup stop
RuntimeDirectory=rtpengine
PIDFile=/run/rtpengine/ngcp-rtpengine-daemon.pid
User=rtpengine
Group=rtpengine
AmbientCapabilities=CAP_NET_ADMIN CAP_SYS_NICE
LimitNOFILE=150000
ExecStartPre=+/usr/sbin/ngcp-rtpengine-iptables-setup start
ExecStart=/usr/sbin/rtpengine -f -E --no-log-timestamps --pidfile /run/rtpengine/ngcp-rtpengine-daemon.pid --config-file /etc/rtpengine/rtpengine.conf
ExecStopPost=+/usr/sbin/ngcp-rtpengine-iptables-setup stop
[Install]
WantedBy=multi-user.target

+ 1
- 1
debian/ngcp-rtpengine-recording-daemon.default View File

@ -1,6 +1,6 @@
CONFIG_FILE=/etc/rtpengine/rtpengine-recording.conf
# CONFIG_SECTION=rtpengine-recording
PIDFILE=/run/ngcp-rtpengine-recording-daemon.pid
PIDFILE=/run/rtpengine-recording/ngcp-rtpengine-recording-daemon.pid
#SET_USER=root
#SET_GROUP=root # GROUP only needs to be set if USER is not set or if the user isn't in the group
#


+ 16
- 0
debian/ngcp-rtpengine-recording-daemon.postinst View File

@ -0,0 +1,16 @@
#!/bin/sh
set -e
if [ "$1" = configure ]; then
for DIR in /var/lib/rtpengine-recording /var/spool/rtpengine; do
if ! dpkg-statoverride --list "$DIR" > /dev/null 2>&1; then
chown rtpengine:rtpengine "$DIR"
chmod 0770 "$DIR"
fi
done
fi
#DEBHELPER#
exit 0

+ 6
- 2
debian/ngcp-rtpengine-recording-daemon.service View File

@ -9,8 +9,12 @@ Requires=ngcp-rtpengine-recording-nfs-mount.service
[Service]
Type=notify
LimitNOFILE=100000
PIDFile=/run/ngcp-rtpengine-recording-daemon.pid
ExecStart=/usr/sbin/rtpengine-recording -f -E --no-log-timestamps --pidfile /run/ngcp-rtpengine-recording-daemon.pid --config-file /etc/rtpengine/rtpengine-recording.conf
RuntimeDirectory=rtpengine-recording
PIDFile=/run/rtpengine-recording/ngcp-rtpengine-recording-daemon.pid
AmbientCapabilities=CAP_NET_ADMIN
User=rtpengine
Group=rtpengine
ExecStart=/usr/sbin/rtpengine-recording -f -E --no-log-timestamps --pidfile /run/rtpengine-recording/ngcp-rtpengine-recording-daemon.pid --config-file /etc/rtpengine/rtpengine-recording.conf
[Install]
WantedBy=multi-user.target

Loading…
Cancel
Save