<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom">
  <channel>
    <title>ecksun.com</title>
    <description></description>
    <link>https://ecksun.com/</link>
    <atom:link href="https://ecksun.com/feed.xml" rel="self" type="application/rss+xml"/>
    <pubDate>Mon, 24 Feb 2025 23:09:00 +0100</pubDate>
    <lastBuildDate>Mon, 24 Feb 2025 23:09:00 +0100</lastBuildDate>
    <generator>Jekyll v4.3.4</generator>
    
      <item>
        <title>CPU performance: Why do my cores perform differently?</title>
        <description>&lt;p&gt;This post follows up on &lt;a href=&quot;/performance/2025/01/02/cpu-core-imbalance.html&quot;&gt;CPU Performance: Why is that one core so heavily
utilized?&lt;/a&gt;
where we explored why one core was much more heavily utilized than others, even
with an evenly distributed workload.&lt;/p&gt;

&lt;p&gt;In this post we will look at the other strange behaviour I saw during that load
testing work.&lt;/p&gt;

&lt;h1 id=&quot;background&quot;&gt;Background&lt;/h1&gt;

&lt;p&gt;If you have already read the &lt;a href=&quot;/performance/2025/01/02/cpu-core-imbalance.html&quot;&gt;the previous
post&lt;/a&gt; you can
skip the background section as it contains the same information.&lt;/p&gt;

&lt;p&gt;Last year, I was conducting load testing on a system at work and noticed a
couple of intriguing behaviours.&lt;/p&gt;

&lt;p&gt;I was working with a product that streams MPEG-TS video between processes. This
is commonly achieved by using UDP over localhost as its what most programs
support. But even over localhost there are cases where packets might arrive out
of order, specifically when the sending processes migrates between CPU cores.&lt;/p&gt;

&lt;p&gt;The simplest way of mitigating this issue is to pin the various threads to
specific CPU cores to ensure each thread only ever runs on one core.&lt;/p&gt;

&lt;p&gt;During load testing I pinned 200 processes to 20 cores, with 10 threads per
core. Despite each CPU performing the same amount of work the load distribution
was uneven:&lt;/p&gt;

&lt;p&gt;&lt;img src=&quot;/images/2025-01-01/uneven-cpu-load.png&quot; alt=&quot;Uneaven CPU load with both issues&quot; width=&quot;100%&quot; /&gt;&lt;/p&gt;

&lt;p&gt;When I first saw this, two questions immediately came to mind:&lt;/p&gt;

&lt;ul&gt;
  &lt;li&gt;What is going on with cpu8?&lt;/li&gt;
  &lt;li&gt;What is causing cpu12–cpu19 to have a higher load than cpu0–cpu11?&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;This post will only address the last question, check out &lt;a href=&quot;/performance/2025/01/02/cpu-core-imbalance.html&quot;&gt;the previous
post&lt;/a&gt; for a
deep dive into the first.&lt;/p&gt;

&lt;p&gt;After solving the first issue the CPU load looked like this:&lt;/p&gt;

&lt;p&gt;&lt;img src=&quot;/images/2025-01-01/uneven-cpu-load-fixed-hashing.png&quot; alt=&quot;Uneaven CPU load&quot; width=&quot;100%&quot; /&gt;&lt;/p&gt;

&lt;h1 id=&quot;what-is-causing-cpu12-cpu19-to-have-a-higher-load-than-cpu0-cpu11&quot;&gt;What is causing cpu12-cpu19 to have a higher load than cpu0-cpu11?&lt;/h1&gt;

&lt;p&gt;In three words; &lt;a href=&quot;https://en.wikipedia.org/wiki/Heterogeneous_computing#Heterogeneous_CPU_topology&quot;&gt;Heterogeneous CPU topology&lt;/a&gt;.&lt;/p&gt;

&lt;p&gt;Many consumer Intel CPUs use something they call P-cores and E-cores, for
&lt;strong&gt;P&lt;/strong&gt;erformance cores and &lt;strong&gt;E&lt;/strong&gt;fficiency cores. Arm’s implementation is know as
&lt;a href=&quot;https://en.wikipedia.org/wiki/ARM_big.LITTLE&quot;&gt;big.LITTLE&lt;/a&gt;.&lt;/p&gt;

&lt;p&gt;The system I tested used an &lt;a href=&quot;https://www.intel.com/content/www/us/en/products/sku/232134/intel-core-i513500e-processor-24m-cache-up-to-4-60-ghz/specifications.html&quot;&gt;Intel Core
i5-13500E&lt;/a&gt;,
which has 6 P-cores and 8 E-cores. The P-cores use Intel’s
&lt;a href=&quot;https://en.wikipedia.org/wiki/Hyper-threading&quot;&gt;Hyper-threading&lt;/a&gt;, so each
appears as two logical processors to the operating system.&lt;/p&gt;

&lt;p&gt;Thus the first 12 cores in the screenshot are the P-cores and the last 8 are
the E-cores. Evidently the E-cores are less performant than the P-cores and
thus the same work results in higher utilization.&lt;/p&gt;

&lt;h1 id=&quot;why-is-that-a-problem&quot;&gt;Why is that a problem?&lt;/h1&gt;

&lt;p&gt;For most consumer devices — like desktops, laptops and phones — this isn’t a
problem. The system uses the power-efficient E-cores for lighter tasks and the
high-performance P-cores for heavier work, providing both efficiency and speed.&lt;/p&gt;

&lt;p&gt;However in my case I’d like to utilize the computer as much as possible to get
the most value out of it. Thus if I naively assign tasks to cores as in the
screenshot above I can only put as many tasks on the computer as the least
performant cores allows, leaving resources on the table on the more performant
cores.&lt;/p&gt;

&lt;h1 id=&quot;the-solution&quot;&gt;The solution&lt;/h1&gt;

&lt;p&gt;There are many different CPU topologies, designs and architectures. There is no
simple way of taking it all into account. Especially since it also heavily
depends on the workload.&lt;/p&gt;

&lt;p&gt;There is a program called &lt;a href=&quot;https://www.open-mpi.org/projects/hwloc/&quot;&gt;lstopo(1)&lt;/a&gt;
that I really like. It visualizes your system’s CPU topology, showing how cores
and threads are distributed across the system. It’s a simple but powerful tool
and I highly recommend you try it out yourself.&lt;/p&gt;

&lt;p&gt;&lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;lstopo(1)&lt;/code&gt; has this excellent page called “&lt;a href=&quot;https://www-lb.open-mpi.org/projects/hwloc/lstopo/&quot;&gt;The Best of
lstopo&lt;/a&gt;” which very well
illustrates how many different CPU topologies and architectures there exists
out there.&lt;/p&gt;

&lt;p&gt;My solution was to simply use the maximum CPU clock frequency for each CPU. I
read the maximum frequency from
&lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;/sys/devices/system/cpu/cpu[0-9]*/cpufreq/cpuinfo_max_freq&lt;/code&gt; and used the ratio
between the core frequencies to balance task distribution.&lt;/p&gt;

&lt;h1 id=&quot;result&quot;&gt;Result&lt;/h1&gt;

&lt;p&gt;The result is a more evenly distributed load across the CPU cores. The system is
still running 200 processes, but they are now better balanced across the cores:&lt;/p&gt;

&lt;div class=&quot;crossfade&quot;&gt;
  &lt;img class=&quot;bottom&quot; src=&quot;/images/2025-01-01/uneven-cpu-load-fixed-hashing.png&quot; alt=&quot;Before&quot; /&gt;
  &lt;img class=&quot;top&quot; src=&quot;/images/2025-01-01/uneven-cpu-load-fixed-both.png&quot; alt=&quot;After&quot; /&gt;
&lt;/div&gt;

&lt;p&gt;As a result, on a fully loaded system, CPU utilization can be increased by
about 20% (from 240 to 288 processes).&lt;/p&gt;
</description>
        <pubDate>Sat, 04 Jan 2025 00:00:00 +0100</pubDate>
        <link>https://ecksun.com/performance/2025/01/04/cpu-core-utilization.html</link>
        <guid isPermaLink="true">https://ecksun.com/performance/2025/01/04/cpu-core-utilization.html</guid>
        
        <category>Performance</category>
        
        <category>Intel</category>
        
        <category>CPU</category>
        
        
        <category>performance</category>
        
      </item>
    
      <item>
        <title>CPU performance: Why is that one core so heavily utilized?</title>
        <description>&lt;h1 id=&quot;background&quot;&gt;Background&lt;/h1&gt;

&lt;p&gt;Last year, I was conducting load testing on a system at work and noticed a
couple of intriguing behaviours.&lt;/p&gt;

&lt;p&gt;I was working with a product that streams MPEG-TS video between processes. This
is commonly achieved by using UDP over localhost as it’s what most programs
support. But even over localhost there are cases where packets might arrive out
of order, specifically when the sending processes migrates between CPU cores.&lt;/p&gt;

&lt;p&gt;The simplest way of mitigating this issue is to pin the various threads to
specific CPU cores to ensure each thread only ever runs on one core.&lt;/p&gt;

&lt;p&gt;During load testing I pinned 200 processes to 20 cores, with 10 threads per
core. Despite each CPU performing the same amount of work the load distribution
was uneven:&lt;/p&gt;

&lt;p&gt;&lt;img src=&quot;/images/2025-01-01/uneven-cpu-load.png&quot; alt=&quot;Uneaven CPU load&quot; width=&quot;100%&quot; /&gt;&lt;/p&gt;

&lt;p&gt;When I first saw this, two questions immediately came to mind:&lt;/p&gt;

&lt;ul&gt;
  &lt;li&gt;What is going on with cpu8?&lt;/li&gt;
  &lt;li&gt;What is causing cpu12–cpu19 to have a higher load than cpu0–cpu11?&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;This post will only address the first question, the second is coming in a later post.&lt;/p&gt;

&lt;h1 id=&quot;what-is-going-on-with-cpu8&quot;&gt;What is going on with cpu8?&lt;/h1&gt;

&lt;p&gt;Trying to understand what was happening, I turned to
&lt;a href=&quot;https://sysstat.github.io/&quot;&gt;mpstat(1)&lt;/a&gt; which showed that cpu8 was doing much
more &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;%soft&lt;/code&gt; than the other CPU cores:&lt;/p&gt;

&lt;p&gt;&lt;img src=&quot;/images/2025-01-01/mpstat.png&quot; alt=&quot;mpstat&quot; /&gt;&lt;/p&gt;

&lt;p&gt;&lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;%soft&lt;/code&gt; refers to software interrupts and is a mechanism used by the kernel to
handle I/O such as networking more efficiently.&lt;/p&gt;

&lt;p&gt;&lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;/proc/interrupts&lt;/code&gt; showed about the same thing as &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;mpstat(1)&lt;/code&gt; (I have not
included a screenshot as it is a &lt;em&gt;very&lt;/em&gt; wide table). However it also indicated
that all cores were processing interrupts for the network interface, however
cpu8 handled many more than the rest.&lt;/p&gt;

&lt;p&gt;This led me to investigate the algorithm the network driver uses to distribute
packets across CPU cores.
&lt;a href=&quot;https://www.kernel.org/pub/software/network/ethtool/&quot;&gt;ethtool(8)&lt;/a&gt; is a tool to
query and control network driver and hardware settings. Specifically it can
both show and change that algorithm if the network driver supports it. We are
looking for “network flow classification”, specifically &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;rx-flow-hash&lt;/code&gt;:&lt;/p&gt;

&lt;div class=&quot;language-plaintext highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;$ sudo ethtool --show-nfc eno3 rx-flow-hash udp4
UDP over IPV4 flows use these fields for computing Hash flow key:
IP SA
IP DA
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;

&lt;p&gt;The &lt;a href=&quot;https://manpages.debian.org/bookworm/ethtool/ethtool.8.en.html&quot;&gt;ethtool(8) manpage&lt;/a&gt; shows what the different letters mean:&lt;/p&gt;

&lt;table&gt;
  &lt;thead&gt;
    &lt;tr&gt;
      &lt;th&gt;Letter&lt;/th&gt;
      &lt;th&gt;Description&lt;/th&gt;
    &lt;/tr&gt;
  &lt;/thead&gt;
  &lt;tbody&gt;
    &lt;tr&gt;
      &lt;td&gt;s&lt;/td&gt;
      &lt;td&gt;Hash on the IP source address of the rx packet.&lt;/td&gt;
    &lt;/tr&gt;
    &lt;tr&gt;
      &lt;td&gt;d&lt;/td&gt;
      &lt;td&gt;Hash on the IP destination address of the rx packet.&lt;/td&gt;
    &lt;/tr&gt;
  &lt;/tbody&gt;
&lt;/table&gt;

&lt;p&gt;As we can see from the output above only the source and destination IP were
used for hashing.&lt;/p&gt;

&lt;p&gt;Interestingly, this behaviour differed from what I observed on other systems.
I’m not sure if it related to the network driver (ixgbe), the operating system
(Ubuntu 22.04) or some other aspect of the system. The algorithm also differs
from tcp4:&lt;/p&gt;

&lt;div class=&quot;language-plaintext highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;$ sudo ethtool --show-nfc eno3 rx-flow-hash tcp4
TCP over IPV4 flows use these fields for computing Hash flow key:
IP SA
IP DA
L4 bytes 0 &amp;amp; 1 [TCP/UDP src port]
L4 bytes 2 &amp;amp; 3 [TCP/UDP dst port]
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;

&lt;p&gt;Since the load test only used one load-generator and one device under test,
both with a single IP configured, both the source and destination IP were the
same. This caused all packets for the load test to be processed on the same CPU
core, that is cpu8.&lt;/p&gt;

&lt;h1 id=&quot;solution&quot;&gt;Solution&lt;/h1&gt;

&lt;p&gt;Once we understood the problem, the solution was simple. We only need to
configure the network driver to also use the source and destination port for
hashing.&lt;/p&gt;

&lt;p&gt;Because hashing occurs on the raw IP packet before the protocol (TCP, UDP etc)
is parsed it is not possible to directly tell it to use the source and
destination port.&lt;/p&gt;

&lt;p&gt;Lets look at the &lt;a href=&quot;https://en.wikipedia.org/wiki/User_Datagram_Protocol#UDP_datagram_structure&quot;&gt;UDP packet header&lt;/a&gt;:&lt;/p&gt;

&lt;div class=&quot;language-plaintext highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt; 0                   1                   2                   3
 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
|          Source Port          |        Destination Port       |
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
|             Length            |            Checksum           |
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;

&lt;p&gt;And compare that with the table from the &lt;a href=&quot;https://manpages.debian.org/bookworm/ethtool/ethtool.8.en.html&quot;&gt;ethtool(8) manpage&lt;/a&gt;:&lt;/p&gt;

&lt;table&gt;
  &lt;thead&gt;
    &lt;tr&gt;
      &lt;th&gt;Letter&lt;/th&gt;
      &lt;th&gt;Description&lt;/th&gt;
    &lt;/tr&gt;
  &lt;/thead&gt;
  &lt;tbody&gt;
    &lt;tr&gt;
      &lt;td&gt;s&lt;/td&gt;
      &lt;td&gt;Hash on the IP source address of the rx packet.&lt;/td&gt;
    &lt;/tr&gt;
    &lt;tr&gt;
      &lt;td&gt;d&lt;/td&gt;
      &lt;td&gt;Hash on the IP destination address of the rx packet.&lt;/td&gt;
    &lt;/tr&gt;
    &lt;tr&gt;
      &lt;td&gt;f&lt;/td&gt;
      &lt;td&gt;Hash on bytes 0 and 1 of the Layer 4 header of the rx packet.&lt;/td&gt;
    &lt;/tr&gt;
    &lt;tr&gt;
      &lt;td&gt;n&lt;/td&gt;
      &lt;td&gt;Hash on bytes 2 and 3 of the Layer 4 header of the rx packet.&lt;/td&gt;
    &lt;/tr&gt;
  &lt;/tbody&gt;
&lt;/table&gt;

&lt;p&gt;We need to hash bytes 0-4 of the UDP header, that is we want the fields &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;fn&lt;/code&gt; in
addition to &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;sd&lt;/code&gt;, thus, to ensure the packets is evenly distributed across
cores, we run:&lt;/p&gt;

&lt;div class=&quot;language-plaintext highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;sudo ethtool --config-nfc enp15s0 rx-flow-hash udp4 sdfn
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;

&lt;h1 id=&quot;result&quot;&gt;Result&lt;/h1&gt;

&lt;p&gt;The result was a much more balanced load distribution, with a slight increase
in load on all other cores:&lt;/p&gt;

&lt;p&gt;&lt;img src=&quot;/images/2025-01-01/uneven-cpu-load-fixed-hashing.png&quot; alt=&quot;More even CPU load&quot; width=&quot;100%&quot; /&gt;&lt;/p&gt;

&lt;p&gt;The difference between the two images is highlighted by fading between them:&lt;/p&gt;

&lt;div class=&quot;crossfade&quot;&gt;
  &lt;img class=&quot;bottom&quot; src=&quot;/images/2025-01-01/uneven-cpu-load.png&quot; alt=&quot;Before&quot; /&gt;
  &lt;img class=&quot;top&quot; src=&quot;/images/2025-01-01/uneven-cpu-load-fixed-hashing.png&quot; alt=&quot;After&quot; /&gt;
&lt;/div&gt;
</description>
        <pubDate>Thu, 02 Jan 2025 00:00:00 +0100</pubDate>
        <link>https://ecksun.com/performance/2025/01/02/cpu-core-imbalance.html</link>
        <guid isPermaLink="true">https://ecksun.com/performance/2025/01/02/cpu-core-imbalance.html</guid>
        
        <category>Performance</category>
        
        <category>CPU</category>
        
        <category>Drivers</category>
        
        <category>Linux</category>
        
        
        <category>performance</category>
        
      </item>
    
      <item>
        <title>Repairing the SHIFT6mq</title>
        <description>&lt;p&gt;One morning my phone stopped recieving a charge. I tried a number of different
chargers, cables and cleaned the USB-C recepticle without luck.&lt;/p&gt;

&lt;h1 id=&quot;shiftphone&quot;&gt;Shiftphone&lt;/h1&gt;

&lt;p&gt;One of the reasons I bought a Shiftphone was their approach to repairability
and sustainability. In practice this means I can buy all spare parts directly
from their webshop and can repair the entire phone with nothing but a
screwdriver. The SHIFT6mq even has a user-replacable battery!&lt;/p&gt;

&lt;h1 id=&quot;ordering-parts&quot;&gt;Ordering parts&lt;/h1&gt;

&lt;p&gt;When my phone stopped charging I went to their store and found the
&lt;a href=&quot;https://shop.shiftphones.com/sub-pcb-usb-mikrofon-vibration.html&quot;&gt;Sub-PCB&lt;/a&gt;.
The product description gave repair instructions and suggested one re-plug the
ribbon cable between the SUB-PCB and the &lt;a href=&quot;https://shop.shiftphones.com/mainboard-reparatur.html&quot;&gt;main
board&lt;/a&gt;. I tried
it but it did not work for me.&lt;/p&gt;

&lt;p&gt;Even though they mention the ribben cable is often at fault I ordered both. I
like having spare parts close at hand and I did not want to wait longer than
needed in case the SUB-PCB was broken.&lt;/p&gt;

&lt;h1 id=&quot;repairing&quot;&gt;Repairing&lt;/h1&gt;

&lt;p&gt;When the parts arrived it also included a small pamphlet with a link to &lt;a href=&quot;https://www.ifixit.com/Guide/SHIFT6mq+Display+replacement/139918&quot;&gt;iFixit
repair
instructions&lt;/a&gt;.
Though they detail how to replace the display most of the steps are the same.&lt;/p&gt;

&lt;p&gt;I dissasembled my phone and tried to replace the SUB-PCB but it still did not charge.&lt;/p&gt;

&lt;p&gt;I then replaced the ribbon cable as well and when I connected the USB-C charger it worked!&lt;/p&gt;

&lt;p&gt;&lt;img src=&quot;/images/2024-03-15/shift6mq-charging.jpg&quot; alt=&quot;Charging again&quot; title=&quot;The phone is charging&quot; /&gt;&lt;/p&gt;

&lt;p&gt;To verify what was broken I reconnected the old SUB-PCB and tried again and the
phone was still accepting a charge!&lt;/p&gt;

&lt;p&gt;Turns out the ribbon cable was broken, exactly as the item description said.&lt;/p&gt;

&lt;p&gt;&lt;img src=&quot;/images/2024-03-15/broken-ribbon-cable.jpg&quot; alt=&quot;Broken ribbon cable&quot; title=&quot;Broken ribbon cable&quot; /&gt;&lt;/p&gt;

&lt;h1 id=&quot;broken-again&quot;&gt;Broken again&lt;/h1&gt;

