From 5e6a2c0b6bc240fe63b1cf71dd83e43a02af0cef Mon Sep 17 00:00:00 2001 From: don Date: Wed, 11 Mar 2009 10:46:54 +0000 Subject: [PATCH] Call restorecon on the socket and pidfile directories to make SELinux happy (thanks to Russel Coker) (closes: #518552) --- debian/changelog | 7 +++++++ debian/spamass-milter.init | 21 ++++++++++----------- 2 files changed, 17 insertions(+), 11 deletions(-) diff --git a/debian/changelog b/debian/changelog index af904ad..f50a73c 100644 --- a/debian/changelog +++ b/debian/changelog @@ -1,3 +1,10 @@ +spamass-milter (0.3.1-10) UNRELEASED; urgency=low + + * Call restorecon on the socket and pidfile directories to make SELinux + happy (thanks to Russel Coker) (closes: #518552) + + -- Don Armstrong Wed, 11 Mar 2009 03:44:35 -0700 + spamass-milter (0.3.1-9) unstable; urgency=low * Document that using the -x option requires being in the smmsp group diff --git a/debian/spamass-milter.init b/debian/spamass-milter.init index 907f97f..68d4232 100644 --- a/debian/spamass-milter.init +++ b/debian/spamass-milter.init @@ -92,20 +92,19 @@ set -e start() { # Because the default socket is in the same location as the # pidfile, we create them in this order. - if [ ! -d $(dirname $PIDFILE) ]; then - mkdir -p $(dirname $PIDFILE); - if [ -d $(dirname $PIDFILE) ] && [ -n "$RUNAS" ]; then - chown "$RUNAS" $(dirname $PIDFILE); - fi; - fi; + for DIR in "$(dirname $PIDFILE)" "$(dirname $SOCKET)"; do # if the dirname is '.', then it's some kind of odd socket, like # an inet socket. Don't create the directory in such a case - if [ $(dirname $SOCKET) != "." ] && [ ! -d $(dirname $SOCKET) ]; then - mkdir -p $(dirname $SOCKET); - if [ -n "$SOCKETOWNER" ]; then - chown "$RUNAS" $(dirname $SOCKET); + if [ "$DIR" != "." ] && [ ! -d "$DIR" ]; then + mkdir -p "$DIR"; + if [ -x /sbin/restorecon ]; then + /sbin/restorecon "$DIR"; + fi; + if [ -n "$RUNAS" ]; then + chown "$RUNAS" "$DIR"; + fi; fi; - fi; + done; if [ -n "$RUNAS" ] && [ -d $(dirname $PIDFILE) ] && [ "$(stat -c '%U' $(dirname $PIDFILE))" != "$RUNAS" ]; then echo "WARNING: $NAME will run as user $RUNAS but $(dirname $PIDFILE) is not owned by $RUNAS"; -- 2.39.2