divert(-1) # # Copyright (c) 2003, 2004 Victor Ustugov # This hack is under BSD License # Redistributions of source code must retain the above copyright notice # # hacks disscussion's maillist - http://www.mta.org.ua/mailman/listinfo/sendmail-conf # # # Check header Message-Id # Проверка поля Message-Id # dnl # dnl # исключение из проверки Message-Id сообщений от авторизованных отправителей dnl # define(`confCHECK_MESSAGE_ID_SKIP', `AUTH')dnl dnl # dnl # исключение из проверки Message-Id исходящих сообщений, подробней см. HACK(`is_outgoing') dnl # define(`confCHECK_MESSAGE_ID_SKIP', `OUTGOING')dnl dnl # dnl # исключение из проверки Message-Id сообщений: dnl # MAIL FROM которых указан в access_db в виде: dnl # CheckMessageId:mailbox@subdomain.maildomain OK dnl # CheckMessageId:subdomain.maildomain OK dnl # CheckMessageId:maildomain OK dnl # $&{client_name} указан в access_db в виде: dnl # CheckMessageId:hostname.subdomain.maildomain OK dnl # CheckMessageId:subdomain.maildomain OK dnl # CheckMessageId:maildomain OK dnl # $&{client_addr} указан в access_db в виде: dnl # CheckMessageId:A.B.C.D OK dnl # CheckMessageId:A.B.C OK dnl # CheckMessageId:A.B OK dnl # CheckMessageId:A OK dnl # define(`confCHECK_MESSAGE_ID_SKIP', `EXCLUDED')dnl dnl # divert(0) VERSIONID(`$Id: check_message_id.m4,v 8.12-0.08 2005/12/12 16:49:50 corvax Exp $')dnl divert(-1) dnl ifelse_strstr(confCHECK_MESSAGE_ID_SKIP, `EXCLUDED', `dnl ifdef(`_ACCESS_TABLE_', `dnl', `dnl errprint(`*** ERROR: HACK(check_message_id) requires FEATURE(access_db) ')')') dnl ifdef(`confCHECK_MESSAGE_ID_BSD_SYNTAX_MSG',`',` define(`confCHECK_MESSAGE_ID_BSD_SYNTAX_MSG', `554 Message contains invalid header') dnl define(`confCHECK_MESSAGE_ID_BSD_SYNTAX_MSG', `554 Invalid Message-ID header') ')dnl dnl ifdef(`confCHECK_MESSAGE_ID_MISSING_MSG',`',` define(`confCHECK_MESSAGE_ID_MISSING_MSG', `554 Missing Message-ID header') ')dnl dnl dnl LOCAL_RULESETS dnl dnl HMessage-Id: $>+Check_Message_Id dnl SCheck_Message_Id dnl R $* $: $(macro {MessageIdExist} $@ YES $) $1 ifdef(`confCHECK_MESSAGE_ID', `ifelse(confCHECK_MESSAGE_ID, `YES', `dnl ifelse_strstr(confCHECK_MESSAGE_ID_SKIP, `AUTH', `dnl # skip checks for authentificated senders R $* $: $&{auth_type} $| $1 R $+ $| $* $@ SKIP_AUTH R $* $| $* $: $2 ') dnl ifelse_strstr(confCHECK_MESSAGE_ID_SKIP, `OUTGOING', `dnl # skip checks for outgoing messages R $* $: $&{IsOutgoing} $| $1 R YES $| $* $@ SKIP_OUTGOING R $* $| $* $: $2 ') dnl ifelse_strstr(confCHECK_MESSAGE_ID_SKIP, `EXCLUDED', `dnl # skip checks for excluded messages R $* $: $1 R $* $: $1 $| $&{mail_addr} R $* $| $+ $: < $(access CheckMessageId:$2 $: ? $) > $1 $| $2 R $* $| $+ @ $+ $: $>D <$3> R <$*> $: <$1> $2 R $* $| $: $1 R $* $: $1 $| $&{client_name} R $* $| $+ $: $>D <$2> R <$*> $: <$1> $2 R $* $: $1 $| $&{client_addr} R $* $| $+ $: $>A <$2> R <$*> $: <$1> $2 R $* $@ SKIP EXCLUDED R $* $@ SKIP EXCLUDED R <$*> $* $: $2 ') dnl R $* $: $1 R < $+ @ $+ > $: < $1 @ $2 > R $* $: <$1> < confCHECK_MESSAGE_ID_BSD_SYNTAX_MSG > < "Invalid Message-ID header (not <@>): " $1 > R $* $: $1 dnl R $+ $: $1 $| $1 R $+ $| < @ $* > $: <$1> < confCHECK_MESSAGE_ID_BSD_SYNTAX_MSG > < "Invalid Message-ID header (<@): " $1 > R $+ $| < . $* > $: <$1> < confCHECK_MESSAGE_ID_BSD_SYNTAX_MSG > < "Invalid Message-ID header (<.): " $1 > R $+ $| < $* @ . $* > $: <$1> < confCHECK_MESSAGE_ID_BSD_SYNTAX_MSG > < "Invalid Message-ID header (@.): " $1 > R $+ $| < $* . . $* > $: <$1> < confCHECK_MESSAGE_ID_BSD_SYNTAX_MSG > < "Invalid Message-ID header (..): " $1 > R $+ $| < $* @ $* @ $* > $: <$1> < confCHECK_MESSAGE_ID_BSD_SYNTAX_MSG > < "Invalid Message-ID header (@@):" $1 > R $+ $| < $- . $- . $- $u @ $h > $: <$1> < confCHECK_MESSAGE_ID_BSD_SYNTAX_MSG > < "Spam Message-ID header: " $1 > R $+ $| $: <$1> < confCHECK_MESSAGE_ID_BSD_SYNTAX_MSG > < "Reject message from anonymizer: " $1 > R $+ $| $+ $: $1 dnl R <$+> <$+> <$+> $: < $1 > < $2 > $(log $3 $) R <$+> <$+> $#error $@ 5.6.4 $: $2 " (" $&i ")" R $* $: $1 ')') ifdef(`confCHECK_MESSAGE_ID_MUST_EXIST', `ifelse(confCHECK_MESSAGE_ID_MUST_EXIST, `YES', `dnl Scheck_eoh R $* $: $1 $| $>Message_Id_must_exist R $* $| $#$* $#$2 R $* $| $* $: $1 SMessage_Id_must_exist dnl # Check the macro R $* $: < $&{MessageIdExist} > # Clear the macro for the next message R $* $: $1 $(macro {MessageIdExist} $) # Has a Message-Id: header R < YES > $@ OK dnl ifelse_strstr(confCHECK_MESSAGE_ID_SKIP, `AUTH', `dnl # skip checks for authentificated senders R $* $: $&{auth_type} $| $1 R $+ $| $* $@ SKIP_AUTH R $* $| $* $: $2 ') dnl ifelse_strstr(confCHECK_MESSAGE_ID_SKIP, `OUTGOING', `dnl # skip checks for outgoing messages R $* $: $&{IsOutgoing} $| $1 R YES $| $* $@ SKIP_OUTGOING R $* $| $* $: $2 ') dnl ifelse_strstr(confCHECK_MESSAGE_ID_SKIP, `EXCLUDED', `dnl # skip checks for excluded messages R $* $: $1 R $* $: $1 $| $&{mail_addr} R $* $| $+ $: < $(access CheckMessageId:$2 $: ? $) > $1 $| $2 R $* $| $+ @ $+ $: $>D <$3> R <$*> $: <$1> $2 R $* $: $1 $| $&{client_name} R $* $| $+ $: $>D <$2> R <$*> $: <$1> $2 R $* $: $1 $| $&{client_addr} R $* $| $+ $: $>A <$2> R <$*> $: <$1> $2 R $* $@ SKIP EXCLUDED R $* $@ SKIP EXCLUDED R <$*> $* $: $2 ') # Otherwise, reject the mail R $* $: $1 $(log "Missing Message-ID header" $) R $* $#error $@ 5.6.4 $: "554 confCHECK_MESSAGE_ID_MISSING_MSG (" $&i ")" ')')