check file exists before changing permissions

This commit is contained in:
Grant Limberg 2023-03-03 15:32:19 -08:00
commit fe0e7817f7

View file

@ -2239,7 +2239,9 @@ int main(int argc,char **argv)
try {
char p[4096];
OSUtils::ztsnprintf(p, sizeof(p), "%s" ZT_PATH_SEPARATOR_S "identity.secret", homeDir.c_str());
OSUtils::lockDownFile(p, false);
if (OSUtils::fileExists(p)) {
OSUtils::lockDownFile(p, false);
}
}
catch (...) {
}
@ -2247,7 +2249,9 @@ int main(int argc,char **argv)
try {
char p[4096];
OSUtils::ztsnprintf(p, sizeof(p), "%s" ZT_PATH_SEPARATOR_S "authtoken.secret", homeDir.c_str());
OSUtils::lockDownFile(p, false);
if (OSUtils::fileExists(p)) {
OSUtils::lockDownFile(p, false);
}
}
catch (...) {
}