Home | History | Annotate | Line # | Download | only in contrib
      1 #! @PERL@ -T
      2 # -*-Perl-*-
      3 
      4 # Copyright (C) 1994-2005 The Free Software Foundation, Inc.
      5 
      6 # This program is free software; you can redistribute it and/or modify
      7 # it under the terms of the GNU General Public License as published by
      8 # the Free Software Foundation; either version 2, or (at your option)
      9 # any later version.
     10 #
     11 # This program is distributed in the hope that it will be useful,
     12 # but WITHOUT ANY WARRANTY; without even the implied warranty of
     13 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
     14 # GNU General Public License for more details.
     15 
     16 ###############################################################################
     17 ###############################################################################
     18 ###############################################################################
     19 #
     20 # THIS SCRIPT IS PROBABLY BROKEN.  REMOVING THE -T SWITCH ON THE #! LINE ABOVE
     21 # WOULD FIX IT, BUT THIS IS INSECURE.  WE RECOMMEND FIXING THE ERRORS WHICH THE
     22 # -T SWITCH WILL CAUSE PERL TO REPORT BEFORE RUNNING THIS SCRIPT FROM A CVS
     23 # SERVER TRIGGER.  PLEASE SEND PATCHES CONTAINING THE CHANGES YOU FIND
     24 # NECESSARY TO RUN THIS SCRIPT WITH THE TAINT-CHECKING ENABLED BACK TO THE
     25 # <@PACKAGE_BUGREPORT@> MAILING LIST.
     26 #
     27 # For more on general Perl security and taint-checking, please try running the
     28 # `perldoc perlsec' command.
     29 #
     30 ###############################################################################
     31 ###############################################################################
     32 ###############################################################################
     33 
     34 # From: clyne (at] niwot.scd.ucar.EDU (John Clyne)
     35 # Date: Fri, 28 Feb 92 09:54:21 MST
     36 # 
     37 # BTW, i wrote a perl script that is similar to 'nfpipe' except that in
     38 # addition to logging to a file it provides a command line option for mailing
     39 # change notices to a group of users. Obviously you probably wouldn't want
     40 # to mail every change. But there may be certain directories that are commonly
     41 # accessed by a group of users who would benefit from an email notice. 
     42 # Especially if they regularly beat on the same directory. Anyway if you 
     43 # think anyone would be interested here it is. 
     44 #
     45 #	File:		mfpipe
     46 #
     47 #	Author:		John Clyne
     48 #			National Center for Atmospheric Research
     49 #			PO 3000, Boulder, Colorado
     50 #
     51 #	Date:		Wed Feb 26 18:34:53 MST 1992
     52 #
     53 #	Description:	Tee standard input to mail a list of users and to
     54 #			a file. Used by CVS logging.
     55 #
     56 #	Usage:		mfpipe [-f file] [user (at] host...]
     57 #
     58 #	Environment:	CVSROOT	
     59 #				Path to CVS root.
     60 #
     61 #	Files:
     62 #
     63 #
     64 #	Options:	-f file	
     65 #				Capture output to 'file'
     66 #			
     67 
     68 $header = "Log Message:\n";
     69 
     70 $mailcmd = "| mail -s  'CVS update notice'";
     71 $whoami = `whoami`;
     72 chop $whoami;
     73 $date = `date`;
     74 chop $date;
     75 
     76 $cvsroot = $ENV{'CVSROOT'};
     77 
     78 while (@ARGV) {
     79         $arg = shift @ARGV;
     80 
     81 	if ($arg eq '-f') {
     82                 $file = shift @ARGV;
     83 	}
     84 	else {
     85 		$users = "$users $arg";
     86 	}
     87 }
     88 
     89 if ($users) {
     90 	$mailcmd = "$mailcmd $users";
     91 	open(MAIL, $mailcmd) || die "Execing $mail: $!\n";
     92 }
     93  
     94 if ($file) {
     95 	$logfile = "$cvsroot/LOG/$file";
     96 	open(FILE, ">> $logfile") || die "Opening $logfile: $!\n";
     97 }
     98 
     99 print FILE "$whoami $date--------BEGIN LOG ENTRY-------------\n" if ($logfile);
    100 
    101 while (<>) {
    102 	print FILE $log if ($log && $logfile);
    103 
    104 	print FILE $_ if ($logfile);
    105 	print MAIL $_ if ($users);
    106 
    107 	$log = "log: " if ($_ eq $header);
    108 }
    109 
    110 close FILE;
    111 die "Write failed" if $?;
    112 close MAIL;
    113 die "Mail failed" if $?;
    114 
    115 exit 0;
    116