&lt;p&gt;Sadly, not being very experienced repairing phones I managed to rip the
&lt;a href=&quot;https://shop.shiftphones.com/antennenkabel.html&quot;&gt;antenna cable&lt;/a&gt; out of the
connector, so my phone is still broken :(&lt;/p&gt;

&lt;p&gt;&lt;img src=&quot;/images/2024-03-15/broken-antenna-cable.jpg&quot; alt=&quot;Broken antenna cable&quot; title=&quot;Broken antenna cable&quot; /&gt;&lt;/p&gt;

&lt;p&gt;Thankfully the antenna cable is only 3€, lets hope it ships quickly.&lt;/p&gt;
</description>
        <pubDate>Fri, 15 Mar 2024 00:00:00 +0100</pubDate>
        <link>https://ecksun.com/repair/2024/03/15/Shiftphone-repair.html</link>
        <guid isPermaLink="true">https://ecksun.com/repair/2024/03/15/Shiftphone-repair.html</guid>
        
        <category>phone</category>
        
        <category>repair</category>
        
        <category>shiftphone</category>
        
        
        <category>repair</category>
        
      </item>
    
      <item>
        <title>Read receipts and delivery status notifications</title>
        <description>&lt;p&gt;Sometimes I like to get an explicit acknowledgment that an email has been
delivered and read. While this is possible with anti-patterns such as
tracking-pixels or similar technologies there are other well-established ways
of getting such information in a privacy preserving manner. Lets look at how.&lt;/p&gt;

&lt;h1 id=&quot;read-receipts&quot;&gt;Read receipts&lt;/h1&gt;

&lt;p&gt;Read receipts was first proposed in &lt;a href=&quot;https://www.rfc-editor.org/rfc/rfc2298&quot;&gt;RFC
2298&lt;/a&gt;, updated by &lt;a href=&quot;https://www.rfc-editor.org/rfc/rfc3798&quot;&gt;RFC
3798&lt;/a&gt; and finally became an official
internet standard in &lt;a href=&quot;https://www.rfc-editor.org/rfc/rfc8098&quot;&gt;RFC 8098&lt;/a&gt;.&lt;/p&gt;

&lt;p&gt;The header of interest to us is &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;Disposition-Notification-To&lt;/code&gt;. By setting the header
most clients will prompt the user if they want to send a read receipt back. For
example in thunderbird it looks like this:&lt;/p&gt;

&lt;p&gt;&lt;img src=&quot;/images/2022-11-02/thunderbird-read-receipt.png&quot; alt=&quot;Thunderbird read receipt screenshot&quot; title=&quot;Thunderbird read receipt&quot; /&gt;&lt;/p&gt;

&lt;p&gt;In mutt the default shortcut to edit headers is &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;E&lt;/code&gt;, we can then add the header:&lt;/p&gt;

&lt;div class=&quot;language-plaintext highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;Disposition-Notification-To: John &amp;lt;john@example.com&amp;gt;
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;

&lt;h1 id=&quot;delivery-status-notifications&quot;&gt;Delivery status notifications&lt;/h1&gt;

&lt;p&gt;The mechanism to request Delivery status notifications, also called DSN, was
first proposed in &lt;a href=&quot;https://www.rfc-editor.org/rfc/rfc1891&quot;&gt;RFC 1891&lt;/a&gt; and later
in &lt;a href=&quot;https://www.rfc-editor.org/rfc/rfc3461&quot;&gt;RFC 3461&lt;/a&gt;. It works by adding an
extension to SMTP which means it is not part of the email itself like in the
case of read receipts. Instead it is configured by the client
&lt;a href=&quot;https://en.wikipedia.org/wiki/Message_transfer_agent&quot;&gt;MTA&lt;/a&gt; (your SMTP client).&lt;/p&gt;

&lt;p&gt;In my case I use &lt;a href=&quot;https://marlam.de/msmtp/&quot;&gt;msmtp(1)&lt;/a&gt; so I only need to specify
the &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;--dsn-notify&lt;/code&gt; flag. Per default this is disabled and which means the mail
system decides when to send notifications. In my case I would like to know as
much as possible so I specify &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;--dsn-notify failure,delay,success&lt;/code&gt;.&lt;/p&gt;

&lt;p&gt;To configure &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;msmtp(1)&lt;/code&gt; correctly from mutt we can set &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;sendmail&lt;/code&gt;:&lt;/p&gt;

&lt;div class=&quot;language-plaintext highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;:set sendmail = &apos;/usr/bin/msmtp --read-envelope-from --dsn-notify failure,delay,success&apos;
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;
</description>
        <pubDate>Wed, 02 Nov 2022 00:00:00 +0100</pubDate>
        <link>https://ecksun.com/mail/2022/11/02/mutt-read-receipts-and-dsn.html</link>
        <guid isPermaLink="true">https://ecksun.com/mail/2022/11/02/mutt-read-receipts-and-dsn.html</guid>
        
        <category>mutt</category>
        
        <category>mail</category>
        
        <category>SMTP</category>
        
        <category>msmtp</category>
        
        
        <category>mail</category>
        
      </item>
    
      <item>
        <title>Grow an ext4 filesystem past 16TiB</title>
        <description>&lt;p&gt;One of my filesystems just ran out of space. When I tried to grow it it
complained:&lt;/p&gt;

&lt;div class=&quot;language-plaintext highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;$ sudo lvextend --size +400G /dev/frej/frej /dev/mapper/frej --resizefs
  Size of logical volume frej/frej changed from &amp;lt;15.95 TiB (4180236 extents) to &amp;lt;16.34 TiB (4282636 extents).
  Logical volume frej/frej successfully resized.
resize2fs 1.44.5 (15-Dec-2018)
resize2fs: New size too large to be expressed in 32 bits

fsadm: Resize ext4 failed.
  /sbin/fsadm failed: 1
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;

&lt;p&gt;The magic limit turns out to be exactly 16TiB, or &lt;math&gt;16 * 2⁴⁰B&lt;/math&gt;.&lt;/p&gt;

&lt;ul&gt;
  &lt;li&gt;The block size is &lt;math&gt;4096B = 2¹²B&lt;/math&gt;&lt;/li&gt;
  &lt;li&gt;There are &lt;math&gt;2³²&lt;/math&gt; blocks.&lt;/li&gt;
  &lt;li&gt;
    &lt;math&gt;2¹²B * 2³² = 2⁴⁴B = 16 * 2⁴⁰B = 16 TiB&lt;/math&gt;
  &lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;The solution is naturally to use 64 bits instead. 64bit mode is described in
&lt;a href=&quot;https://www.man7.org/linux/man-pages/man5/ext4.5.html&quot;&gt;ext4(5)&lt;/a&gt;:&lt;/p&gt;

&lt;blockquote&gt;
  &lt;p&gt;Enables the file system to be larger than 2^32 blocks. This feature is set
automatically, as needed, but it can be useful to specify this feature
explicitly if the file system might need to be resized larger than 2^32
blocks, even if it was smaller than that threshold when it was originally
created. Note that some older kernels and older versions of e2fsprogs will
not support file systems with this ext4 feature enabled.&lt;/p&gt;
&lt;/blockquote&gt;

&lt;p&gt;This filesystem was created long ago. Way before I could have volumes larger
than 16TiB. Over time I upgraded the hardware and resized the volume. Today I
reached 16TiB and all of a sudden 32 bits was no longer enough.&lt;/p&gt;

&lt;p&gt;Changing the volume to 64bit mode is quite easy. Simply pass the &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;-b&lt;/code&gt; flag to
&lt;a href=&quot;https://www.man7.org/linux/man-pages/man8/resize2fs.8.html&quot;&gt;resize2fs(8)&lt;/a&gt;:&lt;/p&gt;

&lt;div class=&quot;language-plaintext highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;$ sudo resize2fs -b /dev/frej/frej
resize2fs 1.44.5 (15-Dec-2018)
Converting the filesystem to 64-bit.
resize2fs: No space left on device while trying to resize /dev/frej/frej
Please run &apos;e2fsck -fy /dev/frej/frej&apos; to fix the filesystem
after the aborted resize operation.
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;

&lt;p&gt;It failed.&lt;/p&gt;

&lt;p&gt;It took me quite a while to figure out why there was no space left. I first
tried to allocate slightly more space on the underlying logical volume. That
failed too.&lt;/p&gt;

&lt;p&gt;Turns out resize2fs require some free space in the filesystem itself. Since I
ran out of space just before growing the filesystem none was available.
Together with this filesystem not having any reserved blocks (&lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;tune2fs -m 0&lt;/code&gt;)
meant the conversion did not work. I removed about 5 GB and tried again:&lt;/p&gt;

&lt;div class=&quot;language-plaintext highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;$ sudo resize2fs -b -p /dev/frej/frej
resize2fs 1.44.5 (15-Dec-2018)
Please run &apos;e2fsck -f /dev/frej/frej&apos; first.

$ sudo e2fsck -f /dev/frej/frej
e2fsck 1.44.5 (15-Dec-2018)
Pass 1: Checking inodes, blocks, and sizes
Pass 2: Checking directory structure
Pass 3: Checking directory connectivity
Pass 4: Checking reference counts
Pass 5: Checking group summary information
frej: 165788/535072768 files (34.3% non-contiguous), 4279267286/4280561664 blocks
$ sudo resize2fs -b -p /dev/frej/frej
resize2fs 1.44.5 (15-Dec-2018)
Converting the filesystem to 64-bit.
Begin pass 2 (max = 25488)
Relocating blocks             XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
Begin pass 3 (max = 130633)
Scanning inode table          XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
Begin pass 5 (max = 4)
Moving inode table            XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
The filesystem on /dev/frej/frej is now 4280561664 (4k) blocks long.
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;

&lt;p&gt;And now the filesystem has the 64bit feature enabled and we can grow it past
16TiB.&lt;/p&gt;
</description>
        <pubDate>Tue, 15 Sep 2020 00:00:00 +0200</pubDate>
        <link>https://ecksun.com/storage/2020/09/15/ext4-64bit.html</link>
        <guid isPermaLink="true">https://ecksun.com/storage/2020/09/15/ext4-64bit.html</guid>
        
        <category>Linux</category>
        
        <category>LVM</category>
        
        <category>ext4</category>
        
        
        <category>storage</category>
        
      </item>
    
      <item>
        <title>Presseeding a BeagleBone Black</title>
        <description>&lt;h1 id=&quot;introduction&quot;&gt;Introduction&lt;/h1&gt;

&lt;p&gt;I have gotten a hold of quite a few &lt;a href=&quot;https://beagleboard.org/black/&quot;&gt;BeagleBone
Blacks&lt;/a&gt;, a single-board computer much like the
more well known &lt;a href=&quot;https://www.raspberrypi.org/&quot;&gt;Raspberry Pi&lt;/a&gt;. The important
difference to a Rasperry is that the BeagleBone Black can run a completely
open-source system. BeagleBone does provide images based on Debian that you can
flash directly, however I prefer to run upstream Debian without modifications.&lt;/p&gt;

&lt;p&gt;As an example one of my use-cases for some BeagleBones is as simple WiFi Access
Points in order to extend the coverage of my home WiFi network. I might detail
that setup in a future post.&lt;/p&gt;

&lt;p&gt;This post will show how I go about installing Debian on a BeagleBone Black.&lt;/p&gt;

&lt;h1 id=&quot;first-steps&quot;&gt;First steps&lt;/h1&gt;

&lt;p&gt;When I first try to boot the Debian installer from an SD-card it fails, the
only output on the serial console is an ever growing number of the character
&lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;C&lt;/code&gt;:&lt;/p&gt;

&lt;div class=&quot;language-plaintext highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;CCCCCCCCCCCCCCCCCCCCCCCCCC
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;

&lt;p&gt;I don’t understand why this is however I think its related to the u-boot
version that is flashed on my BeagleBones (which is not the same as what they
come shipped with).&lt;/p&gt;

&lt;h2 id=&quot;installing-beaglebones-official-image&quot;&gt;Installing BeagleBones official image&lt;/h2&gt;

&lt;p&gt;In order to solve the boot issue I first install the BeagleBone provided image,
which upgrades the u-boot version.&lt;/p&gt;

&lt;p&gt;First off, lets download the latest image from &lt;a href=&quot;https://beagleboard.org/latest-images&quot;&gt;BeagleBones
website&lt;/a&gt; and flash it to an SD-card:&lt;/p&gt;

&lt;div class=&quot;language-plaintext highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;xzcat ~/Downloads/bone-debian-10.3-iot-armhf-2020-04-06-4gb.img.xz &amp;gt; /dev/sdb
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;

&lt;p&gt;In order to get the BeagleBone to boot from the SD-card you need to hold down
the button next to the USB-port while you power the BeagleBone, otherwise it
will simply boot from the eMMC.&lt;/p&gt;

&lt;p&gt;Then I follow &lt;a href=&quot;https://elinux.org/Beagleboard:BeagleBoneBlack_Debian#Flashing_eMMC&quot;&gt;these
instructions&lt;/a&gt;
for flashing that image to the eMMC. Essentially this only involves
uncommenting the following line in &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;/boot/uEnv.txt&lt;/code&gt;:&lt;/p&gt;

&lt;div class=&quot;language-plaintext highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;# cmdline=init=/opt/scripts/tools/eMMC/init-eMMC-flasher-v3.sh
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;

&lt;p&gt;and then reboot, which will start flashing the image to the eMMC.&lt;/p&gt;

&lt;h2 id=&quot;installing-debian&quot;&gt;Installing Debian&lt;/h2&gt;

&lt;p&gt;After the BeagleBone provided image has been flashed I can boot the ordinary
Debian installer from an SD-card. According to &lt;a href=&quot;https://www.debian.org/releases/stable/armhf/ch05s01.en.html#boot-installer-sd-image&quot;&gt;the Debian
manual&lt;/a&gt;
the images can be &lt;a href=&quot;http://http.us.debian.org/debian/dists/buster/main/installer-armhf/current/images/netboot/SD-card-images/&quot;&gt;downloaded from a debian
mirror&lt;/a&gt;
and written to an SD-card:&lt;/p&gt;

&lt;div class=&quot;language-bash highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;wget http://http.us.debian.org/debian/dists/buster/main/installer-armhf/current/images/netboot/SD-card-images/firmware.BeagleBoneBlack.img.gz
wget http://http.us.debian.org/debian/dists/buster/main/installer-armhf/current/images/netboot/SD-card-images/partition.img.gz

zcat firmware.BeagleBoneBlack.img.gz partition.img.gz &lt;span class=&quot;o&quot;&gt;&amp;gt;&lt;/span&gt; /dev/SD_CARD_DEVICE
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;

&lt;p&gt;Once inserted into the BeagleBone once again hold down the button next to the
USB-port while powering it to boot from the SD-card.&lt;/p&gt;

&lt;h1 id=&quot;preseeding&quot;&gt;Preseeding&lt;/h1&gt;

&lt;p&gt;We will use &lt;a href=&quot;https://wiki.debian.org/DebianInstaller/Preseed&quot;&gt;preseeding&lt;/a&gt; to
automate the installation. This makes the system more easily reproducible and
allows us to leave the installation mostly unattended, which is especially nice
on a slower system such as the BeagleBone. In my case I chose to &lt;a href=&quot;https://wiki.debian.org/DebianInstaller/Preseed#Loading_the_preseeding_file_from_a_webserver&quot;&gt;preseed from
a
webserver&lt;/a&gt;
as it requires the least amount of setup beforehand.&lt;/p&gt;

&lt;p&gt;First off, we need to stop the automatic boot, I generally just spam the space
bar as soon as I have powered on the system. The serial-port will display
something similar to:&lt;/p&gt;

&lt;blockquote&gt;
  &lt;p&gt;Press SPACE to abort autoboot in 0 seconds&lt;/p&gt;
&lt;/blockquote&gt;

&lt;p&gt;Then we just need to provide our own boot arguments to the installer to have it
fetch the preseed file:&lt;/p&gt;

&lt;div class=&quot;language-plaintext highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;env set bootargs auto url=https://example.com/preseed.cfg
boot
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;

&lt;p&gt;Once the installer has started we can press &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;ESC&lt;/code&gt; and select the preseed entry
in the menu:&lt;/p&gt;

&lt;blockquote&gt;
  &lt;p&gt;Download debconf preconfiguration file&lt;/p&gt;
&lt;/blockquote&gt;

&lt;p&gt;Before the installer &lt;a href=&quot;https://debian-handbook.info/browse/stable/sect.automated-installation.html#id-1.15.6.10.6&quot;&gt;downloads the preseed
file&lt;/a&gt;
it will ask a few questions. The questions are relating to network
configuration and will not be preseeded if the preseed file is supplied via the
network.&lt;/p&gt;

&lt;p&gt;However, once the installer has downloaded the preseed file it will continue
with the rest of the installation unattended and leave you with a working
system by the end.&lt;/p&gt;

&lt;h2 id=&quot;date-issues&quot;&gt;Date issues&lt;/h2&gt;

&lt;p&gt;The BeagleBone does not have a persistent hardware clock so it is not uncommon
for the time of the device to be off by years. This is problematic when the
installer needs to fetch the preseed file over https as that requires a system
time to be somewhat close to reality. When it is too far off, i.e. years, the
certificates will be invalid as their notBefore date is in the far future.&lt;/p&gt;

&lt;p&gt;This can easily be solved by just setting the time, press &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;ESC&lt;/code&gt; and select the
shell entry in the menu:&lt;/p&gt;

&lt;blockquote&gt;
  &lt;p&gt;Execute a shell&lt;/p&gt;
&lt;/blockquote&gt;

&lt;p&gt;Once in the shell, set the date and exit:&lt;/p&gt;

&lt;div class=&quot;language-plaintext highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;date --set &quot;2020-06-17 00:00&quot;
exit
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;

&lt;p&gt;Once done retry the “Download debconf preconfiguration file” step.&lt;/p&gt;
</description>
        <pubDate>Wed, 17 Jun 2020 00:00:00 +0200</pubDate>
        <link>https://ecksun.com/beaglebone/2020/06/17/Beaglebone-preseeding.html</link>
        <guid isPermaLink="true">https://ecksun.com/beaglebone/2020/06/17/Beaglebone-preseeding.html</guid>
        
        <category>Debian</category>
        
        <category>Buster</category>
        
        <category>BeagleBone</category>
        
        <category>Preseed</category>
        
        
        <category>beaglebone</category>
        
      </item>
    
      <item>
        <title>Pingeling</title>
        <description>&lt;p&gt;A common issue when managing a larger number of hosts is knowing whether they
are online or not. A couple of weeks ago I got a little time on my hands and
felt like solving that problem.&lt;/p&gt;

&lt;p&gt;The idea is to ping every possible host every so often, parse the response and
finally publish a JSON object to kafka for future processing.&lt;/p&gt;

&lt;p&gt;We split our problem into four distinct parts and tackle them one at a time:&lt;/p&gt;

&lt;ol&gt;
  &lt;li&gt;Ping all hosts continuously with &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;fping&lt;/code&gt;&lt;/li&gt;
  &lt;li&gt;Parse the output from &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;fping&lt;/code&gt; with &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;bash&lt;/code&gt;’s regular expressions&lt;/li&gt;
  &lt;li&gt;Create a JSON message with &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;jq&lt;/code&gt;&lt;/li&gt;
  &lt;li&gt;Send the finished JSON object to &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;kafka&lt;/code&gt; with &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;kafkacat&lt;/code&gt;&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;In essence what we are doing is performing simple stream processing. The source
of our stream is &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;fping&lt;/code&gt;. The data is then transformed with &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;jq&lt;/code&gt; into JSON and
finally the sent to our sink, kafka.&lt;/p&gt;

&lt;h1 id=&quot;ping-hosts&quot;&gt;Ping hosts&lt;/h1&gt;

&lt;p&gt;There are many easy ways of sending ICMP echo requests to all hosts in a
network, such as forking &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;ping&lt;/code&gt; a bunch of times or using &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;paralell&lt;/code&gt;. However
that doesn’t scale particularly well and is difficult to parse. Therefore we
use a tool called &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;fping&lt;/code&gt; which gives us the ability to ping entire subnets
very easily and efficiently.&lt;/p&gt;

&lt;div class=&quot;language-bash highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;fping &lt;span class=&quot;nt&quot;&gt;-A&lt;/span&gt; &lt;span class=&quot;nt&quot;&gt;-e&lt;/span&gt; &lt;span class=&quot;nt&quot;&gt;-l&lt;/span&gt; &lt;span class=&quot;nt&quot;&gt;-b12&lt;/span&gt; &lt;span class=&quot;nt&quot;&gt;-p&lt;/span&gt; 60 &lt;span class=&quot;nt&quot;&gt;-g&lt;/span&gt; 192.168.1.0/24
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;

&lt;p&gt;An explanation of the arguments, these can obviously be found in the
&lt;a href=&quot;https://manpages.debian.org/jessie/fping/fping.8.en.html&quot;&gt;manpage&lt;/a&gt;.&lt;/p&gt;

&lt;table&gt;
  &lt;thead&gt;
    &lt;tr&gt;
      &lt;th&gt;Argument&lt;/th&gt;
      &lt;th&gt;Explanation&lt;/th&gt;
    &lt;/tr&gt;
  &lt;/thead&gt;
  &lt;tbody&gt;
    &lt;tr&gt;
      &lt;td&gt;&lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;-A&lt;/code&gt;&lt;/td&gt;
      &lt;td&gt;Display IP address instead of DNS name&lt;/td&gt;
    &lt;/tr&gt;
    &lt;tr&gt;
      &lt;td&gt;&lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;-e&lt;/code&gt;&lt;/td&gt;
      &lt;td&gt;Show round trip time, we want to know how responsive the host is&lt;/td&gt;
    &lt;/tr&gt;
    &lt;tr&gt;
      &lt;td&gt;&lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;-l&lt;/code&gt;&lt;/td&gt;
      &lt;td&gt;Continue forever&lt;/td&gt;
    &lt;/tr&gt;
    &lt;tr&gt;
      &lt;td&gt;&lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;-b&lt;/code&gt;&lt;/td&gt;
      &lt;td&gt;Message size, the minimal size is 12 bytes&lt;/td&gt;
    &lt;/tr&gt;
    &lt;tr&gt;
      &lt;td&gt;&lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;-p&lt;/code&gt;&lt;/td&gt;
      &lt;td&gt;Time between ICMP echo requests&lt;/td&gt;
    &lt;/tr&gt;
    &lt;tr&gt;
      &lt;td&gt;&lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;-g&lt;/code&gt;&lt;/td&gt;
      &lt;td&gt;The netmask to ping&lt;/td&gt;
    &lt;/tr&gt;
  &lt;/tbody&gt;
&lt;/table&gt;

&lt;h1 id=&quot;handling-fping-output&quot;&gt;Handling fping output&lt;/h1&gt;

&lt;h2 id=&quot;reading-the-output&quot;&gt;Reading the output&lt;/h2&gt;

&lt;p&gt;We do not care about the statistics &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;fping&lt;/code&gt; prints, as they are printed to
&lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;stderr&lt;/code&gt; we can easily ignoring them by piping &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;stderr&lt;/code&gt; to &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;/dev/null&lt;/code&gt; with
&lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;2&amp;gt;/dev/null&lt;/code&gt;.&lt;/p&gt;

&lt;p&gt;Each ping reply is printed to its own line, we thus use the bash builtin &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;read&lt;/code&gt;
to read one line, for example:&lt;/p&gt;

&lt;div class=&quot;language-bash highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;&lt;span class=&quot;o&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;nb&quot;&gt;echo &lt;/span&gt;first line &lt;span class=&quot;o&quot;&gt;&amp;amp;&amp;amp;&lt;/span&gt; &lt;span class=&quot;nb&quot;&gt;echo &lt;/span&gt;second line&lt;span class=&quot;o&quot;&gt;)&lt;/span&gt; | &lt;span class=&quot;k&quot;&gt;while &lt;/span&gt;&lt;span class=&quot;nb&quot;&gt;read &lt;/span&gt;LINE&lt;span class=&quot;p&quot;&gt;;&lt;/span&gt; &lt;span class=&quot;k&quot;&gt;do
    &lt;/span&gt;&lt;span class=&quot;nb&quot;&gt;echo&lt;/span&gt; &lt;span class=&quot;s2&quot;&gt;&quot;&lt;/span&gt;&lt;span class=&quot;nv&quot;&gt;$LINE&lt;/span&gt;&lt;span class=&quot;s2&quot;&gt;&quot;&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;;&lt;/span&gt;
&lt;span class=&quot;k&quot;&gt;done&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;

&lt;h2 id=&quot;parsing-the-output&quot;&gt;Parsing the output&lt;/h2&gt;

&lt;p&gt;As bash have native support for regular expressions we use a regex to parse the
fping output.&lt;/p&gt;

&lt;p&gt;We define an IP address as anything matching &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;0-9a-fA-F.:&lt;/code&gt;. &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;0-9.&lt;/code&gt; matches IPv4
addresses only, while the extra characters &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;a-fA-F:&lt;/code&gt; are used to match IPv6
addresses as well&lt;/p&gt;

