<?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>think &#187; Random</title>
	<atom:link href="http://think.random-stuff.org/topics/uncategorized/feed" rel="self" type="application/rss+xml" />
	<link>http://think.random-stuff.org</link>
	<description></description>
	<lastBuildDate>Wed, 25 May 2011 20:37:48 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.1</generator>
		<item>
		<title>Spotlight for coders</title>
		<link>http://think.random-stuff.org/posts/spotlight-for-coders</link>
		<comments>http://think.random-stuff.org/posts/spotlight-for-coders#comments</comments>
		<pubDate>Tue, 01 Mar 2011 16:40:10 +0000</pubDate>
		<dc:creator>Allan</dc:creator>
				<category><![CDATA[Mac]]></category>
		<category><![CDATA[Random]]></category>

		<guid isPermaLink="false">http://think.random-stuff.org/?p=199</guid>
		<description><![CDATA[Apologies to everyone who already knew this&#8230; I just discovered something very cool. As an only occasional coder (Python, mostly, when I get the chance to write code), I don&#8217;t have a very good grasp of where all the header files for Mac OS X frameworks live. Let&#8217;s say that you want to know where CGEventSourceSecondsSinceLastEventType [...]]]></description>
			<content:encoded><![CDATA[<p>Apologies to everyone who already knew this&#8230;</p>
<p>I just discovered something very cool. As an only occasional coder (Python, mostly, when I get the chance to write code), I don&#8217;t have a very good grasp of where all the header files for Mac OS X frameworks live.</p>
<p>Let&#8217;s say that you want to know where <strong><span style="color: #808080;">CGEventSourceSecondsSinceLastEventType</span></strong> is defined. Just hunt for it in Spotlight and it will turn up all the places it shows up in header files.</p>
<p>E.g.</p>
<p><strong><span style="color: #808080;">/Developer/Platforms/iPhoneSimulator.platform/Developer/SDKs /iPhoneSimulator3.2.sdk/System/Library/Frameworks/ApplicationServices.framework /Versions/A/Frameworks/CoreGraphics.framework/Versions/A/Headers</span></strong></p>
<p>Or</p>
<p><strong><span style="color: #808080;">/Developer/SDKs/MacOSX10.6.sdk/System/Library/Frameworks /IOKit.framework/Versions/A/Headers/hidsystem</span></strong></p>
<p>Clicking on the Spotlight results opens the file in Xcode.</p>
<p>Who knew?</p>
]]></content:encoded>
			<wfw:commentRss>http://think.random-stuff.org/posts/spotlight-for-coders/feed</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>Coming up with a question is also creation</title>
		<link>http://think.random-stuff.org/posts/coming-up-with-a-question-is-also-creation</link>
		<comments>http://think.random-stuff.org/posts/coming-up-with-a-question-is-also-creation#comments</comments>
		<pubDate>Thu, 30 Sep 2010 22:25:49 +0000</pubDate>
		<dc:creator>Allan</dc:creator>
				<category><![CDATA[Museum]]></category>
		<category><![CDATA[Random]]></category>

		<guid isPermaLink="false">http://think.random-stuff.org/?p=181</guid>
		<description><![CDATA[To create is not just to produce objects or phenomena. Coming up [with] a question is also creation. In fact, a question that has a huge receptive capacity doesn&#8217;t even need a definitive answer. The very essence of a question is its power to elicit the possibilities or reply, to trigger a variety of thoughts. [...]]]></description>
			<content:encoded><![CDATA[<p><em>To create is not just to produce objects or phenomena.</em></p>
<p><em>Coming up </em><span style="color: #808080;">[with]</span><em> a question is also creation.</em></p>
<p><em>In fact, a question that has a huge receptive capacity doesn&#8217;t even need a definitive answer.</em></p>
<p><em>The very essence of a question is its power to elicit the possibilities or reply, to trigger a variety of thoughts.</em></p>
<p><em>Questioning is emptiness.</em></p>
<p><em>The total quantity of thoughts triggered by questioning is what matters most.</em></p>
<p><em>I entreat you not to produce more but to think more.</em></p>
<p><em>I believe that the richness of that thinking may very well be the critical resources to giving this world a future.</em></p>
<p>&#8211; <a href="http://www.youtube.com/watch?v=PG4uRmTJUU8#t=51m25s">Kenya Hara at Google</a></p>
<p>Found via <a href="http://www.core77.com/blog/object_culture/japanese_rooms_the_meaning_of_mu_and_kenya_hara_on_emptiness_17529.asp">Core77</a></p>
]]></content:encoded>
			<wfw:commentRss>http://think.random-stuff.org/posts/coming-up-with-a-question-is-also-creation/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Mac OS X ssh quickie</title>
		<link>http://think.random-stuff.org/posts/mac-os-x-ssh-quickie</link>
		<comments>http://think.random-stuff.org/posts/mac-os-x-ssh-quickie#comments</comments>
		<pubDate>Fri, 06 Aug 2010 16:49:33 +0000</pubDate>
		<dc:creator>Allan</dc:creator>
				<category><![CDATA[Mac]]></category>
		<category><![CDATA[Random]]></category>

		<guid isPermaLink="false">http://think.random-stuff.org/?p=174</guid>
		<description><![CDATA[Are you getting these messages in your console log when you make a new user on Mac OS X and then try to ssh in to the computer with that new user name? Aug  6 12:33:25 example sshd[7296]: in pam_sm_authenticate(): Failed to determine Kerberos principal name Aug  6 12:33:29 example sshd[7294]: error: PAM: authentication error [...]]]></description>
			<content:encoded><![CDATA[<p>Are you getting these messages in your console log when you make a new user on Mac OS X and then try to ssh in to the computer with that new user name?</p>

<div class="wp_syntax"><div class="code"><pre class="text" style="font-family:monospace;">Aug  6 12:33:25 example sshd[7296]: in pam_sm_authenticate(): Failed to determine Kerberos principal name
Aug  6 12:33:29 example sshd[7294]: error: PAM: authentication error for user from example.com via 192.168.0.1
Aug  6 12:33:29 example sshd[7297]: in pam_sm_authenticate(): Failed to determine Kerberos principal name.
Aug  6 12:33:32 example sshd[7294]: error: PAM: user account has expired for user from example.com via 192.168.0.1</pre></div></div>

<p>Then don&#8217;t do what I did. After <a href="http://www.google.com/search?q=pam_sm_authenticate():+Failed+to+determine+Kerberos+principal+name">googling to no avail</a>, I went so far as to completely reinstall Mac OS X. No good.</p>
<p>[Update: Actually, what I did was clone a different system that I had recently set up and used it as the "new installation". Had I done a total, from DVD reinstallation, it would have fixed the problem but I wouldn't have discovered the cause.]</p>
<p>The answer? Make sure you didn&#8217;t set the Remote Login preferences in System Preferences/Sharing to &#8220;Only these users&#8221; and then forget to add the new user to the list!</p>
<p>D&#8217;oh.</p>
<p>Hopefully this will help the next person who&#8217;s looking for the answer.</p>
]]></content:encoded>
			<wfw:commentRss>http://think.random-stuff.org/posts/mac-os-x-ssh-quickie/feed</wfw:commentRss>
		<slash:comments>2</slash:comments>
		</item>
		<item>
		<title>Old bits slipping away</title>
		<link>http://think.random-stuff.org/posts/old-bits-slipping-away</link>
		<comments>http://think.random-stuff.org/posts/old-bits-slipping-away#comments</comments>
		<pubDate>Sat, 10 Jul 2010 13:42:07 +0000</pubDate>
		<dc:creator>Allan</dc:creator>
				<category><![CDATA[Random]]></category>

		<guid isPermaLink="false">http://think.random-stuff.org/?p=150</guid>
		<description><![CDATA[I moved this blog from one of the Mac minis in my basement to the other (I&#8217;m trying to put everything on the newer one to free the other one up) yesterday. Originally I had been blogging using Plone (from about 2005-2007) and then moved to WordPress. Moving the Plone part seemed like it was [...]]]></description>
			<content:encoded><![CDATA[<p>I moved this blog from one of the Mac minis in my basement to the other (I&#8217;m trying to put everything on the newer one to free the other one up) yesterday. Originally I had been blogging using Plone (from about 2005-2007) and then moved to WordPress. Moving the Plone part seemed like it was more work than I wanted to put in, so it&#8217;s goodbye to those posts.</p>
]]></content:encoded>
			<wfw:commentRss>http://think.random-stuff.org/posts/old-bits-slipping-away/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Ubuntu on Eee Box B202</title>
		<link>http://think.random-stuff.org/posts/ubuntu-on-eee-box-b202</link>
		<comments>http://think.random-stuff.org/posts/ubuntu-on-eee-box-b202#comments</comments>
		<pubDate>Mon, 05 Apr 2010 20:33:28 +0000</pubDate>
		<dc:creator>Allan</dc:creator>
				<category><![CDATA[Museum]]></category>
		<category><![CDATA[Random]]></category>

		<guid isPermaLink="false">http://think.random-stuff.org/?p=131</guid>
		<description><![CDATA[I&#8217;m always on the lookout for low-cost, easily maintained computers to drive displays or do other odd jobs around the museum. The Mac mini is still the gold standard for me. But even with the educational discount, a Mac mini can seem like overkill. We have an exhibit coming up where there&#8217;s going to be [...]]]></description>
			<content:encoded><![CDATA[<p>I&#8217;m always on the lookout for low-cost, easily maintained computers to drive displays or do other odd jobs around the <a href="http://web.mit.edu/museum/">museum</a>. The Mac mini is <a href="http://think.random-stuff.org/posts/ode-to-the-mac-mini">still the gold standard for me</a>. But even with the educational discount, a Mac mini can seem like overkill. We have an exhibit coming up where there&#8217;s going to be a projection of a single, still image. Some projectors can take an image from a flash drive, but none of the ones we have laying around can do that. So it was either spend money on a projector that can, or get a computer to drive it. (We could also use a DVD player with a single frame video loop, but that wouldn&#8217;t give me full 1024&#215;768 resolution on the projector.) So last week I bought an <a href="http://event.asus.com/eeepc/microsites/eeebox/en/index.html">Eee Box B202</a> preloaded with Linux.</p>
<p>Initially it was a bust. I hooked it up to a monitor, turned it on, and it booted to a text login prompt. No nice multi-media GUI, nothing. Just login:</p>
<p>Googling around was no help. I couldn&#8217;t figure out how to make it start X Windows or anything. The OS that&#8217;s on there is called <a href="http://en.wikipedia.org/wiki/Red_Flag_Linux">Red Flag Linux</a>. It seemed to have everything it needed, but I don&#8217;t have enough Xorg fu to understand how it was supposed to figure out how to configure itself for the monitor I had.</p>
<p>It turns out that was a blessing in disguise. After a little more Googling, I found myself making a <a href="https://help.ubuntu.com/community/Installation/FromUSBStick">bootable USB stick with Ubuntu 9.10</a> on it. I wound up using the &#8220;From Linux&#8221; instructions from another Ubuntu box. I debated whether or not to use the <a href="https://help.ubuntu.com/community/Installation/FromUSBStick#Ubuntu%20CD%20or%20ISO">netbook distro or the full desktop one</a>. I picked the full one. It turned out to be the right choice.</p>
<p>I did mess with the B202&#8242;s BIOS a bit to figure out how to make it boot from the USB stick. I&#8217;m not sure whether any of that was strictly necessary, but I had changed a few things to try to get the original software running.</p>
<p>After that it was smooth sailing. Ubuntu booted right up, running from the USB stick. It helpfully presented the option of installing from the stick. Once I made sure it would be able to work with the ethernet and WiFi, I used the installer to reformat the drive and install Ubuntu.</p>
<p>Things went so well, I&#8217;m ordering another one. The first one&#8217;s going to run our projector. The next one&#8217;s going to act as a <a href="https://help.ubuntu.com/community/Internet/ConnectionSharing">WiFi to ethernet connection sharing</a> router.</p>
<p>This was my first experience with a LiveCD/LiveUSB/etc. linux. It&#8217;s probably unremarkable these days, but I&#8217;m impressed with how easy it was to do.</p>
<p>Update: I just got my 2nd Eee Box. This one came with Windows XP pre-installed. Here are the steps needed to install Ubuntu:</p>
<ol>
<li>When it boots into ExpressGate, click the Exit icon, then hold down DEL to get into the BIOS setup</li>
<li>In BIOS-&gt;Tools: Disable ExpressGate, then hit ESC to exit</li>
<li>In BIOS-&gt;Boot-&gt;Hard Drives: hit + to make 1st drive = USB:SMI USB Disk</li>
<li>Plug in your Ubuntu USB stick</li>
<li>Hit F10 to save and exit</li>
</ol>
<p>Now it will boot from the USB stick. At this point you can either boot into Ubuntu w/o installing (i.e. run from the stick) or install Ubuntu. If you&#8217;re unsure whether you want to go through with this before you try, then choose the first option. Note that it takes a longish time to boot from the stick.</p>
<p>Once it boots, you&#8217;ll see an icon in the upper left corner labeled &#8220;Install Ubuntu 9.10&#8243;. Double-click that to do an installation.</p>
]]></content:encoded>
			<wfw:commentRss>http://think.random-stuff.org/posts/ubuntu-on-eee-box-b202/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>newsyslog on Mac OS X</title>
		<link>http://think.random-stuff.org/posts/newsyslog-on-mac-os-x</link>
		<comments>http://think.random-stuff.org/posts/newsyslog-on-mac-os-x#comments</comments>
		<pubDate>Tue, 30 Mar 2010 01:04:17 +0000</pubDate>
		<dc:creator>Allan</dc:creator>
				<category><![CDATA[Mac]]></category>
		<category><![CDATA[Random]]></category>

		<guid isPermaLink="false">http://think.random-stuff.org/?p=127</guid>
		<description><![CDATA[So, just to finish off what I&#8217;ve learned about newsyslog on Mac OS X&#8230; In addition to figuring out how to deal with denyhosts, here&#8217;s how to set up Apache and Mailman log rotation. I&#8217;m running standard Apache 2.2 that comes with Mac OS X 10.6. I like to keep all my virtual hosts in [...]]]></description>
			<content:encoded><![CDATA[<p>So, just to finish off what I&#8217;ve learned about <a href="http://www.weird.com/~woods/projects/newsyslog.html">newsyslog</a> on Mac OS X&#8230;</p>
<p>In addition to figuring out how to <a href="http://think.random-stuff.org/posts/denyhosts-on-mac-os-x">deal with denyhosts</a>, here&#8217;s how to set up <a href="http://httpd.apache.org/docs/2.2/">Apache</a> and <a href="http://www.gnu.org/software/mailman/docs.html">Mailman</a> log rotation.</p>
<p>I&#8217;m running standard Apache 2.2 that comes with Mac OS X 10.6. I like to keep all my virtual hosts in one place, so in this example they are all in /Users/web/. Each host gets a directory structure with it&#8217;s own name:</p>

<div class="wp_syntax"><div class="code"><pre class="bash" style="font-family:monospace;"><span style="color: #666666; font-style: italic;"># ls -l www.example.org/</span>
drwxrwxr-x   <span style="color: #000000;">4</span> _unknown  _unknown   <span style="color: #000000;">136</span> Jan <span style="color: #000000;">27</span> <span style="color: #000000;">16</span>:<span style="color: #000000;">47</span> htdocs
drwxrwxr-x  <span style="color: #000000;">80</span> _www      _www      <span style="color: #000000;">2720</span> Mar <span style="color: #000000;">29</span> 00:<span style="color: #000000;">33</span> logs
<span style="color: #660033;">-rw-r--r--</span>   <span style="color: #000000;">1</span> adoyle    web       <span style="color: #000000;">1881</span> Feb <span style="color: #000000;">20</span> <span style="color: #000000;">15</span>:<span style="color: #000000;">44</span> www.example.org.conf</pre></div></div>

<p>The logs for each virtual host go into the logs directory for that host (access_log, error_log, rewrite_log). Ownership on the log files turns out to be important. I&#8217;ve found it works best for me if they are owned by the www user and group (or _www, they are essentially the same &#8211; something I need to understand the reason for someday).</p>
<p>In /etc/newsyslog.d/local.conf, the following lines deal with rotating logs for three virtual hosts. Using the &#8216;G&#8217; flag lets you use &#8216;*&#8217; and other shell wildcards in the file names. I think I could probably have collapsed these into a single line if I had used /Users/web/*/logs/*log instead. In this case, folding things up too much makes it less readable, I think.</p>
<p>The _www:_www takes care of preserving the file ownership after the logs are rotated. A count of 30 means keep around up to 30 old logs. $D0 means rotate daily at 0:00. The &#8216;B&#8217; flag prevents the &#8220;Log file was rotated&#8221; message. Apache keeps a pidfile in /var/run/httpd.pid. If you send a kill -30 to the pid in that file, it will cause the equivalent of an &#8216;apachectl graceful&#8217;.</p>
<p>If you don&#8217;t provide the pidfile and proper signal number, the logs will rotate, new log files get created, but Apache won&#8217;t write to them because it&#8217;s still trying to write to the old ones.</p>

<div class="wp_syntax"><div class="code"><pre class="xorg_conf" style="font-family:monospace;"><span style="color: #adadad; font-style: italic;"># logfilename          [owner:group]            mode count  size  when   flags [/pid_file] [sig_num]</span>
/Users/web/lists.example.org/logs/*log _www:_www <span style="color: #cc66cc;">664</span>   <span style="color: #cc66cc;">30</span>     *    $D0     GBJ /var/run/httpd.pid <span style="color: #cc66cc;">30</span>
/Users/web/foo.example.org/logs/*log   _www:_www <span style="color: #cc66cc;">664</span>   <span style="color: #cc66cc;">30</span>     *    $D0     GBJ /var/run/httpd.pid <span style="color: #cc66cc;">30</span>
/Users/web/www.example.org/logs/*log   _www:_www <span style="color: #cc66cc;">664</span>   <span style="color: #cc66cc;">30</span>     *    $D0     GBJ /var/run/httpd.pid <span style="color: #cc66cc;">30</span>
<span style="color: #adadad; font-style: italic;">#</span></pre></div></div>

<p>With Mailman I had a slight problem. Mailman doesn&#8217;t use nice .log or _log names. It just uses names like bounce, error, post, qrunner, etc. I could have made an entry in the local.conf file for each one, but that seemed error-prone. What if later there&#8217;s a new version of Mailman that generates different log files?</p>
<p>My initial assumption was that I could use &#8230;/logs/* and newsyslog wouldn&#8217;t try to rotate logs it had already rotated. Guess again. After two days, my disk had nearly filled up with files ending in .bz2, .bz2.bz2, .bz2.bz2.b2z&#8230;, you get the picture. Luckily I noticed it before the disk did fill up. I got suspicious when my backups on the third day were 15GB bigger than the ones on the first day. I have no idea how many files actually got created. &#8216;ls&#8217; was unable to produce a listing in the amount of time I was willing to wait. Luckily rm -rf did work. It took several hours to delete all the files.</p>
<p>I&#8217;m assuming newsyslog had gotten into a recursive loop right away when it ran at midnight and never stopped churning out files until I killed it.</p>
<p>So anyway, the moral of the story is, if you&#8217;re going to use wildcards, make sure they don&#8217;t match the rotated logs.</p>

<div class="wp_syntax"><div class="code"><pre class="xorg_conf" style="font-family:monospace;"><span style="color: #adadad; font-style: italic;"># logfilename          [owner:group]            mode count  size  when  flags [/pid_file] [sig_num]</span>
/Users/mailman/logs/*<span class="br0">&#91;</span>a-z<span class="br0">&#93;</span>         mailman:_www <span style="color: #cc66cc;">664</span>   <span style="color: #cc66cc;">30</span>     *    $D0     GBJ /Users/mailman/data/master-qrunner.pid <span style="color: #cc66cc;">1</span>
<span style="color: #adadad; font-style: italic;">#</span></pre></div></div>

<p>Mailman wants to be hit with a kill -1, so that&#8217;s what I used.</p>
<p>Things have been noodling along for a few weeks with my setup, so I think I have the kinks ironed out.</p>
]]></content:encoded>
			<wfw:commentRss>http://think.random-stuff.org/posts/newsyslog-on-mac-os-x/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>denyhosts on Mac OS X</title>
		<link>http://think.random-stuff.org/posts/denyhosts-on-mac-os-x</link>
		<comments>http://think.random-stuff.org/posts/denyhosts-on-mac-os-x#comments</comments>
		<pubDate>Fri, 26 Mar 2010 00:46:21 +0000</pubDate>
		<dc:creator>Allan</dc:creator>
				<category><![CDATA[Mac]]></category>
		<category><![CDATA[Random]]></category>

		<guid isPermaLink="false">http://think.random-stuff.org/?p=88</guid>
		<description><![CDATA[I just spent some time figuring out how to set up denyhosts on Snow Leopard. I&#8217;ve used denyhosts before, but never felt like I had things set up properly for Mac OS. Now I think I have it figured out, so here it is. This is for 10.6, your mileage may vary on earlier versions. [...]]]></description>
			<content:encoded><![CDATA[<p>I just spent some time figuring out how to set up <a href="http://denyhosts.sourceforge.net/">denyhosts</a> on Snow Leopard. I&#8217;ve used denyhosts before, but never felt like I had things set up properly for Mac OS. Now I think I have it figured out, so here it is. This is for 10.6, your mileage may vary on earlier versions.</p>
<p>I had three goals – get denyhosts working, get it to start automatically at boot time, and to deal with rotating the logs.</p>
<p><strong>1. Installation</strong><br />
Easiest first &#8211; installing denyhosts. Note that you need to be root to do this. Pretty much just follow the directions. These are the three main settings to worry about.</p>

<div class="wp_syntax"><div class="code"><pre class="xorg_conf" style="font-family:monospace;">SECURE_LOG = /private/var/log/secure.log
LOCK_FILE = /var/run/denyhosts.pid
DAEMON_LOG = /var/log/denyhosts</pre></div></div>

<p>Note that you also may need to create the file <a href="http://developer.apple.com/mac/library/documentation/Darwin/Reference/ManPages/man5/hosts_access.5.html">/etc/hosts.deny</a>:</p>

<div class="wp_syntax"><div class="code"><pre class="bash" style="font-family:monospace;"><span style="color: #c20cb9; font-weight: bold;">touch</span> <span style="color: #000000; font-weight: bold;">/</span>etc<span style="color: #000000; font-weight: bold;">/</span>hosts.deny</pre></div></div>

<p>Using <strong>touch</strong> will create a zero-length file if it&#8217;s not there. It won&#8217;t affect the contents if it is there.</p>
<p><strong>2. Log rotation</strong></p>
<p>Mac OS 10.6 uses <a href="http://www.weird.com/~woods/projects/newsyslog.html">newsyslog</a> to rotate some log files (I&#8217;m not sure why, but apache logs don&#8217;t seem to be dealt with by newsyslog). To add your own to the mix, just put a file into <strong>/etc/newsyslog.d/</strong> following the format for <a href="http://developer.apple.com/mac/library/documentation/Darwin/Reference/ManPages/man5/newsyslog.conf.5.html">newsyslog.conf(5)</a>. I called mine <strong>local.conf</strong></p>

<div class="wp_syntax"><div class="code"><pre class="xorg_conf" style="font-family:monospace;"><span style="color: #adadad; font-style: italic;"># logfilename          [owner:group]            mode count size when  flags [/pid_file] [sig_num]</span>
/var/log/denyhosts                              <span style="color: #cc66cc;">640</span>   <span style="color: #cc66cc;">5</span>     *    $D0     J
<span style="color: #adadad; font-style: italic;">#</span></pre></div></div>

<p>The trouble is, this rotated the log just fine, but then denyhosts stopped logging because newsyslog essentially pulls the rug out from under denyhosts by moving the file.</p>
<p>One design difference between newsyslog and <a href="http://linuxcommand.org/man_pages/logrotate8.html">logrotate</a> is the way they deal with notifying processes that logs have been rotated. Logrotate uses prerotate and postrotate scripts, which would be ideal for denyhosts. The way you start and stop it is with</p>

<div class="wp_syntax"><div class="code"><pre class="bash" style="font-family:monospace;">daemon-control start
&nbsp;
daemon-control stop</pre></div></div>

<p><strong>daemon-control stop</strong> actually sends a <strong>SIGTERM</strong> to the denyhosts process, but that won&#8217;t do any good in the newsyslog config file since once stopped, you need a command line to start it up again. So I decided to tweak the <strong>daemon-control</strong> script to do this. I replaced the <strong>start()</strong> function with the one here:</p>

<div class="wp_syntax"><div class="code"><pre class="python" style="font-family:monospace;"><span style="color: #ff7700;font-weight:bold;">def</span> start<span style="color: black;">&#40;</span><span style="color: #66cc66;">*</span>args<span style="color: black;">&#41;</span>:
    <span style="color: #dc143c;">cmd</span> = <span style="color: #483d8b;">&quot;%s --daemon &quot;</span> <span style="color: #66cc66;">%</span> DENYHOSTS_BIN
    <span style="color: #ff7700;font-weight:bold;">if</span> args: <span style="color: #dc143c;">cmd</span> += <span style="color: #483d8b;">' '</span>.<span style="color: black;">join</span><span style="color: black;">&#40;</span>args<span style="color: black;">&#41;</span>
&nbsp;
    <span style="color: #ff7700;font-weight:bold;">print</span> <span style="color: #483d8b;">&quot;starting DenyHosts:   &quot;</span>, <span style="color: #dc143c;">cmd</span>
&nbsp;
    <span style="color: #ff7700;font-weight:bold;">while</span> <span style="color: #008000;">True</span>:
        <span style="color: #dc143c;">os</span>.<span style="color: black;">system</span><span style="color: black;">&#40;</span><span style="color: #dc143c;">cmd</span><span style="color: black;">&#41;</span>
        <span style="color: #dc143c;">time</span>.<span style="color: black;">sleep</span><span style="color: black;">&#40;</span><span style="color: #ff4500;">5</span><span style="color: black;">&#41;</span>
&nbsp;
        <span style="color: #ff7700;font-weight:bold;">while</span> <span style="color: #008000;">True</span>:
            pid = getpid<span style="color: black;">&#40;</span><span style="color: black;">&#41;</span>
            <span style="color: #ff7700;font-weight:bold;">if</span> pid <span style="color: #66cc66;">&gt;</span>= <span style="color: #ff4500;">0</span>:
                <span style="color: #dc143c;">time</span>.<span style="color: black;">sleep</span><span style="color: black;">&#40;</span><span style="color: #ff4500;">300</span><span style="color: black;">&#41;</span>
            <span style="color: #ff7700;font-weight:bold;">else</span>:
                <span style="color: #ff7700;font-weight:bold;">break</span></pre></div></div>

<p>This just keeps daemon-control running rather than letting it exit after it starts denyhosts. The outer loop starts denyhosts running and later restarts it. The inner loop just waits until it sees the pid file go away. That&#8217;s a sure sign that denyhosts stopped running, most likely because of the SIGHUP it will get from newsyslog. Now all I needed to do was add the signal info to my <span style="text-decoration: line-through;">/etc/denyhosts.d/local.conf</span> /etc/newsyslog.d/local.conf file:</p>

<div class="wp_syntax"><div class="code"><pre class="xorg_conf" style="font-family:monospace;"><span style="color: #adadad; font-style: italic;"># logfilename          [owner:group]            mode count size when  flags [/pid_file] [sig_num]</span>
/var/log/denyhosts                              <span style="color: #cc66cc;">640</span>   <span style="color: #cc66cc;">30</span>     *  $D0     BJ  /var/run/denyhosts.pid <span style="color: #cc66cc;">15</span>
<span style="color: #adadad; font-style: italic;">#</span></pre></div></div>

<p>I&#8217;ve also changed it to keep 30 days of logs, and added the <strong>B</strong> flag to prevent newsyslog from adding a line to the file saying it&#8217;s rotated the logs. Note that I changed the name to daemon-control2 so if I update denyhosts later, my changes don&#8217;t get clobbered.</p>
<p><strong>3. Start at boot time</strong></p>
<p>It turns out that modifying daemon-control to never exit is also just the ticket for running it under <strong>launchd</strong>. Launchd doesn&#8217;t work well on scripts that launch daemonized processes. It watches the script and notices that it&#8217;s exited, then tries to start it again.</p>
<p>I made a file called /Library/LaunchDaemons/net.hosts.deny.plist:</p>
<pre>&lt;?xml version="1.0" encoding="UTF-8"?&gt;
&lt;!DOCTYPE plist PUBLIC "-//Apple Computer//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd"&gt;
&lt;plist version="1.0"&gt;
  &lt;dict&gt;
    &lt;key&gt;Label&lt;/key&gt;
    &lt;string&gt;net.denyhosts&lt;/string&gt;
    &lt;key&gt;ProgramArguments&lt;/key&gt;
    &lt;array&gt;
      &lt;string&gt;/usr/share/denyhosts/daemon-control2&lt;/string&gt;
      &lt;string&gt;start&lt;/string&gt;
    &lt;/array&gt;
    &lt;key&gt;RunAtLoad&lt;/key&gt;
    &lt;true/&gt;
    &lt;key&gt;KeepAlive&lt;/key&gt;
    &lt;true/&gt;
    &lt;key&gt;ServiceDescription&lt;/key&gt;
    &lt;string&gt;Lauch denyhosts&lt;/string&gt;
  &lt;/dict&gt;
&lt;/plist&gt;</pre>
<p>Get it started with launchctl:</p>

<div class="wp_syntax"><div class="code"><pre class="bash" style="font-family:monospace;"> launchctl load <span style="color: #000000; font-weight: bold;">/</span>Library<span style="color: #000000; font-weight: bold;">/</span>LaunchDaemons<span style="color: #000000; font-weight: bold;">/</span>net.hosts.deny.plist</pre></div></div>

<p>My /etc/hosts.deny has about 8500 hosts in it right now. Many of those are probably from the denyhosts synchronization feature pulling in IP addresses from the central server.</p>
<p>Update 2010-03-26: Added some links and clarified some bits.</p>
<p>Update 2010-06-06: Note that /etc/hosts.deny must be present. denyhosts won&#8217;t create it.</p>
]]></content:encoded>
			<wfw:commentRss>http://think.random-stuff.org/posts/denyhosts-on-mac-os-x/feed</wfw:commentRss>
		<slash:comments>9</slash:comments>
		</item>
		<item>
		<title>Dear Safari 4 developers:</title>
		<link>http://think.random-stuff.org/posts/dear-safari-4-developers</link>
		<comments>http://think.random-stuff.org/posts/dear-safari-4-developers#comments</comments>
		<pubDate>Wed, 01 Jul 2009 02:07:44 +0000</pubDate>
		<dc:creator>Allan</dc:creator>
				<category><![CDATA[Mac]]></category>
		<category><![CDATA[Random]]></category>

		<guid isPermaLink="false">http://think.random-stuff.org/?p=66</guid>
		<description><![CDATA[My overall impression is that it&#8217;s slower than the beta and slower than Safari 3. But that&#8217;s gut feel, not with hard data. The &#8220;loading&#8221; bar is also far less obvious now, and I always find myself wondering whether Safari has stopped working because it takes a while to even start showing activity.]]></description>
			<content:encoded><![CDATA[<p><a href="http://think.random-stuff.org/wp-content/uploads/2009/06/flysketchworkflow-20090630-220424.png"><img class="aligncenter size-medium wp-image-68" title="Safari 4 bug report" src="http://think.random-stuff.org/wp-content/uploads/2009/06/flysketchworkflow-20090630-220424-300x182.png" alt="" width="300" height="182" /></a></p>
<p>My overall impression is that it&#8217;s slower than the beta and slower than Safari 3. But that&#8217;s gut feel, not with hard data. The &#8220;loading&#8221; bar is also far less obvious now, and I always find myself wondering whether Safari has stopped working because it takes a while to even start showing activity.</p>
]]></content:encoded>
			<wfw:commentRss>http://think.random-stuff.org/posts/dear-safari-4-developers/feed</wfw:commentRss>
		<slash:comments>2</slash:comments>
		</item>
		<item>
		<title>Moving the server</title>
		<link>http://think.random-stuff.org/posts/moving-the-server</link>
		<comments>http://think.random-stuff.org/posts/moving-the-server#comments</comments>
		<pubDate>Thu, 18 Dec 2008 18:46:12 +0000</pubDate>
		<dc:creator>Allan</dc:creator>
				<category><![CDATA[Mac]]></category>
		<category><![CDATA[Museum]]></category>
		<category><![CDATA[Random]]></category>

		<guid isPermaLink="false">http://think.random-stuff.org/?p=63</guid>
		<description><![CDATA[Is there anything that&#8217;s more nerve-wracking than taking down a perfectly functioning server in order to do something with it? This morning I had to move two servers (a PowerMac G5 running Leopard Server, and a Mac Mini running 10.4) a whopping 6 feet in order to put them onto a dedicated power circuit. I [...]]]></description>
			<content:encoded><![CDATA[<p>Is there anything that&#8217;s more nerve-wracking than taking down a perfectly functioning server in order to do something with it? This morning I had to move two servers (a PowerMac G5 running Leopard Server, and a Mac Mini running 10.4) a whopping 6 feet in order to put them onto a dedicated power circuit. I also needed to install software updates.</p>
<p>Before I ever install any updates on a server, I clone the disk with <a href="http://www.shirt-pocket.com/SuperDuper/SuperDuperDescription.html">SuperDuper</a> or <a href="http://www.bombich.com/software/ccc.html">CCC</a>. That means I also have to first shut down all the services and pull the system off the net, clone the disk, boot the clone to make sure it&#8217;s ok, boot the normal disk, do the update, and test everything. Coupled with having to move the computers, 5 disk drives, and a D-Link switch, I didn&#8217;t have a fun few hours this morning.  I didn&#8217;t update the Leopard Server machine because I couldn&#8217;t get the alternate disk to boot. It turns out that the <a href="http://www.amazon.com/Iomega-33962-FireWire-250GB-Portable/dp/B000W6MFHI/ref=pd_sim_e_3">Iomega portable drive</a> I was using (I love these little disks!) wasn&#8217;t getting enough power from the G5&#8242;s front connector and needed to be plugged in the back. By the time I figured that out, it was too late, the <a href="http://web.mit.edu/museum/">museum</a> staff people were coming in and I had to have the server running again. So I&#8217;ll have to do the update another day.</p>
<p>Now one of the remote users on the updated Mini is having trouble getting in via ssh. So is it due to the move, the upgrade, or something completely unrelated? Having tried a bunch of things and looked at the log files, I&#8217;m leaning towards &#8220;something else&#8221;.</p>
<p>The one good thing that comes from this kind of thing is that you learn whether all the services are properly set up to start at boot time.</p>
]]></content:encoded>
			<wfw:commentRss>http://think.random-stuff.org/posts/moving-the-server/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Quick plug &#8211; some apps</title>
		<link>http://think.random-stuff.org/posts/quick-plug-some-apps</link>
		<comments>http://think.random-stuff.org/posts/quick-plug-some-apps#comments</comments>
		<pubDate>Fri, 27 Jun 2008 00:46:10 +0000</pubDate>
		<dc:creator>Allan</dc:creator>
				<category><![CDATA[Random]]></category>

		<guid isPermaLink="false">http://think.random-stuff.org/?p=20</guid>
		<description><![CDATA[Just a quick plug for some Mac applications that make my life a lot easier. Namely. It&#8217;s a free application launcher for Mac OS X 10.5. I used to use MenuStrip in 10.4 but really only used it for the Quick Launcher feature. When I upgraded to 10.5, I found Namely, which does just one thing. You [...]]]></description>
			<content:encoded><![CDATA[<p>Just a quick plug for some Mac applications that make my life a lot easier.</p>
<p><a href="http://amarsagoo.info/namely/">Namely</a>. It&#8217;s a free application launcher for Mac OS X 10.5. I used to use <a href="http://www.macpoweruser.com/menustrip/">MenuStrip</a> in 10.4 but really only used it for the Quick Launcher feature. When I upgraded to 10.5, I found Namely, which does just one thing. You set a hot-key combination that lets you pop open the Namely window. Then type in a few letters of the application you want to launch, and hit enter. I find myself using the dock less and less these days.</p>
<p><a href="http://fluidapp.com/">Fluid</a>. Another Mac OS X 10.5 only application. It lets you build a &#8220;site specific browser&#8221; i.e. a separate application out of a browser window. I&#8217;ve wrapped my Google Calendar in Fluid and just keep it running all the time.</p>
<p><a href="http://flyingmeat.com/voodoopad/voodoopadpro.html">VoodooPad</a> Pro. I use it for two things. I have one document to keep track of stuff I&#8217;m doing. I have another that I lock with a password to keep track of all my passwords. I haven&#8217;t done any scripting with its built-in <a href="http://www.lua.org/">Lua</a> script engine, but I keep meaning to&#8230;</p>
<p><a href="http://flyingmeat.com/flysketch/">FlySketch</a>. I use this for screen grabs all the time. One great use is to capture those web receipts you get when you buy something or pay for something. I grab them with FlySketch and put them into VoodooPad Pro.</p>
<p><a href="http://www.obdev.at/products/littlesnitch/index.html">Li&#8217;l Snitch</a>. A great little app that lets me know what&#8217;s happening on my net connection.</p>
]]></content:encoded>
			<wfw:commentRss>http://think.random-stuff.org/posts/quick-plug-some-apps/feed</wfw:commentRss>
		<slash:comments>3</slash:comments>
		</item>
	</channel>
</rss>

