Category: Programming

Programming Feed

bluelife.at jetzt auch SSL gesichert

Ich verwende ja schon seit längerem kostenlose StartSSL Zertifikate aber aus Mangel an IP Adressen war die Homepage selbst bisher nicht per https gesichert. Man kann ja aus Protokolldesigngründen noch keine VHosts mit SSL kombinieren außer man hat Wildcard Zertifikate die sind aber wiederum sehr teuer. Nun hab ich aber glücklicherweise bemerkt, dass StartCom seine Zertifikate nicht nur für die Subdomain ausstellt die man beim erstellen angibt sondern zusätzlich noch die Hauptdomain selbst. Das ist ja beinahe schon ein Wildcard Zertifikat und erfüllt genau meine Anforderungen.

Deshalb gibts jetzt bluelife.at auch SSL gesichert und war außerdem noch kostenlos.

Programming : Read more : comments (0) : 31.01.2010 10:17

JCaptcha is using com.sun.image.codec.jpeg and that sucks!

JCaptcha is great for creating captchas but you cannot easily use jcaptcha with OpenJDK because it depends on an internal Sun API. (com.sun.image.codec.jpeg)

That really sucks and breaks a lot of Java products.

Programming, Helma : Read more : comments (0) : 18.01.2010 11:23

devel/p5-subversion: Undefined symbol "svn_ra_init_ra_libs"

Looks like devel/p5-subversion is broken on FreeBSD when installed on a fresh box. Don't know why this does not happen on a few mostly identical boxes but you can test it with perl -MSVN::Ra -e '1' and see if it fails. It looks like this

$ perl -MSVN::Ra -e '1' /libexec/ld-elf.so.1: /usr/local/lib/perl5/site_perl/5.8.9/mach/auto/SVN/_Ra/_Ra.so: Undefined symbol "svn_ra_init_ra_libs"

and i've fixed it with a simple patch which is probably wrong but it works for me.

--- subversion/bindings/swig/perl/native/Makefile.PL.in.orig 2009-11-05 15:23:39 +0100 +++ subversion/bindings/swig/perl/native/Makefile.PL.in 2009-11-05 15:23:24 +0100 @@ -58,7 +58,7 @@ OBJECT => q/$(O_FILES)/, LIBS => [join(' ', $ENV{'LDFLAGS'}, $apr_ldflags, (map <_ = abs_path($_); "-L$_"> @ldpaths), - @ldmodules, '-lsvn_swig_perl-1')], + @ldmodules, '-lsvn_swig_perl-1','-lsvn_ra-1')], test => { TESTS => "$swig_srcdir/perl/native/t/*.t" } );

Programming, FreeBSD : Read more : comments (0) : 05.11.2009 15:24

Kernel 2.6.31 broke my PHP script

Strange things happened when is_dir() suddenly returned false. The directory is there, was always there and file_exists() confirms that. Last thing i've changed on that box was the Kernel update on my Slackware box to 2.6.31 so restarting with 2.6.27 and problem is gone. Very strange.

Okay digging a bit deeper, that directory is mounted via cifs (samba share) and when looking at stat output or ls -lai the Inode number is huge. Really huge. That was caused by a patch that enables cifs serverino option per default but breaks all applications that are not compiled with large file support.

The workaround for this is to pass the option "noserverino" to mount.cifs.

Programming : Read more : comments (0) : 25.09.2009 12:00

Encrypted Slackware on USB Stick

Lession for today is: We need an bootable Slackware 12.2 on an LUKS encrypted USB stick.

The encryption part is not that hard and well documented in README_CRYPT.TXT so i will concentrate on the things that are new.

UUID

Our USB stick needs to work on most desktop boxes so we cannot hardcode /dev/sda1 in /etc/fstab, /etc/crypttab or when creating our initrd. Sad but true Slackware 12.2 supports UUID only in /etc/fstab out of the box so i've needed to patch the missing pieces to get it working.

That patch is against /etc/rc.d/rc.6 scripts from current.