&lt;p&gt;An example of what we want to parse:&lt;/p&gt;

&lt;div class=&quot;language-plaintext highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;192.168.1.1   : [0], 40 bytes, 0.38 ms (0.38 avg, 0% loss)
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;

&lt;table&gt;
  &lt;thead&gt;
    &lt;tr&gt;
      &lt;th&gt;Field&lt;/th&gt;
      &lt;th&gt;Regex&lt;/th&gt;
    &lt;/tr&gt;
  &lt;/thead&gt;
  &lt;tbody&gt;
    &lt;tr&gt;
      &lt;td&gt;IP Address&lt;/td&gt;
      &lt;td&gt;&lt;pre&gt;&lt;code&gt;&lt;strong&gt;([0-9a-fA-F.:]+)&lt;/strong&gt; +: \[(.*)\], (.*) bytes, (.*) ms \((.*) avg, (.*)% loss\)&lt;/code&gt;&lt;/pre&gt;&lt;/td&gt;
    &lt;/tr&gt;
    &lt;tr&gt;
      &lt;td&gt;Sequence number&lt;/td&gt;
      &lt;td&gt;&lt;pre&gt;&lt;code&gt;([0-9a-fA-F.:]+) +: &lt;strong&gt;\[(.*)\]&lt;/strong&gt;, (.*) bytes, (.*) ms \((.*) avg, (.*)% loss\)&lt;/code&gt;&lt;/pre&gt;&lt;/td&gt;
    &lt;/tr&gt;
    &lt;tr&gt;
      &lt;td&gt;Message size&lt;/td&gt;
      &lt;td&gt;&lt;pre&gt;&lt;code&gt;([0-9a-fA-F.:]+) +: \[(.*)\], &lt;strong&gt;(.*) bytes&lt;/strong&gt;, (.*) ms \((.*) avg, (.*)% loss\)&lt;/code&gt;&lt;/pre&gt;&lt;/td&gt;
    &lt;/tr&gt;
    &lt;tr&gt;
      &lt;td&gt;Round trip time&lt;/td&gt;
      &lt;td&gt;&lt;pre&gt;&lt;code&gt;([0-9a-fA-F.:]+) +: \[(.*)\], (.*) bytes, &lt;strong&gt;(.*) ms&lt;/strong&gt; \((.*) avg, (.*)% loss\)&lt;/code&gt;&lt;/pre&gt;&lt;/td&gt;
    &lt;/tr&gt;
    &lt;tr&gt;
      &lt;td&gt;Avarage response time&lt;/td&gt;
      &lt;td&gt;&lt;pre&gt;&lt;code&gt;([0-9a-fA-F.:]+) +: \[(.*)\], (.*) bytes, (.*) ms \(&lt;strong&gt;(.*) avg&lt;/strong&gt;, (.*)% loss\)&lt;/code&gt;&lt;/pre&gt;&lt;/td&gt;
    &lt;/tr&gt;
    &lt;tr&gt;
      &lt;td&gt;Ratio of lost packages&lt;/td&gt;
      &lt;td&gt;&lt;pre&gt;&lt;code&gt;([0-9a-fA-F.:]+) +: \[(.*)\], (.*) bytes, (.*) ms \((.*) avg, &lt;strong&gt;(.*)% loss&lt;/strong&gt;\)&lt;/code&gt;&lt;/pre&gt;&lt;/td&gt;
    &lt;/tr&gt;
  &lt;/tbody&gt;
&lt;/table&gt;

&lt;p&gt;The final regex ended up looking like this:&lt;/p&gt;

&lt;div class=&quot;language-plaintext highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;([0-9a-fA-F.:]+) +: \[(.*)\], (.*) bytes, (.*) ms \((.*) avg, (.*)% loss\)
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;

&lt;h1 id=&quot;formatting-data-before-sending&quot;&gt;Formatting data before sending&lt;/h1&gt;

&lt;p&gt;&lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;jq&lt;/code&gt; is a very powerful tool if you wish to either parse or generate JSON.&lt;/p&gt;

&lt;p&gt;The final JSON object which we send to kafka should contain four fields, &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;ip&lt;/code&gt;,
&lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;size&lt;/code&gt;, &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;roundtrip&lt;/code&gt; and &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;time&lt;/code&gt;. For readability’s sake I have added newlines
and indentations to the example below, however we will skip that in the final
object.&lt;/p&gt;

&lt;div class=&quot;language-json highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;&lt;span class=&quot;p&quot;&gt;{&lt;/span&gt;&lt;span class=&quot;w&quot;&gt;
    &lt;/span&gt;&lt;span class=&quot;nl&quot;&gt;&quot;ip&quot;&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;:&lt;/span&gt;&lt;span class=&quot;w&quot;&gt; &lt;/span&gt;&lt;span class=&quot;s2&quot;&gt;&quot;192.168.1.1&quot;&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt;&lt;span class=&quot;w&quot;&gt;
    &lt;/span&gt;&lt;span class=&quot;nl&quot;&gt;&quot;size&quot;&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;:&lt;/span&gt;&lt;span class=&quot;w&quot;&gt; &lt;/span&gt;&lt;span class=&quot;s2&quot;&gt;&quot;40&quot;&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt;&lt;span class=&quot;w&quot;&gt;
    &lt;/span&gt;&lt;span class=&quot;nl&quot;&gt;&quot;roundtrip&quot;&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;:&lt;/span&gt;&lt;span class=&quot;w&quot;&gt; &lt;/span&gt;&lt;span class=&quot;mf&quot;&gt;0.38&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt;&lt;span class=&quot;w&quot;&gt;
    &lt;/span&gt;&lt;span class=&quot;nl&quot;&gt;&quot;time&quot;&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;:&lt;/span&gt;&lt;span class=&quot;w&quot;&gt; &lt;/span&gt;&lt;span class=&quot;s2&quot;&gt;&quot;2015-06-23T22:42:14,033793204+0200&quot;&lt;/span&gt;&lt;span class=&quot;w&quot;&gt;
&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;}&lt;/span&gt;&lt;span class=&quot;w&quot;&gt;
&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;

&lt;p&gt;Since everything in bash is strings we need to transform the &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;roundtrip&lt;/code&gt; and
&lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;size&lt;/code&gt; to numbers, we can do this with the &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;jq&lt;/code&gt; function &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;tonumber&lt;/code&gt;. Our final
&lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;jq&lt;/code&gt; filter will thus look like this:&lt;/p&gt;

&lt;div class=&quot;language-bash highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;&lt;span class=&quot;o&quot;&gt;{&lt;/span&gt; &lt;span class=&quot;s2&quot;&gt;&quot;ip&quot;&lt;/span&gt;: &lt;span class=&quot;nv&quot;&gt;$ip&lt;/span&gt;, &lt;span class=&quot;s2&quot;&gt;&quot;size&quot;&lt;/span&gt;: &lt;span class=&quot;nv&quot;&gt;$size&lt;/span&gt;|tonumber, &lt;span class=&quot;s2&quot;&gt;&quot;roundtrip&quot;&lt;/span&gt;: &lt;span class=&quot;nv&quot;&gt;$roundtrip&lt;/span&gt;|tonumber, &lt;span class=&quot;s2&quot;&gt;&quot;time&quot;&lt;/span&gt;: &lt;span class=&quot;nv&quot;&gt;$now&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;}&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;

&lt;p&gt;We tell &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;jq&lt;/code&gt; to only generate with &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;--null-input&lt;/code&gt; and the &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;-output&lt;/code&gt; flags lets
us define a nice format for sending to kafka. Moreover we can provide arguments
to &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;jq&lt;/code&gt; with the &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;--arg&lt;/code&gt; argument, arguments in &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;jq&lt;/code&gt; behave much like arguments
in bash and will be substituted for their value.&lt;/p&gt;

&lt;div class=&quot;language-bash highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;jq &lt;span class=&quot;se&quot;&gt;\&lt;/span&gt;
    &lt;span class=&quot;nt&quot;&gt;--null-input&lt;/span&gt; &lt;span class=&quot;se&quot;&gt;\&lt;/span&gt;
    &lt;span class=&quot;nt&quot;&gt;--compact-output&lt;/span&gt; &lt;span class=&quot;nt&quot;&gt;--ascii-output&lt;/span&gt; &lt;span class=&quot;nt&quot;&gt;--monochrome-output&lt;/span&gt; &lt;span class=&quot;se&quot;&gt;\&lt;/span&gt;
    &lt;span class=&quot;nt&quot;&gt;--arg&lt;/span&gt; ip &lt;span class=&quot;s2&quot;&gt;&quot;192.168.1.1&quot;&lt;/span&gt; &lt;span class=&quot;se&quot;&gt;\&lt;/span&gt;
    &lt;span class=&quot;nt&quot;&gt;--arg&lt;/span&gt; size &lt;span class=&quot;s2&quot;&gt;&quot;40&quot;&lt;/span&gt; &lt;span class=&quot;se&quot;&gt;\&lt;/span&gt;
    &lt;span class=&quot;nt&quot;&gt;--arg&lt;/span&gt; roundtrip &lt;span class=&quot;s2&quot;&gt;&quot;0.38&quot;&lt;/span&gt; &lt;span class=&quot;se&quot;&gt;\&lt;/span&gt;
    &lt;span class=&quot;nt&quot;&gt;--arg&lt;/span&gt; now &lt;span class=&quot;s2&quot;&gt;&quot;2015-06-23T22:42:14,033793204+0200&quot;&lt;/span&gt; &lt;span class=&quot;se&quot;&gt;\&lt;/span&gt;
    &lt;span class=&quot;s1&quot;&gt;&apos;{ &quot;ip&quot;: $ip, &quot;size&quot;: $size|tonumber, &quot;roundtrip&quot;: $roundtrip|tonumber, &quot;time&quot;: $now }&apos;&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;

&lt;h1 id=&quot;kafka&quot;&gt;Kafka&lt;/h1&gt;

&lt;p&gt;Finally we want to send the output to kafka, this is trivial by simply piping
the result to &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;kafkacat&lt;/code&gt;. &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;kafkacat&lt;/code&gt; will interpret each line as a separate
message and send it to the topic specified.&lt;/p&gt;

&lt;h1 id=&quot;the-finished-script&quot;&gt;The finished script&lt;/h1&gt;

&lt;p&gt;Putting everything together we get something similar to this:&lt;/p&gt;

&lt;div class=&quot;language-bash highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;&lt;span class=&quot;c&quot;&gt;#!/bin/bash&lt;/span&gt;

&lt;span class=&quot;nv&quot;&gt;TARGET_NETWORK&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;s2&quot;&gt;&quot;10.0.0.0/22&quot;&lt;/span&gt;
&lt;span class=&quot;nv&quot;&gt;WAIT_TIMEOUT&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;k&quot;&gt;$((&lt;/span&gt;&lt;span class=&quot;m&quot;&gt;5&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;*&lt;/span&gt;&lt;span class=&quot;m&quot;&gt;60&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;*&lt;/span&gt;&lt;span class=&quot;m&quot;&gt;1000&lt;/span&gt;&lt;span class=&quot;k&quot;&gt;))&lt;/span&gt;
&lt;span class=&quot;nv&quot;&gt;BROKERS&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;s2&quot;&gt;&quot;zk.example.com&quot;&lt;/span&gt;

fping &lt;span class=&quot;nt&quot;&gt;-A&lt;/span&gt; &lt;span class=&quot;nt&quot;&gt;-e&lt;/span&gt; &lt;span class=&quot;nt&quot;&gt;-l&lt;/span&gt; &lt;span class=&quot;nt&quot;&gt;-b12&lt;/span&gt; &lt;span class=&quot;nt&quot;&gt;-p&lt;/span&gt; &lt;span class=&quot;s2&quot;&gt;&quot;&lt;/span&gt;&lt;span class=&quot;nv&quot;&gt;$WAIT_TIMEOUT&lt;/span&gt;&lt;span class=&quot;s2&quot;&gt;&quot;&lt;/span&gt; &lt;span class=&quot;nt&quot;&gt;-g&lt;/span&gt; &lt;span class=&quot;s2&quot;&gt;&quot;&lt;/span&gt;&lt;span class=&quot;nv&quot;&gt;$TARGET_NETWORK&lt;/span&gt;&lt;span class=&quot;s2&quot;&gt;&quot;&lt;/span&gt; 2&amp;gt;/dev/null &lt;span class=&quot;se&quot;&gt;\&lt;/span&gt;
    | &lt;span class=&quot;k&quot;&gt;while &lt;/span&gt;&lt;span class=&quot;nb&quot;&gt;read&lt;/span&gt; &lt;span class=&quot;nt&quot;&gt;-r&lt;/span&gt; PING_RESPONSE&lt;span class=&quot;p&quot;&gt;;&lt;/span&gt; &lt;span class=&quot;k&quot;&gt;do
    
    &lt;/span&gt;&lt;span class=&quot;nv&quot;&gt;regex&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;s2&quot;&gt;&quot;([0-9a-fA-F.:]+) +: &lt;/span&gt;&lt;span class=&quot;se&quot;&gt;\[&lt;/span&gt;&lt;span class=&quot;s2&quot;&gt;(.*)&lt;/span&gt;&lt;span class=&quot;se&quot;&gt;\]&lt;/span&gt;&lt;span class=&quot;s2&quot;&gt;, (.*) bytes, (.*) ms &lt;/span&gt;&lt;span class=&quot;se&quot;&gt;\(&lt;/span&gt;&lt;span class=&quot;s2&quot;&gt;(.*) avg, (.*)% loss&lt;/span&gt;&lt;span class=&quot;se&quot;&gt;\)&lt;/span&gt;&lt;span class=&quot;s2&quot;&gt;&quot;&lt;/span&gt;
    &lt;span class=&quot;o&quot;&gt;[[&lt;/span&gt; &lt;span class=&quot;nv&quot;&gt;$PING_RESPONSE&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;=&lt;/span&gt;~ &lt;span class=&quot;nv&quot;&gt;$regex&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;]]&lt;/span&gt;
    &lt;span class=&quot;nv&quot;&gt;IP&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;s2&quot;&gt;&quot;&lt;/span&gt;&lt;span class=&quot;k&quot;&gt;${&lt;/span&gt;&lt;span class=&quot;nv&quot;&gt;BASH_REMATCH&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;[1]&lt;/span&gt;&lt;span class=&quot;k&quot;&gt;}&lt;/span&gt;&lt;span class=&quot;s2&quot;&gt;&quot;&lt;/span&gt;
    &lt;span class=&quot;nv&quot;&gt;SIZE&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;s2&quot;&gt;&quot;&lt;/span&gt;&lt;span class=&quot;k&quot;&gt;${&lt;/span&gt;&lt;span class=&quot;nv&quot;&gt;BASH_REMATCH&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;[3]&lt;/span&gt;&lt;span class=&quot;k&quot;&gt;}&lt;/span&gt;&lt;span class=&quot;s2&quot;&gt;&quot;&lt;/span&gt;
    &lt;span class=&quot;nv&quot;&gt;ROUNDTRIP&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;s2&quot;&gt;&quot;&lt;/span&gt;&lt;span class=&quot;k&quot;&gt;${&lt;/span&gt;&lt;span class=&quot;nv&quot;&gt;BASH_REMATCH&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;[4]&lt;/span&gt;&lt;span class=&quot;k&quot;&gt;}&lt;/span&gt;&lt;span class=&quot;s2&quot;&gt;&quot;&lt;/span&gt;

    &lt;span class=&quot;nv&quot;&gt;NOW&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;si&quot;&gt;$(&lt;/span&gt;&lt;span class=&quot;nb&quot;&gt;date&lt;/span&gt; &lt;span class=&quot;nt&quot;&gt;--iso-8601&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;=&lt;/span&gt;ns&lt;span class=&quot;si&quot;&gt;)&lt;/span&gt;

    jq &lt;span class=&quot;se&quot;&gt;\&lt;/span&gt;
        &lt;span class=&quot;nt&quot;&gt;--null-input&lt;/span&gt; &lt;span class=&quot;se&quot;&gt;\&lt;/span&gt;
        &lt;span class=&quot;nt&quot;&gt;--compact-output&lt;/span&gt; &lt;span class=&quot;nt&quot;&gt;--ascii-output&lt;/span&gt; &lt;span class=&quot;nt&quot;&gt;--monochrome-output&lt;/span&gt; &lt;span class=&quot;se&quot;&gt;\&lt;/span&gt;
        &lt;span class=&quot;nt&quot;&gt;--arg&lt;/span&gt; ip &lt;span class=&quot;s2&quot;&gt;&quot;&lt;/span&gt;&lt;span class=&quot;nv&quot;&gt;$IP&lt;/span&gt;&lt;span class=&quot;s2&quot;&gt;&quot;&lt;/span&gt; &lt;span class=&quot;se&quot;&gt;\&lt;/span&gt;
        &lt;span class=&quot;nt&quot;&gt;--arg&lt;/span&gt; size &lt;span class=&quot;s2&quot;&gt;&quot;&lt;/span&gt;&lt;span class=&quot;nv&quot;&gt;$SIZE&lt;/span&gt;&lt;span class=&quot;s2&quot;&gt;&quot;&lt;/span&gt; &lt;span class=&quot;se&quot;&gt;\&lt;/span&gt;
        &lt;span class=&quot;nt&quot;&gt;--arg&lt;/span&gt; roundtrip &lt;span class=&quot;s2&quot;&gt;&quot;&lt;/span&gt;&lt;span class=&quot;nv&quot;&gt;$ROUNDTRIP&lt;/span&gt;&lt;span class=&quot;s2&quot;&gt;&quot;&lt;/span&gt; &lt;span class=&quot;se&quot;&gt;\&lt;/span&gt;
        &lt;span class=&quot;nt&quot;&gt;--arg&lt;/span&gt; now &lt;span class=&quot;s2&quot;&gt;&quot;&lt;/span&gt;&lt;span class=&quot;nv&quot;&gt;$NOW&lt;/span&gt;&lt;span class=&quot;s2&quot;&gt;&quot;&lt;/span&gt; &lt;span class=&quot;se&quot;&gt;\&lt;/span&gt;
        &lt;span class=&quot;s1&quot;&gt;&apos;{ &quot;ip&quot;: $ip, &quot;size&quot;: $size|tonumber, &quot;roundtrip&quot;: $roundtrip|tonumber, &quot;time&quot;: $now }&apos;&lt;/span&gt;

&lt;span class=&quot;k&quot;&gt;done&lt;/span&gt; | kafkacat &lt;span class=&quot;nt&quot;&gt;-P&lt;/span&gt; &lt;span class=&quot;nt&quot;&gt;-b&lt;/span&gt; &lt;span class=&quot;s2&quot;&gt;&quot;&lt;/span&gt;&lt;span class=&quot;nv&quot;&gt;$BROKERS&lt;/span&gt;&lt;span class=&quot;s2&quot;&gt;&quot;&lt;/span&gt; &lt;span class=&quot;nt&quot;&gt;-t&lt;/span&gt; event.JSON.ICMP_response
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;

&lt;h1 id=&quot;conclusion&quot;&gt;Conclusion&lt;/h1&gt;

&lt;p&gt;I started writing this post a while ago but never published. Since then we have
used this script at work in production to keep track of our mobile connected
devices (which is the reason for the small packet size). It has been running
for a long while and has worked flawlessly and without interruption ever since
we first deployed it demonstrating the power of combining simple tools.&lt;/p&gt;
</description>
        <pubDate>Fri, 17 Feb 2017 00:00:00 +0100</pubDate>
        <link>https://ecksun.com/bash/2017/02/17/Pingeling.html</link>
        <guid isPermaLink="true">https://ecksun.com/bash/2017/02/17/Pingeling.html</guid>
        
        <category>bash</category>
        
        <category>fping</category>
        
        <category>jq</category>
        
        <category>kafkacat</category>
        
        <category>kafka</category>
        
        <category>regex</category>
        
        
        <category>bash</category>
        
      </item>
    
      <item>
        <title>SSH Certificate Authorities</title>
        <description>&lt;p&gt;A common nuisance when first connecting with SSH to a server is to verify the
fingerprint. Especially if you have many servers with multiple users, when
everyone needs to know all the fingerprints of all the servers. This can easily
be improved with SSH CA host certificates.&lt;/p&gt;

&lt;p&gt;For example if we were to sign a server’s public key when we provision it,
everyone that already trusts the CA can then also connect to that server
without having to manually verify the fingerprint.&lt;/p&gt;

&lt;p&gt;User certificates on the other hand can help us authorize users to a server
without manually managing each individual key. By deploying a SSH user CA to a
remote host anyone with a valid certificate can connect to it.&lt;/p&gt;

&lt;h1 id=&quot;manpages&quot;&gt;Manpages&lt;/h1&gt;

&lt;p&gt;The manpages of &lt;a href=&quot;http://man.openbsd.org/ssh-keygen&quot;&gt;ssh-keygen(1)&lt;/a&gt; and &lt;a href=&quot;http://man.openbsd.org/sshd&quot;&gt;sshd(8)&lt;/a&gt; contains everything you
need to known about SSH Certificates, of most interest is the section
“CERTIFICATES” of &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;ssh-keygen(1)&lt;/code&gt; and sections “AUTHORIZED_KEYS FILE FORMAT”
and “SSH_KNOWN_HOSTS FILE FORMAT” of &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;sshd(8)&lt;/code&gt;. Use them as a reference and
think of this post as a way to get started.&lt;/p&gt;

&lt;h1 id=&quot;host-certificates&quot;&gt;Host certificates&lt;/h1&gt;

&lt;h2 id=&quot;creating&quot;&gt;Creating&lt;/h2&gt;

&lt;p&gt;The CA itself is generated like any other SSH key.&lt;/p&gt;

&lt;div class=&quot;language-bash highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;ssh-keygen &lt;span class=&quot;nt&quot;&gt;-f&lt;/span&gt; host_ca &lt;span class=&quot;nt&quot;&gt;-t&lt;/span&gt; ed25519
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;

&lt;h2 id=&quot;trusting&quot;&gt;Trusting&lt;/h2&gt;

&lt;p&gt;Users can then choose to trust this CA by adding the a line like toe following
to their &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;known_hosts&lt;/code&gt; file (defined in &lt;a href=&quot;http://man.openbsd.org/sshd&quot;&gt;sshd(8)&lt;/a&gt; section “AUTHORIZED_KEYS
FILE FORMAT”):&lt;/p&gt;

&lt;div class=&quot;language-plaintext highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;@cert-authority *.example.com ssh-ed25519 AAAAC3NzaC1lZDI1NTE5AAAAIIzHKhkOE4C58Zgg/7AO2xXVGKBSAt2iKs9vJgkCu8hh user@host
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;

&lt;p&gt;The second field is to limit the scope of the key, in this case we trust it to
verify everything from &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;*.example.com&lt;/code&gt; but not for example
&lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;secret.example.test&lt;/code&gt;.&lt;/p&gt;

&lt;h2 id=&quot;signing&quot;&gt;Signing&lt;/h2&gt;

