<?xml version="1.0" encoding="utf-8"?>
<feed xmlns="http://www.w3.org/2005/Atom">

  <title><![CDATA[really tenacious guy]]></title>
  <link href="http://rtg.in.ua/atom.xml" rel="self"/>
  <link href="http://rtg.in.ua/"/>
  <updated>2012-02-22T15:25:48+02:00</updated>
  <id>http://rtg.in.ua/</id>
  <author>
    <name><![CDATA[Roman Yepishev]]></name>
    
  </author>
  <generator uri="http://octopress.org/">Octopress</generator>

  
  <entry>
    <title type="html"><![CDATA[Vala and DBus]]></title>
    <link href="http://rtg.in.ua/blog/2012/02/vala-and-dbus/"/>
    <updated>2012-02-22T11:39:00+02:00</updated>
    <id>http://rtg.in.ua/blog/2012/02/vala-and-dbus</id>
    <content type="html"><![CDATA[<p><img class="left" src="http://rtg.in.ua/assets/ubuntuone/1KneGMNdDYv7UGwFevbhSC/source.png">
Once in a while I return to the idea to write something in <a href="http://live.gnome.org/Vala/">Vala</a>. Vala&#8217;s
integration with Glib and Gnome is outstanding, you can write a useful DBus
client in 10 lines, compile and run at native code speed without any scripting
language interpreter overhead.</p>

<p><a href="https://one.ubuntu.com/">Ubuntu One</a> filesync service exports a ton of DBus methods that are then used
for the Control Panel, nautilus plugin, rhythmbox music store plugin and
others. All the communication between the clients and the service on Ubuntu
is based on DBus.</p>

<p>So, let&#8217;s make a client that asks syncdaemon for a list of all published
files and prints it out. Before we start, we need to find out what
methods and signals are actually exported.</p>

<!-- more -->


<p>Launch D-Feet and find <code>com.ubuntuone.SyncDaemon</code> bus name:</p>

<p><a href="http://rtg.in.ua/assets/ubuntuone/01KLyKEVpiryVP8Im5xb3n/d-feet-full.png"><img class="center" src="http://rtg.in.ua/assets/ubuntuone/1564WlIRkJuwLkK6n6cQxU/d-feet.png"></a></p>

<p>As you can see, there is a <code>get_public_files()</code> method which does not return
anything. We need to refer either to the documentation for the method in the
introspection XML data by invoking <code>Introspect()</code> method on
<code>org.freedesktop.DBus.Introspectable</code> interface, on the <a href="https://one.ubuntu.com/developer/files/store_files/ubuntu/#publicfiles-method-comubuntuonesyncdaemonpublicfilesget_public_files">developer website</a>
and if nothing else helps, grep the sources and look at the code.</p>

<p>In Ubuntu One case, Introspect() works:</p>

<figure class='code'><figcaption><span></span></figcaption><div class="highlight"><table><tr><td class="gutter"><pre class="line-numbers"><span class='line-number'>1</span>
<span class='line-number'>2</span>
<span class='line-number'>3</span>
<span class='line-number'>4</span>
<span class='line-number'>5</span>
<span class='line-number'>6</span>
<span class='line-number'>7</span>
<span class='line-number'>8</span>
<span class='line-number'>9</span>
<span class='line-number'>10</span>
<span class='line-number'>11</span>
<span class='line-number'>12</span>
<span class='line-number'>13</span>
<span class='line-number'>14</span>
<span class='line-number'>15</span>
<span class='line-number'>16</span>
<span class='line-number'>17</span>
<span class='line-number'>18</span>
<span class='line-number'>19</span>
</pre></td><td class='code'><pre><code class='xml'><span class='line'><span class="nt">&lt;node</span> <span class="na">name=</span><span class="s">&quot;/publicfiles&quot;</span><span class="nt">&gt;</span>
</span><span class='line'>  ...
</span><span class='line'>  <span class="nt">&lt;interface</span> <span class="na">name=</span><span class="s">&quot;com.ubuntuone.SyncDaemon.PublicFiles&quot;</span><span class="nt">&gt;</span>
</span><span class='line'>    <span class="nt">&lt;signal</span> <span class="na">name=</span><span class="s">&quot;PublicFilesListError&quot;</span><span class="nt">&gt;</span>
</span><span class='line'>      <span class="nt">&lt;docstring&gt;</span><span class="cp">&lt;![CDATA[Report an error in geting the public files list.]]&gt;</span><span class="nt">&lt;/docstring&gt;</span>
</span><span class='line'>      <span class="nt">&lt;arg</span> <span class="na">name=</span><span class="s">&quot;error&quot;</span> <span class="na">type=</span><span class="s">&quot;s&quot;</span> <span class="nt">/&gt;</span>
</span><span class='line'>    <span class="nt">&lt;/signal&gt;</span>
</span><span class='line'>    <span class="nt">&lt;signal</span> <span class="na">name=</span><span class="s">&quot;PublicFilesList&quot;</span><span class="nt">&gt;</span>
</span><span class='line'>      <span class="nt">&lt;docstring&gt;</span><span class="cp">&lt;![CDATA[Notify the list of public files.]]&gt;</span><span class="nt">&lt;/docstring&gt;</span>
</span><span class='line'>      <span class="nt">&lt;arg</span> <span class="na">name=</span><span class="s">&quot;files&quot;</span> <span class="na">type=</span><span class="s">&quot;aa{ss}&quot;</span> <span class="nt">/&gt;</span>
</span><span class='line'>    <span class="nt">&lt;/signal&gt;&lt;method</span> <span class="na">name=</span><span class="s">&quot;get_public_files&quot;</span><span class="nt">&gt;</span>
</span><span class='line'>    <span class="nt">&lt;docstring&gt;</span><span class="cp">&lt;![CDATA[Request the list of public files to the server.</span>
</span><span class='line'>
</span><span class='line'><span class="cp">        The result will be send in a PublicFilesList signal.</span>
</span><span class='line'><span class="cp">        ]]&gt;</span><span class="nt">&lt;/docstring&gt;</span>
</span><span class='line'>    <span class="nt">&lt;/method&gt;</span>
</span><span class='line'>  ...
</span><span class='line'>  <span class="nt">&lt;/interface&gt;</span>
</span><span class='line'><span class="nt">&lt;/node&gt;</span>
</span></code></pre></td></tr></table></div></figure>


<p>So, when we call <code>get_public_files()</code>, the &#8220;output&#8221; is sent back in
<code>PublicFilesList</code> signal. So far so good.</p>

<p>We start writing publicfiles.vala with <code>using</code> statements (as you may know,
Vala syntax is based on C#), which provide us with DBus functionality and
collection objects (such as HashTable). Also, we declare our DBus service.</p>

<figure class='code'><figcaption><span></span></figcaption><div class="highlight"><table><tr><td class="gutter"><pre class="line-numbers"><span class='line-number'>1</span>
<span class='line-number'>2</span>
<span class='line-number'>3</span>
<span class='line-number'>4</span>
<span class='line-number'>5</span>
<span class='line-number'>6</span>
<span class='line-number'>7</span>
<span class='line-number'>8</span>
<span class='line-number'>9</span>
<span class='line-number'>10</span>
<span class='line-number'>11</span>
<span class='line-number'>12</span>
<span class='line-number'>13</span>
<span class='line-number'>14</span>
<span class='line-number'>15</span>
</pre></td><td class='code'><pre><code class='c#'><span class='line'><span class="k">using</span> <span class="nn">GLib</span><span class="p">;</span>
</span><span class='line'><span class="k">using</span> <span class="nn">Gee</span><span class="p">;</span>
</span><span class='line'>
</span><span class='line'><span class="cm">/* Interface name */</span>
</span><span class='line'><span class="n">DBus</span> <span class="p">[(</span><span class="n">name</span> <span class="p">=</span> <span class="s">&quot;com.ubuntuone.SyncDaemon.PublicFiles&quot;</span><span class="p">)]</span>
</span><span class='line'><span class="k">interface</span> <span class="n">PublicFiles</span> <span class="p">:</span> <span class="n">Object</span> <span class="p">{</span>
</span><span class='line'>    <span class="cm">/* vala converts symbol_name to SymbolName for DBus symbols. This</span>
</span><span class='line'><span class="cm">     * preserves the name */</span>
</span><span class='line'><span class="na">    [DBus (name = &quot;get_public_files&quot;)]</span>
</span><span class='line'>    <span class="k">public</span> <span class="k">abstract</span> <span class="k">void</span> <span class="nf">get_public_files</span><span class="p">()</span> <span class="n">throws</span> <span class="n">IOError</span><span class="p">;</span>
</span><span class='line'>
</span><span class='line'>    <span class="cm">/* This is converted to PublicFilesList*/</span>
</span><span class='line'>    <span class="k">public</span> <span class="n">signal</span> <span class="k">void</span> <span class="nf">public_files_list</span> <span class="p">(</span><span class="n">HashTable</span><span class="p">&lt;</span><span class="kt">string</span><span class="p">,</span> <span class="kt">string</span><span class="p">&gt;[]</span>
</span><span class='line'>            <span class="n">files</span><span class="p">);</span>
</span><span class='line'><span class="p">}</span>
</span></code></pre></td></tr></table></div></figure>


<p>Since we are writing a client which needs to react to DBus signals, we need to
use glib mainloop and provide the handler for the signals we are expecting.</p>

<p>But first, how do I know what GObject types are mapped to what DBus types?</p>

<p>Look at the Introspect() output above, and notice that PublicFilesList
signature is <code>aa{ss}</code>. This translates to an &#8220;array of dict of string,string&#8221;.
Look at the <a href="http://live.gnome.org/Vala/DBusServerSample">DBusServerExample</a> to find out how types map. In our case,
<code>aa{ss}</code> is <code>HashTable&lt;string, string&gt;[]</code>. GObject does not support
deserialization of DBus dict to <code>HashMap</code>, you need to use <code>HashTable</code> for
that.</p>

<figure class='code'><figcaption><span></span></figcaption><div class="highlight"><table><tr><td class="gutter"><pre class="line-numbers"><span class='line-number'>1</span>
<span class='line-number'>2</span>
<span class='line-number'>3</span>
<span class='line-number'>4</span>
<span class='line-number'>5</span>
<span class='line-number'>6</span>
<span class='line-number'>7</span>
<span class='line-number'>8</span>
<span class='line-number'>9</span>
<span class='line-number'>10</span>
<span class='line-number'>11</span>
<span class='line-number'>12</span>
</pre></td><td class='code'><pre><code class='c#'><span class='line'><span class="n">MainLoop</span> <span class="n">loop</span><span class="p">;</span>
</span><span class='line'>
</span><span class='line'><span class="cm">/* Handler for PublicFilesList signal */</span>
</span><span class='line'><span class="k">void</span> <span class="nf">on_public_files_list</span><span class="p">(</span> <span class="n">HashTable</span><span class="p">&lt;</span><span class="kt">string</span><span class="p">,</span> <span class="kt">string</span><span class="p">&gt;[]</span> <span class="n">files</span><span class="p">)</span> <span class="p">{</span>
</span><span class='line'>    <span class="k">foreach</span> <span class="p">(</span><span class="n">var</span> <span class="n">file</span> <span class="k">in</span> <span class="n">files</span><span class="p">)</span> <span class="p">{</span>
</span><span class='line'>        <span class="n">stdout</span><span class="p">.</span><span class="n">printf</span><span class="p">(</span><span class="s">&quot;%s -&gt; %s\n&quot;</span><span class="p">,</span> <span class="n">file</span><span class="p">[</span><span class="s">&quot;path&quot;</span><span class="p">],</span> <span class="n">file</span><span class="p">[</span><span class="s">&quot;public_url&quot;</span><span class="p">]);</span>
</span><span class='line'>    <span class="p">}</span>
</span><span class='line'>    <span class="n">stdout</span><span class="p">.</span><span class="n">printf</span><span class="p">(</span><span class="s">&quot;%d files published\n&quot;</span><span class="p">,</span> <span class="n">files</span><span class="p">.</span><span class="n">length</span><span class="p">);</span>
</span><span class='line'>
</span><span class='line'>    <span class="cm">/* We have nothing else to do so quit */</span>
</span><span class='line'>    <span class="n">loop</span><span class="p">.</span><span class="n">quit</span><span class="p">();</span>
</span><span class='line'><span class="p">}</span>
</span></code></pre></td></tr></table></div></figure>


<p>All that is left is to get the DBus proxy, and connect the signals. This has
proven to be a bit time-consuming. The code was written fast but my
application was not receiving any signals. I verified the code several times
and started debugging the generated C code (<code>vala -C ...</code>). Should I have read
this warning in the <a href="http://live.gnome.org/Vala/DBusServerSample">DBusServerExample</a> code, I&#8217;d complete it a lot faster:</p>

<figure class='code'><figcaption><span></span></figcaption><div class="highlight"><table><tr><td class="gutter"><pre class="line-numbers"><span class='line-number'>1</span>
<span class='line-number'>2</span>
</pre></td><td class='code'><pre><code class='c#'><span class='line'><span class="cm">/* Important: keep demo variable out of try/catch scope not lose signals! */</span>
</span><span class='line'><span class="n">Demo</span> <span class="n">demo</span> <span class="p">=</span> <span class="k">null</span><span class="p">;</span>
</span></code></pre></td></tr></table></div></figure>


<p>Yes, I was declaring my proxies within try/catch block and by the end of the
try block they were all gone and signals were never processed. Here&#8217;s the
correct code:</p>

<figure class='code'><figcaption><span></span></figcaption><div class="highlight"><table><tr><td class="gutter"><pre class="line-numbers"><span class='line-number'>1</span>
<span class='line-number'>2</span>
<span class='line-number'>3</span>
<span class='line-number'>4</span>
<span class='line-number'>5</span>
<span class='line-number'>6</span>
<span class='line-number'>7</span>
<span class='line-number'>8</span>
<span class='line-number'>9</span>
<span class='line-number'>10</span>
<span class='line-number'>11</span>
<span class='line-number'>12</span>
<span class='line-number'>13</span>
<span class='line-number'>14</span>
<span class='line-number'>15</span>
<span class='line-number'>16</span>
<span class='line-number'>17</span>
<span class='line-number'>18</span>
<span class='line-number'>19</span>
<span class='line-number'>20</span>
<span class='line-number'>21</span>
<span class='line-number'>22</span>
<span class='line-number'>23</span>
<span class='line-number'>24</span>
<span class='line-number'>25</span>
<span class='line-number'>26</span>
<span class='line-number'>27</span>
<span class='line-number'>28</span>
<span class='line-number'>29</span>
</pre></td><td class='code'><pre><code class='c#'><span class='line'><span class="kt">int</span> <span class="nf">main</span><span class="p">(</span><span class="kt">string</span><span class="p">[]</span> <span class="n">args</span><span class="p">)</span> <span class="p">{</span>
</span><span class='line'>
</span><span class='line'>    <span class="cm">/* This is extremely important:</span>
</span><span class='line'><span class="cm">     *  If you put this in try/catch block, then the signals will _NOT_ be</span>
</span><span class='line'><span class="cm">     *  delivered as the object will go out of scope.</span>
</span><span class='line'><span class="cm">     */</span>
</span><span class='line'>    <span class="n">PublicFiles</span> <span class="n">public_files</span> <span class="p">=</span> <span class="k">null</span><span class="p">;</span>
</span><span class='line'>
</span><span class='line'>    <span class="k">try</span> <span class="p">{</span>
</span><span class='line'>        <span class="n">public_files</span> <span class="p">=</span> <span class="n">Bus</span><span class="p">.</span><span class="n">get_proxy_sync</span><span class="p">(</span><span class="n">BusType</span><span class="p">.</span><span class="n">SESSION</span><span class="p">,</span>
</span><span class='line'>                                            <span class="s">&quot;com.ubuntuone.SyncDaemon&quot;</span><span class="p">,</span>
</span><span class='line'>                                            <span class="s">&quot;/publicfiles&quot;</span><span class="p">);</span>
</span><span class='line'>
</span><span class='line'>        <span class="cm">/* Connecting the signal*/</span>
</span><span class='line'>        <span class="n">public_files</span><span class="p">.</span><span class="n">public_files_list</span><span class="p">.</span><span class="n">connect</span><span class="p">(</span><span class="n">on_public_files_list</span><span class="p">);</span>
</span><span class='line'>
</span><span class='line'>        <span class="cm">/* requesting public files, the &quot;response&quot; will be delivered via DBus</span>
</span><span class='line'><span class="cm">         * as a signal since it can take a lot of time.  */</span>
</span><span class='line'>        <span class="n">public_files</span><span class="p">.</span><span class="n">get_public_files</span><span class="p">();</span>
</span><span class='line'>
</span><span class='line'>    <span class="p">}</span> <span class="k">catch</span> <span class="p">(</span><span class="n">IOError</span> <span class="n">e</span><span class="p">)</span> <span class="p">{</span>
</span><span class='line'>        <span class="k">return</span> <span class="m">1</span><span class="p">;</span>
</span><span class='line'>    <span class="p">}</span>
</span><span class='line'>
</span><span class='line'>    <span class="n">loop</span> <span class="p">=</span> <span class="k">new</span> <span class="n">MainLoop</span><span class="p">();</span>
</span><span class='line'>    <span class="n">loop</span><span class="p">.</span><span class="n">run</span><span class="p">();</span>
</span><span class='line'>
</span><span class='line'>    <span class="k">return</span> <span class="m">0</span><span class="p">;</span>
</span><span class='line'><span class="p">}</span>
</span></code></pre></td></tr></table></div></figure>


<p>That&#8217;s it, time to compile the <a href="http://rtg.in.ua/assets/ubuntuone/6SmK5GEqPMerFH2MU7t8YP/publicfiles.vala">resulting file</a> and run it, making sure that
Ubuntu One syncdaemon is connected.</p>

<figure class='code'><figcaption><span></span></figcaption><div class="highlight"><table><tr><td class="gutter"><pre class="line-numbers"><span class='line-number'>1</span>
<span class='line-number'>2</span>
<span class='line-number'>3</span>
<span class='line-number'>4</span>
<span class='line-number'>5</span>
</pre></td><td class='code'><pre><code class='c#'><span class='line'><span class="err">$</span> <span class="n">valac</span> <span class="n">publicfiles</span><span class="p">.</span><span class="n">vala</span> <span class="p">--</span><span class="n">pkg</span> <span class="n">gee</span><span class="p">-</span><span class="m">1.0</span> <span class="p">--</span><span class="n">pkg</span> <span class="n">gio</span><span class="p">-</span><span class="m">2.0</span>
</span><span class='line'><span class="err">$</span> <span class="p">./</span><span class="n">publicfiles</span>
</span><span class='line'><span class="p">...</span>
</span><span class='line'><span class="p">/</span><span class="n">home</span><span class="p">/</span><span class="n">rtg</span><span class="p">/</span><span class="n">Ubuntu</span> <span class="n">One</span><span class="p">/</span><span class="n">passwords</span><span class="p">.</span><span class="n">txt</span> <span class="p">-&gt;</span> <span class="n">http</span><span class="p">:</span><span class="c1">//ubuntuone.com/7LwB9iLAXvVKQbCbsbmxRT</span>
</span><span class='line'><span class="m">402</span> <span class="n">files</span> <span class="n">published</span>
</span></code></pre></td></tr></table></div></figure>



]]></content>
  </entry>
  
  <entry>
    <title type="html"><![CDATA[SSH attack passwords]]></title>
    <link href="http://rtg.in.ua/blog/2012/02/ssh-attack-passwords/"/>
    <updated>2012-02-19T13:16:00+02:00</updated>
    <id>http://rtg.in.ua/blog/2012/02/ssh-attack-passwords</id>
    <content type="html"><![CDATA[<p><img class="left" src="http://rtg.in.ua/assets/ubuntuone/6LUt1E8ClN1HKbkzgr2CLT/openssh-logo.png">
I am running a few Ubuntu installations connected to the Internet. As you may
know, once machine is connected to the Internet, it is subject to various
hacking attempts, both automatic and manual.</p>

<p>The most widespread attack vector for *nix machines is SSH brute-forcing. I
once <a href="http://rtg.in.ua/blog/2009/06/permitrootlogin-yes-is-default-value/">became a victim</a> of such attack and now all my machines are using SSH
public key authentication only. I was curious what passwords the attackers
were using so I came up with a simple idea of password collection.</p>

<!-- more -->


<p>If you wanted to have it the quick way, using <a href="http://silicon-verl.de/home/flo/software/pamcifs.html">PAM storepw</a>, then this is not going to
work that good, you will need to <a href="http://www.adeptus-mechanicus.com/codex/logsshp/logsshp.html">create a local account</a> for every account
used to brute-force you. This can end up being a lot of work.</p>

<p>Alternatively you can <a href="http://ubuntuforums.org/showthread.php?t=840280">patch OpenSSH</a> to store the passwords in the log files.
Since I did not want to set up a new machine for the sole purpose of password
logging I decided to go an easier route.</p>

<p><a href="http://twistedmatrix.com/">Twisted</a> is a python-based framework for programming network applications.
And it turns out that they have implemented a SSH protocol too.</p>

<p>So my starting point was the <a href="http://www.g-loaded.eu/2010/03/26/python-ssh-server-unix-twisted-conch/">blog post by George Notaras</a> about RapidSSH. I
only needed the passwords to be stored so I removed chunks of code that dealt
with keys and added the code that writes logins and passwords to a gdbm
database.</p>

<p>Here&#8217;s the code:</p>

<div><script src='https://gist.github.com/1555488.js?file='></script>
<noscript><pre><code>#!/usr/bin/env python

import sys
import gdbm
 
from twisted.conch.unix import UnixSSHRealm
from twisted.cred import portal
from twisted.cred.credentials import IUsernamePassword
from twisted.cred.checkers import ICredentialsChecker
from twisted.cred.error import UnauthorizedLogin
from twisted.conch.ssh import factory, userauth, connection, keys, session
from twisted.internet import reactor, defer
from zope.interface import implements
from twisted.python import log
 
# Logging was disabled
# log.startLogging(sys.stderr)
 
# Server-side public and private keys. These are the keys found in
# sshsimpleserver.py. Make sure you generate your own using ssh-keygen!
 
publicKey = 'ssh-rsa AAAAB3NzaC1yc2EAAAABIwAAAGEArzJx8OYOnJmzf4tfBEvLi8DVPrJ3/c9k2I/Az64fxjHf9imyRJbixtQhlH9lfNjUIx+4LmrJH5QNRsFporcHDKOTwTTYLh5KmRpslkYHRivcJSkbh/C+BR3utDS555mV'
 
privateKey = &quot;&quot;&quot;-----BEGIN RSA PRIVATE KEY-----
MIIByAIBAAJhAK8ycfDmDpyZs3+LXwRLy4vA1T6yd/3PZNiPwM+uH8Yx3/YpskSW
4sbUIZR/ZXzY1CMfuC5qyR+UDUbBaaK3Bwyjk8E02C4eSpkabJZGB0Yr3CUpG4fw
vgUd7rQ0ueeZlQIBIwJgbh+1VZfr7WftK5lu7MHtqE1S1vPWZQYE3+VUn8yJADyb
Z4fsZaCrzW9lkIqXkE3GIY+ojdhZhkO1gbG0118sIgphwSWKRxK0mvh6ERxKqIt1
xJEJO74EykXZV4oNJ8sjAjEA3J9r2ZghVhGN6V8DnQrTk24Td0E8hU8AcP0FVP+8
PQm/g/aXf2QQkQT+omdHVEJrAjEAy0pL0EBH6EVS98evDCBtQw22OZT52qXlAwZ2
gyTriKFVoqjeEjt3SZKKqXHSApP/AjBLpF99zcJJZRq2abgYlf9lv1chkrWqDHUu
DZttmYJeEfiFBBavVYIF1dOlZT0G8jMCMBc7sOSZodFnAiryP+Qg9otSBjJ3bQML
pSTqy7c3a2AScC/YyOwkDaICHnnD3XyjMwIxALRzl0tQEKMXs6hH8ToUdlLROCrP
EhQ0wahUTCk1gKA4uPD6TMTChavbh4K63OvbKg==
-----END RSA PRIVATE KEY-----&quot;&quot;&quot;
 
class NullDatabase:
    &quot;&quot;&quot;Authentication/authorization backend using nothing &quot;&quot;&quot;
    credentialInterfaces = IUsernamePassword,
    implements(ICredentialsChecker)

    def __init__(self):
        self.db = gdbm.open(&quot;/home/rtg/twisted-ssh-passwords.db&quot;, &quot;cus&quot;)
 
    def requestAvatarId(self, credentials):
        key = &quot;%s:%s&quot; % ( credentials.username, credentials.password)
        if key in self.db:
            count = int(self.db[key])
        else:
            count = 0

        self.db[key] = str(count + 1)

        return defer.fail(UnauthorizedLogin(&quot;invalid password&quot;))
 
class UnixSSHdFactory(factory.SSHFactory):
    publicKeys = {
        'ssh-rsa': keys.Key.fromString(data=publicKey)
    }
    privateKeys = {
        'ssh-rsa': keys.Key.fromString(data=privateKey)
    }
    services = {
        'ssh-userauth': userauth.SSHUserAuthServer,
        'ssh-connection': connection.SSHConnection
    }
 
# Components have already been registered in twisted.conch.unix
 
portal = portal.Portal(UnixSSHRealm())
portal.registerChecker(NullDatabase())
UnixSSHdFactory.portal = portal
 
if __name__ == '__main__':
    reactor.listenTCP(5022, UnixSSHdFactory())
    reactor.run()
</code></pre></noscript></div>


<p>As you can see, the database is created in /home/rtg/ which is my home
directory, you will want to change the path.</p>

<p>The script itself runs on port 5022 and I redirected the access to 22 port on
the router to go to port 5022 and redirected the real SSH port on WAN. This way my
LAN machines are still able to access the regular SSH port.</p>

<p>The database is created but it is in a binary form, we need to make it
readable:</p>

<div><script src='https://gist.github.com/1863474.js?file=dump-passwords.py'></script>
<noscript><pre><code>#!/usr/bin/env python

import gdbm
import sys
from datetime import datetime

print &quot;&quot;&quot;# Updated: %s
# SSH creds for attack attempts on my server.
# If your password is listed here, CHANGE IT RIGHT NOW
#&quot;&quot;&quot; % (datetime.now().isoformat())

db = gdbm.open(sys.argv[1])

print &quot;# %d entries\n#&quot; % (len(db.keys()), )

for key in sorted(db.keys()):
    print &quot;%s&quot; % (key, )
</code></pre></noscript></div>


<p>This outputs the whole database in a plaintext format, the usage is simply</p>

<figure class='code'><div class="highlight"><table><tr><td class="gutter"><pre class="line-numbers"><span class='line-number'>1</span>
</pre></td><td class='code'><pre><code class=''><span class='line'>$ dump-passwords.py /path/to/passwords.db &gt; passwords.txt</span></code></pre></td></tr></table></div></figure>


<p>And this is what gets into <a href="http://rtg.in.ua/assets/ubuntuone/7LwB9iLAXvVKQbCbsbmxRT/passwords.txt">passwords.txt</a>:</p>

<figure class='code'><div class="highlight"><table><tr><td class="gutter"><pre class="line-numbers"><span class='line-number'>1</span>
<span class='line-number'>2</span>
<span class='line-number'>3</span>
<span class='line-number'>4</span>
<span class='line-number'>5</span>
<span class='line-number'>6</span>
<span class='line-number'>7</span>
<span class='line-number'>8</span>
<span class='line-number'>9</span>
<span class='line-number'>10</span>
<span class='line-number'>11</span>
<span class='line-number'>12</span>
<span class='line-number'>13</span>
<span class='line-number'>14</span>
<span class='line-number'>15</span>
<span class='line-number'>16</span>
</pre></td><td class='code'><pre><code class=''><span class='line'># Updated: 2012-02-19T01:00:01.626648
</span><span class='line'># SSH creds for attack attempts on my server.
</span><span class='line'># If your password is listed here, CHANGE IT RIGHT NOW
</span><span class='line'>#
</span><span class='line'># 16508 entries
</span><span class='line'>#
</span><span class='line'>!@#$%:!@#$%
</span><span class='line'>!@#$%^&*:!@#$%^&*
</span><span class='line'>!@#$%^&:!@#$%^&
</span><span class='line'>!@#$%^:!@#$%^
</span><span class='line'>*:*
</span><span class='line'>.com:.com
</span><span class='line'>.http:.http
</span><span class='line'>0987654321:0987654321
</span><span class='line'>0:0
</span><span class='line'>100:100</span></code></pre></td></tr></table></div></figure>


<p>This file is updated every day with the new entries of user:password that were
attempted on my fake SSH server. Feel free to use this list for any purpose
(e.g. compiling a cracklib dictionary).</p>
]]></content>
  </entry>
  
  <entry>
    <title type="html"><![CDATA[Varta Professional USB Charger]]></title>
    <link href="http://rtg.in.ua/blog/2012/02/varta-professional-usb-charger/"/>
    <updated>2012-02-17T09:05:00+02:00</updated>
    <id>http://rtg.in.ua/blog/2012/02/varta-professional-usb-charger</id>
    <content type="html"><![CDATA[<p><img class="left" src="http://rtg.in.ua/assets/ubuntuone/3NTlbc7j8mR0WxMCA8n6AB/varta-logo.png"></p>

<p>As the old joke goes, &#8220;you cannot lose an android phone because it is always
near the power socket&#8221;. For me this is exactly what I am experiencing with my
Acer Liquid E. Whenever I am using it for browsing the Internet via WiFi or
3G, I can discharge it completely in 2 hours.</p>

<p>So right before we went on a bus trip to Norway I decided to find out what are
my options to get extended battery life for my phone.</p>

<!-- more -->


<p>Of course, there are high capacity battery for all normal phones.
Unfortunately, not an option for mine.</p>

<p>My wife is also using an Android-based HTC Desire Z, so charging different
devices is definitely a plus.</p>

<p>Also, we have cameras that take AA batteries and the ultimate choice would be
able to charge external batteries too.</p>

<p>Well, <a href="http://www.varta-consumer.com/en/Products/Chargers/Professional-Line/Digital-USB.aspx">Varta USB Charger</a> from their &#8220;professional&#8221; line is that ultimate
device.</p>

<p><img class="center" src="http://rtg.in.ua/assets/ubuntuone/7X9qQ7aUHWjvvB8krv82TS/varta-charger-1.jpg"></p>

<p>It can:</p>

<ul>
<li>Charge USB devices using the power from AA/AAA batteries installed <em>or</em>
the power outlet (effectively making this unit a wall outlet USB charger).</li>
<li>Charge 1-4 AA/AAA batteries from USB devices using a USB-to-5V cable
(included)</li>
<li>Charge those batteries from the wall outlet adapter.</li>
</ul>


<p>So, your capacity basically depends on what batteries you chose. The unit I
purchased came with 4xAA batteries of 2700mAh. I purchased another set as a
backup.</p>

<p><img class="left" src="http://rtg.in.ua/assets/ubuntuone/1xLmXHxoiLYk5seZNGDS1o/varta-charger-2.jpg"></p>

<p>It turned out that one set of these batteries can charge a phone and a half
completely. Also, we were able to charge 2 phones simultaneously using an USB
hub - pure awesomeness!</p>

<p>It is worth noting that when the unit functions as a USB charger from wall
outlet, it does not charge the batteries. When functioning as AA/AAA charger it tracks every single battery charge separately.</p>

<p>The only minor issue I found so far is that when the batteries are almost
depleted the current converter starts producing a long squeaky sound until it
shuts down.</p>
]]></content>
  </entry>
  
  <entry>
    <title type="html"><![CDATA[Экспорт в яндекс]]></title>
    <link href="http://rtg.in.ua/blog/2012/02/export-to-yandex/"/>
    <updated>2012-02-16T16:32:00+02:00</updated>
    <id>http://rtg.in.ua/blog/2012/02/export-to-yandex</id>
    <content type="html"><![CDATA[<p>Все записи на русском будут автоматически транслироваться в <a href="http://roman-yepishev.ya.ru/index_blog.xml">мой дневник</a> на
Я.ру.</p>

<p>После поднятия кеширующей прокси все изображения будут загружаться только на
Ubuntu One. Спасибо, Яндекс, было интересно.</p>

<p>Следующая строка нужна для верификации:</p>

<p>61907928.151477480.1329402715.380ef704279a887b61bf013c237d7ad8</p>

<p><img src="http://bs.yandex.ru/resource/spacer.gif?sign=61907928.151477480.1329461924.1c1c7f51aee93df9d849afe85ca0290e" width="1" height="1"></p>
]]></content>
  </entry>
  
  <entry>
    <title type="html"><![CDATA[Migrating to Octopress]]></title>
    <link href="http://rtg.in.ua/blog/2012/02/migrating-to-octopress/"/>
    <updated>2012-02-14T12:16:00+02:00</updated>
    <id>http://rtg.in.ua/blog/2012/02/migrating-to-octopress</id>
    <content type="html"><![CDATA[<p><img class="left" src="http://rtg.in.ua/assets/ubuntuone/1lbZfaGIdq9Z7HWMUcfdQy/Octopus.png">
From now on this blog is powered by a static blog generator called
<a href="http://octopress.org/">Octopress</a>. The entries were imported using <a href="https://gist.github.com/1578928">this import.rb</a>.</p>

<p>At the moment there is no commenting functionality attached, you can send me a
notice via <a href="http://identi.ca/rye/">identi.ca</a>, <a href="http://twitter.com/RomanYepishev">twitter</a>, <a href="https://plus.google.com/108469920510473382972">google+</a> or <a href="mailto:rtg@rtg.in.ua">email</a> instead for now.</p>

<p>All the links to previously published blog posts will continue working,
including the main RSS feed, additionally this blog is now accessible over
IPv6.</p>

<p>Currently the blog is using a standard Octopress theme.</p>
]]></content>
  </entry>
  
  <entry>
    <title type="html"><![CDATA[Обзор Ubuntu A5 Notebook]]></title>
    <link href="http://rtg.in.ua/blog/2012/02/ubuntu-a5-notebook-review/"/>
    <updated>2012-02-11T16:22:00+02:00</updated>
    <id>http://rtg.in.ua/blog/2012/02/ubuntu-a5-notebook-review</id>
    <content type="html"><![CDATA[<p><img class="left" src="http://rtg.in.ua/assets/ubuntuone/7Mu9V6UXEL2oMP3c5XUdPa/notebook-icon.png"></p>

<p>Здравствуйте.</p>

<p>В последнее время в моей жизни участились случаи использования бумажных
носителей информации. Записи на уроках испанского языка, идеи в метро. Все это
было бы удобнее сразу хранить в удобном цифровом виде, однако запись на
бумажный носитель имеет следующие преимущества:</p>

<ol>
<li>Легкость: ввиду того, что таким носителям не требуются элементы питания и
клавиатура, блокнот получается достаточно тонким.</li>
<li>Instant-on: Вы не тратите время на загрузку файлов, достаточно открыть
блокнот. В некоторых случаях, обложка блокнота может также быть использована
для записи данных, что многократно увеличивает скорость доступа к ним.</li>
<li>Надежность: Падение блокнота на бетонный пол не вызовет значительного
повреждения данных. Конечно, как и электронные аналоги, блокнот (а точнее
бумага из которой он сделан) боится воды, однако в других случаях надежность
хранения записей выше.</li>
</ol>


<!-- more -->


<p>К сожалению, у бумажных блокнотов есть свои недостатки:</p>

<ol>
<li>Скорость записи: Скорость записи ограничена скоростью письма владельца.</li>
<li>Отсутствие поддержки rich-media: Вставить видео или аудио-ролик практически
невозможно, для вставки изображения потребуется физическая модификация
исходного материала (вырезание и вклейка).</li>
<li>Невозможность работы без стороннего источника освещения. Этим грешат сейчас
и электронные книжки, так что мы уже привыкли.</li>
<li>Отсутствие поиска. Наверное, это самый большой недостаток. За годы работы с
электронными носителями информации мы привыкли, что можем найти любую запись по
ключевым словам. Здесь же поиск отсутствует. Придется учиться организовывать
записи.</li>
</ol>


<p>Так как я в некотором роде связан с компанией Canonical, которая выпускает
операционную систему Ubuntu, я решил посмотреть, какие есть предложения в сфере
аналоговых носителей информации.</p>

<h1>Ubuntu A5 Notebook</h1>

<p><a href="http://shop.canonical.com/product_info.php?currency=USD&amp;products_id=730">Доступен</a> для заказа в Canonical Store. Стоимость - $9.74 без доставки.</p>

<p><img class="center" src="http://rtg.in.ua/assets/ubuntuone/2n7l0sgvuNwYsJADpDVlWi/exterior.jpg"></p>

<p>Данный блокнот выполнен в стиле Ubuntu. Обложка содержит логотип.</p>

<p>Спираль блокнота выполнена из прозрачного пластика.</p>

<p><img class="center" src="http://rtg.in.ua/assets/ubuntuone/53kJUqIz28QsDawH9VEcHg/spiral.jpg"></p>

<p>Блокнот содержит 5 секций, каждая из которых разлинована в различном стиле:</p>

<ul>
<li>Обрамление страницы</li>
<li>Клетка</li>
<li>Горизонтальные линии</li>
<li>Редкие точки</li>
<li>Нечто похожее на диалог (страница содержит два &#8220;окна&#8221;)</li>
</ul>


<p>Замечу, что разлинованы страницы с обеих сторон.</p>

<p><img class="center" src="http://rtg.in.ua/assets/ubuntuone/0adIelwTYWHa8NXBfDXZrH/lines.jpg"></p>

<p>Между секциями присутствуют вставки с <a href="http://design.ubuntu.com/assets/pictograms">пиктограммами Ubuntu</a>.</p>

<p><img class="center" src="http://rtg.in.ua/assets/ubuntuone/5hxSBMzWNESBjli9dHlqO2/icons.jpg"></p>

<p>Эти вставки сделаны из картона.</p>

<p>Бумага достаточно яркая, поэтому проблем с контрастом текста, написанного
карандашом не будет.</p>

<p>Обложка блокнота с каждой стороны состоит из листа картона, сложенного вдвое и
гнется достаточно просто, однако все равно способна защитить внутренности от
повреждений.</p>

<p>Блокнот удобно держать в руке, пластиковая спираль мягкая, однако при
перелистывании страниц между секциями картонные вставки могут незначительно
мешать.</p>

<p>Этот блокнот у меня первый день и я планирую использовать его для записей на
уроках испанского языка. Посмотрим, сколько он сможет прожить без ухудшения
качеств.</p>

<p>До встречи!</p>
]]></content>
  </entry>
  
  <entry>
    <title type="html"><![CDATA[My new Lenovo Edge E420]]></title>
    <link href="http://rtg.in.ua/blog/2012/02/my-new-lenovo-edge-e420/"/>
    <updated>2012-02-10T11:48:00+02:00</updated>
    <id>http://rtg.in.ua/blog/2012/02/my-new-lenovo-edge-e420</id>
    <content type="html"><![CDATA[<div class='post'>
<p>My Acer Aspire 5520&#8217;s video board failed after 3 years of slow scrolling and 2D rendering of nVidia driver. This time I decided to avoid Acer and nVidia machines altogether and went to a complete different land of Lenovo.</p>
<div class="separator" style="clear: both; float: left; text-align: center; margin: 10px;">
<img border="0" height="200" src="http://rtg.in.ua/assets/ubuntuone/2dh7kP2FF3qWldd0p50jP4/thinkpad-open.jpg" width="186" /></div>
<p>Initially I wanted to get a 13.x&#8221; display, however the only models available locally were Dell Vostro V131 and Dell Vostro 3350, which were small enough, had a matte screen but various sources suggested that the hinges may have not been&nbsp; strong enough in V131 and I was not able to find any reliable info about switching to intel-only graphics on 3350 in Dell user manual.</p>
<p>Then I switched to Lenovo machines (after watching this <a href="http://www.youtube.com/watch?v=Q7_-kQIB-MA">impressive Stress Test video</a>) and found that E420 is being sold here (in Ukraine) and most of the resellers don&#8217;t have the 13&#8221; version. I think 14&#8221; was a good decision.</p>
<p>The model I have is Lenovo Edge E420 1141PZ5 which is powered by quad-core Intel® Core™ i5-2450M CPU @ 2.50GHz with 4GB of DDR3 RAM and 500GB HDD.</p>
<!-- more -->
<p>First of all, it is <a href="http://www.ubuntu.com/certification/hardware/201103-7440">Ubuntu Certified</a>, not exactly the same model (integrated video only), but it is pretty close. I don&#8217;t have any MMC devices and the fact that proprierary Sony Multi-media storage cards are not readable is not an issue at all.</p>
<h2>lspci</h2>
<p>BIOS had &quot;Switchable graphics&quot; enabled (which is AMD Radeon HD 6600M).</p>
<pre class="code">
00:00.0 Host bridge: Intel Corporation 2nd Generation Core Processor Family DRAM Controller (rev 09)
00:01.0 PCI bridge: Intel Corporation Xeon E3-1200/2nd Generation Core Processor Family PCI Express Root Port (rev 09)
00:02.0 VGA compatible controller: Intel Corporation 2nd Generation Core Processor Family Integrated Graphics Controller (rev 09)
00:16.0 Communication controller: Intel Corporation 6 Series/C200 Series Chipset Family MEI Controller #1 (rev 04)
00:1a.0 USB controller: Intel Corporation 6 Series/C200 Series Chipset Family USB Enhanced Host Controller #2 (rev 04)
00:1b.0 Audio device: Intel Corporation 6 Series/C200 Series Chipset Family High Definition Audio Controller (rev 04)
00:1c.0 PCI bridge: Intel Corporation 6 Series/C200 Series Chipset Family PCI Express Root Port 1 (rev b4)
00:1c.1 PCI bridge: Intel Corporation 6 Series/C200 Series Chipset Family PCI Express Root Port 2 (rev b4)
00:1c.2 PCI bridge: Intel Corporation 6 Series/C200 Series Chipset Family PCI Express Root Port 3 (rev b4)
00:1c.3 PCI bridge: Intel Corporation 6 Series/C200 Series Chipset Family PCI Express Root Port 4 (rev b4)
00:1c.7 PCI bridge: Intel Corporation 6 Series/C200 Series Chipset Family PCI Express Root Port 8 (rev b4)
00:1d.0 USB controller: Intel Corporation 6 Series/C200 Series Chipset Family USB Enhanced Host Controller #1 (rev 04)
00:1f.0 ISA bridge: Intel Corporation HM65 Express Chipset Family LPC Controller (rev 04)
00:1f.2 SATA controller: Intel Corporation 6 Series/C200 Series Chipset Family 6 port SATA AHCI Controller (rev 04)
00:1f.3 SMBus: Intel Corporation 6 Series/C200 Series Chipset Family SMBus Controller (rev 04)
01:00.0 VGA compatible controller: Advanced Micro Devices [AMD] nee ATI Whistler [AMD Radeon HD 6600M Series]
03:00.0 Ethernet controller: Realtek Semiconductor Co., Ltd. RTL8111/8168B PCI Express Gigabit Ethernet controller (rev 06)
04:00.0 System peripheral: Ricoh Co Ltd Device e823 (rev 07)
09:00.0 Network controller: Intel Corporation Centrino Wireless-N 1000
</pre>
<h2>lsusb</h2>
<p>With bluetooth controller on</p>
<pre class="code">
Bus 001 Device 001: ID 1d6b:0002 Linux Foundation 2.0 root hub
Bus 002 Device 001: ID 1d6b:0002 Linux Foundation 2.0 root hub
Bus 001 Device 002: ID 8087:0024 Intel Corp. Integrated Rate Matching Hub
Bus 002 Device 002: ID 8087:0024 Intel Corp. Integrated Rate Matching Hub
Bus 001 Device 003: ID 5986:03b3 Acer, Inc # (webcam) 
Bus 002 Device 003: ID 147e:1002 Upek # (fingerprint reader)
Bus 002 Device 004: ID 0a5c:217f Broadcom Corp. Bluetooth Controller
</pre>
<p>At the moment I am using the laptop with Unity3D on Precise Pangolin (soon to be 12.04). The battery installed is 47520 mWh (4400 mAh x 11.1V) and it allows the machine to stay online with wifi working for 3 hours (integrated Intel HD only) which does not look impressive after my 8 hours Acer Aspire One 9cell battery, yet the battery can be replaced.</p>
<p>One commenter reported that the bluetooth stack is not compatible with some bluetooth mice, such as A4tech BT-630. I have exactly the same model and it works properly, so no problems with this.</p>
<p>I am using built-in Intel HD 3000 video only, there are no tasks that require me to fire up a dedicated radeon hardware for now. I switched to integrated video in BIOS setup and I had to blacklist radeon kernel module to prevent it from initializing. I am not sure whether that turned off its power consumption though (it did not &mdash; set &quot;Integrated Graphics&quot; in BIOS Setup). The built-in video board is quite powerful to drive 1920x1080 screen via HDMI connection with unity3d running on both screens (discrete nVidia 8400G with proprietary drivers could not do that without even more text drawing performance degrading).</p>
<p>Matte screen does not sport great viewing angles but it can be used outside, the backlight is pretty bright so things are quite visible in direct sunlight.</p>
<p>Upek fingerprint reader was not tested, but it looks like it can be used with <a href="https://launchpad.net/~fingerprint">Fingerprint readers integration project</a>, not out-of-box.</p>
<p>The web cam is a standard UVC camera, no problems with it.</p>
<p>I found touchpad a little bit too sensitive for me, clicking on things I was not going to, so I disabled clicks. Maybe I got used to a broken low resolution random sensitivity Alps device on my Aspire 5530, don&#8217;t know.</p>
<div class="separator" style="clear: both; text-align: center;">
<a href="http://1.bp.blogspot.com/-4xRpsE0XC-w/TzY_pHJY_GI/AAAAAAAAIEs/9X-SDS0sBjw/s1600/mic.jpg" imageanchor="1" style="clear:left; float:left;margin-right:1em; margin-bottom:1em"><img border="0" height="318" width="400" src="http://1.bp.blogspot.com/-4xRpsE0XC-w/TzY_pHJY_GI/AAAAAAAAIEs/9X-SDS0sBjw/s400/mic.jpg" /></a></div>


<p>I was surprised that there is only one jack to connect your headset. They have merged the mic and headphone jack and it is definitely compatible with <a href="http://pinoutsguide.com/PDA/htc_hd2_headphone_pinout.shtml">HTC wired headset pinout</a> I borrowed from my wife&#8217;s HTC Desire Z. The regular headphones work properly in this jack.</p>
<p>Ubuntu 12.04 <em>does not provide the option to hibernate</em> the laptop and when I forced it to, it did not finish hibernation, I guess I will need to look into it a bit more.</p>
<p>The laptop looks simple and stylish, there are no metal parts in the exterior except the hinges, however it is all matte and does not look cheap at all.</p>
<p>So far I had 1 lockup for unknown reason, but since I am running a bleeding edge OS this is expected. Should any issues arise I will update this blog post with my findings.</p>
<p>If you have any questions regarding this particular model feel free to comment the post.</p></div>
]]></content>
  </entry>
  
  <entry>
    <title type="html"><![CDATA[НСМЕП та Linux]]></title>
    <link href="http://rtg.in.ua/blog/2011/12/nsmep-and-linux-new-blog/"/>
    <updated>2011-12-15T20:19:00+02:00</updated>
    <id>http://rtg.in.ua/blog/2011/12/nsmep-and-linux-new-blog</id>
    <content type="html"><![CDATA[<div class='post'>
НСМЕП: Національна система масових електронних платежів (National system of mass electronic payments).<br />
<br />
Я розпочав дослідження цієї технології місяць тому, і запрошую вас до Яндекс.Клубу, в якому я пишу про прогрес аналізу цієї унікальної, але маловідомої широкому загалу системі.<br />
Цілі дослідження - упевнитися в перспективності розробки НСМЕП для користувача, описати метод використання НСМЕП у середовищі Linux, та якнайповніше описати протокол взаємодії ПЗ з карткою (наразі, специфікації повністю закриті).<br />
<br />
НСМЕП у Яндекс.Клубі: <a href="http://clubs.ya.ru/4611686018427461168/">http://clubs.ya.ru/4611686018427461168/</a><br />
<br />
Перрша ціль досягнута - вдалося запустити ПлатиМо-ІТ під wine: <a href="http://clubs.ya.ru/4611686018427461168/replies.xml?item_no=8">http://clubs.ya.ru/4611686018427461168/replies.xml?item_no=8</a></div>
]]></content>
  </entry>
  
  <entry>
    <title type="html"><![CDATA[Encrypted Ubuntu One]]></title>
    <link href="http://rtg.in.ua/blog/2011/11/encrypted-ubuntu-one/"/>
    <updated>2011-11-26T23:22:00+02:00</updated>
    <id>http://rtg.in.ua/blog/2011/11/encrypted-ubuntu-one</id>
    <content type="html"><![CDATA[<div class='post'>
<div class="section" id="disclaimer">
<h2>Disclaimer</h2>
<p>This is known to work in Oneiric (11.10), earlier versions don&#8217;t work due to inotify bug.</p>
<p>This document is provided AS IS. The author assumes no liability in case any sort
of data loss occurs, but will be very interested in hearing about such case.
As always, before panicking, check the Trash directory. Since Natty Ubuntu One
deletes files to Trash instead of wiping them from the file system.</p>
</div>
<div class="section" id="about-encryption">
<h2>About encryption</h2>
<p>A lot of Ubuntu One users were asking about the security of Ubuntu One. The official
answer is available at the <a class="reference external" href="https://one.ubuntu.com/help/faq/what-security-and-privacy-policies-does-ubuntu-one-have/">Ubuntu One FAQ</a> but you need to know that although the
data is sent over encrypted connections between the servers and clients, it is not
encrypted when stored. This allows you to publish the files, share them with other
users and access the data via the <a class="reference external" href="https://one.ubuntu.com/developer/files/store_files/#cloud">REST API</a>.</p>
<!-- more -->

<p>This may not be obvious but when you ask the installer to encrypt your /home
directory all applications that are running within the context of your user
(such as the browser, e-mail client, or any syncing software) have the access to
unencrypted versions of the files. This protection comes handy when you lose the
access to the computer hard drive (e.g. when stolen or HDD is sent out to be
replaced/repaired) but anything you run under your account will work with
decrypted files.</p>
<p>It is possible to use some sort of encrypted containers, such as TrueCrypt.
The drawback of this method is that you will need to upload the whole container
even if you have changed just one byte. Even if Ubuntu One supported delta uploads,
changing some subset of data in a really secure container would have affected
quite a large area, in order to conceal the actual location of the changed bytes.</p>
<p>Another way is to encrypt each file separately and upload the changes as they
are happening by monitoring the files. This creates two copies of the files,
one is encrypted and another is not. See <a class="reference external" href="http://deepbit.github.com/index.2011-10-05.uOneCrypt.html">this example</a> for such solution
involving REST API.</p>
<p>But I wanted to use the tools already available in Ubuntu. The aforementioned
technology of /home directory encryption is based on eCryptFS - a layered
encrypted file system implemented in the kernel itself. I wanted to be able to
share some subset of files as well as keeping some of them private to my
machines (while synced to the cloud)</p>
<p>Unfortunately, my first attempt to use eCryptFS-driven ~/.Private UDF
(User Designated Folder) was not successful - the kernel was not
sending inotify events (<a class="reference external" href="https://launchpad.net/bugs/773260">LP:773260</a>) to the subscribers
which meant that I needed to ask the synchronization software to rescan the
files every time I modified the files. The kernel issue has been fixed but now
Ubuntu One gets notified about changes in encrypted directories and it does
not expect this type of notification (<a class="reference external" href="https://launchpad.net/bugs/872894">LP:872894</a>)</p>

<p>Fortunately, a simple patch for Ubuntu One is sufficient to enable correct
interaction with encrypted directories and I have created a <a class="reference external" href="https://launchpad.net/~rye/+archive/u1lp872894">PPA</a> (<strong>ppa:rye/u1lp872894</strong>)
which contains the forks of currently released Ubuntu One client with this patch applied.
I will update this blog post when the fix is released to main distribution
channels and will keep the PPA up to date as I am using it too.</p>
<p>Contrary to how it looks, eCryptFS does <strong>not</strong> use your account password to
decrypt your data. In this case, you would have needed to re-encrypt all the
files every time you&#8217;d change your password. Instead, your account password is
used to encrypt and decrypt the real mount pass phrase, stored in
~/.ecryptfs/wrapped-passphrase.</p>
<p>You want to be able to decrypt your data later on (possibly) another machine,
so you will need to know the pass phrase. When you set up private ecryptfs directory, you
will be prompted for it or you can set it manually. In any case you will be
able to decrypt it using <cite>ecryptfs-unwrap-passphrase</cite> application. Write the
key down somewhere in a secure place - we will need that.</p>

</div>
<div class="section" id="setting-it-up">
<h1>Setting it up</h1>
<p>In order to set up a private directory, you will just need to run the
following:</p>
<pre class="literal-block">
$ ecryptfs-setup-private
Enter your login passphrase: &lt;type your account password&gt;
Enter your mount passphrase [leave blank to generate one]: &lt;just Enter&gt;

************************************************************************
YOU SHOULD RECORD YOUR MOUNT PASSPHRASE AND STORE IT IN A SAFE LOCATION.
  ecryptfs-unwrap-passphrase ~/.ecryptfs/wrapped-passphrase
THIS WILL BE REQUIRED IF YOU NEED TO RECOVER YOUR DATA AT A LATER TIME.
************************************************************************

Done configuring.

Testing mount/write/umount/read...
Inserted auth tok with sig [de5cb8a79d96b6e4] into the user session keyring
Inserted auth tok with sig [87a5b4a8514fdcc9] into the user session keyring
Inserted auth tok with sig [de5cb8a79d96b6e4] into the user session keyring
Inserted auth tok with sig [87a5b4a8514fdcc9] into the user session keyring
Testing succeeded.

Logout, and log back in to begin using your encrypted directory.
</pre>
<p>So, now we have ~/.Private directory set up with a random pass phrase. Let&#8217;s
find out what the pass phrase really is (as the ALL CAPS warning above tells
us):</p>

<pre class="literal-block">
$ ecryptfs-unwrap-passphrase
Passphrase: &lt;type your account password&gt;
d5da6e5eaf98d8f2b0a481995710b57e
</pre>
<p>The <cite>d5da6e5eaf98d8f2b0a481995710b57e</cite> string is our real mount pass phrase in
this case. Now you are ready to ask Ubuntu One to enable syncing of ~/.Private
folder:</p>
<pre class="literal-block">
$ u1sdtool --create-folder ~/.Private
</pre>
<p>Now verify that the folder has been created, make sure that you have
ubuntuone-client version 2.0.0-0ubuntu2.2+lp872894 installed from the PPA and
restart the client</p>
<pre class="literal-block">

$ u1sdtool --quit
$ u1sdtool --start
</pre>
<p>Put some file to your ~/Private folder - by default ecryptfs encrypts
file names too, so when the sync completes, you will find something like
<cite>ECRYPTFS_FNEK_ENCRYPTED.FXYl0wXfbLRRD-S7MDeYn8SYOWt.3exR-KbLnhYMpLY8ZwrgYH6xb8MBtBSjZQS9Hfvjo5BYEvrowNc-</cite>
in ~/.Private folder and on the web interface at <a class="reference external" href="https://one.ubuntu.com/files/">https://one.ubuntu.com/files/</a>.</p>
</div>
<div class="section" id="multiple-machines">
<h1>Multiple machines</h1>
<p>OK, now when files are syncing, you can set up Private directory on another
Ubuntu machine and you will be able to access the encrypted files created on
another machine.</p>
<p>I have to say that this does not work extremely well when you edit the same
file on both machines. eCryptFS seems to have some caching in place that
prevents the updated lower file from being immediately available on another
machine. If you use the machines sequentially (e.g. home machine and laptop
you are carrying around) then this should not be a problem.</p>

<p>So, make sure that another machine is also running the version that has the
fix for eCryptFS and set up the private folder:</p>
<pre class="literal-block">
$ ecryptfs-setup-private
Enter your login passphrase: &lt;account password&gt;
Enter your mount passphrase [leave blank to generate one]: &lt;passphrase from first computer&gt;
Enter your mount passphrase (again): &lt;passphrase from first computer again&gt;

************************************************************************
YOU SHOULD RECORD YOUR MOUNT PASSPHRASE AND STORE IT IN A SAFE LOCATION.
ecryptfs-unwrap-passphrase ~/.ecryptfs/wrapped-passphrase
THIS WILL BE REQUIRED IF YOU NEED TO RECOVER YOUR DATA AT A LATER TIME.
************************************************************************

Done configuring.

Testing mount/write/umount/read...
Inserted auth tok with sig [2c007b978eb65d67] into the user session keyring
Inserted auth tok with sig [b899c2e5fcb355f2] into the user session keyring
Inserted auth tok with sig [2c007b978eb65d67] into the user session keyring
Inserted auth tok with sig [b899c2e5fcb355f2] into the user session keyring
Testing succeeded.

Logout, and log back in to begin using your encrypted directory.
</pre>
<p>Good, now subscribe to ~/.Private folder using <cite>ubuntuone-control-panel</cite> or

<cite>u1sdtool</cite> (<cite>&#8211;list-folders</cite> to find out <cite>folder-id</cite> followed by
<cite>&#8211;subscribe-folder=folder-id</cite>).</p>
<p>Restart Ubuntu One client and you should start getting the files you put to
first ~/.Private folder and when you visit ~/Private folder and you will be
able to work with unencrypted files. You might need to refresh the ~/Private
folder for the changes to be visible, this is a limitation of eCryptFS.</p>
</div>
<div class="section" id="windows-support">
<h1>Windows support</h1>

<p>To put it simple, this will not work with Windows, Android or any other Ubuntu
One client for any OS other than Linux with eCryptFS support.
Windows does not support eCryptFS mounts and there appears to be
no plans for this. There may be different solutions with similar approach on
Windows. If you happen to know one, feel free to leave the comment.</p>
<p>The web interface and Android file sync client will show encrypted file names
and will download encrypted content. I am not aware of any eCryptFS-decrypting
solutions for Android.</p>
</div>
<div class="section" id="thanks">
<h1>Thanks</h1>
<p>After all, this blog post does not reveal anything new. The idea to use
eCryptFS with Ubuntu One is quite common. The only value this long post adds
is that it gives the address of the PPA. By the way, this blog post was originally
written in reStructurizedText Markup in Vim.</p>
</div></div>
]]></content>
  </entry>
  
  <entry>
    <title type="html"><![CDATA[Using mod_auth_openid with Ubuntu SSO]]></title>
    <link href="http://rtg.in.ua/blog/2011/11/modauthopenid-and-ubuntu-sso/"/>
    <updated>2011-11-12T11:02:00+02:00</updated>
    <id>http://rtg.in.ua/blog/2011/11/modauthopenid-and-ubuntu-sso</id>
    <content type="html"><![CDATA[<div class='post'>
<p>I have some internal web sites running on my home server. Earlier I configured WebAuth with WebKDC to create SSO-like experience. This was working well, but I wanted to use some 3rd party solution to be able to use auth on remote services even if local WebAuth host is not accessible.</p>
<!-- more -->
<p>
The requirements were:</p>
<ul>
<li>Specify the list of users which are allowed to login</li>
<li>Don&#8217;t require server-side scripting</li>
</ul>
<p>Since <a href="https://login.ubuntu.com">Ubuntu SSO</a> is already used for <a href="https://launchpad.net">Launchpad</a>, <a href="https://one.ubuntu.com">Ubuntu One</a> and various other services I decided that it is good enough for my small network.</p>
<p>Ubuntu hosts are using python-apache-openid python module and it has a very nice feature of being able to restrict access to some launchpad teams. It is not yet critical for me so I decided to look around in the archive and found <em>libapache2-mod-auth-openid</em></p>
<p>This is a packaged version of mod_auth_openid from <a href="http://findingscience.com/mod_auth_openid/">http://findingscience.com/mod_auth_openid/</a> - that web site contains the documentation for the module as well as examples.</p>

<p>The version in Oneiric is 0.5 which did not contain the feature I was after, the ability to restrict the access to some set of OpenID users without resorting to external script. So I went forward and updated the package to 0.6 and for the first time I was so pleased with the resulting package that I decided to send the updates to Debian maintainer. The updated package was successfully built in my <a href="https://launchpad.net/%7Erye/+archive/ppa/">ppa:rye/ppa</a> and can be installed on Oneiric with</p>
<pre>sudo apt-add-repository ppa:rye/ppa
sudo apt-get update
sudo apt-get install libapache2-mod-auth-openid</pre>
<blockquote>apt-add-repository is available from python-software-properties package.</blockquote>

Please verify that you have installed version 0.6:
<pre>
$ apt-cache policy libapache2-mod-auth-openid
libapache2-mod-auth-openid:
  Installed: 0.6-0ubuntu1
  Candidate: 0.6-0ubuntu1
</pre>
<h2>Configuration</h2>
<p>I started with the following in my /etc/apache2/sites-available/default and marked the changed parts in bold</p>

<pre>&lt;VirtualHost *:80&gt;
   ServerAdmin webmaster@localhost

   DocumentRoot /var/www
   &lt;Directory /&gt;
     Options FollowSymLinks
     AllowOverride None
   &lt;/Directory&gt;
   &lt;Directory /var/www/&gt;
     Options Indexes FollowSymLinks MultiViews
     AllowOverride None
     Order allow,deny
     allow from all
   &lt;/Directory&gt;
<b>
  &lt;Location /&gt;
    AuthType OpenID
    Require valid-user
    AuthOpenIDTrusted ^https://login.ubuntu.com/\+openid
    AuthOpenIDLoginPage /openid/
    AuthOpenIDCookiePath /
  &lt;/Location&gt;

  &lt;Location /openid&gt;
    Order allow,deny
    Allow from all
    Satisfy any
  &lt;/Location&gt;
</b>
  ScriptAlias /cgi-bin/ /usr/lib/cgi-bin/
  &lt;Directory "/usr/lib/cgi-bin"&gt;
    AllowOverride None
    Options +ExecCGI -MultiViews +SymLinksIfOwnerMatch
    Order allow,deny
    Allow from all
  &lt;/Directory&gt;

  ErrorLog ${APACHE_LOG_DIR}/error.log

  # Possible values include: debug, info, notice, warn, error, crit,
  # alert, emerg.
  LogLevel warn

  CustomLog ${APACHE_LOG_DIR}/access.log combined

  Alias /doc/ "/usr/share/doc/"
  &lt;Directory "/usr/share/doc/"&gt;
    Options Indexes MultiViews FollowSymLinks
    AllowOverride None
    Order deny,allow
    Deny from all
    Allow from 127.0.0.0/255.0.0.0 ::1/128
  &lt;/Directory&gt;

&lt;/VirtualHost&gt;
</pre>
<p>I am using a <a href="http://findingscience.com/mod_auth_openid/custompage.html">custom login page</a> since I don&#8217;t need to enter my identifier every time. I am using a single provider so I am submitting an OpenID request automatically to Ubuntu SSO.</p>
<p>The /var/www/openid/index.html page is <a href="https://raw.github.com/gist/1363682/">simple</a>:</p>
<script src="https://gist.github.com/1363682.js"> </script>
<p>The query string parsing is actually needed to display the error that has been passed to the page in case the request is canceled on the provider or something else has happened.</p>
<p>Now the module needs to be enabled (this was not working in 0.5 out of the box) and apache needs to be restarted:</p>
<pre>sudo a2enmod authopenid
sudo service apache2 restart</pre>
<p>Now you have OpenID enabled for your virtual host root directory. The thing is it is enabled for <em>everybody</em> with Ubuntu SSO account so we need to restrict the access.</p>
<p>To find your OpenID identifier, log into your system using OpenID and browse the logs:
<pre>
192.168.1.114 - <b>https://login.ubuntu.com/+id/hPQWPsH</b> ↩
  [12/Nov/2011:12:24:54 +0200] ↩
  "GET / HTTP/1.1" 304 210 "-" "Mozilla/5.0 ↩
  (Ubuntu; X11; Linux x86_64; rv:8.0) 
</pre>
<p>Accounts that exist in launchpad can find out their +id/&#8230; value from the https://launchpad.net/~yournick, the openid.delegate will have this info. Launchpad login service and Ubuntu SSO service are currently using the same database, but we are targeting SSO.
<pre>
&lt;link rel="openid.delegate" href="https://login.launchpad.net/+id/<b>hPQWPsH</b>" /&gt;
</pre>
<p>The OpenID value needs to go to the apache config</p>
<pre>
  &lt;Location /&gt;
    AuthType OpenID
    <b>Require user https://login.ubuntu.com/+id/hPQWPsH</b>
    AuthOpenIDTrusted ^https://login.ubuntu.com/\+openid
    AuthOpenIDLoginPage /openid/
    AuthOpenIDCookiePath /
  &lt;/Location&gt;
</pre>
<p>Restart apache, and only the user specified in the Require user directive will be able to access the resource</p>
<h2>Limitations</h2>
<p>This module can be used only for ID authentication. While it is technically possible to request the OpenID provider to reply with user email or any other attributes, the module does not provide any protection from changing the values as they are traveling as a GET request back to the original form target page.</p></div>
]]></content>
  </entry>
  
  <entry>
    <title type="html"><![CDATA[Switching to CIFS]]></title>
    <link href="http://rtg.in.ua/blog/2011/11/switching-to-cifs/"/>
    <updated>2011-11-04T22:46:00+02:00</updated>
    <id>http://rtg.in.ua/blog/2011/11/switching-to-cifs</id>
    <content type="html"><![CDATA[<div class='post'>
<p>I have a fileserver at home. It contains a backup of some photos, various Linux CD/DVD image, runs my virtual machines, serves as a Kerberos domain controller, printer server&#8230; well, pretty much everything I do has something to do with my home server.</p>
<p>Half a year ago I decided to move all my home directory to the server over NFS. I quickly configured NFSv4 with kerberos by following an extremely well-written <a href="https://help.ubuntu.com/community/NFSv4Howto" title="NFSv4Howto - Community Ubuntu Documentation">community help article</a>, created all the bind mounts and&#8230;</p>
<p>Well, I could transfer only half of my photos (6Gb) until the connection hung. I repeated this experiment for several more times and the worst part that any application that visited the mount point was unable to recover. I tried with various intr modes, various buffer sizes, TCP and UDP transports.</p>
<p>I swapped network cards, dropped Kerberos, switched to IPv4-only mode, switched to 100Mbps network instead of gigabit but it was still hanging.</p>
<p>I could transfer all my files over the same link using rsync over SSH, Apache WebDAV, and pretty much everything except NFS.</p>
<p>Today I gave up and set up Samba server on the same machine. And I could transfer everything I needed at the speed I expected without any issues.</p>
<p>I wanted to file the bug on Launchpad, but the kernel server runs at the kernel level, so it&#8217;s not very comfortable for me to debug on a headless machine. And filing a bug w/o followup does not make sense. According to tcpdump, the server simply stopped answering at some point and according to my Google searches I am the only one experiencing this type of issue.</p>
<p>I am still keeping my NFS server running, but it feels a bit weird to use CIFS one a network of Linux-only machines.</p></div>
]]></content>
  </entry>
  
  <entry>
    <title type="html"><![CDATA[Warning: Samsung ChatON]]></title>
    <link href="http://rtg.in.ua/blog/2011/10/warning-samsung-chaton/"/>
    <updated>2011-10-17T21:31:00+03:00</updated>
    <id>http://rtg.in.ua/blog/2011/10/warning-samsung-chaton</id>
    <content type="html"><![CDATA[<div class='post'>
<img class="left" src="http://rtg.in.ua/assets/ubuntuone/1RZog1bP09axueskMn4331/chaton.png" />

<p>tl;dr version: <b>Do not use ChatON on the public WiFi networks</b>. The communication between client and server is not encrypted.</p>
<blockquote><b>Update:</b> Yesterday I found myself unable to sniff the packets properly but today plaintext messages are back, looks like there is something wrong with 46.137.191.242.</blockquote>

<blockquote><del>shortly after posting this (within an hour or so) my attempts to capture the plaintext messages started to fail, something has changed, continuing my investigation. Images are still going via HTTP though.</del></blockquote>
<!-- more -->
<p>Two days ago Samsung launched their new IM service ChatON. ChatON Android application was released and its UI is definitely awesome. Having obtained my copy from Android Market I decided to check what protocol it is using for communication.</p>
<p>I launched tcpdump on my (rooted) Acer Liquid and started listening for the messages.</p>
<p>Among the lines of https (encrypted) messages flowing back and forth I found the following:</p>
<pre>
21:05:01.146225 IP 46.203.98.114.42914 > 46.137.191.242.5223: P 118:345(227) ack 1 win 5600 <nop,nop,timestamp 14403463 195591442>
 0x0000:  4500 0117 30e8 4000 4006 8940 2ecb 6272  E...0�@.@..@.�br
 0x0010:  2e89 bff2 a7a2 1467 ab45 ae43 4473 fdf8  ..����.g�E�CDs�
 0x0020:  8018 15e0 fab9 0000 0101 080a 00db c787  ...���.......��.
 0x0030:  0ba8 7d12 6264 3530 6263 3337 2d65 6532  .�}.ba50bc37-ee2
 0x0040:  382d 3432 6366 2d61 6531 352d 3133 3731  8-42cf-ae15-1371
 0x0050:  3334 3466 3363 3464 0104 00bb 08cd f7ef  344f3c4d...�.��
 0x0060:  87d8 e820 1000 1800 2248 3462 3064 6365  .��....."H4b0dce
 0x0070:  6638 2d64 3733 322d 3464 3038 2d62 3062  f8-d732-4d08-b0b
 0x0080:  612d 6536 3862 3263 3931 3066 6662 6264  a-e68b2c910ffbbd
 0x0090:  3530 6263 3337 2d65 6532 382d 3432 6366  50bc37-ee28-42cf
 0x00a0:  2d61 6531 352d 3133 3731 3334 3466 3363  -ae15-1371344f3c
 0x00b0:  3464 2a0c 3338 3039 3133 3532 3930 3539  4d*.380913529059
 0x00c0:  320c 3338 3039 3337 3532 3539 3836 3a24  2.380937525986:$
 0x00d0:  6264 3530 6263 3337 2d65 6532 382d 3432  bd50bc37-ee28-42
 0x00e0:  6366 2d61 6531 352d 3133 3731 3334 3466  cf-ae15-1371344f
 0x00f0:  3363 3464 420f 3335 3335 3039 3033 3132  3c4dB.3535090312
 0x0100:  3536 3238 354a 1068 692c 2068 6f77 2061  56285J.hi,.how.a
 0x0110:  7265 2079 6f75 3f                        re.you?
</pre>
<pre>
21:05:07.236157 IP 46.137.191.242.5223 > 46.203.98.114.42914: P 228:422(194) ack 345 win 62 <nop,nop,timestamp 195593552 14403463>
 0x0000:  4500 00f6 af74 4000 3206 18d5 2e89 bff2  E..��t@.2..�..�
 0x0010:  2ecb 6272 1467 a7a2 4473 fedb ab45 af26  .�br.g��Ds�۫E�&amp;
 0x0020:  8018 003e b6d2 0000 0101 080a 0ba8 8550  ...&gt;��.......�.P
 0x0030:  00db c787 6264 3530 6263 3337 2d65 6532  .��.ba50bc37-ee2
 0x0040:  382d 3432 6366 2d61 6531 352d 3133 3731  8-42cf-ae15-1371
 0x0050:  3334 3466 3363 3464 0106 009a 0a48 3462  344f3c4d.....H4b
 0x0060:  3064 6365 6638 2d64 3733 322d 3464 3038  0dcef8-d732-4d08
 0x0070:  2d62 3062 612d 6536 3862 3263 3931 3066  -b0ba-e68b2c910f
 0x0080:  6662 6264 3530 6263 3337 2d65 6532 382d  fbbd50bc37-ee28-
 0x0090:  3432 6366 2d61 6531 352d 3133 3731 3334  42cf-ae15-137134
 0x00a0:  3466 3363 3464 1000 1a4a 0a0c 3338 3039  4f3c4d...J..3809
 0x00b0:  3337 3532 3539 3836 120c 3338 3039 3133  37525986..380913
 0x00c0:  3532 3930 3539 1884 d185 fb9e c816 221b  529059..�.�.�.".
 0x00d0:  6920 7761 6e74 2061 205b 686d 5d20 616e  i.want.a.[hm].an
 0x00e0:  6420 6120 5b35 286c 6c29 5d28 c3e5 bb98  d.a.[5(ll)](���.
 0x00f0:  b126 3000 2800                           �&amp;0.(.
</pre>
<p>Do you see something?</p>
<p>Here&#8217;s what you see:</p>
<img class="center" src="http://rtg.in.ua/assets/ubuntuone/6mK9GHfqXnUM05ie66LS0J/ChatON-conversation.png">
<p>Basically, <b>connection to the server is not encrypted</b></p>
<p>The client is using Google Protobuf protocol to send messages back and forth between client and server and the communication is not encrypted in any way. After more careful examination I found that the session initiation <em>IS</em> encrypted, so that it may not be possible to find whom exactly with you are talking to but all the messages will be visible to everybody around you if you are using an unencrypted open network such as you can find at the local cafe shops, restaurants, shopping centres etc.</p>
<p>You may not be in that amount of danger if you are using your cell phone carrier for the internet connection, that communication is encrypted between your phone and the cell towers, however you might not always realize that you have switched to open WiFi network and keep using ChatON.</p>
<p>I don&#8217;t have a Bada-powered device nearby to verify whether that uses the same servers so I will assume that the same unencrypted protocol is used on all Bada devices and Samsung featurephones that have ChatON installed unless I have the proof that it is doing otherwise.</p>
<p>Interesting geeky detail - the servers are running on port 5223 which is usually associated with XMPP over SSL but it is actually a proprietary protocol (well, based on Google&#8217;s protobuf). The chat servers are running on Amazon AWS hosts.</p>
<p>File uploads are also running over plain HTTP/1.1 without encryption:</p>
<pre>
POST /file?uid=bd50bc37-...-1371344f3c4d&param=7daffaa462b802b...92e37870 HTTP/1.1
content-type: image/jpeg
content-length: 48401
User-Agent: Dalvik/1.2.0 (Linux; U; Android 2.2.2; Liquid Build/FRG83G)
Host: eu.file.samsungchaton.com
Connection: Keep-Alive

...
</pre>
<pre>
GET /4b/0d/ce/f8/d7/32/4d/08/b0/ba/e6/8b/2c/91/0f/fb/4b0dcef8-d732-4d08-b0ba-e68b2c910ffb/
       1318879486269_239.jpg?AWSAccessKeyId=AKIAIXENATYOW4T2DJSQ&
       Expires=1319052296&Signature=6UFD%2FYS9Vlls9X7WJov8GcH7EGs%3D HTTP/1.1
User-Agent: Dalvik/1.2.0 (Linux; U; Android 2.2.2; Liquid Build/FRG83G)
Host: eu.chaton-file.s3.amazonaws.com
Connection: Keep-Alive


HTTP/1.1 200 OK
x-amz-id-2: PNglgPsPAkR7SvhFPHk2bkl901Q6MGedePoaCRf/RGArSM36lZgtkMWLN10nmzZK
x-amz-request-id: E25D27220B372F64
Date: Mon, 17 Oct 2011 19:24:58 GMT
Last-Modified: Mon, 17 Oct 2011 19:24:51 GMT
ETag: "3ec7437168455698b4367ed303bfcfad"
Accept-Ranges: bytes
Content-Type: image/jpeg
Content-Length: 738
Server: AmazonS3

...
</pre>

<p>Yeah.</p>

<p>Ah, when user is not properly registered (ChatON on Android Emulator) the message returned is&#8230;</p>
<pre>
13:56:58.562553 IP 46.203.53.202.59299 > 46.137.191.242.5223: P 216:450(234) ack 185 win 3456 <nop,nop,timestamp 1730244 201662886>
 0x0000:  4500 011e df2c 4000 4006 079d 2ecb 35ca  E...�,@.@....�5
 0x0010:  2e89 bff2 e7a3 1467 38a3 84e8 4513 9da9  ..����.g8�.�E..�
 0x0020:  8018 0d80 2c9f 0000 0101 080a 001a 66c4  ....,.........f
 0x0030:  0c05 21a6 6264 3530 6263 3337 2d65 6532  ..!�bd50bc37-ee2
 0x0040:  382d 3432 6366 2d61 6531 352d 3133 3731  8-42cf-ae15-1371
 0x0050:  3334 3466 3363 3464 0104 00c2 088a e2a2  344f3c4d...�..
 0x0060:  fea5 8004 1000 1800 2248 6264 3530 6263  ��......"Hbd50bc
 0x0070:  3337 2d65 6532 382d 3432 6366 2d61 6531  37-ee28-42cf-ae1
 0x0080:  352d 3133 3731 3334 3466 3363 3464 6366  5-1371344f3c4dcf
 0x0090:  6662 3933 3939 2d63 3935 332d 3462 6465  fb9399-c953-4bde
 0x00a0:  2d39 3266 352d 6639 6435 3136 3862 3562  -92f5-f9d5168b5b
 0x00b0:  3764 2a0c 3338 3039 3133 3532 3930 3539  7d*.380913529059
 0x00c0:  320c 3338 3036 3336 3137 3038 3335 3a24  2.380636170835:$
 0x00d0:  6264 3530 6263 3337 2d65 6532 382d 3432  bd50bc37-ee28-42
 0x00e0:  6366 2d61 6531 352d 3133 3731 3334 3466  cf-ae15-1371344f
 0x00f0:  3363 3464 420f 3335 3335 3039 3033 3132  3c4dB.3535090312
 0x0100:  3536 3238 354a 174e 6f77 2069 7420 6973  56285J.Now.it.is
 0x0110:  2077 6f72 6b69 6e67 2061 6761 696e       .working.again
13:56:59.643944 IP 46.137.191.242.5223 > 46.203.53.202.59299: P 185:369(184) ack 450 win 62 <nop,nop,timestamp 201665145 1730244>
 0x0000:  4500 00ec 8237 4000 3206 72c4 2e89 bff2  E..�.7@.2.r�..�
 0x0010:  2ecb 35ca 1467 e7a3 4513 9da9 38a3 85d2  .�5�.g��E..�8�.
 0x0020:  8018 003e a34b 0000 0101 080a 0c05 2a79  ...&gt;�K........*y
 0x0030:  001a 66c4 6264 3530 6263 3337 2d65 6532  ..f�bd50bc37-ee2
 0x0040:  382d 3432 6366 2d61 6531 352d 3133 3731  8-42cf-ae15-1371
 0x0050:  3334 3466 3363 3464 0105 0090 088a e2a2  344f3c4d......
 0x0060:  fea5 8004 1248 6264 3530 6263 3337 2d65  ��...Hbd50bc37-e
 0x0070:  6532 382d 3432 6366 2d61 6531 352d 3133  e28-42cf-ae15-13
 0x0080:  3731 3334 3466 3363 3464 6366 6662 3933  71344f3c4dcffb93
 0x0090:  3939 2d63 3935 332d 3462 6465 2d39 3266  99-c953-4bde-92f
 0x00a0:  352d 6639 6435 3136 3862 3562 3764 1a13  5-f9d5168b5b7d..
 0x00b0:  0a0e 3436 2e31 3337 2e31 3137 2e32 3334  ..46.137.117.234
 0x00c0:  10e7 2820 96cc b5b5 b126 2a20 08f2 2e12  .�(..̵��&*..�..
 0x00d0:  1b4d 6573 7361 6765 2052 6563 6569 7665  .Message.Receive
 0x00e0:  7220 6973 2049 6e76 616c 6964            r.is.Invalid
</pre></div>
]]></content>
  </entry>
  
  <entry>
    <title type="html"><![CDATA[Ubuntu One, Headless]]></title>
    <link href="http://rtg.in.ua/blog/2011/08/ubuntu-one-headless/"/>
    <updated>2011-08-17T20:16:00+03:00</updated>
    <id>http://rtg.in.ua/blog/2011/08/ubuntu-one-headless</id>
    <content type="html"><![CDATA[<div class='post'>
Hello again!<br />
<p><b>Notice:</b> To run real Ubuntu One syncdaemon in headless mode, see <a href="https://wiki.ubuntu.com/UbuntuOne/Headless">Ubuntu One Headless wiki page</a>.</p>
Another idea I have been thinking about for quite a long time but it became extremely simple after Ubuntu One introduced <a href="https://one.ubuntu.com/developer/files/store_files/cloud/">REST API</a> for file access. This API is used by a really wonderful <a href="https://market.android.com/details?id=com.ubuntuone.android.files">Ubuntu One Files application for Android</a> <span style="font-family: inherit;">by</span> <a href="https://twitter.com/#%21/mkarnicki">Michał Karnicki</a><span style="font-family: inherit;"> and Web&amp;Mobile team and <a href="http://webm0nk3y.wordpress.com/">John&#8217;s</a> u1rest <a href="https://launchpad.net/restful-u1">library</a>. </span><br />
I decided to see how hard would it be to create a command line application similar to ftp to upload and download files and navigate my cloud storage using the API directly. The application needed to be usable in the server environment too.<br />
<!-- more -->
<br />
This is an initial version:<br />
<pre class="code">rtg@lucidity:~$ ./ubuntuone-rest-files-client.py --oauth a:b:c:d
Welcome to Ubuntu One!
User id: 52053, name: Roman
Usage: 26.1 GiB/65.0 GiB
&gt; ls
/~/Pictures                                        - -
/~/.gpass                                          - -
/~/Music                                           - -
/~/Pictures - Liquid                               - -
/~/Backup                                          - -
/~/Public                                          - -
/~/Documents                                       - -
/~/.ubuntuone/Purchased from Ubuntu One            - -
/~/Videos                                          - -
&gt; cd ~/Documents
/~/Documents&amp;amp;gt; ls
Articles/                                             2011-04-05T20:07:40Z
Certificates/                                         2011-04-18T07:32:28Z
CV/                                                   2010-12-01T11:14:08Z
DVD Labels.odg                                  13332 2011-03-06T20:38:50Z
eBooks/                                               2011-08-05T15:08:03Z
_image_vab-document.png                        145336 2011-04-30T10:15:33Z
...
/~/Documents&gt; get _image_vab-document.png
Downloading 145336 bytes to _image_vab-document.png...  Done
/~/Documents&gt; cd ../Ubuntu\ One
/~/Ubuntu One&gt; put desktopcouch_0.6.4.orig.tar.gz
Uploading desktopcouch_0.6.4.orig.tar.gz to https://files.one.ubuntu.com/content/~/Ubuntu%20One/desktopcouch_0.6.4.orig.tar.gz
Content size: 105609
/~/Ubuntu One&gt;
</pre>
<br />
Well, you understand the idea. Please understand that at the moment this is a very rough version, so download and use it if you really like to play with something that may suddenly break.<br />
<br />
<h3>

Where to get and how to use</h3>
You will need 2 files from ubuntuone-scripts repository - <code>bzr branch lp:~rye/+junk/ubuntuone-scripts</code>, you can download the latest versions directly from <a href="http://people.canonical.com/%7Eroman.yepishev/us/ubuntuone-sso-login.py">ubuntuone-sso-login.py</a> and <a href="http://people.canonical.com/%7Eroman.yepishev/us/ubuntuone-rest-files-client.py">ubuntuone-rest-files-client.py</a>.<br />
In order to get the a:b:c:d values that are the value for <code>--oauth</code> option run the first script as follows:
<br />
<pre class="code">$ ./ubuntuone-sso-login.py
Creating new entry for buzz
SSO login: <i>Your Ubuntu One SSO e-mail</i>
password: <i>Your password</i>
Using SSO URL: https://login.ubuntu.com/api/1.0/authentications?ws.op=authenticate&amp;amp;amp;token_name=%22Ubuntu+One+%40+buzz%22
OAuth info:
<b>a:b:c:d</b>
Ping result: ok 1/7
</pre>
We are interested in the line after OAuth info. It will be a long string.<br />
<blockquote>
<b>Warning!</b> This OAuth string should be treated as secret, since it is composed of your OAuth <b>consumer key:consumer secret:token:token secret</b>. This string enables anybody who knows it to access your files, and CouchDB databases, think of it as a login/password pair that you can remove when needed. If you suspect that somebody else has that string, go to <a href="https://one.ubuntu.com/account/machines/">Ubuntu One web site</a> and remove the corresponding entry. Then you can run ubuntuone-sso-login.py again and get a new set of credentials for the script.
</blockquote>
Then run ubuntuone-rest-files-client.py:
<br />
<pre class="code">./ubuntuone-rest-files-client.py --oauth <b>a:b:c:d</b>
Welcome to Ubuntu One!
User id: 52053, name: Roman
Usage: 26.1 GiB/65.0 GiB
&gt; 
</pre>
<br />
That&#8217;s pretty much it. The following commands are supported:
<br />
<ul>
<li><code>get <i>remote [local]</i></code> - download the <i>remote</i> file as <i>local</i>, in case local name is omitted it will use the original name</li>
<li><code>put <i>local [remote]</i></code> - upload the <i>local</i> file, same rules for omitting the remote name</li>
<li><code>mget <i>remote1 [remote2 remote3 ... remoteN]</i></code> - download the files to the current working directory</li>
<li><code>cd <i>folder</i></code> - change remote directory. Please remember to quote the path if it contains spaces or escape them - <code>"/~/Ubuntu One"</code> or <code>/~/Ubuntu\ One</code></li>
<li><code>quit</code> or Ctrl+D - terminate the script</li>
<li><code>ls</code> - list folder contents, in case some file is published the URL will be printed</li>
<li><code>publish <i>remote</i></code> - publish an already uploaded file. Will print public URL</li>
<li><code>unpublish <i>remote</i></code> - take down the published file</li>
</ul>
More commands will be added later, at the moment this is a working proof of concept but I am very happy with the API so far. I will make the script much more stable and use less resources in the future (at the moment the whole file is read into memory during upload/download - thank you httplib2).<br />
<br />
Ah, by the way, it works on Fedora too:
<img src="http://rtg.in.ua/assets/ubuntuone/3MgokY3lVmxlZnmbq1W2nW/headless-ubuntuone-fedora.png"
 style="height: 483px; width: 730px;" title="Fedora 14 screenshot" /></div>
]]></content>
  </entry>
  
  <entry>
    <title type="html"><![CDATA[Проблемы Acer Liquid E]]></title>
    <link href="http://rtg.in.ua/blog/2011/08/acer-liquid-e-issues/"/>
    <updated>2011-08-06T22:21:00+03:00</updated>
    <id>http://rtg.in.ua/blog/2011/08/acer-liquid-e-issues</id>
    <content type="html"><![CDATA[<div class='post'>
<div>
Так как этот телефон все еще продается в магазинах, то хотел бы описать его недостатки, которые становятся заметными через некоторое время. Возможно, это кому-нибудь поможет в выборе.<br />
<!-- more -->
<h2>
Перезагрузка во время звонка</h2>
<div style="text-align: center;">
<iframe class="youtube-player" frameborder="0" height="320" src="http://www.youtube.com/embed/N8OcZ4peLag" type="text/html" width="400"></iframe></div>
В GSM сети life:) Украина с тремя разными SIM картами телефон неоднократно перезагружался при входящем звонке, если во время приема звонка шла передача данных по GPRS/EDGE. На видео выше прошивка 2.1 - снял <b>bigzverua</b>, на моем экземпляре прошивка 2.2 (даже 2.2.2, baseband A1-05.01.06) и повторить можно без проблем. На SIM Beeline и Utel (в режиме GSM роуминга в Kyivstar и в их UMTS сети) таких проблем не наблюдалось. Также у телефона может зависнуть GSM часть при исходящем звонке. В таком случае в трубке будет слышен тихий шум, через некоторое время пропадет GSM сигнал и телефон перезагрузится.<br />
<h2>Датирование фотографий - 2002-12-08</h2>
Все фотографии, сделанные стандартным приложением Camera на Acer Liquid E будут датированы восьмым декабря 2002 года в полдень. Эта дата прошита в библиотеке, которая работает с камерой. В галерее фотографии будут группироваться правильно до первого подключения телефона в режиме USB носителя к компьютеру. После отключения от компьютера запускается сканер медиаконтента, который перечитает дату создания снимка и все фотографии будут отображаться в группе 2002-го года. При загрузке фотографий на ресурсы, которые умеют смотреть на EXIF (или импорт в десктопные приложения), сортировка по дате будет бесполезна. <a href="http://en.wikipedia.org/wiki/File:Sky_Towers_1.jpg">Пример</a>.<br />
<h2>
Температура</h2>
Очень часто при работе в сети нижняя часть телефона ощутимо греется <a href="https://twitter.com/#%21/RomanYepishev/status/109539757196972032">(больше +38℃)</a>. Этого не происходит при использовании телефона как плеера в кармане. Недавно пользовались телефоном как GPS навигатором (Google Maps) в машине с подключенной зарядкой. Телефон разогревался до такого состояния, что отключал зарядку аккумулятора.<br />
<h2>
Элементы управления</h2>
На телефоне кнопка включения и камеры расположены так, что сложно сразу определить перевернут ли телефон (например, нажать на кнопку питания для разблокировки экрана до того, как посмотреть на аппарат). Сенсорная клавиша &#8220;Меню&#8221; достаточно часто нажимается при попытке ввода текста в портретной ориентации. <br />
Чувствительность экрана также оставляет желать лучшего. После того, как я снял защитную пленку (есть в комплекте), которую я заботливо наклеил в первый день после покупки, экран стал ощутимо чувствительнее. <br />
<img src="http://ubuntuone.com/p/Tk8/" style="float: left; height: 320px; margin-right: 20px; width: 192px;" /><br />
<h2>
Acer UI</h2>
В этой модели панель нотификаций в Acer UI находится снизу, поэтому постоянно нажимается при попытке набрать пробел на экранной клавиатуре. В следующих моделях панель нотификаций вернули на место. Acer UI появился в прошивке 2.2, его можно выключить и использовать почти стандартный интерфейс Android. <br />
К сожалению, пользоваться клавиатурой XT9 также не совсем удобно, отсутствуют некоторые специальные символы, нет украинских букв. Клавиатуру можно поставить другую из Android Market.<br />
<h2>Место для приложений</h2>
<p>Для пользовательских данных существует раздел /data на 200 мегабайт. Даже если приложения ставятся на SD-карту, odex файл с кодом приложения копируется в /data/dalvik-cache, и при больших объемах приложений, внутренней памяти начинает не хватать. Отваливается возможность получать SMS или сохранять кеш браузера.</p>
<div style="clear: both;">
</div>
<br />
Аппарат остается моим основным телефоном, но уже с Utel (если пришлось менять оператора из-за перезагрузок, то почему бы не на UMTS?). Даты правлю с помощью скриптов при импортировании а от Acer UI избавился, поставив прошивку от Vodafone Italy (которая, впрочем, перезагрузки с <i>life:)</i> не исправила). Если бы я знал все, что я описал выше до покупки, то этот телефон бы брать не стал. Хотя, может это был просто намек, что надо менять оператора? </div></div>
]]></content>
  </entry>
  
  <entry>
    <title type="html"><![CDATA[Проблема с HUAWEI E1550 после активации голоса через MTS PatchDataCard]]></title>
    <link href="http://rtg.in.ua/blog/2011/07/huawei-e1550-problem-after-voice-unlock/"/>
    <updated>2011-07-17T23:17:00+03:00</updated>
    <id>http://rtg.in.ua/blog/2011/07/huawei-e1550-problem-after-voice-unlock</id>
    <content type="html"><![CDATA[<div class='post'>
<p><b>Update:</b> Еще раз перешил модем, уже поправив дату для программы и  убрав невозможность разблокирования. В принципе, это активатор голоса  для life:) украина, 255-06, требуется только добавить свой IMEI. Скачать  можно с&nbsp;<a href="http://ubuntuone.com/p/159a/">Ubuntu One</a> или <a href="http://narod.ru/disk/19416228001/PatchDataCard.zip.html">Яндекс.Народа</a>. </p>

<p>Загорелся я идеей подключить свой life:) модем еще и для голоса. Первый вариант, dc-unlocker пока был отложен в сторонку т.к. я еще не готов был платить за вещь, которая, возможно, мне не будет нужна.</p>
<!-- more -->
<p>После того, как я произвел процедуры, описанные в <a href="http://forum.ru-board.com/topic.cgi?forum=6&amp;topic=6480" title="Активация голоса на модемах HUAWEI - [1] :: Мобила :: Компьютерный форум Ru.Board">активации голоса на модемах HUAWEI E1550, E1750, Е156, E160 и подобных</a>, мой модем больше не захотел подключаться к сети life:) и настаивал на переезде в Россию к МТС. AT^CARDLOCK возвращали &#8220;+CME ERROR: 16&#8221;. Похоже, что в патче к nvram SIM LOCK сделался неснимаемым для моего модема.</p>

<p>В Resource Hacker, который будет в том-же архиве по инструкции нужно сменить IMEI. Но для того, чтобы все заработало мне пришлось менять и SIMLOCK_RANGE_0 на значения life - 25506. На всякий случай оставил 25506|25506|2 - для чего еще раз идентификатор и что значит &#8220;2&#8221; - я не знаю.Возможно это и есть флаг, который указывает на то, можно ли снимать привязку. После изменения любого значения в ресурсе, программа будет ругаться на несоответствие CRC. Над чем именно вычисляется CRC я не докопался, поэтому пошел в лоб - отлавливать значение CRC, которое программа хочет увидеть.</p>

<p>После скачивания в IDA ставим breakpoint на text.00403853 (в районе CRCSlow), запускаем программу через отладчик, когда сработает breakpoint в регистре ESI будет значение контрольной суммы, которое нужно прописать в [CRC] VALUE. Переводим значение из шестнадцатеричного в десятичный, еще раз идем в Resource Hacker, меняем значение суммы, Compile Script, Save и запускаем PatchDataCard снова.</p>
<p>Фух. Я думал, что придется возиться долго.</p>
<p>
Кстати, там еще есть и ресурс с датой, до которой программа может работать, думаю, можно тоже подправить. И, возможно, полностью снести SIM LOCK. Не знаю, результатом доволен. Модем снова зарегистрировался в сети life:)
</p>
<pre>AT+CREG?
+CREG: 0,1

OK
AT^CVOICE?
^CVOICE:0,8000,16,20

OK
</pre>
<p>
Версия прошивки - 11.030.01.07.388
</p></div>
]]></content>
  </entry>
  
  <entry>
    <title type="html"><![CDATA[The world is full of colors!]]></title>
    <link href="http://rtg.in.ua/blog/2011/07/world-is-full-of-colors/"/>
    <updated>2011-07-05T16:13:00+03:00</updated>
    <id>http://rtg.in.ua/blog/2011/07/world-is-full-of-colors</id>
    <content type="html"><![CDATA[<div class='post'>
<img src="http://4.bp.blogspot.com/-sAYZb90sY2I/ThMD-Qmh1wI/AAAAAAAAG-U/lfYZzQugX3Y/s400/colorhelp64.png" class="post-icon-std" />
<p>You can install <b>Color Help</b> application from <a href="https://market.android.com/details?id=net.lappyfamily.colorhelp">Android Market</a>.</p>
<p>I&#8217;ve always had problems identifying the colors. I kept avoiding color-related talks because I felt uncomfortable not being able to name the color, even though I saw that it was different. In 2007 I was finally diagnosed with a partial color blindness and my inability to identify the colors started making sense</p>
<p>The strange part of this is that given two cards of dark green and brown I had problems identifying which is which but when those cards were shown together I could name the colors. Then I found out that sometimes gray color is seen as purple and different light colors were really hard to identify.</p>
<p>But the world is full of colors and sometimes it is really required to tell the other person the color of an object, and it&#8217;s better to be a correct one.</p>
<p>Fast-forward to today, now I have a mobile phone which can be programmed, the API is available and there are lots of examples. So I decided to write my own version of real-world color picker that will help me with my color problem</p>
<div class="separator" style="clear: both; text-align: center;">
<a href="http://3.bp.blogspot.com/-6mgDiMXUkQU/ThMJZFZlIrI/AAAAAAAAG-g/Do5QZbdnhKE/s1600/colorhelp-screen.png" imageanchor="1" style=""><img border="0" height="240" width="400" src="http://3.bp.blogspot.com/-6mgDiMXUkQU/ThMJZFZlIrI/AAAAAAAAG-g/Do5QZbdnhKE/s400/colorhelp-screen.png" /></a></div>
<p>I wanted it to be a real-time application and it should have been as simple as possible. I also wanted it to be Open Source so that other people with the same issues as I could add/fix/propose something. And I wanted to test Android Market account.</p>
<p>You can get the <b>Color Help</b> application from <a href="https://market.android.com/details?id=net.lappyfamily.colorhelp">Android Market</a> for free and <a href="https://code.launchpad.net/~rye/+junk/colorhelp-android">browse the source code in Launchpad</a></p>
<p>Planned features include better NV12 to RGB conversion that is using less CPU, fixes for occasional color detection hanging after returning to Color Help from another application and probably transformation of the stream to color-correct the image to finally be able to pass these crazy color blindness tests :)</p>
<p>I am now aware of the Color ID and Color Find applications, but being able to create something that scratches my own itch in a way I need it and make the source open is a nice exercise too!</p></div>
]]></content>
  </entry>
  
  <entry>
    <title type="html"><![CDATA[Tomblog Note Publishing]]></title>
    <link href="http://rtg.in.ua/blog/2011/03/tomblog-note-publishing/"/>
    <updated>2011-03-28T00:40:00+03:00</updated>
    <id>http://rtg.in.ua/blog/2011/03/tomblog-note-publishing</id>
    <content type="html"><![CDATA[<div class='post'>
<div style="background-color: #f5f5f5;padding: 5px;">
Update (2011-09-16): At the moment the example web site is down. A number of users of Ubuntu One are unable to access CouchDB service due to poor CouchDB performance. The team is working on bringing additional hardware. If you are among the first 475000 users of Ubuntu One then this script will not work.
</div>
<p>You may be interested in this if you:</p>
<ol>
<li>are using Tomboy or Gnote<a href="#tomblog-gnote"><sup>*</sup></a> to store your notes;</li>
<li>want to publish your note easily</li>
</ol>

<p>Well, it is not that far away from now. I&#8217;ve spent this weekend building a simple yet useful django application called tomblog.</p>
<p>First of all the idea to publish the notes from Ubuntu One is not new but at the moment this is not possible via the official web interface. Since CouchDB HTTP access is open for everyone with correct credentials, this is pretty easy to do as a 3rd party service.</p>

<h3>Screenshot</h3>
<a href="http://notes.rtg.in.ua/1df9344f-c854-4aaa-ab29-2b1b1f86c506/"><img src="http://ubuntuone.com/p/jiW/" style="width:650px;height:592px;" /></a>

<h3>Installation notes</h3>
<p>The project is quite new and it is currently a single-user installation. You can grab the code from <b>lp:tomblog</b>. It is easy to add Disqus-powered comments too, there is a JS code snippet in the template for that.</p>
<p>Please note that the code will allow displaying <em>any</em> note you have stored in your Ubuntu One database if the note UUID is known. The code will create links to the notes only if the target note is published, though.</p>
<p>In order to run tomblog on your server you will need to fill in your OAUTH_* credentials in settings-example.py and rename it to settings.py (I just took ones from my keyring), configure the templates dir, create the corresponding CouchDB views from data/views.js, install the following:
<ul>
<li>python-oauth</li>
<li>python-django</li>
<li>python-lxml</li></ul> create the django wsgi application and configure apache server. As you see there is a lot of manual work currently but I plan to enable the service to be available for every Ubuntu One subscriber as a third party application utilizing Ubuntu One/CouchDB API.</p>

<h3>Under the hood</h3>
<p>When you sync your Tomboy notes with Ubuntu One server, the notes are stored in CouchDB on the server side.</p>
<p>This web application is basically a http client which fetches your notes tagged with some specific tag (in my case - Tomboy notebook called &quot;Publish&quot;), performs XML to HTML conversion and displays the published note.</p>
<p>It uses my OAuth token to retrieve the documents and my token can only be used with my CouchDB databases.</p>

<h3>Live Example</h3>
<p>The current trunk is running on <a href="http://notes.rtg.in.ua" title="Index - Roman Yepishev Notes">notes.rtg.in.ua</a> and looks to be pretty working. Drop me a comment if you find this idea useful too.</p>

<p><sup><a name="tomblog-gnote">*</a></sup> GNote is not currently syncing using Snowy protocol. There is a script to sync GNote notes to local CouchDB called gussie, you can grab it from <b>lp:~rye/+junk/gussie</b>.</p></div>
]]></content>
  </entry>
  
  <entry>
    <title type="html"><![CDATA[Отчеты в налоговую по E-Mail]]></title>
    <link href="http://rtg.in.ua/blog/2011/03/tax-office-reports-via-email/"/>
    <updated>2011-03-16T23:33:00+02:00</updated>
    <id>http://rtg.in.ua/blog/2011/03/tax-office-reports-via-email</id>
    <content type="html"><![CDATA[<div class='post'>
<p>Что огорчает предпринимателя на едином налоге в Украине? То, что каждый квартал нужно сдавать отчет в Налоговую, а сейчас потребовалось ежемесячно сдавать пустую декларацию.</p>

<p>Раньше это означало, что несколько дней в году нужно провести в налоговой инспекции, стоя в очередях. По какой-то причине в один прекрасный момент это перестало быть интересным нашей налоговой администрации, и было решено разрешить предпринимателям сдавать отчеты в электронной форме.</p>

<p>Для этого требуется получить ключ и сертификат в одном из <a href="http://www.sta.gov.ua/control/uk/publish/article?art_id=115103&cat_id=115063">авторизованных центров сертификации</a>, принести этот сертификат в налоговую, заключить с инспекцией <a href="http://www.sta.gov.ua/control/uk/publish/article?art_id=249361&cat_id=249353&showHidden=1">договор</a> о том, что отныне документы, подписанные Вашим ключом, будут приравниваться к оригиналам, скачать ПО для создания (возможны различные варианты) и шифрования (зависит от центра сертификации) отчетов и начать им пользоваться.</p>

<p>Единственным неудобством для меня является необходимость использования Windows, т.к. HTML Application &#8220;ОПЗ&#8221; отказывается запускаться под Wine. Однако приложение для шифрования отчетов спокойно запускается в Wine и все красиво показывает, если ему передать LC_ALL=uk_UA.UTF-8.</p>

<h2>Как все происходит</h2>
<p>Сдача отчетов проходит следующим образом:</p>
<ol>
<li>Создаю документ в OPZ в виртуальной Windows.</li>
<li>Копирую результат на основную машину в папку, которая синхронизируется с Ubuntu One.</li>
<li>Программа для шифрования подписывает мой отчет и шифрует его публичным ключом налоговой администрации.</li>
<li>Результирующий файл я отправляю по E-Mail на шлюз электронной отчетности.</li>
<li>В течении нескольких минут мне приходят несколько зашифрованных сообщений, в которых говорится о статусе обработки отчета.</li>
</ol>
<p>Почему-то первой реакцией моих коллег на то, что я сдаю отчетность в электронном виде, было непонимание, зачем мне для четырех раз в год этим было заниматься, да еще и платить 48₴ в год. В качестве примера удобства данного механизма я начал приводить свой отчет, отправленный 2010-01-04 в 00:18. Через несколько минут отчет был принят, и у меня был регистрационный номер. В час ночи.</p>

<h2>Об ошибках</h2>
<p>Пока единственной проблемой, с которой я столкнулся,​ было следующее сообщение от шлюза отчетности:</p>
<blockquote>
Блок даних. Невірний підпис - сертифікат відсутній в базі сертифікатів
</blockquote>
<p>
Как оказалось, сертификаты ИВК имеют свойство менять свой тип на &#8220;печатка&#8221; вместо &#8220;підпис&#8221;. После звонка в налоговую и (как ни странно) приятного и результативного общения с сотрудницей отдела, занимающегося электронной отчетностью, я смог отправить декларацию без каких-либо проблем, попивая чай у себя дома.</p></div>
]]></content>
  </entry>
  
  <entry>
    <title type="html"><![CDATA[Screen Flashlight: Building the first app]]></title>
    <link href="http://rtg.in.ua/blog/2011/02/screen-flashlight-building-first-app/"/>
    <updated>2011-02-10T12:06:00+02:00</updated>
    <id>http://rtg.in.ua/blog/2011/02/screen-flashlight-building-first-app</id>
    <content type="html"><![CDATA[<div class='post'>
<img class="post-icon-std" src="http://4.bp.blogspot.com/-T6en0bfH_6U/TVO-oTCdoNI/AAAAAAAAFoQ/Z1597IxC3xE/s400/android-app.png" />
<p>So, I finally got an Android-based Acer Liquid S100 (Liquid E, with 512Mb RAM). I&#8217;ve spent some time to get accustomed to the Acer changes to the UI and apps and finally found that I can not use Funambol Sync properly on that device. Acer simply replaced the Contacts application with their own version which does not ask for the application to edit the contact. Basically Funambol Contacts are read-only on that device. So I started looking around to find how android is being built.</p>
<p>Liquid E does not have any flash LED (the only thing I am missing that was in my Nokia 5530). The flashlight is rather important to have so every time I reflashed the device to stock state I had to go to Android Market and pick the simplest app possible. At some moment I realized that I cannot find that application anymore.</p>
<h2>How hard is it to build a blank screen/full brightness app?</h2>

<p>AndroidManifest.xml:</p>
<pre class="code">
&lt;?xml version=&quot;1.0&quot; encoding=&quot;utf-8&quot;?&gt;
&lt;manifest xmlns:android=&quot;http://schemas.android.com/apk/res/android&quot;
      package=&quot;com.errormessaging.screenlight&quot;
      android:versionCode=&quot;1&quot;
      android:versionName=&quot;1.0&quot;&gt;
    &lt;application android:icon=&quot;@drawable/icon&quot;
                 android:label=&quot;@string/app_name&quot;
                 android:theme=&quot;@android:style/Theme.NoTitleBar.Fullscreen&quot;&gt;
        &lt;activity android:name=&quot;.ScreenLight&quot;
                  android:label=&quot;@string/app_name&quot;&gt;
            &lt;intent-filter&gt;
                &lt;action android:name=&quot;android.intent.action.MAIN&quot; /&gt;
                &lt;category android:name=&quot;android.intent.category.LAUNCHER&quot; /&gt;
            &lt;/intent-filter&gt;
        &lt;/activity&gt;
    &lt;/application&gt;
&lt;/manifest&gt;
</pre>
<p>src/com/errormessaging/screenlight/ScreenLight.java:</p>
<pre class="code">
package com.errormessaging.screenlight;

import android.app.Activity;
import android.os.Bundle;
import android.view.WindowManager;

public class ScreenLight extends Activity {
    /** Called when the activity is first created. */
    @Override
    public void onCreate(Bundle savedInstanceState) {
        WindowManager.LayoutParams lp = getWindow().getAttributes();
        lp.screenBrightness = 1f;
        lp.flags |= WindowManager.LayoutParams.FLAG_KEEP_SCREEN_ON;
        getWindow().setAttributes(lp);
        
        super.onCreate(savedInstanceState);
        setContentView(R.layout.main);
    }
}
</pre>
<p>That&#8217;s it.</p>
<h2>Source</h2>
<p>Full source code for this awesome application is available in Launchpad Bazaar:<br/>
<b>bzr branch lp:~rye/+junk/screenlight-android</b><br/>
You can download the compiled <b>Screen Light.apk</b> (signed with debug key) from <a href="http://ubuntuone.com/p/cXN/">Ubuntu One</a></p></div>
]]></content>
  </entry>
  
  <entry>
    <title type="html"><![CDATA[Ubuntu One. The Gallery]]></title>
    <link href="http://rtg.in.ua/blog/2010/12/ubuntu-one-gallery/"/>
    <updated>2010-12-18T23:36:00+02:00</updated>
    <id>http://rtg.in.ua/blog/2010/12/ubuntu-one-gallery</id>
    <content type="html"><![CDATA[<div class='post'>
<p>I&#8217;ve been thinking about this since the day Ubuntu One team announced public file sharing. If Ubuntu One is able to provide public access to virtually any type of content then writing the automatic publishing tool and attaching it to in-browser gallery should be pretty trivial.</p>
<p>So the code started to be written&#8230;</p>
<p>After a couple of hours the following emerged: Ubuntu One Gallery proudly powered by <a title="A JavaScript gallery for the Fastidious" href="http://galleria.aino.se/">Galleria</a>.</p>

<p>
<a href="http://ubuntuone.com/p/UNE/">
<img src="http://ubuntuone.com/p/UNX/" style="width:600px; height:375">
</a>
</p>
<p>The files are served from Ubuntu One except of jQuery which is downloaded from Google Content Delivery Network (CDN). Here&#8217;s how the gallery above got created on my machine:
<pre>
$ python ubuntuone-gallerize.py --title "Estonia Pics" \
  -o ~/Public/estonia.html \
  /home/rtg/Pictures/Estonia\ Gallery/*.{jpg,JPG}

/home/rtg/Projects/ubuntuone-gallerize/data
Root is /home/rtg/Ubuntu One
on_public_files_list
publish_galleria
publish_files
publish_images
publish_files
build_gallery
</pre>
Please note that due to early development status it most likely fail to create gallery during one run (Ctrl+C and rerun after it complains about volume_id). It will queue files to be published first but may not wait for them to become published. This all will be fixed but for now I am just exploring the possibilities.
</p>

<p>The code for the script that tries to publish the files, creates HTML file and makes your own private copy of galleria is available from <b>lp:~rye/+junk/ubuntuone-galleria</b>. Please use the code only if you feel adventurous and note that it is nowhere near alpha quality. It works for me and I&#8217;d like people to have access to that code as early as possible. By the way, it will not publish the resulting file for now (rev 2).</p></div>
]]></content>
  </entry>
  
</feed>

