[Date Prev][Date Next] [Thread Prev][Thread Next] [Date Index] [Thread Index]

debconf patch : Follow database files symlinks

Hello !

I would like to submit this patch for debconf.
The aim is, if any database file is a symbolic link, to follow it
explicitly, and reference the destination instead of the original.
Doing this makes the system more robust when both debconf and cdebconf
are installed and used on a system. Because debconf, when saving, writes
to a brand new file, and copies the old one ; if it was initially a
symlink (eg to the cdebconf database), it is replaced by a real file,
and the 2 databases become out of sync.
A god example is what happened to Joey and Christian when switching to
cdebconf :
 * The cdebconf preinst script copied the db files and replaced them
with sysmlinks.
 * Debconf ran the config script, automatically setting the
cdebconf/frontend setting, and saved the db to a new file instead of
following the symlink.
 * When setting DEBCONF_USE_CDEBCONF later on, cdebconf didn't have the
cdebconf/frontend value.

NB : I am definitely not a perl person, so I would strongly recommend
someone with more experience reviews the patch before actually applying it.

>From 349046fd802e9bc10c496642ae10672fd0eb12c3 Mon Sep 17 00:00:00 2001
From: Regis Boudin <regis@boudin.name>
Date: Sat, 26 May 2012 00:27:06 +0200
Subject: [PATCH] File.pm : Get actual filename, following symlinks. It makes
 it possible to switch back and forth between debconf and

 Debconf/DbDriver/File.pm |    3 +++
 1 file changed, 3 insertions(+)

diff --git a/Debconf/DbDriver/File.pm b/Debconf/DbDriver/File.pm
index a1a003c..104e76f 100644
--- a/Debconf/DbDriver/File.pm
+++ b/Debconf/DbDriver/File.pm
@@ -9,6 +9,7 @@ Debconf::DbDriver::File - store database in flat file
 package Debconf::DbDriver::File;
 use strict;
 use Debconf::Log qw(:all);
+use Cwd 'abs_path';
 use POSIX ();
 use Fcntl qw(:DEFAULT :flock);
 use IO::Handle;
@@ -81,6 +82,8 @@ sub init {
 	$this->error("No filename specified") unless $this->{filename};
+	$this->{filename} = abs_path($this->{filename});
 	debug "db $this->{name}" => "started; filename is $this->{filename}";
 	# Make sure that the file exists, and set the mode too.

Reply to: