<?xml version="1.0" encoding="utf-8"?>
<!-- generator="wordpress/2.2" -->
<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/"
	>

<channel>
	<title>darkness</title>
	<link>http://darkness.codefu.org/wordpress</link>
	<description>Technical adventures and blabbering</description>
	<pubDate>Thu, 27 Dec 2007 02:05:16 +0000</pubDate>
	<generator>http://wordpress.org/?v=2.2</generator>
	<language>en</language>
			<item>
		<title>The component system of my dreams</title>
		<link>http://darkness.codefu.org/wordpress/2007/12/26/295</link>
		<comments>http://darkness.codefu.org/wordpress/2007/12/26/295#comments</comments>
		<pubDate>Thu, 27 Dec 2007 02:05:16 +0000</pubDate>
		<dc:creator>darkness</dc:creator>
		
		<category><![CDATA[General]]></category>

		<guid isPermaLink="false">http://darkness.codefu.org/wordpress/2007/12/26/295</guid>
		<description><![CDATA[I&#8217;ve been working in Plone, so I&#8217;ve seen
zope.component.  I&#8217;m
also thinking of making a (potentially) networked game in Python, and
for that I was looking at things like
Twisted and
Kamaelia.  Unsurprisingly, I&#8217;m not really
satisfied with any of these.

Let me try to articulate what I&#8217;m looking for when I say &#8220;component
system&#8221; (perhaps something more nebulous than &#8220;content [...]]]></description>
			<content:encoded><![CDATA[<p>I&#8217;ve been working in Plone, so I&#8217;ve seen
<a href="http://pypi.python.org/pypi/zope.component" ><code>zope.component</code></a>.  I&#8217;m
also thinking of making a (potentially) networked game in Python, and
for that I was looking at things like
<a href="http://www.twistedmatrix.com" >Twisted</a> and
<a href="http://kamaelia.sf.net/" >Kamaelia</a>.  Unsurprisingly, I&#8217;m not really
satisfied with any of these.</p>

<p>Let me try to articulate what I&#8217;m looking for when I say &#8220;component
system&#8221; (perhaps something more nebulous than &#8220;content management
system&#8221;).</p>

<ul>
<li><p>Obviously I want to divide my game into components that implement
defined interfaces.  For example, there&#8217;s a component that handles
the network communication with players, another that handles
streaming the game events to &#8220;observers&#8221; (people that watch but do
not participate), a component to handle physics, a component to
perform (for example) validation on incoming player commands, etc.</p></li>
<li>
<p>I want to define dependencies between components.  These
dependencies are then used to acquire a suitable implementation of
the component&#8217;s interface.</p>

<p>For example, when I start the game maybe I &#8220;start&#8221; the front end
component that handles communications with player; lets call that
the &#8220;player server.&#8221;  Now, the player server generates events such
as &#8220;player connected,&#8221; &#8220;player moved,&#8221; etc.  Somewhere (in code, or
maybe even in something like ZCML) I&#8217;ve defined that this
implementation of the component needs a component implementing
<code>IPlayerEventConsumer</code>.  The component system then finds (using my
configuration) an implementation for that interface and makes it
available to the player server.</p>
</li>
<li><p>Assuming my components are written correctly, I want to be able to
have a component execute in the same thread as other components
(e.g. in the &#8220;main thread&#8221; as a microthread/coroutine), or in a new
thread, or in a new process.  For example, if I have lots of
CPU-intensive physics code, maybe I want to run that on another
processor, so I need threads.  Of course, maybe I&#8217;m running on
CPython, where I might need separate processes to bypass the GIL
(ignoring for the moment the question of efficient IPC).  Or maybe
I&#8217;m working with something like a GUI where I need to have that run
in a separate process (of course, doing a GUI can cause even bigger
headaches).</p></li>
<li>
<p>I want the ability to implement components in other languages (see
also: component executes in separate process, above).  This means I
want a standard protocol for communication between components.
XML-RPC comes to mind.  Something else easy enough to implement
comes to mind.  There&#8217;s things like pickling in Python, but I don&#8217;t
know how much fun that would really be to implement in a non-Python
language; maybe something more language-agnostic?</p>

<p>For fun, I&#8217;ll add here that I might like to be able to communicate
with components using a variety of methods: pipes, Unix sockets,
TCP/IP, and so on.  This is desirable.</p>
</li>
</ul><p>Now, I think I&#8217;ve just described a billion other attempts at
&#8220;component systems&#8221;: COM/DCOM, maybe EJB, CORBA, maybe KDE&#8217;s DCOP.
Let me add a couple more requirements that should narrow the field a
bit:</p>

<ul>
<li><p>The &#8220;component system&#8221; must be platform-independent&#8211;or at least
support including Linux, *BSD, OS X, and Win32 (actually, I could
give up Win32 if I had to).</p></li>
<li><p>I want the component system to be mostly transparent to me, the
coder.  I expect to have to configure the bindings between
interfaces and implementations, specify dependencies, configure the
manner in which a component will execute
(microthread/thread/process; subject to the &#8220;execution style&#8221; the
component is prepared to run in), and configuring the location
(e.g. host/port) of other components in the system.  I don&#8217;t want to
have to manually write up a proxy class for a remote component, for
example.  As much as is humanly possible, I don&#8217;t want my code to
care whether a component is running in shared memory or on a box
1,000 miles away.</p></li>
</ul><p>COM/DCOM is basically going to be Windows, right?  DCOP might not be,
what with KDE 4 supposedly running on Windows (right?).  EJB has
notorious boilerplate (though it has been a while for me), when I
think CORBA I think IDL, etc.  Those aren&#8217;t &#8220;mostly transparent.&#8221;</p>

<p>Kamaelia looks interesting.  The system of &#8220;wiring&#8221; components
together <em>feels</em> right to me; I was first exposed to this in
<a href="http://nescc.sourceforge.net/" >NesC</a>.  However, the implementation
needs to be updated to support the new features of generators in
Python 2.5, as the current syntax strikes me as rather ugly.  In fact,
it looks like Kamaelia needs a recent release, period: the last one I
saw was from 2006.</p>

<p>(As a side note: everything should be <code>easy_install</code>able.  Kamaelia
and Twisted are not, though Twisted has ongoing work to this end.)</p>

<p>Kamaelia also fails to offer multi-process operation, as far as I can
tell (you could write it yourself without <em>too</em> much pain), and it
needs a way to generalize its &#8220;wires&#8221; to support communication with,
e.g., remote components.  You could actually combine the marshalling
component with the framing component and a TCP client/server
components and make this work; but that might have shot straight past
&#8220;configuration&#8221; into &#8220;programming.&#8221;</p>

<p>Twisted is a much, much, <em>much</em> larger framework than I ever
realized, and a lot of it seems pretty good.  Nonetheless, the
centerpiece of Twisted (if you believe the docs) still seems to be
their &#8220;reactors&#8221; which require you to handle concurrency by defining
things like <code>Protocol</code> subclasses that receive event messages
(i.e. method calls) like <code>connectionMade</code> and <code>dataReceived</code>.  This
programming model might feel a little strange.  They&#8217;ve got this neat
looking <a href="http://twistedmatrix.com/documents/current/api/twisted.internet.defer.html#inlineCallbacks" ><code>inlineCallbacks</code>
decorator</a>,
which looks like it might lend itself to a coroutine kind of style.
Then you start to realize that you&#8217;re not sure what you can use it
for.  I actually started writing something like:</p>

<pre><code>class HelloWorldProtocol (LineReceiver):
def connectionMade(self):
    self.transport.write("Hi, who are you?\n")
    # Now I'll read their name:
    line = yield self.readLin  # ... hey, uh, there isn't a read method
</code></pre>

<p>I&#8217;ve seen several IRC logs where people try to figure out similar
things.  For what I&#8217;m doing, <code>inlineCallbacks</code> doesn&#8217;t seem like
something I&#8217;m going to be able to use much.</p>

<p>I&#8217;ve considered building something like Kamaelia&#8217;s style of wiring up
components inside Twisted.  Twisted has some kind of support for
things like processes and threads.  I haven&#8217;t determined if these
really meet my needs, and I keep reading scary things about them being
deprecated.</p>

<p>If you believe <a href="http://twistedmatrix.com/projects/core/documentation/howto/tutorial/index.html" >Twisted&#8217;s finger
tutorial</a>
they&#8217;ve also drank the &#8220;Zope Component Architecture&#8221; Kool-Aid, though
thankfully I didn&#8217;t see any ZCML (yet&#8230;).  Look at <a href="http://twistedmatrix.com/projects/core/documentation/howto/tutorial/configuration.html" >the final product
of that
tutorial</a>
and notice all the interfaces and &#8220;adapters&#8221; flying around.  I don&#8217;t
really feel like I gain enough for that extra code.</p>

<p>The question I ignored earlier, the one of performance, is still
outstanding in my mind: can this kind of system be done [in Python]
efficiently?  I&#8217;m afraid I&#8217;m dreaming of a &#8220;component system&#8221; that&#8217;s
going to be so slow as to be unpractical.</p>

<p>And, finally: do I really need these features?</p>
]]></content:encoded>
			<wfw:commentRss>http://darkness.codefu.org/wordpress/2007/12/26/295/feed</wfw:commentRss>
		</item>
		<item>
		<title>Linux audio strikes back</title>
		<link>http://darkness.codefu.org/wordpress/2007/12/25/293</link>
		<comments>http://darkness.codefu.org/wordpress/2007/12/25/293#comments</comments>
		<pubDate>Tue, 25 Dec 2007 21:23:10 +0000</pubDate>
		<dc:creator>darkness</dc:creator>
		
		<category><![CDATA[General]]></category>

		<guid isPermaLink="false">http://darkness.codefu.org/wordpress/2007/12/25/293</guid>
		<description><![CDATA[Fedora 7&#8217;s new Firewire stuff might not be totally together: when I
plugged in my DV cam, I couldn&#8217;t read the device except (I guess?) as
root.  (Kino also kept crashing, and I ended up just using dvgrab.)

Apparent side-effect of running sudo kino: some shared memory used
by dmix became owned by root and mod 0600.  [...]]]></description>
			<content:encoded><![CDATA[<p>Fedora 7&#8217;s new Firewire stuff might not be totally together: when I
plugged in my DV cam, I couldn&#8217;t read the device except (I guess?) as
root.  (Kino also kept crashing, and I ended up just using dvgrab.)</p>

<p>Apparent side-effect of running <code>sudo kino</code>: some shared memory used
by <code>dmix</code> became owned by <code>root</code> and mod <code>0600</code>.  Thus when you run
something like, say, <code>aplay</code> (ALSA configured to use dmix by default),
you get &#8220;unable to create IPC semaphore&#8221; (among some other lines).</p>

<p>My fix:</p>

<ol>
<li>
<code>grep ipc_key /etc/alsa/*</code>.  In my case, I see something like
<code>/etc/alsa/alsa.conf:defaults.pcm.ipc_key 5678293</code> (that&#8217;s
<code>0x56a4d5</code>).</li>
<li>
<code>ipcs -a</code> and look for the IPC key in hex.  I had both <code>0x56a4d5</code>
and <code>0x56a4d6</code>.  I&#8230; hope <code>0x56a4d6</code> belonged to ALSA because&#8230;</li>
<li>First I made sure that the <code>nattach</code> column said <code>0</code> for any
dmix-related segments/semaphores, then</li>
<li>I used <code>ipcrm -M 0x56a4d5</code> (and then <code>ipcrm -M 0x56a4d6</code>) to
delete those shared memory segments, and <code>ipcrm -S 0x56a4d5</code> to
delete the semaphores (&#8220;Semaphore Arrays&#8221; is the heading; maybe
simply saying &#8220;semaphores&#8221; is poor form on my part).</li>
</ol><p>Then audio worked.</p>

<p>I am more and more looking forward to Fedora 8 and PulseAudio.</p>
]]></content:encoded>
			<wfw:commentRss>http://darkness.codefu.org/wordpress/2007/12/25/293/feed</wfw:commentRss>
		</item>
		<item>
		<title>Audio in Linux is awesome</title>
		<link>http://darkness.codefu.org/wordpress/2007/12/15/292</link>
		<comments>http://darkness.codefu.org/wordpress/2007/12/15/292#comments</comments>
		<pubDate>Sun, 16 Dec 2007 00:01:02 +0000</pubDate>
		<dc:creator>darkness</dc:creator>
		
		<category><![CDATA[General]]></category>

		<guid isPermaLink="false">http://darkness.codefu.org/wordpress/2007/12/15/292</guid>
		<description><![CDATA[I&#8217;ve got some poorly recorded MP3s of people speaking.  I want to try
to make them a little easier to hear.  In Windows I&#8217;d reach for Sound
Forge.  How about in Linux?


Search Google for &#8220;sound forge equivalent for Linux.&#8221;
Find several references to &#8220;Wave Forge.&#8221;
Find &#8220;Wave Forge&#8221; hasn&#8217;t been
updated this century.  Move on.
Decide to [...]]]></description>
			<content:encoded><![CDATA[<p>I&#8217;ve got some poorly recorded MP3s of people speaking.  I want to try
to make them a little easier to hear.  In Windows I&#8217;d reach for Sound
Forge.  How about in Linux?</p>

<ol>
<li>Search Google for &#8220;sound forge equivalent for Linux.&#8221;</li>
<li>Find several references to &#8220;Wave Forge.&#8221;</li>
<li>Find <a href="http://www.tfm.ro/waveforge/" >&#8220;Wave Forge&#8221;</a> hasn&#8217;t been
updated this century.  Move on.</li>
<li>Decide to try Audacity because it&#8217;s in the back of your head, and
Ardour because you found a bunch of links to it somewhere.</li>
<li>
<code>yum install audacity ardour</code>.  That was easy.</li>
<li>Run Ardour.  Tells you it needs JACK.  WTF is a JACK?  Move on.</li>
<li>Run Audacity.  Loads.  GUI looks a little silly compared to Sound
Forge, but it looks functional enough.</li>
<li>Try to load the MP3 file.  Get told this version doesn&#8217;t have MP3
support.</li>
<li>Fish around for something to decode an MP3 to a WAV file.  Feel
bad about considering installing xmms just because you remember
how to do this with WinAmp.  Rejoice when you find <code>lame
--decode</code>.</li>
<li>Load the WAV in Audacity.  Looks good.</li>
<li>Hit the play button.  Get told there&#8217;s an error in sound output.</li>
<li>Check sound preferences.  Note that there are no available
playback devices.</li>
<li>Read around for a while about JACK.  See references to <code>jackd</code>.
Eventually realize that this is something you need to run
yourself, as your own user.</li>
<li>Run <code>jackd</code>.  Get told that it can&#8217;t open the hardware device,
presumably because other things (Amarok, Flash) are using it.</li>
<li>Find the correct invocation to run <code>jackd</code> which is something like
<code>jackd -d alsa -d default</code> (<code>-d</code> twice, WTF).</li>
<li>
<code>jackd</code> seems to keep running.  Cross fingers, run Ardour.  It
opens.</li>
<li>Look at the Ardour interface.  Decide that (1) it&#8217;s not what I
want, and (2) dear god that is ugly.  Is that Tk?  Motif?  Holy
hell.  Run away.</li>
<li>Open Audacity back up for the shit of it.  Lo, there is some sort
of JACK playback device now.  Select it, hit OK.</li>
<li>Click play button in Audacity.  Error with sound card.</li>
<li>Go into settings, change record device from OSS to JACK.  (But I&#8217;m
not recording?) Click play button in Audacity.  Sound comes out!
Rejoice.</li>
<li>Select a section, figure out how to zoom in.  Click play.  Get an
error telling you it can&#8217;t play.</li>
<li>Try playing different selections, no selections.  Keep getting the
same error.</li>
<li>Restart Audacity.  Same error.</li>
<li>Restart <code>jackd</code>.  Restart Audacity.  Same error.</li>
<li>Read about <code>qjackctl</code> being very helpful.  <code>yum install qjackctl</code>.
That was easy.</li>
<li>Run it.  Not sure what I&#8217;m looking at.  Says JACK is started.  Try
to turn on logging.  Tells me I have to restart something.
Whatever.</li>
<li>Restart Audacity.  Hit play.  Same error.</li>
<li>
<code>strace jackd</code>.  Hit play in Audacity.  No activity.</li>
<li>Stop <code>jackd</code> and tell <code>qjackctl</code> to start it.  Get a pretty
incomprehensible error message in its &#8220;log.&#8221;</li>
<li>Realize that it&#8217;s bitching because it&#8217;s trying to start it with
real-time priority, which it presumably doesn&#8217;t have permission to
do.</li>
<li>Read <a href="http://jackaudio.org/faq" >http://jackaudio.org/faq</a>.  &#8220;The simplest, and least-secure
way to provide real-time privileges is running jackd as root. This
has the disadvantage of also requiring all of JACK clients to run
as root.&#8221; Yeah, no.</li>
<li>Google around a bit, find out about <code>/etc/security/limits.conf</code>.
Find some lines in there referring to <code>@jackuser</code>.</li>
<li>Try to <code>usermod -a -G jackuser myuser</code>.  Fails, presumably because
my user is in LDAP (but the group is in <code>/etc/group</code>).</li>
<li>
<code>vigr</code>, add myself to the <code>jackuser</code> group by hand.</li>
<li>Don&#8217;t want to restart my X session to get new groups.  Figure I
need to log in from scratch to get new limits.  Fuck it, <code>ssh
localhost</code>.</li>
<li>Run <code>qjackctl</code>.  Tell it to start <code>jackd</code>.  Works.  Rejoice.</li>
<li>Run Audacity.  Hit play.  It works!</li>
<li>Stop.  Hit play again.  It still works!</li>
<li>Stop.  Make a selection.  Play the selection.  Holy shit it played
the selection!</li>
</ol><p>Really not very much work at all.  And Audacity only crashed, like,
three or four times while I was using it!  (Mostly when hitting the
play button to play the section I was working on.  I can&#8217;t remember if
<code>jackd</code> exited too.)</p>

<p>I can&#8217;t wait for
<a href="http://fedoraproject.org/wiki/Releases/FeaturePulseaudio" >PulseAudio</a>.
I&#8217;m sure that will make all of this <em>even easier</em>.</p>

<p>Oh, but in the end, I just ended up using <code>sox</code> and <code>normalize</code> in a
script to do my MP3s in a batch&#8230;</p>
]]></content:encoded>
			<wfw:commentRss>http://darkness.codefu.org/wordpress/2007/12/15/292/feed</wfw:commentRss>
		</item>
		<item>
		<title>Restoring mailboxes to Cyrus and CRLF</title>
		<link>http://darkness.codefu.org/wordpress/2007/11/17/291</link>
		<comments>http://darkness.codefu.org/wordpress/2007/11/17/291#comments</comments>
		<pubDate>Sun, 18 Nov 2007 01:22:05 +0000</pubDate>
		<dc:creator>darkness</dc:creator>
		
		<category><![CDATA[General]]></category>

		<guid isPermaLink="false">http://darkness.codefu.org/wordpress/2007/11/17/291</guid>
		<description><![CDATA[I had to restore some Maildir-style mailboxes from an old Courier IMAP
server to a newish Cyrus IMAP server.  There&#8217;s not much to it, and
this is well documented elsewhere, but basically you can copy the
files in (I don&#8217;t know if they need to be named like 123. like Cyrus
does by default), make sure permissions are [...]]]></description>
			<content:encoded><![CDATA[<p>I had to restore some Maildir-style mailboxes from an old Courier IMAP
server to a newish Cyrus IMAP server.  There&#8217;s not much to it, and
this is well documented elsewhere, but basically you can copy the
files in (I don&#8217;t know if they need to be named like <code>123.</code> like Cyrus
does by default), make sure permissions are right (and SELinux, if
applicable), and invoke some combinations of <code>reconstruct</code>.</p>

<p>I did hit a few gotchas though:</p>

<ul>
<li>Like I said above, don&#8217;t forget to <code>restorecon -Rv</code> on the restored
files if you&#8217;re on a system with SELinux enabled.</li>
<li>If you have mailboxes, particularly folders underneath the inbox,
you may need to invoke <code>reconstruct</code> with <code>-p default</code>.  This
registers them in <code>mailboxes.db</code>, I guess?  It makes them show up in
<code>lm</code> from <code>cyradm</code> which can&#8217;t be bad.</li>
<li>Related to the above, I don&#8217;t think <code>reconstruct</code> will believe a
directory is a mailbox unless there is a <code>cyrus.header</code> file in it.
Just <code>touch cyrus.header</code> was enough for me.  (I was calling
<code>reconstruct -p default -xrf</code> BTW; I don&#8217;t know if, for example,
<code>-x</code> makes it rewrite <code>cyrus.header</code> to have valid/meaningful
contents.  It should be non-empty, I believe.)</li>
<li>Finally, Courier&#8217;s messages all just used a line feed for line
endings.  Cyrus demands DOS-style CRLF for line endings.  Symptom
for this: bringing up the message index (in Mutt, at least) goes
much, much slower than it should.  I believe this happens because
too much information gets put in the Cyrus header/cache files.  (Use
the <code>mbexamine</code> program and you&#8217;ll see lots of weird information in
the &#8220;headers&#8221; I think.)  Fixing this for me was as simple as running
<code>unix2dos</code> over the files (and then fixing permissions; I should
have done <code>sudo -u cyrus unix2dos [0-9]*.</code> instead of just running
<code>unix2dos</code> as <code>root</code>.)</li>
</ul>
]]></content:encoded>
			<wfw:commentRss>http://darkness.codefu.org/wordpress/2007/11/17/291/feed</wfw:commentRss>
		</item>
		<item>
		<title>Letting Cyrus&#8217; Sieve send e-mail on CentOS 5</title>
		<link>http://darkness.codefu.org/wordpress/2007/11/01/290</link>
		<comments>http://darkness.codefu.org/wordpress/2007/11/01/290#comments</comments>
		<pubDate>Thu, 01 Nov 2007 05:50:29 +0000</pubDate>
		<dc:creator>darkness</dc:creator>
		
		<category><![CDATA[General]]></category>

		<guid isPermaLink="false">http://darkness.codefu.org/wordpress/2007/11/01/290</guid>
		<description><![CDATA[Problem: sieve rules like redirect (A.K.A. forward) don&#8217;t work on
CentOS 5.  You see things in the logs like:

Oct 29 17:15:52 gateway lmtpunix[26948]: sieve runtime error for
someone@example.com id &#60;blahlblahasdlahd@as987da97da987ads7&#62;:
Vacation: Sendmail process terminated normally, exit status 75

Nov  1 00:47:10 gateway lmtpunix[30206]: FATAL: couldn't exec() sendmail


Explanation: SELinux is preventing Cyrus from running sendmail.

Solution:


Install the selinux-policy-devel package.

Jam [...]]]></description>
			<content:encoded><![CDATA[<p>Problem: sieve rules like <code>redirect</code> (A.K.A. forward) don&#8217;t work on
CentOS 5.  You see things in the logs like:</p>

<pre><code>Oct 29 17:15:52 gateway lmtpunix[26948]: sieve runtime error for
someone@example.com id &lt;blahlblahasdlahd@as987da97da987ads7&gt;:
Vacation: Sendmail process terminated normally, exit status 75

Nov  1 00:47:10 gateway lmtpunix[30206]: FATAL: couldn't exec() sendmail
</code></pre>

<p>Explanation: SELinux is preventing Cyrus from running sendmail.</p>

<p>Solution:</p>

<ol>
<li>Install the <code>selinux-policy-devel</code> package.</li>
<li>
<p>Jam this in <code>local_cyrus.te</code>:</p>

<pre><code>policy_module(local_cyrus, 1.0.3)


require {
        type cyrus_t;
};


corecmd_exec_sbin(cyrus_t)
mta_send_mail(cyrus_t)
</code></pre>
</li>
<li><p><code>make -f /usr/share/selinux/devel/Makefile local_cyrus.pp</code></p></li>
<li><code>semodule --install local_cyrus.pp</code></li>
</ol><p>Now Cyrus should be able to run <code>sendmail</code>.</p>

<p><strong>WARNING</strong>: this may allow Cyrus to do more than it should be able
to.  I&#8217;m hardly an SELinux expert.</p>
]]></content:encoded>
			<wfw:commentRss>http://darkness.codefu.org/wordpress/2007/11/01/290/feed</wfw:commentRss>
		</item>
		<item>
		<title>Groupware!</title>
		<link>http://darkness.codefu.org/wordpress/2007/10/09/289</link>
		<comments>http://darkness.codefu.org/wordpress/2007/10/09/289#comments</comments>
		<pubDate>Tue, 09 Oct 2007 21:56:39 +0000</pubDate>
		<dc:creator>darkness</dc:creator>
		
		<category><![CDATA[General]]></category>

		<guid isPermaLink="false">http://darkness.codefu.org/wordpress/2007/10/09/289</guid>
		<description><![CDATA[A client wants to know about possible &#8220;calendaring solutions,&#8221; things
like a Notes or an Exchange, but presumably cheap/free.

In this case, these guys aren&#8217;t currently Outlook/Exchange users, and
obviously Exchange doesn&#8217;t fit the definition of &#8220;cheap,&#8221; so I don&#8217;t
have to contend with that.  Here I&#8217;m referring to the difficulty
switching away from Outlook/Exchange, which generally boils down [...]]]></description>
			<content:encoded><![CDATA[<p>A client wants to know about possible &#8220;calendaring solutions,&#8221; things
like a Notes or an Exchange, but presumably cheap/free.</p>

<p>In this case, these guys aren&#8217;t currently Outlook/Exchange users, and
obviously Exchange doesn&#8217;t fit the definition of &#8220;cheap,&#8221; so I don&#8217;t
have to contend with that.  Here I&#8217;m referring to the difficulty
switching away from Outlook/Exchange, which generally boils down to:</p>

<ol>
<li><p>Useful features that are available in Exchange but not generally
available in competing FOSS products.  A few years ago lots of
products were missing free/busy information, which was often a deal
breaker.  (Today many packages seem to have this, but certainly not
all of them.)  Other things might be the slick web interface that
is Outlook Web Access (as long as you&#8217;re in IE), integration with
Windows Mobile and Blackberry (well, with BES at least) devices.</p></li>
<li><p>People generally like Outlook, or at least hate it less than other
things they&#8217;ve used.  It&#8217;s consistent with another fixture in most
businesses, Microsoft Office.  It&#8217;s got a variety of software
available for it and software that integrates with it
(particularly&#8230; Microsoft Office).  It&#8217;s also prettier than a lot
of the competition.</p></li>
</ol><p>I&#8217;m loathe to say Outlook/Exchange is <em>good</em>, precisely.  Were I to
try to start using Outlook I expect I&#8217;d find a number of things to
hate about it, and I know of many occasions when administering
Exchange was a bitch (for example, crashing with no explanation for
why (inadequate logging, that is), or MTA features that Exchange
should have).  The fact remains, however, that for businesses invested
in Microsoft Windows and Microsoft Office, and putting aside the issue
of cost, you could do a lot worse than Outlook/Exchange.  The two
products offer useful features still not found in most FOSS products
(at least, not all in the same product).</p>

<p>So it&#8217;s a good thing I don&#8217;t have to contend with that.  (My own
personal biases aside, normally I would probably suggest Exchange, in
the interests of my client.  In this particular case, their budget
rules it out.)</p>

<p>Moving on, I don&#8217;t know of a good product to suggest to them!  That
is, I&#8217;ve found several FOSS projects, which I&#8217;ll list below, but I
have no idea which of them are even production quality, let alone
stable, usable, and whether they will meet my client&#8217;s needs.  I don&#8217;t
have time to review them, so unfortunately I probably won&#8217;t be able to
make a &#8220;recommendation&#8221; other than basically giving them this list.</p>

<p>This is not me asking for any help, really, though I welcome opinions
on these various products I suppose.  The real purpose of this post is
to note the small amount of research I&#8217;ve done at this point, and to
give me a list of products I can go back and check later when I have
some time (laughter ensues).</p>

<p>Without further delay, the list of generally free and/or open source
<a href="http://www.jwz.org/doc/groupware.html" >&#8220;groupware&#8221;</a> I&#8217;ve found:</p>

<ul>
<li>
<a href="http://buni.org/" >Meldware Communication Suite</a>: Java (immediate
reaction: mmm, huge footprints and one million dependencies). looks
like it includes an MTA, calendar server (think
<a href="http://en.wikipedia.org/wiki/Web_Calendar_Access_Protocol" >WCAP</a>),
and separately some sort of &#8220;web interface.&#8221;  They have some
1.0&#8230; milestone releases?</li>
<li>
<a href="http://www.citadel.org" >Citadel</a>: this used to be BBS software,
says Wikipedia?  WTF?  Nonetheless I&#8217;ve read several recommendations
for it.  Web interface supposed to be modern (read: AJAX) and pretty
nice.  I just don&#8217;t know if this is good for, like, scheduling
meetings.</li>
<li><a href="http://www.opengroupware.org/" >OpenGroupware.org</a></li>
<li>
<a href="http://www.open-xchange.com/" >Open-Xchange</a>: How free is it?  I
don&#8217;t know.  I&#8217;m pretty sure they have at least some commercial
(which is to say, proprietary and not free-as-in-beer) components.
Been around for a long time.</li>
<li><a href="http://www.scalix.com/" >Scalix</a></li>
<li>
<a href="http://www.zimbra.com/" >Zimbra</a>: I don&#8217;t even really know if the
calendaring here, my client&#8217;s major requirement, is even available,
let alone useful for a business.  Plus I&#8217;m still biased against
Zimbra because the last time I tried to install from source was an
incredible nightmare.</li>
<li><a href="http://www.group-office.com/" >Group-Office</a></li>
<li>
<a href="http://www.horde.org/groupware/" >Horde Groupware</a>: This is
basically a nice distribution of the various Horde applications such
as Kronolith, their calendaring software.  This looks attractive to
me, since they&#8217;re already using Imp for webmail.  I&#8217;m also fairly
certain Horde is going to serve as the web interface for Kolab (see
below) which probably says that others find it to be a good
interface and easy enough to integrate with.</li>
<li>
<a href="http://www.kolab.org/" >Kolab</a>: I confess that I didn&#8217;t really look
at these guys, since their web interface is still &#8220;experimental,&#8221;
and I probably require that.</li>
<li><a href="http://www.simple-groupware.de/" >Simple Groupware</a></li>
<li><a href="http://www.phpgroupware.org/" >phpGroupWare</a></li>
<li><a href="http://www.egroupware.org/" >eGroupWare</a></li>
<li>
<a href="http://chandlerproject.org/" >Chandler</a>: Is it usable now?  Does it
have a web interface?  I have no idea.</li>
<li>
<a href="https://www.google.com/a/help/intl/en/admins/editions.html" >Google
Calendar</a>:
They&#8217;ve got &#8220;conference room and resource scheduling&#8221; and free/busy
information at least.  I like Google Spreadsheet so far.  I&#8217;m not
sure if $50/year is totally unrealistic for my client&#8217;s budget or
not.</li>
</ul><p>So that&#8217;s the list of contenders I found.  Since I had no real time to
review/demo these products, I have no idea if some of them are
unusable, defunct, or closed/proprietary/costly.</p>
]]></content:encoded>
			<wfw:commentRss>http://darkness.codefu.org/wordpress/2007/10/09/289/feed</wfw:commentRss>
		</item>
		<item>
		<title>SELinux and EPEL&#8217;s mod_fcgid on CentOS 5</title>
		<link>http://darkness.codefu.org/wordpress/2007/09/26/288</link>
		<comments>http://darkness.codefu.org/wordpress/2007/09/26/288#comments</comments>
		<pubDate>Wed, 26 Sep 2007 06:02:02 +0000</pubDate>
		<dc:creator>darkness</dc:creator>
		
		<category><![CDATA[General]]></category>

		<guid isPermaLink="false">http://darkness.codefu.org/wordpress/2007/09/26/288</guid>
		<description><![CDATA[I rebuilt EPEL&#8217;s mod_fcgid
package with the latest mod_fcgid (2.2 I believe) with no problems.
Make sure to define a macro like rhel with value 5 to get the
SELinux policy module built too (echo '%rhel 5' &#62;&#62; ~/.rpmmacros or
maybe rpmbuild --define 'rhel 5' ...).

Now, I&#8217;m using FastCGI and Apache&#8217;s suEXEC to run the FastCGIs as
particular (per-site) users. [...]]]></description>
			<content:encoded><![CDATA[<p>I rebuilt <a href="http://fedoraproject.org/wiki/EPEL" >EPEL</a>&#8217;s mod_fcgid
package with the latest mod_fcgid (2.2 I believe) with no problems.
Make sure to define a macro like <code>rhel</code> with value <code>5</code> to get the
SELinux policy module built too (<code>echo '%rhel 5' &gt;&gt; ~/.rpmmacros</code> or
maybe <code>rpmbuild --define 'rhel 5' ...</code>).</p>

<p>Now, I&#8217;m using FastCGI and Apache&#8217;s suEXEC to run the FastCGIs as
particular (per-site) users.  So for one site my configuration looks
like:</p>

<pre><code>&lt;VirtualHost www.example.com:80&gt;
        ServerName www.example.com
        DocumentRoot /srv/www/www.example.com/root

        SuexecUserGroup www_example_com www_example_com
        ScriptAlias /trac /var/www/suexec/www_example_com/trac.fcgi
&lt;/VirtualHost&gt;
</code></pre>

<p>suEXEC (as distributed with CentOS 5) will only run things under
<code>/var/www</code>, so I created <code>/var/www/suexec</code>.  I want to run things as
the <code>example</code> user, lets say, so I <code>mkdir
/var/www/suexec/www_example_com</code> and <code>chown</code> that directory to
<code>example:example</code>, because suEXEC requires that.  Then I make a little
<code>.fcgi</code> file that starts my FastCGI app (for
<a href="http://trac.edgewall.org" >Trac</a> as you may have noticed).</p>

<p>So on and so forth; none of that is interesting.  Now here comes
SELinux: I did install the <code>mod_fcgid-selinux</code> package, which
automatically installs an SELinux policy module for mod_fcgid
(<code>semodule --list | grep fastcgi</code>).  As far as I can tell, you <em>must</em>
<code>chcon -t httpd_fastcgi_script_exec_t</code> your FastCGI scripts; without
this, I believe your script won&#8217;t have access to various pipes or
shared memory or <em>something</em> that it needs to communicate back to
mod_fcgid living in Apache.  Don&#8217;t label the whole directory
<code>httpd_fastcgi_script_exec_t</code>, just the <code>.fcgi</code> file.  See also the
<code>README.SELinux</code> that comes in the <code>mod_fcgid-selinux</code> package.</p>

<p>At this point, especially since I had the SELinux <code>httpd_unified</code>
boolean on (it&#8217;s on by default), I might have been in the clear.  I go
to run my <code>trac.fcgi</code> (via <code>/trac</code>)&#8230; and I get an internal error.
<code>/var/log/httpd/error_log</code> spews HTML and other errors that sound
generally like &#8220;I didn&#8217;t start as a FastCGI at all, here&#8217;s me as a
regular CGI, whee!&#8221;  The best part?  No AVC messages.</p>

<p>Here&#8217;s where <a href="http://danwalsh.livejournal.com/11673.html" >Dan Walsh&#8217;s post on disabling <code>dontaudit</code>
rules</a> comes in.  As he
says, the cool stuff is in Fedora 8 where all <code>dontaudit</code> rules can be
disabled, even ones in policy modules (policy modules like the
<code>fastcgi</code> module that is installed by <code>mod_fcgid-selinux</code>).  However,
in this case, and because I rebuilt <code>fastcgi</code> with no <code>dontaudit</code>
rules, I can tell you the problem is in the base policy and not in a
policy module; so using <code>semodule -b
/usr/share/selinux/targeted/enableaudit.pp</code> works just fine to
troubleshoot this.</p>

<p>So execute the above <code>semodule</code> command, restart Apache (for good
measure?), reload <code>/trac</code>, and now we get:</p>

<pre><code>type=AVC msg=audit(1190783371.758:8180): avc: denied { read write }
for pid=3 2127 comm="suexec" name="[180326]" dev=sockfs
ino=180326 scontext=user_u:system_ r:httpd_suexec_t:s0
tcontext=user_u:system_r:httpd_t:s0 tclass=unix_stream_socke t

type=AVC msg=audit(1190783371.758:8180): avc: denied { siginh }
for pid=32127 comm="suexec" scontext=user_u:system_r:httpd_t:s0
tcontext=user_u:system_r:http d_suexec_t:s0 tclass=process

type=AVC msg=audit(1190783371.758:8180): avc: denied { rlimitinh }
for pid=32 127 comm="suexec" scontext=user_u:system_r:httpd_t:s0
tcontext=user_u:system_r:h ttpd_suexec_t:s0 tclass=process

type=AVC msg=audit(1190783371.758:8180): avc: denied { noatsecure }
for pid=32127 comm="suexec" scontext=user_u:system_r:httpd_t:s0
tcontext=user_u:system_r: httpd_suexec_t:s0 tclass=process
</code></pre>

<p>Now, the last three messages are apparently no big deal.  That first
one, though, is the problem.  So I run that through <code>audit2allow</code>, a
little editing, and I come out with something like:</p>

<pre><code> policy_module(local_fastcgi, 1.0.0)

 require {
     type httpd_suexec_t;
     type httpd_t;
 };

 allow httpd_suexec_t httpd_t:unix_stream_socket { rw_stream_socket_perms };
</code></pre>

<p>(OK, sorry, that&#8217;s actually a significant bit of editing.  I just
learned about the macros that I guess you&#8217;re supposed to use, like
<code>policy_module</code>.  I found <code>rw_stream_socket_perms</code> in the <code>fastcgi</code>
policy source.)</p>

<p>I slap that in a file like <code>local_fastcgi.te</code> then <code>make -f
/usr/share/selinux/devel/Makefile load</code> (careful!  I think that will
build and install <strong>every</strong> policy in&#8211;and possibly every policy
under&#8211;the current directory).  Once loaded, I restart Apache, and now
my FastCGI being run by suEXEC works.</p>

<p>I hope you didn&#8217;t just read this overly verbose post just to find
&#8220;install the above policy module and FastCGIs running with suEXEC
under CentOS 5 will work with SELinux on.&#8221;  Er, sorry.</p>

<p>I would report this as a bug&#8230; maybe I should file it against EPEL,
if they&#8217;ve got some bug tracking.  Then they&#8217;ll probably end up
pushing it upstream to the F7 maintainer?  Which I assume is where the
EPEL package was derived from.  My question then is: does F7 have this
problem too, or is it fixed in F7 by virtue of some other part of the
policy?</p>

<p>The rule to <code>dontaudit</code> <code>httpd_suexec_t</code> getting at
<code>httpd_t:unix_stream_socket</code> is actually in the core Apache policy, I
think, and it seems to make a reference to how Apache should
&#8220;close-on-exec.&#8221;  So I&#8217;m really not even sure if this policy change
should go into Apache&#8217;s policy (and have a bool?) or if it should go
into mod_fcgid&#8217;s policy module (and have a bool there?).</p>

<p>So, does someone want to advise me as to where and against what
package(s) I should file a bug?  Or maybe I need to wade onto the
Fedora SELinux mailing list?</p>
]]></content:encoded>
			<wfw:commentRss>http://darkness.codefu.org/wordpress/2007/09/26/288/feed</wfw:commentRss>
		</item>
		<item>
		<title>Making a remote Dell PE1600SC at The Planet use software RAID</title>
		<link>http://darkness.codefu.org/wordpress/2007/09/24/287</link>
		<comments>http://darkness.codefu.org/wordpress/2007/09/24/287#comments</comments>
		<pubDate>Mon, 24 Sep 2007 20:15:34 +0000</pubDate>
		<dc:creator>darkness</dc:creator>
		
		<category><![CDATA[General]]></category>

		<guid isPermaLink="false">http://darkness.codefu.org/wordpress/2007/09/24/287</guid>
		<description><![CDATA[We just got another server at The Planet.  They had a deal on another
of the same 1600SC&#8217;s we got before: dual Xeon, but this time with dual
10k 136GB SCSI disks.

They offer CentOS 5 now.  (When we bought our last one, they only
offered RHEL 3, which I had to remotely upgrade to CentOS 4.) [...]]]></description>
			<content:encoded><![CDATA[<p>We just got another server at The Planet.  They had a deal on another
of the same 1600SC&#8217;s we got before: dual Xeon, but this time with dual
10k 136GB SCSI disks.</p>

<p>They offer CentOS 5 now.  (When we bought our last one, they only
offered RHEL 3, which I had to remotely upgrade to CentOS 4.)  When
they turn the server over to you, you&#8217;ve got <code>/</code>, <code>/boot</code>, swap, and
then <code>/dev/sdb</code> is one big partition.  My task: change it to LVM on
software RAID 1.</p>

<p>I don&#8217;t think their web site mentions it, and there was some question
about whether they still offer it, but this newest server still has a
Dell DRAC III card in it, which I needed to toy with grub (when I
screwed up).  You could probably do without remote console access,
except (1) it will be hard to see errors, and (2) I don&#8217;t recall if
grub has a functionality similar to <code>lilo -R</code> (&#8220;for the next boot
only, use boot entry N&#8221;) these days.</p>

<p>Here are my rough steps to complete this task.  This is based partly
on what I did, partly what I should have done, and it&#8217;s all from
memory (granted, memories that are scant hours old).  Note that <strong>you
probably don&#8217;t want to do this on a &#8220;production&#8221; machine</strong> (duh), as
this will require reboots and potentially horking things.  I did it on
a fresh install that I wasn&#8217;t afraid to have reinstalled; you&#8217;ve been
warned.</p>

<ol>
<li>Partition <code>/dev/sdb</code>.  For me, that&#8217;s 128MB <code>/dev/sda1</code> as <code>/boot</code>,
and the rest in <code>/dev/sdb2</code>.  Both types <code>0xfd</code> for RAID
auto-detect.  I set <code>sdb1</code>, which will be software RAID 1 for
<code>/boot</code>, to be an &#8220;active&#8221; (AFAIK means &#8220;can boot off of here&#8221;)
partition, in case <code>sda1</code> fails.</li>
<li>Create the software RAID devices.  For <code>/boot</code>, this like like
<code>mdadm --create -l 1 -n 2 /dev/md0 missing /dev/sdb1</code>.  <code>missing</code>
is the word I always forget: it says &#8220;the disk that would normally
go in this slot is&#8230; well, missing.&#8221;  Repeat for <code>/dev/md1</code> with
<code>/dev/sdb2</code>.</li>
<li>
<code>pvinit</code>, <code>vgcreate</code>, and then <code>lvcreate</code> all the logical volumes
you want.</li>
<li>
<code>mkfs</code> or equivalent on all your new devices.  For the record, I
found out RH&#8217;s anaconda does something like <code>mke2fs -j -i &lt;inode
size&gt; &lt;device&gt;</code>.  I left out the <code>-i</code>.  Other options for <code>mke2fs</code>
are apparently read from <code>/etc/mke2fs.conf</code>.  After <code>mke2fs</code>
anaconda seems to do <code>tune2fs -i0 -c0 -ouser_xattr,acl -Odir_index
&lt;device&gt;</code>.  (This is from memory, I hope it&#8217;s right.)  Don&#8217;t forget
to <code>e2label</code> everything too.  RHEL 5&#8217;s <code>mkswap</code> apparently takes
<code>-L</code> to set a label, which you can use in <code>/etc/fstab</code>.</li>
<li>Mount up your new, empty filesystem(s) somewhere.  I made and used
<code>/mnt/sdb</code>.</li>
<li>
<p>Edit <code>grub.conf</code>.  Note on my system, <code>/etc/grub.conf</code> was not
symlinked to the actual file, <code>/boot/grub/grub.conf</code>.  If you see
this I don&#8217;t see why you shouldn&#8217;t <code>rm /etc/grub.conf &amp;&amp; ln -s
../boot/grub/grub.conf /etc/grub.conf</code> like I did.</p>

<p>In <code>grub.conf</code> you want to make a copy of your currently booted
stanza.  In this copy, change the <code>root (hd0,0)</code> to be <code>root
(hd1,0)</code>, and also change the <code>root=LABEL=/</code> in the <code>kernel</code> line
to point at something like <code>root=/dev/vgmain/lvroot</code> (or wherever
your root FS is).</p>

<p>Also, for people like me on a DRAC III, you&#8217;ll want to comment out
any <code>bootsplash</code> or <code>hiddenmenu</code> lines, you don&#8217;t need any serial
console (I commented out both <code>serial</code> and <code>terminal</code> lines for
GRUB and also removed <code>console=...</code> parameters to the kernel).  You
may want to bump up the <code>timeout</code>.  Additionally, <a href="http://darkness.codefu.org/wordpress/2006/09/22/247" >DRAC III users
will need to add <code>i8042.dumbkbd=1</code> to the <code>kernel</code> &#8220;command
line.&#8221;</a></p>
</li>
<li><p>I don&#8217;t think this is necessary&#8230; but I did add <code>(hd1) /dev/sdb</code>
to <code>/boot/grub/device.map</code> and I also re-ran <code>/sbin/grub-install</code>.</p></li>
<li>Copy everything from the running filesystems to the new
filesystem(s).  I used <code>cd /; find . -xdev -print | cpio -pvdm
/mnt/sdb/</code> to do this, and then the same with <code>/boot</code>.  Jumping
ahead some steps, after I finally got the new arrays booted, I
don&#8217;t think this copied the SELinux labels right, which is no good.
I encourage you to find a command that does copy the SELinux
labels.  Maybe <code>star</code> can help?  Or <code>cp -ax</code>?  If you use my
method, go ahead and touch <code>.autorelabel</code> in the root of your new
filesystem, which should cause SELinux relabelling at boot.</li>
<li>
<code>chroot</code> to your new FS.  <code>mount /proc &amp;&amp; mount /sys</code>.</li>
<li>Edit <code>/etc/fstab</code> on the new FS to reflect your new layout.  I note
that a fresh CentOS 5 install using LVM on RAID doesn&#8217;t use
<code>LABEL=...</code> syntax for selecting devices, so I&#8217;d put actual device
names for everything on software RAID or LVM in column 1 of
<code>fstab</code>.  Note that I never got <code>mkinitrd</code> to run correctly
(i.e. include the LVM stuff) as long as I was using <code>LABEL=/</code> for
my <code>/</code> partition.</li>
<li>This is kind of weird: I think you need the device nodes hanging
around to ensure that <code>mkinitrd</code> works right in the next step, so
run <code>start_udev</code>.  The weird part: this is going to kill the
running <code>udevd</code> and replace it with one whose <code>/</code> points to your
new root.  I was able to finish my work and reboot my system
without <code>udevd</code> running on my real root; hopefully your mileage
<em>won&#8217;t</em> vary.</li>
<li>If you&#8217;re using LVM like me, you need to run <code>vgmknodes</code> now, to
make things like <code>/dev/vgmain/lvroot</code> (example name).</li>
<li>Now it&#8217;s time to run <code>mkinitrd</code>.  <code>rm</code> the existing <code>initrd</code> in
<code>/boot</code> and run <code>mkinitrd</code> with the <code>-v</code> switch.  Make sure it
pulls in <code>lvm</code> (and look for <code>lvm.conf</code> too).</li>
<li>Theoretically you&#8217;re now ready to go, and it&#8217;s time to reboot.
(Last chance to <code>touch /.autorelabel</code>.)  <code>killall udevd; umount
sys &amp;&amp; umount proc &amp;&amp; exit</code> to get out of the chroot.  <code>umount</code>
the rest of the stuff for fun, maybe <code>vgchange -a n</code> and then
<code>mdadm --stop</code> all your new RAID devices (since I&#8217;m paranoid and
not sure if RHEL would do this for me, since they weren&#8217;t there at
boot), and reboot.</li>
<li>Hopefully you can now select your new GRUB entry at boot, and boot
from your new disks.  (If you touched <code>.autolabel</code> you&#8217;re in for
an extra reboot.)  Once it boots, log in and make sure <code>mount</code>
looks right, with your new LVM/RAID devices.  Also check
<code>/proc/swaps</code> to make sure the right swap device is being used.</li>
<li>Once you&#8217;re sure you&#8217;re OK, and you don&#8217;t want anything off the
old disk, <code>sfdisk --dump /dev/sdb | sed 's/sdb/sda/g' | sfdisk
/dev/sda</code> to copy the partition table from <code>sdb</code> to <code>sda</code>.</li>
<li>
<code>mdadm --manage --add</code> the <code>sda</code> partitions to the RAID devices.</li>
<li>Wait for resync (i.e. bounce on <code>cat /proc/mdstat</code>).</li>
<li>Now go back to <code>grub.conf</code>, take out your extra entry (the one
using <code>(hd1,0)</code>).  Change the old entry (in my <code>grub.conf</code> I now
only had one entry) to use the real root device path, so (ex.)
<code>root=/dev/vgmain/lvroot</code>) instead of <code>root=LABEL=/</code>.</li>
<li>Make sure <code>/etc/fstab</code> looks right still.  Again, I recommend
against using <code>LABEL=</code> syntax for anything on software RAID or
LVM.</li>
<li>I re-ran <code>mkinitrd</code> with <code>-v</code>, more than anything just to make
sure it worked right.  (Again: if your <code>/</code> is on LVM, make sure
you see things like <code>lvm.conf</code> being put on the initrd.  I didn&#8217;t
the first time I did this, and it turned out to be because I was
using <code>LABEL=...</code> syntax in <code>/etc/fstab</code> for <code>/</code>.)</li>
<li>Optional: I wrote a GRUB boot sector to <code>sdb</code> as if it were the first disk
in the system.  Run <code>grub</code>, <code>device (hd0) /dev/sdb</code>, <code>root
(hd0,1)</code>, <code>setup(hd0)</code>.  You can check that GRUB is now on <code>sdb</code>
with something like <code>dd if=/dev/sdb bs=512 count=1 | strings |
grep GRUB</code> and you should see <code>GRUB</code> as output.</li>
<li>Reboot (and pray, perhaps).</li>
</ol><p>Once you&#8217;ve rebooted this last time you&#8217;ll probably want to look at
<code>mount</code> to make sure everything is still where it should be, check
your swap is on, and check <code>/proc/mdstat</code> to make sure the arrays are
OK.  In my case, and slightly to my surprise, everything was OK.</p>

<p>Sorry to the folks at The Planet if my turning off serial console
stuff in GRUB/the kernel screws them up.  (Feel free to drop me a line
and I&#8217;ll turn it back on and update these instructions.)</p>
]]></content:encoded>
			<wfw:commentRss>http://darkness.codefu.org/wordpress/2007/09/24/287/feed</wfw:commentRss>
		</item>
		<item>
		<title>Python drive-by</title>
		<link>http://darkness.codefu.org/wordpress/2007/09/14/286</link>
		<comments>http://darkness.codefu.org/wordpress/2007/09/14/286#comments</comments>
		<pubDate>Sat, 15 Sep 2007 00:17:05 +0000</pubDate>
		<dc:creator>darkness</dc:creator>
		
		<category><![CDATA[General]]></category>

		<guid isPermaLink="false">http://darkness.codefu.org/wordpress/2007/09/14/286</guid>
		<description><![CDATA[Making simple tree data structures out of things like lists and dicts
in Python always pains me.  In my head other languages, like maybe
ECMAScript or Lua, have better syntax for this.  Here&#8217;s an example of
what I might write to set up a particular data structure:

day = {}
day["date"] = "date object here"
day["title"] = "string data [...]]]></description>
			<content:encoded><![CDATA[<p>Making simple tree data structures out of things like lists and dicts
in Python always pains me.  In my head other languages, like maybe
ECMAScript or Lua, have better syntax for this.  Here&#8217;s an example of
what I might write to set up a particular data structure:</p>

<pre><code>day = {}
day["date"] = "date object here"
day["title"] = "string data here"
sections = day["sections"] = [dict(title="section title")]
jobs = sections[0]["jobs"] = []
jobs.append(dict(title="Google",
                 url="http://www.google.com"))
jobs.append(dict(title="Yahoo!",
                 url="http://www.yahoo.com"))
</code></pre>

<p>Perhaps <code>pprint</code> can make it easier to see what I&#8217;ve done here:</p>

<pre><code>{'date': 'date object here',
 'sections': [{'jobs': [{'title': 'Google', 'url': 'http://www.google.com'},
                        {'title': 'Yahoo!', 'url': 'http://www.yahoo.com'}],
               'title': 'section title'}],
 'title': 'string data here'}
</code></pre>

<p>You might want to argue that I made bad choices WRT that syntax, since
the pretty printed version above probably looks better.  Here&#8217;s an
alternative, I guess:</p>

<pre><code>day = {"date": "calculate date object here",
       "sections": [{"title": "section title",
                     "jobs": [{"title": "Google",
                               "url": "http://www.google.com"},
                              {"title": "Yahoo!",
                               "url": "http://www.yahoo.com"},
                              ],
                      },
                     ],
       }
# Can't assign this in-line, unless I calculate "date" into a local
# variable first.
day["title"] = "this is based on " + day["date"]
</code></pre>

<p>It&#8217;s not really fair to say &#8220;just write it like <code>pprint</code> has.&#8221;
<code>pprint</code> has a few advantages, such as having everything that it needs
to put in its rendered data structure up front, and also being a
computer.  As a human writing this data structure, I think of the
<code>title</code> before I think of putting in the <code>jobs</code> for example; <code>pprint</code>
alphabetizes the keys, so it puts <code>jobs</code> first, which means you don&#8217;t
potentially have <code>}]}]}</code> at the end of the structure.  Also note that
I needed one of the values in the structure to compute another;
<code>pprint</code> already had that value when it went to render the data
structure.</p>

<p>Also, I may need to think about switching from double quotes to single
quotes.  To my overly picky mind, they now look a little &#8220;cleaner.&#8221;
My use of double quotes can be traced back to when I was frequently
programming in C, but is not helped by the fact that <code>''</code> and <code>""</code>
behave differently in languages such as Perl and the Bourne Shell.  (C
also makes/made me do slightly weird things in Perl and sh, such as
writing <code>'x'</code> and <code>"xxx"</code> with different quote types.)</p>

<p>So I went crazy and made a class which is currently called DataObject.
It&#8217;s actually a somewhat disgusting set of wrappers over dictionaries,
but check out the syntax:</p>

<pre><code>day = DataObject()
day.date = "date object here"
day.title = "string data here"
day.sections[0].title = "section title"
day.sections[0].jobs.new_child(title="Google",
                               url="http://www.google.com")
day.sections[0].jobs.new_child(title="Yahoo!",
                               url="http://www.yahoo.com")
</code></pre>

<p>To me this is vastly more readable (and easier to write too), and it
works just like the data structure I made above with Python&#8217;s built-in
types.  You can also ask for a clone of the data using built-in types
by calling <code>day.to_native()</code> (it operates recursively).</p>

<p>I think there may be some weird side-effects, like weird exceptions
that happen when you make a typo on a &#8220;key&#8221; (since attributes are
mapped to keys) and a new object springs into existence.  I&#8217;m going to
try using it a bit more before I pass judgment on whether or not it&#8217;s
a useful idea.</p>
]]></content:encoded>
			<wfw:commentRss>http://darkness.codefu.org/wordpress/2007/09/14/286/feed</wfw:commentRss>
		</item>
		<item>
		<title>The XV-6700 is going back</title>
		<link>http://darkness.codefu.org/wordpress/2007/08/13/284</link>
		<comments>http://darkness.codefu.org/wordpress/2007/08/13/284#comments</comments>
		<pubDate>Mon, 13 Aug 2007 19:28:10 +0000</pubDate>
		<dc:creator>darkness</dc:creator>
		
		<category><![CDATA[General]]></category>

		<guid isPermaLink="false">http://darkness.codefu.org/wordpress/2007/08/13/284</guid>
		<description><![CDATA[What I like about the XV-6700 from Verizon
Wireless:


I can get on the web pretty fast from anywhere; especially fast
with built-in 802.11b.  EV-DO (rev. 0) isn&#8217;t anything to sneeze
at, either.
Slide out QWERTY keyboard.
Pretty decent screen, including a flip to landscape when you slide
out the keyboard.

Windows Live
Search
(and maybe Google Maps
Mobile).

Microsoft Voice
Command.
USB Mini-B connector built in.  [...]]]></description>
			<content:encoded><![CDATA[<p>What I like about <a href="http://www.america.htc.com/products/verizon/features-specs.html" >the XV-6700 from Verizon
Wireless</a>:</p>

<ol>
<li>I can get on the web pretty fast from anywhere; especially fast
with built-in 802.11b.  EV-DO (rev. 0) isn&#8217;t anything to sneeze
at, either.</li>
<li>Slide out QWERTY keyboard.</li>
<li>Pretty decent screen, including a flip to landscape when you slide
out the keyboard.</li>
<li>
<a href="http://mobile.search.live.com/about/download/default.aspx" >Windows Live
Search</a>
(and maybe <a href="http://www.google.com/gmm/index.html" >Google Maps
Mobile</a>).</li>
<li>
<a href="http://www.microsoft.com/windowsmobile/voicecommand/default.mspx" >Microsoft Voice
Command</a>.</li>
<li>USB Mini-B connector built in.  Good for charging, good for
tethering.</li>
<li>
<a href="http://www.howardforums.com/showthread.php?threadid=827559" >USB and Bluetooth
tethering</a>
is possible.  (Supposedly.  I enabled it as stated but I haven&#8217;t
actually tried it yet.)</li>
<li>Windows Mobile (henceforth WM) is widespread enough that there&#8217;s a
good bit of software available for it.</li>
</ol><p>What I don&#8217;t like about the XV-6700:</p>

<ol>
<li>No EV-DO rev. A.  (The XV-6800 should be &#8220;soon&#8221; with rev. A
however.)</li>
<li>Slow to turn on.  Two seconds minimum to turn the device on.  My
Palm turns on almost instantly.  My v710, which was a decent
phone, was always on.  My friend&#8217;s HTC TyTN on AT&amp;T supposedly
turns on within 0.5s (i.e. 4x faster).</li>
<li>Slow to use.  Hit the start menu.  Wait a bit.  Wait for the
browser to load.  Wait for the phone to lock and turn the display
off.  Wait for the phone application to pop up.  On a PC, I&#8217;m used
to waiting.  On a phone, I&#8217;m not, and I don&#8217;t really think I want
to.  All of this talking about slowness is based on my use of
&#8220;dumbphones,&#8221; like my v710, and my Palm.  My (several years old)
Palm Tungsten C is practically instantaneous for launching any
application.</li>
<li>The WM interface and I don&#8217;t really get along.  Why does the &#8220;OK&#8221;
button <em>close</em> applications?  Moving around with the 4-way switch
also screws me up sometimes; it seems inconsistent.  (Granted,
within Microsoft applications it&#8217;s probably pretty consistent.
But this phone, from Verizon at least, seems to come with its
share of third-party software already installed, not counting what
else you&#8217;ll want to install (see below).) Also, why is it, when I
think I&#8217;m closing an application, I&#8217;m not really closing it?</li>
<li>Lots of features that should probably be standard, but you end up
having to pay extra for.
<ul>
<li>Microsoft Voice Command, which allows you to voice dial (built
in to the v710, and really very usable): $40.</li>
<li>If I go to the bathroom and leave my phone on my desk, and I
get a text message while I&#8217;m in the bathroom, WM doesn&#8217;t go
out of its way to notify me that I have an unread message: you
only get the notice when it comes in.  Similar sorts of things
may or may not happen with missed calls, e-mails, etc. (it&#8217;s
not totally clear to me how all the notifications work).  So
you need <a href="http://www.spbsoftwarehouse.com/products/phonesuite/?en" >Spb Phone
Suite</a>.
$20.  My v710 would beep or vibrate (depending on the mode you
have it in) forever until you cleared it (with a hard button
on the side while it&#8217;s still in the holster, even).  You&#8217;ll
also want Spb Phone Suite for the ease of changing ringer
profiles from the Today screen.  (You could change these on my
v710 with hard buttons on the side, without flipping the phone
open.  If you&#8217;re minimally flexible, you can do it while it&#8217;s
still in the holster.) (There may be a free application called
something like &#8220;DontForget&#8221; that does this for you.  Still,
why isn&#8217;t this built in?)</li>
<li>Want applications to actually exit when you tap in the upper
right?  Want to easily switch between running applications?
You need Spb Pocket Plus.  $25.  (There may be cheaper/free
fixes for this too.)</li>
<li>Pocket IE (PIE) is supposedly deficient sometimes.  Maybe you
want <a href="http://www.opera.com/buy/?show=mobile" >Opera Mobile</a>:
$24. I don&#8217;t see much point in Opera, myself, except maybe
that it works in a couple places where PIE doesn&#8217;t.  (PIE
seems pretty peppy to me.) What you really <em>need</em>, though, is
<a href="http://www.picsel.com/index.php/solutions/view/C11/" >Picsel
Browser</a>,
a browser that&#8217;s actually useful for reading whole pages.  I&#8217;d
give you a price, but I don&#8217;t even think you can buy this; I
think this is a browser made available to OEMs, like Samsung,
to ship on their phones.  (Note: Microsoft does have
<a href="http://labs.live.com/deepfish/" >Deepfish</a> in the pipeline, I
guess.  But you and I can&#8217;t use it right now, so who cares?)</li>
<li>You&#8217;re going to run out of hardware buttons, so you&#8217;re going
to need (AE Button Plus)[http://ae.inc.ru/aebplusbuy.php],
which I haven&#8217;t actually tried yet.  $7.</li>
</ul>
</li>
<li>I&#8217;ve soft reset the device several times.  Powering on and off is
sometimes a crap shoot: I press the power button, wait for a bit
to see if it turns on.  Oh, it didn&#8217;t, I hit it again.  Whoops,
maybe it was turning on slowly, because now it turned back off.
My v710 was rebooting somewhat frequently before I got this phone,
probably because I tended to be pretty rough with it (for example,
I once tried to close a car door on it), but it still rebooted
faster than this phone.  I&#8217;ve had applications here and there seem
to lock up too.  (And did I mention the device is kind of slow?)</li>
<li>This may not be valid, but so far battery life seems kind of poor,
compared to regular phone.  I set it not to turn off automatically
when on battery yesterday and I was in extreme low battery warning
territory by the time I went to bed.  If you set the phone not to
turn off automatically, the good news is that the phone &#8220;turns on&#8221;
[the backlight] rather rapidly; the bad news is that your battery
won&#8217;t last.  If you set it to turn off automatically, you have
that painful delay to turn it back on.</li>
<li>Dialing on screen kind of sucks.</li>
<li>The speaker does not strike me as sounding very good at all, nor
very loud.  Turning it all the way up just makes sound go all to
shit, whether using it as a speakerphone or for the OS sounds.</li>
<li>When using BT, the incoming voice is not very loud at all, and I
can&#8217;t see to turn it up.</li>
<li>What is probably the last straw: when I lock the phone (by the
way, sane locking&#8212;i.e., from a hardware button&#8212;seems to
require third-party software) the &#8220;end call&#8221; button still ends the
call.  So I pop on my BT headset, start a call, lock the phone,
stuff it into my holster, and I just hung up on the other person.
I seem to do this with 100% accuracy.  Yesterday I was on the
phone with my dad.  As I was getting out of the car, I said to
him, &#8220;Yeah, I just got this new phone.&#8221; I then slid the phone into
the holster and then we were disconnected.  Perfect.</li>
<li>The screen is kind of small, and hard to browse with, frankly.
(What are you going to do?  It&#8217;s a phone, it still needs to be
small enough to be practical.  I don&#8217;t want to hold an 8&#8221; LCD up
to the side of my head.)</li>
<li>No Bluetooth 2.0 EDR, so tethering with BT is supposedly pretty
slow, especially relative to tethering with USB.  (Again, I
haven&#8217;t tried this.) In its defense, almost nothing has BT 2.0,
and I think the only Verizon device that <em>might</em> have EDR is a
Blackberry.</li>
<li>(Added) Sometimes the backlight goes to zero.  For example, I&#8217;ll
be trying to turn the phone on (see previous comments about how it
doesn&#8217;t always seem to work, or work quickly at least) and somehow
I&#8217;ll manage to turn the backlight off totally, and it won&#8217;t come
back on until I find a decent light source where I can use the
stylus to navigate to the backlight control panel and turn it up.
(Why is there a backlight setting that has the backlight turn all
the way off in the first place?  Is that something people want,
for the backlight to never be on?)</li>
</ol><p>Now, there are two things to note about the way I&#8217;m trying to use this
device that might lead some people to consider it &#8220;unfair&#8221;:</p>

<ol>
<li>I don&#8217;t use Exchange.  I&#8217;m not even sure I want e-mail on my
phone; it&#8217;s not set up right now on this 6700.  I hear that this
phone&#8217;s Exchange integration is the bee&#8217;s knees, if you&#8217;re in to
that kind of thing.  So maybe I&#8217;m missing a big piece of what
makes this phone so awesome for other people.</li>
<li>It&#8217;s a <em>phone</em>.  At least, I <em>think</em> it&#8217;s supposed to be used as a
phone.  As a PDA, it might be alright.  As a mobile browsing
device (as long as you get your hands on some things like Live
Search and Picsel Browser) it&#8217;s not bad.  But I want a <em>phone</em>,
and for that I think this device isn&#8217;t very good at all.
(Seriously, why not lock the hard buttons!  Totally unacceptable.)
Part of this is due to physical considerations (i.e. hard button
for numbers on the front) and some is software (no notifications
of unread text messages). All the comparisons to my v710 are due
to this fact: I wanted a <em>phone</em> that also has a good browser and
fast Internet access, not a PDA that happens to occasionally make
calls.</li>
</ol><p>I don&#8217;t really want to convince people that love these HTC phones and
Windows Mobile that their phone sucks.  If you like it, and you can
use it, that&#8217;s great for you.  There are even more features this phone
phone has that I didn&#8217;t mention and don&#8217;t take advantage of, perhaps;
playing MP3s or gaming comes to mind.</p>

<p>For my tastes, though, I think the XV-6700 is going back in favor of a
simple, fast, reliable, usable <em>phone</em>.  Probably a Motorola, since
I&#8217;m used to the interface (<strong>oh wait, Verizon fucked that up!</strong>), or
maybe one of the LG models.  (I probably need to stick with Verizon,
at least for now.) For mobile browsing I think I&#8217;m going to be happier
with something like an <a href="http://web.nseries.com/products/n800/" >N800</a>
running Linux kept in my bag, and maybe something insane like a
<a href="http://www.frogpad.com/" >FrogPad</a> for more serious typing.  Then I
can tether it to&#8230; a <em>dumbphone</em>.</p>
]]></content:encoded>
			<wfw:commentRss>http://darkness.codefu.org/wordpress/2007/08/13/284/feed</wfw:commentRss>
		</item>
	</channel>
</rss>
