X-Git-Url: https://tinc-vpn.org/git/browse?a=blobdiff_plain;f=src%2Ffsck.c;h=e5e7dd5afb7f9b4572b74c050ba5f96fb99ceb41;hb=c7c5c74d4af7442b92d863fc9eb04395c456b0be;hp=205a599c4eef10354b9ce9f7c4a08e17c05932a8;hpb=417981462a2dde7800768eb58cf8f4e5238d4ad7;p=tinc diff --git a/src/fsck.c b/src/fsck.c index 205a599c..e5e7dd5a 100644 --- a/src/fsck.c +++ b/src/fsck.c @@ -216,6 +216,7 @@ int fsck(const char *argv0) { return 1; } +#if !defined(HAVE_MINGW) && !defined(HAVE_CYGWIN) if(st.st_mode & 077) { fprintf(stderr, "WARNING: unsafe file permissions on %s.\n", fname); if(st.st_uid != uid) { @@ -227,6 +228,7 @@ int fsck(const char *argv0) { fprintf(stderr, "Fixed permissions of %s.\n", fname); } } +#endif } #endif @@ -255,6 +257,7 @@ int fsck(const char *argv0) { return 1; } +#if !defined(HAVE_MINGW) && !defined(HAVE_CYGWIN) if(st.st_mode & 077) { fprintf(stderr, "WARNING: unsafe file permissions on %s.\n", fname); if(st.st_uid != uid) { @@ -266,6 +269,7 @@ int fsck(const char *argv0) { fprintf(stderr, "Fixed permissions of %s.\n", fname); } } +#endif } #ifdef DISABLE_LEGACY @@ -281,7 +285,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)) @@ -293,9 +297,10 @@ int fsck(const char *argv0) { rsa_t *rsa_pub = NULL; f = fopen(fname, "r"); - if(f) + if(f) { rsa_pub = rsa_read_pem_public_key(f); - fclose(f); + fclose(f); + } if(rsa_priv) { if(!rsa_pub) { @@ -342,14 +347,18 @@ 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); - fclose(f); + if(f) { + ecdsa_pub = get_pubkey(f); + if(!ecdsa_pub) { + rewind(f); + ecdsa_pub = ecdsa_read_pem_public_key(f); + } + fclose(f); + } if(ecdsa_priv) { if(!ecdsa_pub) {