<?xml version="1.0" encoding="utf-8" ?>

<?xml-stylesheet type="text/xsl" href="/templates/2k11/rss.xsl" media="screen" ?>
<rss version="2.0" 
   xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#"
   xmlns:admin="http://webns.net/mvcb/"
   xmlns:dc="http://purl.org/dc/elements/1.1/"
   xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
   xmlns:wfw="http://wellformedweb.org/CommentAPI/"
   xmlns:content="http://purl.org/rss/1.0/modules/content/"
   >
<channel>
    
    <title>Daniel Lange's blog (Entries tagged as apache)</title>
    <link>http://daniel-lange.com/</link>
    <description>agrep -pB IT /dev/life</description>
    <dc:language>en</dc:language>
    <generator>Serendipity 2.6.0 - http://www.s9y.org/</generator>
    <pubDate>Sun, 21 Jun 2020 19:38:00 GMT</pubDate>

    <image>
    <url>//daniel-lange.com/uploads/Avatar_Blog_144_234.png</url>
    <title>RSS: Daniel Lange's blog - agrep -pB IT /dev/life</title>
    <link>http://daniel-lange.com/</link>
    <width>144</width>
    <height>234</height>
</image>

<item>
    <title>Upgrading Limesurvey with (near) zero downtime</title>
    <link>http://daniel-lange.com/archives/162-Upgrading-Limesurvey-with-near-zero-downtime.html</link>
            <category>Open Source</category>
    
    <comments>http://daniel-lange.com/archives/162-Upgrading-Limesurvey-with-near-zero-downtime.html#comments</comments>
    <wfw:comment>http://daniel-lange.com/wfwcomment.php?cid=162</wfw:comment>

    <slash:comments>0</slash:comments>
    <wfw:commentRss>http://daniel-lange.com/rss.php?version=2.0&amp;type=comments&amp;cid=162</wfw:commentRss>
    

    <author>nospam@example.com (Daniel Lange)</author>
    <content:encoded>
    &lt;p&gt;Limesurvey is an online survey tool. It is very powerful and commonly used in academic environments because it is Free Software (GPLv2+), allows for local installations protecting the data of participants and allowing to comply with data protection regulations. This also means there are typically no load-balanced multi-server szenarios with HA databases. But simple VMs where Limesurvey runs and needs upgrading in place.&lt;/p&gt;

&lt;p&gt;There&#039;s an LTS branch (currently 3.x) and a stable branch (currently 4.x). There&#039;s also a 2.06 LTS branch that is restricted to paying customers. The main developers behind Limesurvey offer many services from template design to custom development to support to hosting (&quot;Cloud&quot;, &quot;Limesurvey Pro&quot;). Unfortunately they also charge for easy updates called &quot;ComfortUpdate&quot; (currently 39€ for three months) and the manual process is made a bit cumbersome to make the &quot;ComfortUpdate&quot; offer more attractive.&lt;/p&gt;

&lt;p&gt;Due to Limesurvey being an old code base and UI elements not being clearly separated, most serious use cases will end up patching files and symlinking logos around template directories. That conflicts a bit with the opaque &quot;ComfortUpdate&quot; process where you push a button and then magic happens. Or you have downtime and a recovery case while surveys are running.&lt;/p&gt;

&lt;p&gt;If you do not intend to use the &quot;ComfortUpdate&quot; offering, you can prevent Limesurvey from connecting to &lt;code&gt;http://comfortupdate.limesurvey.org&lt;/code&gt; daily by adding the &lt;code&gt;updatable&lt;/code&gt; stanza as in &lt;strong&gt;line 14&lt;/strong&gt; to &lt;code&gt;limesurvey/application/config/config.php&lt;/code&gt;:&lt;/p&gt;

&lt;div class=&quot;php geshi&quot; style=&quot;text-align: left&quot;&gt;&lt;ol&gt;&lt;li style=&quot;font-weight: normal; vertical-align:top;&quot;&gt;&lt;div style=&quot;font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;&quot;&gt;&lt;span style=&quot;color: #b1b100;&quot;&gt;return&lt;/span&gt; &lt;a href=&quot;http://www.php.net/array&quot;&gt;&lt;span style=&quot;color: #990000;&quot;&gt;array&lt;/span&gt;&lt;/a&gt;&lt;span style=&quot;color: #009900;&quot;&gt;&amp;#40;&lt;/span&gt;&lt;/div&gt;&lt;/li&gt;&lt;li style=&quot;font-weight: normal; vertical-align:top;&quot;&gt;&lt;div style=&quot;font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;&quot;&gt;&amp;#160;&lt;span style=&quot;color: #009900;&quot;&gt;&amp;#91;&lt;/span&gt;&lt;span style=&quot;color: #339933;&quot;&gt;...&lt;/span&gt;&lt;span style=&quot;color: #009900;&quot;&gt;&amp;#93;&lt;/span&gt;&lt;/div&gt;&lt;/li&gt;&lt;li style=&quot;font-weight: normal; vertical-align:top;&quot;&gt;&lt;div style=&quot;font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;&quot;&gt;&amp;#160; &amp;#160; &amp;#160; &amp;#160; &amp;#160;&lt;span style=&quot;color: #666666; font-style: italic;&quot;&gt;// Use the following config variable to set modified optional settings copied from config-defaults.php&lt;/span&gt;&lt;/div&gt;&lt;/li&gt;&lt;li style=&quot;font-weight: normal; vertical-align:top;&quot;&gt;&lt;div style=&quot;font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;&quot;&gt;&amp;#160; &amp;#160; &amp;#160; &amp;#160; &lt;span style=&quot;color: #0000ff;&quot;&gt;&#039;config&#039;&lt;/span&gt;&lt;span style=&quot;color: #339933;&quot;&gt;=&amp;gt;&lt;/span&gt;&lt;a href=&quot;http://www.php.net/array&quot;&gt;&lt;span style=&quot;color: #990000;&quot;&gt;array&lt;/span&gt;&lt;/a&gt;&lt;span style=&quot;color: #009900;&quot;&gt;&amp;#40;&lt;/span&gt;&lt;/div&gt;&lt;/li&gt;&lt;li style=&quot;font-weight: normal; vertical-align:top;&quot;&gt;&lt;div style=&quot;font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;&quot;&gt;&amp;#160; &amp;#160; &amp;#160; &amp;#160; &lt;span style=&quot;color: #666666; font-style: italic;&quot;&gt;// debug: Set this to 1 if you are looking for errors. If you still get no errors after enabling this&lt;/span&gt;&lt;/div&gt;&lt;/li&gt;&lt;li style=&quot;font-weight: normal; vertical-align:top;&quot;&gt;&lt;div style=&quot;font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;&quot;&gt;&amp;#160; &amp;#160; &amp;#160; &amp;#160; &lt;span style=&quot;color: #666666; font-style: italic;&quot;&gt;// then please check your error-logs - either in your hosting provider admin panel or in some /logs directory&lt;/span&gt;&lt;/div&gt;&lt;/li&gt;&lt;li style=&quot;font-weight: normal; vertical-align:top;&quot;&gt;&lt;div style=&quot;font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;&quot;&gt;&amp;#160; &amp;#160; &amp;#160; &amp;#160; &lt;span style=&quot;color: #666666; font-style: italic;&quot;&gt;// on your webspace.&lt;/span&gt;&lt;/div&gt;&lt;/li&gt;&lt;li style=&quot;font-weight: normal; vertical-align:top;&quot;&gt;&lt;div style=&quot;font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;&quot;&gt;&amp;#160; &amp;#160; &amp;#160; &amp;#160; &lt;span style=&quot;color: #666666; font-style: italic;&quot;&gt;// LimeSurvey developers: Set this to 2 to additionally display STRICT PHP error messages and get full access to standard templates&lt;/span&gt;&lt;/div&gt;&lt;/li&gt;&lt;li style=&quot;font-weight: normal; vertical-align:top;&quot;&gt;&lt;div style=&quot;font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;&quot;&gt;&amp;#160; &amp;#160; &amp;#160; &amp;#160; &amp;#160; &amp;#160; &amp;#160; &amp;#160; &lt;span style=&quot;color: #0000ff;&quot;&gt;&#039;debug&#039;&lt;/span&gt;&lt;span style=&quot;color: #339933;&quot;&gt;=&amp;gt;&lt;/span&gt;&lt;span style=&quot;color: #cc66cc;&quot;&gt;0&lt;/span&gt;&lt;span style=&quot;color: #339933;&quot;&gt;,&lt;/span&gt;&lt;/div&gt;&lt;/li&gt;&lt;li style=&quot;font-weight: normal; vertical-align:top;&quot;&gt;&lt;div style=&quot;font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;&quot;&gt;&amp;#160; &amp;#160; &amp;#160; &amp;#160; &amp;#160; &amp;#160; &amp;#160; &amp;#160; &lt;span style=&quot;color: #0000ff;&quot;&gt;&#039;debugsql&#039;&lt;/span&gt;&lt;span style=&quot;color: #339933;&quot;&gt;=&amp;gt;&lt;/span&gt;&lt;span style=&quot;color: #cc66cc;&quot;&gt;0&lt;/span&gt;&lt;span style=&quot;color: #339933;&quot;&gt;,&lt;/span&gt; &lt;span style=&quot;color: #666666; font-style: italic;&quot;&gt;// Set this to 1 to enanble sql logging, only active when debug = 2&lt;/span&gt;&lt;/div&gt;&lt;/li&gt;&lt;li style=&quot;font-weight: normal; vertical-align:top;&quot;&gt;&lt;div style=&quot;font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;&quot;&gt;&amp;#160; &amp;#160; &amp;#160; &amp;#160; &amp;#160; &amp;#160; &amp;#160; &amp;#160; &lt;span style=&quot;color: #666666; font-style: italic;&quot;&gt;// Mysql database engine (INNODB|MYISAM):&lt;/span&gt;&lt;/div&gt;&lt;/li&gt;&lt;li style=&quot;font-weight: normal; vertical-align:top;&quot;&gt;&lt;div style=&quot;font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;&quot;&gt;&amp;#160; &amp;#160; &amp;#160; &amp;#160; &amp;#160; &amp;#160; &amp;#160; &amp;#160; &amp;#160;&lt;span style=&quot;color: #0000ff;&quot;&gt;&#039;mysqlEngine&#039;&lt;/span&gt; &lt;span style=&quot;color: #339933;&quot;&gt;=&amp;gt;&lt;/span&gt; &lt;span style=&quot;color: #0000ff;&quot;&gt;&#039;MYISAM&#039;&lt;/span&gt;&lt;/div&gt;&lt;/li&gt;&lt;li style=&quot;font-weight: normal; vertical-align:top;&quot;&gt;&lt;div style=&quot;font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;&quot;&gt;&lt;span style=&quot;color: #339933;&quot;&gt;,&lt;/span&gt; &amp;#160; &amp;#160; &amp;#160; &amp;#160; &amp;#160; &amp;#160; &amp;#160; &lt;span style=&quot;color: #666666; font-style: italic;&quot;&gt;// Update default LimeSurvey config here&lt;/span&gt;&lt;/div&gt;&lt;/li&gt;&lt;li style=&quot;font-weight: normal; vertical-align:top;&quot;&gt;&lt;div style=&quot;font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;&quot;&gt;&amp;#160; &amp;#160; &amp;#160; &amp;#160; &amp;#160; &amp;#160; &amp;#160; &amp;#160; &lt;span style=&quot;color: #0000ff;&quot;&gt;&#039;updatable&#039;&lt;/span&gt; &lt;span style=&quot;color: #339933;&quot;&gt;=&amp;gt;&lt;/span&gt; &lt;span style=&quot;color: #009900; font-weight: bold;&quot;&gt;false&lt;/span&gt;&lt;span style=&quot;color: #339933;&quot;&gt;,&lt;/span&gt;&lt;/div&gt;&lt;/li&gt;&lt;li style=&quot;font-weight: normal; vertical-align:top;&quot;&gt;&lt;div style=&quot;font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;&quot;&gt;&amp;#160; &amp;#160; &amp;#160; &amp;#160; &lt;span style=&quot;color: #009900;&quot;&gt;&amp;#41;&lt;/span&gt;&lt;/div&gt;&lt;/li&gt;&lt;li style=&quot;font-weight: normal; vertical-align:top;&quot;&gt;&lt;div style=&quot;font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;&quot;&gt;&lt;span style=&quot;color: #009900;&quot;&gt;&amp;#41;&lt;/span&gt;&lt;span style=&quot;color: #339933;&quot;&gt;;&lt;/span&gt;&lt;/div&gt;&lt;/li&gt;&lt;/ol&gt;&lt;/div&gt;

