DebConf Issues on OpenSolaris

So, with new system calls added to lx-brand it's possible to run an up-to-date Debian in an OpenSolaris zone, but apt will not work correctly due to the following error:

debconf: DbDriver "config": /var/cache/debconf/config.dat is locked by another process: Bad file descriptor

Doing a bit of investigation it appears to be failing because Debconf tries to acquire an exclusive lock on a read-only file descriptor. Apparently, this is fine to do on a Linux machine but OpenSolaris doesn't allow it. The offending code is in /usr/share/perl5/Debconf/DbDriver/ (version 1.5.28):

51: if (! open ($this->{_fh}, $this->{filename})) {
57:   while (! flock($this->{_fh}, LOCK_EX | LOCK_NB)) {

Some tutorials suggest just removing the lock code as a solution. This actually allows debconf to work but may cause weird issues if running multiple debconf utilities at the same time.

Nexenta also modifies the debconf code, but instead of removing the lock code, it changes it to a shared lock.

Another possible fix is to simply make DebConf open the file descriptor with write access, this is what I'm currently using and it seems to be the safest method since it allows acquisition of an exclusive lock even on OpenSolaris.

51: if (! open ($this->{_fh}, "+<", $this->{filename})) {

I'm not sure if it's worth changing the lx_brand code to emulate this specific behaviour, hacking the debconf code is easy enough and seems to work fine.