6 use Digest::SHA1 qw(sha1_hex);
12 use vars qw($dbhost $dbname $dbuser $dbpass $dbport);
16 my $sig = $query->path_info;
19 my $animal = $query->param('animal');
20 my $sysnotes = $query->param('sysnotes');
22 my $content = "animal=$animal\&sysnotes=$sysnotes";
24 require "$ENV{BFConfDir}/BuildFarmWeb.pl";
26 die "no dbname" unless $dbname;
27 die "no dbuser" unless $dbuser;
29 my $dsn="dbi:Pg:dbname=$dbname";
30 $dsn .= ";host=$dbhost" if $dbhost;
31 $dsn .= ";port=$dbport" if $dbport;
33 unless ($animal && defined($sysnotes) && $sig)
36 "Status: 490 bad parameters\nContent-Type: text/plain\n\n",
37 "bad parameters for request\n";
43 my $db = DBI->connect($dsn,$dbuser,$dbpass);
45 die $DBI::errstr unless $db;
48 "select secret from buildsystems where name = ? and status = 'approved'";
49 my $sth = $db->prepare($gethost);
50 $sth->execute($animal);
51 my ($secret)=$sth->fetchrow_array();
58 "Status: 495 Unknown System\nContent-Type: text/plain\n\n",
59 "System $animal is unknown\n";
68 my $calc_sig = sha1_hex($content,$secret);
70 if ($calc_sig ne $sig)
73 print "Status: 450 sig mismatch\nContent-Type: text/plain\n\n";
74 print "$sig mismatches $calc_sig on content:\n$content";
79 # undo escape-proofing of base64 data and decode it
80 map {tr/$@/+=/; $_ = decode_base64($_); }
86 set sys_notes = nullif($2,''),
88 when coalesce($2,'') <> '' then now()
92 and status = 'approved'
96 $sth = $db->prepare($set_notes);
97 my $rv = $sth->execute($animal,$sysnotes);
100 print "Status: 460 old data fetch\nContent-Type: text/plain\n\n";
101 print "error: ",$db->errstr,"\n";
112 print "Content-Type: text/plain\n\n";
113 print "request was on:\n$content\n";