&lt;p&gt;The &lt;strong&gt;comma&lt;/strong&gt; on &lt;strong&gt;line 13&lt;/strong&gt; is placed like that in the current default limesurvey &lt;code&gt;config.php&lt;/code&gt;, don&#039;t let yourself get confused.
Every item in a php array must end with a comma. It can be on the next line.&lt;/p&gt;

&lt;p&gt;The basic principle of low risk, near-zero downtime, in-place upgrades is:&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;Create a diff between the current release and the target release&lt;/li&gt;
&lt;li&gt;Inspect the diff&lt;/li&gt;
&lt;li&gt;Make backups of the application webroot&lt;/li&gt;
&lt;li&gt;Patch a copy of the application in-place&lt;/li&gt;
&lt;li&gt;(optional) stop the web server&lt;/li&gt;
&lt;li&gt;Make a backup of the production database&lt;/li&gt;
&lt;li&gt;Move the patched application to the production webroot&lt;/li&gt;
&lt;li&gt;(if 5) Start the webserver&lt;/li&gt;
&lt;li&gt;Upgrade the database (if needed)&lt;/li&gt;
&lt;li&gt;Check the application&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;So, in detail:&lt;/p&gt;
 &lt;a class=&quot;block_level&quot; href=&quot;http://daniel-lange.com/archives/162-Upgrading-Limesurvey-with-near-zero-downtime.html#extended&quot;&gt;Continue reading &quot;Upgrading Limesurvey with (near) zero downtime&quot;&lt;/a&gt;
    </content:encoded>

    <pubDate>Sun, 21 Jun 2020 19:38:00 +0000</pubDate>
    <guid isPermaLink="false">http://daniel-lange.com/archives/162-guid.html</guid>
    <category>apache</category>
<category>diff</category>
<category>limesurvey</category>
<category>patch</category>
<category>production</category>
<category>update</category>
<category>updated</category>
<category>web</category>

</item>
<item>
    <title>Openssh taking minutes to become available, booting takes half an hour ... because your server waits for a few bytes of randomness</title>
    <link>http://daniel-lange.com/archives/152-Openssh-taking-minutes-to-become-available,-booting-takes-half-an-hour-...-because-your-server-waits-for-a-few-bytes-of-randomness.html</link>
            <category>Linux</category>
    
    <comments>http://daniel-lange.com/archives/152-Openssh-taking-minutes-to-become-available,-booting-takes-half-an-hour-...-because-your-server-waits-for-a-few-bytes-of-randomness.html#comments</comments>
    <wfw:comment>http://daniel-lange.com/wfwcomment.php?cid=152</wfw:comment>

    <slash:comments>22</slash:comments>
    <wfw:commentRss>http://daniel-lange.com/rss.php?version=2.0&amp;type=comments&amp;cid=152</wfw:commentRss>
    

    <author>nospam@example.com (Daniel Lange)</author>
    <content:encoded>
    &lt;p&gt;So, your machine now needs minutes to boot before you can ssh in where it used to be seconds before the Debian Buster update?&lt;/p&gt;

&lt;h1&gt;Problem&lt;/h1&gt;

&lt;p&gt;Linux 3.17 (2014-10-05) learnt a new syscall getrandom() that, well, gets bytes from the entropy pool.
Glibc learnt about this with 2.25 (2017-02-05) and &lt;a href=&quot;https://github.com/openssl/openssl/pull/180&quot;&gt;two tries&lt;/a&gt; and four years after the kernel, OpenSSL used that functionality from release 1.1.1 (2018-09-11).
OpenSSH implemented this natively for the 7.8 release (2018-08-24) as well.&lt;/p&gt;

&lt;p&gt;Now the getrandom() syscall will block&lt;sup id=&quot;fnref:1&quot;&gt;&lt;a href=&quot;#fn:1&quot; rel=&quot;footnote&quot;&gt;1&lt;/a&gt;&lt;/sup&gt; if the kernel can&#039;t provide enough entropy. And that&#039;s frequenty the case during boot. Esp. with VMs that have no input devices or IO jitter to source the pseudo random number generator from.&lt;/p&gt;

&lt;h2&gt;First seen in the wild January 2017&lt;/h2&gt;

&lt;p&gt;I vividly remember not seeing my Alpine Linux VMs back on the net after the Alpine 3.5 upgrade. That was basically the same &lt;a href=&quot;https://bugs.alpinelinux.org/issues/6635&quot; title=&quot;Alpine Linux bug tracker #6636&quot;&gt;issue&lt;/a&gt;.&lt;/p&gt;

&lt;h2&gt;&lt;a name=&quot;systemd&quot;&gt;&lt;/a&gt;Systemd. Yeah.&lt;/h2&gt;

