- Timestamp:
- 05/17/16 17:37:32 (8 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/dns-rpc.cgi
r717 r721 246 246 ($code,$msg) = $dnsdb->delZone($args{zone}, $args{revrec}); 247 247 } else { 248 die "Need zone location\n" if !defined($args{location}); 248 249 my $zoneid; 249 $zoneid = $dnsdb->domainID($args{zone} ) if $args{revrec} eq 'n';250 $zoneid = $dnsdb->revID($args{zone} ) if $args{revrec} eq 'y';250 $zoneid = $dnsdb->domainID($args{zone}, $args{location}) if $args{revrec} eq 'n'; 251 $zoneid = $dnsdb->revID($args{zone}, $args{location}) if $args{revrec} eq 'y'; 251 252 die "Can't find zone: ".$dnsdb->errstr."\n" if !$zoneid; 252 253 ($code,$msg) = $dnsdb->delZone($zoneid, $args{revrec}); … … 264 265 _commoncheck(\%args, 'y'); 265 266 266 my $domid = $dnsdb->domainID($args{domain} );267 my $domid = $dnsdb->domainID($args{domain}, $args{location}); 267 268 die $dnsdb->errstr."\n" if !$domid; 268 269 return $domid; … … 450 451 die "Missing zone ID\n" if !$args{id}; 451 452 453 # caller may not know about zone IDs. accept the zone name, but require a location if so 454 if ($args{id} !~ /^\d+$/) { 455 die "Location required to use the zone name\n" if !defined($args{location}); 456 } 457 452 458 # set some optional args 453 459 $args{offset} = 0 if !$args{offset}; … … 461 467 if ($args{defrec} eq 'n') { 462 468 if ($args{revrec} eq 'n') { 463 $args{id} = $dnsdb->domainID($args{id} ) if $args{id} !~ /^\d+$/;469 $args{id} = $dnsdb->domainID($args{id}, $args{location}) if $args{id} !~ /^\d+$/; 464 470 } else { 465 $args{id} = $dnsdb->revID($args{id} ) if $args{id} !~ /^\d+$/471 $args{id} = $dnsdb->revID($args{id}, $args{location}) if $args{id} !~ /^\d+$/ 466 472 } 467 473 } … … 485 491 486 492 _reccheck(\%args); 493 494 # caller may not know about zone IDs. accept the zone name, but require a location if so 495 if ($args{id} !~ /^\d+$/) { 496 die "Location required to use the zone name\n" if !defined($args{location}); 497 } 487 498 488 499 # set some optional args … … 493 504 $args{direction} = 'ASC' if !$args{direction}; 494 505 506 # convert zone name to zone ID, if needed 507 if ($args{defrec} eq 'n') { 508 if ($args{revrec} eq 'n') { 509 $args{id} = $dnsdb->domainID($args{id}, $args{location}) if $args{id} !~ /^\d+$/; 510 } else { 511 $args{id} = $dnsdb->revID($args{id}, $args{location}) if $args{id} !~ /^\d+$/ 512 } 513 } 514 515 # fail if we *still* don't have a valid zone ID 516 die $dnsdb->errstr."\n" if !$args{id}; 517 495 518 my $ret = $dnsdb->getRecCount(defrec => $args{defrec}, revrec => $args{revrec}, 496 519 id => $args{id}, filter => $args{filter}); … … 499 522 500 523 return $ret; 501 } 524 } # getRecCount() 502 525 503 526 # The core sub uses references for some arguments to allow limited modification for … … 572 595 _commoncheck(\%args, 'y'); 573 596 my $cidr = new NetAddr::IP $args{cidr}; 597 598 # Location required so we don't turn up unrelated zones in getZonesByCIDR(). 599 # Caller should generally have some knowledge of this. 600 die "Need location\n" if !defined($args{location}); 574 601 575 602 my $zonelist = $dnsdb->getZonesByCIDR(%args); … … 696 723 my $cidr = new NetAddr::IP $args{cidr}; 697 724 725 # Location required so we don't turn up unrelated zones in getZonesByCIDR(). 726 # Caller should generally have some knowledge of this. 727 die "Need location\n" if !defined($args{location}); 728 698 729 my $zonelist = $dnsdb->getZonesByCIDR(%args); 699 730 … … 764 795 765 796 my $up_res; 797 798 # Location required so we don't turn up unrelated zones in getZonesByCIDR(). 799 # Caller should generally have some knowledge of this. 800 die "Need location\n" if !defined($args{location}); 766 801 767 802 my $zonelist = $dnsdb->getZonesByCIDR(%args); … … 827 862 my @retlist; 828 863 829 my $zsth = $dnsdb->{dbh}->prepare("SELECT rdns_id,group_id FROM revzones WHERE revnet >>= ?"); 864 # Location required so we don't turn up unrelated zones 865 die "Need location\n" if !defined($args{location}); 866 867 my $zsth = $dnsdb->{dbh}->prepare("SELECT rdns_id,group_id FROM revzones WHERE revnet >>= ? AND location = ?"); 830 868 # Going to assume template records with no expiry 831 869 # Also note IPv6 template records don't expand sanely the way v4 records do … … 850 888 eval { 851 889 foreach my $template (@{$args{templates}}) { 852 $zsth->execute($template );890 $zsth->execute($template, $args{location}); 853 891 my ($zid,$zgrp) = $zsth->fetchrow_array; 854 892 if (!$zid) { … … 909 947 # Caller may pass 'n' in delsubs. Assume it should be false/undefined 910 948 # unless the caller explicitly requested 'yes' 911 $args{delsubs} = 0 if $args{delsubs} ne 'y';949 $args{delsubs} = 0 if !$args{delsubs} || $args{delsubs} ne 'y'; 912 950 913 951 # Don't delete the A component of an A+PTR by default 914 952 $args{delforward} = 0 if !$args{delforward}; 915 953 916 # make sure this is set if not passed917 $args{location} = '' if !$args{location};954 # Location required so we don't turn up unrelated zones in getZonesByCIDR(). 955 die "Need location\n" if !defined($args{location}); 918 956 919 957 # much like addOrUpdateRevRec()
Note:
See TracChangeset
for help on using the changeset viewer.