Have "tinc fsck" recognize Ed25519PublicKey statements.
[tinc] / src / fsck.c
index 8df95ec..138b1cd 100644 (file)
@@ -155,7 +155,11 @@ static void check_conffile(const char *fname, bool server) {
 }
 
 int fsck(const char *argv0) {
+#ifdef HAVE_MINGW
+       int uid = 0;
+#else
        uid_t uid = getuid();
+#endif
 
        // Check that tinc.conf is readable.
 
@@ -277,7 +281,7 @@ int fsck(const char *argv0) {
        }
 
        // Check for public keys.
-       // TODO: use RSAPublicKeyFile and Ed25519PublicKeyFile variables if present.
+       // TODO: use RSAPublicKeyFile variable if present.
 
        snprintf(fname, sizeof fname, "%s/hosts/%s", confbase, name);
        if(access(fname, R_OK))
@@ -338,13 +342,17 @@ int fsck(const char *argv0) {
                        fprintf(stderr, "WARNING: A public RSA key was found but no private key is known.\n");
        }
 #endif
-       //
-       // TODO: this should read the Ed25519PublicKey config variable instead.
+
        ecdsa_t *ecdsa_pub = NULL;
 
        f = fopen(fname, "r");
-       if(f)
-               ecdsa_pub = ecdsa_read_pem_public_key(f);
+       if(f) {
+               ecdsa_pub = get_pubkey(f);
+               if(!f) {
+                       rewind(f);
+                       ecdsa_pub = ecdsa_read_pem_public_key(f);
+               }
+       }
        fclose(f);
 
        if(ecdsa_priv) {