X-Git-Url: https://tinc-vpn.org/git/browse?p=tinc;a=blobdiff_plain;f=src%2Ffsck.c;h=b90710b958aca48b0b5b2bfb87a3368fec20fe04;hp=8df95ec6f7a17de386a9f51c78d1a886dc3e5dd9;hb=390d25f0b80dd7418e147de3561c70461628574d;hpb=268e3ffca7b45cfc736e1bc9bec7a113c6c45701 diff --git a/src/fsck.c b/src/fsck.c index 8df95ec6..b90710b9 100644 --- a/src/fsck.c +++ b/src/fsck.c @@ -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. @@ -212,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) { @@ -223,6 +228,7 @@ int fsck(const char *argv0) { fprintf(stderr, "Fixed permissions of %s.\n", fname); } } +#endif } #endif @@ -251,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) { @@ -262,6 +269,7 @@ int fsck(const char *argv0) { fprintf(stderr, "Fixed permissions of %s.\n", fname); } } +#endif } #ifdef DISABLE_LEGACY @@ -277,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)) @@ -338,13 +346,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) {