--- slackware-current/source/a/sysvinit-scripts/scripts/rc.6.orig 2008-12-02 21:32:00.000000000 +0100 +++ slackware-current/source/a/sysvinit-scripts/scripts/rc.6 2009-07-29 12:05:59.000000000 +0200 @@ -208,6 +208,11 @@ LUKS=$(echo $line | tr 't' ' ' | tr -s ' ' | cut -f1 -d' ') DEV=$(echo $line | tr 't' ' ' | tr -s ' ' | cut -f2 -d' ') OPTS=$(echo $line | tr 't' ' ' | tr -s ' ' | cut -f4 -d' ') + + if echo $DEV | egrep -q "(LABEL=|UUID=)" ; then + DEV=`findfs $DEV` + fi + if /sbin/cryptsetup.static isLuks $DEV 2>/dev/null ; then echo "Locking LUKS crypt volume '${LUKS}':" /sbin/cryptsetup.static luksClose ${LUKS} --- slackware-current/source/a/sysvinit-scripts/scripts/rc.S.orig 2009-04-22 04:48:39.000000000 +0200 +++ slackware-current/source/a/sysvinit-scripts/scripts/rc.S 2009-07-29 13:18:19.000000000 +0200 @@ -74,6 +74,7 @@ PASS="${LUKSARRAY[2]}" OPTS="${LUKSARRAY[3]}" LUKSOPTS="" + if echo $DEV | egrep -q "(LABEL=|UUID=)" ; then DEV=`findfs $DEV` ; fi if echo $OPTS | grep -wq ro ; then LUKSOPTS="${LUKSOPTS} --readonly" ; fi

# Skip LUKS volumes that were already unlocked (in the initrd):

After you have applied that patch you can replace all device entries in /etc/fstab and /etc/crypttab with UUID entries. To find the UUID for your devices you can use blkid or tune2fs -l.

initrd

You have already created an initrd during the installation if you followed the encryption guide but that initrd cannot mount a root device per UUID. To get that feature we need to patch the init script of the initrd tree which is a shellscript in a small busybox environment. The base for that initrd is /usr/share/mkinitrd/initrd-tree.tar.gz and mkinitrd does not much more than extracting that archive, modify a few files with config parameters and put that all in an compressed cpio archive when you create a new initrd.

So you need to patch that init script in /usr/share/mkinitrd/initrd-tree.tar.gz. The init script from current which will soon get Slackware 13 already has LABEL support so i've taken that and added UUID and luksdev support.

