# HG changeset patch # User Heiko Schlittermann # Date 1293657081 -3600 # Node ID fe2c4391758ec53df25e216140bb267477820b06 # Parent 8a85723f4b5329a765b08291cf3637e7012a5b5e# Parent 991f8f1593dc3b4c0d2aff6fc523752ecf1406e4 merged changes from a.suess diff -r 8a85723f4b53 -r fe2c4391758e dnssec-keytool.pl --- a/dnssec-keytool.pl Wed Dec 29 22:10:40 2010 +0100 +++ b/dnssec-keytool.pl Wed Dec 29 22:11:21 2010 +0100 @@ -3,18 +3,42 @@ use warnings; use strict; use FindBin; +use File::Temp; + +sub read_conf; +sub read_argv($); +sub rm_keys(@); +sub creat_zsk(@); + +MAIN: { + my @zone; + my $do; + + my %conf = read_conf(); + ($do, @zone) = read_argv($conf{master_dir}); + + # completed the program, if not a valid zones was handed over + unless (@zone) { exit; } + + if ($do eq "rm") { rm_keys($conf{master_dir}, @zone); exit; } +# if ($do eq "ck") { &ck_zone; } + if ($do eq "ksk") { creat_ksk($conf{master_dir}, @zone); } + + creat_zsk($conf{master_dir}, @zone); +# &post_creat; +} sub read_conf { # read configuration - my @configs = ("$FindBin::Bin/dnstools.conf", "/etc/dnstools.conf"); - our %config; + my @conffile = ("etc/dnstools.conf", "$FindBin::Bin/dnstools.conf"); + my %return; - for (grep { -f } @configs) { - open(CONFIG, $_) or die "Can't open $_: $!\n"; + for (grep { -f } @conffile) { + open(CONFIG, "<", $_) or die "Can't open $_: $!\n"; } unless (seek(CONFIG, 0, 0)) { - die "Can't open config (searched: @configs)\n"; + die "Can't open config (searched: @conffile)\n"; } while () { chomp; @@ -24,18 +48,20 @@ next unless length; my ($cname, $ccont) = split(/\s*=\s*/, $_, 2); - $config{$cname} = $ccont; + $return{$cname} = $ccont; } close(CONFIG); + return %return; } -sub read_argv { +sub read_argv ($) { # evaluate argv or print the help + my $master_dir = $_[0]; + my $arg = shift @ARGV; my $zone; - our $do; - our @zones; - our $master_dir; + my $do; # return + my @zone; # return if (!defined $arg) { print " usage: dnssec-keytool