[Dovecot] Bug in keywords conversion with courier-dovecot-migrate.pl v1.1.7

Steffen Kaiser skdovecot at smail.inf.fh-brs.de
Mon Sep 22 12:02:53 EEST 2008


-----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-----


More information about the dovecot mailing list