bstinson / centos / t_functional

Forked from centos/t_functional 3 years ago
Clone

Blame tests/p_postfix/40_postfix_sasl.sh

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 47aac2
t_InstallPackage dovecot nc
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 9827be
  cat >> /etc/dovecot.conf <
Christoph Galuschka 9827be
client {
Christoph Galuschka 9827be
       path = /var/spool/postfix/private/auth
Christoph Galuschka 9827be
       mode = 0660
Christoph Galuschka 9827be
       user = postfix
Christoph Galuschka 9827be
       group = postfix
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 47aac2
  #Running test
Christoph Galuschka 9827be
echo "ehlo test" | nc -w 3 localhost 25 | grep -q 'AUTH PLAIN'
Christoph Galuschka 9827be
ret_val=$?
Christoph Galuschka 9827be
#else
Christoph Galuschka 9827be
#  t_Log 'C5 System, test not yet working, skipping'
Christoph Galuschka 9827be
#  ret_val=0
Christoph Galuschka 9827be
#fi
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