<?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 &#187; Linux / Unix</title>
	<atom:link href="http://nerdcenter.de/category/linux-unix/feed/" rel="self" type="application/rss+xml" />
	<link>http://nerdcenter.de</link>
	<description>IT-Kniffe eines Webentwicklers.</description>
	<lastBuildDate>Fri, 25 Jun 2010 15:11:58 +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>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>
		<item>
		<title>Debian Lenny: pam_mount, files and loop devices</title>
		<link>http://nerdcenter.de/debian-lenny-pam-mount-files-loop-devices/</link>
		<comments>http://nerdcenter.de/debian-lenny-pam-mount-files-loop-devices/#comments</comments>
		<pubDate>Thu, 17 Jun 2010 07:35:21 +0000</pubDate>
		<dc:creator>kcore</dc:creator>
				<category><![CDATA[Administration]]></category>
		<category><![CDATA[Linux / Unix]]></category>
		<category><![CDATA[Debian]]></category>
		<category><![CDATA[devices]]></category>
		<category><![CDATA[Lenny]]></category>
		<category><![CDATA[libpam-mount]]></category>
		<category><![CDATA[linux]]></category>
		<category><![CDATA[loop]]></category>
		<category><![CDATA[pam_mount]]></category>

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

When I was trying to automatically mount an encrypted image at login using pam_mount, I encountered a strange problem:
I wasn&#8217;t able to find any errors in my configuration (at least none connected to this behaviour), but mount.crypt was unable to mount the image.
Enabling debugging in pam_mount.conf.xml (&#60;debug enable=&#34;1&#34; /&#62;) revealed the command used for mounting:
pam_mount(misc.c:272) [...]]]></description>
			<content:encoded><![CDATA[
<!-- google_ad_section_start -->
<p>When I was trying to automatically mount an encrypted image at login using pam_mount, I encountered a strange problem:<br />
I wasn&#8217;t able to find any errors in my configuration (at least none connected to this behaviour), but mount.crypt was unable to mount the image.<br />
Enabling debugging in pam_mount.conf.xml (&lt;debug enable=&quot;1&quot; /&gt;) revealed the command used for mounting:</p>
<p><b>pam_mount(misc.c:272) command: mount.crypt [-o loop] [/home/foobar/container] [/home/foobar/crypto]</b></p>
<p>In Debians libpam-mount 0.44-1+lenny3, /sbin/mount.crypt is a bash script that calls cryptsetup with parameters generated during its runtime.<br />
Debugging it (set -x), I stumpled upon the following command:</p>
<p><i>cryptsetup -c aes -h ripemd160 -s 256 create _home_foobar_container /home/foobar/container</i></p>
<p>&#8230;which returned the following error message:</p>
<p><b>Command failed: BLKROGET failed on device: Inappropriate ioctl for device</b></p>
<p>So mount.crypt has been passed the loop option but cryptsetup was told to mount the encrypted image instead of the associated loopback device (normally mount.crypt executes losetup to create this association in its function _losetup, but this apparently has never been called).</p>
<p>Long story short:<br />
There seems to be a bug in Debians libpam-mount 0.44-1+lenny3.<br />
The case statement at line 110 in /sbin/mount.crypt doesn&#8217;t work as expected because the variable $KEY used for option comparison has an ordinary space at its values beginning.<br />
To fix this, you can either change the way how passed options are saved in the OPTION variable (starting at line 60) or change line 110 to the following:</p>
<p><b>case ${KEY/ /} in</b></p>
<p>This will remove all spaces.</p>
<!-- google_ad_section_end -->
]]></content:encoded>
			<wfw:commentRss>http://nerdcenter.de/debian-lenny-pam-mount-files-loop-devices/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>suPHP und PHP Opcode Caches</title>
		<link>http://nerdcenter.de/suphp-php-opcode-cache/</link>
		<comments>http://nerdcenter.de/suphp-php-opcode-cache/#comments</comments>
		<pubDate>Sat, 29 Aug 2009 11:02:37 +0000</pubDate>
		<dc:creator>kcore</dc:creator>
				<category><![CDATA[Linux / Unix]]></category>
		<category><![CDATA[PHP]]></category>
		<category><![CDATA[Webserver]]></category>

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

