Apache 2.2.13 upgrade breaks my SSL configuration

Today I upgraded my Apache installation to 2.2.13 on my FreeBSD server. (Thankfully I first upgraded my internal server before upgrading the server this blog is on).
The server didn't start:

[error] Server should be SSL-aware but has no certificate configured [Hint: SSLCertificateFile]

To solve this problem I usually fall back to google...

Finding some discussions about this problem I tried the following:
Moving the SSLCerticateFile and SSLCertificateKey outside a virtualhost tag as suggested, I've got the following error:

 [error] Illegal attempt to re-initialise SSL for server (theoretically shouldn't happen!)

More info wasn't available...

After some debuggin/playing I found out I must remove ALL SSL stuff out of my directives except for the line SSLEngine ON.
So in short my config file :

# Those two lines are placed OUTSIDE the <virtualhost> tag
SSLCertificateFile /usr/local/etc/apache22/ssl.crt/server.crt
SSLCertificateKeyFile /usr/local/etc/apache22/ssl.key/server.key

# in a virtual host file:
&lt;VirtualHost *:443&gt;
  ServerName sample.com
  DocumentRoot /usr/local/www/sample

    SSLEngine on
  
   &lt;Directory /usr/local/www/sample &gt;
      Options Indexes FollowSymLinks MultiViews
      AllowOverride All
      Order allow,deny
      allow from all
  &lt;/Directory&gt;
 &lt;/VirtualHost&gt;

Finally the sites are up again. Besides the Apache warning about SSL and virtual hosts everything runs find. PHeeew!

[warn] Init: You should not use name-based virtual hosts in conjunction with SSL!!

Now I must update this server, so If you can read this, the upgrade was succesful ;-)

Freebsd Ports – Environmental variables

I'm a big fan of the FreeBSD port system. But the last few weeks
I had problems updating my freebsd ports.

A growing number of ports were giving the following error: "cc: /sbin:/bin:/...:/root/bin: No such file or directory"

A full sample:

libtool: link: cc -shared  .libs/lqr_gradient.o .libs/lqr_rwindow.o .libs/lqr_energy.o .libs/lqr_cursor.o .libs/lqr_carver.o .libs/lqr_carver_list.o .libs/lqr_carver_bias.o .libs/lqr_carver_rigmask.o .libs/lqr_vmap.o .libs/lqr_vmap_list.o .libs/lqr_progress.o   -Wl,-rpath -Wl,/usr/local/lib -Wl,-rpath -Wl,/usr/local/lib -L/usr/local/lib /usr/local/lib/libglib-2.0.so /sbin:/bin:/usr/sbin:/usr/bin:/usr/games:/usr/local/sbin:/usr/local/bin:/usr/X11R6/bin:/root/bin /usr/local/lib/libintl.so /usr/local/lib/libiconv.so /usr/local/lib/libpcre.so -lm    -Wl,-soname -Wl,liblqr-1.so.3 -o .libs/liblqr-1.so.3
cc: /sbin:/bin:/usr/sbin:/usr/bin:/usr/games:/usr/local/sbin:/usr/local/bin:/usr/X11R6/bin:/root/bin: No such file or directory
gmake[2]: *** [liblqr-1.la] Error 1
gmake[2]: Leaving directory `/usr/ports/graphics/liblqr-1/work/liblqr-1-0.4.1/lqr'
gmake[1]: *** [all-recursive] Error 1
gmake[1]: Leaving directory `/usr/ports/graphics/liblqr-1/work/liblqr-1-0.4.1'
gmake: *** [all] Error 2
*** Error code 1

After a lof of debugging and digging deeply in the /work directories of the broken ports. I found out
that libtool was generating a 'wrong' cc command. The part -L /sbin:/bin/usr/bin ... etc was wrong. The path seperator ':' should not be used. I thought libtool was broken. (Rule X pragmatic programmer: "SELECT Isn't broken" ;-) )

