<?xml version="1.0" encoding="utf-8"?>
<?xml-stylesheet type="text/css" href="http://insyte.squad51.net/"?>
<rss version="2.0" xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:admin="http://webns.net/mvcb/" xmlns:atom="http://www.w3.org/2005/Atom">
<channel>
<title>Insyteful</title>
<atom:link href="http://insyte.squad51.net/rss.xml" rel="self" type="application/rss+xml" />
<link>http://insyte.squad51.net</link>
<description>random ramblings</description>
<dc:language>en-us</dc:language>
<dc:creator>Insyte</dc:creator>
<dc:date>2010-06-17T01:01:02-05:00</dc:date>
<admin:generatorAgent rdf:resource="http://nanoblogger.sourceforge.net" />
<item>
<link>http://insyte.squad51.net/archives/2009/12/index.html#e2009-12-07T11_55_19.txt</link>
<guid isPermaLink="true">http://insyte.squad51.net/archives/2009/12/index.html#e2009-12-07T11_55_19.txt</guid>
<title>Managing SSH keys on the N900</title>
<dc:date>2009-12-07T11:55:19-05:00</dc:date>
<dc:creator>Insyte</dc:creator>
<dc:subject>n900</dc:subject>
<description>
<![CDATA[<p>The <a href="http://maemo.nokia.com/n900/">Nokia N900</a> is a great device for *nix
sytems admins.  It features, among other things, a native port of both
xterm and OpenSSH.  Being a good sysadmin, the first thing I did was
generate a new (encrypted) SSH key.  The next was discover that
<code>ssh-agent</code> was not managed by the OS so that all processes have access to
the <code>$SSH_AUTH_SOCK</code> variable.  As I was not feeling quite adventurous
enough to hack up the somewhat non-standard boot process / X startup, I
needed to find a different way.</p>

<p>With a little trial and error I was able to come up with a brief snippet
of code to include in <code>~user/.profile</code> to ensure that I always have access
to <code>ssh-agent</code> and can share that agent between numerous xterm sessions.</p>

<p>This is what I did:</p>

<pre><code># cat ~user/.profile

unset SSH_AUTH_SOCK
unset SSH_AGENT_PID

if [[ -f ~/.ssh-agent ]]
then
        source ~/.ssh-agent &gt;&gt; /dev/null
fi

ssh-add -l 2&gt;&amp;1 &gt; /dev/null
r=$?
if [[ $r == 2 ]]
then
        echo No agent.
        pkill ssh-agent
        ssh-agent -t 5400 &gt; ~/.ssh-agent
        source ~/.ssh-agent &gt; /dev/null
fi
</code></pre>

<p>What does it do?</p>

<p>First I check to see if <code>~/.ssh-agent</code> exists.  If it does, it should
contain the details for the last <code>ssh-agent</code> instance launched.  By
sourcing that file, the appropriate environment variables are set allowing
<code>ssh</code> and <code>ssh-add</code> to find the (possibly) running agent.</p>

<p>Next, I attempt to execute <code>ssh-add -l</code>, which if an agent is running and
has a key loaded, would list the loaded keys.  If <code>ssh-add -l</code> exited with
2, that means either there isn't an <code>ssh-agent</code> running or that we can't
find it.  In either case, next I attempt to kill off any running instances
of <code>ssh-agent</code> and launch a new one, caching the details in
<code>~/.ssh-agent</code>.</p>

<p>Note the <code>-t 5400</code> option on ssh-agent.  That dumps any loaded keys after
90 minutes.  I don't want to leave unencrypted ssh keys lying around in
such an easily stolen package...</p>]]>
</description>
</item>
<item>
<link>http://insyte.squad51.net/archives/2009/09/index.html#e2009-09-03T18_27_23.txt</link>
<guid isPermaLink="true">http://insyte.squad51.net/archives/2009/09/index.html#e2009-09-03T18_27_23.txt</guid>
<title>Building libreadline on Snow Leopard (10.6)</title>
<dc:date>2009-09-03T18:27:23-05:00</dc:date>
<dc:creator>Insyte</dc:creator>
<description>
<![CDATA[<p>More fun and games building stuff on OS X.</p>

<p>I like Snow Leopard.  Really, I do.  However there is pain involved in
getting <a href="http://ipython.scipy.org/moin/">ipython</a> to work properly.  After
the upgrade (on a fresh install of Leopard) I used the system python to
install ipython:</p>

<pre><code># easy_install ipython
</code></pre>

<p>Initially everything looked good.  Aside from the rather ominous "Leopard
libedit detected." message on startup.  Unfortunately once I started using
it, problems quickly became apparent:</p>

<ul>
<li>Cursor not returning to the correct location on the line when using
up/down arrow to browse history.</li>
<li>No ctrl-r to search through history.</li>
<li>Other random weirdness.</li>
</ul>

<p>Fortunately Patrick van Kouteren wrote an excellent
<a href="http://www.vankouteren.eu/blog/2009/06/getting-ipython-readline-and-auto-completion-to-work-on-mac-os-x/">article</a>
that got me headed in the right direction.  Unfortunately, building the
ipython-packaged readline failed miserably during the initial configure
process.  As always, <code>config.log</code> tells the tale:</p>

<pre><code>configure:1883: gcc -isysroot /Developer/SDKs/MacOSX10.5.sdk 
  -arch i386 -arch ppc -arch x86_64 -arch ppc64 -DNEED_EXTERN_PC
  -isysroot /Developer/SDKs/MacOSX10.5.sdk -arch i386 -arch ppc
  -arch x86_64 -arch ppc64 conftest.c  &gt;&amp;5
ld: library not found for -lcrt1.10.6.o
collect2: ld returned 1 exit status
ld: library not found for -lcrt1.10.6.o
collect2: ld returned 1 exit status
</code></pre>

<p>Fortunately for my sanity, it looks like distutils no longer tries to
force <a href="http://insyte.squad51.net/archives/2006/12/07/index.html#e2006-12-07T17_28_59.txt">building of Universal binaries on the
Mac</a>
but still this looked awfully similar.</p>

<p>Solution:</p>

<ol>
<li><p>Edit <code>setup.py</code> and comment out these lines:</p>

<pre><code>if distutils.util.get_platform().find('macosx-10.5') == 0:
    UNIVERSAL = '-isysroot /Developer/SDKs/MacOSX10.5.sdk ' + \
                '-arch i386 -arch ppc -arch x86_64 -arch ppc64'
</code></pre></li>
<li><p>Edit <code>rl/build.sh</code> and comment out these lines:</p>

<pre><code>export CFLAGS='-isysroot /Developer/SDKs/MacOSX10.5.sdk 
  -arch i386 -arch ppc -arch x86_64 -arch ppc64'
export LDFLAGS='-isysroot /Developer/SDKs/MacOSX10.5.sdk
  -arch i386 -arch ppc -arch x86_64 -arch ppc64'
</code></pre></li>
</ol>]]>
</description>
</item>
<item>
<link>http://insyte.squad51.net/archives/2008/09/index.html#e2008-09-08T23_46_32.txt</link>
<guid isPermaLink="true">http://insyte.squad51.net/archives/2008/09/index.html#e2008-09-08T23_46_32.txt</guid>
<title>Failure rate of large SATA drives</title>
<dc:date>2008-09-08T23:46:32-05:00</dc:date>
<dc:creator>Insyte</dc:creator>
<dc:subject>Unix Stuff</dc:subject>
<description>
<![CDATA[<p>I came across two fascinating articles today about why SATA RAID can be
scary and dangerous:</p>

<ul>
<li><a href="http://alumnit.ca/~apenwarr/log/?m=200809#08">SATA vs. SCSI reliability</a></li>
<li><a href="http://permabit.wordpress.com/2008/08/20/are-fibre-channel-and-scsi-drives-more-reliable/">Are Fibre Channel and SCSI Drives More
Reliable?</a></li>
</ul>

<p>Basically, drive size has increased dramatically.  The "bit error rate"[1]
has remained essentially constant.  As you approach something around 12TB,
it's virtually certain that you have unreadable blocks on your array.</p>

<p>Who cares if a couple of bytes in the middle of some old archived log
files are munged?  I sure as hell don't.  Unfortunately, most failed
blocks are only discovered during the one process that requires reading
and checksumming every block of data on the array:  Rebuilding the array
after a drive failure.  What happens then?  Depends on the RAID
controller.  Apparently it's pretty common for it to give up and leave you
with no useable data at all.</p>

<p>It wasn't until I read this article that I understood why the über-smart
folks at <a href="http://www.coraid.com">Coraid</a> implemented a technology called
RAIDShield that basically continuously reads every sector of every disk in
the background.  If a bad block is found, the correct data is calculated
from the parity data and written out to the "bad" sector.  This triggers
the drives internal sector remapping, guaranteeing that the data is
written to a good portion of the disk and flagging the sector as unusable.</p>

<p>I really like knowing our vendors have solved problems we didn't even know
we had.  Makes me feel all warm and fuzzy.</p>

<p>[1] The ratio of the number of unreadable blocks to the total number of
    blocks on the drive/array.</p>]]>
