I'm enclosing the diffs between majordomo-1.93 resend
and the one I use.
There are several changes included here:
o it includes some hopefully improved error handling.
o it relaxes the location of the inbody "Approved" header.
I needed this to accomdate MIME messages without having
to teach resend about the MIME format.
o If an inbody "Approved" header is found the
headers from the message are used if
no headers are found after it. This
should reduce the number moderated messages that
get "Apparently-To" headers
o a -i option that disables the processing of in
body headers. This means that for moderated
lists the headers of the message as received
by resend are used. This is generally useful
only for lists in which the persons submitting
the posting already know the "Approved" password
o there are some cosmetic changes
It's really hard to talk about this stuff since
there are several different sets of "headers".
arnold
*** 1.1 1995/02/24 19:55:59
--- resend 1995/04/27 20:35:51
***************
*** 58,69 ****
chdir($homedir) || die("Can't chdir(\"$homedir\"): $!");
unshift(@INC, $homedir);
require "majordomo.pl";
require "majordomo_version.pl";
require "getopts.pl";
require "config_parse.pl";
! &Getopts("Aa:df:h:I:l:m:M:p:Rr:s") || die("resend: Getopts() failed: $!");
if (! defined($opt_l) || ! defined($opt_h)) {
die("resend: must specify both '-l list' and '-h host' arguments");
--- 58,71 ----
chdir($homedir) || die("Can't chdir(\"$homedir\"): $!");
unshift(@INC, $homedir);
+ unshift(@INC,"$homedir/etc");
require "majordomo.pl";
require "majordomo_version.pl";
require "getopts.pl";
+ require "sysexits.ph";
require "config_parse.pl";
! &Getopts("Aa:df:h:I:il:m:M:p:Rr:s") || die("resend: Getopts() failed: $!");
if (! defined($opt_l) || ! defined($opt_h)) {
die("resend: must specify both '-l list' and '-h host' arguments");
***************
*** 96,101 ****
--- 98,104 ----
if ($config_opts{$opt_l,"reply_to"} ne '');
$opt_I = $config_opts{$opt_l,"restrict_post"}
if ($config_opts{$opt_l,"restrict_post"} ne '');
+ $opt_i = 1 if defined($opt_i);
$opt_R = &cf_ck_bool($opt_l,"purge_received")
if &cf_ck_bool($opt_l,"purge_received");
$opt_s = &cf_ck_bool($opt_l,"administrivia")
***************
*** 133,206 ****
}
close(IN);
open(IN, "/tmp/resend.$$.in") ||
! die("resend: Can't open /tmp/resend.$$.tmp: $!");
!
! do {
$restart = 0;
- $pre_hdr = 1;
while (<IN>) {
if ($pre_hdr) {
- if (/^\s*$/) {
# skip leading blank lines; usually only there if this is a
# restart after an in-body "Approved:" line
! next;
! } else {
$pre_hdr = 0;
- $in_hdr = 1;
$kept_last = 0;
! }
}
if ($in_hdr) {
if (/^\s*$/) {
! # end of header; add new header fields
! print OUT "Sender: $sender\n";
! if (defined($opt_p)) {
! print OUT "Precedence: $opt_p\n";
! }
! if (defined($opt_r)) {
! print OUT "Reply-To: ", &config'substitute_values($opt_r),
! "\n";
! }
!
! # print out additonal headers
! if ( $config_opts{$opt_l,"message_headers"} ne '' ) {
! local($headers) = &config'substitute_values (
! $config_opts{$opt_l,"message_headers"}, $opt_l);
$headers =~ s/\001/\n/g;
! print OUT $headers;
! }
!
! $in_hdr = 0;
! print OUT $_;
!
! # print out front matter
! if ( $config_opts{$opt_l,"message_fronter"} ne '' ) {
! local($fronter) = &config'substitute_values (
! $config_opts{$opt_l,"message_fronter"}, $opt_l);
! $fronter =~ s/\001|$/\n/g;
! print OUT $fronter;
! }
} elsif (/^approved:\s*(.*)/i && defined($opt_a)) {
! $approved = &chop_nl($1);
! if ($approved ne $opt_a &&
! !(&main'valid_passwd($listdir, $opt_l, $approved))) {
! &bounce("Invalid 'Approved:' header");
! }
} elsif (/^from /i # skip all these headers
! || /^sender:/i
! || /^return-receipt-to:/i
! || /^errors-to:/i
! || /^return-path:/i
! || (/^reply-to:/i && defined($opt_r)) # skip only if "-r" set
! || (/^precedence:/i && defined($opt_p)) # skip only if "-p" set
! || (/^received:/i && defined($opt_R)) # skip only if "-R" set
! || (/^\s/ && ! $kept_last) # skip if skipped last
! ) {
! # reset $kept_last in case next line is continuation
! $kept_last = 0;
! } else {
# check for administrivia requests
if (defined($opt_s) && ! defined($approved)
&& (/^subject:\s*subscribe\b/i ||
--- 136,211 ----
}
close(IN);
+ &abort("resend: Can't finish writing /tmp/resend.$$.in: $!") if $?;
open(IN, "/tmp/resend.$$.in") ||
! &abort("resend: Can't open /tmp/resend.$$.tmp: $!");
! $pre_hdr = 0;
! $in_hdr = 1;
! RESTART: do {
$restart = 0;
while (<IN>) {
if ($pre_hdr) {
# skip leading blank lines; usually only there if this is a
# restart after an in-body "Approved:" line
! next if (/^\s*$/);
$pre_hdr = 0;
$kept_last = 0;
! if ((/^[a-z\-]+:.*/i) && (!$opt_i)) {
! # found a header during restart so
! # start over
! $in_hdr = 1;
! close(OUT);
! &abort("resend: Can't finish writing /tmp/resend.$$.out: $!") if $?;
! unlink("/tmp/resend.$$.out");
! open(OUT, ">/tmp/resend.$$.out") ||
! &abort("resend: Can't open /tmp/resend.$$.out: $!");
! }
!
}
if ($in_hdr) {
if (/^\s*$/) {
! # end of header; add new header fields
! print OUT "Sender: $sender\n";
! print OUT "Precedence: $opt_p\n" if (defined($opt_p));
! print OUT "Reply-To: ", &config'substitute_values($opt_r), "\n"
! if (defined($opt_r));
!
! # print out additional headers they exists
! local($headers) = &config'substitute_values($config_opts{$opt_l,"message_headers"}, $opt_l)
! if ( $config_opts{$opt_l,"message_headers"} ne '' );
$headers =~ s/\001/\n/g;
! print OUT $headers if $headers;
!
! print OUT $_;
! $in_hdr = 0;
!
! # print out front matter
! if ( $config_opts{$opt_l,"message_fronter"} ne '' ) {
! local($fronter) = &config'substitute_values (
! $config_opts{$opt_l,"message_fronter"}, $opt_l);
! $fronter =~ s/\001|$/\n/g;
! print OUT $fronter;
! }
} elsif (/^approved:\s*(.*)/i && defined($opt_a)) {
! $approved = &chop_nl($1);
! if ($approved ne $opt_a &&
! !(&main'valid_passwd($listdir, $opt_l, $approved))) {
! &bounce("Invalid 'Approved:' header");
! }
} elsif (/^from /i # skip all these headers
! || /^sender:/i
! || /^return-receipt-to:/i
! || /^errors-to:/i
! || /^return-path:/i
! || (/^reply-to:/i && defined($opt_r)) # skip only if "-r" set
! || (/^precedence:/i && defined($opt_p)) # skip only if "-p" set
! || (/^received:/i && defined($opt_R)) # skip only if "-R" set
! || (/^\s/ && ! $kept_last) # skip if skipped last
! ) {
! # reset $kept_last in case next line is continuation
! $kept_last = 0;
! } else { # not in header any more
# check for administrivia requests
if (defined($opt_s) && ! defined($approved)
&& (/^subject:\s*subscribe\b/i ||
***************
*** 247,257 ****
&check_hdr_line($_); # check for length & balance
$kept_last = 1;
print OUT $_;
! }
} else {
! # this isn't a header line, so print it (maybe)
! # first, though, is the first line of the body an "Approved:" line?
! if (($body_len == 0) && /^approved:\s*(.*)/i && defined($opt_a)) {
# OK, is it a valid "Approved:" line?
$approved = &chop_nl($1);
if ($approved ne $opt_a &&
--- 252,266 ----
&check_hdr_line($_); # check for length & balance
$kept_last = 1;
print OUT $_;
! }
} else {
! # this is not a header line, so print it (maybe)
! # first, though, is the first real line the
! # body an "Approved:" line?
! # 1000 allows us to skip past separators that
! # mime be present like in MIME message
! # this should probably be a config variable
! if (($body_len <= 1000) && /^approved:\s*(.*)/i && defined($opt_a)) {
# OK, is it a valid "Approved:" line?
$approved = &chop_nl($1);
if ($approved ne $opt_a &&
***************
*** 261,270 ****
# Yes, it's a valid "Approved:" line...
# So, we start over
$restart = 1;
! close(OUT);
! unlink("/tmp/resend.$$.out");
! &open_temp(OUT, "/tmp/resend.$$.out") ||
! &abort("resend:2 Can't open /tmp/resend.$$.out: $!");
last;
}
}
--- 270,276 ----
# Yes, it's a valid "Approved:" line...
# So, we start over
$restart = 1;
! $pre_hdr = 1;
last;
}
}
***************
*** 316,321 ****
--- 322,328 ----
}
close(OUT);
+ &abort("resend: Can't finish writing /tmp/resend.$$.out: $!") if $?;
if ( defined($opt_I) && defined($from) && ! defined($approved) ) {
local($infile) = 0;
***************
*** 335,352 ****
last;
}
} else {
! die("resend:a Can't open $file: $!");
}
}
- if ( $infile == 0 ) {
- &bounce ("Non-member submission from [$from]");
- }
- }
! if (defined($opt_A) && ! defined($approved)) {
! &bounce("Approval required");
}
$sendmail_cmd = "/usr/lib/sendmail $opt_m -f$sendmail_sender " .
join(" ", @ARGV);
--- 342,356 ----
last;
}
} else {
! &abort("resend:a Can't open $file: $!");
}
}
! &bounce ("Non-member submission from [$from]") if ( $infile == 0 );
}
+
+ &bounce("Approval required") if (defined($opt_A) && ! defined($approved));
$sendmail_cmd = "/usr/lib/sendmail $opt_m -f$sendmail_sender " .
join(" ", @ARGV);
***************
*** 366,371 ****
--- 370,377 ----
print MAILOUT $_;
}
close(MAILOUT);
+ local($status) = ($? >>8);
+ exit(&EX_TEMPFAIL) if ($status == &EX_TEMPFAIL); # requeue if delivery fails
close(MAILIN);
unlink(</tmp/resend.$$.*>);
exit(0);
|
|