Skip to content
This repository has been archived by the owner on Oct 15, 2024. It is now read-only.

Commit

Permalink
disable cascading writes, fix #3742
Browse files Browse the repository at this point in the history
  • Loading branch information
hannes99 committed Apr 23, 2023
1 parent 4801797 commit 11c436a
Show file tree
Hide file tree
Showing 4 changed files with 29 additions and 4 deletions.
10 changes: 8 additions & 2 deletions src/tools/kdb/editor.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -86,7 +86,13 @@ int EditorCommand::execute (Cmdline const & cl)
{
throw invalid_argument ("wrong number of arguments, 1 needed");
}
Key root = cl.createKey (0, false);
Key root = cl.createKey (0);

if (root.getNamespace () == kdb::ElektraNamespace::CASCADING)
{
cerr << "Aborting: Specify a namespace for editing a value." << endl;
return 12;
}

KeySet ours;
KDB kdb;
Expand Down Expand Up @@ -140,7 +146,7 @@ int EditorCommand::execute (Cmdline const & cl)
if (!runAllEditors (filename))
{
std::cerr << "Could not run any editor, please change /sw/elektra/kdb/#0/current/editor" << std::endl;
return 12;
return 15;
}
}

Expand Down
6 changes: 6 additions & 0 deletions src/tools/kdb/import.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,12 @@ int ImportCommand::execute (Cmdline const & cl)
{
throw invalid_argument ("root key \"" + cl.arguments[0] + "\" is not a valid key name");
}
if (root.getNamespace () == kdb::ElektraNamespace::CASCADING)
{
cerr << "Aborting: Specify a namespace for importing." << endl;
return 2;
}


KeySet originalKeys;
kdb.get (originalKeys, root);
Expand Down
10 changes: 8 additions & 2 deletions src/tools/kdb/mv.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -32,9 +32,15 @@ int MvCommand::execute (Cmdline const & cl)
}

KeySet conf;
Key sourceKey = cl.createKey (0, false);
Key sourceKey = cl.createKey (0);

Key destKey = cl.createKey (1, false);
Key destKey = cl.createKey (1);

if (sourceKey.getNamespace () == kdb::ElektraNamespace::CASCADING || destKey.getNamespace () == kdb::ElektraNamespace::CASCADING)
{
cerr << "Aborting: Specify a namespace for destination and source when moving a key." << endl;
return 12;
}
string newDirName = destKey.getName ();

Key root = tools::helper::commonKeyName (sourceKey, destKey);
Expand Down
7 changes: 7 additions & 0 deletions src/tools/kdb/rm.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,13 @@ int RemoveCommand::execute (Cmdline const & cl)

KeySet conf;
Key x = cl.createKey (0);

if (x.getNamespace () == kdb::ElektraNamespace::CASCADING)
{
cerr << "Aborting: Specify a namespace for deleting a key." << endl;
return 12;
}

Key parentKey = cl.getParentKey (x);

kdb.get (conf, parentKey);
Expand Down

0 comments on commit 11c436a

Please sign in to comment.