Merge from vendor branch OPENSSL:
[dragonfly.git] / contrib / cvs-1.12 / contrib / commit_prep.in
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 # Perl filter to handle pre-commit checking of files.  This program
35 # records the last directory where commits will be taking place for
36 # use by the log_accum.pl script.
37 #
38 # IMPORTANT: this script interacts with log_accum, they have to agree
39 # on the tmpfile name to use.  See $LAST_FILE below.
40 #
41 # Contributed by David Hampton <hampton@cisco.com>
42 # Stripped to minimum by Roy Fielding
43 #
44 ############################################################
45 $TMPDIR        = $ENV{'TMPDIR'} || '/tmp';
46 $FILE_PREFIX   = '#cvs.';
47
48 # If see a "-u $USER" argument, then destructively remove it from the
49 # argument list, so $ARGV[0] will be the repository dir again, as it
50 # used to be before we added the -u flag.
51 if ($ARGV[0] eq '-u') {
52   shift @ARGV;
53   $CVS_USERNAME = shift (@ARGV);
54 }
55
56 # This needs to match the corresponding var in log_accum.pl, including
57 # the appending of the pgrp and username suffixes (see uses of this
58 # var farther down).
59 $LAST_FILE = "$TMPDIR/${FILE_PREFIX}lastdir";
60
61 sub write_line {
62     my ($filename, $line) = @_;
63
64 # A check of some kind is needed here, but the rules aren't apparent
65 # at the moment:
66
67 #    foreach($filename, $line){ 
68 #        $_ =~ m#^([-\@\w.\#]+)$#;
69 #        $_ = $1;
70 #    }
71
72     open(FILE, ">$filename") || die("Cannot open $filename: $!\n");
73     print(FILE $line, "\n");
74     close(FILE);
75 }
76
77 #
78 # Record this directory as the last one checked.  This will be used
79 # by the log_accumulate script to determine when it is processing
80 # the final directory of a multi-directory commit.
81 #
82 $id = getpgrp();
83
84 &write_line("$LAST_FILE.$id.$CVS_USERNAME", $ARGV[0]);
85
86 exit(0);