Changeset 121 for trunk/dns-rpc.cgi
- Timestamp:
- 09/08/11 18:09:58 (13 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/dns-rpc.cgi
r119 r121 5 5 use warnings; 6 6 use DNSDB; # note we're not importing subs; this lets us (ab)use the same sub names here for convenience 7 use Data::Dumper; 7 8 8 9 #use Frontier::RPC2; … … 19 20 # need to create a DNSDB object too 20 21 my ($dbh,$msg) = DNSDB::connectDB("dnsdb","dnsdb","secret","dnsdbhost"); 22 DNSDB::initGlobals($dbh); 21 23 22 24 my $methods = { 23 25 'dnsdb.addDomain' => \&addDomain, 24 26 'dnsdb.delDomain' => \&delDomain, 27 'dnsdb.addGroup' => \&addGroup, 28 'dnsdb.delGroup' => \&delGroup, 29 'dnsdb.addUser' => \&addUser, 30 'dnsdb.updateUser' => \&updateUser, 31 'dnsdb.delUser' => \&delUser, 32 'dnsdb.getSOA' => \&getSOA, 33 25 34 'dnsdb.getMethods' => \&get_method_list 26 35 }; … … 79 88 die "Missing remote system name" if !$args{rpcsystem}; # for logging 80 89 90 my ($code,$msg); 81 91 # Let's be nice; delete based on domid OR domain name. Saves an RPC call round-trip, maybe. 82 92 if ($args{domain} =~ /^\d+$/) { 83 my($code,$msg) = DNSDB::delDomain($dbh, $args{domain});93 ($code,$msg) = DNSDB::delDomain($dbh, $args{domain}); 84 94 } else { 85 95 my $domid = DNSDB::domainID($dbh, $args{domain}); 86 96 die "Can't find domain" if !$domid; 87 my($code,$msg) = DNSDB::delDomain($dbh, $domid);97 ($code,$msg) = DNSDB::delDomain($dbh, $domid); 88 98 } 89 99 die $msg if $code eq 'FAIL'; … … 101 111 102 112 # not sure how to usefully represent permissions from any further out from DNSDB.pm :/ 113 # not to mention, permissions are checked at the UI layer, not the DB layer. 103 114 my $perms = {domain_edit => 1, domain_create => 1, domain_delete => 1, 104 115 record_edit => 1, record_create => 1, record_delete => 1 … … 117 128 die "Missing remote system name" if !$args{rpcsystem}; # for logging 118 129 130 my ($code,$msg); 119 131 # Let's be nice; delete based on groupid OR group name. Saves an RPC call round-trip, maybe. 120 132 if ($args{group} =~ /^\d+$/) { 121 my($code,$msg) = DNSDB::delGroup($dbh, $args{group});133 ($code,$msg) = DNSDB::delGroup($dbh, $args{group}); 122 134 } else { 123 135 my $grpid = DNSDB::groupID($dbh, $args{group}); 124 136 die "Can't find group" if !$grpid; 125 my($code,$msg) = DNSDB::delGroup($dbh, $grpid);137 ($code,$msg) = DNSDB::delGroup($dbh, $grpid); 126 138 } 127 139 die $msg if $code eq 'FAIL'; … … 139 151 die "Missing remote system name" if !$args{rpcsystem}; # for logging 140 152 153 # not sure how to usefully represent permissions from any further out from DNSDB.pm :/ 154 # not to mention, permissions are checked at the UI layer, not the DB layer. 155 my $perms = {domain_edit => 1, domain_create => 1, domain_delete => 1, 156 record_edit => 1, record_create => 1, record_delete => 1 157 }; 141 158 # bend and twist; get those arguments in in the right order! 142 159 $args{type} = 'u' if !$args{type}; … … 162 179 163 180 die "Missing UID" if !$args{uid}; 181 182 # not sure how to usefully represent permissions from any further out from DNSDB.pm :/ 183 # not to mention, permissions are checked at the UI layer, not the DB layer. 184 my $perms = {domain_edit => 1, domain_create => 1, domain_delete => 1, 185 record_edit => 1, record_create => 1, record_delete => 1 186 }; 164 187 # bend and twist; get those arguments in in the right order! 165 188 my @userargs = ($args{uid}, $args{username}, $args{group}, $args{pass}, $args{state}, $args{type}); … … 196 219 die "Missing remote username" if !$args{rpcuser}; # for logging 197 220 die "Missing remote system name" if !$args{rpcsystem}; # for logging 221 222 my %ret = DNSDB::getSOA($dbh, $args{def}, $args{id}); 223 if (!$ret{recid}) { 224 if ($args{def} eq 'y') { 225 die "No default SOA record in group"; 226 } else { 227 die "No SOA record in domain"; 228 } 229 } 230 return \%ret; 198 231 } 199 232
Note:
See TracChangeset
for help on using the changeset viewer.