&lt;p&gt;This is how we sign a server’s public key, that is, generate a certificate for
that server:&lt;/p&gt;

&lt;div class=&quot;language-bash highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;ssh-keygen &lt;span class=&quot;nt&quot;&gt;-s&lt;/span&gt; &lt;span class=&quot;s2&quot;&gt;&quot;&lt;/span&gt;&lt;span class=&quot;nv&quot;&gt;$HOST_CA&lt;/span&gt;&lt;span class=&quot;s2&quot;&gt;&quot;&lt;/span&gt; &lt;span class=&quot;nt&quot;&gt;-I&lt;/span&gt; &lt;span class=&quot;s2&quot;&gt;&quot;&lt;/span&gt;&lt;span class=&quot;nv&quot;&gt;$IDENTIFIER&lt;/span&gt;&lt;span class=&quot;s2&quot;&gt;&quot;&lt;/span&gt; &lt;span class=&quot;nt&quot;&gt;-h&lt;/span&gt; &lt;span class=&quot;nt&quot;&gt;-n&lt;/span&gt; &lt;span class=&quot;s2&quot;&gt;&quot;&lt;/span&gt;&lt;span class=&quot;nv&quot;&gt;$SERVER_DOMAIN&lt;/span&gt;&lt;span class=&quot;s2&quot;&gt;&quot;&lt;/span&gt; &lt;span class=&quot;s2&quot;&gt;&quot;&lt;/span&gt;&lt;span class=&quot;nv&quot;&gt;$PUBLIC_KEY&lt;/span&gt;&lt;span class=&quot;s2&quot;&gt;&quot;&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;

&lt;p&gt;A quick explanation to the arguments:&lt;/p&gt;

&lt;table&gt;
  &lt;thead&gt;
    &lt;tr&gt;
      &lt;th&gt;Argument&lt;/th&gt;
      &lt;th&gt;Description&lt;/th&gt;
    &lt;/tr&gt;
  &lt;/thead&gt;
  &lt;tbody&gt;
    &lt;tr&gt;
      &lt;td&gt;&lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;-s&lt;/code&gt;&lt;/td&gt;
      &lt;td&gt;The CA key to sign with&lt;/td&gt;
    &lt;/tr&gt;
    &lt;tr&gt;
      &lt;td&gt;&lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;-I&lt;/code&gt;&lt;/td&gt;
      &lt;td&gt;An identifier for the certificate, used for logging and revocation&lt;/td&gt;
    &lt;/tr&gt;
    &lt;tr&gt;
      &lt;td&gt;&lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;-h&lt;/code&gt;&lt;/td&gt;
      &lt;td&gt;Create a host certificate&lt;/td&gt;
    &lt;/tr&gt;
    &lt;tr&gt;
      &lt;td&gt;&lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;-n&lt;/code&gt;&lt;/td&gt;
      &lt;td&gt;Principals, in practice which domain this certificate will be valid for&lt;/td&gt;
    &lt;/tr&gt;
  &lt;/tbody&gt;
&lt;/table&gt;

&lt;p&gt;Its also possible to limit when a certificate is valid with &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;-V&lt;/code&gt;.&lt;/p&gt;

&lt;p&gt;In order to sign the public key &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;ssh_host_ed25519_key.pub&lt;/code&gt; of server
&lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;server.example.com&lt;/code&gt;  with the &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;host_ca&lt;/code&gt; CA we can run:&lt;/p&gt;

&lt;div class=&quot;language-bash highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;ssh-keygen &lt;span class=&quot;nt&quot;&gt;-s&lt;/span&gt; &lt;span class=&quot;s2&quot;&gt;&quot;host_ca&quot;&lt;/span&gt; &lt;span class=&quot;nt&quot;&gt;-I&lt;/span&gt; &lt;span class=&quot;s2&quot;&gt;&quot;user_1@host_ca&quot;&lt;/span&gt; &lt;span class=&quot;nt&quot;&gt;-h&lt;/span&gt; &lt;span class=&quot;nt&quot;&gt;-n&lt;/span&gt; &lt;span class=&quot;s2&quot;&gt;&quot;server.example.com&quot;&lt;/span&gt; &lt;span class=&quot;s2&quot;&gt;&quot;ssh_host_ed25519_key.pub&quot;&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;

&lt;p&gt;This will create a file called &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;ssh_host_ed25519_key-cert.pub&lt;/code&gt; that we need to
configure the server to use. This is done with the &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;HostCertificate&lt;/code&gt; directive
from &lt;a href=&quot;http://man.openbsd.org/sshd_config&quot;&gt;sshd_config(5)&lt;/a&gt;.&lt;/p&gt;

&lt;div class=&quot;language-plaintext highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;HostCertificate /etc/ssh/ssh_host_ed25519_key-cert.pub
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;

&lt;h2 id=&quot;demoing&quot;&gt;Demoing&lt;/h2&gt;

&lt;p&gt;Lets put everything together into a working example.&lt;/p&gt;