&lt;p&gt;Systemd makes this behaviour worse, see issues &lt;a href=&quot;https://github.com/systemd/systemd/issues/4271&quot;&gt;#4271&lt;/a&gt;, &lt;a href=&quot;https://github.com/systemd/systemd/pull/4513&quot;&gt;#4513&lt;/a&gt; and &lt;a href=&quot;https://github.com/systemd/systemd/pull/10621&quot;&gt;#10621&lt;/a&gt;.&lt;br /&gt;
Basically as of now the entropy file saved as &lt;code&gt;/var/lib/systemd/random-seed&lt;/code&gt; will not - drumroll - add entropy to the random pool when played back during boot. Actually it will. It will just not be accounted for. So Linux doesn&#039;t know. And continues blocking getrandom(). This is obviously different from SysVinit times&lt;sup id=&quot;fnref:2&quot;&gt;&lt;a href=&quot;#fn:2&quot; rel=&quot;footnote&quot;&gt;2&lt;/a&gt;&lt;/sup&gt; when &lt;code&gt;/var/lib/urandom/random-seed&lt;/code&gt; (that you still have lying around on updated systems) made sure the system carried enough entropy over reboot to continue working right after enough of the system was booted.&lt;/p&gt;

&lt;p&gt;&lt;a href=&quot;https://github.com/systemd/systemd/issues/4167&quot;&gt;#4167&lt;/a&gt; is a re-opened discussion about systemd eating randomness early at boot (hashmaps in PID 0...). Some Debian folks participate in the recent discussion and it is worth reading if you want to learn about the mess that booting a Linux system has become.&lt;/p&gt;

&lt;p&gt;While we&#039;re talking systemd ... &lt;a href=&quot;https://github.com/systemd/systemd/pull/10676&quot;&gt;#10676&lt;/a&gt; also means systems will use RDRAND in the future despite &lt;a href=&quot;https://plus.google.com/+TheodoreTso/posts/SDcoemc9V3J&quot;&gt;Ted Ts&#039;o&#039;s warning on RDRAND&lt;/a&gt; [&lt;a href=&quot;https://web.archive.org/web/20180320163305/https://plus.google.com/+TheodoreTso/posts/SDcoemc9V3J&quot;&gt;Archive.org mirror&lt;/a&gt; and mirrored locally as &lt;a href=&quot;http://daniel-lange.com/documents/130905_Ted_Tso_on_RDRAND.pdf&quot;&gt;130905_Ted_Tso_on_RDRAND.pdf, 205kB&lt;/a&gt; as &lt;a href=&quot;https://killedbygoogle.com/&quot;&gt;Google+ will be discontinued&lt;/a&gt; in April 2019].&lt;br /&gt;
Update: RDRAND doesn&#039;t return random data on pre-Ryzen AMD CPUs (AMD CPU family &amp;lt;23) as per &lt;a href=&quot;https://github.com/systemd/systemd/issues/11810#issuecomment-489727505&quot;&gt;systemd bug #11810&lt;/a&gt;. It will always be 0xFFFFFFFFFFFFFFFF (2&lt;sup&gt;64&lt;/sup&gt;-1). This is a known issue since 2014, see &lt;a href=&quot;https://bugzilla.kernel.org/show_bug.cgi?id=85911&quot;&gt;kernel bug #85991&lt;/a&gt;.&lt;/p&gt;

&lt;h2&gt;Debian&lt;/h2&gt;

&lt;p&gt;Debian is seeing the same issue working up towards the Buster release, e.g. &lt;a href=&quot;https://bugs.debian.org/cgi-bin/bugreport.cgi?bug=912087&quot;&gt;Bug #912087&lt;/a&gt;.&lt;/p&gt;

&lt;p&gt;The typical issue is:&lt;/p&gt;

&lt;div class=&quot;bash geshi&quot; style=&quot;text-align: left&quot;&gt;&lt;span style=&quot;color: #7a0874; font-weight: bold;&quot;&gt;&amp;#91;&lt;/span&gt; &amp;#160; &amp;#160;&lt;span style=&quot;color: #000000;&quot;&gt;4.428797&lt;/span&gt;&lt;span style=&quot;color: #7a0874; font-weight: bold;&quot;&gt;&amp;#93;&lt;/span&gt; EXT4-fs &lt;span style=&quot;color: #7a0874; font-weight: bold;&quot;&gt;&amp;#40;&lt;/span&gt;vda1&lt;span style=&quot;color: #7a0874; font-weight: bold;&quot;&gt;&amp;#41;&lt;/span&gt;: mounted filesystem with ordered data mode. Opts: &lt;span style=&quot;color: #007800;&quot;&gt;data&lt;/span&gt;=ordered&lt;br /&gt;&lt;span style=&quot;color: #7a0874; font-weight: bold;&quot;&gt;&amp;#91;&lt;/span&gt; &lt;span style=&quot;color: #000000;&quot;&gt;130.970863&lt;/span&gt;&lt;span style=&quot;color: #7a0874; font-weight: bold;&quot;&gt;&amp;#93;&lt;/span&gt; random: crng init &lt;span style=&quot;color: #000000; font-weight: bold;&quot;&gt;done&lt;/span&gt;&lt;/div&gt;

&lt;p&gt;with delays up to tens of minutes on systems with very little external random sources.&lt;/p&gt;

&lt;p&gt;This is what it should look like:&lt;/p&gt;

&lt;div class=&quot;bash geshi&quot; style=&quot;text-align: left&quot;&gt;&lt;span style=&quot;color: #7a0874; font-weight: bold;&quot;&gt;&amp;#91;&lt;/span&gt; &amp;#160; &amp;#160;&lt;span style=&quot;color: #000000;&quot;&gt;1.616819&lt;/span&gt;&lt;span style=&quot;color: #7a0874; font-weight: bold;&quot;&gt;&amp;#93;&lt;/span&gt; random: fast init &lt;span style=&quot;color: #000000; font-weight: bold;&quot;&gt;done&lt;/span&gt;&lt;br /&gt;&lt;span style=&quot;color: #7a0874; font-weight: bold;&quot;&gt;&amp;#91;&lt;/span&gt; &amp;#160; &amp;#160;&lt;span style=&quot;color: #000000;&quot;&gt;2.299314&lt;/span&gt;&lt;span style=&quot;color: #7a0874; font-weight: bold;&quot;&gt;&amp;#93;&lt;/span&gt; random: crng init &lt;span style=&quot;color: #000000; font-weight: bold;&quot;&gt;done&lt;/span&gt;&lt;/div&gt;

&lt;p&gt;Check &lt;code&gt;dmesg | grep -E &quot;(rng|random)&quot;&lt;/code&gt; to see how your systems are doing.&lt;/p&gt;

&lt;p&gt;If this is not fully solved before the Buster release, I hope some of the below can end up in the &lt;a href=&quot;https://salsa.debian.org/ddp-team/release-notes&quot;&gt;release notes&lt;/a&gt;&lt;sup id=&quot;fnref:3&quot;&gt;&lt;a href=&quot;#fn:3&quot; rel=&quot;footnote&quot;&gt;3&lt;/a&gt;&lt;/sup&gt;.&lt;/p&gt;

&lt;h1&gt;Solutions&lt;/h1&gt;

&lt;p&gt;You need to get entropy into the random pool earlier at boot. There are many ways to achieve this and - currently - all require action by the system administrator.&lt;/p&gt;

&lt;h2&gt;Kernel boot parameter&lt;/h2&gt;

