summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorNiko Tyni <ntyni@iki.fi>2005-09-04 11:20:48 +0200
committerNiko Tyni <ntyni@iki.fi>2005-09-04 11:20:48 +0200
commit733f5ee3d4aad0c1a21d796d5a36baa82389e199 (patch)
tree73a76e9a5ae4ef3b01f947b0e1a21a241428953e
parent08a913068ea426a7bd7c520ef140f3a2f50b8939 (diff)
downloadsmokeping-733f5ee3d4aad0c1a21d796d5a36baa82389e199.tar.gz
smokeping-733f5ee3d4aad0c1a21d796d5a36baa82389e199.tar.xz
* 2.0/lib/Smokeping.pm,
2.0/TODO, 2.0/CHANGES: + return '404 not found' when DYNAMIC updates fail
-rw-r--r--CHANGES2
-rw-r--r--TODO6
-rw-r--r--lib/Smokeping.pm19
3 files changed, 14 insertions, 13 deletions
diff --git a/CHANGES b/CHANGES
index 4d19be9..bb48678 100644
--- a/CHANGES
+++ b/CHANGES
@@ -1,3 +1,5 @@
+* return '404 not found' when DYNAMIC updates fail
+ - niko, suggested by Marc Haber <mh+smokeping-users *zugschlus.de>
* make errors in DYNAMIC updates appear in the web server error log
-- niko
* remove a quotemeta() call in Config::Grammar to allow metacharacters
diff --git a/TODO b/TODO
index 5a8f386..625350f 100644
--- a/TODO
+++ b/TODO
@@ -41,12 +41,6 @@
- suggested by Leos Bitto,
<http://lists.ee.ethz.ch/smokeping-users/msg01632.html>
-* CGI RETURN VALUE
- return something else than 200 OK in error situations at least
- when updating DYNAMIC addresses
- - suggested by Marc Haber,
- <http://lists.ee.ethz.ch/smokeping-users/msg01644.html>
-
* CONFIG
make the .adr (and .snmp) directory configurable
- suggested by Marc Haber,
diff --git a/lib/Smokeping.pm b/lib/Smokeping.pm
index 050cb34..18415f4 100644
--- a/lib/Smokeping.pm
+++ b/lib/Smokeping.pm
@@ -118,11 +118,11 @@ sub update_dynaddr ($$){
my $address = $ENV{REMOTE_ADDR};
my $targetptr = $cfg->{Targets};
foreach my $step (@target){
- return "Error: Unknown Target $step"
+ return "Error: Unknown target $step"
unless defined $targetptr->{$step};
$targetptr = $targetptr->{$step};
};
- return "Error: Invalid Target"
+ return "Error: Invalid target or secret"
unless defined $targetptr->{host} and
$targetptr->{host} eq "DYNAMIC/${secret}";
my $file = $cfg->{General}{datadir}."/".(join "/", @target);
@@ -2568,15 +2568,20 @@ sub cgi ($) {
umask 022;
load_cfg shift;
my $q=new CGI;
- print $q->header(-type=>'text/html',
- -expires=>'+'.($cfg->{Database}{step}).'s',
- -charset=> ( $cfg->{Presentation}{charset} || 'iso-8859-15')
- );
initialize_cgilog();
if ($q->param(-name=>'secret') && $q->param(-name=>'target') ) {
my $ret = update_dynaddr $cfg,$q;
- do_cgilog($ret) if defined $ret and $ret ne "";
+ if (defined $ret and $ret ne "") {
+ print $q->header(-status => "404 Not Found");
+ do_cgilog("Updating DYNAMIC address failed: $ret");
+ } else {
+ print $q->header; # no HTML output on success
+ }
} else {
+ print $q->header(-type=>'text/html',
+ -expires=>'+'.($cfg->{Database}{step}).'s',
+ -charset=> ( $cfg->{Presentation}{charset} || 'iso-8859-15')
+ );
display_webpage $cfg,$q;
}
}