diff options
author | Daniil Baturin <daniil@baturin.org> | 2014-08-12 03:27:12 +0700 |
---|---|---|
committer | Daniil Baturin <daniil@baturin.org> | 2014-08-12 03:27:12 +0700 |
commit | ecd21575b32541890346e911a7d9db69cd312c4a (patch) | |
tree | 8c40b48bfee511dc0bc465e34906759e3e328c96 | |
parent | 960810b0b56d404b4abf275abfadfe3d77888ae5 (diff) | |
parent | 3cd370e33c2261142946cbeb37dcdd4baa130944 (diff) | |
download | vyatta-op-vpn-ecd21575b32541890346e911a7d9db69cd312c4a.tar.gz vyatta-op-vpn-ecd21575b32541890346e911a7d9db69cd312c4a.zip |
Merge pull request #3 from cyclops8456/helium
vyatta-op-vpn: prevent invalid rsa key file from being generated & display the config path location for the rsa key file
-rwxr-xr-x | scripts/gen_local_rsa_key.pl | 15 | ||||
-rwxr-xr-x | scripts/vyatta-show-vpn.pl | 4 |
2 files changed, 18 insertions, 1 deletions
diff --git a/scripts/gen_local_rsa_key.pl b/scripts/gen_local_rsa_key.pl index 4f800ab..ce3f69b 100755 --- a/scripts/gen_local_rsa_key.pl +++ b/scripts/gen_local_rsa_key.pl @@ -85,6 +85,21 @@ if (-r $local_key_file) { } } +# Remove the temporary file used to hold the new key if it already exists +# as this can cause invalid key generation if a previous run has been +# aborted. + +my $temp_key_file = $local_key_file.".new"; + +if (-e $temp_key_file) { + $cmd = "rm $temp_key_file"; + vpn_debug $cmd; + $rc = system($cmd); + if ($rc != 0) { + die "Cannot remove temporary key file $!\n"; + } +} + $cmd = "/usr/lib/ipsec/newhostkey --output $local_key_file --bits $bits"; # # The default random number generator is /dev/random, but it will block diff --git a/scripts/vyatta-show-vpn.pl b/scripts/vyatta-show-vpn.pl index 80d08b4..720ba56 100755 --- a/scripts/vyatta-show-vpn.pl +++ b/scripts/vyatta-show-vpn.pl @@ -27,6 +27,7 @@ use strict; use warnings; use lib "/opt/vyatta/share/perl5/"; +use Vyatta::Misc qw(get_short_config_path); my $arg0 = $ARGV[0]; if (!defined($arg0)) { @@ -82,10 +83,11 @@ if ($arg0 eq 'rsa-keys') { die "No key file $key_file found.\n"; } my $pubkey = rsa_get_local_pubkey($key_file); + my $config_key_file = get_short_config_path($key_file); if ($pubkey eq 0) { die "No local pubkey found.\n"; } - print "\nLocal public key ($key_file):\n\n$pubkey\n\n"; + print "\nLocal public key ($config_key_file):\n\n$pubkey\n\n"; use Vyatta::Config; my $vc = new Vyatta::Config(); |