osmith has submitted this change. ( https://gerrit.osmocom.org/c/osmo-bts/+/30133?usp=email )
Change subject: contrib/systemd: run as osmocom user ......................................................................
contrib/systemd: run as osmocom user
I have verified that with AmbientCapabilities=CAP_SYS_NICE, setting scheduling policy as described in the manual still works as expected.
Related: OS#4107 Change-Id: I37be0dd4df012047a495235195912bd06ad2423d --- M contrib/systemd/osmo-bts-trx.service M contrib/systemd/osmo-bts-virtual.service A debian/osmo-bts-trx.postinst A debian/osmo-bts-virtual.postinst 4 files changed, 97 insertions(+), 0 deletions(-)
Approvals: laforge: Looks good to me, approved fixeria: Looks good to me, but someone else must approve Jenkins Builder: Verified
diff --git a/contrib/systemd/osmo-bts-trx.service b/contrib/systemd/osmo-bts-trx.service index 9763dff..99e981c 100644 --- a/contrib/systemd/osmo-bts-trx.service +++ b/contrib/systemd/osmo-bts-trx.service @@ -10,6 +10,9 @@ WorkingDirectory=%S/osmocom Restart=always RestartSec=2 +User=osmocom +Group=osmocom +AmbientCapabilities=CAP_SYS_NICE
# CPU scheduling policy: CPUSchedulingPolicy=rr diff --git a/contrib/systemd/osmo-bts-virtual.service b/contrib/systemd/osmo-bts-virtual.service index dee3ab7..2bca83b 100644 --- a/contrib/systemd/osmo-bts-virtual.service +++ b/contrib/systemd/osmo-bts-virtual.service @@ -10,6 +10,9 @@ WorkingDirectory=%S/osmocom Restart=always RestartSec=2 +User=osmocom +Group=osmocom +AmbientCapabilities=CAP_SYS_NICE
# CPU scheduling policy: CPUSchedulingPolicy=rr diff --git a/debian/osmo-bts-trx.postinst b/debian/osmo-bts-trx.postinst new file mode 100755 index 0000000..af5d821 --- /dev/null +++ b/debian/osmo-bts-trx.postinst @@ -0,0 +1,39 @@ +#!/bin/sh -e +case "$1" in + configure) + # Create the osmocom group and user (if it doesn't exist yet) + if ! getent group osmocom >/dev/null; then + groupadd --system osmocom + fi + if ! getent passwd osmocom >/dev/null; then + useradd \ + --system \ + --gid osmocom \ + --home-dir /var/lib/osmocom \ + --shell /sbin/nologin \ + --comment "Open Source Mobile Communications" \ + osmocom + fi + + # Fix permissions of previous (root-owned) install (OS#4107) + if dpkg --compare-versions "$2" le "1.13.0"; then + if [ -e /etc/osmocom/osmo-bts-trx.cfg ]; then + chown -v osmocom:osmocom /etc/osmocom/osmo-bts-trx.cfg + chmod -v 0660 /etc/osmocom/osmo-bts-trx.cfg + fi + + if [ -d /etc/osmocom ]; then + chown -v root:osmocom /etc/osmocom + chmod -v 2775 /etc/osmocom + fi + + mkdir -p /var/lib/osmocom + chown -R -v osmocom:osmocom /var/lib/osmocom + fi + ;; +esac + +# dh_installdeb(1) will replace this with shell code automatically +# generated by other debhelper scripts. +#DEBHELPER# + diff --git a/debian/osmo-bts-virtual.postinst b/debian/osmo-bts-virtual.postinst new file mode 100755 index 0000000..19ecd83 --- /dev/null +++ b/debian/osmo-bts-virtual.postinst @@ -0,0 +1,39 @@ +#!/bin/sh -e +case "$1" in + configure) + # Create the osmocom group and user (if it doesn't exist yet) + if ! getent group osmocom >/dev/null; then + groupadd --system osmocom + fi + if ! getent passwd osmocom >/dev/null; then + useradd \ + --system \ + --gid osmocom \ + --home-dir /var/lib/osmocom \ + --shell /sbin/nologin \ + --comment "Open Source Mobile Communications" \ + osmocom + fi + + # Fix permissions of previous (root-owned) install (OS#4107) + if dpkg --compare-versions "$2" le "1.13.0"; then + if [ -e /etc/osmocom/osmo-bts-virtual.cfg ]; then + chown -v osmocom:osmocom /etc/osmocom/osmo-bts-virtual.cfg + chmod -v 0660 /etc/osmocom/osmo-bts-virtual.cfg + fi + + if [ -d /etc/osmocom ]; then + chown -v root:osmocom /etc/osmocom + chmod -v 2775 /etc/osmocom + fi + + mkdir -p /var/lib/osmocom + chown -R -v osmocom:osmocom /var/lib/osmocom + fi + ;; +esac + +# dh_installdeb(1) will replace this with shell code automatically +# generated by other debhelper scripts. +#DEBHELPER# +