Commit 53777f21 authored by Vladimir Bashkirtsev's avatar Vladimir Bashkirtsev

Added support for fully qualified domain delivery

parent 4169243b
......@@ -50,8 +50,13 @@ all: sendmail-config mail-aliases sendmail-default sm-client-service sendmail-se
cd sendmail-8.16.1/doc/op && install -v -m644 op.ps /usr/share/doc/sendmail-8.16.1
openssl req -new -x509 -nodes -out /etc/ssl/private/server.pem -keyout /etc/ssl/private/server.pem -days 3650 -subj "/C=US/ST=Denial/L=Springfield/O=Dis/CN=localhost"
echo $$(hostname) > /etc/mail/local-host-names
touch /etc/mail/access
makemap hash /etc/mail/access.db < /etc/mail/access
touch /etc/mail/mailertable
makemap hash /etc/mail/mailertable.db < /etc/mail/mailertable
echo "@$$(hostname) error:nouser No such user here" > /etc/mail/virtusertable
makemap hash /etc/mail/virtusertable.db < /etc/mail/virtusertable
touch /etc/mail/virtuserdomains
@echo "$$MAIL_ALIASES" > /etc/mail/aliases
newaliases
install -v -Dm644 sendmail.mc /etc/mail
......
......@@ -138,7 +138,7 @@ set_mail_server_user_password() {
idx=$(($2 - 1))
users=(`$UCI_SHOW mail.@server[$pos].user | sed -e 's/^.*=\(.*\)$/\1/g'`)
user=$(eval echo ${users[$idx]})
hostname=`$UCI_GET mail.@server[$pos].hostname`
sendmail-init
echo "$3 $user"
echo "$3" | saslpasswd2 $user
echo "$3" | saslpasswd2 $user@$hostname
}
......@@ -5,8 +5,11 @@ UCI_SHOW="/sbin/uci -q show"
configure_sendmail() {
CONFIG=`$UCI_SHOW mail | awk '{ match($0, /\[([0-9]+)\]\.(hostname|user)=(.*)/, arr); if (arr[1] != "") print arr[1] " " arr[2] " " arr[3] }' | tr -d \'`
truncate --size 0 /data/etc/mail/access
truncate --size 0 /data/etc/mail/local-host-names
truncate --size 0 /data/etc/mail/mailertable
truncate --size 0 /data/etc/mail/virtusertable
truncate --size 0 /data/etc/mail/virtuserdomains
while read -a myarray
do
......@@ -20,23 +23,27 @@ configure_sendmail() {
if [ "$type" = "hostname" ]; then
hostname=$values
elif [ "$hostname" != "" ] && [ "${values[@]}" != "" ]; then
echo $hostname >> /data/etc/mail/local-host-names
echo "$hostname RELAY" >> /data/etc/mail/access
echo "$hostname error:nouser No such user here" >> /data/etc/mail/mailertable
for user in ${values[@]}
do
echo "$user@$hostname $user@$(hostname)" >> /data/etc/mail/virtusertable
echo $user
echo "$user@$hostname !" >> /data/etc/mail/virtusertable
echo $user@$hostname
done
echo "@$hostname error:nouser No such user here" >> /data/etc/mail/virtusertable
echo $hostname >> /data/etc/mail/virtuserdomains
fi
done <<< $CONFIG
echo $(hostname) >> /data/etc/mail/local-host-names
echo "@$(hostname) error:nouser No such user here" >> /data/etc/mail/virtusertable
makemap hash /data/etc/mail/access.db < /data/etc/mail/access
makemap hash /data/etc/mail/virtusertable.db < /data/etc/mail/virtusertable
makemap hash /data/etc/mail/mailertable.db < /data/etc/mail/mailertable
}
existing_users() {
CONFIG=`/usr/sbin/sasldblistusers2 | awk '{ match($0, /^(.*)@/, arr); if (arr[1] != "") print arr[1] }' | sort | uniq`
CONFIG=`/usr/sbin/sasldblistusers2 | awk '{ match($0, /^(.*@.*):/, arr); if (arr[1] != "") print arr[1] }' | sort | uniq`
echo $CONFIG
}
......@@ -52,7 +59,7 @@ done
for user in $(printf '%s\n' "${existing[@]}" | sort | uniq); do
if [[ ! " ${users[@]} " =~ " ${user} " ]]; then
fullname=`/usr/sbin/sasldblistusers2 | sed -n "s/^\($user@.*\):.*/\\1/p" | sort | uniq`
fullname=`/usr/sbin/sasldblistusers2 | sed -n "s/^\($user\):.*/\\1/p" | sort | uniq`
saslpasswd2 -d $fullname
fi
done
......@@ -7,7 +7,10 @@ DOMAIN(generic)dnl
define(`confTRUSTED_USER', `cyrus')dnl
define(`confDONT_PROBE_INTERFACES', `True')dnl
FEATURE(use_cw_file)dnl
FEATURE(`access_db', `hash -o -T<TMPF> /etc/mail/access.db')dnl
FEATURE(`mailertable', `hash -o /etc/mail/mailertable.db')dnl
FEATURE(`virtusertable', `hash -o /etc/mail/virtusertable.db')dnl
VIRTUSER_DOMAIN_FILE(`-o /etc/mail/virtuserdomains')
dnl ----------------------------------------------------------------------------
dnl Allow relaying of mail from clients on the local host.
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment