From f884447b26fca212d02dd748e42375e2aefd47a3 Mon Sep 17 00:00:00 2001 From: Nicola Murino Date: Thu, 15 Oct 2020 10:01:31 +0200 Subject: [PATCH] rpm: set proper permissions for /var/lib/sftpgo and /srv/sftpgo it seems we have to check the permissions after each update, probably because nfpm defines these dirs as empty folders --- pkgs/debian/postinst | 11 +++++------ pkgs/scripts/deb/postinstall.sh | 11 +++++------ pkgs/scripts/rpm/postinstall | 12 +++++++----- 3 files changed, 17 insertions(+), 17 deletions(-) diff --git a/pkgs/debian/postinst b/pkgs/debian/postinst index c7034105..5f2a4f48 100644 --- a/pkgs/debian/postinst +++ b/pkgs/debian/postinst @@ -29,14 +29,13 @@ if [ "$1" = "configure" ]; then echo "Please be sure to have the python3-requests package installed if you want to use the REST API CLI" fi - # check permissions for /srv/sftpgo and adjust them if needed + # we added /srv/sftpgo after 1.1.0, we should check if we are upgrading + # from this version but a non-recursive chmod/chown shouldn't hurt if [ -d /srv/sftpgo ]; then - if [ $(stat -c '%U' /srv/sftpgo) != sftpgo ]; then - echo "Set permissions for /srv/sftpgo" - chown -R sftpgo:sftpgo /srv/sftpgo - chmod 750 /srv/sftpgo - fi + chown sftpgo:sftpgo /srv/sftpgo + chmod 750 /srv/sftpgo fi + fi #DEBHELPER# diff --git a/pkgs/scripts/deb/postinstall.sh b/pkgs/scripts/deb/postinstall.sh index fe80bfa4..f5e296cd 100644 --- a/pkgs/scripts/deb/postinstall.sh +++ b/pkgs/scripts/deb/postinstall.sh @@ -29,14 +29,13 @@ if [ "$1" = "configure" ]; then echo "Please be sure to have the python3-requests package installed if you want to use the REST API CLI" fi - # check permissions for /srv/sftpgo and adjust them if needed + # we added /srv/sftpgo after 1.1.0, we should check if we are upgrading + # from this version but a non-recursive chmod/chown shouldn't hurt if [ -d /srv/sftpgo ]; then - if [ $(stat -c '%U' /srv/sftpgo) != sftpgo ]; then - echo "Set permissions for /srv/sftpgo" - chown -R sftpgo:sftpgo /srv/sftpgo - chmod 750 /srv/sftpgo - fi + chown sftpgo:sftpgo /srv/sftpgo + chmod 750 /srv/sftpgo fi + fi if [ "$1" = "configure" ] || [ "$1" = "abort-upgrade" ] || [ "$1" = "abort-deconfigure" ] || [ "$1" = "abort-remove" ] ; then diff --git a/pkgs/scripts/rpm/postinstall b/pkgs/scripts/rpm/postinstall index 993c1a55..06592de5 100644 --- a/pkgs/scripts/rpm/postinstall +++ b/pkgs/scripts/rpm/postinstall @@ -22,13 +22,15 @@ if [ $1 -eq 1 ]; then /bin/echo "Please be sure to have the python requests library installed if you want to use the REST API CLI" fi -# check permissions for /srv/sftpgo and adjust them if needed +# adjust permissions for /srv/sftpgo and /var/lib/sftpgo if [ -d /srv/sftpgo ]; then - if [ $(/usr/bin/stat -c '%U' /srv/sftpgo) != sftpgo ]; then - /bin/echo "Set permissions for /srv/sftpgo" - /usr/bin/chown -R sftpgo:sftpgo /srv/sftpgo + /usr/bin/chown sftpgo:sftpgo /srv/sftpgo /usr/bin/chmod 750 /srv/sftpgo - fi +fi + +if [ -d /var/lib/sftpgo ]; then + /usr/bin/chown sftpgo:sftpgo /var/lib/sftpgo + /usr/bin/chmod 750 /var/lib/sftpgo fi # reload to pick up any changes to systemd files