Version 0.3.3

This commit is contained in:
phil 2017-03-18 13:37:07 +01:00
parent 561cfd3f85
commit 976b3f3ccc
8 changed files with 239 additions and 56 deletions

18
Changes
View File

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

View File

@ -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 = <FILE>) {
$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;
}

View File

@ -10,3 +10,4 @@ gpg-ezmlm-convert.pl
gpg-ezmlm-manage.pl
gpg-ezmlm-send.pl
META.yml Module meta-data (added by MakeMaker)

10
META.yml Normal file
View File

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

40
README Normal file
View File

@ -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 <dir> <dot>
Where <dir> is the directory the current ezmlm list lives in, and
<dot> 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-<list> and .qmail-<list>-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...

View File

@ -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 <dir> <dot>
Where <dir> is the directory the current ezmlm list lives in, and <dot> 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-<list> and .qmail-<list>-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 (<DOT>) {
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 (<DEFAULT>) {
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 <<ENDCONFIG;
#This is the configuration file for gpg-ezmlm. The file as distributed
#with the package contains all options set to their default values,
#and commented out. To change these options, uncomment the line,
@ -73,7 +114,25 @@ print CONFIG << ENDCONFIG;
#
# NokeyNocrypt no
#VerifiedKeyReq requies that all keys that are used be trusted keys.
#setting allowKeySubmission to yes permits users to automatically
#submit keys during the subscription confirmation email. Only
#keys corresponding to the email address that is being subscribed
#will be accepted. Setting this to no effectively requires the list
#admin to manage all keys themselves.
#
# allowKeySubmission yes
#encryptToAll controls whether gpg-ezmlm will encrypt a message
#once, to all subscriber keys, and send that message to all users,
#or encrypt each subscriber's message to them individually. The
#default is to individually encrypt. This means that subscribers
#on the list cannot see who else is on the list by looking at
#the keyIDs the message is encrypted to, but it takes more CPU
#time.
#
# encryptToAll no
#VerifiedKeyReq requires that all keys that are used be trusted keys.
#An untrusted key is treated the same as no key at all.
#
# VerifiedKeyReq no
@ -86,3 +145,37 @@ print CONFIG << ENDCONFIG;
# RequireSub no
ENDCONFIG
close(CONFIG);
print "It is recommended that you generate a mailing list key.\n";
print "YOU MUST LEAVE THE PASSPHRASE BLANK!\n";
print "Would you like to generate this key now? [y/n]\n";
my $input = <>;
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 = <CONFIRM>)) {
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";

View File

@ -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 = <FILE>) {
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 (<STDIN>) {
$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;

View File

@ -60,13 +60,16 @@ if($config{requireSub}) {
}
}
open NUM, "<num" or mydie(111, "unable to open $dir/num: $!\n");
my $taintnum = <NUM>;
if($taintnum =~ /(\d+)/) {
$num = $1;
if(open NUM, "<num") {
my $taintnum = <NUM>;
if($taintnum =~ /(\d+)/) {
$num = $1;
}
close(NUM);
$num++;
} else {
$num = 1;
}
close(NUM);
$num++;
if($config{archived}) {
use integer;