| [216] | 1 | #!/usr/bin/perl -w -T | 
|---|
| [262] | 2 | # XMLRPC interface to manipulate most DNS DB entities | 
|---|
|  | 3 | ## | 
|---|
| [200] | 4 | # $Id: dns-rpc.cgi 407 2012-10-05 16:45:23Z kdeugau $ | 
|---|
| [320] | 5 | # Copyright 2012 Kris Deugau <kdeugau@deepnet.cx> | 
|---|
| [262] | 6 | # | 
|---|
|  | 7 | #    This program is free software: you can redistribute it and/or modify | 
|---|
|  | 8 | #    it under the terms of the GNU General Public License as published by | 
|---|
|  | 9 | #    the Free Software Foundation, either version 3 of the License, or | 
|---|
|  | 10 | #    (at your option) any later version. | 
|---|
|  | 11 | # | 
|---|
|  | 12 | #    This program is distributed in the hope that it will be useful, | 
|---|
|  | 13 | #    but WITHOUT ANY WARRANTY; without even the implied warranty of | 
|---|
|  | 14 | #    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the | 
|---|
|  | 15 | #    GNU General Public License for more details. | 
|---|
|  | 16 | # | 
|---|
|  | 17 | #    You should have received a copy of the GNU General Public License | 
|---|
|  | 18 | #    along with this program.  If not, see <http://www.gnu.org/licenses/>. | 
|---|
|  | 19 | ## | 
|---|
| [119] | 20 |  | 
|---|
|  | 21 | use strict; | 
|---|
|  | 22 | use warnings; | 
|---|
| [216] | 23 |  | 
|---|
|  | 24 | # don't remove!  required for GNU/FHS-ish install from tarball | 
|---|
|  | 25 | use lib '.';    ##uselib## | 
|---|
|  | 26 |  | 
|---|
| [119] | 27 | use DNSDB;      # note we're not importing subs;  this lets us (ab)use the same sub names here for convenience | 
|---|
| [121] | 28 | use Data::Dumper; | 
|---|
| [119] | 29 |  | 
|---|
|  | 30 | #use Frontier::RPC2; | 
|---|
|  | 31 | use Frontier::Responder; | 
|---|
|  | 32 |  | 
|---|
|  | 33 | ## We need to handle a couple of things globally, rather than pasting the same bit into *every* sub. | 
|---|
|  | 34 | ## So, let's subclass Frontier::RPC2 + Frontier::Responder, so we can override the single sub in each | 
|---|
|  | 35 | ## that needs kicking | 
|---|
|  | 36 | #### hmm.  put this in a separate file? | 
|---|
|  | 37 | #package DNSDB::RPC; | 
|---|
|  | 38 | #our @ISA = ("Frontier::RPC2", "Frontier::Responder"); | 
|---|
|  | 39 | #package main; | 
|---|
|  | 40 |  | 
|---|
| [401] | 41 | DNSDB::loadConfig(rpcflag => 1); | 
|---|
| [191] | 42 |  | 
|---|
| [119] | 43 | # need to create a DNSDB object too | 
|---|
| [191] | 44 | my ($dbh,$msg) = DNSDB::connectDB($DNSDB::config{dbname}, $DNSDB::config{dbuser}, | 
|---|
|  | 45 | $DNSDB::config{dbpass}, $DNSDB::config{dbhost}); | 
|---|
|  | 46 |  | 
|---|
| [121] | 47 | DNSDB::initGlobals($dbh); | 
|---|
| [119] | 48 |  | 
|---|
|  | 49 | my $methods = { | 
|---|
|  | 50 | 'dnsdb.addDomain'       => \&addDomain, | 
|---|
| [401] | 51 | 'dnsdb.delZone'         => \&delZone, | 
|---|
| [405] | 52 | 'dnsdb.addRDNS'         => \&addRDNS, | 
|---|
| [121] | 53 | 'dnsdb.addGroup'        => \&addGroup, | 
|---|
|  | 54 | 'dnsdb.delGroup'        => \&delGroup, | 
|---|
|  | 55 | 'dnsdb.addUser'         => \&addUser, | 
|---|
|  | 56 | 'dnsdb.updateUser'      => \&updateUser, | 
|---|
|  | 57 | 'dnsdb.delUser'         => \&delUser, | 
|---|
|  | 58 | 'dnsdb.getSOA'          => \&getSOA, | 
|---|
| [123] | 59 | 'dnsdb.getRecLine'      => \&getRecLine, | 
|---|
|  | 60 | 'dnsdb.getDomRecs'      => \&getDomRecs, | 
|---|
|  | 61 | 'dnsdb.getRecCount'     => \&getRecCount, | 
|---|
|  | 62 | 'dnsdb.addRec'          => \&addRec, | 
|---|
| [405] | 63 | 'dnsdb.updateRec'       => \&updateRec, | 
|---|
| [123] | 64 | 'dnsdb.delRec'          => \&delRec, | 
|---|
| [405] | 65 | 'dnsdb.zoneStatus'      => \&zoneStatus, | 
|---|
| [121] | 66 |  | 
|---|
| [119] | 67 | 'dnsdb.getMethods'      => \&get_method_list | 
|---|
|  | 68 | }; | 
|---|
|  | 69 |  | 
|---|
|  | 70 | my $res = Frontier::Responder->new( | 
|---|
|  | 71 | methods => $methods | 
|---|
|  | 72 | ); | 
|---|
|  | 73 |  | 
|---|
|  | 74 | # "Can't do that" errors | 
|---|
|  | 75 | if (!$dbh) { | 
|---|
|  | 76 | print "Content-type: text/xml\n\n".$res->{_decode}->encode_fault(5, $msg); | 
|---|
|  | 77 | exit; | 
|---|
|  | 78 | } | 
|---|
|  | 79 | ##fixme:  fail on missing rpcuser/rpcsystem args | 
|---|
|  | 80 |  | 
|---|
|  | 81 | print $res->answer; | 
|---|
|  | 82 |  | 
|---|
|  | 83 | exit; | 
|---|
|  | 84 |  | 
|---|
|  | 85 | ## | 
|---|
|  | 86 | ## Subs below here | 
|---|
|  | 87 | ## | 
|---|
|  | 88 |  | 
|---|
| [401] | 89 | # Utility subs | 
|---|
|  | 90 | sub _aclcheck { | 
|---|
|  | 91 | my $subsys = shift; | 
|---|
|  | 92 | return 1 if grep /$ENV{REMOTE_ADDR}/, @{$DNSDB::config{rpcacl}{$subsys}}; | 
|---|
|  | 93 | return 0; | 
|---|
|  | 94 | } | 
|---|
|  | 95 |  | 
|---|
| [405] | 96 | # Let's see if we can factor these out of the RPC method subs | 
|---|
|  | 97 | sub _commoncheck { | 
|---|
|  | 98 | my $argref = shift; | 
|---|
|  | 99 | my $needslog = shift; | 
|---|
|  | 100 |  | 
|---|
|  | 101 | die "Missing remote system name\n" if !$argref->{rpcsystem}; | 
|---|
|  | 102 | die "Access denied\n" if !_aclcheck($argref->{rpcsystem}); | 
|---|
|  | 103 | if ($needslog) { | 
|---|
|  | 104 | die "Missing remote username\n" if !$argref->{rpcuser}; | 
|---|
|  | 105 | die "Couldn't set userdata for logging\n" | 
|---|
|  | 106 | unless DNSDB::initRPC($dbh, (username => $argref->{rpcuser}, rpcsys => $argref->{rpcsystem}, | 
|---|
|  | 107 | fullname => ($argref->{fullname} ? $argref->{fullname} : $argref->{rpcuser}) ) ); | 
|---|
|  | 108 | } | 
|---|
|  | 109 | } | 
|---|
|  | 110 |  | 
|---|
| [119] | 111 | #sub connectDB { | 
|---|
|  | 112 | #sub finish { | 
|---|
|  | 113 | #sub initGlobals { | 
|---|
|  | 114 | #sub initPermissions { | 
|---|
|  | 115 | #sub getPermissions { | 
|---|
|  | 116 | #sub changePermissions { | 
|---|
|  | 117 | #sub comparePermissions { | 
|---|
|  | 118 | #sub changeGroup { | 
|---|
|  | 119 | #sub _log { | 
|---|
|  | 120 |  | 
|---|
|  | 121 | sub addDomain { | 
|---|
|  | 122 | my %args = @_; | 
|---|
|  | 123 |  | 
|---|
| [405] | 124 | _commoncheck(\%args, 'y'); | 
|---|
| [119] | 125 |  | 
|---|
|  | 126 | my ($code, $msg) = DNSDB::addDomain($dbh, $args{domain}, $args{group}, $args{state}); | 
|---|
|  | 127 | die $msg if $code eq 'FAIL'; | 
|---|
|  | 128 | return $msg;  # domain ID | 
|---|
|  | 129 | } | 
|---|
|  | 130 |  | 
|---|
| [401] | 131 | sub delZone { | 
|---|
| [119] | 132 | my %args = @_; | 
|---|
|  | 133 |  | 
|---|
| [405] | 134 | _commoncheck(\%args, 'y'); | 
|---|
|  | 135 | die "Need forward/reverse zone flag\n" if !$args{revrec}; | 
|---|
| [119] | 136 |  | 
|---|
| [121] | 137 | my ($code,$msg); | 
|---|
| [405] | 138 | # Let's be nice;  delete based on zone id OR zone name.  Saves an RPC call round-trip, maybe. | 
|---|
|  | 139 | if ($args{zone} =~ /^\d+$/) { | 
|---|
|  | 140 | ($code,$msg) = DNSDB::delZone($dbh, $args{zone}, $args{revrec}); | 
|---|
| [119] | 141 | } else { | 
|---|
| [405] | 142 | my $zoneid; | 
|---|
|  | 143 | $zoneid = DNSDB::domainID($dbh, $args{zone}) if $args{revrec} eq 'n'; | 
|---|
|  | 144 | $zoneid = DNSDB::revID($dbh, $args{zone}) if $args{revrec} eq 'y'; | 
|---|
|  | 145 | die "Can't find zone: $DNSDB::errstr\n" if !$zoneid; | 
|---|
|  | 146 | ($code,$msg) = DNSDB::delZone($dbh, $zoneid, $args{revrec}); | 
|---|
| [119] | 147 | } | 
|---|
|  | 148 | die $msg if $code eq 'FAIL'; | 
|---|
| [405] | 149 | return $msg; | 
|---|
| [119] | 150 | } | 
|---|
|  | 151 |  | 
|---|
| [405] | 152 | #sub domainName {} | 
|---|
|  | 153 | #sub revName {} | 
|---|
|  | 154 | #sub domainID {} | 
|---|
|  | 155 | #sub revID {} | 
|---|
| [119] | 156 |  | 
|---|
| [405] | 157 | sub addRDNS { | 
|---|
|  | 158 | my %args = @_; | 
|---|
|  | 159 |  | 
|---|
|  | 160 | _commoncheck(\%args, 'y'); | 
|---|
|  | 161 |  | 
|---|
|  | 162 | my ($code, $msg) = DNSDB::addRDNS($dbh, $args{revzone}, $args{revpatt}, $args{group}, $args{state}); | 
|---|
|  | 163 | die $msg if $code eq 'FAIL'; | 
|---|
|  | 164 | return $msg;  # domain ID | 
|---|
|  | 165 | } | 
|---|
|  | 166 |  | 
|---|
|  | 167 | #sub getZoneCount {} | 
|---|
|  | 168 | #sub getZoneList {} | 
|---|
|  | 169 | #sub getZoneLocation {} | 
|---|
|  | 170 |  | 
|---|
| [119] | 171 | sub addGroup { | 
|---|
|  | 172 | my %args = @_; | 
|---|
|  | 173 |  | 
|---|
| [405] | 174 | _commoncheck(\%args, 'y'); | 
|---|
| [407] | 175 | die "Missing new group name\n" if !$args{groupname}; | 
|---|
|  | 176 | die "Missing parent group ID\n" if !$args{parent_id}; | 
|---|
| [119] | 177 |  | 
|---|
| [407] | 178 | # not sure how to usefully represent permissions via RPC.  :/ | 
|---|
| [121] | 179 | # not to mention, permissions are checked at the UI layer, not the DB layer. | 
|---|
| [119] | 180 | my $perms = {domain_edit => 1, domain_create => 1, domain_delete => 1, | 
|---|
|  | 181 | record_edit => 1, record_create => 1, record_delete => 1 | 
|---|
|  | 182 | }; | 
|---|
|  | 183 | ## optional $inhert arg? | 
|---|
|  | 184 | my ($code,$msg) = DNSDB::addGroup($dbh, $args{groupname}, $args{parent_id}, $perms); | 
|---|
|  | 185 | die $msg if $code eq 'FAIL'; | 
|---|
|  | 186 | return $msg; | 
|---|
|  | 187 | } | 
|---|
|  | 188 |  | 
|---|
|  | 189 | sub delGroup { | 
|---|
|  | 190 | my %args = @_; | 
|---|
|  | 191 |  | 
|---|
| [405] | 192 | _commoncheck(\%args, 'y'); | 
|---|
| [407] | 193 | die "Missing group ID or name to remove\n" if !$args{group}; | 
|---|
| [119] | 194 |  | 
|---|
| [121] | 195 | my ($code,$msg); | 
|---|
| [119] | 196 | # Let's be nice;  delete based on groupid OR group name.  Saves an RPC call round-trip, maybe. | 
|---|
|  | 197 | if ($args{group} =~ /^\d+$/) { | 
|---|
| [121] | 198 | ($code,$msg) = DNSDB::delGroup($dbh, $args{group}); | 
|---|
| [119] | 199 | } else { | 
|---|
|  | 200 | my $grpid = DNSDB::groupID($dbh, $args{group}); | 
|---|
| [407] | 201 | die "Can't find group\n" if !$grpid; | 
|---|
| [121] | 202 | ($code,$msg) = DNSDB::delGroup($dbh, $grpid); | 
|---|
| [119] | 203 | } | 
|---|
|  | 204 | die $msg if $code eq 'FAIL'; | 
|---|
| [407] | 205 | return $msg; | 
|---|
| [119] | 206 | } | 
|---|
|  | 207 |  | 
|---|
| [405] | 208 | #sub getChildren {} | 
|---|
|  | 209 | #sub groupName {} | 
|---|
|  | 210 | #sub getGroupCount {} | 
|---|
|  | 211 | #sub getGroupList {} | 
|---|
|  | 212 | #sub groupID {} | 
|---|
| [119] | 213 |  | 
|---|
|  | 214 | sub addUser { | 
|---|
|  | 215 | my %args = @_; | 
|---|
|  | 216 |  | 
|---|
| [405] | 217 | _commoncheck(\%args, 'y'); | 
|---|
| [119] | 218 |  | 
|---|
| [121] | 219 | # not sure how to usefully represent permissions from any further out from DNSDB.pm :/ | 
|---|
|  | 220 | # not to mention, permissions are checked at the UI layer, not the DB layer. | 
|---|
|  | 221 | my $perms = {domain_edit => 1, domain_create => 1, domain_delete => 1, | 
|---|
|  | 222 | record_edit => 1, record_create => 1, record_delete => 1 | 
|---|
|  | 223 | }; | 
|---|
| [119] | 224 | # bend and twist;  get those arguments in in the right order! | 
|---|
|  | 225 | $args{type} = 'u' if !$args{type}; | 
|---|
|  | 226 | $args{permstring} = 'i' if !defined($args{permstring}); | 
|---|
|  | 227 | my @userargs = ($args{username}, $args{group}, $args{pass}, $args{state}, $args{type}, $args{permstring}); | 
|---|
|  | 228 | for my $argname ('fname','lname','phone') { | 
|---|
|  | 229 | last if !$args{$argname}; | 
|---|
|  | 230 | push @userargs, $args{$argname}; | 
|---|
|  | 231 | } | 
|---|
|  | 232 | my ($code,$msg) = DNSDB::addUser($dbh, @userargs); | 
|---|
|  | 233 | die $msg if $code eq 'FAIL'; | 
|---|
|  | 234 | return $msg; | 
|---|
|  | 235 | } | 
|---|
|  | 236 |  | 
|---|
| [405] | 237 | #sub getUserCount {} | 
|---|
|  | 238 | #sub getUserList {} | 
|---|
|  | 239 | #sub getUserDropdown {} | 
|---|
|  | 240 | #sub checkUser {} | 
|---|
| [119] | 241 |  | 
|---|
|  | 242 | sub updateUser { | 
|---|
|  | 243 | my %args = @_; | 
|---|
|  | 244 |  | 
|---|
| [405] | 245 | _commoncheck(\%args, 'y'); | 
|---|
| [119] | 246 |  | 
|---|
| [401] | 247 | die "Missing UID\n" if !$args{uid}; | 
|---|
| [121] | 248 |  | 
|---|
|  | 249 | # not sure how to usefully represent permissions from any further out from DNSDB.pm :/ | 
|---|
|  | 250 | # not to mention, permissions are checked at the UI layer, not the DB layer. | 
|---|
|  | 251 | my $perms = {domain_edit => 1, domain_create => 1, domain_delete => 1, | 
|---|
|  | 252 | record_edit => 1, record_create => 1, record_delete => 1 | 
|---|
|  | 253 | }; | 
|---|
| [119] | 254 | # bend and twist;  get those arguments in in the right order! | 
|---|
|  | 255 | my @userargs = ($args{uid}, $args{username}, $args{group}, $args{pass}, $args{state}, $args{type}); | 
|---|
|  | 256 | for my $argname ('fname','lname','phone') { | 
|---|
|  | 257 | last if !$args{$argname}; | 
|---|
|  | 258 | push @userargs, $args{$argname}; | 
|---|
|  | 259 | } | 
|---|
|  | 260 | ##fixme:  also underlying in DNSDB::updateUser():  no way to just update this or that attribute; | 
|---|
|  | 261 | #         have to pass them all in to be overwritten | 
|---|
|  | 262 | my ($code,$msg) = DNSDB::addUser($dbh, @userargs); | 
|---|
|  | 263 | die $msg if $code eq 'FAIL'; | 
|---|
|  | 264 | } | 
|---|
|  | 265 |  | 
|---|
|  | 266 | sub delUser { | 
|---|
|  | 267 | my %args = @_; | 
|---|
|  | 268 |  | 
|---|
| [405] | 269 | _commoncheck(\%args, 'y'); | 
|---|
| [119] | 270 |  | 
|---|
| [401] | 271 | die "Missing UID\n" if !$args{uid}; | 
|---|
| [119] | 272 | my ($code,$msg) = DNSDB::delUser($dbh, $args{uid}); | 
|---|
|  | 273 | die $msg if $code eq 'FAIL'; | 
|---|
|  | 274 | } | 
|---|
|  | 275 |  | 
|---|
| [405] | 276 | #sub userFullName {} | 
|---|
|  | 277 | #sub userStatus {} | 
|---|
|  | 278 | #sub getUserData {} | 
|---|
| [119] | 279 |  | 
|---|
| [405] | 280 | #sub addLoc {} | 
|---|
|  | 281 | #sub updateLoc {} | 
|---|
|  | 282 | #sub delLoc {} | 
|---|
|  | 283 | #sub getLoc {} | 
|---|
|  | 284 | #sub getLocCount {} | 
|---|
|  | 285 | #sub getLocList {} | 
|---|
|  | 286 | #sub getLocDropdown {} | 
|---|
|  | 287 |  | 
|---|
| [119] | 288 | sub getSOA { | 
|---|
|  | 289 | my %args = @_; | 
|---|
|  | 290 |  | 
|---|
| [405] | 291 | _commoncheck(\%args); | 
|---|
| [121] | 292 |  | 
|---|
|  | 293 | my %ret = DNSDB::getSOA($dbh, $args{def}, $args{id}); | 
|---|
|  | 294 | if (!$ret{recid}) { | 
|---|
|  | 295 | if ($args{def} eq 'y') { | 
|---|
| [401] | 296 | die "No default SOA record in group\n"; | 
|---|
| [121] | 297 | } else { | 
|---|
| [401] | 298 | die "No SOA record in domain\n"; | 
|---|
| [121] | 299 | } | 
|---|
|  | 300 | } | 
|---|
|  | 301 | return \%ret; | 
|---|
| [119] | 302 | } | 
|---|
|  | 303 |  | 
|---|
| [405] | 304 | #sub updateSOA {} | 
|---|
|  | 305 |  | 
|---|
| [119] | 306 | sub getRecLine { | 
|---|
|  | 307 | my %args = @_; | 
|---|
|  | 308 |  | 
|---|
| [405] | 309 | _commoncheck(\%args); | 
|---|
| [123] | 310 |  | 
|---|
|  | 311 | my $ret = DNSDB::getRecLine($dbh, $args{def}, $args{id}); | 
|---|
|  | 312 |  | 
|---|
|  | 313 | die $DNSDB::errstr if !$ret; | 
|---|
|  | 314 |  | 
|---|
|  | 315 | return $ret; | 
|---|
| [119] | 316 | } | 
|---|
|  | 317 |  | 
|---|
|  | 318 | sub getDomRecs { | 
|---|
|  | 319 | my %args = @_; | 
|---|
|  | 320 |  | 
|---|
| [405] | 321 | _commoncheck(\%args); | 
|---|
| [123] | 322 |  | 
|---|
| [405] | 323 | # set some optional args | 
|---|
| [123] | 324 | $args{nrecs} = 'all' if !$args{nrecs}; | 
|---|
|  | 325 | $args{nstart} = 0 if !$args{nstart}; | 
|---|
|  | 326 | ## for order, need to map input to column names | 
|---|
|  | 327 | $args{order} = 'host' if !$args{order}; | 
|---|
|  | 328 | $args{direction} = 'ASC' if !$args{direction}; | 
|---|
|  | 329 |  | 
|---|
| [401] | 330 | my $ret = DNSDB::getDomRecs($dbh, (defrec => $args{defrec}, revrec => $args{revrec}, id => $args{id}, | 
|---|
|  | 331 | offset => $args{offset}, sortby => $args{sortby}, sortorder => $args{sortorder}, | 
|---|
|  | 332 | filter => $args{filter}) ); | 
|---|
| [123] | 333 |  | 
|---|
|  | 334 | die $DNSDB::errstr if !$ret; | 
|---|
|  | 335 |  | 
|---|
|  | 336 | return $ret; | 
|---|
| [119] | 337 | } | 
|---|
|  | 338 |  | 
|---|
| [123] | 339 | sub getRecCount { | 
|---|
|  | 340 | my %args = @_; | 
|---|
| [119] | 341 |  | 
|---|
| [405] | 342 | _commoncheck(\%args); | 
|---|
| [123] | 343 |  | 
|---|
| [405] | 344 | # set some optional args | 
|---|
|  | 345 | $args{nrecs} = 'all' if !$args{nrecs}; | 
|---|
|  | 346 | $args{nstart} = 0 if !$args{nstart}; | 
|---|
|  | 347 | ## for order, need to map input to column names | 
|---|
|  | 348 | $args{order} = 'host' if !$args{order}; | 
|---|
|  | 349 | $args{direction} = 'ASC' if !$args{direction}; | 
|---|
|  | 350 |  | 
|---|
|  | 351 | my $ret = DNSDB::getRecCount($dbh, (defrec => $args{defrec}, revrec => $args{revrec}, id => $args{id}, | 
|---|
|  | 352 | offset => $args{offset}, sortby => $args{sortby}, sortorder => $args{sortorder}, | 
|---|
|  | 353 | filter => $args{filter}) ); | 
|---|
|  | 354 |  | 
|---|
|  | 355 | die $DNSDB::errstr if !$ret; | 
|---|
|  | 356 |  | 
|---|
|  | 357 | return $ret; | 
|---|
| [123] | 358 | } | 
|---|
|  | 359 |  | 
|---|
| [119] | 360 | sub addRec { | 
|---|
|  | 361 | my %args = @_; | 
|---|
|  | 362 |  | 
|---|
| [405] | 363 | _commoncheck(\%args, 'y'); | 
|---|
| [123] | 364 |  | 
|---|
| [405] | 365 | # note dist, weight, port are not required on all types;  will be ignored if not needed. | 
|---|
| [401] | 366 | my ($code, $msg) = DNSDB::addRec($dbh, $args{def}, $args{domid}, $args{host}, $DNSDB::typemap{$args{type}}, | 
|---|
| [123] | 367 | $args{val}, $args{ttl}, $args{dist}, $args{weight}, $args{port}); | 
|---|
|  | 368 |  | 
|---|
|  | 369 | die $msg if $code eq 'FAIL'; | 
|---|
| [119] | 370 | } | 
|---|
|  | 371 |  | 
|---|
|  | 372 | sub updateRec { | 
|---|
|  | 373 | my %args = @_; | 
|---|
|  | 374 |  | 
|---|
| [405] | 375 | _commoncheck(\%args, 'y'); | 
|---|
| [123] | 376 |  | 
|---|
| [405] | 377 | # note dist, weight, port are not required on all types;  will be ignored if not needed. | 
|---|
| [401] | 378 | my ($code, $msg) = DNSDB::updateRec($dbh, $args{def}, $args{recid}, $args{host}, $DNSDB::typemap{$args{type}}, | 
|---|
| [123] | 379 | $args{val}, $args{ttl}, $args{dist}, $args{weight}, $args{port}); | 
|---|
|  | 380 |  | 
|---|
|  | 381 | die $msg if $code eq 'FAIL'; | 
|---|
| [119] | 382 | } | 
|---|
|  | 383 |  | 
|---|
|  | 384 | sub delRec { | 
|---|
|  | 385 | my %args = @_; | 
|---|
|  | 386 |  | 
|---|
| [405] | 387 | _commoncheck(\%args, 'y'); | 
|---|
| [123] | 388 |  | 
|---|
|  | 389 | my ($code, $msg) = DNSDB::delRec($dbh, $args{def}, $args{recid}); | 
|---|
|  | 390 |  | 
|---|
|  | 391 | die $msg if $code eq 'FAIL'; | 
|---|
| [119] | 392 | } | 
|---|
|  | 393 |  | 
|---|
| [405] | 394 | #sub getLogCount {} | 
|---|
|  | 395 | #sub getLogEntries {} | 
|---|
|  | 396 | #sub getTypelist {} | 
|---|
|  | 397 | #sub parentID {} | 
|---|
|  | 398 | #sub isParent {} | 
|---|
| [123] | 399 |  | 
|---|
| [405] | 400 | sub zoneStatus { | 
|---|
| [123] | 401 | my %args = @_; | 
|---|
|  | 402 |  | 
|---|
| [405] | 403 | _commoncheck(\%args, 'y'); | 
|---|
| [123] | 404 |  | 
|---|
| [405] | 405 | my @arglist = ($dbh, $args{zoneid}); | 
|---|
| [123] | 406 | push @arglist, $args{status} if defined($args{status}); | 
|---|
|  | 407 |  | 
|---|
| [405] | 408 | my $status = DNSDB::zoneStatus(@arglist); | 
|---|
| [123] | 409 | } | 
|---|
|  | 410 |  | 
|---|
| [405] | 411 | #sub importAXFR {} | 
|---|
|  | 412 | #sub importBIND {} | 
|---|
|  | 413 | #sub import_tinydns {} | 
|---|
|  | 414 | #sub export {} | 
|---|
|  | 415 | #sub __export_tiny {} | 
|---|
|  | 416 | #sub _printrec_tiny {} | 
|---|
|  | 417 | #sub mailNotify {} | 
|---|
| [119] | 418 |  | 
|---|
|  | 419 | sub get_method_list { | 
|---|
|  | 420 | my @methods = keys %{$methods}; | 
|---|
|  | 421 | return \@methods; | 
|---|
|  | 422 | } | 
|---|