# FQDN-alias override # # This is the simple interface to the db/fqdnalias file in classical # aliasing style. # # We check in order following: # - address existing (in lower-case) in the fqdnaliases database # - address domain-part existing (@domain) in the fqdnaliases database # - address existing (in lower-case) in the MAILVAR/fqlists/ -directory # in similar manner to those in MAILVAR/lists/ at the aliases.cf # - owner-*, *-owner, and *-request -relation of the MAILVAR/fqlists/ # likewise # # We do not support '+'-selectors in similar manner to those that aliases # processing does! # # FQDN-aliases initializations # # Relations: fqdnalias provide fqdnaliasdb # # FQDN-aliases, in autoconfigured dbase type # if [ -f $MAILVAR/db/fqdnaliases.zmsh ]; then . $MAILVAR/db/fqdnaliases.zmsh else if [ -f $MAILVAR/db/fqdnaliases ]; then # Need to be updated at boot ? if [ ! -f $MAILVAR/db/fqdnaliases$DBEXTtest -o \ $MAILVAR/db/fqdnaliases -nt $MAILVAR/db/fqdnaliases$DBEXTtest ]; then # Yes, so update! $MAILBIN/zmailer newfqdnaliases fi relation -lmt $DBTYPE -f $MAILVAR/db/fqdnaliases$DBEXT fqdnaliases else fqdnaliases () { return 1 } fi fi # # Define an LDAP hook, just in case... # if [ -f $MAILVAR/db/fqdnaliasesldap.zmsh ]; then . $MAILVAR/db/fqdnaliasesldap.zmsh else if [ -f $MAILVAR/db/fqdnalias.ldap ]; then relation -lmt ldap -s 9999 -e 2000 \ -f $MAILVAR/db/fqdnalias.ldap fqdnaliasesldap else fqdnaliasesldap () { return 1 } fi fi require fqdnaliasdb provide fqdnalias fqdn_neighbour (domain, address, A) { # "domain" is dummy.. local lcaddress key l a priv nattr user athost local plustail lcaddress="$(recase -l "$address")" key="$lcaddress" # It may be a "sender" address! case "$(get $A type)" in sender) if $(didexpand userdbmailname) && a="$(userdb "$lcaddress:mailname")" ; then db add expansions "$key.userdbmailname" 1 nattr=$(newattribute $A privilege $priv) && return $(echo "$a" | \ listaddresses -c "$a sender fqdn userdb mailname" \ -e root | \ maprrouter $nattr "sender-fqdn-userdb-mailname" \ "$address" "$plustail" "$athost") fi return 1 ;; esac plustail="" tsift "$lcaddress" in (.+)@(.+) user="\1" athost="@\2" break ;; .* return 1 # Not in uu@hh form! ;; tfist # For a recipient address we may do a FQDN-aliasing # We are better NOT to have aliasing loops here, though # we do expansion recursion pruning by falling thru to # normal target address locality testing, and such... # Already expanded ? If yes, go away! #if [ -n "$(expansions "$lcaddress")" ] ; then # return 1 #fi # Yes, add to the expansions. Success ? # Yes, Any success with filepriv from the alias db ? # Yes, generate new privilege attribute for it. Success ? # Yes, do the expansion! (echo .. | listexpand ...) # if $(didexpand fqdnaliases) && a="$(fqdnaliases "$lcaddress")" ; then db add expansions "$key.fqdnaliases" 1 priv=$(filepriv -M 644 $MAILVAR/db/fqdnaliases$DBEXTtest \ $(db owner fqdnaliases)) && nattr=$(newattribute $A privilege $priv) && return $(echo "$a" | \ listaddresses -c "$a fqdn alias expansion" \ -e root | \ maprrouter $nattr "fqdnalias" "$address" \ "$plustail" "$athost") fi if $(didexpand fqdnaliasesldap) && a="$(fqdnaliasesldap "$lcaddress")" ; then db add expansions "$key.fqdnaliasesldap" 1 # FIXME: privilege NOBODY! return $(echo "$a" | \ listaddresses -c "$a fqdn ldap expansion" \ -e root | \ maprrouter $A "fqdnalias" "$address" \ "$plustail" "$athost") fi # Didn't match, # Plusfull usernames ?? ssift "$user" in ([^+]+)\+(.*) local u2 pl2 u2="\1" pl2="+\2" key="$u2$athost" if $(didexpand fqdnaliases) && a="$(fqdnaliases "$key")" ; then db add expansions "$key.fqdnaliases" 1 priv=$(filepriv -M 644 $MAILVAR/db/fqdnaliases$DBEXTtest \ $(db owner fqdnaliases)) && nattr=$(newattribute $A privilege $priv) && return $(echo "$a" | \ listaddresses -c "$a fqdn+ alias expansion" \ -e root | \ maprrouter $nattr "fqdnalias" "$address" \ "$pl2" "$athost") fi if $(didexpand fqdnaliasesldap) && a="$(fqdnaliasesldap "$key")" ; then db add expansions "$key.fqdnaliasesldap" 1 # FIXME: privilege NOBODY! return $(echo "$a" | \ listaddresses -c "$a fqdn+ ldap expansion" \ -e root | \ maprrouter $A "fqdnalias" "$address" \ "$plustail" "$athost") fi ;; tfiss # Didn't match, # We may also match for: "@domain.name" # Yes, add to the expansions. Success ? # Yes, Any success with filepriv from the alias db ? # Yes, generate new privilege attribute for it. Success ? # Yes, do the expansion! (echo .. | listexpand ...) # key="$athost" if $(didexpand fqdnaliases) && a="$(fqdnaliases "$key")" ; then db add expansions "$key.fqdnaliases" 1 priv=$(filepriv -M 644 $MAILVAR/db/fqdnaliases \ $(db owner fqdnaliases)) && nattr=$(newattribute $A privilege $priv) && return $(echo "$a" | \ listaddresses -c "$a fqdn alias expansion" \ -e root | \ maprrouter $nattr "fqdnalias" "$address" \ "$plustail" "$athost") fi if $(didexpand fqdnaliasesldap) && a="$(fqdnaliasesldap "$key")" ; then db add expansions "$key.fqdnaliasesldap" 1 # FIXME: privilege NOBODY! return $(echo "$a" | \ listaddresses -c "$a fqdn ldap expansion" \ -e root | \ maprrouter $A "fqdnalias" "$address" \ "$plustail" "$athost") fi # TODO: *@any.domain which maps somebody@any.domain via # replacement pattern(s): %s@other.domain or other.uucp!%s, or .. # to: somebody@other.domain, or other.uucp!somebody # Problem: Supporting ONE target replacement is easy, supporting more # will need major coding work at ``listexpand'' [mea] priv=$(get $A privilege) # Do we have a file with that name ? a="$MAILVAR/fqlists/$lcaddress" key="$ldaddress" l="$preowner$user$postowner$athost" nattr=() if [ -f "$a" ] && $(didexpand fqlists); then db add expansions "$key.fqlists" 1 priv=$(getpriv "644" $priv "$a" maillist) nattr=$(newattribute $A privilege $priv sender "$l") return $(runas $priv cat "$a" | \ listexpand -E "$l" -e "$l" -p $priv \ -c "$a file expansion" \ "$nattr" "$a" "$user$athost" \ "$plustail" "$athost") fi # Ok, if the list (MAILVAR/fqlists/user@host) did exist, we did # process it's expansion above. See if we are looking for *-owner, # owner-*, or *-request of same lists. ssift "$user" in (.+)-owner a="$MAILVAR/fqlists/\1$athost" if [ -f "$a" ] && $(didexpand fqlistowner); then db add expansions "$key.fqlistowner" 1 return $(rrouter "$(uid2login $(filepriv -M 664 "$a"))" \ "$address" $A "" "" "$domain") fi break ;; (.+)-request a="$MAILVAR/fqlists/\1$athost" if [ -f "$a" ] && $(didexpand fqlistrequest); then db add expansions "$key.fqlistrequest" 1 return $(rrouter "$(uid2login $(filepriv -M 664 "$a"))" \ "$address" $A "" "" "$domain") fi break ;; owner-(.+) a="$MAILVAR/fqlists/\1$athost" if [ -f "$a" ] && $(didexpand ownerfqlists); then db add expansions "$key.ownerfqlists" 1 return $(rrouter "$(uid2login $(filepriv -M 664 "$a"))" \ "$address" $A "" "" "$domain") fi ;; tfiss return 1 } mapfqrrouter (attribute, localpart, origaddr, plustail, domain) { local shh al al=() while read address do case "$address" in '') shh=(((error expansion "$localpart"))) lappend al $shh continue ;; esac defer='' shh=$(rrouter "$address" "$origaddr" $attribute \ "$plustail" "$domain") [ "$defer" ] && shh=(((hold "$defer" "$address" $attribute))) defer='' lappend al $shh done return $al }