On Mon, Jan 19, 2009 at 12:12:25AM +0100, José Luis Tallón wrote:
> Christian Hammers wrote:
> > Hello
> >
> > Any progress with this Release Critical bug?
> >
> Ready to be uploaded, at:
>
> http://devel.adv-solutions.net/debian/pool/main/mail/imapproxy/up-imapproxy_1.2.6-5.dsc
That still unconditionally overwrites local changes to listen_port,
proc_username etc.
> Thank you to Niko Tyni and other contributors.
Please note that the patch wasn't written by me but by Andreas Henriksson.
The attached new patch seems to work for me, but please verify. It uses ucf
for config file handling, which simplifies things IMO.
I'm not uploading an NMU for now, and I think #512369 should be fixed too.
I'd suggest making at least listen_port debconf-configurable for lenny+1.
--
Niko Tyni [email protected]
diff -u up-imapproxy-1.2.6/debian/control up-imapproxy-1.2.6/debian/control
--- up-imapproxy-1.2.6/debian/control
+++ up-imapproxy-1.2.6/debian/control
@@ -9,7 +9,7 @@
Package: imapproxy
Architecture: any
-Depends: lsb-base, ${shlibs:Depends}, ${misc:Depends}
+Depends: lsb-base, ${shlibs:Depends}, ${misc:Depends}, ucf (>= 0.28)
Description: IMAP protocol proxy
UP-ImapProxy proxies IMAP transactions between an IMAP client and an IMAP
server. The general idea is that the client should never know that it is
diff -u up-imapproxy-1.2.6/debian/rules up-imapproxy-1.2.6/debian/rules
--- up-imapproxy-1.2.6/debian/rules
+++ up-imapproxy-1.2.6/debian/rules
@@ -67,6 +67,10 @@
mv debian/imapproxy/usr/sbin/in.imapproxyd \
debian/imapproxy/usr/sbin/imapproxyd
+ # prepare the default configuration file
+ perl debian/prepare-config-file < scripts/imapproxy.conf \
+ > debian/imapproxy/usr/share/imapproxy/imapproxy.conf.default
+
dh_installexamples
chmod 644 $(CURDIR)/debian/imapproxy/usr/share/doc/imapproxy/examples/imapproxy.conf
diff -u up-imapproxy-1.2.6/debian/changelog up-imapproxy-1.2.6/debian/changelog
--- up-imapproxy-1.2.6/debian/changelog
+++ up-imapproxy-1.2.6/debian/changelog
@@ -1,3 +1,11 @@
+up-imapproxy (1.2.6-4.1) unstable; urgency=medium
+
+ * Non-maintainer upload.
+ * Don't overwrite the config file on upgrades. (Closes: #510432)
+ + now depends on ucf (>= 0.28)
+
+ -- Niko Tyni <[email protected]> Mon, 19 Jan 2009 21:58:39 +0200
+
up-imapproxy (1.2.6-4) unstable; urgency=medium
* 'postinst' script: configuration file processing
diff -u up-imapproxy-1.2.6/debian/imapproxy.config up-imapproxy-1.2.6/debian/imapproxy.config
--- up-imapproxy-1.2.6/debian/imapproxy.config
+++ up-imapproxy-1.2.6/debian/imapproxy.config
@@ -12,9 +12,14 @@
set -e
+CONFIG=/etc/imapproxy.conf
case "$1" in
configure|reconfigure)
+ if [ -f $CONFIG ]; then
+ SERVER="$(perl -ne '/^\s*server_hostname\s*(\S+)$/ && print $1' $CONFIG)"
+ [ -z "$SERVER" ] || db_set imapproxy/imap-server "$SERVER"
+ fi
db_input medium imapproxy/imap-server || true
db_go
;;
diff -u up-imapproxy-1.2.6/debian/imapproxy.dirs up-imapproxy-1.2.6/debian/imapproxy.dirs
--- up-imapproxy-1.2.6/debian/imapproxy.dirs
+++ up-imapproxy-1.2.6/debian/imapproxy.dirs
@@ -2,6 +2,7 @@
etc/default
usr/sbin
var/lib/imapproxy/chroot
+usr/share/imapproxy
usr/share/doc/imapproxy
usr/share/doc/imapproxy/examples
var/run
diff -u up-imapproxy-1.2.6/debian/imapproxy.postinst up-imapproxy-1.2.6/debian/imapproxy.postinst
--- up-imapproxy-1.2.6/debian/imapproxy.postinst
+++ up-imapproxy-1.2.6/debian/imapproxy.postinst
@@ -29,14 +29,7 @@
# `abort-remove' or `abort-deconfigure'.
DESTFILE=/etc/imapproxy.conf
-CFGFILE=imapproxy.conf
-
-PARAMS="server_hostname proc_username proc_groupname chroot_directory listen_port"
-server_hostname="localhost"
-proc_username="nobody"
-proc_groupname="nogroup"
-chroot_directory="/var/lib/imapproxy/chroot"
-listen_port=143
+SRCFILE=/usr/share/imapproxy/imapproxy.conf.default
case "$1" in
configure)
@@ -48,31 +41,16 @@
if [ "$server_hostname" = "localhost" ]; then
# change bind port if localhost (#470431)
listen_port=1143;
+ else
+ listen_port=143
fi
- test -f $DESTFILE || cp /usr/share/doc/imapproxy/examples/$CFGFILE $DESTFILE;
TMPFILE=`tempfile`
- mv $DESTFILE $TMPFILE
- export PARAMS
- export $PARAMS
-
-/usr/bin/perl -- - $DESTFILE $TMPFILE << 'EOSCRIPT'
-use warnings;
-use strict;
-
-my $CFG;
-open(CFG, '>', shift) or die "imapproxy.postint: could not open: $!";
-
-my %params = map { $_ => undef } split(/\s/, $ENV{'PARAMS'});
-
-while (<>)
-{
- my ($key) = m/^#?(\w+)/;
- if ( defined $key and exists $params{$key} ) { print CFG "$key $ENV{$key}\n"; }
- else { print CFG $_; }
-}
-
-EOSCRIPT
+ sed "s/^server_hostname .*/server_hostname ${server_hostname}/ ;
+ s/^listen_port .*/listen_port ${listen_port}/" \
+ < $SRCFILE > $TMPFILE
+ chmod 644 $TMPFILE
+ ucf --debconf-ok $TMPFILE $DESTFILE
# prevent incorrect time zone config (#436555)
if [ ! -f ${chroot_directory}/etc/localtime ]; then
@@ -80,14 +58,14 @@
cp /etc/localtime ${chroot_directory}/etc
fi
+ ucfr imapproxy $DESTFILE
- # Clean env. & temp file
- for p in $PARAMS PARAMS; do export $p= ; done
+ # Clean temp file
rm -f $TMPFILE
else # -e /usr/share/debconf/confmodule
-
- test -f $DESTFILE || cp /usr/share/doc/imapproxy/examples/$CFGFILE $DESTFILE;
+ # this should never happen, really
+ test -f $DESTFILE || cp $SRCFILE $DESTFILE;
fi
;;
diff -u up-imapproxy-1.2.6/debian/imapproxy.postrm up-imapproxy-1.2.6/debian/imapproxy.postrm
--- up-imapproxy-1.2.6/debian/imapproxy.postrm
+++ up-imapproxy-1.2.6/debian/imapproxy.postrm
@@ -22,6 +22,12 @@
;;
purge)
rm -f /etc/imapproxy.conf
+ if which ucf >/dev/null 2>&1; then
+ ucf --purge /etc/imapproxy.conf
+ fi
+ if which ucfr >/dev/null 2>&1; then
+ ucfr --purge imapproxy /etc/imapproxy.conf
+ fi
;;
*)
only in patch2:
unchanged:
--- up-imapproxy-1.2.6.orig/debian/prepare-config-file
+++ up-imapproxy-1.2.6/debian/prepare-config-file
@@ -0,0 +1,17 @@
+#!/usr/bin/perl -w
+use strict;
+
+# server_hostname and server_port are handled by the postinst
+
+my %params=(
+ proc_username => "nobody",
+ proc_groupname => "nogroup",
+ chroot_directory => "/var/lib/imapproxy/chroot",
+);
+
+while (<>)
+{
+ my ($key) = m/^#?(\w+)/;
+ if ( defined $key and exists $params{$key} ) { print "$key $params{$key}\n"; }
+ else { print $_; }
+}