# Blackmail Proxy
# by Ken Hollis <khollis@chatlink.com>

## If you want FULL HEADERS to be sent in each message that is intercepted
## from BlackMail, uncomment this line.  Caution, FULL HEADERS take up
## 8 lines in the header field.  It is not uncommon to comment this line.
## This is not recommended if you run a large ISP.  Some customers may
## complain that the headers show too much information (especially in
## mailers like Eudora.)  Use this with caution, or when first installing
## BlackMail.  If you comment this line, the headers take up 3 lines at
## most.
#FULL_HEAD= -DFULL_HEADERS


### Ident options:

## If you want BlackMail to reject any sites not matching an IDENT entry
## then enable this line.  This is only recommended if you are using
## BlackMail for your own personal use.  If you are running a large site
## with BlackMail, you probably don't want this function enabled.
#FORCE_IDENT= -DFORCED_IDENT

## If you want BlackMail to show the progress of an IDENTD request from
## another site getting connected, you can enable this option.  This is
## not required, but it gives the user on the other end an idea of what's
## going on in case they want to report a problem.
#IDENT_INTERACT= -DIDENT_INTERACT

## Normally the IDENT checks are a good idea, but if you only receive you
## mail from trusted hosts they can be disabled. (e.g. Demon Internet users)
#DISABLE_IDENT= -DDISABLE_IDENT


### Check method options:

## If you want BlackMail to reject HTML email, enable this.
#BAN_HTML= -DBAN_HTML

## If you want BlackMail to reject matching To: and From: enable this.
## Mail sent within your site is immune.
TO_FROM= -DTO_FROM

## To check all visible email address with DNS enable this.
## Does not appear to work on SVR4.
DNS_CHECK= -DDNS_CHECK

## Experimental new options - check IPs against 'RBL' (Realtime BlackList)
## BEFORE using this option you must see http://maps.vix.com/rbl for
## more details on the RBL. These option is likely to reject some valid
## mail within the sea of spam from the listed IPs.
## If you are unsure, leave well alone!
## RBL_CHECK enables a check on the incoming IP i.e. one query per connection
## RBL_CHECK_ALL checks the IP returned after all DNS checks i.e. lots of
## queries per message.
## DNS checking must be enabled before RBL checks will work.
#RBL_CHECK= -DRBL_CHECK
#RBL_CHECK= -DRBL_CHECK -DRBL_CHECK_ALL


### Debugging and testing options

## If you want debugging enabled, uncomment the DEBUG line.  Caution,
## debugging eats up loads of CPU since all of the debugging information
## is sent to syslog.  Use this with caution, or if you want to report
## a bug. Logs normally end up in the 'messages' file, typically in /var/log
## or /usr/adm.
DEBUG= -DDEBUG

## DEBUG2 will cause the mailer to log the reasons it would have rejected
## mail without physically rejecting any mail. This is a useful option to
## use when first installing Blackmail as you won't lose any mail is you
## haven't configured it 100% ! You will need to read you log files though.
## Be aware that you will get lots of logs.
#DEBUG= -DDEBUG -DDEBUG2 -DSYSLOG_ALL

## If you want BlackMail to send all the SMTP commands of all messages to your
## syslog, which could ultimately lead to a humongous syslog log file,
## uncomment this next line:
#SYSLOG_ALL= -DSYSLOG_ALL

## The PASSIVE option is for initial testing purposes and will stop
## Blackmail sending any reject/defer codes back to the SMTP sender
## (and thus will never bounce any spam) except for unauthorised
## relay attempts.
## The second option PASSIVE_RELAY will make the unauthorized relay checking
## code passive too. This should only be used while you are confirming your
## blackmail.conf TREAT_AS_LOCALHOST and ALLOWED_MAIL_SITES are correct.
##
## You can use these options to safely test out Blackmail without
## the risk of any mail bouncing or being delayed. Everyone will get
## their mail, but a header or footer will be added to warn if it would
## have been rejected.
## Normally, logging is minimal, enable DEBUG, DEBUG2 and/or SYSLOG_ALL if
## you need more information logged.
#PASSIVE = -DPASSIVE
PASSIVE = -DPASSIVE -DPASSIVE_RELAY

## In DEBUG2 and PASSIVE mode, you can choose to have a header and/or
## footer that lets you know how many checks that message failed on.
## (Check your log files against the PID reported for the reasons.)
DEBUG_TAGS= -DDEBUG_HEADER -DDEBUG_FOOTER


### DO NOT MODIFY ANYTHING BELOW THIS LINE ###
EXTRA_DATA= $(FULL_HEAD) $(DEBUG) $(FORCE_IDENT) $(IDENT_INTERACT) \
	$(BAN_HTML) $(TO_FROM) $(DNS_CHECK) $(SYSLOG_ALL) $(DISABLE_IDENT) \
	$(PASSIVE) $(DEBUG_TAGS) $(RBL_CHECK)
MDIR= modules
FDIR= filter

