Ezmlm.pm

filter: Statementstmt 6.1% 28 / 455 Branchbran 1.7% 6 / 352 Conditioncond 0.0% 0 / 341 MC/DCmcdc 0.0% 0 / 154 Subroutinesub 8.7% 4 / 46 Podpod 11.1% 4 / 36 totaltotal 3.0% 42 / 1384 CC 270 SCAR 55.1
CC
270
Cov
3%
_getconfigmanual
812.0
make
462.0
update
462.0
CRAP 246.8
↑ Summary Ezmlm/GpgEzmlm.pm »
1 # ===========================================================================
2 # Ezmlm.pm - version 0.08.2 - 10/15/2008
3 # $Id: Ezmlm.pm 453 2008-10-16 01:22:44Z lars $
4 #
5 # Object methods for ezmlm mailing lists
6 #
7 # Copyright (C) 1999-2005, Guy Antony Halse, All Rights Reserved.
8 # Copyright (C) 2005-2008, Lars Kruse, All Rights Reserved.
9 # Please send bug reports and comments to ezmlm-web@sumpfralle.de.
10 #
11 # Redistribution and use in source and binary forms, with or without
12 # modification, are permitted provided that the following conditions are
13 # met:
14 #
15 # Redistributions of source code must retain the above copyright notice,
16 # this list of conditions and the following disclaimer.
17 #
18 # Redistributions in binary form must reproduce the above copyright notice,
19 # this list of conditions and the following disclaimer in the documentation
20 # and/or other materials provided with the distribution.
21 #
22 # Neither name Guy Antony Halse nor the names of any contributors
23 # may be used to endorse or promote products derived from this software
24 # without specific prior written permission.
25 #
26 # THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS ``AS
27 # IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
28 # THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
29 # PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE
30 # LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
31 # CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
32 # SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
33 # INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
34 # CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
35 # ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
36 # POSSIBILITY OF SUCH DAMAGE.
37 #
38 # ==========================================================================
39 # POD is at the end of this file. Search for '=head' to find it
40 package Mail::Ezmlm;
41  
42 1 ▶use strict;
Subroutine BEGIN: called CC=1 SCAR=0.0
43 1 ▶use vars qw($QMAIL_BASE $EZMLM_BASE $MYSQL_BASE $VERSION @ISA @EXPORT @EXPORT_OK);
Subroutine BEGIN: called CC=1 SCAR=0.0
44 1 ▶use Carp;
Subroutine BEGIN: called CC=1 SCAR=0.0
45 1 ▶use Text::ParseWords;
Subroutine BEGIN: called CC=1 SCAR=0.0
46  
47 1 require Exporter;
48  
49 1 @ISA = qw(Exporter);
50 # Items to export into callers namespace by default. Note: do not export
51 # names by default without a very good reason. Use EXPORT_OK instead.
52 # Do not simply export all your public functions/methods/constants.
53 1 @EXPORT = qw(
54
55 );
56 1 $VERSION = '0.08.2';
57  
58 1 require 5.005;
59  
60 # == Begin site dependant variables ==
61 1 $EZMLM_BASE = '/usr/local/bin/ezmlm'; #Autoinserted by Makefile.PL
62 1 $QMAIL_BASE = '/var/qmail'; #Autoinserted by Makefile.PL
63 1 $MYSQL_BASE = ''; #Autoinserted by Makefile.PL
64 # == End site dependant variables ==
65  
66 # == check the ezmlm-make path ==
67 1 ▶$EZMLM_BASE = '/usr/local/bin/ezmlm' unless (-e "$EZMLM_BASE/ezmlm-make");
Branch: 1 branch
BranchTrueFalseTotal
unless -e "$Mail::Ezmlm::EZMLM_BASE/ezmlm-make" 1 0 1
68 1 ▶$EZMLM_BASE = '/usr/local/bin/ezmlm-idx' unless (-e "$EZMLM_BASE/ezmlm-make");
Branch: 1 branch
BranchTrueFalseTotal
unless -e "$Mail::Ezmlm::EZMLM_BASE/ezmlm-make" 1 0 1
69 1 ▶$EZMLM_BASE = '/usr/local/bin' unless (-e "$EZMLM_BASE/ezmlm-make");
Branch: 1 branch
BranchTrueFalseTotal
unless -e "$Mail::Ezmlm::EZMLM_BASE/ezmlm-make" 1 0 1
70 1 ▶$EZMLM_BASE = '/usr/bin/ezmlm' unless (-e "$EZMLM_BASE/ezmlm-make");
Branch: 1 branch
BranchTrueFalseTotal
unless -e "$Mail::Ezmlm::EZMLM_BASE/ezmlm-make" 1 0 1
71 1 ▶$EZMLM_BASE = '/usr/bin/ezmlm-idx' unless (-e "$EZMLM_BASE/ezmlm-make");
Branch: 1 branch
BranchTrueFalseTotal
unless -e "$Mail::Ezmlm::EZMLM_BASE/ezmlm-make" 1 0 1
72 1 ▶$EZMLM_BASE = '/usr/bin' unless (-e "$EZMLM_BASE/ezmlm-make");
Branch: 1 branch
BranchTrueFalseTotal
unless -e "$Mail::Ezmlm::EZMLM_BASE/ezmlm-make" 1 0 1
73  
74 # == clean up the path for taint checking ==
75 1 local $ENV{'PATH'} = $EZMLM_BASE;
76  
77 # == Initialiser - Returns a reference to the object ==
78 0 ▶sub new {
Subroutine new: not called CC=5 SCAR=34.0
Pod documented
79 0 my($class, $list) = @_;
80 0 my $self = {};
81 0 ▶ bless $self, ref $class || $class || 'Mail::Ezmlm';
Condition0%0/5
ref $class || $class || 'Mail::Ezmlm'
l!l
00
ref $class or $class
l!l&&r!l&&!r
000
MC/DC0%0/2
ref $class || $class || 'Mail::Ezmlm'
ref $class $class
Truth table0%0/3
A or B
A= ref $classB= $class
ABresult
1X1
011
000
82 0 ▶ $self->setlist($list) if(defined($list) && $list);
Branch: 1 branch
BranchTrueFalseTotal
if defined $list and $list 0 0 0
Condition0%0/3
defined $list and $list
!ll&&!rl&&r
000
MC/DC0%0/2
defined $list and $list
defined $list $list
Truth table0%0/3
A and B
A= defined $listB= $list
ABresult
0X0
100
111
83 0 return $self;
84 }
85  
86 # == Make a new mailing list and set it to current ==
87 0 ▶sub make {
Subroutine make: not called CC=21 SCAR=61.4
Pod documented
88 0 my($self, %list) = @_;
89 0 my($VHOST, $comandline, $hostname);
90  
91 # Do we want to use command line switches
92 0 my $commandline = '';
93 0 ▶ $commandline = '-' . $list{'-switches'} if(defined($list{'-switches'}));
Branch: 1 branch
BranchTrueFalseTotal
if defined $list{"-switches"} 0 0 0
94 0 my @commandline;
95 0 foreach (&quotewords('\s+', 1, $commandline)) {
96 0 ▶ next if (!defined($_));
Branch: 1 branch
BranchTrueFalseTotal
unless defined $_ 0 0 0
97 # untaint input
98 0 $_ =~ s/['"]//g;
99 0 $_ =~ m/^([\w _\/,\.\@:'"-]*)$/;
100 0 ▶ if ($_ =~ /^\s*$/) {
Branch: 1 branch
BranchTrueFalseTotal
if ($_ =~ /^\s*$/) { } 0 0 0
101 0 push @commandline, "";
102 } else {
103 0 push @commandline, $1;
104 }
105 }
106  
107 # These three variables are essential
108 0 ▶ ($self->_seterror(-1, 'must define -dir in a make()') && return 0) unless(defined($list{'-dir'}));
Branch: 1 branch
BranchTrueFalseTotal
unless defined $list{"-dir"} 0 0 0
Condition0%0/5
defined $list{'-dir'} || $self->_seterror(-1, 'must define -dir in a make()') && (return 0)
l!l&&r!l&&!r
000
$self->_seterror(-1, "must define -dir in a make()") and return 0
!ll
00
MC/DC0%0/2
defined $list{'-dir'} || $self->_seterror(-1, 'must define -dir in a make()') && (return 0)
defined $list{'-dir'} $self->_seterror(-1, "must define -dir in a make()")
Truth table0%0/3
A || B
A= defined $list{'-dir'}B= $self->_seterror(-1, "must define -dir in a make()")
ABresult
1X1
011
000
109 0 ▶ ($self->_seterror(-1, 'must define -qmail in a make()') && return 0) unless(defined($list{'-qmail'}));
Branch: 1 branch
BranchTrueFalseTotal
unless defined $list{"-qmail"} 0 0 0
Condition0%0/5
defined $list{'-qmail'} || $self->_seterror(-1, 'must define -qmail in a make()') && (return 0)
l!l&&r!l&&!r
000
$self->_seterror(-1, "must define -qmail in a make()") and return 0
!ll
00
MC/DC0%0/2
defined $list{'-qmail'} || $self->_seterror(-1, 'must define -qmail in a make()') && (return 0)
defined $list{'-qmail'} $self->_seterror(-1, "must define -qmail in a make()")
Truth table0%0/3
A || B
A= defined $list{'-qmail'}B= $self->_seterror(-1, "must define -qmail in a make()")
ABresult
1X1
011
000
110 0 ▶ ($self->_seterror(-1, 'must define -name in a make()') && return 0) unless(defined($list{'-name'}));
Branch: 1 branch
BranchTrueFalseTotal
unless defined $list{"-name"} 0 0 0
Condition0%0/5
defined $list{'-name'} || $self->_seterror(-1, 'must define -name in a make()') && (return 0)
l!l&&r!l&&!r
000
$self->_seterror(-1, "must define -name in a make()") and return 0
!ll
00
MC/DC0%0/2
defined $list{'-name'} || $self->_seterror(-1, 'must define -name in a make()') && (return 0)
defined $list{'-name'} $self->_seterror(-1, "must define -name in a make()")
Truth table0%0/3
A || B
A= defined $list{'-name'}B= $self->_seterror(-1, "must define -name in a make()")
ABresult
1X1
011
000
111  
112 # Determine hostname if it is not supplied
113 0 $hostname = $self->_getdefaultdomain;
114 0 ▶ if(defined($list{'-host'})) {
Branch: 1 branch
BranchTrueFalseTotal
if (defined $list{'-host'}) { } 0 0 0
115 0 ▶ $VHOST = 1 unless ($list{'-host'} eq $hostname);
Branch: 1 branch
BranchTrueFalseTotal
unless $list{"-host"} eq $hostname 0 0 0
116 } else {
117 0 $list{'-host'} = $hostname;
118 }
119  
120 # does the mailing list directory already exist?
121 0 ▶ if (-e $list{'-dir'}) {
Branch: 1 branch
BranchTrueFalseTotal
if (-e $list{"-dir"}) 0 0 0
122 $self->_seterror(-1,
123 0 '-the mailing list directory already exists: ' . $list{'-dir'});
124 0 return undef;
125 }
126  
127 # Attempt to make the list if we can.
128 0 ▶ if (system("$EZMLM_BASE/ezmlm-make", @commandline, $list{'-dir'}, $list{'-qmail'}, $list{'-name'}, $list{'-host'}) != 0) {
Branch: 1 branch
BranchTrueFalseTotal
if (system("$Mail::Ezmlm::EZMLM_BASE/ezmlm-make", @commandline, $list{"-dir"}, $list{"-qmail"}, $list{"-name"}, $list{"-host"}) != 0) 0 0 0
129 0 $self->_seterror($?, '-failed to create mailing list - check your webserver\'s log file for details');
130 0 return undef;
131 }
132  
133 # Sort out the DIR/inlocal problem if necessary
134 0 ▶ if(defined($VHOST)) {
Branch: 1 branch
BranchTrueFalseTotal
if (defined $VHOST) 0 0 0
135 0 ▶ unless(defined($list{'-user'})) {
Branch: 1 branch
BranchTrueFalseTotal
unless (defined $list{"-user"}) 0 0 0
136 0 ▶ ($self->_seterror(-1, '-user must match virtual host user in make()') && return 0) unless($list{'-user'} = $self->_getvhostuser($list{'-host'}));
Branch: 1 branch
BranchTrueFalseTotal
unless $list{"-user"} = $self->_getvhostuser($list{"-host"}) 0 0 0
Condition0%0/5
($list{'-user'} = $self->_getvhostuser($list{'-host'})) || $self->_seterror(-1, '-user must match virtual host user in make()') && (return 0)
l!l&&r!l&&!r
000
$self->_seterror(-1, "-user must match virtual host user in make()") and return 0
!ll
00
MC/DC0%0/2
($list{'-user'} = $self->_getvhostuser($list{'-host'})) || $self->_seterror(-1, '-user must match virtual host user in make()') && (return 0)
($list{'-user'} = $self->_getvhostuser($list{'-host'})) $self->_seterror(-1, "-user must match virtual host user in make()")
Truth table0%0/3
A || B
A= ($list{'-user'} = $self->_getvhostuser($list{'-host'}))B= $self->_seterror(-1, "-user must match virtual host user in make()")
ABresult
1X1
011
000
137 }
138  
139 0 ▶ open(INLOCAL, ">$list{'-dir'}/inlocal") || ($self->_seterror(-1, 'unable to read inlocal in make()') && return 0);
Branch: 1 branch
BranchTrueFalseTotal
open INLOCAL, qq[>$list{"-dir"}/inlocal] or $self->_seterror(-1, "unable to read inlocal in make()") and return 0 0 0 0
Condition0%0/5
open(INLOCAL, ">$list{'-dir'}/inlocal") || $self->_seterror(-1, 'unable to read inlocal in make()') && (return 0)
l!l&&r!l&&!r
000
$self->_seterror(-1, "unable to read inlocal in make()") and return 0
!ll
00
MC/DC0%0/2
open(INLOCAL, ">$list{'-dir'}/inlocal") || $self->_seterror(-1, 'unable to read inlocal in make()') && (return 0)
open(INLOCAL, ">$list{'-dir'}/inlocal") $self->_seterror(-1, "unable to read inlocal in make()")
Truth table0%0/3
A || B
A= open(INLOCAL, ">$list{'-dir'}/inlocal")B= $self->_seterror(-1, "unable to read inlocal in make()")
ABresult
1X1
011
000
140 0 print INLOCAL $list{'-user'} . '-' . $list{'-name'} . "\n";
141 0 close INLOCAL;
142 }
143  
144 0 $self->_seterror(undef);
145 0 return $self->setlist($list{'-dir'});
146 }
147  
148 # == Update the current list ==
149 0 ▶sub update {
Subroutine update: not called CC=21 SCAR=61.4
Pod undocumented
150 0 my($self, $switches) = @_;
151 0 my($outhost, $inlocal);
152  
153 # Do we have the command line switches
154 0 ▶ ($self->_seterror(-1, 'nothing to update()') && return 0) unless(defined($switches));
Branch: 1 branch
BranchTrueFalseTotal
unless defined $switches 0 0 0
Condition0%0/5
defined $switches || $self->_seterror(-1, 'nothing to update()') && (return 0)
l!l&&r!l&&!r
000
$self->_seterror(-1, "nothing to update()") and return 0
!ll
00
MC/DC0%0/2
defined $switches || $self->_seterror(-1, 'nothing to update()') && (return 0)
defined $switches $self->_seterror(-1, "nothing to update()")
Truth table0%0/3
A || B
A= defined $switchesB= $self->_seterror(-1, "nothing to update()")
ABresult
1X1
011
000
155 0 $switches = '-e' . $switches;
156 0 my @switch_list;
157  
158 0 foreach (&quotewords('\s+', 1, $switches)) {
159 0 ▶ next if (!defined($_));
Branch: 1 branch
BranchTrueFalseTotal
unless defined $_ 0 0 0
160 # untaint input
161 0 $_ =~ s/['"]//g;
162 0 $_ =~ m/^([\w _\/,\.\@:'"-]*)$/;
163 0 ▶ if ($_ =~ /^\s*$/) {
Branch: 1 branch
BranchTrueFalseTotal
if ($_ =~ /^\s*$/) { } 0 0 0
164 0 push @switch_list, "";
165 } else {
166 0 push @switch_list, $1;
167 }
168 }
169  
170 # can we actually alter this list;
171 0 ▶ ($self->_seterror(-1, 'must setlist() before you update()') && return 0) unless(defined($self->{'LIST_NAME'}));
Branch: 1 branch
BranchTrueFalseTotal
unless defined $self->{"LIST_NAME"} 0 0 0
Condition0%0/5
defined $self->{'LIST_NAME'} || $self->_seterror(-1, 'must setlist() before you update()') && (return 0)
l!l&&r!l&&!r
000
$self->_seterror(-1, "must setlist() before you update()") and return 0
!ll
00
MC/DC0%0/2
defined $self->{'LIST_NAME'} || $self->_seterror(-1, 'must setlist() before you update()') && (return 0)
defined $self->{'LIST_NAME'} $self->_seterror(-1, "must setlist() before you update()")
Truth table0%0/3
A || B
A= defined $self->{'LIST_NAME'}B= $self->_seterror(-1, "must setlist() before you update()")
ABresult
1X1
011
000
172 # check for important files: 'config' (idx < v5.0) or 'flags' (idx >= 5.0)
173 0 ▶ ($self->_seterror(-1, "$self->{'LIST_NAME'} does not appear to be a valid list in update()") && return 0) unless((-e "$self->{'LIST_NAME'}/config") || (-e "$self->{'LIST_NAME'}/flags"));
Branch: 1 branch
BranchTrueFalseTotal
unless -e qq[$self->{"LIST_NAME"}/config] or -e qq[$self->{"LIST_NAME"}/flags] 0 0 0
Condition0%0/8
-e "$self->{'LIST_NAME'}/config" || -e "$self->{'LIST_NAME'}/flags" || $self->_seterror(-1, "$self->{'LIST_NAME'} does not appear to be a valid list in update()") && (return 0)
l!l&&r!l&&!r
000
-e qq[$self->{"LIST_NAME"}/config] or -e qq[$self->{"LIST_NAME"}/flags]
l!l&&r!l&&!r
000
$self->_seterror(-1, qq[$self->{"LIST_NAME"} does not appear to be a valid list in update()]) and return 0
!ll
00
MC/DC0%0/3
-e "$self->{'LIST_NAME'}/config" || -e "$self->{'LIST_NAME'}/flags" || $self->_seterror(-1, "$self->{'LIST_NAME'} does not appear to be a valid list in update()") && (return 0)
-e qq[$self->{"LIST_NAME"}/config] -e qq[$self->{"LIST_NAME"}/flags] $self->_seterror(-1, qq[$self->{"LIST_NAME"} does not appear to be a valid list in update()])
Truth table0%0/4
A or B || C
A= -e qq[$self->{"LIST_NAME"}/config]B= -e qq[$self->{"LIST_NAME"}/flags]C= $self->_seterror(-1, qq[$self->{"LIST_NAME"} does not appear to be a valid list in update()])
ABCresult
1XX1
01X1
0011
0000
174  
175 # Work out if this is a vhost.
176 0 ▶ open(OUTHOST, "<$self->{'LIST_NAME'}/outhost") || ($self->_seterror(-1, 'unable to read outhost in update()') && return 0);
Branch: 1 branch
BranchTrueFalseTotal
open OUTHOST, qq[<$self->{"LIST_NAME"}/outhost] or $self->_seterror(-1, "unable to read outhost in update()") and return 0 0 0 0
Condition0%0/5
open(OUTHOST, "<$self->{'LIST_NAME'}/outhost") || $self->_seterror(-1, 'unable to read outhost in update()') && (return 0)
l!l&&r!l&&!r
000
$self->_seterror(-1, "unable to read outhost in update()") and return 0
!ll
00
MC/DC0%0/2
open(OUTHOST, "<$self->{'LIST_NAME'}/outhost") || $self->_seterror(-1, 'unable to read outhost in update()') && (return 0)
open(OUTHOST, "<$self->{'LIST_NAME'}/outhost") $self->_seterror(-1, "unable to read outhost in update()")
Truth table0%0/3
A || B
A= open(OUTHOST, "<$self->{'LIST_NAME'}/outhost")B= $self->_seterror(-1, "unable to read outhost in update()")
ABresult
1X1
011
000
177 0 chomp($outhost = <OUTHOST>);
178 0 close(OUTHOST);
179  
180 # Save the contents of inlocal if it is a vhost
181 0 ▶ unless($outhost eq $self->_getdefaultdomain) {
Branch: 1 branch
BranchTrueFalseTotal
unless ($outhost eq $self->_getdefaultdomain) 0 0 0
182 0 ▶ open(INLOCAL, "<$self->{'LIST_NAME'}/inlocal") || ($self->_seterror(-1, 'unable to read inlocal in update()') && return 0);
Branch: 1 branch
BranchTrueFalseTotal
open INLOCAL, qq[<$self->{"LIST_NAME"}/inlocal] or $self->_seterror(-1, "unable to read inlocal in update()") and return 0 0 0 0
Condition0%0/5
open(INLOCAL, "<$self->{'LIST_NAME'}/inlocal") || $self->_seterror(-1, 'unable to read inlocal in update()') && (return 0)
l!l&&r!l&&!r
000
$self->_seterror(-1, "unable to read inlocal in update()") and return 0
!ll
00
MC/DC0%0/2
open(INLOCAL, "<$self->{'LIST_NAME'}/inlocal") || $self->_seterror(-1, 'unable to read inlocal in update()') && (return 0)
open(INLOCAL, "<$self->{'LIST_NAME'}/inlocal") $self->_seterror(-1, "unable to read inlocal in update()")
Truth table0%0/3
A || B
A= open(INLOCAL, "<$self->{'LIST_NAME'}/inlocal")B= $self->_seterror(-1, "unable to read inlocal in update()")
ABresult
1X1
011
000
183 0 chomp($inlocal = <INLOCAL>);
184 0 close(INLOCAL);
185 }
186  
187 # Attempt to update the list if we can.
188 0 ▶ system("$EZMLM_BASE/ezmlm-make", @switch_list, $self->{'LIST_NAME'}) == 0
Branch: 1 branch
BranchTrueFalseTotal
system("$Mail::Ezmlm::EZMLM_BASE/ezmlm-make", @switch_list, $self->{"LIST_NAME"}) == 0 or $self->_seterror($?) and return undef 0 0 0
Condition0%0/5
system("$Mail::Ezmlm::EZMLM_BASE/ezmlm-make", @switch_list, $self->{'LIST_NAME'}) == 0 || $self->_seterror($?) && (return undef)
l!l&&r!l&&!r
000
$self->_seterror($?) and return undef
!ll
00
MC/DC0%0/2
system("$Mail::Ezmlm::EZMLM_BASE/ezmlm-make", @switch_list, $self->{'LIST_NAME'}) == 0 || $self->_seterror($?) && (return undef)
system("$Mail::Ezmlm::EZMLM_BASE/ezmlm-make", @switch_list, $self->{'LIST_NAME'}) == 0 $self->_seterror($?)
Truth table0%0/3
A || B
A= system("$Mail::Ezmlm::EZMLM_BASE/ezmlm-make", @switch_list, $self->{'LIST_NAME'}) == 0B= $self->_seterror($?)
ABresult
1X1
011
000
189 || ($self->_seterror($?) && return undef);
190
191 # Sort out the DIR/inlocal problem if necessary
192 0 ▶ if(defined($inlocal)) {
Branch: 1 branch
BranchTrueFalseTotal
if (defined $inlocal) 0 0 0
193 0 ▶ open(INLOCAL, ">$self->{'LIST_NAME'}/inlocal") || ($self->_seterror(-1, 'unable to write inlocal in update()') && return 0);
Branch: 1 branch
BranchTrueFalseTotal
open INLOCAL, qq[>$self->{"LIST_NAME"}/inlocal] or $self->_seterror(-1, "unable to write inlocal in update()") and return 0 0 0 0
Condition0%0/5
open(INLOCAL, ">$self->{'LIST_NAME'}/inlocal") || $self->_seterror(-1, 'unable to write inlocal in update()') && (return 0)
l!l&&r!l&&!r
000
$self->_seterror(-1, "unable to write inlocal in update()") and return 0
!ll
00
MC/DC0%0/2
open(INLOCAL, ">$self->{'LIST_NAME'}/inlocal") || $self->_seterror(-1, 'unable to write inlocal in update()') && (return 0)
open(INLOCAL, ">$self->{'LIST_NAME'}/inlocal") $self->_seterror(-1, "unable to write inlocal in update()")
Truth table0%0/3
A || B
A= open(INLOCAL, ">$self->{'LIST_NAME'}/inlocal")B= $self->_seterror(-1, "unable to write inlocal in update()")
ABresult
1X1
011
000
194 0 print INLOCAL "$inlocal\n";
195 0 close INLOCAL;
196 }
197  
198 0 $self->_seterror(undef);
199 0 return $self->{'LIST_NAME'};
200 }
201  
202 # == Get a list of options for the current list ==
203 0 ▶sub getconfig {
Subroutine getconfig: not called CC=9 SCAR=45.0
Pod undocumented
204 0 my($self) = @_;
205 0 my($options);
206  
207 # Read the config file
208 0 ▶ if(-e $self->{LIST_NAME} . "/flags") {
Branch: 2 branches
BranchTrueFalseTotal
if (-e $self->{'LIST_NAME'} . '/flags') { } 0 0 0
elsif (open CONFIG, '<' . $self->{'LIST_NAME'} . '/config') { } 0 0 0
209 # this file exists since ezmlm-idx-5.0.0
210 # 'config' is not authorative anymore since that version
211 0 $options = $self->_getconfig_idx5();
212 } elsif(open(CONFIG, "<" . $self->{LIST_NAME} . "/config")) {
213 # 'config' contains the authorative information
214 0 ▶ while(<CONFIG>) {
Branch: 1 branch
BranchTrueFalseTotal
if (defined($_ = readline CONFIG)) 0 0 0
215 0 ▶ if (/^F:-(\w+)/) {
Branch: 2 branches
BranchTrueFalseTotal
if (/^F:-(\w+)/) { } 0 0 0
elsif (/^(\d):(.+)$/) { } 0 0 0
216 0 $options = $1;
217 } elsif (/^(\d):(.+)$/) {
218 0 my $opt_num = $1;
219 0 my $value = $2;
220 0 ▶ $options .= " -$opt_num '$value'" if ($value =~ /\S/);
Branch: 1 branch
BranchTrueFalseTotal
if $value =~ /\S/ 0 0 0
221 }
222 }
223 0 close CONFIG;
224 } else {
225 # Try manually - this will ignore all string settings, that can only be found
226 # in the config file
227 0 $options = $self->_getconfigmanual();
228 }
229  
230 0 ▶ ($self->_seterror(-1, 'unable to read configuration in getconfig()') && return undef) unless (defined($options));
Branch: 1 branch
BranchTrueFalseTotal
unless defined $options 0 0 0
Condition0%0/5
defined $options || $self->_seterror(-1, 'unable to read configuration in getconfig()') && (return undef)
l!l&&r!l&&!r
000
$self->_seterror(-1, "unable to read configuration in getconfig()") and return undef
!ll
00
MC/DC0%0/2
defined $options || $self->_seterror(-1, 'unable to read configuration in getconfig()') && (return undef)
defined $options $self->_seterror(-1, "unable to read configuration in getconfig()")
Truth table0%0/3
A || B
A= defined $optionsB= $self->_seterror(-1, "unable to read configuration in getconfig()")
ABresult
1X1
011
000
231  
232 0 $self->_seterror(undef);
233 0 return $options;
234 }
235  
236 # == Return the name of the current list ==
237 0 ▶sub thislist {
Subroutine thislist: not called CC=1 SCAR=6.9
Pod undocumented
238 0 my($self) = shift;
239 0 $self->_seterror(undef);
240 0 return $self->{'LIST_NAME'};
241 }
242  
243 # == Set the current mailing list ==
244 0 ▶sub setlist {
Subroutine setlist: not called CC=3 SCAR=24.8
Pod undocumented
245 0 my($self, $list) = @_;
246 0 ▶ if ($list =~ m/^([\w\d\_\-\.\/\@]+)$/) {
Branch: 1 branch
BranchTrueFalseTotal
if ($list =~ m[^([\w\d\_\-\./\@]+)$]) { } 0 0 0
247 0 $list = $1;
248 0 ▶ if (-e "$list/lock") {
Branch: 1 branch
BranchTrueFalseTotal
if (-e "$list/lock") { } 0 0 0
249 0 $self->_seterror(undef);
250 0 return $self->{'LIST_NAME'} = $list;
251 } else {
252 0 $self->_seterror(-1, "$list does not appear to be a valid list in setlist()");
253 0 return undef;
254 }
255 } else {
256 0 $self->_seterror(-1, "$list contains tainted data in setlist()");
257 0 return undef;
258 }
259 }
260  
261 # == Output the subscribers to $stream ==
262 0 ▶sub list {
Subroutine list: not called CC=3 SCAR=24.8
Pod documented
263 0 my($self, $stream, $part) = @_;
264 0 ▶ $stream = *STDOUT unless (defined($stream));
Branch: 1 branch
BranchTrueFalseTotal
unless defined $stream 0 0 0
265 0 ▶ if(defined($part)) {
Branch: 1 branch
BranchTrueFalseTotal
if (defined $part) { } 0 0 0
266 0 print $stream $self->subscribers($part);
267 } else {
268 0 print $stream $self->subscribers;
269 }
270 }
271  
272 # == Return an array of subscribers ==
273 0 ▶sub subscribers {
Subroutine subscribers: not called CC=11 SCAR=48.8
Pod documented
274 0 my($self, $part) = @_;
275 0 my(@subscribers);
276 0 ▶ ($self->_seterror(-1, 'must setlist() before returning subscribers()') && return undef) unless(defined($self->{'LIST_NAME'}));
Branch: 1 branch
BranchTrueFalseTotal
unless defined $self->{"LIST_NAME"} 0 0 0
Condition0%0/5
defined $self->{'LIST_NAME'} || $self->_seterror(-1, 'must setlist() before returning subscribers()') && (return undef)
l!l&&r!l&&!r
000
$self->_seterror(-1, "must setlist() before returning subscribers()") and return undef
!ll
00
MC/DC0%0/2
defined $self->{'LIST_NAME'} || $self->_seterror(-1, 'must setlist() before returning subscribers()') && (return undef)
defined $self->{'LIST_NAME'} $self->_seterror(-1, "must setlist() before returning subscribers()")
Truth table0%0/3
A || B
A= defined $self->{'LIST_NAME'}B= $self->_seterror(-1, "must setlist() before returning subscribers()")
ABresult
1X1
011
000
277 0 ▶ if(defined($part) && $part) {
Branch: 1 branch
BranchTrueFalseTotal
if (defined $part and $part) { } 0 0 0
Condition0%0/3
defined $part and $part
!ll&&!rl&&r
000
MC/DC0%0/2
defined $part and $part
defined $part $part
Truth table0%0/3
A and B
A= defined $partB= $part
ABresult
0X0
100
111
278 0 ▶ ($self->_seterror(-1, "$part part of $self->{'LIST_NAME'} does not appear to exist in subscribers()") && return undef) unless(-e "$self->{'LIST_NAME'}/$part");
Branch: 1 branch
BranchTrueFalseTotal
unless -e qq[$self->{"LIST_NAME"}/$part] 0 0 0
Condition0%0/5
-e "$self->{'LIST_NAME'}/$part" || $self->_seterror(-1, "$part part of $self->{'LIST_NAME'} does not appear to exist in subscribers()") && (return undef)
l!l&&r!l&&!r
000
$self->_seterror(-1, qq[$part part of $self->{"LIST_NAME"} does not appear to exist in subscribers()]) and return undef
!ll
00
MC/DC0%0/2
-e "$self->{'LIST_NAME'}/$part" || $self->_seterror(-1, "$part part of $self->{'LIST_NAME'} does not appear to exist in subscribers()") && (return undef)
-e "$self->{'LIST_NAME'}/$part" $self->_seterror(-1, qq[$part part of $self->{"LIST_NAME"} does not appear to exist in subscribers()])
Truth table0%0/3
A || B
A= -e "$self->{'LIST_NAME'}/$part"B= $self->_seterror(-1, qq[$part part of $self->{"LIST_NAME"} does not appear to exist in subscribers()])
ABresult
1X1
011
000
279 0 ▶ @subscribers = map { s/[\r\n]// && $_ } sort `$EZMLM_BASE/ezmlm-list $self->{'LIST_NAME'}/$part`;
Condition0%0/3
s/[\r\n]// && $_
!ll&&!rl&&r
000
MC/DC0%0/2
s/[\r\n]// && $_
s/[\r\n]// $_
Truth table0%0/3
A && B
A= s/[\r\n]//B= $_
ABresult
0X0
100
111
280 } else {
281 0 ▶ @subscribers = map { s/[\r\n]// && $_ } sort `$EZMLM_BASE/ezmlm-list $self->{'LIST_NAME'}`;
Condition0%0/3
s/[\r\n]// && $_
!ll&&!rl&&r
000
MC/DC0%0/2
s/[\r\n]// && $_
s/[\r\n]// $_
Truth table0%0/3
A && B
A= s/[\r\n]//B= $_
ABresult
0X0
100
111
282 }
283  
284 0 ▶ if($?) {
Branch: 1 branch
BranchTrueFalseTotal
if ($?) { } 0 0 0
285 0 $self->_seterror($?, 'error during ezmlm-list in subscribers()');
286 0 ▶ return (scalar @subscribers ? @subscribers : undef);
Branch: 1 branch
BranchTrueFalseTotal
scalar @subscribers ? : 0 0 0
287 } else {
288 0 $self->_seterror(undef);
289 0 return @subscribers;
290 }
291 }
292  
293 # == Subscribe users to the current list ==
294 0 ▶sub sub {
Subroutine sub: not called CC=19 SCAR=59.4
Pod undocumented
295 0 my($self, @addresses) = @_;
296 0 ▶ ($self->_seterror(-1, 'sub() must be called with at least one address') && return 0) unless @addresses;
Branch: 1 branch
BranchTrueFalseTotal
unless @addresses 0 0 0
Condition0%0/5
@addresses || $self->_seterror(-1, 'sub() must be called with at least one address') && (return 0)
l!l&&r!l&&!r
000
$self->_seterror(-1, "sub() must be called with at least one address") and return 0
!ll
00
MC/DC0%0/2
@addresses || $self->_seterror(-1, 'sub() must be called with at least one address') && (return 0)
@addresses $self->_seterror(-1, "sub() must be called with at least one address")
Truth table0%0/3
A || B
A= @addressesB= $self->_seterror(-1, "sub() must be called with at least one address")
ABresult
1X1
011
000
297 0 ▶ my($part) = pop @addresses unless ($#addresses < 1 or $addresses[$#addresses] =~ /\@/);
Branch: 1 branch
BranchTrueFalseTotal
unless $#addresses < 1 or $addresses[$#addresses] =~ /\@/ 0 0 0
Condition0%0/3
$#addresses < 1 or $addresses[$#addresses] =~ /\@/
l!l&&r!l&&!r
000
MC/DC0%0/2
$#addresses < 1 or $addresses[$#addresses] =~ /\@/
$#addresses < 1 $addresses[$#addresses] =~ /\@/
Truth table0%0/3
A or B
A= $#addresses < 1B= $addresses[$#addresses] =~ /\@/
ABresult
1X1
011
000
298 0 my($address);
299 0 ▶ ($self->_seterror(-1, 'must setlist() before sub()') && return 0) unless(defined($self->{'LIST_NAME'}));
Branch: 1 branch
BranchTrueFalseTotal
unless defined $self->{"LIST_NAME"} 0 0 0
Condition0%0/5
defined $self->{'LIST_NAME'} || $self->_seterror(-1, 'must setlist() before sub()') && (return 0)
l!l&&r!l&&!r
000
$self->_seterror(-1, "must setlist() before sub()") and return 0
!ll
00
MC/DC0%0/2
defined $self->{'LIST_NAME'} || $self->_seterror(-1, 'must setlist() before sub()') && (return 0)
defined $self->{'LIST_NAME'} $self->_seterror(-1, "must setlist() before sub()")
Truth table0%0/3
A || B
A= defined $self->{'LIST_NAME'}B= $self->_seterror(-1, "must setlist() before sub()")
ABresult
1X1
011
000
300  
301 0 ▶ if(defined($part) && $part) {
Branch: 1 branch
BranchTrueFalseTotal
if (defined $part and $part) { } 0 0 0
Condition0%0/3
defined $part and $part
!ll&&!rl&&r
000
MC/DC0%0/2
defined $part and $part
defined $part $part
Truth table0%0/3
A and B
A= defined $partB= $part
ABresult
0X0
100
111
302 0 ▶ ($self->_seterror(-1, "$part of $self->{'LIST_NAME'} does not appear to exist in sub()") && return 0) unless(-e "$self->{'LIST_NAME'}/$part");
Branch: 1 branch
BranchTrueFalseTotal
unless -e qq[$self->{"LIST_NAME"}/$part] 0 0 0
Condition0%0/5
-e "$self->{'LIST_NAME'}/$part" || $self->_seterror(-1, "$part of $self->{'LIST_NAME'} does not appear to exist in sub()") && (return 0)
l!l&&r!l&&!r
000
$self->_seterror(-1, qq[$part of $self->{"LIST_NAME"} does not appear to exist in sub()]) and return 0
!ll
00
MC/DC0%0/2
-e "$self->{'LIST_NAME'}/$part" || $self->_seterror(-1, "$part of $self->{'LIST_NAME'} does not appear to exist in sub()") && (return 0)
-e "$self->{'LIST_NAME'}/$part" $self->_seterror(-1, qq[$part of $self->{"LIST_NAME"} does not appear to exist in sub()])
Truth table0%0/3
A || B
A= -e "$self->{'LIST_NAME'}/$part"B= $self->_seterror(-1, qq[$part of $self->{"LIST_NAME"} does not appear to exist in sub()])
ABresult
1X1
011
000
303 0 foreach $address (@addresses) {
304 0 ▶ next unless $self->_checkaddress($address);
Branch: 1 branch
BranchTrueFalseTotal
unless $self->_checkaddress($address) 0 0 0
305 0 ▶ system("$EZMLM_BASE/ezmlm-sub", "$self->{'LIST_NAME'}/$part", $address) == 0 ||
Branch: 1 branch
BranchTrueFalseTotal
system("$Mail::Ezmlm::EZMLM_BASE/ezmlm-sub", qq[$self->{"LIST_NAME"}/$part], $address) == 0 or $self->_seterror($?) and return undef 0 0 0
Condition0%0/5
system("$Mail::Ezmlm::EZMLM_BASE/ezmlm-sub", "$self->{'LIST_NAME'}/$part", $address) == 0 || $self->_seterror($?) && (return undef)
l!l&&r!l&&!r
000
$self->_seterror($?) and return undef
!ll
00
MC/DC0%0/2
system("$Mail::Ezmlm::EZMLM_BASE/ezmlm-sub", "$self->{'LIST_NAME'}/$part", $address) == 0 || $self->_seterror($?) && (return undef)
system("$Mail::Ezmlm::EZMLM_BASE/ezmlm-sub", "$self->{'LIST_NAME'}/$part", $address) == 0 $self->_seterror($?)
Truth table0%0/3
A || B
A= system("$Mail::Ezmlm::EZMLM_BASE/ezmlm-sub", "$self->{'LIST_NAME'}/$part", $address) == 0B= $self->_seterror($?)
ABresult
1X1
011
000
306 ($self->_seterror($?) && return undef);
307 }
308 } else {
309 0 foreach $address (@addresses) {
310 0 ▶ next unless $self->_checkaddress($address);
Branch: 1 branch
BranchTrueFalseTotal
unless $self->_checkaddress($address) 0 0 0
311 0 ▶ system("$EZMLM_BASE/ezmlm-sub", $self->{'LIST_NAME'}, $address) == 0 ||
Branch: 1 branch
BranchTrueFalseTotal
system("$Mail::Ezmlm::EZMLM_BASE/ezmlm-sub", $self->{"LIST_NAME"}, $address) == 0 or $self->_seterror($?) and return undef 0 0 0
Condition0%0/5
system("$Mail::Ezmlm::EZMLM_BASE/ezmlm-sub", $self->{'LIST_NAME'}, $address) == 0 || $self->_seterror($?) && (return undef)
l!l&&r!l&&!r
000
$self->_seterror($?) and return undef
!ll
00
MC/DC0%0/2
system("$Mail::Ezmlm::EZMLM_BASE/ezmlm-sub", $self->{'LIST_NAME'}, $address) == 0 || $self->_seterror($?) && (return undef)
system("$Mail::Ezmlm::EZMLM_BASE/ezmlm-sub", $self->{'LIST_NAME'}, $address) == 0 $self->_seterror($?)
Truth table0%0/3
A || B
A= system("$Mail::Ezmlm::EZMLM_BASE/ezmlm-sub", $self->{'LIST_NAME'}, $address) == 0B= $self->_seterror($?)
ABresult
1X1
011
000
312 ($self->_seterror($?) && return undef);
313 }
314 }
315 0 $self->_seterror(undef);
316 0 return 1;
317 }
318  
319 # == Unsubscribe users from a list ==
320 0 ▶sub unsub {
Subroutine unsub: not called CC=19 SCAR=59.4
Pod undocumented
321 0 my($self, @addresses) = @_;
322 0 ▶ ($self->_seterror(-1, 'unsub() must be called with at least one address') && return 0) unless @addresses;
Branch: 1 branch
BranchTrueFalseTotal
unless @addresses 0 0 0
Condition0%0/5
@addresses || $self->_seterror(-1, 'unsub() must be called with at least one address') && (return 0)
l!l&&r!l&&!r
000
$self->_seterror(-1, "unsub() must be called with at least one address") and return 0
!ll
00
MC/DC0%0/2
@addresses || $self->_seterror(-1, 'unsub() must be called with at least one address') && (return 0)
@addresses $self->_seterror(-1, "unsub() must be called with at least one address")
Truth table0%0/3
A || B
A= @addressesB= $self->_seterror(-1, "unsub() must be called with at least one address")
ABresult
1X1
011
000
323 0 ▶ my($part) = pop @addresses unless ($#addresses < 1 or $addresses[$#addresses] =~ /\@/);
Branch: 1 branch
BranchTrueFalseTotal
unless $#addresses < 1 or $addresses[$#addresses] =~ /\@/ 0 0 0
Condition0%0/3
$#addresses < 1 or $addresses[$#addresses] =~ /\@/
l!l&&r!l&&!r
000
MC/DC0%0/2
$#addresses < 1 or $addresses[$#addresses] =~ /\@/
$#addresses < 1 $addresses[$#addresses] =~ /\@/
Truth table0%0/3
A or B
A= $#addresses < 1B= $addresses[$#addresses] =~ /\@/
ABresult
1X1
011
000
324 0 my($address);
325 0 ▶ ($self->_seterror(-1, 'must setlist() before unsub()') && return 0) unless(defined($self->{'LIST_NAME'}));
Branch: 1 branch
BranchTrueFalseTotal
unless defined $self->{"LIST_NAME"} 0 0 0
Condition0%0/5
defined $self->{'LIST_NAME'} || $self->_seterror(-1, 'must setlist() before unsub()') && (return 0)
l!l&&r!l&&!r
000
$self->_seterror(-1, "must setlist() before unsub()") and return 0
!ll
00
MC/DC0%0/2
defined $self->{'LIST_NAME'} || $self->_seterror(-1, 'must setlist() before unsub()') && (return 0)
defined $self->{'LIST_NAME'} $self->_seterror(-1, "must setlist() before unsub()")
Truth table0%0/3
A || B
A= defined $self->{'LIST_NAME'}B= $self->_seterror(-1, "must setlist() before unsub()")
ABresult
1X1
011
000
326  
327 0 ▶ if(defined($part) && $part) {
Branch: 1 branch
BranchTrueFalseTotal
if (defined $part and $part) { } 0 0 0
Condition0%0/3
defined $part and $part
!ll&&!rl&&r
000
MC/DC0%0/2
defined $part and $part
defined $part $part
Truth table0%0/3
A and B
A= defined $partB= $part
ABresult
0X0
100
111
328 0 ▶ ($self->_seterror(-1, "$part of $self->{'LIST_NAME'} does not appear to exist in unsub()") && return 0) unless(-e "$self->{'LIST_NAME'}/$part");
Branch: 1 branch
BranchTrueFalseTotal
unless -e qq[$self->{"LIST_NAME"}/$part] 0 0 0
Condition0%0/5
-e "$self->{'LIST_NAME'}/$part" || $self->_seterror(-1, "$part of $self->{'LIST_NAME'} does not appear to exist in unsub()") && (return 0)
l!l&&r!l&&!r
000
$self->_seterror(-1, qq[$part of $self->{"LIST_NAME"} does not appear to exist in unsub()]) and return 0
!ll
00
MC/DC0%0/2
-e "$self->{'LIST_NAME'}/$part" || $self->_seterror(-1, "$part of $self->{'LIST_NAME'} does not appear to exist in unsub()") && (return 0)
-e "$self->{'LIST_NAME'}/$part" $self->_seterror(-1, qq[$part of $self->{"LIST_NAME"} does not appear to exist in unsub()])
Truth table0%0/3
A || B
A= -e "$self->{'LIST_NAME'}/$part"B= $self->_seterror(-1, qq[$part of $self->{"LIST_NAME"} does not appear to exist in unsub()])
ABresult
1X1
011
000
329 0 foreach $address (@addresses) {
330 0 ▶ next unless $self->_checkaddress($address);
Branch: 1 branch
BranchTrueFalseTotal
unless $self->_checkaddress($address) 0 0 0
331 0 ▶ system("$EZMLM_BASE/ezmlm-unsub", "$self->{'LIST_NAME'}/$part", $address) == 0 ||
Branch: 1 branch
BranchTrueFalseTotal
system("$Mail::Ezmlm::EZMLM_BASE/ezmlm-unsub", qq[$self->{"LIST_NAME"}/$part], $address) == 0 or $self->_seterror($?) and return undef 0 0 0
Condition0%0/5
system("$Mail::Ezmlm::EZMLM_BASE/ezmlm-unsub", "$self->{'LIST_NAME'}/$part", $address) == 0 || $self->_seterror($?) && (return undef)
l!l&&r!l&&!r
000
$self->_seterror($?) and return undef
!ll
00
MC/DC0%0/2
system("$Mail::Ezmlm::EZMLM_BASE/ezmlm-unsub", "$self->{'LIST_NAME'}/$part", $address) == 0 || $self->_seterror($?) && (return undef)
system("$Mail::Ezmlm::EZMLM_BASE/ezmlm-unsub", "$self->{'LIST_NAME'}/$part", $address) == 0 $self->_seterror($?)
Truth table0%0/3
A || B
A= system("$Mail::Ezmlm::EZMLM_BASE/ezmlm-unsub", "$self->{'LIST_NAME'}/$part", $address) == 0B= $self->_seterror($?)
ABresult
1X1
011
000
332 ($self->_seterror($?) && return undef);
333 }
334 } else {
335 0 foreach $address (@addresses) {
336 0 ▶ next unless $self->_checkaddress($address);
Branch: 1 branch
BranchTrueFalseTotal
unless $self->_checkaddress($address) 0 0 0
337 0 ▶ system("$EZMLM_BASE/ezmlm-unsub", $self->{'LIST_NAME'}, $address) == 0 ||
Branch: 1 branch
BranchTrueFalseTotal
system("$Mail::Ezmlm::EZMLM_BASE/ezmlm-unsub", $self->{"LIST_NAME"}, $address) == 0 or $self->_seterror($?) and return undef 0 0 0
Condition0%0/5
system("$Mail::Ezmlm::EZMLM_BASE/ezmlm-unsub", $self->{'LIST_NAME'}, $address) == 0 || $self->_seterror($?) && (return undef)
l!l&&r!l&&!r
000
$self->_seterror($?) and return undef
!ll
00
MC/DC0%0/2
system("$Mail::Ezmlm::EZMLM_BASE/ezmlm-unsub", $self->{'LIST_NAME'}, $address) == 0 || $self->_seterror($?) && (return undef)
system("$Mail::Ezmlm::EZMLM_BASE/ezmlm-unsub", $self->{'LIST_NAME'}, $address) == 0 $self->_seterror($?)
Truth table0%0/3
A || B
A= system("$Mail::Ezmlm::EZMLM_BASE/ezmlm-unsub", $self->{'LIST_NAME'}, $address) == 0B= $self->_seterror($?)
ABresult
1X1
011
000
338 ($self->_seterror($?) && return undef);
339 }
340 }
341 0 $self->_seterror(undef);
342 0 return 1;
343 }
344  
345 # == Test whether people are subscribed to the list ==
346 0 ▶sub issub {
Subroutine issub: not called CC=13 SCAR=52.0
Pod undocumented
347 0 my($self, @addresses) = @_;
348 0 ▶ my($part) = pop @addresses unless ($#addresses < 1 or $addresses[$#addresses] =~ /\@/);
Branch: 1 branch
BranchTrueFalseTotal
unless $#addresses < 1 or $addresses[$#addresses] =~ /\@/ 0 0 0
Condition0%0/3
$#addresses < 1 or $addresses[$#addresses] =~ /\@/
l!l&&r!l&&!r
000
MC/DC0%0/2
$#addresses < 1 or $addresses[$#addresses] =~ /\@/
$#addresses < 1 $addresses[$#addresses] =~ /\@/
Truth table0%0/3
A or B
A= $#addresses < 1B= $addresses[$#addresses] =~ /\@/
ABresult
1X1
011
000
349 0 my($address, $issub); $issub = 1;
350 0 ▶ ($self->_seterror(-1, 'must setlist() before issub()') && return 0) unless(defined($self->{'LIST_NAME'}));
Branch: 1 branch
BranchTrueFalseTotal
unless defined $self->{"LIST_NAME"} 0 0 0
Condition0%0/5
defined $self->{'LIST_NAME'} || $self->_seterror(-1, 'must setlist() before issub()') && (return 0)
l!l&&r!l&&!r
000
$self->_seterror(-1, "must setlist() before issub()") and return 0
!ll
00
MC/DC0%0/2
defined $self->{'LIST_NAME'} || $self->_seterror(-1, 'must setlist() before issub()') && (return 0)
defined $self->{'LIST_NAME'} $self->_seterror(-1, "must setlist() before issub()")
Truth table0%0/3
A || B
A= defined $self->{'LIST_NAME'}B= $self->_seterror(-1, "must setlist() before issub()")
ABresult
1X1
011
000
351  
352 0 local $ENV{'SENDER'};
353  
354 0 ▶ if(defined($part) && $part) {
Branch: 1 branch
BranchTrueFalseTotal
if (defined $part and $part) { } 0 0 0
Condition0%0/3
defined $part and $part
!ll&&!rl&&r
000
MC/DC0%0/2
defined $part and $part
defined $part $part
Truth table0%0/3
A and B
A= defined $partB= $part
ABresult
0X0
100
111
355 0 ▶ ($self->_seterror(-1, "$part of $self->{'LIST_NAME'} does not appear to exist in issub()") && return 0) unless(-e "$self->{'LIST_NAME'}/$part");
Branch: 1 branch
BranchTrueFalseTotal
unless -e qq[$self->{"LIST_NAME"}/$part] 0 0 0
Condition0%0/5
-e "$self->{'LIST_NAME'}/$part" || $self->_seterror(-1, "$part of $self->{'LIST_NAME'} does not appear to exist in issub()") && (return 0)
l!l&&r!l&&!r
000
$self->_seterror(-1, qq[$part of $self->{"LIST_NAME"} does not appear to exist in issub()]) and return 0
!ll
00
MC/DC0%0/2
-e "$self->{'LIST_NAME'}/$part" || $self->_seterror(-1, "$part of $self->{'LIST_NAME'} does not appear to exist in issub()") && (return 0)
-e "$self->{'LIST_NAME'}/$part" $self->_seterror(-1, qq[$part of $self->{"LIST_NAME"} does not appear to exist in issub()])
Truth table0%0/3
A || B
A= -e "$self->{'LIST_NAME'}/$part"B= $self->_seterror(-1, qq[$part of $self->{"LIST_NAME"} does not appear to exist in issub()])
ABresult
1X1
011
000
356 0 foreach $address (@addresses) {
357 0 $ENV{'SENDER'} = $address;
358 0 ▶ undef($issub) if ((system("$EZMLM_BASE/ezmlm-issubn", "$self->{'LIST_NAME'}/$part") / 256) != 0)
Branch: 1 branch
BranchTrueFalseTotal
if system("$Mail::Ezmlm::EZMLM_BASE/ezmlm-issubn", qq[$self->{"LIST_NAME"}/$part]) / 256 != 0 0 0 0
359 }
360 } else {
361 0 foreach $address (@addresses) {
362 0 $ENV{'SENDER'} = $address;
363 0 ▶ undef($issub) if ((system("$EZMLM_BASE/ezmlm-issubn", $self->{'LIST_NAME'}) / 256) != 0)
Branch: 1 branch
BranchTrueFalseTotal
if system("$Mail::Ezmlm::EZMLM_BASE/ezmlm-issubn", $self->{"LIST_NAME"}) / 256 != 0 0 0 0
364 }
365 }
366  
367 0 $self->_seterror(undef);
368 0 return $issub;
369 }
370  
371 # == Is the list posting moderated ==
372 # DEPRECATED: useless - you should better check the appropriate config flag
373 0 ▶sub ismodpost {
Subroutine ismodpost: not called CC=3 SCAR=24.8
Pod undocumented
374 0 my($self) = @_;
375 0 ▶ ($self->_seterror(-1, 'must setlist() before ismodpost()') && return 0) unless(defined($self->{'LIST_NAME'}));
Branch: 1 branch
BranchTrueFalseTotal
unless defined $self->{"LIST_NAME"} 0 0 0
Condition0%0/5
defined $self->{'LIST_NAME'} || $self->_seterror(-1, 'must setlist() before ismodpost()') && (return 0)
l!l&&r!l&&!r
000
$self->_seterror(-1, "must setlist() before ismodpost()") and return 0
!ll
00
MC/DC0%0/2
defined $self->{'LIST_NAME'} || $self->_seterror(-1, 'must setlist() before ismodpost()') && (return 0)
defined $self->{'LIST_NAME'} $self->_seterror(-1, "must setlist() before ismodpost()")
Truth table0%0/3
A || B
A= defined $self->{'LIST_NAME'}B= $self->_seterror(-1, "must setlist() before ismodpost()")
ABresult
1X1
011
000
376 0 $self->_seterror(undef);
377 0 return -e "$self->{'LIST_NAME'}/modpost";
378 }
379  
380 # == Is the list subscriber moderated ==
381 # DEPRECATED: useless - you should better check the appropriate config flag
382 0 ▶sub ismodsub {
Subroutine ismodsub: not called CC=3 SCAR=24.8
Pod undocumented
383 0 my($self) = @_;
384 0 ▶ ($self->_seterror(-1, 'must setlist() before ismodsub()') && return 0) unless(defined($self->{'LIST_NAME'}));
Branch: 1 branch
BranchTrueFalseTotal
unless defined $self->{"LIST_NAME"} 0 0 0
Condition0%0/5
defined $self->{'LIST_NAME'} || $self->_seterror(-1, 'must setlist() before ismodsub()') && (return 0)
l!l&&r!l&&!r
000
$self->_seterror(-1, "must setlist() before ismodsub()") and return 0
!ll
00
MC/DC0%0/2
defined $self->{'LIST_NAME'} || $self->_seterror(-1, 'must setlist() before ismodsub()') && (return 0)
defined $self->{'LIST_NAME'} $self->_seterror(-1, "must setlist() before ismodsub()")
Truth table0%0/3
A || B
A= defined $self->{'LIST_NAME'}B= $self->_seterror(-1, "must setlist() before ismodsub()")
ABresult
1X1
011
000
385 0 $self->_seterror(undef);
386 0 return -e "$self->{'LIST_NAME'}/modsub";
387 }
388  
389 # == Is the list remote adminable ==
390 # DEPRECATED: useless - you should better check the appropriate config flag
391 0 ▶sub isremote {
Subroutine isremote: not called CC=3 SCAR=24.8
Pod undocumented
392 0 my($self) = @_;
393 0 ▶ ($self->_seterror(-1, 'must setlist() before isremote()') && return 0) unless(defined($self->{'LIST_NAME'}));
Branch: 1 branch
BranchTrueFalseTotal
unless defined $self->{"LIST_NAME"} 0 0 0
Condition0%0/5
defined $self->{'LIST_NAME'} || $self->_seterror(-1, 'must setlist() before isremote()') && (return 0)
l!l&&r!l&&!r
000
$self->_seterror(-1, "must setlist() before isremote()") and return 0
!ll
00
MC/DC0%0/2
defined $self->{'LIST_NAME'} || $self->_seterror(-1, 'must setlist() before isremote()') && (return 0)
defined $self->{'LIST_NAME'} $self->_seterror(-1, "must setlist() before isremote()")
Truth table0%0/3
A || B
A= defined $self->{'LIST_NAME'}B= $self->_seterror(-1, "must setlist() before isremote()")
ABresult
1X1
011
000
394 0 $self->_seterror(undef);
395 0 return -e "$self->{'LIST_NAME'}/remote";
396 }
397  
398 # == Does the list have a kill list ==
399 # DEPRECATED: useless - you should better check the appropriate config flag
400 0 ▶sub isdeny {
Subroutine isdeny: not called CC=3 SCAR=24.8
Pod undocumented
401 0 my($self) = @_;
402 0 ▶ ($self->_seterror(-1, 'must setlist() before isdeny()') && return 0) unless(defined($self->{'LIST_NAME'}));
Branch: 1 branch
BranchTrueFalseTotal
unless defined $self->{"LIST_NAME"} 0 0 0
Condition0%0/5
defined $self->{'LIST_NAME'} || $self->_seterror(-1, 'must setlist() before isdeny()') && (return 0)
l!l&&r!l&&!r
000
$self->_seterror(-1, "must setlist() before isdeny()") and return 0
!ll
00
MC/DC0%0/2
defined $self->{'LIST_NAME'} || $self->_seterror(-1, 'must setlist() before isdeny()') && (return 0)
defined $self->{'LIST_NAME'} $self->_seterror(-1, "must setlist() before isdeny()")
Truth table0%0/3
A || B
A= defined $self->{'LIST_NAME'}B= $self->_seterror(-1, "must setlist() before isdeny()")
ABresult
1X1
011
000
403 0 $self->_seterror(undef);
404 0 return -e "$self->{'LIST_NAME'}/deny";
405 }
406  
407 # == Does the list have an allow list ==
408 # DEPRECATED: useless - the allow list is always created automatically
409 0 ▶sub isallow {
Subroutine isallow: not called CC=3 SCAR=24.8
Pod undocumented
410 0 my($self) = @_;
411 0 ▶ ($self->_seterror(-1, 'must setlist() before isallow()') && return 0) unless(defined($self->{'LIST_NAME'}));
Branch: 1 branch
BranchTrueFalseTotal
unless defined $self->{"LIST_NAME"} 0 0 0
Condition0%0/5
defined $self->{'LIST_NAME'} || $self->_seterror(-1, 'must setlist() before isallow()') && (return 0)
l!l&&r!l&&!r
000
$self->_seterror(-1, "must setlist() before isallow()") and return 0
!ll
00
MC/DC0%0/2
defined $self->{'LIST_NAME'} || $self->_seterror(-1, 'must setlist() before isallow()') && (return 0)
defined $self->{'LIST_NAME'} $self->_seterror(-1, "must setlist() before isallow()")
Truth table0%0/3
A || B
A= defined $self->{'LIST_NAME'}B= $self->_seterror(-1, "must setlist() before isallow()")
ABresult
1X1
011
000
412 0 $self->_seterror(undef);
413 0 return -e "$self->{'LIST_NAME'}/allow";
414 }
415  
416 # == Is this a digested list ==
417 # DEPRECATED: useless - you should better check the appropriate config flag
418 0 ▶sub isdigest {
Subroutine isdigest: not called CC=3 SCAR=24.8
Pod undocumented
419 0 my($self) = @_;
420 0 ▶ ($self->_seterror(-1, 'must setlist() before isdigest()') && return 0) unless(defined($self->{'LIST_NAME'}));
Branch: 1 branch
BranchTrueFalseTotal
unless defined $self->{"LIST_NAME"} 0 0 0
Condition0%0/5
defined $self->{'LIST_NAME'} || $self->_seterror(-1, 'must setlist() before isdigest()') && (return 0)
l!l&&r!l&&!r
000
$self->_seterror(-1, "must setlist() before isdigest()") and return 0
!ll
00
MC/DC0%0/2
defined $self->{'LIST_NAME'} || $self->_seterror(-1, 'must setlist() before isdigest()') && (return 0)
defined $self->{'LIST_NAME'} $self->_seterror(-1, "must setlist() before isdigest()")
Truth table0%0/3
A || B
A= defined $self->{'LIST_NAME'}B= $self->_seterror(-1, "must setlist() before isdigest()")
ABresult
1X1
011
000
421 0 $self->_seterror(undef);
422 0 return -e "$self->{'LIST_NAME'}/digest";
423 }
424  
425 # == retrieve file contents ==
426 0 ▶sub getpart {
Subroutine getpart: not called CC=10 SCAR=47.0
Pod undocumented
427 0 my($self, $part) = @_;
428 0 my(@contents, $content);
429 # check for the file in the list directory first
430 0 my $filename = $self->{'LIST_NAME'} . "/$part";
431 # check for default file in config directory, if necessary
432 # BEWARE: get_config_dir and get_lang may _not_ cause an eternal loop :)
433 0 ▶ $filename = $self->get_config_dir() . '/' . $self->get_lang() . "/$part"
Branch: 1 branch
BranchTrueFalseTotal
if not -e "$filename" and get_version() >= 5 and $part ne "conf-etc" and $part ne "conf-lang" 0 0 0
Condition0%0/9
not -e "$filename" and get_version() >= 5 and $part ne "conf-etc" and $part ne "conf-lang"
!ll&&!rl&&r
000
not -e "$filename" and get_version() >= 5 and $part ne "conf-etc"
!ll&&!rl&&r
000
not -e "$filename" and get_version() >= 5
!ll&&!rl&&r
000
MC/DC0%0/4
not -e "$filename" and get_version() >= 5 and $part ne "conf-etc" and $part ne "conf-lang"
not -e "$filename" get_version() >= 5 $part ne "conf-etc" $part ne "conf-lang"
Truth table0%0/5
not(A) and B and C and D
A= not -e "$filename"B= get_version() >= 5C= $part ne "conf-etc"D= $part ne "conf-lang"
ABCDresult
0XXX0
10XX0
110X0
11100
11111
434 if (!(-e "$filename") && (get_version() >= 5) &&
435 ($part ne 'conf-etc') && ($part ne 'conf-lang'));
436 0 ▶ if (open(PART, "<$filename")) {
Branch: 1 branch
BranchTrueFalseTotal
if (open PART, "<$filename") 0 0 0
437 0 ▶ while(<PART>) {
Branch: 1 branch
BranchTrueFalseTotal
if (defined($_ = readline PART)) 0 0 0
438 0 ▶ unless ( /^#/ ) {
Branch: 1 branch
BranchTrueFalseTotal
unless (/^#/) 0 0 0
439 0 chomp($contents[$#contents++] = $_);
440 0 $content .= $_;
441 }
442 }
443 0 close PART;
444 0 ▶ if(wantarray) {
Branch: 1 branch
BranchTrueFalseTotal
if (wantarray) { } 0 0 0
445 0 return @contents;
446 } else {
447 0 return $content;
448 }
449 0 ▶ } ($self->_seterror($?) && return undef);
Branch: 1 branch
BranchTrueFalseTotal
$self->_seterror($?) and return undef 0 0 0
450 }
451  
452 # == set files contents ==
453 0 ▶sub setpart {
Subroutine setpart: not called CC=4 SCAR=30.0
Pod undocumented
454 0 my($self, $part, @content) = @_;
455 0 my($line);
456 0 ▶ if(open(PART, ">$self->{'LIST_NAME'}/$part")) {
Branch: 1 branch
BranchTrueFalseTotal
if (open PART, qq[>$self->{"LIST_NAME"}/$part]) 0 0 0
457 0 foreach $line (@content) {
458 0 $line =~ s/[\r]//g; $line =~ s/\n$//;
459 0 print PART "$line\n";
460 }
461 0 close PART;
462 0 return 1;
463 0 ▶ } ($self->_seterror($?) && return undef);
Branch: 1 branch
BranchTrueFalseTotal
$self->_seterror($?) and return undef 0 0 0
464 }
465  
466 # == get the configuration directory for this list (idx >= 5.0) ==
467 # return '/etc/ezmlm' for idx < 5.0
468 0 ▶sub get_config_dir {
Subroutine get_config_dir: not called CC=4 SCAR=30.0
Pod undocumented
469 0 my $self = shift;
470 0 my $conf_dir;
471 0 ▶ if ((get_version() >= 5) && (ref $self) && (-e "$self->{'LIST_NAME'}/conf-etc")) {
Branch: 1 branch
BranchTrueFalseTotal
if (get_version() >= 5 and ref $self and -e "$self->{'LIST_NAME'}/conf-etc") { } 0 0 0
Condition0%0/6
get_version() >= 5 and ref $self and -e qq[$self->{"LIST_NAME"}/conf-etc]
!ll&&!rl&&r
000
get_version() >= 5 and ref $self
!ll&&!rl&&r
000
MC/DC0%0/3
get_version() >= 5 and ref $self and -e qq[$self->{"LIST_NAME"}/conf-etc]
get_version() >= 5 ref $self -e qq[$self->{"LIST_NAME"}/conf-etc]
Truth table0%0/4
A and B and C
A= get_version() >= 5B= ref $selfC= -e qq[$self->{"LIST_NAME"}/conf-etc]
ABCresult
0XX0
10X0
1100
1111
472 0 chomp($conf_dir = $self->getpart('conf-etc'));
473 } else {
474 0 $conf_dir = '/etc/ezmlm';
475 }
476 0 return $conf_dir;
477 }
478  
479 # == set the configuration directory for this list (idx >= 5.0) ==
480 # return without error for idx < 5.0
481 0 ▶sub set_config_dir {
Subroutine set_config_dir: not called CC=2 SCAR=17.9
Pod undocumented
482 0 my ($self, $conf_dir) = @_;
483 0 ▶ return (0==0) if (get_version() < 5);
Branch: 1 branch
BranchTrueFalseTotal
if get_version() < 5 0 0 0
484 0 $self->setpart('conf-etc', "$conf_dir");
485 }
486  
487  
488 # == get list of available languages (for idx >= 5.0) ==
489 # return empty list for idx < 5.0
490 0 ▶sub get_available_languages {
Subroutine get_available_languages: not called CC=10 SCAR=47.0
Pod undocumented
491 0 my $self = shift;
492 0 my @langs = ();
493 0 ▶ return @langs if (get_version() < 5);
Branch: 1 branch
BranchTrueFalseTotal
if get_version() < 5 0 0 0
494  
495 0 ▶ $self->_seterror(undef) if (ref $self);
Branch: 1 branch
BranchTrueFalseTotal
if ref $self 0 0 0
496  
497 # check for language directories
498 0 my $conf_dir;
499 0 ▶ if (ref $self) {
Branch: 1 branch
BranchTrueFalseTotal
if (ref $self) { } 0 0 0
500 0 ▶ ($self->_seterror(-1, 'could not retrieve configuration directory') && return 0)
Branch: 1 branch
BranchTrueFalseTotal
unless $conf_dir = $self->get_config_dir 0 0 0
Condition0%0/5
($conf_dir = $self->get_config_dir) || $self->_seterror(-1, 'could not retrieve configuration directory') && (return 0)
l!l&&r!l&&!r
000
$self->_seterror(-1, "could not retrieve configuration directory") and return 0
!ll
00
MC/DC0%0/2
($conf_dir = $self->get_config_dir) || $self->_seterror(-1, 'could not retrieve configuration directory') && (return 0)
($conf_dir = $self->get_config_dir) $self->_seterror(-1, "could not retrieve configuration directory")
Truth table0%0/3
A || B
A= ($conf_dir = $self->get_config_dir)B= $self->_seterror(-1, "could not retrieve configuration directory")
ABresult
1X1
011
000
501 unless ($conf_dir = $self->get_config_dir());
502 } else {
503 0 $conf_dir = get_config_dir();
504 }
505 0 ▶ if (opendir DIR, "$conf_dir") {
Branch: 1 branch
BranchTrueFalseTotal
if (opendir DIR, "$conf_dir") { } 0 0 0
506 0 my @dirs;
507 0 @dirs = grep !/^\./, readdir DIR;
508 0 closedir DIR;
509 0 my $item;
510 0 foreach $item (@dirs) {
511 0 ▶ push (@langs, $item) if (-e "$conf_dir/$item/text");
Branch: 1 branch
BranchTrueFalseTotal
if -e "$conf_dir/$item/text" 0 0 0
512 }
513 0 return @langs;
514 } else {
515 0 ▶ $self->_seterror(-1, 'could not access configuration directory') if (ref $self);
Branch: 1 branch
BranchTrueFalseTotal
if ref $self 0 0 0
516 0 return undef;
517 }
518 }
519  
520  
521 # == get the selected language of the list (idx >= 5.0) ==
522 # return empty string for idx < 5.0
523 0 ▶sub get_lang {
Subroutine get_lang: not called CC=3 SCAR=24.8
Pod undocumented
524 0 my ($self) = shift;
525 0 my $lang;
526 0 ▶ return '' if (get_version() < 5);
Branch: 1 branch
BranchTrueFalseTotal
if get_version() < 5 0 0 0
527 0 ▶ if (-e "$self->{'LIST_NAME'}/conf-lang") {
Branch: 1 branch
BranchTrueFalseTotal
if (-e "$self->{'LIST_NAME'}/conf-lang") { } 0 0 0
528 0 chomp($lang = $self->getpart('conf-lang'));
529 } else {
530 0 $lang = 'default';
531 }
532 0 return $lang;
533 }
534  
535  
536 # == set the selected language of the list (idx >= 5.0) ==
537 # return without error for idx < 5.0
538 0 ▶sub set_lang {
Subroutine set_lang: not called CC=6 SCAR=37.4
Pod undocumented
539 0 my ($self, $lang) = @_;
540 0 ▶ return (0==0) if (get_version() < 5);
Branch: 1 branch
BranchTrueFalseTotal
if get_version() < 5 0 0 0
541 0 ▶ if (($lang eq 'default') || ($lang eq '')) {
Branch: 1 branch
BranchTrueFalseTotal
if ($lang eq 'default' or $lang eq '') { } 0 0 0
Condition0%0/3
$lang eq "default" or $lang eq ""
l!l&&r!l&&!r
000
MC/DC0%0/2
$lang eq "default" or $lang eq ""
$lang eq "default" $lang eq ""
Truth table0%0/3
A or B
A= $lang eq "default"B= $lang eq ""
ABresult
1X1
011
000
542 0 ▶ return 1 if (unlink "$self->{'LIST_NAME'}/conf-lang");
Branch: 1 branch
BranchTrueFalseTotal
if unlink qq[$self->{"LIST_NAME"}/conf-lang] 0 0 0
543 } else {
544 0 ▶ return 1 if ($self->setpart('conf-lang', "$lang"));
Branch: 1 branch
BranchTrueFalseTotal
if $self->setpart("conf-lang", "$lang") 0 0 0
545 }
546 0 return 0;
547 }
548  
549  
550 # == get the selected charset of the list ==
551 # return default value (us-ascii) if no charset is specified
552 0 ▶sub get_charset {
Subroutine get_charset: not called CC=3 SCAR=24.8
Pod undocumented
553 0 my ($self) = shift;
554 0 my $charset;
555 0 $charset = $self->getpart('charset');
556 0 ▶ $charset = '' unless defined($charset);
Branch: 1 branch
BranchTrueFalseTotal
unless defined $charset 0 0 0
557 # default if no 'charset' file exists
558 0 ▶ $charset = 'us-ascii' if ($charset eq '');
Branch: 1 branch
BranchTrueFalseTotal
if $charset eq "" 0 0 0
559 0 return $charset;
560 }
561  
562  
563 # == set the selected charset of the list (idx >= 5.0) ==
564 # remove list' specific charset file, if the default charset of the current language
565 # was chosen
566 0 ▶sub set_charset {
Subroutine set_charset: not called CC=4 SCAR=30.0
Pod undocumented
567 0 my ($self, $charset) = @_;
568 # first: remove current charset
569 0 unlink "$self->{'LIST_NAME'}/charset";
570 # second: get default value of the current language
571 0 my $default_charset = $self->getpart('charset');
572 # last: create new charset file only if the selected charset is not the default anyway
573 0 ▶ if (($charset eq $default_charset) || ($charset !~ /\S/)) {
Branch: 1 branch
BranchTrueFalseTotal
if ($charset eq $default_charset or not $charset =~ /\S/) { } 0 0 0
Condition0%0/3
$charset eq $default_charset or not $charset =~ /\S/
l!l&&r!l&&!r
000
MC/DC0%0/2
$charset eq $default_charset or not $charset =~ /\S/
$charset eq $default_charset not $charset =~ /\S/
Truth table0%0/3
A or not(B)
A= $charset eq $default_charsetB= not $charset =~ /\S/
ABresult
1X1
011
000
574 # do not write the specific charset, as the default charset of the language is
575 # sufficient
576 0 return 1;
577 } else {
578 0 ▶ return 1 if ($self->setpart('charset', "$charset"));
Branch: 1 branch
BranchTrueFalseTotal
if $self->setpart("charset", "$charset") 0 0 0
579 }
580 0 return 0;
581 }
582  
583  
584 # == get list of available text files ==
585 0 ▶sub get_available_text_files {
Subroutine get_available_text_files: not called CC=10 SCAR=47.0
Pod undocumented
586 0 my ($self) = shift;
587 0 my @files;
588 my $item;
589 0 my %seen = ();
590
591 # customized text files of this list (idx >= 5.0)
592 # OR text files of this list (idx < 5.0)
593 0 ▶ if (opendir DIR, "$self->{'LIST_NAME'}/text") {
Branch: 1 branch
BranchTrueFalseTotal
if (opendir DIR, qq[$self->{"LIST_NAME"}/text]) 0 0 0
594 0 my @local_files = grep !/^\./, readdir DIR;
595 0 closedir DIR;
596 0 foreach $item (@local_files) {
597 0 ▶ unless ($seen{$item}) {
Branch: 1 branch
BranchTrueFalseTotal
unless ($seen{$item}) 0 0 0
598 0 push (@files, $item);
599 0 $seen{$item} = 1;
600 }
601 }
602 }
603  
604 # default text files (only idx >= 5.0)
605 0 ▶ if (get_version() >= 5) {
Branch: 1 branch
BranchTrueFalseTotal
if (get_version() >= 5) 0 0 0
606 0 my $dirname = $self->get_config_dir . '/' . $self->get_lang() . '/text';
607 0 ▶ $dirname = $self->get_config_dir . '/default/text' unless (-e $dirname);
Branch: 1 branch
BranchTrueFalseTotal
unless -e $dirname 0 0 0
608 0 ▶ if (opendir GLOBDIR, $dirname) {
Branch: 1 branch
BranchTrueFalseTotal
if (opendir GLOBDIR, $dirname) 0 0 0
609 0 my @global_files = grep !/^\./, readdir GLOBDIR;
610 0 closedir GLOBDIR;
611 0 foreach $item (@global_files) {
612 0 ▶ unless ($seen{$item}) {
Branch: 1 branch
BranchTrueFalseTotal
unless ($seen{$item}) 0 0 0
613 0 push (@files, $item);
614 0 $seen{$item} = 1;
615 }
616 }
617 }
618 }
619  
620 0 ▶ if ($#files > 0) {
Branch: 1 branch
BranchTrueFalseTotal
if ($#files > 0) { } 0 0 0
621 0 return @files;
622 } else {
623 0 $self->_seterror(-1, 'no textfiles found');
624 0 return undef;
625 }
626 }
627  
628 # == get text file content ==
629 0 ▶sub get_text_content {
Subroutine get_text_content: not called CC=7 SCAR=40.3
Pod undocumented
630 0 my ($self, $textfile) = @_;
631  
632 0 ▶ if (-e "$self->{'LIST_NAME'}/text/$textfile") {
Branch: 2 branches
BranchTrueFalseTotal
if (-e "$self->{'LIST_NAME'}/text/$textfile") { } 0 0 0
elsif (get_version() >= 5) { } 0 0 0
633 0 return $self->getpart("text/$textfile");
634 } elsif (get_version() >= 5) {
635 0 my $filename = $self->get_config_dir() . '/' . $self->get_lang() . "/text/$textfile";
636 0 ▶ $filename = "/etc/ezmlm/default/$textfile" unless (-e "$filename");
Branch: 1 branch
BranchTrueFalseTotal
unless -e "$filename" 0 0 0
637 0 my @contents;
638 my $content;
639 0 ▶ if (open(PART, "<$filename")) {
Branch: 1 branch
BranchTrueFalseTotal
if (open PART, "<$filename") { } 0 0 0
640 0 ▶ while(<PART>) {
Branch: 1 branch
BranchTrueFalseTotal
if (defined($_ = readline PART)) 0 0 0
641 0 chomp($contents[$#contents++] = $_);
642 0 $content .= $_;
643 }
644 0 close PART;
645 0 ▶ if(wantarray) {
Branch: 1 branch
BranchTrueFalseTotal
if (wantarray) { } 0 0 0
646 0 return @contents;
647 } else {
648 0 return $content;
649 }
650 } else {
651 0 $self->_seterror($?, "could not open $filename");
652 0 return undef;
653 }
654 } else {
655 0 $self->_seterror(-1, "could not get the text file ($textfile)");
656 0 return undef;
657 }
658 }
659  
660  
661 # == set text file content ==
662 0 ▶sub set_text_content {
Subroutine set_text_content: not called CC=3 SCAR=24.8
Pod undocumented
663 0 my ($self, $textfile, @content) = @_;
664 0 ▶ mkdir "$self->{'LIST_NAME'}/text" unless (-e "$self->{'LIST_NAME'}/text");
Branch: 1 branch
BranchTrueFalseTotal
unless -e qq[$self->{"LIST_NAME"}/text] 0 0 0
665 0 ▶ return 1 if ($self->setpart("text/$textfile", @content));
Branch: 1 branch
BranchTrueFalseTotal
if $self->setpart("text/$textfile", @content) 0 0 0
666 0 return 0;
667 }
668  
669  
670 # == check if specified text file is customized or default (for idx >= 5.0) ==
671 # return whether the text file exists in the list's directory (false) or not (true)
672 # empty filename returns false
673 0 ▶sub is_text_default {
Subroutine is_text_default: not called CC=3 SCAR=24.8
Pod undocumented
674 0 my ($self, $textfile) = @_;
675 0 ▶ return (0==1) if ($textfile eq '');
Branch: 1 branch
BranchTrueFalseTotal
if $textfile eq "" 0 0 0
676 0 ▶ if (-e "$self->{'LIST_NAME'}/text/$textfile") {
Branch: 1 branch
BranchTrueFalseTotal
if (-e "$self->{'LIST_NAME'}/text/$textfile") { } 0 0 0
677 0 return (1==0);
678 } else {
679 0 return (0==0);
680 }
681 }
682  
683  
684 # == remove non-default text file (for idx >= 5.0) ==
685 # return without error for idx < 5
686 # otherwise: remove customized text file from the list's directory
687 0 ▶sub reset_text {
Subroutine reset_text: not called CC=7 SCAR=40.3
Pod undocumented
688 0 my ($self, $textfile) = @_;
689 0 ▶ return if (get_version() < 5);
Branch: 1 branch
BranchTrueFalseTotal
if get_version() < 5 0 0 0
690 0 ▶ return if ($textfile eq '');
Branch: 1 branch
BranchTrueFalseTotal
if $textfile eq "" 0 0 0
691 0 ▶ return if ($textfile =~ /[^\w_\.-]/);
Branch: 1 branch
BranchTrueFalseTotal
if $textfile =~ /[^\w_\.-]/ 0 0 0
692 0 ▶ return if ($self->is_text_default($textfile));
Branch: 1 branch
BranchTrueFalseTotal
if $self->is_text_default($textfile) 0 0 0
693 0 ▶ ($self->_seterror(-1, "could not remove customized text file ($textfile)") && return 0)
Branch: 1 branch
BranchTrueFalseTotal
unless unlink qq[$self->{"LIST_NAME"}/text/$textfile] 0 0 0
Condition0%0/5
unlink("$self->{'LIST_NAME'}/text/$textfile") || $self->_seterror(-1, "could not remove customized text file ($textfile)") && (return 0)
l!l&&r!l&&!r
000
$self->_seterror(-1, "could not remove customized text file ($textfile)") and return 0
!ll
00
MC/DC0%0/2
unlink("$self->{'LIST_NAME'}/text/$textfile") || $self->_seterror(-1, "could not remove customized text file ($textfile)") && (return 0)
unlink("$self->{'LIST_NAME'}/text/$textfile") $self->_seterror(-1, "could not remove customized text file ($textfile)")
Truth table0%0/3
A || B
A= unlink("$self->{'LIST_NAME'}/text/$textfile")B= $self->_seterror(-1, "could not remove customized text file ($textfile)")
ABresult
1X1
011
000
694 unless unlink("$self->{'LIST_NAME'}/text/$textfile");
695 0 return 1;
696 }
697  
698  
699 # == return an error message if appropriate ==
700 0 ▶sub errmsg {
Subroutine errmsg: not called CC=1 SCAR=6.9
Pod undocumented
701 0 my($self) = @_;
702 0 return $self->{'ERRMSG'};
703 }
704  
705 0 ▶sub errno {
Subroutine errno: not called CC=1 SCAR=6.9
Pod undocumented
706 0 my($self) = @_;
707 0 return $self->{'ERRNO'};
708 }
709  
710 # == Test the compatiblity of the module ==
711 # return 0 for a valid version
712 # return the version string for an invalid version
713 0 ▶sub check_version {
Subroutine check_version: not called CC=3 SCAR=24.8
Pod undocumented
714 0 my $self = shift;
715 0 my $version = `$EZMLM_BASE/ezmlm-make -V 2>&1`;
716 0 ▶ $self->_seterror(undef) if (ref $self);
Branch: 1 branch
BranchTrueFalseTotal
if ref $self 0 0 0
717  
718 # ezmlm-idx is necessary
719 0 ▶ if (get_version() >= 4) {
Branch: 1 branch
BranchTrueFalseTotal
if (get_version() >= 4) { } 0 0 0
720 0 return 0;
721 } else {
722 0 return $version;
723 }
724 }
725  
726 # == get the major ezmlm version ==
727 # return values:
728 # 0 => unknown version
729 # 3 => ezmlm v0.53
730 # 4 => ezmlm-idx v0.4*
731 # 5 => ezmlm-idx v5.0
732 # 5.1 => ezmlm-idx v5.1
733 # 6 => ezmlm-idx v6.*
734 # 7 => ezmlm-idx v7.*
735 0 ▶sub get_version {
Subroutine get_version: not called CC=17 SCAR=57.2
Pod undocumented
736 0 my ($ezmlm, $idx);
737 0 my $version = `$EZMLM_BASE/ezmlm-make -V 2>&1`;
738  
739 0 ▶ $version = $1 if ($version =~ m/^[^:]*:\s+(.*)$/);
Branch: 1 branch
BranchTrueFalseTotal
if $version =~ /^[^:]*:\s+(.*)$/ 0 0 0
740 0 ▶ $ezmlm = $1 if ($version =~ m/ezmlm-([\d\.]+)$/);
Branch: 1 branch
BranchTrueFalseTotal
if $version =~ /ezmlm-([\d\.]+)$/ 0 0 0
741 0 ▶ $idx = $1 if ($version =~ m/ezmlm-idx-([\d\.]+)$/);
Branch: 1 branch
BranchTrueFalseTotal
if $version =~ /ezmlm-idx-([\d\.]+)$/ 0 0 0
742  
743 0 ▶ if (defined($ezmlm)) {
Branch: 2 branches
BranchTrueFalseTotal
if (defined $ezmlm) { } 0 0 0
elsif (defined $idx) { } 0 0 0
744 0 return 3;
745 } elsif (defined($idx)) {
746 0 ▶ if (($idx =~ m/^(\d)/) && ($1 >= 7)) {
Branch: 5 branches
BranchTrueFalseTotal
if ($idx =~ /^(\d)/ and $1 >= 7) { } 0 0 0
elsif ($idx =~ /^(\d)/ and $1 == 6) { } 0 0 0
elsif ($idx =~ /^(\d)\.(\d)/ and $1 >= 5 and $2 == 1) { } 0 0 0
elsif ($idx =~ /^(\d)/ and $1 >= 5) { } 0 0 0
elsif ($idx =~ /^0\.(\d)/ and $1 >= 0) { } 0 0 0
Condition0%0/3
$idx =~ /^(\d)/ and $1 >= 7
!ll&&!rl&&r
000
MC/DC0%0/2
$idx =~ /^(\d)/ and $1 >= 7
$idx =~ /^(\d)/ $1 >= 7
Truth table0%0/3
A and B
A= $idx =~ /^(\d)/B= $1 >= 7
ABresult
0X0
100
111
747 # version 6.0 or higher
748 0 return 7;
749 ▶ } elsif (($idx =~ m/^(\d)/) && ($1 == 6)){
Condition0%0/3
$idx =~ /^(\d)/ and $1 == 6
!ll&&!rl&&r
000
MC/DC0%0/2
$idx =~ /^(\d)/ and $1 == 6
$idx =~ /^(\d)/ $1 == 6
Truth table0%0/3
A and B
A= $idx =~ /^(\d)/B= $1 == 6
ABresult
0X0
100
111
750 0 return 6;
751 ▶ } elsif (($idx =~ m/^(\d)\.(\d)/) && ($1 >= 5) && ($2 == 1)) {
Condition0%0/6
$idx =~ /^(\d)\.(\d)/ and $1 >= 5 and $2 == 1
!ll&&!rl&&r
000
$idx =~ /^(\d)\.(\d)/ and $1 >= 5
!ll&&!rl&&r
000
MC/DC0%0/3
$idx =~ /^(\d)\.(\d)/ and $1 >= 5 and $2 == 1
$idx =~ /^(\d)\.(\d)/ $1 >= 5 $2 == 1
Truth table0%0/4
A and B and C
A= $idx =~ /^(\d)\.(\d)/B= $1 >= 5C= $2 == 1
ABCresult
0XX0
10X0
1100
1111
752 # version 5.1
753 0 return 5.1;
754 ▶ } elsif (($idx =~ m/^(\d)/) && ($1 >= 5)) {
Condition0%0/3
$idx =~ /^(\d)/ and $1 >= 5
!ll&&!rl&&r
000
MC/DC0%0/2
$idx =~ /^(\d)/ and $1 >= 5
$idx =~ /^(\d)/ $1 >= 5
Truth table0%0/3
A and B
A= $idx =~ /^(\d)/B= $1 >= 5
ABresult
0X0
100
111
755 # version 5.0
756 0 return 5;
757 ▶ } elsif (($idx =~ m/^0\.(\d)/) && ($1 >= 0)) {
Condition0%0/3
$idx =~ /^0\.(\d)/ and $1 >= 0
!ll&&!rl&&r
000
MC/DC0%0/2
$idx =~ /^0\.(\d)/ and $1 >= 0
$idx =~ /^0\.(\d)/ $1 >= 0
Truth table0%0/3
A and B
A= $idx =~ /^0\.(\d)/B= $1 >= 0
ABresult
0X0
100
111
758 # version 0.4xx
759 0 return 4;
760 } else {
761 0 return 0;
762 }
763 } else {
764 0 return 0;
765 }
766 }
767  
768 # == Create SQL Database tables if defined for a list ==
769 0 ▶sub createsql {
Subroutine createsql: not called CC=17 SCAR=57.2
Pod undocumented
770 0 my($self) = @_;
771  
772 0 ▶ ($self->_seterror(-1, 'MySQL must be compiled into Ezmlm for createsql() to work') && return 0) unless(defined($MYSQL_BASE) && $MYSQL_BASE);
Branch: 1 branch
BranchTrueFalseTotal
unless defined $Mail::Ezmlm::MYSQL_BASE and $Mail::Ezmlm::MYSQL_BASE 0 0 0
Condition0%0/8
defined $Mail::Ezmlm::MYSQL_BASE && $Mail::Ezmlm::MYSQL_BASE || $self->_seterror(-1, 'MySQL must be compiled into Ezmlm for createsql() to work') && (return 0)
l!l&&r!l&&!r
000
defined $Mail::Ezmlm::MYSQL_BASE and $Mail::Ezmlm::MYSQL_BASE
!ll&&!rl&&r
000
$self->_seterror(-1, "MySQL must be compiled into Ezmlm for createsql() to work") and return 0
!ll
00
MC/DC0%0/3
defined $Mail::Ezmlm::MYSQL_BASE && $Mail::Ezmlm::MYSQL_BASE || $self->_seterror(-1, 'MySQL must be compiled into Ezmlm for createsql() to work') && (return 0)
defined $Mail::Ezmlm::MYSQL_BASE $Mail::Ezmlm::MYSQL_BASE $self->_seterror(-1, "MySQL must be compiled into Ezmlm for createsql() to work")
Truth table0%0/5
A and B || C
A= defined $Mail::Ezmlm::MYSQL_BASEB= $Mail::Ezmlm::MYSQL_BASEC= $self->_seterror(-1, "MySQL must be compiled into Ezmlm for createsql() to work")
ABCresult
11X1
0X11
1011
0X00
1000
773 0 ▶ ($self->_seterror(-1, 'must setlist() before isdigest()') && return 0) unless(defined($self->{'LIST_NAME'}));
Branch: 1 branch
BranchTrueFalseTotal
unless defined $self->{"LIST_NAME"} 0 0 0
Condition0%0/5
defined $self->{'LIST_NAME'} || $self->_seterror(-1, 'must setlist() before isdigest()') && (return 0)
l!l&&r!l&&!r
000
$self->_seterror(-1, "must setlist() before isdigest()") and return 0
!ll
00
MC/DC0%0/2
defined $self->{'LIST_NAME'} || $self->_seterror(-1, 'must setlist() before isdigest()') && (return 0)
defined $self->{'LIST_NAME'} $self->_seterror(-1, "must setlist() before isdigest()")
Truth table0%0/3
A || B
A= defined $self->{'LIST_NAME'}B= $self->_seterror(-1, "must setlist() before isdigest()")
ABresult
1X1
011
000
774 0 my($config) = $self->getconfig();
775  
776 0 ▶ if($config =~ m/-6\s+'(.+?)'\s*/){
Branch: 1 branch
BranchTrueFalseTotal
if ($config =~ /-6\s+'(.+?)'\s*/) { } 0 0 0
777 0 my($sqlsettings) = $1;
778 0 my($host, $port, $user, $password, $database, $table) = split(':', $sqlsettings, 6);
779  
780 0 ▶ ($self->_seterror(-1, 'error in list configuration while trying createsql()') && return 0)
Branch: 1 branch
BranchTrueFalseTotal
unless defined $host and defined $port and defined $user and defined $password and defined $database and defined $table 0 0 0
Condition0%0/20
defined $host && defined $port && defined $user && defined $password && defined $database && defined $table || $self->_seterror(-1, 'error in list configuration while trying createsql()') && (return 0)
l!l&&r!l&&!r
000
defined $host and defined $port and defined $user and defined $password and defined $database and defined $table
!ll&&!rl&&r
000
defined $host and defined $port and defined $user and defined $password and defined $database
!ll&&!rl&&r
000
defined $host and defined $port and defined $user and defined $password
!ll&&!rl&&r
000
defined $host and defined $port and defined $user
!ll&&!rl&&r
000
defined $host and defined $port
!ll&&!rl&&r
000
$self->_seterror(-1, "error in list configuration while trying createsql()") and return 0
!ll
00
MC/DC0%0/7
defined $host && defined $port && defined $user && defined $password && defined $database && defined $table || $self->_seterror(-1, 'error in list configuration while trying createsql()') && (return 0)
defined $host defined $port defined $user defined $password defined $database defined $table $self->_seterror(-1, "error in list configuration while trying createsql()")
Truth table0%0/13
A and B and C and D and E and F || G
A= defined $hostB= defined $portC= defined $userD= defined $passwordE= defined $databaseF= defined $tableG= $self->_seterror(-1, "error in list configuration while trying createsql()")
ABCDEFGresult
111111X1
0XXXXX11
10XXXX11
110XXX11
1110XX11
11110X11
11111011
0XXXXX00
10XXXX00
110XXX00
1110XX00
11110X00
11111000
781 unless (defined($host) && defined($port) && defined($user)
782 && defined($password) && defined($database) && defined($table));
783  
784 0 ▶ system("$EZMLM_BASE/ezmlm-mktab -d $table | $MYSQL_BASE/mysql -h$host -P$port -u$user -p$password -f $database") == 0 ||
Branch: 1 branch
BranchTrueFalseTotal
system("$Mail::Ezmlm::EZMLM_BASE/ezmlm-mktab -d $table | $Mail::Ezmlm::MYSQL_BASE/mysql -h$host -P$port -u$user -p$password -f $database") == 0 or $self->_seterror($?) and return undef 0 0 0
Condition0%0/5
system("$Mail::Ezmlm::EZMLM_BASE/ezmlm-mktab -d $table | $Mail::Ezmlm::MYSQL_BASE/mysql -h$host -P$port -u$user -p$password -f $database") == 0 || $self->_seterror($?) && (return undef)
l!l&&r!l&&!r
000
$self->_seterror($?) and return undef
!ll
00
MC/DC0%0/2
system("$Mail::Ezmlm::EZMLM_BASE/ezmlm-mktab -d $table | $Mail::Ezmlm::MYSQL_BASE/mysql -h$host -P$port -u$user -p$password -f $database") == 0 || $self->_seterror($?) && (return undef)
system("$Mail::Ezmlm::EZMLM_BASE/ezmlm-mktab -d $table | $Mail::Ezmlm::MYSQL_BASE/mysql -h$host -P$port -u$user -p$password -f $database") == 0 $self->_seterror($?)
Truth table0%0/3
A || B
A= system("$Mail::Ezmlm::EZMLM_BASE/ezmlm-mktab -d $table | $Mail::Ezmlm::MYSQL_BASE/mysql -h$host -P$port -u$user -p$password -f $database") == 0B= $self->_seterror($?)
ABresult
1X1
011
000
785 ($self->_seterror($?) && return undef);
786  
787 } else {
788 0 $self->_seterror(-1, 'config for thislist() must include SQL options');
789 0 return 0;
790 }
791  
792 0 ▶ ($self->_seterror(undef) && return 1);
Branch: 1 branch
BranchTrueFalseTotal
$self->_seterror(undef) and return 1 0 0 0
793  
794 }
795  
796  
797 # == Internal function to set the error to return ==
798 0 ▶sub _seterror {
Subroutine _seterror: not called CC=7 SCAR=40.3
799 0 my($self, $no, $mesg) = @_;
800  
801 0 ▶ if(defined($no) && $no) {
Branch: 1 branch
BranchTrueFalseTotal
if (defined $no and $no) { } 0 0 0
Condition0%0/3
defined $no and $no
!ll&&!rl&&r
000
MC/DC0%0/2
defined $no and $no
defined $no $no
Truth table0%0/3
A and B
A= defined $noB= $no
ABresult
0X0
100
111
802 0 ▶ if($no < 0) {
Branch: 1 branch
BranchTrueFalseTotal
if ($no < 0) { } 0 0 0
803 0 $self->{'ERRNO'} = -1;
804 0 ▶ $self->{'ERRMSG'} = $mesg || 'An undefined error occoured';
Condition0%0/2
$mesg || 'An undefined error occoured'
l!l
00
MC/DC0%0/1
$mesg || 'An undefined error occoured'
$mesg
Truth table0%0/2
A
A= $mesg
Aresult
11
00
805 } else {
806 0 $self->{'ERRNO'} = $no / 256;
807 0 ▶ $self->{'ERRMSG'} = $! || $mesg || 'An undefined error occoured in a system() call';
Condition0%0/5
$! || $mesg || 'An undefined error occoured in a system() call'
l!l
00
$! or $mesg
l!l&&r!l&&!r
000
MC/DC0%0/2
$! || $mesg || 'An undefined error occoured in a system() call'
$! $mesg
Truth table0%0/3
A or B
A= $!B= $mesg
ABresult
1X1
011
000
808 }
809 } else {
810 0 $self->{'ERRNO'} = 0;
811 0 $self->{'ERRMSG'} = undef;
812 }
813 0 return 1;
814 }
815  
816 # == Internal function to test for valid email addresses ==
817 0 ▶sub _checkaddress {
Subroutine _checkaddress: not called CC=3 SCAR=24.8
818 0 my($self, $address) = @_;
819 0 ▶ return 1 unless defined($address);
Branch: 1 branch
BranchTrueFalseTotal
unless defined $address 0 0 0
820 0 ▶ return 0 unless ($address =~ m/^(\S+\@\S+\.\S+)$/);
Branch: 1 branch
BranchTrueFalseTotal
unless $address =~ /^(\S+\@\S+\.\S+)$/ 0 0 0
821 0 $_[1] = $1;
822 0 return 1;
823 }
824  
825 # == Internal function to work out a list configuration (idx >= v5.0) ==
826 0 ▶sub _getconfig_idx5 {
Subroutine _getconfig_idx5: not called CC=6 SCAR=37.4
827 0 my($self) = @_;
828 0 my ($options, %optionfiles);
829 0 my ($file, $opt_num, $temp);
830  
831 # read flag file (available since ezmlm-idx 5.0.0)
832 0 chomp($options = $self->getpart('flags'));
833 # remove prefixed '-'
834 0 $options =~ s/^-//;
835  
836 # since ezmlm-idx v5, we have to read the config
837 # values from different files
838 # first: preset a array with "filename" and "option_number"
839 0 %optionfiles = (
840 'sublist', 0,
841 'fromheader', 3,
842 'tstdigopts', 4,
843 'owner', 5,
844 'sql', 6,
845 'modpost', 7,
846 'modsub', 8,
847 'remote', 9);
848 0 ▶ while (($file, $opt_num) = each(%optionfiles)) {
Branch: 1 branch
BranchTrueFalseTotal
if (() = each %optionfiles) 0 0 0
849 0 ▶ if (-e "$self->{'LIST_NAME'}/$file") {
Branch: 1 branch
BranchTrueFalseTotal
if (-e qq[$self->{"LIST_NAME"}/$file]) 0 0 0
850 0 chomp($temp = $self->getpart($file));
851 0 $temp =~ m/^(.*)$/m; # take only the first line
852 0 $temp = $1;
853 # the 'owner' setting can be ignored if it is a path (starts with '/')
854 0 ▶ unless (($opt_num == 5) && ($temp =~ m#^/#)) {
Branch: 1 branch
BranchTrueFalseTotal
unless ($opt_num == 5 and $temp =~ m[^/]) 0 0 0
Condition0%0/3
$opt_num == 5 and $temp =~ m[^/]
!ll&&!rl&&r
000
MC/DC0%0/2
$opt_num == 5 and $temp =~ m[^/]
$opt_num == 5 $temp =~ m[^/]
Truth table0%0/3
A and B
A= $opt_num == 5B= $temp =~ m[^/]
ABresult
0X0
100
111
855 0 ▶ $options .= " -$opt_num '$temp'" if ($temp =~ /\S/);
Branch: 1 branch
BranchTrueFalseTotal
if $temp =~ /\S/ 0 0 0
856 }
857 }
858 }
859  
860 0 return $options;
861 }
862  
863 # == Internal function to work out a list configuration manually (idx < v5.0.0 ) ==
864 0 ▶sub _getconfigmanual {
Subroutine _getconfigmanual: not called CC=28 SCAR=67.0
865 # use this function for strange lists without
866 # 'config' (idx < v5.0) and 'flags' (idx >= v5.0)
867 0 my($self) = @_;
868 0 my ($savedollarslash, $options, $manager, $editor, $i);
869  
870 # Read the whole of DIR/editor and DIR/manager in
871 0 $savedollarslash = $/;
872 0 undef $/;
873 # $/ = \0777;
874  
875 0 ▶ open (EDITOR, "<$self->{'LIST_NAME'}/editor") || ($self->_seterror($?) && return undef);
Branch: 1 branch
BranchTrueFalseTotal
open EDITOR, qq[<$self->{"LIST_NAME"}/editor] or $self->_seterror($?) and return undef 0 0 0
Condition0%0/5
open(EDITOR, "<$self->{'LIST_NAME'}/editor") || $self->_seterror($?) && (return undef)
l!l&&r!l&&!r
000
$self->_seterror($?) and return undef
!ll
00
MC/DC0%0/2
open(EDITOR, "<$self->{'LIST_NAME'}/editor") || $self->_seterror($?) && (return undef)
open(EDITOR, "<$self->{'LIST_NAME'}/editor") $self->_seterror($?)
Truth table0%0/3
A || B
A= open(EDITOR, "<$self->{'LIST_NAME'}/editor")B= $self->_seterror($?)
ABresult
1X1
011
000
876 0 ▶ open (MANAGER, "<$self->{'LIST_NAME'}/manager") || ($self->_seterror($?) && return undef);
Branch: 1 branch
BranchTrueFalseTotal
open MANAGER, qq[<$self->{"LIST_NAME"}/manager] or $self->_seterror($?) and return undef 0 0 0
Condition0%0/5
open(MANAGER, "<$self->{'LIST_NAME'}/manager") || $self->_seterror($?) && (return undef)
l!l&&r!l&&!r
000
$self->_seterror($?) and return undef
!ll
00
MC/DC0%0/2
open(MANAGER, "<$self->{'LIST_NAME'}/manager") || $self->_seterror($?) && (return undef)
open(MANAGER, "<$self->{'LIST_NAME'}/manager") $self->_seterror($?)
Truth table0%0/3
A || B
A= open(MANAGER, "<$self->{'LIST_NAME'}/manager")B= $self->_seterror($?)
ABresult
1X1
011
000
877 0 $editor = <EDITOR>; $manager = <MANAGER>;
878 0 close(EDITOR), close(MANAGER);
879  
880 0 $/ = $savedollarslash;
881
882 0 $options = '';
883 0 ▶ $options .= 'a' if (-e "$self->{'LIST_NAME'}/archived");
Branch: 1 branch
BranchTrueFalseTotal
if -e qq[$self->{"LIST_NAME"}/archived] 0 0 0
884 0 ▶ $options .= 'd' if (-e "$self->{'LIST_NAME'}/digest");
Branch: 1 branch
BranchTrueFalseTotal
if -e qq[$self->{"LIST_NAME"}/digest] 0 0 0
885 0 ▶ $options .= 'f' if (-e "$self->{'LIST_NAME'}/prefix");
Branch: 1 branch
BranchTrueFalseTotal
if -e qq[$self->{"LIST_NAME"}/prefix] 0 0 0
886 0 ▶ $options .= 'g' if ($manager =~ /ezmlm-get -\w*s/ );
Branch: 1 branch
BranchTrueFalseTotal
if $manager =~ /ezmlm-get -\w*s/ 0 0 0
887 0 ▶ $options .= 'i' if (-e "$self->{'LIST_NAME'}/indexed");
Branch: 1 branch
BranchTrueFalseTotal
if -e qq[$self->{"LIST_NAME"}/indexed] 0 0 0
888 0 ▶ $options .= 'k' if (-e "$self->{'LIST_NAME'}/blacklist" || -e "$self->{'LIST_NAME'}/deny");
Branch: 1 branch
BranchTrueFalseTotal
if -e qq[$self->{"LIST_NAME"}/blacklist] or -e qq[$self->{"LIST_NAME"}/deny] 0 0 0
Condition0%0/3
-e qq[$self->{"LIST_NAME"}/blacklist] or -e qq[$self->{"LIST_NAME"}/deny]
l!l&&r!l&&!r
000
MC/DC0%0/2
-e qq[$self->{"LIST_NAME"}/blacklist] or -e qq[$self->{"LIST_NAME"}/deny]
-e qq[$self->{"LIST_NAME"}/blacklist] -e qq[$self->{"LIST_NAME"}/deny]
Truth table0%0/3
A or B
A= -e qq[$self->{"LIST_NAME"}/blacklist]B= -e qq[$self->{"LIST_NAME"}/deny]
ABresult
1X1
011
000
889 0 ▶ $options .= 'l' if ($manager =~ /ezmlm-manage -\w*l/ );
Branch: 1 branch
BranchTrueFalseTotal
if $manager =~ /ezmlm-manage -\w*l/ 0 0 0
890 0 ▶ $options .= 'm' if (-e "$self->{'LIST_NAME'}/modpost");
Branch: 1 branch
BranchTrueFalseTotal
if -e qq[$self->{"LIST_NAME"}/modpost] 0 0 0
891 0 ▶ $options .= 'n' if ($manager =~ /ezmlm-manage -\w*e/ );
Branch: 1 branch
BranchTrueFalseTotal
if $manager =~ /ezmlm-manage -\w*e/ 0 0 0
892 0 ▶ $options .= 'p' if (-e "$self->{'LIST_NAME'}/public");
Branch: 1 branch
BranchTrueFalseTotal
if -e qq[$self->{"LIST_NAME"}/public] 0 0 0
893 0 ▶ $options .= 'q' if ($manager =~ /ezmlm-request/ );
Branch: 1 branch
BranchTrueFalseTotal
if $manager =~ /ezmlm-request/ 0 0 0
894 0 ▶ $options .= 'r' if (-e "$self->{'LIST_NAME'}/remote");
Branch: 1 branch
BranchTrueFalseTotal
if -e qq[$self->{"LIST_NAME"}/remote] 0 0 0
895 0 ▶ $options .= 's' if (-e "$self->{'LIST_NAME'}/modsub");
Branch: 1 branch
BranchTrueFalseTotal
if -e qq[$self->{"LIST_NAME"}/modsub] 0 0 0
896 0 ▶ $options .= 't' if (-e "$self->{'LIST_NAME'}/text/trailer");
Branch: 1 branch
BranchTrueFalseTotal
if -e qq[$self->{"LIST_NAME"}/text/trailer] 0 0 0
897 0 ▶ $options .= 'u' if (($options !~ /m/ && $editor =~ /ezmlm-issubn \'/ )
Branch: 1 branch
BranchTrueFalseTotal
if not $options =~ /m/ and $editor =~ /ezmlm-issubn \'/ or $editor =~ /ezmlm-gate/ 0 0 0
Condition0%0/6
not $options =~ /m/ and $editor =~ /ezmlm-issubn \'/ or $editor =~ /ezmlm-gate/
l!l&&r!l&&!r
000
not $options =~ /m/ and $editor =~ /ezmlm-issubn \'/
!ll&&!rl&&r
000
MC/DC0%0/3
not $options =~ /m/ and $editor =~ /ezmlm-issubn \'/ or $editor =~ /ezmlm-gate/
not $options =~ /m/ $editor =~ /ezmlm-issubn \'/ $editor =~ /ezmlm-gate/
Truth table0%0/5
not(A) and B or C
A= not $options =~ /m/B= $editor =~ /ezmlm-issubn \'/C= $editor =~ /ezmlm-gate/
ABCresult
11X1
0X11
1011
0X00
1000
898 || $editor =~ /ezmlm-gate/ );
899 0 ▶ $options .= 'x' if (-e "$self->{'LIST_NAME'}/extra" || -e "$self->{'LIST_NAME'}/allow");
Branch: 1 branch
BranchTrueFalseTotal
if -e qq[$self->{"LIST_NAME"}/extra] or -e qq[$self->{"LIST_NAME"}/allow] 0 0 0
Condition0%0/3
-e qq[$self->{"LIST_NAME"}/extra] or -e qq[$self->{"LIST_NAME"}/allow]
l!l&&r!l&&!r
000
MC/DC0%0/2
-e qq[$self->{"LIST_NAME"}/extra] or -e qq[$self->{"LIST_NAME"}/allow]
-e qq[$self->{"LIST_NAME"}/extra] -e qq[$self->{"LIST_NAME"}/allow]
Truth table0%0/3
A or B
A= -e qq[$self->{"LIST_NAME"}/extra]B= -e qq[$self->{"LIST_NAME"}/allow]
ABresult
1X1
011
000
900  
901 # Add the unselected options too
902 # but we will skip invalid options (any of 'cevz')
903 0 foreach $i ('a' .. 'z') {
904 0 ▶ $options .= uc($i) unless (('cevz' =~ /$i/) || ($options =~ /$i/i))
Branch: 1 branch
BranchTrueFalseTotal
unless "cevz" =~ /$i/ or $options =~ /$i/i 0 0 0
Condition0%0/3
"cevz" =~ /$i/ or $options =~ /$i/i
l!l&&r!l&&!r
000
MC/DC0%0/2
"cevz" =~ /$i/ or $options =~ /$i/i
"cevz" =~ /$i/ $options =~ /$i/i
Truth table0%0/3
A or B
A= "cevz" =~ /$i/B= $options =~ /$i/i
ABresult
1X1
011
000
905 }
906
907 # there is no way to get the other string settings, that are only
908 # defined in 'config' - sorry ...
909
910 0 return $options;
911 }
912  
913 # == Internal Function to try to determine the vhost user ==
914 0 ▶sub _getvhostuser {
Subroutine _getvhostuser: not called CC=5 SCAR=34.0
915 0 my($self, $hostname) = @_;
916 0 my($username);
917  
918 0 ▶ open(VD, "<$QMAIL_BASE/control/virtualdomains") || ($self->_seterror($?) && return undef);
Branch: 1 branch
BranchTrueFalseTotal
open VD, "<$Mail::Ezmlm::QMAIL_BASE/control/virtualdomains" or $self->_seterror($?) and return undef 0 0 0
Condition0%0/5
open(VD, "<$Mail::Ezmlm::QMAIL_BASE/control/virtualdomains") || $self->_seterror($?) && (return undef)
l!l&&r!l&&!r
000
$self->_seterror($?) and return undef
!ll
00
MC/DC0%0/2
open(VD, "<$Mail::Ezmlm::QMAIL_BASE/control/virtualdomains") || $self->_seterror($?) && (return undef)
open(VD, "<$Mail::Ezmlm::QMAIL_BASE/control/virtualdomains") $self->_seterror($?)
Truth table0%0/3
A || B
A= open(VD, "<$Mail::Ezmlm::QMAIL_BASE/control/virtualdomains")B= $self->_seterror($?)
ABresult
1X1
011
000
919 0 ▶ while(<VD>) {
Branch: 1 branch
BranchTrueFalseTotal
if (defined($_ = readline VD)) 0 0 0
920 0 ▶ last if(($username) = /^\s*$hostname:(\w+)$/);
Branch: 1 branch
BranchTrueFalseTotal
if ($username) = /^\s*$hostname:(\w+)$/ 0 0 0
921 }
922 0 close VD;
923  
924 0 return $username;
925 }
926  
927 # == Internal function to work out default host name ==
928 0 ▶sub _getdefaultdomain {
Subroutine _getdefaultdomain: not called CC=4 SCAR=30.0
929 0 my($self) = @_;
930 0 my($hostname);
931  
932 0 ▶ open (GETHOST, "<$QMAIL_BASE/control/defaultdomain")
Branch: 1 branch
BranchTrueFalseTotal
open GETHOST, "<$Mail::Ezmlm::QMAIL_BASE/control/defaultdomain" or open GETHOST, "<$Mail::Ezmlm::QMAIL_BASE/control/me" or $self->_seterror($?) and return undef 0 0 0
Condition0%0/8
open(GETHOST, "<$Mail::Ezmlm::QMAIL_BASE/control/defaultdomain") || open(GETHOST, "<$Mail::Ezmlm::QMAIL_BASE/control/me") || $self->_seterror($?) && (return undef)
l!l&&r!l&&!r
000
open GETHOST, "<$Mail::Ezmlm::QMAIL_BASE/control/defaultdomain" or open GETHOST, "<$Mail::Ezmlm::QMAIL_BASE/control/me"
l!l&&r!l&&!r
000
$self->_seterror($?) and return undef
!ll
00
MC/DC0%0/3
open(GETHOST, "<$Mail::Ezmlm::QMAIL_BASE/control/defaultdomain") || open(GETHOST, "<$Mail::Ezmlm::QMAIL_BASE/control/me") || $self->_seterror($?) && (return undef)
open GETHOST, "<$Mail::Ezmlm::QMAIL_BASE/control/defaultdomain" open GETHOST, "<$Mail::Ezmlm::QMAIL_BASE/control/me" $self->_seterror($?)
Truth table0%0/4
A or B || C
A= open GETHOST, "<$Mail::Ezmlm::QMAIL_BASE/control/defaultdomain"B= open GETHOST, "<$Mail::Ezmlm::QMAIL_BASE/control/me"C= $self->_seterror($?)
ABCresult
1XX1
01X1
0011
0000
933 || open (GETHOST, "<$QMAIL_BASE/control/me")
934 || ($self->_seterror($?) && return undef);
935 0 chomp($hostname = <GETHOST>);
936 0 close GETHOST;
937  
938 0 return $hostname;
939 }
940  
941 1 1;
942 __END__
↑ Summary Ezmlm/GpgEzmlm.pm »