--- slackware-current/source/a/mkinitrd/init.orig 2009-04-03 00:13:59.000000000 +0200 +++ slackware-current/source/a/mkinitrd/init 2009-07-29 12:05:12.000000000 +0200 @@ -79,10 +79,13 @@ luksdev=/dev/*) LUKSDEV=`echo $ARG | cut -f2 -d=` ;; + luksdev=LABEL=*|luksdev=UUID=*) + LUKSDEV=`echo $ARG | cut -f2- -d=` + ;; waitforroot=*) WAIT=`echo $ARG | cut -f2 -d=` ;; - root=LABEL=*) + root=LABEL=*|root=UUID=*) ROOTDEV=`echo $ARG | cut -f2- -d=` ;; resume=*) @@ -137,11 +140,17 @@ /sbin/mdadm -A -s fi

- # Find root device if a label was given: - if echo $ROOTDEV | grep -q "LABEL=" ; then + # Find root device if a label or uuid was given: + if echo $ROOTDEV | egrep -q "(LABEL=|UUID=)" ; then ROOTDEV=`findfs $ROOTDEV` fi

+ if echo $LUKSDEV | egrep -q "(LABEL=|UUID=)" ; then + if findfs $LUKSDEV 1>/dev/null 2>/dev/null ; then + LUKSDEV=`findfs $LUKSDEV` + fi + fi + # Make encrypted root partition available: # The useable device will be under /dev/mapper/ # Three scenarios for the commandline exist: @@ -175,6 +184,12 @@ # Make encrypted root partition available (scenario 3): # We have to handle cases here where the LUKS volume is created on a LV if [ -x /sbin/cryptsetup ]; then + if echo $LUKSDEV | egrep -q "(LABEL=|UUID=)" ; then + if findfs $LUKSDEV 1>/dev/null 2>/dev/null ; then + LUKSDEV=`findfs $LUKSDEV` + fi + fi + if /sbin/cryptsetup isLuks ${LUKSDEV} 1>/dev/null 2>/dev/null ; then # Only act if we could not open the LUKS device before (i.e. is on a LV): if [ "x$CRYPTDEV" == "x" ]; then

findfs

Slackware current already includes findfs in the initrd busybox environment but for Slackware 12.2 you need a static compiled version of findfs which is part of e2fsprogs. So you have to include it in your /usr/share/mkinitrd/initrd-tree.tar.gz under bin or sbin.

let's create our initrd

mkinitrd -c -k 2.6.27.7-smp -m ext3:ehci_hcd:uhci_hcd:usb_storage -f ext3 -r cryptroot -C UUID="ae04abe2-90f4-472c-9db6-ac0d2b14c4a5" -w 10

It's that easy. You need the USB kernel modules which are ehci_hcd uhci_hcd and usb_storage and wait a few seconds at boot until the drive appears so we add "-w 10" to wait for 10 seconds.

Don't forget to call lilo before rebooting and have fun with your mobile Slackware USB stick.

Programming, Linux : Read more : comments (0) : 29.07.2009 14:36

Helma on Jetty 6.1.16

About a year ago i've started thinking about how to implement Request Based Priority Queues in Helma and got to the conclusion that Jetty 5.1 which Helma uses up to now is too old for what i wanted to do so i've created a patch for Helma to use a newer Jetty but had never time to finish it.

Today i've read about hannes wishlist for Helma 1.7 and time seemed perfect to talk with him about my patch. About 10 Hours later i've succeeded and can serve at least the welcome app.

Patch: http://home.bluelife.at/tmp/helma-jetty6-v3.patch

img/articles/helma-jetty6.jpg

Programming, Helma : Read more : comments (0) : 05.04.2009 17:49

Erste Erfahrungen mit WebServices

Wenn zwei Systeme mit einander kommunizieren sollen hört man seit einigen Jahren immer wieder von Web Services und jetzt war es auch bei mir so weit, dass ich mich näher damit beschäftigen durfte.

Das Thema wird in unzähligen Zeitschriften und Firmen gehyped aber umfasst so viele Spezifikationen, Protokollen, Frameworks und Eclipse Plugins, dass es schwer fällt einen Überblick zu gewinnen. Diesen Überblick müsst ihr euch leider selbst verschaffen denn ich möchte hier nur auf ein Quick-Start Beispiel eingehen.

Es entsteht sehr oft der Eindruck, dass man sofort einen Tomcat oder JBoss Server braucht um damit herumspielen zu können und das ist für viele ein großes Hindernis. Glücklicherweise ist es nicht notwendig denn Axis2 hat einen standalone Server integriert der vorerst völlig ausreicht.

Vorbereitungen

Gut dann legen wir mal los. Wir brauchen dazu folgendes … Ich hab es auf unterschiedlichen Rechnern mit Eclipse 3.2 versucht und glaubt mir es ist den Aufwand nicht wert!

Axis2 Setup

Axis2 POJO AddressBook

Da wir hier bei keinem Kindergeburtstag sind nehmen wir zumindest eines der mitgelieferten Beispiele von Axis2 für unsere Spielchen. Das müssen wir dazu aber erst über ant kompilieren und dann Axis2 vorwerfen.

(Eclipse meint dann, dass er libraries nicht findet und zeigt Syntax Errors an - kann man ignorieren denn das ant buildscript findet sie) Dann sollte das ant buildscript durchlaufen und mit "BUILD SUCCESSFUL" anzeigen, dass es erfolgreich war. Nun können wir unseren Axis2 Server in einer Shell/Eingabeaufforderung starten … (für Windows ist es axis2server.bat) cd bin ./axis2server.sh

Nun können wir im Browser kontrollieren ob bisher alles geklappt hat wie es soll indem wir "http://localhost:8080/axis2/services/" aufrufen. Dort sollten wir 2 Services "Version" und "AddressBookService" vorfinden.

Writing the Client

Nachdem wir jetzt unseren Webservice laufen haben beginnt der interessante Teil. Der AddressBookService sollte 2 Methoden bereitstellen und zwar "addEntry" und "findEntry". Aus diesen Informationen wird Eclipse gleich unsere Java Klassen anlegen die genau diese Methoden implementieren.

Eclipse hat jetzt alle notwendigen Klassen für unser generiert die wir für einen Zugriff auf die WebService Schnittstelle brauchen. import sample.addressbook.entry.xsd.Entry; import sample.addressbook.service.AddressBookServiceLocator; import sample.addressbook.service.AddressBookServicePortType;

public class Main {

public static void main(String[] args) {

try { AddressBookServiceLocator locator = new AddressBookServiceLocator(); AddressBookServicePortType book = locator.getAddressBookServiceHttpSoap12Endpoint();

book.addEntry(new Entry("City", "Club3k", "9000", "Austria", "Fakestreet 69"));

Entry entry = book.findEntry("Club3k");

System.out.println("Found: " + entry.getName()); } catch (Exception e) { e.printStackTrace(); } } }

So mehr ist es nicht. Das ist alles was man selbst noch machen muss um den Webservice nutzen zu können. Bei den Methodenaufrufen addEntry und findEntry wird dabei intern ein SOAP Request auf die Webservice Schnittstelle gemacht und das Resultat sehen wir gleich.

Der Output wenn alles richtig gelaufen ist:

Found: Club3k

Programming : Read more : comments (0) : 27.05.2008 09:03

SVN::Web Charset Patch

Recently I discovered in my SVN::Web installation that they send out an Content-Type header with UTF-8 charset but i need ISO-8859-1 and there is no parameter in the config.

So i wrote a little patch for SVN::Web 0.53. If you use FreeBSD you can put this into /usr/ports/devel/p5-SVN-Web/files/patch-charset.diff and be happy with it. --- lib/SVN/Web.pm.orig 2007-04-29 19:22:51.000000000 +0000 +++ lib/SVN/Web.pm 2008-01-16 12:39:34.000000000 +0000 @@ -345,7 +345,7 @@

if(ref($html)) { print $cfg->{cgi}->header( - -charset => $html->{charset} || 'UTF-8', + -charset => $html->{charset} || 'ISO-8859-1', -type => $html->{mimetype} || 'text/html', -cookie => @cookies, ); @@ -361,7 +361,7 @@ } } else { print $cfg->{cgi}->header( - -charset => 'UTF-8', + -charset => 'ISO-8859-1', -type => 'text/html', -cookie => @cookies, ); @@ -391,7 +391,7 @@ if(ref($html)) { my $content_type = $html->{mimetype} || 'text/html'; $content_type .= '; charset='; - $content_type .= $html->{charset} || 'UTF-8'; + $content_type .= $html->{charset} || 'ISO-8859-1'; $cfg->{request}->content_type($content_type);

if(mod_perl_2) { @@ -411,7 +411,7 @@ $cfg->{request}->print($html->{body}); } } else { - $cfg->{request}->content_type('text/html; charset=UTF-8'); + $cfg->{request}->content_type('text/html; charset=ISO-8859-1');

if(mod_perl_2) { $cfg->{request}->headers_out();

Programming, FreeBSD : Read more : comments (0) : 16.01.2008 12:46

Böse Sonderzeichen in Webchats

Nur wenigen ist bekannt, dass im HTML 4.0 Standard ein Sonderzeichen definiert ist das es ermöglicht die Textausrichtung auf "arabisch" umzustellen. Das bedeutet, dass alle Zeilen rechts beginnen und nach links geschrieben werden.

Das ist für arabische Schriften notwendig aber in nicht arabischen Webchats eine Qual. In diesem Fall ist es von Vorteil, dass Microsoft es nicht für nötig hält sich an Standards zu halten denn der Internet Explorer ignoriert dieses Sonderzeichen gekonnt. Bei Firefox wird es allerdings unterstützt und führt dazu, dass der Chatstream beinahe unbrauchbar wird.

Die einzige mir bekannte Lösung ist das filtern der entsprechenden Sonderzeichen in der Chatengine und zwar möglichst früh damit es auch nicht in Raumnamen verwendet werden kann. Wenn es möglich ist Kurzbeschreibungen anzuzeigen muss dort ebenfalls sichergestellt werden, dass diese Sonderzeichen keine Probleme verursachen.

Falls jemand glaubt sich aufregen zu müssen kann er das gerne tun. Uns ist dieser Sachverhalt seit dem 27. September 2007 bekannt und es wurden daraufhin sowohl FreeCS als auch Cyberworkers Entwickler über diese Tatsache informiert, haben es aber bisher nicht für notwendig empfunden zu antworten oder einen Patch zu schreiben. Wenn 3 Monate nicht genug dafür sind wird wohl mehr Zeit auch nicht helfen.

Update (22.12.2007 12.00) rene-m hat reagiert und seit FreeCS Version 1.2.20071222 werden nun alle 8 Sonderzeichen gefiltert.

2. Update (22.12.2007 12.30) Vielen Dank für den Hinweis, dass es noch weitere Unicode Zeichen gibt die ebenfalls eine ähnliche Wirkung haben. In einem kurzen Test konnte ich das zwar nur für 2 der 8 Zeichen bestätigen aber zur Sicherheit sollte man alle 8 Zeichen sowie deren Hex Equivalent filtern.

Unicode Nr.Unicode Hex Nr.Beschreibung
Zeilen-Abgrenzung
Absatz-Abgrenzung
Einbettung von links nach rechts
Einbettung von rechts nach links
Pop Directional Formatting (PDF)
Left-to-Right Override (LRO)
Right-to-Left Override (RLO)
Schmaler Leerschritt ohne Zeilenumbruch

Links:

Programming, Club3k : Read more : comments (7) : 19.12.2007 21:56

java.nio.* Bug

Seit vielen Jahren gibt es bei Webchats die java.nio verwenden einen seltenen Bug der dazu führt, dass Sockets irgendwie hängen bleiben und die User dazu dann im Chat stecken. Das tritt bei club3k.at bei ca 1 bis 2 Usern pro Woche auf. Vom Code her bemerkt man den Fehler nicht denn schreiben in den Socket geht immer gut und man bekommt keine Exception die einen auf einen Fehler aufmerksam macht. Natürlich funktioniert auch ein schließen des Sockets nicht sauber und so hängen die User dann da und beschweren sich, dass sie nicht mehr reinkommen weil ihr Nick im Chat festhängt. Also alle paar Wochen den Chat neu starten dann geht es wieder weiter.

Das Problem ist altbekannt und bisher sind wir davon ausgegangen, dass es ein Java Bug ist den wir zumindest seit JDK 1.3 kennen. Vor ein paar Wochen haben wir aber den Chat auf einen FreeBSD 6.2 Server in eine Jail migriert und siehe da - es hängen keine User mehr im Chat! Hm woran liegts nun? Ist der TCP/IP Stack vom Linux 2.4 und 2.6er Kernel der Schuldige oder muss man auf die Java Implementierung von java.nio.* schimpfen?

Update Den Fehler gibt es auch unter Windows also deutet das eher auf ein Problem in der JDK hin. Schön wäre jetzt noch wenn ich einen Bugeintrag dazu finde oder jemanden der das Problem bestätigen kann.

2. Update Kaum schreibt man darüber schon tritt er auch unter FreeBSD auf. Es hat jetzt 16 Tage gedauert bis wieder einer hängt und nachweislich gibt es auf OS Ebene keinen passenden Socket mehr. Klingt wie der Startschuss zum debuggen.

Programming : Read more : comments (0) : 19.12.2007 16:30