.deb/.rpm: add osmocom user during package install

Create osmocom user & group during package installation.
Fix the configuration dir/files permission to match.

Related: OS#4107
Tweaked-By: Oliver Smith <osmith@sysmocom.de>
Change-Id: I7826fedb1b055a282954e5774615245092ddae5d
This commit is contained in:
Max
2022-10-12 18:22:46 +03:00
committed by Oliver Smith
parent 6122400451
commit e3dd323579
4 changed files with 56 additions and 2 deletions

2
debian/control vendored
View File

@@ -17,7 +17,7 @@ Vcs-Browser: https://gitea.osmocom.org/cellular-infrastructure/osmo-sip-connecto
Package: osmo-sip-connector
Architecture: any
Depends: ${shlibs:Depends}, ${misc:Depends}
Depends: ${shlibs:Depends}, ${misc:Depends}, adduser
Description: MNCC to SIP bridge for osmo-nitb
Use the osmo-nitb MNCC interface and bridge it to SIP.

39
debian/postinst vendored Executable file
View File

@@ -0,0 +1,39 @@
#!/bin/sh -e
# Create 'osmocom' user and group (if it doesn't exist yet) and adjust permissions
# of directories which are not automatically adjusted by systemd from previous (root-owned)
# install.
# N. B: the user is intentionally NOT removed during package uninstall:
# see https://wiki.debian.org/AccountHandlingInMaintainerScripts for reasoning.
chperms() {
# chperms <user> <group> <perms> <file>
if ! OVERRIDE=`dpkg-statoverride --list $4 2>&1`; then
if [ -e $4 ]; then
chown $1:$2 $4
chmod $3 $4
fi
fi
}
case "$1" in
configure)
if ! getent passwd osmocom > /dev/null; then
adduser --quiet \
--system \
--group \
--no-create-home \
--disabled-password \
--home /var/lib/osmocom \
--gecos "Open Source Mobile Communications" \
osmocom
fi
# Set permissions according to https://www.debian.org/doc/debian-policy/ch-files.html#s-permissions-owners
chperms osmocom osmocom 0660 /etc/osmocom/osmo-sip-connector.cfg
chperms root osmocom 2775 /etc/osmocom
;;
esac
# dh_installdeb(1) will replace this with shell code automatically
# generated by other debhelper scripts.
#DEBHELPER#