diff --git a/src/Access/AccessControlManager.cpp b/src/Access/AccessControlManager.cpp
index 6158be1b603..1fa26c85354 100644
--- a/src/Access/AccessControlManager.cpp
+++ b/src/Access/AccessControlManager.cpp
@@ -281,41 +281,33 @@ void AccessControlManager::addStoragesFromMainConfig(
String config_dir = std::filesystem::path{config_path}.remove_filename().string();
String dbms_dir = config.getString("path", DBMS_DEFAULT_PATH);
String include_from_path = config.getString("include_from", "/etc/metrika.xml");
+ bool has_user_directories = config.has("user_directories");
- if (config.has("user_directories"))
+ /// If path to users' config isn't absolute, try guess its root (current) dir.
+ /// At first, try to find it in dir of main config, after will use current dir.
+ String users_config_path = config.getString("users_config", "");
+ if (users_config_path.empty())
{
- if (config.has("users_config"))
- LOG_WARNING(getLogger(), " is specified, the path from won't be used: " + config.getString("users_config"));
- if (config.has("access_control_path"))
- LOG_WARNING(getLogger(), " is specified, the path from won't be used: " + config.getString("access_control_path"));
-
- addStoragesFromUserDirectoriesConfig(
- config,
- "user_directories",
- config_dir,
- dbms_dir,
- include_from_path,
- get_zookeeper_function);
- }
- else
- {
- /// If path to users' config isn't absolute, try guess its root (current) dir.
- /// At first, try to find it in dir of main config, after will use current dir.
- String users_config_path = config.getString("users_config", "");
- if (users_config_path.empty())
+ if (!has_user_directories)
users_config_path = config_path;
- else if (std::filesystem::path{users_config_path}.is_relative() && std::filesystem::exists(config_dir + users_config_path))
- users_config_path = config_dir + users_config_path;
+ }
+ else if (std::filesystem::path{users_config_path}.is_relative() && std::filesystem::exists(config_dir + users_config_path))
+ users_config_path = config_dir + users_config_path;
+ if (!users_config_path.empty())
+ {
if (users_config_path != config_path)
checkForUsersNotInMainConfig(config, config_path, users_config_path, getLogger());
addUsersConfigStorage(users_config_path, include_from_path, dbms_dir, get_zookeeper_function);
-
- String disk_storage_dir = config.getString("access_control_path", "");
- if (!disk_storage_dir.empty())
- addDiskStorage(disk_storage_dir);
}
+
+ String disk_storage_dir = config.getString("access_control_path", "");
+ if (!disk_storage_dir.empty())
+ addDiskStorage(disk_storage_dir);
+
+ if (has_user_directories)
+ addStoragesFromUserDirectoriesConfig(config, "user_directories", config_dir, dbms_dir, include_from_path, get_zookeeper_function);
}
diff --git a/tests/integration/test_user_directories/configs/local_directories.xml b/tests/integration/test_user_directories/configs/local_directories.xml
index e2cbcd135df..7b9601da982 100644
--- a/tests/integration/test_user_directories/configs/local_directories.xml
+++ b/tests/integration/test_user_directories/configs/local_directories.xml
@@ -12,4 +12,6 @@
/var/lib/clickhouse/access3-ro/
+
+
diff --git a/tests/integration/test_user_directories/configs/memory.xml b/tests/integration/test_user_directories/configs/memory.xml
index 6e906d2b1d6..78da38ed0bc 100644
--- a/tests/integration/test_user_directories/configs/memory.xml
+++ b/tests/integration/test_user_directories/configs/memory.xml
@@ -5,4 +5,7 @@
+
+
+
diff --git a/tests/integration/test_user_directories/configs/mixed_style.xml b/tests/integration/test_user_directories/configs/mixed_style.xml
new file mode 100644
index 00000000000..d6ddecf6f5d
--- /dev/null
+++ b/tests/integration/test_user_directories/configs/mixed_style.xml
@@ -0,0 +1,8 @@
+
+
+
+
+
+ /etc/clickhouse-server/users6.xml
+ /var/lib/clickhouse/access6/
+
diff --git a/tests/integration/test_user_directories/configs/old_style.xml b/tests/integration/test_user_directories/configs/old_style.xml
index a0ff36edaba..cc753006b22 100644
--- a/tests/integration/test_user_directories/configs/old_style.xml
+++ b/tests/integration/test_user_directories/configs/old_style.xml
@@ -1,5 +1,6 @@
/etc/clickhouse-server/users2.xml
/var/lib/clickhouse/access2/
+
diff --git a/tests/integration/test_user_directories/configs/relative_path.xml b/tests/integration/test_user_directories/configs/relative_path.xml
index 8906478959e..c4ef3c5fd79 100644
--- a/tests/integration/test_user_directories/configs/relative_path.xml
+++ b/tests/integration/test_user_directories/configs/relative_path.xml
@@ -4,4 +4,7 @@
users4.xml
+
+
+
diff --git a/tests/integration/test_user_directories/test.py b/tests/integration/test_user_directories/test.py
index 8b7f34cf999..218330cb1a5 100644
--- a/tests/integration/test_user_directories/test.py
+++ b/tests/integration/test_user_directories/test.py
@@ -16,6 +16,7 @@ def started_cluster():
node.exec_in_container("cp /etc/clickhouse-server/users.xml /etc/clickhouse-server/users3.xml")
node.exec_in_container("cp /etc/clickhouse-server/users.xml /etc/clickhouse-server/users4.xml")
node.exec_in_container("cp /etc/clickhouse-server/users.xml /etc/clickhouse-server/users5.xml")
+ node.exec_in_container("cp /etc/clickhouse-server/users.xml /etc/clickhouse-server/users6.xml")
yield cluster
@@ -49,3 +50,10 @@ def test_memory():
node.restart_clickhouse()
assert node.query("SELECT * FROM system.user_directories") == TSV([["users.xml", "users.xml", "/etc/clickhouse-server/users5.xml", 1, 1],
["memory", "memory", "", 0, 2]])
+
+def test_mixed_style():
+ node.copy_file_to_container(os.path.join(SCRIPT_DIR, "configs/mixed_style.xml"), '/etc/clickhouse-server/config.d/z.xml')
+ node.restart_clickhouse()
+ assert node.query("SELECT * FROM system.user_directories") == TSV([["users.xml", "users.xml", "/etc/clickhouse-server/users6.xml", 1, 1],
+ ["local directory", "local directory", "/var/lib/clickhouse/access6/", 0, 2],
+ ["memory", "memory", "", 0, 3]])