Archive for June, 2009

Migrating Firebird Security Databases from 1.x.x to 2.x.x

Tuesday, June 23rd, 2009

One of the main goals of Firebird 2.0 was to enhance database security.  In order to achieve this, certain changes were made to the security database which made it incompatible with prior versions.  So now, unlike prior upgrades, you can’t just copy your old security database to the new installation directory.  If you try to do this you will get a “Cannot attach to password database” error when you try to connect to the server.  You have to put your old security database through a conversion process to be able to use it with the new Firebird.  Here is how it is done:

  1. Copy your existing security database (security.fdb or isc4.gdb) to a safe place.  NOT in the new Firebird installation directory.
  2. Install Firebird 2.x.
  3. Convert your existing security database to ODS 11 by using the gbak tool to back up and restore the database.
  4. Connect to your existing secuity database (newly converted to ODS 11) using the isql tool and run the security database update script using the input command.  This script can be found in misc\upgrade\security\security_database.sql in the Firebird 2.x installation directory.
  5. Stop the Firebird service.
  6. Save a copy of the Firebird 2.x security database (security2.fdb) in a safe place just in case.
  7. Copy the updated security database into the Firebird 2.x installation directory and rename it security2.fdb.
  8. Restart Firebird

You should now be able to connect to Firebird using all of your old user names and passwords.

I/O Errors Reported for USB Disk Drives After Inactivity

Monday, June 22nd, 2009

I just purchased a new USB disk to use for backups on my Linux server.  The old one had died so I got one of the new Seagate terabyte units.  Everything seemed find until the disk had been inactive long enough for the firmware to put the disk into power saving mode and spin it down.  The first attempt to access the disk after that resulted in Linux reporting an I/O error.

I found a simple way to get around this problem.  Before accessing the disk simply issue the following command:

 sdparm –command start <device>

where <device> is the device name for your USB drive.  In my case, /dev/sdc.

Since I only use the disk for backups and all of my backups are run from shell scripts this works very well for me.  Someone who is using a USB disk in a more adhoc fashion will probably have to set the disk’s timeout value such that it never goes inactive and spins down.  You can use the sdparm command for that as well but the setting names and values probably vary from disk to disk so it isn’t really possible to give complete details here.

Using HtmlHelp in a Delphi Active Form

Tuesday, June 16th, 2009

I stumbled across a bug in the Delphi HtmlHelpViewer unit yesterday.  I had written an ActiveX control based on a Delphi form (active form) and I wanted to display the contents of an HtmlHelp file.  Sounded easy enough, just put HtmlHelpViewer in the uses list.  And that worked insofar as I could display the required help pages. But (isn’t there always a but) if the user didn’t display any help pages the application would hang when it tried to close.

Googling provided some hints as to what the problem might be but no solution to the problem.  It turns out there is a bug in Delphi’s HtmlHelpViewer unit.  It only calls HtmlHelp using the HH_INITIALIZE command if you try to display a help page.  Sounds reasonable, why would you want to initialize the help engine if you aren’t going to display any help, right?  Unfortunately, HtmlHelpViewer calls HtmlHelp using the HH_CLOSE_ALL command unconditionally when the application shuts down.  That means that it tries to close all open help windows without ever having initialized the Html help system.  In a normal application, this doesn’t cause any problems but if you try to do this from an ActiveX control, the application will hang.

After much messing around I finally found a workaround.  I simply put a call to HtmlHelp using the HH_INITIALIZE command in my ActiveX control’s start up code and the problem is gone.

There are references to this problem in Embarcadero’s Quality Central but they don’t seem to have done anything about it yet.


This turned out to be not quite so easy as I thought.  In addition to placing an HH_INITIALIZE command in the active form’s OnCreate event handler (DO NOT put this in the initialization section of the unit because it won’t work) I also had to copy the HmtlHelpViewer to my project directory, add it to my project and make the following change:

procedure THtmlHelpViewer.SoftShutDown;
if (FInitialized) then  // Only call HH_CLOSE_ALL if we are initialized
HtmlHelp(0, nil, HH_CLOSE_ALL, 0);

For reasons that elude me neither fix on its own solves the problem but it you use both then it seems to work.

IE8 and File Security

Friday, June 12th, 2009

I inadvertently installed the Internet Explorer 8 upgrade the other day and ever since then I get File Security Warning dialogues every time I try to execute a file or open a .CHM file from one of my network drives.   Apparently Microsoft has learned nothing from the Vista UAC fiasco and now they are trying to impose the same asinine access control dialogues on unsuspecting IE8 users on Windows XP.

After about 1.5 hours of googling I finally found a way to get rid of the extremely annoying warning.  You need to add your file server to your list of trusted sites under IE.  To do this you open IE and click Tools | Options.  Click the Security tab, highlight the Trusted Sites icon and click the Sites button.  Enter the UNC path for your server into the edit box like this:


Click the Add button and click the Close button.

Now you should be able to open all of those supposedly unsafe file from your file server without having to deal with the annoying dialogues.

As if that weren’t bad enough, the IE8 upgrade seems to have undone the changes I made a long time ago to allow the content of .CHM files from my file server to be displayed.  See my article on this subject to find out how to re-enable this.