diff options
author | jake <jake@jakes-mail.top> | 2022-02-01 00:01:11 -0500 |
---|---|---|
committer | jake <jake@jakes-mail.top> | 2022-02-01 00:01:11 -0500 |
commit | d52c3560f6707e37804c9f52ebb3269f7daa75d1 (patch) | |
tree | 9c87653ce0460c6f4aea627b140e22d85e08286b | |
parent | 74ecd05e6a9ccf8cc2e4019b50d4b0839f20264f (diff) |
known_hosts matter now
-rwxr-xr-x | gmi.pl | 23 |
1 files changed, 21 insertions, 2 deletions
@@ -363,7 +363,7 @@ sub peer_cert { print $OUT "Do you still wish to connect to it? y/N "; chomp(my $yORn = <STDIN>); if (lc $yORn eq 'y') { - print $OUT "Would you like to replace the known_host fingerprint with this one? y/N "; + print $OUT "Would you like to replace the known_hosts fingerprint with this one? y/N "; chomp(my $yORn = <STDIN>); if (lc $yORn eq 'y') { $known_hosts{$hostname} = $peer_fingerprint; @@ -1137,7 +1137,7 @@ sub bookmarks { sub bookmark_del { my ($b) = @_; if ($b and $b =~ m/^\d+$/) { - if (@bookmarks[$b-1]) { + if ($bookmarks[$b-1]) { print $OUT "Removing $bookmarks[$b-1]"; splice(@bookmarks,$b-1,1); } @@ -1195,9 +1195,18 @@ sub load_config { close $FH; } ### @bookmarks + if (-e "$xdg_data/known_hosts") { + open(my $FH, '<', "$xdg_data/known_hosts"); + while (<$FH>) { + my ($a, $b) = split(' ', $_); + $known_hosts{$a} = $b; + } + } + ### %known_hosts } sub begin_exit { + my $old_umask = umask(077); if ($config{keep_history}) { # over writes the history with old and new open(my $FH, '>', "$xdg_data/history"); @@ -1206,11 +1215,21 @@ sub begin_exit { } close $FH; } + # over writes the bookmarks with old and new open(my $FH, '>', "$xdg_data/bookmarks"); for my $bookmark (@bookmarks) { print $FH "$bookmark\n"; } close $FH; + + # over writes the known_hosts with old and new + open($FH, '>', "$xdg_data/known_hosts"); + for my $known_host (sort keys %known_hosts) { + print $FH "$known_host $known_hosts{$known_host}\n"; + } + close $FH; + umask($old_umask); + exit 0; } |