After dinging deeply in this script I saw the $path variable was placed in this command...

After typing 'set' to see all environment variables I found out I defined a custom $path variable.
Probably by a typing mistake. Because the real environment variable for path is PATH (uppercase...)

After remove this variable 'path' ("unset path" in bash), all my problems were gone.... Yess !

So some words of wisdom: NEVER define an environment variable 'path' on freebsd !! (And be VERY careful with your other environment variables!)

Production gotcha: Rails send_file seems to corrupt files

What's wrong with the following Rails code?

class ResourceController < ApplicationController  
  DEFAULT_OPTIONS = { :disposition => 'inline' }

  def send_file1
    send_file 'flash1.swf', DEFAULT_OPTIONS
  end

  def send_file2
    send_file 'flash2.swf', DEFAULT_OPTIONS
  end
end

This code works perfectly in development mode. In production mode retrieving the two different files the second file gets corrupt / wrong...

After a long search I looked in the rails code:

  def send_file(path, options = {}) #:doc:
    raise MissingFile, "Cannot read file #{path}" unless File.file?(path) and File.readable?(path)
 
    options[:length]   ||= File.size(path)
    options[:filename] ||= File.basename(path) unless options[:url_based_filename] 
    send_file_headers! options  
    #.... 
  end

OOops... the send_file code modifies my class constant!
And after the first call the length and filename is placed in the class constant...
This is no problem in development mode because the classes are reloaded every time. In production mode every mongrel server has it's own instance...

Victory: Installing JBuilder 2006 on VISTA

No I really don't like JBuilder that much. But I really hate the workspace thing in Eclipse.

The problem:
At the company I work for, we have a lot of modules written in JBuilder. The gui designer layouts are not compatible with any other IDE. Even The newest JBuilder, which simply is Eclipse doesn't support these gui designs...
Borland: This is a VERY BAD company policy...!!!
We will migrate the GUI to netbean.. Ha!

JBuilder 2006 doesn't work in Vista anymore
JBuilder 2006 doesn't activate anymore

The solution for Vista Install:

  • Before installing disable the fancy vista layout and select classic windows (else you have invisible checkboxes in the setup)
  • Run setup as Administrator! (Right mouseclick exe, "Run as Administator"
  • Install JBuilder the normal way
  • Download the latest JDK1.5 and replace the JDK1.5 in the JBuilder director
  • In the startmenu, rightmouse click on the Jbuilder start icon, choose properties and set the compatibility mode to Windows XP. Disable visual themes. And enable " Run as admninistrator"

The solution for activating:

  • Make sure you have the registrationmail/file: reg674.txt
  • Copy this file in your user directory: C:\Users\username (in vista) or c:\Documents and Settings\username (in windows xp)
  • Set the date of your PC to the year and month you've downloaded the file. My working date is 25 october 2005 (I guess the activation is +/- 30 days valid)
  • Start JBuilder and activate with the given file
  • Run JBuilder and exit it again
  • restore the computer date
  • et voila.. JBuilder works !

UPDATE 2008-11-07

Working with JBuilder I found it had some redraw problems. Scrolling didn't go wel...
I solved this by setting the following lines in the file bin\jdk.config


#vmparam -Dsun.java2d.ddoffscreen=false
vmparam -Dsun.java2d.noddraw
vmparam -Dsun.java2d.d3d=false

I found the solution for these redraw problems here.

Crash IE, slow down Firefox, with this e-mail validation routine

Searching the internet I found the following e-mail validation routine:


function isValidEmailAddress( address )
{
return String(address).match(/^\w+([\.-]?\w+)*@\w+([\.-]?\w+)*(\.\w{2,7})+$/);
}

Feed the following (invalid) address to the routine

123456789012345678901234567890abcdefg

Result:

IE hangs, need a complete browser restart!! Maybe you need to be very very patient!
Firefox detects a slow script

I think this is pretty strange!!

Click the link below to test this 'bug':

Please crash my browser