&lt;div class=&quot;language-bash highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;ssh-keygen &lt;span class=&quot;nt&quot;&gt;-f&lt;/span&gt; host_ca &lt;span class=&quot;nt&quot;&gt;-t&lt;/span&gt; ed25519
&lt;span class=&quot;nb&quot;&gt;echo&lt;/span&gt; &lt;span class=&quot;s2&quot;&gt;&quot;@cert-authority *.example.com &lt;/span&gt;&lt;span class=&quot;si&quot;&gt;$(&lt;/span&gt;&lt;span class=&quot;nb&quot;&gt;cat &lt;/span&gt;host_ca.pub&lt;span class=&quot;si&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;s2&quot;&gt;&quot;&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;&amp;gt;&amp;gt;&lt;/span&gt; ~/.ssh/known_hosts
scp server.example.com:/etc/ssh/ssh_host_ed25519_key.pub &lt;span class=&quot;nb&quot;&gt;.&lt;/span&gt;
ssh-keygen &lt;span class=&quot;nt&quot;&gt;-s&lt;/span&gt; host_ca &lt;span class=&quot;nt&quot;&gt;-I&lt;/span&gt; &lt;span class=&quot;s2&quot;&gt;&quot;user_1@host_ca&quot;&lt;/span&gt; &lt;span class=&quot;nt&quot;&gt;-h&lt;/span&gt; &lt;span class=&quot;nt&quot;&gt;-n&lt;/span&gt; server.example.com &lt;span class=&quot;se&quot;&gt;\&lt;/span&gt;
    ssh_host_ed25519_key.pub
scp ssh_host_ed25519_key-cert.pub server.example.com:
ssh &lt;span class=&quot;nt&quot;&gt;-t&lt;/span&gt; server.example.com &lt;span class=&quot;s1&quot;&gt;&apos;echo &quot;HostCertificate /etc/ssh/ssh_host_ed25519_key-cert.pub&quot; | sudo tee --append /etc/ssh/sshd_config&apos;&lt;/span&gt;
ssh &lt;span class=&quot;nt&quot;&gt;-t&lt;/span&gt; server.example.com &lt;span class=&quot;nb&quot;&gt;sudo &lt;/span&gt;systemctl reload ssh
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;

&lt;p&gt;Lets test it out&lt;/p&gt;

&lt;div class=&quot;language-bash highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;&lt;span class=&quot;nb&quot;&gt;echo&lt;/span&gt; &lt;span class=&quot;s2&quot;&gt;&quot;@cert-authority *.example.com &lt;/span&gt;&lt;span class=&quot;si&quot;&gt;$(&lt;/span&gt;&lt;span class=&quot;nb&quot;&gt;cat &lt;/span&gt;host_ca.pub&lt;span class=&quot;si&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;s2&quot;&gt;&quot;&lt;/span&gt; &lt;span class=&quot;se&quot;&gt;\&lt;/span&gt;
    | &lt;span class=&quot;nb&quot;&gt;sudo&lt;/span&gt; &lt;span class=&quot;nt&quot;&gt;-u&lt;/span&gt; newuser &lt;span class=&quot;nt&quot;&gt;-i&lt;/span&gt; bash &lt;span class=&quot;nt&quot;&gt;-c&lt;/span&gt; &lt;span class=&quot;s2&quot;&gt;&quot;cat &amp;gt; ~/.ssh/known_hosts&quot;&lt;/span&gt;
&lt;span class=&quot;nb&quot;&gt;sudo&lt;/span&gt; &lt;span class=&quot;nt&quot;&gt;-u&lt;/span&gt; newuser ssh server.example.com
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;

&lt;p&gt;Notice how it does not ask you to verify the fingerprint, as we already trusted
the CA.&lt;/p&gt;

&lt;h1 id=&quot;user-certificates&quot;&gt;User certificates&lt;/h1&gt;

&lt;p&gt;By installing a CA’s public key into a remote users &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;authorized_keys&lt;/code&gt; file (or
globally on the server) everyone who has their public key signed by the CA
(i.e. a certificate) will have access to the server.&lt;/p&gt;

&lt;h2 id=&quot;creating-1&quot;&gt;Creating&lt;/h2&gt;

&lt;p&gt;We create user CA’s in the exact same manner as host CA’s, or ordinary ssh keys
for that matter.&lt;/p&gt;

&lt;div class=&quot;language-bash highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;ssh-keygen &lt;span class=&quot;nt&quot;&gt;-f&lt;/span&gt; &lt;span class=&quot;s2&quot;&gt;&quot;user_ca&quot;&lt;/span&gt; &lt;span class=&quot;nt&quot;&gt;-t&lt;/span&gt; &lt;span class=&quot;s2&quot;&gt;&quot;ed25519&quot;&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;

&lt;h2 id=&quot;trusting-1&quot;&gt;Trusting&lt;/h2&gt;

&lt;p&gt;By adding the user CA’s public key to a remote user’s &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;authorized_keys&lt;/code&gt; file we
will grant access to anyone who has a valid certificate from the CA. For this
to work we also need to give the key the &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;cert-authority&lt;/code&gt; option. The format is
specified by section “AUTHORIZED_KEYS FILE FORMAT” of &lt;a href=&quot;http://man.openbsd.org/sshd&quot;&gt;sshd(8)&lt;/a&gt;.&lt;/p&gt;

&lt;p&gt;For example:&lt;/p&gt;

&lt;div class=&quot;language-plaintext highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;cert-authority ssh-ed25519 AAAAC3NzaC1lZDI1NTE5AAAAIK624pJT4N/5RrU9AE4I5U1fZCVGwlyqM4nylreB15oB user@host
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;

&lt;p&gt;It is also possible to globally install a CA key by using the
&lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;TrustedUserCAKeys&lt;/code&gt; of &lt;a href=&quot;http://man.openbsd.org/sshd_config&quot;&gt;sshd_config(5)&lt;/a&gt;. In that case it is however &lt;strong&gt;very&lt;/strong&gt;
important to limit the scope of the certificates as a certificate will
otherwise give access to any account on the server.&lt;/p&gt;

&lt;h2 id=&quot;signing-1&quot;&gt;Signing&lt;/h2&gt;

&lt;p&gt;A user certificate is generated in much the same way as a host certificate, the
big difference is that the &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;-h&lt;/code&gt; argument is missing.&lt;/p&gt;

&lt;div class=&quot;language-bash highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;ssh-keygen &lt;span class=&quot;nt&quot;&gt;-s&lt;/span&gt; &lt;span class=&quot;s2&quot;&gt;&quot;&lt;/span&gt;&lt;span class=&quot;nv&quot;&gt;$USER_CA&lt;/span&gt;&lt;span class=&quot;s2&quot;&gt;&quot;&lt;/span&gt; &lt;span class=&quot;nt&quot;&gt;-I&lt;/span&gt; &lt;span class=&quot;s2&quot;&gt;&quot;&lt;/span&gt;&lt;span class=&quot;nv&quot;&gt;$IDENTIFIER&lt;/span&gt;&lt;span class=&quot;s2&quot;&gt;&quot;&lt;/span&gt; &lt;span class=&quot;s2&quot;&gt;&quot;&lt;/span&gt;&lt;span class=&quot;nv&quot;&gt;$PUBLIC_KEY&lt;/span&gt;&lt;span class=&quot;s2&quot;&gt;&quot;&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;

&lt;p&gt;The other difference is the principals defined with &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;-n&lt;/code&gt;. With user
certificates they define which users the certificate is valid for, instead of
which hosts. If you have installed the CA globally (with &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;TrustedUserCAKeys&lt;/code&gt; in
&lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;sshd_config&lt;/code&gt;) it is &lt;strong&gt;strongly&lt;/strong&gt; recommended you use this, as the certificate
otherwise will grant access to any account.&lt;/p&gt;

&lt;div class=&quot;language-bash highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;ssh-keygen &lt;span class=&quot;nt&quot;&gt;-s&lt;/span&gt; &lt;span class=&quot;s2&quot;&gt;&quot;&lt;/span&gt;&lt;span class=&quot;nv&quot;&gt;$USER_CA&lt;/span&gt;&lt;span class=&quot;s2&quot;&gt;&quot;&lt;/span&gt; &lt;span class=&quot;nt&quot;&gt;-I&lt;/span&gt; &lt;span class=&quot;s2&quot;&gt;&quot;&lt;/span&gt;&lt;span class=&quot;nv&quot;&gt;$IDENTIFIER&lt;/span&gt;&lt;span class=&quot;s2&quot;&gt;&quot;&lt;/span&gt; &lt;span class=&quot;nt&quot;&gt;-n&lt;/span&gt; &lt;span class=&quot;s2&quot;&gt;&quot;&lt;/span&gt;&lt;span class=&quot;nv&quot;&gt;$USER&lt;/span&gt;&lt;span class=&quot;s2&quot;&gt;&quot;&lt;/span&gt; &lt;span class=&quot;s2&quot;&gt;&quot;&lt;/span&gt;&lt;span class=&quot;nv&quot;&gt;$PUBLIC_KEY&lt;/span&gt;&lt;span class=&quot;s2&quot;&gt;&quot;&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;

&lt;h2 id=&quot;demoing-1&quot;&gt;Demoing&lt;/h2&gt;

&lt;p&gt;Lets try out a working example of user certificates:&lt;/p&gt;

&lt;div class=&quot;language-bash highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;ssh-keygen &lt;span class=&quot;nt&quot;&gt;-f&lt;/span&gt; user_ca &lt;span class=&quot;nt&quot;&gt;-t&lt;/span&gt; ed25519
&lt;span class=&quot;nb&quot;&gt;echo&lt;/span&gt; &lt;span class=&quot;s2&quot;&gt;&quot;cert-authority &lt;/span&gt;&lt;span class=&quot;si&quot;&gt;$(&lt;/span&gt;&lt;span class=&quot;nb&quot;&gt;cat &lt;/span&gt;user_ca.pub&lt;span class=&quot;si&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;s2&quot;&gt;&quot;&lt;/span&gt; &lt;span class=&quot;se&quot;&gt;\&lt;/span&gt;
    | ssh server.example.com &lt;span class=&quot;s2&quot;&gt;&quot;cat &amp;gt;&amp;gt; .ssh/authorized_keys&quot;&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;

&lt;p&gt;And test if it works:&lt;/p&gt;

&lt;div class=&quot;language-bash highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;&lt;span class=&quot;c&quot;&gt;# We use sudo to be able to write to newuser&apos;s homedir in order to simplify&lt;/span&gt;
&lt;span class=&quot;c&quot;&gt;# this demo&lt;/span&gt;
&lt;span class=&quot;nb&quot;&gt;sudo &lt;/span&gt;ssh-keygen &lt;span class=&quot;nt&quot;&gt;-s&lt;/span&gt; user_ca &lt;span class=&quot;nt&quot;&gt;-I&lt;/span&gt; &lt;span class=&quot;s2&quot;&gt;&quot;newuser@user_ca&quot;&lt;/span&gt; ~newuser/.ssh/id_ed25519.pub
&lt;span class=&quot;nb&quot;&gt;sudo&lt;/span&gt; &lt;span class=&quot;nt&quot;&gt;-u&lt;/span&gt; newuser &lt;span class=&quot;nt&quot;&gt;-i&lt;/span&gt; ssh user@server.example.com
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;

&lt;p&gt;Notice that no password is required, in fact, if you followed this post in
order you should have been logged in without neither verifying a fingerprint
nor providing a password.&lt;/p&gt;

&lt;h1 id=&quot;revocation&quot;&gt;Revocation&lt;/h1&gt;

&lt;p&gt;Revoking keys is also possible, however because of the length of this post and
the fact that I have yet to configure any key revocation lists I have chosen
not to discuss that in this post. You can however read about it in the section
“KEY REVOCATION LISTS” of &lt;a href=&quot;http://man.openbsd.org/ssh-keygen&quot;&gt;ssh-keygen(1)&lt;/a&gt;.&lt;/p&gt;

</description>
        <pubDate>Sat, 14 Jan 2017 00:00:00 +0100</pubDate>
        <link>https://ecksun.com/ssh/2017/01/14/SSH_CA.html</link>
        <guid isPermaLink="true">https://ecksun.com/ssh/2017/01/14/SSH_CA.html</guid>
        
        <category>ssh</category>
        
        <category>sshd</category>
        
        <category>CA</category>
        
        
        <category>ssh</category>
        
      </item>
    
      <item>
        <title>One container per connection</title>
        <description>&lt;p&gt;I’m thinking about setting up a wargame like scenario for work and thought it
would be nice if I could have the users ssh to some machines for different
steps of the game. However since the users aren’t really trusted I would prefer
to only give them access to a container. Moreover I don’t want the different
teams to be able to interact with each other on the machine itself, so I needed
to spawn one container for every team.&lt;/p&gt;

&lt;p&gt;This is when I realized that socket-activation is exactly what I want, I just
need to bundle it with docker and all should be well.&lt;/p&gt;

&lt;h1 id=&quot;running-sshd-from-docker&quot;&gt;Running sshd from docker&lt;/h1&gt;

&lt;p&gt;First, we need a Dockerfile&lt;/p&gt;

&lt;div class=&quot;language-Dockerfile highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;&lt;span class=&quot;k&quot;&gt;FROM&lt;/span&gt;&lt;span class=&quot;s&quot;&gt; debian:stretch&lt;/span&gt;

&lt;span class=&quot;k&quot;&gt;RUN &lt;/span&gt;&lt;span class=&quot;o&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;se&quot;&gt;\
&lt;/span&gt;        &lt;span class=&quot;nb&quot;&gt;export &lt;/span&gt;&lt;span class=&quot;nv&quot;&gt;DEBIAN_FRONTEND&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;=&lt;/span&gt;noninteractive &lt;span class=&quot;o&quot;&gt;&amp;amp;&amp;amp;&lt;/span&gt; &lt;span class=&quot;se&quot;&gt;\
&lt;/span&gt;        apt-get update  &lt;span class=&quot;o&quot;&gt;&amp;amp;&amp;amp;&lt;/span&gt; &lt;span class=&quot;se&quot;&gt;\
&lt;/span&gt;        apt-get &lt;span class=&quot;nb&quot;&gt;install&lt;/span&gt; &lt;span class=&quot;nt&quot;&gt;-y&lt;/span&gt; &lt;span class=&quot;nt&quot;&gt;--no-install-recommends&lt;/span&gt; &lt;span class=&quot;se&quot;&gt;\
&lt;/span&gt;            openssh-server &lt;span class=&quot;se&quot;&gt;\
&lt;/span&gt;        &lt;span class=&quot;o&quot;&gt;&amp;amp;&amp;amp;&lt;/span&gt; &lt;span class=&quot;se&quot;&gt;\
&lt;/span&gt;        apt-get autoremove &lt;span class=&quot;o&quot;&gt;&amp;amp;&amp;amp;&lt;/span&gt; &lt;span class=&quot;se&quot;&gt;\
&lt;/span&gt;        apt-get clean &lt;span class=&quot;se&quot;&gt;\
&lt;/span&gt;    &lt;span class=&quot;o&quot;&gt;)&lt;/span&gt;
&lt;span class=&quot;k&quot;&gt;RUN &lt;/span&gt;&lt;span class=&quot;o&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;se&quot;&gt;\
&lt;/span&gt;    useradd &lt;span class=&quot;nt&quot;&gt;--create-home&lt;/span&gt; user &lt;span class=&quot;o&quot;&gt;&amp;amp;&amp;amp;&lt;/span&gt; &lt;span class=&quot;se&quot;&gt;\
&lt;/span&gt;    &lt;span class=&quot;nb&quot;&gt;echo&lt;/span&gt; &lt;span class=&quot;s1&quot;&gt;&apos;user:woop&apos;&lt;/span&gt; | chpasswd &lt;span class=&quot;o&quot;&gt;&amp;amp;&amp;amp;&lt;/span&gt; &lt;span class=&quot;se&quot;&gt;\
&lt;/span&gt;    &lt;span class=&quot;nb&quot;&gt;mkdir&lt;/span&gt; /var/run/sshd &lt;span class=&quot;se&quot;&gt;\
&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;)&lt;/span&gt;

&lt;span class=&quot;k&quot;&gt;CMD&lt;/span&gt;&lt;span class=&quot;s&quot;&gt; /usr/sbin/sshd -i&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;

&lt;p&gt;Everything in this Dockerfile is to get &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;sshd&lt;/code&gt; to run. However the &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;-i&lt;/code&gt; flag is
special. It tells &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;sshd&lt;/code&gt; that it is run from inetd(8). This is what we need to
get socket-activation to work.&lt;/p&gt;

&lt;h1 id=&quot;systemd-units&quot;&gt;Systemd units&lt;/h1&gt;

&lt;p&gt;Now we need to define our systemd units. First we define the unit
(&lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;sshd@.service&lt;/code&gt;) to start the container and sshd in it. This was heavly
inspired by the &lt;a href=&quot;https://git.archlinux.org/svntogit/packages.git/tree/trunk/sshd@.service?h=packages/openssh&amp;amp;id=38518a1e4196a5011fb95b4c37e9a92526be8d1e&quot;&gt;sshd service file in
Arch&lt;/a&gt;.&lt;/p&gt;

&lt;div class=&quot;language-plaintext highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;[Unit]
Description=sshd container

[Service]
ExecStart=-/usr/bin/docker run --rm -i sshd
StandardInput=socket
StandardError=syslog
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;

&lt;p&gt;To be honest I’m not sure if the &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;-i&lt;/code&gt; flag is required, however it helped with
debugging because it made the container behave nicely with ^C.&lt;/p&gt;

&lt;p&gt;&lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;StandardInput=socket&lt;/code&gt; is what will make systemd run this service like inetd(8)
would have.&lt;/p&gt;

&lt;p&gt;We also need to setup the &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;sshd.socket&lt;/code&gt; unit file.&lt;/p&gt;

&lt;div class=&quot;language-plaintext highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;[Unit]
Description=SSH socket

[Socket]
ListenStream=0.0.0.0:22
Accept=yes
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;

&lt;h1 id=&quot;testing&quot;&gt;Testing&lt;/h1&gt;

&lt;p&gt;With all of this up and running, we should be able to connect to the ssh server.&lt;/p&gt;

&lt;div class=&quot;language-bash highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;ssh &lt;span class=&quot;se&quot;&gt;\&lt;/span&gt;
	&lt;span class=&quot;nt&quot;&gt;-o&lt;/span&gt; &lt;span class=&quot;nv&quot;&gt;UserKnownHostsFile&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;=&lt;/span&gt;~/tmp-known_hosts &lt;span class=&quot;se&quot;&gt;\&lt;/span&gt;
	&lt;span class=&quot;nt&quot;&gt;-o&lt;/span&gt; &lt;span class=&quot;nv&quot;&gt;ControlMaster&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;=&lt;/span&gt;no &lt;span class=&quot;se&quot;&gt;\&lt;/span&gt;
	&lt;span class=&quot;nt&quot;&gt;-o&lt;/span&gt; &lt;span class=&quot;nv&quot;&gt;ControlPath&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;=&lt;/span&gt;none &lt;span class=&quot;se&quot;&gt;\&lt;/span&gt;
	user@localhost
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;

&lt;p&gt;I use a custom identityfile as every time you rebuild your container it will
generate a new private key and I don’t want to clutter my ordinary known_hosts
file. Moreover I had to disable ControlMaster as otherwise ssh would simply use
that to connect to the same container I had already connected to.&lt;/p&gt;

&lt;p&gt;Now for the actual test, for brevity I have omitted the motd.&lt;/p&gt;

&lt;div class=&quot;language-plaintext highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;$ ssh -o UserKnownHostsFile=~/tmp-known_hosts -o ControlMaster=no -o ControlPath=none user@localhost
user@localhost&apos;s password: 
$ ls
$ touch asdf
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;

&lt;p&gt;and then, without closing that terminal:&lt;/p&gt;

&lt;div class=&quot;language-plaintext highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;$ ssh -o UserKnownHostsFile=~/tmp-known_hosts -o ControlMaster=no -o ControlPath=none user@localhost
user@localhost&apos;s password: 
$ ls
$
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;

&lt;p&gt;&lt;em&gt;Success!&lt;/em&gt;&lt;/p&gt;

&lt;h1 id=&quot;resources&quot;&gt;Resources&lt;/h1&gt;

&lt;p&gt;Some resources I used to arrive at this solution:&lt;/p&gt;

&lt;ul&gt;
  &lt;li&gt;man systemd.socket&lt;/li&gt;
  &lt;li&gt;&lt;a href=&quot;http://0pointer.net/blog/projects/socket-activated-containers.html&quot;&gt;systemd for Administrators, Part XX&lt;/a&gt;&lt;/li&gt;
  &lt;li&gt;&lt;a href=&quot;irc://chat.freenode.net/systemd&quot;&gt;#systemd@freenode&lt;/a&gt;&lt;/li&gt;
&lt;/ul&gt;
</description>
        <pubDate>Sat, 13 Aug 2016 00:00:00 +0200</pubDate>
        <link>https://ecksun.com/systemd/2016/08/13/Socket_activated_containers.html</link>
        <guid isPermaLink="true">https://ecksun.com/systemd/2016/08/13/Socket_activated_containers.html</guid>
        
        <category>systemd</category>
        
        <category>docker</category>
        
        <category>sshd</category>
        
        <category>containers</category>
        
        <category>linux</category>
        
        
        <category>systemd</category>
        
      </item>
    
      <item>
        <title>Upgrading storage</title>
        <description>&lt;p&gt;A while ago I realized one of my RAID arrays was running out of space. Since I
didn’t have the space required to take a backup of everything I needed to
perform the upgrade in place. In this post I replace all drives in my RAID5
array, resize the mdadm array, resize both the LVM physical volume and logical
volume, the LUKS container and lastly the file system.&lt;/p&gt;

&lt;h1 id=&quot;upgrading-the-hardware&quot;&gt;Upgrading the hardware&lt;/h1&gt;
&lt;p&gt;I have no more space left in my case nor do I have any SATA connections left on
my motherboard, thus I bought a SATA to USB adapter which I used for replacing
drives.&lt;/p&gt;

&lt;p&gt;In this section we replace one drive at a time, we assume the old drive is
called &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;/dev/sda&lt;/code&gt; and the new drive is called &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;/dev/sdb&lt;/code&gt;. The mdadm volume we
operate on is /dev/md126.&lt;/p&gt;

&lt;h2 id=&quot;partitioning-the-new-drives&quot;&gt;Partitioning the new drives&lt;/h2&gt;

&lt;p&gt;I partitioned the drives with the same sized partitions as the old drives, I
don’t think thats required (anything bigger works), I just wanted to postpone
taking a decision on the partition-size.&lt;/p&gt;

&lt;div class=&quot;language-bash highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;&lt;span class=&quot;c&quot;&gt;# Check the size of the partition of the previous drive&lt;/span&gt;
&lt;span class=&quot;nv&quot;&gt;$ &lt;/span&gt;&lt;span class=&quot;nb&quot;&gt;sudo &lt;/span&gt;parted /dev/sda unit s print
Model: ATA ST4000DM000-1F21 &lt;span class=&quot;o&quot;&gt;(&lt;/span&gt;scsi&lt;span class=&quot;o&quot;&gt;)&lt;/span&gt;
Disk /dev/sda: 7814037168s
Sector size &lt;span class=&quot;o&quot;&gt;(&lt;/span&gt;logical/physical&lt;span class=&quot;o&quot;&gt;)&lt;/span&gt;: 512B/4096B
Partition Table: gpt
Disk Flags:

Number  Start  End          Size         File system  Name     Flags
 1      2048s  2930277160s  2930275113s               primary

&lt;span class=&quot;c&quot;&gt;# Partition the new drive in the same manner.&lt;/span&gt;
&lt;span class=&quot;nv&quot;&gt;$ &lt;/span&gt;&lt;span class=&quot;nb&quot;&gt;sudo &lt;/span&gt;parted /dev/sdb
&lt;span class=&quot;o&quot;&gt;(&lt;/span&gt;parted&lt;span class=&quot;o&quot;&gt;)&lt;/span&gt; mktable gpt
&lt;span class=&quot;o&quot;&gt;(&lt;/span&gt;parted&lt;span class=&quot;o&quot;&gt;)&lt;/span&gt; mkpart primary 2048s 2930277160s

&lt;span class=&quot;c&quot;&gt;# Check that it looks alright&lt;/span&gt;
&lt;span class=&quot;nv&quot;&gt;$ &lt;/span&gt;&lt;span class=&quot;nb&quot;&gt;sudo &lt;/span&gt;parted /dev/sdb unit s print
Model: ATA WDC WD40EFRX-68W &lt;span class=&quot;o&quot;&gt;(&lt;/span&gt;scsi&lt;span class=&quot;o&quot;&gt;)&lt;/span&gt;
Disk /dev/sdb: 7814037168s
Sector size &lt;span class=&quot;o&quot;&gt;(&lt;/span&gt;logical/physical&lt;span class=&quot;o&quot;&gt;)&lt;/span&gt;: 512B/4096B
Partition Table: gpt
Disk Flags:

Number  Start  End          Size         File system  Name     Flags
 1      2048s  2930277160s  2930275113s               primary
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;

&lt;h2 id=&quot;replacing-the-drives&quot;&gt;Replacing the drives&lt;/h2&gt;

&lt;p&gt;Its easy to &lt;a href=&quot;https://unix.stackexchange.com/questions/74924/how-to-safely-replace-a-not-yet-failed-disk-in-a-linux-raid5-array/104052#104052&quot;&gt;replace
drives&lt;/a&gt;
with mdadm, especially since version 3.3.&lt;/p&gt;

&lt;div class=&quot;language-bash highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;&lt;span class=&quot;nv&quot;&gt;$ &lt;/span&gt;&lt;span class=&quot;nb&quot;&gt;sudo &lt;/span&gt;mdadm &lt;span class=&quot;nt&quot;&gt;--manage&lt;/span&gt; /dev/md126 &lt;span class=&quot;nt&quot;&gt;--add-spare&lt;/span&gt; /dev/sdb1
mdadm: added /dev/sdb1
&lt;span class=&quot;nv&quot;&gt;$ &lt;/span&gt;&lt;span class=&quot;nb&quot;&gt;sudo &lt;/span&gt;mdadm /dev/md126 &lt;span class=&quot;nt&quot;&gt;--replace&lt;/span&gt; /dev/sda1
mdadm: Marked /dev/sda1 &lt;span class=&quot;o&quot;&gt;(&lt;/span&gt;device 4 &lt;span class=&quot;k&quot;&gt;in&lt;/span&gt; /dev/md126&lt;span class=&quot;o&quot;&gt;)&lt;/span&gt; &lt;span class=&quot;k&quot;&gt;for &lt;/span&gt;replacement
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;

&lt;p&gt;&lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;--replace&lt;/code&gt; will replace the drive as soon as a replacement is available. When
the drive is replaced the old drive will be marked as faulty. Using &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;--replace&lt;/code&gt;
compared to simply swapping the drives has the advantage of never putting the
array in a degraded state, as the old drive will continue to be used until it
is replaced.&lt;/p&gt;

&lt;p&gt;Once the drive is replaced an email is generated with a Fail event, we then
need to remove the old drive from the array:&lt;/p&gt;

&lt;div class=&quot;language-bash highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;&lt;span class=&quot;nv&quot;&gt;$ &lt;/span&gt;&lt;span class=&quot;nb&quot;&gt;sudo &lt;/span&gt;mdadm &lt;span class=&quot;nt&quot;&gt;--manage&lt;/span&gt; /dev/md126 &lt;span class=&quot;nt&quot;&gt;--remove&lt;/span&gt; failed
mdadm: hot removed 8:1 from /dev/md126
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;

&lt;h1 id=&quot;increasing-available-space&quot;&gt;Increasing available space&lt;/h1&gt;
&lt;p&gt;In this section the mdadm device is still called &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;/dev/md126&lt;/code&gt; and both the LVM
logical volume and physical volume is called &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;frej&lt;/code&gt;.&lt;/p&gt;

&lt;h2 id=&quot;partition-resizing&quot;&gt;Partition resizing&lt;/h2&gt;

&lt;blockquote&gt;
  &lt;p&gt;&lt;em&gt;NOTE:&lt;/em&gt;
I suggest you simply create the partitions as big as you want them from the
beginning, it makes the upgrade simpler.&lt;/p&gt;
&lt;/blockquote&gt;

&lt;h3 id=&quot;stop&quot;&gt;Stop&lt;/h3&gt;

&lt;p&gt;I do not know why it would be beneficial to not use the partitions when
resizing them. However since there seem to be an equal divide between people
saying you should and people saying it doesn’t matter my goal was to take
the safe path and not use the partitions while resizing. I did however forget
to stop the RAID when resizing 4 out of my 5 partitions and never noticed any
issues.&lt;/p&gt;

&lt;div class=&quot;language-bash highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;&lt;span class=&quot;nv&quot;&gt;$ &lt;/span&gt;&lt;span class=&quot;nb&quot;&gt;sudo &lt;/span&gt;umount /mnt/frej
&lt;span class=&quot;nv&quot;&gt;$ &lt;/span&gt;&lt;span class=&quot;nb&quot;&gt;sudo &lt;/span&gt;lvchange &lt;span class=&quot;nt&quot;&gt;-an&lt;/span&gt; /dev/frej/frej
&lt;span class=&quot;nv&quot;&gt;$ &lt;/span&gt;&lt;span class=&quot;nb&quot;&gt;sudo &lt;/span&gt;vgchange &lt;span class=&quot;nt&quot;&gt;-an&lt;/span&gt; frej
  0 logical volume&lt;span class=&quot;o&quot;&gt;(&lt;/span&gt;s&lt;span class=&quot;o&quot;&gt;)&lt;/span&gt; &lt;span class=&quot;k&quot;&gt;in &lt;/span&gt;volume group &lt;span class=&quot;s2&quot;&gt;&quot;frej&quot;&lt;/span&gt; now active
&lt;span class=&quot;nv&quot;&gt;$ &lt;/span&gt;&lt;span class=&quot;nb&quot;&gt;sudo &lt;/span&gt;cryptsetup close /dev/mapper/frej
&lt;span class=&quot;nv&quot;&gt;$ &lt;/span&gt;&lt;span class=&quot;nb&quot;&gt;sudo &lt;/span&gt;mdadm &lt;span class=&quot;nt&quot;&gt;--stop&lt;/span&gt; /dev/md126
mdadm: stopped /dev/md126
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;

&lt;h3 id=&quot;resize&quot;&gt;Resize&lt;/h3&gt;

&lt;p&gt;When resizing with parted you provide the &lt;em&gt;end&lt;/em&gt; of the partition, not the size
of it. I started specifying this as 4TB but then, as the start of my partition
is 1048576B, my partition only became 3999998951936B big. Not having 4TB would
have annoyed me so I resized it to the first multiple of 1 MiB above 4TB.
Moreover we want the end of the sector, not the beginning of the next one, so
we subtract one:&lt;/p&gt;

&lt;p&gt;&lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;⌈(4*10¹² + 1024²)/1024²⌉*1024² - 1 = 4000001818623&lt;/code&gt;.&lt;/p&gt;

&lt;div class=&quot;language-bash highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;&lt;span class=&quot;nv&quot;&gt;$ &lt;/span&gt;&lt;span class=&quot;nb&quot;&gt;sudo &lt;/span&gt;parted /dev/sdb resizepart 1 4000001818623B

&lt;span class=&quot;nv&quot;&gt;$ &lt;/span&gt;&lt;span class=&quot;nb&quot;&gt;sudo &lt;/span&gt;parted /dev/sdb unit b print
Model: ATA WDC WD40EFRX-68W &lt;span class=&quot;o&quot;&gt;(&lt;/span&gt;scsi&lt;span class=&quot;o&quot;&gt;)&lt;/span&gt;
Disk /dev/sdb: 4000787030016B
Sector size &lt;span class=&quot;o&quot;&gt;(&lt;/span&gt;logical/physical&lt;span class=&quot;o&quot;&gt;)&lt;/span&gt;: 512B/4096B
Partition Table: gpt
Disk Flags:

Number  Start     End             Size            File system  Name     Flags
 1      1048576B  4000001818623B  4000000770048B               primary
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;

&lt;h3 id=&quot;restart&quot;&gt;Restart&lt;/h3&gt;

&lt;p&gt;After resizing all partitions lets see if it worked:&lt;/p&gt;

&lt;div class=&quot;language-bash highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;&lt;span class=&quot;nv&quot;&gt;$ &lt;/span&gt;&lt;span class=&quot;nb&quot;&gt;sudo &lt;/span&gt;mdadm &lt;span class=&quot;nt&quot;&gt;--assemble&lt;/span&gt; &lt;span class=&quot;nt&quot;&gt;--scan&lt;/span&gt;
mdadm: /dev/md/frej has been started with 5 drives.
&lt;span class=&quot;nv&quot;&gt;$ &lt;/span&gt;&lt;span class=&quot;nb&quot;&gt;sudo &lt;/span&gt;vgscan
  Reading all physical volumes.  This may take a &lt;span class=&quot;k&quot;&gt;while&lt;/span&gt;...
  Found volume group &lt;span class=&quot;s2&quot;&gt;&quot;frej&quot;&lt;/span&gt; using metadata &lt;span class=&quot;nb&quot;&gt;type &lt;/span&gt;lvm2
&lt;span class=&quot;nv&quot;&gt;$ &lt;/span&gt;&lt;span class=&quot;nb&quot;&gt;sudo &lt;/span&gt;vgchange &lt;span class=&quot;nt&quot;&gt;-ay&lt;/span&gt; frej
  1 logical volume&lt;span class=&quot;o&quot;&gt;(&lt;/span&gt;s&lt;span class=&quot;o&quot;&gt;)&lt;/span&gt; &lt;span class=&quot;k&quot;&gt;in &lt;/span&gt;volume group &lt;span class=&quot;s2&quot;&gt;&quot;frej&quot;&lt;/span&gt; now active
&lt;span class=&quot;nv&quot;&gt;$ &lt;/span&gt;&lt;span class=&quot;nb&quot;&gt;sudo &lt;/span&gt;mount &lt;span class=&quot;nt&quot;&gt;-a&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;

&lt;p&gt;It seemed I didn’t have to reopen the LUKS container, I’m guessing it is
related to me having the device in crypttab and something causes the device to
be reopened.&lt;/p&gt;

&lt;h2 id=&quot;growing-the-raid&quot;&gt;Growing the RAID&lt;/h2&gt;

&lt;div class=&quot;language-bash highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;&lt;span class=&quot;nv&quot;&gt;$ &lt;/span&gt;&lt;span class=&quot;nb&quot;&gt;sudo &lt;/span&gt;mdadm &lt;span class=&quot;nt&quot;&gt;--grow&lt;/span&gt; /dev/md126 &lt;span class=&quot;nt&quot;&gt;--size&lt;/span&gt; max
mdadm: component size of /dev/md126 has been &lt;span class=&quot;nb&quot;&gt;set &lt;/span&gt;to 3906249728K
unfreeze
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;

&lt;p&gt;This will take a while, since it needs to resync the unused space.&lt;/p&gt;

&lt;div class=&quot;language-bash highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;&lt;span class=&quot;nv&quot;&gt;$ &lt;/span&gt;&lt;span class=&quot;nb&quot;&gt;cat&lt;/span&gt; /proc/mdstat
Personalities : &lt;span class=&quot;o&quot;&gt;[&lt;/span&gt;raid6] &lt;span class=&quot;o&quot;&gt;[&lt;/span&gt;raid5] &lt;span class=&quot;o&quot;&gt;[&lt;/span&gt;raid4] &lt;span class=&quot;o&quot;&gt;[&lt;/span&gt;raid1]
md126 : active raid5 sdb1[5] sdf1[6] sde1[7] sdd1[9] sdc1[8]
      15624998912 blocks super 1.2 level 5, 512k chunk, algorithm 2 &lt;span class=&quot;o&quot;&gt;[&lt;/span&gt;5/5] &lt;span class=&quot;o&quot;&gt;[&lt;/span&gt;UUUUU]
      &lt;span class=&quot;o&quot;&gt;[=======&amp;gt;&lt;/span&gt;.............]  resync &lt;span class=&quot;o&quot;&gt;=&lt;/span&gt; 37.5% &lt;span class=&quot;o&quot;&gt;(&lt;/span&gt;1468675572/3906249728&lt;span class=&quot;o&quot;&gt;)&lt;/span&gt; &lt;span class=&quot;nv&quot;&gt;finish&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;=&lt;/span&gt;767.9min &lt;span class=&quot;nv&quot;&gt;speed&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;=&lt;/span&gt;52901K/sec
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;

&lt;p&gt;For me it took about 13 hours to complete the resync, thus mdadm’s estimate was
quite accurate.&lt;/p&gt;

&lt;h2 id=&quot;resizing-the-luks-container-and-the-lvm-physical-volume&quot;&gt;Resizing the LUKS container and the LVM physical volume&lt;/h2&gt;

&lt;div class=&quot;language-bash highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;&lt;span class=&quot;nv&quot;&gt;$ &lt;/span&gt;&lt;span class=&quot;nb&quot;&gt;sudo &lt;/span&gt;cryptsetup resize /dev/mapper/frej
&lt;span class=&quot;nv&quot;&gt;$ &lt;/span&gt;&lt;span class=&quot;nb&quot;&gt;sudo &lt;/span&gt;pvresize /dev/mapper/frej
  Physical volume &lt;span class=&quot;s2&quot;&gt;&quot;/dev/mapper/frej&quot;&lt;/span&gt; changed
  1 physical volume&lt;span class=&quot;o&quot;&gt;(&lt;/span&gt;s&lt;span class=&quot;o&quot;&gt;)&lt;/span&gt; resized / 0 physical volume&lt;span class=&quot;o&quot;&gt;(&lt;/span&gt;s&lt;span class=&quot;o&quot;&gt;)&lt;/span&gt; not resized
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;

&lt;h2 id=&quot;filling-the-empty-space-with-random-data&quot;&gt;Filling the empty space with random data&lt;/h2&gt;

&lt;p&gt;Since we have newly allocated space we should fill it with random data to make
sure no information is leaked through our LUKS container. I have chosen to do
this by simply creating a new logical volume with the remaining free space,
create an encrypted device over it and fill that devices with zeros. Since the
zeros are encrypted with a random key the final data should be random.&lt;/p&gt;

&lt;div class=&quot;language-bash highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;&lt;span class=&quot;nv&quot;&gt;$ &lt;/span&gt;&lt;span class=&quot;nb&quot;&gt;sudo &lt;/span&gt;lvcreate &lt;span class=&quot;nt&quot;&gt;--extents&lt;/span&gt; 100%FREE &lt;span class=&quot;nt&quot;&gt;--name&lt;/span&gt; filltemp frej
&lt;span class=&quot;nv&quot;&gt;$ &lt;/span&gt;&lt;span class=&quot;nb&quot;&gt;sudo &lt;/span&gt;cryptsetup &lt;span class=&quot;nt&quot;&gt;--key-file&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;=&lt;/span&gt;/dev/urandom create filltempcrypt /dev/frej/filltemp
&lt;span class=&quot;nv&quot;&gt;$ &lt;/span&gt;&lt;span class=&quot;nb&quot;&gt;sudo dd &lt;/span&gt;&lt;span class=&quot;k&quot;&gt;if&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;=&lt;/span&gt;/dev/zero &lt;span class=&quot;nv&quot;&gt;of&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;=&lt;/span&gt;/dev/mapper/filltempcrypt &lt;span class=&quot;nv&quot;&gt;bs&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;=&lt;/span&gt;1M &lt;span class=&quot;c&quot;&gt;# This takes a _long_ time&lt;/span&gt;
&lt;span class=&quot;nv&quot;&gt;$ &lt;/span&gt;&lt;span class=&quot;nb&quot;&gt;sudo &lt;/span&gt;cryptsetup close /dev/mapper/filltempcrypt
&lt;span class=&quot;nv&quot;&gt;$ &lt;/span&gt;&lt;span class=&quot;nb&quot;&gt;sudo &lt;/span&gt;lvchange &lt;span class=&quot;nt&quot;&gt;-an&lt;/span&gt; /dev/frej/filltemp
&lt;span class=&quot;nv&quot;&gt;$ &lt;/span&gt;&lt;span class=&quot;nb&quot;&gt;sudo &lt;/span&gt;lvremove /dev/frej/filltemp
  Logical volume &lt;span class=&quot;s2&quot;&gt;&quot;filltemp&quot;&lt;/span&gt; successfully removed
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;

&lt;p&gt;You can check the progress of dd by sending it the SIGUSR1 signal:&lt;/p&gt;

&lt;div class=&quot;language-bash highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;&lt;span class=&quot;nv&quot;&gt;$ &lt;/span&gt;&lt;span class=&quot;nb&quot;&gt;sudo &lt;/span&gt;pkill &lt;span class=&quot;nt&quot;&gt;-f&lt;/span&gt; &lt;span class=&quot;s1&quot;&gt;&apos;^dd if=/dev/zero&apos;&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;

&lt;p&gt;The output from dd will look something like this:&lt;/p&gt;

&lt;div class=&quot;language-plaintext highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;220340+0 records in
220340+0 records out
112814080 bytes (113 MB) copied, 0.521177 s, 116 MB/s
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;

&lt;blockquote&gt;
  &lt;p&gt;&lt;em&gt;NOTE:&lt;/em&gt;
I ran into the same performance issue I did &lt;a href=&quot;/wiki/RAID.html&quot;&gt;years ago&lt;/a&gt; when
setting up the array, since I had reinitialized the array after boot my fixes
did not get applied (they are run from rc.local).&lt;/p&gt;
&lt;/blockquote&gt;

&lt;h2 id=&quot;resize-the-lvm-logical-volume-and-file-system&quot;&gt;Resize the LVM logical volume and file system&lt;/h2&gt;

&lt;p&gt;Now we need to extend the size of our logical volume and file system. I choose
to add 3 TiB as thats what I needed to migrate the data I had on a different
volume.&lt;/p&gt;

&lt;div class=&quot;language-bash highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;&lt;span class=&quot;nv&quot;&gt;$ &lt;/span&gt;&lt;span class=&quot;nb&quot;&gt;sudo &lt;/span&gt;lvextend &lt;span class=&quot;nt&quot;&gt;--size&lt;/span&gt; +3T /dev/frej/frej
  Size of logical volume frej/frej changed from 5.46 TiB &lt;span class=&quot;o&quot;&gt;(&lt;/span&gt;1430796 extents&lt;span class=&quot;o&quot;&gt;)&lt;/span&gt; to 8.46 TiB &lt;span class=&quot;o&quot;&gt;(&lt;/span&gt;2217228 extents&lt;span class=&quot;o&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;nb&quot;&gt;.&lt;/span&gt;
  Logical volume frej successfully resized

&lt;span class=&quot;nv&quot;&gt;$ &lt;/span&gt;&lt;span class=&quot;nb&quot;&gt;sudo &lt;/span&gt;resize2fs /dev/mapper/frej-frej
resize2fs 1.42.12 &lt;span class=&quot;o&quot;&gt;(&lt;/span&gt;29-Aug-2014&lt;span class=&quot;o&quot;&gt;)&lt;/span&gt;
Filesystem at /dev/mapper/frej-frej is mounted on /mnt/frej&lt;span class=&quot;p&quot;&gt;;&lt;/span&gt; on-line resizing required
old_desc_blocks &lt;span class=&quot;o&quot;&gt;=&lt;/span&gt; 350, new_desc_blocks &lt;span class=&quot;o&quot;&gt;=&lt;/span&gt; 542
The filesystem on /dev/mapper/frej-frej is now 2270441472 &lt;span class=&quot;o&quot;&gt;(&lt;/span&gt;4k&lt;span class=&quot;o&quot;&gt;)&lt;/span&gt; blocks long.
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;

&lt;h1 id=&quot;conclusion&quot;&gt;Conclusion&lt;/h1&gt;

&lt;p&gt;Using modern technologies such as mdadm, LVM and LUKS it is really easy to
increase the storage capabilities of a server. Most of the steps can also be
performed online. My chassi does not have the ability to easily replace drives,
which means I risk damaging them if I try to replace a drive physically while
the system is still online.&lt;/p&gt;

&lt;p&gt;Had I only had a better chassi I could have performed this entire procedure
online, completely without downtime.&lt;/p&gt;
</description>
        <pubDate>Wed, 25 Mar 2015 00:00:00 +0100</pubDate>
        <link>https://ecksun.com/storage/2015/03/25/Upgrading_Storage.html</link>
        <guid isPermaLink="true">https://ecksun.com/storage/2015/03/25/Upgrading_Storage.html</guid>
        
        <category>RAID</category>
        
        <category>resize</category>
        
        <category>mdadm</category>
        
        <category>LUKS</category>
        
        <category>LVM</category>
        
        
        <category>storage</category>
        
      </item>
    
      <item>
        <title>Encrypting bitlbee traffic with stunnel</title>
        <description>&lt;p&gt;While going through all my externally facing services I noticed bitlbee is not
actually encrypted. This was quite a surprise for me, mainly for the fact that I
did not notice it while setting bitlbee up the first time. On the other hand
not much was compromised as the services I use via bitlbee are all run by
untrustworthy corporations. All communication through them is as good as
unencrypted anyway :). Likewise since I have setup my firewall to only accept
connections from one other host, which I also control, gaining control over
bitlbee itself would have been difficult for an attacker.&lt;/p&gt;

&lt;p&gt;Regardless, I needed to reset my passwords for all accounts used and obviously
make sure my communication with bitlbee was encrypted. Since bitlbee have been
working so well for me I opted to use stunnel to encrypt the traffic. I was
also curious to see if I could get client-side certificates to work, which is a
feature stunnel provides.&lt;/p&gt;

&lt;p&gt;I have omitted the output from most commands on this page in order reduce
clutter. Only a few commands are interactive, such as &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;openssl req&lt;/code&gt;.&lt;/p&gt;

&lt;h2 id=&quot;stunnel&quot;&gt;stunnel&lt;/h2&gt;

&lt;p&gt;I based my stunnel config of the sample provided in debian in
&lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;/usr/share/doc/stunnel4/examples/stunnel.conf-sample&lt;/code&gt;. I have gathered most
information from the sample, manpages and
&lt;a href=&quot;http://www.stunnel.org/static/stunnel.html&quot;&gt;http://www.stunnel.org/static/stunnel.html&lt;/a&gt;.&lt;/p&gt;

&lt;p&gt;This is my the entire contents of my config file (&lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;/etc/stunnel/stunnel.conf&lt;/code&gt;)
excluding the service definitions:&lt;/p&gt;

&lt;div class=&quot;language-plaintext highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;chroot = /var/lib/stunnel4/
setuid = stunnel4
setgid = stunnel4
pid = /stunnel4.pid
cert = /etc/stunnel/stunnel.pem
verify = 3
CApath = /certs
options = NO_SSLv3
options = SINGLE_ECDH_USE
options = SINGLE_DH_USE
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;

&lt;h3 id=&quot;chroot&quot;&gt;chroot&lt;/h3&gt;

&lt;p&gt;It is interesting to note that since we are running a chroot it is not possible
to reload the config file. When stunnel first starts it reads the proper one,
however if you try to reload it (&lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;sudo /etc/init.d/stunnel reload&lt;/code&gt;) it will not
be able to find the file, as it is searching in the chroot.&lt;/p&gt;

&lt;p&gt;The chroot itself needs to contain certain files, I simply assumed that most of
the files listed in the documentation were required.&lt;/p&gt;

&lt;div class=&quot;language-plaintext highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;user@server $ ls /var/lib/stunnel4/
certs  nsswitch.conf  resolv.conf  timezone
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;

&lt;h2 id=&quot;certificates&quot;&gt;Certificates&lt;/h2&gt;

&lt;p&gt;We need to generate the key and certificate on the server. Remember to specify
the domain name of the server correctly when creating the certificate request
(&lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;openssl req&lt;/code&gt;) is the same that we later use to connect to via irssi. It must
match the host you use when connecting from irssi, if they do not match the
certificate will be invalid and irssi will refuse to connect.&lt;/p&gt;

&lt;div class=&quot;language-plaintext highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;user@server $ openssl genrsa 4096 &amp;gt; stunnel.key
user@server $ openssl req -new -key stunnel.key -x509 -days 1095 -out stunnel.crt
user@server $ cat stunnel.{key,crt} &amp;gt; stunnel.pem
user@server $ openssl gendh 2048 &amp;gt;&amp;gt; stunnel.pem
user@server $ sudo mv stunnel.pem /etc/stunnel/stunnel.pem
user@server $ # Let stunnel4 own it
user@server $ sudo chown stunnel4:stunnel4 /etc/stunnel/stunnel.pem
user@server $ # Make sure no-one else can read it
user@server $ sudo chmod 600 /etc/stunnel/stunnel.pem
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;

&lt;p&gt;And on the client we need a key and certificate as well:&lt;/p&gt;

&lt;div class=&quot;language-plaintext highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;user@client $ openssl genrsa 4096 &amp;gt; client.key
user@client $ openssl req -new -key client.key -x509 -days 1095 -out client.crt
user@client $ cat client.{key,crt} &amp;gt; client.pem
user@client $ scp client.crt server:                # Upload the client certificate
user@client $ scp server:stunnel.crt .              # Download the server certificate
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;

&lt;p&gt;Now we need to put the client certificate into the certs folder on the server&lt;/p&gt;

&lt;div class=&quot;language-plaintext highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;user@server $ sudo mv client.crt /var/lib/stunnel4/certs
user@server $ # Generate symlinks with checksums for the certificates, this
user@server $ # is the files that are actually read by stunnel
user@server $ sudo c_rehash /var/lib/stunnel4/certs
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;

&lt;h2 id=&quot;bitlbee&quot;&gt;Bitlbee&lt;/h2&gt;

&lt;p&gt;Setting up bitlbee is simple, we only have to listen to the port specified in
the stunnel config file. I also recommend listening only to localhost:
&lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;DaemonInterface = 127.0.0.1&lt;/code&gt;&lt;/p&gt;

&lt;blockquote&gt;
  &lt;p&gt;&lt;em&gt;NOTE:&lt;/em&gt;
On debian the port from &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;bitlbee.conf&lt;/code&gt; is ignored, run 
&lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;sudo dpkg-reconfigure bitlbee-common&lt;/code&gt; instead&lt;/p&gt;
&lt;/blockquote&gt;

&lt;h2 id=&quot;irssi&quot;&gt;irssi&lt;/h2&gt;

&lt;p&gt;The last step is to setup irssi, its a simple one-liner:&lt;/p&gt;

&lt;div class=&quot;language-plaintext highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;/server add -ssl -ssl_cert client.pem -ssl_cafile stunnel.crt -ssl_verify &amp;lt;host&amp;gt; &amp;lt;port&amp;gt;
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;
</description>
        <pubDate>Wed, 09 Apr 2014 00:00:00 +0200</pubDate>
        <link>https://ecksun.com/security/2014/04/09/Bitlbee-stunnel.html</link>
        <guid isPermaLink="true">https://ecksun.com/security/2014/04/09/Bitlbee-stunnel.html</guid>
        
        <category>Linux</category>
        
        <category>openssl</category>
        
        <category>Bitlbee</category>
        
        <category>stunnel</category>
        
        <category>irssi</category>
        
        
        <category>security</category>
        
      </item>
    
      <item>
        <title>Getting OpenElec working on an Intel NUC</title>
        <description>&lt;p&gt;I have long had a Boxee box as my main HTPC. It has never really been able to
do everything I wanted and was never able to properly deal with my media
library. I thus decided to get a Intel NUC to run OpenElec with XBMC on it, the
parts I got were:&lt;/p&gt;

&lt;ul&gt;
  &lt;li&gt;Intel NUC D54250WYK - I5-4250U&lt;/li&gt;
  &lt;li&gt;Intel 525 series 60GB SSD mSATA&lt;/li&gt;
  &lt;li&gt;Crucial Ballistix Sport 4GB PC12800/1600MHz CL9&lt;/li&gt;
&lt;/ul&gt;

&lt;h2 id=&quot;fan-noise&quot;&gt;Fan noise&lt;/h2&gt;

&lt;p&gt;The first thing I noticed after setting it up was that it was quite noisy. The
cooling section in the UEFI BIOS told me the fan was running at slightly over
3000 rpm when idle, which seemed slightly high. My solution was to simply
change the &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;Minimum Duty Cycle (%)&lt;/code&gt; from 40 to 0. This reduced the fan speed
drastically. At times (mostly right after boot) the fan was completely turned
of, however most often when the system is idling the fan speed is between 1500
and 2300 rpm.&lt;/p&gt;

&lt;h2 id=&quot;shutdown-issue&quot;&gt;Shutdown issue&lt;/h2&gt;

&lt;p&gt;I’m also having problems with turning off the device. Turning the device off
via the UI or &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;poweroff&lt;/code&gt; simply reboots it (it goes through BIOS, so it is not
simply reloading XBMC as others have had issues with). Running &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;halt&lt;/code&gt; makes the
UI hang but does not power off the device.&lt;/p&gt;

&lt;p&gt;However, if I have a keyboard plugged in, it works as expected, the device
shuts off and stays off. The same is however not true for USB-keys (the only
other USB-device I have tried), as that also makes the device reboot instead of
shutting down.&lt;/p&gt;

&lt;h3 id=&quot;solution&quot;&gt;Solution&lt;/h3&gt;
&lt;p&gt;I found a discussion around the issue on
&lt;a href=&quot;https://communities.intel.com/message/233618#233618&quot; title=&quot;Shutdown reboot fix&quot;&gt;intels forums&lt;/a&gt;
where a Intel employee posted a
&lt;a href=&quot;https://downloadcenter.intel.com/Detail_Desc.aspx?agr=Y&amp;amp;DwnldID=23826&quot;&gt;beta version&lt;/a&gt;
of the BIOS (based on version 4024) that seems to resolve the issue.&lt;/p&gt;
</description>
        <pubDate>Mon, 18 Nov 2013 00:00:00 +0100</pubDate>
        <link>https://ecksun.com/htpc/2013/11/18/Intel_NUC_with_XBMC.html</link>
        <guid isPermaLink="true">https://ecksun.com/htpc/2013/11/18/Intel_NUC_with_XBMC.html</guid>
        
        <category>Linux</category>
        
        <category>OpenElec</category>
        
        <category>XBMC</category>
        
        <category>Intel NUC</category>
        
        <category>NUC</category>
        
        <category>Intel</category>
        
        
        <category>htpc</category>
        
      </item>
    
      <item>
        <title>Expanding a live ext4 filesystem on LVM</title>
        <description>&lt;p&gt;When installing my machine I used an encrypted LVM with ext4 as the filesystem
for both &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;/home&lt;/code&gt; and &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;/&lt;/code&gt;. I allocated 50 GB for &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;/home&lt;/code&gt; and 30 GB for &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;/&lt;/code&gt; and
left the rest unused, in order to be able to use it where needed, mostly to try
out and see if it is a nice setup or not.&lt;/p&gt;

&lt;p&gt;Today I was messing around with virtual machines and noticed I only had 15 GB
free space on my home partition and needed more. So I did some searching in
order to find out how to increase the size of &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;/home&lt;/code&gt; and was surprised at how
easy it was:&lt;/p&gt;

&lt;div class=&quot;language-plaintext highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;$ sudo lvextend -L+50G /dev/System/home
Extending logical volume home to 102 GiB
Logical volume home successfully resized
$ sudo resize2fs /dev/mapper/System-home
resize2fs 1.42.8 (20-Jun-2013)
Filesystem at /dev/mapper/home is mounted on /home; on-line resizing required
old desc_blocks = 180, new_desc_blocks = 261
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;

&lt;p&gt;This can even be done online, that is without unmounting the filesystem, if you
have a kernel newer than 2.6.&lt;/p&gt;
</description>
        <pubDate>Sun, 04 Aug 2013 00:00:00 +0200</pubDate>
        <link>https://ecksun.com/linux/2013/08/04/Resizing_ext4_LVM.html</link>
        <guid isPermaLink="true">https://ecksun.com/linux/2013/08/04/Resizing_ext4_LVM.html</guid>
        
        <category>Linux</category>
        
        <category>LVM</category>
        
        <category>ext4</category>
        
        
        <category>linux</category>
        
      </item>
    
      <item>
        <title>Updating Loopia domains with DD-WRT</title>
        <description>&lt;p&gt;I recently switched from running tomato on my router to running DD-WRT. One of
the issues I noticed was that DD-WRT don’t have a way to use loopia.se DynDNS
API, as that requires the IP to be part of the URI.&lt;/p&gt;

&lt;p&gt;Searching the problem I found some ways to do it, however none did it properly.
For example some solutions will get the IP at boot-time while others doesn’t
take into account the IP the domain actually resolves to.&lt;/p&gt;

&lt;p&gt;So I wrote a small script to update my domain if my current external IP differs
from the IP my domain currently resolves to, the sources can be found at
&lt;a href=&quot;https://github.com/ecksun/Loopia-WRT&quot;&gt;github&lt;/a&gt; .&lt;/p&gt;

&lt;p&gt;The biggest issue I had with getting my DNS-updater to work was to actually
store the script on the device, which required me to re-flash my router with a
different version of DD-WRT with JFFS support. However once that was done and
the cronjob (check the github repo for info) was configured everything worked
like a charm.&lt;/p&gt;

</description>
        <pubDate>Sun, 20 May 2012 00:00:00 +0200</pubDate>
        <link>https://ecksun.com/dns/2012/05/20/loopia-WRT.html</link>
        <guid isPermaLink="true">https://ecksun.com/dns/2012/05/20/loopia-WRT.html</guid>
        
        <category>Loopia</category>
        
        <category>DD-WRT</category>
        
        <category>Github</category>
        
        
        <category>DNS</category>
        
      </item>
    
      <item>
        <title>PR 1.2</title>
        <description>&lt;p&gt;When the OTA arrived and I tried to install the update it told me to use Nokia
Software Updater to flash the device, which ofc didn’t work. It complained
about not being able to download the update and got stuck at 33.6 MB. According
to the folks at TMO it was Nokias fault :)&lt;/p&gt;