&lt;p&gt;From kernel 4.19 (Debian Buster currently runs 4.18 [Update: but will be getting 4.19 before release according to &lt;a href=&quot;https://twitter.com/mikagrml/status/1080602882737610754&quot; title=&quot;Of course this is formal Debian planning. It&#039;s on Twitter!&quot;&gt;Ben via Mika&lt;/a&gt;]) you can set &lt;code&gt;RANDOM_TRUST_CPU&lt;/code&gt; at compile time or &lt;code&gt;random.trust_cpu=on&lt;/code&gt; on the kernel command line. This will make recent Intel / AMD systems trust RDRAND and fill the entropy pool with it. See the warning from Ted Ts&#039;o linked above.&lt;/p&gt;

&lt;p&gt;Update: Since Linux kernel build 4.19.20-1 &lt;code&gt;CONFIG_RANDOM_TRUST_CPU&lt;/code&gt; has been &lt;a href=&quot;https://lists.debian.org/debian-devel/2019/02/msg00170.html&quot;&gt;enabled by default&lt;/a&gt; in Debian.&lt;/p&gt;

&lt;h2&gt;Using a TPM&lt;/h2&gt;

&lt;p&gt;The Trusted Platform Module has an embedded random number generator that can be used. Of course you need to have one on your board for this to be useful. It&#039;s a hardware device.&lt;/p&gt;

&lt;p&gt;Load the &lt;code&gt;tpm-rng&lt;/code&gt; module (ideally from initrd) or compile it into the kernel (&lt;code&gt;config HW_RANDOM_TPM&lt;/code&gt;).
Now, the kernel does not &quot;trust&quot; the TPM RNG by default, so you need to add&lt;/p&gt;

&lt;p&gt;&lt;code&gt;rng_core.default_quality=1000&lt;/code&gt;&lt;/p&gt;

&lt;p&gt;to the kernel command line.
1000 means &quot;trust&quot;, 0 means &quot;don&#039;t use&quot;. So you can chose any value in between that works for you depending on how much you consider your TPM to be unbugged.&lt;/p&gt;

&lt;h2&gt;VirtIO (KVM, QEMU, ...)&lt;/h2&gt;

&lt;p&gt;For Virtual Machines (VMs) you can forward entropy from the host (that should be running longer than the VMs and have enough entropy) via &lt;code&gt;virtio_rng&lt;/code&gt;.&lt;/p&gt;

&lt;p&gt;So on the host, you do:&lt;/p&gt;

&lt;p&gt;&lt;code&gt;kvm ... -object rng-random,filename=/dev/urandom,id=rng0 -device virtio-rng-pci,rng=rng0,bus=pci.0,addr=0x7&lt;/code&gt;&lt;/p&gt;

&lt;p&gt;and within the VM newer kernels should automatically load &lt;code&gt;virtio_rng&lt;/code&gt; and use that.&lt;/p&gt;

&lt;p&gt;You can confirm with dmesg as per above.&lt;/p&gt;

&lt;p&gt;Or check:&lt;/p&gt;

&lt;div class=&quot;bash geshi&quot; style=&quot;text-align: left&quot;&gt;&lt;span style=&quot;color: #666666; font-style: italic;&quot;&gt;# cat /sys/devices/virtual/misc/hw_random/rng_available&lt;/span&gt;&lt;br /&gt;virtio_rng.0&lt;br /&gt;&lt;span style=&quot;color: #666666; font-style: italic;&quot;&gt;# cat /sys/devices/virtual/misc/hw_random/rng_current&lt;/span&gt;&lt;br /&gt;virtio_rng.0&lt;/div&gt;

&lt;h2&gt;Patching systemd&lt;/h2&gt;

&lt;p&gt;The Fedora bugtracker has a &lt;a href=&quot;https://bugzilla.redhat.com/show_bug.cgi?id=1572944#c46&quot;&gt;bash / python script&lt;/a&gt; that replaces the systemd &lt;code&gt;rnd&lt;/code&gt; seeding with a (better) working one. The script can also serve as a good starting point if you need to script your own solution, e.g. for reading from an entropy provider available within your (secure) network.&lt;/p&gt;

&lt;h2&gt;Chaoskey&lt;/h2&gt;

&lt;p&gt;The wonderful Keith Packard and Bdale Garbee have developed a USB dongle, &lt;a href=&quot;https://altusmetrum.org/ChaosKey/&quot;&gt;ChaosKey&lt;/a&gt;, that supplies entropy to the kernel. Hard- and software are open source.&lt;/p&gt;

&lt;p&gt;&lt;a name=&quot;jitterentropy_rng&quot;&gt;&lt;/a&gt;&lt;/p&gt;

&lt;h2&gt;Jitterentropy_RNG&lt;/h2&gt;

&lt;p&gt;Kernel 4.2 introduced &lt;a href=&quot;https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/commit/?id=bb5530e4082446aac3a3d69780cd4dbfa4520013&quot;&gt;&lt;code&gt;jitterentropy_rng&lt;/code&gt;&lt;/a&gt; which will use the jitter in CPU timings to generate randomness.&lt;/p&gt;

&lt;p&gt;&lt;code&gt;modprobe jitterentropy_rng&lt;/code&gt;&lt;/p&gt;

&lt;p&gt;This &lt;a href=&quot;https://pthree.org/2016/05/24/cpu-jitter-entropy-for-the-linux-kernel/&quot;&gt;apparently needs a userspace daemon&lt;/a&gt; though (read: design mistake) so&lt;/p&gt;

&lt;p&gt;&lt;code&gt;apt install jitterentropy-rngd&lt;/code&gt; (available from &lt;a href=&quot;https://packages.debian.org/search?keywords=jitterentropy-rngd&quot;&gt;Buster/testing&lt;/a&gt;).&lt;/p&gt;

&lt;p&gt;The current version 1.0.8-3 installs nicely on Stretch. &lt;code&gt;dpkg -i&lt;/code&gt; is your friend.&lt;/p&gt;

&lt;p&gt;But - drumroll - that daemon doesn&#039;t seem to use the kernel module at all.&lt;/p&gt;

&lt;p&gt;That&#039;s where I stopped looking at that solution. At least for now. There are extensive &lt;a href=&quot;http://www.chronox.de/jent/doc/CPU-Jitter-NPTRNG.html&quot;&gt;docs&lt;/a&gt; if you want to dig into this yourself.&lt;/p&gt;

&lt;p&gt;Update: The Linux kernel 5.3 will have an updated jitterentropy_rng as per &lt;a href=&quot;https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/commit/?id=4d2fa8b44b891f0da5ceda3e5a1402ccf0ab6f26&quot;&gt;Commit 4d2fa8b44&lt;/a&gt;. This is based on the &lt;a href=&quot;https://www.chronox.de/jent.html&quot;&gt;upstream&lt;/a&gt; version &lt;a href=&quot;https://github.com/smuellerDD/jitterentropy-library/releases/tag/v2.1.2&quot;&gt;2.1.2&lt;/a&gt; and should be worth another look.&lt;/p&gt;

&lt;h2&gt;Haveged&lt;/h2&gt;

&lt;p&gt;&lt;code&gt;apt install haveged&lt;/code&gt;&lt;/p&gt;

&lt;p&gt;Haveged is a user-space daemon that gathers entropy though the timing jitter any CPU has. It will only run &quot;late&quot; in boot but may still get your openssh back online within seconds and not minutes.&lt;/p&gt;

&lt;p&gt;It is also - to the best of my knowledge - not verified at all regarding the quality of randomness it generates.
The haveged &lt;a href=&quot;http://issihosts.com/haveged/history.html#havege&quot;&gt;design and history page&lt;/a&gt; provides and interesting read and I wouldn&#039;t recommend haveged if you have alternatives. If you have none, haveged is a wonderful solution though as it works reliably. And unverified entropy is better than no entropy. Just forget this is &lt;del&gt;2018&lt;/del&gt; 2019 &lt;img src=&quot;http://daniel-lange.com/plugins/serendipity_event_emoticate/img/emoticons/smile.png&quot; alt=&quot;:-)&quot; class=&quot;emoticon&quot; /&gt;.&lt;/p&gt;

&lt;h2&gt;early-rng-init-tools&lt;/h2&gt;

&lt;p&gt;Thorsten Glaser has posted newly developed &lt;a href=&quot;https://evolvis.org/plugins/scmgit/cgi-bin/gitweb.cgi?p=alioth/early-rng-init-tools.git;a=tree&quot;&gt;early-rng-init-tools&lt;/a&gt; in a &lt;a href=&quot;https://lists.debian.org/debian-devel/2019/02/msg00327.html&quot;&gt;debian-devel thread&lt;/a&gt;. He provides packages at &lt;a href=&quot;http://fish.mirbsd.org/~tg/Debs/dists/sid/wtf/Pkgs/early-rng-init-tools/&quot;&gt;http://fish.mirbsd.org/~tg/Debs/dists/sid/wtf/Pkgs/early-rng-init-tools/&lt;/a&gt; .&lt;/p&gt;

&lt;p&gt;First he deserves kudos for naming a tool for what it does. This makes it much more easily discoverable than the trend to name things after girlfriends, pets or anime characters. The implementation hooks into the early boot via initrd integration and carries over a seed generated during the previous shutdown. This and some other implementation details are not ideal and there has been quite extensive &lt;a href=&quot;https://lists.debian.org/debian-devel/2019/02/threads.html#00327&quot;&gt;scrutiny&lt;/a&gt; but none that discovered serious issues. Early-rng-init-tools look like a good option for non-RDRAND (~CONFIG_RANDOM_TRUST_CPU) capable platforms.&lt;/p&gt;

&lt;p&gt;&lt;a name=&quot;linustotherescue&quot;&gt;&lt;/a&gt;&lt;/p&gt;

&lt;h2&gt;Linus to the rescue&lt;/h2&gt;

&lt;p&gt;Luckily end of September Linus Torvalds was fed up with the entropy starvation issue and the non-conclusive discussions about (mostly) who&#039;s at fault and ... &lt;a href=&quot;https://lore.kernel.org/lkml/CAHk-=wi0vxLmwEBn2Xgu7hZ0U8z2kN4sgCax+57ZJMVo3huDaQ@mail.gmail.com/&quot;&gt;started coding&lt;/a&gt;.&lt;/p&gt;

&lt;p&gt;With the kernel 5.4 release on 25.11.2019 his &lt;a href=&quot;https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/commit/?id=50ee7529ec4500c88f8664560770a7a1b65db72b&quot;&gt;patch&lt;/a&gt; has made it into mainline. He created a &lt;code&gt;try_to_generate_entropy&lt;/code&gt; function that uses CPU jitter to generate seed entropy for the PRNG early in boot.&lt;/p&gt;

&lt;p&gt;In the &lt;a href=&quot;https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/commit/?id=3f2dc2798b81531fd93a3b9b7c39da47ec689e55&quot;&gt;merge commit&lt;/a&gt; Linus explains:&lt;/p&gt;

&lt;blockquote&gt;
&lt;p&gt;This is admittedly partly &quot;for discussion&quot;.  We need to have a way
forward for the boot time deadlocks where user space ends up waiting for
more entropy, but no entropy is forthcoming because the system is
entirely idle just waiting for something to happen.&lt;/p&gt;

&lt;p&gt;While this was triggered by what is arguably a user space bug with
GDM/gnome-session asking for secure randomness during early boot, when
they didn&#039;t even need any such truly secure thing, the issue ends up
being that our &quot;getrandom()&quot; interface is prone to that kind of
confusion, because people don&#039;t think very hard about whether they want
to block for sufficient amounts of entropy.&lt;/p&gt;

&lt;p&gt;The approach here-in is to decide to not just passively wait for entropy
to happen, but to start actively collecting it if it is missing.  This
is not necessarily always possible, but if the architecture has a CPU
cycle counter, there is a fair amount of noise in the exact timings of
reasonably complex loads.&lt;/p&gt;

&lt;p&gt;We may end up tweaking the load and the entropy estimates, but this
should be at least a reasonable starting point.&lt;/p&gt;
&lt;/blockquote&gt;

&lt;p&gt;So once this kernel is available in your distribution, you should be safe from entropy starvation at boot on any platform that has hardware timers (I haven&#039;t encountered one that does not in the last decade).&lt;/p&gt;

&lt;p&gt;Ted Ts&#039;o &lt;a href=&quot;https://lore.kernel.org/lkml/20190930033706.GD4994@mit.edu/&quot;&gt;reviewed the approach and was fine&lt;/a&gt; and Ahmed Dawish did some &lt;a href=&quot;https://lore.kernel.org/lkml/20191001161448.GA1918@darwi-home-pc/&quot;&gt;testing of the quality of randomness generated and that seems fine&lt;/a&gt;, too.&lt;/p&gt;

&lt;h1&gt;Updates&lt;/h1&gt;

&lt;h3&gt;14.01.2019&lt;/h3&gt;

&lt;p&gt;&lt;a href=&quot;https://sfritsch.de/&quot;&gt;Stefan Fritsch&lt;/a&gt;, the Apache2 maintainer in Debian, OpenBSD developer and a former Debian security team member stumbled over the systemd issue preventing Apache libssl to initialize at boot in a Debian bug &lt;a href=&quot;https://bugs.debian.org/cgi-bin/bugreport.cgi?bug=916690&quot;&gt;#916690 - apache2: getrandom call blocks on first startup, systemd kills with timeout&lt;/a&gt;.&lt;/p&gt;

&lt;p&gt;The bug has been retitled &quot;document getrandom changes causing entropy starvation&quot; hinting at not fixing the underlying issue but documenting it in the Debian Buster release notes.&lt;/p&gt;

&lt;p&gt;Unhappy with this &quot;minimal compromise&quot; Stefan wrote a &lt;a href=&quot;https://lists.debian.org/debian-devel/2018/12/msg00184.html&quot;&gt;comprehensive summary of the current situation&lt;/a&gt; to the Debian-devel mailing list. The discussion spans over &lt;a href=&quot;https://lists.debian.org/debian-devel/2018/12/&quot;&gt;December 2018&lt;/a&gt; and &lt;a href=&quot;https://lists.debian.org/debian-devel/2019/01/&quot;&gt;January 2019&lt;/a&gt; and mostly iterated what had been written above already. The discussion has - so far - not reached any consensus. There is still the &quot;systemd stance&quot; (&lt;a href=&quot;https://bugs.debian.org/cgi-bin/bugreport.cgi?bug=914297#59&quot;&gt;not our problem, fix the daemons&lt;/a&gt;) and the &quot;ssh/apache stance&quot; (&lt;a href=&quot;https://bugs.debian.org/cgi-bin/bugreport.cgi?bug=914297#66&quot;&gt;fix systemd, credit entropy&lt;/a&gt;).&lt;/p&gt;

&lt;p&gt;The &quot;document in release notes&quot; minimal compromise was brought up again and Stefan &lt;a href=&quot;https://lists.debian.org/debian-devel/2019/01/msg00129.html&quot;&gt;warned of the problems this would create for Buster users&lt;/a&gt;:&lt;/p&gt;

&lt;pre&gt;
&gt; I&#039;d prefer having this documented in the release notes:
&gt; https://bugs.debian.org/cgi-bin/bugreport.cgi?bug=916690
&gt; with possible solutions like installing haveged, configuring virtio-rng,
&gt; etc. depending on the situation.

That would be an extremely user-unfriendly &quot;solution&quot; and would lead to 
countless hours of debugging and useless bug reports.
&lt;/pre&gt;

&lt;p&gt;This is exactly why I wrote this blog entry and keep it updated. We need to either fix this or tell everybody we can reach before upgrading to Buster. Otherwise this will lead to huge amounts of systems dead on the network after what looked like a successful upgrade.&lt;/p&gt;

&lt;p&gt;Some interesting tidbits were mentioned within the thread:&lt;/p&gt;

&lt;p&gt;Raphael Hertzog fixed the issue for Kali Linux by &lt;a href=&quot;https://lists.debian.org/debian-devel/2019/01/msg00120.html&quot;&gt;installing haveged by default&lt;/a&gt;. Michael Prokop did &lt;a href=&quot;https://lists.debian.org/debian-devel/2019/01/msg00122.html&quot;&gt;the same for the grml distribution&lt;/a&gt; within its December 2018 release.&lt;/p&gt;

&lt;p&gt;Ben Hutchings pointed to an &lt;a href=&quot;https://lists.debian.org/debian-release/2018/05/threads.html#00130&quot;&gt;interesting thread&lt;/a&gt; on the debian-release mailing list he kicked off in May 2018. Multiple people summarized the options and the fact that there is no &lt;a href=&quot;https://lists.debian.org/debian-release/2018/05/msg00374.html&quot;&gt;&quot;general solution that is both correct and easy&quot;&lt;/a&gt; at the time.&lt;/p&gt;

&lt;p&gt;Sam Hartman identified Debian Buster VMs running under VMware as an issue, because that supervisor does not provide virtio-rng. So &lt;a href=&quot;https://lists.debian.org/debian-devel/2019/01/msg00167.html&quot;&gt;Debian VMs wouldn&#039;t boot into ssh availability&lt;/a&gt; within a reasonable time. This is an issue for real world use cases albeit running a proprietary product as the supervisor.&lt;/p&gt;

&lt;h3&gt;16.01.2019&lt;/h3&gt;

&lt;p&gt;&lt;a href=&quot;https://dkg.fifthhorseman.net/blog/&quot;&gt;Daniel Kahn Gillmor&lt;/a&gt; wrote in to explain a risk for VMs starting right after the boot of the host OS:&lt;/p&gt;

&lt;p&gt;&lt;tt&gt;
If that pool is used by the guest to generate long-term secrets because it appears to be well-initialized, that could be a serious problem.&lt;br /&gt;
(e.g. &quot;Mining your P&#039;s and Q&#039;s&quot; by Heninger et al -- &lt;a href=&quot;https://factorable.net/weakkeys12.extended.pdf&quot;&gt;https://factorable.net/weakkeys12.extended.pdf&lt;/a&gt;)&lt;br /&gt;
I&#039;ve just opened &lt;a href=&quot;https://bugs.launchpad.net/qemu/+bug/1811758&quot;&gt;https://bugs.launchpad.net/qemu/+bug/1811758&lt;/a&gt; to report a way to improve that situation in qemu by default.
&lt;/tt&gt;&lt;/p&gt;

&lt;p&gt;So ... make sure that your host OS has access to a hardware random number generator or at least carries over its random seed properly across reboots. You could also delay VM starts until the crng on the host Linux is fully initialized (&lt;code&gt;random: crng init done&lt;/code&gt;).&lt;br /&gt;
Otherwise your VMs may get insufficiently generated pseudo-random numbers and won&#039;t even know.&lt;/p&gt;

&lt;h3&gt;12.03.2019&lt;/h3&gt;

&lt;p&gt;Stefan Fritsch revived the &lt;a href=&quot;https://lists.debian.org/debian-devel/2019/01/msg00079.html&quot;&gt;thread on debian-devel&lt;/a&gt; again and got a few more interesting tidbits out of the developer community:&lt;/p&gt;

&lt;p&gt;Ben Hutchings has &lt;a href=&quot;https://lists.debian.org/debian-devel/2019/02/msg00170.html&quot;&gt;enabled CONFIG_RANDOM_TRUST_CPU for Debian kernels from 4.19.20-1&lt;/a&gt; so the problem is somewhat contained for recent CPU AMD64 systems (RDRAND capable) in Buster.&lt;/p&gt;

&lt;p&gt;Thorsten Glaser developed &lt;a href=&quot;https://lists.debian.org/debian-devel/2019/02/msg00327.html&quot;&gt;early-rng-init-tools&lt;/a&gt; which combine a few options to try and get entropy carried across boot and generated early during boot. He received some &lt;a href=&quot;https://lists.debian.org/debian-devel/2019/02/threads.html#00327&quot;&gt;scrutiny&lt;/a&gt; as can be expected but none that would discourage me from using it. He explains that this is for early boot and thus has initrd integration. It &lt;a href=&quot;https://lists.debian.org/debian-devel/2019/02/msg00383.html&quot;&gt;complements safer randomness sources or haveged&lt;/a&gt;.&lt;/p&gt;

&lt;h3&gt;16.04.2019&lt;/h3&gt;

&lt;p&gt;The Debian installer for Buster is running into the same problem now as indicated in the &lt;a href=&quot;https://lists.debian.org/debian-devel-announce/2019/04/msg00004.html&quot;&gt;release notes for RC1&lt;/a&gt;.
&lt;a href=&quot;https://bugs.debian.org/cgi-bin/bugreport.cgi?bug=923675&quot;&gt;Bug #923675&lt;/a&gt; has details. Essentially &lt;code&gt;choose-mirror&lt;/code&gt; waits serveral minutes for entropy when used with https mirrors.&lt;/p&gt;

&lt;h3&gt;08.05.2019&lt;/h3&gt;

&lt;p&gt;The RDRAND use introduced in systemd to bypass the kernel random number generator during boot falls for a AMD pre-Ryzen bug as RDRAND on these systems doesn&#039;t return random data after a suspend / resume cycle. Added an update note to the &lt;a href=&quot;#systemd&quot;&gt;systemd section&lt;/a&gt; above.&lt;/p&gt;

&lt;h3&gt;03.06.2019&lt;/h3&gt;

&lt;p&gt;Bastian Blank reports the issue is &lt;a href=&quot;https://lists.debian.org/debian-devel/2019/06/msg00027.html&quot;&gt;affecting Debian cloud images&lt;/a&gt; now as well as cloud-init generates ssh keys during boot.&lt;/p&gt;

&lt;h3&gt;10.07.2019&lt;/h3&gt;

&lt;p&gt;Added the update of jitterentropy_rng to a version based on upstream v2.1.2 into the &lt;a href=&quot;#jitterentropy_rng&quot;&gt;Jitterentropy section above&lt;/a&gt;.&lt;/p&gt;

&lt;h3&gt;16.09.2019&lt;/h3&gt;

&lt;p&gt;The Linux Kernel Mailing List (LKML) is re-iterating the entropy starvation issue and the un-willingness of systemd to fix its usage of randomness in early boot. Ahmed S. Darwish has &lt;a href=&quot;https://lore.kernel.org/linux-ext4/20190910042107.GA1517@darwi-home-pc/&quot;&gt;reported the issue leading to ext4 reproducibly blocking boot with Kernel 5.3-r8&lt;/a&gt;. There are a few patches floated and the whole discussion it worth reading albeit non-conclusive as of now.&lt;/p&gt;

&lt;blockquote&gt;Ted Ts&#039;o says &quot;I really very strongly believe that the idea of making getrandom(2) non-blocking and to blindly assume that we can load up the buffer with &#039;best efforts&#039; randomness to be a terrible, terrible idea that is going to cause major security problems that we will potentially regret very badly. Linus Torvalds believes I am an incompetent systems designer.&quot; in &lt;a href=&quot;https://lore.kernel.org/linux-ext4/20190915052242.GG19710@mit.edu/&quot;&gt;this email&lt;/a&gt;.&lt;/blockquote&gt;

&lt;p&gt;In case you needed a teaser to really start reading the thread! Linus Torvalds also mentions the issue (and a primer on what &quot;never break userspace&quot; means) in the &lt;a href=&quot;https://lkml.org/lkml/2019/9/15/241&quot;&gt;Linux kernel 5.3 release notes&lt;/a&gt;.&lt;/p&gt;

&lt;h3&gt;18.09.2019&lt;/h3&gt;

&lt;p&gt;... and &lt;a href=&quot;https://lkml.org/lkml/2019/9/17/885&quot;&gt;Martin Steigerwald kindly noticed that I update this blog post&lt;/a&gt; with the relevant discussions I come across as this entropy starvation mess continues to haunt us.&lt;/p&gt;

&lt;h3&gt;25.11.2019&lt;/h3&gt;

&lt;p&gt;Added the &lt;a href=&quot;#linustotherescue&quot;&gt;&quot;Linus to the rescue&quot;&lt;/a&gt; section after the Linux kernel 5.4 has been released.&lt;/p&gt;

&lt;h3&gt;02.04.2020&lt;/h3&gt;

&lt;p&gt;I ran into the same issue on a Gentoo system today. Luckily &lt;a href=&quot;https://en.wikipedia.org/wiki/OpenRC&quot;&gt;OpenRC&lt;/a&gt; handeled this gracefully but it delayed booting:
&lt;code&gt;syslog-ng&lt;/code&gt; actually hangs the boot for some time ... waiting for entropy. Argh.
The &lt;a href=&quot;https://forums.gentoo.org/viewtopic-t-1053732-start-0.html&quot;&gt;Gentoo forums thread&lt;/a&gt; on the topic clearly listed the options:&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;Make syslog-ng depend on haveged by adding &lt;code&gt;rc_syslog_ng_need=&quot;haveged&quot;&lt;/code&gt; to &lt;code&gt;/etc/rc.conf&lt;/code&gt; (and obviously having haveged installed)&lt;/li&gt;
&lt;li&gt;Re-compiling the kernel with &lt;code&gt;CONFIG_RANDOM_TRUST_CPU=y&lt;/code&gt; where that is an option&lt;/li&gt;
&lt;/ol&gt;

&lt;div class=&quot;footnotes&quot;&gt;
&lt;hr /&gt;
&lt;ol&gt;

&lt;li id=&quot;fn:1&quot;&gt;
&lt;p&gt;it will return with EAGAIN in the GRND_NONBLOCK use case. The blocking behaviour when lacking entropy is a security measure as per &lt;a href=&quot;https://bugs.chromium.org/p/project-zero/issues/detail?id=1559&quot;&gt;Bug #1559 of Google&#039;s Project Zero&lt;/a&gt;.&amp;#160;&lt;a href=&quot;#fnref:1&quot; rev=&quot;footnote&quot;&gt;&amp;#8617;&lt;/a&gt;&lt;/p&gt;
&lt;/li&gt;

&lt;li id=&quot;fn:2&quot;&gt;
&lt;p&gt;Update 18.12.2018: &quot;SysVinit times&quot; ::= &quot;The times when most Linux distros used SysVinit over other init systems.&quot; So Wheezy and previous for Debian. Some people objected to the statement, so I added this footnote as a clarification. See the discussion in the comments below.&amp;#160;&lt;a href=&quot;#fnref:2&quot; rev=&quot;footnote&quot;&gt;&amp;#8617;&lt;/a&gt;&lt;/p&gt;
&lt;/li&gt;

&lt;li id=&quot;fn:3&quot;&gt;
&lt;p&gt;there is no Buster branch in the release notes repository yet (17.12.2018). Update: I wrote a section for the release notes 06.05.2019 and Paul Gevers amended and committed that. So when users of affected systems read the release notes before upgrading to Buster they will hopefully not be surprised (and worried) by the long boot delays.&amp;#160;&lt;a href=&quot;#fnref:3&quot; rev=&quot;footnote&quot;&gt;&amp;#8617;&lt;/a&gt;&lt;/p&gt;
&lt;/li&gt;

&lt;/ol&gt;
&lt;/div&gt;
 
    </content:encoded>

    <pubDate>Mon, 17 Dec 2018 15:45:00 +0000</pubDate>
    <guid isPermaLink="false">http://daniel-lange.com/archives/152-guid.html</guid>
    <category>alpine</category>
<category>apache</category>
<category>boot</category>
<category>debian</category>
<category>fedora</category>
<category>hang</category>
<category>linux</category>
<category>random</category>
<category>security</category>
<category>ssh</category>
<category>sshd</category>
<category>updated</category>

</item>
<item>
    <title>Multiple Apache VHosts on the same IP and port</title>
    <link>http://daniel-lange.com/archives/2-Multiple-Apache-VHosts-on-the-same-IP-and-port.html</link>
            <category>Apache</category>
    
    <comments>http://daniel-lange.com/archives/2-Multiple-Apache-VHosts-on-the-same-IP-and-port.html#comments</comments>
    <wfw:comment>http://daniel-lange.com/wfwcomment.php?cid=2</wfw:comment>

    <slash:comments>7</slash:comments>
    <wfw:commentRss>http://daniel-lange.com/rss.php?version=2.0&amp;type=comments&amp;cid=2</wfw:commentRss>
    

    <author>nospam@example.com (Daniel Lange)</author>
    <content:encoded>
    &lt;p&gt;I just learned yesterday again, what I knew a few years ago, but since had forgotten:&lt;/p&gt;

&lt;p&gt;You cannot put multiple SSL-enabled virtual Apache hosts onto the same IP and port.&lt;/p&gt;

&lt;p&gt;Apache cannot identify which VirtualHost to serve a request from because the payload is encrypted in its entirety. So a&lt;/p&gt;

&lt;pre&gt;Host: servertwo.tld&lt;/pre&gt;

&lt;p&gt;header cannot be parsed until the encryption has been removed. Which requires the key, which is listed in the VHost section that could not be identified in the first place...
So a name-based VirtualHost-configuration like this won&#039;t work:&lt;/p&gt;

&lt;div class=&quot;apache geshi&quot; style=&quot;text-align: left&quot;&gt;&lt;ol&gt;&lt;li style=&quot;font-weight: normal; vertical-align:top;&quot;&gt;&lt;div style=&quot;font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;&quot;&gt;&lt;span style=&quot;color: #00007f;&quot;&gt;Listen&lt;/span&gt; &lt;span style=&quot;color: #ff0000;&quot;&gt;443&lt;/span&gt;&lt;/div&gt;&lt;/li&gt;&lt;li style=&quot;font-weight: normal; vertical-align:top;&quot;&gt;&lt;div style=&quot;font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;&quot;&gt;&lt;span style=&quot;color: #00007f;&quot;&gt;NameVirtualHost&lt;/span&gt; *:&lt;span style=&quot;color: #ff0000;&quot;&gt;443&lt;/span&gt;&lt;/div&gt;&lt;/li&gt;&lt;li style=&quot;font-weight: normal; vertical-align:top;&quot;&gt;&lt;div style=&quot;font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;&quot;&gt;&amp;lt;&lt;span style=&quot;color: #000000; font-weight:bold;&quot;&gt;virtualhost&lt;/span&gt;&amp;gt;&lt;/div&gt;&lt;/li&gt;&lt;li style=&quot;font-weight: normal; vertical-align:top;&quot;&gt;&lt;div style=&quot;font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;&quot;&gt;&amp;#160; &amp;#160;&lt;span style=&quot;color: #00007f;&quot;&gt;SSLEngine&lt;/span&gt; &lt;span style=&quot;color: #0000ff;&quot;&gt;On&lt;/span&gt;&lt;/div&gt;&lt;/li&gt;&lt;li style=&quot;font-weight: normal; vertical-align:top;&quot;&gt;&lt;div style=&quot;font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;&quot;&gt;&amp;#160; &amp;#160;&lt;span style=&quot;color: #00007f;&quot;&gt;ServerName&lt;/span&gt; serverone.tld:&lt;span style=&quot;color: #ff0000;&quot;&gt;443&lt;/span&gt;&lt;/div&gt;&lt;/li&gt;&lt;li style=&quot;font-weight: normal; vertical-align:top;&quot;&gt;&lt;div style=&quot;font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;&quot;&gt;&amp;#160; &amp;#160;&lt;span style=&quot;color: #00007f;&quot;&gt;SSLCertificateFile&lt;/span&gt; /etc/apache2/ssl/serverone.crt&lt;/div&gt;&lt;/li&gt;&lt;li style=&quot;font-weight: normal; vertical-align:top;&quot;&gt;&lt;div style=&quot;font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;&quot;&gt;&amp;#160; &amp;#160;&lt;span style=&quot;color: #00007f;&quot;&gt;SSLCertificateKeyFile&lt;/span&gt; /etc/apache2/ssl/serverone.key&lt;/div&gt;&lt;/li&gt;&lt;li style=&quot;font-weight: normal; vertical-align:top;&quot;&gt;&lt;div style=&quot;font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;&quot;&gt;&amp;#160; &amp;#160;[...]&lt;/div&gt;&lt;/li&gt;&lt;li style=&quot;font-weight: normal; vertical-align:top;&quot;&gt;&lt;div style=&quot;font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;&quot;&gt;&amp;lt;/&lt;span style=&quot;color: #000000; font-weight:bold;&quot;&gt;virtualhost&lt;/span&gt;&amp;gt;&lt;/div&gt;&lt;/li&gt;&lt;li style=&quot;font-weight: normal; vertical-align:top;&quot;&gt;&lt;div style=&quot;font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;&quot;&gt;&amp;lt;&lt;span style=&quot;color: #000000; font-weight:bold;&quot;&gt;virtualhost&lt;/span&gt;&amp;gt;&lt;/div&gt;&lt;/li&gt;&lt;li style=&quot;font-weight: normal; vertical-align:top;&quot;&gt;&lt;div style=&quot;font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;&quot;&gt;&amp;#160; &amp;#160;&lt;span style=&quot;color: #00007f;&quot;&gt;SSLEngine&lt;/span&gt; &lt;span style=&quot;color: #0000ff;&quot;&gt;On&lt;/span&gt;&lt;/div&gt;&lt;/li&gt;&lt;li style=&quot;font-weight: normal; vertical-align:top;&quot;&gt;&lt;div style=&quot;font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;&quot;&gt;&amp;#160; &amp;#160;&lt;span style=&quot;color: #00007f;&quot;&gt;ServerName&lt;/span&gt; servertwo.tld:&lt;span style=&quot;color: #ff0000;&quot;&gt;443&lt;/span&gt;&lt;/div&gt;&lt;/li&gt;&lt;li style=&quot;font-weight: normal; vertical-align:top;&quot;&gt;&lt;div style=&quot;font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;&quot;&gt;&amp;#160; &amp;#160;&lt;span style=&quot;color: #00007f;&quot;&gt;SSLCertificateFile&lt;/span&gt; /etc/apache2/ssl/servertwo.crt&lt;/div&gt;&lt;/li&gt;&lt;li style=&quot;font-weight: normal; vertical-align:top;&quot;&gt;&lt;div style=&quot;font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;&quot;&gt;&amp;#160; &amp;#160;&lt;span style=&quot;color: #00007f;&quot;&gt;SSLCertificateKeyFile&lt;/span&gt; /etc/apache2/ssl/servertwo.key&lt;/div&gt;&lt;/li&gt;&lt;li style=&quot;font-weight: normal; vertical-align:top;&quot;&gt;&lt;div style=&quot;font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;&quot;&gt;&amp;#160; &amp;#160;[...]&lt;/div&gt;&lt;/li&gt;&lt;li style=&quot;font-weight: normal; vertical-align:top;&quot;&gt;&lt;div style=&quot;font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;&quot;&gt;&amp;lt;/&lt;span style=&quot;color: #000000; font-weight:bold;&quot;&gt;virtualhost&lt;/span&gt;&amp;gt;&lt;/div&gt;&lt;/li&gt;&lt;/ol&gt;&lt;/div&gt;

&lt;p&gt;It will just serve any request out of the first VirtualHost (serverone.tld) regardless of the hostname in the request headers.&lt;/p&gt;

&lt;p&gt;There is some light at the end of this tunnel though:
&lt;a target=&quot;_blank&quot; title=&quot;RFC 4366&quot; href=&quot;http://www.ietf.org/rfc/rfc4366.txt&quot;&gt;RFC4366&lt;/a&gt; describes an optional field to the TLS (&lt;a target=&quot;_blank&quot; title=&quot;Wikipedia:Transport Layer Security - TLS&quot; href=&quot;http://en.wikipedia.org/wiki/Transport_Layer_Security&quot;&gt;Transport Layer Security&lt;/a&gt;) client request called &amp;quot;Server Name Indication&amp;quot; (SNI). With this the client just includes a list of ServerNames (usually one) that it&#039;s trying to contact. Apache can easily match the supplied name from the client against a ServerName (or ServerAlias) directive from it&#039;s configuration files.&lt;/p&gt;

&lt;p&gt;SNI will be supported with &lt;a target=&quot;_blank&quot; title=&quot;OpenSSL Homepage&quot; href=&quot;http://openssl.org&quot;&gt;OpenSSL&lt;/a&gt; v0.9.9 in mod_ssl. Sometime in the future. There is a backport to v0.9.8 available from Steven Henson linked &lt;a target=&quot;_blank&quot; title=&quot;Blog Entry: Mozillazine - gerv&quot; href=&quot;http://weblogs.mozillazine.org/gerv/archives/2007/08/virtual_hosting_ssl_and_sni.html&quot;&gt;here&lt;/a&gt;. Or you can use mod_gnutls as described by George Notaras in a recent &lt;a target=&quot;_blank&quot; title=&quot;Blog entry: SSL-enabled Name-based Apache Virtual Hosts with mod_gnutls&quot; href=&quot;http://www.g-loaded.eu/2007/08/10/ssl-enabled-name-based-apache-virtual-hosts-with-mod_gnutls/&quot;&gt;blog entry&lt;/a&gt;.&lt;/p&gt;

&lt;p&gt;In either cases the above configuration snippet will &amp;quot;just work&amp;quot; once SNI is understood by Apache.&lt;/p&gt;

&lt;p&gt;Currently Internet Explorer 7 (on Vista only, wanna upgrade &lt;img src=&quot;http://daniel-lange.com/plugins/serendipity_event_emoticate/img/emoticons/smile.png&quot; alt=&quot;:-)&quot; class=&quot;emoticon&quot; /&gt;), Mozilla Firefox 2+, Opera 7.6+, KDE Konqueror 3.5+ support sending the SNI. You can test your browser at Kaspar Brand&#039;s &lt;a target=&quot;_blank&quot; title=&quot;https://sni.velox.ch/&quot; href=&quot;https://sni.velox.ch/&quot;&gt;SNI testpage&lt;/a&gt;. He also has a patch available to make Apache 2.2 mod_ssl SNI capable when compiled against a CVS-version of OpenSSL.&lt;/p&gt;

&lt;p&gt;I&#039;m rather sure that spreading SNI capable hosts will also provide new hacking opportunities:
Let&#039;s assume a system serves both Intranet and Internet traffic. A client contacts the Internet IP with SSL but specifies the Intranet Hostname in it&#039;s TLS SNI entry. Guess what will happen? Yup.&lt;/p&gt;

&lt;h2&gt;Update&lt;/h2&gt;

&lt;p&gt;02.09.2009: Gee, after two years people still read this blog entry. So I&#039;ll point you to a few updates. 2009 is not 2007 &lt;img src=&quot;http://daniel-lange.com/plugins/serendipity_event_emoticate/img/emoticons/smile.png&quot; alt=&quot;:-)&quot; class=&quot;emoticon&quot; /&gt; SNI has made some slow progress since the original article. But major steps forward only came this summer: Apache has official support for SNI since 2.2.12 (&lt;a href=&quot;https://issues.apache.org/bugzilla/show_bug.cgi?id=34607&quot; title=&quot;Apache bugtracker bug 34607 - Support for Server Name Indication&quot;&gt;tracking bug&lt;/a&gt;). Gentoo has been early to support SNI and &lt;a href=&quot;http://dev.gentoo.org/~dertobi123/&quot; title=&quot;Tobias&#039; Gentoo dev page&quot;&gt;Tobias Scheerbaum&lt;/a&gt; has written a blog entry on &lt;a href=&quot;http://blog.scherbaum.info/2008/07/20/apache-ssl-und-sni/&quot; title=&quot;Tobias Scheerbaum&#039;s blog entry (in GERMAN)&quot;&gt;Apache, SSL und SNI in Gentoo (in German)&lt;/a&gt; summarizing how it works out of the box. Support for SNI has also been added to Debian (&lt;a href=&quot;http://bugs.debian.org/cgi-bin/bugreport.cgi?bug=461917&quot; title=&quot;Debian bugtracker bug 461917 - Apache 2.2 TLS-SNI support,Package: apache2&quot;&gt;tracking bug&lt;/a&gt;) but for now the default config files don&#039;t reflect SNI capability yet. Ubuntu will see SNI in Karmic Koala, the release scheduled for next month i.e. &quot;9.10&quot; (&lt;a href=&quot;https://bugs.launchpad.net/ubuntu/+source/apache2/+bug/184131&quot; title=&quot;Ubuntu bugtracker bug 184131 - Apache 2.2 SNI support&quot;&gt;tracking bug&lt;/a&gt;). Fedora has a SNI enabled Apache from httpd-2.2.13-1.fc11 onwards (&lt;a href=&quot;https://bugzilla.redhat.com/show_bug.cgi?id=443513&quot; title=&quot;Red Hat bugtracker bug 443513 - SNI support for mod_ssl&quot;&gt;tracking bug&lt;/a&gt;). Tobias also states that SP3 for Windows XP enables IE6 to send the SNI (SP2 is not sufficient).&lt;/p&gt;
 
    </content:encoded>

    <pubDate>Sat, 13 Oct 2007 12:00:00 +0000</pubDate>
    <guid isPermaLink="false">http://daniel-lange.com/archives/2-guid.html</guid>
    <category>apache</category>
<category>sni</category>
<category>ssl</category>
<category>updated</category>
<category>virtualhost</category>

</item>
<item>
    <title>Apache fails to start at boot, but works when started manually</title>
    <link>http://daniel-lange.com/archives/1-Apache-fails-to-start-at-boot,-but-works-when-started-manually.html</link>
            <category>Apache</category>
            <category>Gentoo</category>
    
    <comments>http://daniel-lange.com/archives/1-Apache-fails-to-start-at-boot,-but-works-when-started-manually.html#comments</comments>
    <wfw:comment>http://daniel-lange.com/wfwcomment.php?cid=1</wfw:comment>

    <slash:comments>0</slash:comments>
    <wfw:commentRss>http://daniel-lange.com/rss.php?version=2.0&amp;type=comments&amp;cid=1</wfw:commentRss>
    

    <author>nospam@example.com (Daniel Lange)</author>
    <content:encoded>
    &lt;p&gt;Since a baselayout update Apache fails to start on Gentoo at (re-)boot of a server if that server has unused ethernet interfaces.&lt;/p&gt;

&lt;p&gt;The symptom is that Apache fails to start on boot although it has been added to the runlevel with&lt;br /&gt;&lt;font face=&quot;courier new,courier,monospace&quot;&gt; rc-update add apache default&lt;/font&gt;&lt;/p&gt;

&lt;p&gt;This is caused by recent baselayouts not working properly with more than one eth and not all of them being up.&lt;br /&gt;&lt;br /&gt;Thus changing &lt;font face=&quot;courier new,courier,monospace&quot;&gt;depend() { need net ... }&lt;/font&gt; into&lt;br /&gt;&lt;font face=&quot;courier new,courier,monospace&quot;&gt;depend() { need net&lt;b&gt;.eth0&lt;/b&gt; ... }&lt;/font&gt; at the top of /etc/init.d/apache2 will help.&lt;br /&gt;&lt;br /&gt;While you&#039;re at it you could also add an nice &lt;font face=&quot;courier new,courier,monospace&quot;&gt;after urandom&lt;/font&gt; to the existing &lt;font face=&quot;courier new,courier,monospace&quot;&gt;depend ()&lt;/font&gt; construct&lt;br /&gt;and make sure apr and apache are emerged with flag urandom set. Reading from /dev/random to initialize the digest authentication mechanism (or SSL for that matter) might cause apache to block otherwise if there is not enough entropy in the random pool.&lt;br /&gt;&lt;br /&gt;&lt;/p&gt;
 
    </content:encoded>

    <pubDate>Wed, 03 Oct 2007 14:26:28 +0000</pubDate>
    <guid isPermaLink="false">http://daniel-lange.com/archives/1-guid.html</guid>
    <category>apache</category>
<category>baselayout</category>
<category>bug</category>
<category>eth</category>
<category>gentoo</category>
<category>init.d</category>
<category>network</category>

</item>

</channel>
</rss>
