From 976b3f3ccc91a944bdd3a25d4aa19d666fe12303 Mon Sep 17 00:00:00 2001 From: phil Date: Sat, 18 Mar 2017 13:37:07 +0100 Subject: [PATCH] Version 0.3.3 --- Changes | 18 +++++++ GpgEzmlm.pm | 49 ++++++++++++++++-- MANIFEST | 1 + META.yml | 10 ++++ README | 40 +++++++++++++++ gpg-ezmlm-convert.pl | 115 ++++++++++++++++++++++++++++++++++++++----- gpg-ezmlm-manage.pl | 47 +++++------------- gpg-ezmlm-send.pl | 15 +++--- 8 files changed, 239 insertions(+), 56 deletions(-) create mode 100644 META.yml create mode 100644 README diff --git a/Changes b/Changes index 1ffe506..1e08c00 100644 --- a/Changes +++ b/Changes @@ -23,3 +23,21 @@ Revision history for Perl extension gpg-ezmlm. - Fixed a bug in runcmd that caused the gpg-ezmlm to sometimes truncate some of the data sent in large messages. Cleaned the manifest. + +0.3.2 March 26, 2005 + - Added the Delivered-To line and any lines in the headeradd file + to outgoing mail. This more closely conforms with ezmlm + behavior. Thanks to Lars Kruse for the catch on the behavior + mismatch. + +0.3.3 April 20, 2005 + - Modified the copy routine to allow blank lines in the + headeradd file. Applied fixes from Elan Ruusamae to the + gpg-ezmlm-convert.pl program fixing typos and providing + helpful messages in case of incorrect usage. Added functionality + that I'd accidentally wiped from gpg-ezmlm-convert.pl before + I started using a sane version control system. Added additional + config parameters to the default config file. Fixed a bug + that would occur if gpg-ezmlm was installed before the + mailing list was used normally. + \ No newline at end of file diff --git a/GpgEzmlm.pm b/GpgEzmlm.pm index 1d68c85..977b82f 100644 --- a/GpgEzmlm.pm +++ b/GpgEzmlm.pm @@ -13,7 +13,8 @@ require Exporter; @EXPORT = qw( mydie - mail + copy + mail runcmd readConfig hashaddr @@ -24,7 +25,7 @@ require Exporter; reject ); -$VERSION = '0.3.1'; +$VERSION = '0.3.3'; =head1 NAME @@ -210,6 +211,41 @@ sub readConfig { } } +#copy takes a filename and a buffer, and appends the contents of that +#file to the buffer. These files are the messages that the mailing list +#sends back. If a line consists of a !R or !A, or contains the +#tags <#l#>, <#n#>, or <#h#>, then the contents of that line are replaced. + + +sub copy { + my $file = shift; + my $buffer = shift; + my $isHeader = shift; + my $configRef = shift; + my $confirm = shift; + my $target = shift; + my $outmsgnum = shift; + + open FILE, "<$file" or mydie(111, "unable to open $file: $!\n"); + + while (my $line = ) { + $line =~ s/^\!R/$confirm/; + $line =~ s/^\!A/$target/; + $line =~ s/<\#l\#>/$$configRef{outlocal}/; + $line =~ s/<\#h\#>/$$configRef{outhost}/; + $line =~ s/<\#n\#>/$outmsgnum/; + if($isHeader > 0) { + if($line =~ /\S+/) { + $$buffer .= $line; + } + } else { + $$buffer .= $line; + } + } + close(FILE); +} + + #runcmd - Runs a command, pushes all the input through it, and writes #to output and err. Select()s across reading and writing, for those #processes that can't hold all your input before they need to be read from @@ -303,7 +339,7 @@ sub runcmd { } } - # I know the below looks like an error, it should be + # I know the below looks like an error, that it should be # ($errDone and $readDone and $writeDone), but I've been testing this, # and the select never lets me through to pick the EOF off the READ # filehandle on gpg encrypts. If you know why, please enlighten me. @@ -623,6 +659,13 @@ sub prepare { } } my $mail; + + $mail .= $mydtline. "\n"; + + if (-r "headeradd") { + copy("headeradd", \$mail, 1, $configref); + } + foreach my $hline (@header) { $mail .= $hline; } diff --git a/MANIFEST b/MANIFEST index afedab8..ffcd26e 100644 --- a/MANIFEST +++ b/MANIFEST @@ -10,3 +10,4 @@ gpg-ezmlm-convert.pl gpg-ezmlm-manage.pl gpg-ezmlm-send.pl +META.yml Module meta-data (added by MakeMaker) diff --git a/META.yml b/META.yml new file mode 100644 index 0000000..3a005cf --- /dev/null +++ b/META.yml @@ -0,0 +1,10 @@ +# http://module-build.sourceforge.net/META-spec.html +#XXXXXXX This is a prototype!!! It will change in the future!!! XXXXX# +name: gpg-ezmlm +version: 0.3.3 +version_from: GpgEzmlm.pm +installdirs: site +requires: + +distribution_type: module +generated_by: ExtUtils::MakeMaker version 6.17 diff --git a/README b/README new file mode 100644 index 0000000..c911eef --- /dev/null +++ b/README @@ -0,0 +1,40 @@ +GpgEzmlm version 0.3.3 +====================== + +INSTALLATION + +To install this module type the following: + + perl Makefile.PL + make + make install + +To convert an existing ezmlm mailing list to a gpg-ezmlm mailing list, +run: + +gpg-ezmlm-convert.pl + +Where is the directory the current ezmlm list lives in, and + is in the form of ~/.qmail-mlname, for a mailing list named +mlname. Same as the dot that you used in ezmlm-make(1). Edit the +config file created in the directory to your preferences. + +To convert an existing gpg-ezmlm list to this version, just point the +dotfiles (.qmail- and .qmail--default) to the new +gpg-ezmlm-send.pl and gpg-ezmlm-manage.pl. If you want to change the +default configuration settings, a sample config file has been included, +edit to taste. + +DEPENDENCIES + +This suite requires these other modules, libraries, and tools: + +GnuPG ( http://www.gnupg.org ) +ezmlm ( http://cr.yp.to/ezmlm.html ) +qmail ( http://cr.yp.to/qmail.html ) +perl ( http://www.cpan.org ) +Digest::MD5 ( http://search.cpan.org/search?module=Digest::MD5 ) +File::Sync ( http://search.cpan.org/search?module=File::Sync ) + +Sorry about all the requirements. I did try to avoid Gnome syndrome... + diff --git a/gpg-ezmlm-convert.pl b/gpg-ezmlm-convert.pl index 4703d4d..c34a015 100755 --- a/gpg-ezmlm-convert.pl +++ b/gpg-ezmlm-convert.pl @@ -1,33 +1,74 @@ -#/usr/bin/perl -w +#!/usr/bin/perl -w #gpg-ezmlm-convert is a tool to convert a currently existing ezmlm #list into a gpg-ezmlm list, by replacing the appropriate lines, #creating the appropriate subdirs, and generating a list key for you. +use Config; use strict; -my $dir = shift; -my $dot = shift; +my $usage = "Usage: $0 +Where is the directory the current ezmlm list lives in, and is in +the form of ~/.qmail-mlname, for a mailing list named mlname. Same as the dot +that you used in ezmlm-make(1). Edit the config file created in the directory +to your preferences. + +To convert an existing gpg-ezmlm list to this version, just point the dotfiles +(.qmail- and .qmail--default) to the new gpg-ezmlm-send.pl and +gpg-ezmlm-manage.pl. If you want to change the default configuration settings, +a sample config file has been included, edit to taste. + +"; + +my $installbin = "$Config{installbin}"; + +my $dir = shift or die $usage; +my $dot = shift or die $usage; if (!(-d $dir)) { - die "No such directory $maildirlist\n"; + die "No such directory $dir\n"; } mkdir "$dir/.gnupg", 0700 or - die "Cannot make $maildirlist/.gnupg: $!\n"; + die "Cannot make $dir/.gnupg: $!\n"; mkdir "$dir/tmp", 0700 or - die "Cannot make $maildirlist/tmp: $!\n"; + die "Cannot make $dir/tmp: $!\n"; -open NEWSEND, ">$dot.n" or die "Cannot make temporary file $dot.n: $!\n"; -open NEWDEFAULT, ">$dot-default.n" or - die 'Cannot make temporary file $dot-default.n: $!\n"; +open NEWDOT, ">$dot.n" or die "Cannot make temporary file $dot.n: $!\n"; +open NEWDEFAULT, ">$dot-default.n" or + die "Cannot make temporary file $dot-default.n: $!\n"; +open DOT, "<$dot" or die "Cannot open $dot: $!\n"; +open DEFAULT, "<$dot-default" or die "Cannot open $dot-default: $!\n"; +while () { + my $line = $_; + if ($line =~ /ezmlm-send\s+(\S+)/) { + print NEWDOT "\|$installbin/gpg-ezmlm-send.pl $1\n"; + } else { + print NEWDOT $line; + } +} +close (DOT); +close (NEWDOT); +rename "$dot.n", "$dot" or die "Cannot move $dot.n to $dot: $!\n"; +while () { + my $line = $_; + if ($line =~ /ezmlm-manage\s+(\S+)/) { + print NEWDEFAULT "\|$installbin/gpg-ezmlm-manage.pl $1\n"; + } else { + print NEWDEFAULT $line; + } +} +close (DEFAULT); +close (NEWDEFAULT); +rename "$dot-default.n", "$dot-default" + or die "Cannot move $dot-default.n to $dot-default: $!\n"; open CONFIG, ">$dir/config" or die "Cannot open $dir/config: $!\n"; -print CONFIG << ENDCONFIG; +print CONFIG <; +if ($input =~ /y/i) { + system("gpg --homedir $dir/.gnupg --gen-key"); +} else { + print "OK, skipping key generation for now. Generate later with\n"; + print "gpg --homedir $dir/.gnupg --gen-key\n"; + exit(); +} + +open CONFIRM, "<$dir/text/sub-confirm" or + die "Cannot open $dir/text/sub-confirm: $!\n"; +open NEWCONFIRM, ">$dir/text/sub-confirm.n" or + die "Cannot open $dir/text/sub-confirm.n: $!\n"; + +my $line; +while(defined($line = )) { + if($line =~ /an empty reply/) { + $line =~ s/an empty reply/a reply with your\npublic key in the body/; + } + print NEWCONFIRM $line; +} +close(CONFIRM); +print NEWCONFIRM "The public key for this mailing list is contained below:\n"; +my $key = `gpg --homedir $dir/.gnupg --export -a`; +print NEWCONFIRM $key; +close(NEWCONFIRM); +rename "$dir/text/sub-confirm.n", "$dir/text/sub-confirm" + or die "Cannot move $dir/text/sub-confirm.n to $dir/text/sub-confirm: $!\n"; + + diff --git a/gpg-ezmlm-manage.pl b/gpg-ezmlm-manage.pl index 708dd33..61685e1 100755 --- a/gpg-ezmlm-manage.pl +++ b/gpg-ezmlm-manage.pl @@ -16,31 +16,6 @@ my %config = (); $ENV{PATH} = "/bin:/usr/bin"; $ENV{ENV} = ""; -#copy takes a filename and a buffer, and appends the contents of that -#file to the buffer. These files are the messages that the mailing list -#sends back. If a line consists of a !R or !A, then the contents of -#that line are replaced. - -sub copy { - my $file = shift; - my $buffer = shift; - my $confirm = shift; - my $target = shift; - - open FILE, "<$file" or mydie(111, "unable to open $file: $!\n"); - - while (my $line = ) { - if($line =~ /\!R/) { - $$buffer .= $confirm; - } elsif ($line =~ /\!A/) { - $$buffer .= $target; - } else { - $$buffer .= $line; - } - } - close(FILE); -} - #cookie generates a hash given a timestamp, a secret, etc. This infomation #is used to generate and check confirmation strings. This is _not_ the #same hash algorithm used by ezmlm, but since the strings are ephemeral, @@ -387,11 +362,11 @@ while () { $message .= $line; } } -copy("text/top", \$message, $confirm, $target); +copy("text/top", \$message, 0, \%config, $confirm, $target); if ($action =~ /^-subscribe$/) { - copy("text/sub-confirm", \$message, $confirm, $target); + copy("text/sub-confirm", \$message, 0, \%config, $confirm, $target); } elsif ($action =~ /^-unsubscribe$/) { - copy("text/unsub-confirm", \$message, $confirm, $target); + copy("text/unsub-confirm", \$message, 0, \%config, $confirm, $target); } elsif ($action =~ /^-sc\./) { if($flaghashok) { if($config{allowKeySubmission}) { @@ -399,28 +374,28 @@ if ($action =~ /^-subscribe$/) { } if (subscribe($target, 1) > 0) { maillog("+",$target); - copy("text/sub-ok", \$message, $confirm, $target); + copy("text/sub-ok", \$message, 0, \%config, $confirm, $target); } else { - copy("text/sub-nop", \$message, $confirm, $target); + copy("text/sub-nop", \$message, 0, \%config, $confirm, $target); } } else { - copy("text/sub-bad", \$message, $confirm, $target); + copy("text/sub-bad", \$message, 0, \%config, $confirm, $target); } } elsif ($action =~ /^-uc\./) { if($flaghashok) { if (subscribe($target, 0) > 0) { maillog("-", $target); - copy("text/unsub-ok", \$message, $confirm, $target); + copy("text/unsub-ok", \$message, 0, \%config, $confirm, $target); } else { - copy("text/unsub-nop", \$message, $confirm, $target); + copy("text/unsub-nop", \$message, 0, \%config, $confirm, $target); } } else { - copy("text/unsub-bad", \$message, $confirm, $target); + copy("text/unsub-bad", \$message, 0, \%config, $confirm, $target); } } else { - copy("text/help", \$message, $confirm, $target); + copy("text/help", \$message, 0, \%config, $confirm, $target); } -copy("text/bottom", \$message, $confirm, $target); +copy("text/bottom", \$message, 0, \%config, $confirm, $target); $message .= "Return-Path: <$sender>\n"; $message .= $messagecp; diff --git a/gpg-ezmlm-send.pl b/gpg-ezmlm-send.pl index 8ece8f9..608f54e 100755 --- a/gpg-ezmlm-send.pl +++ b/gpg-ezmlm-send.pl @@ -60,13 +60,16 @@ if($config{requireSub}) { } } -open NUM, "; -if($taintnum =~ /(\d+)/) { - $num = $1; +if(open NUM, "; + if($taintnum =~ /(\d+)/) { + $num = $1; + } + close(NUM); + $num++; +} else { + $num = 1; } -close(NUM); -$num++; if($config{archived}) { use integer;