osmith has submitted this change. (
https://gerrit.osmocom.org/c/osmo-gbproxy/+/36941?usp=email )
Change subject: contrib/systemd: run as osmocom user
......................................................................
contrib/systemd: run as osmocom user
Related: OS#4107
Change-Id: I13529cd8c6ca94c43a9a81e2ea60bafc3f189ab4
---
M contrib/systemd/osmo-gbproxy.service
A debian/postinst
2 files changed, 51 insertions(+), 0 deletions(-)
Approvals:
Jenkins Builder: Verified
pespin: Looks good to me, but someone else must approve
fixeria: Looks good to me, approved
diff --git a/contrib/systemd/osmo-gbproxy.service b/contrib/systemd/osmo-gbproxy.service
index 1c63a25..8dfc27d 100644
--- a/contrib/systemd/osmo-gbproxy.service
+++ b/contrib/systemd/osmo-gbproxy.service
@@ -9,8 +9,11 @@
StateDirectory=osmocom
WorkingDirectory=%S/osmocom
Restart=always
+User=osmocom
+Group=osmocom
RestartSec=2
RestartPreventExitStatus=1
+AmbientCapabilities=CAP_NET_RAW
[Install]
WantedBy=multi-user.target
diff --git a/debian/postinst b/debian/postinst
new file mode 100755
index 0000000..87bed8c
--- /dev/null
+++ b/debian/postinst
@@ -0,0 +1,38 @@
+#!/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 "0.4.2"; then
+ if [ -e /etc/osmocom/osmo-gbproxy.cfg ]; then
+ chown -v osmocom:osmocom /etc/osmocom/osmo-gbproxy.cfg
+ chmod -v 0660 /etc/osmocom/osmo-gbproxy.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#
--
To view, visit
https://gerrit.osmocom.org/c/osmo-gbproxy/+/36941?usp=email
To unsubscribe, or for help writing mail filters, visit
https://gerrit.osmocom.org/settings
Gerrit-Project: osmo-gbproxy
Gerrit-Branch: master
Gerrit-Change-Id: I13529cd8c6ca94c43a9a81e2ea60bafc3f189ab4
Gerrit-Change-Number: 36941
Gerrit-PatchSet: 3
Gerrit-Owner: osmith <osmith(a)sysmocom.de>
Gerrit-Reviewer: Jenkins Builder
Gerrit-Reviewer: daniel <dwillmann(a)sysmocom.de>
Gerrit-Reviewer: fixeria <vyanitskiy(a)sysmocom.de>
Gerrit-Reviewer: neels <nhofmeyr(a)sysmocom.de>
Gerrit-Reviewer: osmith <osmith(a)sysmocom.de>
Gerrit-Reviewer: pespin <pespin(a)sysmocom.de>
Gerrit-MessageType: merged