summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorjake <jake@jakes-mail.top>2022-02-01 00:01:11 -0500
committerjake <jake@jakes-mail.top>2022-02-01 00:01:11 -0500
commitd52c3560f6707e37804c9f52ebb3269f7daa75d1 (patch)
tree9c87653ce0460c6f4aea627b140e22d85e08286b
parent74ecd05e6a9ccf8cc2e4019b50d4b0839f20264f (diff)
known_hosts matter now
-rwxr-xr-xgmi.pl23
1 files changed, 21 insertions, 2 deletions
diff --git a/gmi.pl b/gmi.pl
index 1f7d1f6..03cdf55 100755
--- a/gmi.pl
+++ b/gmi.pl
@@ -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;
}