<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
	>

<channel>
	<title>rugmonster.org</title>
	<atom:link href="http://rugmonster.org/feed/" rel="self" type="application/rss+xml" />
	<link>http://rugmonster.org</link>
	<description>sys admin guides, tips and one-liners</description>
	<lastBuildDate>Thu, 28 Jan 2010 04:48:05 +0000</lastBuildDate>
	<generator>http://wordpress.org/?v=2.9.2</generator>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
			<item>
		<title>Simple activity report from FTP xferlog</title>
		<link>http://rugmonster.org/2010/01/xferlog-activity/</link>
		<comments>http://rugmonster.org/2010/01/xferlog-activity/#comments</comments>
		<pubDate>Thu, 28 Jan 2010 04:45:16 +0000</pubDate>
		<dc:creator>Rugmonster</dc:creator>
				<category><![CDATA[Linux]]></category>
		<category><![CDATA[AWK]]></category>
		<category><![CDATA[bash]]></category>
		<category><![CDATA[FTP]]></category>
		<category><![CDATA[log analysis]]></category>

		<guid isPermaLink="false">http://rugmonster.org/?p=10</guid>
		<description><![CDATA[UPDATE: I found that what I originally posted was wrong and didn&#8217;t work at all. I don&#8217;t know how I managed to do that, but I&#8217;ve fixed it and it&#8217;s verified as working now.
I was asked if there was a way to extract the FTP activity to be emailed to someone. The server had a [...]]]></description>
			<content:encoded><![CDATA[<p>UPDATE: I found that what I originally posted was wrong and didn&#8217;t work at all. I don&#8217;t know how I managed to do that, but I&#8217;ve fixed it and it&#8217;s verified as working now.</p>
<p>I was asked if there was a way to extract the FTP activity to be emailed to someone. The server had a typical xferlog, but the box was being used for shared hosting and the reports didn&#8217;t need to include results for all of the other sites.</p>
<p>I put together the following script to extract the activity and transpose it to a more friendlier output.<span id="more-10"></span></p>

<div class="wp_syntax"><div class="code"><pre class="bash" style="font-family:monospace;"><span style="color: #666666; font-style: italic;">#!/bin/bash</span>
&nbsp;
<span style="color: #000000; font-weight: bold;">if</span> <span style="color: #7a0874; font-weight: bold;">&#91;</span><span style="color: #7a0874; font-weight: bold;">&#91;</span> <span style="color: #660033;">-z</span> $<span style="color: #000000;">1</span> <span style="color: #000000; font-weight: bold;">||</span> <span style="color: #660033;">-z</span> $<span style="color: #000000;">2</span> <span style="color: #7a0874; font-weight: bold;">&#93;</span><span style="color: #7a0874; font-weight: bold;">&#93;</span>
<span style="color: #000000; font-weight: bold;">then</span>
        <span style="color: #7a0874; font-weight: bold;">echo</span> <span style="color: #ff0000;">&quot;Usage: $0 &lt;PATTERN&gt; &lt;XFERLOG&gt;&quot;</span>
        <span style="color: #7a0874; font-weight: bold;">exit</span> <span style="color: #000000;">1</span>
<span style="color: #000000; font-weight: bold;">fi</span>
&nbsp;
<span style="color: #000000; font-weight: bold;">if</span> <span style="color: #7a0874; font-weight: bold;">&#91;</span> <span style="color: #000000; font-weight: bold;">!</span> <span style="color: #660033;">-f</span> $<span style="color: #000000;">2</span> <span style="color: #7a0874; font-weight: bold;">&#93;</span>
<span style="color: #000000; font-weight: bold;">then</span>
        <span style="color: #7a0874; font-weight: bold;">echo</span> <span style="color: #ff0000;">&quot;Log file does not exist&quot;</span>
        <span style="color: #7a0874; font-weight: bold;">exit</span> <span style="color: #000000;">1</span>
<span style="color: #000000; font-weight: bold;">fi</span>
&nbsp;
<span style="color: #c20cb9; font-weight: bold;">awk</span> <span style="color: #ff0000;">&quot;/$1/&quot;</span><span style="color: #ff0000;">' {
        gsub(&quot; d &quot;,&quot; deleted &quot;);
        gsub(&quot; o &quot;,&quot; downloaded &quot;);
        gsub(&quot; i &quot;,&quot; uploaded &quot;);
        printf(&quot;%s %s %s %s: %s@%s - %s %s\n&quot;,$1,$2,$3,$4,$14,$7,$12,$9);
     }'</span> <span style="color: #ff0000;">&quot;$2&quot;</span></pre></div></div>

<p>Feel free to download it <a href="/scripts/xfer-report.sh">here</a>. Make sure you <tt>chmod +x xfer-report.sh</tt> before you try to use it.</p>
<p>The first argument, <tt>PATTERN</tt>, is for the regex that awk will use to isolate the appropriate entries. The second argument, <tt>XFERLOG</tt>, is the path to the xferlog to be processed. For example, the following would match any entries containing &#8220;rugmonster.org&#8221; from the log at /var/log/xferlog.1:</p>
<pre>./xfer-report.sh 'rugmonster\.org' /var/log/xferlog.1</pre>
<p>The resulting output would then give you something like:</p>
<pre>Fri Feb 27 20:23:00: user@12.34.56.78 - downloaded /path/to/file
|-------DATE------|       |SOURCE IP|   |-ACTION-| |----FILE---|</pre>
<p>The results can be pretty long if there&#8217;s been a lot of FTP activity, but this was prompted as a result of some files be deleted by someone that shouldn&#8217;t have been only to be discovered too late to be restored from backup. The bigger lesson, of course, is that you should ensure only those that need access to your server have it and measure twice, cut once.</p>
]]></content:encoded>
			<wfw:commentRss>http://rugmonster.org/2010/01/xferlog-activity/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Remove old messages from Plesk/Qmail Maildir mailboxes</title>
		<link>http://rugmonster.org/2009/12/remove-old-messages-from-pleskqmail-maildir-mailboxes/</link>
		<comments>http://rugmonster.org/2009/12/remove-old-messages-from-pleskqmail-maildir-mailboxes/#comments</comments>
		<pubDate>Tue, 01 Dec 2009 17:47:05 +0000</pubDate>
		<dc:creator>Rugmonster</dc:creator>
				<category><![CDATA[Linux]]></category>
		<category><![CDATA[Mail]]></category>
		<category><![CDATA[One-Liners]]></category>
		<category><![CDATA[Plesk]]></category>
		<category><![CDATA[qmail]]></category>

		<guid isPermaLink="false">http://rugmonster.org/?p=116</guid>
		<description><![CDATA[I needed to remove messages older than a week old for a list of email accounts on a Plesk system running Qmail. I put together the following BASH script to locate the messages using find and back them up outside of the mailbox (just in case). This builds on the technique I used in my [...]]]></description>
			<content:encoded><![CDATA[<p>I needed to remove messages older than a week old for a list of email accounts on a Plesk system running Qmail. I put together the following BASH script to locate the messages using find and back them up outside of the mailbox (just in case). This builds on the technique I used in my previous post, <a href="http://rugmonster.org/2009/11/maintain-directory-structure-copying-find-results/">Maintain directory structure copying `find` results</a>.</p>
<p>All you need to do is create a file with one address per line to be read in by the command.</p>

<div class="wp_syntax"><div class="code"><pre class="bash" style="font-family:monospace;"><span style="color: #7a0874; font-weight: bold;">cd</span> <span style="color: #000000; font-weight: bold;">/</span>var<span style="color: #000000; font-weight: bold;">/</span>qmail<span style="color: #000000; font-weight: bold;">/</span>mailnames; \
<span style="color: #007800;">IFS</span>=<span style="color: #ff0000;">&quot;@&quot;</span>; \ 
<span style="color: #000000; font-weight: bold;">while</span> <span style="color: #c20cb9; font-weight: bold;">read</span> LINE ; \
<span style="color: #000000; font-weight: bold;">do</span> \
    <span style="color: #007800;">ADDR</span>=<span style="color: #7a0874; font-weight: bold;">&#40;</span> <span style="color: #800000;">${LINE}</span> <span style="color: #7a0874; font-weight: bold;">&#41;</span>; \
    <span style="color: #7a0874; font-weight: bold;">echo</span> <span style="color: #ff0000;">&quot;<span style="color: #007800;">${ADDR[0]}</span>@<span style="color: #007800;">${ADDR[1]}</span>&quot;</span>; \
    <span style="color: #c20cb9; font-weight: bold;">find</span> <span style="color: #800000;">${ADDR[1]}</span><span style="color: #000000; font-weight: bold;">/</span><span style="color: #800000;">${ADDR[0]}</span><span style="color: #000000; font-weight: bold;">/</span>Maildir<span style="color: #000000; font-weight: bold;">/</span> \
        \<span style="color: #7a0874; font-weight: bold;">&#40;</span> <span style="color: #660033;">-path</span> <span style="color: #ff0000;">&quot;*/cur/*&quot;</span> <span style="color: #660033;">-o</span> <span style="color: #660033;">-path</span> <span style="color: #ff0000;">&quot;*/new/*&quot;</span> \<span style="color: #7a0874; font-weight: bold;">&#41;</span> \
        <span style="color: #000000; font-weight: bold;">!</span> <span style="color: #660033;">-type</span> d <span style="color: #660033;">-mtime</span> +<span style="color: #000000;">7</span> <span style="color: #000000; font-weight: bold;">|</span> \
        <span style="color: #000000; font-weight: bold;">while</span> <span style="color: #c20cb9; font-weight: bold;">read</span> FILE; \
        <span style="color: #000000; font-weight: bold;">do</span> \
            <span style="color: #007800;">DIR</span>=$<span style="color: #7a0874; font-weight: bold;">&#40;</span> <span style="color: #c20cb9; font-weight: bold;">dirname</span> <span style="color: #800000;">${FILE}</span> <span style="color: #7a0874; font-weight: bold;">&#41;</span>; \
            <span style="color: #c20cb9; font-weight: bold;">mkdir</span> <span style="color: #660033;">-p</span> <span style="color: #000000; font-weight: bold;">/</span>path<span style="color: #000000; font-weight: bold;">/</span>to<span style="color: #000000; font-weight: bold;">/</span>dst<span style="color: #000000; font-weight: bold;">/</span><span style="color: #800000;">${DIR}</span>; \
            <span style="color: #c20cb9; font-weight: bold;">mv</span> <span style="color: #800000;">${FILE}</span> <span style="color: #000000; font-weight: bold;">/</span>path<span style="color: #000000; font-weight: bold;">/</span>to<span style="color: #000000; font-weight: bold;">/</span>dst<span style="color: #000000; font-weight: bold;">/</span><span style="color: #800000;">${DIR}</span>; \
        <span style="color: #000000; font-weight: bold;">done</span>; \
<span style="color: #000000; font-weight: bold;">done</span> <span style="color: #000000; font-weight: bold;">&lt;</span> <span style="color: #000000; font-weight: bold;">/</span>path<span style="color: #000000; font-weight: bold;">/</span>to<span style="color: #000000; font-weight: bold;">/</span>address_file</pre></div></div>

]]></content:encoded>
			<wfw:commentRss>http://rugmonster.org/2009/12/remove-old-messages-from-pleskqmail-maildir-mailboxes/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Maintain directory structure copying `find` results</title>
		<link>http://rugmonster.org/2009/11/maintain-directory-structure-copying-find-results/</link>
		<comments>http://rugmonster.org/2009/11/maintain-directory-structure-copying-find-results/#comments</comments>
		<pubDate>Fri, 27 Nov 2009 16:56:33 +0000</pubDate>
		<dc:creator>Rugmonster</dc:creator>
				<category><![CDATA[Linux]]></category>
		<category><![CDATA[One-Liners]]></category>

		<guid isPermaLink="false">http://rugmonster.org/?p=94</guid>
		<description><![CDATA[Let&#8217;s say you have a directory structure consisting of files owned by various users, but you want to copy only the files of a particular user to another path, but maintain the directory structure in the destination path. If you just use something like this&#8230;

find /path/to/src/ -user foo -exec cp -a &#123;&#125; /path/to/dst/

&#8230;you end up [...]]]></description>
			<content:encoded><![CDATA[<p>Let&#8217;s say you have a directory structure consisting of files owned by various users, but you want to copy only the files of a particular user to another path, but maintain the directory structure in the destination path. If you just use something like this&#8230;</p>

<div class="wp_syntax"><div class="code"><pre class="bash" style="font-family:monospace;"><span style="color: #c20cb9; font-weight: bold;">find</span> <span style="color: #000000; font-weight: bold;">/</span>path<span style="color: #000000; font-weight: bold;">/</span>to<span style="color: #000000; font-weight: bold;">/</span>src<span style="color: #000000; font-weight: bold;">/</span> <span style="color: #660033;">-user</span> foo <span style="color: #660033;">-exec</span> <span style="color: #c20cb9; font-weight: bold;">cp</span> <span style="color: #660033;">-a</span> <span style="color: #7a0874; font-weight: bold;">&#123;</span><span style="color: #7a0874; font-weight: bold;">&#125;</span> <span style="color: #000000; font-weight: bold;">/</span>path<span style="color: #000000; font-weight: bold;">/</span>to<span style="color: #000000; font-weight: bold;">/</span>dst<span style="color: #000000; font-weight: bold;">/</span></pre></div></div>

<p>&#8230;you end up with all of the files in <span style="font-family: monospace;">/path/to/dst/</span> with the original directory structure flattened out.</p>
<p>I came up with the following to solve the problem:</p>

<div class="wp_syntax"><div class="code"><pre class="bash" style="font-family:monospace;"><span style="color: #c20cb9; font-weight: bold;">find</span> <span style="color: #000000; font-weight: bold;">/</span>path<span style="color: #000000; font-weight: bold;">/</span>to<span style="color: #000000; font-weight: bold;">/</span>src<span style="color: #000000; font-weight: bold;">/</span> <span style="color: #660033;">-user</span> foo <span style="color: #000000; font-weight: bold;">|</span> <span style="color: #000000; font-weight: bold;">while</span> <span style="color: #c20cb9; font-weight: bold;">read</span> FILE \
<span style="color: #000000; font-weight: bold;">do</span> \
    <span style="color: #007800;">DIR</span>=$<span style="color: #7a0874; font-weight: bold;">&#40;</span> <span style="color: #c20cb9; font-weight: bold;">dirname</span> <span style="color: #800000;">${FILE}</span> <span style="color: #7a0874; font-weight: bold;">&#41;</span>; \
    <span style="color: #c20cb9; font-weight: bold;">mkdir</span> <span style="color: #660033;">-p</span> <span style="color: #000000; font-weight: bold;">/</span>path<span style="color: #000000; font-weight: bold;">/</span>to<span style="color: #000000; font-weight: bold;">/</span>dst<span style="color: #000000; font-weight: bold;">/</span><span style="color: #800000;">${DIR}</span>; \
    <span style="color: #c20cb9; font-weight: bold;">cp</span> <span style="color: #660033;">-d</span> <span style="color: #660033;">--preserve</span>=mode,ownership,timestamp <span style="color: #800000;">${FILE}</span> <span style="color: #000000; font-weight: bold;">/</span>path<span style="color: #000000; font-weight: bold;">/</span>to<span style="color: #000000; font-weight: bold;">/</span>dst<span style="color: #000000; font-weight: bold;">/</span><span style="color: #800000;">${DIR}</span>; \
<span style="color: #000000; font-weight: bold;">done</span></pre></div></div>

<p>Here&#8217;s a brief explanation. Since the find command returns the relative path of the matching item in it&#8217;s STDOUT, we can use the <a href="http://www.linuxmanpages.com/man1/dirname.1.php"><span style="font-family: monospace;">dirname</span></a> command to get the original relative directory name. We then create the directory if it doesn&#8217;t exist, and finally do the copy.</p>
]]></content:encoded>
			<wfw:commentRss>http://rugmonster.org/2009/11/maintain-directory-structure-copying-find-results/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>Squirrelmail &#8220;Invalid mailbox name&#8221; error with Plesk 9.2.1</title>
		<link>http://rugmonster.org/2009/05/squirrelmail-invalid-mailbox-name-error-plesk/</link>
		<comments>http://rugmonster.org/2009/05/squirrelmail-invalid-mailbox-name-error-plesk/#comments</comments>
		<pubDate>Fri, 29 May 2009 14:07:33 +0000</pubDate>
		<dc:creator>Rugmonster</dc:creator>
				<category><![CDATA[Uncategorized]]></category>

		<guid isPermaLink="false">http://rugmonster.org/?p=86</guid>
		<description><![CDATA[A client today had a problem with Squirrelmail giving the following error, preventing the folder listing from coming up:
Query: CREATE "Sent"
Reason Given: Invalid mailbox name.

To resolve the issue, I had to change some of the Squirrelmail folder settings in /etc/squirrelmail/config.php.

$default_folder_prefix          = 'mail/';
$trash_folder     [...]]]></description>
			<content:encoded><![CDATA[<p>A client today had a problem with Squirrelmail giving the following error, preventing the folder listing from coming up:</p>
<pre>Query: CREATE "Sent"
Reason Given: Invalid mailbox name.</pre>
<p><span id="more-86"></span><br />
To resolve the issue, I had to change some of the Squirrelmail folder settings in /etc/squirrelmail/config.php.</p>

<div class="wp_syntax"><div class="code"><pre class="php" style="font-family:monospace;"><span style="color: #000088;">$default_folder_prefix</span>          <span style="color: #339933;">=</span> <span style="color: #0000ff;">'mail/'</span><span style="color: #339933;">;</span>
<span style="color: #000088;">$trash_folder</span>                   <span style="color: #339933;">=</span> <span style="color: #0000ff;">'INBOX.Trash'</span><span style="color: #339933;">;</span>
<span style="color: #000088;">$sent_folder</span>                    <span style="color: #339933;">=</span> <span style="color: #0000ff;">'INBOX.Sent'</span><span style="color: #339933;">;</span>
<span style="color: #000088;">$draft_folder</span>                   <span style="color: #339933;">=</span> <span style="color: #0000ff;">'INBOX.Drafts'</span><span style="color: #339933;">;</span></pre></div></div>

<p>This was on a RHEL 5.3 box, so the config.php may be located at another path if you&#8217;re using another distro.</p>
]]></content:encoded>
			<wfw:commentRss>http://rugmonster.org/2009/05/squirrelmail-invalid-mailbox-name-error-plesk/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Plesk and RBL checking versus SMTP Authentication</title>
		<link>http://rugmonster.org/2009/05/plesk-and-rbl-checking-versus-smtp-authentication/</link>
		<comments>http://rugmonster.org/2009/05/plesk-and-rbl-checking-versus-smtp-authentication/#comments</comments>
		<pubDate>Sun, 17 May 2009 15:32:26 +0000</pubDate>
		<dc:creator>Rugmonster</dc:creator>
				<category><![CDATA[qmail]]></category>
		<category><![CDATA[Plesk]]></category>
		<category><![CDATA[spam]]></category>

		<guid isPermaLink="false">http://rugmonster.org/?p=73</guid>
		<description><![CDATA[A couple of weeks ago at work, I was arguing which RBLs should be used with Plesk came up. I had always assumed that Plesk&#8217;s qmail setup would allow authenticated users regardless of any RBL results. If that were the case, then using zen.spamhaus.org wouldn&#8217;t pose any problem to mail users on a residential Internet [...]]]></description>
			<content:encoded><![CDATA[<p>A couple of weeks ago at work, I was arguing which RBLs should be used with Plesk came up. I had always assumed that Plesk&#8217;s qmail setup would allow authenticated users regardless of any RBL results. If that were the case, then using zen.spamhaus.org wouldn&#8217;t pose any problem to mail users on a residential Internet service. I was wrong, but I wanted to sort out why and what options were available.<span id="more-73"></span></p>
<p>To begin, I setup the necessary DNS records for a test blacklist containing my laptop&#8217;s IP, 10.20.50.40.</p>
<pre>40.50.20.10.rugmonster.org. 600	IN	A	127.0.0.2
40.50.20.10.rugmonster.org. 600	IN	TXT	"go away"</pre>
<p>Using a VM running CentOS 5.3 with Plesk 8.6, I setup rugmonster.org as a DNSBL for incoming mail. I connected to TCP port 25 on the VM using telnet to simulate an SMTP exchange.</p>
<pre>1.  rblsmtpd: 10.20.50.40 pid 8586: 451 go away
2.  220 rblsmtpd.local
3.  EHLO daniel-nb.home
4.  250 rblsmtpd.local
5.  AUTH PLAIN AGRhbmllbEBwbGVzazg2LmhvbWUAcGFzc3dvcmQ=
6.  451 go away</pre>
<p>[1-2]	Initial server response<br />
[3]	I send the reqired client identification<br />
[4]	Server responds, but doesn&#8217;t give any service extensions<br />
[5]	I tried to authenticate<br />
[6]	And the server </p>
<p>Once I looked at <i>/etc/xinetd.d/smtp_psa</i>, I realized why this was happening. </p>
<pre>server_args  = -Rt0 /usr/sbin/rblsmtpd -r rugmonster.org
	/var/qmail/bin/relaylock /var/qmail/bin/qmail-smtpd
	/var/qmail/bin/smtp_auth /var/qmail/bin/true
	/var/qmail/bin/cmd5checkpw /var/qmail/bin/true</pre>
<p>When the SMTP connection is made, <i>rblsmtpd</i> is handed the connection and does its DNSBL checking. It&#8217;s then responsible for either executing the next program (<i>relaylock</i>) if there&#8217;s no match, or handling the connection itself if it does find a match. It was <i>rblsmtpd</i> that I was interacting with above, which had no way of handling authenticiation, not <i>qmail-smtpd</i>.</p>
<p>I did find that you can patch qmail to use plugins thanks to <a href="http://qmail-spp.sourceforge.net/">qmail-spp</a> and the <a href="http://xs3.b92.net/tomislavr/qmail.html#ii"rblssp and ifauthskip plugins</a>. This solution would require qmail&#8217;s source to be patched and a custom compile done, which makes upgrading in the future much more complicated.</p>
<p>I also found <a href="http://www.spamdyke.org/">spamdyke</a>, &#8220;a drop-in connection-time filter for qmail&#8230;[that] does not require patching or recompiling qmail.&#8221; I also found a <a href="http://www.blueoryx.info/linux_administration/spamdyke">HOWTO for installing spamdyke and integrating it with Plesk</a>. While I haven&#8217;t tried it, from what I saw on their site, spamdyke would be a great tool to ensure users can send mail properly while keeping spam out.</p>
<p>Finally, Plesk 9.x has included <a href="http://www.postfix.org/">Postfix</a>, which has no problem <a href="http://rugmonster.org/2009/03/blocking-spammers-with-postfix-alone/">handling this sort of situation out of the box</a>. I am making another assumption though, since I haven&#8217;t tested Plesk 9.x with Postfix yet. I&#8217;ve heard that Parallels hasn&#8217;t done the best job in with bringing Postfix into the mix. At work, there are only a handful of clients running Plesk 9 and Plesk 9.2.x seems to be less problematic than the 9.0.x releases, but I&#8217;m not giving any recommendations to upgrade yet.</p>
]]></content:encoded>
			<wfw:commentRss>http://rugmonster.org/2009/05/plesk-and-rbl-checking-versus-smtp-authentication/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Blocking spammers with Postfix alone</title>
		<link>http://rugmonster.org/2009/03/blocking-spammers-with-postfix-alone/</link>
		<comments>http://rugmonster.org/2009/03/blocking-spammers-with-postfix-alone/#comments</comments>
		<pubDate>Sun, 08 Mar 2009 16:00:05 +0000</pubDate>
		<dc:creator>Rugmonster</dc:creator>
				<category><![CDATA[Postfix]]></category>
		<category><![CDATA[spam]]></category>

		<guid isPermaLink="false">http://rugmonster.org/?p=54</guid>
		<description><![CDATA[The battle between email admins and spammers is an ongoing arms race. The spammers are at a disadvantage because by and large, they have to rely on exploiting vulnerable systems to send their mail. With the ever growing size of botnets, they have a pretty large pool of exploited systems to send from, but Postfix [...]]]></description>
			<content:encoded><![CDATA[<p>The battle between email admins and spammers is an ongoing arms race. The spammers are at a disadvantage because by and large, they have to rely on exploiting vulnerable systems to send their mail. With the ever growing size of botnets, they have a pretty large pool of exploited systems to send from, but Postfix can be configured to weed out most of that.</p>
<p><span id="more-54"></span>I&#8217;ve used the following configuration for many systems that were being plagued by spam problems. In many cases, SpamAssassin was doing the job, but it was having to process so much junk that it was putting an amazing amount of load on the server. After adding this to the Postfix configuration, Postfix was able to reject mail before it came into the queue, thereby reducing the amount of mail that made it through to SpamAssassin.</p>
<p><em>Add to /etc/postfix/main.cf</em></p>
<pre>smtpd_delay_reject = yes
smtpd_helo_required = yes
disable_vrfy_command = yes

smtpd_helo_restrictions =
	permit_mynetworks,
	reject_non_fqdn_helo_hostname,
	reject_invalid_helo_hostname,
	reject_unknown_helo_hostname,
	permit

smtpd_sender_restrictions =
	permit_sasl_authenticated,
	permit_mynetworks,
	reject_non_fqdn_sender,
	reject_unknown_sender_domain,
	permit

smtpd_recipient_restrictions =
	permit_mynetworks,
	permit_sasl_authenticated,
	reject_unauth_pipelining,
	reject_non_fqdn_recipient,
	reject_unknown_recipient_domain,
	reject_unauth_destination,
	reject_rbl_client bl.spamcop.net,
	reject_rbl_client zen.spamhaus.org,
	permit</pre>
<p>On average, only about two or three spam messages a day actually get accepted for delivery, which SpamAssassin then handles appropriately. You can see some stats on how well this is working through <a href="http://munin.rugmonster.org/localhost/localhost-postfix_filtered_awk.html" target="_blank">my Postfix stats*</a>.</p>
<p>* <em>I just started tracking the stats, so they may not show much depending on when you&#8217;re getting here.</em></p>
]]></content:encoded>
			<wfw:commentRss>http://rugmonster.org/2009/03/blocking-spammers-with-postfix-alone/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Building mod_fastcgi on RHEL5</title>
		<link>http://rugmonster.org/2009/03/building-mod_fastcgi-on-rhel5/</link>
		<comments>http://rugmonster.org/2009/03/building-mod_fastcgi-on-rhel5/#comments</comments>
		<pubDate>Thu, 05 Mar 2009 15:44:55 +0000</pubDate>
		<dc:creator>Rugmonster</dc:creator>
				<category><![CDATA[Apache]]></category>
		<category><![CDATA[RHEL 5]]></category>
		<category><![CDATA[FastCGI]]></category>
		<category><![CDATA[RHEL]]></category>

		<guid isPermaLink="false">http://rugmonster.org/?p=30</guid>
		<description><![CDATA[Apparently, I&#8217;m one of the only people who has ever built mod_fastcgi on Red Hat Enterprise Linux 5. At least after much Googling and gnashing of teeth, here&#8217;s how it&#8217;s done.

yum install httpd-devel
wget http://www.fastcgi.com/dist/mod_fastcgi-current.tar.gz
tar xzf mod_fastcgi-current.tar.gz
cd mod_fastcgi-
cp Makefile.AP2 Makefile

The next step will depend on your architecture:
ia-32

make top_dir=/usr/lib/httpd
make top_dir=/usr/lib/httpd install

ia-64

make top_dir=/usr/lib64/httpd
make top_dir=/usr/lib64/httpd install

You&#8217;ll find the module [...]]]></description>
			<content:encoded><![CDATA[<p>Apparently, I&#8217;m one of the only people who has ever built <a href="http://www.fastcgi.com">mod_fastcgi</a> on <a href="http://www.redhat.com/rhel/">Red Hat Enterprise Linux 5</a>. At least after much Googling and gnashing of teeth, here&#8217;s how it&#8217;s done.<span id="more-30"></span></p>

<div class="wp_syntax"><div class="code"><pre class="bash" style="font-family:monospace;">yum <span style="color: #c20cb9; font-weight: bold;">install</span> httpd-devel
<span style="color: #c20cb9; font-weight: bold;">wget</span> http:<span style="color: #000000; font-weight: bold;">//</span>www.fastcgi.com<span style="color: #000000; font-weight: bold;">/</span>dist<span style="color: #000000; font-weight: bold;">/</span>mod_fastcgi-current.tar.gz
<span style="color: #c20cb9; font-weight: bold;">tar</span> xzf mod_fastcgi-current.tar.gz
<span style="color: #7a0874; font-weight: bold;">cd</span> mod_fastcgi-
<span style="color: #c20cb9; font-weight: bold;">cp</span> Makefile.AP2 Makefile</pre></div></div>

<p>The next step will depend on your architecture:</p>
<p><strong>ia-32</strong></p>

<div class="wp_syntax"><div class="code"><pre class="bash" style="font-family:monospace;"><span style="color: #c20cb9; font-weight: bold;">make</span> <span style="color: #007800;">top_dir</span>=<span style="color: #000000; font-weight: bold;">/</span>usr<span style="color: #000000; font-weight: bold;">/</span>lib<span style="color: #000000; font-weight: bold;">/</span>httpd
<span style="color: #c20cb9; font-weight: bold;">make</span> <span style="color: #007800;">top_dir</span>=<span style="color: #000000; font-weight: bold;">/</span>usr<span style="color: #000000; font-weight: bold;">/</span>lib<span style="color: #000000; font-weight: bold;">/</span>httpd <span style="color: #c20cb9; font-weight: bold;">install</span></pre></div></div>

<p><strong>ia-64</strong></p>

<div class="wp_syntax"><div class="code"><pre class="bash" style="font-family:monospace;"><span style="color: #c20cb9; font-weight: bold;">make</span> <span style="color: #007800;">top_dir</span>=<span style="color: #000000; font-weight: bold;">/</span>usr<span style="color: #000000; font-weight: bold;">/</span>lib64<span style="color: #000000; font-weight: bold;">/</span>httpd
<span style="color: #c20cb9; font-weight: bold;">make</span> <span style="color: #007800;">top_dir</span>=<span style="color: #000000; font-weight: bold;">/</span>usr<span style="color: #000000; font-weight: bold;">/</span>lib64<span style="color: #000000; font-weight: bold;">/</span>httpd <span style="color: #c20cb9; font-weight: bold;">install</span></pre></div></div>

<p>You&#8217;ll find the module is now installed in /etc/httpd/modules. You can now add the configuration directive to load the module. I suggest adding the following to <em>/etc/httpd/conf.d/fastcgi.conf</em> to follow RHEL convention:</p>

<div class="wp_syntax"><div class="code"><pre class="apache" style="font-family:monospace;"><span style="color: #00007f;">LoadModule</span> fastcgi_module modules/mod_fastcgi.so</pre></div></div>

<p>I may get around to creating an RPM for this, but that will be time permitting.</p>
]]></content:encoded>
			<wfw:commentRss>http://rugmonster.org/2009/03/building-mod_fastcgi-on-rhel5/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Kill long running MySQL processes</title>
		<link>http://rugmonster.org/2009/02/kill-mysql-procs/</link>
		<comments>http://rugmonster.org/2009/02/kill-mysql-procs/#comments</comments>
		<pubDate>Fri, 20 Feb 2009 04:39:37 +0000</pubDate>
		<dc:creator>Rugmonster</dc:creator>
				<category><![CDATA[One-Liners]]></category>
		<category><![CDATA[bash]]></category>
		<category><![CDATA[grep]]></category>
		<category><![CDATA[MySQL]]></category>
		<category><![CDATA[performance]]></category>

		<guid isPermaLink="false">http://rugmonster.org/?p=3</guid>
		<description><![CDATA[It&#8217;s all too common for me to come across a box that is hopelessly overloaded with Apache requests and MySQL queries. Sometimes, it takes some brute force to keep the whole box from going under. When all else fails, I use the following one-liner to kill off all of those queries that have been running [...]]]></description>
			<content:encoded><![CDATA[<p>It&#8217;s all too common for me to come across a box that is hopelessly overloaded with Apache requests and MySQL queries. Sometimes, it takes some brute force to keep the whole box from going under. When all else fails, I use the following one-liner to kill off all of those queries that have been running for too long.<span id="more-3"></span></p>

<div class="wp_syntax"><div class="code"><pre class="bash" style="font-family:monospace;">mysql <span style="color: #660033;">-e</span> <span style="color: #ff0000;">'show processlist\G'</span> <span style="color: #000000; font-weight: bold;">|</span>\
<span style="color: #c20cb9; font-weight: bold;">egrep</span> <span style="color: #660033;">-b5</span> <span style="color: #ff0000;">'Time: [0-9]{2,}'</span> <span style="color: #000000; font-weight: bold;">|</span>\
<span style="color: #c20cb9; font-weight: bold;">grep</span> <span style="color: #ff0000;">'Id:'</span> <span style="color: #000000; font-weight: bold;">|</span>\
<span style="color: #c20cb9; font-weight: bold;">cut</span> <span style="color: #660033;">-d</span><span style="color: #ff0000;">':'</span> <span style="color: #660033;">-f2</span> <span style="color: #000000; font-weight: bold;">|</span>\
<span style="color: #c20cb9; font-weight: bold;">sed</span> <span style="color: #ff0000;">'s/^ //'</span> <span style="color: #000000; font-weight: bold;">|</span>\
<span style="color: #000000; font-weight: bold;">while</span> <span style="color: #c20cb9; font-weight: bold;">read</span> <span style="color: #c20cb9; font-weight: bold;">id</span>
<span style="color: #000000; font-weight: bold;">do</span>
    mysql <span style="color: #660033;">-e</span> <span style="color: #ff0000;">&quot;kill <span style="color: #007800;">$id</span>;&quot;</span>
<span style="color: #000000; font-weight: bold;">done</span></pre></div></div>

<p>This goes with the assumption that you&#8217;re MySQL authentication credentials are in ~/.my.cnf. You aren&#8217;t running this as root with no root password set, are you?</p>
]]></content:encoded>
			<wfw:commentRss>http://rugmonster.org/2009/02/kill-mysql-procs/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>
