<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
	>

<channel>
	<title>Of white hats and black hats</title>
	<atom:link href="http://blogs.operationaldynamics.com/paul/feed" rel="self" type="application/rss+xml" />
	<link>http://blogs.operationaldynamics.com/paul</link>
	<description>May the Funk be with you.</description>
	<lastBuildDate>Wed, 02 May 2012 15:21:00 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.3.2</generator>
		<item>
		<title>DDRescue Survival Mode</title>
		<link>http://blogs.operationaldynamics.com/paul/disaster-recovery/ddrescue-survival-mode</link>
		<comments>http://blogs.operationaldynamics.com/paul/disaster-recovery/ddrescue-survival-mode#comments</comments>
		<pubDate>Fri, 23 Mar 2012 02:11:53 +0000</pubDate>
		<dc:creator>Paul Drain</dc:creator>
				<category><![CDATA[Disaster Recovery]]></category>

		<guid isPermaLink="false">http://blogs.operationaldynamics.com/paul/?p=106</guid>
		<description><![CDATA[note: This post is more for my own future reference than anything else, but I figure it might help others out in a jam, so i&#8217;d post it here &#8212; Paul. Recently, I was asked to attempt to recover an NTFS based drive that had developed &#8220;Click Of Death&#8221; &#8212; in a laptop that moves [...]]]></description>
			<content:encoded><![CDATA[<p><em>note:</em> This post is more for my own future reference than anything else, but I figure it might help others out in a jam, so i&#8217;d post it here &#8212; Paul.</p>

<p>Recently, I was asked to attempt to recover an NTFS based drive that had developed &#8220;Click Of Death&#8221; &#8212; in a laptop that moves around a bit, such a thing is not uncommon, but I always forget the lines that <strong>ddrescue</strong> that work &#8216;most reliably&#8217; for me when i&#8217;m on a remote machine, so i&#8217;m documenting them for completeness.</p>

<p>Firstly, back up the MBR / Partition Table (really, really useful on NTFS based machines that fail)</p>

<pre><code>dd if=/dev/sdX of=/media/working-drive/mbr.code bs=512 count=1
</code></pre>

<p>Then, presuming the destination drive is as, or is larger than the source one, run:</p>

<pre><code>ddrescue --no-split /dev/sdX /media/working-drive/backup_cdrive.img  /media/working-drive/backup_cdrive.log 

ddrescue --direct --preallocate --max-retries=9 /dev/sdX /media/working-drive/backup_cdrive.img  /media/working-drive/backup_cdrive.log

ddrescue --direct --preallocate --retrim --max-retries=9 /dev/sdX /media/working-drive/backup_cdrive.img  /media/working-drive/backup_cdrive.log
</code></pre>

<p>Then, when you&#8217;ve checked your images for bugs with a tool like &#8216;testdisk&#8217; or&#8217;sectrecover&#8217; or any commerical based one you may have on hand, the recovery process is:</p>

<ol>
    <li>Partition the new drive.</li>
    <li><em>Restore Images</em></li>
    <li>Run:    dd if=/media/working-drive/mbr.code of=/dev/sdY bs=446 count=1</li>
</ol>

<p><em>&#8220;Restore Images&#8221;</em> in this case, can be:</p>

<ol>
    <li>something physical, like: e2fsck -f /media/working-drive/backup_cdrive.img &#038;&#038; dd if=/media/working-drive/backup_cdrive.img of=/dev/sdY[1-100]</li>
    <li>or, something virtual, like: e2fsck -f /media/working-drive/backup_cdrive.img &#038;&#038; VBoxManage convertfromraw backup_cdrive.img backup_cdrive.vdi &#8211;format VDI</li>
</ol>

<p>(and, for those wondering &#8212; the <em>446</em> byte copy is due to the fact the new drive is probably <strong>not</strong> the same as the old one, so we&#8217;ll do the partitioning manually and only recover the MBR code, not the whole lot &#8212; which is a <strong><em>446</em> byte MBR</strong>, a <strong><em>64</em> byte partition table</strong> and a <strong><em>2</em> byte signature block</strong>.)</p>
]]></content:encoded>
			<wfw:commentRss>http://blogs.operationaldynamics.com/paul/disaster-recovery/ddrescue-survival-mode/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>HTML Formatting, Blockquotes, Paragraphs &amp; You</title>
		<link>http://blogs.operationaldynamics.com/paul/web-technologies/html-formatting-blockquotes-paragraphs-you</link>
		<comments>http://blogs.operationaldynamics.com/paul/web-technologies/html-formatting-blockquotes-paragraphs-you#comments</comments>
		<pubDate>Sun, 26 Feb 2012 14:10:02 +0000</pubDate>
		<dc:creator>Paul Drain</dc:creator>
				<category><![CDATA[Web Technologies]]></category>

		<guid isPermaLink="false">http://blogs.operationaldynamics.com/paul/?p=92</guid>
		<description><![CDATA[Since i&#8217;ve been blogging here, one thing has continually frustrated me about the WordPress interface &#8212; the fact blockquotes and code tags in the editor will always, automatically put a br tag in, making formatting code, HTML fragments and other configuration examples rather annoying to post. So, I went looking for a solution &#8212; as [...]]]></description>
			<content:encoded><![CDATA[<p>Since i&#8217;ve been blogging here, one thing has continually frustrated me about the WordPress interface &#8212; the fact <em>blockquotes</em> and <em>code</em> tags in the editor will always, automatically put a <em>br</em> tag in, making formatting code, HTML fragments and other configuration examples rather annoying to post.</p>

<p>So, I went looking for a solution &#8212; as most of my posts here will have <em>code</em> examples <img src='http://blogs.operationaldynamics.com/paul/wp-includes/images/smilies/icon_smile.gif' alt=':)' class='wp-smiley' /> </p>

<p>As it turns out, the <a href="https://codex.wordpress.org/Function_Reference/wpautop" target="_blank">WordPress Codex for wpautop()</a> already has the ability to turn off the function that does this as part of it&#8217;s design &#8212; and because I didn&#8217;t want to get rid of the function altogether, it was easier to craft my own.</p>

<p>So, in <strong>functions.php</strong> &#8212; it&#8217;s a case of:</p>

<ol>
    <li>Removing the existing filter.</li>
    <li>Adding our own filter that returns &#8216;<strong>false</strong>&#8216; for the <em>$br</em> portion.</li>
    <li>Adding our new filter.</li>
</ol>

<p>Which looks like:</p>

<pre><code>remove_filter( 'the_content', 'wpautop' );
remove_filter( 'the_excerpt', 'wpautop' );

function wpautop_fixed($str) {
 return wpautop($str, false);
}

add_filter( 'the_content', 'wpautop_fixed' );
add_filter( 'the_excerpt', 'wpautop_fixed' );
</code></pre>

<p>Problem solved, <em>code</em> lines don&#8217;t break anymore &#8212; and the amount of extra HTML I have to add to get the standard editor (or indeed, the uber-cool <a href="https://wordpress.org/extend/plugins/markdown-on-save-improved/" target="_blank">Markdown on Save Improved</a> plugin we use here) is minimised.</p>
]]></content:encoded>
			<wfw:commentRss>http://blogs.operationaldynamics.com/paul/web-technologies/html-formatting-blockquotes-paragraphs-you/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Evolution, Databases, Grief.</title>
		<link>http://blogs.operationaldynamics.com/paul/opensource/evolution-databases-grief</link>
		<comments>http://blogs.operationaldynamics.com/paul/opensource/evolution-databases-grief#comments</comments>
		<pubDate>Sat, 11 Feb 2012 13:18:56 +0000</pubDate>
		<dc:creator>Paul Drain</dc:creator>
				<category><![CDATA[Disaster Recovery]]></category>
		<category><![CDATA[Open Source]]></category>

		<guid isPermaLink="false">http://blogs.operationaldynamics.com/paul/?p=86</guid>
		<description><![CDATA[Recently, Evolution on my Ubuntu Oneiric Desktop popped up with a dialogue stating: Database Disk Image Is Malformed Which caused it to not index anything in any of the folders I had listed in my IMAP setup &#8212; restarting, using evolution &#8211;force-shutdown and various other solutions found on the interschnitzel had no effect, however &#8212; [...]]]></description>
			<content:encoded><![CDATA[<p>Recently, Evolution on my Ubuntu Oneiric Desktop popped up with a dialogue stating:</p>

<p><em><strong>Database Disk Image Is Malformed</strong></em></p>

<p>Which caused it to not index anything in any of the folders I had listed in my IMAP setup &#8212; restarting, using <strong>evolution &#8211;force-shutdown</strong> and various other solutions found on the interschnitzel had no effect, however &#8212; a slightly modified version of <a href="http://aslakjohansen.wordpress.com/2009/09/06/evolution-unable-to-generate-folder-list/" title="Aslak Johansen's 2009 Blog Post on the Subject" target="_blank">this page</a> worked a treat.</p>

<p>Slightly modified, as Evolution 3.x and beyond on Ubuntu use <em>~/.local/share/evolution/mail</em> for their mail storage &#8212; so the correct sequence of events to fix this problem became:</p>

<pre><code>sudo apt-get -f install sqlite3
</code></pre>

<p>Then:</p>

<pre><code>cd ~/.local/share/evolution/mail
for i in `find . -name folders.db`; do 
echo "Rebuilding Table $i"; 
sqlite3 $i "pragma integrity_check;"; 
done
</code></pre>

<p>Which turned:</p>

<blockquote>
<p>Rebuilding Table ./imap/paul@recovered-mail/folders.db</p>
<p>*** in database main ***</p>
<p>On tree page 11 cell 0: 2nd reference to page 173</p>
<p>On tree page 11 cell 1: 2nd reference to page 174</p>
<p>On tree page 11 cell 2: 2nd reference to page 450</p>
<p>On tree page 11 cell 3: 2nd reference to page 711</p>
<p>On tree page 11 cell 4: 2nd reference to page 924</p>
<p>On tree page 1060 cell 0: 2nd reference to page 805</p>
<p>On tree page 1060 cell 1: 2nd reference to page 849</p>
<p>On tree page 1060 cell 2: 2nd reference to page 921</p>
<p>On tree page 1060 cell 3: 2nd reference to page 851</p>
<p>On tree page 1060 cell 4: 2nd reference to page 911</p>
<p>On tree page 1060 cell 5: 2nd reference to page 850</p>
<p>On tree page 1060 cell 6: 2nd reference to page 848</p>
<p>Page 1067: btreeInitPage() returns error code 7</p>
<p>Page 1069: btreeInitPage() returns error code 11</p>
<p>Error: database disk image is malformed</p>
</blockquote>

<p>Into:</p>

<blockquote>
<p>Rebuilding Table ./imap/paul@recovered-mail/folders.db</p>
<p>ok</p>
</blockquote>

<p>Of course, one needs to make sure the databases aren&#8217;t being used at the time &#8212; and, at least under Oneiric, <strong>evolution &#8211;force-shutdown</strong> tends to be a bit strange, so you might need to manually kill processes such as the <strong>evolution-alarm-notifier</strong> before starting this process.</p>
]]></content:encoded>
			<wfw:commentRss>http://blogs.operationaldynamics.com/paul/opensource/evolution-databases-grief/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Upstream, Downstream and &#8230; What is it exactly?</title>
		<link>http://blogs.operationaldynamics.com/paul/opensource/upstream-downstream-and-what-is-it-exactly</link>
		<comments>http://blogs.operationaldynamics.com/paul/opensource/upstream-downstream-and-what-is-it-exactly#comments</comments>
		<pubDate>Thu, 20 Oct 2011 18:08:37 +0000</pubDate>
		<dc:creator>Paul Drain</dc:creator>
				<category><![CDATA[Open Source]]></category>

		<guid isPermaLink="false">http://blogs.operationaldynamics.com/paul/?p=53</guid>
		<description><![CDATA[Talking with Peter the other evening about kernel development teams (if you&#8217;ve been following along here throughout October, you&#8217;ll see that&#8217;s been the bulk of my month.) &#8212; we wondered: &#8220;What is it called when you&#8217;re doing your [kernel] development outside of any sanctioned tree, but other developers with the same vein/idea are *also* taking [...]]]></description>
			<content:encoded><![CDATA[<p>Talking with <a href="http://blogs.operationaldynamics.com/pmiller/" title="Peter Miller's Operational Dynamics Blog" target="_blank">Peter</a> the other evening about kernel development teams (if you&#8217;ve been following along here throughout October, you&#8217;ll see that&#8217;s been the bulk of my month.) &#8212; we wondered:</p>

<h4>
&#8220;What is it called when you&#8217;re doing your [kernel] development outside of any sanctioned tree, but other developers with the same vein/idea are *also* taking ideas / code from your tree?&#8221;
</h4>

<p>In the Linux world, that&#8217;s not mainline &#8212; because that&#8217;s Linus&#8217;s domain &#8212; and, in the Google Android case, <em>Android != Mainline</em>, so it&#8217;s not Android / Google either.</p>

<p>Indeed, it&#8217;s not &#8220;upstream&#8221; either &#8212; as we&#8217;ve seen, Google often does <em>not</em> have changes that are done in external trees &#8212; there&#8217;s a reason there&#8217;s a Qualcomm tree exists that specific vendors pull chipset changes from, for example.</p>

<p>It&#8217;s not &#8220;downstream&#8221; in that same vein &#8212; as individual products commonly have either differing hardware, or differing versions of the same code on a device-by-device basis.</p>

<p>So, the two of us got onto something else &#8212; and I suddenly thought:</p>

<h3>Sidestream</h3>

<p>and Peter &amp; I mulled it over for a few sentences and thought, yes, that&#8217;s more like it &#8212; after all, <em>Sidestream</em> infers:</p>

<p>Development done in parallel with versions upstream (Android Versions, in this case), but not <em>included</em> in upstream, not <em>cherry-picked</em> by upstream.</p>

<p><em>but also</em></p>

<p>Development used by downstream (Mobile Vendors, in this case) to provide updates and fixes to individual products &#8212; but changes to <em>those</em> files (by the vendors) are not necessarily sent back to either upstream or sidestream repositories.</p>

<p>Taking the Qualcomm example, changes are taken from there and cherry-picked into the ARM &#8220;mainline&#8221;, but new developments are used and tested there for a suitable amount of time before this happens.</p>

<p>Depending on when and if new Android kernel releases are frozen, the &#8220;upstream&#8221; code may not include these changes (for obvious reasons).</p>

<p>Vendors who require fixes for the frozen drivers in their &#8220;upstream&#8221; code, can then cherry-pick or take verbatim changes from the Qualcomm &#8220;sidestream&#8221; tree when required.</p>

<p>Thoughts? Could it catch on as a new buzzword for <em>external kernel</em> development? <img src='http://blogs.operationaldynamics.com/paul/wp-includes/images/smilies/icon_wink.gif' alt=';)' class='wp-smiley' /> </p>
]]></content:encoded>
			<wfw:commentRss>http://blogs.operationaldynamics.com/paul/opensource/upstream-downstream-and-what-is-it-exactly/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>The choice of a fix?</title>
		<link>http://blogs.operationaldynamics.com/paul/opensource/the-choice-of-a-fix</link>
		<comments>http://blogs.operationaldynamics.com/paul/opensource/the-choice-of-a-fix#comments</comments>
		<pubDate>Sun, 16 Oct 2011 14:31:12 +0000</pubDate>
		<dc:creator>Paul Drain</dc:creator>
				<category><![CDATA[Open Source]]></category>

		<guid isPermaLink="false">http://blogs.operationaldynamics.com/paul/?p=38</guid>
		<description><![CDATA[As any Open Source enthusiast knows, our ecosystem is built using layers &#8212; there&#8217;s the kernel, the platform then the application, each of these serve clearly different purposes and usually, parts at the bottom (the kernel) expose required parts of themselves to things further up the stack. This, of course provides different levels of tuning [...]]]></description>
			<content:encoded><![CDATA[<p>As any Open Source enthusiast knows, our ecosystem is built using layers &#8212; there&#8217;s the kernel, the platform then the application, each of these serve clearly different purposes and usually, parts at the bottom (the kernel) expose required parts of themselves to things further up the stack.</p>

<p>This, of course provides different levels of tuning and optimisation &#8212; kernels have the ability to use <code>/proc</code> or <code>sysfs</code> to allow userspace tuning &#8212; the GNOME platform has things like <code>dconf</code>, <code>gconf2</code> and <code>gsettings</code> to allow programs like <code>gnome-tweak-tool</code> to function for &#8220;power&#8221; users, as well as the standard control panel for &#8220;normal&#8221; users &#8212; and of course, individual programs have the ability to customise settings via use of the <em>Edit / Preferences</em> menu.</p>

<p>TCP/IP, as part of this ecosystem &#8212; is no exception. Of course, there are numerous examples of how to configure the TCP/IP stack, from <a href="http://proj.sunet.se/E2E/tcptune.html" title="SUNet's TCP Tuning Pages" target="_blank">academia</a>, <a href="http://www.psc.edu/networking/projects/tcptune/" title="Pittsburgh Supercomputing Center's TCP Tuning Site -- Recommended Reading!" target="_blank">research</a> <a href="http://fasterdata.es.net/fasterdata/host-tuning/linux/" title="Energy Services Network Tuning Pages" target="_blank">departments</a>, <a href="http://en.gentoo-wiki.com/wiki/TCP_Tuning" title="Gentoo Linux TCP Tuning Page" target="_blank">distributions</a>, <a href="https://www.ibm.com/developerworks/linux/library/l-hisock/index.html" title="IBM's TCP/IP DeveloperWorks Pages" target="_blank">systems integrators</a> and <a href="https://gettys.wordpress.com/2011/01/28/bufferbloat-talk-bufferbloat-net-is-up/" title="Jim Gettys Personal Blog on Bufferbloat, an up-and-coming TCP performance issue." target="_blank">individuals</a>. Most, if not all of these pages discuss using the <code>sysctl</code> program to control the <code>/proc</code> infrastructure in order to make changes to the TCP/IP stack &#8212; this is the <em>way it should be</em>.</p>

<p>All of this, is a long-winded lead-in to a seemingly innocuous issue I discovered while working with one of our teams on some mobile kernel analysis work recently &#8212; and following my <a href="http://blogs.operationaldynamics.com/paul/opensource/a-tale-of-two-mobile-device-ttys" title="A tale of two mobile device TTYs." target="_blank">last post</a> here, made me wonder:</p>

<p><em>Why?</em></p>

<p>When looking at an <sup> <em>n</em> <em>x</em> <em>k</em> <em>x</em> <em>t</em> </sup> space when comparing kernels, one-line changes which occur in a single tree usually stand out like a &#8220;<em>deer in the headlights</em>&#8221; and this one typified the sort of question we all eventually had in the end.</p>

<p>Consider:</p>

<p><code>
<pre>
<code>--- a/net/ipv4/tcp_output.c      2011-10-04 00:00:00.000000000 +0000</code>
<code>+++ b/net/ipv4/tcp_output.c      2011-03-25 00:00:00.000000000 +0000</code>
<code>@@ -243,6 +243,8 @@ void tcp_select_initial_window(int __spa</code>
<code>else if (*rcv_wnd &amp;gt; init_cwnd * mss)</code>
<code>*rcv_wnd = init_cwnd * mss;</code>
<code>}</code>
<code>+        /* Lock the initial TCP window size to 64K*/</code>
<code>+        *rcv_wnd = 64240;</code>
<code></code>
<code>/* Set the clamp no higher than max representable value */</code>
<code>(*window_clamp) = min(65535U &amp;lt;&amp;lt; (*rcv_wscale), *window_clamp);</code>
</pre>
</code></p>

<p>Once again, <em>Why?</em></p>

<p>Especially when:</p>

<p><code>/sbin/sysctl -w net.ipv4.tcp_rmem = 64240 64240 [MAX]</code></p>

<p>and:</p>

<p><code>/sbin/sysctl -w net.ipv4.tcp_wmem = 64240 64240 [MAX]</code></p>

<p>(Where <code>tcp_{r/w}mem</code> takes the <em>minimum</em>, <em>default</em> and <em>maximum</em> values respectively.)</p>

<p>From userspace (for example, in the <code>init.rc</code> file) or from patching the Android <code>sysctl.conf</code> file &#8212; would have done the same thing the code above does <em>but</em> would have allowed tuning by product teams if required.</p>

<p>A <a href="http://daemonsolutions.com/mobile-internet-tcp-networking-considerations/" title="Daemon Internet's (UK) Page on TCP &amp; Mobile Technologies" target="_blank">good quote</a> I saw during the course of my investigations into the <em>Why</em> question, was:</p>

<blockquote>
There is an argument for not applying any optimisation to the TCP connection between a webserver and a mobile phone.

The features of a TCP connection can only be negotiated when the initial connection is established. If you move from an area with 3G reception to an area only offering 2.5G, or vice versa, the optimisations you may have done for the 3G connection may cause terrible performance on the 2.5G connection, due to the differences in the network characteristics.

Assuming that a connection will always be on the same type of network technology means that you could fall into the pitfall of premature optimisation.
</blockquote>

<p>Could such a fix have been done because the production team once again had an internal testing issue that was resolved by doing such a thing, was it a case of it being the easiest way of doing <a href="http://www.cscjournals.org/csc/manuscript/Journals/IJE/Volume2/Issue1/IJE-11.pdf" title="TCP Performance Measurement in GPRS Link Adaptation Process PDF Document" target="_blank" rel="nofollow">interoperation with <em>difficult</em> client operating systems</a> such as Windows XP, or was it done for another reason?</p>

<p>Indeed, it may have been done because often the kernel team in these situations is a <em>completely</em> different entity to those creating the platform &#8212; and asking the platform team to &#8216;<em>tweak</em>&#8216; these settings may have been more difficult than making a one-liner fix in the kernel.</p>

<p>Also, from viewing this one-line change, we do not know:</p>

<ul>
<li> If Selective Acknowledgment (SACK) was enabled as part of this vendors platform code? (Reading of most <abbr title="General packet radio service (GPRS)">GPRS</abbr> optimisation guides available on the web, including RFC <a href="https://tools.ietf.org/html/rfc3481" title="TCP over Second (2.5G) and Third (3G) Generation Wireless Networks (RFC 3481)" target="_blank">3481</a> suggest <em>it should be</em>). </li>
<li> If TCP/IP Window Scaling (RFC <a href="https://tools.ietf.org/html/rfc1323" target="_blank">1323</a>) was switched on and supported by default. </li> 
<li> If TCP ECN (RFC <a href="https://tools.ietf.org/html/rfc3168" target="_blank">3168</a>) was switched on and supported by default. </li>
<li> If the Cell Towers (that actually do the grunt of the work and are worldwide) as well as the intermediary networks that these particular devices exist on (which indeed, the vendor has <strong>no</strong> control over at all) have TCP/IP Header Compression (RFC <a href="https://tools.ietf.org/html/rfc1144" target="_blank">1144</a>) turned <strong>OFF</strong>. </li>
</ul> 

<p>as well as a number of other things about this device and it&#8217;s networking functionality.</p>

<p>The wrong part of the stack to &#8220;fix&#8221; this type of issue though, for sure &#8212; and we can tell that, not just because we&#8217;ve (that&#8217;s the Operational Dynamics &#8220;we&#8221; here) got experience with the way this type of thing <em>should</em> be fixed, but because from our <sup> <em>n</em> <em>x</em> <em>k</em> <em>x</em> <em>t</em> </sup> space equation from before, <em>no other team</em> (even within the same organisation) chose to fix their particular device the same way.</p>

<p>The more I look at it, the more I think the use of the <em><a href="https://secure.wikimedia.org/wikipedia/en/wiki/Think_aloud_protocol" title="Wikipedia's Page on the Think Aloud Protocol" target="_blank">Think-aloud Protocol</a></em> in &#8220;external&#8221; kernel development, would be an interesting thing to investigate.</p>
]]></content:encoded>
			<wfw:commentRss>http://blogs.operationaldynamics.com/paul/opensource/the-choice-of-a-fix/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>A tale of two mobile device TTYs.</title>
		<link>http://blogs.operationaldynamics.com/paul/opensource/a-tale-of-two-mobile-device-ttys</link>
		<comments>http://blogs.operationaldynamics.com/paul/opensource/a-tale-of-two-mobile-device-ttys#comments</comments>
		<pubDate>Wed, 12 Oct 2011 05:22:31 +0000</pubDate>
		<dc:creator>Paul Drain</dc:creator>
				<category><![CDATA[Open Source]]></category>
		<category><![CDATA[Security]]></category>

		<guid isPermaLink="false">http://blogs.operationaldynamics.com/paul/?p=30</guid>
		<description><![CDATA[Recently, i&#8217;ve been tinkering with mobile phone code &#8212; specifically Android-based mobile code, it&#8217;s had a dual purpose, but it&#8217;s also had an enlightening effect on exactly why homebrew mobile modding (such as the very well constructed Cyanogen mod) communities actually exist. One of the alterations I ran across while attempting to unbrick a friends [...]]]></description>
			<content:encoded><![CDATA[<p>Recently, i&#8217;ve been tinkering with mobile phone code &#8212; specifically Android-based mobile code, it&#8217;s had a dual purpose, but it&#8217;s also had an enlightening effect on exactly why homebrew mobile modding (such as the very well constructed <a href="http://www.cyanogenmod.com/" title="The Cyanogen Aftermarket Homebrew Firmware Code" target="_blank">Cyanogen</a> mod) communities actually exist.</p>

<p>One of the alterations I ran across while attempting to unbrick a friends HTC-based mobile phone (who, is <em>not</em> a technical person, but their warranty had expired and a failed &#8216;Software Upgrade&#8217; on a Win32 based workstation, which had caused their phone to cease being a phone) was very interesting.</p>

<p>Consider the following code from HTC&#8217;s own <code>htc_headset_mgr.c</code> file (~ line 775 depending on your Android Kernel Revision):</p>

<pre><code>static DEVICE_ACCESSORY_ATTR(tty, 0666, tty_flag_show, tty_flag_store);
</code></pre>

<p><code>htc_headset_mgr.c</code>, for want of a better description, is the manager code for such devices as a wired headset, the code it controls (specifically, <em>htc_headset.c</em>) does not set permissions for the sysfs files or device nodes it creates &#8212; so presumably, that&#8217;s what <em>this</em> code does.</p>

<p>It should be noted the case of world-writable sysfs in device code is hardly new, nor is HTC the only vendor with these types of issues and there&#8217;s <a href="http://lists.infradead.org/pipermail/linux-arm-kernel/2011-March/045863.html" title="Reference to such fixes on the ARM LKML" target="_blank">ongoing attempts</a> to try and fix this from members of the <a href="http://www.openwall.com/" title="The Openwall Project Homepage" target="_blank">Openwall</a> project and others, some more successfully than others &#8212; but with the gambit of drivers, some using <abbr title="Discretionary Access Control (DAC)">DAC</abbr>, some using <a href="http://www.cis.syr.edu/~wedu/seed/Labs/Capability_Exploration/" title="Syracuse University's Linux Capabilities Lab Page, featuring test cases, documentation and examples of Linux Capabilities handling." target="_blank">capabilities</a> and some using neither &#8212; that&#8217;s hardly surprising.</p>

<p>This driver is one that uses <em>neither</em>, presumably because it was written without consideration for ever appearing outside the HTC tree (ie. upstream) or because the developers didn&#8217;t consider capabilities being worth their time to implement.</p>

<p>Cyanogen, fix this with:</p>

<pre><code>static DEVICE_ACCESSORY_ATTR(tty, 0644, tty_flag_show, tty_flag_store);
</code></pre>

<p>Which fixes the obvious incorrectness, but the question remains:</p>

<p><em>Why?</em></p>

<ul>
<li>Why would the headset require rw+ access for the allocated TTY (and presumably, any other driver this management module pertains to) in the first place.</li>
<li>Why does a development team, potentially shipping millions of devices featuring this device worldwide *not* implement _basic_ capabilities handling, or, failing that &#8212; at least some form of DAC in their code.</li>
<li>Why does a homebrew modding community take the time to find and &#8220;fix&#8221; this.</li>
<li>Why does the upstream production team not apply these changes, after they&#8217;ve been found in the wild by another community.</li>
</ul>

<p>It may have been an oversight, it may have been a hack to get a testcase to pass internally that was never corrected, it may have just been a production team&#8217;s time-crunch deadline (every development team has those, after all) or it could be a lack of suitable training and information?</p>

<p>Still, it did make me wonder exactly which <em>other</em> drivers are being shipped with consumer electronics that have the same issues &#8212; and, if all this stuff is being done outside sanctioned upstream trees &#8212; the kind of issues those of us looking in from the outside are just &#8220;not privileged enough&#8221; to see.</p>
]]></content:encoded>
			<wfw:commentRss>http://blogs.operationaldynamics.com/paul/opensource/a-tale-of-two-mobile-device-ttys/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Headers, and Lions, and Tigers, and Explorers (oh my.)</title>
		<link>http://blogs.operationaldynamics.com/paul/opensource/headers-and-lions-and-tigers-and-explorers-oh-my</link>
		<comments>http://blogs.operationaldynamics.com/paul/opensource/headers-and-lions-and-tigers-and-explorers-oh-my#comments</comments>
		<pubDate>Tue, 27 Sep 2011 16:35:09 +0000</pubDate>
		<dc:creator>Paul Drain</dc:creator>
				<category><![CDATA[Open Source]]></category>
		<category><![CDATA[Web Technologies]]></category>

		<guid isPermaLink="false">http://blogs.operationaldynamics.com/paul/?p=15</guid>
		<description><![CDATA[It seems a lot of my time of late is spent debugging, testing and fixing web technologies &#8212; mostly from a security perspective, or a performance one &#8212; but, occasionally, it&#8217;s more involved helping our people fix issues at runtime in the wild. So, when a Redmine installation starts looking miserable from a site that [...]]]></description>
			<content:encoded><![CDATA[<p>It seems a lot of my time of late is spent debugging, testing and fixing web technologies &#8212; mostly from a security perspective, or a performance one &#8212; but, occasionally, it&#8217;s more involved helping our people fix issues at runtime in the wild.</p>

<p>So, when a Redmine installation starts looking miserable from a site that looks <em>bad</em> in Internet Explorer &#8212; and we debug it to the point we can suggestively point out it&#8217;s the &#8220;<em>Compatibility Mode</em>&#8221; of IE, how do we fix this?</p>

<p>&#8230; and moreover, how do <em>we</em> fix this! (without the client needing to edit code to add the oft-used <em>X-UA-Compatible</em> meta string everywhere, in other words.)</p>

<p>It&#8217;s not that it&#8217;s hard, in reality &#8212; it just requires a little thinking from left field <img src='http://blogs.operationaldynamics.com/paul/wp-includes/images/smilies/icon_wink.gif' alt=';)' class='wp-smiley' /> </p>

<p>Sites like StackOverflow have a <a href="http://stackoverflow.com/questions/831119/how-do-i-set-x-ua-compatible-header-to-ie-emulateie7-for-ie-8-browsers-using-apa" title="An example of setting mod_headers for this very issue at StackOverflow" target="_blank" rel="nofollow">few examples</a> on how to do this, but i&#8217;d like to suggest a better one which uses the <em>setenvif</em> and <em>headers</em> modules and a neat little tweak to make things &#8216;just work(tm)&#8217; on earlier browsers and is both <em>.htaccess</em> and vhost compatible.</p>

<p><code>
<pre>
&lt;IfModule mod&#95;setenvif.c&gt;
&lt;IfModule mod&#95;headers.c&gt;
BrowserMatch \bMSIE\s[89] good-versions
BrowserMatch \bMSIE\s[67] bad-versions
Header set X-UA-Compatible "IE=IE9,IE=8" env=good-versions
Header set X-UA-Compatible "IE=EmulateIE7,chrome=1" env=bad-versions
&lt;/IfModule&gt;
&lt;/IfModule&gt;
</pre>
</code></p>

<p>Which says:</p>

<ul>
    <li>The <strong>BrowserMatch</strong> lines match browser user-agent lines that use IE9 or IE8, followed by IE7 and IE6 respectively and applies the environment variable <em>good/bad</em>-versions to them respectively.</li>
    <li>The <em>X-UA-Compatible</em> header is <strong>set</strong>, then applied to those variables, with a degrading-based version numbering (ie. you apply from the highest supported version of IE to the lowest in that order.</li>
    <li>Finally, the <em>bad-versions</em> line also applies <a href="http://www.google.com/chromeframe" title="The Google Chrome Frame Homepage" target="_blank">Google Chrome Frame</a> to the end of it&#8217;s line, so browsers like IE6 are asked if they would like to use that, before your code resorts to browser-based CSS hacks and other IE-related workarounds.</li>
</ul>

<p>The list of X-UA-Compatible tags are <a href="http://msdn.microsoft.com/en-us/library/cc288325%28v=vs.85%29.aspx" title="The Microsoft MSDN on X-UA-Compatible metatags" target="_blank">listed here.</a></p>

<p>If you use support for IE 10 / Windows 8 Development Editions, feel free to add something like:</p>

<p><code>
<pre>
BrowserMatch \bMSIE10 new-versions
Header set X-UA-Compatible "IE=Edge" env=new-versions
</pre>
</code></p>

<p>To your Apache configuration / .htaccess file in the relevant spots &#8212; that should keep you covered for future versions of the code <img src='http://blogs.operationaldynamics.com/paul/wp-includes/images/smilies/icon_smile.gif' alt=':)' class='wp-smiley' /> </p>
]]></content:encoded>
			<wfw:commentRss>http://blogs.operationaldynamics.com/paul/opensource/headers-and-lions-and-tigers-and-explorers-oh-my/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>One Hosed Apache Configuration, One Little Fix.</title>
		<link>http://blogs.operationaldynamics.com/paul/opensource/one-hosed-apache-configuration-one-little-fix</link>
		<comments>http://blogs.operationaldynamics.com/paul/opensource/one-hosed-apache-configuration-one-little-fix#comments</comments>
		<pubDate>Tue, 20 Sep 2011 12:41:35 +0000</pubDate>
		<dc:creator>Paul Drain</dc:creator>
				<category><![CDATA[Open Source]]></category>
		<category><![CDATA[Web Technologies]]></category>

		<guid isPermaLink="false">http://blogs.operationaldynamics.com/paul/?p=12</guid>
		<description><![CDATA[note: This is mainly here so the next time something happens to my Apache Installation The other night, in the very, very, very early morning &#8212; one of the Apache servers I look after had a small issue with fsck and the /etc/apache2/modules-* directories became rather hosed. After pulling up all the backups and applying [...]]]></description>
			<content:encoded><![CDATA[<p><sup><strong>note:</strong> This is mainly here so the next time something happens to my Apache Installation <img src='http://blogs.operationaldynamics.com/paul/wp-includes/images/smilies/icon_smile.gif' alt=':)' class='wp-smiley' /> </sup></p>

<p>The other night, in the very, very, very early morning &#8212; one of the Apache servers I look after had a small issue with fsck and the /etc/apache2/modules-* directories became rather <em>hosed</em>.</p>

<p>After pulling up all the backups and applying the most recent web code, <strong>chmod</strong>&#8216;ing the results and firing a <strong>service apache restart</strong>, I received:</p>

<p><code>access to <em>client_directory</em> failed, reason: require directives present and no Authoritative handler</code></p>

<p>The solution:</p>

<p><code><strong>#</strong> a2enmod mod&#95;authz&#95;user</code></p>

<p>If, for some reason your installation doesn&#8217;t have the a2enmod software:</p>

<p><code><strong>#</strong> ln -s /etc/apache2/sites-available/authz&#95;user.load /etc/apache2/sites-enabled/authz&#95;user.load</code></p>

<p>Works equally as well.</p>
]]></content:encoded>
			<wfw:commentRss>http://blogs.operationaldynamics.com/paul/opensource/one-hosed-apache-configuration-one-little-fix/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Returning to the Matrix</title>
		<link>http://blogs.operationaldynamics.com/paul/unappropriated/back-in-the-matrix</link>
		<comments>http://blogs.operationaldynamics.com/paul/unappropriated/back-in-the-matrix#comments</comments>
		<pubDate>Sat, 10 Sep 2011 04:17:51 +0000</pubDate>
		<dc:creator>Paul Drain</dc:creator>
				<category><![CDATA[Nonsense and Disinformation]]></category>

		<guid isPermaLink="false">http://blogs.operationaldynamics.com/paul/?p=1</guid>
		<description><![CDATA[Returning from the blogging wilderness, Paul's blog has information on everything from security to lions and bears.]]></description>
			<content:encoded><![CDATA[<p>Making a return to blogging about goings-on for the first time since 2007 &#8212; one will see how effective this is, but given <a title="Andrew's Operational Dynamics Blog" href="/andrew/" target="_blank">Andrew</a> and <a title="Peter's Operational Dynamics Blog" href="/pmiller/" target="_blank">Peter</a> are already doing it, I thought it&#8217;d be a fine time to join the &#8220;<em>in crowd</em>&#8220;.</p>

<p>For anyone that doesn&#8217;t know, I am mainly interested / involved in Free &amp; Open Software hackery, hitting hardware with hammers and have a passion for gambling, snowboarding and other foolhardy exploits with my own health. <sup><strong>*</strong></sup></p>

<p>( [<sup><strong>*</strong></sup>] In Addition, It has been noted I may or may not actually be a real person and simply an enigma. )</p>
]]></content:encoded>
			<wfw:commentRss>http://blogs.operationaldynamics.com/paul/unappropriated/back-in-the-matrix/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>

