1*a7c91847Schristos#! @PERL@ -T 2*a7c91847Schristos# -*-Perl-*- 3*a7c91847Schristos 4*a7c91847Schristos# Copyright (C) 1994-2005 The Free Software Foundation, Inc. 5*a7c91847Schristos 6*a7c91847Schristos# This program is free software; you can redistribute it and/or modify 7*a7c91847Schristos# it under the terms of the GNU General Public License as published by 8*a7c91847Schristos# the Free Software Foundation; either version 2, or (at your option) 9*a7c91847Schristos# any later version. 10*a7c91847Schristos# 11*a7c91847Schristos# This program is distributed in the hope that it will be useful, 12*a7c91847Schristos# but WITHOUT ANY WARRANTY; without even the implied warranty of 13*a7c91847Schristos# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 14*a7c91847Schristos# GNU General Public License for more details. 15*a7c91847Schristos 16*a7c91847Schristos############################################################################### 17*a7c91847Schristos############################################################################### 18*a7c91847Schristos############################################################################### 19*a7c91847Schristos# 20*a7c91847Schristos# THIS SCRIPT IS PROBABLY BROKEN. REMOVING THE -T SWITCH ON THE #! LINE ABOVE 21*a7c91847Schristos# WOULD FIX IT, BUT THIS IS INSECURE. WE RECOMMEND FIXING THE ERRORS WHICH THE 22*a7c91847Schristos# -T SWITCH WILL CAUSE PERL TO REPORT BEFORE RUNNING THIS SCRIPT FROM A CVS 23*a7c91847Schristos# SERVER TRIGGER. PLEASE SEND PATCHES CONTAINING THE CHANGES YOU FIND 24*a7c91847Schristos# NECESSARY TO RUN THIS SCRIPT WITH THE TAINT-CHECKING ENABLED BACK TO THE 25*a7c91847Schristos# <@PACKAGE_BUGREPORT@> MAILING LIST. 26*a7c91847Schristos# 27*a7c91847Schristos# For more on general Perl security and taint-checking, please try running the 28*a7c91847Schristos# `perldoc perlsec' command. 29*a7c91847Schristos# 30*a7c91847Schristos############################################################################### 31*a7c91847Schristos############################################################################### 32*a7c91847Schristos############################################################################### 33*a7c91847Schristos 34*a7c91847Schristos# Perl filter to handle pre-commit checking of files. This program 35*a7c91847Schristos# records the last directory where commits will be taking place for 36*a7c91847Schristos# use by the log_accum.pl script. 37*a7c91847Schristos# 38*a7c91847Schristos# IMPORTANT: this script interacts with log_accum, they have to agree 39*a7c91847Schristos# on the tmpfile name to use. See $LAST_FILE below. 40*a7c91847Schristos# 41*a7c91847Schristos# Contributed by David Hampton <hampton@cisco.com> 42*a7c91847Schristos# Stripped to minimum by Roy Fielding 43*a7c91847Schristos# 44*a7c91847Schristos############################################################ 45*a7c91847Schristos$TMPDIR = $ENV{'TMPDIR'} || '/tmp'; 46*a7c91847Schristos$FILE_PREFIX = '#cvs.'; 47*a7c91847Schristos 48*a7c91847Schristos# If see a "-u $USER" argument, then destructively remove it from the 49*a7c91847Schristos# argument list, so $ARGV[0] will be the repository dir again, as it 50*a7c91847Schristos# used to be before we added the -u flag. 51*a7c91847Schristosif ($ARGV[0] eq '-u') { 52*a7c91847Schristos shift @ARGV; 53*a7c91847Schristos $CVS_USERNAME = shift (@ARGV); 54*a7c91847Schristos} 55*a7c91847Schristos 56*a7c91847Schristos# This needs to match the corresponding var in log_accum.pl, including 57*a7c91847Schristos# the appending of the pgrp and username suffixes (see uses of this 58*a7c91847Schristos# var farther down). 59*a7c91847Schristos$LAST_FILE = "$TMPDIR/${FILE_PREFIX}lastdir"; 60*a7c91847Schristos 61*a7c91847Schristossub write_line { 62*a7c91847Schristos my ($filename, $line) = @_; 63*a7c91847Schristos 64*a7c91847Schristos# A check of some kind is needed here, but the rules aren't apparent 65*a7c91847Schristos# at the moment: 66*a7c91847Schristos 67*a7c91847Schristos# foreach($filename, $line){ 68*a7c91847Schristos# $_ =~ m#^([-\@\w.\#]+)$#; 69*a7c91847Schristos# $_ = $1; 70*a7c91847Schristos# } 71*a7c91847Schristos 72*a7c91847Schristos open(FILE, ">$filename") || die("Cannot open $filename: $!\n"); 73*a7c91847Schristos print(FILE $line, "\n"); 74*a7c91847Schristos close(FILE); 75*a7c91847Schristos} 76*a7c91847Schristos 77*a7c91847Schristos# 78*a7c91847Schristos# Record this directory as the last one checked. This will be used 79*a7c91847Schristos# by the log_accumulate script to determine when it is processing 80*a7c91847Schristos# the final directory of a multi-directory commit. 81*a7c91847Schristos# 82*a7c91847Schristos$id = getpgrp(); 83*a7c91847Schristos 84*a7c91847Schristos&write_line("$LAST_FILE.$id.$CVS_USERNAME", $ARGV[0]); 85*a7c91847Schristos 86*a7c91847Schristosexit(0); 87