Don't exec mail any more.
git-svn-id: svn://10.0.0.236/trunk@5944 18797224-902f-48f8-a5cc-f745e15eee43
This commit is contained in:
parent
53a3c681fb
commit
6267ed2bcb
@ -1,46 +1,15 @@
|
||||
#!/tools/ns/bin/perl5
|
||||
# -*- Mode: perl; indent-tabs-mode: nil -*-
|
||||
#
|
||||
# The contents of this file are subject to the Netscape Public License
|
||||
# Version 1.0 (the "License"); you may not use this file except in
|
||||
# compliance with the License. You may obtain a copy of the License at
|
||||
# http://www.mozilla.org/NPL/
|
||||
#
|
||||
# Software distributed under the License is distributed on an "AS IS"
|
||||
# basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See the
|
||||
# License for the specific language governing rights and limitations
|
||||
# under the License.
|
||||
#
|
||||
# The Original Code is the Bonsai CVS tool.
|
||||
#
|
||||
# The Initial Developer of the Original Code is Netscape Communications
|
||||
# Corporation. Portions created by Netscape are Copyright (C) 1998
|
||||
# Netscape Communications Corporation. All Rights Reserved.
|
||||
#! /tools/ns/bin/perl5
|
||||
|
||||
use Socket;
|
||||
|
||||
# You need to put this in your CVSROOT directory, and check it in. (Change the
|
||||
# first line above to point to a real live perl5.) Then, add a line to your
|
||||
# CVSROOT/loginfo file that says something like:
|
||||
#
|
||||
# ALL $CVSROOT/CVSROOT/dolog.pl -r /cvsroot bonsai-checkin-daemon@my.bonsai.machine
|
||||
#
|
||||
# Replace "/cvsroot" with the name of the CVS root directory, and
|
||||
# "my.bonsai.machine" with the name of the machine Bonsai runs on.
|
||||
# Now, on my.bonsai.machine, add a mail alias so that mail sent to
|
||||
# "bonsai-checkin-daemon" will get piped to handleCheckinMail.tcl.
|
||||
# The first argument to handleCheckinMail.tcl is the directory that
|
||||
# bonsai is installed in.
|
||||
|
||||
|
||||
$username = getlogin || (getpwuid($<))[0] || "nobody";
|
||||
$MAILER = "/usr/lib/sendmail -t";
|
||||
$username = $ENV{"CVS_USER"} || getlogin || (getpwuid($<))[0] || "nobody";
|
||||
$envcvsroot = $ENV{'CVSROOT'};
|
||||
$cvsroot = $envcvsroot;
|
||||
$flag_debug = 0;
|
||||
$flag_tagcmd = 0;
|
||||
$repository = '';
|
||||
$repository_tag = '';
|
||||
$rlogcommand = '/tools/ns/bin/rlog';
|
||||
$mailhost = 'localhost';
|
||||
|
||||
@mailto=();
|
||||
@changed_files = ();
|
||||
@ -98,6 +67,8 @@ sub process_args {
|
||||
} elsif ($arg eq '-t') {
|
||||
$flag_tagcmd = 1;
|
||||
last; # Keep the rest in ARGV; they're handled later.
|
||||
} elsif ($arg eq '-h') {
|
||||
$mailhost = shift @ARGV;
|
||||
} else {
|
||||
push(@mailto, $arg);
|
||||
}
|
||||
@ -165,7 +136,9 @@ sub get_loginfo {
|
||||
|
||||
sub process_cvs_info {
|
||||
local($d,$fn,$rev,$mod_time,$sticky,$tag,$stat,@d,$l,$rcsfile);
|
||||
open(ENT, "<CVS/Entries" );
|
||||
if (!open(ENT, "<CVS/Entries.Log" )) {
|
||||
open(ENT, "<CVS/Entries");
|
||||
}
|
||||
$time = time;
|
||||
while( <ENT> ){
|
||||
chop;
|
||||
@ -178,16 +151,15 @@ sub process_cvs_info {
|
||||
if( ! -r $rcsfile ){
|
||||
$rcsfile = "$envcvsroot/$repository/Attic/$fn,v";
|
||||
}
|
||||
open(LOG, "$rlogcommand -N -r$rev $rcsfile |")
|
||||
open(LOG, "/tools/ns/bin/rlog -N -r$rev $rcsfile |")
|
||||
|| print STDERR "dolog.pl: Couldn't run rlog\n";
|
||||
while(<LOG>){
|
||||
if( /^revision /){
|
||||
$l = <LOG>;
|
||||
chop($l);
|
||||
if( $flag_debug ){ print STDERR "$l\n";}
|
||||
@d = split(/[ ]+/,$l);
|
||||
$lines_added = $d[8];
|
||||
$lines_removed = $d[9];
|
||||
if (/^date:.* author: ([^;]*);.*/) {
|
||||
$username = $1;
|
||||
if (/lines: \+([0-9]*) -([0-9]*)/) {
|
||||
$lines_added = $1;
|
||||
$lines_removed = $2;
|
||||
}
|
||||
}
|
||||
}
|
||||
close( LOG );
|
||||
@ -225,15 +197,74 @@ sub do_commitinfo {
|
||||
|
||||
|
||||
|
||||
sub mail_notification {
|
||||
|
||||
open(MAIL, "| /bin/mail @mailto");
|
||||
if ($flag_tagcmd) {
|
||||
print MAIL "Subject: cvs tag in $repository\n";
|
||||
} else {
|
||||
print MAIL "Subject: cvs commit to $repository\n";
|
||||
sub get_response_code {
|
||||
my ($expecting) = @_;
|
||||
# if ($flag_debug) {
|
||||
# print STDERR "SMTP: Waiting for code $expecting\n";
|
||||
# }
|
||||
while (1) {
|
||||
my $line = <S>;
|
||||
# if ($flag_debug) {
|
||||
# print STDERR "SMTP: $line";
|
||||
# }
|
||||
if ($line =~ /^[0-9]*-/) {
|
||||
next;
|
||||
}
|
||||
if ($line =~ /(^[0-9]*) /) {
|
||||
my $code = $1;
|
||||
if ($code == $expecting) {
|
||||
# if ($flag_debug) {
|
||||
# print STDERR "SMTP: got it.\n";
|
||||
# }
|
||||
return;
|
||||
}
|
||||
die "Bad response from SMTP -- $line";
|
||||
}
|
||||
}
|
||||
print MAIL "\n";
|
||||
print MAIL @outlist, "\n";
|
||||
close(MAIL);
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
sub mail_notification {
|
||||
chop(my $hostname = `hostname`);
|
||||
|
||||
my ($remote,$port, $iaddr, $paddr, $proto, $line);
|
||||
|
||||
$remote = $mailhost;
|
||||
$port = 25;
|
||||
if ($port =~ /\D/) { $port = getservbyname($port, 'tcp') }
|
||||
die "No port" unless $port;
|
||||
$iaddr = inet_aton($remote) || die "no host: $remote";
|
||||
$paddr = sockaddr_in($port, $iaddr);
|
||||
|
||||
$proto = getprotobyname('tcp');
|
||||
socket(S, PF_INET, SOCK_STREAM, $proto) || die "socket: $!";
|
||||
connect(S, $paddr) || die "connect: $!";
|
||||
select(S); $| = 1; select(STDOUT);
|
||||
|
||||
get_response_code(220);
|
||||
print S "EHLO $hostname\n";
|
||||
get_response_code(250);
|
||||
print S "MAIL FROM: bonsai-daemon@$hostname\n";
|
||||
get_response_code(250);
|
||||
foreach $i (@mailto) {
|
||||
print S "RCPT TO: $i\n";
|
||||
get_response_code(250);
|
||||
}
|
||||
print S "DATA\n";
|
||||
get_response_code(354);
|
||||
# Get one line starting with "354 ".
|
||||
if ($flag_tagcmd) {
|
||||
print S "Subject: cvs tag in $repository\n";
|
||||
} else {
|
||||
print S "Subject: cvs commit to $repository\n";
|
||||
}
|
||||
print S "\n";
|
||||
print S @outlist, "\n";
|
||||
print S ".\n";
|
||||
get_response_code(250);
|
||||
print S "QUIT\n";
|
||||
close(S);
|
||||
}
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user