|
Christoph Galuschka |
47aac2 |
#!/bin/sh
|
|
Christoph Galuschka |
47aac2 |
# Author: Christoph Galuschka <christoph.galuschka@chello.at>
|
|
Christoph Galuschka |
47aac2 |
|
|
Christoph Galuschka |
47aac2 |
t_Log "Running $0 - Postfix plain SASL test."
|
|
Christoph Galuschka |
47aac2 |
t_Log "Installing prerequisits"
|
|
Christoph Galuschka |
47aac2 |
|
|
Christoph Galuschka |
29c450 |
t_InstallPackage dovecot
|
|
Christoph Galuschka |
47aac2 |
|
|
Christoph Galuschka |
9827be |
#creating backups of changed files
|
|
Christoph Galuschka |
9827be |
cp -a /etc/postfix/main.cf /etc/postfix/main.cf_testing
|
|
Christoph Galuschka |
9827be |
if [ $centos_ver = 5 ]
|
|
Christoph Galuschka |
47aac2 |
then
|
|
Christoph Galuschka |
9827be |
cp -a /etc/dovecot.conf /etc/dovecot.conf_testing
|
|
Christoph Galuschka |
9827be |
else
|
|
Christoph Galuschka |
f944d2 |
cp -a /etc/dovecot/dovecot.conf /etc/dovecot/dovecot.conf_testing
|
|
Christoph Galuschka |
9827be |
fi
|
|
Christoph Galuschka |
f944d2 |
|
|
Christoph Galuschka |
9827be |
#adding parameters to postfix
|
|
Christoph Galuschka |
9827be |
cat >> /etc/postfix/main.cf <
|
|
Christoph Galuschka |
f944d2 |
smtpd_sasl_auth_enable = yes
|
|
Christoph Galuschka |
f944d2 |
broken_sasl_auth_clients = yes
|
|
Christoph Galuschka |
f944d2 |
smtpd_sasl_type = dovecot
|
|
Christoph Galuschka |
f944d2 |
smtpd_sasl_path = private/auth
|
|
Christoph Galuschka |
f944d2 |
smtpd_sasl_security_options = noanonymous
|
|
Christoph Galuschka |
47aac2 |
|
|
Christoph Galuschka |
f944d2 |
smtpd_recipient_restrictions =
|
|
Christoph Galuschka |
47aac2 |
permit_mynetworks,
|
|
Christoph Galuschka |
47aac2 |
permit_sasl_authenticated,
|
|
Christoph Galuschka |
47aac2 |
reject_unauth_destination
|
|
Christoph Galuschka |
f944d2 |
EOF
|
|
Christoph Galuschka |
f944d2 |
|
|
Christoph Galuschka |
9827be |
#adding parameters to dovecot
|
|
Christoph Galuschka |
9827be |
if [ $centos_ver = 5 ]
|
|
Christoph Galuschka |
9827be |
then
|
|
Christoph Galuschka |
1a14e7 |
cat > /etc/dovecot.conf <
|
|
Christoph Galuschka |
1a14e7 |
protocol imap {
|
|
Christoph Galuschka |
1a14e7 |
}
|
|
Christoph Galuschka |
1a14e7 |
protocol pop3 {
|
|
Christoph Galuschka |
1a14e7 |
}
|
|
Christoph Galuschka |
1a14e7 |
protocol lda {
|
|
Christoph Galuschka |
1a14e7 |
postmaster_address = postmaster@example.com
|
|
Christoph Galuschka |
1a14e7 |
}
|
|
Christoph Galuschka |
1a14e7 |
auth default {
|
|
Christoph Galuschka |
1a14e7 |
mechanisms = plain
|
|
Christoph Galuschka |
1a14e7 |
passdb pam {
|
|
Christoph Galuschka |
1a14e7 |
}
|
|
Christoph Galuschka |
1a14e7 |
userdb passwd {
|
|
Christoph Galuschka |
1a14e7 |
}
|
|
Christoph Galuschka |
1a14e7 |
user = root
|
|
Christoph Galuschka |
1a14e7 |
socket listen {
|
|
Christoph Galuschka |
1a14e7 |
client {
|
|
Christoph Galuschka |
1a14e7 |
path = /var/spool/postfix/private/auth
|
|
Christoph Galuschka |
1a14e7 |
mode = 0660
|
|
Christoph Galuschka |
1a14e7 |
user = postfix
|
|
Christoph Galuschka |
1a14e7 |
group = postfix
|
|
Christoph Galuschka |
1a14e7 |
}
|
|
Christoph Galuschka |
1a14e7 |
}
|
|
Christoph Galuschka |
1a14e7 |
}
|
|
Christoph Galuschka |
1a14e7 |
dict {
|
|
Christoph Galuschka |
1a14e7 |
}
|
|
Christoph Galuschka |
1a14e7 |
plugin {
|
|
Christoph Galuschka |
9827be |
}
|
|
Christoph Galuschka |
9827be |
EOF
|
|
Christoph Galuschka |
9827be |
else
|
|
Christoph Galuschka |
47aac2 |
cat >> /etc/dovecot/dovecot.conf <
|
|
Christoph Galuschka |
f944d2 |
service auth {
|
|
Christoph Galuschka |
f944d2 |
unix_listener /var/spool/postfix/private/auth {
|
|
Christoph Galuschka |
f944d2 |
mode = 0660
|
|
Christoph Galuschka |
f944d2 |
user = postfix
|
|
Christoph Galuschka |
f944d2 |
group = postfix
|
|
Christoph Galuschka |
47aac2 |
}
|
|
Christoph Galuschka |
f944d2 |
}
|
|
Christoph Galuschka |
f944d2 |
EOF
|
|
Christoph Galuschka |
9827be |
fi
|
|
Christoph Galuschka |
9827be |
|
|
Christoph Galuschka |
9827be |
#restarting services
|
|
Christoph Galuschka |
9827be |
t_ServiceControl postfix restart
|
|
Christoph Galuschka |
9827be |
t_ServiceControl dovecot restart
|
|
Christoph Galuschka |
47aac2 |
|
|
Christoph Galuschka |
4cedd1 |
#Running test
|
|
Christoph Galuschka |
4cedd1 |
t_Log "Testing if postfix accepts connections and offers AUTH PLAIN"
|
|
Christoph Galuschka |
9827be |
echo "ehlo test" | nc -w 3 localhost 25 | grep -q 'AUTH PLAIN'
|
|
Christoph Galuschka |
9827be |
ret_val=$?
|
|
Christoph Galuschka |
1a14e7 |
|
|
Christoph Galuschka |
f944d2 |
# restoring changed files
|
|
Christoph Galuschka |
f944d2 |
mv -f /etc/postfix/main.cf_testing /etc/postfix/main.cf
|
|
Christoph Galuschka |
9827be |
if [ $centos_ver = 5 ]
|
|
Christoph Galuschka |
9827be |
then
|
|
Christoph Galuschka |
9827be |
mv -f /etc/dovecot.conf_testing /etc/dovecot.conf
|
|
Christoph Galuschka |
9827be |
else
|
|
Christoph Galuschka |
9827be |
mv -f /etc/dovecot/dovecot.conf_testing /etc/dovecot/dovecot.conf
|
|
Christoph Galuschka |
9827be |
fi
|
|
Christoph Galuschka |
f944d2 |
|
|
Christoph Galuschka |
47aac2 |
t_CheckExitStatus $ret_val
|