1
0
mirror of https://github.com/Ylianst/MeshAgent synced 2025-12-06 00:13:33 +00:00

Modified behavior on Windows to match that on Linux... If the db is wiped, new certs will be generated.

Also updated the Mesh Agent Service Installer on windows, so that the db is wiped on install.
This commit is contained in:
Bryan Roe
2019-02-15 15:02:42 -08:00
parent ec112d2d22
commit f6eed29c31
2 changed files with 21 additions and 22 deletions

View File

@@ -1877,11 +1877,12 @@ int agent_LoadCertificates(MeshAgentHostContainer *agent)
{
#if defined(WIN32)
// No cert in this .db file. Try to load or generate a root certificate from a Windows crypto provider. This can be TPM backed which is great.
if (wincrypto_open(FALSE) == 0)
// However, if we don't have the second cert created, we need to regen the root...
if (wincrypto_open(FALSE) == 0 && ILibSimpleDataStore_Get(agent->masterDb, "SelfNodeTlsCert", NULL, 0) != 0)
{
char* str = NULL;
int l;
do {
// Finish off work with our own certificate
l = wincrypto_getcert(&str);

View File

@@ -717,28 +717,26 @@ void fullinstall(int uninstallonly, char* proxy, int proxylen, char* tag, int ta
setup2[setup2len + 2] = 0;
remove(setup2);
if (uninstallonly != 0) {
// Remove "[Executable].tag" file
if ((setup2len = (int)strnlen_s(targetexe, _MAX_PATH + 40)) < 4 || setup2len > 259) return;
memcpy_s(setup2, sizeof(setup2), targetexe, setup2len);
memcpy_s(setup2 + (setup2len - 3), sizeof(setup2) - setup2len - 3, "tag", 4);
setup2[setup2len] = 0;
remove(setup2);
// Remove "[Executable].tag" file
if ((setup2len = (int)strnlen_s(targetexe, _MAX_PATH + 40)) < 4 || setup2len > 259) return;
memcpy_s(setup2, sizeof(setup2), targetexe, setup2len);
memcpy_s(setup2 + (setup2len - 3), sizeof(setup2) - setup2len - 3, "tag", 4);
setup2[setup2len] = 0;
remove(setup2);
// Remove "[Executable].log" file
if ((setup2len = (int)strnlen_s(targetexe, _MAX_PATH + 40)) < 4 || setup2len > 259) return;
memcpy_s(setup2, sizeof(setup2), targetexe, setup2len);
memcpy_s(setup2 + (setup2len - 3), sizeof(setup2) - setup2len - 3, "log", 4);
setup2[setup2len] = 0;
remove(setup2);
// Remove "[Executable].log" file
if ((setup2len = (int)strnlen_s(targetexe, _MAX_PATH + 40)) < 4 || setup2len > 259) return;
memcpy_s(setup2, sizeof(setup2), targetexe, setup2len);
memcpy_s(setup2 + (setup2len - 3), sizeof(setup2) - setup2len - 3, "log", 4);
setup2[setup2len] = 0;
remove(setup2);
// Remove "[Executable].db" file
if ((setup2len = (int)strnlen_s(targetexe, _MAX_PATH + 40)) < 4 || setup2len > 256) return;
memcpy_s(setup2, sizeof(setup2), targetexe, setup2len);
memcpy_s(setup2 + (setup2len - 3), sizeof(setup2) - setup2len - 3, "db", 3);
setup2[setup2len] = 0;
remove(setup2);
}
// Remove "[Executable].db" file
if ((setup2len = (int)strnlen_s(targetexe, _MAX_PATH + 40)) < 4 || setup2len > 256) return;
memcpy_s(setup2, sizeof(setup2), targetexe, setup2len);
memcpy_s(setup2 + (setup2len - 3), sizeof(setup2) - setup2len - 3, "db", 3);
setup2[setup2len] = 0;
remove(setup2);
// Remove the folder.
targetexe[targetexelen - 14] = 0;