savannah-cvs
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Savannah-cvs] administration/infra/commit_prep-log_accum log_...


From: Sylvain Beucler
Subject: [Savannah-cvs] administration/infra/commit_prep-log_accum log_...
Date: Sat, 11 Dec 2004 05:00:52 -0500

CVSROOT:        /cvsroot/administration
Module name:    administration
Branch:         
Changes by:     Sylvain Beucler <address@hidden>        04/12/11 09:47:52

Modified files:
        infra/commit_prep-log_accum: log_accum.pl 
Added files:
        infra/commit_prep-log_accum: commit_prep.pl 

Log message:
        Changes by rao

CVSWeb URLs:
http://savannah.gnu.org/cgi-bin/viewcvs/administration/administration/infra/commit_prep-log_accum/commit_prep.pl?rev=1.1
http://savannah.gnu.org/cgi-bin/viewcvs/administration/administration/infra/commit_prep-log_accum/log_accum.pl.diff?tr1=1.1&tr2=1.2&r1=text&r2=text

Patches:
Index: administration/infra/commit_prep-log_accum/log_accum.pl
diff -u administration/infra/commit_prep-log_accum/log_accum.pl:1.1 
administration/infra/commit_prep-log_accum/log_accum.pl:1.2
--- administration/infra/commit_prep-log_accum/log_accum.pl:1.1 Sat Dec 11 
09:46:29 2004
+++ administration/infra/commit_prep-log_accum/log_accum.pl     Sat Dec 11 
09:47:52 2004
@@ -1,7 +1,7 @@
 #!/usr/bin/perl
 # -*-Perl-*-
 #
-# $Id: log_accum.pl,v 1.1 2004/12/11 09:46:29 Beuc Exp $
+# $Id: log_accum.pl,v 1.2 2004/12/11 09:47:52 Beuc Exp $
 # Perl filter to handle the log messages from the checkin of files in
 # a directory.  This script will group the lists of files by log
 # message, and mail a single consolidated log message at the end of
@@ -34,7 +34,6 @@
 #
 #      Configurable options
 #
-use Net::SMTP;
 
 # Clean up the environment
 $ENV{"PATH"} = "/bin";
@@ -309,28 +308,26 @@
     print STDERR "mail_notification: to $names, subject $subject\n" if 
($debug);
 
     my @email_list = split (/\s+/, $names);
+    my @socketmail_args = ("/bin/socket-mail", $mailname, @email_list);
 
-    my $smtp = Net::SMTP->new ("127.0.0.1");
-    die "FATAL: SMTP connection failed" unless $smtp;
+    my $pid = open (MAIL, "|-");
+    $SIG{PIPE} = sub { die "whoops, pipe broke" };
 
-    $smtp->mail ($fullname);
-    my @smtp_result = $smtp->recipient (@email_list, { SkipBad => 1});
-
-    if (scalar @smtp_result == 0) {
-       $smtp->quit ();
-       return;
-    }
-
-    $smtp->data ();
-    $smtp->datasend ("To: " . join (", ", @email_list) . "\n");
-    $smtp->datasend ("Reply-To: $mailname\n");
-    $smtp->datasend ("Subject: $subject\n");
-    $smtp->datasend ("\n");
-    $smtp->datasend (join ("\n", @text));
-    $smtp->datasend ("\n");
-    $smtp->dataend ();
-
-    $smtp->quit ();
+    if ($pid) {  # parent
+       print MAIL "To: " . join (", ", @email_list) . "\n";
+       print MAIL "From: $fullname <$mailname>\n";
+       print MAIL "Subject: $subject\n";
+       print MAIL "\n";
+       print MAIL join ("\n", @text);
+       print MAIL "\n";
+       print MAIL ".\n";
+       close(MAIL) || warn "child exited $?";
+
+    } else {     # child
+       exec (@socketmail_args)
+           || die "can't exec program: $!";
+       # NOTREACHED
+    }  
 }
 
 sub write_commitlog {
@@ -406,16 +403,15 @@
 $id = getpgrp();               # note, you *must* use a shell which does 
setpgrp()
 $state = $STATE_NONE;
 local ($login, $gecos);
-$login = $ENV{'USER'};
-if (! $login)
-{
-    ($login, $gecos) = (getpwuid ($<))[0,6];
-}
-else
-{
-    $login = "nobody" if (! $login);
-    $gecos = (getpwnam ($login))[6];
+
+$login = $ENV{'USERNAME'};
+open (PASSWD, "/etc/passwd") || die "passwd open failed";
+while (<PASSWD>) {
+    next unless /^${login}:.+:.+:.+:(.+):.+:.+$/;
+    $gecos = $1;
+    last if defined $gecos;
 }
+close PASSWD;
 
 # Determine the mailname and fullname.
 if ($gecos =~ /^([^<]*\s+)<(address@hidden)>/)




reply via email to

[Prev in Thread] Current Thread [Next in Thread]