source: trunk/cgi-bin/main.cgi@ 811

Last change on this file since 811 was 811, checked in by Kris Deugau, 8 years ago

/trunk

"add VRF" action etc. See #54.

  • Property svn:executable set to *
  • Property svn:keywords set to Date Rev Author
File size: 55.8 KB
RevLine 
[4]1#!/usr/bin/perl
2# ipdb/cgi-bin/main.cgi
[8]3###
4# SVN revision info
5# $Date: 2016-03-08 18:54:14 +0000 (Tue, 08 Mar 2016) $
6# SVN revision $Rev: 811 $
7# Last update by $Author: kdeugau $
8###
[417]9# Copyright (C) 2004-2010 - Kris Deugau
[4]10
11use strict;
12use warnings;
13use CGI::Carp qw(fatalsToBrowser);
[517]14use CGI::Simple;
15use HTML::Template;
[4]16use DBI;
17use POSIX qw(ceil);
18use NetAddr::IP;
[582]19use Frontier::Client;
[4]20
21use Sys::Syslog;
22
[417]23# don't remove! required for GNU/FHS-ish install from tarball
24##uselib##
25
[515]26use CustIDCK;
[417]27use MyIPDB;
28
[431]29openlog "IPDB","pid","$IPDB::syslog_facility";
[4]30
[517]31## Environment. Collect some things, process some things, set some things...
32
[233]33# Collect the username from HTTP auth. If undefined, we're in
34# a test environment, or called without a username.
[4]35my $authuser;
36if (!defined($ENV{'REMOTE_USER'})) {
37 $authuser = '__temptest';
38} else {
39 $authuser = $ENV{'REMOTE_USER'};
40}
41
[517]42# anyone got a better name? :P
43my $thingroot = $ENV{SCRIPT_FILENAME};
44$thingroot =~ s|cgi-bin/main.cgi||;
45
[402]46syslog "debug", "$authuser active, $ENV{'REMOTE_ADDR'}";
[4]47
[517]48##fixme there *must* be a better order to do things in so this can go back where it was
49# CGI fiddling done here so we can declare %webvar so we can alter $webvar{action}
50# to show the right page on DB errors.
51# Set up the CGI object...
52my $q = new CGI::Simple;
53# ... and get query-string params as well as POST params if necessary
54$q->parse_query_string;
55
56# Convenience; saves changing all references to %webvar
57##fixme: tweak for handling <select multiple='y' size=3> (list with multiple selection)
58my %webvar = $q->Vars;
59
[106]60# Why not a global DB handle? (And a global statement handle, as well...)
61# Use the connectDB function, otherwise we end up confusing ourselves
62my $ip_dbh;
63my $errstr;
[142]64($ip_dbh,$errstr) = connectDB_My;
[106]65if (!$ip_dbh) {
[517]66 $webvar{action} = "dberr";
67} else {
68 initIPDBGlobals($ip_dbh);
[106]69}
[4]70
[517]71# Set up some globals
[793]72$ENV{HTML_TEMPLATE_ROOT} = $thingroot;
73my @templatepath = [ "localtemplates", "templates" ];
[233]74
[793]75my $header = HTML::Template->new(filename => "header.tmpl", path => @templatepath);
76my $footer = HTML::Template->new(filename => "footer.tmpl", path => @templatepath);
77my $utilbar = HTML::Template->new(filename => "utilbar.tmpl", loop_context_vars => 1, global_vars => 1,
78 path => @templatepath);
[233]79
[697]80print "Content-type: text/html\n\n";
81
[517]82$header->param(version => $IPDB::VERSION);
83$header->param(addperm => $IPDBacl{$authuser} =~ /a/);
84$header->param(webpath => $IPDB::webpath);
[4]85
[697]86$utilbar->param(webpath => $IPDB::webpath);
[4]87
[697]88print $header->output;
89
[760]90##fixme: whine and complain when the user is not present in the ACL hash above
[697]91
[4]92#main()
[517]93my $aclerr;
[4]94
95if(!defined($webvar{action})) {
[517]96 $webvar{action} = "index"; #shuts up the warnings.
[4]97}
98
[517]99my $page;
[793]100if (-e "$ENV{HTML_TEMPLATE_ROOT}/templates/$webvar{action}.tmpl") {
101 $page = HTML::Template->new(filename => "$webvar{action}.tmpl", loop_context_vars => 1, global_vars => 1,
102 path => @templatepath);
[517]103} else {
[793]104 $page = HTML::Template->new(filename => "dunno.tmpl", die_on_bad_params => 0,
105 path => @templatepath);
[517]106}
107
[4]108if($webvar{action} eq 'index') {
109 showSummary();
[808]110} elsif ($webvar{action} eq 'showvrf') {
111 showVRF();
[810]112
113} elsif ($webvar{action} eq 'addvrf') {
114 if ($IPDBacl{$authuser} !~ /s/) {
115 $aclerr = 'addvrf';
116 }
117
118 # Retrieve the list of DNS locations if we've got a place to grab them from
119 if ($IPDB::rpc_url) {
120 my %rpcargs = (
121 rpcuser => $authuser,
122 group => 1, # bleh
123 defloc => '',
124 );
125 my $result = IPDB::_rpc('getLocDropdown', %rpcargs);
126 $page->param(loclist => $result);
127 }
128
[811]129} elsif ($webvar{action} eq 'newvrf') {
130 if ($IPDBacl{$authuser} !~ /s/) {
131 $aclerr = 'addvrf';
132 } else {
133 my ($code,$msg) = addVRF($ip_dbh, $webvar{vrf}, comment => $webvar{comment}, location => $webvar{loc});
134
135 if ($code eq 'FAIL') {
136 syslog "err", "Could not add VRF '$webvar{vrf}' to database: '$msg'";
137 $page->param(err => $msg);
138 $page->param(vrf => $webvar{vrf});
139 } else {
140 $page->param(vrf => $msg);
141 if ($code eq 'WARN') {
142 $IPDB::errstr =~ s/\n\n/<br>\n/g;
143 $IPDB::errstr =~ s/:\n/:<br>\n/g;
144 $page->param(warn => $IPDB::errstr);
145 }
146 syslog "info", "$authuser added VRF $webvar{vrf}";
147 }
148
149 } # ACL check
150
[233]151} elsif ($webvar{action} eq 'addmaster') {
152 if ($IPDBacl{$authuser} !~ /a/) {
[517]153 $aclerr = 'addmaster';
[233]154 }
[582]155
156 # Retrieve the list of DNS locations if we've got a place to grab them from
157 if ($IPDB::rpc_url) {
158 my %rpcargs = (
159 rpcuser => $authuser,
160 group => 1, # bleh
161 defloc => '',
162 );
[623]163 my $result = IPDB::_rpc('getLocDropdown', %rpcargs);
[582]164 $page->param(loclist => $result);
165 }
166
[4]167} elsif ($webvar{action} eq 'newmaster') {
168
[233]169 if ($IPDBacl{$authuser} !~ /a/) {
[517]170 $aclerr = 'addmaster';
[233]171 } else {
172 my $cidr = new NetAddr::IP $webvar{cidr};
[517]173 $page->param(cidr => "$cidr");
[4]174
[582]175 my ($code,$msg) = addMaster($ip_dbh, $webvar{cidr}, (vrf => $webvar{vrf}, rdns => $webvar{rdns},
176 rwhois => $webvar{rwhois}, defloc => $webvar{loc}, user => $authuser) );
[4]177
[371]178 if ($code eq 'FAIL') {
[320]179 syslog "err", "Could not add master block '$webvar{cidr}' to database: '$msg'";
[517]180 $page->param(err => $msg);
[233]181 } else {
[624]182 $page->param(parent => $msg);
[582]183 if ($code eq 'WARN') {
[624]184 $IPDB::errstr =~ s/\n\n/<br>\n/g;
185 $IPDB::errstr =~ s/:\n/:<br>\n/g;
186 $page->param(warn => $IPDB::errstr);
[582]187 }
[233]188 syslog "info", "$authuser added master block $webvar{cidr}";
189 }
[4]190
[233]191 } # ACL check
192
[4]193} # end add new master
194
[567]195elsif ($webvar{action} eq 'showsubs') {
196 showSubs();
197}
198
[4]199elsif($webvar{action} eq 'listpool') {
[528]200 showPool();
[4]201}
202
203# Not modified or added; just shuffled
204elsif($webvar{action} eq 'assign') {
205 assignBlock();
206}
207elsif($webvar{action} eq 'confirm') {
208 confirmAssign();
209}
210elsif($webvar{action} eq 'insert') {
211 insertAssign();
212}
213elsif($webvar{action} eq 'edit') {
214 edit();
215}
216elsif($webvar{action} eq 'update') {
217 update();
218}
[702]219elsif($webvar{action} eq 'split') {
220 prepSplit();
221}
222elsif($webvar{action} eq 'dosplit') {
223 doSplit();
224}
[717]225elsif($webvar{action} eq 'merge') {
226 prepMerge();
227}
[720]228elsif($webvar{action} eq 'confmerge') {
229 confMerge();
230}
[751]231elsif($webvar{action} eq 'domerge') {
232 doMerge();
233}
[4]234elsif($webvar{action} eq 'delete') {
235 remove();
236}
237elsif($webvar{action} eq 'finaldelete') {
238 finalDelete();
239}
[397]240elsif ($webvar{action} eq 'nodesearch') {
[519]241 my $nodelist = getNodeList($ip_dbh);
242 $page->param(nodelist => $nodelist);
[517]243}
[397]244
[517]245# DB failure. Can't do much here, really.
246elsif ($webvar{action} eq 'dberr') {
247 $page->param(errmsg => $errstr);
[397]248}
249
[517]250# Default is an error. It shouldn't be possible to get here unless you're
251# randomly feeding in values for webvar{action}.
[4]252else {
253 my $rnd = rand 500;
254 my $boing = sprintf("%.2f", rand 500);
[517]255 my @excuses = (
256 "Aether cloudy. Ask again later about $webvar{action}.",
257 "The gods are unhappy with your sacrificial $webvar{action}.",
258 "Because one of $webvar{action}'s legs are both the same",
259 "<b>wibble</b><br>Can't $webvar{action}, the grue will get me!<br>Can't $webvar{action}, the grue will get me!",
260 "Hey, man, you've had your free $webvar{action}. Next one's gonna... <i>cost</i>....",
261 "I ain't done $webvar{action}",
262 "Oooo, look! A flying $webvar{action}!",
263 "$webvar{action} too evil, avoiding.",
264 "Rocks fall, $webvar{action} dies.",
265 "Bit bucket must be emptied before I can $webvar{action}..."
266 );
267 $page->param(dunno => $excuses[$rnd/50.0]);
[4]268}
[111]269## Finally! Done with that NASTY "case" emulation!
[4]270
271
[517]272# Switch to a different template if we've tripped on an ACL error.
273# Note that this should only be exercised in development, when
274# deeplinked, or when being attacked; normal ACL handling should
275# remove the links a user is not allowed to click on.
276if ($aclerr) {
[793]277 $page = HTML::Template->new(filename => "aclerror.tmpl", path => @templatepath);
[517]278 $page->param(ipdbfunc => $aclmsg{$aclerr});
279}
[4]280
[106]281# Clean up IPDB globals, DB handle, etc.
[111]282finish($ip_dbh);
[199]283
[517]284## Do all our printing here so we can generate errors and stick them into the slots in the templates.
[199]285
[517]286# can't do this yet, too many blowups
287#print "Content-type: text/html\n\n", $header->output;
288$page->param(webpath => $IPDB::webpath);
[697]289print $utilbar->output;
[517]290print $page->output;
291
292# include the admin tools link in the output?
293$footer->param(adminlink => ($IPDBacl{$authuser} =~ /A/));
294$footer->param(webpath => $IPDB::webpath);
295print $footer->output;
296
[106]297# Just in case something waaaayyy down isn't in place
298# properly... we exit explicitly.
[517]299exit 0;
[4]300
301
[806]302# Initial display: Show list of VRFs
[118]303sub showSummary {
[806]304 my $vrflist = listVRF($ip_dbh);
305 $page->param(vrflist => $vrflist);
[106]306
[806]307 # Only systems/network should be allowed to add VRFs - or maybe higher?
308 $page->param(addvrf => ($IPDBacl{$authuser} =~ /s/) );
[4]309} # showSummary
310
311
[808]312# Show IP blocks in a VRF
313sub showVRF {
314 my $masterlist = listSummary($ip_dbh, $webvar{vrf});
315 $page->param(vrf => $webvar{vrf});
316 $page->param(masterlist => $masterlist);
317
318 # we don't have a netblock; pass 0 for the block ID
319 # Tree navigation
320 my $crumbs = getBreadCrumbs($ip_dbh, 0, $webvar{vrf});
321 my @rcrumbs = reverse (@$crumbs);
322 $utilbar->param(breadcrumb => \@rcrumbs);
323
324 $page->param(addmaster => ($IPDBacl{$authuser} =~ /s/) );
325} # showVRF
326
327
[566]328# Display blocks immediately within a given parent
329sub showSubs {
[682]330 # Which layout?
331 if ($IPDB::sublistlayout == 2) {
332
333 # 2-part layout; mixed containers and end-use allocations and free blocks.
334 # Containers have a second line for the subblock metadata.
335 # We need to load an alternate template for this case.
[793]336 $page = HTML::Template->new(filename => "showsubs2.tmpl", loop_context_vars => 1, global_vars => 1,
337 path => @templatepath);
[682]338
339 $page->param(maydel => ($IPDBacl{$authuser} =~ /d/));
340
341 my $sublist = listSubs($ip_dbh, parent => $webvar{parent});
342 $page->param(sublist => $sublist);
343
344 } else {
345
[685]346 # 3-part layout; containers, end-use allocations, and free blocks
[682]347
348 my $contlist = listContainers($ip_dbh, parent => $webvar{parent});
349 $page->param(contlist => $contlist);
350
351 my $alloclist = listAllocations($ip_dbh, parent => $webvar{parent});
352 $page->param(alloclist => $alloclist);
353
354 # only show "delete" button if we have no container or usage allocations
355 $page->param(maydel => ($IPDBacl{$authuser} =~ /d/) && !(@$contlist || @$alloclist));
356
357 }
358
359 # Common elements
[627]360 my $pinfo = getBlockData($ip_dbh, $webvar{parent});
361
[685]362##fixme: do we add a wrapper to not show the edit link for master blocks?
363#$page->param(editme => 1) unless $pinfo->{type} ne 'mm';
364
[808]365 my $crumbs = getBreadCrumbs($ip_dbh, $pinfo->{parent_id}, $pinfo->{vrf});
[697]366 my @rcrumbs = reverse (@$crumbs);
367 $utilbar->param(breadcrumb => \@rcrumbs);
368
[685]369 $page->param(self_id => $webvar{parent});
[627]370 $page->param(block => $pinfo->{block});
[566]371 $page->param(mayadd => ($IPDBacl{$authuser} =~ /a/));
[4]372
[627]373 my $flist = listFree($ip_dbh, parent => $webvar{parent});
[566]374 $page->param(freelist => $flist);
375} # showSubs
[4]376
377
378# List the IPs used in a pool
[528]379sub showPool {
[4]380
[631]381 my $poolinfo = getBlockData($ip_dbh, $webvar{pool});
382 my $cidr = new NetAddr::IP $poolinfo->{block};
[771]383 $page->param(vlan => $poolinfo->{vlan});
[4]384
[697]385 # Tree navigation
386 my $crumbs = getBreadCrumbs($ip_dbh, $poolinfo->{parent_id});
387 my @rcrumbs = reverse (@$crumbs);
388 $utilbar->param(breadcrumb => \@rcrumbs);
389
[631]390 $page->param(block => $cidr);
[517]391 $page->param(netip => $cidr->addr);
392 $cidr++;
393 $page->param(gate => $cidr->addr);
394 $cidr--; $cidr--;
395 $page->param(bcast => $cidr->addr);
396 $page->param(mask => $cidr->mask);
[157]397
[528]398 $page->param(disptype => $disp_alloctypes{$poolinfo->{type}});
399 $page->param(city => $poolinfo->{city});
[517]400
[157]401 # Only display net/gw/bcast if it's a "real" netblock and not a PPP(oE) lunacy
[528]402 $page->param(realblock => $poolinfo->{type} =~ /^.d$/);
[4]403
404# probably have to add an "edit IP allocation" link here somewhere.
405
[528]406 my $plist = listPool($ip_dbh, $webvar{pool});
407 # technically slightly more efficient to check the ACL in an if () once outside the foreach
408 foreach (@{$plist}) {
409 $$_{maydel} = $IPDBacl{$authuser} =~ /d/;
[4]410 }
[528]411 $page->param(poolips => $plist);
412} # end showPool
[4]413
414
[106]415# Show "Add new allocation" page. Note that the actual page may
416# be one of two templates, and the lists come from the database.
[4]417sub assignBlock {
418
[233]419 if ($IPDBacl{$authuser} !~ /a/) {
[517]420 $aclerr = 'addblock';
[233]421 return;
422 }
423
[517]424 # hack pthbttt eww
[633]425 $webvar{parent} = 0 if !$webvar{parent};
[517]426 $webvar{block} = '' if !$webvar{block};
[21]427
[575]428 $page->param(allocfrom => $webvar{block}); # fb-assign flag, if block is set, we're in fb-assign
[517]429
[633]430 if ($webvar{fbid} || $webvar{fbtype}) {
[575]431
432 # Common case, according to reported usage. Block to assign is specified.
[21]433 my $block = new NetAddr::IP $webvar{block};
[187]434
[675]435 my ($rdns,$cached) = getBlockRDNS($ip_dbh, id => $webvar{parent}, type => $webvar{fbtype}, user => $authuser);
[585]436 $page->param(rdns => $rdns) if $rdns;
[633]437 $page->param(parent => $webvar{parent});
438 $page->param(fbid => $webvar{fbid});
[675]439 # visual flag that we're working IPDB-local, not off more authoritative data in dnsadmin
440 $page->param(cached => $cached);
[585]441
[691]442 my $pinfo = getBlockData($ip_dbh, $webvar{parent});
443 # seems reasonable that a new allocation would share a VRF with its parent
444 $page->param(pvrf => $pinfo->{vrf});
445
[697]446 # Tree navigation
447 my $crumbs = getBreadCrumbs($ip_dbh, $webvar{parent});
448 my @rcrumbs = reverse (@$crumbs);
449 $utilbar->param(breadcrumb => \@rcrumbs);
450
[575]451 $webvar{fbtype} = '' if !$webvar{fbtype};
452 if ($webvar{fbtype} eq 'i') {
[633]453 my $ipinfo = getBlockData($ip_dbh, $webvar{block}, 'i');
[575]454 $page->param(
455 fbip => 1,
[633]456 block => $ipinfo->{block},
[575]457 fbdisptype => $list_alloctypes{$ipinfo->{type}},
458 type => $ipinfo->{type},
[633]459 allocfrom => $pinfo->{block},
[575]460 );
[187]461 } else {
[529]462 # get "primary" alloctypes, since these are all that can correctly be assigned if we're in this branch
[575]463 my $tlist = getTypeList($ip_dbh, 'n');
[529]464 $tlist->[0]->{sel} = 1;
[575]465 $page->param(typelist => $tlist, block => $block);
[106]466 }
[575]467
[21]468 } else {
[575]469
470 # Uncommon case, according to reported usage. Block to assign needs to be found based on criteria.
[541]471 my $mlist = getMasterList($ip_dbh, 'c');
472 $page->param(masterlist => $mlist);
[517]473
474 my @pops;
[633]475 foreach my $pop (@citylist) {
[517]476 my %row = (pop => $pop);
477 push (@pops, \%row);
[92]478 }
[517]479 $page->param(pops => \@pops);
480
[529]481 # get all standard alloctypes
482 my $tlist = getTypeList($ip_dbh, 'a');
483 $tlist->[0]->{sel} = 1;
484 $page->param(typelist => $tlist);
[21]485 }
[517]486
487 my @cities;
[92]488 foreach my $city (@citylist) {
[517]489 my %row = (city => $city);
490 push (@cities, \%row);
[92]491 }
[517]492 $page->param(citylist => \@cities);
[4]493
[397]494## node hack
[530]495 my $nlist = getNodeList($ip_dbh);
496 $page->param(nodelist => $nlist);
[397]497## end node hack
498
[782]499 $page->param(nocling => $IPDBacl{$authuser} =~ /s/);
[284]500
[4]501} # assignBlock
502
503
504# Take info on requested IP assignment and see what we can provide.
505sub confirmAssign {
[233]506 if ($IPDBacl{$authuser} !~ /a/) {
[517]507 $aclerr = 'addblock';
[233]508 return;
509 }
[4]510
511 my $cidr;
[692]512 my $resv; # Reserved for expansion.
[4]513 my $alloc_from;
[633]514 my $fbid = $webvar{fbid};
515 my $p_id = $webvar{parent};
[4]516
517 # Going to manually validate some items.
518 # custid and city are automagic.
[111]519 return if !validateInput();
[4]520
[665]521 # make sure this is defined
522 $webvar{fbassign} = 'n' if !$webvar{fbassign};
523
[4]524# Several different cases here.
525# Static IP vs netblock
526# + Different flavours of static IP
527# + Different flavours of netblock
528
[575]529 if ($webvar{alloctype} =~ /^.i$/ && $webvar{fbassign} ne 'y') {
[665]530 if (!$webvar{pop}) {
531 $page->param(err => "Please select a location/POP site to allocate from.");
532 return;
533 }
[532]534 my $plist = getPoolSelect($ip_dbh, $webvar{alloctype}, $webvar{pop});
[517]535 $page->param(staticip => 1);
[532]536 $page->param(poollist => $plist) if $plist;
[4]537 $cidr = "Single static IP";
[517]538##fixme: need to handle "no available pools"
[4]539
540 } else { # end show pool options
[21]541
[533]542 if ($webvar{fbassign} && $webvar{fbassign} eq 'y') {
[697]543
544 # Tree navigation
545 my $crumbs = getBreadCrumbs($ip_dbh, $webvar{parent});
546 my @rcrumbs = reverse (@$crumbs);
547 $utilbar->param(breadcrumb => \@rcrumbs);
548
[21]549 $cidr = new NetAddr::IP $webvar{block};
[575]550 $alloc_from = new NetAddr::IP $webvar{allocfrom};
[21]551 $webvar{maskbits} = $cidr->masklen;
[692]552 # Some additional checks are needed for reserving free space
553 if ($webvar{reserve}) {
554 if ($cidr == $alloc_from) {
555# We could still squirm and fiddle to try to find a way to reserve space, but the storage model for
556# IPDB means that all continguous free space is kept in the smallest number of strict CIDR netblocks
557# possible. (In theory.) If the request and the freeblock are the same, it is theoretically impossible
558# to reserve an equivalent-sized block either ahead or behind the requested one, because the pair
559# together would never be a strict CIDR block.
560 $page->param(warning => "Can't reserve space for expansion; free block and requested allocation are the same.");
561 delete $webvar{reserve};
562 } else {
563 # Find which new free block will match the reqested block.
564 # Take the requested mask, shift by one
565 my $tmpmask = $webvar{maskbits};
566 $tmpmask--;
567 # find the subnets with that mask in the selected free block
568 my @pieces = $alloc_from->split($tmpmask);
569 foreach my $slice (@pieces) {
570 if ($slice->contains($cidr)) {
571 # For the subnet that contains the requested block, split that in two,
572 # and flag/cache the one that's not the requested block.
573 my @bits = $slice->split($webvar{maskbits});
574 if ($bits[0] == $cidr) {
575 $resv = $bits[1];
576 } else {
577 $resv = $bits[0];
578 }
579 }
580 }
581 }
582 } # reserve block check
583
[21]584 } else { # done with direct freeblocks assignment
585
586 if (!$webvar{maskbits}) {
[517]587 $page->param(err => "Please specify a CIDR mask length.");
[111]588 return;
[21]589 }
[533]590
591##fixme ick, ew, bleh. gotta handle the failure message generation better. push it into findAllocateFrom()?
592 my $failmsg = "No suitable free block found.<br>\n";
[187]593 if ($webvar{alloctype} eq 'rm') {
[533]594 $failmsg .= "We do not have a free routeable block of that size.<br>\n".
595 "You will have to either route a set of smaller netblocks or a single smaller netblock.";
[4]596 } else {
[214]597 if ($webvar{alloctype} =~ /^.[pc]$/) {
[533]598 $failmsg .= "You will have to route another superblock from one of the<br>\n".
599 "master blocks or chose a smaller block size for the pool.";
[21]600 } else {
[517]601 if (!$webvar{pop}) {
602 $page->param(err => 'Please select a POP to route the block from/through.');
603 return;
604 }
[533]605 $failmsg .= "You will have to route another superblock to $webvar{pop}<br>\n".
[692]606 "from one of the master blocks";
607 if ($webvar{reserve}) {
608 $failmsg .= ', choose a smaller blocksize, or uncheck "Reserve space for expansion".';
609 } else {
610 $failmsg .= " or chose a smaller blocksize.";
611 }
[21]612 }
[4]613 }
[533]614
[692]615 # if requesting extra space "reserved for expansion", we need to find a free
616 # block at least double the size of the request.
617 if ($webvar{reserve}) {
618 $webvar{maskbits}--;
619 }
620
[633]621 ($fbid,$cidr,$p_id) = findAllocateFrom($ip_dbh, $webvar{maskbits}, $webvar{alloctype},
622 $webvar{city}, $webvar{pop}, (master => $webvar{allocfrom}, allowpriv => $webvar{allowpriv}) );
[533]623 if (!$cidr) {
[517]624 $page->param(err => $failmsg);
[111]625 return;
[21]626 }
[533]627 $cidr = new NetAddr::IP $cidr;
[575]628
629 $alloc_from = "$cidr";
[692]630
631 # when autofinding a block to allocate from, use the first piece of the found
632 # block for the allocation, and the next piece for the "reserved for expansion".
633 if ($webvar{reserve}) {
634 # reset the mask to the real requested one, now that we've got a
635 # block large enough for the request plus reserve
636 $webvar{maskbits}++;
637 ($cidr,$resv) = $cidr->split($webvar{maskbits});
638 }
639
[575]640 # If the block to be allocated is smaller than the one we found,
641 # figure out the "real" block to be allocated.
642 if ($cidr->masklen() ne $webvar{maskbits}) {
643 my $maskbits = $cidr->masklen();
644 my @subblocks;
645 while ($maskbits++ < $webvar{maskbits}) {
646 @subblocks = $cidr->split($maskbits);
647 }
648 $cidr = $subblocks[0];
649 }
[21]650 } # check for freeblocks assignment or IPDB-controlled assignment
[4]651
[674]652 # Generate the IP list for the new allocation in case someone wants to set per-IP rDNS right away.
653 # We don't do this on the previous page because we don't know how big a block or even what IP range
654 # it's for (if following the "normal" allocation process)
655 if ($IPDBacl{$authuser} =~ /c/
656 && $cidr->masklen != $cidr->bits
[780]657 && ($cidr->bits - $cidr->masklen) <= $IPDB::maxrevlist
658 # config flag for "all block types" OR "not-a-pool-or-IP type"
659 && ($IPDB::revlistalltypes || $webvar{alloctype} !~ /^.[dpi]/)
660 # safety against trying to retrieve and display more than 1k (10 bits, /22 v4) worth of individual IPs
661 # ever. If you really need to manage a long list of IPs like that all in one place, you can use the DNS
662 # management tool. Even a /26 is a bit much, really.
663 && ($cidr->bits - $cidr->masklen) <= 10
[674]664 # do we want to allow v6 at all?
665 #&& ! $cidr->{isv6}
666 ) {
667 my @list;
668 foreach my $ip (@{$cidr->splitref()}) {
669 my %row;
670 $row{r_ip} = $ip->addr;
671 $row{iphost} = '';
672 push @list, \%row;
673 }
674 $page->param(r_iplist => \@list);
675 # We don't use this here, because these IPs should already be bare.
676 # ... or should we be paranoid? Make it a config option?
677 #getRDNSbyIP($ip_dbh, type => $webvar{alloctype}, range => "$cidr", user => $authuser) );
678 }
[157]679 } # if ($webvar{alloctype} =~ /^.i$/)
[4]680
[397]681## node hack
682 if ($webvar{node} && $webvar{node} ne '-') {
[530]683 my $nodename = getNodeName($ip_dbh, $webvar{node});
[517]684 $page->param(nodename => $nodename);
685 $page->param(nodeid => $webvar{node});
[397]686 }
687## end node hack
688
[760]689 # flag DNS info if we can't publish the entry remotely
690 my $pinfo = getBlockData($ip_dbh, $webvar{parent});
691 $page->param(dnslocal => 1) unless ($pinfo->{revpartial} || $pinfo->{revavail});
692
[692]693 # reserve for expansion
694 $page->param(reserve => $webvar{reserve});
695 # probably just preventing a little log noise doing this; could just set the param
696 # all the time since it won't be shown if the reserve param above isn't set.
697# if ($webvar{reserve}) {
698 $page->param(resvblock => $resv);
699# }
700
[4]701 # Stick in the allocation data
[517]702 $page->param(alloc_type => $webvar{alloctype});
703 $page->param(typefull => $q->escapeHTML($disp_alloctypes{$webvar{alloctype}}));
704 $page->param(alloc_from => $alloc_from);
[633]705 $page->param(parent => $p_id);
706 $page->param(fbid => $fbid);
[517]707 $page->param(cidr => $cidr);
[585]708 $page->param(rdns => $webvar{rdns});
[691]709 $page->param(vrf => $webvar{vrf});
710 $page->param(vlan => $webvar{vlan});
[517]711 $page->param(city => $q->escapeHTML($webvar{city}));
712 $page->param(custid => $webvar{custid});
713 $page->param(circid => $q->escapeHTML($webvar{circid}));
714 $page->param(desc => $q->escapeHTML($webvar{desc}));
[4]715
[517]716##fixme: find a way to have the displayed copy have <br> substitutions
717# for newlines, and the <input> value have either encoded or bare newlines.
718# Also applies to privdata.
719 $page->param(notes => $q->escapeHTML($webvar{notes},'y'));
720
[284]721 # Check to see if user is allowed to do anything with sensitive data
[800]722 if ($IPDBacl{$authuser} =~ /s/) {
[782]723 $page->param(nocling => 1);
724 $page->param(privdata => $q->escapeHTML($webvar{privdata},'y'));
[517]725
[782]726 $page->param(backupfields => $webvar{backupfields});
727 $page->param(bkbrand => $webvar{bkbrand});
728 $page->param(bkmodel => $webvar{bkmodel});
729 $page->param(bktype => $webvar{bktype});
730 $page->param(bksrc => $webvar{bksrc});
731 $page->param(bkuser => $webvar{bkuser});
732 # these two could use virtually any character
733 $page->param(bkvpass => $q->escapeHTML($webvar{bkvpass}));
734 $page->param(bkepass => $q->escapeHTML($webvar{bkepass}));
735 $page->param(bkport => $webvar{bkport});
[798]736 $page->param(bkip => $webvar{bkip});
[782]737 }
738
[517]739 # Yay! This now has it's very own little home.
740 $page->param(billinguser => $webvar{userid})
[299]741 if $webvar{userid};
[284]742
[517]743##fixme: this is only needed iff confirm.tmpl and
744# confirmRemove.tmpl are merged (quite possible, just
745# a little tedious)
746 $page->param(action => "insert");
[284]747
[4]748} # end confirmAssign
749
750
751# Do the work of actually inserting a block in the database.
752sub insertAssign {
[233]753 if ($IPDBacl{$authuser} !~ /a/) {
[517]754 $aclerr = 'addblock';
[233]755 return;
756 }
[4]757 # Some things are done more than once.
[111]758 return if !validateInput();
[4]759
[782]760##fixme: permission check
[284]761 if (!defined($webvar{privdata})) {
762 $webvar{privdata} = '';
763 }
[575]764
[106]765 # $code is "success" vs "failure", $msg contains OK for a
766 # successful netblock allocation, the IP allocated for static
767 # IP, or the error message if an error occurred.
[517]768
[677]769##fixme: consider just passing \%webvar to allocateBlock()?
770 # collect per-IP rDNS fields. only copy over the ones that actually have something in them.
771 my %iprev;
772 foreach (keys %webvar) {
773 $iprev{$_} = $webvar{$_} if /host_[\d.a-fA-F:]+/ && $webvar{$_};
774 }
775
[691]776 # Easier to see and cosmetically fiddle the list like this
777 my %insert_args = (
778 cidr => $webvar{fullcidr},
779 fbid => $webvar{fbid},
[692]780 reserve => $webvar{reserve},
[691]781 parent => $webvar{parent},
782 custid => $webvar{custid},
783 type => $webvar{alloctype},
784 city => $webvar{city},
785 desc => $webvar{desc},
786 notes => $webvar{notes},
787 circid => $webvar{circid},
788 privdata => $webvar{privdata},
789 nodeid => $webvar{node},
790 rdns => $webvar{rdns},
791 vrf => $webvar{vrf},
792 vlan => $webvar{vlan},
793 user => $authuser,
794 );
[4]795
[782]796##fixme: permission check
797 # fill in backup data, if present/allowed
798 if ($webvar{backupfields}) {
799 $insert_args{backup} = 1;
[798]800 for my $bkfield (@IPDB::backupfields) {
[782]801 $insert_args{"bk$bkfield"} = ($webvar{"bk$bkfield"} ? $webvar{"bk$bkfield"} : '');
802 }
803 }
804
[766]805 my $pinfo = getBlockData($ip_dbh, $webvar{parent});
806
807 # clean up a minor mess with guided allocation of static IPs
808 if ($webvar{alloctype} =~ /^.i$/) {
809 $insert_args{alloc_from} = $pinfo->{block};
810 }
811
[691]812 my ($code,$msg) = allocateBlock($ip_dbh, %insert_args, iprev => \%iprev);
813
[111]814 if ($code eq 'OK') {
[766]815 # breadcrumbs lite! provide at least a link to the parent of the block we just allocated.
816 $page->param(parentid => $webvar{parent});
817 $page->param(parentblock => $pinfo->{block});
818
[106]819 if ($webvar{alloctype} =~ /^.i$/) {
[300]820 $msg =~ s|/32||;
[517]821 $page->param(staticip => $msg);
822 $page->param(custid => $webvar{custid});
823 $page->param(billinguser => $webvar{billinguser});
[416]824 mailNotify($ip_dbh, "a$webvar{alloctype}", "ADDED: $disp_alloctypes{$webvar{alloctype}} allocation",
825 "$disp_alloctypes{$webvar{alloctype}} $msg allocated to customer $webvar{custid}\n".
826 "Description: $webvar{desc}\n\nAllocated by: $authuser\n");
[106]827 } else {
[301]828 my $netblock = new NetAddr::IP $webvar{fullcidr};
[517]829 $page->param(fullcidr => $webvar{fullcidr});
830 $page->param(alloctype => $disp_alloctypes{$webvar{alloctype}});
831 $page->param(custid => $webvar{custid});
[697]832
833 # Full breadcrumbs
834 my $crumbs = getBreadCrumbs($ip_dbh, $webvar{parent});
835 my @rcrumbs = reverse (@$crumbs);
836 $utilbar->param(breadcrumb => \@rcrumbs);
837
[517]838 if ($webvar{alloctype} eq 'pr' && $webvar{billinguser}) {
839 $page->param(billinguser => $webvar{billinguser});
840 $page->param(custid => $webvar{custid});
841 $page->param(netaddr => $netblock->addr);
842 $page->param(masklen => $netblock->masklen);
843 }
[416]844 mailNotify($ip_dbh, "a$webvar{alloctype}", "ADDED: $disp_alloctypes{$webvar{alloctype}} allocation",
845 "$disp_alloctypes{$webvar{alloctype}} $webvar{fullcidr} allocated to customer $webvar{custid}\n".
846 "Description: $webvar{desc}\n\nAllocated by: $authuser\n");
[4]847 }
[106]848 syslog "notice", "$authuser allocated '$webvar{fullcidr}' to '$webvar{custid}' as ".
[256]849 "'$webvar{alloctype}' ($msg)";
[111]850 } else {
851 syslog "err", "Allocation of '$webvar{fullcidr}' to '$webvar{custid}' as ".
852 "'$webvar{alloctype}' by $authuser failed: '$msg'";
[766]853 $page->param(err => "Allocation of $webvar{fullcidr} as '$disp_alloctypes{$webvar{alloctype}}' failed:");
854 $page->param(errmsg => $msg);
[106]855 }
[4]856
857} # end insertAssign()
858
859
860# Does some basic checks on common input data to make sure nothing
861# *really* weird gets in to the database through this script.
862# Does NOT do complete input validation!!!
863sub validateInput {
864 if ($webvar{city} eq '-') {
[517]865 $page->param(err => 'Please choose a city');
[111]866 return;
[4]867 }
[138]868
869 # Alloctype check.
[4]870 chomp $webvar{alloctype};
[138]871 if (!grep /$webvar{alloctype}/, keys %disp_alloctypes) {
872 # Danger! Danger! alloctype should ALWAYS be set by a dropdown. Anyone
873 # managing to call things in such a way as to cause this deserves a cryptic error.
[517]874 $page->param(err => 'Invalid alloctype');
[138]875 return;
876 }
877
878 # CustID check
[4]879 # We have different handling for customer allocations and "internal" or "our" allocations
[214]880 if ($def_custids{$webvar{alloctype}} eq '') {
[4]881 if (!$webvar{custid}) {
[517]882 $page->param(err => 'Please enter a customer ID.');
[111]883 return;
[4]884 }
[546]885 # Crosscheck with billing.
886 my $status = CustIDCK->custid_exist($webvar{custid});
887 if ($CustIDCK::Error) {
888 $page->param(err => "Error verifying customer ID: ".$CustIDCK::ErrMsg);
889 return;
[4]890 }
[546]891 if (!$status) {
892 $page->param(err => "Customer ID not valid. Make sure the Customer ID ".
893 "is correct.<br>\nUse STAFF for staff static IPs, and $IPDB::defcustid for any other ".
894 "non-customer assignments.");
895 return;
896 }
[400]897# print "<!-- [ In validateInput(). Insert customer ID cross-check here. ] -->\n";
[138]898 } else {
[167]899 # New! Improved! And now Loaded From The Database!!
[320]900 if ((!$webvar{custid}) || ($webvar{custid} ne 'STAFF')) {
901 $webvar{custid} = $def_custids{$webvar{alloctype}};
902 }
[4]903 }
[111]904
[571]905## hmmm.... is this even useful?
906if (0) {
[111]907 # Check POP location
908 my $flag;
[187]909 if ($webvar{alloctype} eq 'rm') {
[111]910 $flag = 'for a routed netblock';
911 foreach (@poplist) {
912 if (/^$webvar{city}$/) {
913 $flag = 'n';
914 last;
915 }
916 }
917 } else {
918 $flag = 'n';
[442]919##fixme: hook to force-set POP or city on certain alloctypes
920# if ($webvar{alloctype =~ /foo,bar,bz/ { $webvar{pop} = 'blah'; }
[536]921 if ($webvar{pop} && $webvar{pop} =~ /^-$/) {
[111]922 $flag = 'to route the block from/through';
923 }
924 }
[517]925
926 # if the alloctype has a restricted city/POP list as determined above,
927 # and the reqested city/POP does not match that list, complain
[111]928 if ($flag ne 'n') {
[517]929 $page->param(err => "Please choose a valid POP location $flag. Valid ".
[111]930 "POP locations are currently:<br>\n".join (" - ", @poplist));
931 return;
932 }
[571]933}
[111]934
[691]935 # VRF. Not a full validity check, just a basic sanity check.
936 if ($webvar{vrf}) {
937 # Trim leading and trailing whitespace first
938 $webvar{vrf} =~ s/^\s+//;
939 $webvar{vrf} =~ s/\s+$//;
940 if ($webvar{vrf} !~ /^[\w\d_.-]{1,32}$/) {
941 $page->param(err => "VRF values may only contain alphanumerics, and may not be more than 32 characters");
942 return;
943 }
944 }
945
946 # VLAN. Should we allow/use VLAN names, or just the numeric ID?
947 if ($webvar{vlan}) {
948 # Trim leading and trailing whitespace first
949 $webvar{vlan} =~ s/^\s+//;
950 $webvar{vlan} =~ s/\s+$//;
951 # ... ve make it ze configurable thingy!
952 if ($IPDB::numeric_vlan) {
953 if ($webvar{vlan} !~ /^\d+$/) {
954 $page->param(err => "VLANs must be numeric");
955 return;
956 }
957 } else {
958 if ($webvar{vlan} !~ /^[\w\d_.-]+$/) {
959 $page->param(err => "VLANs must be alphanumeric");
960 return;
961 }
962 }
963 }
964
[782]965 # Backup fields. Minimal sanity checks.
966 for my $bkfield (qw(brand model)) {
[798]967 if (!$webvar{"bk$bkfield"}) {
968 $page->param(err => "Backup $bkfield must be filled in if IP/netblock is flagged for backup");
969 return;
970 }
971 if ($webvar{"bk$bkfield"} !~ /^[a-zA-Z0-9\s_.-]+$/) {
[782]972 $page->param(err => "Invalid characters in backup $bkfield");
973 return;
974 }
975 }
976 for my $bkfield (qw(type src user)) { # no spaces in these!
977 if ($webvar{"bk$bkfield"} && $webvar{"bk$bkfield"} !~ /^[a-zA-Z0-9_.-]+$/) {
978 $page->param(err => "Invalid characters in backup $bkfield");
979 return;
980 }
981 }
982 if ($webvar{bkport}) {
983 $webvar{bkport} =~ s/^\s+//g;
984 $webvar{bkport} =~ s/\s+$//g;
985 if ($webvar{bkport} !~ /^\d+$/) {
986 $page->param(err => "Backup port must be numeric");
987 return;
988 }
989 }
[798]990##fixme: code review: should normalize $webvar{cidr} variants so we can
991# check for non-/32 allocations having the backup IP field filled in here,
992# instead of failing on the allocation or update attempt
993 if ($webvar{bkip}) {
994 $webvar{bkip} =~ s/^\s+//g;
995 $webvar{bkip} =~ s/\s+$//g;
996 if ($webvar{bkip} !~ /^[\da-fA-F:.]+$/) {
997 $page->param(err => "Backup IP must be an IP");
998 return;
999 }
1000 }
[782]1001
[111]1002 return 'OK';
[4]1003} # end validateInput
1004
1005
1006# Displays details of a specific allocation in a form
1007# Allows update/delete
1008# action=edit
1009sub edit {
1010
[534]1011 # snag block info from db
[634]1012 my $blockinfo = getBlockData($ip_dbh, $webvar{id}, $webvar{basetype});
[750]1013 my $cidr = new NetAddr::IP $blockinfo->{block};
[691]1014 $page->param(id => $webvar{id});
[634]1015 $page->param(basetype => $webvar{basetype});
[4]1016
[697]1017 # Tree navigation
1018 my $crumbs = getBreadCrumbs($ip_dbh, $blockinfo->{parent_id});
1019 my @rcrumbs = reverse (@$crumbs);
1020 $utilbar->param(breadcrumb => \@rcrumbs);
1021
[705]1022 # Show link to IP list for pools
1023 $page->param(ispool => 1) if $blockinfo->{type} =~ /^.[dp]$/;
1024
[534]1025 # Clean up extra whitespace on alloc type. Mainly a legacy-data cleanup.
1026 $blockinfo->{type} =~ s/\s//;
[4]1027
[760]1028##fixme: The case of "allocation larger than a /24" (or any similar case
1029# where the allocation is larger than the zone(s) in DNS) doesn't work well.
1030# Best solution may just be to add a warning that the entry shown may not be
1031# correct/complete.
1032 if ($blockinfo->{revavail} || $blockinfo->{revpartial}) {
1033 $page->param(showrev => ($blockinfo->{revavail} || $blockinfo->{revpartial}) );
[750]1034 my $cached;
1035 # Get rDNS info; duplicates a bit of getBlockData but also does the RPC call if possible
1036 ($blockinfo->{rdns},$cached) = getBlockRDNS($ip_dbh, id => $webvar{id}, type => $blockinfo->{type}, user => $authuser);
[760]1037 $page->param(rdns => $blockinfo->{rdns});
[750]1038 # visual flag that we're working IPDB-local, not off more authoritative data in dnsadmin
1039 $page->param(cached => $cached);
[586]1040
[750]1041 # Limit the per-IP rDNS list based on CIDR length; larger ones just take up too much space.
1042 # Also, don't show on IP pools; the individual IPs will have a space for rDNS
1043 # Don't show on single IPs; these use the "pattern" field
1044 if ($IPDBacl{$authuser} =~ /c/
1045 && $cidr->masklen != $cidr->bits
1046 && ($cidr->bits - $cidr->masklen) <= $IPDB::maxrevlist
[780]1047 # config flag for "all block types" OR "not-a-pool-or-IP type"
1048 && ($IPDB::revlistalltypes || $blockinfo->{type} !~ /^.[dpi]/)
1049 # safety against trying to retrieve and display more than 1k (10 bits, /22 v4) worth of individual IPs
1050 # ever. If you really need to manage a long list of IPs like that all in one place, you can use the DNS
1051 # management tool. Even a /26 is a bit much, really.
1052 && ($cidr->bits - $cidr->masklen) <= 10
[750]1053 # do we want to allow v6 at all?
1054 #&& ! $cidr->{isv6}
1055 ) {
1056 $page->param(r_iplist => getRDNSbyIP($ip_dbh, id => $webvar{id}, type => $blockinfo->{type},
1057 range => $blockinfo->{block}, user => $authuser) );
1058 }
1059 } # rDNS availability check
[675]1060
[786]1061 # backup data
1062 if ($blockinfo->{hasbk}) {
1063 $page->param(hasbackup => $blockinfo->{hasbk});
[798]1064 for my $bkfield (@IPDB::backupfields) {
[786]1065 $page->param("bk$bkfield" => $blockinfo->{"bk$bkfield"});
1066 }
1067 $page->param(bktelnet => 1) if $blockinfo->{bktype} eq 'telnet';
1068 $page->param(bkssh => 1) if $blockinfo->{bktype} eq 'SSH';
1069 }
1070
[691]1071 # consider extending this to show time as well as date
1072 my ($lastmod,undef) = split /\s+/, $blockinfo->{lastmod};
1073 $page->param(lastmod => $lastmod);
[4]1074
[691]1075 $page->param(block => $blockinfo->{block});
1076 $page->param(city => $blockinfo->{city});
1077 $page->param(custid => $blockinfo->{custid});
[4]1078
[187]1079##fixme The check here should be built from the database
[517]1080# Need to expand to support pool types too
[534]1081 if ($blockinfo->{type} =~ /^.[ne]$/ && $IPDBacl{$authuser} =~ /c/) {
[517]1082 $page->param(changetype => 1);
1083 $page->param(alloctype => [
[534]1084 { selme => ($blockinfo->{type} eq 'me'), type => "me", disptype => "Dialup netblock" },
1085 { selme => ($blockinfo->{type} eq 'de'), type => "de", disptype => "Dynamic DSL netblock" },
1086 { selme => ($blockinfo->{type} eq 'ce'), type => "ce", disptype => "Dynamic cable netblock" },
1087 { selme => ($blockinfo->{type} eq 'we'), type => "we", disptype => "Dynamic wireless netblock" },
1088 { selme => ($blockinfo->{type} eq 'cn'), type => "cn", disptype => "Customer netblock" },
1089 { selme => ($blockinfo->{type} eq 'en'), type => "en", disptype => "End-use netblock" },
1090 { selme => ($blockinfo->{type} eq 'in'), type => "in", disptype => "Internal netblock" },
[517]1091 ]
1092 );
1093 } else {
[534]1094 $page->param(disptype => $disp_alloctypes{$blockinfo->{type}});
1095 $page->param(type => $blockinfo->{type});
[517]1096 }
1097
[397]1098## node hack
[634]1099 my ($nodeid,$nodename) = getNodeInfo($ip_dbh, $blockinfo->{block});
1100# $page->param(havenodeid => $nodeid);
1101 $page->param(nodename => $nodename);
[517]1102
1103##fixme: this whole hack needs cleanup and generalization for all alloctypes
1104##fixme: arguably a bug that presence of a nodeid implies it can be changed..
[634]1105 if ($IPDBacl{$authuser} =~ /c/) {
1106 my $nlist = getNodeList($ip_dbh);
1107 if ($nodeid) {
[530]1108 foreach (@{$nlist}) {
[634]1109 $$_{selme} = ($$_{node_id} == $nodeid);
[397]1110 }
1111 }
[634]1112 $page->param(nodelist => $nlist);
[397]1113 }
1114## end node hack
[517]1115
[691]1116 $page->param(vrf => $blockinfo->{vrf});
1117 $page->param(vlan => $blockinfo->{vlan});
[33]1118
[695]1119 # Reserved-for-expansion
1120 $page->param(reserve => $blockinfo->{reserve});
1121 $page->param(reserve_id => $blockinfo->{reserve_id});
1122 my $newblock = NetAddr::IP->new($cidr->addr, $cidr->masklen - 1)->network;
1123 $page->param(newblock => $newblock);
1124
[517]1125 # not happy with the upside-down logic, but...
[534]1126 $page->param(swipable => $blockinfo->{type} !~ /.i/);
[691]1127 $page->param(swip => $blockinfo->{swip} ne 'n') if $blockinfo->{swip};
[320]1128
[691]1129 $page->param(circid => $blockinfo->{circuitid});
1130 $page->param(desc => $blockinfo->{description});
1131 $page->param(notes => $blockinfo->{notes});
1132
[284]1133 # Check to see if we can display sensitive data
[691]1134 $page->param(nocling => $IPDBacl{$authuser} =~ /s/);
[534]1135 $page->param(privdata => $blockinfo->{privdata});
[284]1136
[517]1137 # ACL trickery - these two template booleans control the presence of all form/input tags
1138 $page->param(maychange => $IPDBacl{$authuser} =~ /c/);
1139 $page->param(maydel => $IPDBacl{$authuser} =~ /d/);
[4]1140
[702]1141 # Need to find internal knobs to twist to actually vary these. (Ab)use "change" flag for now
[789]1142 $page->param(maymerge => ($IPDBacl{$authuser} =~ /m/ && $blockinfo->{type} !~ /^.i$/));
1143
[702]1144 if ($IPDBacl{$authuser} =~ /c/ && $blockinfo->{type} !~ /^.i$/) {
1145 if ($blockinfo->{type} =~ /^.p$/) {
1146 # PPP pools
1147 $page->param(maysplit => 1) if $cidr->masklen+1 < $cidr->bits;
1148 } elsif ($blockinfo->{type} =~ /.d/) {
1149 # Non-PPP pools
1150 $page->param(maysplit => 1) if $cidr->masklen+2 < $cidr->bits;
1151 } else {
1152 # Standard netblocks. Arguably allowing splitting these down to single IPs
1153 # doesn't make much sense, but forcing users to apply allocation types
1154 # "properly" is worse than herding cats.
1155 $page->param(maysplit => 1) if $cidr->masklen < $cidr->bits;
1156 }
1157 }
1158
[4]1159} # edit()
1160
1161
1162# Stuff new info about a block into the db
1163# action=update
1164sub update {
[284]1165 if ($IPDBacl{$authuser} !~ /c/) {
[517]1166 $aclerr = 'updateblock';
[284]1167 return;
1168 }
[4]1169
[706]1170 # Collect existing block info here, since we need it for the breadcrumb nav
1171 my $binfo = getBlockData($ip_dbh, $webvar{block}, $webvar{basetype});
1172 my $crumbs = getBreadCrumbs($ip_dbh, $binfo->{parent_id});
1173 my @rcrumbs = reverse (@$crumbs);
1174 $utilbar->param(breadcrumb => \@rcrumbs);
1175
[4]1176 # Make sure incoming data is in correct format - custID among other things.
[228]1177 return if !validateInput;
[4]1178
[536]1179 $webvar{swip} = 'n' if !$webvar{swip};
1180
[531]1181 my %updargs = (
1182 custid => $webvar{custid},
1183 city => $webvar{city},
1184 description => $webvar{desc},
1185 notes => $webvar{notes},
1186 circuitid => $webvar{circid},
1187 block => $webvar{block},
1188 type => $webvar{alloctype},
[536]1189 swip => $webvar{swip},
[588]1190 rdns => $webvar{rdns},
[691]1191 vrf => $webvar{vrf},
1192 vlan => $webvar{vlan},
[588]1193 user => $authuser,
[531]1194 );
1195
[788]1196 # Check to see if user is allowed to do anything with sensitive data
1197 if ($IPDBacl{$authuser} =~ /s/) {
1198 $updargs{privdata} = $webvar{privdata};
[798]1199 for my $bkfield (@IPDB::backupfields) {
[788]1200 $updargs{"bk$bkfield"} = $webvar{"bk$bkfield"};
1201 }
[798]1202 $updargs{backup} = $webvar{backupfields};
[788]1203 } else {
1204 # If the user doesn't have permissions to monkey with NOC-things, pass
1205 # a flag so we don't treat it as "backup data removed"
1206 $updargs{ignorebk} = 1;
1207 }
1208
[531]1209 # Semioptional values
1210 $updargs{node} = $webvar{node} if $webvar{node};
1211
[677]1212 # collect per-IP rDNS fields. only copy over the ones that actually have something in them.
1213 my %iprev;
1214 foreach (keys %webvar) {
1215 $iprev{$_} = $webvar{$_} if /host_[\d.a-fA-F:]+/ && $webvar{$_};
1216 }
[531]1217
[695]1218 # Merge with reserved freeblock
1219 $updargs{fbmerge} = $webvar{expandme} if $webvar{expandme};
1220
[677]1221 my ($code,$msg) = updateBlock($ip_dbh, %updargs, iprev => \%iprev);
1222
[531]1223 if ($code eq 'FAIL') {
[787]1224 syslog "err", "$authuser could not update block/IP '$binfo->{block}' (id $webvar{block}): '$msg'";
1225 $page->param(err => "Could not update block/IP $binfo->{block}: $msg");
[111]1226 return;
[4]1227 }
1228
1229 # If we get here, the operation succeeded.
[787]1230 syslog "notice", "$authuser updated $binfo->{block}";
[531]1231##fixme: log details of the change? old way is in the .debug stream anyway.
[416]1232##fixme: need to wedge something in to allow "update:field" notifications
1233## hmm. how to tell what changed? O_o
[787]1234mailNotify($ip_dbh, 's:swi', "SWIPed: $disp_alloctypes{$webvar{alloctype}} $binfo->{block}",
1235 "$binfo->{block} had SWIP status changed to \"Yes\" by $authuser") if $webvar{swip} eq 'on';
[4]1236
[517]1237## node hack
1238 if ($webvar{node} && $webvar{node} ne '-') {
[530]1239 my $nodename = getNodeName($ip_dbh, $webvar{node});
[517]1240 $page->param(nodename => $nodename);
1241 }
1242## end node hack
1243
[380]1244 # Link back to browse-routed or list-pool page on "Update complete" page.
[634]1245 my $pblock = getBlockData($ip_dbh, $binfo->{parent_id});
1246 $page->param(backid => $binfo->{parent_id});
1247 $page->param(backblock => $pblock->{block});
1248 $page->param(backpool => ($webvar{basetype} eq 'i'));
[380]1249
[536]1250 # Do some HTML fiddling here instead of using ESCAPE=HTML in the template,
1251 # because otherwise we can't convert \n to <br>. *sigh*
1252 $webvar{notes} = $q->escapeHTML($webvar{notes}); # escape first...
1253 $webvar{notes} =~ s/\n/<br>\n/; # ... then convert newlines
1254 $webvar{privdata} = ($webvar{privdata} ? $q->escapeHTML($webvar{privdata}) : "&nbsp;");
1255 $webvar{privdata} =~ s/\n/<br>\n/;
1256
[765]1257 if ($webvar{expandme}) {
1258 # this is fugly but still faster than hitting the DB again with getBlockData()
1259 my $tmp = new NetAddr::IP $binfo->{block};
1260 my $fb = new NetAddr::IP $binfo->{reserve};
1261 my @newblock = $tmp->compact($fb);
1262 $page->param(cidr => $newblock[0]);
1263 } else {
1264 $page->param(cidr => $binfo->{block});
1265 }
[588]1266 $page->param(rdns => $webvar{rdns});
[517]1267 $page->param(city => $webvar{city});
1268 $page->param(disptype => $disp_alloctypes{$webvar{alloctype}});
1269 $page->param(custid => $webvar{custid});
1270 $page->param(swip => $webvar{swip} eq 'on' ? 'Yes' : 'No');
[536]1271 $page->param(circid => $webvar{circid});
1272 $page->param(desc => $webvar{desc});
1273 $page->param(notes => $webvar{notes});
[788]1274 if ($IPDBacl{$authuser} =~ /s/) {
1275 $page->param(nocling => 1);
1276 $page->param(privdata => $webvar{privdata});
[798]1277 if ($webvar{backupfields} && $webvar{backupfields} eq 'on') {
1278 $page->param(hasbackup => 1);
[800]1279 for my $bkfield (@IPDB::backupfields) {
[798]1280 $page->param("bk$bkfield" => $webvar{"bk$bkfield"});
[788]1281 }
1282 }
1283 }
[4]1284
1285} # update()
1286
1287
[702]1288sub prepSplit {
1289 if ($IPDBacl{$authuser} !~ /c/) {
1290 $aclerr = 'splitblock';
1291 return;
1292 }
1293
1294 my $blockinfo = getBlockData($ip_dbh, $webvar{block});
1295
[705]1296 # Tree navigation
1297 my $crumbs = getBreadCrumbs($ip_dbh, $blockinfo->{parent_id});
1298 my @rcrumbs = reverse (@$crumbs);
1299 $utilbar->param(breadcrumb => \@rcrumbs);
1300
[702]1301 if ($blockinfo->{type} =~ /^.i$/) {
1302 $page->param(err => "Can't split a single IP allocation");
1303 return;
1304 }
1305
1306 # Info about current allocation
1307 $page->param(oldblock => $blockinfo->{block});
1308 $page->param(block => $webvar{block});
1309
1310# Note that there are probably different rules that should be followed to restrict splitting IPv6 blocks;
1311# strictly speaking it will be exceptionally rare to see smaller than a /64 assigned to a customer, since that
1312# breaks auto-addressing schemes.
1313
1314 # Generate possible splits
1315 my $block = new NetAddr::IP $blockinfo->{block};
1316 my $oldmask = $block->masklen;
1317 if ($blockinfo->{type} =~ /^.d$/) {
1318 # Non-PPP pools
[705]1319 $page->param(ispool => 1);
[702]1320 if ($oldmask+2 >= $block->bits) {
1321 $page->param(err => "Can't split a standard netblock pool any further");
1322 return;
1323 }
1324 # Allow splitting down to v4 /30 (which results in one usable IP; dubiously useful)
1325 $page->param(sp4mask => $oldmask+2) if $oldmask+2 <= $block->bits-2;
1326 } elsif ($blockinfo->{type} =~ /.p/) {
[705]1327 $page->param(ispool => 1);
[702]1328 # Allow splitting PPP pools down to v4 /31
1329 $page->param(sp4mask => $oldmask+2) if $oldmask+2 <= $block->bits-1;
1330 } else {
1331 # Allow splitting all other non-pool netblocks down to single IPs, which...
1332 # arguably should be *aggregated* in a pool. Except where they shouldn't.
1333 $page->param(sp4mask => $oldmask+2) if $oldmask+2 <= $block->bits;
1334 }
1335 # set the split-in-half mask
1336 $page->param(sp2mask => $oldmask+1);
1337
1338 # Generate possible shrink targets
1339 my @keepers = $block->split($block->masklen+1);
1340 $page->param(newblockA => $keepers[0]);
1341 $page->param(newblockB => $keepers[1]);
1342} # prepSplit()
1343
1344
1345sub doSplit {
1346 if ($IPDBacl{$authuser} !~ /c/) {
1347 $aclerr = 'splitblock';
1348 return;
1349 }
1350
1351##fixme: need consistent way to identify "this thing that is this thing" with only the ID
1352# also applies to other locations
1353 my $blockinfo = getBlockData($ip_dbh, $webvar{block});
1354
[705]1355 # Tree navigation
1356 my $crumbs = getBreadCrumbs($ip_dbh, $blockinfo->{parent_id});
1357 my @rcrumbs = reverse (@$crumbs);
1358 $utilbar->param(breadcrumb => \@rcrumbs);
1359
[702]1360 if ($blockinfo->{type} =~ /^.i$/) {
1361 $page->param(err => "Can't split a single IP allocation");
1362 return;
1363 }
1364
1365 if ($webvar{subact} eq 'split') {
1366 $page->param(issplit => 1);
[705]1367 my $block = new NetAddr::IP $blockinfo->{block};
[707]1368 my $newblocks = splitBlock($ip_dbh, id => $webvar{block}, basetype => 'b', newmask => $webvar{split},
1369 user => $authuser);
[702]1370 if ($newblocks) {
1371 $page->param(newblocks => $newblocks);
1372 } else {
1373 $page->param(err => $IPDB::errstr);
1374 }
1375
[705]1376 } elsif ($webvar{subact} eq 'shrink') {
1377 $page->param(nid => $webvar{block});
1378 $page->param(newblock => $webvar{shrink});
1379 my $newfree = shrinkBlock($ip_dbh, $webvar{block}, $webvar{shrink});
1380 if ($newfree) {
1381 $page->param(newfb => $newfree);
1382 } else {
1383 $page->param(err => $IPDB::errstr);
1384 }
1385
[702]1386 } else {
[705]1387 # Your llama is on fire.
1388 $page->param(err => "Missing form field that shouldn't be missing.");
1389 return;
[702]1390 }
[705]1391
1392 # common bits
1393 $page->param(cidr => $blockinfo->{block});
1394 # and the backlink to the parent container
1395 my $pinfo = getBlockData($ip_dbh, $blockinfo->{parent_id});
1396 $page->param(backid => $blockinfo->{parent_id});
1397 $page->param(backblock => $pinfo->{block});
[702]1398} # doSplit()
1399
1400
[717]1401# Set up for merge
1402sub prepMerge {
[789]1403 if ($IPDBacl{$authuser} !~ /m/) {
1404 $aclerr = 'mergeblock';
1405 return;
1406 }
1407
[717]1408 my $binfo = getBlockData($ip_dbh, $webvar{block});
[760]1409
1410 # Tree navigation
1411 my $crumbs = getBreadCrumbs($ip_dbh, $binfo->{parent_id});
1412 my @rcrumbs = reverse (@$crumbs);
1413 $utilbar->param(breadcrumb => \@rcrumbs);
1414
[717]1415 $page->param(block => $webvar{block});
1416 $page->param(ispool => $binfo->{type} =~ /.[dp]/);
1417 $page->param(ismaster => $binfo->{type} eq 'mm');
1418 $page->param(oldblock => $binfo->{block});
1419 $page->param(oldtype => $disp_alloctypes{$binfo->{type}});
1420 $page->param(typelist => getTypeList($ip_dbh, 'n', $binfo->{type})); # down the rabbit hole we go...
1421
[733]1422 # Strings for scope; do this way so we don't have to edit them many places
1423 $page->param(vis_keepall => $merge_display{keepall});
1424 $page->param(vis_mergepeer => $merge_display{mergepeer});
1425 $page->param(vis_clearpeer => $merge_display{clearpeer});
1426 $page->param(vis_clearall => $merge_display{clearall});
1427
[717]1428} # prepMerge()
1429
1430
[720]1431# Show what will be merged, present warnings about data loss
1432sub confMerge {
[789]1433 if ($IPDBacl{$authuser} !~ /m/) {
1434 $aclerr = 'mergeblock';
1435 return;
1436 }
1437
[720]1438 if (!$webvar{newmask} || $webvar{newmask} !~ /^\d+$/) {
1439 $page->param(err => 'New netmask required');
1440 return;
1441 }
1442
1443 $page->param(block => $webvar{block});
1444 my $binfo = getBlockData($ip_dbh, $webvar{block});
1445 my $pinfo = getBlockData($ip_dbh, $binfo->{parent_id});
1446 my $minfo = getBlockData($ip_dbh, $binfo->{master_id});
1447 my $block = new NetAddr::IP $binfo->{block};
1448
1449 # Tree navigation
1450 my $crumbs = getBreadCrumbs($ip_dbh, $binfo->{parent_id});
1451 my @rcrumbs = reverse (@$crumbs);
1452 $utilbar->param(breadcrumb => \@rcrumbs);
1453
1454 $page->param(oldblock => $binfo->{block});
1455 $page->param(oldtype => $disp_alloctypes{$binfo->{type}});
1456 $page->param(ismaster => $binfo->{type} eq 'mm');
1457 $page->param(ispool => $webvar{alloctype} =~ /.[dp]/);
1458 $page->param(isleaf => $webvar{alloctype} =~ /.[enr]/);
1459 $page->param(newtype => $webvar{alloctype});
1460 $page->param(newdisptype => $disp_alloctypes{$webvar{alloctype}});
1461 my $newblock = new NetAddr::IP $block->addr."/$webvar{newmask}";
1462 $newblock = $newblock->network;
1463 $page->param(newmask => $webvar{newmask});
1464 $page->param(newblock => "$newblock");
1465
1466 # get list of allocations and freeblocks to be merged
1467 my $malloc_list = listForMerge($ip_dbh, $binfo->{parent_id}, $newblock, 'a');
1468 $page->param(mergealloc => $malloc_list);
1469
[733]1470 $page->param(vis_scope => $merge_display{$webvar{scope}});
[727]1471 $page->param(scope => $webvar{scope});
[720]1472} # confMerge()
1473
1474
[751]1475# Make it so
1476sub doMerge {
[789]1477 if ($IPDBacl{$authuser} !~ /m/) {
1478 $aclerr = 'mergeblock';
1479 return;
1480 }
1481
[751]1482 if (!$webvar{newmask} || $webvar{newmask} !~ /^\d+$/) {
1483 $page->param(err => 'New netmask required');
1484 return;
1485 }
1486
1487 $page->param(block => $webvar{block});
1488 my $binfo = getBlockData($ip_dbh, $webvar{block});
1489 my $pinfo = getBlockData($ip_dbh, $binfo->{parent_id});
1490 my $block = new NetAddr::IP $binfo->{block};
1491
1492 # Tree navigation
1493 my $crumbs = getBreadCrumbs($ip_dbh, $binfo->{parent_id});
1494 my @rcrumbs = reverse (@$crumbs);
1495 $utilbar->param(breadcrumb => \@rcrumbs);
1496
1497 $page->param(oldblock => $binfo->{block});
1498 $page->param(oldtype => $disp_alloctypes{$binfo->{type}});
1499 $page->param(newdisptype => $disp_alloctypes{$webvar{newtype}});
1500 my $newblock = new NetAddr::IP $block->addr."/$webvar{newmask}";
1501 $newblock = $newblock->network;
1502 $page->param(newblock => $newblock);
1503 $page->param(vis_scope => $merge_display{$webvar{scope}});
1504
1505 my $mlist = mergeBlocks($ip_dbh, $webvar{block}, %webvar, user => $authuser);
1506
1507 if ($mlist) {
1508 #(newtype => $webvar{newtype}, newmask => $webvar{newmask}));
1509 # Slice off first entry (the new parent - note this may be a new allocation,
1510 # not the same ID that was "merged"!
1511 my $parent = shift @$mlist;
1512 $page->param(backpool => $webvar{newtype} =~ /.[dp]/);
1513 if ($webvar{newtype} =~ /.[enr]/) {
1514 $page->param(backleaf => 1);
1515 $page->param(backid => $binfo->{parent_id});
1516 $page->param(backblock => $pinfo->{block});
1517 } else {
1518 $page->param(backid => $parent->{id});
1519 $page->param(backblock => $parent->{block});
1520 }
1521 $page->param(mergelist => $mlist);
1522 } else {
1523 $page->param(err => "Merge failed: $IPDB::errstr");
1524 }
1525} # doMerge()
1526
1527
[4]1528# Delete an allocation.
[106]1529sub remove {
[233]1530 if ($IPDBacl{$authuser} !~ /d/) {
[517]1531 $aclerr = 'delblock';
[233]1532 return;
1533 }
1534
[4]1535 # Serves'em right for getting here...
1536 if (!defined($webvar{block})) {
[517]1537 $page->param(err => "Can't delete a block that doesn't exist");
[111]1538 return;
[4]1539 }
1540
[538]1541 my $blockdata;
[638]1542 $blockdata = getBlockData($ip_dbh, $webvar{block}, $webvar{basetype});
[4]1543
[765]1544 # Tree navigation
1545 my $crumbs = getBreadCrumbs($ip_dbh, $blockdata->{parent_id});
1546 my @rcrumbs = reverse (@$crumbs);
1547 $utilbar->param(breadcrumb => \@rcrumbs);
1548
[638]1549 if ($blockdata->{parent_id} == 0) { # $webvar{alloctype} eq 'mm'
[538]1550 $blockdata->{city} = "N/A";
1551 $blockdata->{custid} = "N/A";
1552 $blockdata->{circuitid} = "N/A";
1553 $blockdata->{description} = "N/A";
1554 $blockdata->{notes} = "N/A";
1555 $blockdata->{privdata} = "N/A";
[638]1556 } # end cases for different alloctypes
[517]1557
[638]1558 $page->param(blockid => $webvar{block});
1559 $page->param(basetype => $webvar{basetype});
[4]1560
[538]1561 $page->param(block => $blockdata->{block});
[589]1562 $page->param(rdns => $blockdata->{rdns});
1563
1564 # maybe need to apply more magic here?
1565 # most allocations we *do* want to autodelete the forward as well as reverse; for a handful we don't.
1566 # -> all real blocks (nb: pool IPs need extra handling)
1567 # -> NOC/private-IP (how to ID?)
1568 # -> anything with a pattern matching $IPDB::domain?
1569 if ($blockdata->{type} !~ /^.i$/) {
1570 $page->param(autodel => 1);
1571 }
1572
[538]1573 $page->param(disptype => $disp_alloctypes{$blockdata->{type}});
1574 $page->param(city => $blockdata->{city});
1575 $page->param(custid => $blockdata->{custid});
1576 $page->param(circid => $blockdata->{circuitid});
1577 $page->param(desc => $blockdata->{description});
1578 $blockdata->{notes} = $q->escapeHTML($blockdata->{notes});
1579 $blockdata->{notes} =~ s/\n/<br>\n/;
1580 $page->param(notes => $blockdata->{notes});
1581 $blockdata->{privdata} = $q->escapeHTML($blockdata->{privdata});
[540]1582 $blockdata->{privdata} = '&nbsp;' if !$blockdata->{privdata};
[538]1583 $blockdata->{privdata} =~ s/\n/<br>\n/;
1584 $page->param(privdata => $blockdata->{privdata}) if $IPDBacl{$authuser} =~ /s/;
1585 $page->param(delpool => $blockdata->{type} =~ /^.[pd]$/);
[4]1586
[517]1587} # end remove()
[4]1588
1589
1590# Delete an allocation. Return it to the freeblocks table; munge
1591# data as necessary to keep as few records as possible in freeblocks
1592# to prevent weirdness when allocating blocks later.
1593# Remove IPs from pool listing if necessary
1594sub finalDelete {
[233]1595 if ($IPDBacl{$authuser} !~ /d/) {
[517]1596 $aclerr = 'delblock';
[233]1597 return;
1598 }
[4]1599
[370]1600 # need to retrieve block data before deleting so we can notify on that
[638]1601 my $blockinfo = getBlockData($ip_dbh, $webvar{block}, $webvar{basetype});
1602 my $pinfo = getBlockData($ip_dbh, $blockinfo->{parent_id}, 'b');
[370]1603
[765]1604 # Tree navigation
1605 my $crumbs = getBreadCrumbs($ip_dbh, $blockinfo->{parent_id});
1606 my @rcrumbs = reverse (@$crumbs);
1607 $utilbar->param(breadcrumb => \@rcrumbs);
1608
[638]1609 my ($code,$msg) = deleteBlock($ip_dbh, $webvar{block}, $webvar{basetype}, $webvar{delforward}, $authuser);
[4]1610
[638]1611 $page->param(block => $blockinfo->{block});
[651]1612 $page->param(bdisp => $q->escapeHTML($disp_alloctypes{$blockinfo->{type}}));
[766]1613 $page->param(delparent_id => $blockinfo->{parent_id});
[651]1614 if ($pinfo) {
1615 $page->param(delparent => $pinfo->{block});
1616 $page->param(pdisp => $q->escapeHTML($disp_alloctypes{$pinfo->{type}}));
1617 }
[638]1618 $page->param(returnpool => ($webvar{basetype} eq 'i') );
[591]1619 if ($code =~ /^WARN(POOL|MERGE)/) {
[638]1620 my ($pid,$pcidr) = split /,/, $msg;
[654]1621 my $real_pinfo = getBlockData($ip_dbh, $pid, 'b');
[638]1622 $page->param(parent_id => $pid);
1623 $page->param(parent => $pcidr);
[654]1624 $page->param(real_disp => $q->escapeHTML($disp_alloctypes{$real_pinfo->{type}}));
[577]1625 $page->param(mergeip => $code eq 'WARNPOOL');
1626 }
[591]1627 if ($code eq 'WARN') {
1628 $msg =~ s/\n/<br>\n/g;
1629 $page->param(genwarn => $msg);
1630 }
[577]1631 if ($code eq 'OK' || $code =~ /^WARN/) {
[638]1632 syslog "notice", "$authuser deallocated '".$blockinfo->{type}."'-type netblock $webvar{block} ".
[528]1633 $blockinfo->{custid}.", ".$blockinfo->{city}.", desc='".$blockinfo->{description}."'";
[638]1634 mailNotify($ip_dbh, 'da', "REMOVED: ".$disp_alloctypes{$blockinfo->{type}}." $webvar{block}",
1635 $disp_alloctypes{$blockinfo->{type}}." $webvar{block} deallocated by $authuser\n".
[528]1636 "CustID: ".$blockinfo->{custid}."\nCity: ".$blockinfo->{city}.
1637 "\nDescription: ".$blockinfo->{description}."\n");
[106]1638 } else {
[517]1639 $page->param(failmsg => $msg);
[106]1640 if ($webvar{alloctype} =~ /^.i$/) {
1641 syslog "err", "$authuser could not deallocate static IP '$webvar{block}': '$msg'";
1642 } else {
1643 syslog "err", "$authuser could not deallocate netblock '$webvar{block}': '$msg'";
[517]1644 $page->param(netblock => 1);
[4]1645 }
[106]1646 }
[4]1647
1648} # finalDelete
Note: See TracBrowser for help on using the repository browser.