<?xml version="1.0" encoding="utf-8" ?>

<rss version="2.0" 
   xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#"
   xmlns:admin="http://webns.net/mvcb/"
   xmlns:dc="http://purl.org/dc/elements/1.1/"
   xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
   xmlns:wfw="http://wellformedweb.org/CommentAPI/"
   xmlns:content="http://purl.org/rss/1.0/modules/content/"
   xmlns:creativeCommons="http://backend.userland.com/creativeCommonsRssModule">
<channel>
    <title>freebsd.munk.me.uk</title>
    <link>http://freebsd.munk.me.uk/</link>
    <description>FreeBSD System Administration</description>
    <dc:language>en</dc:language>
    <generator>Serendipity 1.5.2 - http://www.s9y.org/</generator>
    
    <image>
        <url>http://freebsd.munk.me.uk/templates/default/img/s9y_banner_small.png</url>
        <title>RSS: freebsd.munk.me.uk - FreeBSD System Administration</title>
        <link>http://freebsd.munk.me.uk/</link>
        <width>100</width>
        <height>21</height>
    </image>

<item>
    <title>Command Line Web Browsing With WWW::Mechanize::Shell</title>
    <link>http://freebsd.munk.me.uk/archives/179-Command-Line-Web-Browsing-With-WWWMechanizeShell.html</link>
            <category>Perl</category>
            <category>Ports</category>
            <category>Shell</category>
    
    <comments>http://freebsd.munk.me.uk/archives/179-Command-Line-Web-Browsing-With-WWWMechanizeShell.html#comments</comments>
    <wfw:comment>http://freebsd.munk.me.uk/wfwcomment.php?cid=179</wfw:comment>

    <slash:comments>2</slash:comments>
    <wfw:commentRss>http://freebsd.munk.me.uk/rss.php?version=2.0&amp;type=comments&amp;cid=179</wfw:commentRss>
    

    <author>nospam@example.com (munk)</author>
    <content:encoded>
    &lt;span style=&quot;font-weight:bold&quot;&gt;Introduction&lt;/span&gt;&lt;br /&gt;
