Have "tinc fsck" recognize Ed25519PublicKey statements.
authorGuus Sliepen <guus@tinc-vpn.org>
Sat, 23 Apr 2016 15:20:08 +0000 (17:20 +0200)
committerGuus Sliepen <guus@tinc-vpn.org>
Sat, 23 Apr 2016 15:20:08 +0000 (17:20 +0200)
src/fsck.c
src/tincctl.c
src/tincctl.h

index 205a599c4eef10354b9ce9f7c4a08e17c05932a8..138b1cd77c469153fdbc5924c57edba678779634 100644 (file)
@@ -281,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))
@@ -342,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) {
index 4231cce39f09f42ffdefc8f239d1fe58453a82a5..f41e0307b6abeed018ba207df1a8e81a79bef35d 100644 (file)
@@ -1,6 +1,6 @@
 /*
     tincctl.c -- Controlling a running tincd
-    Copyright (C) 2007-2015 Guus Sliepen <guus@tinc-vpn.org>
+    Copyright (C) 2007-2016 Guus Sliepen <guus@tinc-vpn.org>
 
     This program is free software; you can redistribute it and/or modify
     it under the terms of the GNU General Public License as published by
@@ -89,7 +89,7 @@ static struct option const long_options[] = {
 static void version(void) {
        printf("%s version %s (built %s %s, protocol %d.%d)\n", PACKAGE,
                   BUILD_VERSION, BUILD_DATE, BUILD_TIME, PROT_MAJOR, PROT_MINOR);
-       printf("Copyright (C) 1998-2015 Ivo Timmermans, Guus Sliepen and others.\n"
+       printf("Copyright (C) 1998-2016 Ivo Timmermans, Guus Sliepen and others.\n"
                        "See the AUTHORS file for a complete list.\n\n"
                        "tinc comes with ABSOLUTELY NO WARRANTY.  This is free software,\n"
                        "and you are welcome to redistribute it under certain conditions;\n"
@@ -1433,7 +1433,7 @@ char *get_my_name(bool verbose) {
        return NULL;
 }
 
-static ecdsa_t *get_pubkey(FILE *f) {
+ecdsa_t *get_pubkey(FILE *f) {
        char buf[4096];
        char *value;
        while(fgets(buf, sizeof buf, f)) {
index 4a917af828bce167473fe17bd811cbcd0a969bd0..6628f2bbf80d12d07d53e6c44c917f39afa8adbc 100644 (file)
@@ -1,6 +1,6 @@
 /*
     tincctl.h -- header for tincctl.c.
-    Copyright (C) 2011-2013 Guus Sliepen <guus@tinc-vpn.org>
+    Copyright (C) 2011-2016 Guus Sliepen <guus@tinc-vpn.org>
 
     This program is free software; you can redistribute it and/or modify
     it under the terms of the GNU General Public License as published by
@@ -50,6 +50,7 @@ extern bool sendline(int fd, char *format, ...);
 extern bool recvline(int fd, char *line, size_t len);
 extern int check_port(char *name);
 extern FILE *fopenmask(const char *filename, const char *mode, mode_t perms);
+extern ecdsa_t *get_pubkey(FILE *f);
 
 #endif