summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-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;
}
}