diff --git a/contrib/osmo-hnodeb.spec.in b/contrib/osmo-hnodeb.spec.in index 0f9795b..e28340e 100644 --- a/contrib/osmo-hnodeb.spec.in +++ b/contrib/osmo-hnodeb.spec.in @@ -92,6 +92,8 @@ chown osmocom:osmocom /etc/osmocom/osmo-hnodeb.cfg chmod 0660 /etc/osmocom/osmo-hnodeb.cfg chown root:osmocom /etc/osmocom chmod 2775 /etc/osmocom +mkdir -p /var/lib/osmocom +chown -R osmocom:osmocom /var/lib/osmocom %check make %{?_smp_mflags} check || (find . -name testsuite.log -exec cat {} +) diff --git a/debian/control b/debian/control index 365e07e..86ddb27 100644 --- a/debian/control +++ b/debian/control @@ -30,7 +30,7 @@ Homepage: https://projects.osmocom.org/projects/osmo-hnodeb Package: osmo-hnodeb Architecture: any Multi-Arch: foreign -Depends: ${misc:Depends}, ${shlibs:Depends}, adduser +Depends: ${misc:Depends}, ${shlibs:Depends} Recommends: osmo-mgw Description: OsmoHNodeB: Osmocom's Home NodeB for 3G mobile networks diff --git a/debian/postinst b/debian/postinst index bdf0e8b..c65375e 100755 --- a/debian/postinst +++ b/debian/postinst @@ -1,37 +1,28 @@ #!/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 - 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-hnodeb.cfg - chperms root osmocom 2775 /etc/osmocom + 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) + chown osmocom:osmocom /etc/osmocom/osmo-hnodeb.cfg + chmod 0660 /etc/osmocom/osmo-hnodeb.cfg + chown root:osmocom /etc/osmocom + chmod 2775 /etc/osmocom + mkdir -p /var/lib/osmocom + chown -R osmocom:osmocom /var/lib/osmocom + ;; esac # dh_installdeb(1) will replace this with shell code automatically