The perl module &lt;a href=&quot;http://search.cpan.org/~corion/WWW-Mechanize-Shell/&quot;  title=&quot;WWW::Mechanize::Shell On CPAN&quot;&gt;WWW::Mechanize::Shell&lt;/a&gt; is a brilliant tool for browsing websites at a very low level - think somewhere in between using telnet and using a command line based browser like lynx or links or w3m and you&#039;ll be close.  WWW::Mechanize::Shell is more than that though, it allows you to script a complete HTTP session so it can be replayed back at a later date without any interaction using WWW::Mechanize::Shell&#039;s parent perl module WWW::Mechanize - great for automatically submitting HTML forms/ POST data regularly via a cron job for example.&lt;br /&gt;
&lt;br /&gt;
In this article I&#039;ll be talking about installing WWW::Mechanize::Shell, look at a typical WWW::Mechanize::Shell browsing session and look at some examples of how I use WWW::Mechanize::Shell to make things easier.  Finally the article will end with a real world example - using mechshell to automate logging into FreshPorts and updating a watch list.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;span style=&quot;font-weight:bold&quot;&gt;Installing WWW::Mechanize::Shell&lt;/span&gt;&lt;br /&gt;
As the name suggests, WWW::Mechanize::Shell is a perl module whose &#039;parent&#039; is the &lt;a href=&quot;http://search.cpan.org/~petdance/WWW-Mechanize/&quot;  title=&quot;WWW::Mechanize at CPAN&quot;&gt;WWW::Mechanize&lt;/a&gt; module written by Andy Lester (WWW::Mechanize::Shell itself is written by Max Maischein at time of original writing).  WWW::Mechanize does all the work in the background - WWW::Mechanize::Shell just makes it easy to interact in a HTTP session.  WWW::Mechanize::Shell and all it&#039;s dependencies can be installed from the ports tree:&lt;br /&gt;
&lt;br /&gt;
&lt;div class=&quot;bb-code-title&quot;&gt;CODE:&lt;/div&gt;&lt;div class=&quot;bb-code&quot;&gt;root@users&amp;#160;/root#&amp;#160;cd&amp;#160;/usr/ports/www/p5-WWW-Mechanize-Shell/&lt;br /&gt;
root@users&amp;#160;/home/munk/ports/www/p5-WWW-Mechanize-Shell#&amp;#160;make&amp;#160;install&lt;br /&gt;
root@users&amp;#160;/home/munk/ports/www/p5-WWW-Mechanize-Shell#&amp;#160;rehash&lt;/div&gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;span style=&quot;font-weight:bold&quot;&gt;Getting Started Using WWW::Mechanize::Shell&lt;/span&gt;&lt;br /&gt;
Once installed, start up the WWW::Mechanize::Shell using the following you can use the following commandline:&lt;br /&gt;
&lt;br /&gt;
&lt;div class=&quot;bb-code-title&quot;&gt;CODE:&lt;/div&gt;&lt;div class=&quot;bb-code&quot;&gt;root@users&amp;#160;/root#&amp;#160;perl&amp;#160;-MWWW&amp;#58;&amp;#58;Mechanize&amp;#58;&amp;#58;Shell&amp;#160;-eshell&lt;/div&gt;&lt;br /&gt;
&lt;br /&gt;
To make things easier though I use a CSH shell alias which aliases &#039;mechshell&#039; to the command above:&lt;br /&gt;
&lt;br /&gt;
&lt;div class=&quot;bb-code-title&quot;&gt;CODE:&lt;/div&gt;&lt;div class=&quot;bb-code&quot;&gt;root@users&amp;#160;/root#&amp;#160;grep&amp;#160;mechshell&amp;#160;$cshrc&lt;br /&gt;
alias&amp;#160;mechshell&amp;#160;perl&amp;#160;-MWWW&amp;#58;&amp;#58;Mechanize&amp;#58;&amp;#58;Shell&amp;#160;-eshell&lt;/div&gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;span style=&quot;font-weight:bold&quot;&gt;Examples of WWW::Mechanize Usage&lt;/span&gt;&lt;br /&gt;
I usually use WWW::Mechanize when I want to manipulate data from websites that require a stateful HTTP session - ie a browsing session where there&#039;s more than one URL you have to visit to complete the &#039;session&#039;.  Usually these kind of stateful sessions involve logging into the website first, then browsing to another page to obtain the data and then I have the WWW::Mechanize perl script handle the data and return any results on the commandline.&lt;br /&gt;
&lt;br /&gt;
Some examples of scripts that I&#039;ve use WWW::Mechanize with:&lt;br /&gt;
&lt;br /&gt;
eclipse_flex_speed.pl&lt;br /&gt;
My ISP (Eclipse UK) used to allow you to &#039;flex&#039; your internet speed from 256k up to 2Mbps.  They ran an offer for a while where you could flex to the max for 3 months - unfortunately you could only flex for 12 hours at a time, which meant logging into the control panel every 12hrs, selecting the maximum speed and then submitting the form.  PITA basically.&lt;br /&gt;
&lt;br /&gt;
Instead I wrote eclipse_flex_speed.pl to automatically login to the Eclipse control panel, &#039;click&#039; the 2Mbps radio button and then submit the form so my speed got flexed automagically.  I then added the script as a cron job to autorun every 12hours, saving the haslle of doing it all manually!&lt;br /&gt;
&lt;br /&gt;
aod_get.pl&lt;br /&gt;
The BBC website allows you to listen to streams of all BBC radio broadcasts for up to a week after they&#039;ve been aired live.  The problem is that the web interface you listen to the stream on in your web browser only allows you to skip 5 or 15 minutes ahead in time and doesn&#039;t allow you to go to specific times in the stream.  To get around this you can obtain the URL of the real player stream and open it in a standalone real player - doing this you can go to any point in the stream easily.  Trouble is finding the URL of the stream isn&#039;t that easy and involves viewing the source HTML of the web UI and copy/pasting a partial URL.&lt;br /&gt;
&lt;br /&gt;
I started to write a WWW::Mechanize script to automate the &#039;screen scraping&#039; of all the available feeds from the BBC Audio On Demand site and listing them on one single HTML page linking the name of the feed to the real player feed URL.  As it goes though, someone else - Dave Cross - already had the same idea and wrote &lt;a href=&quot;http://blog.dave.org.uk/archives/000652.html&quot;&gt;a great script for scraping the BBC feeds&lt;/a&gt; automatically.  I now run this in a cronjob once a week.&lt;br /&gt;
&lt;br /&gt;
torrentflux_ctl.pl&lt;br /&gt;
This is a script for starting and stopping all torrents under the control of the torrentflux web based bittorrent client.  The script logs in as the torrent owner and then stops or starts all the torrents for that user - basically just does a GET of a URL that causes torrentflux to stop or start all torrents.  Crude but effective.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;span style=&quot;font-weight:bold&quot;&gt;Real world example - Automating the update of FreshPorts watch list&lt;/span&gt;&lt;br /&gt;
Below is a real world example usage of WWW::Mechanize::Shell - automating the procedure of updating your watch list on &lt;a href=&quot;http://www.freshports.org/about.php&quot;  title=&quot;About FreshPorts&quot;&gt;Freshports.org&lt;/a&gt;.  I&#039;ve included comments as &#039;# this is a comment&#039; to help explain what each command is doing.&lt;br /&gt;
&lt;br /&gt;
&lt;div class=&quot;bb-code-title&quot;&gt;CODE:&lt;/div&gt;&lt;div class=&quot;bb-code&quot;&gt;#&amp;#160;Start&amp;#160;up&amp;#160;mechshell&amp;#160;-&amp;#160;alias&amp;#160;for&amp;#160;&#039;perl&amp;#160;-MWWW&amp;#58;&amp;#58;Mechanize&amp;#58;&amp;#58;Shell&amp;#160;-eshell&#039;&amp;#58;&lt;br /&gt;
munk@users&amp;#160;/home/munk#&amp;#160;mechshell&lt;br /&gt;
&lt;br /&gt;
#&amp;#160;Request&amp;#160;the&amp;#160;URL&amp;#160;http&amp;#58;//www.freshports.org/login.php.&lt;br /&gt;
#&amp;#160;Note&amp;#160;the&amp;#160;HTTP&amp;#160;response&amp;#160;&#039;&amp;#40;200&amp;#41;&#039;&amp;#160;is&amp;#160;displayed&amp;#160;underneath&lt;br /&gt;
#&amp;#160;to&amp;#160;indicate&amp;#160;the&amp;#160;page&amp;#160;was&amp;#160;fetched&amp;#160;successfully&amp;#58;&lt;br /&gt;
&amp;#40;no&amp;#160;url&amp;#41;&amp;#62;get&amp;#160;http&amp;#58;//www.freshports.org/login.php&lt;br /&gt;
Retrieving&amp;#160;http&amp;#58;//www.freshports.org/login.php&amp;#40;200&amp;#41;&lt;br /&gt;
&lt;br /&gt;
#&amp;#160;Use&amp;#160;the&amp;#160;mechshell&amp;#160;&#039;dump&#039;&amp;#160;command&amp;#160;to&amp;#160;dump&amp;#160;the&amp;#160;contents&lt;br /&gt;
#&amp;#160;of&amp;#160;all&amp;#160;forms&amp;#160;found&amp;#160;on&amp;#160;the&amp;#160;login&amp;#160;page&amp;#58;&lt;br /&gt;
http&amp;#58;//www.freshports.org/login.php&amp;#62;dump&lt;br /&gt;
POST&amp;#160;http&amp;#58;//www.freshports.org/login.php?origin=%2F&amp;#160;&amp;#91;l&amp;#93;&lt;br /&gt;
&amp;#160;&amp;#160;custom_settings=1&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#40;hidden&amp;#160;readonly&amp;#41;&lt;br /&gt;
&amp;#160;&amp;#160;LOGIN=1&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#40;hidden&amp;#160;readonly&amp;#41;&lt;br /&gt;
&amp;#160;&amp;#160;UserID=&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#40;text&amp;#41;&lt;br /&gt;
&amp;#160;&amp;#160;Password=&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#40;password&amp;#41;&lt;br /&gt;
&amp;#160;&amp;#160;submit=Login&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#40;submit&amp;#41;&lt;br /&gt;
&amp;#160;&amp;#160;&amp;#60;NONAME&amp;#62;=&amp;#60;UNDEF&amp;#62;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#40;reset&amp;#41;&lt;br /&gt;
&lt;br /&gt;
#&amp;#160;There&#039;s&amp;#160;just&amp;#160;a&amp;#160;single&amp;#160;form&amp;#160;on&amp;#160;this&amp;#160;page&amp;#58;&lt;br /&gt;
#&amp;#160;-&amp;#160;the&amp;#160;form&#039;s&amp;#160;&#039;ACTION&#039;&amp;#160;is&amp;#160;set&amp;#160;to&amp;#160;submit&amp;#160;the&amp;#160;form&amp;#160;using&amp;#160;the&amp;#160;POST&amp;#160;method&lt;br /&gt;
#&amp;#160;&amp;#160;&amp;#160;to&amp;#160;the&amp;#160;url&amp;#160;http&amp;#58;//www.freshports.org/login.php?origin=%2F&lt;br /&gt;
#&amp;#160;The&amp;#160;form&amp;#160;contains&amp;#160;the&amp;#160;following&amp;#160;form&amp;#160;fields&amp;#58;&lt;br /&gt;
#&amp;#160;-&amp;#160;2&amp;#160;hidden&amp;#160;fields&lt;br /&gt;
#&amp;#160;-&amp;#160;1&amp;#160;text&amp;#160;field&amp;#160;called&amp;#160;&#039;UserID&#039;&lt;br /&gt;
#&amp;#160;-&amp;#160;1&amp;#160;password&amp;#160;field&amp;#160;called&amp;#160;&#039;Password&#039;&lt;br /&gt;
#&amp;#160;-&amp;#160;1&amp;#160;submit&amp;#160;field&amp;#160;called&amp;#160;&#039;Login&#039;&lt;br /&gt;
&lt;br /&gt;
#&amp;#160;Fill&amp;#160;in&amp;#160;the&amp;#160;&#039;UserID&#039;&amp;#160;and&amp;#160;&#039;Password&#039;&amp;#160;fields&amp;#58;&lt;br /&gt;
http&amp;#58;//www.freshports.org/login.php&amp;#62;value&amp;#160;UserID&amp;#160;munk&lt;br /&gt;
http&amp;#58;//www.freshports.org/login.php&amp;#62;value&amp;#160;Password&amp;#160;xxxxxx&lt;br /&gt;
&lt;br /&gt;
#&amp;#160;And&amp;#160;then&amp;#160;submit&amp;#160;the&amp;#160;form.&amp;#160;&amp;#160;Note&amp;#160;we&amp;#160;can&amp;#160;just&amp;#160;use&amp;#160;the&amp;#160;mechshell&amp;#160;&#039;submit&#039;&lt;br /&gt;
#&amp;#160;command&amp;#160;here&amp;#160;because&amp;#160;there&amp;#160;is&amp;#160;only&amp;#160;a&amp;#160;single&amp;#160;form&amp;#160;on&amp;#160;the&amp;#160;page.&amp;#160;&amp;#160;If&amp;#160;there&amp;#160;were&lt;br /&gt;
#&amp;#160;more&amp;#160;than&amp;#160;one&amp;#160;form&amp;#160;on&amp;#160;the&amp;#160;page&amp;#160;we&amp;#160;would&amp;#160;need&amp;#160;to&amp;#160;specify&amp;#160;which&amp;#160;button&amp;#160;exactly&amp;#160;to&lt;br /&gt;
#&amp;#160;click&amp;#58;&lt;br /&gt;
http&amp;#58;//www.freshports.org/login.php&amp;#62;submit&lt;br /&gt;
200&lt;br /&gt;
&lt;br /&gt;
#&amp;#160;Again&amp;#160;note&amp;#160;that&amp;#160;the&amp;#160;&#039;200&#039;&amp;#160;response&amp;#160;indicates&amp;#160;the&amp;#160;request&amp;#160;was&amp;#160;successful.&lt;br /&gt;
#&amp;#160;Also&amp;#160;note&amp;#160;that&amp;#160;the&amp;#160;next&amp;#160;mechshell&amp;#160;prompt&amp;#160;below&amp;#160;has&amp;#160;changed&amp;#160;from&lt;br /&gt;
#&amp;#160;&#039;http&amp;#58;//www.freshports.org/login.php&amp;#62;&#039;&amp;#160;to&amp;#160;just&amp;#160;&#039;http&amp;#58;//www.freshports.org/&#039;&amp;#160;-&lt;br /&gt;
#&amp;#160;this&amp;#160;indicates&amp;#160;that&amp;#160;the&amp;#160;login&amp;#160;script&amp;#160;has&amp;#160;probably&amp;#160;redirected&amp;#160;us&amp;#160;to&amp;#160;the&lt;br /&gt;
#&amp;#160;freshports&amp;#160;home&amp;#160;page.&lt;br /&gt;
&lt;br /&gt;
#&amp;#160;Now&amp;#160;we&amp;#160;take&amp;#160;a&amp;#160;look&amp;#160;to&amp;#160;check&amp;#160;that&amp;#160;the&amp;#160;login&amp;#160;succeeded&amp;#160;ok.&amp;#160;&amp;#160;To&amp;#160;do&amp;#160;this&amp;#160;we&amp;#160;use&lt;br /&gt;
#&amp;#160;the&amp;#160;mechshell&amp;#160;&#039;content&#039;&amp;#160;command&amp;#160;which&amp;#160;effectively&amp;#160;dumps&amp;#160;the&amp;#160;content&amp;#160;of&amp;#160;the&lt;br /&gt;
#&amp;#160;returned&amp;#160;page&amp;#160;back&amp;#160;at&amp;#160;us&amp;#160;in&amp;#160;a&amp;#160;pager.&lt;br /&gt;
#&amp;#160;What&amp;#160;we&#039;re&amp;#160;looking&amp;#160;for&amp;#160;is&amp;#160;the&amp;#160;text&amp;#160;&#039;Logged&amp;#160;in&amp;#160;as&amp;#160;munk&#039;&amp;#160;which&amp;#160;will&amp;#160;indicate&amp;#160;we&lt;br /&gt;
#&amp;#160;logged&amp;#160;in&amp;#160;ok&amp;#58;&lt;br /&gt;
http&amp;#58;//www.freshports.org/&amp;#62;content&lt;br /&gt;
&amp;#60;!DOCTYPE&amp;#160;HTML&amp;#160;PUBLIC&amp;#160;&quot;-//W3C//DTD&amp;#160;HTML&amp;#160;4.01&amp;#160;Transitional//EN&quot;&amp;#62;&lt;br /&gt;
&amp;#60;HTML&amp;#62;&lt;br /&gt;
&amp;#60;HEAD&amp;#62;&lt;br /&gt;
-snip-&lt;br /&gt;
&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#60;td&amp;#160;NOWRAP&amp;#62;&amp;#60;FONT&amp;#160;SIZE=&quot;-1&quot;&amp;#62;Logged&amp;#160;in&amp;#160;as&amp;#160;munk&amp;#60;/FONT&amp;#62;&amp;#60;br&amp;#62;&amp;#60;FONT&amp;#160;SIZE=&quot;-1&quot;&amp;#62;&amp;#60;a&amp;#160;href=&quot;http://freebsd.munk.me.uk/customize.php?origin=%2F&quot;&amp;#160;title=&quot;Customize&amp;#160;your&amp;#160;settings&quot;&amp;#62;Customize&amp;#60;/a&lt;br /&gt;
&amp;#62;&amp;#60;/FONT&amp;#62;&amp;#60;br&amp;#62;&amp;#60;FONT&amp;#160;SIZE=&quot;-1&quot;&amp;#62;&amp;#60;a&amp;#160;href=&quot;http://freebsd.munk.me.uk/logout.php&quot;&amp;#160;title=&quot;Logout&amp;#160;of&amp;#160;the&amp;#160;website&quot;&amp;#62;Logout&amp;#60;/a&amp;#62;&amp;#60;/FONT&amp;#62;&amp;#60;br&amp;#62;&amp;#60;FONT&amp;#160;SIZE=&quot;-1&quot;&amp;#62;&amp;#60;a&amp;#160;href=&quot;/my-flagged-commits.php&quot;&amp;#160;title=&quot;Li&lt;br /&gt;
st&amp;#160;of&amp;#160;commits&amp;#160;you&amp;#160;have&amp;#160;flagged&quot;&amp;#62;My&amp;#160;Flagged&amp;#160;Commits&amp;#60;/a&amp;#62;&amp;#60;/FONT&amp;#62;&amp;#60;br&amp;#62;&lt;br /&gt;
-snip-&lt;br /&gt;
&lt;br /&gt;
#&amp;#160;Now&amp;#160;we&#039;re&amp;#160;logged&amp;#160;in&amp;#160;ok&amp;#160;we&amp;#160;can&amp;#160;continue&amp;#160;to&amp;#160;upload&amp;#160;the&amp;#160;mypkg_info.txt&amp;#160;file&amp;#160;we&lt;br /&gt;
#&amp;#160;created&amp;#160;earlier.&lt;br /&gt;
&lt;br /&gt;
#&amp;#160;First&amp;#160;browse&amp;#160;to&amp;#160;the&amp;#160;pkg_upload.php&amp;#160;page&amp;#58;&lt;br /&gt;
http&amp;#58;//www.freshports.org/&amp;#62;get&amp;#160;http&amp;#58;//www.freshports.org/pkg_upload.php&lt;br /&gt;
Retrieving&amp;#160;http&amp;#58;//www.freshports.org/pkg_upload.php&amp;#40;200&amp;#41;&lt;br /&gt;
&lt;br /&gt;
#&amp;#160;Now&amp;#160;use&amp;#160;&#039;dump&#039;&amp;#160;to&amp;#160;see&amp;#160;a&amp;#160;list&amp;#160;of&amp;#160;form&amp;#160;fields&amp;#160;on&amp;#160;this&amp;#160;page.&lt;br /&gt;
#&amp;#160;Note&amp;#160;that&amp;#160;there&amp;#160;are&amp;#160;2&amp;#160;submit&amp;#160;buttons&amp;#160;on&amp;#160;this&amp;#160;page&amp;#58;&lt;br /&gt;
http&amp;#58;//www.freshports.org/pkg_upload.php&amp;#62;dump&lt;br /&gt;
POST&amp;#160;http&amp;#58;//www.freshports.org/pkg_upload.php&amp;#160;&amp;#40;multipart/form-data&amp;#41;&lt;br /&gt;
&amp;#160;&amp;#160;pkg_info=&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#40;file&amp;#41;&lt;br /&gt;
&amp;#160;&amp;#160;staging=Staging&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#40;submit&amp;#41;&lt;br /&gt;
&amp;#160;&amp;#160;wlid=5393&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#40;option&amp;#41;&amp;#160;&amp;#160;&amp;#160;&amp;#91;&amp;#42;5393/main&amp;#42;&amp;#93;&lt;br /&gt;
&amp;#160;&amp;#160;replaceappend=replace&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#40;radio&amp;#41;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#91;&amp;#42;replace/Replace&amp;#160;list&amp;#160;contents|append/Append&amp;#160;to&amp;#160;list&amp;#160;&amp;#40;duplicates&amp;#160;will&amp;#160;be&amp;#160;removed&amp;#41;&amp;#93;&lt;br /&gt;
&amp;#160;&amp;#160;upload=Upload&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#40;submit&amp;#41;&lt;br /&gt;
&lt;br /&gt;
#&amp;#160;We&amp;#160;need&amp;#160;to&amp;#160;fill&amp;#160;out&amp;#160;the&amp;#160;form&amp;#160;here.&amp;#160;&amp;#160;Uploading&amp;#160;files&amp;#160;with&amp;#160;mechshell&amp;#160;is&amp;#160;as&lt;br /&gt;
#&amp;#160;simple&amp;#160;as&amp;#160;completing&amp;#160;the&amp;#160;correct&amp;#160;file&amp;#160;type&amp;#160;field&amp;#58;&lt;br /&gt;
http&amp;#58;//www.freshports.org/pkg_upload.php&amp;#62;value&amp;#160;pkg_info&amp;#160;/tmp/mypkg_info.txt&lt;br /&gt;
&lt;br /&gt;
#&amp;#160;Ok,&amp;#160;now&amp;#160;we&#039;re&amp;#160;ready&amp;#160;to&amp;#160;submit&amp;#160;the&amp;#160;form.&lt;br /&gt;
#&amp;#160;Note&amp;#160;that&amp;#160;because&amp;#160;there&amp;#160;are&amp;#160;2&amp;#160;submit&amp;#160;buttons&amp;#160;on&amp;#160;this&amp;#160;form,&amp;#160;we&amp;#160;must&amp;#160;explicitly&lt;br /&gt;
#&amp;#160;tell&amp;#160;mechshell&amp;#160;which&amp;#160;button&amp;#160;it&amp;#160;is&amp;#160;that&amp;#160;we&amp;#160;want&amp;#160;to&amp;#160;click&amp;#160;on&amp;#160;-&amp;#160;to&amp;#160;do&amp;#160;that&amp;#160;we&amp;#160;use&lt;br /&gt;
#&amp;#160;the&amp;#160;&#039;click&#039;&amp;#160;command.&amp;#160;&amp;#160;Just&amp;#160;using&amp;#160;&#039;submit&#039;&amp;#160;here&amp;#160;would&amp;#160;possibly&amp;#160;click&amp;#160;on&amp;#160;the&lt;br /&gt;
#&amp;#160;&#039;staging&#039;&amp;#160;button&amp;#160;which&amp;#160;is&amp;#160;not&amp;#160;what&amp;#160;we&amp;#160;want&amp;#160;-&amp;#160;instead&amp;#160;we&amp;#160;use&amp;#160;the&amp;#160;command&lt;br /&gt;
#&amp;#160;&#039;click&amp;#160;upload&#039;&amp;#160;to&amp;#160;indicate&amp;#160;we&amp;#160;want&amp;#160;to&amp;#160;click&amp;#160;on&amp;#160;the&amp;#160;&#039;upload&#039;&amp;#160;button&amp;#58;&lt;br /&gt;
http&amp;#58;//www.freshports.org/pkg_upload.php&amp;#62;click&amp;#160;upload&lt;br /&gt;
&amp;#40;200&amp;#41;&lt;br /&gt;
&lt;br /&gt;
#&amp;#160;Success!&amp;#160;&amp;#160;It&#039;s&amp;#160;a&amp;#160;good&amp;#160;idea&amp;#160;now&amp;#160;to&amp;#160;just&amp;#160;check&amp;#160;that&amp;#160;this&amp;#160;worked&amp;#160;by&amp;#160;browsing&amp;#160;in&lt;br /&gt;
#&amp;#160;a&amp;#160;web&amp;#160;browser&amp;#160;to&amp;#160;your&amp;#160;watch&amp;#160;list&amp;#160;and&amp;#160;checking&amp;#160;the&amp;#160;new&amp;#160;items&amp;#160;were&amp;#160;updated&amp;#160;ok&amp;#160;&amp;#40;of&lt;br /&gt;
#&amp;#160;course&amp;#160;you&amp;#160;can&amp;#160;do&amp;#160;this&amp;#160;in&amp;#160;mechshell&amp;#160;if&amp;#160;you&amp;#160;want&amp;#160;but&amp;#160;I&#039;ll&amp;#160;leave&amp;#160;that&amp;#160;out&amp;#160;here!&amp;#41;.&lt;br /&gt;
&lt;br /&gt;
#&amp;#160;Finally,&amp;#160;the&amp;#160;really&amp;#160;cool&amp;#160;bit.&amp;#160;&amp;#160;The&amp;#160;mechshell&amp;#160;&#039;script&#039;&amp;#160;command&amp;#160;will&amp;#160;dump&amp;#160;out&lt;br /&gt;
#&amp;#160;the&amp;#160;perl&amp;#160;code&amp;#160;required&amp;#160;to&amp;#160;perform&amp;#160;all&amp;#160;of&amp;#160;the&amp;#160;above&amp;#160;actions&amp;#160;again&amp;#160;if&amp;#160;you&amp;#160;copy&lt;br /&gt;
#&amp;#160;them&amp;#160;into&amp;#160;a&amp;#160;perl&amp;#160;script&amp;#58;&lt;br /&gt;
http&amp;#58;//www.freshports.org/pkg_upload.php&amp;#62;script&lt;br /&gt;
#!perl&amp;#160;-w&lt;br /&gt;
use&amp;#160;strict;&lt;br /&gt;
use&amp;#160;WWW&amp;#58;&amp;#58;Mechanize;&lt;br /&gt;
use&amp;#160;WWW&amp;#58;&amp;#58;Mechanize&amp;#58;&amp;#58;FormFiller;&lt;br /&gt;
use&amp;#160;URI&amp;#58;&amp;#58;URL;&lt;br /&gt;
-snip-&lt;br /&gt;
&lt;br /&gt;
#&amp;#160;Also,&amp;#160;if&amp;#160;you&amp;#160;provide&amp;#160;a&amp;#160;filename&amp;#160;as&amp;#160;an&amp;#160;argument&amp;#160;to&amp;#160;the&amp;#160;&#039;script&#039;&amp;#160;command,&lt;br /&gt;
#&amp;#160;mechshell&amp;#160;will&amp;#160;dump&amp;#160;all&amp;#160;the&amp;#160;script&amp;#160;commands&amp;#160;to&amp;#160;that&amp;#160;filename&amp;#58;&lt;br /&gt;
http&amp;#58;//www.freshports.org/pkg_upload.php&amp;#62;script&amp;#160;/tmp/freshports_update.pl&lt;br /&gt;
&lt;br /&gt;
#&amp;#160;Finally,&amp;#160;use&amp;#160;&#039;quit&#039;&amp;#160;to&amp;#160;exit&amp;#160;the&amp;#160;mechshell&amp;#58;&lt;br /&gt;
http&amp;#58;//www.freshports.org/pkg_upload.php&amp;#62;quit&lt;br /&gt;
munk@users&amp;#160;/home/munk#&lt;/div&gt;&lt;br /&gt;
&lt;br /&gt;
Now all that remains is to open up /tmp/freshports_update.pl and tidy the script up so that it&#039;s more suitable for automated use via cron.  For example, any &#039;dump&#039; and &#039;content&#039; commands can be taken out - these would only cause problems anyway if run from a non-interactive shell as used by cron.&lt;br /&gt;
&lt;br /&gt;
We also need to add some code to have the script dump the contents of &#039;pkg_info -qoa&#039; to a temporary file prior to uploading.&lt;br /&gt;
&lt;br /&gt;
The completed &#039;quick and dirty&#039; hack looks like this then:&lt;br /&gt;
&lt;br /&gt;
&lt;div class=&quot;bb-code-title&quot;&gt;CODE:&lt;/div&gt;&lt;div class=&quot;bb-code&quot;&gt;#!/usr/bin/perl&amp;#160;-w&lt;br /&gt;
use&amp;#160;strict;&lt;br /&gt;
use&amp;#160;WWW&amp;#58;&amp;#58;Mechanize;&lt;br /&gt;
use&amp;#160;WWW&amp;#58;&amp;#58;Mechanize&amp;#58;&amp;#58;FormFiller;&lt;br /&gt;
use&amp;#160;URI&amp;#58;&amp;#58;URL;&lt;br /&gt;
&lt;br /&gt;
#&amp;#160;FreshPorts&amp;#160;username/pass&amp;#58;&lt;br /&gt;
my&amp;#160;$user=&quot;munk&quot;;&lt;br /&gt;
my&amp;#160;$pass=&quot;xxxxx&quot;;&lt;br /&gt;
&lt;br /&gt;
#&amp;#160;Temp&amp;#160;location&amp;#160;to&amp;#160;store&amp;#160;output&amp;#160;from&amp;#160;&#039;pkg_info&amp;#160;-qoa&#039;&amp;#58;&lt;br /&gt;
my&amp;#160;$mypkg_info=&quot;/tmp/freshports/mypkg_info.txt&quot;;&lt;br /&gt;
&lt;br /&gt;
#&amp;#160;prepare&amp;#160;file&amp;#160;containing&amp;#160;output&amp;#160;from&amp;#58;&amp;#160;pkg_info&amp;#160;-qoa&lt;br /&gt;
`pkg_info&amp;#160;-qoa&amp;#160;&amp;#62;&amp;#160;$mypkg_info`;&lt;br /&gt;
&lt;br /&gt;
#&amp;#160;Prepare&amp;#160;WWW&amp;#58;&amp;#58;Mechanize&amp;#58;&lt;br /&gt;
my&amp;#160;$agent&amp;#160;=&amp;#160;WWW&amp;#58;&amp;#58;Mechanize-&amp;#62;new&amp;#40;&amp;#160;autocheck&amp;#160;=&amp;#62;&amp;#160;1&amp;#160;&amp;#41;;&lt;br /&gt;
my&amp;#160;$formfiller&amp;#160;=&amp;#160;WWW&amp;#58;&amp;#58;Mechanize&amp;#58;&amp;#58;FormFiller-&amp;#62;new&amp;#40;&amp;#41;;&lt;br /&gt;
$agent-&amp;#62;env_proxy&amp;#40;&amp;#41;;&lt;br /&gt;
&lt;br /&gt;
#&amp;#160;Login&amp;#160;to&amp;#160;FreshPorts&amp;#58;&lt;br /&gt;
$agent-&amp;#62;get&amp;#40;&#039;http&amp;#58;//www.freshports.org/login.php&#039;&amp;#41;;&lt;br /&gt;
$agent-&amp;#62;form_number&amp;#40;1&amp;#41;&amp;#160;if&amp;#160;$agent-&amp;#62;forms&amp;#160;and&amp;#160;scalar&amp;#160;@{$agent-&amp;#62;forms};&lt;br /&gt;
{&amp;#160;local&amp;#160;$^W;&amp;#160;$agent-&amp;#62;current_form-&amp;#62;value&amp;#40;&#039;UserID&#039;,&amp;#160;$user&amp;#41;;&amp;#160;};&lt;br /&gt;
{&amp;#160;local&amp;#160;$^W;&amp;#160;$agent-&amp;#62;current_form-&amp;#62;value&amp;#40;&#039;Password&#039;,&amp;#160;$pass&amp;#41;;&amp;#160;};&lt;br /&gt;
$agent-&amp;#62;submit&amp;#40;&amp;#41;;&lt;br /&gt;
&lt;br /&gt;
#&amp;#160;Submit&amp;#160;pkg_info&amp;#160;details&amp;#160;to&amp;#160;FreshPorts&amp;#160;pkg_upload&amp;#160;page&amp;#58;&lt;br /&gt;
$agent-&amp;#62;get&amp;#40;&#039;http&amp;#58;//www.freshports.org/pkg_upload.php&#039;&amp;#41;;&lt;br /&gt;
$agent-&amp;#62;form_number&amp;#40;1&amp;#41;&amp;#160;if&amp;#160;$agent-&amp;#62;forms&amp;#160;and&amp;#160;scalar&amp;#160;@{$agent-&amp;#62;forms};&lt;br /&gt;
{&amp;#160;local&amp;#160;$^W;&amp;#160;$agent-&amp;#62;current_form-&amp;#62;value&amp;#40;&#039;pkg_info&#039;,&amp;#160;$mypkg_info&amp;#41;;&amp;#160;};&lt;br /&gt;
$agent-&amp;#62;click&amp;#40;&#039;upload&#039;&amp;#41;;&lt;br /&gt;
&lt;br /&gt;
#&amp;#160;Remove&amp;#160;temporary&amp;#160;file&amp;#58;&lt;br /&gt;
`rm&amp;#160;$mypkg_info`;&lt;/div&gt;&lt;br /&gt;
&lt;br /&gt;
After saving the script and making the file executable, an entry can then be added to cron to have the script auto update the list of ports at freshports once a week - or however often you require it to be updated, once a week is more than enough for me.  Sorted! :) 
    </content:encoded>

    <pubDate>Wed, 15 Aug 2007 12:46:00 +0000</pubDate>
    <guid isPermaLink="false">http://freebsd.munk.me.uk/archives/179-guid.html</guid>
    <creativeCommons:license>http://creativecommons.org/licenses/by/2.5/</creativeCommons:license>
</item>
<item>
    <title>Migrating server to new hdd</title>
    <link>http://freebsd.munk.me.uk/archives/217-Migrating-server-to-new-hdd.html</link>
            <category>General</category>
    
    <comments>http://freebsd.munk.me.uk/archives/217-Migrating-server-to-new-hdd.html#comments</comments>
    <wfw:comment>http://freebsd.munk.me.uk/wfwcomment.php?cid=217</wfw:comment>

    <slash:comments>0</slash:comments>
    <wfw:commentRss>http://freebsd.munk.me.uk/rss.php?version=2.0&amp;type=comments&amp;cid=217</wfw:commentRss>
    

    <author>nospam@example.com (munk)</author>
    <content:encoded>
    Never know quite how to describe this &#039;migration&#039; - it&#039;s the same old bits in the machine but I&#039;ve built a new installation of FreeBSD onto a new HDD and am now putting this new &#039;server&#039; (hdd!) into the old machine!  Sounds pretty weak/easy maybe but it&#039;s taken me almost a month to get this done what with migrating various bits and bobs and tidying up crap along the way - together with a heavy dose of procrastination along with it all.  Just managed to whittle the MySQL dbs down to about 25% of what they used to be, so many dbs and users that haven&#039;t used anything since 2003 or so!&lt;br /&gt;
&lt;br /&gt;
Mind, not that it&#039;s active that much now, we&#039;re talking maybe a dozen users or so...&lt;br /&gt;
&lt;br /&gt;
Anyway, still got a lot to do, the server is just about running now with the new HDD, managed to get named up and running along with apache, exim and mysql with all the data more or less migrated over now.  There *will* be lots of problems with web services but that can wait for now, nothing that can&#039;t wait til tomorrow. 
    </content:encoded>

    <pubDate>Thu, 01 Feb 2007 00:56:28 +0000</pubDate>
    <guid isPermaLink="false">http://freebsd.munk.me.uk/archives/217-guid.html</guid>
    <creativeCommons:license>http://creativecommons.org/licenses/by/2.5/</creativeCommons:license>
</item>
<item>
    <title>Installing Exim, SASLAuthd, ClamAV and SpamAssassin on FreeBSD 6.2</title>
    <link>http://freebsd.munk.me.uk/archives/212-Installing-Exim,-SASLAuthd,-ClamAV-and-SpamAssassin-on-FreeBSD-6.2.html</link>
            <category>Email</category>
            <category>Ports</category>
            <category>Security</category>
            <category>Spam</category>
    
    <comments>http://freebsd.munk.me.uk/archives/212-Installing-Exim,-SASLAuthd,-ClamAV-and-SpamAssassin-on-FreeBSD-6.2.html#comments</comments>
    <wfw:comment>http://freebsd.munk.me.uk/wfwcomment.php?cid=212</wfw:comment>

    <slash:comments>13</slash:comments>
    <wfw:commentRss>http://freebsd.munk.me.uk/rss.php?version=2.0&amp;type=comments&amp;cid=212</wfw:commentRss>
    

    <author>nospam@example.com (munk)</author>
    <content:encoded>
    &lt;strong&gt;Introduction&lt;/strong&gt;&lt;br /&gt;
This article describes the steps necessary to install and configure Exim on FreeBSD 6.2 with support for the following:&lt;br /&gt;
&lt;br /&gt;
&lt;ul&gt;&lt;li/&gt;authenticated SMTP (asmtp) using SASLAuthd&lt;br /&gt;
&lt;li/&gt;spam detection and quarantine using SpamAssassin&lt;br /&gt;
&lt;li/&gt;malware detection and quarantine using ClamAV&lt;/ul&gt;&lt;br /&gt;
&lt;br /&gt;
Each of the required &#039;dependencies&#039; or components will be installed and configured, Exim will be installed and configured and finally we will test to check each component is working as required.&lt;br /&gt;
&lt;br /&gt;
With regards to spam and malware scanning, the system described will quarantine any files/messages that it finds classified as spam or malware.  In this way the quarantined files can be checked over by the admin at a later date and various stats gathering can be done if required.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;strong&gt;Installing and Configuring SASLAuthd&lt;/strong&gt;&lt;br /&gt;
SASLAuthd is an authentication daemon that can handle authentication requests from 3rd party applications such as Exim - generally for any application that can&#039;t directly access a system password database because of permission restrictions.  In this case running Exim MTA as &#039;root&#039; is a potential security risk, so exim runs as the &#039;mailnull&#039; user on FreeBSD.  Unfortunately this means Exim can&#039;t easily read the system password database to authenticate users who want to send mail via the server, which is where SASLAuthd comes in.  Any requests for authentication with Exim are passed on to the SASLAuthd daemon which will then verify whether the user credentials are valid - if so, the email is delivered, if not, it&#039;s rejected.&lt;br /&gt;
&lt;br /&gt;
&lt;ol&gt;&lt;li/&gt;Install SASLAuthd from the FreeBSD ports tree:&lt;br /&gt;
&lt;br /&gt;
&lt;div class=&quot;bb-code-title&quot;&gt;CODE:&lt;/div&gt;&lt;div class=&quot;bb-code&quot;&gt;root@win&amp;#160;/root#&amp;#160;cd&amp;#160;/usr/ports/security/cyrus-sasl2-saslauthd/&lt;br /&gt;
root@win&amp;#160;/usr/ports/security/cyrus-sasl2-saslauthd#&amp;#160;make&amp;#160;install&lt;br /&gt;
...&lt;br /&gt;
root@win&amp;#160;/usr/ports/security/cyrus-sasl2-saslauthd#&amp;#160;rehash&lt;/div&gt;&lt;br /&gt;
&lt;br /&gt;
&lt;li/&gt;Configure SASLAuthd to run at boot.&lt;br /&gt;
&lt;br /&gt;
Edit /etc/rc.conf to include the following:&lt;br /&gt;
&lt;br /&gt;
&lt;div class=&quot;bb-code-title&quot;&gt;CODE:&lt;/div&gt;&lt;div class=&quot;bb-code&quot;&gt;saslauthd_enable=&quot;YES&quot;&lt;br /&gt;
saslauthd_flags=&quot;-a&amp;#160;getpwent&quot;&lt;/div&gt;&lt;br /&gt;
&lt;br /&gt;
&lt;b&gt;Note:&lt;/b&gt;&lt;br /&gt;
SASLAuthd will run using the &#039;getpwent&#039; authentication mechanism with the flag above.  This method uses the passwd file directly instead of using other means like kerberos or PAM.  If you require another method, check the manpage for saslauthd.&lt;br /&gt;
&lt;br /&gt;
&lt;li/&gt;Start the SASLAuthd daemon running:&lt;br /&gt;
&lt;br /&gt;
&lt;div class=&quot;bb-code-title&quot;&gt;CODE:&lt;/div&gt;&lt;div class=&quot;bb-code&quot;&gt;root@win&amp;#160;/usr/ports/security/cyrus-sasl2-saslauthd#&amp;#160;cd&amp;#160;/usr/local/etc/rc.d&lt;br /&gt;
root@win&amp;#160;/usr/local/etc/rc.d#&amp;#160;./saslauthd&amp;#160;start&lt;/div&gt;&lt;br /&gt;
&lt;br /&gt;
&lt;li/&gt;(Optional) Test the SASLAuthd daemon:&lt;br /&gt;
&lt;br /&gt;
Substitute &#039;user&#039; and &#039;pass&#039; for the username and password of a user&lt;br /&gt;
account on your system:&lt;br /&gt;
&lt;br /&gt;
&lt;div class=&quot;bb-code-title&quot;&gt;CODE:&lt;/div&gt;&lt;div class=&quot;bb-code&quot;&gt;root@win&amp;#160;/usr/local/etc/rc.d#&amp;#160;testsaslauthd&amp;#160;-u&amp;#160;user&amp;#160;-p&amp;#160;pass&lt;br /&gt;
0&amp;#58;&amp;#160;OK&amp;#160;&quot;Success.&quot;&lt;/div&gt;&lt;br /&gt;
&lt;/ol&gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;strong&gt;Installing and Configuring SpamAssassin&lt;/strong&gt;&lt;br /&gt;
SpamAssassin (SA) is one solution to the problem of spam.  SA can run as a daemon (spamd) in the background and accept requests from an MTA such as Exim to check whether an email message should be classified as spam.&lt;br /&gt;
&lt;br /&gt;
Spamd looks at the message and checks for various factors that make the message more or less likely to be spam and assigns the message a score based on what it finds.  Spamd will then reply to the MTA, telling it the spam score that it gave that message.  The MTA can then decide - based on that score - whether to accept/reject the message - or in the case of this guide whether to instead quarantine the message.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;ol&gt;&lt;li/&gt;Install SA from the FreeBSD ports.&lt;br /&gt;
&lt;br /&gt;
&lt;b&gt;Note:&lt;/b&gt;&lt;br /&gt;
There are various installation options you can choose when installing SA which you should see when you first run &#039;make install&#039; in the SA port directory.  To see the options after already configuring them you can run &#039;make config&#039;.&lt;br /&gt;
&lt;br /&gt;
In turn, each of SA&#039;s dependencies may also have options you can configure at install time.&lt;br /&gt;
&lt;br /&gt;
To write this guide I&#039;m only using the single option &#039;AS_ROOT&#039; in the SA install configuation and for the other items  generally just choose the&lt;br /&gt;
defaults.&lt;br /&gt;
&lt;br /&gt;
&lt;div class=&quot;bb-code-title&quot;&gt;CODE:&lt;/div&gt;&lt;div class=&quot;bb-code&quot;&gt;root@win&amp;#160;/root#&amp;#160;cd&amp;#160;/usr/ports/mail/p5-Mail-SpamAssassin/&lt;br /&gt;
root@win&amp;#160;/usr/ports/mail/p5-Mail-SpamAssassin#&amp;#160;make&amp;#160;install&lt;/div&gt;&lt;br /&gt;
&lt;br /&gt;
Once complete, you should see:&lt;br /&gt;
&lt;br /&gt;
&lt;div class=&quot;bb-code-title&quot;&gt;CODE:&lt;/div&gt;&lt;div class=&quot;bb-code&quot;&gt;&amp;#42;&amp;#42;&amp;#42;&amp;#42;&amp;#42;&amp;#42;&amp;#42;&amp;#42;&amp;#42;&amp;#42;&amp;#42;&amp;#42;&amp;#42;&amp;#42;&amp;#42;&amp;#42;&amp;#42;&amp;#42;&amp;#42;&amp;#42;&amp;#42;&amp;#42;&amp;#42;&amp;#42;&amp;#42;&amp;#42;&amp;#42;&amp;#42;&amp;#42;&amp;#42;&amp;#42;&amp;#42;&amp;#42;&amp;#42;&amp;#42;&amp;#42;&amp;#42;&amp;#42;&amp;#42;&amp;#42;&amp;#42;&amp;#42;&amp;#42;&amp;#42;&amp;#42;&amp;#42;&amp;#42;&amp;#42;&amp;#42;&amp;#42;&amp;#42;&amp;#42;&amp;#42;&amp;#42;&amp;#42;&amp;#42;&amp;#42;&amp;#42;&amp;#42;&amp;#42;&amp;#42;&amp;#42;&amp;#42;&amp;#42;&amp;#42;&amp;#42;&amp;#42;&amp;#42;&amp;#42;&amp;#42;&amp;#42;&amp;#42;&amp;#42;&lt;br /&gt;
&amp;#42;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;_&amp;#160;&amp;#160;_____&amp;#160;_____&amp;#160;_____&amp;#160;_&amp;#160;&amp;#160;&amp;#160;_&amp;#160;_____&amp;#160;___&amp;#160;___&amp;#160;&amp;#160;_&amp;#160;&amp;#160;&amp;#160;_&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#42;&lt;br /&gt;
&amp;#42;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;/&amp;#160;\|_&amp;#160;&amp;#160;&amp;#160;_|_&amp;#160;&amp;#160;&amp;#160;_|&amp;#160;____|&amp;#160;\&amp;#160;|&amp;#160;|_&amp;#160;&amp;#160;&amp;#160;_|_&amp;#160;_/&amp;#160;_&amp;#160;\|&amp;#160;\&amp;#160;|&amp;#160;|&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#42;&lt;br /&gt;
&amp;#42;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;/&amp;#160;_&amp;#160;\&amp;#160;|&amp;#160;|&amp;#160;&amp;#160;&amp;#160;|&amp;#160;|&amp;#160;|&amp;#160;&amp;#160;_|&amp;#160;|&amp;#160;&amp;#160;\|&amp;#160;|&amp;#160;|&amp;#160;|&amp;#160;&amp;#160;|&amp;#160;|&amp;#160;|&amp;#160;|&amp;#160;|&amp;#160;&amp;#160;\|&amp;#160;|&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#42;&lt;br /&gt;
&amp;#42;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;/&amp;#160;___&amp;#160;\|&amp;#160;|&amp;#160;&amp;#160;&amp;#160;|&amp;#160;|&amp;#160;|&amp;#160;|___|&amp;#160;|\&amp;#160;&amp;#160;|&amp;#160;|&amp;#160;|&amp;#160;&amp;#160;|&amp;#160;|&amp;#160;|_|&amp;#160;|&amp;#160;|\&amp;#160;&amp;#160;|&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#42;&lt;br /&gt;
&amp;#42;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;/_/&amp;#160;&amp;#160;&amp;#160;\_\_|&amp;#160;&amp;#160;&amp;#160;|_|&amp;#160;|_____|_|&amp;#160;\_|&amp;#160;|_|&amp;#160;|___\___/|_|&amp;#160;\_|&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#42;&lt;br /&gt;
&amp;#42;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#42;&lt;br /&gt;
&amp;#42;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;See&amp;#160;/usr/local/share/doc/p5-Mail-SpamAssassin/INSTALL,&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#42;&lt;br /&gt;
&amp;#42;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;and&amp;#160;/usr/local/share/doc/p5-Mail-SpamAssassin/UPGRADE,&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#42;&lt;br /&gt;
&amp;#42;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;or&amp;#160;http&amp;#58;//spamassassin.org/dist/INSTALL&amp;#160;and&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#42;&lt;br /&gt;
&amp;#42;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;http&amp;#58;//spamassassin.org/dist/UPGRADE&amp;#160;BEFORE&amp;#160;enabling&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#42;&lt;br /&gt;
&amp;#42;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;this&amp;#160;version&amp;#160;of&amp;#160;SpamAssassin&amp;#160;for&amp;#160;important&amp;#160;information&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#42;&lt;br /&gt;
&amp;#42;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;regarding&amp;#160;changes&amp;#160;in&amp;#160;this&amp;#160;version.&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#42;&lt;br /&gt;
&amp;#42;&amp;#42;&amp;#42;&amp;#42;&amp;#42;&amp;#42;&amp;#42;&amp;#42;&amp;#42;&amp;#42;&amp;#42;&amp;#42;&amp;#42;&amp;#42;&amp;#42;&amp;#42;&amp;#42;&amp;#42;&amp;#42;&amp;#42;&amp;#42;&amp;#42;&amp;#42;&amp;#42;&amp;#42;&amp;#42;&amp;#42;&amp;#42;&amp;#42;&amp;#42;&amp;#42;&amp;#42;&amp;#42;&amp;#42;&amp;#42;&amp;#42;&amp;#42;&amp;#42;&amp;#42;&amp;#42;&amp;#42;&amp;#42;&amp;#42;&amp;#42;&amp;#42;&amp;#42;&amp;#42;&amp;#42;&amp;#42;&amp;#42;&amp;#42;&amp;#42;&amp;#42;&amp;#42;&amp;#42;&amp;#42;&amp;#42;&amp;#42;&amp;#42;&amp;#42;&amp;#42;&amp;#42;&amp;#42;&amp;#42;&amp;#42;&amp;#42;&amp;#42;&amp;#42;&amp;#42;&amp;#42;&amp;#42;&amp;#42;&amp;#42;&lt;/div&gt;&lt;br /&gt;
&lt;br /&gt;
It&#039;s a good idea to read the files listed in the banner above.  SA has a large number of options that can be configured; a good place to start configuring options on FreeBSD is in /usr/local/etc/mail/spamassassin/.&lt;br /&gt;
&lt;br /&gt;
&lt;li/&gt;Configure SA to run at boot.&lt;br /&gt;
&lt;br /&gt;
Edit /etc/rc.conf to include the following:&lt;br /&gt;
&lt;br /&gt;
&lt;div class=&quot;bb-code-title&quot;&gt;CODE:&lt;/div&gt;&lt;div class=&quot;bb-code&quot;&gt;spamd_enable=&quot;YES&quot;&lt;/div&gt;&lt;br /&gt;
&lt;br /&gt;
&lt;li/&gt;Start SA spamd.&lt;br /&gt;
&lt;br /&gt;
We can now go on to actually start spamd running as a daemon and verify spamd started ok:&lt;br /&gt;
&lt;br /&gt;
&lt;div class=&quot;bb-code-title&quot;&gt;CODE:&lt;/div&gt;&lt;div class=&quot;bb-code&quot;&gt;root@win&amp;#160;/root#&amp;#160;cd&amp;#160;/usr/local/etc/rc.d&lt;br /&gt;
root@win&amp;#160;/usr/local/etc/rc.d#&amp;#160;rehash&lt;br /&gt;
root@win&amp;#160;/usr/local/etc/rc.d#&amp;#160;./sa&lt;br /&gt;
sa-spamd&amp;#42;&amp;#160;&amp;#160;&amp;#160;saslauthd&amp;#42;&lt;br /&gt;
root@win&amp;#160;/usr/local/etc/rc.d#&amp;#160;./sa-spamd&amp;#160;start&lt;br /&gt;
Starting&amp;#160;spamd.&lt;br /&gt;
munk@win&amp;#160;/usr/local/etc/rc.d#&amp;#160;./sa-spamd&amp;#160;status&lt;br /&gt;
spamd&amp;#160;is&amp;#160;running&amp;#160;as&amp;#160;pid&amp;#160;754.&lt;/div&gt;&lt;br /&gt;
&lt;br /&gt;
This tells us spamd is running ok in the background.&lt;br /&gt;
&lt;/ol&gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;strong&gt;Installing and Configuring ClamAV&lt;/strong&gt;&lt;br /&gt;
ClamAV is an anti-virus suite and includes a daemon clamd (runs in the background to check for requests to test for virii), another daemon freshclam (updates the virus definition database) and a couple of clients to run on the commandline if you need them for local virus scanning.&lt;br /&gt;
&lt;br /&gt;
Exim will send requests to the clamd server in much the same was as spamd does - if clamd classifies a message as containing a virus, Exim will reject delivery of the message and instaed quarantine it.&lt;br /&gt;
&lt;br /&gt;
&lt;ol&gt;&lt;li/&gt;Install ClamAV from the FreeBSD ports tree:&lt;br /&gt;
&lt;br /&gt;
&lt;div class=&quot;bb-code-title&quot;&gt;CODE:&lt;/div&gt;&lt;div class=&quot;bb-code&quot;&gt;root@win&amp;#160;/root#&amp;#160;cd&amp;#160;/usr/ports/security/clamav&lt;br /&gt;
root@win&amp;#160;/usr/ports/security/clamav#&amp;#160;make&amp;#160;install&lt;/div&gt;&lt;br /&gt;
&lt;br /&gt;
&lt;li/&gt;Configure ClamAV to start at boot time.&lt;br /&gt;
&lt;br /&gt;
Edit /etc/rc.conf to include:&lt;br /&gt;
&lt;br /&gt;
&lt;div class=&quot;bb-code-title&quot;&gt;CODE:&lt;/div&gt;&lt;div class=&quot;bb-code&quot;&gt;clamav_clamd_enable=&quot;YES&quot;&lt;br /&gt;
clamav_freshclam_enable=&quot;YES&quot;&lt;/div&gt;&lt;br /&gt;
&lt;br /&gt;
&lt;li/&gt;Configure clamd.&lt;br /&gt;
&lt;br /&gt;
Edit /usr/local/etc/clamd.conf to include the following:&lt;br /&gt;
&lt;br /&gt;
&lt;div class=&quot;bb-code-title&quot;&gt;CODE:&lt;/div&gt;&lt;div class=&quot;bb-code&quot;&gt;LogFile&amp;#160;/var/log/clamav/clamd.log&lt;br /&gt;
PidFile&amp;#160;/var/run/clamav/clamd.pid&lt;br /&gt;
DatabaseDirectory&amp;#160;/var/db/clamav&lt;br /&gt;
LocalSocket&amp;#160;/var/run/clamav/clamd&lt;br /&gt;
FixStaleSocket&lt;br /&gt;
User&amp;#160;clamav&lt;br /&gt;
AllowSupplementaryGroups&lt;br /&gt;
ScanMail&lt;br /&gt;
ScanArchive&lt;/div&gt;&lt;br /&gt;
&lt;br /&gt;
&lt;li/&gt;Start clamd and freshclam.&lt;br /&gt;
&lt;br /&gt;
&lt;div class=&quot;bb-code-title&quot;&gt;CODE:&lt;/div&gt;&lt;div class=&quot;bb-code&quot;&gt;root@win&amp;#160;/root#&amp;#160;cd&amp;#160;/usr/local/etc/rc.d&lt;br /&gt;
root@win&amp;#160;/usr/local/etc/rc.d#&amp;#160;./clamav-clamd&amp;#160;start&lt;br /&gt;
Starting&amp;#160;clamav_clamd.&lt;br /&gt;
root@win&amp;#160;/usr/local/etc/rc.d#&amp;#160;./clamav-freshclam&amp;#160;start&lt;br /&gt;
Starting&amp;#160;clamav_freshclam.&lt;/div&gt;&lt;br /&gt;
&lt;br /&gt;
&lt;strong&gt;Note:&lt;/strong&gt;&lt;br /&gt;
You may see the following message on first running clamd:&lt;br /&gt;
&lt;br /&gt;
&lt;div class=&quot;bb-code-title&quot;&gt;CODE:&lt;/div&gt;&lt;div class=&quot;bb-code&quot;&gt;LibClamAV&amp;#160;Warning&amp;#58;&amp;#160;&amp;#42;&amp;#42;&amp;#42;&amp;#42;&amp;#42;&amp;#42;&amp;#42;&amp;#42;&amp;#42;&amp;#42;&amp;#42;&amp;#42;&amp;#42;&amp;#42;&amp;#42;&amp;#42;&amp;#42;&amp;#42;&amp;#42;&amp;#42;&amp;#42;&amp;#42;&amp;#42;&amp;#42;&amp;#42;&amp;#42;&amp;#42;&amp;#42;&amp;#42;&amp;#42;&amp;#42;&amp;#42;&amp;#42;&amp;#42;&amp;#42;&amp;#42;&amp;#42;&amp;#42;&amp;#42;&amp;#42;&amp;#42;&amp;#42;&amp;#42;&amp;#42;&amp;#42;&amp;#42;&amp;#42;&amp;#42;&amp;#42;&amp;#42;&lt;br /&gt;
LibClamAV&amp;#160;Warning&amp;#58;&amp;#160;&amp;#42;&amp;#42;&amp;#42;&amp;#160;&amp;#160;The&amp;#160;virus&amp;#160;database&amp;#160;is&amp;#160;older&amp;#160;than&amp;#160;7&amp;#160;days.&amp;#160;&amp;#160;&amp;#42;&amp;#42;&amp;#42;&lt;br /&gt;
LibClamAV&amp;#160;Warning&amp;#58;&amp;#160;&amp;#42;&amp;#42;&amp;#42;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;Please&amp;#160;update&amp;#160;it&amp;#160;IMMEDIATELY!&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#42;&amp;#42;&amp;#42;&lt;br /&gt;
LibClamAV&amp;#160;Warning&amp;#58;&amp;#160;&amp;#42;&amp;#42;&amp;#42;&amp;#42;&amp;#42;&amp;#42;&amp;#42;&amp;#42;&amp;#42;&amp;#42;&amp;#42;&amp;#42;&amp;#42;&amp;#42;&amp;#42;&amp;#42;&amp;#42;&amp;#42;&amp;#42;&amp;#42;&amp;#42;&amp;#42;&amp;#42;&amp;#42;&amp;#42;&amp;#42;&amp;#42;&amp;#42;&amp;#42;&amp;#42;&amp;#42;&amp;#42;&amp;#42;&amp;#42;&amp;#42;&amp;#42;&amp;#42;&amp;#42;&amp;#42;&amp;#42;&amp;#42;&amp;#42;&amp;#42;&amp;#42;&amp;#42;&amp;#42;&amp;#42;&amp;#42;&amp;#42;&amp;#42;&lt;/div&gt;&lt;br /&gt;
&lt;br /&gt;
As long as you&#039;re running freshclam, you can safely ignore this message.  Freshclam should update your definitions automatically.  Be sure to configure freshclam to update the virus definitions regularly.&lt;br /&gt;
&lt;/ol&gt;&lt;br /&gt;
&lt;br /&gt;
ClamAV should be configured now and ready to accept request to check for malware from the Exim MTA.&lt;br /&gt;
&lt;br /&gt;
We can now move on finally to install and configure Exim.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;strong&gt;Installing and Configuring Exim&lt;/strong&gt;&lt;br /&gt;
Exim configuration can be very complicated.  This guide will only deal with the configuration of Exim so it accepts mail on a domain &#039;mail.example.com&#039;, scans the mail for malware/spam  - quarantining anything it finds as malware/spam and accepts authentication requests correctly.&lt;br /&gt;
&lt;br /&gt;
&lt;strong&gt;Important:&lt;/strong&gt;&lt;br /&gt;
Ensure your mail server&#039;s DNS is configured correctly and preferably has a reverse DNS record (rDNS) set up.  Many mail servers will not deliver mail correctly to/from your mail server without rDNS.&lt;br /&gt;
&lt;br /&gt;
&lt;ol&gt;&lt;li/&gt;Install Exim from the FreeBSD ports tree:&lt;br /&gt;
&lt;br /&gt;
&lt;div class=&quot;bb-code-title&quot;&gt;CODE:&lt;/div&gt;&lt;div class=&quot;bb-code&quot;&gt;&amp;#91;12&amp;#58;10&amp;#58;57&amp;#93;&amp;#160;root@win&amp;#160;/root#&amp;#160;cd&amp;#160;/usr/ports/mail/exim&lt;br /&gt;
&amp;#91;12&amp;#58;12&amp;#58;30&amp;#93;&amp;#160;root@win&amp;#160;/usr/ports/mail/exim#&amp;#160;&amp;#160;make&amp;#160;-DWITH_CONTENT_SCAN&amp;#160;-DWITH_SASLAUTHD&amp;#160;install&lt;/div&gt;&lt;br /&gt;
&lt;br /&gt;
&lt;li/&gt;Stop the Sendmail daemon if it&#039;s already running:&lt;br /&gt;
&lt;br /&gt;
&lt;div class=&quot;bb-code-title&quot;&gt;CODE:&lt;/div&gt;&lt;div class=&quot;bb-code&quot;&gt;root@win&amp;#160;/root#&amp;#160;cd&amp;#160;/etc/rc.d&lt;br /&gt;
root@win&amp;#160;/etc/rc.d#&amp;#160;./sendmail&amp;#160;stop&lt;/div&gt;&lt;br /&gt;
&lt;br /&gt;
&lt;li/&gt;Configure Exim to run at boot time.&lt;br /&gt;
&lt;br /&gt;
Edit /etc/rc.conf to include:&lt;br /&gt;
&lt;br /&gt;
&lt;div class=&quot;bb-code-title&quot;&gt;CODE:&lt;/div&gt;&lt;div class=&quot;bb-code&quot;&gt;sendmail_enable=&quot;NO&quot;&lt;br /&gt;
sendmail_submit_enable=&quot;NO&quot;&lt;br /&gt;
sendmail_outbound_enable=&quot;NO&quot;&lt;br /&gt;
sendmail_msp_queue_enable=&quot;NO&quot;&lt;br /&gt;
exim_enable=&quot;YES&quot;&lt;/div&gt;&lt;br /&gt;
&lt;br /&gt;
This has the effect of disabling sendmail at boot time - the default FreeBSD MTA - and running Exim instead.&lt;br /&gt;
&lt;br /&gt;
&lt;li/&gt;Configure mailer.conf to use Exim as the default MTA.&lt;br /&gt;
&lt;br /&gt;
Edit /etc/mail/mailer.conf to read:&lt;br /&gt;
&lt;br /&gt;
&lt;div class=&quot;bb-code-title&quot;&gt;CODE:&lt;/div&gt;&lt;div class=&quot;bb-code&quot;&gt;sendmail&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;/usr/local/sbin/exim&lt;br /&gt;
send-mail&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;/usr/local/sbin/exim&lt;br /&gt;
mailq&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;/usr/local/sbin/exim&amp;#160;-bp&lt;br /&gt;
newaliases&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;/usr/bin/true&lt;/div&gt;&lt;br /&gt;
&lt;br /&gt;
This will allow any FreeBSD base system mail related commands to use Exim instead of Sendmail.&lt;br /&gt;
&lt;/ol&gt;&lt;br /&gt;
&lt;br /&gt;
&lt;strong&gt;Configuring Exim&lt;/strong&gt;&lt;br /&gt;
We now move on to configuring Exim.&lt;br /&gt;
&lt;br /&gt;
&lt;ol&gt;&lt;li&gt;Set the primary hostname.&lt;br /&gt;
&lt;br /&gt;
Edit /usr/local/etc/exim/configure.&lt;br /&gt;
&lt;br /&gt;
Find and edit the &#039;primary_hostname&#039; line for your domain:&lt;br /&gt;
&lt;br /&gt;
&lt;div class=&quot;bb-code-title&quot;&gt;CODE:&lt;/div&gt;&lt;div class=&quot;bb-code&quot;&gt;primary_hostname&amp;#160;=&amp;#160;example.com&lt;/div&gt;&lt;br /&gt;
&lt;br /&gt;
This configures Exim to accept mail primarily for the &#039;example.com&#039; domain - ie foobar@example.com.&lt;br /&gt;
&lt;br /&gt;
&lt;li/&gt;Find and edit the following lines to read:&lt;br /&gt;
&lt;br /&gt;
&lt;div class=&quot;bb-code-title&quot;&gt;CODE:&lt;/div&gt;&lt;div class=&quot;bb-code&quot;&gt;av_scanner&amp;#160;=&amp;#160;clamd&amp;#58;/var/run/clamav/clamd&lt;br /&gt;
spamd_address&amp;#160;=&amp;#160;127.0.0.1&amp;#160;783&lt;/div&gt;&lt;br /&gt;
&lt;br /&gt;
&lt;li/&gt;Configure the malware and spam Access Control Lists (ACLs).&lt;br /&gt;
&lt;br /&gt;
&lt;strong&gt;How malware/spam checking works in this system:&lt;/strong&gt;&lt;br /&gt;
We add a check in the acl_check_data ACL for spam and malware.  Exim will request each email is checked for spam/malware by the relevant daemon - spamd for spam, clamd for malware.  If the message is classified as spam/malware by the relevant daemons, Exim will add a header to the message &#039;X-Quarantine-Me-Spam&#039; (similar for malware).&lt;br /&gt;
&lt;br /&gt;
Later on when it comes to actually delivering (termed &#039;routing&#039; in Exim terminology), we add two routers to test for the existence of the headers that are added in the acl_check_data ACL if a message is found to be spam/malware.  If the headers are found by the malware/spam routers, the message is not delivered but instead copied to a quarantine location on disk.&lt;br /&gt;
&lt;br /&gt;
This quarantine location can then be checked later by an admin to check if anything is amiss - ie regular non spam/malware mail that should really have been delivered.&lt;br /&gt;
&lt;br /&gt;
Once you&#039;re satisfied the configuration is working as it should - ie after a few months of operation - and not finding false positives, you can change the malware/spam acl checks to just deny instead of adding the quarantine headers.  Having said that, I still opt to just quarantine malware/spam and remove it at a later date.&lt;br /&gt;
&lt;br /&gt;
On to configuring the data ACL:&lt;br /&gt;
&lt;br /&gt;
Modify the acl_check_data ACL to read/include:&lt;br /&gt;
&lt;br /&gt;
&lt;div class=&quot;bb-code-title&quot;&gt;CODE:&lt;/div&gt;&lt;div class=&quot;bb-code&quot;&gt;acl_check_data&amp;#58;&lt;br /&gt;
&lt;br /&gt;
&amp;#160;&amp;#160;#&amp;#160;Deny&amp;#160;if&amp;#160;the&amp;#160;message&amp;#160;contains&amp;#160;a&amp;#160;virus.&amp;#160;Before&amp;#160;enabling&amp;#160;this&amp;#160;check,&amp;#160;you&lt;br /&gt;
&amp;#160;&amp;#160;#&amp;#160;must&amp;#160;install&amp;#160;a&amp;#160;virus&amp;#160;scanner&amp;#160;and&amp;#160;set&amp;#160;the&amp;#160;av_scanner&amp;#160;option&amp;#160;above.&lt;br /&gt;
&amp;#160;&amp;#160;#&lt;br /&gt;
&amp;#160;&amp;#160;#&amp;#160;defer_ok&amp;#160;-&amp;#160;pass&amp;#160;this&amp;#160;message&amp;#160;if&amp;#160;scanner&amp;#160;is&amp;#160;down&amp;#160;etc&amp;#58;&lt;br /&gt;
&amp;#160;&amp;#160;warn&amp;#160;&amp;#160;message&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;=&amp;#160;X-Quarantine-Me-Malware&amp;#58;&amp;#160;$malware_name&lt;br /&gt;
&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;log_message&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;=&amp;#160;malware&amp;#58;&amp;#160;$malware_name&lt;br /&gt;
&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;demime&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;=&amp;#160;&amp;#42;&lt;br /&gt;
&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;malware&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;=&amp;#160;&amp;#42;/defer_ok&lt;br /&gt;
&lt;br /&gt;
&amp;#160;&amp;#160;#&amp;#160;Add&amp;#160;headers&amp;#160;to&amp;#160;a&amp;#160;message&amp;#160;if&amp;#160;it&amp;#160;is&amp;#160;judged&amp;#160;to&amp;#160;be&amp;#160;spam.&amp;#160;Before&amp;#160;enabling&amp;#160;this,&lt;br /&gt;
&amp;#160;&amp;#160;#&amp;#160;you&amp;#160;must&amp;#160;install&amp;#160;SpamAssassin.&amp;#160;You&amp;#160;may&amp;#160;also&amp;#160;need&amp;#160;to&amp;#160;set&amp;#160;the&amp;#160;spamd_address&lt;br /&gt;
&amp;#160;&amp;#160;#&amp;#160;option&amp;#160;above.&lt;br /&gt;
&amp;#160;&amp;#160;#&lt;br /&gt;
&amp;#160;&amp;#160;warn&amp;#160;&amp;#160;&amp;#160;&amp;#160;message&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;=&amp;#160;X-Quarantine-Me-Spam&amp;#58;&amp;#160;SA&amp;#160;score&amp;#160;$spam_score\n\&lt;br /&gt;
&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;X-SA-Report&amp;#58;&amp;#160;$spam_report&lt;br /&gt;
&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;log_message&amp;#160;&amp;#160;&amp;#160;=&amp;#160;Spam&amp;#160;score&amp;#160;$spam_score&amp;#160;&amp;#62;&amp;#160;5&lt;br /&gt;
&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;spam&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;=&amp;#160;spamd/defer_ok&lt;br /&gt;
&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;condition&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;=&amp;#160;${if&amp;#160;&amp;#62;{$spam_score_int}{50}{1}{0}}&lt;br /&gt;
&lt;br /&gt;
&amp;#160;&amp;#160;#&amp;#160;Accept&amp;#160;the&amp;#160;message.&lt;br /&gt;
&lt;br /&gt;
&amp;#160;&amp;#160;accept&lt;/div&gt;&lt;br /&gt;
&lt;br /&gt;
&lt;strong&gt;At the top of the routers section&lt;/strong&gt;, modify to read/include:&lt;br /&gt;
&lt;br /&gt;
&lt;div class=&quot;bb-code-title&quot;&gt;CODE:&lt;/div&gt;&lt;div class=&quot;bb-code&quot;&gt;begin&amp;#160;routers&lt;br /&gt;
&lt;br /&gt;
check_malware&amp;#58;&lt;br /&gt;
&amp;#160;&amp;#160;driver&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;=&amp;#160;redirect&lt;br /&gt;
&amp;#160;&amp;#160;condition&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;=&amp;#160;${if&amp;#160;def&amp;#58;h_X-Quarantine-Me-Malware&amp;#58;&amp;#160;{1}{0}}&lt;br /&gt;
&amp;#160;&amp;#160;headers_add&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;=&amp;#160;X-Quarantined-Malware&amp;#58;&amp;#160;$h_X-Quarantine-Me-Malware&amp;#58;&lt;br /&gt;
&amp;#160;&amp;#160;headers_remove&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;=&amp;#160;X-Quarantine-Me-Malware&lt;br /&gt;
&amp;#160;&amp;#160;data&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;=&amp;#160;/var/quarantine/malware/malware.$tod_logfile&lt;br /&gt;
&amp;#160;&amp;#160;file_transport&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;=&amp;#160;address_file&lt;br /&gt;
&lt;br /&gt;
check_spam&amp;#58;&lt;br /&gt;
&amp;#160;&amp;#160;driver&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;=&amp;#160;redirect&lt;br /&gt;
&amp;#160;&amp;#160;condition&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;=&amp;#160;${if&amp;#160;def&amp;#58;h_X-Quarantine-Me-Spam&amp;#58;&amp;#160;{1}{0}}&lt;br /&gt;
&amp;#160;&amp;#160;headers_add&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;=&amp;#160;X-Quarantined-Spam&amp;#58;&amp;#160;$h_X-Quarantine-Me-Spam&amp;#58;&lt;br /&gt;
&amp;#160;&amp;#160;headers_remove&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;=&amp;#160;X-Quarantine-Me-Spam&lt;br /&gt;
&amp;#160;&amp;#160;data&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;=&amp;#160;/var/quarantine/spam/spam.$tod_logfile&lt;br /&gt;
&amp;#160;&amp;#160;file_transport&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;=&amp;#160;address_file&lt;br /&gt;
&lt;br /&gt;
	no_more&lt;/div&gt;&lt;br /&gt;
&lt;br /&gt;
Modify the authenticators section to read:&lt;br /&gt;
&lt;br /&gt;
&lt;div class=&quot;bb-code-title&quot;&gt;CODE:&lt;/div&gt;&lt;div class=&quot;bb-code&quot;&gt;begin&amp;#160;authenticators&lt;br /&gt;
plain&amp;#58;&lt;br /&gt;
	driver&amp;#160;=&amp;#160;plaintext&lt;br /&gt;
	public_name&amp;#160;=&amp;#160;PLAIN&lt;br /&gt;
	server_condition&amp;#160;=&amp;#160;${if&amp;#160;saslauthd{{$2}{$3}}{1}{0}}&lt;br /&gt;
&lt;br /&gt;
login&amp;#58;&lt;br /&gt;
	driver&amp;#160;=&amp;#160;plaintext&lt;br /&gt;
	public_name&amp;#160;=&amp;#160;LOGIN&lt;br /&gt;
	server_prompts&amp;#160;=&amp;#160;&quot;Username&amp;#58;&amp;#58;&amp;#160;&amp;#58;&amp;#160;Password&amp;#58;&amp;#58;&quot;&lt;br /&gt;
	server_condition&amp;#160;=&amp;#160;${if&amp;#160;saslauthd{{$1}{$2}}{1}{0}}&lt;/div&gt;&lt;br /&gt;
&lt;br /&gt;
&lt;strong&gt;Save the /usr/local/etc/exim/configuration file.&lt;/strong&gt;&lt;br /&gt;
&lt;br /&gt;
&lt;li/&gt;Create the quarantine directories and change ownership to mailnull:mail:&lt;br /&gt;
&lt;br /&gt;
&lt;div class=&quot;bb-code-title&quot;&gt;CODE:&lt;/div&gt;&lt;div class=&quot;bb-code&quot;&gt;root@win&amp;#160;/root#&amp;#160;mkdir&amp;#160;-p&amp;#160;/var/quarantine/{malware,spam}&lt;br /&gt;
root@win&amp;#160;/root#&amp;#160;chown&amp;#160;mailnull&amp;#58;mail&amp;#160;/var/quarantine/{malware,spam}&lt;/div&gt;&lt;br /&gt;
&lt;br /&gt;
&lt;li/&gt;Restart Exim to suck in the new config options:&lt;br /&gt;
&lt;br /&gt;
&lt;div class=&quot;bb-code-title&quot;&gt;CODE:&lt;/div&gt;&lt;div class=&quot;bb-code&quot;&gt;root@win&amp;#160;/root#&amp;#160;/usr/local/etc/rc.d/exim&amp;#160;restart&lt;br /&gt;
Stopping&amp;#160;exim.&lt;br /&gt;
Starting&amp;#160;exim.&lt;/div&gt;&lt;br /&gt;
&lt;/ol&gt;&lt;br /&gt;
&lt;br /&gt;
Exim should now be set to check for malware/spam and to authenticate users.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;strong&gt;Testing Exim configuration&lt;/strong&gt;&lt;br /&gt;
Finally we can move on to test that our config works correctly for spam/malware checking and for authenticating users.&lt;br /&gt;
&lt;br /&gt;
&lt;ol&gt;&lt;li/&gt;Testing Exim&#039;s malware/spam scanning.&lt;br /&gt;
&lt;br /&gt;
The easiest option is to send an email to your mailserver with specially crafted malware/spam signatures included in the body of the message.  When spamd/clamd see these signature strings in the body of the messages, they should classify the message as spam/malware and Exim in turn will quarantine the messages.&lt;br /&gt;
&lt;br /&gt;
The official EICAR malware/virus testing signature is as follows:&lt;br /&gt;
&lt;br /&gt;
&lt;div class=&quot;bb-code-title&quot;&gt;CODE:&lt;/div&gt;&lt;div class=&quot;bb-code&quot;&gt;X5O%@AP&amp;#91;4\PZX54&amp;#40;P^&amp;#41;7CC&amp;#41;7}$EICAR-STANDARD-ANTIVIRUS-TEST-FILEspamcH+H&amp;#42;&lt;/div&gt;&lt;br /&gt;
See here for the official string:&lt;br /&gt;
&lt;a href=&quot;http://www.eicar.org/anti_virus_test_file.htm&quot;  title=&quot;http://www.eicar.org/anti_virus_test_file.htm&quot;&gt;&lt;br /&gt;
http://www.eicar.org/anti_virus_test_file.htm&lt;/a&gt;&lt;br /&gt;
&lt;br /&gt;
The official GTUBE spam testing signature is as follows:&lt;br /&gt;
&lt;br /&gt;
&lt;div class=&quot;bb-code-title&quot;&gt;CODE:&lt;/div&gt;&lt;div class=&quot;bb-code&quot;&gt;XJS&amp;#42;C4JDBQADN1.NSBN3&amp;#42;2IDNEN&amp;#42;GTUBE-STANDARD-ANTI-UBE-TEST-EMAIL&amp;#42;C.34X&lt;/div&gt;&lt;br /&gt;
See here for the official string:&lt;br /&gt;
&lt;br /&gt;
&lt;a href=&quot;http://spamassassin.apache.org/gtube/&quot;  title=&quot;http://spamassassin.apache.org/gtube/&quot;&gt;http://spamassassin.apache.org/gtube/&lt;/a&gt;&lt;br /&gt;
&lt;br /&gt;
&lt;strong&gt;Note:&lt;/strong&gt;&lt;br /&gt;
Another option for testing spam/malware scanning is to run exim from the commandline using the command &#039;exim -bh 127.0.0.1&#039;.  This will run an SMTP session from the commandline (think telnet) and allow you to inject your own specially crafted message using the signatures above.  This requires you enter a valid SMTP session, something like:&lt;br /&gt;
&lt;br /&gt;
&lt;div class=&quot;bb-code-title&quot;&gt;CODE:&lt;/div&gt;&lt;div class=&quot;bb-code&quot;&gt;HELO&amp;#160;example.com&lt;br /&gt;
MAIL&amp;#160;FROM&amp;#58;foo@example.com&lt;br /&gt;
RCPT&amp;#160;TO&amp;#58;foo@example.com&lt;br /&gt;
DATA&lt;br /&gt;
X5O%@AP&amp;#91;4\PZX54&amp;#40;P^&amp;#41;7CC&amp;#41;7}$EICAR-STANDARD-ANTIVIRUS-TEST-FILEspamcH+H&amp;#42;&lt;br /&gt;
.&lt;/div&gt;&lt;br /&gt;
&lt;br /&gt;
This would simulate the injection of a mail message with a virus in it and in &#039;exim -bh&#039; mode you can see a lot of useful debugging info to verify everything works ok.&lt;br /&gt;
&lt;br /&gt;
&lt;li/&gt;Testing Exim&#039;s Authentication configuration.&lt;br /&gt;
&lt;br /&gt;
We can now test that ASMTP is working.  For this you can either run exim in one of it&#039;s many excellent debugging modes or you can simply configure a remote email client to use ASMTP.  This guide will use the commandline to test ASMTP.&lt;br /&gt;
&lt;br /&gt;
&lt;strong&gt;Important:&lt;/strong&gt;&lt;br /&gt;
Before attempting this method please read &lt;a href=&quot;http://www.exim.org/exim-html-4.10/doc/html/spec_32.html#IX1630&quot; target=&quot;_blank&quot;&gt;the exim documentation on how ASMTP works&lt;/a&gt;.  The following assumes you have read and understood that text.&lt;br /&gt;
&lt;br /&gt;
First create a simple perl script called &#039;encode&#039; in /usr/local/etc/exim/ and make sure it is executable:&lt;br /&gt;
&lt;br /&gt;
&lt;div class=&quot;bb-code-title&quot;&gt;CODE:&lt;/div&gt;&lt;div class=&quot;bb-code&quot;&gt;root@win&amp;#160;/usr/local/etc/exim#&amp;#160;cat&amp;#160;encode&lt;br /&gt;
#!/usr/bin/perl&lt;br /&gt;
use&amp;#160;MIME&amp;#58;&amp;#58;Base64;&lt;br /&gt;
printf&amp;#160;&amp;#40;&quot;%s&quot;,&amp;#160;encode_base64&amp;#40;eval&amp;#160;&quot;&quot;$ARGV&amp;#91;0&amp;#93;&quot;&quot;&amp;#41;&amp;#41;;&lt;br /&gt;
root@darkstar&amp;#160;/usr/local/etc/exim#&amp;#160;chmod&amp;#160;+x&amp;#160;encode&lt;br /&gt;
root@darkstar&amp;#160;/usr/local/etc/exim#&amp;#160;ls&amp;#160;-al&amp;#160;encode&lt;br /&gt;
-rwxr-xr-x&amp;#160;&amp;#160;1&amp;#160;root&amp;#160;&amp;#160;wheel&amp;#160;&amp;#160;85&amp;#160;Apr&amp;#160;23&amp;#160;12&amp;#58;25&amp;#160;encode&lt;/div&gt;&lt;br /&gt;
&lt;br /&gt;
Now decide which user account on your server you wish to test ASMTP with.  It must be an account you know the password for obviously.  I created an account called &#039;dummy&#039; and set the password to &#039;dummy&#039; as well - if you do this remember to remove the account or disable it as soon as you&#039;ve finished testing.&lt;br /&gt;
&lt;br /&gt;
Encode the user:password pair into base64 MIME using the &#039;encode&#039; script we created above:&lt;br /&gt;
&lt;br /&gt;
&lt;div class=&quot;bb-code-title&quot;&gt;CODE:&lt;/div&gt;&lt;div class=&quot;bb-code&quot;&gt;root@darkstar&amp;#160;/usr/local/etc/exim#&amp;#160;./encode&amp;#160;&quot;\0dummy\0dummy&quot;&lt;br /&gt;
AGR1bW15AGR1bW15&lt;/div&gt;&lt;br /&gt;
&lt;br /&gt;
Now enter into Exim&#039;s fake SMTP session command-line mode and just for good measure do it in authentication debug mode as well:&lt;br /&gt;
&lt;br /&gt;
&lt;div class=&quot;bb-code-title&quot;&gt;CODE:&lt;/div&gt;&lt;div class=&quot;bb-code&quot;&gt;root@win&amp;#160;/root#&amp;#160;&amp;#160;exim&amp;#160;-d+auth&amp;#160;-bh&amp;#160;127.0.0.1&lt;br /&gt;
Exim&amp;#160;version&amp;#160;4.66&amp;#160;&amp;#40;FreeBSD&amp;#160;6.1&amp;#41;&amp;#160;uid=0&amp;#160;gid=0&amp;#160;pid=3056&amp;#160;D=fbb95cfd&lt;br /&gt;
Probably&amp;#160;Berkeley&amp;#160;DB&amp;#160;version&amp;#160;1.8x&amp;#160;&amp;#40;native&amp;#160;mode&amp;#41;&lt;br /&gt;
Support&amp;#160;for&amp;#58;&amp;#160;crypteq&amp;#160;iconv&amp;#40;&amp;#41;&amp;#160;IPv6&amp;#160;use_setclassresources&amp;#160;PAM&amp;#160;Perl&amp;#160;OpenSSL&amp;#160;Content_Scanning&amp;#160;Old_Demime&lt;br /&gt;
Lookups&amp;#58;&amp;#160;lsearch&amp;#160;wildlsearch&amp;#160;nwildlsearch&amp;#160;iplsearch&amp;#160;cdb&amp;#160;dbm&amp;#160;dbmnz&amp;#160;dnsdb&amp;#160;dsearch&amp;#160;nis&amp;#160;nis0&amp;#160;passwd&lt;br /&gt;
Authenticators&amp;#58;&amp;#160;cram_md5&amp;#160;plaintext&amp;#160;spa&lt;br /&gt;
Routers&amp;#58;&amp;#160;accept&amp;#160;dnslookup&amp;#160;ipliteral&amp;#160;manualroute&amp;#160;queryprogram&amp;#160;redirect&lt;br /&gt;
Transports&amp;#58;&amp;#160;appendfile/maildir/mailstore/mbx&amp;#160;autoreply&amp;#160;lmtp&amp;#160;pipe&amp;#160;smtp&lt;br /&gt;
Fixed&amp;#160;never_users&amp;#58;&amp;#160;0&lt;br /&gt;
Size&amp;#160;of&amp;#160;off_t&amp;#58;&amp;#160;8&lt;br /&gt;
changed&amp;#160;uid/gid&amp;#58;&amp;#160;forcing&amp;#160;real&amp;#160;=&amp;#160;effective&lt;br /&gt;
&amp;#160;&amp;#160;uid=0&amp;#160;gid=0&amp;#160;pid=3056&lt;br /&gt;
&amp;#160;&amp;#160;auxiliary&amp;#160;group&amp;#160;list&amp;#58;&amp;#160;0&lt;br /&gt;
seeking&amp;#160;password&amp;#160;data&amp;#160;for&amp;#160;user&amp;#160;&quot;mailnull&quot;&amp;#58;&amp;#160;using&amp;#160;cached&amp;#160;result&lt;br /&gt;
getpwnam&amp;#40;&amp;#41;&amp;#160;succeeded&amp;#160;uid=26&amp;#160;gid=26&lt;br /&gt;
seeking&amp;#160;password&amp;#160;data&amp;#160;for&amp;#160;user&amp;#160;&quot;root&quot;&amp;#58;&amp;#160;cache&amp;#160;not&amp;#160;available&lt;br /&gt;
getpwnam&amp;#40;&amp;#41;&amp;#160;succeeded&amp;#160;uid=0&amp;#160;gid=0&lt;br /&gt;
configuration&amp;#160;file&amp;#160;is&amp;#160;/usr/local/etc/exim/configure&lt;br /&gt;
log&amp;#160;selectors&amp;#160;=&amp;#160;00000ffc&amp;#160;00089001&lt;br /&gt;
trusted&amp;#160;user&lt;br /&gt;
admin&amp;#160;user&lt;br /&gt;
changed&amp;#160;uid/gid&amp;#58;&amp;#160;privilege&amp;#160;not&amp;#160;needed&lt;br /&gt;
&amp;#160;&amp;#160;uid=26&amp;#160;gid=6&amp;#160;pid=3056&lt;br /&gt;
&amp;#160;&amp;#160;auxiliary&amp;#160;group&amp;#160;list&amp;#58;&amp;#160;6&amp;#160;6&lt;br /&gt;
seeking&amp;#160;password&amp;#160;data&amp;#160;for&amp;#160;user&amp;#160;&quot;mailnull&quot;&amp;#58;&amp;#160;cache&amp;#160;not&amp;#160;available&lt;br /&gt;
getpwnam&amp;#40;&amp;#41;&amp;#160;succeeded&amp;#160;uid=26&amp;#160;gid=26&lt;br /&gt;
originator&amp;#58;&amp;#160;uid=0&amp;#160;gid=0&amp;#160;login=root&amp;#160;name=Charlie&amp;#160;Root&lt;br /&gt;
sender&amp;#160;address&amp;#160;=&amp;#160;root@win.munk.me.uk&lt;br /&gt;
sender_fullhost&amp;#160;=&amp;#160;&amp;#91;127.0.0.1&amp;#93;&lt;br /&gt;
sender_rcvhost&amp;#160;=&amp;#160;&amp;#91;127.0.0.1&amp;#93;&lt;br /&gt;
&lt;br /&gt;
&amp;#42;&amp;#42;&amp;#42;&amp;#42;&amp;#160;SMTP&amp;#160;testing&amp;#160;session&amp;#160;as&amp;#160;if&amp;#160;from&amp;#160;host&amp;#160;127.0.0.1&lt;br /&gt;
&amp;#42;&amp;#42;&amp;#42;&amp;#42;&amp;#160;but&amp;#160;without&amp;#160;any&amp;#160;ident&amp;#160;&amp;#40;RFC&amp;#160;1413&amp;#41;&amp;#160;callback.&lt;br /&gt;
&amp;#42;&amp;#42;&amp;#42;&amp;#42;&amp;#160;This&amp;#160;is&amp;#160;not&amp;#160;for&amp;#160;real!&lt;br /&gt;
&lt;br /&gt;
host&amp;#160;in&amp;#160;hosts_connection_nolog?&amp;#160;no&amp;#160;&amp;#40;option&amp;#160;unset&amp;#41;&lt;br /&gt;
LOG&amp;#58;&amp;#160;smtp_connection&amp;#160;MAIN&lt;br /&gt;
&amp;#160;&amp;#160;SMTP&amp;#160;connection&amp;#160;from&amp;#160;&amp;#91;127.0.0.1&amp;#93;&lt;br /&gt;
host&amp;#160;in&amp;#160;host_lookup?&amp;#160;yes&amp;#160;&amp;#40;matched&amp;#160;&quot;&amp;#42;&quot;&amp;#41;&lt;br /&gt;
looking&amp;#160;up&amp;#160;host&amp;#160;name&amp;#160;for&amp;#160;127.0.0.1&lt;br /&gt;
DNS&amp;#160;lookup&amp;#160;of&amp;#160;1.0.0.127.in-addr.arpa&amp;#160;&amp;#40;PTR&amp;#41;&amp;#160;succeeded&lt;br /&gt;
IP&amp;#160;address&amp;#160;lookup&amp;#160;yielded&amp;#160;localhost.munk.me.uk&lt;br /&gt;
gethostbyname2&amp;#160;looked&amp;#160;up&amp;#160;these&amp;#160;IP&amp;#160;addresses&amp;#58;&lt;br /&gt;
&amp;#160;&amp;#160;name=localhost.munk.me.uk&amp;#160;address=&amp;#58;&amp;#58;1&lt;br /&gt;
&amp;#160;&amp;#160;name=localhost.munk.me.uk&amp;#160;address=127.0.0.1&lt;br /&gt;
checking&amp;#160;addresses&amp;#160;for&amp;#160;localhost.munk.me.uk&lt;br /&gt;
&amp;#160;&amp;#160;&amp;#58;&amp;#58;1&lt;br /&gt;
&amp;#160;&amp;#160;127.0.0.1&amp;#160;OK&lt;br /&gt;
sender_fullhost&amp;#160;=&amp;#160;localhost.munk.me.uk&amp;#160;&amp;#91;127.0.0.1&amp;#93;&lt;br /&gt;
sender_rcvhost&amp;#160;=&amp;#160;localhost.munk.me.uk&amp;#160;&amp;#40;&amp;#91;127.0.0.1&amp;#93;&amp;#41;&lt;br /&gt;
set_process_info&amp;#58;&amp;#160;&amp;#160;3056&amp;#160;handling&amp;#160;incoming&amp;#160;connection&amp;#160;from&amp;#160;localhost.munk.me.uk&amp;#160;&amp;#91;127.0.0.1&amp;#93;&lt;br /&gt;
host&amp;#160;in&amp;#160;host_reject_connection?&amp;#160;no&amp;#160;&amp;#40;option&amp;#160;unset&amp;#41;&lt;br /&gt;
host&amp;#160;in&amp;#160;sender_unqualified_hosts?&amp;#160;no&amp;#160;&amp;#40;option&amp;#160;unset&amp;#41;&lt;br /&gt;
host&amp;#160;in&amp;#160;recipient_unqualified_hosts?&amp;#160;no&amp;#160;&amp;#40;option&amp;#160;unset&amp;#41;&lt;br /&gt;
host&amp;#160;in&amp;#160;helo_verify_hosts?&amp;#160;no&amp;#160;&amp;#40;option&amp;#160;unset&amp;#41;&lt;br /&gt;
host&amp;#160;in&amp;#160;helo_try_verify_hosts?&amp;#160;no&amp;#160;&amp;#40;option&amp;#160;unset&amp;#41;&lt;br /&gt;
host&amp;#160;in&amp;#160;helo_accept_junk_hosts?&amp;#160;no&amp;#160;&amp;#40;option&amp;#160;unset&amp;#41;&lt;br /&gt;
SMTP&amp;#62;&amp;#62;&amp;#160;220&amp;#160;win.munk.me.uk&amp;#160;ESMTP&amp;#160;Exim&amp;#160;4.66&amp;#160;Wed,&amp;#160;17&amp;#160;Jan&amp;#160;2007&amp;#160;19&amp;#58;24&amp;#58;22&amp;#160;+0000&lt;br /&gt;
220&amp;#160;win.munk.me.uk&amp;#160;ESMTP&amp;#160;Exim&amp;#160;4.66&amp;#160;Wed,&amp;#160;17&amp;#160;Jan&amp;#160;2007&amp;#160;19&amp;#58;24&amp;#58;22&amp;#160;+0000&lt;br /&gt;
smtp_setup_msg&amp;#160;entered&lt;/div&gt;&lt;br /&gt;
&lt;br /&gt;
When you get to this point you are ready to start an SMTP &#039;conversation&#039; with Exim.  First introduce yourself to Exim using the SMTP &#039;EHLO localhost&#039; command:&lt;br /&gt;
&lt;br /&gt;
&lt;div class=&quot;bb-code-title&quot;&gt;CODE:&lt;/div&gt;&lt;div class=&quot;bb-code&quot;&gt;EHLO&amp;#160;localhost&lt;br /&gt;
SMTP&amp;#60;&amp;#60;&amp;#160;EHLO&amp;#160;localhost&lt;br /&gt;
sender_fullhost&amp;#160;=&amp;#160;localhost.munk.me.uk&amp;#160;&amp;#40;localhost&amp;#41;&amp;#160;&amp;#91;127.0.0.1&amp;#93;&lt;br /&gt;
sender_rcvhost&amp;#160;=&amp;#160;localhost.munk.me.uk&amp;#160;&amp;#40;&amp;#91;127.0.0.1&amp;#93;&amp;#160;helo=localhost&amp;#41;&lt;br /&gt;
set_process_info&amp;#58;&amp;#160;&amp;#160;3103&amp;#160;handling&amp;#160;incoming&amp;#160;connection&amp;#160;from&amp;#160;localhost.munk.me.uk&amp;#160;&amp;#40;localhost&amp;#41;&amp;#160;&amp;#91;127.0.0.1&amp;#93;&lt;br /&gt;
host&amp;#160;in&amp;#160;pipelining_advertise_hosts?&amp;#160;yes&amp;#160;&amp;#40;matched&amp;#160;&quot;&amp;#42;&quot;&amp;#41;&lt;br /&gt;
host&amp;#160;in&amp;#160;auth_advertise_hosts?&amp;#160;yes&amp;#160;&amp;#40;matched&amp;#160;&quot;&amp;#42;&quot;&amp;#41;&lt;br /&gt;
host&amp;#160;in&amp;#160;tls_advertise_hosts?&amp;#160;no&amp;#160;&amp;#40;option&amp;#160;unset&amp;#41;&lt;br /&gt;
250-win.munk.me.uk&amp;#160;Hello&amp;#160;localhost.munk.me.uk&amp;#160;&amp;#91;127.0.0.1&amp;#93;&lt;br /&gt;
250-SIZE&amp;#160;52428800&lt;br /&gt;
250-PIPELINING&lt;br /&gt;
250-AUTH&amp;#160;PLAIN&amp;#160;LOGIN&lt;br /&gt;
250&amp;#160;HELP&lt;br /&gt;
SMTP&amp;#62;&amp;#62;&amp;#160;250-win.munk.me.uk&amp;#160;Hello&amp;#160;localhost.munk.me.uk&amp;#160;&amp;#91;127.0.0.1&amp;#93;&lt;br /&gt;
250-SIZE&amp;#160;52428800&lt;br /&gt;
250-PIPELINING&lt;br /&gt;
250-AUTH&amp;#160;PLAIN&amp;#160;LOGIN&lt;br /&gt;
250&amp;#160;HELP&lt;/div&gt;&lt;br /&gt;
&lt;br /&gt;
In response to your &#039;EHLO localhost&#039; command, Exim returns more debug information but most importantly for us it also indicates what authentication options it offers in this line:&lt;br /&gt;
&lt;br /&gt;
&lt;div class=&quot;bb-code-title&quot;&gt;CODE:&lt;/div&gt;&lt;div class=&quot;bb-code&quot;&gt;250-AUTH&amp;#160;PLAIN&amp;#160;LOGIN&lt;/div&gt;&lt;br /&gt;
&lt;br /&gt;
This indicates that currently acceptable AUTH methods are PLAIN and LOGIN.&lt;br /&gt;
&lt;br /&gt;
We can then test the PLAIN login method using the &quot;\0dummy\0dummy&quot; user:password pair we encoded above:&lt;br /&gt;
&lt;br /&gt;
&lt;div class=&quot;bb-code-title&quot;&gt;CODE:&lt;/div&gt;&lt;div class=&quot;bb-code&quot;&gt;AUTH&amp;#160;PLAIN&amp;#160;AGR1bW15AGR1bW15&lt;br /&gt;
SMTP&amp;#60;&amp;#60;&amp;#160;AUTH&amp;#160;PLAIN&amp;#160;AGR1bW15AGR1bW15&lt;br /&gt;
Running&amp;#160;pwcheck&amp;#160;authentication&amp;#160;for&amp;#160;user&amp;#160;&quot;dummy&quot;&lt;br /&gt;
pwcheck&amp;#58;&amp;#160;success&amp;#160;&amp;#40;NULL&amp;#41;&lt;br /&gt;
plain&amp;#160;authenticator&amp;#58;&lt;br /&gt;
&amp;#160;&amp;#160;$1&amp;#160;=&lt;br /&gt;
&amp;#160;&amp;#160;$2&amp;#160;=&amp;#160;dummy&lt;br /&gt;
&amp;#160;&amp;#160;$3&amp;#160;=&amp;#160;dummy&lt;br /&gt;
expanded&amp;#160;string&amp;#58;&amp;#160;1&lt;br /&gt;
SMTP&amp;#62;&amp;#62;&amp;#160;235&amp;#160;Authentication&amp;#160;succeeded&lt;br /&gt;
235&amp;#160;Authentication&amp;#160;succeeded&lt;/div&gt;&lt;br /&gt;
&lt;br /&gt;
This indicates that authentication for &#039;dummy:dummy&#039; would succeed and mail would be relayed (pending further conditional checks by Exim).&lt;br /&gt;
&lt;/ol&gt;&lt;br /&gt;
&lt;br /&gt;
So we now have a working Exim with support for spam/malware checking and authentication over SMTP. 
    </content:encoded>

    <pubDate>Wed, 17 Jan 2007 20:19:00 +0000</pubDate>
    <guid isPermaLink="false">http://freebsd.munk.me.uk/archives/212-guid.html</guid>
    <creativeCommons:license>http://creativecommons.org/licenses/by/2.5/</creativeCommons:license>
</item>
<item>
    <title>Cursor Artifacts Using nv nVidia drivers on X</title>
    <link>http://freebsd.munk.me.uk/archives/213-Cursor-Artifacts-Using-nv-nVidia-drivers-on-X.html</link>
            <category>Hardware</category>
            <category>X Window System</category>
    
    <comments>http://freebsd.munk.me.uk/archives/213-Cursor-Artifacts-Using-nv-nVidia-drivers-on-X.html#comments</comments>
    <wfw:comment>http://freebsd.munk.me.uk/wfwcomment.php?cid=213</wfw:comment>

    <slash:comments>0</slash:comments>
    <wfw:commentRss>http://freebsd.munk.me.uk/rss.php?version=2.0&amp;type=comments&amp;cid=213</wfw:commentRss>
    

    <author>nospam@example.com (munk)</author>
    <content:encoded>
    Just come across an annoying problem whilst using a GeForce 6200 in X - in Firefox, scrolling around inside form fields or the URL bar with the arrow keys results in a number of cursor artifacts left behind making reading or editing anything in those areas impossible.  Switching focus away and then back to the Firefox window removes the artifacts, but this isn&#039;t very practical.&lt;br /&gt;
&lt;br /&gt;
After some digging around to confirm the bug is with the &#039;&lt;a href=&quot;http://wiki.x.org/wiki/nv&quot;  title=&quot;nVidia nv Xorg driver&quot;&gt;nv&lt;/a&gt;&#039; driver (the problem disappears when running with just the vesa driver), I scanned the &lt;a href=&quot;https://bugs.freedesktop.org/buglist.cgi?query_format=specific&amp;order=relevance+desc&amp;bug_status=__all__&amp;product=xorg&amp;content=nv&quot;  title=&quot;nv driver bugs&quot;&gt;bugs listed for the nv driver&lt;/a&gt; and thankfully found the &lt;a href=&quot;https://bugs.freedesktop.org/show_bug.cgi?id=8173&quot;  title=&quot;nv nvidia X Firefox cursor artifact bug&quot;&gt;bug listed already here&lt;/a&gt;.  &lt;br /&gt;
&lt;br /&gt;
The bug report also thankfully had a simple workaround to the problem - adding:&lt;br /&gt;
&lt;br /&gt;
&lt;div class=&quot;bb-code-title&quot;&gt;CODE:&lt;/div&gt;&lt;div class=&quot;bb-code&quot;&gt;Option&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&quot;XaaNoSolidFillRect&quot;&lt;/div&gt;&lt;br /&gt;
&lt;br /&gt;
in the card&#039;s device section.  No idea what the drawbacks are to using this option, searching for the term &quot;XaaNoSolidFillRect&quot; just comes up with a list of other nv bug reports citing the above as a solution.  From those results, the same problem is described in more detail also at this URL by another nv user with an ascii art representation of the problem (woot!):&lt;br /&gt;
&lt;br /&gt;
&lt;a href=&quot;http://lists.debian.org/debian-x/2006/01/msg00056.html&quot; &gt;http://lists.debian.org/debian-x/2006/01/msg00056.html&lt;/a&gt; 
    </content:encoded>

    <pubDate>Mon, 15 Jan 2007 12:26:28 +0000</pubDate>
    <guid isPermaLink="false">http://freebsd.munk.me.uk/archives/213-guid.html</guid>
    <creativeCommons:license>http://creativecommons.org/licenses/by/2.5/</creativeCommons:license>
</item>
<item>
    <title>FreeBSD installation problems with Maxtor DiamondMax 10 250 Gb HDD 6L250R0</title>
    <link>http://freebsd.munk.me.uk/archives/211-FreeBSD-installation-problems-with-Maxtor-DiamondMax-10-250-Gb-HDD-6L250R0.html</link>
            <category>Hardware</category>
    
    <comments>http://freebsd.munk.me.uk/archives/211-FreeBSD-installation-problems-with-Maxtor-DiamondMax-10-250-Gb-HDD-6L250R0.html#comments</comments>
    <wfw:comment>http://freebsd.munk.me.uk/wfwcomment.php?cid=211</wfw:comment>

    <slash:comments>2</slash:comments>
    <wfw:commentRss>http://freebsd.munk.me.uk/rss.php?version=2.0&amp;type=comments&amp;cid=211</wfw:commentRss>
    

    <author>nospam@example.com (munk)</author>
    <content:encoded>
    As I mentioned in another post, I recently got a new Maxtor DiamondMax 10 250Gb HDD - model is 6L250R0 - and decided to install FreeBSD 6.1 on it.  I downloaded and burnt a copy of the distribution to disc, booted from the installer OK and everything went well until it got to the installation commit part where I received a number of errors like this:&lt;br /&gt;
&lt;br /&gt;
&lt;div class=&quot;bb-code-title&quot;&gt;CODE:&lt;/div&gt;&lt;div class=&quot;bb-code&quot;&gt;ad0&amp;#58;&amp;#160;WARNING&amp;#160;-&amp;#160;READ_DMA&amp;#160;UDMA&amp;#160;ICRC&amp;#160;error&amp;#160;&amp;#40;retrying&amp;#160;request&amp;#41;&amp;#160;LBA=0&lt;br /&gt;
ad0&amp;#58;&amp;#160;FAILURE&amp;#160;-&amp;#160;READ_DMA&amp;#160;status=51&amp;#60;READY,DSC,ERROR&amp;#62;&amp;#160;error=84&amp;#60;ICRC,ABORTED&amp;#62;&amp;#160;LBA=0&lt;/div&gt;&lt;br /&gt;
&lt;br /&gt;
The short version of the solution is to either use an &lt;a href=&quot;http://www.pcguide.com/ref/hdd/if/ide/conf_Cable80.htm&quot;  title=&quot;80 conductor / strand IDE cable&quot;&gt;80 conductor IDE cable&lt;/a&gt; to allow correct Ultra DMA transfers OR run the FreeBSD installation in safe mode.  The first option is &lt;br /&gt;
much prefered, even if only to increase the transfer speed used by the HDD.  Installing in safe mode might work ok, but the underlying issues with UDMA may still persist after the installation when the operating system is in use, which is obviously not a good thing.  If possible go for upgrading the IDE cable to 80 conductor.&lt;br /&gt;
&lt;br /&gt;
More details of the problem are detailed below:&lt;br /&gt;
&lt;br /&gt;
The problem occurs at the point where the installer attempts to write the disk labels.  The disk appears to be formatted ok and the FreeBSD slices (DOS &#039;partitions&#039;) are created ok, the errors occur when the FreeBSD partitions inside each slice are created (ad0s1a-h).  &lt;br /&gt;
&lt;br /&gt;
(Incidentally I found that I could only assign a maximum of 7 partitions per slice which seems to contradict what I read somewhere else about this saying that you could create up to 8 partitions per slice.  Perhaps this is to do with swap partition creation though, I&#039;m not sure, the 7 does include one swap partition - ie not 7 regular parts plus the swap...)&lt;br /&gt;
&lt;br /&gt;
Anyway back to the problem.  After a quick search I found &lt;a href=&quot;http://lists.freebsd.org/pipermail/freebsd-stable/2006-October/030078.html&quot;  title=&quot;freebsd disk partitioning failure&quot;&gt;this post&lt;/a&gt; which almost exactly describes my problem along with a much appreciated reply - qutoe from that post:&lt;br /&gt;
&lt;br /&gt;
&lt;div class=&quot;bb-code-title&quot;&gt;QUOTE:&lt;/div&gt;&lt;div class=&quot;bb-quote&quot;&gt;&lt;br /&gt;
Finally I got things working!&lt;br /&gt;
&lt;br /&gt;
First I tried several other IDE cables, which did not help.&lt;br /&gt;
&lt;br /&gt;
Then I tried Carl&#039;s advice and bought a 80-connector cable. And amazingly&lt;br /&gt;
enough... It worked! &lt;br /&gt;
&lt;/div&gt;&lt;br /&gt;
&lt;br /&gt;
From what I can gather the problem seems to be that the FreeBSD installer doesn&#039;t detect the DMA mode correctly and tries to use the faster UDMA mode (Ultra DMA) regardless of whether a compatible 80 conductor IDE cable is in use or not (an 80 conductor cable is required to make use of the extra speed of UDMA (&lt;a href=&quot;http://www.pcguide.com/ref/hdd/if/ide/conf_Cable80.htm&quot;  title=&quot;80 conductor IDE cables&quot;&gt;see here for a good description of 80 conductor IDE cables&lt;/a&gt;) and attempting to use UDMA without an 80 conductor cable causes problems *from what little I understand of the thing*).  Why this is missing on FreeBSD I don&#039;t know - it seems to be detected OK on Windows XP and from what I read, OpenBSD works fine around this problem too.&lt;br /&gt;
&lt;br /&gt;
Anyway, I ordered an 80 conductor IDE cable from ebay so hopefully that will make installation easier and generally increase speed as well for the HDD.  Of course by &lt;a href=&quot;http://en.wikipedia.org/wiki/Sod&#039;s_law&quot;  title=&quot;Sod&#039;s Law&quot;&gt;sod&#039;s law&lt;/a&gt;, as soon as I&#039;d done this I found a way to get around the problem...&lt;br /&gt;
&lt;br /&gt;
Out of curiousity I decided to try and use the FreeBSD installer&#039;s &#039;Safe Mode&#039; to see if it would fall back to using a safer DMA mode.  I had to use a standard PS/2 keyboard instead of my USB one - presumably because USB support isn&#039;t included in safe mode - but the installer actually managed to write to the disk properly this time which is good.&lt;br /&gt;
&lt;br /&gt;
The caveat, as mentioned above, is that the problems may still persist after the installation, I&#039;ve not tested this out as yet so don&#039;t know but would be surprised if the problems magically dissappeared without using an 80 conductor cable.  End of the day, make sure to use an 80 conductor IDE cable if you run across this kind of problem on FreeBSD. 
    </content:encoded>

    <pubDate>Fri, 05 Jan 2007 14:30:21 +0000</pubDate>
    <guid isPermaLink="false">http://freebsd.munk.me.uk/archives/211-guid.html</guid>
    <creativeCommons:license>http://creativecommons.org/licenses/by/2.5/</creativeCommons:license>
</item>
<item>
    <title>Moving munk.me.uk to a new HDD - filesystem layout</title>
    <link>http://freebsd.munk.me.uk/archives/210-Moving-munk.me.uk-to-a-new-HDD-filesystem-layout.html</link>
            <category>FreeBSD</category>
            <category>General</category>
            <category>Hardware</category>
    
    <comments>http://freebsd.munk.me.uk/archives/210-Moving-munk.me.uk-to-a-new-HDD-filesystem-layout.html#comments</comments>
    <wfw:comment>http://freebsd.munk.me.uk/wfwcomment.php?cid=210</wfw:comment>

    <slash:comments>0</slash:comments>
    <wfw:commentRss>http://freebsd.munk.me.uk/rss.php?version=2.0&amp;type=comments&amp;cid=210</wfw:commentRss>
    

    <author>nospam@example.com (munk)</author>
    <content:encoded>
    Well after having been on FreeBSD 4.x for as long as I can remember (4years now I guess), it&#039;s finally time to move to FreeBSD 6.x!  For ages I&#039;ve been saying as soon as I get a larger HDD I&#039;d upgrade the system and santa kindly delivered a shiny new 250Gb Maxtor DiamondMax 10, so it&#039;s time to sort it out and make the move.&lt;br /&gt;
&lt;br /&gt;
Funny now I think about it, for me upgrading to a larger capacity HDD has always been a fairly rare occasion.  Back in 2000 or so I remember moving from a measily 1.6Gb to a whopping 20Gb HDD and thinking that was way too much.  In a way it&#039;s a good thing to not have a lot of space - it makes you more tidy and less likely to spam crap all over the filesystem.  Of course on the other hand not having a lot of space also sucks if you want to store a lot of stuff (duh).  This is kind of how it&#039;s been with my FreeBSD server for the last 4yrs or so - I&#039;ve only had a 40Gb drive and in that time I&#039;ve hosted over 100 users at the same time, dozens of domains, ran a load of services, and never really had a lot to complain about re lack of space.  The main reason for the change I guess is the increased use of broadband/bittorrent which I really need more space to save files to disk for.&lt;br /&gt;
&lt;br /&gt;
I&#039;m gonna document the filesystem layout of the new HDD here, no doubt it&#039;ll only be me that ever reads this again (and you if you&#039;re reading this heh :o).&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;b&gt;File System Layout&lt;/b&gt;&lt;br /&gt;
I spent quite a while thinking about how best to partition/slice up the new 250Gb disk, mainly because my server is running 24/7 and various applications really do kane the filesystem when accessing data (ie apache and mysql for two).  I want to try and partition the disk so that it&#039;s more efficient for apache and mysql to read/write from/to the disks.  &lt;br /&gt;
&lt;br /&gt;
The other deliberation I went through whilst thinking about the file system layout was where to mount partitions for backups, music, videos and windows application installers.  Of course this could be anywhere really - /backups /music /videos /windows for example - but I don&#039;t really like spamming the root level filesystem with lots of folders that only add clutter.&lt;br /&gt;
&lt;br /&gt;
I had a quick look at the &lt;a href=&quot;http://www.pathname.com/fhs/&quot;  title=&quot;filesystem hierarchy standard&quot;&gt;Filesystem Hierarchy Standard&lt;/a&gt; which is a standard aimed at encouraging clean and consistent filesystem layouts on Unix type OSs and eventually ended up with the following layout:&lt;br /&gt;
&lt;br /&gt;
&lt;div class=&quot;bb-code-title&quot;&gt;CODE:&lt;/div&gt;&lt;div class=&quot;bb-code&quot;&gt;G=Gigabytes&lt;br /&gt;
&lt;br /&gt;
fdisk&amp;#58;&lt;br /&gt;
======&lt;br /&gt;
&lt;br /&gt;
Name&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;Size&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;Partition&amp;#160;Type&lt;br /&gt;
====&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;====&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;==============&lt;br /&gt;
ad1s1&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;59G&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;freebsd&lt;br /&gt;
ad1s2&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;89G&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;freebsd&lt;br /&gt;
ad1s3&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;49G&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;freebsd&lt;br /&gt;
ad1s4&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;33G&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;freebsd&lt;br /&gt;
&lt;br /&gt;
disklabel&amp;#58;&lt;br /&gt;
==========&lt;br /&gt;
&lt;br /&gt;
Partition&amp;#160;&amp;#160;&amp;#160;&amp;#160;Mount&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;Size&amp;#160;&amp;#40;approx.&amp;#41;&lt;br /&gt;
=========&amp;#160;&amp;#160;&amp;#160;&amp;#160;=====&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;==============&lt;br /&gt;
ad1s1&amp;#58;&lt;br /&gt;
------&lt;br /&gt;
&lt;br /&gt;
ad1s1a&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;/&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;0.5G&lt;br /&gt;
&lt;br /&gt;
ad1s1b&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;swap&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;2G&lt;br /&gt;
&lt;br /&gt;
ad1s1d&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;/tmp&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;1G&lt;br /&gt;
&lt;br /&gt;
ad1s1e&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;/var/db/mysql&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;20G&lt;br /&gt;
&lt;br /&gt;
ad1s1f&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;/var/www&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;10G&lt;br /&gt;
&lt;br /&gt;
ad1s1g&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;/var/&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;10G&lt;br /&gt;
&lt;br /&gt;
ad1s1h&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;/usr&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;20G&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
ad1s2&amp;#58;&lt;br /&gt;
------&lt;br /&gt;
&lt;br /&gt;
ad1s2d&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;/home&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;40G&lt;br /&gt;
&lt;br /&gt;
ad1s2e&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;/var/backups&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;50G&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
ad1s3&amp;#58;&lt;br /&gt;
------&lt;br /&gt;
&lt;br /&gt;
ad1s3d&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;/var/media&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;50G&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
ad1s4&amp;#58;&lt;br /&gt;
------&lt;br /&gt;
&lt;br /&gt;
ad2s4d&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;/var/win32&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;35G&lt;/div&gt; 
    </content:encoded>

    <pubDate>Fri, 05 Jan 2007 14:25:00 +0000</pubDate>
    <guid isPermaLink="false">http://freebsd.munk.me.uk/archives/210-guid.html</guid>
    <creativeCommons:license>http://creativecommons.org/licenses/by/2.5/</creativeCommons:license>
</item>
<item>
    <title>Block Brute Force Attacks Against sshd and proftpd Using blockhosts</title>
    <link>http://freebsd.munk.me.uk/archives/209-Block-Brute-Force-Attacks-Against-sshd-and-proftpd-Using-blockhosts.html</link>
            <category>FTP</category>
            <category>Security</category>
            <category>SSH</category>
    
    <comments>http://freebsd.munk.me.uk/archives/209-Block-Brute-Force-Attacks-Against-sshd-and-proftpd-Using-blockhosts.html#comments</comments>
    <wfw:comment>http://freebsd.munk.me.uk/wfwcomment.php?cid=209</wfw:comment>

    <slash:comments>4</slash:comments>
    <wfw:commentRss>http://freebsd.munk.me.uk/rss.php?version=2.0&amp;type=comments&amp;cid=209</wfw:commentRss>
    

    <author>nospam@example.com (munk)</author>
    <content:encoded>
    For a long time now I&#039;ve had a lot of problems with brute force attacks against sshd and proftpd - attacks where a host will attempt to login with a dictionary of common usernames and passwords, trying each one until they find a combination that works.  Apart from being a security issue, this uses up a lot of bandwidth so it&#039;s worth taking some measures to block these kind of attacks.&lt;br /&gt;
&lt;br /&gt;
Both sshd and ftpd services have their own individual means for blocking individual connections, but unfortunately neither have an inbuilt method for detecting brute force attacks - counting how many failed login attempts are made from each individual IP address and then blocking that IP address if the number of failed login attempts is more than a certain number.  This is where a 3rd party utility is required.&lt;br /&gt;
&lt;br /&gt;
There are a few utilities that can mitigate brute force attacks on services.  For a while now I&#039;ve used &lt;a href=&quot;http://denyhosts.sourceforge.net/&quot;  title=&quot;DenyHosts&quot;&gt;DenyHosts&lt;/a&gt; successfully to block sshd brute force attacks.  DenyHosts works by constantly monitoring sshd logfiles and keeping track of how many failed logins have occured per IP address over time.  If the number of failed logins reaches a certain threshold, DenyHosts adds an entry in /etc/hosts.allow that effectively blocks the IP address, stopping that host from connecting to the sshd service any more.&lt;br /&gt;
&lt;br /&gt;
DenyHosts is great, but unfortunately it&#039;s aimed only at blocking sshd brute force attacks and I need to protect the ftpd service as well as just sshd - and in future maybe adapt to block other services.  With this in mind I decided to move to using a very similar script called &lt;a href=&quot;http://www.aczoom.com/tools/blockhosts/&quot;  title=&quot;BlockHosts&quot;&gt;BlockHosts&lt;/a&gt; (the documentation for BlockHosts actually mentions that it was inspired by DenyHosts).  BlockHosts can scan a list of service logfiles in one go instead of just a single logfile as with DenyHosts, so is ideal for monitoring a number of different services for brute force attacks.&lt;br /&gt;
&lt;br /&gt;
The following describes how to install and configure BlockHosts on FreeBSD so it&#039;s executed every time the sshd or proftpd services are accessed using TCP_WRAPPERS - ie modifying /etc/hosts.allow so the blockhosts script is run each time sshd or proftpd are accessed.  The BlockHosts script will then check if this current connection attempt is part of a brute force attack and if so, add a blocking rule to /etc/hosts.allow to deny further access.&lt;br /&gt;
&lt;br /&gt;
&lt;span style=&quot;font-weight:bold&quot;&gt;Installation of BlockHosts&lt;/span&gt;&lt;br /&gt;
&lt;ol&gt;&lt;li&gt;&lt;a href=&quot;http://www.aczoom.com/cms/blockhosts/download&quot;  title=&quot;BlockHosts download page&quot;&gt;Download blockhosts from the download page&lt;/a&gt;, extract the distribution (note please check the download link for the latest version, the version below was latest at time of writing):&lt;br /&gt;
&lt;div class=&quot;bb-code-title&quot;&gt;CODE:&lt;/div&gt;&lt;div class=&quot;bb-code&quot;&gt;root@users&amp;#160;/home/munk/bin/python/blockhosts#&amp;#160;wget&amp;#160;http&amp;#58;//www.aczoom.com/tools/blockhosts/BlockHosts-1.0.5.tar.gz&lt;br /&gt;
root@users&amp;#160;/home/munk/bin/python/blockhosts#&amp;#160;tar&amp;#160;zxvf&amp;#160;BlockHosts-1.0.5.tar.gz&lt;br /&gt;
BlockHosts-1.0.5/&lt;br /&gt;
BlockHosts-1.0.5/Makefile&lt;br /&gt;
...&lt;/div&gt;&lt;br /&gt;
&lt;br /&gt;
&lt;li&gt;Change to BlockHosts directory:&lt;br /&gt;
&lt;div class=&quot;bb-code-title&quot;&gt;CODE:&lt;/div&gt;&lt;div class=&quot;bb-code&quot;&gt;root@users&amp;#160;/home/munk/bin/python/blockhosts#&amp;#160;cd&amp;#160;BlockHosts-1.0.5&lt;/div&gt;&lt;br /&gt;
&lt;br /&gt;
&lt;li&gt;Edit and save blockhosts.py to read:&lt;br /&gt;
&lt;br /&gt;
&lt;div class=&quot;bb-code-title&quot;&gt;CODE:&lt;/div&gt;&lt;div class=&quot;bb-code&quot;&gt;CONFIG_FILE&amp;#160;=&amp;#160;&quot;/usr/local/etc/blockhosts.cfg&quot;&lt;br /&gt;
...&lt;br /&gt;
&amp;#160;&amp;#160;&amp;#160;&amp;#160;&quot;LOGFILES&quot;&amp;#58;&amp;#160;&amp;#40;&amp;#160;&quot;/var/log/auth.log&quot;,&amp;#160;&amp;#41;,&lt;/div&gt;&lt;br /&gt;
&lt;span style=&quot;font-weight:bold&quot;&gt;Note:&lt;/span&gt; may seem a bit odd editing the blockhosts.py script before it&#039;s installed - the reason for this is that the installation locations used by setup.py below are taken from blockhosts.py, so by modifying blockhosts.py like this we get the config file installed into /usr/local/etc/ (FreeBSD default for 3rd party software) instead of into /etc (default for linux 3rd party software).&lt;br /&gt;
&lt;br /&gt;
&lt;li&gt;Install blockhosts:&lt;br /&gt;
&lt;br /&gt;
&lt;div class=&quot;bb-code-title&quot;&gt;CODE:&lt;/div&gt;&lt;div class=&quot;bb-code&quot;&gt;root@users&amp;#160;/home/munk/bin/python/blockhosts/BlockHosts-1.0.5#&amp;#160;python&amp;#160;setup.py&amp;#160;-v&amp;#160;install&lt;br /&gt;
running&amp;#160;install&lt;br /&gt;
running&amp;#160;build&lt;br /&gt;
running&amp;#160;build_scripts&lt;br /&gt;
creating&amp;#160;build&lt;br /&gt;
creating&amp;#160;build/scripts-2.4&lt;br /&gt;
copying&amp;#160;and&amp;#160;adjusting&amp;#160;blockhosts.py&amp;#160;-&amp;#62;&amp;#160;build/scripts-2.4&lt;br /&gt;
changing&amp;#160;mode&amp;#160;of&amp;#160;build/scripts-2.4/blockhosts.py&amp;#160;from&amp;#160;644&amp;#160;to&amp;#160;755&lt;br /&gt;
running&amp;#160;install_scripts&lt;br /&gt;
copying&amp;#160;build/scripts-2.4/blockhosts.py&amp;#160;-&amp;#62;&amp;#160;/usr/local/bin&lt;br /&gt;
changing&amp;#160;mode&amp;#160;of&amp;#160;/usr/local/bin/blockhosts.py&amp;#160;to&amp;#160;755&lt;br /&gt;
running&amp;#160;install_data&lt;br /&gt;
copying&amp;#160;blockhosts.cfg&amp;#160;-&amp;#62;&amp;#160;/usr/local/etc&lt;/div&gt;&lt;br /&gt;
&lt;br /&gt;
This installs the blockhosts.py script into /usr/local/bin and the config file blockhosts.cfg into /usr/local/etc.  Make sure to run &#039;rehash&#039; to reread the binary paths again so blockhosts.py will run from anywhere:&lt;br /&gt;
&lt;br /&gt;
&lt;div class=&quot;bb-code-title&quot;&gt;CODE:&lt;/div&gt;&lt;div class=&quot;bb-code&quot;&gt;root@users&amp;#160;/home/munk/bin/python/blockhosts/BlockHosts-1.0.5#&amp;#160;rehash&lt;/div&gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;li&gt;Edit and save the /usr/local/etc/blockhosts.cfg file so it reads:&lt;br /&gt;
&lt;br /&gt;
&lt;div class=&quot;bb-code-title&quot;&gt;CODE:&lt;/div&gt;&lt;div class=&quot;bb-code&quot;&gt;LOGFILES&amp;#160;=&amp;#160;&amp;#91;&amp;#160;&quot;/var/log/auth.log&quot;,&amp;#160;&quot;/var/log/ftp.log&quot;&amp;#160;&amp;#93;&lt;/div&gt;&lt;br /&gt;
&lt;br /&gt;
&lt;span style=&quot;font-weight:bold&quot;&gt;Important:&lt;/span&gt;&lt;br /&gt;
Add the logfiles you want blockhosts to monitor for brute force attacks here.  /var/log/auth.log is standard for sshd, /var/log/ftp.log is maybe not standard for all ftpd, this is just what I have setup here.&lt;br /&gt;
&lt;br /&gt;
At this point it&#039;s best to read through the documentation for blockhosts completely - the README, INSTALL and the blockhosts.py script itself.  The following section is pretty much copy/pasted from what&#039;s mentioned in there.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;li&gt;Edit and save /etc/hosts.allow to include the section that blockhosts.py will modify.  Make sure you allow your own IP blocks first and any trusted IPs so they don&#039;t get blocked accidentally:&lt;br /&gt;
&lt;br /&gt;
&lt;strong&gt;GOTCHA LOOKOUT!&lt;/strong&gt;&lt;br /&gt;
One gotcha to watch out for in this is the line:&lt;br /&gt;
&lt;br /&gt;
&lt;div class=&quot;bb-code-title&quot;&gt;CODE:&lt;/div&gt;&lt;div class=&quot;bb-code&quot;&gt;ALL&amp;#160;&amp;#58;&amp;#160;ALL&amp;#160;&amp;#58;&amp;#160;allow&lt;/div&gt;&lt;br /&gt;
&lt;br /&gt;
You &lt;strong&gt;MUST&lt;/strong&gt; remove this line - replace it with your IP block instead so you don&#039;t get locked out from your own address range.  If this line isn&#039;t removed/commented out, anything below it just isn&#039;t read/executed and blockhosts won&#039;t work.&lt;br /&gt;
&lt;br /&gt;
This is how my /etc/hosts.allow looks:&lt;br /&gt;
&lt;br /&gt;
&lt;div class=&quot;bb-code-title&quot;&gt;CODE:&lt;/div&gt;&lt;div class=&quot;bb-code&quot;&gt;#######################################################################&lt;br /&gt;
#&amp;#160;blockhosts&lt;br /&gt;
#######################################################################&lt;br /&gt;
#&amp;#160;----&lt;br /&gt;
#&amp;#160;see&amp;#160;&quot;man&amp;#160;5&amp;#160;hosts_access&quot;&amp;#160;for&amp;#160;details&amp;#160;of&amp;#160;the&amp;#160;format&amp;#160;of&amp;#160;IP&amp;#160;addresses,&lt;br /&gt;
#services,&amp;#160;allow/deny&amp;#160;options.&amp;#160;Also&amp;#160;see&amp;#160;&quot;man&amp;#160;hosts_options&quot;&lt;br /&gt;
#order&amp;#160;of&amp;#160;lines&amp;#160;in&amp;#160;this&amp;#160;file&amp;#160;is&amp;#160;important,&amp;#160;first&amp;#160;matched&amp;#160;IP&amp;#160;address&amp;#160;line&lt;br /&gt;
#is&amp;#160;rule&amp;#160;applied&amp;#160;by&amp;#160;hosts_access&lt;br /&gt;
#&lt;br /&gt;
#&amp;#160;permanent&amp;#160;whitelist&amp;#160;addresses&amp;#160;-&amp;#160;these&amp;#160;should&amp;#160;always&amp;#160;be&amp;#160;allowed&amp;#160;access&lt;br /&gt;
&lt;br /&gt;
ALL&amp;#160;&amp;#58;&amp;#160;213.152.51.192/255.255.255.248&amp;#160;&amp;#58;&amp;#160;allow&lt;br /&gt;
#&amp;#160;ALL&amp;#58;&amp;#160;127.0.0.1&amp;#160;&amp;#160;&amp;#58;&amp;#160;allow&lt;br /&gt;
#&amp;#160;ALL&amp;#58;&amp;#160;192.168.0.&amp;#160;&amp;#58;&amp;#160;allow&lt;br /&gt;
&lt;br /&gt;
#&amp;#160;permanent&amp;#160;blacklist&amp;#160;addresses&amp;#160;-&amp;#160;these&amp;#160;should&amp;#160;always&amp;#160;be&amp;#160;denied&amp;#160;access&lt;br /&gt;
&lt;br /&gt;
#&amp;#160;ALL&amp;#58;&amp;#160;10.&amp;#160;&amp;#160;&amp;#58;&amp;#160;deny&lt;br /&gt;
#&amp;#160;ALL&amp;#58;&amp;#160;192.&amp;#160;&amp;#58;&amp;#160;deny&lt;br /&gt;
#&amp;#160;ALL&amp;#58;&amp;#160;172.&amp;#160;&amp;#58;&amp;#160;deny&lt;br /&gt;
&lt;br /&gt;
#&amp;#160;----------------------------------------&lt;br /&gt;
#&amp;#160;next&amp;#160;section&amp;#160;is&amp;#160;the&amp;#160;blockhosts&amp;#160;section&amp;#160;-&amp;#160;it&amp;#160;will&amp;#160;add/delete&amp;#160;entries&amp;#160;in&lt;br /&gt;
#&amp;#160;between&amp;#160;the&amp;#160;two&amp;#160;marker&amp;#160;lines&amp;#160;&amp;#40;#----&amp;#160;BlockHosts&amp;#160;Additions&amp;#41;&lt;br /&gt;
&lt;br /&gt;
#----&amp;#160;BlockHosts&amp;#160;Additions&lt;br /&gt;
#----&amp;#160;BlockHosts&amp;#160;Additions&lt;br /&gt;
&lt;br /&gt;
#&amp;#160;----------------------------------------&lt;br /&gt;
#&amp;#160;finally,&amp;#160;the&amp;#160;command&amp;#160;to&amp;#160;execute&amp;#160;the&amp;#160;blockhosts&amp;#160;script,&amp;#160;based&amp;#160;on&lt;br /&gt;
#&amp;#160;connection&amp;#160;to&amp;#160;particular&amp;#160;service&amp;#160;or&amp;#160;services,&amp;#160;for&amp;#160;example,&amp;#160;for&lt;br /&gt;
#&amp;#160;sshd&amp;#160;and&amp;#160;proftpd&amp;#160;-&amp;#160;if&amp;#160;using&amp;#160;vsftpd,&amp;#160;pure-ftpd,&amp;#160;be&amp;#160;sure&amp;#160;to&amp;#160;use&amp;#160;those&lt;br /&gt;
#&amp;#160;words&amp;#160;instead&amp;#58;&lt;br /&gt;
&lt;br /&gt;
sshd,&amp;#160;proftpd&amp;#58;&amp;#160;ALL&amp;#58;&amp;#160;spawn&amp;#160;&amp;#40;/usr/local/bin/blockhosts.py&amp;#160;--verbose&amp;#160;--echo&amp;#160;&quot;%c-%s&quot;&amp;#160;&amp;#62;&amp;#62;&amp;#160;/var/log/blockhosts.log&amp;#160;2&amp;#62;&amp;amp;1&amp;#160;&amp;#41;&amp;amp;&amp;#160;&amp;#58;&amp;#160;allow&lt;br /&gt;
&lt;br /&gt;
#&amp;#160;remove&amp;#58;&amp;#160;&amp;#160;&amp;#160;&amp;#62;&amp;#62;&amp;#160;/var/log/blockhosts.log&amp;#160;2&amp;#62;&amp;amp;1&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;if&amp;#160;logging&amp;#160;to&lt;br /&gt;
#&amp;#160;blockhosts.log&amp;#160;is&amp;#160;not&amp;#160;needed&amp;#160;-&amp;#160;it&amp;#160;will&amp;#160;still&amp;#160;log&amp;#160;to&amp;#160;syslog&amp;#160;&amp;#40;minimally&amp;#41;&lt;br /&gt;
#&amp;#160;see&amp;#160;examples&amp;#160;below&lt;br /&gt;
#&amp;#160;--&lt;br /&gt;
#&amp;#160;See&amp;#160;&quot;man&amp;#160;hosts.allow&quot;&amp;#160;for&amp;#160;info&amp;#160;on&amp;#160;%c&amp;#160;and&amp;#160;%s&amp;#160;identifiers&lt;br /&gt;
#----&lt;br /&gt;
#&amp;#160;for&amp;#160;non-verbose,&amp;#160;with&amp;#160;identification,&amp;#160;to&amp;#160;syslog&amp;#160;only&amp;#160;&amp;#40;/var/log/messages&amp;#41;&amp;#58;&lt;br /&gt;
#sshd,&amp;#160;proftpd,&amp;#160;in.proftpd&amp;#58;&amp;#160;ALL&amp;#58;&amp;#160;spawn&amp;#160;/usr/bin/blockhosts.py&amp;#160;--echo&amp;#160;&quot;%c-%s&quot;&amp;#160;&amp;amp;&amp;#160;&amp;#58;&amp;#160;allow&lt;br /&gt;
#----&lt;br /&gt;
#&amp;#160;minimal&amp;#160;logging,&amp;#160;to&amp;#160;syslog&amp;#160;&amp;#40;usually&amp;#160;goes&amp;#160;to&amp;#160;/var/log/messages&amp;#41;&amp;#58;&lt;br /&gt;
#sshd,&amp;#160;proftpd,&amp;#160;in.proftpd&amp;#58;&amp;#160;ALL&amp;#58;&amp;#160;spawn&amp;#160;/usr/bin/blockhosts.py&amp;#160;&amp;amp;&amp;#160;&amp;#58;&amp;#160;allow&lt;br /&gt;
#----&lt;br /&gt;
#&amp;#160;To&amp;#160;test&amp;#160;hosts.allow,&amp;#160;and&amp;#160;to&amp;#160;find&amp;#160;out&amp;#160;exact&amp;#160;names&amp;#160;of&amp;#160;SSH/FTP&amp;#160;services,&lt;br /&gt;
#&amp;#160;add&amp;#160;this&amp;#160;line&amp;#160;to&amp;#160;the&amp;#160;beginning&amp;#160;of&amp;#160;hosts.allow,&amp;#160;use&amp;#160;ssh/ftp&amp;#160;to&amp;#160;connect&lt;br /&gt;
#&amp;#160;to&amp;#160;your&amp;#160;server,&amp;#160;and&amp;#160;then&amp;#160;look&amp;#160;at&amp;#160;the&amp;#160;log&amp;#160;&amp;#40;/var/log/messages&amp;#160;or&lt;br /&gt;
#&amp;#160;blockhosts.log&amp;#41;&amp;#160;to&amp;#160;see&amp;#160;the&amp;#160;name&amp;#160;of&amp;#160;the&amp;#160;invoked&amp;#160;service.&lt;br /&gt;
#&amp;#160;IMPORTANT&amp;#58;&amp;#160;after&amp;#160;your&amp;#160;test&amp;#160;is&amp;#160;done,&amp;#160;remove&amp;#160;this&amp;#160;line&amp;#160;from&amp;#160;hosts.allow!&lt;br /&gt;
#&amp;#160;Otherwise&amp;#160;everyone&amp;#160;will&amp;#160;always&amp;#160;have&amp;#160;access.&lt;br /&gt;
#ALL&amp;#160;&amp;#58;&amp;#160;ALL&amp;#58;&amp;#160;spawn&amp;#160;&amp;#40;/usr/bin/blockhosts.py&amp;#160;--verbose&amp;#160;--echo&amp;#160;&quot;%c-%s&quot;&amp;#160;&amp;#62;&amp;#62;&amp;#160;/var/log/blockhosts.log&amp;#160;2&amp;#62;&amp;amp;1&amp;#160;&amp;#41;&amp;amp;&amp;#160;&amp;#58;&amp;#160;allow&lt;br /&gt;
#######################################################################&lt;br /&gt;
#&amp;#160;blockhosts&lt;br /&gt;
#######################################################################&lt;/div&gt;&lt;br /&gt;
&lt;br /&gt;
&lt;span style=&quot;font-weight:bold&quot;&gt;Important Note for ProFTPD users:&lt;/span&gt;&lt;br /&gt;
The following sections describes the configuration needed when using proftpd via inetd.  If you are using ProFTPD in standalone mode, you need to use the proftpd mod_wrap/mod_wrap_file functionality to have proftpd read and honour the TCP_WRAPPERS//etc/hosts.allow file(s) when denying/allowing hosts.  Additionally you need to specifiy the configure flag --enable-wrapper-options when building proftpd.  For a heavily used server, this might be worth doing but personally I don&#039;t get that many connections that I need to worry about inetd being overloaded so I can just go down the (easier to configure for blockhosts) inetd path.&lt;br /&gt;
&lt;br /&gt;
&lt;li&gt;Ensure proftpd is configured to run correctly via inetd.&lt;br /&gt;
&lt;br /&gt;
Edit and save /usr/local/etc/proftpd.conf to read:&lt;br /&gt;
&lt;div class=&quot;bb-code-title&quot;&gt;CODE:&lt;/div&gt;&lt;div class=&quot;bb-code&quot;&gt;ServerType&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;inetd&lt;/div&gt;&lt;br /&gt;
&lt;br /&gt;
&lt;span style=&quot;font-weight:bold&quot;&gt;Important:&lt;/span&gt; remember to delete or rename /usr/local/etc/rc.d/proftpd.sh so it&#039;s not run at boot time - the proftpd daemon doesn&#039;t need to be started at boot if you&#039;re using inetd, inetd handles all the proftpd connections, see below:&lt;br /&gt;
&lt;br /&gt;
Edit and save /etc/inetd.conf to read:&lt;br /&gt;
&lt;div class=&quot;bb-code-title&quot;&gt;CODE:&lt;/div&gt;&lt;div class=&quot;bb-code&quot;&gt;ftp&amp;#160;stream&amp;#160;&amp;#160;tcp&amp;#160;nowait&amp;#160;&amp;#160;root&amp;#160;&amp;#160;&amp;#160;&amp;#160;/usr/local/sbin/in.proftpd&amp;#160;proftpd&lt;/div&gt;&lt;br /&gt;
&lt;br /&gt;
then restart inetd:&lt;br /&gt;
&lt;br /&gt;
&lt;div class=&quot;bb-code-title&quot;&gt;CODE:&lt;/div&gt;&lt;div class=&quot;bb-code&quot;&gt;root@users&amp;#160;/usr/local/etc#&amp;#160;kill&amp;#160;-HUP&amp;#160;`cat&amp;#160;/var/run/inetd.pid&amp;#160;`&lt;/div&gt;&lt;br /&gt;
This forces inetd to restart, rereading the config file changes made to /etc/inetd.conf.  ftp connections will now be handled by proftpd via inetd.&lt;br /&gt;
&lt;/ol&gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
We&#039;re now ready to run blockhosts.py for the first time.  BlockHosts will parse each logfile mentioned in blockhosts.cfg and check for any brute force attacks and if it finds any, blocks will be added to the /etc/hosts.allow file.  &lt;br /&gt;
&lt;br /&gt;
&lt;span style=&quot;font-weight:bold&quot;&gt;Note:&lt;/span&gt; This initial check does not take into account the period over which failed logins took place, so any IP that has more than the default 7 failed login entries will look like a brute force attacker.  However, the ban BlockHosts adds will only last for the default 12 hours so this shouldn&#039;t cause a huge issue - just be aware of this and check the IPs that are added on the first run.&lt;br /&gt;
&lt;br /&gt;
For the very first time it&#039;s a good idea to try a &#039;dry run&#039; just to see what blockhosts finds and what it&#039;d do, without actually doing anything to the /etc/hosts.allow file.  To do this, run blockhosts with the &#039;--dry-run&#039; flag:&lt;br /&gt;
&lt;br /&gt;
&lt;div class=&quot;bb-code-title&quot;&gt;CODE:&lt;/div&gt;&lt;div class=&quot;bb-code&quot;&gt;root@users&amp;#160;/usr/local/etc#&amp;#160;/usr/local/bin/blockhosts.py&amp;#160;--verbose&amp;#160;--dry-run&lt;br /&gt;
blockhosts&amp;#160;1.0.5&amp;#160;started&amp;#58;&amp;#160;2006-12-30&amp;#160;14&amp;#58;15&amp;#58;30&lt;br /&gt;
&amp;#160;...&amp;#160;will&amp;#160;discard&amp;#160;all&amp;#160;host&amp;#160;entries&amp;#160;older&amp;#160;than&amp;#160;&amp;#160;2006-12-30&amp;#160;02&amp;#58;15&lt;br /&gt;
&amp;#160;...&amp;#160;load&amp;#160;blockfile&amp;#58;&amp;#160;/etc/hosts.allow&lt;br /&gt;
&amp;#160;...&amp;#160;found&amp;#160;both&amp;#160;markers,&amp;#160;count&amp;#160;of&amp;#160;hosts&amp;#160;being&amp;#160;watched&amp;#58;&amp;#160;0&lt;br /&gt;
&amp;#160;&amp;#160;Warning&amp;#58;&amp;#160;no&amp;#160;offset&amp;#160;found,&amp;#160;will&amp;#160;read&amp;#160;from&amp;#160;beginning&amp;#160;in&amp;#160;logfile&amp;#58;&amp;#160;/var/log/auth.log&lt;br /&gt;
&amp;#160;...&amp;#160;securelog,&amp;#160;loading&amp;#160;file,&amp;#160;offset&amp;#58;&amp;#160;/var/log/auth.log&amp;#160;0&lt;br /&gt;
&amp;#160;&amp;#160;Warning&amp;#58;&amp;#160;no&amp;#160;offset&amp;#160;found,&amp;#160;will&amp;#160;read&amp;#160;from&amp;#160;beginning&amp;#160;in&amp;#160;logfile&amp;#58;&amp;#160;/var/log/ftp.log&lt;br /&gt;
&amp;#160;...&amp;#160;securelog,&amp;#160;loading&amp;#160;file,&amp;#160;offset&amp;#58;&amp;#160;/var/log/ftp.log&amp;#160;0&lt;br /&gt;
&amp;#160;...&amp;#160;updates&amp;#58;&amp;#160;counts&amp;#58;&amp;#160;hosts&amp;#160;to&amp;#160;block&amp;#58;&amp;#160;9;&amp;#160;hosts&amp;#160;being&amp;#160;watched&amp;#58;&amp;#160;21&lt;br /&gt;
#----&amp;#160;BlockHosts&amp;#160;Additions&lt;br /&gt;
ALL&amp;#58;&amp;#160;&amp;#160;203.88.192.225&amp;#160;&amp;#58;&amp;#160;deny&lt;br /&gt;
ALL&amp;#58;&amp;#160;&amp;#160;&amp;#160;&amp;#160;200.71.192.7&amp;#160;&amp;#58;&amp;#160;deny&lt;br /&gt;
ALL&amp;#58;&amp;#160;&amp;#160;212.227.81.146&amp;#160;&amp;#58;&amp;#160;deny&lt;br /&gt;
ALL&amp;#58;&amp;#160;&amp;#160;&amp;#160;&amp;#160;218.25.62.75&amp;#160;&amp;#58;&amp;#160;deny&lt;br /&gt;
ALL&amp;#58;&amp;#160;&amp;#160;200.46.108.164&amp;#160;&amp;#58;&amp;#160;deny&lt;br /&gt;
ALL&amp;#58;&amp;#160;&amp;#160;&amp;#160;&amp;#160;201.57.163.2&amp;#160;&amp;#58;&amp;#160;deny&lt;br /&gt;
ALL&amp;#58;&amp;#160;&amp;#160;205.129.191.11&amp;#160;&amp;#58;&amp;#160;deny&lt;br /&gt;
ALL&amp;#58;&amp;#160;&amp;#160;&amp;#160;&amp;#160;200.68.51.91&amp;#160;&amp;#58;&amp;#160;deny&lt;br /&gt;
ALL&amp;#58;&amp;#160;&amp;#160;&amp;#160;&amp;#160;82.38.68.217&amp;#160;&amp;#58;&amp;#160;deny&lt;br /&gt;
&lt;br /&gt;
#bh&amp;#58;&amp;#160;ip&amp;#58;&amp;#160;&amp;#160;&amp;#160;85.184.10.200&amp;#160;&amp;#58;&amp;#160;&amp;#160;&amp;#160;1&amp;#160;&amp;#58;&amp;#160;2006-12-30-14-15&lt;br /&gt;
#bh&amp;#58;&amp;#160;ip&amp;#58;&amp;#160;&amp;#160;84.158.231.209&amp;#160;&amp;#58;&amp;#160;&amp;#160;&amp;#160;1&amp;#160;&amp;#58;&amp;#160;2006-12-30-14-15&lt;br /&gt;
#bh&amp;#58;&amp;#160;ip&amp;#58;&amp;#160;&amp;#160;&amp;#160;&amp;#160;82.38.68.217&amp;#160;&amp;#58;&amp;#160;&amp;#160;11&amp;#160;&amp;#58;&amp;#160;2006-12-30-14-15&lt;br /&gt;
#bh&amp;#58;&amp;#160;ip&amp;#58;&amp;#160;&amp;#160;&amp;#160;&amp;#160;82.153.28.16&amp;#160;&amp;#58;&amp;#160;&amp;#160;&amp;#160;2&amp;#160;&amp;#58;&amp;#160;2006-12-30-14-15&lt;br /&gt;
#bh&amp;#58;&amp;#160;ip&amp;#58;&amp;#160;&amp;#160;&amp;#160;67.113.225.66&amp;#160;&amp;#58;&amp;#160;&amp;#160;&amp;#160;1&amp;#160;&amp;#58;&amp;#160;2006-12-30-14-15&lt;br /&gt;
#bh&amp;#58;&amp;#160;ip&amp;#58;&amp;#160;&amp;#160;&amp;#160;59.108.34.228&amp;#160;&amp;#58;&amp;#160;&amp;#160;&amp;#160;2&amp;#160;&amp;#58;&amp;#160;2006-12-30-14-15&lt;br /&gt;
#bh&amp;#58;&amp;#160;ip&amp;#58;&amp;#160;&amp;#160;222.68.192.132&amp;#160;&amp;#58;&amp;#160;&amp;#160;&amp;#160;2&amp;#160;&amp;#58;&amp;#160;2006-12-30-14-15&lt;br /&gt;
#bh&amp;#58;&amp;#160;ip&amp;#58;&amp;#160;&amp;#160;&amp;#160;&amp;#160;218.25.62.75&amp;#160;&amp;#58;&amp;#160;&amp;#160;20&amp;#160;&amp;#58;&amp;#160;2006-12-30-14-15&lt;br /&gt;
#bh&amp;#58;&amp;#160;ip&amp;#58;&amp;#160;&amp;#160;217.83.162.157&amp;#160;&amp;#58;&amp;#160;&amp;#160;&amp;#160;1&amp;#160;&amp;#58;&amp;#160;2006-12-30-14-15&lt;br /&gt;
#bh&amp;#58;&amp;#160;ip&amp;#58;&amp;#160;&amp;#160;212.227.81.146&amp;#160;&amp;#58;&amp;#160;29499&amp;#160;&amp;#58;&amp;#160;2006-12-30-14-15&lt;br /&gt;
#bh&amp;#58;&amp;#160;ip&amp;#58;&amp;#160;&amp;#160;&amp;#160;210.1.132.178&amp;#160;&amp;#58;&amp;#160;&amp;#160;&amp;#160;4&amp;#160;&amp;#58;&amp;#160;2006-12-30-14-15&lt;br /&gt;
#bh&amp;#58;&amp;#160;ip&amp;#58;&amp;#160;&amp;#160;205.129.191.11&amp;#160;&amp;#58;&amp;#160;&amp;#160;20&amp;#160;&amp;#58;&amp;#160;2006-12-30-14-15&lt;br /&gt;
#bh&amp;#58;&amp;#160;ip&amp;#58;&amp;#160;&amp;#160;&amp;#160;204.141.87.14&amp;#160;&amp;#58;&amp;#160;&amp;#160;&amp;#160;3&amp;#160;&amp;#58;&amp;#160;2006-12-30-14-15&lt;br /&gt;
#bh&amp;#58;&amp;#160;ip&amp;#58;&amp;#160;&amp;#160;203.88.192.225&amp;#160;&amp;#58;&amp;#160;448&amp;#160;&amp;#58;&amp;#160;2006-12-30-14-15&lt;br /&gt;
#bh&amp;#58;&amp;#160;ip&amp;#58;&amp;#160;&amp;#160;202.108.40.109&amp;#160;&amp;#58;&amp;#160;&amp;#160;&amp;#160;1&amp;#160;&amp;#58;&amp;#160;2006-12-30-14-15&lt;br /&gt;
#bh&amp;#58;&amp;#160;ip&amp;#58;&amp;#160;&amp;#160;&amp;#160;&amp;#160;201.57.163.2&amp;#160;&amp;#58;&amp;#160;2867&amp;#160;&amp;#58;&amp;#160;2006-12-30-14-15&lt;br /&gt;
#bh&amp;#58;&amp;#160;ip&amp;#58;&amp;#160;&amp;#160;&amp;#160;&amp;#160;200.71.192.7&amp;#160;&amp;#58;&amp;#160;761&amp;#160;&amp;#58;&amp;#160;2006-12-30-14-15&lt;br /&gt;
#bh&amp;#58;&amp;#160;ip&amp;#58;&amp;#160;&amp;#160;&amp;#160;&amp;#160;200.68.51.91&amp;#160;&amp;#58;&amp;#160;&amp;#160;10&amp;#160;&amp;#58;&amp;#160;2006-12-30-14-15&lt;br /&gt;
#bh&amp;#58;&amp;#160;ip&amp;#58;&amp;#160;&amp;#160;200.46.108.164&amp;#160;&amp;#58;&amp;#160;170&amp;#160;&amp;#58;&amp;#160;2006-12-30-14-15&lt;br /&gt;
#bh&amp;#58;&amp;#160;ip&amp;#58;&amp;#160;&amp;#160;200.105.255.90&amp;#160;&amp;#58;&amp;#160;&amp;#160;&amp;#160;7&amp;#160;&amp;#58;&amp;#160;2006-12-30-14-15&lt;br /&gt;
#bh&amp;#58;&amp;#160;ip&amp;#58;&amp;#160;&amp;#160;152.104.125.14&amp;#160;&amp;#58;&amp;#160;&amp;#160;&amp;#160;3&amp;#160;&amp;#58;&amp;#160;2006-12-30-14-15&lt;/div&gt;&lt;br /&gt;
&lt;br /&gt;
From this you can see nicely what blockhosts makes of the service logfiles and the addresses that have tried to connect unsuccessfully.  On my host, as you can see above, there are a few that are obviously dodgy (I would only expect a max of maybe 8 connections per ip per month, so clearly 29,499 connections is just &lt;span style=&quot;font-style:italic&quot;&gt;wrong&lt;/span&gt;!).&lt;br /&gt;
&lt;br /&gt;
Once you&#039;re happy that the output is correct, run blockhosts again without the &#039;--dry-run&#039; flag and the /etc/hosts.allow file will be modified.  Also from now on the logfiles will only be read from the last recorded offset which saves a lot of time if your logfiles are very big.&lt;br /&gt;
&lt;br /&gt;
Big thanks to the BlockHosts author Avinash Chopde ! 
    </content:encoded>

    <pubDate>Sat, 30 Dec 2006 11:52:15 +0000</pubDate>
    <guid isPermaLink="false">http://freebsd.munk.me.uk/archives/209-guid.html</guid>
    <creativeCommons:license>http://creativecommons.org/licenses/by/2.5/</creativeCommons:license>
</item>
<item>
    <title>Portupgrade fails to upgrade dependencies</title>
    <link>http://freebsd.munk.me.uk/archives/199-Portupgrade-fails-to-upgrade-dependencies.html</link>
            <category>Perl</category>
            <category>Ports</category>
    
    <comments>http://freebsd.munk.me.uk/archives/199-Portupgrade-fails-to-upgrade-dependencies.html#comments</comments>
    <wfw:comment>http://freebsd.munk.me.uk/wfwcomment.php?cid=199</wfw:comment>

    <slash:comments>3</slash:comments>
    <wfw:commentRss>http://freebsd.munk.me.uk/rss.php?version=2.0&amp;type=comments&amp;cid=199</wfw:commentRss>
    

    <author>nospam@example.com (munk)</author>
    <content:encoded>
    When using portupgrade to upgrade ports recursively, occasionally you get a problem where portupgrade fails to upgrade a dependency of a port that&#039;s being upgraded.    This seems to happen most often with perl ports - p5-* ports - probably because perl packages/ports use the most dependencies of all with being modular in design anyway.&lt;br /&gt;
&lt;br /&gt;
An example is when I just went to run the weekly &#039;portupgrade -arR&#039; and whilst upgrading p5-PathTools-3.21, portupgrade found that another port - p5-Scalar-List-Utils-1.18 - also needed upgrading.  Unfortunately the upgrade of that port failed with the following error:&lt;br /&gt;
&lt;br /&gt;
&lt;div class=&quot;bb-code-title&quot;&gt;CODE:&lt;/div&gt;&lt;div class=&quot;bb-code&quot;&gt;===&amp;#62;&amp;#160;&amp;#160;Checking&amp;#160;if&amp;#160;lang/p5-Scalar-List-Utils&amp;#160;already&amp;#160;installed&lt;br /&gt;
===&amp;#62;&amp;#160;&amp;#160;&amp;#160;p5-Scalar-List-Utils-1.18,1&amp;#160;is&amp;#160;already&amp;#160;installed&lt;br /&gt;
&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;You&amp;#160;may&amp;#160;wish&amp;#160;to&amp;#160;``make&amp;#160;deinstall&#039;&#039;&amp;#160;and&amp;#160;install&amp;#160;this&amp;#160;port&amp;#160;again&lt;br /&gt;
&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;by&amp;#160;``make&amp;#160;reinstall&#039;&#039;&amp;#160;to&amp;#160;upgrade&amp;#160;it&amp;#160;properly.&lt;br /&gt;
&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;If&amp;#160;you&amp;#160;really&amp;#160;wish&amp;#160;to&amp;#160;overwrite&amp;#160;the&amp;#160;old&amp;#160;port&amp;#160;of&amp;#160;lang/p5-Scalar-List-Utils&lt;br /&gt;
&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;without&amp;#160;deleting&amp;#160;it&amp;#160;first,&amp;#160;set&amp;#160;the&amp;#160;variable&amp;#160;&quot;FORCE_PKG_REGISTER&quot;&lt;br /&gt;
&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;in&amp;#160;your&amp;#160;environment&amp;#160;or&amp;#160;the&amp;#160;&quot;make&amp;#160;install&quot;&amp;#160;command&amp;#160;line.&lt;br /&gt;
&amp;#42;&amp;#42;&amp;#42;&amp;#160;Error&amp;#160;code&amp;#160;1&lt;br /&gt;
&lt;br /&gt;
Stop&amp;#160;in&amp;#160;/home/munk/ports/lang/p5-Scalar-List-Utils.&lt;br /&gt;
&amp;#42;&amp;#42;&amp;#42;&amp;#160;Error&amp;#160;code&amp;#160;1&lt;br /&gt;
&lt;br /&gt;
Stop&amp;#160;in&amp;#160;/home/munk/ports/devel/p5-PathTools.&lt;/div&gt;&lt;br /&gt;
&lt;br /&gt;
The problem is that any already installed dependencies - regardless of whether they need upgrading or not - are seen by portupgrade as being installed already and so it refuses to upgrade.  Hence if the port you&#039;re trying to upgrade has a dependency that *also* needs upgrading, this will fail.  Adding &#039;-f&#039; onto the portupgrade line makes no difference.&lt;br /&gt;
&lt;br /&gt;
One solution is to set the environment variable &#039;FORCE_PKG_REGISTER&#039;:&lt;br /&gt;
&lt;br /&gt;
&lt;div class=&quot;bb-code-title&quot;&gt;CODE:&lt;/div&gt;&lt;div class=&quot;bb-code&quot;&gt;setenv&amp;#160;FORCE_PKG_REGISTER&amp;#160;1&lt;/div&gt;&lt;br /&gt;
&lt;br /&gt;
and then run the portupgrade command again.  The installed status of the dependencies are then effectively ignored and the port dependencies are forcibly installed.  Not sure why portupgrade doesn&#039;t upgrade any dependencies automatically - I would have thought any dependencies of a port would be automatically checked for upgrades and upgraded if necessary.  Maybe I&#039;m missing something. 
    </content:encoded>

    <pubDate>Sun, 24 Dec 2006 15:01:00 +0000</pubDate>
    <guid isPermaLink="false">http://freebsd.munk.me.uk/archives/199-guid.html</guid>
    <creativeCommons:license>http://creativecommons.org/licenses/by/2.5/</creativeCommons:license>
</item>
<item>
    <title>Let root see all files with locate</title>
    <link>http://freebsd.munk.me.uk/archives/207-Let-root-see-all-files-with-locate.html</link>
            <category>FreeBSD</category>
            <category>Shell</category>
            <category>SSH</category>
    
    <comments>http://freebsd.munk.me.uk/archives/207-Let-root-see-all-files-with-locate.html#comments</comments>
    <wfw:comment>http://freebsd.munk.me.uk/wfwcomment.php?cid=207</wfw:comment>

    <slash:comments>6</slash:comments>
    <wfw:commentRss>http://freebsd.munk.me.uk/rss.php?version=2.0&amp;type=comments&amp;cid=207</wfw:commentRss>
    

    <author>nospam@example.com (munk)</author>
    <content:encoded>
    The &lt;a href=&quot;http://nixdoc.net/man-pages/FreeBSD/locate.1.html&quot;  title=&quot;locate manpage&quot;&gt;locate&lt;/a&gt; utility on linux was one of the first tools I hit when I made the move to FreeBSD a few years back - knowing where files are is half the battle when you&#039;re trying to configure things and find documentation on how to do it. The trouble with locate though as &lt;a href=&quot;http://freebsd.amazingdev.com/blog/archives/000805.html&quot;  title=&quot;Locate This!&quot;&gt;jdarnold mentions in his article &#039;Locate This!&#039;&lt;/a&gt; is that if you build the locate database as &#039;root&#039;, you end up exposing everything to any user that runs the locate command.  The other problem he mentions is the locate db is only updated weekly on FreeBSD by default via the &lt;a href=&quot;http://www.freebsd.org/cgi/man.cgi?query=periodic&amp;apropos=0&amp;sektion=0&amp;manpath=FreeBSD+6.1-RELEASE&amp;format=html&quot;  title=&quot;periodic manpage&quot;&gt;periodic&lt;/a&gt; system which isn&#039;t really enough if you use your system regularly.&lt;br /&gt;
&lt;br /&gt;
I remember thinking along the same lines a while back and after reading through the man pages the solution I found was to create two separate databases - one for root and one for regular users.  The &#039;regular&#039; db is updated on a weekly basis as per the default on FreeBSD via periodic, whereas the other &#039;root&#039; locate db is built daily in a crontab so I can get the latest up to date details on which files are where.&lt;br /&gt;
&lt;br /&gt;
To get the root db built first you need to create a crontab entry - i put this in /etc/crontab:&lt;br /&gt;
&lt;br /&gt;
&lt;div class=&quot;bb-code-title&quot;&gt;CODE:&lt;/div&gt;&lt;div class=&quot;bb-code&quot;&gt;39&amp;#160;&amp;#160;2&amp;#160;&amp;#160;&amp;#160;&amp;#42;&amp;#160;&amp;#160;&amp;#160;&amp;#42;&amp;#160;&amp;#160;&amp;#160;&amp;#42;&amp;#160;&amp;#160;&amp;#160;root&amp;#160;&amp;#160;&amp;#160;&amp;#160;env&amp;#160;-i&amp;#160;LOCATE_CONFIG=/root/locate/conf/locate.rc&amp;#160;/usr/libexec/locate.updatedb&amp;#160;&amp;#62;&amp;#160;/dev/null&amp;#160;2&amp;#62;&amp;amp;1&lt;/div&gt;&lt;br /&gt;
&lt;br /&gt;
This tells the locate.updatedb script to use a separate configuration file - /root/locate/conf/locate.rc - for building root&#039;s locate db.  The content of /root/locate/conf/locate.rc look like this:&lt;br /&gt;
&lt;br /&gt;
&lt;div class=&quot;bb-code-title&quot;&gt;CODE:&lt;/div&gt;&lt;div class=&quot;bb-code&quot;&gt;FCODES=&quot;/root/locate/db/locate.database.root&quot;&lt;/div&gt;&lt;br /&gt;
&lt;br /&gt;
which indicates that this db should be built in /root/locate/db/locate.database.root instead of the default locate in /var/db/locate.database.  You can safely run the command as root on the commandline to initialize your new db:&lt;br /&gt;
&lt;br /&gt;
&lt;div class=&quot;bb-code-title&quot;&gt;CODE:&lt;/div&gt;&lt;div class=&quot;bb-code&quot;&gt;root@users&amp;#160;/root#&amp;#160;env&amp;#160;-i&amp;#160;LOCATE_CONFIG=/root/locate/conf/locate.rc&amp;#160;/usr/libexec/locate.updatedb&lt;/div&gt;&lt;br /&gt;
&lt;br /&gt;
Once the database is built you can move on to test the new db works ok:&lt;br /&gt;
&lt;br /&gt;
&lt;div class=&quot;bb-code-title&quot;&gt;CODE:&lt;/div&gt;&lt;div class=&quot;bb-code&quot;&gt;root@users&amp;#160;/root#&amp;#160;locate&amp;#160;-d&amp;#160;/root/locate/db/locate.database.root&amp;#160;.cshrc.root&lt;br /&gt;
/root/.cshrc.root&lt;/div&gt;&lt;br /&gt;
&lt;br /&gt;
This file is only readable by root, so it seems to work ok.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
To make things easier, add a shell alias in root&#039;s .cshrc file aliasing &#039;locate&#039; to the command &#039;locate -d /root/locate/db/locate.database.root&#039;:&lt;br /&gt;
&lt;br /&gt;
&lt;div class=&quot;bb-code-title&quot;&gt;CODE:&lt;/div&gt;&lt;div class=&quot;bb-code&quot;&gt;root@users&amp;#160;/root#&amp;#160;grep&amp;#160;locate&amp;#160;$cshrc&lt;br /&gt;
alias&amp;#160;locate&amp;#160;locate&amp;#160;-d&amp;#160;/root/locate/db/locate.database.root&lt;/div&gt;&lt;br /&gt;
&lt;br /&gt;
With the &quot;-d /root/locate/db/locate.database.root&quot; switch, locate will use the db at /root/locate/db/locate.database.root instead of the default /var/db/locate.database and root will be able to use locate to find any files in the filesystem, not just those that are world readable.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Finally, one way to update the regular locate db as root but without making it list every world readable file is to perform the following:&lt;br /&gt;
&lt;br /&gt;
&lt;div class=&quot;bb-code-title&quot;&gt;CODE:&lt;/div&gt;&lt;div class=&quot;bb-code&quot;&gt;#!/bin/sh&lt;br /&gt;
#&amp;#160;make&amp;#160;sure&amp;#160;db&amp;#160;file&amp;#160;exists&amp;#58;&lt;br /&gt;
touch&amp;#160;/var/db/locate.database&lt;br /&gt;
&lt;br /&gt;
#&amp;#160;then&amp;#160;change&amp;#160;ownership&amp;#160;to&amp;#160;the&amp;#160;nobody&amp;#160;user&amp;#58;&lt;br /&gt;
chown&amp;#160;nobody&amp;#160;/var/db/locate.database&lt;br /&gt;
&lt;br /&gt;
#&amp;#160;make&amp;#160;it&amp;#160;writeable&amp;#160;by&amp;#160;nobody&amp;#160;and&amp;#160;readable&amp;#160;by&amp;#160;everyone&amp;#160;else&amp;#58;&lt;br /&gt;
chmod&amp;#160;644&amp;#160;/var/db/locate.database&amp;#160;&lt;br /&gt;
&lt;br /&gt;
#&amp;#160;then&amp;#160;move&amp;#160;on&amp;#160;to&amp;#160;update&amp;#160;the&amp;#160;db...&lt;br /&gt;
#&amp;#160;first&amp;#160;make&amp;#160;sure&amp;#160;we&#039;re&amp;#160;in&amp;#160;the&amp;#160;/&amp;#160;folder&amp;#160;where&amp;#160;the&amp;#160;db&amp;#160;update&amp;#160;starts&amp;#58;&lt;br /&gt;
cd&amp;#160;/&amp;#160;&lt;br /&gt;
&lt;br /&gt;
#&amp;#160;then&amp;#160;finally&amp;#160;run&amp;#160;the&amp;#160;updatedb&amp;#160;command&amp;#160;as&amp;#160;the&amp;#160;&#039;nobody&#039;&amp;#160;user&amp;#58;&lt;br /&gt;
echo&amp;#160;&quot;/usr/libexec/locate.updatedb&quot;&amp;#160;|&amp;#160;su&amp;#160;-&amp;#160;-fm&amp;#160;nobody&lt;/div&gt;&lt;br /&gt;
&lt;br /&gt;
This is basically what the 310.locate periodic script does and results in a locate db that contains only files that are readable by the &#039;nobody&#039; user - essentially all &#039;world readable&#039; files.&lt;br /&gt;
&lt;br /&gt;
Comparing the sizes of the root db against the nobody db:&lt;br /&gt;
&lt;br /&gt;
&lt;div class=&quot;bb-code-title&quot;&gt;CODE:&lt;/div&gt;&lt;div class=&quot;bb-code&quot;&gt;root@users&amp;#160;/#&amp;#160;ls&amp;#160;-al&amp;#160;/var/db/locate.database&amp;#160;/root/locate/db/locate.database.root&lt;br /&gt;
-rw-r--r--&amp;#160;&amp;#160;1&amp;#160;root&amp;#160;&amp;#160;&amp;#160;&amp;#160;wheel&amp;#160;&amp;#160;4070484&amp;#160;Nov&amp;#160;18&amp;#160;02&amp;#58;45&amp;#160;/root/locate/db/locate.database.root&lt;br /&gt;
-rw-r--r--&amp;#160;&amp;#160;1&amp;#160;nobody&amp;#160;&amp;#160;wheel&amp;#160;&amp;#160;3280409&amp;#160;Nov&amp;#160;18&amp;#160;11&amp;#58;41&amp;#160;/var/db/locate.database&lt;/div&gt;&lt;br /&gt;
&lt;br /&gt;
You can see the size difference there, not as many entries in nobody&#039;s db as root&#039;s.  Just to double check:&lt;br /&gt;
&lt;br /&gt;
&lt;div class=&quot;bb-code-title&quot;&gt;CODE:&lt;/div&gt;&lt;div class=&quot;bb-code&quot;&gt;root@users&amp;#160;/root#&amp;#160;locate&amp;#160;.cshrc.root&lt;br /&gt;
/root/bin/ktrace.out&lt;br /&gt;
/root/ktrace.out&lt;br /&gt;
/usr/local/etc/snort/ktrace.out&lt;br /&gt;
root@users&amp;#160;/root#&amp;#160;echo&amp;#160;&quot;locate&amp;#160;ktrace.out&quot;&amp;#160;|&amp;#160;su&amp;#160;-&amp;#160;-fm&amp;#160;nobody&lt;br /&gt;
/usr/local/etc/snort/ktrace.out&lt;/div&gt;&lt;br /&gt;
&lt;br /&gt;
So from that you can see that &#039;nobody&#039; can see the ktrace.out files located in /root - apart from root of course :)  Sorted. 
    </content:encoded>

    <pubDate>Sat, 18 Nov 2006 10:38:40 +0000</pubDate>
    <guid isPermaLink="false">http://freebsd.munk.me.uk/archives/207-guid.html</guid>
    <creativeCommons:license>http://creativecommons.org/licenses/by/2.5/</creativeCommons:license>
</item>
<item>
    <title>FreeBSD 6.2 To Include Security Event Auditing</title>
    <link>http://freebsd.munk.me.uk/archives/206-FreeBSD-6.2-To-Include-Security-Event-Auditing.html</link>
            <category>FreeBSD</category>
            <category>Security</category>
    
    <comments>http://freebsd.munk.me.uk/archives/206-FreeBSD-6.2-To-Include-Security-Event-Auditing.html#comments</comments>
    <wfw:comment>http://freebsd.munk.me.uk/wfwcomment.php?cid=206</wfw:comment>

    <slash:comments>0</slash:comments>
    <wfw:commentRss>http://freebsd.munk.me.uk/rss.php?version=2.0&amp;type=comments&amp;cid=206</wfw:commentRss>
    

    <author>nospam@example.com (munk)</author>
    <content:encoded>
    Just read an interesting article about &lt;a href=&quot;http://www.securityfocus.com/columnists/422/&quot;  title=&quot;Security Event Auditing in FreeBSD 6.2&quot;&gt; the addition of &#039;Security Event Auditing&#039; in FreeBSD 6.2&lt;/a&gt;.  Until now FreeBSD hasn&#039;t had any really useful security auditing other than using &#039;accounting&#039; to log all syscalls which at best was confusing when it came to working out who did what when and how.&lt;br /&gt;
&lt;br /&gt;
At one time &lt;a href=&quot;http://freebsd.munk.me.uk/archives/112-Installed-and-Configured-lrexec-module-For-Logging-System-Calls.html#extended&quot;  title=&quot;lrexec kernel module security logging on FreeBSD&quot;&gt;I installed a kernel module lrexec to log all system exec calls&lt;/a&gt;, but this was also quite a handful to configure scripts so they reported only on certain users.  Hopefully this new security auditing daemon will make security auditing a lot easier on FreeBSD.  &lt;br /&gt;
&lt;br /&gt;
Read the article for more info on what&#039;s new:&lt;br /&gt;
&lt;a href=&quot;http://www.securityfocus.com/columnists/422/&quot;  title=&quot;Security Event Auditing in FreeBSD 6.2&quot;&gt; Security Event Auditing in FreeBSD 6.2&lt;/a&gt;&lt;br /&gt;
&lt;br /&gt;
Also of interest is the new addition to the FreeBSD handbook on security auditing:&lt;br /&gt;
&lt;a href=&quot;http://www.freebsd.org/doc/en_US.ISO8859-1/books/handbook/audit.html&quot;  title=&quot;Security event auditing in FreeBSD handbook&quot;&gt;FreeBSD Handbook: Security Event Auditing&lt;/a&gt; 
    </content:encoded>

    <pubDate>Tue, 14 Nov 2006 16:38:39 +0000</pubDate>
    <guid isPermaLink="false">http://freebsd.munk.me.uk/archives/206-guid.html</guid>
    <creativeCommons:license>http://creativecommons.org/licenses/by/2.5/</creativeCommons:license>
</item>
<item>
    <title>Expand shell globs using 'ctrl-z'</title>
    <link>http://freebsd.munk.me.uk/archives/205-Expand-shell-globs-using-ctrl-z.html</link>
            <category>Shell</category>
    
    <comments>http://freebsd.munk.me.uk/archives/205-Expand-shell-globs-using-ctrl-z.html#comments</comments>
    <wfw:comment>http://freebsd.munk.me.uk/wfwcomment.php?cid=205</wfw:comment>

    <slash:comments>2</slash:comments>
    <wfw:commentRss>http://freebsd.munk.me.uk/rss.php?version=2.0&amp;type=comments&amp;cid=205</wfw:commentRss>
    

    <author>nospam@example.com (munk)</author>
    <content:encoded>
    Just noticed a semi useful feature of the CSH shell (shells in general? not tested it) whilst running &#039;rm -rf *&#039; in a directory.  Got a bit paranoid I was doing something silly (running the command as root), so hit &#039;ctrl-z&#039; to put the process into the background and the &#039;*&#039; part was expanded in the job control list:&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;div class=&quot;bb-code-title&quot;&gt;CODE:&lt;/div&gt;&lt;div class=&quot;bb-code&quot;&gt;&amp;#91;11&amp;#58;21&amp;#58;24&amp;#93;&amp;#160;root@users&amp;#160;/usr/local/www/web/torrentflux.munk.me.uk#&amp;#160;rm&amp;#160;-rf&amp;#160;&amp;#42;&lt;br /&gt;
^Z&lt;br /&gt;
&amp;#91;1&amp;#93;&amp;#160;&amp;#160;+&amp;#160;Suspended&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;rm&amp;#160;-rf&amp;#160;TF_BitTornado&amp;#160;adodb&amp;#160;downloads&amp;#160;images&amp;#160;language&amp;#160;mods&amp;#160;searchEngines&amp;#160;themes&lt;/div&gt;&lt;br /&gt;
&lt;br /&gt;
Yay.  Useful tip #341 you&#039;ll probably never use but at some point in the future think mmm... now where did I read about that thing about this thing... 
    </content:encoded>

    <pubDate>Sun, 05 Nov 2006 11:22:58 +0000</pubDate>
    <guid isPermaLink="false">http://freebsd.munk.me.uk/archives/205-guid.html</guid>
    <creativeCommons:license>http://creativecommons.org/licenses/by/2.5/</creativeCommons:license>
</item>
<item>
    <title>Firefox 2.0 Released</title>
    <link>http://freebsd.munk.me.uk/archives/204-Firefox-2.0-Released.html</link>
            <category>Firefox</category>
            <category>WWW</category>
    
    <comments>http://freebsd.munk.me.uk/archives/204-Firefox-2.0-Released.html#comments</comments>
    <wfw:comment>http://freebsd.munk.me.uk/wfwcomment.php?cid=204</wfw:comment>

    <slash:comments>0</slash:comments>
    <wfw:commentRss>http://freebsd.munk.me.uk/rss.php?version=2.0&amp;type=comments&amp;cid=204</wfw:commentRss>
    

    <author>nospam@example.com (munk)</author>
    <content:encoded>
    &lt;strong&gt;UPDATE:&lt;/strong&gt;&lt;br /&gt;
Here&#039;s a list of the pros I found about 2.0 so far:&lt;br /&gt;
&lt;br /&gt;
&lt;ul&gt;&lt;li/&gt;Memory usage actually seems to have gone down somewhat - ok ok it probably couldn&#039;t have gotten any worse!  I was half expecting memory to go through the roof with 2.0, but surprisingly it seems to actually free up memory ok when you close a lot of tabs or excess windows.&lt;br /&gt;
&lt;li/&gt;Generally speed wise, pages seem to load a lot faster than before.&lt;br /&gt;
&lt;li/&gt;Recently closed tabs are available via the history file menu.  Can&#039;t remember that being there in 1.5.  &lt;br /&gt;
The number of days of browsing history to keep track of also seems to be configurable in Firefox 2.0 - maybe it was in 1.5, can&#039;t remember seeing it obviously though.&lt;br /&gt;
&lt;li/&gt;Built in anti phishing tool is pretty nifty.  Tried browsing to a phishing spam mail sent to my gmail account and Firefox spotted the site was fake, blacked the window out and popped up a warning instead with a few options on it - all in a jedi mind concentrate stylee.  Smart.&lt;br /&gt;
&lt;li/&gt;Updates to extensions are now listed in a separate tab when they&#039;re found in the &#039;add ons&#039; window (Tools, Options).  Makes it easier than paging down through pages of extensions looking for the ones that have updates.&lt;br /&gt;
&lt;li/&gt;Interface is v snazmondo :D&lt;br /&gt;
&lt;/ul&gt;&lt;br /&gt;
&lt;br /&gt;
And here&#039;s a list of the cons I have so far - so far it&#039;s mainly to do with tabs:&lt;br /&gt;
&lt;br /&gt;
&lt;ul&gt;&lt;li/&gt;Tabs in 2.0 now have individual &#039;X&#039;/close buttons on them.  I find this quite annoying - apart from taking up extra space on the tab bar, the close buttons are now harder to hit with the mouse than they used to be.  In 1.5 the X button was always to the far right of the tab bar, but now it&#039;s in a more random place on the tab bar depending on what tab you&#039;re reading/wanting to close.  In 1.5 I&#039;d just hover over to the right of the tab bar, whack on the close button and job done.  Now though in 2.0 there&#039;s a split second where I have to think &#039;mmm where&#039;s the X this time then...?&#039;.  Minor annoyance but no doubt I&#039;ll get used to it.&lt;br /&gt;
&lt;br /&gt;
&lt;strong&gt;UPDATE:&lt;/strong&gt;As soon as I&#039;d written this, sods law, the first thing I read was an &lt;a href=&quot;http://blog.wired.com/monkeybites/2006/10/the_firefox_has.html&quot;  title=&quot;Wired article, firefox 2.0 pros and cons&quot;&gt;article about pros/cons of Firefox 2.0 on Wired&lt;/a&gt; with a fix for the problem - just change &#039;browser.tabs.CloseButtons&#039; in about:config to 3 instead of the default of 1.  Still think this sucks though having to use about:config to change this kind of thing.  Also there&#039;s something in those comments about setting Firefox to not resize images automatically - the option to do that has now dissappeared in Firefox 2.0 - you have to change stuff in about:config to fix the problem.  That&#039;s another gripe I did notice but didn&#039;t think too much about last night.&lt;br /&gt;
&lt;br /&gt;
&lt;li/&gt;Come to think about it I don&#039;t like the drop down button that lists all the current tabs open either.  Again there&#039;s a fix but it involves editing the userChrome.css file found in the Firefox profile folder.  &lt;br /&gt;
&lt;br /&gt;
&lt;a href=&quot;http://mozillalinks.org/wp/2006/10/firefox-2-tweaks-tab-browsing/&quot;  title=&quot;Tab tweaks for Firefox 2.0&quot;&gt;Here is a list of other tab tweaks for Firefox 2.0.&lt;/a&gt;&lt;br /&gt;
&lt;br /&gt;
&lt;li/&gt;There&#039;s a new feature to allow Firefox to restart itself after extensions etc have installed themselves.  Unfortunately though this useful feature doesn&#039;t seem to have a user interface - it&#039;s only available to extension installations (and themes?).  It&#039;d be good to be able to restart the browser when you make changes in the &#039;Addons&#039; window - for example when you disable/enable some extension or another and want to restart the browser but keep your session going.&lt;br /&gt;
&lt;br /&gt;
&lt;li/&gt;Too much faffing around in about:config!!! &lt;br /&gt;
&lt;br /&gt;
&lt;li/&gt;Ok, yet another problem that needs config changing to fix it.  I&#039;m not mad about the &#039;restore from crash&#039; functionality - if firefox crashes it automatically restores the last &#039;session&#039; - group of windows/tabs.  Unfortunately I often close my machine down using the power button on the PC and any open windows are &#039;gracelessly&#039; killed - so next time I boot up, Firefox cheerfully asks me if I want to restore the crashed session which isn&#039;t really what I want and is quite annoying tbh.&lt;br /&gt;
&lt;br /&gt;
The resolution is - surprise surprise yet another hack - to edit the config so the value of the boolean config option &lt;a href=&quot;http://kb.mozillazine.org/Browser.sessionstore.resume_from_crash&quot;  title=&quot;http://kb.mozillazine.org/Browser.sessionstore.resume_from_crash&quot;&gt;browser.sessionstore.resume_from_crash&lt;/a&gt; is set to false.  In my case the key didn&#039;t even exist so I had to create it first and set it to &#039;false&#039;.  Haven&#039;t actually tested it out yet but presumably it works and doesn&#039;t give the annoying nag about resuming the session after a &#039;crash&#039;.&lt;br /&gt;
&lt;/ul&gt;&lt;br /&gt;
&lt;br /&gt;
Have to say all these config changes I&#039;ve had to make so far are pretty tedious and if it weren&#039;t for this article I&#039;d probably forget how I did it all if I needed to reinstall.  By the same token though the very fact you can hack away at the config at all via about:config so easily is quite nice.&lt;br /&gt;
&lt;br /&gt;
&lt;hr/&gt;&lt;br /&gt;
&lt;a href=&quot;http://www.mozilla.com/en-US/firefox/2.0/releasenotes/&quot;  title=&quot;Firefox 2.0 Release Notes&quot;&gt;Mozilla have just released a new point version of Firefox, version 2.0&lt;/a&gt;.  I held off installing and testing the beta/release candidate versions for a while because so many of the extensions I use wouldn&#039;t work with 2.0, but now 2.0 is officially out it seems most of my extensions now work ok.&lt;br /&gt;
&lt;br /&gt;
There were 6 extensions that weren&#039;t compatible with 2.0 - most of them I could live without, but there was one, &lt;a href=&quot;http://www.pikey.me.uk/mozilla/?extension=cw&quot;  title=&quot;Clone Window Firefox Extension&quot;&gt;Clone Window&lt;/a&gt;, that I really couldn&#039;t do without.  Clone window allows you to create a new tab/window with the history of the tab/window it was cloned from, without this the world just isn&#039;t right, bit like going out on the tiles for a few beers and waking up the next morning wondering how the fsck you ended up in a tent. :D&lt;br /&gt;
&lt;br /&gt;
I ended up finding a similar extension called &lt;a href=&quot;http://twanno.mozdev.org/duplicatetab/index.html&quot;  title=&quot;Duplicate Tab Firefox Extension&quot;&gt;Duplicate Tabs&lt;/a&gt; which effectively does the same thing as Clone Window and more even.  As well as creating clone tabs/windows, it even allows you to merge all open windows or a selection of open tabs into one window which is quite cool (not sure how much I&#039;ll use it but it&#039;s a good idea none the less).&lt;br /&gt;
&lt;br /&gt;
Only trouble with the Duplicate Tabs extension is that the default key mapping to clone a tab - ctrl-shift-t - wouldn&#039;t work.  Turns out that mapping was already in use by the &lt;a href=&quot;http://chrispederick.com/work/webdeveloper/&quot;  title=&quot;Web Developer Firefox Extension&quot;&gt;Web Developer extension&lt;/a&gt; - tried changing the mapping in the web developer options, but that didn&#039;t seem to make any difference which was annoying.  &lt;br /&gt;
&lt;br /&gt;
Eventually tried to change the mapping using &lt;em&gt;yet another&lt;/em&gt; extension called &lt;a href=&quot;http://forums.mozillazine.org/viewtopic.php?t=72994&quot;  title=&quot;Keyconfig Extension&quot;&gt;keyconfig&lt;/a&gt; - although annoyingly keyconfig wouldn&#039;t install because it wasn&#039;t compatible with 2.0! Grr... so I&#039;ve now kind of hacked things up so it WOULD install by adding a boolean key &lt;a href=&quot;http://kb.mozillazine.org/Extensions.checkCompatibility&quot;  title=&quot;http://kb.mozillazine.org/Extensions.checkCompatibility&quot;&gt;extensions.checkCompatibility&lt;/a&gt; in about:config in Firefox and setting it to false - this stops Firefox checking the compatibility of extensions when they&#039;re installed or started with Firefox.  Not entirely sure this is a good thing yet since it&#039;s now enabled all the extensions (those 6 above) that weren&#039;t compatible with 2.0 and there&#039;s a chance that might cause problems.  Will see.&lt;br /&gt;
&lt;br /&gt;
Generally though moving to Firefox 2.0 actually seems like a positive experience - browsing does seem to be faster in some unquantifiable way.  Whether this is just the smoother looking interface making things seem quicker... I don&#039;t think it is... pages actually do seem to load faster now so I&#039;m a happy bunny right now.  Once all my extensions are compatible without forcing them I&#039;ll be even happier :)&lt;br /&gt;
&lt;br /&gt;
If you&#039;ve not upgraded as yet, I&#039;d recommend it now it&#039;s offical.&lt;br /&gt;
&lt;br /&gt;
I&#039;ll add any extra comments about my experience as I go on.&lt;br /&gt;
 
    </content:encoded>

    <pubDate>Sat, 28 Oct 2006 01:57:00 +0000</pubDate>
    <guid isPermaLink="false">http://freebsd.munk.me.uk/archives/204-guid.html</guid>
    <creativeCommons:license>http://creativecommons.org/licenses/by/2.5/</creativeCommons:license>
</item>
<item>
    <title>Modsecurity 2.0 Released</title>
    <link>http://freebsd.munk.me.uk/archives/203-Modsecurity-2.0-Released.html</link>
            <category>Apache</category>
            <category>Security</category>
    
    <comments>http://freebsd.munk.me.uk/archives/203-Modsecurity-2.0-Released.html#comments</comments>
    <wfw:comment>http://freebsd.munk.me.uk/wfwcomment.php?cid=203</wfw:comment>

    <slash:comments>0</slash:comments>
    <wfw:commentRss>http://freebsd.munk.me.uk/rss.php?version=2.0&amp;type=comments&amp;cid=203</wfw:commentRss>
    

    <author>nospam@example.com (munk)</author>
    <content:encoded>
    A new version of mod_security has just been released - 2.0 - complete with a total rewrite that includes a number of new features.  &lt;a href=&quot;http://www.theregister.co.uk/2006/10/19/modsecurity_2_release/&quot;  title=&quot;modsecurity mod_security releases 2.0&quot;&gt;El reg is running an article on the new release which includes an interview with ModSecurity&#039;s author Ivan Ristic&lt;/a&gt;.&lt;br /&gt;
&lt;br /&gt;
mod_security is an apache module for monitoring requests made to a web server and acting on those requests according to rules - useful for blocking malicious bots, stopping web spammers and so on.  I&#039;ve been using it for a few years now and it handles blocking of weblog spammers and trojan worms/bots very well, though it has to be said the configuration isn&#039;t the simplest of all time.&lt;br /&gt;
&lt;br /&gt;
Hopefully this configuration issue might be made easier with the also newly released &lt;a href=&quot;http://www.modsecurity.org/projects/console/index.html&quot;  title=&quot;modsecurity console&quot;&gt;modsecurity console&lt;/a&gt;, although reading through that page it doesn&#039;t seem to mention anything about using it to configure mod_security...  Will have a look at it later and see what&#039;s what.&lt;br /&gt;
&lt;br /&gt;
A list of the new features or improved features in ModSecurity 2.0 - taken from the article above:&lt;br /&gt;
&lt;br /&gt;
&lt;ul&gt;&lt;li&gt;Five processing phases (where there were only two in 1.9.x). These are: request headers, request body, response headers, response body, and logging. Those users who wanted to do things at the earliest possible moment can do them now.&lt;/li&gt;&lt;br /&gt;
&lt;li&gt;Per-rule transformation options (previously normalisation was implicit and hard-coded). Many new transformation functions were added.&lt;/li&gt;&lt;br /&gt;
&lt;li&gt;Transaction variables. This can be used to store pieces of data, create a transaction anomaly score, and so on.&lt;/li&gt;&lt;br /&gt;
&lt;li&gt;Data persistence (can be configured any way you want although most people will want to use this feature to track IP addresses, application sessions, and application users).&lt;/li&gt;&lt;br /&gt;
&lt;li&gt;Support for anomaly scoring and basic event correlation (counters can be automatically decreased over time; variables can be expired).&lt;/li&gt;&lt;br /&gt;
&lt;li&gt;Support for web applications and session IDs.&lt;/li&gt;&lt;br /&gt;
&lt;li&gt;Regular Expression back-references (allows one to create custom variables using transaction content).&lt;/li&gt;&lt;br /&gt;
&lt;li&gt;There are now many functions that can be applied to the variables (where previously one could only use regular expressions).&lt;/li&gt;&lt;br /&gt;
&lt;li&gt;XML support (parsing, validation, XPath).&lt;/li&gt;&lt;/ul&gt;&lt;br /&gt;
&lt;br /&gt;
The article is well worth reading if you already use ModSecurity - particularly if you&#039;re interested in moving from just simple blocking and logging of requests as in mod_security 1.0 to a more sophisticated web application firewalling system - mod_security 2.0.  2.0 includes a pseudo web app firewalling programming language making it easy to manipulate and process HTTP in a stateful manner - tracking HTTP sessions per IP in real time for example or perhaps watching for anomalous web activity and then flagging any IP that transgresses behaviour deemed as acceptable and watching for that IP in the future. 
    </content:encoded>

    <pubDate>Fri, 20 Oct 2006 14:24:52 +0000</pubDate>
    <guid isPermaLink="false">http://freebsd.munk.me.uk/archives/203-guid.html</guid>
    <creativeCommons:license>http://creativecommons.org/licenses/by/2.5/</creativeCommons:license>
</item>
<item>
    <title>CSH Tips: Auto 'whereis' on the tcsh command line</title>
    <link>http://freebsd.munk.me.uk/archives/202-CSH-Tips-Auto-whereis-on-the-tcsh-command-line.html</link>
            <category>Shell</category>
    
    <comments>http://freebsd.munk.me.uk/archives/202-CSH-Tips-Auto-whereis-on-the-tcsh-command-line.html#comments</comments>
    <wfw:comment>http://freebsd.munk.me.uk/wfwcomment.php?cid=202</wfw:comment>

    <slash:comments>0</slash:comments>
    <wfw:commentRss>http://freebsd.munk.me.uk/rss.php?version=2.0&amp;type=comments&amp;cid=202</wfw:commentRss>
    

    <author>nospam@example.com (munk)</author>
    <content:encoded>
    Just read &lt;a href=&quot;http://freebsd.amazingdev.com/blog/archives/000776.html&quot;  title=&quot;whereis &quot;&gt;this entry&lt;/a&gt; about the &#039;whereis&#039; command on Unix and it reminded me of another great shell tip for tcsh users (csh/tcsh on FreeBSD since they&#039;re the same thing!) - the shell can &#039;normalize&#039; any command on the command line if you bind the normalize function to a keystroke - this allows you to easily see how a command would expand after it&#039;s executed.  Somewhat esoteric without an example, but I use it so much I thought I&#039;d post about it.&lt;br /&gt;
&lt;br /&gt;
First off set a key binding for the normalize command - in the shell type in:&lt;br /&gt;
&lt;br /&gt;
&lt;div class=&quot;bb-code-title&quot;&gt;CODE:&lt;/div&gt;&lt;div class=&quot;bb-code&quot;&gt;bindkey&amp;#160;&quot;^W&quot;&amp;#160;normalize-command&lt;/div&gt;&lt;br /&gt;
&lt;br /&gt;
or add it to ~/.cshrc to make it permanent.  Obviously you can set it to whatever keybinding you want, I use ctrl-w.&lt;br /&gt;
&lt;br /&gt;
Now type in any command that you&#039;d use on the commandline and then whilst the cursor is at the end of the command, hit the keystroke you entered for the normalize command - in our case above, ctrl-w.&lt;br /&gt;
&lt;br /&gt;
The command you entered should automatically get expanded to the absolute path of the command.  For example if I type in:&lt;br /&gt;
&lt;br /&gt;
&lt;div class=&quot;bb-code-title&quot;&gt;CODE:&lt;/div&gt;&lt;div class=&quot;bb-code&quot;&gt;ls&lt;/div&gt;&lt;br /&gt;
&lt;br /&gt;
and then hit &#039;ctrl-w&#039; whilst the cursor is just after the &#039;s&#039;, the result will look like:&lt;br /&gt;
&lt;br /&gt;
&lt;div class=&quot;bb-code-title&quot;&gt;CODE:&lt;/div&gt;&lt;div class=&quot;bb-code&quot;&gt;/bin/ls&lt;/div&gt;&lt;br /&gt;
&lt;br /&gt;
Magic!  &lt;br /&gt;
&lt;br /&gt;
Like I say I use this function quite a lot on the commandline, particularly when I want to see how a command I enter will get expanded - the normalize function works on aliases as well as just plain commands, so it&#039;s quicker to type &#039;portupgrade^w&#039; than to type in &#039;alias portupgrade&#039; to see how I&#039;ve got my portupgrade alias set up.   It&#039;s also great for quickly editing system executables from the commandline without having to remember where the file/script is or cut/paste the results from &#039;whereis&#039; or &#039;locate&#039; etc.&lt;br /&gt;
 
    </content:encoded>

    <pubDate>Wed, 18 Oct 2006 00:10:26 +0000</pubDate>
    <guid isPermaLink="false">http://freebsd.munk.me.uk/archives/202-guid.html</guid>
    <creativeCommons:license>http://creativecommons.org/licenses/by/2.5/</creativeCommons:license>
</item>
<item>
    <title>Shell Tip: Review your most commonly used command lines</title>
    <link>http://freebsd.munk.me.uk/archives/201-Shell-Tip-Review-your-most-commonly-used-command-lines.html</link>
            <category>Shell</category>
    
    <comments>http://freebsd.munk.me.uk/archives/201-Shell-Tip-Review-your-most-commonly-used-command-lines.html#comments</comments>
    <wfw:comment>http://freebsd.munk.me.uk/wfwcomment.php?cid=201</wfw:comment>

    <slash:comments>0</slash:comments>
    <wfw:commentRss>http://freebsd.munk.me.uk/rss.php?version=2.0&amp;type=comments&amp;cid=201</wfw:commentRss>
    

    <author>nospam@example.com (munk)</author>
    <content:encoded>
    Just got through reading an interesting article on &lt;a href=&quot;http://www.lifehacker.com/software/unix/review-your-most-oftused-unix-commands-202712.php&quot;  title=&quot;review commonly used unix commandlines&quot;&gt;how to review your most commonly used Unix commands&lt;/a&gt;.  The idea is to sort the most commonly used commands numerically with a view to maybe shortening the most command ones using aliases, similar in a way to the time saving article mentioned &lt;a href=&quot;http://freebsd.munk.me.uk/archives/177-CSH-Tips-Create-Variables-Everywhere.html&quot;  title=&quot;Shell Shortcuts&quot;&gt;here&lt;/a&gt; a while ago.&lt;br /&gt;
&lt;br /&gt;
(The lifehacker article is actually just picking up on the original article on IBM&#039;s site entitled &lt;a href=&quot;http://www-128.ibm.com/developerworks/aix/library/au-productivitytips.html?ca=dgr-lnxw07UNIX-Office-Tips&quot;  title=&quot;Unix productivity tips&quot;&gt;Unix productivity tips&lt;/a&gt; and is a good read for anyone wanting to improve their efficiency on the shell command line.)&lt;br /&gt;
&lt;br /&gt;
Note for tcsh on FreeBSD, the command you probably want to use is this:&lt;br /&gt;
&lt;br /&gt;
&lt;div class=&quot;bb-code-title&quot;&gt;CODE:&lt;/div&gt;&lt;div class=&quot;bb-code&quot;&gt;history&amp;#160;|&amp;#160;tail&amp;#160;-1000&amp;#160;|&amp;#160;awk&amp;#160;&#039;{print&amp;#160;$3}&#039;&amp;#160;|&amp;#160;sort&amp;#160;|&amp;#160;uniq&amp;#160;-c&amp;#160;|&amp;#160;sort&amp;#160;-r&lt;/div&gt;&lt;br /&gt;
&lt;br /&gt;
which outputs this kind of list for my shell history (listing top 10 used commands using &#039;| head -10&#039;):&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;div class=&quot;bb-code-title&quot;&gt;CODE:&lt;/div&gt;&lt;div class=&quot;bb-code&quot;&gt;;&amp;#160;history&amp;#160;|&amp;#160;tail&amp;#160;-1000&amp;#160;|&amp;#160;awk&amp;#160;&#039;{print&amp;#160;$3}&#039;&amp;#160;|&amp;#160;sort&amp;#160;|&amp;#160;uniq&amp;#160;-c&amp;#160;|&amp;#160;sort&amp;#160;-r&amp;#160;|&amp;#160;head&amp;#160;-10&lt;br /&gt;
&amp;#160;212&amp;#160;sc&lt;br /&gt;
&amp;#160;158&amp;#160;m&lt;br /&gt;
&amp;#160;&amp;#160;96&amp;#160;fg&lt;br /&gt;
&amp;#160;&amp;#160;75&amp;#160;s&lt;br /&gt;
&amp;#160;&amp;#160;68&amp;#160;cd&lt;br /&gt;
&amp;#160;&amp;#160;56&amp;#160;vi&lt;br /&gt;
&amp;#160;&amp;#160;37&amp;#160;ls&lt;br /&gt;
&amp;#160;&amp;#160;26&amp;#160;grep&lt;br /&gt;
&amp;#160;&amp;#160;19&amp;#160;man&lt;br /&gt;
&amp;#160;&amp;#160;18&amp;#160;alias&lt;/div&gt;&lt;br /&gt;
&lt;br /&gt;
I&#039;m pretty happy with that, most of the commands are either 1 or 2 character aliases at least :) 
    </content:encoded>

    <pubDate>Tue, 10 Oct 2006 00:22:47 +0000</pubDate>
    <guid isPermaLink="false">http://freebsd.munk.me.uk/archives/201-guid.html</guid>
    <creativeCommons:license>http://creativecommons.org/licenses/by/2.5/</creativeCommons:license>
</item>

</channel>
</rss>