Don't reference nanosleep at all, but describe the behaviour.
[dragonfly.git] / contrib / cvs-1.12.12 / contrib / commit_prep.in
1 #! @PERL@ -T
2 # -*-Perl-*-
3
4 ###############################################################################
5 ###############################################################################
6 ###############################################################################
7 #
8 # THIS SCRIPT IS PROBABLY BROKEN.  REMOVING THE -T SWITCH ON THE #! LINE ABOVE
9 # WOULD FIX IT, BUT THIS IS INSECURE.  WE RECOMMEND FIXING THE ERRORS WHICH THE
10 # -T SWITCH WILL CAUSE PERL TO REPORT BEFORE RUNNING THIS SCRIPT FROM A CVS
11 # SERVER TRIGGER.  PLEASE SEND PATCHES CONTAINING THE CHANGES YOU FIND
12 # NECESSARY TO RUN THIS SCRIPT WITH THE TAINT-CHECKING ENABLED BACK TO THE
13 # <bug-cvs@gnu.org> MAILING LIST.
14 #
15 # For more on general Perl security and taint-checking, please try running the
16 # `perldoc perlsec' command.
17 #
18 ###############################################################################
19 ###############################################################################
20 ###############################################################################
21
22 # Perl filter to handle pre-commit checking of files.  This program
23 # records the last directory where commits will be taking place for
24 # use by the log_accum.pl script.
25 #
26 # IMPORTANT: this script interacts with log_accum, they have to agree
27 # on the tmpfile name to use.  See $LAST_FILE below.
28 #
29 # Contributed by David Hampton <hampton@cisco.com>
30 # Stripped to minimum by Roy Fielding
31 #
32 ############################################################
33 $TMPDIR        = $ENV{'TMPDIR'} || '/tmp';
34 $FILE_PREFIX   = '#cvs.';
35
36 # If see a "-u $USER" argument, then destructively remove it from the
37 # argument list, so $ARGV[0] will be the repository dir again, as it
38 # used to be before we added the -u flag.
39 if ($ARGV[0] eq '-u') {
40   shift @ARGV;
41   $CVS_USERNAME = shift (@ARGV);
42 }
43
44 # This needs to match the corresponding var in log_accum.pl, including
45 # the appending of the pgrp and username suffixes (see uses of this
46 # var farther down).
47 $LAST_FILE = "$TMPDIR/${FILE_PREFIX}lastdir";
48
49 sub write_line {
50     my ($filename, $line) = @_;
51
52 # A check of some kind is needed here, but the rules aren't apparent
53 # at the moment:
54
55 #    foreach($filename, $line){ 
56 #        $_ =~ m#^([-\@\w.\#]+)$#;
57 #        $_ = $1;
58 #    }
59
60     open(FILE, ">$filename") || die("Cannot open $filename: $!\n");
61     print(FILE $line, "\n");
62     close(FILE);
63 }
64
65 #
66 # Record this directory as the last one checked.  This will be used
67 # by the log_accumulate script to determine when it is processing
68 # the final directory of a multi-directory commit.
69 #
70 $id = getpgrp();
71
72 &write_line("$LAST_FILE.$id.$CVS_USERNAME", $ARGV[0]);
73
74 exit(0);