mirror of
https://github.com/ClickHouse/ClickHouse.git
synced 2024-11-22 07:31:57 +00:00
Add storages from <user_directories> after ones from <users_config> and <access_control_path>.
This commit is contained in:
parent
318f14b95e
commit
7ac4bd7d1e
@ -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(), "<user_directories> is specified, the path from <users_config> won't be used: " + config.getString("users_config"));
|
||||
if (config.has("access_control_path"))
|
||||
LOG_WARNING(getLogger(), "<access_control_path> is specified, the path from <access_control_path> 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);
|
||||
}
|
||||
|
||||
|
||||
|
@ -12,4 +12,6 @@
|
||||
<path>/var/lib/clickhouse/access3-ro/</path>
|
||||
</local_directory>
|
||||
</user_directories>
|
||||
<users_config remove="remove"/>
|
||||
<access_control_path remove="remove"/>
|
||||
</yandex>
|
||||
|
@ -5,4 +5,7 @@
|
||||
</users_xml>
|
||||
<memory/>
|
||||
</user_directories>
|
||||
|
||||
<users_config remove="remove"/>
|
||||
<access_control_path remove="remove"/>
|
||||
</yandex>
|
||||
|
@ -0,0 +1,8 @@
|
||||
<yandex>
|
||||
<user_directories replace="replace">
|
||||
<memory/>
|
||||
</user_directories>
|
||||
|
||||
<users_config>/etc/clickhouse-server/users6.xml</users_config>
|
||||
<access_control_path>/var/lib/clickhouse/access6/</access_control_path>
|
||||
</yandex>
|
@ -1,5 +1,6 @@
|
||||
<yandex>
|
||||
<users_config>/etc/clickhouse-server/users2.xml</users_config>
|
||||
<access_control_path>/var/lib/clickhouse/access2/</access_control_path>
|
||||
|
||||
<user_directories remove="remove"/>
|
||||
</yandex>
|
||||
|
@ -4,4 +4,7 @@
|
||||
<path>users4.xml</path>
|
||||
</users_xml>
|
||||
</user_directories>
|
||||
|
||||
<users_config remove="remove"/>
|
||||
<access_control_path remove="remove"/>
|
||||
</yandex>
|
||||
|
@ -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]])
|
||||
|
Loading…
Reference in New Issue
Block a user