MAJOR=4
MINOR=13
DEVNAME=tty13
  /   ˆ{‹„„-i[D<†ªoZƒ›Ù«Ã556_‘I|¥‰ÓMdœv ©ƒ†ü+=ÃÂ ,    ‹      Å•QoÚ0…ßû+<?ì-¹è¨hâ©#HC£€(Ó4M{pb‡XMâÈ6dì×ÏÙ+Õºí%vœßïœX7þ«p:X|žÑûÅýÍ>¾�; Ÿ:€pÖºnËN0Â©1e ª*·ê¸R-a1‡ÔäY´Q"6.3“+»F®�ŸrÊìˆ|#LÆÉ¨`ü’	¹2Z0nw.WQ&âÃ0™kÐ¼`‰È¸Ëx.ÝT»±”¥-Äd¬­³ƒÚ–Ýh`|qJtûÞèUdÏÁ˜ÍuÏ‡º´…�=�I¶ÙBzÿÈÖÝEB£×vªˆoR´¦™X6²ÄÄùiD,QF‹Gw)Œhfüe4˜~µ:0éömâS”*žøí ˜ÜNƒ“	Í¹ô´æÞjî0SmP.™HggÅµøA|?¿aXkB®c%J#dq”‚µØ´ËL—Ôz½¶RÕTÕöT4þ)ŒÙÝ|8Y„£y	Ûnq¤û'Ÿ“U¼0(ŠÇFªÍÞóºˆty{¸E{wJ,Sƒ	B:©|F$«â±�UÑLÅ&~2k{iþBÔnµß8^ÛiµQ»Õïv:#´ýáÃŸ¢'2c\5ÉÏ}ÉRV\Ù¨ëñrþ›³ü/ýåüÍãrœ?éÃs:-äõúÝÞ_õñŒ#´âk{Ö1©Ç—0ðûƒtaó€}[õa×å}¨E? U�xí    6   ˆl–Ü4ý(&”ÔD¨ 	ÅÝÀ3pS�ÿ�þD'F³�•÷\hnJÛÀþÆƒyá9ÅÄÃ "z    #!/bin/bash
#
# Copyright Â© 2004 Patrick Koetter
# 
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 3 of the License, or (at
# your option) any later version.
#
# This program is distributed in the hope that it will be useful, but
# WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
# General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program.  If not, see <http://www.gnu.org/licenses/>.
#

#####################################################################
#                          VARIABLES                                #
#####################################################################
# set -e
scriptname="${0##*/}"
scriptversion=1.0.4

declare -a sasl_dirs valid_sasl_lib_names

sasl_dirs=(/usr/lib/sasl \
/usr/lib64/sasl2 \
/var/lib/sasl \
/opt/lib/sasl \
/usr/lib/sasl2 \
/var/lib/sasl2 \
/opt/lib/sasl2 \
/usr/local/lib/sasl2 \
/etc/sasl2 \
/etc/postfix/sasl \
/etc/cyrus-sasl \
/usr/pkg/lib)

sasl_libs=(libsasl.so libsasl2.so)

#####################################################################
#                     COMMANDS AND FUNCTIONS                        #
#####################################################################

export PATH="/bin:/sbin:/usr/bin:/usr/sbin:$PATH"

function start () {
	echo "${scriptname} - postfix Cyrus sasl configuration $(date)"
	echo "version: ${scriptversion}"
	echo "mode: ${mode} SMTP AUTH"
}

function end () {
	echo "-- end of ${scriptname} output --"
}

function postconf_get () { 
	postconf -h ${1}; 
}

function get_saslpasswd () { 
	postconf -h smtp_sasl_password_maps | sed -e s/^.*://; 
}

function get_mail_version () {
	declare -a systems
	local systems=("/etc/redhat-release" "/etc/fedora-release" "/etc/slackware-version" "/etc/gentoo-release" "/etc/issue" "/etc/motd")
	echo "-- basics --"
	echo "Postfix: $(postconf_get mail_version)"
	for system in ${systems[@]}; do
		if [[ -e ${system} ]]; then
			echo "System: $(cat ${system})"
			break
		else
			continue
		fi
	done
}

function get_sasl_dirs () {
	local i=0
	local sasldir=""
	for sasldir in ${sasl_dirs[@]}; do
		if [ -d ${sasldir} ]; then
			valid_sasldirs[$i]=${sasldir}
			let "i = $i + 1"
		fi
	done
	if ! [[ ${valid_sasldirs[@]} ]]; then
		echo -e "\aCould not find any valid Cyrus SASL directories."
		echo "Cyrus SASL is required to setup SMTP AUTH!"
		exit 72
	fi
}


function get_sasl_support () {
	local sasllib=""
	echo "-- $1 is linked to --"
	for sasllib in ${sasl_libs[@]}; do
	local ldd_res="$(ldd "$(postconf_get daemon_directory)/${1}" | egrep -e "${sasllib}" 2>/dev/null)"
		if [ -n "${ldd_res}" ]; then
			echo "${ldd_res}"
		fi
	done
}


function get_smtp_dialogue () {
	echo "-- mechanisms on ${1} --"
	if echo "EHLO $HOSTNAME\r\nQUIT\r\n" | nc -w 1 -v ${1} 25 2>/dev/null | egrep "AUTH" 2>/dev/null; then
	  echo
	elif echo "EHLO $HOSTNAME\r\nQUIT\r\n" | netcat -w 1 -v ${1} 25 2>/dev/null | egrep "AUTH" 2>/dev/null; then
	  echo
	else
		(echo "EHLO $HOSTNAME"; sleep 2) | telnet ${1} 25 2>/dev/null | egrep "(AUTH)"
	fi
}


function get_maincf () {
	if test ${1} = "smtpd"; then
		local authparams="(^smtpd