&lt;p&gt;I also read about people being able to install the update after removing some
packages, so I did. When I had removed about 20 applications it actually began
to download and install, however when everything was completed and the device
rebooted I got a rather peculiar error:&lt;/p&gt;

&lt;p&gt;&lt;a href=&quot;/images/2010-05-28/20100528_002.jpg&quot;&gt;&lt;img src=&quot;/images/2010-05-28/20100528_002-300x225.jpg&quot; alt=&quot;PR1.2 Upgrade fail - Desktop&quot; /&gt;&lt;/a&gt;
&lt;a href=&quot;/images/2010-05-28/20100528_003.jpg&quot;&gt;&lt;img src=&quot;/images/2010-05-28/20100528_003-300x225.jpg&quot; alt=&quot;PR1.2 Upgrade fail - Menu&quot; /&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;I then decided it was a bit to much work to debug so I used the Maemo flasher
and began again.&lt;/p&gt;
</description>
        <pubDate>Thu, 01 Sep 2011 00:00:00 +0200</pubDate>
        <link>https://ecksun.com/maemo/2011/09/01/Maemo_PR1.2.html</link>
        <guid isPermaLink="true">https://ecksun.com/maemo/2011/09/01/Maemo_PR1.2.html</guid>
        
        <category>Maemo</category>
        
        <category>Bugs</category>
        
        <category>PR1.2</category>
        
        
        <category>Maemo</category>
        
      </item>
    
      <item>
        <title>TI - Evalbot</title>
        <description>&lt;p&gt;Three month ago I ordered a TI Stellaris Development board (aka evalbot) for
25$, 100$ off the original price. I had no idea if it actually was going to
arrive, but earlier today it did.&lt;/p&gt;

&lt;p&gt;TI (or fedex?) apparently don’t know how to handle non-ascii characters, so
fedex called me this morning to ask for my real address.&lt;/p&gt;

&lt;p&gt;Just because I have no idea what to do with it, I decided to do an unboxing,
images follow.&lt;/p&gt;

&lt;figure&gt;
&lt;a href=&quot;/images/2011-02-00/2011_02_00_dsc03434.jpg&quot;&gt;
&lt;img src=&quot;/images/2011-02-00/2011_02_00_dsc03434-thumb.jpg&quot; alt=&quot;
The box the evalbot arrived in
&quot; title=&quot;Evalbot shipping box&quot; /&gt;
&lt;/a&gt;
&lt;figcaption&gt;
The box the evalbot arrived in
&lt;/figcaption&gt;
&lt;/figure&gt;

&lt;figure&gt;
&lt;a href=&quot;/images/2011-02-00/2011_02_00_dsc03435.jpg&quot;&gt;
&lt;img src=&quot;/images/2011-02-00/2011_02_00_dsc03435-thumb.jpg&quot; alt=&quot;
There were a whole bunch of packaging material.
&quot; title=&quot;Box filling&quot; /&gt;
&lt;/a&gt;
&lt;figcaption&gt;
There were a whole bunch of packaging material.
&lt;/figcaption&gt;
&lt;/figure&gt;

&lt;p&gt;There were two boxes inside the evalbot-box, inside the packaging box, alas
there were two boxes in the box in the box.&lt;/p&gt;

&lt;figure&gt;
&lt;a href=&quot;/images/2011-02-00/2011_02_00_dsc03436.jpg&quot;&gt;
&lt;img src=&quot;/images/2011-02-00/2011_02_00_dsc03436-thumb.jpg&quot; alt=&quot;
A box in the box
&quot; title=&quot;The evalbot box&quot; /&gt;
&lt;/a&gt;
&lt;figcaption&gt;
A box in the box
&lt;/figcaption&gt;
&lt;/figure&gt;

&lt;figure&gt;
&lt;a href=&quot;/images/2011-02-00/2011_02_00_dsc03437.jpg&quot;&gt;
&lt;img src=&quot;/images/2011-02-00/2011_02_00_dsc03437-thumb.jpg&quot; alt=&quot;
With two boxes
&quot; title=&quot;Boxes in boxes&quot; /&gt;
&lt;/a&gt;
&lt;figcaption&gt;
With two boxes
&lt;/figcaption&gt;
&lt;/figure&gt;

&lt;figure&gt;
&lt;a href=&quot;/images/2011-02-00/2011_02_00_dsc03438.jpg&quot;&gt;
&lt;img src=&quot;/images/2011-02-00/2011_02_00_dsc03438-thumb.jpg&quot; alt=&quot;
The hardware contents
&quot; title=&quot;The box content&quot; /&gt;
&lt;/a&gt;
&lt;figcaption&gt;
The hardware contents
&lt;/figcaption&gt;
&lt;/figure&gt;

&lt;figure&gt;
&lt;a href=&quot;/images/2011-02-00/2011_02_00_dsc03439.jpg&quot;&gt;
&lt;img src=&quot;/images/2011-02-00/2011_02_00_dsc03439-thumb.jpg&quot; alt=&quot;
The software contents
&quot; title=&quot;The contents of the software box&quot; /&gt;
&lt;/a&gt;
&lt;figcaption&gt;
The software contents
&lt;/figcaption&gt;
&lt;/figure&gt;

&lt;p&gt;Content of the software box:&lt;/p&gt;

&lt;ul&gt;
  &lt;li&gt;A cord&lt;/li&gt;
  &lt;li&gt;Four AA batteries&lt;/li&gt;
  &lt;li&gt;A bunch of screws and other random stuff&lt;/li&gt;
&lt;/ul&gt;

