/usr/lib/news/bin/mailpost is in inn2 2.6.1-4build1.
This file is owned by root:root, with mode 0o755.
The actual contents of the file can be viewed below.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 465 466 467 468 469 470 471 472 473 474 475 476 477 478 479 480 481 482 483 484 485 486 487 488 489 490 491 492 493 494 495 496 497 498 499 500 501 502 503 504 505 506 507 508 509 510 511 512 513 514 515 516 517 518 519 520 521 522 523 524 525 526 527 528 529 530 531 532 533 534 535 536 537 538 539 540 541 542 543 544 545 546 547 548 549 550 551 552 553 554 555 556 557 558 559 560 561 562 563 564 565 566 567 568 569 570 571 572 573 574 575 576 577 578 579 580 581 582 583 584 585 586 587 588 589 590 591 592 593 594 595 596 597 598 599 600 601 602 603 604 605 606 607 608 609 610 611 612 613 614 615 616 617 618 619 620 621 622 623 624 625 626 627 628 629 630 631 632 633 634 635 636 637 638 639 640 641 642 643 644 645 646 647 648 649 650 651 652 653 654 655 656 657 658 659 660 661 662 663 664 665 666 667 668 669 670 671 672 673 674 675 676 677 678 679 680 681 682 683 684 685 686 687 688 689 690 691 692 693 694 695 696 697 698 699 700 701 702 703 704 705 706 707 708 709 710 711 712 713 714 715 716 717 718 719 720 721 722 723 724 725 726 727 728 729 730 731 732 733 734 735 736 737 738 739 740 741 742 743 744 745 746 747 748 749 750 751 752 753 754 755 756 757 758 759 760 761 762 763 764 765 766 767 768 769 770 771 772 773 774 775 776 777 778 779 780 781 782 783 784 785 786 787 788 789 790 791 792 793 794 795 796 797 798 799 800 801 802 803 804 | #! /usr/bin/perl -w
use lib '/usr/share/perl5'; use INN::Config;
# mailpost - Yet another mail-to-news filter
#
# $Id: mailpost.in 10076 2016-10-08 20:37:36Z iulius $
#
# 21feb00 [added "lc" to duplicate header fixer stmt to make it case-insensitive]
# doka 11may99 [fixed duplicate headers problem]
# brister 19oct98 [cleaned up somewhat for Perl v. 5. and made a little more robust]
# vixie 29jan95 [RCS'd]
# vixie 15jun93 [added -m]
# vixie 30jun92 [added -a and -d]
# vixie 17jun92 [attempt simple-minded fixup to $path]
# vixie 14jun92 [original]
use Getopt::Std;
use IPC::Open3;
use IO::Select;
use POSIX qw(setsid);
use Sys::Hostname;
use INN::Utils::Shlock;
use strict;
my $debugging = 0 ;
my $tmpfile ;
my $tmpfile2 ;
my $msg ;
END {
unlink ($tmpfile) if $tmpfile; # in case we die()
unlink ($tmpfile2) if $tmpfile2; # in case we die()
# In case we bail out, typically by calling mailArtAndDie(), while
# holding a lock.
INN::Utils::Shlock::releaselocks();
}
my $usage = $0 ;
$usage =~ s!.*/!! ;
my $prog = $usage ;
my $use_syslog = 0;
eval { require Sys::Syslog; import Sys::Syslog; $use_syslog = 1; };
if ($use_syslog) {
if ($Sys::Syslog::VERSION lt 0.15) {
eval "sub Sys::Syslog::_PATH_LOG { '/dev/log' }" if $^O eq 'dec_osf';
Sys::Syslog::setlogsock('unix') if $^O =~ /linux|dec_osf|freebsd|darwin/;
}
openlog($prog, 'pid', $INN::Config::syslog_facility);
}
$usage .= "[ -h ][ -n ][ -r addr ][ -f addr ][ -a approved ][ -d distribution ]" .
"[ -m mailing-list ][ -b database ][ -o output-path ][ -c wait-time ]" .
"[ -x header[:header...] ][ -p port ][ -t tempdir ] newsgroups" ;
use vars qw($opt_r $opt_f $opt_a $opt_d $opt_m $opt_b $opt_n $opt_o $opt_h $opt_c $opt_x $opt_p $opt_t) ;
getopts("hr:f:a:d:m:b:no:c:x:p:t:") || die "usage: $usage\n" ;
die "usage: $usage\n" if $opt_h ;
#
# $Submit is a program which takes no arguments and whose stdin is supposed
# to be a news article (without the #!rnews header but with the news hdr).
#
my $Sendmail = $INN::Config::mta ;
my $Submit = $INN::Config::inews . " -S -h" . ($opt_p ? " -p $opt_p" : '');
my $Maintainer = $INN::Config::newsmaster || "usenet" ;
my $WhereTo = $opt_o || $Submit ;
my $Mailname = $INN::Config::fromhost || hostname ;
my $Databasedir = $opt_b || $INN::Config::pathdb;
die "Database path $Databasedir is not a directory\n" unless -d $Databasedir;
die "Database directory $Databasedir is not writable\n" unless -w $Databasedir;
my $Database = $Databasedir . "/mailpost-msgid" ;
# Can't always use $INN::Config::pathtmp as we're usually not running as news.
my $Tmpdir = $opt_t || (-w $INN::Config::pathtmp ? $INN::Config::pathtmp : "/var/tmp");
die "Path $Tmpdir is not a directory\n" unless -d $Tmpdir;
die "Directory $Tmpdir is not writable\n" unless -w $Tmpdir;
if ($debugging || $opt_n) {
$Sendmail = "cat" ;
$WhereTo = "cat" ;
} else {
$Sendmail = sprintf($Sendmail, $Maintainer);
}
#
# Our command-line argument(s) are the list of newsgroups to post to.
#
# There may be a "-r sender" or "-f sender" which becomes the $path
# (which is in turn overridden below by various optional headers).
#
# -d (distribution) and -a (approved) are also supported to supply
# or override the mail headers by those names.
#
my $path = 'nobody';
my $newsgroups = undef;
my $approved = undef;
my $distribution = undef;
my $mailing_list = undef;
my $references = undef;
my @errorText = ();
if ($opt_r || $opt_f) {
$path = $opt_r || $opt_f ;
push @errorText, "((path: $path))\n" ;
}
if ($opt_a) {
$approved = &fix_sender_addr($opt_a);
push @errorText, "((approved: $approved))\n";
}
if ($opt_d) {
$distribution = $opt_d ;
push @errorText, "((distribution: $distribution))\n";
}
if ($opt_m) {
$mailing_list = "<" . $opt_m . "> /dev/null";
push @errorText, "((mailing_list: $mailing_list))\n";
}
my $exclude = 'Archive|Archived-At|Comments|Distribution|Injection-Date|Keywords|Organization|Summary';
if ($opt_x) {
$exclude .= '|' . join('|', split(/:/, $opt_x));
}
$newsgroups = join ",", @ARGV ;
die "usage: $0 newsgroup [newsgroup ...]\n" unless $newsgroups;
#
# Do the header. Our input is a mail message, with or without the From.
#
#$message_id = sprintf("<mailpost.%d.%d@%s>", time, $$, $Hostname);
my $real_news_hdrs = '';
my $weird_mail_hdrs = '';
my $fromHdr = "MAILPOST-UNKNOWN-FROM" ;
my $dateHdr= "MAILPOST-UNKNOWN-DATE" ;
my $msgIdHdr = "MAILPOST-UNKNOWN-MESSAGE-ID" ;
my $from = undef;
my $date = undef;
my $hdr = undef;
my $txt = undef;
my $message_id ;
my $subject = "(NONE)";
my @emptyHdrs = ();
my $emptyHdrsString;
$_ = <STDIN>;
if (!$_) {
if ( $debugging || -t STDERR ) {
die "empty input" ;
} else {
syslog("err", "empty input") if ($use_syslog);
exit (0) ;
}
}
# Remove (CR)LF at the end of each line.
s/\r?\n$//;
my $line = undef;
if (/^From\s+([^\s]+)\s+/) {
$path = $1;
push @errorText, "((path: $path))\n";
$_ = $';
if (/ remote from /) {
$path = $' . '!' . $path;
$_ = $`;
}
} else {
$line = $_;
}
for (;;) {
last if defined($line) && ($line =~ /^$/) ;
$_ = <STDIN> ;
last unless defined $_ ;
# Remove (CR)LF at the end of each line.
s/\r?\n$//;
# Gather up a single header with possible continuation lines into $line.
if (/^\s+/) {
if (! $line) {
$msg = "First line with leading whitespace!" ;
if ($use_syslog) {
syslog("err", $msg) unless -t STDERR;
}
die "$msg\n" ;
}
$line .= "\n" . $_ ;
next ;
}
# Add a space after the colon following a header name, if not present.
s/:/: / if ($_ !~ /^[^:]+: /);
# On the first header, $line will be undefined.
($_, $line) = ($line, $_) ; # Swap $line and $_.
last if defined($_) && /^$/;
next unless defined($_); # Only on first header will this happen.
push @errorText, "($_)\n";
next if /^Approved:\s/sio && defined($approved);
next if /^Distribution:\s/sio && defined($distribution);
# Remove empty header lines within header body.
s/\n[ \t]+\n/\n/g; # middle lines in header field
s/\n[ \t]+$//; # last line in header field
s/^([^:]+:[ \t]+)\n/$1/; # first line in header field
# Collect empty header field names.
if (/^([^:]+):\s*$/) {
# 975 = 998 - length("X-Mailpost-Empty-Hdrs: ")
push(@emptyHdrs, $1) if length($1) < 975;
next;
}
if (/^($exclude):\s*/sio) {
$real_news_hdrs .= "$_\n";
next;
}
if (/^Subject:\s*/sio) {
$subject = $';
next;
}
if (/^Message-ID:\s*/sio) {
$message_id = $';
next;
}
if (/^Mailing-List:\s*/sio) {
$mailing_list = $';
next;
}
if (/^(Sender|Approved):\s*/sio) {
$real_news_hdrs .= "$&" . fix_sender_addr($') . "\n";
next;
}
if (/^Return-Path:\s*/sio) {
$path = $';
$path = $1 if ($path =~ /\<([^\>]*)\>/);
push @errorText, "((path: $path))\n";
next;
}
if (/^Date:\s*/sio) {
$date = $';
next;
}
if (/^From:\s*/sio) {
$from = &fix_sender_addr($');
next;
}
if (/^References:\s*/sio) {
$references = $';
# 986 = 998 (maximum per RFC 5536) - length("References: ")
if (length($references) > 985) {
my @refarray = ( $references =~ /(<.*?>)/g );
# Keep only the first and the last two message-IDs, per RFC 5537.
#
# Remove the header in case we do not have at least 3 message-IDs
# because it then probably means that the header is broken, or
# contains CFWS that we do not deal with.
if (scalar(@refarray) > 2) {
my $last_mid = pop(@refarray);
$references = shift(@refarray) . ' ' . pop(@refarray) . ' ' . $last_mid;
} else {
$references = undef;
}
}
next;
}
if (!defined($references) && /^In-Reply-To:[^\<]*\<([^\>]+)\>/sio) {
$references = "<$1>";
# FALLTHROUGH
}
if (/^(MIME|Content)-[^:]+:\s*/sio) {
$real_news_hdrs .= $_ . "\n" ;
next ;
}
# Strip out news X-Trace: and X-Complaints-To: headers since otherwise posting
# may fail. Other trace headers will be renamed to add 'X-' so we don't have
# to worry about them.
if (/^X-(Trace|Complaints-To):\s*/sio) {
next ;
}
# Random unknown header. Prepend 'X-' if it is not already there.
$_ = "X-$_" unless /^X-/sio ;
$weird_mail_hdrs .= "$_\n";
}
$msgIdHdr = $message_id if $message_id ;
$fromHdr = $from if $from ;
$dateHdr = $date if $date ;
if ($path !~ /\!/) {
$path = "$'!$`" if ($path =~ /\@/);
}
$real_news_hdrs .= "Subject: ${subject}\n";
$real_news_hdrs .= "Message-ID: ${msgIdHdr}\n" if defined($message_id);
$real_news_hdrs .= "Mailing-List: ${mailing_list}\n" if defined($mailing_list);
$real_news_hdrs .= "Distribution: ${distribution}\n" if defined($distribution);
$real_news_hdrs .= "Approved: ${approved}\n" if defined($approved);
$real_news_hdrs .= "References: ${references}\n" if defined($references);
# Keep trace of empty header fields.
$emptyHdrsString = join("\n\t", @emptyHdrs);
$real_news_hdrs .= "X-Mailpost-Empty-Hdrs: $emptyHdrsString\n"
if (length($emptyHdrsString) > 0);
# Remove duplicate headers.
my %headers = ();
$real_news_hdrs =~ s/((.*?:) .*?($|\n)([ \t]+.*?($|\n))*)/$headers{lc$2}++?"":"$1"/ges;
# inews writes error messages to stdout. We want to capture those and mail
# them back to the newsmaster. Trying to write and read from a subprocess is
# ugly and prone to deadlock, so we use a temp file.
$tmpfile = sprintf "%s/mailpost.%d.%d", $Tmpdir, time, $$ ;
if (!open TMPFILE,">$tmpfile") {
$msg = "can't open temp file ($tmpfile): $!" ;
$tmpfile = undef ;
if ($use_syslog) {
syslog("err", "$msg") unless $debugging || -t STDERR;
}
open(TMPFILE, "|" . $Sendmail) ||
die "die(no tmpfile): sendmail: $!\n" ;
print TMPFILE <<"EOF";
To: $Maintainer
Subject: mailpost failure ($newsgroups): $msg
-------- Article Contents
EOF
}
print TMPFILE <<"EOF";
Path: ${path}
From: ${fromHdr}
Newsgroups: ${newsgroups}
${real_news_hdrs}Date: ${dateHdr}
${weird_mail_hdrs}
EOF
my $rest = '';
$rest .= $_ while (<STDIN>);
$rest =~ s/\n*$/\n/g; # Remove trailing \n except very last.
print TMPFILE $rest;
close TMPFILE ;
if ( ! $tmpfile ) {
# We had to bail and mail the article to the admin.
print STDERR "The creation of the temporary file $tmpfile failed.\n" if -t STDERR;
exit(1);
}
##
## We've got the article in a temp file and now we validate some of the
## data we found and update our Message-ID database.
##
mailArtAndDie ("no From: found") unless $from;
mailArtAndDie ("no Message-ID: found") unless $message_id;
mailArtAndDie ("Malformed Message-ID ($message_id)")
if ($message_id !~ /\<(\S+)\@(\S+)\>/);
# Update (with locking) our Message-ID database. This is used to make sure we
# don't loop our own gatewayed articles back through the mailing list.
my ($lhs, $rhs) = ($1, $2); # Of message_id matched above.
$rhs =~ tr/A-Z/a-z/;
$message_id = "${lhs}\@${rhs}";
push @errorText, "(TAS message-ID database for $message_id)\n";
my $lockfile = sprintf("%s.lock", $Database);
# Acquire a lock.
INN::Utils::Shlock::lock($lockfile, 5) or mailArtAndDie ("cannot create lockfile $lockfile");
my %DATABASE ;
dbmopen(%DATABASE, $Database, 0666) || mailArtAndDie ("can't dbmopen $Database: $!");
if (defined $DATABASE{$message_id}) {
if (!$opt_c) {
syslog("err", "Duplicate article <$message_id>.") if $use_syslog;
print STDERR "Duplicate article <$message_id>.\n" if -t STDERR;
exit(1);
}
## crosspost -c
$newsgroups = &append_newsgroups($DATABASE{$message_id}, $newsgroups) ;
syslog("err", "crosspost $newsgroups") if $debugging && $use_syslog;
}
#$DATABASE{$message_id} = sprintf "%d.%s", time, 'mailpost' ;
$DATABASE{$message_id} = $newsgroups ;
mailArtAndDie ("TAS didn't set $message_id") unless defined $DATABASE{$message_id};
dbmclose(%DATABASE) || mailArtAndDie ("can't dbmclose $Database: $!") ;
# Unlock.
INN::Utils::Shlock::unlock($lockfile) or mailArtAndDie ("cannot unlock $lockfile");
## For crosspost.
if ($opt_c) {
my $pid = fork();
if (!defined($pid)) {
undef $tmpfile; # Don't unlink $tmpfile.
print STDERR "An error occurred during the fork.\n" if -t STDERR;
exit(1);
}
if ($pid != 0) { # Parent.
undef $tmpfile; # Don't unlink $tmpfile.
exit(0);
}
close STDIN;
close STDOUT;
close STDERR;
setsid();
open (STDIN, "</dev/zero");
open (STDOUT, ">/dev/null");
open (STDERR, ">&STDOUT");
sleep $opt_c ;
# Acquire a lock.
INN::Utils::Shlock::lock($lockfile, 5) or mailArtAndDie ("cannot create lockfile $lockfile");
my $umask_bak = umask();
umask(000);
dbmopen(%DATABASE, $Database, 0666) || mailArtAndDie ("can't dbmopen $Database: $!");
umask($umask_bak);
my $dup = undef ;
syslog("err", "check " . $DATABASE{$message_id} . " : $newsgroups") if $debugging && $use_syslog;
$dup = 1 if ($DATABASE{$message_id} ne $newsgroups) ;
dbmclose(%DATABASE) || mailArtAndDie ("can't dbmclose $Database: $!") ;
# Unlock.
INN::Utils::Shlock::unlock($lockfile) or mailArtAndDie ("cannot unlock $lockfile");
if (defined($dup)) {
syslog("err", "mismatch $newsgroups") if $debugging && $use_syslog;
exit(1);
}
# Replace Newsgroups:.
open(TMPFILE, "$tmpfile") || mailArtAndDie ("can't open temp file ($tmpfile): $!") ;
$tmpfile2 = sprintf "%s/mailpost-crosspost.%d.%d", $Tmpdir, time, $$ ;
if ( !open TMPFILE2, ">$tmpfile2") {
$msg = "can't open temp file ($tmpfile2): $!" ;
$tmpfile2 = undef ;
die $msg ;
}
for (;;) {
$_ = <TMPFILE> ;
# Remove (CR)LF at the end of each line.
s/\r?\n$//;
last if defined($_) && /^$/ ;
if (/^Newsgroups:\s*/sio) {
printf TMPFILE2 "Newsgroups: %s\n", $newsgroups ;
next ;
}
print TMPFILE2 "$_\n" ;
}
printf TMPFILE2 "\n" ;
my $rest = '';
$rest .= $_ while (<TMPFILE>);
$rest =~ s/\n*$/\n/g; # Remove trailing \n except very last.
print TMPFILE2 $rest;
close TMPFILE2 ;
close TMPFILE ;
rename($tmpfile2, $tmpfile) || mailArtAndDie ("can't rename $tmpfile2 $tmpfile: $!") ;
$tmpfile2 = undef ;
}
if (!open INEWS, "$WhereTo < $tmpfile 2>&1 |") {
mailArtAndDie ("can't start $WhereTo: $!") ;
}
my @inews = <INEWS> ;
close INEWS ;
my $status = $? ;
if (@inews) {
chomp @inews ;
mailArtAndDie ("inews failed: @inews") ;
}
unlink $tmpfile ;
exit $status;
sub mailArtAndDie {
my ($msg) = @_ ;
syslog("err", "$msg") if $use_syslog;
print STDERR $msg,"\n" if -t STDERR ;
open(SENDMAIL, "|" . $Sendmail) ||
die "die($msg): sendmail: $!\n" ;
print SENDMAIL <<"EOF" ;
To: $Maintainer
Subject: mailpost failure ($newsgroups)
$msg
EOF
if ($tmpfile && -f $tmpfile) {
print SENDMAIL "\n-------- Article Contents\n\n" ;
open(FILE, "<$tmpfile") || die "open($tmpfile): $!\n" ;
print SENDMAIL while <FILE> ;
close FILE ;
} else {
print STDERR "No article left to send back.\n" if -t STDERR;
}
close SENDMAIL ;
# unlink $tmpfile ;
# We use here a non-zero exit. It should normally not cause problems.
exit(1);
}
#
# Take RFC-5322-format name (either "comment <addr> comment" or "addr (comment)")
# and return in always-qualified RFC-5321-format ("addr (comment)").
#
sub fix_sender_addr {
my ($address) = @_;
my ($lcomment, $addr, $rcomment, $comment);
local ($',$`,$_) ;
if ($address =~ /\<([^\>]*)\>/) {
($lcomment, $addr, $rcomment) = (&dltb($`), &dltb($1), &dltb($'));
} elsif ($address =~ /\(([^\)]*)\)/) {
($lcomment, $addr, $rcomment) = ('', &dltb($`.$'), &dltb($1));
} else {
($lcomment, $addr, $rcomment) = ('', &dltb($address), '');
}
#print STDERR "fix_sender_addr($address) == ($lcomment, $addr, $rcomment)\n";
$addr .= "\@$Mailname" unless ($addr =~ /\@/);
if ($lcomment && $rcomment) {
$comment = $lcomment . ' ' . $rcomment;
} else {
$comment = $lcomment . $rcomment;
}
$_ = $addr;
$_ .= " ($comment)" if $comment;
#print STDERR "\t-> $_\n";
return $_;
}
#
# Delete leading and trailing blanks.
#
sub dltb {
my ($str) = @_;
$str =~ s/^\s+//o;
$str =~ s/\s+$//o;
return $str;
}
sub append_newsgroups ($$) {
my (@orig) = split(/,/,$_[0]) ;
my (@new) = split(/,/,$_[1]) ;
my $newsgroup ;
foreach $newsgroup (@new) {
if ( !grep($_ eq $newsgroup,@orig)) {
push @orig, $newsgroup ;
} else {
# mailArtAndDie ("Duplicate Newsgroups: $newsgroup") ;
}
}
return join ",", @orig ;
}
=head1 NAME
mailpost - Feed an e-mail message into a newsgroup
=head1 SYNOPSIS
B<mailpost> [B<-hn>] [B<-a> I<addr>] [B<-b> I<database>] [B<-c> I<wait-time>]
[B<-d> I<distribution>] [B<-f> I<addr>] [B<-m> I<mailing-list>]
[B<-o> I<output-command>] [B<-p> I<port>] [B<-r> I<addr>] [B<-t> I<tempdir>]
[B<-x> I<header>[B<:>I<header>...]] I<newsgroups>
=head1 DESCRIPTION
The B<mailpost> program reads a properly formatted e-mail message from stdin
and feeds it to B<inews> for posting to a news server. I<newsgroups> is a
whitespace-separated list of group names to which to post the article
(at least one newsgroup must be specified).
Before feeding the article to B<inews>, it checks that the article has not
been seen before, and it changes some headers (cleans up some address
headers, removes X-Trace: and X-Complaints-To:, and puts C<X-> in front
of unknown headers).
If the article has been seen before (B<mailpost> records the Message-ID of
each article it handles), then the article will be dropped with a non-zero
error status. Other errors will cause the article to be mailed to the
newsmaster (selected at configure time and defaulting to C<usenet>).
Normally, B<mailpost> is run by sendmail(8) via an alias entry:
local-mail-wreck-bikes: "|<pathbin in inn.conf>/mailpost
-b /var/tmp -t /var/tmp -d local local.mail.rec.bicycles.racing"
The B<-b> and B<-t> flags are useful to change the directories used by
B<mailpost> by default. As a matter of fact, though it is recommended to
run B<mailpost> as the news user, it is as often as not run as another
user, for instance the mail user. Therefore, you should make sure to
create and set to be writable by the user that B<mailpost> runs as the
directories where to put the database and the temporary files.
Instead of F</var/tmp>, the mail spool directory can be specified,
or any other directory where the B<mailpost> process has write access.
=head1 OPTIONS
=over 4
=item B<-a> I<addr>
If the B<-a> flag is used, the value given is added to the article as
an Approved: header.
=item B<-b> I<database>
If the B<-b> flag is used, then it defines the location of the
persistent database used to store the Message-IDs of articles sent on.
This is to prevent articles looping around if a news-to-mail gateway
sends them back here. This option may be required if the B<mailpost>
process does not have write access to the news database directory.
The default value is I<pathdb> as set in F<inn.conf>.
=item B<-c> I<wait-time>
The B<-c> flag indicates a length of time to sleep before posting. If
duplicate messages are received in this interval (by any instance of
B<mailpost> using the same database), the article is only posted once, but
with Newsgroups: header modified to crosspost the article to all indicated
groups. The units for I<wait-time> are seconds; a reasonable value may be
anywhere from tens to hundreds of seconds, or even higher, depending on how
long mail can be delayed on its way to your system.
=item B<-d> I<distribution>
If the B<-d> flag is used, the value given is added to the article as a
Distribution: header.
=item B<-f> I<addr>
The B<-f> flag is a synonym for the B<-r> flag.
=item B<-h>
Print usage information and exit.
=item B<-m> I<mailing-list>
If the B<-m> flag is used, the value given is added to the article in
a Mailing-List: header, if such a header doesn't already exist.
=item B<-n>
If the B<-n> flag is used, neither an article is posted nor a mail is sent
in case an error occurs. Everything is written to the standard output.
=item B<-o> I<output-command>
Specifies the program to which the resulting article processed by B<mailpost>
should be sent. For debugging purpose, C<-o cat> can be used. The default
value is C<inews -S -h>.
=item B<-p> I<port>
Specifies the port on which B<nnrpd> is listening, used for article posting.
If given, B<-p> is passed along to B<inews>.
=item B<-r> I<addr>
A heuristic is used to determine a reasonable value for the Path: header.
The B<-r> flag indicates what to use if no other value can be determined.
=item B<-t> I<tempdir>
If the B<-t> flag is used, then it defines the location of the
directory to use to temporarily store error messages that are sent to
the newsmaster. This option may be required if the default value refers
to a path that does not exist or the B<mailpost> process does not have
write access to. Two paths are tried by default: I<pathtmp> as set
in F<inn.conf>, and then F</var/tmp> if I<pathtmp> is not writable.
=item B<-x> I<header>[B<:>I<header>...]
A colon-separated list of additional header fields which should be
treated as known header fields; these header fields will be passed
through to B<inews> without having C<X-> prepended.
Known header fields are:
Archive
Archived-At
Comments
Content-*
Date
Distribution
From
Injection-Date
Keywords
Mailing-List
Message-ID
MIME-*
Organization
References
Return-Path
Sender
Subject
Summary
=back
=head1 FILES
=over 4
=item I<pathbin>/mailpost
The Perl script itself used to feed an e-mail message to a newsgroup.
=item I<pathdb>/mailpost-msgid.dir and I<pathdb>/mailpost-msgid.pag
The default database files which record previously seen Message-IDs.
=back
=head1 HISTORY
Written by Paul Vixie long ago and then hacked up by James Brister for
INN integration.
$Id: mailpost.in 10076 2016-10-08 20:37:36Z iulius $
=head1 SEE ALSO
active(5), inews(1), inn.conf(5), nnrpd(8), uwildmat(3).
=cut
|