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

<channel>
	<title>Stefan Reuter</title>
	<atom:link href="https://blogs.reucon.com/srt/feed/" rel="self" type="application/rss+xml" />
	<link>https://blogs.reucon.com/srt</link>
	<description>My Personal Blog</description>
	<lastBuildDate>Thu, 28 Nov 2013 11:36:19 +0000</lastBuildDate>
	<language>en-US</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>https://wordpress.org/?v=4.7.4</generator>
	<item>
		<title>Update on Arch Linux</title>
		<link>https://blogs.reucon.com/srt/update-on-arch-linux-11308/</link>
		<comments>https://blogs.reucon.com/srt/update-on-arch-linux-11308/#respond</comments>
		<pubDate>Wed, 21 Nov 2012 04:29:01 +0000</pubDate>
		<dc:creator><![CDATA[Stefan Reuter]]></dc:creator>
				<category><![CDATA[arch]]></category>
		<category><![CDATA[linux]]></category>

		<guid isPermaLink="false">https://blogs.reucon.com/srt/?p=11308</guid>
		<description><![CDATA[After having started my switch to Arch Linux in June 2011 I have now also switched my main desktop PC and my local server. The general experience is great, most of the time I don&#8217;t miss Ubuntu. The only thing &#8230; <a href="https://blogs.reucon.com/srt/update-on-arch-linux-11308/">Continue reading <span class="meta-nav">&#8594;</span></a>]]></description>
				<content:encoded><![CDATA[<p>After having started my switch to Arch Linux in June 2011 I have now also switched my main desktop PC and my local server.</p>
<p>The general experience is great, most of the time I don&#8217;t miss Ubuntu. The only thing that works great with Ubuntu where I didn&#8217;t yet find a good alternative on Arch is <a href="https://launchpad.net/vmbuilder">vmbuilder</a> to bootstrap virtual machines in a KVM/libvirt environment.</p>
<p>I really like the up to date packages and the rolling releases. The <a href="https://wiki.archlinux.org/">ArchWiki</a> is very helpful and the community is great.</p>
]]></content:encoded>
			<wfw:commentRss>https://blogs.reucon.com/srt/update-on-arch-linux-11308/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Insecure Libraries</title>
		<link>https://blogs.reucon.com/srt/insecure-libraries-11238/</link>
		<comments>https://blogs.reucon.com/srt/insecure-libraries-11238/#respond</comments>
		<pubDate>Tue, 27 Mar 2012 09:19:31 +0000</pubDate>
		<dc:creator><![CDATA[Stefan Reuter]]></dc:creator>
				<category><![CDATA[Business]]></category>
		<category><![CDATA[Development]]></category>
		<category><![CDATA[java]]></category>
		<category><![CDATA[security]]></category>

		<guid isPermaLink="false">https://blogs.reucon.com/srt/?p=11238</guid>
		<description><![CDATA[Sonatype and Aspect Securitiy recently published a study titled &#8220;The Unfortunate Reality of Insecure Libraries&#8221; (registration required). The bottom line is that 80% of the code in today’s applications comes from libraries and frameworks and that the risk of vulnerabilities &#8230; <a href="https://blogs.reucon.com/srt/insecure-libraries-11238/">Continue reading <span class="meta-nav">&#8594;</span></a>]]></description>
				<content:encoded><![CDATA[<p>Sonatype and Aspect Securitiy recently published a study titled &#8220;<a href="https://www.aspectsecurity.com/blog/the-unfortunate-reality-of-insecure-libraries/">The Unfortunate Reality of Insecure Libraries</a>&#8221; (registration required). The bottom line is that 80% of the code in today’s applications comes from libraries and frameworks and that the risk of vulnerabilities in these components is widely neglected. Sonatype and Aspect Security have analyzed the downloads from Maven Central and found that 26% of the downloaded libraries have known vulnerabilities.</p>
<p>Of course this is marketing material but nevertheless it contains a lot of truth. Many organizations lack a process to ensure the libraries they are using in their applications are up to date. The larger an organization is the higher the probability that they prefer not to update their dependencies because they fear to break something. Never touch a running system &#8211; even if it is insecure.</p>
<p>You can argue that the metrics they use are inaccurate as a vulnerability in a library that is used in an application does not imply that the application itself is vulnerable. However if the application is not affected by the vulnerability of a dependant library this is more often by coincidence than by analysis and informed decision.</p>
<p>For applications that we are building for our customers we have a few rules in place that lower the risks involved:</p>
<ul>
<li>We prefer proven frameworks and libraries with a good security track</li>
<li>We check the general code quality of frameworks and libraries we use before we include them</li>
<li>Each iteration starts with updating the dependencies of our applications to their latest stable version</li>
</ul>
<p>While this works well for applications while they are built it does not help for the phase where no active development takes place. It also doesn&#8217;t help with security issues that are discovered and need an immediate fix for the release currently deployed to production.</p>
<p>Therefore we offer support contracts for our applications that cover the latest production release in supported environments. To minimize cost we do not support older versions or milestone, beta and candidate releases.</p>
<p>For those versions we provide our customers with security fixes for vulnerabilities found in one of the supported products or the libraries used in one of these products. This of course includes monitoring the libraries and frameworks we use for reported vulnerabilities and security issues.</p>
<p>We also encourage our customers to plan for maintenence releases at least every six months to keep the dependencies up to date even if there are no new features to be included.</p>
]]></content:encoded>
			<wfw:commentRss>https://blogs.reucon.com/srt/insecure-libraries-11238/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Vulnerability in ApacheDS 1.5</title>
		<link>https://blogs.reucon.com/srt/vulnerability-in-apacheds-1-5-10878/</link>
		<comments>https://blogs.reucon.com/srt/vulnerability-in-apacheds-1-5-10878/#comments</comments>
		<pubDate>Mon, 19 Mar 2012 16:00:04 +0000</pubDate>
		<dc:creator><![CDATA[Stefan Reuter]]></dc:creator>
				<category><![CDATA[Development]]></category>
		<category><![CDATA[java]]></category>
		<category><![CDATA[security]]></category>

		<guid isPermaLink="false">https://blogs.reucon.com/srt/?p=10878</guid>
		<description><![CDATA[Apache Directory Server (ApacheDS) is an LDAP server implemented in Java from the Apache Software Foundation. The server supports a number of password hash functions including MD5, SHA, SMD5 and SSHA so that the clear text password used for authentication &#8230; <a href="https://blogs.reucon.com/srt/vulnerability-in-apacheds-1-5-10878/">Continue reading <span class="meta-nav">&#8594;</span></a>]]></description>
				<content:encoded><![CDATA[<p><img align="right" title="apacheds-server-icon_128x128" src="https://blogs.reucon.com/srt/files/2012/03/apacheds-server-icon_128x128.png" alt="" width="128" height="128" /><a href="http://directory.apache.org/">Apache Directory Server</a> (ApacheDS) is an LDAP server implemented in Java from the Apache Software Foundation.</p>
<p>The server supports a number of password hash functions including MD5, SHA, SMD5 and SSHA so that the clear text password used for authentication is not stored on the server and an attacker who gains access to the data can not use it for authentication unless he breaks the hash.</p>
<p>Password checks are implemented in the class <code>SimpleAuthenticator</code> that includes the following code:</p>
<pre class="brush: java; gutter: false; first-line: 1; highlight: []; html-script: false">// Get the stored password, either from cache or from backend
byte[] storedPassword = principal.getUserPassword();

// Short circuit for PLAIN TEXT passwords : we compare the byte array directly
// Are the passwords equal ?
if ( Arrays.equals( credentials, storedPassword ) )
{
    if ( IS_DEBUG )
    {
        LOG.debug( &quot;{} Authenticated&quot;, opContext.getDn() );
    }

    return principal;
}</pre>
<p>The provided credentials are compared to the stored password which can either be a plain password or the hash of a password. This causes ApacheDS to allow users to authenticate either with the password or the corresponding hash. So authentication of a user with the password <code>abc</code> which is stored as the salted SHA1 hash <code>{SSHA}lIifvzM278asTV8NtjfO3EV3z4caaC5uJPouWw==</code> will succeed if either the original password or the hash is provided.</p>
<p>Both calls will succeed equally:</p>
<pre>ldapsearch -h localhost -p 10389 -D uid=admin,ou=system -x -w &#039;abc&#039;
ldapsearch -h localhost -p 10389 -D uid=admin,ou=system -x \
  -w &#039;{SSHA}lIifvzM278asTV8NtjfO3EV3z4caaC5uJPouWw==&#039;</pre>
<p>An attacker who gains access to the stored hash will thus be able to successfully authenticate as any user without having to know the password.</p>
<p>It seems all versions of ApacheDS 1.5.x including 1.5.7 are vulnerable. The new 2.0 branch does not seem vulnerable.</p>
<p>I&#8217;ve notified the <a href="http://www.apache.org/security/">Apache Security Team</a> on 2012-03-12 and informed them on 2012-03-15 that I will publish this blog entry on 2012-03-19 after they remained silent for three days.</p>
<p>Emmanuel Lécharny finally replied that he does not consider 1.5.7 stable and that</p>
<blockquote><p>People using the server *must* use 2.0.0-Mx versions, even if this version is not stabilized yet.</p></blockquote>
<p>The reason they still link to the vulnerable 1.5.7 version in their &#8220;Latest Downloads&#8221; section without a word on the security issue is</p>
<blockquote><p>Pure laziness&#8230; Sadly, we are knees deep into coding, and we have neglected the web site and the doco :/</p></blockquote>
<p>Seems priorities are more on publishing good news.</p>
<p>Update 2012-03-27: Now more than two weeks after the notification they had plenty of time writing emails explaining why this isn&#8217;t a problem but apparently no time to remove the link to the vulnerable version from the <a href="http://directory.apache.org/">Latest Downloads</a> section.</p>
]]></content:encoded>
			<wfw:commentRss>https://blogs.reucon.com/srt/vulnerability-in-apacheds-1-5-10878/feed/</wfw:commentRss>
		<slash:comments>2</slash:comments>
		</item>
		<item>
		<title>Malicious Toolbars</title>
		<link>https://blogs.reucon.com/srt/malicious-toolbars-10256/</link>
		<comments>https://blogs.reucon.com/srt/malicious-toolbars-10256/#respond</comments>
		<pubDate>Wed, 29 Feb 2012 21:59:42 +0000</pubDate>
		<dc:creator><![CDATA[Stefan Reuter]]></dc:creator>
				<category><![CDATA[Development]]></category>
		<category><![CDATA[javascript]]></category>
		<category><![CDATA[security]]></category>

		<guid isPermaLink="false">http://blogs.reucon.com/srt/?p=10256</guid>
		<description><![CDATA[We recently received a bug report for a web application. The user was unable to use the application due to JavaScript errors that showed up when loading the main page and the screenshot we received showed JavaScript code in a &#8230; <a href="https://blogs.reucon.com/srt/malicious-toolbars-10256/">Continue reading <span class="meta-nav">&#8594;</span></a>]]></description>
				<content:encoded><![CDATA[<p>We recently received a bug report for a web application. The user was unable to use the application due to JavaScript errors that showed up when loading the main page and the screenshot we received showed JavaScript code in a place where the application usually displays a list of informational messages:<br />
<img src="/srt/files/2012/01/code.png" alt="" title="JavaScript Code" width="568" height="150" class="alignnone size-full wp-image-10276" /><br />
Our first attempt was to <a href="http://www.bing.com/search?q=%22function%28a%29%7Bif%28this%3D%3D%3Dvoid%7B%7D+0%7C%7C%22">google</a> for the code snippet to see if it was mentioned elsewhere. It showed up on a few sites, in some forums but nothing really interesting.</p>
<p>The screenshot included an additional detail that caught our attention. A few toolbars were installed in Internet Explorer including the Pdfforge Toolbar:<br />
<img src="/srt/files/2012/01/pdfforge.png" alt="" title="Pdfforge Toolbar" width="568" height="90" class="alignnone size-full wp-image-10286" /></p>
<p>This toolbar comes with <a href="http://en.wikipedia.org/wiki/PDFCreator">PDFCreater</a> and Wikipedia has some details on it:</p>
<blockquote><p>The installation package includes a closed-source browser toolbar that is considered by many users to be malicious software (see below). Although technically an optional component, the opt-out procedure is a multi-step process which is considered by many to be intentionally confusing.</p></blockquote>
<p>The toolbar injects additional JavaScript code into the browser to track its users, report visited sites and show ads.</p>
<p>It turned out that the toolbar had added an <code>indexOf()</code> function to <code>Array.prototype</code>:</p>
<pre>
Array.prototype.indexOf=function(a){if(this===void 0||this===null)
throw new TypeError;var b=Object(this),c=b.length&gt;&gt;&gt;0;
if(c===0)return-1;var d=0,e=d;arguments.length&gt;0&amp;&amp;(
d=Number(arguments[1]),d!==d?d=0:d!==0&amp;&amp;d!==1/e&amp;&amp;d!==-(1/e)&amp;&amp;
(d=(d&gt;0||-1)*Math.floor(Math.abs(d))));if(d&gt;=c)return-1;
var f=d&gt;=0?d:Math.max(c-Math.abs(d),0);for(;f&lt;c;f++)
if(f in b&amp;&amp;b[f]===a)return f;return-1}
</pre>
<p>This seems to be a workaround for older versions of Internet Explorer that don&#8217;t support the <code>indexOf()</code> function natively. To understand how the code ended up in the info messages field here is how the application iterated over the array of messages to display:</p>
<pre>
for (var i in messages) {
  // adds an element for each key in the messages object
  // including messages[&quot;indexOf&quot;]
}
</pre>
<p>The correct way to iterate over an array is however</p>
<pre>
for (var i = 0; i &lt; messages.length; i++) {
  // adds elements only for the values in the array
}
</pre>
<p>Yet another case where the two loops show different results is the following:</p>
<pre>
var a = [];
a[5] = 5;

for (var i=0; i&lt;a.length; i++) {
    // iterates over numeric indexes from 0 to 5
}
</pre>
<p>compared to</p>
<pre>
for (var key in a) {
    // shows only the index of &quot;5&quot; and ignores 0 to 4
}
</pre>
<p>What can we learn from this?</p>
<ul>
<li>Do not use <code>for..in</code> with arrays</li>
<li>Do not modify built-in datatypes as others may depend on them</li>
<li>Be careful what you install on your computer</li>
</ul>
]]></content:encoded>
			<wfw:commentRss>https://blogs.reucon.com/srt/malicious-toolbars-10256/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>ClassLoader Leaks by Oracle</title>
		<link>https://blogs.reucon.com/srt/classloader-leaks-by-oracle-9056/</link>
		<comments>https://blogs.reucon.com/srt/classloader-leaks-by-oracle-9056/#respond</comments>
		<pubDate>Sat, 07 Jan 2012 04:16:15 +0000</pubDate>
		<dc:creator><![CDATA[Stefan Reuter]]></dc:creator>
				<category><![CDATA[Development]]></category>
		<category><![CDATA[java]]></category>
		<category><![CDATA[leak]]></category>
		<category><![CDATA[oracle]]></category>
		<category><![CDATA[tomcat]]></category>

		<guid isPermaLink="false">http://blogs.reucon.com/srt/?p=9056</guid>
		<description><![CDATA[I recently had trouble with a web application deployed on Tomcat that leaked its ClassLoader every time it was redeployed resulting in OutOfMemoryErrors after a few redeployments. This is quite nasty if you plan to do continuous deployment and don&#8217;t &#8230; <a href="https://blogs.reucon.com/srt/classloader-leaks-by-oracle-9056/">Continue reading <span class="meta-nav">&#8594;</span></a>]]></description>
				<content:encoded><![CDATA[<p>I recently had trouble with a web application deployed on Tomcat that leaked its ClassLoader every time it was redeployed resulting in OutOfMemoryErrors after a few redeployments. This is quite nasty if you plan to do continuous deployment and don&#8217;t want to restart the servlet container with each deployment.</p>
<p>Recent versions of Tomcat include <a href="http://wiki.apache.org/tomcat/MemoryLeakProtection">some code</a> that makes you aware of problems when you undeploy the application:</p>
<pre>SEVERE: The web application [] registered the JDBC driver [oracle.jdbc.OracleDriver] but failed to unregister it when the web application was stopped.
 To prevent a memory leak, the JDBC Driver has been forcibly unregistered.
SEVERE: The web application [] appears to have started a thread named [Thread-14] but has failed to stop it. This is very likely to create a memory leak.
SEVERE: The web application [] appears to have started a thread named [Thread-15] but has failed to stop it. This is very likely to create a memory leak.
SEVERE: The web application [] appears to have started a thread named [Thread-16] but has failed to stop it. This is very likely to create a memory leak.
SEVERE: The web application [] appears to have started a thread named [Thread-17] but has failed to stop it. This is very likely to create a memory leak.
SEVERE: The web application [] appears to have started a thread named [Thread-18] but has failed to stop it. This is very likely to create a memory leak.</pre>
<p>As you can see Tomcat managed to unregister the JDBC driver that the application had failed to unregister but could do nothing regarding the threads that had been started but not stopped.</p>
<p>I ran the application with <a href="http://www.yourkit.com/">YourKit</a> attached to check that the WebappClassLoader had actually leaked and to see what those threads were that prevented it from being garbage collected. The &#8220;Paths from GC Roots&#8221; view in YourKit is well suited for this:</p>
<p><img class="alignnone  wp-image-9256" title="ons-leaking-threads" src="/srt/files/2012/01/ons-leaking-threads.png" alt="ONS Leaking Threads" width="569" height="198" /></p>
<p>As you can see there are four threads from <acronym title="Oracle Notification Service">ONS</acronym> that prevent the ClassLoader from being garbage collected: <code>oracle.ons.SenderThread</code>s and <code>oracle.ons.ReceiverThread</code>s.</p>
<p>I wrote a small ServletContextListener that shuts down ONS to get rid of them. After that I noticed that Oracle registered a <code>OracleDiagnosabilityMBean</code> that I had to unregister. Finally I made sure the JDBC drivers that the application had registered were properly unregistered from <code>DriverManager</code>.</p>
<p>With those changes in place the application undeployed well and was fully garbage collected.</p>
<p>Here is the code:</p>
<div class="gistem"><div id="gist-1571892" class="gist">

        <div class="gist-file">
          <div class="gist-data gist-syntax">
              <div class="highlight"><pre><div class='line' id='LC1'><span class="kn">import</span> <span class="nn">oracle.ons.ONS</span><span class="o">;</span></div><div class='line' id='LC2'><span class="kn">import</span> <span class="nn">oracle.ons.SenderThread</span><span class="o">;</span></div><div class='line' id='LC3'><span class="kn">import</span> <span class="nn">org.slf4j.Logger</span><span class="o">;</span></div><div class='line' id='LC4'><span class="kn">import</span> <span class="nn">org.slf4j.LoggerFactory</span><span class="o">;</span></div><div class='line' id='LC5'><span class="kn">import</span> <span class="nn">org.springframework.util.ReflectionUtils</span><span class="o">;</span></div><div class='line' id='LC6'><br/></div><div class='line' id='LC7'><span class="kn">import</span> <span class="nn">javax.management.MBeanServer</span><span class="o">;</span></div><div class='line' id='LC8'><span class="kn">import</span> <span class="nn">javax.management.ObjectName</span><span class="o">;</span></div><div class='line' id='LC9'><span class="kn">import</span> <span class="nn">javax.servlet.ServletContextEvent</span><span class="o">;</span></div><div class='line' id='LC10'><span class="kn">import</span> <span class="nn">javax.servlet.ServletContextListener</span><span class="o">;</span></div><div class='line' id='LC11'><span class="kn">import</span> <span class="nn">java.lang.management.ManagementFactory</span><span class="o">;</span></div><div class='line' id='LC12'><span class="kn">import</span> <span class="nn">java.lang.reflect.Field</span><span class="o">;</span></div><div class='line' id='LC13'><span class="kn">import</span> <span class="nn">java.lang.reflect.Method</span><span class="o">;</span></div><div class='line' id='LC14'><span class="kn">import</span> <span class="nn">java.sql.Driver</span><span class="o">;</span></div><div class='line' id='LC15'><span class="kn">import</span> <span class="nn">java.sql.DriverManager</span><span class="o">;</span></div><div class='line' id='LC16'><span class="kn">import</span> <span class="nn">java.util.ArrayList</span><span class="o">;</span></div><div class='line' id='LC17'><span class="kn">import</span> <span class="nn">java.util.Enumeration</span><span class="o">;</span></div><div class='line' id='LC18'><span class="kn">import</span> <span class="nn">java.util.Hashtable</span><span class="o">;</span></div><div class='line' id='LC19'><span class="kn">import</span> <span class="nn">java.util.List</span><span class="o">;</span></div><div class='line' id='LC20'><br/></div><div class='line' id='LC21'><span class="kd">public</span> <span class="kd">class</span> <span class="nc">CleanUpListener</span> <span class="kd">implements</span> <span class="n">ServletContextListener</span> <span class="o">{</span></div><div class='line' id='LC22'>&nbsp;&nbsp;&nbsp;&nbsp;<span class="kd">private</span> <span class="n">Logger</span> <span class="n">logger</span> <span class="o">=</span> <span class="n">LoggerFactory</span><span class="o">.</span><span class="na">getLogger</span><span class="o">(</span><span class="n">getClass</span><span class="o">());</span></div><div class='line' id='LC23'><br/></div><div class='line' id='LC24'>&nbsp;&nbsp;&nbsp;&nbsp;<span class="nd">@Override</span></div><div class='line' id='LC25'>&nbsp;&nbsp;&nbsp;&nbsp;<span class="kd">public</span> <span class="kt">void</span> <span class="nf">contextInitialized</span><span class="o">(</span><span class="n">ServletContextEvent</span> <span class="n">sce</span><span class="o">)</span> <span class="o">{</span></div><div class='line' id='LC26'>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<span class="c1">// do nothing</span></div><div class='line' id='LC27'>&nbsp;&nbsp;&nbsp;&nbsp;<span class="o">}</span></div><div class='line' id='LC28'><br/></div><div class='line' id='LC29'>&nbsp;&nbsp;&nbsp;&nbsp;<span class="nd">@Override</span></div><div class='line' id='LC30'>&nbsp;&nbsp;&nbsp;&nbsp;<span class="kd">public</span> <span class="kt">void</span> <span class="nf">contextDestroyed</span><span class="o">(</span><span class="n">ServletContextEvent</span> <span class="n">sce</span><span class="o">)</span> <span class="o">{</span></div><div class='line' id='LC31'>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<span class="n">shutdownOns</span><span class="o">();</span></div><div class='line' id='LC32'>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<span class="n">deregisterJdbcDrivers</span><span class="o">();</span></div><div class='line' id='LC33'>&nbsp;&nbsp;&nbsp;&nbsp;<span class="o">}</span></div><div class='line' id='LC34'><br/></div><div class='line' id='LC35'>&nbsp;&nbsp;&nbsp;&nbsp;<span class="nd">@SuppressWarnings</span><span class="o">(</span><span class="s">&quot;unchecked&quot;</span><span class="o">)</span></div><div class='line' id='LC36'>&nbsp;&nbsp;&nbsp;&nbsp;<span class="kd">private</span> <span class="kt">void</span> <span class="nf">shutdownOns</span><span class="o">()</span> <span class="o">{</span></div><div class='line' id='LC37'>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<span class="n">logger</span><span class="o">.</span><span class="na">info</span><span class="o">(</span><span class="s">&quot;Shutting down ONS&quot;</span><span class="o">);</span></div><div class='line' id='LC38'>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<span class="kd">final</span> <span class="n">Method</span> <span class="n">getRunningONS</span> <span class="o">=</span> <span class="n">ReflectionUtils</span><span class="o">.</span><span class="na">findMethod</span><span class="o">(</span><span class="n">ONS</span><span class="o">.</span><span class="na">class</span><span class="o">,</span> <span class="s">&quot;getRunningONS&quot;</span><span class="o">);</span></div><div class='line' id='LC39'>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<span class="kd">final</span> <span class="n">Method</span> <span class="n">shutdown</span> <span class="o">=</span> <span class="n">ReflectionUtils</span><span class="o">.</span><span class="na">findMethod</span><span class="o">(</span><span class="n">ONS</span><span class="o">.</span><span class="na">class</span><span class="o">,</span> <span class="s">&quot;shutdown&quot;</span><span class="o">);</span></div><div class='line' id='LC40'>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<span class="n">ReflectionUtils</span><span class="o">.</span><span class="na">makeAccessible</span><span class="o">(</span><span class="n">getRunningONS</span><span class="o">);</span></div><div class='line' id='LC41'>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<span class="n">ReflectionUtils</span><span class="o">.</span><span class="na">makeAccessible</span><span class="o">(</span><span class="n">shutdown</span><span class="o">);</span></div><div class='line' id='LC42'>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<span class="kd">final</span> <span class="n">ONS</span> <span class="n">ons</span> <span class="o">=</span> <span class="o">(</span><span class="n">ONS</span><span class="o">)</span> <span class="n">ReflectionUtils</span><span class="o">.</span><span class="na">invokeMethod</span><span class="o">(</span><span class="n">getRunningONS</span><span class="o">,</span> <span class="kc">null</span><span class="o">);</span></div><div class='line' id='LC43'>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<span class="k">if</span> <span class="o">(</span><span class="n">ons</span> <span class="o">==</span> <span class="kc">null</span><span class="o">)</span> <span class="o">{</span></div><div class='line' id='LC44'>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<span class="k">return</span><span class="o">;</span></div><div class='line' id='LC45'>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<span class="o">}</span></div><div class='line' id='LC46'>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</div><div class='line' id='LC47'>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<span class="n">ReflectionUtils</span><span class="o">.</span><span class="na">invokeMethod</span><span class="o">(</span><span class="n">shutdown</span><span class="o">,</span> <span class="n">ons</span><span class="o">);</span></div><div class='line' id='LC48'><br/></div><div class='line' id='LC49'>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<span class="kd">final</span> <span class="n">Field</span> <span class="n">senders</span> <span class="o">=</span> <span class="n">ReflectionUtils</span><span class="o">.</span><span class="na">findField</span><span class="o">(</span><span class="n">ONS</span><span class="o">.</span><span class="na">class</span><span class="o">,</span> <span class="s">&quot;senders&quot;</span><span class="o">);</span></div><div class='line' id='LC50'>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<span class="n">ReflectionUtils</span><span class="o">.</span><span class="na">makeAccessible</span><span class="o">(</span><span class="n">senders</span><span class="o">);</span></div><div class='line' id='LC51'>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<span class="kd">final</span> <span class="n">List</span><span class="o">&lt;</span><span class="n">SenderThread</span><span class="o">&gt;</span> <span class="n">senderThreads</span> <span class="o">=</span> <span class="o">(</span><span class="n">List</span><span class="o">&lt;</span><span class="n">SenderThread</span><span class="o">&gt;)</span> <span class="n">ReflectionUtils</span><span class="o">.</span><span class="na">getField</span><span class="o">(</span><span class="n">senders</span><span class="o">,</span> <span class="n">ons</span><span class="o">);</span></div><div class='line' id='LC52'>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<span class="k">if</span> <span class="o">(</span><span class="n">senderThreads</span> <span class="o">==</span> <span class="kc">null</span><span class="o">)</span> <span class="o">{</span></div><div class='line' id='LC53'>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<span class="k">return</span><span class="o">;</span></div><div class='line' id='LC54'>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<span class="o">}</span></div><div class='line' id='LC55'>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</div><div class='line' id='LC56'>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<span class="kd">final</span> <span class="n">Method</span> <span class="n">stopThread</span> <span class="o">=</span> <span class="n">ReflectionUtils</span><span class="o">.</span><span class="na">findMethod</span><span class="o">(</span><span class="n">SenderThread</span><span class="o">.</span><span class="na">class</span><span class="o">,</span> <span class="s">&quot;stopThread&quot;</span><span class="o">);</span></div><div class='line' id='LC57'>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<span class="n">ReflectionUtils</span><span class="o">.</span><span class="na">makeAccessible</span><span class="o">(</span><span class="n">stopThread</span><span class="o">);</span></div><div class='line' id='LC58'>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<span class="k">for</span> <span class="o">(</span><span class="n">SenderThread</span> <span class="n">senderThread</span> <span class="o">:</span> <span class="n">senderThreads</span><span class="o">)</span> <span class="o">{</span></div><div class='line' id='LC59'>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<span class="n">ReflectionUtils</span><span class="o">.</span><span class="na">invokeMethod</span><span class="o">(</span><span class="n">stopThread</span><span class="o">,</span> <span class="n">senderThread</span><span class="o">);</span></div><div class='line' id='LC60'>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<span class="o">}</span></div><div class='line' id='LC61'>&nbsp;&nbsp;&nbsp;&nbsp;<span class="o">}</span></div><div class='line' id='LC62'>&nbsp;&nbsp;&nbsp;&nbsp;</div><div class='line' id='LC63'>&nbsp;&nbsp;&nbsp;&nbsp;<span class="kd">private</span> <span class="kt">void</span> <span class="nf">deregisterJdbcDrivers</span><span class="o">()</span> <span class="o">{</span></div><div class='line' id='LC64'>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<span class="n">logger</span><span class="o">.</span><span class="na">info</span><span class="o">(</span><span class="s">&quot;Deregistering JDBC Drivers&quot;</span><span class="o">);</span></div><div class='line' id='LC65'>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<span class="kd">final</span> <span class="n">Enumeration</span><span class="o">&lt;</span><span class="n">Driver</span><span class="o">&gt;</span> <span class="n">driverEnumeration</span> <span class="o">=</span> <span class="n">DriverManager</span><span class="o">.</span><span class="na">getDrivers</span><span class="o">();</span></div><div class='line' id='LC66'>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<span class="kd">final</span> <span class="n">List</span><span class="o">&lt;</span><span class="n">Driver</span><span class="o">&gt;</span> <span class="n">drivers</span> <span class="o">=</span> <span class="k">new</span> <span class="n">ArrayList</span><span class="o">&lt;</span><span class="n">Driver</span><span class="o">&gt;();</span></div><div class='line' id='LC67'>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<span class="k">while</span> <span class="o">(</span><span class="n">driverEnumeration</span><span class="o">.</span><span class="na">hasMoreElements</span><span class="o">())</span> <span class="o">{</span></div><div class='line' id='LC68'>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<span class="n">drivers</span><span class="o">.</span><span class="na">add</span><span class="o">(</span><span class="n">driverEnumeration</span><span class="o">.</span><span class="na">nextElement</span><span class="o">());</span></div><div class='line' id='LC69'>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<span class="o">}</span></div><div class='line' id='LC70'><br/></div><div class='line' id='LC71'>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<span class="k">for</span> <span class="o">(</span><span class="n">Driver</span> <span class="n">driver</span> <span class="o">:</span> <span class="n">drivers</span><span class="o">)</span> <span class="o">{</span></div><div class='line' id='LC72'>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<span class="k">if</span> <span class="o">(</span><span class="n">driver</span><span class="o">.</span><span class="na">getClass</span><span class="o">().</span><span class="na">getClassLoader</span><span class="o">()</span> <span class="o">!=</span> <span class="n">getClass</span><span class="o">().</span><span class="na">getClassLoader</span><span class="o">())</span> <span class="o">{</span></div><div class='line' id='LC73'>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<span class="n">logger</span><span class="o">.</span><span class="na">debug</span><span class="o">(</span><span class="s">&quot;Not deregistering {} as it does not originate from this webapp&quot;</span><span class="o">,</span> <span class="n">driver</span><span class="o">.</span><span class="na">getClass</span><span class="o">().</span><span class="na">getName</span><span class="o">());</span></div><div class='line' id='LC74'>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<span class="k">continue</span><span class="o">;</span></div><div class='line' id='LC75'>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<span class="o">}</span></div><div class='line' id='LC76'>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<span class="k">try</span> <span class="o">{</span></div><div class='line' id='LC77'>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<span class="n">DriverManager</span><span class="o">.</span><span class="na">deregisterDriver</span><span class="o">(</span><span class="n">driver</span><span class="o">);</span></div><div class='line' id='LC78'>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<span class="n">logger</span><span class="o">.</span><span class="na">debug</span><span class="o">(</span><span class="s">&quot;Deregistered JDBC driver &#39;{}&#39;&quot;</span><span class="o">,</span> <span class="n">driver</span><span class="o">.</span><span class="na">getClass</span><span class="o">().</span><span class="na">getName</span><span class="o">());</span></div><div class='line' id='LC79'>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<span class="k">if</span> <span class="o">(</span><span class="s">&quot;oracle.jdbc.OracleDriver&quot;</span><span class="o">.</span><span class="na">equals</span><span class="o">(</span><span class="n">driver</span><span class="o">.</span><span class="na">getClass</span><span class="o">().</span><span class="na">getName</span><span class="o">()))</span> <span class="o">{</span></div><div class='line' id='LC80'>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<span class="n">deregisterOracleDiagnosabilityMBean</span><span class="o">();</span></div><div class='line' id='LC81'>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<span class="o">}</span></div><div class='line' id='LC82'>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<span class="o">}</span> <span class="k">catch</span> <span class="o">(</span><span class="n">Throwable</span> <span class="n">e</span><span class="o">)</span> <span class="o">{</span></div><div class='line' id='LC83'>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<span class="n">logger</span><span class="o">.</span><span class="na">error</span><span class="o">(</span><span class="s">&quot;Deregistration error&quot;</span><span class="o">,</span> <span class="n">e</span><span class="o">);</span></div><div class='line' id='LC84'>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<span class="o">}</span></div><div class='line' id='LC85'>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<span class="o">}</span></div><div class='line' id='LC86'>&nbsp;&nbsp;&nbsp;&nbsp;<span class="o">}</span></div><div class='line' id='LC87'><br/></div><div class='line' id='LC88'>&nbsp;&nbsp;&nbsp;&nbsp;<span class="kd">private</span> <span class="kt">void</span> <span class="nf">deregisterOracleDiagnosabilityMBean</span><span class="o">()</span> <span class="o">{</span></div><div class='line' id='LC89'>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<span class="kd">final</span> <span class="n">ClassLoader</span> <span class="n">cl</span> <span class="o">=</span> <span class="n">Thread</span><span class="o">.</span><span class="na">currentThread</span><span class="o">().</span><span class="na">getContextClassLoader</span><span class="o">();</span></div><div class='line' id='LC90'>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<span class="k">try</span> <span class="o">{</span></div><div class='line' id='LC91'>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<span class="kd">final</span> <span class="n">MBeanServer</span> <span class="n">mbs</span> <span class="o">=</span> <span class="n">ManagementFactory</span><span class="o">.</span><span class="na">getPlatformMBeanServer</span><span class="o">();</span></div><div class='line' id='LC92'>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<span class="kd">final</span> <span class="n">Hashtable</span><span class="o">&lt;</span><span class="n">String</span><span class="o">,</span> <span class="n">String</span><span class="o">&gt;</span> <span class="n">keys</span> <span class="o">=</span> <span class="k">new</span> <span class="n">Hashtable</span><span class="o">&lt;</span><span class="n">String</span><span class="o">,</span> <span class="n">String</span><span class="o">&gt;();</span></div><div class='line' id='LC93'>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<span class="n">keys</span><span class="o">.</span><span class="na">put</span><span class="o">(</span><span class="s">&quot;type&quot;</span><span class="o">,</span> <span class="s">&quot;diagnosability&quot;</span><span class="o">);</span></div><div class='line' id='LC94'>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<span class="n">keys</span><span class="o">.</span><span class="na">put</span><span class="o">(</span><span class="s">&quot;name&quot;</span><span class="o">,</span> <span class="n">cl</span><span class="o">.</span><span class="na">getClass</span><span class="o">().</span><span class="na">getName</span><span class="o">()</span> <span class="o">+</span> <span class="s">&quot;@&quot;</span> <span class="o">+</span> <span class="n">Integer</span><span class="o">.</span><span class="na">toHexString</span><span class="o">(</span><span class="n">cl</span><span class="o">.</span><span class="na">hashCode</span><span class="o">()).</span><span class="na">toLowerCase</span><span class="o">());</span></div><div class='line' id='LC95'>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<span class="n">mbs</span><span class="o">.</span><span class="na">unregisterMBean</span><span class="o">(</span><span class="k">new</span> <span class="n">ObjectName</span><span class="o">(</span><span class="s">&quot;com.oracle.jdbc&quot;</span><span class="o">,</span> <span class="n">keys</span><span class="o">));</span></div><div class='line' id='LC96'>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<span class="n">logger</span><span class="o">.</span><span class="na">info</span><span class="o">(</span><span class="s">&quot;Deregistered OracleDiagnosabilityMBean&quot;</span><span class="o">);</span></div><div class='line' id='LC97'>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<span class="o">}</span> <span class="k">catch</span> <span class="o">(</span><span class="n">javax</span><span class="o">.</span><span class="na">management</span><span class="o">.</span><span class="na">InstanceNotFoundException</span> <span class="n">e</span><span class="o">)</span> <span class="o">{</span></div><div class='line' id='LC98'>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<span class="n">logger</span><span class="o">.</span><span class="na">debug</span><span class="o">(</span><span class="s">&quot;Oracle OracleDiagnosabilityMBean not found&quot;</span><span class="o">,</span> <span class="n">e</span><span class="o">);</span></div><div class='line' id='LC99'>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<span class="o">}</span> <span class="k">catch</span> <span class="o">(</span><span class="n">Throwable</span> <span class="n">e</span><span class="o">)</span> <span class="o">{</span></div><div class='line' id='LC100'>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<span class="n">logger</span><span class="o">.</span><span class="na">error</span><span class="o">(</span><span class="s">&quot;Oracle JMX unregistration error&quot;</span><span class="o">,</span> <span class="n">e</span><span class="o">);</span></div><div class='line' id='LC101'>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<span class="o">}</span></div><div class='line' id='LC102'>&nbsp;&nbsp;&nbsp;&nbsp;<span class="o">}</span></div><div class='line' id='LC103'><span class="o">}</span></div><div class='line' id='LC104'><br/></div></pre></div>
          </div>

          <div class="gist-meta">
            <a href="https://gist.github.com/raw/1571892/f8d0b7099209db9be49135248d036b4a8c710947/CleanUpListener.java" style="float:right;">view raw</a>
            <a href="https://gist.github.com/1571892#file_clean_up_listener.java" style="float:right;margin-right:10px;color:#666">CleanUpListener.java</a>
            <a href="https://gist.github.com/1571892">This Gist</a> is brought to you using <a href="http://en.bainternet.info/2011/simple-gist-embed"><small>Simple Gist Embed</small></a>.
          </div>
        </div>
</div>
</div><style type="text/css">@import "https://gist.github.com/stylesheets/gist/embed.css"; .gistem .highlight {background: inherit; !important;}</style>
]]></content:encoded>
			<wfw:commentRss>https://blogs.reucon.com/srt/classloader-leaks-by-oracle-9056/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>My First Steps with Arch Linux</title>
		<link>https://blogs.reucon.com/srt/my-first-steps-with-arch-linux-8286/</link>
		<comments>https://blogs.reucon.com/srt/my-first-steps-with-arch-linux-8286/#comments</comments>
		<pubDate>Sat, 18 Jun 2011 17:04:00 +0000</pubDate>
		<dc:creator><![CDATA[Stefan Reuter]]></dc:creator>
				<category><![CDATA[arch]]></category>
		<category><![CDATA[linux]]></category>

		<guid isPermaLink="false">/?p=8286</guid>
		<description><![CDATA[I&#8217;ve been using Ubuntu for quite some time now on my desktop and for my servers. It works well and I like the Debian style apt package manager. However I am less happy with the more recent developments. Ubuntu packages &#8230; <a href="https://blogs.reucon.com/srt/my-first-steps-with-arch-linux-8286/">Continue reading <span class="meta-nav">&#8594;</span></a>]]></description>
				<content:encoded><![CDATA[<p><img src="/srt/wp-content/files/2011/12/archlinux.png" align="right"/><br />
I&#8217;ve been using <a href="http://www.ubuntu.com/">Ubuntu</a> for quite some time now on my desktop and for my servers. It works well and I like the Debian style apt package manager. However I am less happy with the more recent developments. Ubuntu packages differ more and more from the upstream packages and with their focus on <a href="http://unity.ubuntu.com/">Unity</a> I started wondering whether there is a better fit for my Linux needs.</p>
<p>For my new T420s I decided to give <a href="http://www.archlinux.org/">Arch Linux</a> a try after I had a short look at Mint, Debian, Fedora and openSUSE.</p>
<p> <a href="https://wiki.archlinux.org/index.php/The_Arch_Way">The Arch Way</a> makes Arch different as it values simplicity and takes an elegant, minimalist approach. The core installation installs just what you absolutely need so you are greeted by a friendly command line when it&#8217;s done. After that you can easily install a graphical environment including Gnome 3 with or without shell, KDE and Xfce along with whatever packages you need. Software patches are kept to a minimum so most Arch packages are identical or at least very close to their upstream counterparts. The difference is similar to the &#8220;Google experience&#8221; of a Nexus One or Nexus S and the modified Android versions sold by the manufacturers. New versions of upstream software end up in Arch within days.</p>
<p>Arch is a rolling release distro that allows for a one-time installation and perpetual software upgrades. There is no need to reinstall or upgrade the system from one version to the next. Everything in Arch is bleeding edge.</p>
<p>Installation on my T420s did not work as smooth as Ubuntu. The latest official <a href="http://www.archlinux.org/download/">installation ISO</a> is from May 2010 and does not support the network card of the T420s. There are newer testing versions but they have <a href="https://bugs.archlinux.org/task/24729">issues</a> setting up full disk encryption. So I went with the official ISO and installed the updates via WLAN which worked well.</p>
<p>If you come from the Debian world you are used to apt for package management. Arch comes with <a href="https://wiki.archlinux.org/index.php/Pacman">pacman</a> which is similar but a lot faster. Bringing your system up to date just means you have to run <code>pacman -Syu</code> instead of <code>apt-get update && apt-get upgrade</code>. After that you have the latest kernel (2.6.39 as of now). I Installed a few additional packages including XF86, Gnome, Chromium, Thunderbird and Libre Office and had a nice working system. Sound and the Touchpad including scrolling worked out of the box. For the network I decided to use Gnome&#8217;s NetworkManager so I installed network-manager-applet and modemmanager and got an easy to manage network setup with support for wired lan, WLAN and wireless broadband. My Ericsson F5521gw was recognized automatically and UMTS worked right away.</p>
<p>The <a href="https://wiki.archlinux.org">Arch Wiki</a> is a great resource and the home of the excellent documentation of Arch. For each part of the system you have multiple options to choose from and they are well explained.</p>
<p>Up to now I am really happy with Arch.</p>
<p><b>A few notes:</b></p>
<p>To setup focus follows mouse in Gnome run</p>
<pre>gconf-editor /apps/metacity/general/focus_mode</pre>
<p>and change the value from <code>click</code> to <code>sloppy</code>.</p>
<p>To make the massive Gnome 3 title bars a bit less high run</p>
<pre>sed -i \
 &quot;/title_vertical_pad/s/value=\&quot;[0-9]\{1,2\}\&quot;/value=\&quot;0\&quot;/g&quot; \
 /usr/share/themes/Adwaita/metacity-1/metacity-theme-3.xml</pre></p>
]]></content:encoded>
			<wfw:commentRss>https://blogs.reucon.com/srt/my-first-steps-with-arch-linux-8286/feed/</wfw:commentRss>
		<slash:comments>5</slash:comments>
		</item>
		<item>
		<title>From Subversion to Git</title>
		<link>https://blogs.reucon.com/srt/from-subversion-to-git-8156/</link>
		<comments>https://blogs.reucon.com/srt/from-subversion-to-git-8156/#respond</comments>
		<pubDate>Sat, 25 Dec 2010 13:32:58 +0000</pubDate>
		<dc:creator><![CDATA[Stefan Reuter]]></dc:creator>
				<category><![CDATA[git]]></category>
		<category><![CDATA[subversion]]></category>

		<guid isPermaLink="false">/?p=8156</guid>
		<description><![CDATA[Yesterday I&#8217;ve converted the Asterisk-Java repositories from Subversion to git. It&#8217;s rather easy when you use git-svn: sudo apt-get install git-svn git svn clone file:///var/lib/svn/repos/asterisk-java \ --no-metadata -A authors.txt \ -t tags -b branches -T trunk asterisk-java The authors file &#8230; <a href="https://blogs.reucon.com/srt/from-subversion-to-git-8156/">Continue reading <span class="meta-nav">&#8594;</span></a>]]></description>
				<content:encoded><![CDATA[<p>
Yesterday I&#8217;ve converted the <a href="http://asterisk-java.org">Asterisk-Java</a> repositories from Subversion to git. It&#8217;s rather easy when you use git-svn:
</p>
<pre class="brush: plain;">
sudo apt-get install git-svn
git svn clone file:///var/lib/svn/repos/asterisk-java \
  --no-metadata -A authors.txt \
  -t tags -b branches -T trunk asterisk-java
</pre>
<p>
The authors file maps the users in Subversion to the git users. While Subversion usually uses a short username, git uses the full name with email address as a globally unique identifier for users. My authors file looked like this:
</p>
<pre class="brush: plain;">
srt = Stefan Reuter &lt;stefan.reuter@example.com&gt;
root = Stefan Reuter &lt;stefan.reuter@example.com&gt;
</pre>
<p>
As I had direct filesystem access to the Subversion repositories I chose to use the file protocol instead of HTTP so it was much faster. The <code>--no-metadata</code> option tells git-svn not to include the orignal Subversion revision number in every commit. This removes clutter from the history.
</p>
<p>
Finally git-svn creates branches for all tags in Subversion which is a bit nasty. So I converted them to git tags:
</p>
<pre class="brush: plain;">
cd asterisk-java
for tag in `git branch -r | grep '^  tags' | sed 's,  tags/,,'`
do
  echo Converting Tag $tag
  git tag $tag tags/$tag
  git branch -r -d tags/$tag
done
</pre>
<p>
There it is a nice git repository containing the full history. I only had to push it to <a href="http://github.com">github</a> to make it available to everybody who is interested:
</p>
<pre class="brush: plain;">
git remote add origin git@github.com:srt/asterisk-java.git
git push origin master
git push --tags
</pre>
]]></content:encoded>
			<wfw:commentRss>https://blogs.reucon.com/srt/from-subversion-to-git-8156/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Spring Framework Security Vulnerability Part 2</title>
		<link>https://blogs.reucon.com/srt/spring-framework-security-vulnerability-part-2-8756/</link>
		<comments>https://blogs.reucon.com/srt/spring-framework-security-vulnerability-part-2-8756/#respond</comments>
		<pubDate>Mon, 12 Jul 2010 12:14:00 +0000</pubDate>
		<dc:creator><![CDATA[Stefan Reuter]]></dc:creator>
				<category><![CDATA[Development]]></category>
		<category><![CDATA[Operations]]></category>
		<category><![CDATA[security]]></category>
		<category><![CDATA[spring]]></category>

		<guid isPermaLink="false">/?p=8756</guid>
		<description><![CDATA[I&#8217;ve already talked about CVE-2010-1622 and what SpringSource could have done better when dealing with this security issue. Today I want to focus on what you as a developer or system administrator can learn from the bug. What can developers &#8230; <a href="https://blogs.reucon.com/srt/spring-framework-security-vulnerability-part-2-8756/">Continue reading <span class="meta-nav">&#8594;</span></a>]]></description>
				<content:encoded><![CDATA[<p>
I&#8217;ve already talked about <a href="http://blogs.reucon.com/srt/2010/06/26/spring_framework_security_vulnerability_part_1.html">CVE-2010-1622</a> and what SpringSource could have done better when dealing with this security issue.<br />
Today I want to focus on what you as a developer or system administrator can learn from the bug.
</p>
<p><b>What can developers learn from CVE-2010-1622?</b></p>
<p>The exploit requires manipulating the class loader property so that it will download code from an external site. So you can prevent the attack by disallowing modifications of the class loader and by disallowing your application to download and run code from external sites.</p>
<p>Be explicit! Explicitly allow binding of certain properties. This prevents the exploit from working as there is no valid use case that requires access to the class property. Explicitly whitelisting properties also makes sure users cannot change the id of the object bound to a form or altering data that is managed internally like &#8220;date of creation&#8221; or &#8220;last modified by&#8221; properties.</p>
<p>To prevent code from external sites being downloaded and executed you can make sure your applications behaves well when run with a <a href="http://download.oracle.com/docs/cd/E17409_01/javase/tutorial/security/tour2/index.html">security manager</a>. While this is a common concept used for client side code like applets it is far less common for server side applications. Tomcat usually works well with a security manager though it is not enabled by default. Making sure you appplications works with a security manager is also a variant of being explicit: You explicitly grant certain privileges to your code bases and disallow everything else that might be abused by attackers.</p>
<p><b>What can system administrators learn from CVE-2010-1622?</b></p>
<p>Your applications should run in a demilitarized zone where they are unable to access the internet or your intranet. If you really need access to external resources use a proxy server and white list the URLs your application needs to contact. Doing so prevents attackers from making your application download external code.</p>
<p>If your applications are built in a way that they work with a security manager use it! For Tomcat there is a short <a href="http://tomcat.apache.org/tomcat-7.0-doc/security-manager-howto.html">Howto</a> available.</p>
]]></content:encoded>
			<wfw:commentRss>https://blogs.reucon.com/srt/spring-framework-security-vulnerability-part-2-8756/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Spring Framework Security Vulnerability Part 1</title>
		<link>https://blogs.reucon.com/srt/spring-framework-security-vulnerability-part-1-8786/</link>
		<comments>https://blogs.reucon.com/srt/spring-framework-security-vulnerability-part-1-8786/#respond</comments>
		<pubDate>Sat, 26 Jun 2010 09:25:00 +0000</pubDate>
		<dc:creator><![CDATA[Stefan Reuter]]></dc:creator>
				<category><![CDATA[Development]]></category>
		<category><![CDATA[security]]></category>
		<category><![CDATA[spring]]></category>

		<guid isPermaLink="false">/?p=8786</guid>
		<description><![CDATA[Spring Source recently published CVE-2010-1622. The advisory describes a vulnerability that affects Spring Framework prior to 3.0.3 and allows attackers to execute arbitrary code. What could SpringSource have done better? When Spring Source announced the release of 3.0.3 they reported &#8230; <a href="https://blogs.reucon.com/srt/spring-framework-security-vulnerability-part-1-8786/">Continue reading <span class="meta-nav">&#8594;</span></a>]]></description>
				<content:encoded><![CDATA[<p>
<img src="/srt/wp-content/files/2011/12/spring09_logo.png" align="right" hspace="5" vspace="5"/><br />
Spring Source recently published <a href="http://www.springsource.com/security/cve-2010-1622">CVE-2010-1622</a>. The advisory describes a vulnerability that affects Spring Framework prior to 3.0.3 and allows attackers to execute arbitrary code.
</p>
<p><b>What could SpringSource have done better?</b></p>
<p>
When Spring Source announced the release of 3.0.3 they reported to have fixed <a href="http://blog.springsource.com/2010/06/15/spring-framework-3-0-3-released/">&#8220;more than a hundred minor issues&#8221;</a> &mdash; no indication of the security fix. This could be understandable as they have released the fix 2 days prior to publishing the advisory. I do not understand why they did not announce it later however. The advisory was published as silently as possible although the vulnerability is rated critical, can be exploited remotely and probably affects a large number of applications.<br />
I would have preferred receiving the security advisory through the usual channels used for announcements in addition to the <a href="http://www.springsource.com/security">security team page</a>.
</p>
<p>
Having a look at <a href="http://cve.mitre.org/cgi-bin/cvename.cgi?name=CVE-2010-1622">cve.mitre.org</a> reveals another interesting fact. The CVE id was assigned on April, 29th. That is almost 2 months before the advisory was published. The bug was <a href="https://fisheye.springsource.org/changelog/spring-framework?cs=3374">fixed</a> on May, 27th.<br />
Why does it take more than 4 weeks for a 3 line fix? Why does it take almost 3 additional weeks after the fix to announce the vulnerability?<br />
I would have preferred a priority fix as soon as possible after discovery and a release following short time after that.
</p>
<p>
Finally SpringSource dicided not to provide a fixed release for dm Server, a product based on Spring Framework, which is also vulnerable. Users are advised to manually patch it instead. SpringSource also continues to provide the vulnerable <a href="http://www.springsource.com/products/springsource-download-center">dm Server 2.0.2</a> for download without any warning.<br />
I would have preferred to receive a fixed release of dm Server instead of seeing SpringSource continue to ship products containing known security issues.
</p>
<p><b>What can you learn from CVE-2010-1622?</b></p>
<p>
I will follow up with the lessons learned for application developers and system administrators in the next days. Stay tuned.
</p>
<p>
There is also an interesting analysis of the issue at <a href="http://blog.o0o.nu/2010/06/cve-2010-1622.html">blog.o0o.nu</a>.</p>
]]></content:encoded>
			<wfw:commentRss>https://blogs.reucon.com/srt/spring-framework-security-vulnerability-part-1-8786/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Code Style: Braces, Indentation and Line Length</title>
		<link>https://blogs.reucon.com/srt/code-style-braces-indentation-and-line-length-8846/</link>
		<comments>https://blogs.reucon.com/srt/code-style-braces-indentation-and-line-length-8846/#respond</comments>
		<pubDate>Sun, 23 May 2010 20:26:31 +0000</pubDate>
		<dc:creator><![CDATA[Stefan Reuter]]></dc:creator>
				<category><![CDATA[Development]]></category>

		<guid isPermaLink="false">/?p=8846</guid>
		<description><![CDATA[We&#8217;ve recently revisted our Java Coding Conventions. For several years we are now using a style based on the excellent book The Elements of Java Style by RougeWave. It follows the Sun Code Style in many aspects and adds a &#8230; <a href="https://blogs.reucon.com/srt/code-style-braces-indentation-and-line-length-8846/">Continue reading <span class="meta-nav">&#8594;</span></a>]]></description>
				<content:encoded><![CDATA[<p>
<a href="http://www.amazon.de/gp/product/0521777682?ie=UTF8&#038;tag=reuconcom-21&#038;linkCode=as2&#038;camp=1638&#038;creative=19454&#038;creativeASIN=0521777682"><img border="0" hspace="5" src="/srt/wp-content/files/2011/12/elements_of_java_style.jpg" align="right"></a><br />
We&#8217;ve recently revisted our Java Coding Conventions. For several years we are now using a style based on the excellent book <a href="http://www.amazon.de/gp/product/0521777682?ie=UTF8&#038;tag=reuconcom-21&#038;linkCode=as2&#038;camp=1638&#038;creative=19454&#038;creativeASIN=0521777682">The Elements of Java Style</a> by RougeWave. It follows the <a href="http://java.sun.com/docs/codeconv/html/CodeConvTOC.doc.html">Sun Code Style</a> in many aspects and adds a lot of reasoning.
</p>
<p>
Our Code Style differs mainly in two aspects:
</p>
<ul>
<li>We place curly braces on new lines</li>
<li>We use a maximum line length of 130 characters</li>
</ul>
<p>
I am well aware that there are religious opinions regarding those questions but after reconsidering our style we came to the conclusion that both differences actually make sense.
</p>
<p>
Lining up curly braces vertically (called Allman or ANSI style) makes it easy to check that the braces match. The indented code is clearly set apart from the containing statement by lines that are almost completely whitespace which makes the code easier to read. In contrast to K&amp;R style it consumes more space but today&#8217;s screens are well capable to show more than the ancient 24 lines.
</p>
<p>Good:</p>
<pre class="brush: java;">
if (condition)
{
    body;
}
</pre>
<p>Bad:</p>
<pre class="brush: java;">
if (condition) {
    body;
}
</pre>
<p>
The reason to limit the line length to 80 characters comes from the limitation of old printers that usually printed 80 characters per line. We seldomly print code on paper and modern printers are well capable to print at other resolutions. Limiting us to to 80 characters would waste a lot of screen space as with a decent screen size showing 130 characters still leaves enough place for the IDE to show up additional frames including outlines and project files left and right to the code.
</p>
<p>
What we learned: Use the mainstream conventions by default. Challenge them and check if the underlying assumptions hold true in your environment. Only derive if there is enough benefit to justify the change.</p>
]]></content:encoded>
			<wfw:commentRss>https://blogs.reucon.com/srt/code-style-braces-indentation-and-line-length-8846/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>
