[seahorse] ssh-source: Don't parse non-existing keys files



commit f7b8d83f0439997175b397e63e769c8a7d7ae67e
Author: Niels De Graef <nielsdegraef gmail com>
Date:   Tue May 31 21:28:01 2022 +0200

    ssh-source: Don't parse non-existing keys files
    
    If .authorized_keys or .other_keys doesn't exist, don't try to read it
    either (or we'll give warnings).

 ssh/source.vala | 25 ++++++++++++-------------
 1 file changed, 12 insertions(+), 13 deletions(-)
---
diff --git a/ssh/source.vala b/ssh/source.vala
index 9226a371..c4646c9f 100644
--- a/ssh/source.vala
+++ b/ssh/source.vala
@@ -278,18 +278,22 @@ public class Seahorse.Ssh.Source : GLib.Object, Gcr.Collection, Seahorse.Place {
             load_key_for_private_file.begin(privfile);
         }
 
-        // Now load the authorized keys
+        // Now load the authorized keys (if it exists)
         string pubfile = authorized_keys_path();
-        var result = yield Key.parse_file(pubfile);
-        foreach (unowned var keydata in result.public_keys) {
-            Source.add_key_from_parsed_data(this, keydata, pubfile, true, true, null);
+        if (FileUtils.test(pubfile, FileTest.IS_REGULAR)) {
+            var result = yield Key.parse_file(pubfile);
+            foreach (unowned var keydata in result.public_keys) {
+                Source.add_key_from_parsed_data(this, keydata, pubfile, true, true, null);
+            }
         }
 
         // Load the "other keys" (public keys without authorization)
         pubfile = other_keys_path();
-        result = yield Key.parse_file(pubfile);
-        foreach (unowned var keydata in result.public_keys) {
-            Source.add_key_from_parsed_data(this, keydata, pubfile, true, false, null);
+        if (FileUtils.test(pubfile, FileTest.IS_REGULAR)) {
+            var result = yield Key.parse_file(pubfile);
+            foreach (unowned var keydata in result.public_keys) {
+                Source.add_key_from_parsed_data(this, keydata, pubfile, true, false, null);
+            }
         }
 
         return true;
@@ -300,8 +304,7 @@ public class Seahorse.Ssh.Source : GLib.Object, Gcr.Collection, Seahorse.Place {
                                                 string pubfile,
                                                 bool partial,
                                                 bool authorized,
-                                                string? privfile = null,
-                                                GLib.GenericArray<string>? checks = null) {
+                                                string? privfile = null) {
         return_val_if_fail (keydata != null && keydata.is_valid(), null);
 
         keydata.pubfile = pubfile;
@@ -310,10 +313,6 @@ public class Seahorse.Ssh.Source : GLib.Object, Gcr.Collection, Seahorse.Place {
         if (privfile != null)
             keydata.privfile = privfile;
 
-        // Mark src key as seen
-        if (checks != null)
-            checks.remove(keydata.fingerprint);
-
         // Does src key exist in the context?
         Key? prev = src.find_key_by_fingerprint(keydata.fingerprint);
         if (prev != null)


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]