include Makefile.tmpl

MODULES= $(MDIR)/data.o $(MDIR)/quit.o $(MDIR)/rcpt.o $(MDIR)/mail.o \
	 $(MDIR)/helo.o $(MDIR)/ehlo.o $(MDIR)/vrfy.o $(MDIR)/expn.o

FILTERS= $(FDIR)/reply-to.o $(FDIR)/from.o $(FDIR)/to.o $(FDIR)/received.o \
	 $(FDIR)/distribution.o $(FDIR)/comments.o \
	 $(FDIR)/message-id.o $(FDIR)/apparently-to.o

LINK_FLAGS= main.o blackmail.o wildmat.o util.o rblcheck.o $(MODULES) $(FILTERS)
CLEAN_PATTERN= *.o modules/*.o filter/*.o core blackmail
DNS_TEST_CLEAN= dns-test/*.o dns-test/dns-test
blackmail:	$(LINK_FLAGS)
		$(CC) -o $@ $(LINK_FLAGS) $(LDFLAGS) $(LDLIBS)

install:
		cp blackmail /usr/sbin
#		cp blackmail.conf /etc
		cp man/blackmail.3 /usr/man/man3
		@echo
		@echo "Don't forget to read the \"README\" and"
		@echo "\"INSTALL\" files for installation instructions!"
		@echo
		@echo "Good luck!"
		@echo

real-clean:
		rm -f $(CLEAN_PATTERN) $(DNS_TEST_CLEAN) Makefile.tmpl

clean:
		rm -f $(CLEAN_PATTERN)

### LINKFILE RULES ###
main.o: main.c
	$(CC) $(CFLAGS) -c main.c
blackmail.o: blackmail.c
	$(CC) $(CFLAGS) -c blackmail.c
wildmat.o: wildmat.c
	$(CC) $(CFLAGS) -funroll-loops -c wildmat.c
util.o: util.c
	$(CC) $(CFLAGS) -c util.c
rblcheck.o: rblcheck.c
	$(CC) $(CFLAGS) -c rblcheck.c

$(MDIR)/data.o: $(MDIR)/data.c
	$(CC) $(CFLAGS) -c $(MDIR)/data.c -o $(MDIR)/data.o
$(MDIR)/quit.o: $(MDIR)/quit.c
	$(CC) $(CFLAGS) -c $(MDIR)/quit.c -o $(MDIR)/quit.o
$(MDIR)/rcpt.o: $(MDIR)/rcpt.c
	$(CC) $(CFLAGS) -c $(MDIR)/rcpt.c -o $(MDIR)/rcpt.o
$(MDIR)/mail.o: $(MDIR)/mail.c
	$(CC) $(CFLAGS) -c $(MDIR)/mail.c -o $(MDIR)/mail.o
$(MDIR)/helo.o: $(MDIR)/helo.c
	$(CC) $(CFLAGS) -c $(MDIR)/helo.c -o $(MDIR)/helo.o
$(MDIR)/ehlo.o: $(MDIR)/ehlo.c
	$(CC) $(CFLAGS) -c $(MDIR)/ehlo.c -o $(MDIR)/ehlo.o
$(MDIR)/vrfy.o: $(MDIR)/vrfy.c
	$(CC) $(CFLAGS) -c $(MDIR)/vrfy.c -o $(MDIR)/vrfy.o
$(MDIR)/expn.o: $(MDIR)/expn.c
	$(CC) $(CFLAGS) -c $(MDIR)/expn.c -o $(MDIR)/expn.o

$(FDIR)/reply-to.o: $(FDIR)/reply-to.c
	$(CC) $(CFLAGS) -c $(FDIR)/reply-to.c -o $(FDIR)/reply-to.o
$(FDIR)/from.o: $(FDIR)/from.c
	$(CC) $(CFLAGS) -c $(FDIR)/from.c -o $(FDIR)/from.o
$(FDIR)/to.o: $(FDIR)/to.c
	$(CC) $(CFLAGS) -c $(FDIR)/to.c -o $(FDIR)/to.o
$(FDIR)/received.o: $(FDIR)/received.c
	$(CC) $(CFLAGS) -c $(FDIR)/received.c -o $(FDIR)/received.o
$(FDIR)/distribution.o: $(FDIR)/distribution.c
	$(CC) $(CFLAGS) -c $(FDIR)/distribution.c -o $(FDIR)/distribution.o
$(FDIR)/comments.o: $(FDIR)/comments.c
	$(CC) $(CFLAGS) -c $(FDIR)/comments.c -o $(FDIR)/comments.o
$(FDIR)/message-id.o: $(FDIR)/message-id.c
	$(CC) $(CFLAGS) -c $(FDIR)/message-id.c -o $(FDIR)/message-id.o
$(FDIR)/apparently-to.o: $(FDIR)/apparently-to.c
	$(CC) $(CFLAGS) -c $(FDIR)/apparently-to.c -o $(FDIR)/apparently-to.o
