From b4ee37b00ee7326b43c3f9ff1d502fbfc187653e Mon Sep 17 00:00:00 2001 From: lars Date: Tue, 10 Mar 2009 01:36:41 +0000 Subject: [PATCH] ezmlm-web code: * handle a missing backup conversion directory gracefully (useful for encrypted lists, that were created without ezmlm-web) --- Ezmlm/trunk/Ezmlm/GpgEzmlm.pm | 32 +++++++++++++++++++++++++++----- 1 file changed, 27 insertions(+), 5 deletions(-) diff --git a/Ezmlm/trunk/Ezmlm/GpgEzmlm.pm b/Ezmlm/trunk/Ezmlm/GpgEzmlm.pm index 1540ad8..ac70516 100644 --- a/Ezmlm/trunk/Ezmlm/GpgEzmlm.pm +++ b/Ezmlm/trunk/Ezmlm/GpgEzmlm.pm @@ -614,6 +614,7 @@ sub _is_encrypted { # 1) as part of the plaintext->encryption conversion of a list # 2) after calling ezmlm-make for an encrypted list (since the dotqmail files # are overwritten by ezmlm-make) +# This function may safely assume, that the backup_dir exists already. sub _cleanup_dotqmail_files { my $list_dir = shift; my ($backup_dir, $dot_loc, $dot_prefix); @@ -745,11 +746,25 @@ sub _enable_encryption_config_file { } # store the current original config file - if ((-e "$list_dir/config") && (!File::Copy::copy("$list_dir/config", - "$backup_dir/config.original"))) { - warn "[GpgEzmlm] failed to save the current ezmlm-idx config file ('" - . "$list_dir/config') to '$backup_dir/config.original': $!"; - return undef; + if (-e "$list_dir/config") { + if ((! -d $backup_dir) && !mkdir($backup_dir)) { + warn "[GpgEzmlm] failed to create gpg-ezmlm conversion " + . "backup dir ($backup_dir): $!"; + return undef; + } + if (!File::Copy::copy("$list_dir/config", + "$backup_dir/config.original")) { + warn "[GpgEzmlm] failed to save the current ezmlm-idx " + . "config file ('$list_dir/config') to " + . "'$backup_dir/config.original': $!"; + return undef; + { + } else { + # the current config file is missing - but we need to restore + # the original anyway. + # This should not happen. + warn "[GpgEzmlm] the original config file ('$list_dir/config') " + . "is missing - continuing anyway."; } # copy the encryption config file to the list directory @@ -778,6 +793,13 @@ sub _enable_plaintext_config_file { return undef; } + # create the encryption backup dir if necessary + if ((! -e $backup_dir) && (!mkdir($backup_dir))) { + warn "[GpgEzmlm] failed to create gpg-ezmlm conversion backup dir (" + . "$backup_dir): $!"; + return undef; + } + # store the current gpg-ezmlm config file unless (File::Copy::copy("$list_dir/config", "$backup_dir/config.gpg-ezmlm")) {