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

Last change on this file since 814 was 813, checked in by Kris Deugau, 9 years ago

/trunk

Wrap validation of backup fields in an ACL check. See #52.

  • Property svn:executable set to *
  • Property svn:keywords set to Date Rev Author
File size: 56.0 KB
RevLine 
[4]1#!/usr/bin/perl
2# ipdb/cgi-bin/main.cgi
[8]3###
4# SVN revision info
5# $Date: 2016-03-08 21:08:40 +0000 (Tue, 08 Mar 2016) $
6# SVN revision $Rev: 813 $
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.
[813]966 # Bypass if the user isn't authorized for backup data, or if the checkbox is unchecked
967 if ($IPDBacl{$authuser} =~ /s/ && defined($webvar{backupfields})) {
968 for my $bkfield (qw(brand model)) {
969 if (!$webvar{"bk$bkfield"}) {
970 $page->param(err => "Backup $bkfield must be filled in if IP/netblock is flagged for backup");
971 return;
972 }
973 if ($webvar{"bk$bkfield"} !~ /^[a-zA-Z0-9\s_.-]+$/) {
974 $page->param(err => "Invalid characters in backup $bkfield");
975 return;
976 }
[798]977 }
[813]978 for my $bkfield (qw(type src user)) { # no spaces in these!
979 if ($webvar{"bk$bkfield"} && $webvar{"bk$bkfield"} !~ /^[a-zA-Z0-9_.-]+$/) {
980 $page->param(err => "Invalid characters in backup $bkfield");
981 return;
982 }
[782]983 }
[813]984 if ($webvar{bkport}) {
985 $webvar{bkport} =~ s/^\s+//g;
986 $webvar{bkport} =~ s/\s+$//g;
987 if ($webvar{bkport} !~ /^\d+$/) {
988 $page->param(err => "Backup port must be numeric");
989 return;
990 }
[782]991 }
[798]992##fixme: code review: should normalize $webvar{cidr} variants so we can
993# check for non-/32 allocations having the backup IP field filled in here,
994# instead of failing on the allocation or update attempt
[813]995 if ($webvar{bkip}) {
996 $webvar{bkip} =~ s/^\s+//g;
997 $webvar{bkip} =~ s/\s+$//g;
998 if ($webvar{bkip} !~ /^[\da-fA-F:.]+$/) {
999 $page->param(err => "Backup IP must be an IP");
1000 return;
1001 }
[798]1002 }
[813]1003 } # backup
[782]1004
[111]1005 return 'OK';
[4]1006} # end validateInput
1007
1008
1009# Displays details of a specific allocation in a form
1010# Allows update/delete
1011# action=edit
1012sub edit {
1013
[534]1014 # snag block info from db
[634]1015 my $blockinfo = getBlockData($ip_dbh, $webvar{id}, $webvar{basetype});
[750]1016 my $cidr = new NetAddr::IP $blockinfo->{block};
[691]1017 $page->param(id => $webvar{id});
[634]1018 $page->param(basetype => $webvar{basetype});
[4]1019
[697]1020 # Tree navigation
1021 my $crumbs = getBreadCrumbs($ip_dbh, $blockinfo->{parent_id});
1022 my @rcrumbs = reverse (@$crumbs);
1023 $utilbar->param(breadcrumb => \@rcrumbs);
1024
[705]1025 # Show link to IP list for pools
1026 $page->param(ispool => 1) if $blockinfo->{type} =~ /^.[dp]$/;
1027
[534]1028 # Clean up extra whitespace on alloc type. Mainly a legacy-data cleanup.
1029 $blockinfo->{type} =~ s/\s//;
[4]1030
[760]1031##fixme: The case of "allocation larger than a /24" (or any similar case
1032# where the allocation is larger than the zone(s) in DNS) doesn't work well.
1033# Best solution may just be to add a warning that the entry shown may not be
1034# correct/complete.
1035 if ($blockinfo->{revavail} || $blockinfo->{revpartial}) {
1036 $page->param(showrev => ($blockinfo->{revavail} || $blockinfo->{revpartial}) );
[750]1037 my $cached;
1038 # Get rDNS info; duplicates a bit of getBlockData but also does the RPC call if possible
1039 ($blockinfo->{rdns},$cached) = getBlockRDNS($ip_dbh, id => $webvar{id}, type => $blockinfo->{type}, user => $authuser);
[760]1040 $page->param(rdns => $blockinfo->{rdns});
[750]1041 # visual flag that we're working IPDB-local, not off more authoritative data in dnsadmin
1042 $page->param(cached => $cached);
[586]1043
[750]1044 # Limit the per-IP rDNS list based on CIDR length; larger ones just take up too much space.
1045 # Also, don't show on IP pools; the individual IPs will have a space for rDNS
1046 # Don't show on single IPs; these use the "pattern" field
1047 if ($IPDBacl{$authuser} =~ /c/
1048 && $cidr->masklen != $cidr->bits
1049 && ($cidr->bits - $cidr->masklen) <= $IPDB::maxrevlist
[780]1050 # config flag for "all block types" OR "not-a-pool-or-IP type"
1051 && ($IPDB::revlistalltypes || $blockinfo->{type} !~ /^.[dpi]/)
1052 # safety against trying to retrieve and display more than 1k (10 bits, /22 v4) worth of individual IPs
1053 # ever. If you really need to manage a long list of IPs like that all in one place, you can use the DNS
1054 # management tool. Even a /26 is a bit much, really.
1055 && ($cidr->bits - $cidr->masklen) <= 10
[750]1056 # do we want to allow v6 at all?
1057 #&& ! $cidr->{isv6}
1058 ) {
1059 $page->param(r_iplist => getRDNSbyIP($ip_dbh, id => $webvar{id}, type => $blockinfo->{type},
1060 range => $blockinfo->{block}, user => $authuser) );
1061 }
1062 } # rDNS availability check
[675]1063
[786]1064 # backup data
1065 if ($blockinfo->{hasbk}) {
1066 $page->param(hasbackup => $blockinfo->{hasbk});
[798]1067 for my $bkfield (@IPDB::backupfields) {
[786]1068 $page->param("bk$bkfield" => $blockinfo->{"bk$bkfield"});
1069 }
1070 $page->param(bktelnet => 1) if $blockinfo->{bktype} eq 'telnet';
1071 $page->param(bkssh => 1) if $blockinfo->{bktype} eq 'SSH';
1072 }
1073
[691]1074 # consider extending this to show time as well as date
1075 my ($lastmod,undef) = split /\s+/, $blockinfo->{lastmod};
1076 $page->param(lastmod => $lastmod);
[4]1077
[691]1078 $page->param(block => $blockinfo->{block});
1079 $page->param(city => $blockinfo->{city});
1080 $page->param(custid => $blockinfo->{custid});
[4]1081
[187]1082##fixme The check here should be built from the database
[517]1083# Need to expand to support pool types too
[534]1084 if ($blockinfo->{type} =~ /^.[ne]$/ && $IPDBacl{$authuser} =~ /c/) {
[517]1085 $page->param(changetype => 1);
1086 $page->param(alloctype => [
[534]1087 { selme => ($blockinfo->{type} eq 'me'), type => "me", disptype => "Dialup netblock" },
1088 { selme => ($blockinfo->{type} eq 'de'), type => "de", disptype => "Dynamic DSL netblock" },
1089 { selme => ($blockinfo->{type} eq 'ce'), type => "ce", disptype => "Dynamic cable netblock" },
1090 { selme => ($blockinfo->{type} eq 'we'), type => "we", disptype => "Dynamic wireless netblock" },
1091 { selme => ($blockinfo->{type} eq 'cn'), type => "cn", disptype => "Customer netblock" },
1092 { selme => ($blockinfo->{type} eq 'en'), type => "en", disptype => "End-use netblock" },
1093 { selme => ($blockinfo->{type} eq 'in'), type => "in", disptype => "Internal netblock" },
[517]1094 ]
1095 );
1096 } else {
[534]1097 $page->param(disptype => $disp_alloctypes{$blockinfo->{type}});
1098 $page->param(type => $blockinfo->{type});
[517]1099 }
1100
[397]1101## node hack
[634]1102 my ($nodeid,$nodename) = getNodeInfo($ip_dbh, $blockinfo->{block});
1103# $page->param(havenodeid => $nodeid);
1104 $page->param(nodename => $nodename);
[517]1105
1106##fixme: this whole hack needs cleanup and generalization for all alloctypes
1107##fixme: arguably a bug that presence of a nodeid implies it can be changed..
[634]1108 if ($IPDBacl{$authuser} =~ /c/) {
1109 my $nlist = getNodeList($ip_dbh);
1110 if ($nodeid) {
[530]1111 foreach (@{$nlist}) {
[634]1112 $$_{selme} = ($$_{node_id} == $nodeid);
[397]1113 }
1114 }
[634]1115 $page->param(nodelist => $nlist);
[397]1116 }
1117## end node hack
[517]1118
[691]1119 $page->param(vrf => $blockinfo->{vrf});
1120 $page->param(vlan => $blockinfo->{vlan});
[33]1121
[695]1122 # Reserved-for-expansion
1123 $page->param(reserve => $blockinfo->{reserve});
1124 $page->param(reserve_id => $blockinfo->{reserve_id});
1125 my $newblock = NetAddr::IP->new($cidr->addr, $cidr->masklen - 1)->network;
1126 $page->param(newblock => $newblock);
1127
[517]1128 # not happy with the upside-down logic, but...
[534]1129 $page->param(swipable => $blockinfo->{type} !~ /.i/);
[691]1130 $page->param(swip => $blockinfo->{swip} ne 'n') if $blockinfo->{swip};
[320]1131
[691]1132 $page->param(circid => $blockinfo->{circuitid});
1133 $page->param(desc => $blockinfo->{description});
1134 $page->param(notes => $blockinfo->{notes});
1135
[284]1136 # Check to see if we can display sensitive data
[691]1137 $page->param(nocling => $IPDBacl{$authuser} =~ /s/);
[534]1138 $page->param(privdata => $blockinfo->{privdata});
[284]1139
[517]1140 # ACL trickery - these two template booleans control the presence of all form/input tags
1141 $page->param(maychange => $IPDBacl{$authuser} =~ /c/);
1142 $page->param(maydel => $IPDBacl{$authuser} =~ /d/);
[4]1143
[702]1144 # Need to find internal knobs to twist to actually vary these. (Ab)use "change" flag for now
[789]1145 $page->param(maymerge => ($IPDBacl{$authuser} =~ /m/ && $blockinfo->{type} !~ /^.i$/));
1146
[702]1147 if ($IPDBacl{$authuser} =~ /c/ && $blockinfo->{type} !~ /^.i$/) {
1148 if ($blockinfo->{type} =~ /^.p$/) {
1149 # PPP pools
1150 $page->param(maysplit => 1) if $cidr->masklen+1 < $cidr->bits;
1151 } elsif ($blockinfo->{type} =~ /.d/) {
1152 # Non-PPP pools
1153 $page->param(maysplit => 1) if $cidr->masklen+2 < $cidr->bits;
1154 } else {
1155 # Standard netblocks. Arguably allowing splitting these down to single IPs
1156 # doesn't make much sense, but forcing users to apply allocation types
1157 # "properly" is worse than herding cats.
1158 $page->param(maysplit => 1) if $cidr->masklen < $cidr->bits;
1159 }
1160 }
1161
[4]1162} # edit()
1163
1164
1165# Stuff new info about a block into the db
1166# action=update
1167sub update {
[284]1168 if ($IPDBacl{$authuser} !~ /c/) {
[517]1169 $aclerr = 'updateblock';
[284]1170 return;
1171 }
[4]1172
[706]1173 # Collect existing block info here, since we need it for the breadcrumb nav
1174 my $binfo = getBlockData($ip_dbh, $webvar{block}, $webvar{basetype});
1175 my $crumbs = getBreadCrumbs($ip_dbh, $binfo->{parent_id});
1176 my @rcrumbs = reverse (@$crumbs);
1177 $utilbar->param(breadcrumb => \@rcrumbs);
1178
[4]1179 # Make sure incoming data is in correct format - custID among other things.
[228]1180 return if !validateInput;
[4]1181
[536]1182 $webvar{swip} = 'n' if !$webvar{swip};
1183
[531]1184 my %updargs = (
1185 custid => $webvar{custid},
1186 city => $webvar{city},
1187 description => $webvar{desc},
1188 notes => $webvar{notes},
1189 circuitid => $webvar{circid},
1190 block => $webvar{block},
1191 type => $webvar{alloctype},
[536]1192 swip => $webvar{swip},
[588]1193 rdns => $webvar{rdns},
[691]1194 vrf => $webvar{vrf},
1195 vlan => $webvar{vlan},
[588]1196 user => $authuser,
[531]1197 );
1198
[788]1199 # Check to see if user is allowed to do anything with sensitive data
1200 if ($IPDBacl{$authuser} =~ /s/) {
1201 $updargs{privdata} = $webvar{privdata};
[798]1202 for my $bkfield (@IPDB::backupfields) {
[788]1203 $updargs{"bk$bkfield"} = $webvar{"bk$bkfield"};
1204 }
[798]1205 $updargs{backup} = $webvar{backupfields};
[788]1206 } else {
1207 # If the user doesn't have permissions to monkey with NOC-things, pass
1208 # a flag so we don't treat it as "backup data removed"
1209 $updargs{ignorebk} = 1;
1210 }
1211
[531]1212 # Semioptional values
1213 $updargs{node} = $webvar{node} if $webvar{node};
1214
[677]1215 # collect per-IP rDNS fields. only copy over the ones that actually have something in them.
1216 my %iprev;
1217 foreach (keys %webvar) {
1218 $iprev{$_} = $webvar{$_} if /host_[\d.a-fA-F:]+/ && $webvar{$_};
1219 }
[531]1220
[695]1221 # Merge with reserved freeblock
1222 $updargs{fbmerge} = $webvar{expandme} if $webvar{expandme};
1223
[677]1224 my ($code,$msg) = updateBlock($ip_dbh, %updargs, iprev => \%iprev);
1225
[531]1226 if ($code eq 'FAIL') {
[787]1227 syslog "err", "$authuser could not update block/IP '$binfo->{block}' (id $webvar{block}): '$msg'";
1228 $page->param(err => "Could not update block/IP $binfo->{block}: $msg");
[111]1229 return;
[4]1230 }
1231
1232 # If we get here, the operation succeeded.
[787]1233 syslog "notice", "$authuser updated $binfo->{block}";
[531]1234##fixme: log details of the change? old way is in the .debug stream anyway.
[416]1235##fixme: need to wedge something in to allow "update:field" notifications
1236## hmm. how to tell what changed? O_o
[787]1237mailNotify($ip_dbh, 's:swi', "SWIPed: $disp_alloctypes{$webvar{alloctype}} $binfo->{block}",
1238 "$binfo->{block} had SWIP status changed to \"Yes\" by $authuser") if $webvar{swip} eq 'on';
[4]1239
[517]1240## node hack
1241 if ($webvar{node} && $webvar{node} ne '-') {
[530]1242 my $nodename = getNodeName($ip_dbh, $webvar{node});
[517]1243 $page->param(nodename => $nodename);
1244 }
1245## end node hack
1246
[380]1247 # Link back to browse-routed or list-pool page on "Update complete" page.
[634]1248 my $pblock = getBlockData($ip_dbh, $binfo->{parent_id});
1249 $page->param(backid => $binfo->{parent_id});
1250 $page->param(backblock => $pblock->{block});
1251 $page->param(backpool => ($webvar{basetype} eq 'i'));
[380]1252
[536]1253 # Do some HTML fiddling here instead of using ESCAPE=HTML in the template,
1254 # because otherwise we can't convert \n to <br>. *sigh*
1255 $webvar{notes} = $q->escapeHTML($webvar{notes}); # escape first...
1256 $webvar{notes} =~ s/\n/<br>\n/; # ... then convert newlines
1257 $webvar{privdata} = ($webvar{privdata} ? $q->escapeHTML($webvar{privdata}) : "&nbsp;");
1258 $webvar{privdata} =~ s/\n/<br>\n/;
1259
[765]1260 if ($webvar{expandme}) {
1261 # this is fugly but still faster than hitting the DB again with getBlockData()
1262 my $tmp = new NetAddr::IP $binfo->{block};
1263 my $fb = new NetAddr::IP $binfo->{reserve};
1264 my @newblock = $tmp->compact($fb);
1265 $page->param(cidr => $newblock[0]);
1266 } else {
1267 $page->param(cidr => $binfo->{block});
1268 }
[588]1269 $page->param(rdns => $webvar{rdns});
[517]1270 $page->param(city => $webvar{city});
1271 $page->param(disptype => $disp_alloctypes{$webvar{alloctype}});
1272 $page->param(custid => $webvar{custid});
1273 $page->param(swip => $webvar{swip} eq 'on' ? 'Yes' : 'No');
[536]1274 $page->param(circid => $webvar{circid});
1275 $page->param(desc => $webvar{desc});
1276 $page->param(notes => $webvar{notes});
[788]1277 if ($IPDBacl{$authuser} =~ /s/) {
1278 $page->param(nocling => 1);
1279 $page->param(privdata => $webvar{privdata});
[798]1280 if ($webvar{backupfields} && $webvar{backupfields} eq 'on') {
1281 $page->param(hasbackup => 1);
[800]1282 for my $bkfield (@IPDB::backupfields) {
[798]1283 $page->param("bk$bkfield" => $webvar{"bk$bkfield"});
[788]1284 }
1285 }
1286 }
[4]1287
1288} # update()
1289
1290
[702]1291sub prepSplit {
1292 if ($IPDBacl{$authuser} !~ /c/) {
1293 $aclerr = 'splitblock';
1294 return;
1295 }
1296
1297 my $blockinfo = getBlockData($ip_dbh, $webvar{block});
1298
[705]1299 # Tree navigation
1300 my $crumbs = getBreadCrumbs($ip_dbh, $blockinfo->{parent_id});
1301 my @rcrumbs = reverse (@$crumbs);
1302 $utilbar->param(breadcrumb => \@rcrumbs);
1303
[702]1304 if ($blockinfo->{type} =~ /^.i$/) {
1305 $page->param(err => "Can't split a single IP allocation");
1306 return;
1307 }
1308
1309 # Info about current allocation
1310 $page->param(oldblock => $blockinfo->{block});
1311 $page->param(block => $webvar{block});
1312
1313# Note that there are probably different rules that should be followed to restrict splitting IPv6 blocks;
1314# strictly speaking it will be exceptionally rare to see smaller than a /64 assigned to a customer, since that
1315# breaks auto-addressing schemes.
1316
1317 # Generate possible splits
1318 my $block = new NetAddr::IP $blockinfo->{block};
1319 my $oldmask = $block->masklen;
1320 if ($blockinfo->{type} =~ /^.d$/) {
1321 # Non-PPP pools
[705]1322 $page->param(ispool => 1);
[702]1323 if ($oldmask+2 >= $block->bits) {
1324 $page->param(err => "Can't split a standard netblock pool any further");
1325 return;
1326 }
1327 # Allow splitting down to v4 /30 (which results in one usable IP; dubiously useful)
1328 $page->param(sp4mask => $oldmask+2) if $oldmask+2 <= $block->bits-2;
1329 } elsif ($blockinfo->{type} =~ /.p/) {
[705]1330 $page->param(ispool => 1);
[702]1331 # Allow splitting PPP pools down to v4 /31
1332 $page->param(sp4mask => $oldmask+2) if $oldmask+2 <= $block->bits-1;
1333 } else {
1334 # Allow splitting all other non-pool netblocks down to single IPs, which...
1335 # arguably should be *aggregated* in a pool. Except where they shouldn't.
1336 $page->param(sp4mask => $oldmask+2) if $oldmask+2 <= $block->bits;
1337 }
1338 # set the split-in-half mask
1339 $page->param(sp2mask => $oldmask+1);
1340
1341 # Generate possible shrink targets
1342 my @keepers = $block->split($block->masklen+1);
1343 $page->param(newblockA => $keepers[0]);
1344 $page->param(newblockB => $keepers[1]);
1345} # prepSplit()
1346
1347
1348sub doSplit {
1349 if ($IPDBacl{$authuser} !~ /c/) {
1350 $aclerr = 'splitblock';
1351 return;
1352 }
1353
1354##fixme: need consistent way to identify "this thing that is this thing" with only the ID
1355# also applies to other locations
1356 my $blockinfo = getBlockData($ip_dbh, $webvar{block});
1357
[705]1358 # Tree navigation
1359 my $crumbs = getBreadCrumbs($ip_dbh, $blockinfo->{parent_id});
1360 my @rcrumbs = reverse (@$crumbs);
1361 $utilbar->param(breadcrumb => \@rcrumbs);
1362
[702]1363 if ($blockinfo->{type} =~ /^.i$/) {
1364 $page->param(err => "Can't split a single IP allocation");
1365 return;
1366 }
1367
1368 if ($webvar{subact} eq 'split') {
1369 $page->param(issplit => 1);
[705]1370 my $block = new NetAddr::IP $blockinfo->{block};
[707]1371 my $newblocks = splitBlock($ip_dbh, id => $webvar{block}, basetype => 'b', newmask => $webvar{split},
1372 user => $authuser);
[702]1373 if ($newblocks) {
1374 $page->param(newblocks => $newblocks);
1375 } else {
1376 $page->param(err => $IPDB::errstr);
1377 }
1378
[705]1379 } elsif ($webvar{subact} eq 'shrink') {
1380 $page->param(nid => $webvar{block});
1381 $page->param(newblock => $webvar{shrink});
1382 my $newfree = shrinkBlock($ip_dbh, $webvar{block}, $webvar{shrink});
1383 if ($newfree) {
1384 $page->param(newfb => $newfree);
1385 } else {
1386 $page->param(err => $IPDB::errstr);
1387 }
1388
[702]1389 } else {
[705]1390 # Your llama is on fire.
1391 $page->param(err => "Missing form field that shouldn't be missing.");
1392 return;
[702]1393 }
[705]1394
1395 # common bits
1396 $page->param(cidr => $blockinfo->{block});
1397 # and the backlink to the parent container
1398 my $pinfo = getBlockData($ip_dbh, $blockinfo->{parent_id});
1399 $page->param(backid => $blockinfo->{parent_id});
1400 $page->param(backblock => $pinfo->{block});
[702]1401} # doSplit()
1402
1403
[717]1404# Set up for merge
1405sub prepMerge {
[789]1406 if ($IPDBacl{$authuser} !~ /m/) {
1407 $aclerr = 'mergeblock';
1408 return;
1409 }
1410
[717]1411 my $binfo = getBlockData($ip_dbh, $webvar{block});
[760]1412
1413 # Tree navigation
1414 my $crumbs = getBreadCrumbs($ip_dbh, $binfo->{parent_id});
1415 my @rcrumbs = reverse (@$crumbs);
1416 $utilbar->param(breadcrumb => \@rcrumbs);
1417
[717]1418 $page->param(block => $webvar{block});
1419 $page->param(ispool => $binfo->{type} =~ /.[dp]/);
1420 $page->param(ismaster => $binfo->{type} eq 'mm');
1421 $page->param(oldblock => $binfo->{block});
1422 $page->param(oldtype => $disp_alloctypes{$binfo->{type}});
1423 $page->param(typelist => getTypeList($ip_dbh, 'n', $binfo->{type})); # down the rabbit hole we go...
1424
[733]1425 # Strings for scope; do this way so we don't have to edit them many places
1426 $page->param(vis_keepall => $merge_display{keepall});
1427 $page->param(vis_mergepeer => $merge_display{mergepeer});
1428 $page->param(vis_clearpeer => $merge_display{clearpeer});
1429 $page->param(vis_clearall => $merge_display{clearall});
1430
[717]1431} # prepMerge()
1432
1433
[720]1434# Show what will be merged, present warnings about data loss
1435sub confMerge {
[789]1436 if ($IPDBacl{$authuser} !~ /m/) {
1437 $aclerr = 'mergeblock';
1438 return;
1439 }
1440
[720]1441 if (!$webvar{newmask} || $webvar{newmask} !~ /^\d+$/) {
1442 $page->param(err => 'New netmask required');
1443 return;
1444 }
1445
1446 $page->param(block => $webvar{block});
1447 my $binfo = getBlockData($ip_dbh, $webvar{block});
1448 my $pinfo = getBlockData($ip_dbh, $binfo->{parent_id});
1449 my $minfo = getBlockData($ip_dbh, $binfo->{master_id});
1450 my $block = new NetAddr::IP $binfo->{block};
1451
1452 # Tree navigation
1453 my $crumbs = getBreadCrumbs($ip_dbh, $binfo->{parent_id});
1454 my @rcrumbs = reverse (@$crumbs);
1455 $utilbar->param(breadcrumb => \@rcrumbs);
1456
1457 $page->param(oldblock => $binfo->{block});
1458 $page->param(oldtype => $disp_alloctypes{$binfo->{type}});
1459 $page->param(ismaster => $binfo->{type} eq 'mm');
1460 $page->param(ispool => $webvar{alloctype} =~ /.[dp]/);
1461 $page->param(isleaf => $webvar{alloctype} =~ /.[enr]/);
1462 $page->param(newtype => $webvar{alloctype});
1463 $page->param(newdisptype => $disp_alloctypes{$webvar{alloctype}});
1464 my $newblock = new NetAddr::IP $block->addr."/$webvar{newmask}";
1465 $newblock = $newblock->network;
1466 $page->param(newmask => $webvar{newmask});
1467 $page->param(newblock => "$newblock");
1468
1469 # get list of allocations and freeblocks to be merged
1470 my $malloc_list = listForMerge($ip_dbh, $binfo->{parent_id}, $newblock, 'a');
1471 $page->param(mergealloc => $malloc_list);
1472
[733]1473 $page->param(vis_scope => $merge_display{$webvar{scope}});
[727]1474 $page->param(scope => $webvar{scope});
[720]1475} # confMerge()
1476
1477
[751]1478# Make it so
1479sub doMerge {
[789]1480 if ($IPDBacl{$authuser} !~ /m/) {
1481 $aclerr = 'mergeblock';
1482 return;
1483 }
1484
[751]1485 if (!$webvar{newmask} || $webvar{newmask} !~ /^\d+$/) {
1486 $page->param(err => 'New netmask required');
1487 return;
1488 }
1489
1490 $page->param(block => $webvar{block});
1491 my $binfo = getBlockData($ip_dbh, $webvar{block});
1492 my $pinfo = getBlockData($ip_dbh, $binfo->{parent_id});
1493 my $block = new NetAddr::IP $binfo->{block};
1494
1495 # Tree navigation
1496 my $crumbs = getBreadCrumbs($ip_dbh, $binfo->{parent_id});
1497 my @rcrumbs = reverse (@$crumbs);
1498 $utilbar->param(breadcrumb => \@rcrumbs);
1499
1500 $page->param(oldblock => $binfo->{block});
1501 $page->param(oldtype => $disp_alloctypes{$binfo->{type}});
1502 $page->param(newdisptype => $disp_alloctypes{$webvar{newtype}});
1503 my $newblock = new NetAddr::IP $block->addr."/$webvar{newmask}";
1504 $newblock = $newblock->network;
1505 $page->param(newblock => $newblock);
1506 $page->param(vis_scope => $merge_display{$webvar{scope}});
1507
1508 my $mlist = mergeBlocks($ip_dbh, $webvar{block}, %webvar, user => $authuser);
1509
1510 if ($mlist) {
1511 #(newtype => $webvar{newtype}, newmask => $webvar{newmask}));
1512 # Slice off first entry (the new parent - note this may be a new allocation,
1513 # not the same ID that was "merged"!
1514 my $parent = shift @$mlist;
1515 $page->param(backpool => $webvar{newtype} =~ /.[dp]/);
1516 if ($webvar{newtype} =~ /.[enr]/) {
1517 $page->param(backleaf => 1);
1518 $page->param(backid => $binfo->{parent_id});
1519 $page->param(backblock => $pinfo->{block});
1520 } else {
1521 $page->param(backid => $parent->{id});
1522 $page->param(backblock => $parent->{block});
1523 }
1524 $page->param(mergelist => $mlist);
1525 } else {
1526 $page->param(err => "Merge failed: $IPDB::errstr");
1527 }
1528} # doMerge()
1529
1530
[4]1531# Delete an allocation.
[106]1532sub remove {
[233]1533 if ($IPDBacl{$authuser} !~ /d/) {
[517]1534 $aclerr = 'delblock';
[233]1535 return;
1536 }
1537
[4]1538 # Serves'em right for getting here...
1539 if (!defined($webvar{block})) {
[517]1540 $page->param(err => "Can't delete a block that doesn't exist");
[111]1541 return;
[4]1542 }
1543
[538]1544 my $blockdata;
[638]1545 $blockdata = getBlockData($ip_dbh, $webvar{block}, $webvar{basetype});
[4]1546
[765]1547 # Tree navigation
1548 my $crumbs = getBreadCrumbs($ip_dbh, $blockdata->{parent_id});
1549 my @rcrumbs = reverse (@$crumbs);
1550 $utilbar->param(breadcrumb => \@rcrumbs);
1551
[638]1552 if ($blockdata->{parent_id} == 0) { # $webvar{alloctype} eq 'mm'
[538]1553 $blockdata->{city} = "N/A";
1554 $blockdata->{custid} = "N/A";
1555 $blockdata->{circuitid} = "N/A";
1556 $blockdata->{description} = "N/A";
1557 $blockdata->{notes} = "N/A";
1558 $blockdata->{privdata} = "N/A";
[638]1559 } # end cases for different alloctypes
[517]1560
[638]1561 $page->param(blockid => $webvar{block});
1562 $page->param(basetype => $webvar{basetype});
[4]1563
[538]1564 $page->param(block => $blockdata->{block});
[589]1565 $page->param(rdns => $blockdata->{rdns});
1566
1567 # maybe need to apply more magic here?
1568 # most allocations we *do* want to autodelete the forward as well as reverse; for a handful we don't.
1569 # -> all real blocks (nb: pool IPs need extra handling)
1570 # -> NOC/private-IP (how to ID?)
1571 # -> anything with a pattern matching $IPDB::domain?
1572 if ($blockdata->{type} !~ /^.i$/) {
1573 $page->param(autodel => 1);
1574 }
1575
[538]1576 $page->param(disptype => $disp_alloctypes{$blockdata->{type}});
1577 $page->param(city => $blockdata->{city});
1578 $page->param(custid => $blockdata->{custid});
1579 $page->param(circid => $blockdata->{circuitid});
1580 $page->param(desc => $blockdata->{description});
1581 $blockdata->{notes} = $q->escapeHTML($blockdata->{notes});
1582 $blockdata->{notes} =~ s/\n/<br>\n/;
1583 $page->param(notes => $blockdata->{notes});
1584 $blockdata->{privdata} = $q->escapeHTML($blockdata->{privdata});
[540]1585 $blockdata->{privdata} = '&nbsp;' if !$blockdata->{privdata};
[538]1586 $blockdata->{privdata} =~ s/\n/<br>\n/;
1587 $page->param(privdata => $blockdata->{privdata}) if $IPDBacl{$authuser} =~ /s/;
1588 $page->param(delpool => $blockdata->{type} =~ /^.[pd]$/);
[4]1589
[517]1590} # end remove()
[4]1591
1592
1593# Delete an allocation. Return it to the freeblocks table; munge
1594# data as necessary to keep as few records as possible in freeblocks
1595# to prevent weirdness when allocating blocks later.
1596# Remove IPs from pool listing if necessary
1597sub finalDelete {
[233]1598 if ($IPDBacl{$authuser} !~ /d/) {
[517]1599 $aclerr = 'delblock';
[233]1600 return;
1601 }
[4]1602
[370]1603 # need to retrieve block data before deleting so we can notify on that
[638]1604 my $blockinfo = getBlockData($ip_dbh, $webvar{block}, $webvar{basetype});
1605 my $pinfo = getBlockData($ip_dbh, $blockinfo->{parent_id}, 'b');
[370]1606
[765]1607 # Tree navigation
1608 my $crumbs = getBreadCrumbs($ip_dbh, $blockinfo->{parent_id});
1609 my @rcrumbs = reverse (@$crumbs);
1610 $utilbar->param(breadcrumb => \@rcrumbs);
1611
[638]1612 my ($code,$msg) = deleteBlock($ip_dbh, $webvar{block}, $webvar{basetype}, $webvar{delforward}, $authuser);
[4]1613
[638]1614 $page->param(block => $blockinfo->{block});
[651]1615 $page->param(bdisp => $q->escapeHTML($disp_alloctypes{$blockinfo->{type}}));
[766]1616 $page->param(delparent_id => $blockinfo->{parent_id});
[651]1617 if ($pinfo) {
1618 $page->param(delparent => $pinfo->{block});
1619 $page->param(pdisp => $q->escapeHTML($disp_alloctypes{$pinfo->{type}}));
1620 }
[638]1621 $page->param(returnpool => ($webvar{basetype} eq 'i') );
[591]1622 if ($code =~ /^WARN(POOL|MERGE)/) {
[638]1623 my ($pid,$pcidr) = split /,/, $msg;
[654]1624 my $real_pinfo = getBlockData($ip_dbh, $pid, 'b');
[638]1625 $page->param(parent_id => $pid);
1626 $page->param(parent => $pcidr);
[654]1627 $page->param(real_disp => $q->escapeHTML($disp_alloctypes{$real_pinfo->{type}}));
[577]1628 $page->param(mergeip => $code eq 'WARNPOOL');
1629 }
[591]1630 if ($code eq 'WARN') {
1631 $msg =~ s/\n/<br>\n/g;
1632 $page->param(genwarn => $msg);
1633 }
[577]1634 if ($code eq 'OK' || $code =~ /^WARN/) {
[638]1635 syslog "notice", "$authuser deallocated '".$blockinfo->{type}."'-type netblock $webvar{block} ".
[528]1636 $blockinfo->{custid}.", ".$blockinfo->{city}.", desc='".$blockinfo->{description}."'";
[638]1637 mailNotify($ip_dbh, 'da', "REMOVED: ".$disp_alloctypes{$blockinfo->{type}}." $webvar{block}",
1638 $disp_alloctypes{$blockinfo->{type}}." $webvar{block} deallocated by $authuser\n".
[528]1639 "CustID: ".$blockinfo->{custid}."\nCity: ".$blockinfo->{city}.
1640 "\nDescription: ".$blockinfo->{description}."\n");
[106]1641 } else {
[517]1642 $page->param(failmsg => $msg);
[106]1643 if ($webvar{alloctype} =~ /^.i$/) {
1644 syslog "err", "$authuser could not deallocate static IP '$webvar{block}': '$msg'";
1645 } else {
1646 syslog "err", "$authuser could not deallocate netblock '$webvar{block}': '$msg'";
[517]1647 $page->param(netblock => 1);
[4]1648 }
[106]1649 }
[4]1650
1651} # finalDelete
Note: See TracBrowser for help on using the repository browser.