summaryrefslogtreecommitdiffstats
path: root/contrib/sendmail/contrib
diff options
context:
space:
mode:
authorgshapiro <gshapiro@FreeBSD.org>2004-08-01 01:04:57 +0000
committergshapiro <gshapiro@FreeBSD.org>2004-08-01 01:04:57 +0000
commit1fc446a819a244515d9461fa50d34ee191414d6f (patch)
treef6477ae85b00ee6d58b086b0d1d597dd9a403391 /contrib/sendmail/contrib
parent238623a0204c90e8d61dbde7b3b499a5036f2e5d (diff)
downloadFreeBSD-src-1fc446a819a244515d9461fa50d34ee191414d6f.zip
FreeBSD-src-1fc446a819a244515d9461fa50d34ee191414d6f.tar.gz
Import sendmail 8.13.1
Diffstat (limited to 'contrib/sendmail/contrib')
-rwxr-xr-xcontrib/sendmail/contrib/buildvirtuser2
-rwxr-xr-xcontrib/sendmail/contrib/cidrexpand149
-rw-r--r--contrib/sendmail/contrib/qtool.815
-rwxr-xr-xcontrib/sendmail/contrib/qtool.pl3
-rwxr-xr-xcontrib/sendmail/contrib/socketmapClient.pl67
-rwxr-xr-xcontrib/sendmail/contrib/socketmapServer.pl98
6 files changed, 213 insertions, 121 deletions
diff --git a/contrib/sendmail/contrib/buildvirtuser b/contrib/sendmail/contrib/buildvirtuser
index 8c0aa44..abed167 100755
--- a/contrib/sendmail/contrib/buildvirtuser
+++ b/contrib/sendmail/contrib/buildvirtuser
@@ -27,7 +27,7 @@
# OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
# SUCH DAMAGE.
-# $Id: buildvirtuser,v 1.5.2.1 2003/03/15 23:30:26 gshapiro Exp $
+# $Id: buildvirtuser,v 1.6 2003/03/15 23:30:09 gshapiro Exp $
=head1 NAME
diff --git a/contrib/sendmail/contrib/cidrexpand b/contrib/sendmail/contrib/cidrexpand
index 67b62c5..b7ace25 100755
--- a/contrib/sendmail/contrib/cidrexpand
+++ b/contrib/sendmail/contrib/cidrexpand
@@ -1,17 +1,13 @@
-#!/usr/local/bin/perl -w
+#!/usr/bin/perl -w
-# v 0.2-very-beta
+# $Id: cidrexpand,v 8.4 2002/11/22 21:13:14 ca Exp $
#
-# 17 July 2000 Derek J. Balling (dredd@megacity.org)
-#
-# The $SENDMAIL flag tells the code to lump networks in sendmail format
-# if applicable. If this flag is disabled, cidrexpand will literally create
-# a single line for each entry, which may or may not be what you want. :)
-# makes for a rather large hash table...
+# v 0.4
#
+# 17 July 2000 Derek J. Balling (dredd@megacity.org)
+#
# Acts as a preparser on /etc/mail/access_db to allow you to use address/bit
-# notation. Caveat: the address portion MUST be the start address or your
-# results will NOT be what what you want.
+# notation.
#
# If you have two overlapping CIDR blocks with conflicting actions
# e.g. 10.2.3.128/25 REJECT and 10.2.3.143 ACCEPT
@@ -22,27 +18,35 @@
#
# Modifications
# -------------
-# 5 Nov 2002 Richard Rognlie (richard@sendmail.com)
+# 26 Jul 2001 Derek Balling (dredd@megacity.org)
+# Now uses Net::CIDR because it makes life a lot easier.
+#
+# 5 Nov 2002 Richard Rognlie (richard@sendmail.com)
# Added code to deal with the prefix tags that may now be included in
# the access_db
#
# Added clarification in the notes for what to do if you have
# exceptions to a larger CIDR block.
#
-# usage:
+# usage:
# cidrexpand < /etc/mail/access | makemap -r hash /etc/mail/access
#
-# Report bugs to: dredd@megacity.org
#
+# Report bugs to: <dredd@megacity.org>
+#
+
+
+use strict;
+use Net::CIDR;
my $spaceregex = '\s+';
while (my $arg = shift @ARGV)
{
- if ($arg eq '-t')
- {
+ if ($arg eq '-t')
+ {
$spaceregex = shift;
- }
+ }
}
use strict;
@@ -51,109 +55,40 @@ my $SENDMAIL = 1;
while (<>)
{
- my ($prefix,$left,$right,$space);
+ my ($prefix,$left,$right,$space);
- if (! /^(|\S\S*:)(\d+\.){3}\d+\/\d\d?$spaceregex.*/ )
- {
+ if (! /^(|\S\S*:)(\d+\.){3}\d+\/\d\d?$spaceregex.*/ )
+ {
print;
- }
- else
- {
+ }
+ else
+ {
($prefix,$left,$space,$right) = /^(|\S\S*:)((?:\d+\.){3}\d+\/\d\d?)($spaceregex)(.*)$/;
-
+
my @new_lefts = expand_network($left);
foreach my $nl (@new_lefts)
{
print "$prefix$nl$space$right\n";
}
-
- }
+ }
}
sub expand_network
{
- my ($network,$mask) = split /\//, shift;
- my @diffs = calc_changes($network,$mask);
- my ($first,$second,$third,$fourth) = split /\./, $network;
-
- my @rc = ();
-
- for my $f ($first..($first+$diffs[0]))
- {
- if ( ( $SENDMAIL ) and ($diffs[1] == 255))
- {
- push @rc, "$f";
- }
- else
+ my $left_input = shift;
+ my @rc = ($left_input);
+ my ($network,$mask) = split /\//, $left_input;
+ if (defined $mask)
+ {
+ my @parts = split /\./, $network;
+ while ($#parts < 3)
{
- for my $s ($second..($second+$diffs[1]))
- {
- if ( ($SENDMAIL) and ($diffs[2] == 255) )
- {
- push @rc,"$f\.$s";
- }
- else
- {
- for my $t ($third..($third+$diffs[2]))
- {
- if ( ($SENDMAIL) and ($diffs[3] == 255))
- {
- push @rc, "$f\.$s\.$t";
- }
- else
- {
- for my $fr ($fourth..($fourth+$diffs[3]))
- {
- push @rc, "$f\.$s\.$t\.$fr";
- }
- }
- }
- }
- }
+ push @parts, "0";
}
- }
- return @rc;
-}
-
-sub calc_changes
-{
- my ($network,$mask) = @_;
-
- my @octs = split /\./, $network;
-
- my ($first,$second,$third,$fourth) = (0,0,0,0);
-
- my $power = 32 - $mask;
-
- if ($mask > 24)
- {
- $fourth = 2**$power - 1;
- }
- elsif ($mask > 16)
- {
- $fourth = 255;
- $third = 2**($power-8) - 1;
- }
- elsif ($mask > 8)
- {
- $fourth = 255;
- $third = 255;
- $second = 2**($power-16) - 1;
- }
- elsif ($mask > 0)
- {
- $fourth = 255;
- $third = 255;
- $second = 255;
- $first = 2**($power-24) - 1;
- }
- elsif ($mask == 0)
- {
- $fourth = 255;
- $third = 255;
- $second = 255;
- $first = 255;
- }
-
- return ($first,$second,$third,$fourth);
+ my $clean_input = join '.', @parts;
+ $clean_input .= "/$mask";
+ my @octets = Net::CIDR::cidr2octets($clean_input);
+ @rc = @octets;
+ }
+ return @rc;
}
diff --git a/contrib/sendmail/contrib/qtool.8 b/contrib/sendmail/contrib/qtool.8
index fbc90fac..0a4cbff 100644
--- a/contrib/sendmail/contrib/qtool.8
+++ b/contrib/sendmail/contrib/qtool.8
@@ -6,9 +6,9 @@
.\" the sendmail distribution.
.\"
.\"
-.\" $Id: qtool.8,v 8.17 2002/01/29 21:55:49 ca Exp $
+.\" $Id: qtool.8,v 8.20 2004/06/28 17:49:41 ca Exp $
.\"
-.TH QTOOL 8 "$Date: 2002/01/29 21:55:49 $"
+.TH QTOOL 8 "$Date: 2004/06/28 17:49:41 $"
.SH NAME
qtool
\- manipulate sendmail queues
@@ -56,7 +56,7 @@ Defaults to /etc/mail/sendmail.cf.
Delete all of the messages specified by source.
.TP
\fB\-e\fP \fIperl_expression\fP
-Evalute \fIperl_expression\fP for each queue file as specified
+Evaluate \fIperl_expression\fP for each queue file as specified
by \fIsource\fP. If \fIperl_expression\fP evaluates to true, then that
queue file is moved. See below for more detail on \fIperl_expression\fP.
.TP
@@ -102,9 +102,6 @@ The size of the control file in bytes.
\fBcreation_time\fP
The time when the control file was created.
.TP
-\fBcurrent_delay\fP
-Current delay for queue delay algorithm if _FFR_QUEUEDELAY is enabled.
-.TP
\fBdata_file_name\fP
The data file name (deprecated).
.TP
@@ -173,11 +170,7 @@ Original recipient (ORCPT= parameter).
Adjusted priority of message.
.TP
\fBquarantine_reason\fP
-Quarantine reason for quarantined (held) envelopes if _FFR_QUARANTINE is
-enabled.
-.TP
-\fBqueue_delay\fP
-Queue delay algorithm if _FFR_QUEUEDELAY is enabled.
+Quarantine reason for quarantined (held) envelopes.
.TP
\fBrecipient\fP
Array of character flags followed by colon and recipient name. Flags:
diff --git a/contrib/sendmail/contrib/qtool.pl b/contrib/sendmail/contrib/qtool.pl
index 08f808b..ba944c2 100755
--- a/contrib/sendmail/contrib/qtool.pl
+++ b/contrib/sendmail/contrib/qtool.pl
@@ -3,7 +3,7 @@
## Copyright (c) 1998-2002 Sendmail, Inc. and its suppliers.
## All rights reserved.
##
-## $Id: qtool.pl,v 8.27 2002/01/29 21:55:49 ca Exp $
+## $Id: qtool.pl,v 8.28 2002/06/27 23:06:16 gshapiro Exp $
##
use strict;
use File::Basename;
@@ -485,7 +485,6 @@ sub parse
'E' => 'error_recipient',
'F' => 'flags',
'H' => 'parse_header',
- 'G' => 'queue_delay',
'I' => 'inode_number',
'K' => 'next_delivery_time',
'L' => 'content-length',
diff --git a/contrib/sendmail/contrib/socketmapClient.pl b/contrib/sendmail/contrib/socketmapClient.pl
new file mode 100755
index 0000000..28fe603
--- /dev/null
+++ b/contrib/sendmail/contrib/socketmapClient.pl
@@ -0,0 +1,67 @@
+#!/usr/bin/perl -w
+#
+# Contributed by Bastiaan Bakker for SOCKETMAP
+# $Id: socketmapClient.pl,v 1.1 2003/05/21 15:36:33 ca Exp $
+
+use strict;
+use IO::Socket;
+
+die "usage: $0 <connection> <mapname> <key> [<key2> ...]" if (@ARGV < 3);
+
+my $connection = shift @ARGV;
+my $mapname = shift @ARGV;
+
+my $sock;
+
+if ($connection =~ /tcp:(.+):([0-9]*)/) {
+ $sock = new IO::Socket::INET (
+ PeerAddr => $1,
+ PeerPort => $2,
+ Proto => 'tcp',
+ );
+} elsif ($connection =~ /((unix)|(local)):(.+)/) {
+ $sock = new IO::Socket::UNIX (
+ Type => SOCK_STREAM,
+ Peer => $4
+ );
+} else {
+ die "unrecognized connection specification $connection";
+}
+
+die "Could not create socket: $!\n" unless $sock;
+
+while(my $key = shift @ARGV) {
+ my $request = "$mapname $key";
+ netstringWrite($sock, $request);
+ $sock->flush();
+ my $response = netstringRead($sock);
+
+ print "$key => $response\n";
+}
+
+$sock->close();
+
+sub netstringWrite {
+ my $sock = shift;
+ my $data = shift;
+
+ print $sock length($data).':'.$data.',';
+}
+
+sub netstringRead {
+ my $sock = shift;
+ my $saveSeparator = $/;
+ $/ = ':';
+ my $dataLength = <$sock>;
+ die "cannot read netstring length" unless defined($dataLength);
+ chomp $dataLength;
+ my $data;
+ if ($sock->read($data, $dataLength) == $dataLength) {
+ ($sock->getc() eq ',') or die "data misses closing ,";
+ } else {
+ die "received only ".length($data)." of $dataLength bytes";
+ }
+
+ $/ = $saveSeparator;
+ return $data;
+}
diff --git a/contrib/sendmail/contrib/socketmapServer.pl b/contrib/sendmail/contrib/socketmapServer.pl
new file mode 100755
index 0000000..153e9ef
--- /dev/null
+++ b/contrib/sendmail/contrib/socketmapServer.pl
@@ -0,0 +1,98 @@
+#!/usr/bin/perl -w
+#
+# Contributed by Bastiaan Bakker for SOCKETMAP
+# $Id: socketmapServer.pl,v 1.1 2003/05/21 15:36:33 ca Exp $
+
+use strict;
+use IO::Socket;
+
+die "usage: $0 <connection>" if (@ARGV < 1);
+my $connection = shift @ARGV;
+my $sock;
+
+if ($connection =~ /tcp:(.+):([0-9]*)/) {
+ $sock = new IO::Socket::INET (
+ LocalAddr => $1,
+ LocalPort => $2,
+ Proto => 'tcp',
+ Listen => 32,
+ ReuseAddr => 1
+ );
+} elsif ($connection =~ /((unix)|(local)):(.+)/) {
+ unlink($4);
+ $sock = new IO::Socket::UNIX (
+ Type => SOCK_STREAM,
+ Local => $4,
+ Listen => 32
+ );
+} else {
+ die "unrecognized connection specification $connection";
+}
+
+while(my $client = $sock->accept()) {
+ my $childpid = fork();
+ if ($childpid) {
+ $client->close();
+ } else {
+ die "can't fork $!" unless defined($childpid);
+ $sock->close();
+ handleConnection($client);
+ $client->close();
+ exit;
+ }
+}
+
+$sock->close();
+
+sub handleConnection {
+ my $client = shift;
+ $client->autoflush(1);
+
+ while(!eof($client)) {
+ eval {
+ my $request = netstringRead($client);
+ my ($mapName, $key) = split(' ', $request);
+ my $value = mapLookup($mapName, $key);
+ my $result = (defined($value)) ? "OK $value" : "NOTFOUND";
+ netstringWrite($client, $result);
+ };
+ if ($@) {
+ print STDERR "$@\n";
+ last;
+ }
+ }
+}
+
+sub mapLookup {
+ my %mapping = ('bastiaan.bakker@example.com' => 'bastiaan',
+ 'wolter.eldering@example.com' => 'wolter@other.example.com');
+ my $mapName = shift;
+ my $key = shift;
+ my $value = ($mapName eq "virtuser") ? $mapping{$key} : undef;
+ return $value;
+}
+
+sub netstringWrite {
+ my $sock = shift;
+ my $data = shift;
+
+ print $sock length($data).':'.$data.',';
+}
+
+sub netstringRead {
+ my $sock = shift;
+ my $saveSeparator = $/;
+ $/ = ':';
+ my $dataLength = <$sock>;
+ die "cannot read netstring length" unless defined($dataLength);
+ chomp $dataLength;
+ my $data;
+ if ($sock->read($data, $dataLength) == $dataLength) {
+ ($sock->getc() eq ',') or die "data misses closing ,";
+ } else {
+ die "received only ".length($data)." of $dataLength bytes";
+ }
+
+ $/ = $saveSeparator;
+ return $data;
+}
OpenPOWER on IntegriCloud