<?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>Sat, 11 Jun 2011 17:37:14 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.3.1</generator>
		<item>
		<title>Chromium easy update</title>
		<link>http://rugmonster.org/2010/09/chromium-easy-update/</link>
		<comments>http://rugmonster.org/2010/09/chromium-easy-update/#comments</comments>
		<pubDate>Tue, 28 Sep 2010 19:49:21 +0000</pubDate>
		<dc:creator>Rugmonster</dc:creator>
				<category><![CDATA[Uncategorized]]></category>
		<category><![CDATA[bash]]></category>
		<category><![CDATA[Chromium]]></category>
		<category><![CDATA[curl]]></category>
		<category><![CDATA[Mac]]></category>

		<guid isPermaLink="false">http://rugmonster.org/?p=202</guid>
		<description><![CDATA[Update: The URL's no longer work, so this is busted. I've gone back to Firefox since 4.0 came out. It is heavier than Chrom(e&#124;ium), but I was finding that there were some features I was really missing. As such, this still can serve as the basis for an update if given the correct URL's. I'm [...]]]></description>
			<content:encoded><![CDATA[<p><i>Update:</i> The URL's no longer work, so this is busted. I've gone back to Firefox since 4.0 came out. It is heavier than Chrom(e|ium), but I was finding that there were some features I was really missing. As such, this still can serve as the basis for an update if given the correct URL's.</p>
<p>I'm a bleeding edge kind of guy. No, I'm not. When it comes to software, I'm generally a bleeding edge kind of guy. I really like Chromium. I hate going to the Chromium build site, downloading it, closing my browser, then moving it in place. I'm a lazy admin. </p>
<p>Here's a couple quick-n-dirty bash script that retrieves the latest Chromium build.</p>
<h2>Mac Version</h2>
<p><b>Special Notes:</b></p>
<li>Ensure Chromium is not running when you run this or it will not work out as planned (open files)</li>
<li>Assumes that Chromium is installed in /Applications, not /Users/user/Applications</li>
<p><br/></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>
<span style="color: #7a0874; font-weight: bold;">echo</span> <span style="color: #660033;">-n</span> <span style="color: #ff0000;">&quot;Retrieving latest build: &quot;</span>
<span style="color: #007800;">VER</span>=$<span style="color: #7a0874; font-weight: bold;">&#40;</span> curl <span style="color: #660033;">-s</span> http:<span style="color: #000000; font-weight: bold;">//</span>build.chromium.org<span style="color: #000000; font-weight: bold;">/</span>f<span style="color: #000000; font-weight: bold;">/</span>chromium<span style="color: #000000; font-weight: bold;">/</span>snapshots<span style="color: #000000; font-weight: bold;">/</span>chromium-rel-mac<span style="color: #000000; font-weight: bold;">/</span>LATEST <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;">$VER</span>&quot;</span>  
&nbsp;
<span style="color: #007800;">TMPDIR</span>=$<span style="color: #7a0874; font-weight: bold;">&#40;</span> <span style="color: #c20cb9; font-weight: bold;">mktemp</span> <span style="color: #660033;">-d</span> <span style="color: #000000; font-weight: bold;">/</span>tmp<span style="color: #000000; font-weight: bold;">/</span>chromium.XXXXX <span style="color: #7a0874; font-weight: bold;">&#41;</span>  
&nbsp;
<span style="color: #7a0874; font-weight: bold;">echo</span> <span style="color: #ff0000;">&quot;Downloading Chromium: &quot;</span>
curl <span style="color: #660033;">-o</span> <span style="color: #800000;">${TMPDIR}</span><span style="color: #000000; font-weight: bold;">/</span>chromium.zip http:<span style="color: #000000; font-weight: bold;">//</span>build.chromium.org<span style="color: #000000; font-weight: bold;">/</span>f<span style="color: #000000; font-weight: bold;">/</span>chromium<span style="color: #000000; font-weight: bold;">/</span>snapshots<span style="color: #000000; font-weight: bold;">/</span>chromium-rel-mac<span style="color: #000000; font-weight: bold;">/</span><span style="color: #800000;">${VER}</span><span style="color: #000000; font-weight: bold;">/</span>chrome-mac.zip  
&nbsp;
<span style="color: #7a0874; font-weight: bold;">echo</span> <span style="color: #660033;">-n</span> <span style="color: #ff0000;">&quot;Decompressing archive: &quot;</span>  
<span style="color: #c20cb9; font-weight: bold;">unzip</span> <span style="color: #660033;">-qqx</span> <span style="color: #800000;">${TMPDIR}</span><span style="color: #000000; font-weight: bold;">/</span>chromium <span style="color: #660033;">-d</span> <span style="color: #800000;">${TMPDIR}</span>  
<span style="color: #7a0874; font-weight: bold;">echo</span> <span style="color: #ff0000;">&quot;done&quot;</span>  
&nbsp;
<span style="color: #c20cb9; font-weight: bold;">rm</span> <span style="color: #660033;">-rf</span> <span style="color: #000000; font-weight: bold;">/</span>Applications<span style="color: #000000; font-weight: bold;">/</span>Chromium.app  
<span style="color: #c20cb9; font-weight: bold;">mv</span> <span style="color: #800000;">${TMPDIR}</span><span style="color: #000000; font-weight: bold;">/</span>chrome-mac<span style="color: #000000; font-weight: bold;">/</span>Chromium.app <span style="color: #000000; font-weight: bold;">/</span>Applications<span style="color: #000000; font-weight: bold;">/</span>  
&nbsp;
<span style="color: #c20cb9; font-weight: bold;">rm</span> <span style="color: #660033;">-rf</span> <span style="color: #800000;">${TMPDIR}</span>  
<span style="color: #7a0874; font-weight: bold;">echo</span> <span style="color: #ff0000;">&quot;New Chromium installed!&quot;</span></pre></div></div>

<h2>Linux Version</h2>
<p><b>Special Notes:</b></p>
<li>Requires 7zip to be installed</li>
<li>Assumes that Chromium is installed in /opt</li>
<li>I have a group named "opt", to which my user belongs, that has write access to /opt</li>
<li>I have /opt/bin, which is in my $PATH, that has a symlink for "chrome" pointed to /opt/chrome-linux/chrome</li>
<p><br/></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>
<span style="color: #7a0874; font-weight: bold;">echo</span> <span style="color: #660033;">-n</span> <span style="color: #ff0000;">&quot;Retrieving latest build: &quot;</span>
<span style="color: #007800;">VER</span>=$<span style="color: #7a0874; font-weight: bold;">&#40;</span> curl <span style="color: #660033;">-s</span> http:<span style="color: #000000; font-weight: bold;">//</span>build.chromium.org<span style="color: #000000; font-weight: bold;">/</span>f<span style="color: #000000; font-weight: bold;">/</span>chromium<span style="color: #000000; font-weight: bold;">/</span>snapshots<span style="color: #000000; font-weight: bold;">/</span>chromium-rel-linux-<span style="color: #000000;">64</span><span style="color: #000000; font-weight: bold;">/</span>LATEST <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;">$VER</span>&quot;</span>  
&nbsp;
<span style="color: #007800;">TMPDIR</span>=$<span style="color: #7a0874; font-weight: bold;">&#40;</span> <span style="color: #c20cb9; font-weight: bold;">mktemp</span> <span style="color: #660033;">-d</span> <span style="color: #000000; font-weight: bold;">/</span>tmp<span style="color: #000000; font-weight: bold;">/</span>chromium.XXXXX <span style="color: #7a0874; font-weight: bold;">&#41;</span>  
&nbsp;
<span style="color: #7a0874; font-weight: bold;">echo</span> <span style="color: #ff0000;">&quot;Downloading Chromium: &quot;</span>
curl <span style="color: #660033;">-o</span> <span style="color: #800000;">${TMPDIR}</span><span style="color: #000000; font-weight: bold;">/</span>chrome-linux.zip http:<span style="color: #000000; font-weight: bold;">//</span>build.chromium.org<span style="color: #000000; font-weight: bold;">/</span>f<span style="color: #000000; font-weight: bold;">/</span>chromium<span style="color: #000000; font-weight: bold;">/</span>snapshots<span style="color: #000000; font-weight: bold;">/</span>chromium-rel-linux-<span style="color: #000000;">64</span><span style="color: #000000; font-weight: bold;">/</span><span style="color: #800000;">${VER}</span><span style="color: #000000; font-weight: bold;">/</span>chrome-linux.zip  
&nbsp;
<span style="color: #7a0874; font-weight: bold;">echo</span> <span style="color: #660033;">-n</span> <span style="color: #ff0000;">&quot;Decompressing archive: &quot;</span>  
7z x <span style="color: #660033;">-tzip</span> <span style="color: #660033;">-o</span><span style="color: #800000;">${TMPDIR}</span> <span style="color: #800000;">${TMPDIR}</span><span style="color: #000000; font-weight: bold;">/</span>chrome-linux.zip <span style="color: #000000; font-weight: bold;">&gt;</span> <span style="color: #000000; font-weight: bold;">/</span>dev<span style="color: #000000; font-weight: bold;">/</span>null
<span style="color: #7a0874; font-weight: bold;">echo</span> <span style="color: #ff0000;">&quot;done&quot;</span>  
&nbsp;
<span style="color: #000000; font-weight: bold;">if</span> <span style="color: #7a0874; font-weight: bold;">&#91;</span> <span style="color: #660033;">-d</span> <span style="color: #000000; font-weight: bold;">/</span>opt<span style="color: #000000; font-weight: bold;">/</span>chrome-linux.1 <span style="color: #7a0874; font-weight: bold;">&#93;</span>
<span style="color: #000000; font-weight: bold;">then</span>
        <span style="color: #c20cb9; font-weight: bold;">rm</span> <span style="color: #660033;">-rf</span> <span style="color: #000000; font-weight: bold;">/</span>opt<span style="color: #000000; font-weight: bold;">/</span>chrome-linux.1
<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: #660033;">-d</span> <span style="color: #000000; font-weight: bold;">/</span>opt<span style="color: #000000; font-weight: bold;">/</span>chrome-linux <span style="color: #7a0874; font-weight: bold;">&#93;</span>
<span style="color: #000000; font-weight: bold;">then</span>
        <span style="color: #c20cb9; font-weight: bold;">mv</span> <span style="color: #000000; font-weight: bold;">/</span>opt<span style="color: #000000; font-weight: bold;">/</span>chrome-linux <span style="color: #000000; font-weight: bold;">/</span>opt<span style="color: #000000; font-weight: bold;">/</span>chrome-linux.1 
<span style="color: #000000; font-weight: bold;">fi</span>
&nbsp;
<span style="color: #c20cb9; font-weight: bold;">mv</span> <span style="color: #800000;">${TMPDIR}</span><span style="color: #000000; font-weight: bold;">/</span>chrome-linux <span style="color: #000000; font-weight: bold;">/</span>opt<span style="color: #000000; font-weight: bold;">/</span> 
<span style="color: #c20cb9; font-weight: bold;">find</span> <span style="color: #000000; font-weight: bold;">/</span>opt<span style="color: #000000; font-weight: bold;">/</span>chrome-linux <span style="color: #660033;">-type</span> d <span style="color: #660033;">-exec</span> <span style="color: #c20cb9; font-weight: bold;">chmod</span> <span style="color: #000000;">2775</span> <span style="color: #7a0874; font-weight: bold;">&#123;</span><span style="color: #7a0874; font-weight: bold;">&#125;</span> \;
<span style="color: #c20cb9; font-weight: bold;">find</span> <span style="color: #000000; font-weight: bold;">/</span>opt<span style="color: #000000; font-weight: bold;">/</span>chrome-linux <span style="color: #660033;">-type</span> f <span style="color: #660033;">-perm</span> <span style="color: #000000; font-weight: bold;">/</span><span style="color: #000000;">100</span> <span style="color: #660033;">-exec</span> <span style="color: #c20cb9; font-weight: bold;">chmod</span> <span style="color: #000000;">775</span> <span style="color: #7a0874; font-weight: bold;">&#123;</span><span style="color: #7a0874; font-weight: bold;">&#125;</span> \;
<span style="color: #c20cb9; font-weight: bold;">find</span> <span style="color: #000000; font-weight: bold;">/</span>opt<span style="color: #000000; font-weight: bold;">/</span>chrome-linux <span style="color: #660033;">-type</span> f <span style="color: #000000; font-weight: bold;">!</span> <span style="color: #660033;">-perm</span> <span style="color: #000000; font-weight: bold;">/</span><span style="color: #000000;">100</span> <span style="color: #660033;">-exec</span> <span style="color: #c20cb9; font-weight: bold;">chmod</span> <span style="color: #000000;">664</span> <span style="color: #7a0874; font-weight: bold;">&#123;</span><span style="color: #7a0874; font-weight: bold;">&#125;</span> \;
<span style="color: #c20cb9; font-weight: bold;">chgrp</span> <span style="color: #660033;">-R</span> opt <span style="color: #000000; font-weight: bold;">/</span>opt<span style="color: #000000; font-weight: bold;">/</span>chrome-linux
&nbsp;
<span style="color: #c20cb9; font-weight: bold;">rm</span> <span style="color: #660033;">-rf</span> <span style="color: #800000;">${TMPDIR}</span>  
<span style="color: #7a0874; font-weight: bold;">echo</span> <span style="color: #ff0000;">&quot;New Chromium installed!&quot;</span></pre></div></div>

<p>Enjoy!</p>
<p><b>8 Nov 2010:</b> Updated to match new URLs being used</p>
]]></content:encoded>
			<wfw:commentRss>http://rugmonster.org/2010/09/chromium-easy-update/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>MacPorts &#8220;PortIndex file may be corrupt&#8221; Resolution</title>
		<link>http://rugmonster.org/2010/05/portindex-file-may-be-corrupt-resolution/</link>
		<comments>http://rugmonster.org/2010/05/portindex-file-may-be-corrupt-resolution/#comments</comments>
		<pubDate>Sat, 29 May 2010 13:36:57 +0000</pubDate>
		<dc:creator>Rugmonster</dc:creator>
				<category><![CDATA[Uncategorized]]></category>
		<category><![CDATA[Mac]]></category>
		<category><![CDATA[MacPorts]]></category>

		<guid isPermaLink="false">http://rugmonster.org/?p=180</guid>
		<description><![CDATA[In the past few months, I moved to a Mac, which has been great. Shortly after switching, I found MacPorts, which has also been great. The other day, however, when doing an upgrade, I got the following warning over and over and my upgrade wouldn't complete: Warning: It looks like your PortIndex file for rsync://rsync.macports.org/release/ports/ [...]]]></description>
			<content:encoded><![CDATA[<p>In the past few months, I moved to a Mac, which has been great. Shortly after switching, I found <a href="http://www.macports.org/">MacPorts</a>, which has also been great. The other day, however, when doing an upgrade, I got the following warning over and over and my upgrade wouldn't complete:</p>
<p><code>Warning: It looks like your PortIndex file for rsync://rsync.macports.org/release/ports/ may be corrupt.</code></p>
<p>I couldn't find a clear answer on what was going on, until I found <a href="https://trac.macports.org/ticket/20874">a bug report</a> on the MacPorts site. The fix for this will be put into MacPorts 1.9.0, but I'm on 1.8.2 now, so that doesn't help much.</p>
<p>The issue sounds like it has to do with a cache of the PortIndex can build up stale information. My brute force resolution was to remove that cache. I wasn't terribly sure where that was, but I did find it.</p>
<p><code>$ locate PortIndex.quick<br />
/opt/local/var/macports/sources/rsync.macports.org/release/ports/PortIndex.quick<br />
$ sudo rm /opt/local/var/macports/sources/rsync.macports.org/release/ports/PortIndex.quick</code></p>
<p>Alternatively, you could move the file out of the way if that makes you more comfortable.</p>
<p>Once that was done, I went ahead and gave it try.</p>
<p><code>$ sudo port sync<br />
Warning: No quick index file found, attempting to generate one for source: rsync://rsync.macports.org/release/ports/<br />
$ sudo port upgrade outdated<br />
...</code></p>
<p>All worked as it should! So until we see MacPorts 1.9.0, this will be my solution should I see this come up again.</p>
]]></content:encoded>
			<wfw:commentRss>http://rugmonster.org/2010/05/portindex-file-may-be-corrupt-resolution/feed/</wfw:commentRss>
		<slash:comments>2</slash:comments>
		</item>
		<item>
		<title>My address IS valid, Facebook!</title>
		<link>http://rugmonster.org/2010/05/my-address-is-valid-facebook/</link>
		<comments>http://rugmonster.org/2010/05/my-address-is-valid-facebook/#comments</comments>
		<pubDate>Wed, 05 May 2010 03:59:06 +0000</pubDate>
		<dc:creator>Rugmonster</dc:creator>
				<category><![CDATA[Mail]]></category>
		<category><![CDATA[Postfix]]></category>
		<category><![CDATA[Annoying]]></category>
		<category><![CDATA[Facebook]]></category>
		<category><![CDATA[SpamCop]]></category>

		<guid isPermaLink="false">http://rugmonster.org/?p=140</guid>
		<description><![CDATA[If you happened to have seen my previous post, Blocking spammers with Postfix alone, you saw that I use SpamCop for one of my RBLs. It's worked great for years. My whole setup has worked great for over a year now with very minimal changes. Imagine my confusion when Facebook told me to that my [...]]]></description>
			<content:encoded><![CDATA[<p>If you happened to have seen my previous post, <a href="http://rugmonster.org/2009/03/blocking-spammers-with-postfix-alone/">Blocking spammers with Postfix alone</a>, you saw that I use <a href="http://www.spamcop.net">SpamCop</a> for one of my <a href="http://en.wikipedia.org/wiki/DNSBL">RBLs</a>. It's worked great for years. My whole setup has worked great for over a year now with very minimal changes. Imagine my confusion when Facebook told me to that my email address was detected as no longer valid.</p>
<div id="attachment_146" class="wp-caption aligncenter" style="width: 525px"><a href="http://c475063.r63.cf2.rackcdn.com/wp-content/uploads/2010/05/fb_fail1.png"><img class="size-full wp-image-146" title="Facebook Fail" src="http://c475063.r63.cf2.rackcdn.com/wp-content/uploads/2010/05/fb_fail1.png" alt="Facebook Fail" width="515" height="151" /></a><p class="wp-caption-text">What?!</p></div>
<p>So I dug in my mail server's logs and found that SpamCop had listed some of the Facebook mail servers on their DNS Blacklist.</p>
<p><span id="more-140"></span></p>
<p><em>Example from today:</em><br />
<code>May  4 18:49:14 sh-srv2 postfix/smtpd[28197]: NOQUEUE: reject: RCPT from outmail006.snc1.tfbnw.net[69.63.178.165]: 554 5.7.1 Service unavailable; Client host [69.63.178.165] blocked using bl.spamcop.net; Blocked - see http://www.spamcop.net/bl.shtml?69.63.178.165; from=&lt;notification+mu_miidm@facebookmail.com&gt; to=&lt;daniel@*don't spam me*&gt; proto=ESMTP helo=&lt;mx-out.facebook.com&gt;<br />
</code></p>
<p>As you can see, Postfix did what it was supposed to do according to my configuration. The problem is, apparently, Facebook doesn't check the actual server responses and assumes that if a message is undeliverable for any reason, the address is no longer valid. Over the past month, I've had 101 messages from Facebook mail servers blocked based on the listing from SpamCop. I can't tell you how many times I've had to click the "reconfirm your current email" link to get the message to go away.</p>
<p><span style="font-size: 10pt;"><em>As most experienced Postfix admins know, you can always manipulate Postfix's access control mechanisms just about any way you can imagine. If you're an experienced Postfix admin, you can probably move along since you probably already know what I'm going to explain from here.</em></span></p>
<p>I don't know why, but today was the final straw. Once again, SpamCop had listed one of the Facebook mail relays and a message had been rejected. While I had tolerated reconfirming my address before, today I decided that this could be fixed and I was going to share it with the world.</p>
<p>In looking at the server names for all of the blocked Facebook servers, they had a standard naming convention of <em>outmail###.snc1.tfbnw.net</em>. Obviously, <em>tfbnw.net</em> stands for The Facebook Network. My guess is that <em>snc1</em> is an identifier for datacenter or something along those lines. I figured that it would be safe enough to whitelist all subdomains of <em>tfbnw.net</em>.</p>
<p>First, I created a new file I called <span style="font-family: monospace; font-size: 12px;">/etc/postfix/rbl_whitelist</span>, which contains the following lines:</p>
<p><code># Facebook<br />
/.*.tfbnw.net/ OK<br />
</code></p>
<p>In the first field, I have a regular expression, <span style="font-family: monospace; font-size: 12px;">/.*.tfbnw.net</span>, which should match anything sent from <em>tfbnw.net</em> domain and any subdomain. The second field specifies what action Postfix should take when it encounters that pattern. Easy enough. Since I'm using a <em>regexp</em> type table, there's no need to use <span style="font-family: monospace; font-size: 12px;">postmap</span>.</p>
<p>Next, I had to tell Postfix that it needed to use this file to check for "client" access, or remote servers sending mail destined for my server. Since Postfix evaluates <span style="font-family: monospace; font-size: 12px;"><a href="http://www.postfix.org/postconf.5.html#smtpd_client_restrictions">smtpd_client_restrictions</a></span> in order they are defined, I simply needed to drop <span style="font-family: monospace; font-size: 12px;"><a href="http://www.postfix.org/postconf.5.html#check_client_access">check_client_access</a> hash:/etc/postfix/wl_servers</span> in before my other restrictions. This made my <span style="font-family: monospace; font-size: 12px;">smtpd_recipient_restrictions</span> look like this:</p>
<pre>smtpd_client_restrictions =
     permit_mynetworks,
     permit_sasl_authenticated,
     check_client_access regexp:/etc/postfix/rbl_whitelist,
     reject_unauth_pipelining,
     reject_rbl_client bl.spamcop.net,
     reject_rbl_client zen.spamhaus.org,
     permit</pre>
<p>This causes Postfix to catch any thing sent from a Facebook mail relay and accept it before any DNSBL checks are done. Problem solved.</p>
<p><em><strong>Updated 20 May 2010:</strong> I realized that having the check_client_access in the smtpd_recipient_restrictions was not giving the desired results. The check_client_access was being ignored since it was really in the wrong spot. Once I realized that, I also figured out that the reject_rbl_client directives could be moved under smtpd_client_restrictions as well.</em></p>
<p><em><strong>Updated 29 May 2010:</strong> I got prompted again to confirm my address. I checked if the inbound hostnames were actually matching on the hash table I was previously using, but it was not, so I moved it to a regexp table instead. I couldn't figure out why the hash wasn't working as was expected. Perhaps due to the multiple levels of subdomains off of tfbnw.net, but the regexp works fine.</em></p>
]]></content:encoded>
			<wfw:commentRss>http://rugmonster.org/2010/05/my-address-is-valid-facebook/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>iPhone&#8217;s mail.app and IMAP folders</title>
		<link>http://rugmonster.org/2010/03/iphones-mail-app-and-imap-folders/</link>
		<comments>http://rugmonster.org/2010/03/iphones-mail-app-and-imap-folders/#comments</comments>
		<pubDate>Fri, 12 Mar 2010 04:04:18 +0000</pubDate>
		<dc:creator>Rugmonster</dc:creator>
				<category><![CDATA[Apple]]></category>
		<category><![CDATA[iPhone]]></category>
		<category><![CDATA[Mail]]></category>
		<category><![CDATA[Postfix]]></category>

		<guid isPermaLink="false">http://rugmonster.org/?p=124</guid>
		<description><![CDATA[I use IMAP folders combined with fairly extensive Sieve rules to sort my incoming mail into the appropriate folders. This works great for me, because my Facebook notifications go to "Websites", bill notifications go into "Bills". It makes it easy for me to find what I'm looking for without having to sort through a single, [...]]]></description>
			<content:encoded><![CDATA[<div id="attachment_125" class="wp-caption alignleft" style="width: 173px"><a href="http://c475063.r63.cf2.rackcdn.com/wp-content/uploads/2010/03/mailboxes1.png"><img class="size-full wp-image-125" title="IMAP Folders Example" src="http://c475063.r63.cf2.rackcdn.com/wp-content/uploads/2010/03/mailboxes1.png" alt="IMAP Folders Example" width="163" height="266" /></a><p class="wp-caption-text">My IMAP Folders</p></div>
<p>I use IMAP folders combined with fairly extensive <a href="http://www.ietf.org/rfc/rfc5228.txt">Sieve</a> rules to sort my incoming mail into the appropriate folders. This works great for me, because my Facebook notifications go to "Websites", bill notifications go into "Bills". It makes it easy for me to find what I'm looking for without having to sort through a single, massive Inbox.</p>
<p>When I got my iPhone, I was very disappointed in its handling of folders. It simply lacks the ability to check all folders for new mail. I didn't want to have to click through each folder to see if I got new mail in one of them. I wanted to be able to see my little mail badge with the number of new messages I had, when I got a new message, no matter what folder it happened to reside in. I thought of various solutions, such as writing a server-side IMAP proxy that would do the checking for me and present a virtual mailbox of only new messages. While it may have been a fun project, a friend pointed out a more obvious solution: setup a second mailbox and have all of my mail forwarded to it. Here are the details of what I setup.<br />
<span id="more-124"></span></p>
<p>I created an account named "iphone" on my mail server. While I could have just added a .forward in my primary user's home directory and called it done, I didn't want to get <em>everything</em> sent to the mailbox on my iPhone. For example, SpamAssassin is setup to flag spam, and while I keep a "Spam" folder to periodically go back through for false-positives, I am not interested in seeing those on my iPhone. Also, I have several servers sending me logs occasionally. Again, I don't care to see those on my iPhone. To keep the unnecessary stuff from being forwarded on, I implemented some rules to exclude the unwanted messages and forward the rest.</p>
<p>Here is an example for handling the messages marked as spam from my ~/.dovecot.sieve file:</p>
<pre>require ["imapflags","fileinto","copy"];

if  header :is "X-Spam-Flag" "YES" {
    addflag "\Seen";
    fileinto "Spam";
    stop;
} else {
    redirect :copy "iphone@rugmonster.org";
}</pre>
<p>I put all of the rules for things I don't want to be sent to the iPhone's mailbox before the "redirect" statement.</p>
<p><em>I happen to like Sieve for setting up mail delivery rules, but this could also be accomplished with procmail if your local delivery agent doesn't support Sieve. You could also do this with any mail client that supports mail processing rules.</em></p>
<p>To prevent mail from being sent directly to the iPhone's mailbox, I added a recipient check in my Postfix config. First, I created a file I called "denied_recipients" with the following:</p>
<pre>iphone@	REJECT	This address doesn't accept mail directly</pre>
<p>I updated my smtpd_recipient_restrictions so Postfix would check that file. It looks like this now:</p>
<pre>smtpd_recipient_restrictions =
     permit_mynetworks,
     permit_sasl_authenticated,
     check_recipient_access hash:/etc/postfix/denied_recipients,
     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>Since mail is being forwarded locally, everything gets through perfectly fine. And because I'm not accepting mail for that address, I can comfortably put iphone@rugmonster.org up on here and not worry about spammers sending me a bunch of crap.</p>
<p>While that all works great, I did one more thing to make things a bit easier for myself. I don't always delete messages out of the mailbox on the iPhone on a regular basis. In fact, I would commonly delete the messages straight out of the maildir from the shell when the mailbox got too big. To keep the mailbox fairly tidy, I've setup a cronjob to clean things up for me.</p>
<pre>0 0 * * * find /home/iphone/Maildir/ ! -type d -type f
-path "*/cur/*" -daystart -ctime +1 -exec rm -f {} ; 2&gt; /dev/null/</pre>
<p><em>Note that the newline is only for formatting on this page. cron does not permit commands to be split across multiple lines.</em></p>
<p>This just goes through the iphone mailbox's Maildir and removes and messages that are older than 1 day. It gets not only the messages in the inbox, but also anything that I may have manually deleted. This isn't necessary by any means, but I'm lazy. What sys admin isn't, though.</p>
]]></content:encoded>
			<wfw:commentRss>http://rugmonster.org/2010/03/iphones-mail-app-and-imap-folders/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<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't work at all. I don't know how I managed to do that, but I've fixed it and it'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 [...]]]></description>
			<content:encoded><![CDATA[<p>UPDATE: I found that what I originally posted was wrong and didn't work at all. I don't know how I managed to do that, but I've fixed it and it'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'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: #007800;">$1</span> <span style="color: #000000; font-weight: bold;">||</span> <span style="color: #660033;">-z</span> <span style="color: #007800;">$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: #007800;">$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 "rugmonster.org" 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's been a lot of FTP activity, but this was prompted as a result of some files be deleted by someone that shouldn'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>1</slash:comments>
		</item>
	</channel>
</rss>

<!-- Performance optimized by W3 Total Cache. Learn more: http://www.w3-edge.com/wordpress-plugins/

Page Caching using disk: enhanced
Object Caching 440/551 objects using disk: basic
Content Delivery Network via Rackspace Cloud Files: c475063.r63.cf2.rackcdn.com

Served from: rugmonster.org @ 2012-05-19 21:19:23 -->
