mirror of
https://github.com/ClickHouse/ClickHouse.git
synced 2024-11-25 17:12:03 +00:00
Merge pull request #39404 from HeenaBansal2009/Issue_39395
Clickhouse-local fixes
This commit is contained in:
commit
cdee1d94d0
@ -323,13 +323,29 @@ void LocalServer::setupUsers()
|
||||
auto & access_control = global_context->getAccessControl();
|
||||
access_control.setNoPasswordAllowed(config().getBool("allow_no_password", true));
|
||||
access_control.setPlaintextPasswordAllowed(config().getBool("allow_plaintext_password", true));
|
||||
if (config().has("users_config") || config().has("config-file") || fs::exists("config.xml"))
|
||||
if (config().has("config-file") || fs::exists("config.xml"))
|
||||
{
|
||||
String config_path = config().getString("config-file", "");
|
||||
bool has_user_directories = config().has("user_directories");
|
||||
const auto config_dir = fs::path{config_path}.remove_filename().string();
|
||||
String users_config_path = config().getString("users_config", "");
|
||||
|
||||
if (users_config_path.empty() && has_user_directories)
|
||||
{
|
||||
users_config_path = config().getString("user_directories.users_xml.path");
|
||||
if (fs::path(users_config_path).is_relative() && fs::exists(fs::path(config_dir) / users_config_path))
|
||||
users_config_path = fs::path(config_dir) / users_config_path;
|
||||
}
|
||||
|
||||
if (users_config_path.empty())
|
||||
users_config = getConfigurationFromXMLString(minimal_default_user_xml);
|
||||
else
|
||||
{
|
||||
const auto users_config_path = config().getString("users_config", config().getString("config-file", "config.xml"));
|
||||
ConfigProcessor config_processor(users_config_path);
|
||||
const auto loaded_config = config_processor.loadConfig();
|
||||
users_config = loaded_config.configuration;
|
||||
}
|
||||
}
|
||||
else
|
||||
users_config = getConfigurationFromXMLString(minimal_default_user_xml);
|
||||
if (users_config)
|
||||
@ -338,7 +354,6 @@ void LocalServer::setupUsers()
|
||||
throw Exception("Can't load config for users", ErrorCodes::CANNOT_LOAD_CONFIG);
|
||||
}
|
||||
|
||||
|
||||
void LocalServer::connect()
|
||||
{
|
||||
connection_parameters = ConnectionParameters(config());
|
||||
|
@ -0,0 +1 @@
|
||||
1
|
54
tests/queries/0_stateless/02360_clickhouse_local_config-option.sh
Executable file
54
tests/queries/0_stateless/02360_clickhouse_local_config-option.sh
Executable file
@ -0,0 +1,54 @@
|
||||
#!/usr/bin/env bash
|
||||
# Tags: no-parallel
|
||||
set -e
|
||||
|
||||
CUR_DIR=$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)
|
||||
# shellcheck source=../shell_config.sh
|
||||
. "$CUR_DIR"/../shell_config.sh
|
||||
|
||||
echo "<clickhouse>
|
||||
<logger>
|
||||
<level>trace</level>
|
||||
<console>true</console>
|
||||
</logger>
|
||||
|
||||
<tcp_port>9000</tcp_port>
|
||||
|
||||
<path>./</path>
|
||||
|
||||
<mark_cache_size>0</mark_cache_size>
|
||||
<user_directories>
|
||||
<users_xml>
|
||||
<!-- Path to configuration file with predefined users. -->
|
||||
<path>users.xml</path>
|
||||
</users_xml>
|
||||
</user_directories>
|
||||
</clickhouse>" > $CUR_DIR/config.xml
|
||||
|
||||
echo "<clickhouse>
|
||||
<profiles>
|
||||
<default></default>
|
||||
</profiles>
|
||||
<users>
|
||||
<default>
|
||||
<password></password>
|
||||
<networks>
|
||||
<ip>::/0</ip>
|
||||
</networks>
|
||||
<profile>default</profile>
|
||||
<quota>default</quota>
|
||||
</default>
|
||||
</users>
|
||||
<quotas>
|
||||
<default></default>
|
||||
</quotas>
|
||||
</clickhouse>" > $CUR_DIR/users.xml
|
||||
|
||||
local_opts=(
|
||||
"--config-file=$CUR_DIR/config.xml"
|
||||
"--send_logs_level=none")
|
||||
|
||||
${CLICKHOUSE_LOCAL} "${local_opts[@]}" --query 'Select 1' |& grep -v -e 'Processing configuration file'
|
||||
|
||||
rm -rf $CUR_DIR/users.xml
|
||||
rm -rf $CUR_DIR/config.xml
|
Loading…
Reference in New Issue
Block a user