Eigentlich ist suPHP eine nette Sache. Das Apache Modul mod_suphp sorgt in Kombination mit einem SetUID Binary dafür, dass PHP-Skripte mit den Berechtigungen des Benutzers, dem sie gehören, ausgeführt werden. Damit das funktioniert muss man in Binär-Distributionen wie etwa Debian Linux nicht mehr tun, als dass Modul zu installieren, einen Blick auf dessen Konfiguration zu [...]]]></description>
			<content:encoded><![CDATA[
<!-- google_ad_section_start -->
<p>Eigentlich ist suPHP eine nette Sache. Das Apache Modul mod_suphp sorgt in Kombination mit einem SetUID Binary dafür, dass PHP-Skripte mit den Berechtigungen des Benutzers, dem sie gehören, ausgeführt werden. Damit das funktioniert muss man in Binär-Distributionen wie etwa Debian Linux nicht mehr tun, als dass Modul zu installieren, einen Blick auf dessen Konfiguration zu werfen und es anschließend zu aktivieren. Vielleicht ist es gerade diese Einfachheit (deren Preis die Starrheit ist), die es so beliebt macht.</p>
<p>Ein großes Problem tut sich aber dann auf, wenn man PHP-Caches wie APC, TurckMM oder eAccelerator verwenden möchte. Denn all diese Caches funktionieren nicht im Zusammenspiel mit suPHP. Zwar lässt sich eine solche Kombination verwenden, doch ist sie leider nutzlos, da nichts gecached wird.</p>
<p>Eine wundervolle Alternative zu der Verwendung von suPHP ist eine Kombination aus Apache, SuExec, FCGID und PHP-CGI. Mit dieser Kombination funktioniert auch das Caching problemlos. Eine Anleitung zum Aufsetzen dieser Kombination findet sich bei <a href="http://wiki.hetzner.de/index.php/Apache_PHP5_fcgi_und_SuExec">Hetzner.de</a>.</p>
<p>Wer seine Websites nicht in dem von der jeweils genutzten Linux Distribution dafür vorgesehenen Verzeichnis ablegt sondern stattdessen beispielsweise in /home/*/public_html/ muss darauf achten, SuExec selbst zu kompilieren oder auf Debian-Systemen die gepatchte Version apache2-suexec-common zu verwenden. Aus Sicherheitsgründen erwartet SuExec bereits bei der Kompilierung den Pfad zum Docroot. Bei der Verwendung von apache2-suexec-common lässt sich das Docroot in der Datei /etc/apache2/suexec/www-data angeben.</p>
<!-- google_ad_section_end -->
]]></content:encoded>
			<wfw:commentRss>http://nerdcenter.de/suphp-php-opcode-cache/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>XEN Loop Disk Image vergrößern</title>
		<link>http://nerdcenter.de/xen-loop-disk-image-vergrosern/</link>
		<comments>http://nerdcenter.de/xen-loop-disk-image-vergrosern/#comments</comments>
		<pubDate>Tue, 25 Aug 2009 11:47:13 +0000</pubDate>
		<dc:creator>kcore</dc:creator>
				<category><![CDATA[Linux / Unix]]></category>
		<category><![CDATA[XEN]]></category>
		<category><![CDATA[disk]]></category>
		<category><![CDATA[domU]]></category>
		<category><![CDATA[grow]]></category>
		<category><![CDATA[image]]></category>
		<category><![CDATA[loop]]></category>
		<category><![CDATA[resize]]></category>
		<category><![CDATA[vergrößern]]></category>

		<guid isPermaLink="false">http://nerdcenter.de/xen-loop-disk-image-vergrosern/</guid>
		<description><![CDATA[

Das Loop Disk Image einer XEN DomU ist zu klein geworden? Solang die Festplatte des Hypervisors noch genügend Platzreserven hat, ist das glücklicherweise kein unlösbares Problem. Loop Disk Images können mit Bordmitteln vergrößert werden. Zwei kleine Beispiele für die Vorgehensweise bei EXT2, EXT3 und XFS Dateisystem:
EXT2 / EXT3 Dateisystem
VM herunterfahren:
xm shutdown domu.blub.local
Image um 30GB vergrößern:
dd [...]]]></description>
			<content:encoded><![CDATA[
<!-- google_ad_section_start -->
<p>Das Loop Disk Image einer XEN DomU ist zu klein geworden? Solang die Festplatte des Hypervisors noch genügend Platzreserven hat, ist das glücklicherweise kein unlösbares Problem. Loop Disk Images können mit Bordmitteln vergrößert werden. Zwei kleine Beispiele für die Vorgehensweise bei EXT2, EXT3 und XFS Dateisystem:</p>
<p><strong>EXT2 / EXT3 Dateisystem</strong><br />
VM herunterfahren:</p>
<pre>xm shutdown domu.blub.local</pre>
<p>Image um 30GB vergrößern:</p>
<pre>dd if=/dev/zero bs=1024k count=30720 >> disk.img</pre>
<p>Fehler im Dateisystem korrigieren:</p>
<pre>e2fsck -f disk.img</pre>
<p>Dateisystem auf die Größe des Images vergrößern:</p>
<pre>resize2fs disk.img</pre>
<p><strong>XFS Dateisystem</strong><br />
VM herunterfahren:</p>
<pre>xm shutdown domu.blub.local</pre>
<p>Image um 30GB vergrößern:</p>
<pre>dd if=/dev/zero bs=1024k count=30720 >> disk.img</pre>
<p>Fehler im Dateisystem korrigieren:</p>
<pre>xfs_repair -f disk.img</pre>
<p>Dateisystem auf die Größe des Images vergrößern:</p>
<pre>mount disk.img /mnt/tmp/ -o loop
xfs_growfs -d /mnt/tmp/</pre>
<!-- google_ad_section_end -->
]]></content:encoded>
			<wfw:commentRss>http://nerdcenter.de/xen-loop-disk-image-vergrosern/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Module &#8216;json&#8217; already loaded in Unknown on line 0</title>
		<link>http://nerdcenter.de/module-json-already-loaded-in-unknown-on-line-0/</link>
		<comments>http://nerdcenter.de/module-json-already-loaded-in-unknown-on-line-0/#comments</comments>
		<pubDate>Sun, 08 Feb 2009 22:35:32 +0000</pubDate>
		<dc:creator>kcore</dc:creator>
				<category><![CDATA[Linux / Unix]]></category>
		<category><![CDATA[PHP]]></category>

		<guid isPermaLink="false">http://www.nerdcenter.de/module-json-already-loaded-in-unknown-on-line-0/</guid>
		<description><![CDATA[

Mir sind gerade fast die Augen rausgefallen als ich bei einem Blick ins Error-Log des Apache Webservers unter Debian Etch abertausende Zeilen mit der Fehlermeldung &#34;PHP Warning: Module &#8216;json&#8217; already loaded in Unknown on line 0&#34; sah. Jeder Seitenaufruf erzeugte diesen Fehler. Die installierten Pakete (php5-cgi + Module sowie apache2 + Module) entstammen dem offiziellen [...]]]></description>
			<content:encoded><![CDATA[
<!-- google_ad_section_start -->
<p>Mir sind gerade fast die Augen rausgefallen als ich bei einem Blick ins Error-Log des Apache Webservers unter Debian Etch abertausende Zeilen mit der Fehlermeldung <strong>&quot;PHP Warning: Module &#8216;json&#8217; already loaded in Unknown on line 0&quot;</strong> sah. Jeder Seitenaufruf erzeugte diesen Fehler. Die installierten Pakete (php5-cgi + Module sowie apache2 + Module) entstammen dem offiziellen Debian Etch Repository, das Problem betrifft also wahrscheinlich auch noch viele weitere Systeme, bei denen nicht ständig ins Error-Log geschaut wird. Wahrscheinlich wird beim Start des php-cgi Prozesses noch eine andere Konfigurationsdatei als <em>/etc/php5/cgi/php.ini</em>, mit der Anweisung das Modul zu laden, ausgelesen.</p>
<p>Beheben lässt sich das Problem durch das Editieren von <em>/etc/php5/cgi/php.ini</em>. Dort die Zeile, die das json-Modul lädt, einfach auskommentieren und den Apache neustarten.</p>
<!-- google_ad_section_end -->
]]></content:encoded>
			<wfw:commentRss>http://nerdcenter.de/module-json-already-loaded-in-unknown-on-line-0/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>phpDocumentor bei SVN commit starten</title>
		<link>http://nerdcenter.de/phpdocumentor-bei-svn-commit-starten/</link>
		<comments>http://nerdcenter.de/phpdocumentor-bei-svn-commit-starten/#comments</comments>
		<pubDate>Tue, 05 Aug 2008 18:58:48 +0000</pubDate>
		<dc:creator>kcore</dc:creator>
				<category><![CDATA[Linux / Unix]]></category>
		<category><![CDATA[PHP]]></category>
		<category><![CDATA[phpdocumentor]]></category>
		<category><![CDATA[svn]]></category>

		<guid isPermaLink="false">http://www.nerdcenter.de/phpdocumentor-bei-svn-commit-starten/</guid>
		<description><![CDATA[

Was ist Code ohne Dokumentation? Genau: total daneben.
Zum Glück gibt es ja praktische Helfer wie phpDocumentor, um aus Kommentaren eine richtig anständige Dokumentation zu zaubern. Aber das verdammte Ding nach jedem SVN commit anzustoßen ist auf Dauer ganz schön nervig&#8230;
Abhilfe verspricht der post-commit hook. In dem Wurzelverzeichnis jedes SVN Repositorys befindet sich ein Verzeichnis namens [...]]]></description>
			<content:encoded><![CDATA[
<!-- google_ad_section_start -->
<p>Was ist Code ohne Dokumentation? Genau: total daneben.</p>
<p>Zum Glück gibt es ja praktische Helfer wie <strong>phpDocumentor</strong>, um aus Kommentaren eine richtig anständige Dokumentation zu zaubern. Aber das verdammte Ding nach jedem <strong>SVN commit</strong> anzustoßen ist auf Dauer ganz schön nervig&#8230;</p>
<p>Abhilfe verspricht der <strong>post-commit hook</strong>. In dem Wurzelverzeichnis jedes SVN Repositorys befindet sich ein Verzeichnis namens hooks. Dort können beliebige ausführbare Dateien hinterlegt werden, die je nach deren Dateinamen zu einem bestimmten Zeitpunkt ausgeführt werden (Beispiele / Templates sind bereits in dem Verzeichnis enthalten).<br />
Um phpDocumentor nach einem erfolgreichen SVN commit zu starten kann man ein Bash-script verwenden, indem man diesem den Dateinamen post-commit verpasst und das Executebit setzt (chmod +x foo).</p>
<p>Der Ablauf im Script ist dann wie folgt:<br />
1. SVN checkout anwerfen<br />
2. phpdoc -d anwerfen<br />
3. Quellcode löschen (bei Bedarf)</p>
<p>Das Script bekommt bei seinem Aufruf 2 Argumente: den absoluten Pfad zum betroffenen Repository sowie die Reversion nach dem commit.</p>
<p>Besonders praktisch finde ich daran die Möglichkeit den Quelltext zusammen mit der entsprechenden Dokumentation im Intranet zugänglich zu machen.</p>
<!-- google_ad_section_end -->
]]></content:encoded>
			<wfw:commentRss>http://nerdcenter.de/phpdocumentor-bei-svn-commit-starten/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>pdftk statisch linken (kompilieren)</title>
		<link>http://nerdcenter.de/pdftk-statisch-linken-kompilieren/</link>
		<comments>http://nerdcenter.de/pdftk-statisch-linken-kompilieren/#comments</comments>
		<pubDate>Wed, 02 Apr 2008 22:16:10 +0000</pubDate>
		<dc:creator>kcore</dc:creator>
				<category><![CDATA[Linux / Unix]]></category>
		<category><![CDATA[Programmierung]]></category>
		<category><![CDATA[gcc]]></category>
		<category><![CDATA[lgcj]]></category>
		<category><![CDATA[libgcj]]></category>
		<category><![CDATA[linking]]></category>
		<category><![CDATA[linux]]></category>
		<category><![CDATA[pdftk]]></category>
		<category><![CDATA[statically]]></category>
		<category><![CDATA[unix]]></category>

		<guid isPermaLink="false">http://www.nerdcenter.de/pdftk-statisch-linken-kompilieren/</guid>
		<description><![CDATA[

pdftk
pdftk ist eine Open Source Software, die es ermöglicht, PDF-Dateien per Kommandozeile zu bearbeiten. Zu den vielfältigen Features von pdftk gehört etwa die Möglichkeit PDFs übereinander zu legen.
pdftk statisch kompilieren
Einleitung
Möchte man pdftk statisch kompilieren, um es etwa auf einem Hetzner Managed Server betreiben zu können, müssen die mitgelieferten Java Bibliotheken statisch kompiliert werden. Um dies [...]]]></description>
			<content:encoded><![CDATA[
<!-- google_ad_section_start -->
<p><strong>pdftk</strong><br />
<a href="http://www.pdfhacks.com/pdftk/">pdftk</a> ist eine Open Source Software, die es ermöglicht, PDF-Dateien per Kommandozeile zu bearbeiten. Zu den vielfältigen Features von pdftk gehört etwa die Möglichkeit PDFs übereinander zu legen.</p>
<p><strong>pdftk statisch kompilieren</strong></p>
<p><b>Einleitung</b><br />
Möchte man pdftk statisch kompilieren, um es etwa auf einem Hetzner Managed Server betreiben zu können, müssen die mitgelieferten Java Bibliotheken statisch kompiliert werden. Um dies zu erreich genügt es sowohl bei pdftk 1.21 als auch bei pdftk 1.41, die Makefiles<br />
anzupassen &#8211; von Änderungen am Quelltext bleibt man verschont. Es ist übrigens durchaus sinnvoll, pdftk als 32bit Applikation zu kompilieren, denn nur so läuft es auf nahezu jedem Linuxsystem &#8211; ohne dass man sich auch noch mit Cross-Compiling herumschlagen muss.</p>
<p><strong>Makefiles anpassen</strong><br />
Nachdem man pdftk heruntergeladen hat, das Archiv entpackt hat und in das neue Verzeichnis gewechselt hat, gilt es die Dateien Makefile.Base und Makefile.DEINE-DISTRIBUTION bzw. Makefile.Generic anzupassen. Diese befinden sich im Unterverzeichnis pdftk.</p>
<p><strong>Makefile.Generic / Makefile.DEINE-DISTRIBUTION </strong><br />
In der Datei Makefile.Generic (bzw. in der Datei, die make mit dem Parameter -f übergeben wird, z.B. make -f Makefile.RedHat) werden die Flags für den Gnu Java Compiler GCJ gesetzt:</p>
<p><code># itext compiler flags<br />
export GCJFLAGS=</code></p>
<p>Um GCJ anzuweisen, die (mitgelieferten) Java Bibliotheken statisch zu kompilieren, müssen die GCJFLAGS wie folgt geändert werden:<br />
<code>export GCJFLAGS= -static</code></p>
<p>In diesem Makefile werden auch die Flags für den C++-Compiler g++ gesetzt.<br />
Default hat die Entsprechende Konstante in dem Makefile Makefile.RedHat folgenden Wert:<br />
<code>CXXFLAGS= -lrt -ldl -lgcj</code></p>
<p>Auch diese Flags müssen angepasst werden:<br />
<code>CXXFLAGS= -W1,-v -static -W1,-Bstatic -lgcj -lpthread -lm -lz -ldl -lrt -W1,-Bdynamic -lsupc++ -lstdc++ -lc</code></p>
<p>Die Flags, die mit &#8220;-W1,&#8221; beginnen, werden an den Linker ld übergeben. Abgesehen von libc, libsupc++ und libstdc++ werden alle Bibliotheken statisch gelinkt, um deren dynamische Versionen auf dem Zielsystem nicht erforderlich zu machen (auf den Managed Servern von<br />
Hetzner ist beispielsweise keine (dynamische) libgcj installiert).</p>
<p><strong>Makefile.Base</strong><br />
In der Datei Makefile.Base werden Konfigurationen vorgenommen, die weniger Distributionsabhängig sind, als jene in den anderen Makefiles. Der Entwickler von pdftk hielt sie offenbar sogar für komplett Distributionsabhängig, deshalb wird dieses Makefile von allen anderen<br />
eingebunden. Für das Vorhaben pdftk statisch zu kompilieren ist sie eigentlich uninteressant &#8211; es sei denn man erhält (wie bei mir während des Linkens von pdftk 1.41 passiert) eine Fehlermeldung im Stil von &#8220;multiple definition of `convert&#8217;&#8221;.<br />
pdftk liefert nämlich selbst alte Java Bibliotheken mit. Im Beispiel von Convert reicht es die betreffende Zeile im Makefile auszukommentieren, um das Problem zu beheben:</p>
<p><code>libgcj_local_libs = \<br />
$(java_libs_root)/java_local/security/security.a \<br />
$(java_libs_root)/gnu_local/java/security/provider/provider.a \<br />
$(java_libs_root)/gnu_local/java/security/security.a# \<br />
#$(java_libs_root)/gnu/gcj/convert/convert.a</code></p>
<p><strong>Tücken</strong><br />
<strong>GCC Versionen</strong><br />
Die aktuelle Version von pdftk stammt vom 28. November 2006 &#8211; anders ausgedrückt: pdftk wird nicht mehr aktualisiert. Da sich die GNU Compiler Collection jedoch mit jeder neuen Version ändert und beispielsweise strikter wird, was Syntax angeht, lassen sich pdftk Version 1.21 sowie pdftk 1.41 am besten mit alten Compilern kompilieren. Ich habe pdftk 1.21 erfolgreich mit GCC 3.4.5 kompiliert sowie pdftk 1.41 mit GCC 4.0.4. Statt sein System hierfür vollzumüllen<br />
kann ich die Installation von Fedora Core 2 in einer VM (z.B. der kostenlose VMWare Server) empfehlen.</p>
<p><strong>Statische Libraries mit &#8220;falschen&#8221; (unerwarteten) Dateinamen</strong><br />
Während des Kompilierens von pdftk werden u.a. die statischen Bibliotheken libgcj.a und libgcc_s.a erwartet. Sind die entsprechenden Pakete (meist libgcc-devel, libgcj-devel o.ä.) installiert, kann es trotzdem sein, dass die entsprechenden Dateien nicht vom Linker ld<br />
gefunden werden können. In meinem Fall hat sich libgcj.a unter dem Dateinamen libgcj_bc.so versteckt, libgcc_s.a hieß libgcc_s.so.1. Ein Symlink (ls -s) auf den richtigen Dateinamen behebt dieses Problem.<br />
Die GCC Bibliotheken befinden sich bei Linuxdistributionen standardmäßig im Verzeichnis /usr/lib/gcc/*/.</p>
<p><strong>GCC 4.0.4 auf Fedora Core 2 kompilieren</strong><br />
GCC 3.4 ist auf Fedora Core 2 bereits installiert. GCC 4.0.4 kann auf einem der zahlreichen GCC Mirrors heruntergeladen werden.</p>
<p>GCC 4.0.4 habe ich wie folgt konfiguriert / kompiliert / installiert:<br />
<code>tar jxf gcc*.tar.bz2<br />
cd gcc-*<br />
mkdir objdir &#038;&#038; cd objdir<br />
../configure --enable-languages=c,c++,java --prefix=/opt --enable-threads=posix &#038;&#038; make &#038;&#038; make -k check<br />
make install</code></p>
<!-- google_ad_section_end -->
]]></content:encoded>
			<wfw:commentRss>http://nerdcenter.de/pdftk-statisch-linken-kompilieren/feed/</wfw:commentRss>
		<slash:comments>4</slash:comments>
		</item>
		<item>
		<title>Ubuntu Linux Bus-Error: Wenn Programme nicht starten</title>
		<link>http://nerdcenter.de/ubuntu-linux-bus-error-wenn-programme-nicht-starten/</link>
		<comments>http://nerdcenter.de/ubuntu-linux-bus-error-wenn-programme-nicht-starten/#comments</comments>
		<pubDate>Wed, 20 Feb 2008 21:30:20 +0000</pubDate>
		<dc:creator>kcore</dc:creator>
				<category><![CDATA[Linux / Unix]]></category>

		<guid isPermaLink="false">http://www.nerdcenter.de/ubuntu-linux-bus-error-wenn-programme-nicht-starten/</guid>
		<description><![CDATA[

Wer sich ein frisches Ubuntu Linux installiert und anschließend wahllos ein Upgrade auf aktuelle Pakete fährt sollte damit rechnen, dass sein System anschließend nicht mehr einwandfrei funktionsfähig ist.
Dies wurde mir erst heute wieder bewusst, als ich auf meiner Workstation ein apt-get update &#038;&#038; apt-get upgrade durchgeführt hatte. Anschließend hatte ich mit einem lästigen Fehler zu [...]]]></description>
			<content:encoded><![CDATA[
<!-- google_ad_section_start -->
<p>Wer sich ein frisches <b>Ubuntu Linux</b> installiert und anschließend wahllos ein Upgrade auf aktuelle Pakete fährt sollte damit rechnen, dass sein System anschließend nicht mehr einwandfrei funktionsfähig ist.<br />
Dies wurde mir erst heute wieder bewusst, als ich auf meiner Workstation ein apt-get update &#038;&#038; apt-get upgrade durchgeführt hatte. Anschließend hatte ich mit einem lästigen Fehler zu kämpfen: Viele Programme verweigerten ihren Dienst mit der Fehlermeldung <b>Bus-Error</b>. Ein <b>Bus Error</b> entsteht für gewöhnlich, wenn die CPU versucht auf Speicher zuzugreifen, den sie physikalisch nicht adressieren kann. Ein weiterer möglicher Grund ist ein Hardware-Fehler. Doch mein Rechner lief ansonsten einwandfrei und auch Windows machte keine Murren.</p>
<p>Der Grund für das Problem liegt in einem Fehler in den Ubuntu libc6 Paketen. Ein simples apt-get &#8211;reinstall install libc6 &#038;&#038; apt-get &#8211;reinstall install libc6-i386 (als root! also vorher: sudo su) schafft Abhilfe.</p>
<!-- google_ad_section_end -->
]]></content:encoded>
			<wfw:commentRss>http://nerdcenter.de/ubuntu-linux-bus-error-wenn-programme-nicht-starten/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>Mit FFmpeg Videos ins FLV Format konvertieren (PHP)</title>
		<link>http://nerdcenter.de/mit-ffmpeg-videos-ins-flv-format-konvertieren-php/</link>
		<comments>http://nerdcenter.de/mit-ffmpeg-videos-ins-flv-format-konvertieren-php/#comments</comments>
		<pubDate>Wed, 09 Jan 2008 18:27:37 +0000</pubDate>
		<dc:creator>kcore</dc:creator>
				<category><![CDATA[Linux / Unix]]></category>
		<category><![CDATA[PHP]]></category>
		<category><![CDATA[Programmierung]]></category>

		<guid isPermaLink="false">http://www.nerdcenter.de/mit-ffmpeg-videos-ins-flv-format-konvertieren-php/</guid>
		<description><![CDATA[

Wer seinen Usern die Möglichkeit geben möchte Videos hochzuladen und beim Abspielen Kompabilitäts-Probleme vermeiden möchte kommt um FLV (Flash Video) nicht vorbei, denn den Flash-Player hat eigentlich jeder installiert und aktiviert. Der Download eines extra Players bzw. Codecs entfällt so auch bei exotischeren Betriebssystemen.
Mit FFmpeg lassen sich diverse Videotypen in das FLV Format konvertieren. Da [...]]]></description>
			<content:encoded><![CDATA[
<!-- google_ad_section_start -->
<p>Wer seinen Usern die Möglichkeit geben möchte Videos hochzuladen und beim Abspielen Kompabilitäts-Probleme vermeiden möchte kommt um <strong>FLV</strong> (Flash Video) nicht vorbei, denn den Flash-Player hat eigentlich jeder installiert und aktiviert. Der Download eines extra Players bzw. Codecs entfällt so auch bei exotischeren Betriebssystemen.</p>
<p>Mit <strong>FFmpeg</strong> lassen sich diverse Videotypen in das FLV Format konvertieren. Da man aus PHP Skripten heraus beliebige Prozesse mit den Rechten des Benutzers, der <strong>PHP</strong> ausführt, starten kann, lässt sich FFmpeg auch sehr gut in einem PHP Skript verwenden um Videos direkt nach dem Upload automatisch zu <strong>konvertieren</strong>.</p>
<p><strong>1. Download, Kompilieren und Installation von LAME:</strong><br />
Auf <a href="http://sourceforge.net/project/showfiles.php?group_id=290&#038;package_id=309">Sourceforge</a> gehen und aktuellste Version auswählen, Download URL kopieren und per wget auf dem Server herunterladen, also z.B. <em>wget http://surfnet.dl.sourceforge.net/sourceforge/lame/lame-3.97.tar.gz</em><br />
Nach dem Download den Tarball mit <em>tar zxf lame-3.97.tar.gz</em> entpacken und mit <em>cd lame-3.97</em> in das Verzeichnis wechseln. Nun das Configure-Skript durchlaufen lassen, kompilieren und installieren: <em>./configure &#038;&#038; make &#038;&#038; sudo make install</em></p>
<p><strong>2. Download, Kompilieren und Installation von FFmpeg:</strong><br />
<a href="http://ffmpeg.mplayerhq.hu/ffmpeg-export-snapshot.tar.bz2">FFmpeg Sources runterladen</a>: <em>wget http://ffmpeg.mplayerhq.hu/ffmpeg-export-snapshot.tar.bz2</em> , mit <em>tar jxf ffmpeg-export*</em> entpacken. Jetzt das Configure-Skript durchlaufen lassen, kompilieren und installieren: <em>./configure &#8211;enable-libmp3lame &#038;&#038; make &#038;&#038; sudo make install</em></p>
<p><strong>3. FFmpeg von PHP aus starten:</strong><br />
<em>&lt;?php<br />
system(&#8221;/usr/local/bin/ffmpeg  -i input.mov -ar 22050 -ab 56 -aspect 4:3 -b 200 -r 12 -f flv -s 320&#215;240 -acodec mp3 -ac 1 output.flv&#8221;);<br />
?&gt;</em></p>
<p>Tipp: Wenn FFmpeg den Start verweigert weil es libmp3lame.so.0 nicht finden konnte muss das Configure-Skript von LAME mit &#8211;prefix=/usr aufgerufen werden.</p>
<!-- google_ad_section_end -->
]]></content:encoded>
			<wfw:commentRss>http://nerdcenter.de/mit-ffmpeg-videos-ins-flv-format-konvertieren-php/feed/</wfw:commentRss>
		<slash:comments>4</slash:comments>
		</item>
	</channel>
</rss>
