# ~jhs/public_html/dots/Makefile by Julian Stacey all: index.html .procmailrc.spam # not using default html_links warn: -ls -l .kde/share/apps/knotes/notes/knote* @# file "knote 1" has a space in the name, which is a bloody nuisance ! .rhosts.for_export: ../../.rhosts.master echo "Dummy" > $@ chmod 600 $@ #grep -v ^# ../../.rhosts.master > $@ BLA!= cd ${.CURDIR} ; find . -type f -print0 \( ! -name index.html -and ! -name index.lmth.tmp \) index.lmth: ${BLA} Makefile echo "
Generated `date` by " >> $@
echo "Makefile
" >> $@
echo "(Generated " >> $@
echo "because web servers do not list dot files.)
" >> $@ echo "
' >> $@
chmod 644 $@
Xdefaults:
le -d .Xdefaults.master > .Xdefaults.desk
le -w .Xdefaults.master > .Xdefaults.wall
le -p .Xdefaults.master > .Xdefaults.phil
le -c .Xdefaults.master > .Xdefaults.chris
ln .Xdefaults.desk .Xdefaults
# le -`hostname` .Xdefaults.master > .Xdefaults
SPAM_PHRASES = ../../.DOTS/.procmailrc.spam.phrases
vi:
@# Obsolete now all is .forwarded:
@# @echo "Filtering any mail on host \"mail\""
@# rsh mail procmail.sh
@# @echo "Filtering any mail on local host"
@# procmail.sh
make .procmailrc.spam
make sort
@echo "Now manually add new phrases & domains while reading mail."
@# sleep 2
vi ${SPAM_PHRASES} /host/conf/site/etc/mail/domains2block
@# .procmailrc.spam.domains -> /site/etc/mail/domains2block
@# It is diffifcult to decide whether one should re-sort the lists
@# Against re-sort:
@# New lines of spam phrases or domains may not have
@# been added, but sorting (unless I improve it by
@# sorting to a temporary file) would
@# force a new datestamp even if nothing was added
@# which used to mean (when I exported list to
@# ~/public_html) a superfluous upload to web.
@# For re-sort:
@# Spam arrives in waves, usually with multiples
@# containing same excrement, so enable any new
@# phrases as fast as possible.
make sort
@# Obsolete now all is .forwarded:
@# @echo "Processing any new mail."
@# @echo "If it next complains: \"Maybe a stale lock file exists\""
@# @echo "probably crontab started a procmail.sh while you were editing."
@# rsh mail procmail.sh
sort:
make sort-phrases
rsh conf "cd public_html/dots ; make sort-domain"
@# rsh as .procmailrc.spam.domains is a sym link to /site, & if we
@# update any other host, rdist from host=conf will zap it later.
sort-phrases:
@# ls -l ${SPAM_PHRASES}
cat ${SPAM_PHRASES} | \
tr ABCDEFGHIJKLMNOPQRSTUVWXYZ abcdefghijklmnopqrstuvwxyz | \
sort | uniq | grep -v "^$$" > $@.tmp
@# ls -l ${SPAM_PHRASES} $@.tmp
if ( test -s $@.tmp && ! cmp -s $@.tmp ${SPAM_PHRASES} ) ; \
then \
mv $@.tmp ${.CURDIR}/${SPAM_PHRASES} ; \
echo "${SPAM_PHRASES} now sorted" ; \
else \
echo -n "No difference (or zero size), " ; \
echo "so not updating ${SPAM_PHRASES}" ; \
rm $@.tmp ; \
fi
sort-domain:
cat .procmailrc.spam.domains | \
tr ABCDEFGHIJKLMNOPQRSTUVWXYZ abcdefghijklmnopqrstuvwxyz \
| sort | uniq | grep -v "^$$" | grep -v "^10\\." \
| grep -v "^192\\.168\\." | grep -v "^172\\.16\\." \
| grep -v 83.236.223.114 | grep -v 83.236.223.115 \
| grep -v 194.246.123.68 | grep -v t-dialin.net \
| grep -v dsl.sntc01.pacbell.net \
| grep -v " " \
> $@.tmp
if ( test -s $@.tmp && ! cmp $@.tmp .procmailrc.spam.domains ) ; \
then \
cp $@.tmp ${.CURDIR}/.procmailrc.spam.domains && \
rm $@.tmp ; \
echo ".procmailrc.spam.domains now sorted" ; \
else \
echo -n "No difference (or zero size), " ; \
echo "so not updating .procmailrc.spam.domains" ; \
rm $@.tmp ; \
fi
@# cp rather than move as .procmailrc.spam.domains --> /site/...
@# The cp may fail if /site/etc/mail/domains2block is not uid=jhs,
@# I'd like to add dip.t-dialin.net to the block list,
@# but that would block me.
@# I ensure I havent included internal private IP ranges from spammers,
@# that other innocents elsewhere will also use, by deleting
@# 10.*.*.* & 192.168.*.* & 172.16.0.0-172.31.255.255
@# The other IPs are numbers I might paste by mistake.
# It is important to remove blank lines, else they get turned into
# a match line in .procmailrc.spam consisting of a simple "* "
# which matches all lines, & personal mail gets dumped in spam box.
# Later the phrases may be fed into a different anti spam tool, so preserve
# the original list, before reducing to a safer form for procmail. The line
# "rem|o|ved" was sufficient to wrongly dump all in spam box. So I delete
# lines with pipe symbols as EG single word "removed" would not be a good
# filter match. See SHELLMETAS in man procmailrc.
.procmailrc.spam.shrunk: ${SPAM_PHRASES} Makefile
cat ${SPAM_PHRASES} | \
grep -v '&' | grep -v '|' | grep -v '<' | grep -v '>' | grep -v '~' | \
grep -v ';' | grep -v '?' | grep -v '*' | grep -v '\[' | grep -v "^$$" \
> $@
# Unfortunately removing lines with meta characters above, means its no good
# hoping to scan for spam like eg: "fugen sie * in ihre liste donnerstag"
ZZ = ${HOME}/tmp/.procmailrc.spam.tmp
# ZZ achieves a Massive speed-up, avoiding 5000 slow small nfs appends
# to ~/dots/.procmailrc.spam
.procmailrc.spam: .procmailrc.spam.shrunk Makefile .procmailrc.spam.domains
echo "# ~/dots/$@ built by ~/dots/Makefile" > $@
@echo "# Do Not Edit: Built by ~/public_html/dots/Makefile" >> $@
@echo "# Included by ~/.procmailrc.private" >> $@
@echo "#---" >> $@
@echo "# Phrases: From ~/dots/${SPAM_PHRASES}" >> $@
@# "Warning phrases such as h.o.t. false match to olt in Ashbolt"
@# "Warning phrases such as i.r.a.q false match mime encoded pics"
cp /dev/null ${ZZ}
cat .procmailrc.spam.shrunk | \
while read phrase ; do \
echo ":0 BH" >> ${ZZ} ;\
echo -n "* " >> ${ZZ} ; echo $$phrase >> ${ZZ} ;\
echo '| $$RCVSTORE +spam/phrases' >> ${ZZ} ;\
done
cat ${ZZ} >> $@
@# Do not "rm .procmailrc.spam.shrunk" as useful for grepspam.
@# @echo "#---" >> $@
@# @echo "# Domains: From ~/dots/.procmailrc.spam.domains" >> $@
@# @# Warnings:
@# @# - short domains create false matches.
@# @# - domain "this.com" used to falsely match against non spam
@# @# email which had "this complaint" in the body, so as a
@# @# temporary half fix I have reduced ":0 BH" below to just
@# @# ":0 H", however thats not good enough,
@# @# JJLATER I should either delimit all "." or
@# @# tell procmail its a literal string
@# cp /dev/null ${ZZ}
@# cat .procmailrc.spam.domains | \
@# while read domain ; do \
@# echo ":0 H" >> ${ZZ} ;\
@# echo "* ^Received:.*$$domain" >> ${ZZ} ;\
@# echo '| $$RCVSTORE +spam/domain' >> ${ZZ} ;\
@# done
@# cat ${ZZ} >> $@
@# rm ${ZZ}
@# @echo "#---" >> $@
check: .procmailrc.spam.shrunk .procmailrc.spam.domains Makefile
@# Search for domains first, as thats more likely troublesome.
@# Limitation: this does not search domains of lists maintained by
@# majordomo on the remote servers.
@# The '-' in next line is necessary to avoid first non matching
@# line stopping the while loop.
@# Do not "rm .procmailrc.spam.shrunk" as useful for grepspam.
-cat .procmailrc.spam.domains | \
while read phrase ; do \
echo "Searching for $$phrase" > /dev/null ;\
(cd /site ; xs Grep $$phrase |\
grep -v ./etc/mail/domains2block: |\
grep -v ./domain/js.berklix.net/etc/mail/access: |\
grep -v ./domain/berklix/etc/mail/access \
) ;\
done
echo "make xx still needs to be developed"
xx:
@# the DISCARD above is typically a line such as:
@# ./domain/js.berklix.net/etc/mail/access:best-deals2u.biz DISCARD
@# Search for phrases.
-cat .procmailrc.spam.shrunk | \
while read phrase ; do \
echo Seeking for "\"$$phrase\"" ;\
(cd /site ; xs Grep "\"$$phrase\"" ) ;\
sleep 10 ;\
done
PROCM = .procmailrc
PROCM += .procmailrc.3d
PROCM += .procmailrc.errors
PROCM += .procmailrc.fonts
PROCM += .procmailrc.lists
PROCM += .procmailrc.owner.dump
PROCM += .procmailrc.owner.keep
PROCM += .procmailrc.private.dump
PROCM += .procmailrc.private.keep
PROCM += .procmailrc.private.self
PROCM += .procmailrc.system.logs
PROCM += .procmailrc.web_form
# Do not check these:
# .procmailrc.spam.domains ${SPAM_PHRASES}:
# automaticaly sorted by makefile, so no chance to insert extra lines
# .procmailrc.spam:
# auto generated from above
PLOG = $$HOME/mail/procfile.log
brackets:
@# test for unmatched bracket count on .procmailrc files
@# theres''s a lot more syntax checking could be done than this,
@# but it''s a start, & also ${PLOG} catches errors
cd $$HOME && for i in ${PROCM} ; do \
brackets $$i | tail -1 ;\
echo $$i ;\
echo ;\
done
log:
@echo "Checking for some errors ive noticed in .procmailrc*"
@#---------------
-grep "procmail: Invalid regexp " ${PLOG} || true
@# If a ( has not been delimited to ( & the other ) has been to \)
@#---------------
-grep "procmail: Skipped " ${PLOG} || true
@# If a ":0" line has been forgotten, preceeding a "* Match pattern".
@# true avoids the ouput nessed by "*** Error code 1 (ignored)"
@#---------------
-grep "Missing closing brace" ${PLOG} || true
@# If no action rule before an existing close brace }
@#---------------
-grep "Folder: :0" ${PLOG} || true
@# I can not remember what error produces this but I have seen it.
@#- - - - - - - -
@# If eg one has an action rule of "| $RCVSTORE +$INBOX_PLAIN"
@# & one has forgotten to define INBOX_PLAIN one get this log error:
@# "^ Folder: /usr/local/libexec/nmh/rcvstore +^I"
@# I need to add delimeter to next line
-grep "^ Folder: /usr/local/libexec/nmh/rcvstore + " ${PLOG} || true
@# & one gets files such as ~/mail/1
if [ -e ~/mail/0 ] ; then \
ls -l ~/mail/[0-9]* ; \
fi
@#---------------
NO_OBJ= true
.include