--- ciabot.pl 2003-12-14 20:15:27.000000000 -0500 +++ gentoo-ciabot.pl 2003-12-14 20:15:09.000000000 -0500 @@ -1,4 +1,7 @@ -#!/usr/bin/perl -w +#!/usr/bin/perl +# Distributed under the terms of the GNU General Public License v2 +# $Header: /home/cvsroot/CVSROOT/ciabot.pl,v 1.4 2003/12/10 00:49:49 solar Exp $ + # # ciabot -- Mail a CVS log message to a given address, for the purposes of CIA # @@ -24,7 +27,7 @@ # Note that the last three parameters are optional, you can alternatively change # the defaults below in the configuration section. # -# $Id: ciabot.pl,v 1.62 2003/09/30 11:06:12 pasky Exp $ +# $Id: ciabot.pl,v 1.4 2003/12/10 00:49:49 solar Exp $ use strict; use vars qw ($project $from_email $dest_email @sendmail $max_lines $max_files @@ -37,13 +40,15 @@ ### Configuration # Project name (as known to CIA). -$project = 'ELinks'; +$project = ''; # The from address in the generated mails. -$from_email = 'pasky@ucw.cz'; +# $from_email = 'pasky@ucw.cz'; +$from_email = ''; # Mail all reports to this address. -$dest_email = 'commits@picogui.org'; +# $dest_email = 'commits@picogui.org'; +$dest_email = ''; # Path to your sendmail binary. If you have it at a different place (and # outside of $PATH), add your location at the start of the list. By all means @@ -91,7 +96,15 @@ # none $trimmed_template = '(log message trimmed)'; - +#use POSIX ":sys_wait_h"; +#sub REAPER { +# my $child; +# while ($child = waitpid(-1,WNOHANG)) { +# $Kid_Status{$child} = $?; +# } +# $SIG{CHLD} = \&REAPER; # still loathe sysV +#} +#$SIG{CHLD} = \&REAPER; ### The code itself @@ -160,8 +173,7 @@ my $syncfile; # Name of the file used for syncing $syncfile = "/tmp/cvscia.$project.$module.$sum"; - -if (-f $syncfile) { +if (-w $syncfile) { # The synchronization file for this file already exists, so we are not the # first ones. So let's just dump what we know and exit. @@ -175,10 +187,20 @@ # wait a bit with the new one. Then we'll grab what the others collected and # go on. - # We don't need to care about permissions since all the instances of the one - # commit will obviously live as the same user. + ### We don't need to care about permissions since all the instances of the one + ### commit will obviously live as the same user. - system("touch $syncfile"); + # Gentoo gives a damn about file permissions and avoiding race conditions + if (-f $syncfile) { + # oh my a syncfile exists and it must not be writeable by our user. + # how ironic this would be. + unlink($syncfile); + die("Please tell/mail solar\@gentoo.org that we just avoided a tmp race condition with $syncfile"); + } + # Gentoo feels that calling system() is sloppy and a security risk. + #- system("touch $syncfile"); + open(FF, ">>$syncfile"); + close(FF); exit if (fork); sleep($sync_delay);