Have "tinc fsck" recognize Ed25519PublicKey statements.

This commit is contained in:
Guus Sliepen 2016-04-23 17:20:08 +02:00
parent 6805b15731
commit 76955a6c8b
3 changed files with 14 additions and 9 deletions

View file

@ -281,7 +281,7 @@ int fsck(const char *argv0) {
} }
// Check for public keys. // 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); snprintf(fname, sizeof fname, "%s/hosts/%s", confbase, name);
if(access(fname, R_OK)) 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"); fprintf(stderr, "WARNING: A public RSA key was found but no private key is known.\n");
} }
#endif #endif
//
// TODO: this should read the Ed25519PublicKey config variable instead.
ecdsa_t *ecdsa_pub = NULL; ecdsa_t *ecdsa_pub = NULL;
f = fopen(fname, "r"); f = fopen(fname, "r");
if(f) if(f) {
ecdsa_pub = ecdsa_read_pem_public_key(f); ecdsa_pub = get_pubkey(f);
if(!f) {
rewind(f);
ecdsa_pub = ecdsa_read_pem_public_key(f);
}
}
fclose(f); fclose(f);
if(ecdsa_priv) { if(ecdsa_priv) {

View file

@ -1,6 +1,6 @@
/* /*
tincctl.c -- Controlling a running tincd 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 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 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) { static void version(void) {
printf("%s version %s (built %s %s, protocol %d.%d)\n", PACKAGE, printf("%s version %s (built %s %s, protocol %d.%d)\n", PACKAGE,
BUILD_VERSION, BUILD_DATE, BUILD_TIME, PROT_MAJOR, PROT_MINOR); 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" "See the AUTHORS file for a complete list.\n\n"
"tinc comes with ABSOLUTELY NO WARRANTY. This is free software,\n" "tinc comes with ABSOLUTELY NO WARRANTY. This is free software,\n"
"and you are welcome to redistribute it under certain conditions;\n" "and you are welcome to redistribute it under certain conditions;\n"
@ -1433,7 +1433,7 @@ char *get_my_name(bool verbose) {
return NULL; return NULL;
} }
static ecdsa_t *get_pubkey(FILE *f) { ecdsa_t *get_pubkey(FILE *f) {
char buf[4096]; char buf[4096];
char *value; char *value;
while(fgets(buf, sizeof buf, f)) { while(fgets(buf, sizeof buf, f)) {

View file

@ -1,6 +1,6 @@
/* /*
tincctl.h -- header for tincctl.c. 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 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 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 bool recvline(int fd, char *line, size_t len);
extern int check_port(char *name); extern int check_port(char *name);
extern FILE *fopenmask(const char *filename, const char *mode, mode_t perms); extern FILE *fopenmask(const char *filename, const char *mode, mode_t perms);
extern ecdsa_t *get_pubkey(FILE *f);
#endif #endif