426 } |
424 } |
427 |
425 |
428 return @r; |
426 return @r; |
429 } |
427 } |
430 |
428 |
431 sub begin_ro { |
429 sub begin_rollover(@) { |
|
430 my @zones = @_; |
|
431 my @r; |
432 |
432 |
433 # anfang des key-rollovers |
433 # anfang des key-rollovers |
434 our @begin_ro_list; |
434 |
435 our @new_serial; |
435 #?? for (uniq(@begin_ro_list)) { |
436 |
436 foreach my $zone (@zones) { |
437 for (uniq(@begin_ro_list)) { |
|
438 |
437 |
439 #erzeugt zsks |
438 #erzeugt zsks |
440 my $zone = $_; |
439 my $dir = "$config{master_dir}/$zone"; |
441 my $zpf = "$config{master_dir}/$zone"; |
440 my @keys; |
442 my @index; |
441 |
443 |
442 chomp(my $keyname = `cd $dir && dnssec-keygen -a RSASHA1 -b 512 -n ZONE $zone`); |
444 chdir "$zpf" or die "$zpf: $!\n"; |
443 |
445 my $keyname = `dnssec-keygen -a RSASHA1 -b 512 -n ZONE $zone`; |
444 open(my $fh, "+<$dir/.index.zsk") or die "$dir/.index.zsk: $!\n"; |
446 |
445 chomp(@keys = <$fh>); |
447 open(INDEX, ".index.zsk") or die "$zpf/.index.zsk: $!\n"; |
446 |
448 @index = <INDEX>; |
447 push @keys, $keyname; |
449 close(INDEX); |
448 shift @keys if @keys > 2; |
450 |
449 |
451 push @index, $keyname; |
450 seek($fh, 0, 0) or die "seek"; # FIXME |
452 if (@index > 2) { shift(@index); } |
451 truncate($fh, 0) or die "truncate"; # FIXME |
453 |
452 print $fh join "\n" => @keys; |
454 open(INDEX, ">.index.zsk") or die "$zpf/.index.zsk: $!\n"; |
453 |
455 print INDEX @index; |
|
456 close(INDEX); |
|
457 |
|
458 chomp($keyname); |
|
459 print " * $zone: neuer ZSK $keyname erstellt\n"; |
454 print " * $zone: neuer ZSK $keyname erstellt\n"; |
460 |
455 |
461 open(KC, ">.keycounter") or die "$zpf/keycounter: $!\n"; |
456 open($fh, ">$dir/.keycounter") or die "$dir/.keycounter: $!\n"; |
462 print KC "0"; |
457 say $fh 0; |
463 close(KC); |
458 close($fh); |
464 |
459 |
465 &kill_useless_keys($zone); |
460 &kill_useless_keys($zone); |
466 &key_to_zonefile($zone); |
461 &key_to_zonefile($zone); |
467 push @new_serial, $zone; |
462 push @r, $zone; |
468 } |
463 } |
|
464 |
|
465 return @r; |
469 } |
466 } |
470 |
467 |
471 sub key_to_zonefile { |
468 sub key_to_zonefile { |
472 |
469 |
473 # die funktion fugt alle schluessel in eine zonedatei |
470 # die funktion fugt alle schluessel in eine zonedatei |