Index: /trunk/cgi-bin/IPDB.pm
===================================================================
--- /trunk/cgi-bin/IPDB.pm	(revision 706)
+++ /trunk/cgi-bin/IPDB.pm	(revision 707)
@@ -1462,15 +1462,16 @@
 sub splitBlock {
   my $dbh = shift;
-  my $id = shift;
-  my $basetype = shift;
-  my $newmask = shift;
+  my %args = @_;
+#  my $id = shift;
+#  my $basetype = shift;
+#  my $newmask = shift;
 
 ##fixme:  set errstr on errors so caller can suitably clue-by-four the user
-  return if $basetype ne 'b';  # only netblocks allowed!
-
-  my $binfo = getBlockData($dbh, $id);
+  return if $args{basetype} ne 'b';  # only netblocks allowed!
+
+  my $binfo = getBlockData($dbh, $args{id});
   return if !$binfo;
 
-  return if $newmask !~ /^\d+$/;
+  return if $args{newmask} !~ /^\d+$/;
 
   my @ret;
@@ -1481,6 +1482,6 @@
   # failure modes:
   # difference between $oldmask and $newmask is negative or 0
-  if ($newmask - $oldmask <= 0) {
-    $errstr = "Can't split a /$oldmask allocation into /$newmask pieces";
+  if ($args{newmask} - $oldmask <= 0) {
+    $errstr = "Can't split a /$oldmask allocation into /$args{newmask} pieces";
     return;
   }
@@ -1490,16 +1491,16 @@
   # $oldmask > n, for arbitrary n?  At least check limits of data type.
   if ($block->{isv6}) {
-    if ($newmask - $oldmask > 128) {
-      $errstr = "Impossible IPv6 mask length /$newmask requested";
+    if ($args{newmask} - $oldmask > 128) {
+      $errstr = "Impossible IPv6 mask length /$args{newmask} requested";
       return;
     }
   } else {
-    if ($newmask - $oldmask > 32) {
-      $errstr = "Impossible IPv4 mask length /$newmask requested";
+    if ($args{newmask} - $oldmask > 32) {
+      $errstr = "Impossible IPv4 mask length /$args{newmask} requested";
       return;
     }
   }
 
-  my @newblocks = $block->split($newmask);
+  my @newblocks = $block->split($args{newmask});
 
   local $dbh->{AutoCommit} = 0;
@@ -1517,5 +1518,5 @@
     }
     # note the first block in the split for return
-    push @ret, {nid => $id, nblock => "$newblocks[0]"};
+    push @ret, {nid => $args{id}, nblock => "$newblocks[0]"};
 
     # prepare
@@ -1527,10 +1528,10 @@
 
     # set up update of existing block
-    $dbh->do("UPDATE allocations SET cidr = ? WHERE id = ?", undef, ("$newblocks[0]", $id) );
+    $dbh->do("UPDATE allocations SET cidr = ? WHERE id = ?", undef, ("$newblocks[0]", $args{id}) );
 
     # axe the net, gw, and bcast IPs as necessary when splitting a "normal" pool
     if ($binfo->{type} =~ /.d/) {
       $newblocks[0]--;
-      $nbsth->execute($id, $newblocks[0]->addr);
+      $nbsth->execute($args{id}, $newblocks[0]->addr);
     }
 
@@ -1547,16 +1548,16 @@
       if ($binfo->{type} =~ /.d/) {
         # net
-        $nbsth->execute($id, $newblocks[$i]->addr);
+        $nbsth->execute($args{id}, $newblocks[$i]->addr);
         $newblocks[$i]++;
         # gw
-        $nbsth->execute($id, $newblocks[$i]->addr);
+        $nbsth->execute($args{id}, $newblocks[$i]->addr);
         $newblocks[$i]--;
         $newblocks[$i]--;
         # bcast
-        $nbsth->execute($id, $newblocks[$i]->addr);
+        $nbsth->execute($args{id}, $newblocks[$i]->addr);
         $newblocks[$i]++;
       }
       # ... and update the existing IPs with the new parent_id
-      $poolchildsth->execute($nid, $newblocks[$i], $id);
+      $poolchildsth->execute($nid, $newblocks[$i], $args{id});
     }
 
@@ -1568,4 +1569,8 @@
     return;
   }
+##fixme:  RPC return code?
+# particularly useful in this case as there may be arbitrary combinations of pass, warn, fail
+# results from each of the update and add(s), which could get the user to prod dnsadmin to see what exploded
+  my $foo = _rpc('splitTemplate', cidr => $binfo->{block}, newmask => $args{newmask}, rpcuser => $args{user});
 
   return \@ret;
Index: /trunk/cgi-bin/main.cgi
===================================================================
--- /trunk/cgi-bin/main.cgi	(revision 706)
+++ /trunk/cgi-bin/main.cgi	(revision 707)
@@ -1172,5 +1172,6 @@
     $page->param(issplit => 1);
     my $block = new NetAddr::IP $blockinfo->{block};
-    my $newblocks = splitBlock($ip_dbh, $webvar{block}, 'b', $webvar{split});
+    my $newblocks = splitBlock($ip_dbh, id => $webvar{block}, basetype => 'b', newmask => $webvar{split},
+	user => $authuser);
     if ($newblocks) {
       $page->param(newblocks => $newblocks);
