[Dovecot] Bug in keywords conversion with courier-dovecot-migrate.pl v1.1.7
The problem is the file glob on line 344 in convert_subscriptions()
# read updates from the directory my %updates; foreach (<$keyword_dir/*>) {
This isn't going to pick up any files beginning with a dot, so most of
the update files in the courierimapkeywords directory are going to be
skipped.
On Sep 19, 2008, at 10:26 AM, Timo Sirainen wrote:
opendir/readdir/closedir... Personally I avoid file globs in Perl
whenever possible because of the tricks and limitations involved with
them. For instance, if the glob expands to more than GLOB_LIMIT files
what is going to happen? opendir/readdir/closedir has very
predictable behavior.
Actually since we're talking about that, scan_maildir() is very likely
to hit the glob limit. It should also be switched to readdir. The
maildir files update loop in convert_subscriptions() as well.
-----BEGIN PGP SIGNED MESSAGE----- Hash: SHA1 On Fri, 19 Sep 2008, Timo Sirainen wrote:
Any suggestions how to best fix it? My Perl knowledge isn't too good.
I do recommend using opendir() cycle like so: - --- /tmp/courier-dovecot-migrate.pl.orig 2008-09-22 10:55:00.000000000 +0200 +++ /tmp/courier-dovecot-migrate.pl 2008-09-22 11:00:19.000000000 +0200 @@ -341,12 +341,10 @@ # read updates from the directory my %updates; - - foreach (<$keyword_dir/*>) { - - s,^$keyword_dir/,,; - - next if ($_ eq ":list"); - - - - my $fname = $_; - - if (/^\.(\d+)\.(.*)$/) { + if(opendir(DIR, $keyword_dir)) { + while(defined (my $fname = readdir(DIR))) { + next if $fname eq ':list'; + if ($fname =~ /^\.(\d+)\.(.*)$/) { my ($num, $base_fname) = ($1, $2); if (!defined $updates{$fname}) { $updates{$fname} = $num; @@ -361,6 +359,10 @@ $updates{$fname} = -1; } } + closedir DIR or die "Failed reading $keyword_dir: $!\n"; + } else { + die "Failed opening $keyword_dir: $!\n"; + } # apply the updates foreach (keys %updates) { - -- Steffen Kaiser -----BEGIN PGP SIGNATURE----- Version: GnuPG v1.4.6 (GNU/Linux) iD8DBQFI118/VJMDrex4hCIRArglAJ9K+wkb2pOVDBEATCxTFylX5HhsMQCg1VzP W9NSzDI55wNDZqGRgK6GXVw= =YwiS -----END PGP SIGNATURE-----
participants (3)
-
John Lightsey
-
Steffen Kaiser
-
Timo Sirainen