&lt;figure&gt;
&lt;a href=&quot;/images/2011-02-00/2011_02_00_dsc03440.jpg&quot;&gt;
&lt;img src=&quot;/images/2011-02-00/2011_02_00_dsc03440-thumb.jpg&quot; alt=&quot;
The actual evalbot! Most stuff is already mounted.
&quot; title=&quot;The actual evalbot&quot; /&gt;
&lt;/a&gt;
&lt;figcaption&gt;
The actual evalbot! Most stuff is already mounted.
&lt;/figcaption&gt;
&lt;/figure&gt;

&lt;figure&gt;
&lt;a href=&quot;/images/2011-02-00/2011_02_00_dsc03446.jpg&quot;&gt;
&lt;img src=&quot;/images/2011-02-00/2011_02_00_dsc03446-thumb.jpg&quot; alt=&quot;
A whole bunch of connections
&quot; title=&quot;The evalbots connection&quot; /&gt;
&lt;/a&gt;
&lt;figcaption&gt;
A whole bunch of connections
&lt;/figcaption&gt;
&lt;/figure&gt;

&lt;figure&gt;
&lt;a href=&quot;/images/2011-02-00/2011_02_00_dsc03445.jpg&quot;&gt;
&lt;img src=&quot;/images/2011-02-00/2011_02_00_dsc03445-thumb.jpg&quot; alt=&quot;
A better picture of the evalbot
&quot; title=&quot;The evalbot&quot; /&gt;
&lt;/a&gt;
&lt;figcaption&gt;
A better picture of the evalbot
&lt;/figcaption&gt;
&lt;/figure&gt;

&lt;figure&gt;
&lt;a href=&quot;/images/2011-02-00/2011_02_00_dsc03447.jpg&quot;&gt;
&lt;img src=&quot;/images/2011-02-00/2011_02_00_dsc03447-thumb.jpg&quot; alt=&quot;
The evalbot main chip (I guess) and the display
&quot; title=&quot;Evalbot chip and display&quot; /&gt;
&lt;/a&gt;
&lt;figcaption&gt;
The evalbot main chip (I guess) and the display
&lt;/figcaption&gt;
&lt;/figure&gt;

&lt;figure&gt;
&lt;a href=&quot;/images/2011-02-00/2011_02_00_dsc03448.jpg&quot;&gt;
&lt;img src=&quot;/images/2011-02-00/2011_02_00_dsc03448-thumb.jpg&quot; alt=&quot;
A closeup of the main chip.
&quot; title=&quot;The main chip on the evalbot&quot; /&gt;
&lt;/a&gt;
&lt;figcaption&gt;
A closeup of the main chip.
&lt;/figcaption&gt;
&lt;/figure&gt;

&lt;figure&gt;
&lt;a href=&quot;/images/2011-02-00/2011_02_00_dsc03449.jpg&quot;&gt;
&lt;img src=&quot;/images/2011-02-00/2011_02_00_dsc03449-thumb.jpg&quot; alt=&quot;
The backside of the evalbot, not much interesting
&quot; title=&quot;Evalbot backside&quot; /&gt;
&lt;/a&gt;
&lt;figcaption&gt;
The backside of the evalbot, not much interesting
&lt;/figcaption&gt;
&lt;/figure&gt;

&lt;figure&gt;
&lt;a href=&quot;/images/2011-02-00/2011_02_00_dsc03449.jpg&quot;&gt;
&lt;img src=&quot;/images/2011-02-00/2011_02_00_dsc03449-thumb.jpg&quot; alt=&quot;
The backside of the evalbot, not much interesting
&quot; title=&quot;Evalbot backside&quot; /&gt;
&lt;/a&gt;
&lt;figcaption&gt;
The backside of the evalbot, not much interesting
&lt;/figcaption&gt;
&lt;/figure&gt;

&lt;p&gt;So, thats it, now I only need to figure out how to use it :)&lt;/p&gt;
</description>
        <pubDate>Mon, 31 Jan 2011 00:00:00 +0100</pubDate>
        <link>https://ecksun.com/robots/2011/01/31/TI-evalbot.html</link>
        <guid isPermaLink="true">https://ecksun.com/robots/2011/01/31/TI-evalbot.html</guid>
        
        <category>Robot</category>
        
        <category>Evalbot</category>
        
        
        <category>robots</category>
        
      </item>
    
      <item>
        <title>TVRage in bash</title>
        <description>&lt;p&gt;So, I read two nice pages about bash some weeks ago and wanted to see if you
could build something proper.&lt;/p&gt;

&lt;p&gt;I often check &lt;a href=&quot;http://tvrage.com&quot;&gt;tvrage.com&lt;/a&gt; to see the latest and next
episode of a show, but the search is horribly stupid and the page requires
interaction before I can get the information I want.&lt;/p&gt;

&lt;p&gt;So, yesterday I wrote a bash script that fetches some information from tvrage,
I have published it on
&lt;a href=&quot;https://github.com/ecksun/tvrage&quot;&gt;https://github.com/ecksun/tvrage&lt;/a&gt;.&lt;/p&gt;

&lt;p&gt;It has three ways of finding information. First it uses a internal associative
array to see if the search is present there, if it is (and searching is not
specifically specified) it will get information about that show. If there isn’t
an exact match in the preconfigured array it will search through it with a
regex. If it cannot find anything then either (or hasn’t find the specified
number of hits) it searches on tvrage.&lt;/p&gt;

&lt;p&gt;I don’t know if anyone else has any use for this, but I like getting
information from the CLI, so hopefully it will easy my everyday life :D&lt;/p&gt;

&lt;p&gt;Have a good day!&lt;/p&gt;
</description>
        <pubDate>Tue, 11 Jan 2011 00:00:00 +0100</pubDate>
        <link>https://ecksun.com/bash/2011/01/11/TVRage_in_bash.html</link>
        <guid isPermaLink="true">https://ecksun.com/bash/2011/01/11/TVRage_in_bash.html</guid>
        
        <category>Bash</category>
        
        <category>TVRage</category>
        
        <category>Github</category>
        
        
        <category>bash</category>
        
      </item>
    
      <item>
        <title>Acer TimelineX 3820T</title>
        <description>&lt;ul&gt;
  &lt;li&gt;&lt;a href=&quot;http://ubuntuforums.org/showthread.php?t=1481995&quot;&gt;a forumthread on ubuntuforums.org describing a few problems&lt;/a&gt;&lt;/li&gt;
  &lt;li&gt;&lt;a href=&quot;http://www.notebookcheck.net/Review-Acer-Aspire-3820TG-Timeline-X-Notebook.30294.0.html&quot;&gt;notebookcheck.net’s review of the laptop, containing all specifications&lt;/a&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;h2 id=&quot;wired-network-card&quot;&gt;Wired network card&lt;/h2&gt;
&lt;p&gt;There exists a rather easy fix for getting the wired ethernet card to work.
Download the drivers from atheros homepage (the makers of the ethernet
chipset), the drivers can be found
&lt;a href=&quot;http://partner.atheros.com/Drivers.aspx&quot;&gt;here (dead link)&lt;/a&gt;, search for the file
AR81Family-Linux-v1.0.1.9.tar.gz.&lt;/p&gt;

&lt;ol&gt;
  &lt;li&gt;
    &lt;p&gt;Extract the file, you probably want to this in a new empty directory as the
archive otherwise will clutter the current directory with a buch of files.&lt;/p&gt;

    &lt;div class=&quot;language-plaintext highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt; tar -zxvf AR81Family-Linux-v1.0.1.9.tar.gz
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;    &lt;/div&gt;

    &lt;p&gt;and read the readme :)&lt;/p&gt;
  &lt;/li&gt;
  &lt;li&gt;
    &lt;p&gt;Untar/unzip archive:&lt;/p&gt;

    &lt;div class=&quot;language-plaintext highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt; tar zxf arl1e-x.x.x.x.tar.gz
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;    &lt;/div&gt;
  &lt;/li&gt;
  &lt;li&gt;
    &lt;p&gt;Change to the driver src directory:&lt;/p&gt;

    &lt;div class=&quot;language-plaintext highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt; cd arl1e-x.x.x.x/src/
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;    &lt;/div&gt;
  &lt;/li&gt;
  &lt;li&gt;
    &lt;p&gt;Compile the driver module:&lt;/p&gt;

    &lt;div class=&quot;language-plaintext highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt; make install
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;    &lt;/div&gt;

    &lt;p&gt;The binary will be installed as:&lt;/p&gt;

    &lt;div class=&quot;language-plaintext highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt; /lib/modules//kernel/drivers/net/arl1e.[k]o
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;    &lt;/div&gt;
  &lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;The install locations listed above are the default locations. They might
not be correct for certain Linux distributions. For more information,
see the ldistrib.txt file included in the driver tar.&lt;/p&gt;

&lt;p&gt;To use the module execute:&lt;/p&gt;

&lt;figure class=&quot;highlight&quot;&gt;&lt;pre&gt;&lt;code class=&quot;language-bash&quot; data-lang=&quot;bash&quot;&gt;&lt;span class=&quot;nb&quot;&gt;sudo &lt;/span&gt;insmod /lib/modules/&lt;span class=&quot;sb&quot;&gt;`&lt;/span&gt;&lt;span class=&quot;nb&quot;&gt;uname&lt;/span&gt; &lt;span class=&quot;nt&quot;&gt;-r&lt;/span&gt;&lt;span class=&quot;sb&quot;&gt;`&lt;/span&gt;/kernel/drivers/net/atl1e/atl1e.ko&lt;/code&gt;&lt;/pre&gt;&lt;/figure&gt;

&lt;p&gt;And that should be all.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Note:&lt;/strong&gt; This must be done every time the kernel is recompiled&lt;/p&gt;

</description>
        <pubDate>Thu, 02 Sep 2010 00:00:00 +0200</pubDate>
        <link>https://ecksun.com/problems/2010/09/02/Acer_TimelineX_3820T_Problems.html</link>
        <guid isPermaLink="true">https://ecksun.com/problems/2010/09/02/Acer_TimelineX_3820T_Problems.html</guid>
        
        <category>Acer</category>
        
        <category>Network</category>
        
        <category>Drivers</category>
        
        
        <category>problems</category>
        
      </item>
    
      <item>
        <title>Disk encryption</title>
        <description>&lt;p&gt;This is just a quick reminder to mostly myself on what to do when
installing a new disk. Note that all of the following commands need to be run
as root/with sudo.&lt;/p&gt;

&lt;p&gt;Begin by writing random data to the disk, this is &lt;em&gt;very&lt;/em&gt; important, if it is
skipped the security might be severely compromised. I use badblocks for this as
&lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;/dev/urandom&lt;/code&gt; (and definitely &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;/dev/random&lt;/code&gt;) is to slow to be practical (takes
weeks, or years in the case of &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;/dev/random&lt;/code&gt;).&lt;/p&gt;

&lt;div class=&quot;language-plaintext highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;badblocks -c 10240 -s -w -t random -v $DEVICE
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;

&lt;p&gt;Where &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;-c&lt;/code&gt; sets the block size, &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;-s&lt;/code&gt; shows the progress, &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;-w&lt;/code&gt; sets badblocks to write
mode, &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;-t&lt;/code&gt; specifies the test pattern, in this case random and &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;-v&lt;/code&gt; is verbose,
naturally.&lt;/p&gt;

&lt;p&gt;This usually takes a couple of hours.&lt;/p&gt;

&lt;blockquote&gt;
  &lt;p&gt;&lt;strong&gt;NOTE&lt;/strong&gt;&lt;/p&gt;

  &lt;p&gt;Its not a good idea to use badblocks, instead use 
&lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;dd if=/dev/urandom of=$DEVICE&lt;/code&gt;. I was planning to do this in the future, and
will give details on it once I do it. One cool thing is that its possible to
run one instance of &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;dd&lt;/code&gt; on each core you got, in your entire household. Its
not that hard to use &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;nc&lt;/code&gt; and help with the random generation over the
network.&lt;/p&gt;
&lt;/blockquote&gt;

&lt;p&gt;When done, we need to create a partition with &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;fdisk&lt;/code&gt;&lt;/p&gt;

&lt;div class=&quot;language-plaintext highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;fdisk

n - create new partition
w - write the partition table to disk and quit
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;

&lt;p&gt;I usually create just one partition that covers the whole disk, because I have
no need for several partitions as most of my drives is used for storage.&lt;/p&gt;

&lt;p&gt;Now we create the luks partition:&lt;/p&gt;

&lt;div class=&quot;language-plaintext highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;cryptsetup --verbose --verify-passphrase --key-size 128 luksFormat $DEVICE
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;

&lt;p&gt;i use 128 bits as it has been
&lt;a href=&quot;http://www.schneier.com/blog/archives/2009/07/new_attack_on_a.html&quot;&gt;shown&lt;/a&gt;
that it is more resistant to a brute-force attack then AES 192 and 256 bits.
&lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;cryptsetup&lt;/code&gt; will ask for a pass phrase, I usually have this as a
backup in case I loose my encryption key, like in a disk crash.&lt;/p&gt;

&lt;p&gt;Lets add the encryption key.&lt;/p&gt;

&lt;div class=&quot;language-plaintext highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;cryptsetup luksAddKey $DEVICE $NEW_KEY_FILE
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;

&lt;p&gt;Now we open the luks device in order to format it.&lt;/p&gt;

&lt;div class=&quot;language-plaintext highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;cryptsetup luksOpen $DEVICE $DEVICE_NAME --key-file $KEY_FILE
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;

&lt;p&gt;This will create a new entry in /dev/mapper on which we will write the new
file system.&lt;/p&gt;

&lt;p&gt;Writing the file system:&lt;/p&gt;

&lt;div class=&quot;language-plaintext highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;mkfs.ext3 -L $DEVICE_LABEL -m 0 /dev/mapper/$DEVICE_NAME
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;

&lt;p&gt;The -m switch specifies how much space will be reserved for the super-user, as
my drives is mostly for storage, he doesn’t get any.&lt;/p&gt;

&lt;p&gt;Now we just need to make sure the device is added automatically when we boot.
We need to edit (add a new line) both &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;/etc/crypttab&lt;/code&gt; and
&lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;/etc/fstab&lt;/code&gt; in order to get this to work. The first file opens the
luks devices and the second mounts the unencrypted devices in the file system.&lt;/p&gt;

&lt;p&gt;&lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;/etc/cryptsetup&lt;/code&gt;:&lt;/p&gt;

&lt;div class=&quot;language-plaintext highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;$DEVICE_NAME    $DEVICE_PATH    $KEY_FILE   luks
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;

&lt;p&gt;&lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;/etc/fstab&lt;/code&gt;:&lt;/p&gt;

&lt;div class=&quot;language-plaintext highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;/dev/mapper/$DEVICE_NAME    $MOUNT_POINT ext3   defaults    0   2
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;

&lt;p&gt;A tip is to get the device path from &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;/dev/disk/by-id/&lt;/code&gt;, because
then it doesn’t matter where on your motherboard/controller card the drive is
connected.&lt;/p&gt;

&lt;p&gt;That should be all you need to know to get a proper setup with encrypted drives.&lt;/p&gt;

</description>
        <pubDate>Mon, 23 Aug 2010 00:00:00 +0200</pubDate>
        <link>https://ecksun.com/security/2010/08/23/Disk_Encryption.html</link>
        <guid isPermaLink="true">https://ecksun.com/security/2010/08/23/Disk_Encryption.html</guid>
        
        <category>LUKS</category>
        
        <category>Encryption</category>
        
        <category>HD</category>
        
        
        <category>security</category>
        
      </item>
    
      <item>
        <title>GSoC 2010 Midterm update</title>
        <description>&lt;p&gt;Thought I would give a status update as it is midterm tomorrow.&lt;/p&gt;

&lt;p&gt;Attila notified me the other day that the shepherd source code is up on
gitorioius, you can find it &lt;a href=&quot;http://gitorious.org/shepherd&quot;&gt;here&lt;/a&gt;. I have made
a clone of the repository with all my work, which can be found
&lt;a href=&quot;http://gitorious.org/~ecksun/shepherd/shepherd-sandbox&quot;&gt;here&lt;/a&gt;.&lt;/p&gt;

&lt;p&gt;As it is just now we get access to the shepherd source the plug-ins haven’t
been adapted to work with the shepherd API, which is what I’m working on atm.&lt;/p&gt;

&lt;p&gt;I have also run into a bit of trouble as my hard-drive seems to be failing. A
while after boot/reboot I stop to be able to access files from the drive,
giving me an I/O error at some sector (different depending on the file).
Files/binaries which I have previously used and are cached in ram seem to work
fine.  I’m going to call Acer tomorrow but most likely I’m going to have to buy
a new disk myself. As I’m currently in the middle of nowhere (parents
summer-house) I’m rather limited in what I can do and as I’m only on a HSDPA
connection it will take a couple of hours to download debian, updates,
scratchbox, Qt SDK and so on.&lt;/p&gt;

&lt;p&gt;Other interesting stuff I have run into since my last update:&lt;/p&gt;

&lt;ul&gt;
  &lt;li&gt;QtDBus does per default not define an interface for the objects we try to register (I can at least not find out which interface it used). This was fixed by using:&lt;/li&gt;
&lt;/ul&gt;

&lt;figure class=&quot;highlight&quot;&gt;&lt;pre&gt;&lt;code class=&quot;language-c--&quot; data-lang=&quot;c++&quot;&gt; &lt;span class=&quot;n&quot;&gt;Q_CLASSINFO&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;s&quot;&gt;&quot;D-Bus Interface&quot;&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;s&quot;&gt;&quot;name.of.interface&quot;&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;);&lt;/span&gt; &lt;/code&gt;&lt;/pre&gt;&lt;/figure&gt;

&lt;ul&gt;
  &lt;li&gt;It seems  alarm_action_set_dbus_args only take an array as arguments&lt;/li&gt;
  &lt;li&gt;If you want to receive a string through DBus with QtDBus it apparently cannot
be a std::string, it needs to be a QString&lt;/li&gt;
&lt;/ul&gt;
</description>
        <pubDate>Sun, 11 Jul 2010 00:00:00 +0200</pubDate>
        <link>https://ecksun.com/gsoc/2010/07/11/GSoC_2010_Midterm_update.html</link>
        <guid isPermaLink="true">https://ecksun.com/gsoc/2010/07/11/GSoC_2010_Midterm_update.html</guid>
        
        <category>GSoC</category>
        
        <category>Maemo</category>
        
        <category>Qt</category>
        
        
        <category>GSoC</category>
        
      </item>
    
      <item>
        <title>Debian Squeeze HDMI Sound problems</title>
        <description>&lt;p&gt;Apparently the sound over HDMI didn’t work out of the box on my debian squeeze
installation, I have now gotten it to work and thought I should document my
efforts.&lt;/p&gt;

&lt;p&gt;My setup is as follows:&lt;/p&gt;

&lt;ul&gt;
  &lt;li&gt;Acer 3820T&lt;/li&gt;
  &lt;li&gt;Intel Core i3 330m&lt;/li&gt;
  &lt;li&gt;Intel HDA graphics card (on the same die as the CPU)&lt;/li&gt;
  &lt;li&gt;Debian Squeeze with gnome&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;I came across a
&lt;a href=&quot;http://forums.debian.net/viewtopic.php?f=7&amp;amp;t=33277&amp;amp;start=15#p242018&quot;&gt;post&lt;/a&gt;
on &lt;a href=&quot;http://forums.debian.net&quot;&gt;forums.debian.net&lt;/a&gt; with a possible fix to my
problem.&lt;/p&gt;

&lt;p&gt;When I listed the audio-devices i got the following results:&lt;/p&gt;

&lt;div class=&quot;language-plaintext highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;$ aplay -l
**** List of PLAYBACK Hardware Devices ****
card 0: Intel [HDA Intel], device 0: ALC269 Analog [ALC269 Analog]
Subdevices: 1/1
Subdevice #0: subdevice #0
card 0: Intel [HDA Intel], device 1: ALC269 Digital [ALC269 Digital]
Subdevices: 1/1
Subdevice #0: subdevice #0
card 0: Intel [HDA Intel], device 3: INTEL HDMI [INTEL HDMI]
Subdevices: 1/1
Subdevice #0: subdevice #0
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;

&lt;p&gt;This indicated that there where no problem with the driver/device itself (which
I also knew because it was working flawlessly in windows). Others around the
net seemed to have problem with the device not showing up as it should, which
was probably related to them having dedicated graphic cards and trying to use
the sound card on the mobo or something like that.&lt;/p&gt;

&lt;p&gt;I tried to use &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;aplay&lt;/code&gt; to play a sound through the device but were
unsuccessful, so I continued to search for other solutions. However I later
discovered that &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;speaker-test&lt;/code&gt; also had the ability to play sound through a
certain device, which worked. I assumed there were something wrong with &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;aplay&lt;/code&gt;
or the way I used it and tried to change the switches I enabled in gnome volume
controller.&lt;/p&gt;

&lt;p&gt;I saw three switches:&lt;/p&gt;

&lt;ul&gt;
  &lt;li&gt;IEC958&lt;/li&gt;
  &lt;li&gt;IEC958 Default PCM&lt;/li&gt;
  &lt;li&gt;IEC958 1&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;With only the switch &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;IEC958 1&lt;/code&gt; activated I heard the test-sound over HDMI, success.&lt;/p&gt;

&lt;p&gt;I now continued with boogachamp’s suggestions and added &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;/etc/asound.conf&lt;/code&gt;.
This is how it looks like:&lt;/p&gt;

&lt;div class=&quot;language-plaintext highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;$ cat /etc/asound.conf 
pcm.!default {
    type plug
    slave.pcm {
        type hw
        card 0
        device 3
    }
}
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;

&lt;p&gt;Which I did, restarted &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;alsa-utils&lt;/code&gt; (don’t know if that really was necessary)
and the media player I was using and it worked like charm.&lt;/p&gt;

</description>
        <pubDate>Wed, 07 Jul 2010 00:00:00 +0200</pubDate>
        <link>https://ecksun.com/problems/2010/07/07/Debian_squeeze_HDMI_sound_problems.html</link>
        <guid isPermaLink="true">https://ecksun.com/problems/2010/07/07/Debian_squeeze_HDMI_sound_problems.html</guid>
        
        <category>Debian</category>
        
        <category>Squeeze</category>
        
        <category>HDMI</category>
        
        <category>Sound</category>
        
        
        <category>problems</category>
        
      </item>
    
      <item>
        <title>GSoC 2010 Progress update</title>
        <description>&lt;p&gt;I have just completed another example implementation of an action. This time it
was the notification.&lt;/p&gt;

&lt;p&gt;This means I have working examples for:&lt;/p&gt;

&lt;ul&gt;
  &lt;li&gt;Trigger - WLAN SSID&lt;/li&gt;
  &lt;li&gt;Trigger - Calendar&lt;/li&gt;
  &lt;li&gt;Action - Change profile&lt;/li&gt;
  &lt;li&gt;Action - Secure device&lt;/li&gt;
  &lt;li&gt;Action - Display a notification&lt;/li&gt;
  &lt;li&gt;Action - Turn radio on/off and switch between 2G/3G&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;I have only implemented a way to pull information from the calendar, which is
