181 lines
5.8 KiB
Perl
Executable file
181 lines
5.8 KiB
Perl
Executable file
#!/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 $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 $dir\n";
|
|
}
|
|
|
|
mkdir "$dir/.gnupg", 0700 or
|
|
die "Cannot make $dir/.gnupg: $!\n";
|
|
|
|
mkdir "$dir/tmp", 0700 or
|
|
die "Cannot make $dir/tmp: $!\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;
|
|
#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,
|
|
#and set the option appropriately. Most options take either yes or no
|
|
#as options. Options are case insensitive.
|
|
|
|
#GnuPG is the location of your gpg executable
|
|
#
|
|
# GnuPG /usr/local/bin/gpg
|
|
|
|
#qmailBin is where all of your qmail executables are located
|
|
#
|
|
# qmailBin /var/qmail/bin
|
|
|
|
#keyDir is the location of the keyring for this particular mailing
|
|
#list. gpg-ezmlm supports a separate keyring for each ml, or you
|
|
#can cram them all together if you like by setting the below
|
|
#
|
|
# keyDir .gnupg
|
|
|
|
#tempDir is the location of the purgatory keyrings where submitted keys
|
|
#are stored before they are added to the main mailing list keyring.
|
|
#You should probably not have a reason to change this.
|
|
#
|
|
# tempDir tmp
|
|
|
|
#signMessages controls whether gpg-ezmlm signs outgoing messages
|
|
#or not. If this is not set, messages may be spoofed as if they
|
|
#were from the mailing list
|
|
#
|
|
# signMessages yes
|
|
|
|
#If requireSigs is set to yes, then only messages with a valid, trusted
|
|
#signature will be forwarded to the rest of the group.
|
|
#
|
|
# requireSigs no
|
|
|
|
#Setting NokeyNocrypt to yes will forward the encrypted portions of
|
|
#messages unencrypted to recipients for whom gpg-ezmlm does not
|
|
#possess a key. By default, those recipients will instead receive
|
|
#a message stating "encrypted content not forwarded because I
|
|
#don't have a key for you."
|
|
#
|
|
# NokeyNocrypt no
|
|
|
|
#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
|
|
|
|
#RequireSub, if set to yes, will require that the sender of a message
|
|
#be a subscriber to the email list that he is attempting to post
|
|
#messages to. Senders who are not subscribed to the list will
|
|
#have their submissions rejected automatically.
|
|
#
|
|
# 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";
|
|
|
|
|