Package: maildirsync
Version: 1.2-1.1
Severity: important
Tags: upstream patch


As showed in the sample.sh script, maildirsync need a full (bi-directional) synchronization whenever the local state file has changed. This is needed in order to keep the state files on the two hosts synchronized.

As a new state file is written at any run, the mtime/ctime/inode of the state file cannot be used for determining if the content has changed. The sample.sh script uses the md5 hash of the file for that aim.

Both because it's very often used for similar needs, and because of its inclusion in the sample script, it's likely almost all the users of maildirsync adopted the same solution.

Perl 5.18 anyway introduced a full hash randomization, meaning it's very unlikely two runs of maildirsync produces the same state file content even when no change has been performed on the file-system.

This patch sorts the hash keys when saving the new state file in order to produce reproducible content (and, consequently, permitting md5 hashes comparisons).

-- System Information:
Debian Release: jessie/sid
  APT prefers unstable
  APT policy: (500, 'unstable'), (1, 'experimental')
Architecture: amd64 (x86_64)

Kernel: Linux 3.10-2-amd64 (SMP w/2 CPU cores)
Locale: LANG=en_US.UTF-8, LC_CTYPE=en_US.UTF-8 (charmap=UTF-8)
Shell: /bin/sh linked to /bin/dash

Versions of packages maildirsync depends on:
ii  perl  5.18.1-3

Versions of packages maildirsync recommends:
ii  openssh-client [rsh-client]  1:6.2p2-6

Versions of packages maildirsync suggests:
ii  bzip2  1.0.6-5

-- no debconf information
Mon Sep  2 23:20:48 CEST 2013  Gian Piero Carrubba <gpi...@rm-rf.it>
  * Compatibility fix for Perl 5.18
  
  As showed in the sample.sh script, maildirsync need a full (bi-directional)
  synchronization whenever the local state file has changed. This is needed in
  order to keep the state files on the two hosts synchronized.
  
  As a new state file is written at any run, the mtime/ctime/inode of the state
  file cannot be used for determining if the content has changed.  The sample.sh
  script uses the md5 hash of the file for that aim.
  Both because it's very often used for similar needs, and because of its
  inclusion in the sample script, it's likely almost all the users of maildirsync
  adopted the same solution.
  
  Perl 5.18 anyway introduced a full hash randomization, meaning it's very
  unlikely two runs of maildirsync produces the same state file content even when
  no change has been performed on the file-system.
  
  This patch sorts the hash keys when saving the new state file in order to
  produce reproducible content (and, consequently, permitting md5 hashes
  comparisons).
  
diff -rN -u old-maildirsync-1.2/maildirsync.pl new-maildirsync-1.2/maildirsync.pl
--- old-maildirsync-1.2/maildirsync.pl	2013-09-02 23:21:05.266498292 +0200
+++ new-maildirsync-1.2/maildirsync.pl	2013-09-02 23:21:05.266498292 +0200
@@ -403,7 +403,7 @@
     exit_with_error("Cannot open temporary state file for writing: $newfilename") if !$FH;
     print $FH $STATE_FILE_FIRST_LINE;
     print $FH join("\t",$_, $statedata->[ID]->{$_}, ($statedata->[IDSTORE]->{$_} || ""))."\n"
-        foreach keys %{$statedata->[ID]};
+        foreach sort keys %{$statedata->[ID]};
     close $FH;
     chmod $listfile_perms, $newfilename
         or exit_with_error("Cannot chmod temporary state file: $!");

Reply via email to