Skip to content

Commit

Permalink
permission: move PrintTree into unnamed namespace
Browse files Browse the repository at this point in the history
This function is not declared outside of fs_permission.cc and thus
should not be visible outside the file during the linking stage.

PR-URL: #48874
Reviewed-By: Rafael Gonzaga <rafael.nunu@hotmail.com>
Reviewed-By: Debadree Chatterjee <debadree333@gmail.com>
  • Loading branch information
tniessen authored and RafaelGSS committed Aug 15, 2023
1 parent 65d2394 commit 53ee985
Showing 1 changed file with 29 additions and 28 deletions.
57 changes: 29 additions & 28 deletions src/permission/fs_permission.cc
Original file line number Diff line number Diff line change
Expand Up @@ -67,52 +67,53 @@ bool is_tree_granted(node::permission::FSPermission::RadixTree* granted_tree,
return granted_tree->Lookup(param, true);
}

} // namespace

namespace node {

namespace permission {

void PrintTree(const FSPermission::RadixTree::Node* node, size_t spaces = 0) {
void PrintTree(const node::permission::FSPermission::RadixTree::Node* node,
size_t spaces = 0) {
std::string whitespace(spaces, ' ');

if (node == nullptr) {
return;
}
if (node->wildcard_child != nullptr) {
per_process::Debug(DebugCategory::PERMISSION_MODEL,
"%s Wildcard: %s\n",
whitespace,
node->prefix);
node::per_process::Debug(node::DebugCategory::PERMISSION_MODEL,
"%s Wildcard: %s\n",
whitespace,
node->prefix);
} else {
per_process::Debug(DebugCategory::PERMISSION_MODEL,
"%s Prefix: %s\n",
whitespace,
node->prefix);
node::per_process::Debug(node::DebugCategory::PERMISSION_MODEL,
"%s Prefix: %s\n",
whitespace,
node->prefix);
if (node->children.size()) {
size_t child = 0;
for (const auto& pair : node->children) {
++child;
per_process::Debug(DebugCategory::PERMISSION_MODEL,
"%s Child(%s): %s\n",
whitespace,
child,
std::string(1, pair.first));
node::per_process::Debug(node::DebugCategory::PERMISSION_MODEL,
"%s Child(%s): %s\n",
whitespace,
child,
std::string(1, pair.first));
PrintTree(pair.second, spaces + 2);
}
per_process::Debug(DebugCategory::PERMISSION_MODEL,
"%s End of tree - child(%s)\n",
whitespace,
child);
node::per_process::Debug(node::DebugCategory::PERMISSION_MODEL,
"%s End of tree - child(%s)\n",
whitespace,
child);
} else {
per_process::Debug(DebugCategory::PERMISSION_MODEL,
"%s End of tree: %s\n",
whitespace,
node->prefix);
node::per_process::Debug(node::DebugCategory::PERMISSION_MODEL,
"%s End of tree: %s\n",
whitespace,
node->prefix);
}
}
}

} // namespace

namespace node {

namespace permission {

// allow = '*'
// allow = '/tmp/,/home/example.js'
void FSPermission::Apply(const std::string& allow, PermissionScope scope) {
Expand Down

0 comments on commit 53ee985

Please sign in to comment.