summaryrefslogtreecommitdiff
path: root/debian/local/update_sys.in
diff options
context:
space:
mode:
Diffstat (limited to 'debian/local/update_sys.in')
-rw-r--r--debian/local/update_sys.in135
1 files changed, 51 insertions, 84 deletions
diff --git a/debian/local/update_sys.in b/debian/local/update_sys.in
index 89cad19..ec84f02 100644
--- a/debian/local/update_sys.in
+++ b/debian/local/update_sys.in
@@ -21,12 +21,39 @@
#-----------------------------------------------------------------------------
set +e;
+# Path to other sendmail helpers
+if [ -x ./update_sendmail ]; then
+ sm_path='.';
+elif [ -x $(dirname $0)/update_sendmail ]; then
+ sm_path=$(dirname $0);
+else
+ sm_path=@datadir@/sendmail;
+ fi;
+# Bring in sendmail.conf for the network definitions
+if [ ! -f @sysconfdir@/mail/sendmail.conf ]; then
+ if [ -x $sm_path/update_conf ]; then
+ $sm_path/update_conf;
+ fi;
+ fi;
+if [ -f @sysconfdir@/mail/sendmail.conf ]; then
+ . @sysconfdir@/mail/sendmail.conf;
+ fi;
+if [ "$HANDS_OFF" != 'No' ]; then
+ exit 0;
+ fi;
+
# flag used to indicate a dataset has been moved, may need another update
changed=0;
+#-----------------------------------------------------------------------------
+# Warn the user that this may take a bit...
+#-----------------------------------------------------------------------------
+echo '';
+echo 'Checking filesystem, this may take some time - it will not hang!';
+echo -n ' ... ';
+
#------------------------------------------------------------------------------
# Create any needed directories, and move any prior data to its new home
-
#------------------------------------------------------------------------------
# /etc/aliases should exist, though not owned by sendmail, we'll create one
if [ ! -e @sysconfdir@/aliases ]; then
@@ -61,13 +88,15 @@ if [ ! -e @localstatedir@/mail ]; then
fi;
#
# Make sure the sticky bit is set in pre-existing directories
-if [ -d @localstatedir@/mail -a ! -k @localstatedir@/mail ]; then
+if [ -d @localstatedir@/mail ] && [ ! -k @localstatedir@/mail ]; then
chmod a+t @localstatedir@/mail;
fi;
-if [ -d @localstatedir@/spool/mail -a ! -k @localstatedir@/spool/mail ]; then
+if [ -d @localstatedir@/spool/mail ] \
+&& [ ! -k @localstatedir@/spool/mail ]; then
chmod a+t @localstatedir@/spool/mail;
fi;
-if [ ! -d @localstatedir@/spool/mail -a ! -L @localstatedir@/spool/mail ]; then
+if [ ! -d @localstatedir@/spool/mail ] \
+&& [ ! -L @localstatedir@/spool/mail ]; then
ln -sf ../mail @localstatedir@/spool/mail;
#mkdir @localstatedir@/spool/mail;
#chown root:root @localstatedir@/spool/mail;
@@ -80,8 +109,11 @@ if [ ! -d @sysconfdir@/mail ]; then
changed=1;
mkdir @sysconfdir@/mail;
fi;
-chown root:smmsp @sysconfdir@/mail;
+chown smmta:smmsp @sysconfdir@/mail;
chmod 02755 @sysconfdir@/mail;
+mkdir -p @sysconfdir@/mail/m4;
+chown smmta:smmsp @sysconfdir@/mail/m4;
+chmod 02755 @sysconfdir@/mail/m4;
#
# With the MSP/MTA split, we don't want any g=w files or directories
# to save us from potential sgid attacks
@@ -94,23 +126,23 @@ if [ ! -d @localstatedir@/run/sendmail ]; then
changed=1;
mkdir @localstatedir@/run/sendmail;
fi;
-chown root:smmsp @localstatedir@/run/sendmail;
-chmod 02750 @localstatedir@/run/sendmail;
+chown root:smmta @localstatedir@/run/sendmail;
+chmod 02755 @localstatedir@/run/sendmail;
if [ ! -d @localstatedir@/run/sendmail/mta ]; then
mkdir @localstatedir@/run/sendmail/mta;
fi;
-chown root:smmsp @localstatedir@/run/sendmail/mta;
-chmod 02750 @localstatedir@/run/sendmail/mta;
+chown smmta:smmsp @localstatedir@/run/sendmail/mta;
+chmod 02755 @localstatedir@/run/sendmail/mta;
if [ ! -d @localstatedir@/run/sendmail/msp ]; then
mkdir @localstatedir@/run/sendmail/msp;
fi;
chown smmsp:smmsp @localstatedir@/run/sendmail/msp;
-chmod 02770 @localstatedir@/run/sendmail/msp;
+chmod 02775 @localstatedir@/run/sendmail/msp;
if [ ! -d @localstatedir@/run/sendmail/stampdir ]; then
mkdir @localstatedir@/run/sendmail/stampdir;
fi;
chown root:smmsp @localstatedir@/run/sendmail/stampdir;
-chmod 02770 @localstatedir@/run/sendmail/stampdir;
+chmod 02775 @localstatedir@/run/sendmail/stampdir;
#
# Remove older files
rm -f /var/run/sendmail.pid;
@@ -124,8 +156,8 @@ if [ ! -d @localstatedir@/lib/sendmail ]; then
changed=1;
mkdir @localstatedir@/lib/sendmail;
fi;
-chown root:smmsp @localstatedir@/lib/sendmail;
-chmod 02750 @localstatedir@/lib/sendmail;
+chown smmta:smmta @localstatedir@/lib/sendmail;
+chmod 02751 @localstatedir@/lib/sendmail;
if [ -d /var/state/sendmail/host_status ]; then
changed=1;
echo "Moving /var/state/sendmail/host_status to /var/lib/sendmail/";
@@ -142,11 +174,11 @@ if [ ! -d @localstatedir@/lib/sendmail/host_status ]; then
mkdir @localstatedir@/lib/sendmail/host_status;
fi;
chown root:smmsp @localstatedir@/lib/sendmail/host_status;
-chmod 02750 @localstatedir@/lib/sendmail/host_status;
+chmod 02775 @localstatedir@/lib/sendmail/host_status;
find @localstatedir@/lib/sendmail/host_status -type d -print \
| xargs -r chown root:smmsp;
find @localstatedir@/lib/sendmail/host_status -type d -print \
- | xargs -r chmod 02750;
+ | xargs -r chmod 02755;
#
# if sendmail.st doesn't exist, don't create it !
if [ -f /var/log/sendmail.st ]; then
@@ -188,13 +220,13 @@ if [ ! -d @localstatedir@/spool/mqueue ]; then
changed=1;
mkdir @localstatedir@/spool/mqueue;
fi;
-chown root:smmsp @localstatedir@/spool/mqueue;
+chown smmta:smmsp @localstatedir@/spool/mqueue;
chmod 02750 @localstatedir@/spool/mqueue;
#
# With the MSP/MTA split, we *DO* need g=r, gid=smmsp queue directories and
# files mailq to work...
find @localstatedir@/spool/mqueue -print \
- | xargs -r chown root:smmsp;
+ | xargs -r chown smmta:smmsp;
find @localstatedir@/spool/mqueue -type d -print \
| xargs -r chmod g+rxs-w,o-rwx;
find @localstatedir@/spool/mqueue -type f -print \
@@ -210,73 +242,8 @@ chmod 02770 @localstatedir@/spool/mqueue-client;
find @localstatedir@/spool/mqueue-client -perm +o=r -print \
| xargs -r chmod o-rwx;
-#------------------------------------------------------------------------------
-# /var/log/mail is where we keep our log crap (via syslog)
-# Try to fixup syslog, syslog-ng, etc...
-if [ ! -d @localstatedir@/log/mail -a \
- ! -f /var/log/mail ]; then
- echo "Moving /var/log/mail.* to /var/log/mail/mail.*";
- echo "You will need to adjust any log reading scripts accordingly";
- mkdir @localstatedir@/log/mail;
- chown root:smmsp @localstatedir@/log/mail;
- chmod 02770 @localstatedir@/log/mail;
- mv -f /var/log/mail.log @localstatedir@/log/mail/ \
- 1>/dev/null 2>&1;
- mv -f /var/log/mail.log.[0-9]* @localstatedir@/log/mail/ \
- 1>/dev/null 2>&1;
- mv -f /var/log/mail.err @localstatedir@/log/mail/\
- 1>/dev/null 2>&1;
- mv -f /var/log/mail.err.[0-9]* @localstatedir@/log/mail/ \
- 1>/dev/null 2>&1;
- mv -f /var/log/mail.info @localstatedir@/log/mail/ \
- 1>/dev/null 2>&1;
- mv -f /var/log/mail.info.[0-9]* @localstatedir@/log/mail/ \
- 1>/dev/null 2>&1;
- mv -f /var/log/mail.warn @localstatedir@/log/mail/ \
- 1>/dev/null 2>&1;
- mv -f /var/log/mail.warn.[0-9]* @localstatedir@/log/mail/ \
- 1>/dev/null 2>&1;
- # Create link for compatility with logscan package
- ln -sf @localstatedir@/log/mail/mail.log /var/log/mail.log;
- fi;
-#
-# Support for sysklogd package
-if [ -f /etc/syslog.conf ]; then
- sed -e "s?/var/log/mail.log?@localstatedir@/log/mail/mail.log?g" \
- -e "s?/var/log/mail.err?@localstatedir@/log/mail/mail.err?g" \
- -e "s?/var/log/mail.info?@localstatedir@/log/mail/mail.info?g" \
- -e "s?/var/log/mail.warn?@localstatedir@/log/mail/mail.warn?g" \
- /etc/syslog.conf > /etc/syslog.conf.new;
- chown root:root /etc/syslog.conf.new;
- chmod 0644 /etc/syslog.conf.new;
- mv /etc/syslog.conf.new /etc/syslog.conf;
- /etc/init.d/sysklogd reload;
- fi;
-#
-# Support for syslog-ng package
-if [ -f /etc/syslog-ng/syslog-ng.conf ]; then
- sed -e "s?/var/log/mail.log?@localstatedir@/log/mail/mail.log?g" \
- -e "s?/var/log/mail.err?@localstatedir@/log/mail/mail.err?g" \
- -e "s?/var/log/mail.info?@localstatedir@/log/mail/mail.info?g" \
- -e "s?/var/log/mail.warn?@localstatedir@/log/mail/mail.warn?g" \
- /etc/syslog-ng/syslog-ng.conf > \
- /etc/syslog-ng/syslog-ng.conf.new;
- chown root:root /etc/syslog-ng/syslog-ng.conf.new;
- chmod 0644 /etc/syslog-ng/syslog-ng.conf.new;
- mv /etc/syslog-ng/syslog-ng.conf.new \
- /etc/syslog-ng/syslog-ng.conf;
- /etc/init.d/syslog-ng reload;
- if [ -f /etc/logrotate.d/syslog-ng ]; then
- sed -e '/\/var\/log\/mail\..*/{:a;N;/}\n/!ba;d;}' \
- /etc/logrotate.d/syslog-ng > \
- /etc/logrotate.d/syslog-ng.new;
- chown root:root /etc/logrotate.d/syslog-ng.new;
- chmod 0644 /etc/logrotate.d/syslog-ng.new;
- mv /etc/logrotate.d/syslog-ng.new \
- /etc/logrotate.d/syslog-ng;
- true;
- fi;
- fi;
+#-----------------------------------------------------------------------------
+echo ' Done.';
#------------------------------------------------------------------------------
exit $changed;