- Timestamp:
- 12/11/13 15:31:44 (11 years ago)
- Location:
- branches/stable
- Files:
-
- 12 edited
- 1 copied
Legend:
- Unmodified
- Added
- Removed
-
branches/stable
- Property svn:mergeinfo changed
/trunk merged: 425-429,435,439-440
- Property svn:mergeinfo changed
-
branches/stable/DNSDB.pm
r545 r546 3074 3074 3075 3075 ## DNSDB::updateLoc() 3076 # Update details of a location. 3077 # Takes a database handle, location ID, group ID, short description, 3078 # long comments/notes, and comma/space-separated IP list 3079 # Returns a result code and message 3076 3080 sub updateLoc { 3077 3081 my $dbh = shift; … … 3116 3120 3117 3121 ## DNSDB::delLoc() 3118 sub delLoc {} 3122 sub delLoc { 3123 my $dbh = shift; 3124 my $loc = shift; 3125 3126 # Allow transactions, and raise an exception on errors so we can catch it later. 3127 # Use local to make sure these get "reset" properly on exiting this block 3128 local $dbh->{AutoCommit} = 0; 3129 local $dbh->{RaiseError} = 1; 3130 3131 my $oldloc = getLoc($dbh, $loc); 3132 my $olddesc = ($oldloc->{description} ? $oldloc->{description} : $loc); 3133 my $okmsg = "Deleted location ($olddesc, '".$oldloc->{iplist}."')"; 3134 3135 eval { 3136 # Check for records with this location first. Deleting a location without deleting records 3137 # tagged for that location will render them unpublished without other warning. 3138 my ($r) = $dbh->selectrow_array("SELECT record_id FROM records WHERE location=? LIMIT 1", undef, ($loc) ); 3139 die "Records still exist in location $olddesc\n" if $r; 3140 $dbh->do("DELETE FROM locations WHERE location=?", undef, ($loc) ); 3141 _log($dbh, entry => $okmsg); 3142 $dbh->commit; 3143 }; 3144 if ($@) { 3145 my $msg = $@; 3146 eval { $dbh->rollback; }; 3147 if ($config{log_failures}) { 3148 _log($dbh, (entry => "Failed to delete location ($olddesc, '$oldloc->{iplist}'): $msg")); 3149 $dbh->commit; 3150 } 3151 return ('FAIL', "Failed to delete location ($olddesc, '$oldloc->{iplist}'): $msg"); 3152 } 3153 3154 return ('OK',$okmsg); 3155 } # end delLoc() 3119 3156 3120 3157 3121 3158 ## DNSDB::getLoc() 3159 # Get details about a location/view 3160 # Takes a database handle and location ID. 3161 # Returns a reference to a hash containing the group ID, IP list, description, and comments/notes 3122 3162 sub getLoc { 3123 3163 my $dbh = shift; … … 3325 3365 my $id = shift; 3326 3366 3327 my $sql = "SELECT record_id,host,type,val,ttl,location".($revrec eq 'n' ? ',distance,weight,port' : ''). 3367 my $sql = "SELECT record_id,host,type,val,ttl". 3368 ($defrec eq 'n' ? ',location' : ''). 3369 ($revrec eq 'n' ? ',distance,weight,port' : ''). 3328 3370 (($defrec eq 'y') ? ',group_id FROM ' : ',domain_id,rdns_id FROM '). 3329 3371 _rectable($defrec,$revrec)." WHERE record_id=?"; … … 3400 3442 $sql .= "WHERE "._recparent($args{defrec},$args{revrec})." = ?"; 3401 3443 $sql .= " AND NOT r.type=$reverse_typemap{SOA}"; 3402 $sql .= " AND host ~* ?" if $args{filter};3444 $sql .= " AND (r.host ~* ? OR r.val ~* ?)" if $args{filter}; 3403 3445 $sql .= " ORDER BY $args{sortby} $args{sortorder}"; 3404 3446 # ensure consistent ordering by sorting on record_id too … … 3407 3449 3408 3450 my @bindvars = ($args{id}); 3409 push @bindvars, $args{filter}if $args{filter};3451 push @bindvars, ($args{filter},$args{filter}) if $args{filter}; 3410 3452 3411 3453 my $ret = $dbh->selectall_arrayref($sql, { Slice => {} }, (@bindvars) ); … … 3548 3590 $logdata{entry} .= " [priority $dist] [weight $weight] [port $port]" 3549 3591 if $typemap{$$rectype} eq 'SRV'; 3550 $logdata{entry} .= "', TTL $ttl, location $location"; 3592 $logdata{entry} .= "', TTL $ttl"; 3593 $logdata{entry} .= ", location ".getLoc($dbh, $location)->{description} if $location; 3551 3594 3552 3595 # Allow transactions, and raise an exception on errors so we can catch it later. … … 3709 3752 $logdata{entry} .= " [priority $oldrec->{distance}] [weight $oldrec->{weight}] [port $oldrec->{port}]" 3710 3753 if $typemap{$oldrec->{type}} eq 'SRV'; 3711 $logdata{entry} .= "', TTL $oldrec->{ttl}, location $oldrec->{location}\nto\n"; 3754 $logdata{entry} .= "', TTL $oldrec->{ttl}"; 3755 $logdata{entry} .= ", location ".getLoc($dbh, $oldrec->{location})->{description} if $oldrec->{location}; 3756 $logdata{entry} .= "\nto\n"; 3712 3757 # More NS special 3713 3758 if ($revrec eq 'y' && $$rectype == 2) { … … 3718 3763 $logdata{entry} .= " [distance $dist]" if $typemap{$$rectype} eq 'MX'; 3719 3764 $logdata{entry} .= " [priority $dist] [weight $weight] [port $port]" if $typemap{$$rectype} eq 'SRV'; 3720 $logdata{entry} .= "', TTL $ttl, location $location"; 3765 $logdata{entry} .= "', TTL $ttl"; 3766 $logdata{entry} .= ", location ".getLoc($dbh, $location)->{description} if $location; 3721 3767 3722 3768 local $dbh->{AutoCommit} = 0; … … 3778 3824 $logdata{entry} .= " [priority $oldrec->{distance}] [weight $oldrec->{weight}] [port $oldrec->{port}]" 3779 3825 if $typemap{$oldrec->{type}} eq 'SRV'; 3780 $logdata{entry} .= "', TTL $oldrec->{ttl}\n"; 3826 $logdata{entry} .= "', TTL $oldrec->{ttl}"; 3827 $logdata{entry} .= ", location ".getLoc($dbh, $oldrec->{location})->{description} if $oldrec->{location}; 3781 3828 3782 3829 eval { -
branches/stable/Makefile
r438 r546 55 55 templates/adddomain.tmpl templates/addgroup.tmpl templates/addrec.tmpl templates/adduser.tmpl \ 56 56 templates/axfr.tmpl templates/bulkchange.tmpl templates/bulkdomain.tmpl templates/dberr.tmpl \ 57 templates/deldom.tmpl templates/delgrp.tmpl templates/delrec.tmpl templates/deluser.tmpl \ 57 templates/deldom.tmpl templates/delgrp.tmpl templates/delloc.tmpl templates/delrec.tmpl \ 58 templates/delrevzone.tmpl templates/deluser.tmpl \ 58 59 templates/dns.css templates/dnsq.tmpl templates/domlist.tmpl templates/edgroup.tmpl \ 59 60 templates/editsoa.tmpl templates/footer.tmpl templates/fpnla.tmpl templates/grouptree.css \ … … 82 83 templates/adddomain.tmpl templates/addgroup.tmpl templates/addrec.tmpl templates/adduser.tmpl \ 83 84 templates/axfr.tmpl templates/bulkchange.tmpl templates/bulkdomain.tmpl templates/dberr.tmpl \ 84 templates/deldom.tmpl templates/delgrp.tmpl templates/delrec.tmpl templates/deluser.tmpl \ 85 templates/deldom.tmpl templates/delgrp.tmpl templates/delloc.tmpl templates/delrec.tmpl \ 86 templates/delrevzone.tmpl templates/deluser.tmpl \ 85 87 templates/dns.css templates/dnsq.tmpl templates/domlist.tmpl templates/edgroup.tmpl \ 86 88 templates/editsoa.tmpl templates/footer.tmpl templates/fpnla.tmpl templates/grouptree.css \ -
branches/stable/dns-rpc.cgi
r545 r546 356 356 _commoncheck(\%args, 'y'); 357 357 358 # add records in the zone's default location if none is specified 359 if (!$args{location} && $args{defrec} eq 'n') { 360 $args{location} = DNSDB::getZoneLocation($dbh, $args{revrec}, $args{parent_id}); 361 } 362 363 my @recargs = ($dbh, $args{defrec}, $args{revrec}, $args{parent_id}, 364 \$args{name}, \$args{type}, \$args{address}, $args{ttl}, $args{location}); 365 if ($args{type} == $DNSDB::reverse_typemap{MX} or $args{type} == $DNSDB::reverse_typemap{SRV}) { 366 push @recargs, $args{distance}; 367 if ($args{type} == $DNSDB::reverse_typemap{SRV}) { 368 push @recargs, $args{weight}; 369 push @recargs, $args{port}; 370 } 371 } 372 373 my ($code, $msg) = DNSDB::addRec(@recargs); 374 375 die $msg if $code eq 'FAIL'; 376 return $msg; 377 } 378 379 sub updateRec { 380 my %args = @_; 381 382 _commoncheck(\%args, 'y'); 383 358 384 # note dist, weight, port are not required on all types; will be ignored if not needed. 359 my ($code, $msg) = DNSDB::addRec($dbh, $args{def}, $args{domid}, $args{host}, $DNSDB::typemap{$args{type}}, 360 $args{val}, $args{ttl}, $args{dist}, $args{weight}, $args{port}); 361 362 die $msg if $code eq 'FAIL'; 363 } 364 365 sub updateRec { 366 my %args = @_; 367 368 _commoncheck(\%args, 'y'); 369 370 # note dist, weight, port are not required on all types; will be ignored if not needed. 371 my ($code, $msg) = DNSDB::updateRec($dbh, $args{def}, $args{recid}, $args{host}, $DNSDB::typemap{$args{type}}, 372 $args{val}, $args{ttl}, $args{dist}, $args{weight}, $args{port}); 373 374 die $msg if $code eq 'FAIL'; 385 # parent_id is the "primary" zone we're updating; necessary for forward/reverse voodoo 386 my ($code, $msg) = DNSDB::updateRec($dbh, $args{defrec}, $args{revrec}, $args{id}, $args{parent_id}, 387 \$args{name}, \$args{type}, \$args{address}, $args{ttl}, $args{location}, 388 $args{distance}, $args{weight}, $args{port}); 389 390 die $msg if $code eq 'FAIL'; 391 return $msg; 375 392 } 376 393 … … 380 397 _commoncheck(\%args, 'y'); 381 398 382 my ($code, $msg) = DNSDB::delRec($dbh, $args{def}, $args{recid}); 383 384 die $msg if $code eq 'FAIL'; 399 my ($code, $msg) = DNSDB::delRec($dbh, $args{defrec}, $args{recrev}, $args{id}); 400 401 die $msg if $code eq 'FAIL'; 402 return $msg; 385 403 } 386 404 -
branches/stable/dns.cgi
r545 r546 1362 1362 # } 1363 1363 1364 if ($webvar{locact} eq 'new') {1365 # uuhhmm.... 1366 } elsif ($webvar{locact} eq 'add') {1364 $webvar{locact} = '' if !$webvar{locact}; 1365 1366 if ($webvar{locact} eq 'add') { 1367 1367 changepage(page => "loclist", errmsg => "You are not permitted to add locations/views", id => $webvar{parentid}) 1368 1368 unless ($permissions{admin} || $permissions{location_create}); … … 1430 1430 1431 1431 show_msgs(); 1432 } 1433 1434 } elsif ($webvar{page} eq 'delloc') { 1435 1436 changepage(page=> "loclist", errmsg => "You are not allowed to delete locations") 1437 unless $permissions{admin} || $permissions{location_delete}; 1438 1439 # security check - does the user have permission to access this entity? 1440 # if (!check_scope(id => $webvar{id}, type => 'loc')) { 1441 # changepage(page => "loclist", errmsg => "You are not permitted to <foo> the requested location/view"); 1442 # } 1443 1444 $page->param(locid => $webvar{locid}); 1445 my $locdata = getLoc($dbh, $webvar{locid}); 1446 $locdata->{description} = $webvar{locid} if !$locdata->{description}; 1447 # first pass = confirm y/n (sorta) 1448 if (!defined($webvar{del})) { 1449 $page->param(del_getconf => 1); 1450 $page->param(location => $locdata->{description}); 1451 } elsif ($webvar{del} eq 'ok') { 1452 my ($code,$msg) = delLoc($dbh, $webvar{locid}); 1453 if ($code eq 'OK') { 1454 # success. go back to the user list, do not pass "GO" 1455 changepage(page => "loclist", resultmsg => $msg); 1456 } else { 1457 changepage(page => "loclist", errmsg => $msg); 1458 } 1459 } else { 1460 # cancelled. whee! 1461 changepage(page => "loclist"); 1432 1462 } 1433 1463 -
branches/stable/templates/deldom.tmpl
r100 r546 5 5 <td align="center" valign="top"> 6 6 <h3>Are you really sure you want to delete domain <TMPL_VAR NAME=domain>?</h3> 7 <a href="dns.cgi?sid=<TMPL_VAR NAME=sid>&page=deldom&del=cancel&id=<TMPL_VAR NAME=id>">cancel</a> | <a href="dns.cgi?sid=<TMPL_VAR NAME=sid>&page=deldom&del=ok&id=<TMPL_VAR NAME=id>">confirm</a> 7 <a href="dns.cgi?sid=<TMPL_VAR NAME=sid>&page=deldom&del=cancel&id=<TMPL_VAR NAME=id>">cancel</a> | 8 <a href="dns.cgi?sid=<TMPL_VAR NAME=sid>&page=deldom&del=ok&id=<TMPL_VAR NAME=id>">confirm</a> 8 9 </td></tr></table> 9 10 -
branches/stable/templates/delgrp.tmpl
r141 r546 4 4 5 5 <td align="center" valign="top"> 6 7 6 <h3>Are you really sure you want to delete group <TMPL_VAR NAME=delgroupname>?</h3> 8 7 <a href="dns.cgi?sid=<TMPL_VAR NAME=sid>&page=delgrp&del=cancel&id=<TMPL_VAR NAME=id>">cancel</a> | 9 8 <a href="dns.cgi?sid=<TMPL_VAR NAME=sid>&page=delgrp&del=ok&id=<TMPL_VAR NAME=id>">confirm</a> 10 11 <!--12 fixme: do a check for "group has stuff in it", and splatter a big warning13 up along with an unchecked-by-default check box to YES DAMMIT DELETE THE WHOLE THING14 -->15 16 9 </td></tr></table> 17 10 -
branches/stable/templates/delrevzone.tmpl
r545 r546 5 5 <td align="center" valign="top"> 6 6 <h3>Are you really sure you want to delete reverse zone <TMPL_VAR NAME=revzone>?</h3> 7 <a href="dns.cgi?sid=<TMPL_VAR NAME=sid>&page=delrevzone&del=cancel&id=<TMPL_VAR NAME=id>">cancel</a> | <a href="dns.cgi?sid=<TMPL_VAR NAME=sid>&page=delrevzone&del=ok&id=<TMPL_VAR NAME=id>">confirm</a> 7 <a href="dns.cgi?sid=<TMPL_VAR NAME=sid>&page=delrevzone&del=cancel&id=<TMPL_VAR NAME=id>">cancel</a> | 8 <a href="dns.cgi?sid=<TMPL_VAR NAME=sid>&page=delrevzone&del=ok&id=<TMPL_VAR NAME=id>">confirm</a> 8 9 </td></tr></table> 9 10 -
branches/stable/templates/deluser.tmpl
r100 r546 5 5 <td align="center" valign="top"> 6 6 <h3>Are you really sure you want to delete user <TMPL_VAR NAME=user>?</h3> 7 <a href="dns.cgi?sid=<TMPL_VAR NAME=sid>&page=deluser&del=cancel&id=<TMPL_VAR NAME=id>">cancel</a> | <a href="dns.cgi?sid=<TMPL_VAR NAME=sid>&page=deluser&del=ok&id=<TMPL_VAR NAME=id>">confirm</a> 7 <a href="dns.cgi?sid=<TMPL_VAR NAME=sid>&page=deluser&del=cancel&id=<TMPL_VAR NAME=id>">cancel</a> | 8 <a href="dns.cgi?sid=<TMPL_VAR NAME=sid>&page=deluser&del=ok&id=<TMPL_VAR NAME=id>">confirm</a> 8 9 </td></tr></table> 9 10 -
branches/stable/templates/loclist.tmpl
r545 r546 36 36 <td><TMPL_VAR name=group_name></td> 37 37 <TMPL_IF delloc> 38 <td align="center"><a href="dns.cgi?sid=<TMPL_VAR NAME=sid>&page=delloc& id=<TMPL_VAR39 NAME=loc >"><img src="images/trash2.png" alt="[ Delete ]" /></a></td>38 <td align="center"><a href="dns.cgi?sid=<TMPL_VAR NAME=sid>&page=delloc&locid=<TMPL_VAR 39 NAME=location>"><img src="images/trash2.png" alt="[ Delete ]" /></a></td> 40 40 </TMPL_IF> 41 41 </tr> -
branches/stable/templates/newdomain.tmpl
r545 r546 32 32 <td>Make domain active on next DNS propagation</td><td><input type="checkbox" name="makeactive"<TMPL_UNLESS addinactive> checked="checked"</TMPL_UNLESS> /></td> 33 33 </tr> 34 <TMPL_IF location_view> 34 <TMPL_IF location_view><TMPL_IF record_locchg> 35 35 <tr class="datalinelight"> 36 36 <td>Default location/view:</td> 37 37 <td><select name="defloc"> 38 <option value="">(None/public)</option>39 38 <TMPL_LOOP name=loclist> <option value="<TMPL_VAR NAME=loc>"<TMPL_IF selected> selected="selected"</TMPL_IF>><TMPL_VAR NAME=locname></option> 40 39 </TMPL_LOOP> 41 40 </select></td> 42 41 </tr> 43 </TMPL_IF> 42 </TMPL_IF></TMPL_IF> 44 43 <tr><td colspan="2" class="tblsubmit"><input type="submit" value="Add domain" /></td></tr> 45 44 </table> -
branches/stable/textrecs.cgi
r535 r546 88 88 foreach my $rec (@$reclist) { 89 89 $rec->{type} = $typemap{$rec->{type}}; 90 $rec->{val} .= '.' if $rec->{type} ne 'A' && $rec->{type} ne 'TXT' && $ rec->{val} !~ /\.$/;91 $rec->{host} .= '.' if $ rec->{val} !~ /\.$/;90 $rec->{val} .= '.' if $rec->{type} ne 'A' && $rec->{type} ne 'TXT' && $webvar{revrec} eq 'n' && $rec->{val} !~ /\.$/; 91 $rec->{host} .= '.' if $webvar{revrec} eq 'y' && $rec->{val} !~ /\.$/; 92 92 $rec->{val} = "$rec->{distance} $rec->{val}" if $rec->{type} eq 'MX'; 93 93 $rec->{val} = "$rec->{distance} $rec->{weight} $rec->{port} $rec->{val}" if $rec->{type} eq 'SRV';
Note:
See TracChangeset
for help on using the changeset viewer.