/contrib/cvs/contrib/commit_prep.in

https://bitbucket.org/freebsd/freebsd-head/ · Autoconf · 86 lines · 16 code · 13 blank · 57 comment · 3 complexity · b36a525677fa9c3885e60392722c115b MD5 · raw file

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