module Mail::Ezmlm::GpgEzmlm:
* fix syntax problems * fix regex for detecting settings * fix handling of GnuPG setting * allow string settings (GnuPG and keyDir)
This commit is contained in:
parent
cae467c8f1
commit
5f9454f970
1 changed files with 33 additions and 16 deletions
|
@ -28,7 +28,7 @@ package Mail::Ezmlm::GpgEzmlm;
|
||||||
use strict;
|
use strict;
|
||||||
use warnings;
|
use warnings;
|
||||||
use diagnostics;
|
use diagnostics;
|
||||||
use vars qw($GPG_EZMLM_BASE $VERSION @ISA @EXPORT @EXPORT_OK);
|
use vars qw($GPG_EZMLM_BASE $GPG_BIN $VERSION @ISA @EXPORT @EXPORT_OK);
|
||||||
use File::Copy;
|
use File::Copy;
|
||||||
use Carp;
|
use Carp;
|
||||||
|
|
||||||
|
@ -65,7 +65,7 @@ The Mail::Ezmlm::GpgEzmlm class is inherited from the Mail::Ezmlm class.
|
||||||
|
|
||||||
# == Begin site dependant variables ==
|
# == Begin site dependant variables ==
|
||||||
$GPG_EZMLM_BASE = '/usr/bin'; # Autoinserted by Makefile.PL
|
$GPG_EZMLM_BASE = '/usr/bin'; # Autoinserted by Makefile.PL
|
||||||
$GPG_BIN = '/usr/bin/gpg' # Autoinserted by Makefile.PL
|
$GPG_BIN = '/usr/bin/gpg'; # Autoinserted by Makefile.PL
|
||||||
|
|
||||||
# == clean up the path for taint checking ==
|
# == clean up the path for taint checking ==
|
||||||
local $ENV{PATH};
|
local $ENV{PATH};
|
||||||
|
@ -102,7 +102,7 @@ sub new {
|
||||||
bless $self, ref $class || $class || 'Mail::Ezmlm::GpgEzmlm';
|
bless $self, ref $class || $class || 'Mail::Ezmlm::GpgEzmlm';
|
||||||
# define the available (supported) options for gpg-ezmlm ==
|
# define the available (supported) options for gpg-ezmlm ==
|
||||||
@{$self->{SUPPORTED_OPTIONS}} = (
|
@{$self->{SUPPORTED_OPTIONS}} = (
|
||||||
"GnupG",
|
"GnuPG",
|
||||||
"KeyDir",
|
"KeyDir",
|
||||||
"RequireSub",
|
"RequireSub",
|
||||||
"RequireSigs",
|
"RequireSigs",
|
||||||
|
@ -332,7 +332,7 @@ sub update {
|
||||||
# "repair" the dotqmail files (use "gpg-ezmlm-send" instead of "ezmlm-send")
|
# "repair" the dotqmail files (use "gpg-ezmlm-send" instead of "ezmlm-send")
|
||||||
&_cleanup_dotqmail_files($self->thislist());
|
&_cleanup_dotqmail_files($self->thislist());
|
||||||
|
|
||||||
return the result of the ezmlm-make run
|
# return the result of the ezmlm-make run
|
||||||
return $result;
|
return $result;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -356,11 +356,6 @@ sub update_special {
|
||||||
return undef;
|
return undef;
|
||||||
}
|
}
|
||||||
|
|
||||||
# always set the default value for the "gpg" setting explicitely - otherwise
|
|
||||||
# gpg-ezmlm breaks on most systems (its default location is
|
|
||||||
# /usr/local/bin/gpg)
|
|
||||||
$ok_switches{GnuPG} = $GPG_BIN;
|
|
||||||
|
|
||||||
@delete_switches = ();
|
@delete_switches = ();
|
||||||
# check if all supplied settings are supported
|
# check if all supplied settings are supported
|
||||||
# btw we change the case (upper/lower) of the setting to the default one
|
# btw we change the case (upper/lower) of the setting to the default one
|
||||||
|
@ -391,19 +386,19 @@ sub update_special {
|
||||||
my $errorstring;
|
my $errorstring;
|
||||||
my $config_file_old = $self->thislist() . "/config";
|
my $config_file_old = $self->thislist() . "/config";
|
||||||
my $config_file_new = $self->thislist() . "/config.new";
|
my $config_file_new = $self->thislist() . "/config.new";
|
||||||
|
my $gnupg_setting_found = (0==1);
|
||||||
if (open(CONFIG_OLD, "<$config_file_old")) {
|
if (open(CONFIG_OLD, "<$config_file_old")) {
|
||||||
if (open(CONFIG_NEW, ">$config_file_new")) {
|
if (open(CONFIG_NEW, ">$config_file_new")) {
|
||||||
my ($in_line, $one_opt, $one_val, $new_setting);
|
my ($in_line, $one_opt, $one_val, $new_setting);
|
||||||
while (<CONFIG_OLD>) {
|
while (<CONFIG_OLD>) {
|
||||||
$in_line = $_;
|
$in_line = $_;
|
||||||
|
$gnupg_setting_found = (0==0) if ($in_line =~ m/^\s*GnuPG\s+/i);
|
||||||
if (%ok_switches) {
|
if (%ok_switches) {
|
||||||
my $found = 0;
|
my $found = 0;
|
||||||
while (($one_opt, $one_val) = each(%ok_switches)) {
|
while (($one_opt, $one_val) = each(%ok_switches)) {
|
||||||
# is this the right line (maybe commented out)?
|
# is this the right line (maybe commented out)?
|
||||||
if ($in_line =~ m/^#?\w*$one_opt/i) {
|
if ($in_line =~ m/^#?\s*$one_opt\s+/i) {
|
||||||
print CONFIG_NEW "$one_opt ";
|
print CONFIG_NEW _get_config_line($one_opt, $one_val);
|
||||||
print CONFIG_NEW ($one_val)? "yes" : "no";
|
|
||||||
print CONFIG_NEW "\n";
|
|
||||||
delete $ok_switches{$one_opt};
|
delete $ok_switches{$one_opt};
|
||||||
$found = 1;
|
$found = 1;
|
||||||
}
|
}
|
||||||
|
@ -416,9 +411,13 @@ sub update_special {
|
||||||
}
|
}
|
||||||
# write the remaining settings to the end of the file
|
# write the remaining settings to the end of the file
|
||||||
while (($one_opt, $one_val) = each(%ok_switches)) {
|
while (($one_opt, $one_val) = each(%ok_switches)) {
|
||||||
print CONFIG_NEW "\n$one_opt ";
|
print CONFIG_NEW _get_config_line($one_opt, $one_val);
|
||||||
print CONFIG_NEW ($one_val)? "yes" : "no";
|
}
|
||||||
print CONFIG_NEW "\n";
|
# always set the default value for the "gpg" setting explicitely,
|
||||||
|
# if it was not overriden - otherwise gpg-ezmlm breaks on most
|
||||||
|
# systems (its default location is /usr/local/bin/gpg)
|
||||||
|
unless ($gnupg_setting_found) {
|
||||||
|
print CONFIG_NEW _get_config_line("GnuPG", $GPG_BIN);
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
$errorstring = "failed to write to temporary config file: $config_file_new";
|
$errorstring = "failed to write to temporary config file: $config_file_new";
|
||||||
|
@ -447,6 +446,24 @@ sub update_special {
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
# return the configuration file string for a key/value combination
|
||||||
|
sub _get_config_line {
|
||||||
|
my $key = shift;
|
||||||
|
my $value = shift;
|
||||||
|
|
||||||
|
my $result = "$key ";
|
||||||
|
if (($key eq "GnuPG") || ($key eq "keyDir")) {
|
||||||
|
# these are the only settings with string values
|
||||||
|
# escape special characters
|
||||||
|
$value =~ s/[^\w\.\/\-]/_/g;
|
||||||
|
$result .= $value;
|
||||||
|
} else {
|
||||||
|
$result .= ($value)? "yes" : "no";
|
||||||
|
}
|
||||||
|
$result .= "\n";
|
||||||
|
return $result;
|
||||||
|
}
|
||||||
|
|
||||||
# == Get a list of options for the current list ==
|
# == Get a list of options for the current list ==
|
||||||
|
|
||||||
=head2 Getting the current configuration of the current list:
|
=head2 Getting the current configuration of the current list:
|
||||||
|
|
Loading…
Reference in a new issue