<?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"
	>

<channel>
	<title>dannyman.toldme.com &#187; FreeBSD</title>
	<atom:link href="http://dannyman.toldme.com/category/technical/freebsd/feed/" rel="self" type="application/rss+xml" />
	<link>http://dannyman.toldme.com</link>
	<description>Interesting bits of information and editorial, evolving online since 1995.</description>
	<pubDate>Tue, 25 Nov 2008 04:58:22 +0000</pubDate>
	<generator>http://wordpress.org/?v=2.6.5</generator>
	<language>en</language>
			<item>
		<title>HOWTO: Random Number in Shell Script</title>
		<link>http://dannyman.toldme.com/2008/07/04/shell-sh-bash-random-splay/</link>
		<comments>http://dannyman.toldme.com/2008/07/04/shell-sh-bash-random-splay/#comments</comments>
		<pubDate>Fri, 04 Jul 2008 20:55:23 +0000</pubDate>
		<dc:creator>dannyman</dc:creator>
		
		<category><![CDATA[Featured]]></category>

		<category><![CDATA[FreeBSD]]></category>

		<category><![CDATA[Linux]]></category>

		<category><![CDATA[Mac OS X]]></category>

		<category><![CDATA[Technical]]></category>

		<category><![CDATA[bash]]></category>

		<category><![CDATA[csh]]></category>

		<category><![CDATA[jot sleep]]></category>

		<category><![CDATA[ksh]]></category>

		<category><![CDATA[random]]></category>

		<category><![CDATA[scripting]]></category>

		<category><![CDATA[sh]]></category>

		<category><![CDATA[tcsh]]></category>

		<guid isPermaLink="false">http://dannyman.toldme.com/?p=1541</guid>
		<description><![CDATA[<i>How do you conjure a random number within a specific range in a shell script?</i>  Updated with three different solutions, and two variants.]]></description>
			<content:encoded><![CDATA[<p>The other day I was working on a shell script to be run on several hundred machines at the same time.  Since the script was going to download a file from a central server, and I did not want to overwhelm the central server with hundreds of simultaneous requests, I decided that I wanted to add a random wait time.  <em>But how do you conjure a random number within a specific range in a shell script?</em></p>
<p><b>Updated:</b>  Due to much feedback, I now know of three ways to do this . . .</p>
<p>1) <strong>On BSD systems</strong>, you can use <code><a href="http://developer.apple.com/documentation/Darwin/Reference/ManPages/man1/jot.1.html">jot(1)</a></code>:<br />
<code>sleep `jot -r 1 1 900`</code></p>
<p>2) <strong>If you are scripting with bash</strong>, you can use <code>$RANDOM</code>:<br />
<code>sleep `echo $RANDOM%900 | bc`</code></p>
<p>3) <strong>For portability</strong>, you can resort to my first solution:<br />
<code># Sleep up to fifteen minutes<br />
sleep `echo $$%900 | bc`</code></p>
<p><code>$$</code> is the process ID (PID), or &#8220;random seed&#8221; which on most systems is a value between 1 and <a href="http://en.wikipedia.org/wiki/Integer">65,535</a>.  Fifteen minutes is 900 seconds.  <code>%</code> is <a href="http://en.wikipedia.org/wiki/Modulo_operation">modulo</a>, which is like division but it gives you the remainder.  Thus, <code>$$ % 900</code> will give you a result between 0 and 899.  With bash, <code>$RANDOM</code> provides the same utility, except it is a different value whenever you reference it.</p>
<p><b>Updated yet again . . .</b> says a friend:<br />
nah it&#8217;s using <code>`echo .. | bc`</code> that bugs me, 2 fork+execs, let your shell do the math, it knows how<br />
so <code>$(( $$ % 900 ))</code> should work in bsd sh</p>
<p><strong>For efficiency</strong>, you could rewrite the latter two solutions:<br />
2.1) <code>sleep $(( $RANDOM % 900 ))</code><br />
3.1) <code>sleep $(( $$ % 900 ))</code></p>
<p>The revised solution will work in sh-derived shells: sh, bash, ksh.  My original &#8220;portable&#8221; solution will also work if you&#8217;re scripting in csh or tcsh.</p>
]]></content:encoded>
			<wfw:commentRss>http://dannyman.toldme.com/2008/07/04/shell-sh-bash-random-splay/feed/</wfw:commentRss>
		</item>
		<item>
		<title>Mini-HOWTO: What Time is UTC?</title>
		<link>http://dannyman.toldme.com/2008/05/06/what-time-utc/</link>
		<comments>http://dannyman.toldme.com/2008/05/06/what-time-utc/#comments</comments>
		<pubDate>Tue, 06 May 2008 04:15:41 +0000</pubDate>
		<dc:creator>dannyman</dc:creator>
		
		<category><![CDATA[FreeBSD]]></category>

		<category><![CDATA[Linux]]></category>

		<category><![CDATA[Mac OS X]]></category>

		<category><![CDATA[Technical]]></category>

		<guid isPermaLink="false">http://dannyman.toldme.com/?p=1464</guid>
		<description><![CDATA[I wanted to know what time it was in UTC, but I forgot my local offset.  (It changes twice a year!)  I figured I could look in the date man page, but I came up with an &#8220;easier&#8221; solution.  Simply fudge the time zone and then ask.

0-20:57 djh@noneedto ~$ env TZ=UTC date
Tue [...]]]></description>
			<content:encoded><![CDATA[<p>I wanted to know what time it was in UTC, but I forgot my local offset.  (It changes twice a year!)  I figured I could look in the <code>date</code> man page, but I came up with an &#8220;easier&#8221; solution.  Simply fudge the time zone and <em>then</em> ask.</p>
<pre>
0-20:57 djh@noneedto ~$ <strong>env TZ=UTC date</strong>
Tue May  6 03:57:07 UTC 2008
</pre>
<p>The <code>env</code> bit is not needed in bash, but it makes tcsh happy.</p>
<p><b>Update:</b> <a href="#comment-74835">Mark points out</a> an easier solution:<br />
<code style="font-weight: bolder">date -u</code></p>
<p>Knowing you can set <code>TZ=</code> is still useful in case you ever need to contemplate an alternate timezone.</p>
<p>(Thanks, <a href="http://reasonablegoods.com">Saul</a> and <a href="http://meat.net/">Dave</a> for improving my knowledge.)</p>
]]></content:encoded>
			<wfw:commentRss>http://dannyman.toldme.com/2008/05/06/what-time-utc/feed/</wfw:commentRss>
		</item>
		<item>
		<title>Trendspotting: &#8220;The Amiga Line&#8221;</title>
		<link>http://dannyman.toldme.com/2008/01/26/deader-than-amiga/</link>
		<comments>http://dannyman.toldme.com/2008/01/26/deader-than-amiga/#comments</comments>
		<pubDate>Sat, 26 Jan 2008 05:26:00 +0000</pubDate>
		<dc:creator>dannyman</dc:creator>
		
		<category><![CDATA[Featured]]></category>

		<category><![CDATA[Free Style]]></category>

		<category><![CDATA[FreeBSD]]></category>

		<category><![CDATA[Linux]]></category>

		<category><![CDATA[Mac OS X]]></category>

		<category><![CDATA[Sundry]]></category>

		<category><![CDATA[Technical]]></category>

		<category><![CDATA[Technology]]></category>

		<guid isPermaLink="false">http://dannyman.toldme.com/2008/01/26/deader-than-amiga/</guid>
		<description><![CDATA[I asked myself: what is the threshold for a dead or dying Operating System?]]></description>
			<content:encoded><![CDATA[<p>I have been playing with <a href="http://www.google.com/trends">Google Trends</a>, which will be happy to generate a pretty graph of keyword frequency over time.  A rough gauge to the relative popularity of various things.  This evening, I was riffing off a post from the Royal Pingdom, <a href="http://royal.pingdom.com/?p=239">regarding the relative popularity of Ubuntu and Vista</a>, among other things.</p>
<p>I got started graphing <a href="http://www.google.com/trends?q=Ubuntu%2C+Fedora%2C+SuSE%2C+Gentoo%2C+Debian">various Linux distributions</a> against each other, <a href="http://www.google.com/trends?q=XP%2C+Vista">XP versus Vista</a>, and trying to figure out the best keyword for OS X.  Then, I wondered about FreeBSD.  <a href="http://www.google.com/trends?q=Ubuntu%2C+FreeBSD">Against Ubuntu, it was a flatline.</a>  So, I asked myself: what is the threshold for a dead or dying Operating System?</p>
<p><span style="color: #4684ee">Amiga</span> vs <span style="color: #dc3912">FreeBSD</span>:<br />
<a href="http://www.google.com/trends?q=Amiga%2C+FreeBSD"><img src='http://dannyman.toldme.com/wp-content/uploads/2008/01/amiga-freebsd.png' alt='Google Trends: Amiga versus FreeBSD' border=0 /></a></p>
<p>Ouch!  Can we get deader?</p>
<p><span style="color: #4684ee">Amiga</span> vs <span style="color: #dc3912">FreeBSD</span> vs <span style="color: #ff9900">BeOS</span>:<br />
<a href="http://www.google.com/trends?q=Amiga%2C+FreeBSD%2C+BeOS"><img src='http://dannyman.toldme.com/wp-content/uploads/2008/01/amiga-freebsd-beos.png' alt='Google Trends: Amiga versus FreeBSD versus BeOS' border=0 /></a></p>
<p>To be fair, the cult of Amiga is still strong . . . BeOS is well and truly dead.  But how do the BSDs fare?</p>
<p><span style="color: #4684ee">Amiga</span> vs <span style="color: #dc3912">FreeBSD</span> vs <span style="color: #ff9900">BeOS</span> vs <span style="color: #008000">NetBSD</span> vs <span style="color: #4942cc">OpenBSD</span>:<br />
<a href="http://www.google.com/trends?q=Amiga%2C+FreeBSD%2C+BeOS%2C+NetBSD%2C+OpenBSD"><img src='http://dannyman.toldme.com/wp-content/uploads/2008/01/amiga-bsds.png' alt='Google Trends: *BSD versus Amiga, BeOS' border=0 /></a></p>
<p>NetBSD has been sleeping with the BeOS fishes for a while, and OpenBSD is on its way.  And that&#8217;s a league <em>below</em> Amiga!</p>
<p>In Red Hat land, <a href="http://www.google.com/trends?q=Amiga%2C+Red+Hat%2C+Fedora%2C+CentOS">only Fedora beats &#8220;the Amiga Line&#8221;</a>.  For Unix in general, nothing stops <a href="http://www.google.com/trends?q=FreeBSD%2C+Fedora%2C+Ubuntu%2C+Solaris%2C+SuSE">the Ubuntu juggernaut</a>.  But there&#8217;s <a href="http://www.google.com/trends?q=Ubuntu%2C+Mac%2C+XP%2C+Vista">a long way to go to catch up with Uncle Bill</a>.</p>
<p>(Yes, it is a rainy night and the girlfriend is out of town.)</p>
<p>Postscript: <a href="http://www.google.com/trends?q=Ubuntu%2C+Obama">Ubuntu versus Obama</a></p>
]]></content:encoded>
			<wfw:commentRss>http://dannyman.toldme.com/2008/01/26/deader-than-amiga/feed/</wfw:commentRss>
		</item>
		<item>
		<title>SysAdmin OpEd: Where to Keep the Crons</title>
		<link>http://dannyman.toldme.com/2008/01/11/etc-crontab-or-die/</link>
		<comments>http://dannyman.toldme.com/2008/01/11/etc-crontab-or-die/#comments</comments>
		<pubDate>Fri, 11 Jan 2008 23:04:33 +0000</pubDate>
		<dc:creator>dannyman</dc:creator>
		
		<category><![CDATA[About Me]]></category>

		<category><![CDATA[FreeBSD]]></category>

		<category><![CDATA[Linux]]></category>

		<category><![CDATA[Mac OS X]]></category>

		<category><![CDATA[Technical]]></category>

		<guid isPermaLink="false">http://dannyman.toldme.com/2008/01/11/etc-crontab-or-die/</guid>
		<description><![CDATA[This is just a note which I contributed to a thread on sage-members, to get something off my chest, as to where people should maintain their crontab entries.  I sincerely doubt that reading what I have to say will bring you any great illumination.
I&#8217;d say, any reasonable SysAdmin should default to /etc/crontab because every [...]]]></description>
			<content:encoded><![CDATA[<p>This is just a note which I contributed to a thread on <a href="http://www.sage.org/lists/mailarchive.html">sage-members</a>, to get something off my chest, as to where people should maintain their crontab entries.  I sincerely doubt that reading what I have to say will bring you any great illumination.</p>
<blockquote><p>I&#8217;d say, any reasonable SysAdmin should default to <code>/etc/crontab</code> because every other reasonable SysAdmin already knows where it is.  If anything is used in addition to <code>/etc/crontab</code>, leave a note in <code>/etc/crontab</code> advising the new guy who just got paged at 3:45am where else to look for crons.</p>
<p>For production systems, I strongly object to the use of per-user crontabs.  I&#8217;m glad to hear I&#8217;m not alone.  One thing I have to do in a new environment tends to be to write <a href="/warez/showcrons">a script that will sniff out all the cron entries</a>.</p>
<p>And then there was the shop that used <code>/etc/crontab</code>, user crons, and <a href="http://fcron.free.fr/">fcron</a> to keep crons from running over each other.  This frustrated me enough that I did a poor job of explaining that job concurrency could easily be ensured by executing a command through (something like) <a href="http://fuse4bsd.creo.hu/localcgi/man-cgi.cgi?lockf">the lockf utility</a>, instead of adding <a href="/2006/11/29/crontab-l-u-star/">a new layer of system complexity</a>.</p></blockquote>
<p>Yes, I am a cranky old SysAdmin.</p>
]]></content:encoded>
			<wfw:commentRss>http://dannyman.toldme.com/2008/01/11/etc-crontab-or-die/feed/</wfw:commentRss>
		</item>
		<item>
		<title>HOWTO: Verify a PGP Signature</title>
		<link>http://dannyman.toldme.com/2007/03/30/howto-verify-pgp-signature/</link>
		<comments>http://dannyman.toldme.com/2007/03/30/howto-verify-pgp-signature/#comments</comments>
		<pubDate>Fri, 30 Mar 2007 23:03:16 +0000</pubDate>
		<dc:creator>dannyman</dc:creator>
		
		<category><![CDATA[FreeBSD]]></category>

		<category><![CDATA[Technical]]></category>

		<guid isPermaLink="false">http://dannyman.toldme.com/2007/03/30/howto-verify-pgp-signature/</guid>
		<description><![CDATA[So, assuming you are a SysAdmin, you really want to get a basic understanding of public key cryptography and the rest.  But then, there&#8217;s a lot of stuff you need to learn and sometimes you just need to apply a patch, and would like some decent assurance that the patch hasn&#8217;t been compromised.
Today, I [...]]]></description>
			<content:encoded><![CDATA[<p>So, assuming you are a SysAdmin, you really want to get a basic understanding of public key cryptography and the rest.  But then, there&#8217;s a lot of stuff you need to learn and sometimes you just need to apply a patch, and would like some decent assurance that the patch hasn&#8217;t been compromised.</p>
<p>Today, I am patching&#8211;a few weeks too late&#8211;a FreeBSD system to reflect recent legislative changes to Daylight Saving Time.  The procedure is very simple, and covered in <a href="http://security.freebsd.org/advisories/FreeBSD-EN-07:04.zoneinfo.asc">FreeBSD Security Advisory FreeBSD-EN-07:04.zoneinfo</a>.  It starts:</p>
<blockquote><p>
a) Download the relevant patch from the location below, and verify the detached PGP signature using your PGP utility.</p>
<p><code># <strong>fetch http://security.FreeBSD.org/patches/EN-07:04/zoneinfo.patch</strong><br />
# <strong>fetch http://security.FreeBSD.org/patches/EN-07:04/zoneinfo.patch.asc</strong></code>
</p></blockquote>
<p>Alas, here is a quick-and-dirty crib sheet for the &#8220;verify the detached PGP signature using your PGP utility&#8221; part:<span id="more-1239"></span></p>
<p>If you don&#8217;t already have GPG installed, install it right quick: <code>pkg_add -r gnupg</code></p>
<p>First, generate a key for yourself: <code>gpg --gen-key</code><br />
(Accept the reasonable defaults, and give it a decent passphrase.)</p>
<p>Next, visit <a href="http://www.freebsd.org/doc/en_US.ISO8859-1/books/handbook/pgpkeys.html">The PGP Keys appendix to the FreeBSD Handbook</a> and copy the key data for the Security Officer Team into your text buffer.  (The stuff from <code>pub  1024D/CA6CDFB2</code> to <code>-----END PGP PUBLIC KEY BLOCK-----</code>)  Invoke <code>gpg --import</code> and paste the key data into your terminal.  Press control-D.</p>
<p>Alternatively, you could just suck in all the FreeBSD PGP keys, but that can take a little while:<br />
<code>fetch http://www.freebsd.org/doc/pgpkeyring.txt &#038;&#038; gpg --import pgpkeyking.txt</code></p>
<p>Now, sign the Security Officer Team key with your own key.  This means that you trust that the FreeBSD Security Officer Team is who you think it is, and not someone who has compromised the FreeBSD web site.  This is the dirtiest part of not being a PGP expert, in which case you might have someone in your key ring who could vouch for the FreeBSD Security Officer Team on your behalf.  Anyway: <code>gpg --sign-key security-officer@FreeBSD.org</code></p>
<p>Now, you&#8217;re all set up to verify the zoneinfo signature, and other FreeBSD security patch signatures in the future:</p>
<pre>
&gt; <b>gpg --verify zoneinfo.patch.asc zoneinfo.patch</b>
gpg: WARNING: using insecure memory!
gpg: please see http://www.gnupg.org/faq.html for more information
gpg: Signature made Wed Feb 28 10:36:32 2007 PST using DSA key ID CA6CDFB2
gpg: Good signature from &quot;FreeBSD Security Officer &lt;security-officer@FreeBSD.org&gt;&quot;
</pre>
<p>Yay!  Don&#8217;t forget to learn more about PGP . . . until you do, the drill goes:</p>
<blockquote><p>
<code>gpg --gen-key</code> (Only need to do this once &#8230;)<br />
<code>gpg --import</code><br />
<code>gpg --sign-key</code><br />
<code>gpg --verify</code>  (All you&#8217;ll need to remember once you&#8217;re set up.)
</p></blockquote>
]]></content:encoded>
			<wfw:commentRss>http://dannyman.toldme.com/2007/03/30/howto-verify-pgp-signature/feed/</wfw:commentRss>
		</item>
		<item>
		<title>&#8220;Indiana Time&#8221;</title>
		<link>http://dannyman.toldme.com/2006/03/31/freebsd-howto-fix-indiana-dst/</link>
		<comments>http://dannyman.toldme.com/2006/03/31/freebsd-howto-fix-indiana-dst/#comments</comments>
		<pubDate>Fri, 31 Mar 2006 00:54:28 +0000</pubDate>
		<dc:creator>dannyman</dc:creator>
		
		<category><![CDATA[FreeBSD]]></category>

		<category><![CDATA[Technical]]></category>

		<guid isPermaLink="false">http://dannyman.toldme.com/2006/03/31/freebsd-howto-fix-indiana-dst/</guid>
		<description><![CDATA[Nominally, you would fix a FreeBSD server by supping to stable, and running:
cd /usr/src/share/zoneinfo &#038;&#038; make clean &#038;&#038; make install
Though, you may have a valid reason for not doing all that.  You could instead do this:
~> ls /usr/share/zoneinfo/America/Indiana
Indianapolis    Knox            Marengo [...]]]></description>
			<content:encoded><![CDATA[<p>Nominally, you would fix a FreeBSD server by supping to stable, and running:</p>
<p><code>cd /usr/src/share/zoneinfo &#038;&#038; make clean &#038;&#038; make install</code></p>
<p>Though, you may have a valid reason for not doing all that.  You could instead do this:</p>
<pre><code>~> <strong>ls /usr/share/zoneinfo/America/Indiana</strong>
Indianapolis    Knox            Marengo         Vevay
~> <strong>fetch ftp://elsie.nci.nih.gov/pub/tzdata2006b.tar.gz</strong>
Receiving tzdata2006b.tar.gz (149555 bytes): 100%
149555 bytes transferred in 2.6 seconds (55.68 kBps)
~> <strong>tar xfz tzdata2006b.tar.gz</strong>
~> <strong>sudo zic northamerica</strong>
~> <strong>ls /usr/share/zoneinfo/America/Indiana</strong>
Indianapolis    Marengo         Vevay
Knox            Petersburg      Vincennes</code></pre>
<p>A tip-of-the-hat to <a href="http://wpram.com/log/2006/03/04/commonwealth-games-daylight-saving/">William Computer Blog</a> and participants on <a href="http://lists.freebsd.org/mailman/listinfo/freebsd-questions">the FreeBSD-questions mailing list.</a></p>
]]></content:encoded>
			<wfw:commentRss>http://dannyman.toldme.com/2006/03/31/freebsd-howto-fix-indiana-dst/feed/</wfw:commentRss>
		</item>
		<item>
		<title>pkgwhich == rpm -qf</title>
		<link>http://dannyman.toldme.com/2005/12/07/pkgwhich-rpm-qf/</link>
		<comments>http://dannyman.toldme.com/2005/12/07/pkgwhich-rpm-qf/#comments</comments>
		<pubDate>Wed, 07 Dec 2005 22:17:53 +0000</pubDate>
		<dc:creator>dannyman</dc:creator>
		
		<category><![CDATA[FreeBSD]]></category>

		<category><![CDATA[Linux]]></category>

		<category><![CDATA[Technical]]></category>

		<guid isPermaLink="false">http://dannyman.toldme.com/2005/12/07/pkgwhich-rpm-qf/</guid>
		<description><![CDATA[Aye.  So, let us say you want to know what package a file comes from.
On FreeBSD:
0-17:16 djh@web3 ~> find /var/db/pkg -name +CONTENTS &#124; xargs grep -l pdftex
/var/db/pkg/teTeX-1.0.7_1/+CONTENTS
Ugly, eh?  Which, I think the portinstall stuff has a pkgwhich command.
Linux?
[root@novadb0 pdftex-1.30.5]# rpm -qf /usr/bin/pdftex
tetex-2.0.2-22.EL4.4
Schweet!
]]></description>
			<content:encoded><![CDATA[<p>Aye.  So, let us say you want to know what package a file comes from.</p>
<p>On FreeBSD:</p>
<p><code>0-17:16 djh@web3 ~> <strong>find /var/db/pkg -name +CONTENTS | xargs grep -l pdftex</strong><br />
/var/db/pkg/teTeX-1.0.7_1/+CONTENTS</code></p>
<p>Ugly, eh?  Which, I think the portinstall stuff has a <code>pkgwhich</code> command.</p>
<p>Linux?</p>
<p><code>[root@novadb0 pdftex-1.30.5]# <strong>rpm -qf /usr/bin/pdftex</strong><br />
tetex-2.0.2-22.EL4.4</code></p>
<p>Schweet!</p>
]]></content:encoded>
			<wfw:commentRss>http://dannyman.toldme.com/2005/12/07/pkgwhich-rpm-qf/feed/</wfw:commentRss>
		</item>
		<item>
		<title>WARNING: PermitRootLogin defaults to &#8220;yes&#8221;</title>
		<link>http://dannyman.toldme.com/2005/11/12/permitrootlogin-p4wn3d/</link>
		<comments>http://dannyman.toldme.com/2005/11/12/permitrootlogin-p4wn3d/#comments</comments>
		<pubDate>Sat, 12 Nov 2005 00:14:54 +0000</pubDate>
		<dc:creator>dannyman</dc:creator>
		
		<category><![CDATA[FreeBSD]]></category>

		<category><![CDATA[Linux]]></category>

		<category><![CDATA[Technical]]></category>

		<guid isPermaLink="false">http://dannyman.toldme.com/?p=1025</guid>
		<description><![CDATA[For many yers I have used FreeBSD nearly exclusively.  In the BSD tradition, root is pretty well protected &#8212; root can not log in from remote unless you put some effort into hooking that up, and local users can only run su if they are members of the wheel group.  Because of the [...]]]></description>
			<content:encoded><![CDATA[<p>For many yers I have used FreeBSD nearly exclusively.  In the BSD tradition, <code>root</code> is pretty well protected &#8212; <code>root</code> can not log in from remote unless you put some effort into hooking that up, and local users can only run <code>su</code> if they are members of the <code>wheel</code> group.  Because of the nifty <code>sudo</code> tool and my own disinterest in memorizing any more passwords than necessary, I have tended to remain unconcerned with the root password, setting it and storing the thing somewhere, which is a pain, or setting it to something dumb, or just not setting it, depending on the security needs of a given system.</p>
<p>I recently learned a painful lesson from Fedora: not all unices are as protective of the <code>root</code> user.  Sure, I knew that in Linux any local user can run <code>su</code>, but OpenSSH isn&#8217;t going to allow people to log in as <code>root</code>, right?  <strong>Wrong!</strong><span id="more-1025"></span></p>
<p>I had a test box from ASA that shipped with FC3.  I made it accessible over the Internet.  I added a user for myself, gave him <code>sudo</code> access, and removed the vendor-supplied non-<code>root</code> user.  By default, Fedora Core has a firewall that denies inbound SSH access.  I took that as evidence that Fedora was operating on the principle of least privilege, and reconfigured the firewall to allow inbound SSH, and let the machine be.  A week later I logged in, and kept getting out of memory errors.  Before long, I figured out that the box was owned by hackers, and shut it down.</p>
<p>In discussing the event with colleagues, I learned that Fedora defaults to allowing <code>root</code> to log in via SSH.  And <code>root</code>&#8217;s password had been left, by me, to the default vendor password, which is well-known.  This seems bass ackwards to me &#8212; by default you firewall off SSH, but you allow root to login?  Okay, harsh lesson.  Fedora is stupid.  And I am stupid for not always setting a hard root password.</p>
<p>But it turns out, Fedora isn&#8217;t inventing the stupidity, the stupidity apperently ships with OpenSSH.  Let us RTFM:</p>
<p><b>FreeBSD</b></p>
<pre>
     <strong>PermitRootLogin</strong>
             Specifies whether root can login using ssh(1).  The argument must
             be "yes", "without-password", "forced-commands-only" or
             "no".  <em>The default is "no".</em>  Note that if
             <strong>ChallengeResponseAuthentication</strong> is "yes", the root user may be
             allowed in with its password even if <strong>PermitRootLogin</strong> is set to
             "without-password".
</pre>
<p><b>Fedora</b></p>
<pre>
     <strong>PermitRootLogin</strong>
             Specifies whether root can log in using ssh(1).  The argument
             must be "yes", "without-password", "forced-commands-only", or
             "no".  <em>The default is "yes".</em>
</pre>
<p><b>OpenSSH</b></p>
<p><a HREF="http://www.openssh.com/manual.html">http://www.openssh.com/manual.html</a> links to <a href="http://www.openbsd.org/cgi-bin/man.cgi?query=sshd_config">http://www.openbsd.org/cgi-bin/man.cgi?query=sshd_config</a>:</p>
<pre>
     <strong>PermitRootLogin</strong>
             Specifies whether root can log in using ssh(1).  The argument
             must be "yes", "without-password", "forced-commands-only"
             or "no".  <em>The default is "yes".</em>
</pre>
<p><b>Best Practices</b></p>
<ul>
<li><b>Always set the root password to something hard.</b>  Sure, this will make it harder for you to hop on the console, but it beats getting hacked.  If you have a valid local user and <code>sudo</code> is available, you can usually derive your console from that.</li>
<li><b>Store your root password in an extremely secure location.</b>  Your head is a great default, but this has limited, faulty memory, that is not easily shared with your other admins.  A GPG-encrypted file works well . . .</li>
<li><b>Always audit a new system before putting it on the Internet.</b>  <i>Especially if this is your first time with the OS.</i>  I was lazy because this was a non-production system, but doing an audit would have been a lot more convenient than cleaning this mess.</li>
<li><b>Verify your assumptions.</b> If you think that <code>root</code> should not be allowed to log in via SSH, then test and make sure that this is the case.  Ditto with failover procedures . . . arrange to test them before you assume that you can complete a failover at 3AM.</li>
</ul>
]]></content:encoded>
			<wfw:commentRss>http://dannyman.toldme.com/2005/11/12/permitrootlogin-p4wn3d/feed/</wfw:commentRss>
		</item>
		<item>
		<title>The little things . . .</title>
		<link>http://dannyman.toldme.com/2005/10/10/carp-goldfish-lunch/</link>
		<comments>http://dannyman.toldme.com/2005/10/10/carp-goldfish-lunch/#comments</comments>
		<pubDate>Mon, 10 Oct 2005 19:45:55 +0000</pubDate>
		<dc:creator>dannyman</dc:creator>
		
		<category><![CDATA[FreeBSD]]></category>

		<guid isPermaLink="false">http://dannyman.toldme.com/2005/10/10/carp-goldfish-lunch/</guid>
		<description><![CDATA[It is the little things . . . like goldfish!

So, that is a good checkpoint for my morning&#8217;s work.  Time to eat . . .
]]></description>
			<content:encoded><![CDATA[<p>It is the little things . . . like goldfish!</p>
<p><a href="http://www.flickr.com/photos/dannyman/51293888/" title="Photo Sharing"><img src="http://static.flickr.com/25/51293888_6f193ea852.jpg" width="500" height="132" alt="CARP is the Common Address Redundancy Protocol -- essentially, multiple machines can serve a single IP address, with transparent failover. CARP was implemented by the OpenBSD project, and is similar to Cisco's patent-encumbered VRRP." /></a></p>
<p>So, that is a good checkpoint for my morning&#8217;s work.  Time to eat . . .</p>
]]></content:encoded>
			<wfw:commentRss>http://dannyman.toldme.com/2005/10/10/carp-goldfish-lunch/feed/</wfw:commentRss>
		</item>
		<item>
		<title>Shaddup, Firefox!</title>
		<link>http://dannyman.toldme.com/2005/10/04/shaddup-firefox/</link>
		<comments>http://dannyman.toldme.com/2005/10/04/shaddup-firefox/#comments</comments>
		<pubDate>Tue, 04 Oct 2005 21:31:13 +0000</pubDate>
		<dc:creator>dannyman</dc:creator>
		
		<category><![CDATA[FreeBSD]]></category>

		<category><![CDATA[Technical]]></category>

		<guid isPermaLink="false">http://dannyman.toldme.com/2005/10/04/shaddup-firefox/</guid>
		<description><![CDATA[If you&#8217;re like me, you run Firefox on FreeBSD, or maybe Linux.  And you use a classy nice window environment like fvwm2.  And every time you start Firefox it asks can it be the default browser, and you say yes &#8230; like you use anything else?  (MSIE4-Solaris, anyone?)  And every time [...]]]></description>
			<content:encoded><![CDATA[<p>If you&#8217;re like me, you run Firefox on FreeBSD, or maybe Linux.  And you use a classy nice window environment like fvwm2.  And every time you start Firefox it asks can it be the default browser, and you say yes &#8230; like you use anything else?  (MSIE4-Solaris, anyone?)  And every time you start, it asks again . . . stupid!</p>
<p>I just saw this solution posted to FreeBSD-questions:<span id="more-1001"></span></p>
<p>1) Go to the URL: <code>about:config</code><br />
2) Search for: <code>browser.shell.checkDefaultBrowser</code><br />
3) Right-click on that monkey and toggle it to <strong>false</strong>.<br />
4) Restart your web browser a few times and smile.</p>
<p>Thanks, &#8220;nawcom&#8221; !!</p>
<p>Cheers,<br />
-danny</p>
]]></content:encoded>
			<wfw:commentRss>http://dannyman.toldme.com/2005/10/04/shaddup-firefox/feed/</wfw:commentRss>
		</item>
		<item>
		<title>Perl: Convert Celsius and Fahrenheit</title>
		<link>http://dannyman.toldme.com/2005/06/11/perl-convert-celsius-and-fahrenheit/</link>
		<comments>http://dannyman.toldme.com/2005/06/11/perl-convert-celsius-and-fahrenheit/#comments</comments>
		<pubDate>Sat, 11 Jun 2005 19:00:38 +0000</pubDate>
		<dc:creator>dannyman</dc:creator>
		
		<category><![CDATA[Excerpts]]></category>

		<category><![CDATA[FreeBSD]]></category>

		<category><![CDATA[Technical]]></category>

		<guid isPermaLink="false">http://dannyman.toldme.com/?p=933</guid>
		<description><![CDATA[I recently had a need for two quick temperature conversion algorithms in a Perl script.  I asked Google, but did not immediately get a great answer, so here&#8217;s my answer:

# Two quick helper functions: CtoF and FtoC
sub CtoF { my $c = shift; $c =~ s/[^\d\.]//g; return (9/5)*($c+32); }
sub FtoC { my $f = [...]]]></description>
			<content:encoded><![CDATA[<p>I recently had a need for two quick temperature conversion algorithms in a Perl script.  I asked Google, but did not immediately get a great answer, so here&#8217;s my answer:</p>
<p><code><br />
# Two quick helper functions: CtoF and FtoC<br />
sub CtoF { my $c = shift; $c =~ s/[^\d\.]//g; return (9/5)*($c+32); }<br />
sub FtoC { my $f = shift; $f =~ s/[^\d\.]//g; return (5/9)*($f-32); }<br />
</code></p>
<p>The regex is to untaint the input datum, and could be eliminated if you know that your variable is clean.  This code has been incorporated into a systems health and data trend monitoring script for FreeBSD.  For the vaguely interested, here&#8217;s today&#8217;s perldoc:<span id="more-933"></span></p>
<pre>check_temp($result, $command, $red, $yellow)
        Requires $results -- hashref to %results array.
        Requires $command -- unix command that prints a text representation
                             of system temperature in degree Celsius.
        Optional $red -- threshhold temperature for red alert in degrees
                         Fahrenheit.  (Default: 100)
        Optional $yellow -- threshhold temperature for yellow alert in
                            degrees Fahrenheit.  (Default: 90)

        Will populate:
                temp.C
                temp.F

        Note that input is expected in Celsius, but thresholds are
        calibrated in Fahrenheit.  This is because I am an American, and
        because I personally feel that Fahrenheit is a more inuitive
        temperature metric for humans.

        I have found that the following may work for $command:

                /sbin/sysctl -n hw.acpi.thermal.tz0.temperature
                /usr/local/bin/mbmon -T 1 -c 1

        As there is no consistent, reliable way to measure temperature, and
        because mbmon can cause your system to crash, and because different
        systems have different temperature tolerances, this check must be
        configured explicitly in lilsis.conf.</pre>
<p>As you can guess, mbmon can be had from ports.  And yes, while I love the metric system, I prefer Fahrenheit because its 0-100 metric is roughly calibrated from &#8220;colder than it gets in Denmark&#8221; to &#8220;the temperature of human blood&#8221; which is easier for my monkey brain to grasp than the freezing and boiling points of water.</p>
]]></content:encoded>
			<wfw:commentRss>http://dannyman.toldme.com/2005/06/11/perl-convert-celsius-and-fahrenheit/feed/</wfw:commentRss>
		</item>
		<item>
		<title>FAQ: How do you measure swap utilization in FreeBSD?</title>
		<link>http://dannyman.toldme.com/2005/04/05/freebsd-faq-measure-swap/</link>
		<comments>http://dannyman.toldme.com/2005/04/05/freebsd-faq-measure-swap/#comments</comments>
		<pubDate>Tue, 05 Apr 2005 16:00:17 +0000</pubDate>
		<dc:creator>dannyman</dc:creator>
		
		<category><![CDATA[FreeBSD]]></category>

		<category><![CDATA[Technical]]></category>

		<guid isPermaLink="false">http://dannyman.toldme.com/2005/04/04/faq-how-do-you-measure-swap-utilization-in-freebsd/</guid>
		<description><![CDATA[Q: How do you measure swap utilization in FreeBSD?  (Assuming you are writing a script to gather performance metrics.)
A: If you are writing a C program, check kvm_getswapinfo(3) and maybe take a gander at the bottom of /usr/src/usr.bin/top/machine.c.
A: If you are writing a Perl script:
Measure swap activity:
sysctl vm.stats.vm.v_swapin vm.stats.vm.v_swapout vm.stats.vm.v_swappgsin vm.stats.vm.v_swappgsout
(I believe these results [...]]]></description>
			<content:encoded><![CDATA[<p>Q: <strong>How do you measure swap utilization in FreeBSD?</strong>  (Assuming you are writing a script to gather performance metrics.)</p>
<p>A: <strong>If you are writing a C program,</strong> check <code>kvm_getswapinfo(3)</code> and maybe take a gander at the bottom of <code>/usr/src/usr.bin/top/machine.c</code>.</p>
<p>A: <strong>If you are writing a Perl script:</strong></p>
<p>Measure swap activity:<br />
<code>sysctl vm.stats.vm.v_swapin vm.stats.vm.v_swapout vm.stats.vm.v_swappgsin vm.stats.vm.v_swappgsout</code><br />
(I believe these results are COUNTER type values, like you get from <code>netstat -inb</code>.  You could establish &#8220;swap activity&#8221; by plotting changes in this value.)</p>
<p>Measure swap size:</p>
<pre>0-13:38 djh@mito ~&gt; swapinfo
Device          1K-blocks     Used    Avail Capacity
/dev/ad0s1b       1022224        0  1022224     0%
0-13:38 djh@mito ~&gt; swapctl -l
Device:       1024-blocks     Used:
/dev/ad0s1b     1022224         0</pre>
<p>If you are trying to accomodate n+1 swap devices, try this:</p>
<pre>0-13:44 djh@mito ~> swapctl -lsk
Device:       1024-blocks      Used:
/dev/ad0s1b      1022224          0
Total:           1022224          0</pre>
]]></content:encoded>
			<wfw:commentRss>http://dannyman.toldme.com/2005/04/05/freebsd-faq-measure-swap/feed/</wfw:commentRss>
		</item>
		<item>
		<title>HOWTO: Archive Audio Streams in to mp3 Files</title>
		<link>http://dannyman.toldme.com/2005/02/27/howto-convert-streams-mp3/</link>
		<comments>http://dannyman.toldme.com/2005/02/27/howto-convert-streams-mp3/#comments</comments>
		<pubDate>Sun, 27 Feb 2005 20:00:49 +0000</pubDate>
		<dc:creator>dannyman</dc:creator>
		
		<category><![CDATA[FreeBSD]]></category>

		<category><![CDATA[Technical]]></category>

		<guid isPermaLink="false">http://dannyman.toldme.com/2005/02/26/howto-archive-audio-streams-in-to-mp3-files/</guid>
		<description><![CDATA[I am an NPR junkie, and my new place gets awful reception.  And for a long time I have admired TiVo and wondered if my life might not be better if I had a DVR for NPR programs.  Add to that KQED&#8217;s obnoxious plugin/popup window and the fact that I use an older [...]]]></description>
			<content:encoded><![CDATA[<p>I am an NPR junkie, and my new place gets awful reception.  And for a long time I have admired TiVo and wondered if my life might not be better if I had a DVR for NPR programs.  Add to that KQED&#8217;s obnoxious plugin/popup window and the fact that I use an older version of RealAudio to avoid Spyware, which stutters and rebuffers all the time, and I have enough motivation to rig up something different.</p>
<p>I have rigged up a simple system to schedule rips of programs broadcast on the KQED audio stream in to easily manageable .mp3 files.  If I had one of them iPod thingies I could even listen to the radio programs on the bus.  I might even get around to warezing this to interested friends via BitTorrent and CSS, which would leave us another technical explanation.<span id="more-874"></span></p>
<p>Ingredients used:</p>
<ul>
<li>FreeBSD running on an old laptop, for automatic, hands-free operation.</li>
<li><strong>mplayer</strong>, to rip the Windows Media stream off KQED&#8217;s web site.</li>
<li><strong>lame</strong>, to convert the audio in to mp3.</li>
<li>Two shell scripts, <strong>cron</strong>, and <strong>at</strong>, to automate everything.</li>
</ul>
<p><strong>Where is the Audio Stream?</strong></p>
<p>Mplayer is mighty and awesome, but unfortunately, you can not just click on a web page and feed it to mplayer.  (Well, maybe you can and I am just dumb.)  So, the first task is to find something for mplayer to chew on.  In my case, this means going to http://www.kqed.org/ and clicking on the &#8220;Listen&#8221; link and selecting Windows Media and copying the URL to listen manually.  You can then fetch that URL and examine the contents, and find a URL that starts with <code>mms://</code>.  If you can play this URL in mplayer, then you are doing well.</p>
<p>I would share an example, but this part of KQED&#8217;s web site is throwing errors at the moment.</p>
<p><strong>Ripping</strong></p>
<p>I set up <a href="/warez/recorder">a simple script that launches lame and mplayer, then sits and waits for a specified time, and kills these programs off</a>.  Crude, but effective.</p>
<p><strong>Scheduling</strong></p>
<p>Ah, the potentially trickier part comes with scheduling.  I thought this over for a couple days, and figured that a slightly clever shell script should do the trick.  I wrote <a href="/warez/today">a script called &#8220;today&#8221;</a> which defines a few functions, such as <code>everday()</code> and <code>weekday()</code> and runs through what the schedule should be, depending on the day of the week.  It then schedules rips of the appropriate programs via at at command.  You could also do a comparison with the date command to schedule special one-off recordings.</p>
<p>Anyway, the today script is run out of cron at midnight:</p>
<pre>0-21:33 djh@yomama ~> crontab -l
0 0 * * * $HOME/bin/today</pre>
<p>One other trick, on FreeBSD you have to give yourself permission to use at:</p>
<pre>0-21:35 djh@yomama ~> cat /var/at/at.allow
djh</pre>
<p><strong>Making it Better</strong></p>
<p>Do check out the comments that follow for tips and tricks, especially <a href="http://dannyman.toldme.com/2005/02/27/howto-convert-streams-mp3/#comment-13955">Shawn Dowler</a> who has gone and wrote <a href="http://walkingtowel.org/2006/03/03/record-streaming-audio-with-linux-part-ii/">a page about his revised versions of the scripts.</a></p>
]]></content:encoded>
			<wfw:commentRss>http://dannyman.toldme.com/2005/02/27/howto-convert-streams-mp3/feed/</wfw:commentRss>
		</item>
		<item>
		<title>FAQ: Stream KQED on FreeBSD</title>
		<link>http://dannyman.toldme.com/2005/02/22/faq-stream-kqed-freebsd/</link>
		<comments>http://dannyman.toldme.com/2005/02/22/faq-stream-kqed-freebsd/#comments</comments>
		<pubDate>Tue, 22 Feb 2005 19:17:48 +0000</pubDate>
		<dc:creator>dannyman</dc:creator>
		
		<category><![CDATA[FreeBSD]]></category>

		<category><![CDATA[Technical]]></category>

		<guid isPermaLink="false">http://dannyman.toldme.com/2005/02/22/faq-stream-kqed-freebsd/</guid>
		<description><![CDATA[If you want to listen to KQED using FreeBSD, install mplayer:
mplayer mms://wmbcast.kqed.speedera.net/wmbcast.kqed/wmbcast_kqed_jan032006_0957_103495
UPDATE: I just discovered the -playlist feature.  So, this works even better:
mplayer -playlist http://www.kqed.org/w/streamingfiles/kqed_wmp.asx
I have also figured out how to convert the Windows Media Player stream in to mp3 files, and may set up a system to &#8220;record&#8221; programs on a regular schedule, [...]]]></description>
			<content:encoded><![CDATA[<p>If you want to listen to <a href="http://www.kqed.org/">KQED</a> using <a href="http://www.freebsd.org/">FreeBSD</a>, install <a href="http://www.mplayerhq.hu/">mplayer</a>:</p>
<p><code>mplayer mms://wmbcast.kqed.speedera.net/wmbcast.kqed/wmbcast_kqed_jan032006_0957_103495</code></p>
<p><strong>UPDATE:</strong> I just discovered the -playlist feature.  So, this works even better:</p>
<p><code>mplayer -playlist http://www.kqed.org/w/streamingfiles/kqed_wmp.asx</code></p>
<p>I have also figured out how to convert the Windows Media Player stream in to mp3 files, and may set up a system to &#8220;record&#8221; programs on a regular schedule, at which point I can listen to public radio as I would watch TV on a DVR. (Radio TiVo!)</p>
<p>If anyone might be interested in getting in on a non-RealAudio <a href="http://www.npr.org/archives/">&#8220;NPR audio archive&#8221;</a> via a <a href="http://bittorrent.com/">bittorrent</a> setup, I&#8217;d love to hear from you.</p>
]]></content:encoded>
			<wfw:commentRss>http://dannyman.toldme.com/2005/02/22/faq-stream-kqed-freebsd/feed/</wfw:commentRss>
<enclosure url="http://www.kqed.org/w/streamingfiles/kqed_wmp.asx" length="664" type="video/x-ms-asf" />
		</item>
		<item>
		<title>Skype</title>
		<link>http://dannyman.toldme.com/2005/02/16/skype/</link>
		<comments>http://dannyman.toldme.com/2005/02/16/skype/#comments</comments>
		<pubDate>Thu, 17 Feb 2005 04:01:28 +0000</pubDate>
		<dc:creator>dannyman</dc:creator>
		
		<category><![CDATA[FreeBSD]]></category>

		<category><![CDATA[Technology]]></category>

		<category><![CDATA[Testimonials]]></category>

		<guid isPermaLink="false">http://dannyman.toldme.com/2005/02/16/skype/</guid>
		<description><![CDATA[Skype is an Instant Messenger client with a twist &#8212; if you hook up a microphone you can CALL each other.  Like a telephone, only you can see if your buddy is online before you interrupt them.  The audio quality is very good, and clients are available for Windows, OS X, and Linux. [...]]]></description>
			<content:encoded><![CDATA[<p><a href="http://www.skype.com/">Skype</a> is an Instant Messenger client with a twist &#8212; if you hook up a microphone you can CALL each other.  Like a telephone, only you can see if your buddy is online before you interrupt them.  The audio quality is very good, and clients are available for Windows, OS X, and Linux.  The Linux client works on FreeBSD.</p>
<p>Even nicer, you can dial out on Skype, for exceedingly low rates.  It costs us about 3c a minute to call Japan, though we&#8217;re going to get Noriko-san on Skype soon enough, and then the calls will be free.</p>
<p>If anyone wants to try it out, you can ring me at <strong>dannymanTM</strong>.</p>
<p>To answer a question you may have on your mind, <strong>Skype is not a telephone,</strong> so it is different from a VOIP service, where they send you a telephone that you hook up to your broadband.  Instead, Skype is a way of making telephone calls from your computer.  Unfortunately, people can not yet dial in to someone using Skype.</p>
<p>For me, though, it is as if the Internet has come full-circle: we used to have to find a cheap local number to dial in to the Internet on our existing telephone.  Now, we are finding cheap services to make telephone calls on our existing Internet connection.  Yow!</p>
]]></content:encoded>
			<wfw:commentRss>http://dannyman.toldme.com/2005/02/16/skype/feed/</wfw:commentRss>
		</item>
	</channel>
</rss>
