<?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>Matt's Musings</title>
	<atom:link href="http://www.mattb.net.nz/blog/feed/" rel="self" type="application/rss+xml" />
	<link>http://www.mattb.net.nz/blog</link>
	<description>Matt Browns thoughts on Life, Linux and lots of other things...</description>
	<lastBuildDate>Fri, 16 Mar 2012 23:08:27 +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>Kindle Reading Stats</title>
		<link>http://www.mattb.net.nz/blog/2012/03/17/kindle-reading-stats/</link>
		<comments>http://www.mattb.net.nz/blog/2012/03/17/kindle-reading-stats/#comments</comments>
		<pubDate>Fri, 16 Mar 2012 23:08:27 +0000</pubDate>
		<dc:creator>matt</dc:creator>
				<category><![CDATA[General]]></category>

		<guid isPermaLink="false">http://www.mattb.net.nz/blog/?p=156</guid>
		<description><![CDATA[I&#8217;ve written before about my initial investigations into the Kindle, and I&#8217;ve learnt much more about the software and how it communicates with the Amazon servers since then, but it all requires detailed technical explanation which I can never seem to find the motivation to write down. Extracting reading data out of the system log [...]]]></description>
			<content:encoded><![CDATA[<p>I&#8217;ve <a href="http://www.mattb.net.nz/blog/2010/12/07/under-the-cover-of-the-kindle-3/" title="Under the cover of the Kindle 3">written before</a> about my initial investigations into the Kindle, and I&#8217;ve learnt much more about the software and how it communicates with the Amazon servers since then, but it all requires detailed technical explanation which I can never seem to find the motivation to write down. Extracting reading data out of the system log files is however comparatively simple. </p>
<p>I&#8217;m a big fan of measurement and data so my motivation and goal for the Kindle log files was to see if I could extract some useful information about my Kindle use and reading patterns. In particular, I&#8217;m interested in tracking my pace of reading, and how much time I spend reading over time.</p>
<p>You&#8217;ll recall from the previous post that the Kindle keeps a fairly detailed syslog containing many events, including power state changes, and changes in the &#8220;Booklet&#8221; software system including opening and closing books and position information. You can eyeball any one of those logfiles and understand what is going on fairly quickly, so the analysis scripts are at the core just a set of regexps to extract the relevant lines and a small bit of logic to link them together and calculate time spent in each state/book.</p>
<p>You can find the scripts on Github: <a href="https://github.com/mattbnz/kindle-utils" title="https://github.com/mattbnz/kindle-utils" target="_blank">https://github.com/mattbnz/kindle-utils</a></p>
<p>Of course, they&#8217;re not quite that simple. The Kindle doesn&#8217;t seem to have a proper hardware clock (or mine has a broken hardware clock). My Kindle comes back from every reboot thinking it&#8217;s either at the epoch or somewhere in the middle of 2010, the time doesn&#8217;t get corrected until it can find a network connection and ping an Amazon server for an update, so if you have the network disabled it might be many days or weeks of reading before the system time is updated to reality. Once it has a network connection it uses the MCC reported by the 3G modem to infer what timezone it should be in, and switches the system clock to local time. Unfortunately the log entries all look like this:</p>
<p><code><br />
110703:193542 cvm[7908]: I TimezoneService:MCCChanged:mcc=310,old=GB,new=US:<br />
110703:193542 cvm[7908]: I TimezoneService:TimeZoneChange:offset=-25200,zone=America/Los_Angeles,country=US:<br />
110703:193542 cvm[7908]: I LipcService:EventArrived:source=com.lab126.wan,name=localTimeOffsetChanged,arg0=-25200,arg1=1309689302:<br />
110703:193542 cvm[7908]: I TimezoneService:LTOChanged:time=1309689302000,lto=-25200000:<br />
110703:183542 system: I wancontrol:pc:processing "pppstart"<br />
110703:193542 cvm[7908]: I LipcService:EventArrived:source=com.lab126.wan,name=dataStateChanged,arg0=2,arg1=<none>:<br />
110703:183542 cvm[7908]: I ConnectionService:LipcEventArrived:source=com.lab126.cmd,name=intfPropertiesChanged,arg0=</none><none>,arg1=wan:<br />
110703:183542 cvm[7908]: W ConnectionService:UnhandledLipcEvent:event=intfPropertiesChanged:<br />
110703:193542 wifid[2486]: I wmgr:event:handleWpasupNotify(&lt;2>CTRL-EVENT-DISCONNECTED), state=Searching:<br />
110703:113542 wifid[2486]: I spectator:conn-assoc-fail:t=374931.469106, bssid=00:00:00:00:00:00:<br />
110703:113542 wifid[2486]: I sysev:dispatch:code=Conn failed:<br />
110703:183542 cvm[7908]: I LipcService:EventArrived:source=com.lab126.wifid,name=cmConnectionFailed,arg0=Failed to connect to WiFi network,arg1=</none><none>:<br />
</none></code></p>
<p>Notice how there is no timezone information associated with the date/time information on each line. Worse still the different daemons are logging in at least 3 different timezones/DST offsets all interspersed within the same logfile. Argh!!</p>
<p>So our simple script that just extracts a few regexps and links them together nearly doubles in size to handle the various time and date convolutions that the logs present. Really, the world should just use UTC everywhere. Life would be so much simpler.</p>
<p>The end result is a script that spits out information like:<br />
<code><br />
B000FC1PJI: Quicksilver: Read  1 times. Last Finished: Fri Mar 16 18:30:57 2012<br />
 - Tue Feb 21 11:06:24 2012 => Fri Mar 16 18:30:57 2012. Reading time 19 hours, 29 mins (p9 => p914)</p>
<p>...</p>
<p>Read 51 books in total. 9 days, 2 hours, 29 mins of reading time<br />
</code></p>
<p>I haven&#8217;t got to the point of actually calculating reading pace yet, but the necessary data is all there and I find the overall reading time stats interesting enough for now.</p>
<p>If you have a jailbroken Kindle, I&#8217;d love for you to have a play and let me know what you think. You&#8217;ll probably find logs going back at least 2-3 weeks still on your Kindle to start with, and you can use the <code>fetch-logs</code> script to regularly pull them down to more permanent storage if you desire.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.mattb.net.nz/blog/2012/03/17/kindle-reading-stats/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>How I&#8217;m voting in 2011</title>
		<link>http://www.mattb.net.nz/blog/2011/11/24/how-im-voting-in-2011/</link>
		<comments>http://www.mattb.net.nz/blog/2011/11/24/how-im-voting-in-2011/#comments</comments>
		<pubDate>Thu, 24 Nov 2011 11:45:07 +0000</pubDate>
		<dc:creator>matt</dc:creator>
				<category><![CDATA[General]]></category>
		<category><![CDATA[Life]]></category>
		<category><![CDATA[WLUG / LinuxNZ]]></category>

		<guid isPermaLink="false">http://www.mattb.net.nz/blog/?p=145</guid>
		<description><![CDATA[It&#8217;s general election time again in New Zealand this year, with the added twist of an additional referendum on whether to keep MMP as our electoral system. If you&#8217;re not interested in New Zealand politics, then you should definitely skip the rest of this post. I&#8217;ve never understood why some people consider their voting choices [...]]]></description>
			<content:encoded><![CDATA[<p>It&#8217;s general election time again in New Zealand this year, with the added twist of an additional referendum on whether to keep MMP as our electoral system. If you&#8217;re not interested in New Zealand politics, then you should definitely skip the rest of this post.</p>
<p>I&#8217;ve never understood why some people consider their voting choices a matter of national security, so when via <a href="http://andrew.mcmillan.net.nz/blog/obligation_to_vote_2011" title="Andrew McMillan" target="_blank">Andrew McMillan</a>, I saw a <a href="http://morgue.isprettyawesome.com/?p=2615" title="reasonable rationale" target="_blank">good rationale</a> for why you should share your opinion I found my excuse to write this post.</p>
<p><strong>Party Vote</strong><br />
I&#8217;ll be voting for National. I&#8217;m philosophically much closer to National than Labour, particularly on economic and personal responsibility issues, but even if I wasn&#8217;t the thought of having Phil Goff as Prime Minister would be enough to put me off voting Labour. His early career seems strong, but lately it&#8217;s been one misstep and half-truth after another, the remainder of the Labour caucus and their likely support partners don&#8217;t offer much reassurance either. If I was left-leaning and the mess that Labour is in wasn&#8217;t enough to push me over to National this year then I&#8217;d vote Greens and hope they saw the light and decided to partner with National.</p>
<p><strong>Electorate Vote</strong><br />
I live in Dublin, but you stay registered in the last electorate where you resided, which for me is Tamaki. I have no idea who the candidates there are, so I&#8217;ll just be voting for the National candidate for the reasons above.</p>
<p><strong>MMP Referendum</strong><br />
I have no real objections to MMP and I think it&#8217;s done a good job of increasing representation in our parliament. I like that parties can bring in some star players without them having to spend time in an electorate. I don&#8217;t like the tendency towards unstable coalitions that our past MMP results have sometimes provided.</p>
<p>Of the alternatives, STV is the only one that I think should be seriously considered, FPP and it&#8217;s close cousin SM don&#8217;t give the proportionality of MMP and PV just seems like a simplified version of STV with limited other benefit. If you&#8217;re going to do preferential voting, you might as well do it properly and use STV.</p>
<p>So, I&#8217;ll vote for a change to STV, not because I&#8217;m convinced that MMP is wrong, but because I think it doesn&#8217;t hurt for the country to spend a bit more time and energy confirming that we have the right electoral system. If the referendum succeeds and we get another referendum between MMP and something other than STV in 2014, I&#8217;ll vote to keep MMP. If we have a vote between MMP and STV in 2014 I&#8217;m not yet sure how I&#8217;d vote. STV is arguably an excellent system, but I worry that it&#8217;s too complex for most voters to understand.</p>
<p>PS. Just found this handy list of 10 positive reasons to vote for National, if you&#8217;re still undecided and need a further nudge. <a href="http://www.kiwiblog.co.nz/2011/11/10_positive_reasons_to_vote_national.html" title="http://www.kiwiblog.co.nz/2011/11/10_positive_reasons_to_vote_national.html" target="_blank">Kiwiblog: 10 positive reasons to vote National</a></p>
]]></content:encoded>
			<wfw:commentRss>http://www.mattb.net.nz/blog/2011/11/24/how-im-voting-in-2011/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Using StartCom Free SSL certificates with Cyrus imapd</title>
		<link>http://www.mattb.net.nz/blog/2011/06/13/using-startcom-free-ssl-certificates-with-cyrus-imapd/</link>
		<comments>http://www.mattb.net.nz/blog/2011/06/13/using-startcom-free-ssl-certificates-with-cyrus-imapd/#comments</comments>
		<pubDate>Sun, 12 Jun 2011 21:12:13 +0000</pubDate>
		<dc:creator>matt</dc:creator>
				<category><![CDATA[Linux]]></category>

		<guid isPermaLink="false">http://www.mattb.net.nz/blog/?p=140</guid>
		<description><![CDATA[A stumbled across Start Com a few months ago, an Israeli company that run a Certificate Authority (CA) called StartSSL with a root certificate in all the modern browsers and operating systems. Best of all they don&#8217;t participate in the cartel run by the rest of the SSL certificate industry and offer domain validated certificates [...]]]></description>
			<content:encoded><![CDATA[<p>A stumbled across <a href="http://www.startcom.org/">Start Com</a> a few months ago, an Israeli company that run a Certificate Authority (CA) called <a href="https://www.startssl.com/">StartSSL</a> with a root certificate in all the modern browsers and operating systems. Best of all they don&#8217;t participate in the cartel run by the rest of the SSL certificate industry and offer domain validated certificates at the price it costs them to issue them &#8211; nothing.</p>
<p>I had the first opportunity to use their services today when I needed an SSL cert to secure the IMAP server I run for my parents and I was very pleased with the experience. The web interface is a bit weird and you have to jump through some strange hoops, but to save paying more money to the SSL certificate cartel it seemed more than worthwhile.</p>
<p>Like most CAs these days the certificate which signs your server certificate is not the actual root certificate included in your operating system or browser, but an intermediate CA certificate which is in turn signed by the root certificate. This means that you have to ensure that your server includes the intermediate CA certificate alongside the server certificate so the client can validate the entire path back to the root.</p>
<p>Unlike Apache which explicitly allows you to specify a certificate chain file, the openssl methods used by Cyrus 2.2 only seem to recognise a single CA certificate in the file pointed to by <code>tls_ca_file</code>. All as not lost however, as the openssl libraries are actually quite smart and will automagically determine which intermediate certs they need to bundle into the handshake if you install them appropriately under /etc/ssl/certs (at least on Debian).</p>
<p>The trick is that you have to install the intermediate CA cert into a file named after the hash of the certificate, like so:<br />
<code><br />
# wget http://www.startssl.com/certs/sub.class1.server.ca.pem -O /etc/ssl/certs/startcom-class1-intermediate.pem<br />
# hash=$(openssl x509 -hash -noout -in /etc/ssl/certs/startcom-class1-intermediate.pem)<br />
# ln -s ./startcom-class1-intermediate.pem /etc/ssl/certs/${hash}.0<br />
# ls -l /etc/ssl/certs/${hash}.0<br />
lrwxrwxrwx 1 root root 34 2011-06-13 07:43 /etc/ssl/certs/ea59305e.0 -> ./startcom-class1-intermediate.pem<br />
</code></p>
<p>Then in <code>imapd.conf</code>:<br />
<code><br />
tls_cert_file: /etc/ssl/certs/your-server-cert.pem<br />
tls_key_file: /etc/ssl/private/your-server-key.key<br />
tls_ca_file: /etc/ssl/certs/startcom-ca.pem<br />
</code></p>
<p>Voila. Works everywhere I&#8217;ve tried so far.</p>
<p>Start Com &#8211; Highly Recommended. I&#8217;ll be using them for any future SSL certificate purchases (e.g. EV certs) that I need to make.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.mattb.net.nz/blog/2011/06/13/using-startcom-free-ssl-certificates-with-cyrus-imapd/feed/</wfw:commentRss>
		<slash:comments>7</slash:comments>
		</item>
		<item>
		<title>Linux ignores IPv6 router advertisements when forwarding is enabled</title>
		<link>http://www.mattb.net.nz/blog/2011/05/12/linux-ignores-ipv6-router-advertisements-when-forwarding-is-enabled/</link>
		<comments>http://www.mattb.net.nz/blog/2011/05/12/linux-ignores-ipv6-router-advertisements-when-forwarding-is-enabled/#comments</comments>
		<pubDate>Wed, 11 May 2011 23:26:52 +0000</pubDate>
		<dc:creator>matt</dc:creator>
				<category><![CDATA[Linux]]></category>

		<guid isPermaLink="false">http://www.mattb.net.nz/blog/?p=128</guid>
		<description><![CDATA[IPv6 adoption is increasing, and along with it come a new set of behaviours and defaults that system administrators and users must learn and become familiar with. I was recently caught out by Linux&#8217;s handling of IPv6 router advertisements (RAs) when forwarding is also enabled on the interface. It took me a while to figure [...]]]></description>
			<content:encoded><![CDATA[<p>IPv6 adoption is increasing, and along with it come a new set of behaviours and defaults that system administrators and users must learn and become familiar with. I was recently caught out by Linux&#8217;s handling of IPv6 router advertisements (RAs) when forwarding is also enabled on the interface. It took me a while to figure out and searching for obvious terms (such as those in the first half of the title of this post) didn&#8217;t immediately yield useful answers, so here is my attempt to help shed some light on the subject.</p>
<p>By default Linux will ignore IPv6 RAs if the interface is configured to forward traffic. This is in line with <a href="http://tools.ietf.org/html/rfc2462">RFC2462</a> which states that a device should be either a Host or a Router. If you&#8217;re forwarding packets you&#8217;re a router and you&#8217;re therefore expected to be sending RAs, not receiving them. This policy does make a certain amount of sense but there are obviously situations where it can be useful to accept RAs and still forward packets over the interface[0]. The confusing part is that the Linux IPv6 stack allows the <code>accept_ra</code> sysctl to be set to 1 (enabled) at the same time as the <code>forwarding</code> sysctl is set to 1, yet all incoming RAs are ignored with no hint as to why. If you&#8217;re not aware that the default behaviour is to ignore RAs when forwarding is enabled it looks very much like autoconfiguration has simply broken.</p>
<p>The key piece of information is that makes everything as clear as mud is realising that the  <code>forwarding</code> and <code>accept_ra</code> sysctl&#8217;s are not simple boolean enabled/disabled flags like many of their brethren. There are instead three possible values for each, all clearly documented in <a href="http://www.kernel.org/doc/Documentation/networking/ip-sysctl.txt">sysctl.txt</a>, when you take the time to read it. Ironically the documentation states the type of the values as &#8220;BOOLEAN&#8221; even though they&#8217;re not&#8230; at least it helped me to feel better about my hasty assumption that the sysctl&#8217;s were boolean values.</p>
<blockquote><p>
accept_ra &#8211; BOOLEAN<br />
	Accept Router Advertisements; autoconfigure using them.</p>
<p>	Possible values are:<br />
		0 Do not accept Router Advertisements.<br />
		1 Accept Router Advertisements if forwarding is disabled.<br />
		2 Overrule forwarding behaviour. Accept Router Advertisements<br />
		  even if forwarding is enabled.</p>
<p>	Functional default: enabled if local forwarding is disabled.<br />
			    disabled if local forwarding is enabled.
</p></blockquote>
<p>The documentation for <code>forwarding</code> is similar, but much longer, so you can refer to the link above to see it.</p>
<p>Conclusion: If you want to autoconfigure IPv6 addresses on an interface that you&#8217;re also forwarding IPv6 traffic over, you need to set <code>accept_ra</code> to 2.</p>
<p>No doubt there are more IPv6 quirks and defaults like this waiting to trap me in the future <img src='http://www.mattb.net.nz/blog/wp-includes/images/smilies/icon_smile.gif' alt=':)' class='wp-smiley' /> </p>
<p>[0] Arguably you really don&#8217;t want to be autoconfiguring addresses on your router ever, but that&#8217;s a philosophical debate that isn&#8217;t really relevant to this post.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.mattb.net.nz/blog/2011/05/12/linux-ignores-ipv6-router-advertisements-when-forwarding-is-enabled/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>Under the cover of the Kindle 3</title>
		<link>http://www.mattb.net.nz/blog/2010/12/07/under-the-cover-of-the-kindle-3/</link>
		<comments>http://www.mattb.net.nz/blog/2010/12/07/under-the-cover-of-the-kindle-3/#comments</comments>
		<pubDate>Tue, 07 Dec 2010 00:52:50 +0000</pubDate>
		<dc:creator>matt</dc:creator>
				<category><![CDATA[Linux]]></category>

		<guid isPermaLink="false">http://www.mattb.net.nz/blog/?p=109</guid>
		<description><![CDATA[For my birthday back in October, my wonderful wife gave me a Kindle 3 from Amazon. I&#8217;d been considering other e-book readers for quite some time, but I had mostly ignored the Kindle due to the lack of EPUB support and a general dislike of Amazon&#8217;s DRM enforcement. In the end, the superior hardware and [...]]]></description>
			<content:encoded><![CDATA[<p>For my birthday back in October, my <a href="http://www.sweetsnstitches.com/">wonderful wife</a> gave me a <a href="http://www.amazon.com/Kindle-Wireless-Reading-Display-Generation/dp/B003FSUDM4">Kindle 3</a> from Amazon. I&#8217;d been considering other e-book readers for quite some time, but I had mostly ignored the Kindle due to the lack of EPUB support and a general dislike of Amazon&#8217;s DRM enforcement. In the end, the superior hardware and ecosystem of the Kindle overpowered those concerns and overall I&#8217;m very pleased with the purchase. The screen is amazing, literally just like reading off a piece of paper and the selection of books is OK. I&#8217;ve been buying almost all my books from Amazon to date since it&#8217;s so easy (the Whispernet is amazingly quick!) but it&#8217;s not terribly difficult to get EPUBs from elsewhere onto the device after a quick run through Calibre to turn them into a MOBI file, so I keep telling myself I&#8217;ve still got some flexibility.</p>
<p>Almost as much fun as reading on the device has been learning about how it works. The <a href="http://www.mobileread.com/forums/forumdisplay.php?f=140">Mobile Read forums</a> have lots of step by step posts on how to do specific tasks like replacing the screensaver image, but they don&#8217;t give much background detail on how the Kindle is actually operating which is what really interests me. Luckily among all the step by step posts I also found a &#8220;usbnetwork&#8221; package which also adds an SSH server to the Kindle, so after installing that and then SSHing in to my Kindle I&#8217;ve been poking around.</p>
<p>Under the cover the Kindle reveals a fairly standard Linux installation. While the hardware and IO devices are obviously unique, compared to something like an Android phone, the Kindle is refreshingly &#8220;normal&#8221;.</p>
<p><strong>Hardware</strong></p>
<ul>
<li>﻿Freescale MX35 ARMv6 based CPU with Java specific instruction support.</li>
<li>256MB RAM</li>
<li>4GB of internal flash presented as an SDHC device with four partitions. A ~700MB root partition, a ~30MB /var/local partition, another roughly 30MB kernel partition and then the rest (~3.1G) as the writeable &#8220;user&#8221; partition where your books and other content are stored. The root and /var/local partitions are ext3! (not jffs or some other more traditional flash based file system) while the user partition is vfat for easy use with Windows, etc.</li>
<li>The board is code-named &#8216;luigi&#8217; and there are lots of references to &#8216;mario&#8217; and &#8216;fiona&#8217; scattered around the device, and even in some URLs on Amazon&#8217;s website. Someone was obviously a Super Mario fan.</li>
<li>The wireless chipset is Atheros based using the ar6000 drivers.</li>
<li>The WAN (3G) modem presents itself as a USB serial device and is controlled via a custom daemon named &#8216;wand&#8217; which uses the standard Linux pppd package to establish IP connections over a private APN Amazon (provided by Vodafone here in Ireland).</li>
<li>The EInk display shows up as some special files under <code>/proc</code> rather than as a device. With a bit of digging I found some simple constants that when written to the proc files cause the screen to display the standard boot/progress/upgrading images. I haven&#8217;t deciphered how to make more complex updates to the display yet.</li>
</ul>
<p><strong>Software</strong></p>
<ul>
<li>The kernel is based on Linux 2.6.26, with a bunch of hardware specific patches and drivers from <a href="http://www.lab126.com">lab126.com</a>, an Amazon subsidiary who appear to be responsible for much of the low-level driver and device development.</li>
<li>Lots of familiar open source projects are present, e.g. syslog-ng, DBus, busybox, pppd, wpa_supplicant, gstreamer, pango, openssl and the list goes on. You can download all the sources from Amazon&#8217;s website. I haven&#8217;t spent any time to see what if anything has been modified.</li>
<li>There were a few unexpected finds as well such as GDB and powertop! No doubt useful for the developers, but highly unlikely to actually be used on a shipping Kindle.</li>
<li>Boot-up is controlled by a set of sysv style init scripts which setup the filesystems and then start a handful of daemons to look after the low-level subsystems (network, power, sound) as well as the standard syslog and cron daemons you&#8217;d expect to see on any Linux box.</li>
<li>Once the basic system is up and running the init scripts kick off the &#8220;framework&#8221; which lives under <code>/opt/amazon/ebook</code> and consists of lots of Java classes. The system uses the cvm Java environment from Sun/Oracle which is specialised for embedded low-memory devices like this. The framework appears to take over most of the co-ordination, management and interaction tasks once it has started up.</li>
</ul>
<p>The application/framework code is heavily obfuscated apparently using the <a href="http://www.allatori.com/">Allatori Java Obfuscator</a>. The <a href="http://adq.livejournal.com/107572.html">jrename</a> and <a href="http://java.decompiler.free.fr/">jd-gui</a> utilities have proven very handy in helping to untangle the puzzle, although they still only leave you with a pile of Java source code with mostly single letter alphabetic variable and class names! I&#8217;ve been using IntelliJ&#8217;s support for refactoring/renaming Java code to slowly work through it (thanks in large part to error/log messages and string constants found through the code which can&#8217;t be obfuscated easily and help to explain what is going on), and I&#8217;m slowly beginning to piece together how the book reading functionality works. I&#8217;ll maybe write more on this in a future post.</p>
<p>In one of my initial tweets about the Kindle I mentioned that it seemed to be regularly uploading syslog data to Amazon based on some <code>sendlogs</code> scripts I&#8217;d noticed and a few syslog lines containing GPS co-ordinates that had been pasted on the Mobile Read forums. I can&#8217;t find any trace of GPS co-ordinates in any syslog messages I&#8217;ve seen on my device, but there is definitely information about the cell sites that my Kindle can see, the books that I&#8217;m opening and where I&#8217;m up to in them:<br />
<code><br />
101206:235431 wand[2515]: I dtp:diag: t=4cfd77b7,MCC MNC=272 01,Channel=10762,Band=WCDMA I IMT 2000,Cell ID=1362209,LAC=3021,RAC=1<br />
,Network Time=0000/00/00 00.00.00,Local Time Offset=Not provided,Selection Mode=Automatic,Test Mode=0,Bars=4,Roaming=1,RSSI=-88,Tx<br />
 Power=6,System Mode=WCDMA,Data Service Mode=HSDPA,Service Status=Service,Reg Status=Success,Call Status=Conversation,MM Attach St<br />
ate=Attach accept,MM LU State=LU update,GMM Attach State=Attach accept,GMM State=Registered,GMM RAU State=Not available,PDP State=<br />
Active,Network Mode=CS PS separate attach mode,PMM Mode=Connected,SIM Status=Valid; PIN okay; R3,MM Attach Error=No error,MM LU Er<br />
ror=No error,GMM Attach Error=No error,GMM RAU Error=Not available,PDP Rej Reason=No error,Active/Monitored Sets=0;39;-11 1;180;-1<br />
5,RSCP=-111,DRX=64,HSDPA Status=Active,HSDPA Indication=HSDPA HSUPA unsupp,Neighbor Cells=,Best 6 Cells=,Pathloss=,MFRM=,EGPRS Ind<br />
ication=,HPLMN=,RPLMN=272;01 ,FPLMN=234;33  234;30  234;20  272;05 ,n=1:</p>
<p>101206:235758 cvm[3426]: I Reader:BOOK INFO:book asin=B003IWZZ3Y,file size=233168,file last mod date=2010-11-27 19.18.22 +0000,con<br />
tent type=ebook,length=MobiPosition_ 465747,access=2010-12-06 09.44.32 +0000,last read position=MobiPosition_ 464387,isEncrypted=f<br />
alse,isSample=false,isNew=false,isTTSMetdataPresent=false,isTTSMetadataAllowed=true,fileExtn=azw:</p>
<p>101206:233416 udhcpc[5639]: Offer from server xxx.xxx.2.254 received<br />
101206:233416 udhcpc[5639]: Sending select for xxx.xxx.2.10...<br />
</code></p>
<p>Interestingly you can see from the last two lines, that Amazon has taken some care to preserve privacy by not including the full IP address given to the device by my local Wifi network, so in light of that I find it interesting that they decided not to obfuscate the Cell and Book IDs in those respective log messages too. Seems rather inconsistent.</p>
<p>As to how and when these logs are sent to Amazon, the picture is a little bit murky. Every 15 minutes <code>tinyrot</code> runs out of cron and rotates <code>/var/log/messages</code> if it is greater than 256k in size. Rotated logs are stored into <code>/var/local/log</code> under filenames like <code>messages_00000044_20101207000006.gz</code> and alongside the log files are a set of state files named <code>nexttosendfile</code>, <code>messages_oldest</code>, <code>messages_youngest</code>. Something regularly sweeps through this directory to update the state and remove the old logs (after sending them up to Amazon I assume). I suspect that something is buried in the Java application code mentioned above.</p>
<p>On the whole the Kindle is a fascinating piece of technology. It delivers a wonderful reading experience on top of a familiar Linux system and is going to provide me with many more hours of entertainment as I unpack all the tricks and techniques that have gone into this device. I would recommended it as a present for geeks everywhere.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.mattb.net.nz/blog/2010/12/07/under-the-cover-of-the-kindle-3/feed/</wfw:commentRss>
		<slash:comments>4</slash:comments>
		</item>
	</channel>
</rss>

