update-serial.pl
branchhs12
changeset 59 35a116258422
parent 58 3d3e09a0c028
child 60 2c45d68844bf
equal deleted inserted replaced
58:3d3e09a0c028 59:35a116258422
    18 sub changed_zones();
    18 sub changed_zones();
    19 sub update_index($);
    19 sub update_index($);
    20 sub sign_expired($);
    20 sub sign_expired($);
    21 sub need_rollover();
    21 sub need_rollover();
    22 sub done_rollover();
    22 sub done_rollover();
       
    23 sub begin_rollover(@);
    23 
    24 
    24 sub sign_zone;
    25 sub sign_zone;
    25 sub update_serial;
    26 sub update_serial;
    26 sub mk_zone_conf;
    27 sub mk_zone_conf;
    27 sub file_entry;
    28 sub file_entry;
    28 sub server_reload;
    29 sub server_reload;
    29 sub begin_ro;
       
    30 sub key_to_zonefile;
    30 sub key_to_zonefile;
    31 sub kill_useless_keys;
    31 sub kill_useless_keys;
    32 sub end_ro;
    32 sub end_ro;
    33 
    33 
    34 my %config;
    34 my %config;
    66     my @need_rollover = need_rollover;
    66     my @need_rollover = need_rollover;
    67     my @done_rollover = done_rollover;
    67     my @done_rollover = done_rollover;
    68     ### @candidates
    68     ### @candidates
    69     ### @need_rollover
    69     ### @need_rollover
    70     ### @done_rollover
    70     ### @done_rollover
       
    71 
       
    72     begin_rollover(@need_rollover);    # eine rollover-beginn-sequenz
    71     exit;
    73     exit;
    72 
       
    73     if (@need_rollover) {
       
    74         begin_ro;    # eine rollover-beginn-sequenz
       
    75     }
       
    76 
    74 
    77     if (@end_ro_list) {
    75     if (@end_ro_list) {
    78         end_ro;      # eine rollover-end-squenz
    76         end_ro;      # eine rollover-end-squenz
    79     }
    77     }
    80 
    78 
   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