<?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>nerdcenter</title>
	<atom:link href="http://nerdcenter.de/feed/" rel="self" type="application/rss+xml" />
	<link>http://nerdcenter.de</link>
	<description>IT-Kniffe eines Webentwicklers.</description>
	<lastBuildDate>Sun, 10 Apr 2011 16:55:03 +0000</lastBuildDate>
	<generator>http://wordpress.org/?v=2.8.4</generator>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<xhtml:meta xmlns:xhtml="http://www.w3.org/1999/xhtml" name="robots" content="noindex" />
		<item>
		<title>Firefox 4 ist langsam und hakt beim Scrollen</title>
		<link>http://nerdcenter.de/firefox-4-langsam-scrollen-hakt/</link>
		<comments>http://nerdcenter.de/firefox-4-langsam-scrollen-hakt/#comments</comments>
		<pubDate>Sun, 10 Apr 2011 16:55:03 +0000</pubDate>
		<dc:creator>kcore</dc:creator>
				<category><![CDATA[Userland]]></category>
		<category><![CDATA[Firefox 4]]></category>
		<category><![CDATA[hakt]]></category>
		<category><![CDATA[langsam]]></category>
		<category><![CDATA[update]]></category>

		<guid isPermaLink="false">http://nerdcenter.de/?p=135</guid>
		<description><![CDATA[

Hand aufs Herz &#8211; Mozilla Firefox ist ein toller Browser. Ich kann mir meinen Arbeitsalltag ohne dieses feine Stück Software (insbesondere wegen der zahlreichen Erweiterungen dafür) kaum vorstellen. Deshalb trafen mich die Probleme, die ich nach dem Update auf Firefox 4 hatte, gleich doppelt. Der Browser begann plötzlich damit regelmäßig zu haken. Bei dem Aufruf [...]]]></description>
			<content:encoded><![CDATA[
<!-- google_ad_section_start -->
<p>Hand aufs Herz &#8211; Mozilla Firefox ist ein toller Browser. Ich kann mir meinen Arbeitsalltag ohne dieses feine Stück Software (insbesondere wegen der zahlreichen Erweiterungen dafür) kaum vorstellen. Deshalb trafen mich die Probleme, die ich nach dem Update auf Firefox 4 hatte, gleich doppelt. Der Browser begann plötzlich damit regelmäßig zu haken. Bei dem Aufruf diverser Seiten war das Scrollen für ca 10 Sekunden nicht möglich. Nerviger hätte der Fehler kaum sein können. Warum er auftrat weiß ich leider noch immer nicht. Anfangs habe ich mir eingebildet, dass es etwas mit dem Flash Plugin zu tun hat &#8211; doch ein Update desselbigen brachte keine Besserung. Das schrittweise deaktivieren von Plugins und Addons brachte mich dem Ziel leider ebenfalls nicht näher.<br />
Was hingegen tatsächlich geholfen hat, war das Löschen meines Profils. Unter OS X findet sich das entsprechende Verzeichnis übrigens unter ~/Library/Application Support/Firefox/Profiles. Vorher ist es ratsam seine Bookmarks zu exportieren und sich Gedanken zu machen, ob man sich an alle gespeicherten Passwörter auch so erinnern kann <img src='http://nerdcenter.de/wp-includes/images/smilies/icon_wink.gif' alt="Icon Wink in Firefox 4 ist langsam und hakt beim Scrollen" class='wp-smiley' />  Auch installierte Erweiterungen sind nach dem Löschen des Profils futsch. Im Zweifel macht es sinn, das Verzeichnis als Backup einfach umzubenennen oder zu kopieren.</p>
<!-- google_ad_section_end -->
]]></content:encoded>
			<wfw:commentRss>http://nerdcenter.de/firefox-4-langsam-scrollen-hakt/feed/</wfw:commentRss>
		<slash:comments>13</slash:comments>
		</item>
		<item>
		<title>PHP: making a file executable</title>
		<link>http://nerdcenter.de/making-file-executable-php/</link>
		<comments>http://nerdcenter.de/making-file-executable-php/#comments</comments>
		<pubDate>Thu, 24 Feb 2011 08:49:16 +0000</pubDate>
		<dc:creator>kcore</dc:creator>
				<category><![CDATA[PHP]]></category>

		<guid isPermaLink="false">http://nerdcenter.de/?p=123</guid>
		<description><![CDATA[

The following little code snippet shows you how to change a files permissions to allow its owning user and group to read and execute it.
public function makeExecutable() {
	if(file_exists($this->executablePath)) {
		if(DIRECTORY_SEPARATOR == '/') {
			// add executable (1) and read (4) bits for user and group
			$filePermissions = decoct(fileperms($this->executablePath));
			$filePermissions = substr($filePermissions, strlen($filePermissions) - 3);
			$newFilePermissions = $filePermissions[0] &#124; 5;
			$newFilePermissions .= [...]]]></description>
			<content:encoded><![CDATA[
<!-- google_ad_section_start -->
<p>The following little code snippet shows you how to change a files permissions to allow its owning user and group to read and execute it.</p>
<pre>public function makeExecutable() {
	if(file_exists($this->executablePath)) {
		if(DIRECTORY_SEPARATOR == '/') {
			// add executable (1) and read (4) bits for user and group
			$filePermissions = decoct(fileperms($this->executablePath));
			$filePermissions = substr($filePermissions, strlen($filePermissions) - 3);
			$newFilePermissions = $filePermissions[0] | 5;
			$newFilePermissions .= $filePermissions[1] | 5;
			$newFilePermissions .= $filePermissions[2];
			if($newFilePermissions != $filePermissions) {
				return chmod($this->executablePath, octdec($newFilePermissions));
			}
		}
	}
	return false;
}</pre>
<!-- google_ad_section_end -->
]]></content:encoded>
			<wfw:commentRss>http://nerdcenter.de/making-file-executable-php/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>TYPO3 4.5, t3mootools and JSMin</title>
		<link>http://nerdcenter.de/typo3-4-5-t3mootools-jsmin/</link>
		<comments>http://nerdcenter.de/typo3-4-5-t3mootools-jsmin/#comments</comments>
		<pubDate>Fri, 11 Feb 2011 09:00:06 +0000</pubDate>
		<dc:creator>kcore</dc:creator>
				<category><![CDATA[Uncategorized]]></category>

		<guid isPermaLink="false">http://nerdcenter.de/?p=120</guid>
		<description><![CDATA[

If you are trying to open the backend module of t3mootools 1.3.0 in a TYPO3 4.5 installation you&#8217;ll probably notice that besides a PHP error (PHP Fatal error:  Cannot redeclare class JSMinException in typo3_src-4.5.0/typo3/contrib/jsmin/jsmin.php on line 297) nothing is going to happen. This is happening because t3mootools includes (and uses) a copy of JSMin [...]]]></description>
			<content:encoded><![CDATA[
<!-- google_ad_section_start -->
<p>If you are trying to open the backend module of t3mootools 1.3.0 in a TYPO3 4.5 installation you&#8217;ll probably notice that besides a PHP error (PHP Fatal error:  Cannot redeclare class JSMinException in typo3_src-4.5.0/typo3/contrib/jsmin/jsmin.php on line 297) nothing is going to happen. This is happening because t3mootools includes (and uses) a copy of JSMin which is now also integrated in the TYPO3 core.</p>
<p>Fixing this issue is pretty easy:<br />
1. open typo3conf/ext/t3mootools/mod1/index.php in your favorite text editor<br />
2. look for</p>
<pre>require_once('jsmin2.php');</pre>
<p>3. replace it with</p>
<pre>$coreJSMinPath = PATH_typo3 . '/contrib/jsmin/jsmin.php';
if(file_exists($coreJSMinPath)) {
        require_once($coreJSMinPath);
} else {
        require_once('jsmin2.php');
}</pre>
<p>Of course XClassing the file would be a better solution but as we can expect a fix with the next version of t3mootools, I think this is an acceptable solution.</p>
<!-- google_ad_section_end -->
]]></content:encoded>
			<wfw:commentRss>http://nerdcenter.de/typo3-4-5-t3mootools-jsmin/feed/</wfw:commentRss>
		<slash:comments>11</slash:comments>
		</item>
		<item>
		<title>wget untar on the fly</title>
		<link>http://nerdcenter.de/wget-untar-on-the-fly/</link>
		<comments>http://nerdcenter.de/wget-untar-on-the-fly/#comments</comments>
		<pubDate>Fri, 21 Jan 2011 12:26:46 +0000</pubDate>
		<dc:creator>kcore</dc:creator>
				<category><![CDATA[Administration]]></category>
		<category><![CDATA[Linux / Unix]]></category>

		<guid isPermaLink="false">http://nerdcenter.de/?p=118</guid>
		<description><![CDATA[

Downloading and extracting large tarballs usually takes plenty of time. Extracting tarballs during the their transfer reduces the waiting time because you a) don&#8217;t need to do wait for the transfer to finishes before starting the extraction and b) the machine doesn&#8217;t have to read the tarball from the disk while simultaneously writing to it.
One [...]]]></description>
			<content:encoded><![CDATA[
<!-- google_ad_section_start -->
<p>Downloading and extracting large tarballs usually takes plenty of time. Extracting tarballs during the their transfer reduces the waiting time because you a) don&#8217;t need to do wait for the transfer to finishes before starting the extraction and b) the machine doesn&#8217;t have to read the tarball from the disk while simultaneously writing to it.</p>
<p>One way to extract tarballs on the fly while downloading them is using wget to fetch the file and piping it&#8217;s output (the downloaded data) to tar.<br />
<code>wget --user=&quot;username&quot; --password=&quot;my secret password&quot;  -O - &quot;ftp://foo.bar/foobar.tgz&quot; | tar -xvzf -</code></p>
<p>Hint: You may want to turn hoff Bash&#8217;s history expansion if your username or password contains exclamation marks. The fastest way doing so is starting a new bash process with the corresponding argument (+H):<br />
<code>bash +H<br />
wget...</code></p>
<!-- google_ad_section_end -->
]]></content:encoded>
			<wfw:commentRss>http://nerdcenter.de/wget-untar-on-the-fly/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>TemplaVoilà: Default content for empty fields</title>
		<link>http://nerdcenter.de/templavoil-default-content-for-empty-fields/</link>
		<comments>http://nerdcenter.de/templavoil-default-content-for-empty-fields/#comments</comments>
		<pubDate>Fri, 26 Nov 2010 11:48:29 +0000</pubDate>
		<dc:creator>kcore</dc:creator>
				<category><![CDATA[TypoScript]]></category>

		<guid isPermaLink="false">http://nerdcenter.de/?p=114</guid>
		<description><![CDATA[

Thanks to stdWrap doing this is quite easy:
Edit the TemplaVoilà datastructure, search the field you want to fill with default content if it&#8217;s empty and look for it&#8217;s TypoScript configuration:
&#60;TypoScript&#62;
	10 = RECORDS
	10 {
		source.current = 1
		tables = tt_content
	}
&#60;/TypoScript&#62;
Add the following nodes under it:
&#60;proc type="array"&#62;
	&#60;stdWrap&#62;&#60;![CDATA[
		ifEmpty {
			cObject =&#60; lib.sidebarDefaultContent
		}
	]]&#62;&#60;/stdWrap&#62;
&#60;/proc&#62;
lib.sidebarDefaultContent can be any content object of your choice, for [...]]]></description>
			<content:encoded><![CDATA[
<!-- google_ad_section_start -->
<p>Thanks to stdWrap doing this is quite easy:</p>
<p>Edit the TemplaVoilà datastructure, search the field you want to fill with default content if it&#8217;s empty and look for it&#8217;s TypoScript configuration:</p>
<p><code>&lt;TypoScript&gt;<br />
	10 = RECORDS<br />
	10 {<br />
		source.current = 1<br />
		tables = tt_content<br />
	}<br />
&lt;/TypoScript&gt;</code></p>
<p>Add the following nodes under it:</p>
<p><code>&lt;proc type="array"&gt;<br />
	&lt;stdWrap&gt;&lt;![CDATA[<br />
		ifEmpty {<br />
			cObject =&lt; lib.sidebarDefaultContent<br />
		}<br />
	]]&gt;&lt;/stdWrap&gt;<br />
&lt;/proc&gt;</code></p>
<p>lib.sidebarDefaultContent can be any content object of your choice, for example a RECORDS object:</p>
<p><code>lib.sidebarDefaultContent = RECORDS<br />
lib.sidebarDefaultContent {<br />
  tables = tt_content<br />
  source = 93, 95<br />
}</code></p>
<!-- google_ad_section_end -->
]]></content:encoded>
			<wfw:commentRss>http://nerdcenter.de/templavoil-default-content-for-empty-fields/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Converting MBR Partition Tables to GPT</title>
		<link>http://nerdcenter.de/convert-mbr-partition-tables-gpt/</link>
		<comments>http://nerdcenter.de/convert-mbr-partition-tables-gpt/#comments</comments>
		<pubDate>Thu, 23 Sep 2010 09:54:00 +0000</pubDate>
		<dc:creator>kcore</dc:creator>
				<category><![CDATA[Administration]]></category>
		<category><![CDATA[Linux / Unix]]></category>
		<category><![CDATA[GPT fdisk]]></category>
		<category><![CDATA[GUID Partition Table]]></category>
		<category><![CDATA[MBR]]></category>

		<guid isPermaLink="false">http://nerdcenter.de/?p=110</guid>
		<description><![CDATA[

MSDOS MBR Partition Tables make it impossible to use Partitions larger than 2 TiB. This is a pitfall you maybe will be faced with after expension of a RAID array. The only solution is to convert the MBR Partition Table to GPT (GUID Partition Table).
This can be done quite easily by using GPT fdisk.
GPT fdisk [...]]]></description>
			<content:encoded><![CDATA[
<!-- google_ad_section_start -->
<p>MSDOS MBR Partition Tables make it impossible to use Partitions larger than 2 TiB. This is a pitfall you maybe will be faced with after expension of a RAID array. The only solution is to convert the MBR Partition Table to GPT (GUID Partition Table).</p>
<p>This can be done quite easily by using <a href="http://www.rodsbooks.com/gdisk/">GPT fdisk</a>.<br />
GPT fdisk includes the sgdisk program which can convert MBR Partition Tables to GUID Partition Tables using the following command:</p>
<pre>sgdisk -g device</pre>
<p>(for example sgdisk -g /dev/sda)</p>
<p><strong>Warning: doing this will make your system unbootable as there&#8217;s no longer a master boot record existing.</strong><br />
The <a href="http://grub.enbug.org/BIOS_Boot_Partition">BIOS Boot Partition</a> replaces the MBR. Make sure you have enough unused space to create it.</p>
<!-- google_ad_section_end -->
]]></content:encoded>
			<wfw:commentRss>http://nerdcenter.de/convert-mbr-partition-tables-gpt/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>Solr Multicore: Installation, Configuration</title>
		<link>http://nerdcenter.de/solr-multicore-installation-configuration/</link>
		<comments>http://nerdcenter.de/solr-multicore-installation-configuration/#comments</comments>
		<pubDate>Thu, 09 Sep 2010 11:48:33 +0000</pubDate>
		<dc:creator>kcore</dc:creator>
				<category><![CDATA[Administration]]></category>
		<category><![CDATA[Linux / Unix]]></category>
		<category><![CDATA[Solr]]></category>
		<category><![CDATA[apache]]></category>
		<category><![CDATA[configuration]]></category>
		<category><![CDATA[installation]]></category>
		<category><![CDATA[multicore]]></category>

		<guid isPermaLink="false">http://nerdcenter.de/?p=103</guid>
		<description><![CDATA[

If you start Solr with the default configuration, there will be only one instance running. That&#8217;s enough if you have only one website which you want to index but if you have several websites, you probably don&#8217;t want them to share an index as you then would get search results from both websites.
Luckily Solr already [...]]]></description>
			<content:encoded><![CDATA[
<!-- google_ad_section_start -->
<p>If you start Solr with the default configuration, there will be only one instance running. That&#8217;s enough if you have only one website which you want to index but if you have several websites, you probably don&#8217;t want them to share an index as you then would get search results from both websites.<br />
Luckily Solr already brings the so called multicore feature with it. It allows you to run multiple instances that use different configuration sets and indexes.</p>
<p>This little howto will show you how to install / configure Solr to make use of the multicore feature.</p>
<p>1. Install the Sun Java Runtime Environment<br />
On Debian Linux you will do this by executing apt-get install sun-java6-jre</p>
<p>2. Choose the directory in which you want to install Solr. In this example we will use /opt.<br />
If it doesn&#8217;t exist already, create the directory and cd to it.<br />
<code>cd /opt</code></p>
<p>3. Go to http://www.apache.org/dyn/closer.cgi/lucene/solr/ and choose a mirror. In this example we will use http://ftp-stud.hs-esslingen.de/pub/Mirrors/ftp.apache.org/dist//lucene/solr/. Download the latest Solr version, currently 1.4.1:<br />
<code>wget http://ftp-stud.hs-esslingen.de/pub/Mirrors/ftp.apache.org/dist//lucene/solr/1.4.1/apache-solr-1.4.1.tgz</code></p>
<p>4. Extract the downloaded archive:<br />
<code>tar xzf apache-solr-1.4.1.tgz</code></p>
<p>5. Copy the Solr examples directory. In this example we will copy it to /opt/solr/.<br />
<code>cp -R apache-solr-1.4.1/example/ solr</code></p>
<p>6. cd to /opt/solr/<br />
<code>cd /opt/solr/</code></p>
<p>7. Remove the following directories (you probably won&#8217;t need them):<br />
- example-DIH<br />
- exampledocs<br />
- work</p>
<p><code>rm -Rf example-DIH exampledocs work</code></p>
<p>8. Copy /opt/solr/multicore/solr.xml to /opt/solr/solr/solr.xml and remove the multicore directory.<br />
solr.xml describes the name and location of the cores to use.<br />
<code>cp /opt/solr/multicore/solr.xml /opt/solr/solr/ &#038;&#038; rm -Rf /opt/solr/multicore/</code></p>
<p>9. Edit /opt/solr/solr/solr.xml and modify it to match your needs. For example:<br />
<code>&lt;?xml version=&quot;1.0&quot; encoding=&quot;UTF-8&quot; ?&gt;<br />
&lt;solr persistent=&quot;true&quot;&gt;<br />
  &lt;cores adminPath=&quot;/admin/cores&quot;&gt;<br />
    &lt;core name=&quot;myfirstwebsite&quot; instanceDir=&quot;site_myfirstwebsite&quot; /&gt;<br />
    &lt;core name=&quot;mysecondwebsite&quot; instanceDir=&quot;site_mysecondwebsite&quot; /&gt;<br />
  &lt;/cores&gt;<br />
&lt;/solr&gt;</code></p>
<p>10. Create the directories you specified as &quot;instanceDir&quot; in step 9. Copy /opt/solr/solr/conf into them and create data directories.<br />
<code>mkdir -p /opt/solr/solr/site_myfirstwebsite/data &#038;&#038; cp -R /opt/solr/solr/conf/ /opt/solr/solr/site_myfirstwebsite/<br />
mkdir -p /opt/solr/solr/site_mysecondwebsite/data &#038;&#038; cp -R /opt/solr/solr/conf/ /opt/solr/solr/site_mysecondwebsite/</code></p>
<p>11. Edit /opt/solr/solr/site_myfirstwebsite/conf/solrconfig.xml and /opt/solr/solr/site_mysecondwebsite/conf/solrconfig.xml. Change the dataDir-tag to match the new data directories you created in step 10:<br />
&lt;dataDir&gt;/opt/solr/solr/site_myfirstwebsite/data&lt;/dataDir&gt; respectively &lt;dataDir&gt;/opt/solr/solr/site_mysecondwebsite/data&lt;/dataDir&gt;</p>
<p>12. Start Solr. We will use Jetty here because we wouldn&#8217;t need Tomcat for anything else but Solr.<br />
<code>java -jar -server -Xmx128M -Dfile.encoding=UTF8 -Djava.headless=True /opt/solr/start.jar</code></p>
<p>After Solr has been startet you can access the Solr Admin at http://SOLR_HOSTNAME:8983/solr/ (you should find a link pointing to the Solr Admin for every core you have configured before). Solr queries need to go to http://SOLR_HOSTNAME:8983/solr/CORE_NAME/, f.exp. http://192.168.10.41:8983/solr/myfirstwebsite/select/?q=*%3A*&#038;version=2.2&#038;start=0&#038;rows=10&#038;indent=on</p>
<!-- google_ad_section_end -->
]]></content:encoded>
			<wfw:commentRss>http://nerdcenter.de/solr-multicore-installation-configuration/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Redmine, Apache, Subversion: Could not read status line</title>
		<link>http://nerdcenter.de/redmine-apache-subversion-could-not-read-status-line/</link>
		<comments>http://nerdcenter.de/redmine-apache-subversion-could-not-read-status-line/#comments</comments>
		<pubDate>Thu, 09 Sep 2010 08:45:24 +0000</pubDate>
		<dc:creator>kcore</dc:creator>
				<category><![CDATA[Administration]]></category>
		<category><![CDATA[Linux / Unix]]></category>
		<category><![CDATA[redmine]]></category>
		<category><![CDATA[apache]]></category>
		<category><![CDATA[subversion]]></category>
		<category><![CDATA[svn]]></category>

		<guid isPermaLink="false">http://nerdcenter.de/?p=99</guid>
		<description><![CDATA[

If you use a combination of Redmine.pm, Apache and SVN and are wondering about error messages telling you &#34;COPY of &#8216;foobar&#8217; : Could not read status line: connection was closed by server&#34; or &#34;COPY of &#8216;foobar&#8217; : Could not read status line: secure connection truncated&#34; you probably will want to switch to apache2-mpm-prefork to get [...]]]></description>
			<content:encoded><![CDATA[
<!-- google_ad_section_start -->
<p>If you use a combination of Redmine.pm, Apache and SVN and are wondering about error messages telling you <strong>&quot;COPY of &#8216;foobar&#8217; : Could not read status line: connection was closed by server&quot;</strong> or <strong>&quot;COPY of &#8216;foobar&#8217; : Could not read status line: secure connection truncated&quot;</strong> you probably will want to switch to apache2-mpm-prefork to get rid of them.</p>
<p>A combination of Redmine.pm, apache2-mpm-worker and Redmine.pm doesn&#8217;t seem to be stable at all.</p>
<!-- google_ad_section_end -->
]]></content:encoded>
			<wfw:commentRss>http://nerdcenter.de/redmine-apache-subversion-could-not-read-status-line/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>Java: Periodically check internet connection availability</title>
		<link>http://nerdcenter.de/java-periodically-check-internet-connection-availability/</link>
		<comments>http://nerdcenter.de/java-periodically-check-internet-connection-availability/#comments</comments>
		<pubDate>Fri, 25 Jun 2010 12:27:14 +0000</pubDate>
		<dc:creator>kcore</dc:creator>
				<category><![CDATA[Java]]></category>
		<category><![CDATA[Programmierung]]></category>
		<category><![CDATA[design pattern]]></category>
		<category><![CDATA[internet connection]]></category>
		<category><![CDATA[observer]]></category>

		<guid isPermaLink="false">http://nerdcenter.de/?p=90</guid>
		<description><![CDATA[

A very simple example of how to periodically check the availability of an internet connection by using the observer design pattern.
InternetConnection.java
package net;

import java.net.*;
import java.io.*;

public class InternetConnection {
	/*	use at least one reliable host, in most cases you will want
 		to use the one you're working with later	*/
	private static final String CHECK_URL = "http://www.t-online.de/";
	public static InternetConnectionState isAvailable() [...]]]></description>
			<content:encoded><![CDATA[
<!-- google_ad_section_start -->
<p>A very simple example of how to periodically check the availability of an internet connection by using the observer design pattern.</p>
<p><strong>InternetConnection.java</strong></p>
<pre>package net;

import java.net.*;
import java.io.*;

public class InternetConnection {
	/*	use at least one reliable host, in most cases you will want
 		to use the one you're working with later	*/
	private static final String CHECK_URL = "http://www.t-online.de/";
	public static InternetConnectionState isAvailable() {
		try {
			URL url = new URL(InternetConnection.CHECK_URL);
			HttpURLConnection urlConnection = (HttpURLConnection)url.openConnection();
			Object objData = urlConnection.getContent();
		} catch(UnknownHostException exception) {
			return new InternetConnectionState(false);
		} catch(IOException exception) {
			return new InternetConnectionState(false);
		}
		return new InternetConnectionState(true);
	}
}</pre>
<p><strong>InternetConnectionState.java</strong></p>
<pre>package net;

public class InternetConnectionState {
	private boolean state = false;

	public InternetConnectionState(boolean state) {
		this.state = state;
	}

	public boolean getState() {
		return this.state;
	}

	public void setState(boolean state) {
		this.state = state;
	}
}</pre>
<p><strong>InternetConnectionObserver.java</strong></p>
<pre>package net;

import java.util.Observable;
import java.util.Observer;

public class InternetConnectionObserver implements Observer {
	public InternetConnectionObserver(ObservableInternetConnection internetConnection) {
		internetConnection.addObserver(this);
		new Thread(internetConnection).start();
	}

	public void update(Observable internetConnection, Object state) {
		InternetConnectionState connectionState = (InternetConnectionState)state;
		if(connectionState.getState() == true) {
			System.err.println("active internet connection detected");
		} else {
			System.err.println("lost internet connection");
		}
	}
}</pre>
<p><strong>ObservableInternetConnection.java</strong></p>
<pre>package net;

import java.util.*;
import net.InternetConnectionState;

public class ObservableInternetConnection extends Observable implements Runnable {
	private static final long CHECK_INTERVAL = 30000; // 30 sec
	private InternetConnectionState state;

	public void run() {
		this.state = InternetConnection.isAvailable();

		this.updateConnectionStatus();
	}

	public void updateConnectionStatus() {
		while(true) {
			InternetConnectionState newState = InternetConnection.isAvailable();
			if(newState.getState() != this.state.getState()) {
				this.state = newState;
				setChanged();
				notifyObservers(this.state);
			}
			try {
				Thread.sleep(ObservableInternetConnection.CHECK_INTERVAL);
			} catch(InterruptedException e) {
			}
		}
	}
}</pre>
<p><strong>Usage:</strong></p>
<pre>ObservableInternetConnection observableInternetConnection = new ObservableInternetConnection();
InternetConnectionObserver internetConnectionObserver = new InternetConnectionObserver(observableInternetConnection);</pre>
<p>&#8230;I just startet programming Java a few days ago so I&#8217;m pretty sure there&#8217;s a better way to do this but I didn&#8217;t find it, yet <img src='http://nerdcenter.de/wp-includes/images/smilies/icon_wink.gif' alt="Icon Wink in Java: Periodically check internet connection availability" class='wp-smiley' /> </p>
<!-- google_ad_section_end -->
]]></content:encoded>
			<wfw:commentRss>http://nerdcenter.de/java-periodically-check-internet-connection-availability/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>How-to: Debian: Automatically mounted loopback images with dm-crypt, LUKS, pam_mount</title>
		<link>http://nerdcenter.de/howto-debian-loopback-dm-crypt-luks-pam-mount/</link>
		<comments>http://nerdcenter.de/howto-debian-loopback-dm-crypt-luks-pam-mount/#comments</comments>
		<pubDate>Thu, 17 Jun 2010 13:42:02 +0000</pubDate>
		<dc:creator>kcore</dc:creator>
				<category><![CDATA[Administration]]></category>
		<category><![CDATA[Linux / Unix]]></category>
		<category><![CDATA[Sicherheit]]></category>
		<category><![CDATA[Debian]]></category>
		<category><![CDATA[dm-crypt]]></category>
		<category><![CDATA[image]]></category>
		<category><![CDATA[libpam-mount]]></category>
		<category><![CDATA[loop]]></category>
		<category><![CDATA[loopback]]></category>
		<category><![CDATA[LUKS]]></category>
		<category><![CDATA[pam_mount]]></category>
		<category><![CDATA[Squeeze]]></category>

		<guid isPermaLink="false">http://nerdcenter.de/?p=82</guid>
		<description><![CDATA[

How to create encrypted loopback images with dm-crypt and LUKS + automatically mounting them after login with pam_mount
I recommend using debian squeeze for this scenario as lenny includes a very old version of libpam-mount and I had lots of problems when I tried using it.
Using only the libpam-mount package and its dependencies from squeeze maybe [...]]]></description>
			<content:encoded><![CDATA[
<!-- google_ad_section_start -->
<h3>How to create encrypted loopback images with dm-crypt and LUKS + automatically mounting them after login with pam_mount</h3>
<p>I recommend using debian squeeze for this scenario as lenny includes a very old version of libpam-mount and I had lots of problems when I tried using it.<br />
Using only the libpam-mount package and its dependencies from squeeze maybe (I didn&#8217;t try it and I wouldn&#8217;t recommend it either) does the job too, but at least has a very bitter after taste if you take a closer look at the dependencies.</p>
<p>1. Make sure you have the required kernel modules loaded. If you use the stock debian kernel, this will be the case. if you don&#8217;t, make sure you&#8217;ve set the following options:</p>
<ul>
<li>CONFIG_BLK_DEV_DM=y or CONFIG_BLK_DEV_DM=M</li>
<li>CONFIG_DM_CRYPT=y or CONFIG_DM_CRYPT=M</li>
<li>CONFIG_CRYPTO_CBC=y</li>
</ul>
<p>Additionally, you need to include support for at least one cipher.</p>
<p>In make menuconfig, you can find the required kernel modules at the following locations:</p>
<pre>
Device Drivers  --->
	Multi-device support (RAID and LVM)  --->
		<*> Device mapper support
		<*> Crypt target support

Cryptographic options  --->
	<M> SHA256 digest algorithm
	<M> AES cipher algorithms (x86_64)
</pre>
<p>To avoid a reboot, you can build all of these options as modules. If you chose to do so, you can later load the modules by using modprobe <MODULE_NAME>.</p>
<p>2. Install the required packages<br />
apt-get install cryptsetup libpam-mount<br />
&#8230;apt-get should take care of all dependencies</p>
<p>3. Generate a random key and assign it to a variable for later use</p>
<pre>KEY=`tr -cd [:graph:] < /dev/urandom | head -c 79`</pre>
<p>4. Encrypt the key and save it to a file</p>
<pre>echo $KEY | openssl aes-256-cbc > container.key</pre>
<p>5. Create the loopback file and fill it with random data</p>
<pre>dd if=/dev/urandom of=~/container.img bs=1G count=10</pre>
<p>This will create a 10GB file and fill it with random data taken from /dev/urandom.<br />
Another option (which will be much faster especially on older hardware) is using /dev/zero to fill the loopback file with zeros:</p>
<pre>dd if=/dev/zero of=~/container.img bs=1G count=10</pre>
<p>6. Set up a loop device</p>
<pre>losetup /dev/loop0 ~/container.img</pre>
<p>7. LuksFormat it</p>
<pre>echo $KEY | cryptsetup -v -c aes -s 256 luksFormat /dev/loop0</pre>
<p>8. Open it</p>
<pre>cryptsetup luksOpen /dev/loop0 container</pre>
<p>9. Make a filesystem of your choice</p>
<pre>mkfs.xfs /dev/mapper/container</pre>
<p>10. Close it and delete loop</p>
<pre>cryptsetup luksClose container &#038;&#038; losetup -d /dev/loop0</pre>
<p>11. Configure pam_mount<br />
Open /etc/security/pam_mount.conf.xml in your favorite text editor and change it to the following:</p>
<pre>&lt;?xml version=&quot;1.0&quot; encoding=&quot;utf-8&quot;&nbsp;?&gt;

&lt;!DOCTYPE pam_mount SYSTEM &quot;pam_mount.conf.xml.dtd&quot;&gt;
&lt;pam_mount&gt;
	&lt;debug enable=&quot;1&quot; /&gt;
	&lt;mkmountpoint enable=&quot;1&quot; remove=&quot;true&quot; /&gt;

	&lt;msg-sessionpw&gt;reenter password for pam_mount:&lt;/msg-sessionpw&gt;
	&lt;volume user=&quot;foobar&quot; path=&quot;/home/foobar/container.img&quot; mountpoint=&quot;/home/foobar/containercontents&quot;
		options=&quot;cipher=aes-cbc-essiv:sha256,hash=sha512,keysize=256&quot; fstype=&quot;crypt&quot; fskeycipher=&quot;aes-256-cbc&quot;

		fskeypath=&quot;/home/foobar/container.key&quot; fskeyhash=&quot;md5&quot; /&gt;
&lt;/pam_mount&gt;</pre>
<p>Using this configuration the image /home/foobar/container.img will get mounted into /home/foobar/containercontents when the user foobar logs in.<br />
Enabling debugging is pretty usefull if something isn't working as it should. In this case you can take a look at /var/log/auth.log.</p>
<p>12. Include /etc/pam.d/common-pammount in the PAM configuration files of the services that should use it (for example: SSHd)<br />
Open /etc/security/sshd in your favorite text editor. Look for the line "@include common-session" and add a new line after it:</p>
<pre>...
@include common-session
@include common-pammount
...</pre>
<p>13. If needed, change the configuration of the relevant services (for example: SSHd)<br />
Open /etc/ssh/sshd_config in your favority text editor and make sure you have the following lines in there:</p>
<pre># pam_mount
UsePAM yes
PasswordAuthentication yes
ChallengeResponseAuthentication no
UsePrivilegeSeparation no
PermitUserEnvironment yes</pre>
<p>If you disable PasswordAuthentication and use keys instead you have to enter the users password after connecting via SSH.</p>
<p>14. Test if anything works as expected<br />
Open a root session or use sudo and watch the auth log by using tail -f /var/log/auth.log. Then login as the user for which you have configured a volume earlier.<br />
If the encrypted loopback image gets mounted, also test if it gets unmounted again, when the user logs out.<br />
If anything works remove the debug line from /etc/security/pam_mount.conf.xml.</p>
<p>Many thanks go to the users tuxophil and pillgrim from the gentoo forums. Large parts of this howto were taken from their postings at <a href="http://forums.gentoo.org/viewtopic-t-274651.html">http://forums.gentoo.org/viewtopic-t-274651.html</a>.</p>
<!-- google_ad_section_end -->
]]></content:encoded>
			<wfw:commentRss>http://nerdcenter.de/howto-debian-loopback-dm-crypt-luks-pam-mount/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>

