moved obtaining $signer and $key into a function, which now also ensures that both have a value (if not, abort with an HTTP 400 errro)
renamed LICENSE file for clarity
This commit is contained in:
37
dyndns.pl
37
dyndns.pl
@@ -138,7 +138,28 @@ sub expand_CNAME($;$) {
|
||||
return $host;
|
||||
}
|
||||
|
||||
# Method to perform an DNS Update for a single host
|
||||
# Get signer and key CGI paramseters, abort with HTTP 400 error if not present
|
||||
sub get_authinfo($$) {
|
||||
my ($cgi, $host) = @_;
|
||||
|
||||
# Get signer and key parameters
|
||||
my $signer = ($AuthMode eq 'static') ? $StaticSigner : ($cgi->param('user')
|
||||
|| (($AuthMode eq 'both') ? $StaticSigner : $host));
|
||||
my $key = ($AuthMode eq 'static') ? $StaticKey : ($cgi->param('secret')
|
||||
|| (($AuthMode eq 'both') ? $StaticSigner : undef));
|
||||
|
||||
# Ensure we have a value for signer and key, otherwise abort the processing
|
||||
if($signer eq '' or $key eq '') {
|
||||
print $cgi->header(-status=>400, -type=>'text/plain'),
|
||||
"ERROR - No/incomplete authentication information provided\n";
|
||||
exit
|
||||
}
|
||||
|
||||
# and return the values
|
||||
return($signer, $key);
|
||||
}
|
||||
|
||||
# Perform an DNS Update for a single host
|
||||
sub DNS_Update($$$$$$$) {
|
||||
my ($dnsdomain, $dnshost, $ipv4, $ipv6, $signer, $key, $debug) = @_;
|
||||
my $dnsupdate = Net::DNS::Update->new($dnsdomain);
|
||||
@@ -190,12 +211,7 @@ sub DNS_Update($$$$$$$) {
|
||||
# Handlers for the different requests
|
||||
sub handle_update($$$$$$) {
|
||||
my ($cgi, $mode, $host, $dnshost, $dnsdomain, $debug) = @_;
|
||||
|
||||
# Get signer and key parameters
|
||||
my $signer = ($AuthMode eq 'static') ? $StaticSigner : ($cgi->param('user')
|
||||
|| (($AuthMode eq 'both') ? $StaticSigner : $host));
|
||||
my $key = ($AuthMode eq 'static') ? $StaticKey : ($cgi->param('secret')
|
||||
|| (($AuthMode eq 'both') ? $StaticSigner : undef));
|
||||
my ($signer, $key) = get_authinfo($cgi, $host);
|
||||
|
||||
# perform the action
|
||||
my ($statuscode, $statusmessage);
|
||||
@@ -221,12 +237,7 @@ sub handle_update($$$$$$) {
|
||||
|
||||
sub handle_expire($$$$$$) {
|
||||
my ($cgi, $mode, $host, $dnshost, $dnsdomain, $debug) = @_;
|
||||
|
||||
# Get signer and key parameters
|
||||
my $signer = ($AuthMode eq 'static') ? $StaticSigner : ($cgi->param('user')
|
||||
|| (($AuthMode eq 'both') ? $StaticSigner : $host));
|
||||
my $key = ($AuthMode eq 'static') ? $StaticKey : ($cgi->param('secret')
|
||||
|| (($AuthMode eq 'both') ? $StaticSigner : undef));
|
||||
my ($signer, $key) = get_authinfo($cgi, $host);
|
||||
|
||||
my $debugmsg = ($debug) ? "\n" : '';
|
||||
|
||||
|
||||
Reference in New Issue
Block a user