From 53ee98566b3a429368e243e57caa5f94d901fe97 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Tobias=20Nie=C3=9Fen?= Date: Sun, 23 Jul 2023 21:35:38 +0200 Subject: [PATCH] permission: move PrintTree into unnamed namespace 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: https://github.com/nodejs/node/pull/48874 Reviewed-By: Rafael Gonzaga Reviewed-By: Debadree Chatterjee --- src/permission/fs_permission.cc | 57 +++++++++++++++++---------------- 1 file changed, 29 insertions(+), 28 deletions(-) diff --git a/src/permission/fs_permission.cc b/src/permission/fs_permission.cc index a02f95ea55f3a2..91c63dff6582a8 100644 --- a/src/permission/fs_permission.cc +++ b/src/permission/fs_permission.cc @@ -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) {