</description>
</item>
<item>
<link>http://insyte.squad51.net/archives/2007/01/index.html#e2007-01-31T14_14_04.txt</link>
<guid isPermaLink="true">http://insyte.squad51.net/archives/2007/01/index.html#e2007-01-31T14_14_04.txt</guid>
<title>Installing sqsh on OS X 10.4</title>
<dc:date>2007-01-31T14:14:04-05:00</dc:date>
<dc:creator>Insyte</dc:creator>
<description>
<![CDATA[<p>If forced to use an MS-SQL database, I find it much easier and more
convenient to use the excellent <a href="http://www.sqsh.org">sqsh</a> shell.  On our Ubuntu boxes,
installing it was as simple as <code>apt-get install sqsh</code>.  Unfortunately,
DarwinPorts doesn't include it.  Building from source was somewhat
problematic due to OS X's none-GNU-readline readline.h (it's actually part
of the BSD editline library).</p>

<p>Here's what I needed to do:</p>

<ol>
<li><p>Install FreeTDS:</p>

<pre><code>port install freetds
</code></pre></li>
<li><p><a href="http://sourceforge.net/project/showfiles.php?group_id=106336">Download</a> and untar sqsh.</p></li>
<li><p>Configure as you would normally, setting $SYBASE to point to the top of
the FreeTDS install:</p>

<pre><code>SYBASE=/opt/local ./configure --with-readline
</code></pre></li>
<li><p>Edit <code>src/Makefile</code> and append <code>freetds</code> to line #18 so it looks like
this:</p>

<pre><code>SYBASE_INCDIR = -I$(SYBASE_OCOS)/include/freetds
</code></pre></li>
<li><p>Modify the header/library paths for libreadline to point to the version
from DarwinPorts:</p>

<pre><code>READLINE_LIBDIR =  -L/opt/local/lib
READLINE_INCDIR =  -I/opt/local/include/
</code></pre></li>
<li><p><code>make</code> and <code>make install</code></p></li>
</ol>]]>
</description>
</item>
<item>
<link>http://insyte.squad51.net/archives/2006/12/index.html#e2006-12-07T17_28_59.txt</link>
<guid isPermaLink="true">http://insyte.squad51.net/archives/2006/12/index.html#e2006-12-07T17_28_59.txt</guid>
<title>Distutils on PPC OS X</title>
<dc:date>2006-12-07T17:28:59-05:00</dc:date>
<dc:creator>Insyte</dc:creator>
<dc:subject>Python, Unix Stuff</dc:subject>
<description>
<![CDATA[<p>I've moved away from using the Python from MacPorts (DarwinPorts) and am,
instead, using the Official Mac Python build from python.org.  Overall, it
seems to have been a good move.  However, the first time I tried to build
a C module using distutils, <code>ld</code> popped up this error when trying to link
against <code>libcrypto.dylib</code>:</p>

<p><code>cputype (18, architecture ppc) does not match cputype (7) for specified
-arch flag: i386 (file not loaded)</code></p>

<p>Scrolling back to look at the actual <code>gcc</code> command line revealed a clue.
Present among the flags were: <code>-arch i386 -arch ppc</code>.  </p>

<p>Another clue:</p>

<p><code>tarja:~ ben$ file /opt/local/lib/libcrypto.0.9.8.dylib
/opt/local/lib/libcrypto.0.9.8.dylib: Mach-O dynamically linked shared
library ppc</code></p>

<p>So Python's distutils was determined to build universal binaries, but the
OpenSSL install created by MacPorts was PPC only.  That's not going to
work.</p>

<p>A grep through the source for distutils didn't reveal any instances of
"-arch i386", so I resorted to Google.  <a href="http://www.mail-archive.com/distutils-sig@python.org/msg02491.html">This post</a> provided
the necessary clue.  After editing
<code>/Library/Frameworks/Python.framework/Versions/2.5/lib/python2.5/config/Makefile</code>
and removing all references to <code>-arch i386</code>, the linking succeeded.</p>

<p>Almost.</p>

<p>Then I started seeing errors similar to this one: <code>/usr/bin/ld: warning
can't open dynamic library:
/Developer/SDKs/MacOSX10.4u.sdk/opt/local/lib/lib3rdparty.dylib referenced
from: libMyLibrary.dylib (checking for undefined symbols may be affected)
(No such file or directory, errno = 2)</code></p>

<p>Note that in this example, <code>lib3rdparty.dylib</code> actually does exist in
<code>/opt/local/lib</code>.  As I eventually learned from <a href="http://lists.apple.com/archives/darwin-dev/2006/Apr/msg00041.html">this thread</a>,
using the <code>-isysroot</code> option prepends the SDK directory to all paths.  As
you'll note from the above-linked thread, whether or not this is a bug
depends on who you ask.  The kludgy workaround:  </p>

<p>Make a symlink under <code>/Developer/SDKs/MacOSX10.4u.sdk/</code> to
<code>/opt/local/lib</code>.</p>

<p>Ugly.</p>

<p>But it works.</p>

<p>Thanks, Apple.</p>]]>
</description>
</item>
<item>
<link>http://insyte.squad51.net/archives/2006/01/index.html#e2006-01-20T13_38_51.txt</link>
<guid isPermaLink="true">http://insyte.squad51.net/archives/2006/01/index.html#e2006-01-20T13_38_51.txt</guid>
<title>I Heart Max Barry</title>
<dc:date>2006-01-20T13:38:51-05:00</dc:date>
<dc:creator>Insyte</dc:creator>
<dc:subject>Books</dc:subject>
<description>
<![CDATA[<p>I've been a fan of <a href="http://www.maxbarry.com">Max Barry</a> since I read <a href="http://www.maxbarry.com/jennifergovernment/">Jennifer Government</a> a
few years back, although I think I liked <a href="http://www.maxbarry.com/syrup/">Syrup</a> better.  So when I
read that <a href="http://www.maxbarry.com/company/">Company</a> was coming out soon, I pre-ordered it from Amazon.</p>

<p>Capsule review:</p>

<p>Fascinating and highly entertaining corporate satire featuring rambling,
multiple-forwarded voicemail, a sociopathic but brilliant receptionist,
meaningless mission statements, and a donut.</p>

<p>Read this.  Then read <cite>Syrup</cite> and <cite>Jennifer
Government</cite>.</p>

<p>Extract from the first chapter of <cite>Company</cite>:  <a href="http://www.maxbarry.com/company/preview.html">READ</a></p>]]>
</description>
</item>
<item>
<link>http://insyte.squad51.net/archives/2006/01/index.html#e2006-01-18T14_45_44.txt</link>
<guid isPermaLink="true">http://insyte.squad51.net/archives/2006/01/index.html#e2006-01-18T14_45_44.txt</guid>
<title>Lot's o' Bytes!</title>
<dc:date>2006-01-18T14:45:44-05:00</dc:date>
<dc:creator>Insyte</dc:creator>
<dc:subject>Unix Stuff</dc:subject>
<description>
<![CDATA[<p>I've been doing some work on the
<a href="http://www.netequalizer.com">NetEqualizer</a> and needed to find a
quick-n-dirty way to generate a ton of network traffic between two linux
devices.  <a href="http://netcat.sourceforge.net">Netcat</a> to the rescue!</p>

<p>On the client side:</p>

<pre><code>yes BBBBBBBBBBBBBBBBBBBBBB | nc 10.0.8.2 2223 &gt; /dev/null
</code></pre>

<p>And on the server:</p>

<pre><code>yes AAAAAAAAAAAAAAAAAAAAAA | nc -v -v -l -p 2223 &gt; /dev/null
</code></pre>

<p>Is there anything netcat can't do?</p>]]>
</description>
</item>
<item>
<link>http://insyte.squad51.net/archives/2005/12/index.html#e2005-12-24T03_38_02.txt</link>
<guid isPermaLink="true">http://insyte.squad51.net/archives/2005/12/index.html#e2005-12-24T03_38_02.txt</guid>
<title>Chef's knives</title>
<dc:date>2005-12-24T03:38:02-05:00</dc:date>
<dc:creator>Insyte</dc:creator>
<dc:subject>Food</dc:subject>
<description>
<![CDATA[<p>I've discovered that I am now collecting chef's knives.</p>

<p>When I bought my first <a href="http://www.amazon.com/gp/product/B00005OL44">good knife</a>, it was easily defensible: every
cook needs a high-quality chef's knife.  When my wife bought me a gorgeous
<a href="http://www.kershawknives.com/productdetails.php?id=249&amp;brand=shun">santoku</a>, I would tell people that I prefered it for working with
vegetables.  Then I bought the new <a href="http://www.kershawknives.com/productdetails.php?id=4&amp;brand=shun">Ken Onion</a> blade.  I can't defend
three knives.</p>

<p>So I've accepted that I am a collector.  Which means that I can now
justify buying any other cool knives that catch my eye!</p>]]>
</description>
</item>
<item>
<link>http://insyte.squad51.net/archives/2005/12/index.html#e2005-12-22T14_04_46.txt</link>
<guid isPermaLink="true">http://insyte.squad51.net/archives/2005/12/index.html#e2005-12-22T14_04_46.txt</guid>
<title>OpenLDAP v. OS X Clients</title>
<dc:date>2005-12-22T14:04:46-05:00</dc:date>
<dc:creator>Insyte</dc:creator>
<dc:subject>Unix Stuff</dc:subject>
<description>
<![CDATA[<p>A few months back we moved our entire campus to using network
authentication with OpenLDAP for the backend.  The first step was to use it
as the backend for the mail server.  That worked fine.  Then we turned it
loose on the computer labs.  This initially <em>appeared</em> to work fine, but
occasionally a computer would take several minutes to successfully log in.
Once logged in, computers would randomly exhibit extremely slow AFP access.
This is the story of troubleshooting that problem.</p>

<p>The initial computer used for network authentication was, in retrospect,
underpowered.  In an attempt to compensate for the perceived configuration
problems, I made a number of tweaks, including some timeout settings.</p>

<p>Over the weekend, I built a new server to be the directory server, hoping
it would do better.  It appeared to handle the queries without any
noticeable load or slowdown, but was still dropping a large number of
authentication attempts.  Matt and I began an analysis of the actual
network traffic, looking at the individual network packets.  We noticed an
anomaly in the way LDAP sessions were being closed down after a period of
inactivity.  The LDAP server was sending a "FIN,ACK" packet, the normal
way to request the shutdown of a TCP session.  The client responded,
appropriately, with an "ACK" packet.</p>

<p>This effectively closed the connection from the server to the client, but
not the connection in the other direction.  The way the client <em>should</em>
proceed from here is to respond with its own "FIN,ACK" packet, to which
the server would've responded "ACK" and the session would be cleanly shut
down.</p>

<p>Normal shutdown of a session:</p>

<pre><code> server                client

   (normal data exchange)
  &lt;------- SEARCH ----------
  -------- RESULT ---------&gt;
    (starting shutdown)
  ---------FIN ACK---------&gt;
  &lt;----------ACK------------
     (halfway closed)
  &lt;--------FIN ACK----------
  -----------ACK-----------&gt;
    (completely closed)
</code></pre>

<p>Instead, the client would, frequently, attempt to send a new search
request through the half-closed connection.  The server, righteously and
appropriately indignant, responded with a "RST" (or "reset") packet,
signalling that it was done and wasn't interested in hearing any more.
The client, rebuffed and confused, would deem the server unreachable and
go into a funk for 30 seconds or so (depending on its config).</p>

<p>Broken shutdown of a session:</p>

<pre><code>server                client

    [normal data exchange]
  &lt;------- SEARCH ----------
  -------- RESULT ---------&gt;
  [server starting shutdown]
  ---------FIN ACK---------&gt;
  &lt;----------ACK------------
      [halfway closed]
  &lt;------- SEARCH ----------
  ---------- RST ----------&gt;
     [client panics and
      stops talking]
</code></pre>

<p>Once we understood the problem, the solution was clear:  Make sure the
client always attempted to shut down idle sessions first, so its buggy
half-closed SEARCH requests would not have opportunity to occur.  So we
upped the idle timeout on the LDAP server high enough to guarantee it
would only come into play if the client machine was completely hung
already.  As soon as we made this change, all the logins became speedy,
sessions stopped hanging, and all was right with the world.</p>

<p>I have now eliminated the original (slow) LDAP server completely, shifting
all the load to the new ultra-beefy server.  The next step is to upgrade
the old server to a bit more modern standards and rebuild it to serve as
a backup.</p>]]>
</description>
</item>
</channel>
</rss>

