Skip to content

Commit

Permalink
Fix refresh of OSToken by passing isToken=true to Generation::create()
Browse files Browse the repository at this point in the history
The "true" in the call to Generation::create() in OSToken::OSToken() is
used as the umask when it's supposed to be the isToken value (opendnssec#566).

Remove the default value from isToken because it's dangerous and there are
only two callers. Explicitly pass "true" and "false" for isToken.

Failing to consider this a token generation file means that the value is
never refreshed for read-only operations. All objects are reloaded from
disk every time one of them is refreshed. List operations take a long time
because all of the objects are re-read for each object.

Fixes opendnssec#680.
  • Loading branch information
nomis committed Aug 16, 2022
1 parent ac70dc3 commit 68c6a9e
Show file tree
Hide file tree
Showing 4 changed files with 4 additions and 4 deletions.
2 changes: 1 addition & 1 deletion src/lib/object_store/Generation.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@
#include "Generation.h"

// Factory
Generation* Generation::create(const std::string path, int umask, bool isToken /* = false */)
Generation* Generation::create(const std::string path, int umask, bool isToken)
{
Generation* gen = new Generation(path, umask, isToken);
if ((gen != NULL) && isToken && (gen->genMutex == NULL))
Expand Down
2 changes: 1 addition & 1 deletion src/lib/object_store/Generation.h
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ class Generation
{
public:
// Factory
static Generation* create(const std::string inPath, int inUmask, bool inIsToken = false);
static Generation* create(const std::string inPath, int inUmask, bool inIsToken);

// Destructor
virtual ~Generation();
Expand Down
2 changes: 1 addition & 1 deletion src/lib/object_store/OSToken.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ OSToken::OSToken(const std::string inTokenPath, int inUmask)
umask = inUmask;

tokenDir = new Directory(tokenPath);
gen = Generation::create(tokenPath + OS_PATHSEP + "generation", true);
gen = Generation::create(tokenPath + OS_PATHSEP + "generation", umask, true);
tokenObject = new ObjectFile(this, tokenPath + OS_PATHSEP + "token.object", umask, tokenPath + OS_PATHSEP + "token.lock");
tokenMutex = MutexFactory::i()->getMutex();
valid = (gen != NULL) && (tokenMutex != NULL) && tokenDir->isValid() && tokenObject->valid;
Expand Down
2 changes: 1 addition & 1 deletion src/lib/object_store/ObjectFile.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ ObjectFile::ObjectFile(OSToken* parent, std::string inPath, int inUmask, std::st
{
path = inPath;
umask = inUmask;
gen = Generation::create(path, umask);
gen = Generation::create(path, umask, false);
objectMutex = MutexFactory::i()->getMutex();
valid = (gen != NULL) && (objectMutex != NULL);
token = parent;
Expand Down

0 comments on commit 68c6a9e

Please sign in to comment.