not optimal. I would like to have a Qt slot telling me when changes are made as
I have done in the SSID trigger but I have not been able to do so yet.&lt;/p&gt;

&lt;p&gt;I am also having some troubles with the dbus commands for turning the radio
on/off and switching between 2G/3G, I have found the right dbus command but I
can’t translate what I found to c++ code. The DBus commands I intend to use is
describe &lt;a href=&quot;http://wiki.maemo.org/Phone_control#Enable_cellular_radio&quot;&gt;here&lt;/a&gt;.&lt;/p&gt;

&lt;p&gt;My next task will be to tackle getting the geographical position from GPS or
Cell towers, I looked into that when I wrote my submission for GSoC, so
hopefully it will work out smoothly.&lt;/p&gt;

</description>
        <pubDate>Wed, 09 Jun 2010 00:00:00 +0200</pubDate>
        <link>https://ecksun.com/gsoc/2010/06/09/GSoC_2010_Progress_update.html</link>
        <guid isPermaLink="true">https://ecksun.com/gsoc/2010/06/09/GSoC_2010_Progress_update.html</guid>
        
        <category>GSoC</category>
        
        <category>Maemo</category>
        
        <category>Qt</category>
        
        
        <category>GSoC</category>
        
      </item>
    
      <item>
        <title>Extending Shepherd - GSoC Proposal</title>
        <description>&lt;h2 id=&quot;abstract&quot;&gt;Abstract&lt;/h2&gt;
&lt;p&gt;Shepherd is an advanced scheduler that can do a wide variety of tasks depending
on a number of triggers.&lt;/p&gt;

&lt;p&gt;The project will aim to improve on the capabilities of Shepherd. I plan to add
more ways of triggering an action and more actions to be taken when the
triggers is meet.&lt;/p&gt;

&lt;h2 id=&quot;full-description&quot;&gt;Full Description&lt;/h2&gt;
&lt;p&gt;Shepherd currently has the ability to start and stop processes depending upon
time, connection type and power requirements. The goal of my project is to
extend the capabilities to include a whole range of triggers and also extend
Shepherds capabilities to perform different actions.&lt;/p&gt;

&lt;p&gt;In a certain situation you might not want to be disturbed, say for example at
your workplace. A configuration might then have a trigger on the SSID of the
WLAN-stations at your workplace and the actions might be to silence the phone
and set the telepathy presence to Busy.&lt;/p&gt;

&lt;p&gt;I plan to add a number of plug-ins to shepherd in order to expand its
capabilities as well as help improve on the current code in order to make it
stable enough for a release. Shepherd is written in C++ but I also hope to
enable functionality for python modules.&lt;/p&gt;

&lt;h1 id=&quot;tasks-and-deliverables&quot;&gt;Tasks and deliverables&lt;/h1&gt;

&lt;h2 id=&quot;back-end&quot;&gt;Back-end&lt;/h2&gt;
&lt;p&gt;The back-end is the most important part of Shepherd and is mostly in place. The
back-end uses several parts of Qt, among others QtDBus for inter-process
communication and QtNetwork for networking. Utilizing Qt not only makes the
code simpler but it does also help improve portability.&lt;/p&gt;

&lt;p&gt;The API for the plug-ins (triggers/actions) need to be stabilized in order for
the development of new plug-ins to begin. The functionality for python modules
does also need to be added.&lt;/p&gt;

&lt;p&gt;Each situation should have a priority in order to determine what actions are
most important. There might be cases where several situations are applicable
but define different values for the same actions.&lt;/p&gt;

&lt;h2 id=&quot;front-end&quot;&gt;Front-end&lt;/h2&gt;
&lt;p&gt;At the moment Shepherd has no graphical user interface. The GUI should give
end-users the ability to configure Shepherd as well as add, edit and remove
situations. The plan is to use Qt in the form of QtGui for the design of the
front end.&lt;/p&gt;

&lt;h2 id=&quot;triggers&quot;&gt;Triggers&lt;/h2&gt;

&lt;p&gt;Each trigger is a criteria in a situation. For example the location can be a
trigger, if the device is within a certain range of a point then the criteria
are met.&lt;/p&gt;

&lt;p&gt;Here follows a list of triggers I plan to implement followed by a list of
possible triggers for future implementation.&lt;/p&gt;

&lt;ul&gt;
  &lt;li&gt;WLAN SSID - Check if a WLAN SSID is nearby&lt;/li&gt;
  &lt;li&gt;Location - Check if the device is in a certain location
    &lt;ul&gt;
      &lt;li&gt;GPS - By using the GPS&lt;/li&gt;
      &lt;li&gt;CellID - Or by using the cell-towers, uses less power than GPS.&lt;/li&gt;
    &lt;/ul&gt;
  &lt;/li&gt;
  &lt;li&gt;Calendar - Check if certain events are happening.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;The following triggers might be implemented if time permits.&lt;/p&gt;

&lt;ul&gt;
  &lt;li&gt;Telepathy status - Are certain accounts online/busy/offline?&lt;/li&gt;
  &lt;li&gt;Accelerometer - Check if the device is in a certain position&lt;/li&gt;
  &lt;li&gt;Proximity sensor - Check if something is nearby, e.g. if the device is in the pocket&lt;/li&gt;
  &lt;li&gt;Light sensor - Check if the light is above/below a certain limit.&lt;/li&gt;
  &lt;li&gt;Open/closed HW keyboard&lt;/li&gt;
  &lt;li&gt;USB Cable connected
    &lt;ul&gt;
      &lt;li&gt;in Mass storage mode&lt;/li&gt;
      &lt;li&gt;in PC Suite mode&lt;/li&gt;
    &lt;/ul&gt;
  &lt;/li&gt;
  &lt;li&gt;Headphone connected&lt;/li&gt;
  &lt;li&gt;Certain bluetooth devices nearby&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;All triggers may be negated in order to increase the configuration possibilities.&lt;/p&gt;

&lt;h2 id=&quot;actions&quot;&gt;Actions&lt;/h2&gt;
&lt;p&gt;When a certain situation arise one or more actions are performed.
I’m planning to implement the following list of actions:&lt;/p&gt;

&lt;ul&gt;
  &lt;li&gt;Change profile&lt;/li&gt;
  &lt;li&gt;Turn Radio on/off
    &lt;ul&gt;
      &lt;li&gt;for WLAN&lt;/li&gt;
      &lt;li&gt;for 3G&lt;/li&gt;
    &lt;/ul&gt;
  &lt;/li&gt;
  &lt;li&gt;Change Telepathy status&lt;/li&gt;
  &lt;li&gt;Secure device&lt;/li&gt;
  &lt;li&gt;Display a notification&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;If I have time I will also try to implement some of the following:&lt;/p&gt;

&lt;ul&gt;
  &lt;li&gt;Change volume&lt;/li&gt;
  &lt;li&gt;Turn vibration on/off&lt;/li&gt;
  &lt;li&gt;Turn screen on/off&lt;/li&gt;
  &lt;li&gt;Turn Radio on/off
    &lt;ul&gt;
      &lt;li&gt;for the FM transmitter&lt;/li&gt;
      &lt;li&gt;for the FM Receiver&lt;/li&gt;
      &lt;li&gt;for GSM&lt;/li&gt;
    &lt;/ul&gt;
  &lt;/li&gt;
  &lt;li&gt;Go in/out of offline mode&lt;/li&gt;
  &lt;li&gt;Send IM/SMS/EMail&lt;/li&gt;
  &lt;li&gt;Shut phone off&lt;/li&gt;
  &lt;li&gt;Change background&lt;/li&gt;
  &lt;li&gt;Change ring-tone&lt;/li&gt;
&lt;/ul&gt;

&lt;h1 id=&quot;schedule&quot;&gt;Schedule&lt;/h1&gt;
&lt;h4 id=&quot;april-26---may-24&quot;&gt;April 26 - May 24&lt;/h4&gt;
&lt;p&gt;Find out what is needed for the different actions and triggers. Take a decision
on how the API for plug-ins should look like.&lt;/p&gt;
&lt;h4 id=&quot;may-24---june-13&quot;&gt;May 24 - June 13&lt;/h4&gt;
&lt;p&gt;Work on the back-end and make sure the API is stable and usable.&lt;/p&gt;
&lt;h4 id=&quot;june-14---june-27&quot;&gt;June 14 - June 27&lt;/h4&gt;
&lt;p&gt;Work on the front-end.&lt;/p&gt;
&lt;h4 id=&quot;june-28---july-4&quot;&gt;June 28 - July 4&lt;/h4&gt;
&lt;p&gt;Triggers to be completed:&lt;/p&gt;

&lt;ul&gt;
  &lt;li&gt;Location&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Actions to be completed:&lt;/p&gt;
&lt;ul&gt;
  &lt;li&gt;Display notification&lt;/li&gt;
&lt;/ul&gt;

&lt;h4 id=&quot;july-5---july-11&quot;&gt;July 5 - July 11&lt;/h4&gt;
&lt;p&gt;Make sure the application works properly, all documentation is in place and
everything is in order.&lt;/p&gt;
&lt;h4 id=&quot;july-11---july-16&quot;&gt;July 11 - July 16&lt;/h4&gt;
&lt;p&gt;Midterm evaluations.&lt;/p&gt;
&lt;h4 id=&quot;july-17---july-25&quot;&gt;July 17 - July 25&lt;/h4&gt;
&lt;p&gt;Triggers to be completed:&lt;/p&gt;

&lt;ul&gt;
  &lt;li&gt;Calendar&lt;/li&gt;
  &lt;li&gt;WLAN SSID&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Actions to be completed:&lt;/p&gt;

&lt;ul&gt;
  &lt;li&gt;Change profile&lt;/li&gt;
&lt;/ul&gt;

&lt;h4 id=&quot;july-26---august-1&quot;&gt;July 26 - August 1&lt;/h4&gt;
&lt;p&gt;Actions to be completed:&lt;/p&gt;

&lt;ul&gt;
  &lt;li&gt;Telepathy status&lt;/li&gt;
  &lt;li&gt;Turn WLAN/3G on/off&lt;/li&gt;
&lt;/ul&gt;

&lt;h4 id=&quot;august-1---august-9&quot;&gt;August 1 - August 9&lt;/h4&gt;
&lt;p&gt;Actions to be completed:&lt;/p&gt;

&lt;ul&gt;
  &lt;li&gt;Secure device&lt;/li&gt;
  &lt;li&gt;Change telepathy status&lt;/li&gt;
&lt;/ul&gt;

&lt;h4 id=&quot;august-9---august-16&quot;&gt;August 9 - August 16&lt;/h4&gt;
&lt;p&gt;Make sure the application works properly, all documentation is in place and
everything is in order&lt;/p&gt;
&lt;h4 id=&quot;august-16---august-20&quot;&gt;August 16 - August 20&lt;/h4&gt;
&lt;p&gt;Final evaluations.&lt;/p&gt;

&lt;h1 id=&quot;other-commitments&quot;&gt;Other commitments&lt;/h1&gt;
&lt;p&gt;I have no other commitments during the summer and Shepherd will be my highest
priority.&lt;/p&gt;

&lt;h1 id=&quot;why-me&quot;&gt;Why me&lt;/h1&gt;
&lt;p&gt;I have long seen the need for an application such as Shepherd and I believe it
has a lot of potential. I’m very motivated because of the wide range of
use-cases that exists for Shepherd as well as the opportunity for me to learn
from and contribute to the community around maemo.&lt;/p&gt;

&lt;p&gt;Ever since I heard about Nokia N900 around the release last year and discovered
maemo.org I have been looking forward to develop for the maemo platform. I
finally feel I have found a device and a community I really feel at home with.
I see this project as the perfect opportunity to become a serious developer and
begin contribute in order to give back to the community what I feel it has
given me.&lt;/p&gt;

&lt;p&gt;Last year I participated in GSoC and wrote a command line interface in java to
SIP-Communicator, a VoIP and chat client. I have also participated in NCPC,
Nordic Collegiate Programming Contest, in both 2008 and 2009 which has helped
me improve my problem solving abilities.&lt;/p&gt;

&lt;p&gt;I have worked with C++ in school and have written programs ranging from simple
command line games to integer factorisation algorithms using GMP. I perform
most of my developing in debian using Git in a number of languages, including
python.&lt;/p&gt;

&lt;h1 id=&quot;community-aspects&quot;&gt;Community aspects&lt;/h1&gt;
&lt;p&gt;To be able to change settings automatically is something not only useful to
myself, but to a wide range of users. This is evident by the responses to the
thread &lt;a href=&quot;http://talk.maemo.org/showthread.php?t=31524&quot;&gt;http://talk.maemo.org/showthread.php?t=31524&lt;/a&gt;
in talk and also the great respons Locale have recived on the Android platform.&lt;/p&gt;

&lt;p&gt;Each plug-in does also serve as a good example on how to utilize the
functionality provided within them. This might be useful even for people that
are not directly interested in Shepherd but who are searching for a way to
perform a particular task provided in one of the plug-ins.&lt;/p&gt;

&lt;h1 id=&quot;contact-information&quot;&gt;Contact information&lt;/h1&gt;
&lt;p&gt;Email: linuswa@kth.se
IRC: ecksun at freenode&lt;/p&gt;

&lt;p&gt;XMPP: linus.wallgren@gmail.com&lt;/p&gt;

&lt;p&gt;Skype: ecksun&lt;/p&gt;

&lt;p&gt;SIP: linuswa@kth.se&lt;/p&gt;

&lt;h1 id=&quot;biography&quot;&gt;Biography&lt;/h1&gt;
&lt;p&gt;I’m a student at the Royal institute of technology in Stockholm, Sweden.
Currently I’m doing my third year of a five year computer science masters
program. At the moment I’m working on my bachelor thesis which is about
studying how Q-learning behaves under different circumstances.&lt;/p&gt;

&lt;p&gt;As mentioned earlier I participated in GSoC last year when I worked for
SIP-Communicator and extended its functionality in order to control the client
from the terminal. I did also mention that I competed in the Nordic Collegiate
Programming Contest the last two years.&lt;/p&gt;

&lt;p&gt;On my spare time, when I’m not at my computer, I practice a mixed martial art
called Goshindo or if the weather and time of year allows I love to wake-board.&lt;/p&gt;

&lt;h1 id=&quot;application-suppliment&quot;&gt;Application Suppliment&lt;/h1&gt;
&lt;blockquote&gt;
  &lt;p&gt;&lt;em&gt;achipa wrote:&lt;/em&gt;&lt;/p&gt;

  &lt;p&gt;I would very much like to see the proposal extended/thought out with regard to
the plugin UI. The original problem with plugin UI/API was that it was
difficult to make a consistent GUI for the plugins. The plugins should have a
unified GUI, it would be bad practice for each plugin to have a separate UI
mechanism (except where technically warranted, like spatial input). It would
help avoid situations where contributed plugins get outdated and incompatible
because they rely on different versions of Qt, bindings, etc. This would also
make it reusable for a desktop version of Shepherd.&lt;/p&gt;
&lt;/blockquote&gt;

&lt;h2 id=&quot;my-respons&quot;&gt;My respons:&lt;/h2&gt;

&lt;p&gt;The first part of the GUI the user will see is a list over all available
situations, when you press a situation you can see and edit a list of the
actions and triggers that are utilized in that particular situation.&lt;/p&gt;

&lt;p&gt;Almost all plug-ins will use the same basic types of input:&lt;/p&gt;

&lt;ul&gt;
  &lt;li&gt;Text input&lt;/li&gt;
  &lt;li&gt;Drop-down selection&lt;/li&gt;
  &lt;li&gt;Slider for numbers&lt;/li&gt;
  &lt;li&gt;Do nothing&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;The first three types will be used by several plug-ins, for example the WLAN
SSID trigger might use the text input type and changing profile might use a
drop-down selection. For example to shut the phone off does not really require
any configuration, which merits the existence of a input type that does
nothing. The only plug-in mentioned above that might have use of another type
of input is the Location trigger which could use a map for inputting the
spatial data.&lt;/p&gt;

&lt;p&gt;There will be methods for automatically creating the above input types. This
can be done by calling a GUI component of shepherd and asking it to add one of
the components. For example the code to configure the WLAN SSID trigger might
look something like:&lt;/p&gt;

&lt;div class=&quot;language-plaintext highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;ShepherdGUI::addTextInput(&quot;ssid&quot;, &quot;Please provide an SSID: &quot;);
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;

&lt;p&gt;If no input type is specified the GUI will assume the plug-in will provide its
own GUI and use QUiLoader to load a .ui file in which the plug-in have defined
how the configuration interface will look like.&lt;/p&gt;

&lt;p&gt;The information entered in the input dialogs can be fetched either by the
plug-in asking for it or by a callback, depending on what seems more
appropriate when the time comes to decide how the API should look like.&lt;/p&gt;

</description>
        <pubDate>Sun, 30 May 2010 00:00:00 +0200</pubDate>
        <link>https://ecksun.com/gsoc/2010/05/30/GSoC_2010_Extending_Shepherd.html</link>
        <guid isPermaLink="true">https://ecksun.com/gsoc/2010/05/30/GSoC_2010_Extending_Shepherd.html</guid>
        
        <category>GSoC</category>
        
        <category>Maemo</category>
        
        <category>Qt</category>
        
        
        <category>GSoC</category>
        
      </item>
    
      <item>
        <title>Scratchbox info</title>
        <description>&lt;p&gt;This is just a bunch of info around scratchbox&lt;/p&gt;

&lt;h1 id=&quot;startup&quot;&gt;Startup&lt;/h1&gt;
&lt;p&gt;In order to disable VSDO on debian lenny AMD 64:&lt;/p&gt;

&lt;div class=&quot;language-plaintext highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;sudo sysctl abi.vsyscall32=2
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;

&lt;p&gt;or&lt;/p&gt;

&lt;div class=&quot;language-plaintext highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;sudo sysctl abi.vsyscall32=0
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;

&lt;p&gt;Both work, but when changint the vsdo to 2 i belieave its called compat mode, I
have no idea what that actually is but I think i read somewhere that its a bit
better in some ways than 0.&lt;/p&gt;

&lt;p&gt;It might be possible that changing the mmap_min_addr also is nescesary:&lt;/p&gt;

&lt;div class=&quot;language-plaintext highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;sudo sysctl vm.mmap_min_addr=65536
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;

&lt;p&gt;I read somewhere that 4096 should suffice, but I have as of yet not run into
any problems with the mmap_min_addr at 65536.&lt;/p&gt;

&lt;h1 id=&quot;xephyr&quot;&gt;Xephyr&lt;/h1&gt;
&lt;p&gt;To start xehpyr&lt;/p&gt;

&lt;div class=&quot;language-plaintext highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;Xephyr :2 -host-cursor -screen 800x480x16 -dpi 96 -ac
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;

&lt;p&gt;wiki.maemo.org have &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;-kb &amp;amp;&lt;/code&gt; at the end, however -kb doesn’t exist in the
version provided with lenny&lt;/p&gt;

&lt;p&gt;And in scratchbox, set the right display&lt;/p&gt;

&lt;div class=&quot;language-plaintext highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;export DISPLAY=:2
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;

&lt;h1 id=&quot;maemo-env&quot;&gt;maemo-env&lt;/h1&gt;
&lt;p&gt;Starting the maemo environment inside scratchbox/xephyr
    af-sb-init.sh start&lt;/p&gt;

&lt;h1 id=&quot;other-issues&quot;&gt;Other Issues&lt;/h1&gt;
&lt;p&gt;Had some troubles connecting to the internet through scratchbox, found out it
was related to me not using my normal configuration (I’m tethering instead of
using my wlan). When running &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;ifconfig&lt;/code&gt; I got this error:&lt;/p&gt;

&lt;div class=&quot;language-plaintext highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;SIOCGIFCONF: Bad address
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;

&lt;p&gt;Through some IRC-logs (thx Lateralus for having the same issue :)) i found out
resolv.conf in scratchbox used the wrong nameserver. I corrected the following
three files to get it to work:&lt;/p&gt;

&lt;div class=&quot;language-plaintext highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;/scratchbox/etc/resolv.conf
/scratchbox/users/xun/targets/FREMANTLE_X86/etc/resolv.conf
/scratchbox/users/xun/targets/FREMANTLE_ARMEL/etc/resolv.conf
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;

&lt;p&gt;Where xun is my scratchbox user, ofc.&lt;/p&gt;

</description>
        <pubDate>Fri, 28 May 2010 00:00:00 +0200</pubDate>
        <link>https://ecksun.com/misc/2010/05/28/Scratchbox_info.html</link>
        <guid isPermaLink="true">https://ecksun.com/misc/2010/05/28/Scratchbox_info.html</guid>
        
        <category>Strachbox</category>
        
        <category>ARM</category>
        
        <category>Lenny</category>
        
        
        <category>Misc</category>
        
      </item>
    
      <item>
        <title>Hello World</title>
        <description>&lt;p&gt;My exams are over and most of my school work is done (need to write some java
ee until next week), which means I will finally be able to focus on GSoC.&lt;/p&gt;

&lt;p&gt;As you might guess my GSoC project is about improving Shepherd and later on I
will publish my accepted proposal.&lt;/p&gt;

&lt;p&gt;My progress thus far is rather limited. I have been able to get a working
dev-env with scratchbox and the final maemo SDK up and running. I have
installed and configured a blog-thingy and I have been able to compile and run
some Qt applications. As I have no previous experience with Qt and no work
experience with c++ I figure it will take some time for me to really get
started.&lt;/p&gt;

&lt;p&gt;I have found several sources of information that can be utilized for the
actions/triggers I plan to implement. My next step is to build the ground of
what will become the wlan-ssid trigger. I found the method allConfigurations()
in
&lt;a href=&quot;http://doc.qt.nokia.com/qtmobility-1.0/qnetworkconfigurationmanager.html&quot;&gt;QNetworkConfigurationManager&lt;/a&gt;
which with the right filter should give me all avalible wlans. It does also
seem that the same method could give me a trigger for other types of internet
connections aswell, as GPRS och HSDPA for example.&lt;/p&gt;

&lt;p&gt;With the release of PR1.2 Qt 4.6 is introduced, something almost required for
my work and also shepherd. However I have failed to upgrade my device :( . The
app manager tells me that I have to use Nokia software updater but when I tried
that it failed with some error about not being able to download the update.&lt;/p&gt;

</description>
        <pubDate>Thu, 27 May 2010 00:00:00 +0200</pubDate>
        <link>https://ecksun.com/misc/2010/05/27/Hello_World.html</link>
        <guid isPermaLink="true">https://ecksun.com/misc/2010/05/27/Hello_World.html</guid>
        
        <category>GSoC</category>
        
        
        <category>misc</category>
        
      </item>
    
  </channel>
</rss>
