Skip to content

Commit

Permalink
Merge branch 'master' of [email protected]:virtualmin/virtualmin-mailman
Browse files Browse the repository at this point in the history
  • Loading branch information
jcameron committed Feb 4, 2018
2 parents 3a73dfd + 74fadb9 commit 6377ea5
Show file tree
Hide file tree
Showing 5 changed files with 56 additions and 22 deletions.
4 changes: 4 additions & 0 deletions .travis.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
before_install:
- sudo apt-get update -qq
- sudo apt-get install -qq perl libtest-strict-perl
script: prove
5 changes: 5 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
[![Build Status](https://travis-ci.org/virtualmin/virtualmin-mailman.svg?branch=master)](https://travis-ci.org/virtualmin/virtualmin-mailman)

# virtualmin-mailman

Virtualmin plugin to allow domain owners to manage mailman mailing lists
6 changes: 6 additions & 0 deletions t/all_ok.t
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
#!/usr/bin/env perl
use strict;
use warnings;
use Test::Strict 'no_plan';

all_perl_files_ok();
44 changes: 28 additions & 16 deletions unauthenticated/admin.cgi
Original file line number Diff line number Diff line change
@@ -1,10 +1,18 @@
#!/usr/local/bin/perl
# Run a mailman CGI program, and display output ONLY
use strict;
use warnings;

# Globals
our ($trust_unknown_referers, $module_name);
our (%config, %text);
our $mailman_dir;

chdir(".."); # Cause we are in a sub-directory
delete($ENV{'HTTP_REFERER'}); # So that links from webmail work
$trust_unknown_referers = 1;
require './virtualmin-mailman-lib.pl';
my $lname;
if ($ENV{'PATH_INFO'} =~ /^\/([^\/]+)(.*)/) {
$lname = $1;
}
Expand All @@ -15,14 +23,15 @@ elsif ($ENV{'PATH_INFO'} eq '' || $ENV{'PATH_INFO'} eq '/') {
else {
&error($text{'edit_eurl'});
}
$prog = $ENV{'SCRIPT_NAME'};
my $prog = $ENV{'SCRIPT_NAME'};
$prog =~ s/^.*\///;
$prog =~ s/\.cgi$//;

@lists = &list_lists();
my @lists = &list_lists();
my ($d, $dname);
if ($lname) {
# Get the list, and from it the domain
($list) = grep { $_->{'list'} eq $lname } @lists;
my ($list) = grep { $_->{'list'} eq $lname } @lists;
$list && &can_edit_list($list) || &error($text{'edit_ecannot'});
$list->{'dom'} || &error(&text('edit_edmailman2', $lname));
$d = &virtual_server::get_domain_by("dom", $list->{'dom'});
Expand All @@ -40,7 +49,8 @@ else {
$d || &error(&text('edit_edname', &html_escape($dname)));
$d->{$module_name} || &error(&text('edit_edmailman', $dname));

$cgiuser = &get_mailman_apache_user($d);
my $cgiuser = &get_mailman_apache_user($d);
my ($httphost, $httpport, $httppage, $httpssl, $prot);
if ($config{'rewriteurl'}) {
# Custom URL for Mailman, perhaps if behind proxy
($httphost, $httpport, $httppage, $httpssl) =
Expand All @@ -59,25 +69,27 @@ else {
}

# Work out possible hostnames for URLs
@realhosts = ( &get_system_hostname(),
my @realhosts = ( &get_system_hostname(),
$httphost,
(map { $_->{'dom'} } grep { $_->{$module_name} }
&virtual_server::list_domains()) );

$temp = &transname();
open(TEMP, ">$temp");
my $temp = &transname();
my $qs;
open(my $TEMP, ">", $temp);
if (defined(&read_fully)) {
&read_fully(STDIN, \$qs, $ENV{'CONTENT_LENGTH'});
&read_fully(*STDIN, \$qs, $ENV{'CONTENT_LENGTH'});
}
else {
read(STDIN, $qs, $ENV{'CONTENT_LENGTH'});
}
print TEMP $qs;
close(TEMP);
$cmd = &command_as_user($cgiuser, 0, "$mailman_dir/cgi-bin/$prog");
$textarea = 0;
open(CGI, "$cmd <$temp |");
while(<CGI>) {
print $TEMP $qs;
close($TEMP);
my $cmd = &command_as_user($cgiuser, 0, "$mailman_dir/cgi-bin/$prog");
my $textarea = 0;
my ($headers, $doneheaders, $body);
open(my $CGI, "$cmd <$temp |");
while(<$CGI>) {
# Check if we are in a textarea
if (/<textarea/i) { $textarea = 1; }
if (/<\/textarea/i) { $textarea = 0; }
Expand All @@ -88,7 +100,7 @@ while(<CGI>) {
s/\/(cgi-bin\/)?mailman\/([^\/ "']+)\.cgi/\/$module_name\/unauthenticated\/$2.cgi/g || s/\/(cgi-bin\/)?mailman\/([^\/ "']+)([\/ "'])/\/$module_name\/unauthenticated\/$2.cgi$3/g;
}
if (!/pipermail/) {
foreach $realhost (@realhosts) {
foreach my $realhost (@realhosts) {
s/(http|https):\/\/$realhost\//$prot:\/\/$httphost\//g && last;
}
s/(http|https):\/\/(lists\.)?$d->{'dom'}\//$prot:\/\/$httphost\//g;
Expand All @@ -108,7 +120,7 @@ while(<CGI>) {
$body .= $_;
}
}
close(CGI);
close($CGI);

print $headers;
print "\n";
Expand Down
19 changes: 13 additions & 6 deletions unauthenticated/icons.cgi
Original file line number Diff line number Diff line change
@@ -1,27 +1,34 @@
#!/usr/local/bin/perl
# Output some mailman icon
use strict;
use warnings;

# Global
our %text;
our $trust_unknown_referers;
our $icons_dir;

chdir("..");
delete($ENV{'HTTP_REFERER'}); # So that links from webmail work
$trust_unknown_referers = 1;
require './virtualmin-mailman-lib.pl';
$ENV{'PATH_INFO'} =~ /^\/(.*)/ ||
&error($text{'edit_eurl'});
$icon = $1;
my $icon = $1;
if ($icon =~ /\.\./ || $icon =~ /\0/) {
&error($text{'edit_eurl'});
}

$type = &guess_mime_type("$icons_dir/$icon");
@st = stat("$icons_dir/$icon");
my $type = &guess_mime_type("$icons_dir/$icon");
my @st = stat("$icons_dir/$icon");
print "Content-type: $type\n";
print "Content-length: ",$st[7],"\n";
print "Last-Modified: ",&http_date($st[9]),"\n";
print "Expires: ",&http_date(time()+7*24*60*60),"\n";
print "\n";
open(ICON, "$icons_dir/$icon");
while(<ICON>) {
open(my $ICON, "$icons_dir/$icon");
while(<$ICON>) {
print $_;
}
close(ICON);
close($ICON);

0 comments on commit 6377ea5

Please sign in to comment.