-
Notifications
You must be signed in to change notification settings - Fork 7.5k
Fix crash in IAccessStorage::authenticateImpl #84426
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Open
shankar-iyer
wants to merge
3
commits into
ClickHouse:master
Choose a base branch
from
shankar-iyer:fix_crash_in_IAccess
base: master
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
Show all changes
3 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
21 changes: 21 additions & 0 deletions
21
tests/queries/0_stateless/03574_no_password_existing_user.config.xml.1
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
<clickhouse> | ||
<logger> | ||
<level>trace</level> | ||
<console>true</console> | ||
</logger> | ||
|
||
<tcp_port>9000</tcp_port> | ||
<allow_no_password>1</allow_no_password> | ||
<path>.</path> | ||
<!-- Sources to read users, roles, access rights, profiles of settings, quotas. --> | ||
<user_directories> | ||
<users_xml> | ||
<!-- Path to configuration file with predefined users. --> | ||
<path>users.xml</path> | ||
</users_xml> | ||
<local_directory> | ||
<!-- Path to folder where users created by SQL commands are stored. --> | ||
<path>./</path> | ||
</local_directory> | ||
</user_directories> | ||
</clickhouse> |
21 changes: 21 additions & 0 deletions
21
tests/queries/0_stateless/03574_no_password_existing_user.config.xml.2
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
<clickhouse> | ||
<logger> | ||
<level>trace</level> | ||
<console>true</console> | ||
</logger> | ||
|
||
<tcp_port>9000</tcp_port> | ||
<allow_no_password>0</allow_no_password> | ||
<path>.</path> | ||
<!-- Sources to read users, roles, access rights, profiles of settings, quotas. --> | ||
<user_directories> | ||
<users_xml> | ||
<!-- Path to configuration file with predefined users. --> | ||
<path>users.xml</path> | ||
</users_xml> | ||
<local_directory> | ||
<!-- Path to folder where users created by SQL commands are stored. --> | ||
<path>./</path> | ||
</local_directory> | ||
</user_directories> | ||
</clickhouse> |
1 change: 1 addition & 0 deletions
1
tests/queries/0_stateless/03574_no_password_existing_user.reference
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
u_3574 |
130 changes: 130 additions & 0 deletions
130
tests/queries/0_stateless/03574_no_password_existing_user.sh
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,130 @@ | ||
#!/usr/bin/env bash | ||
# Tags: no-parallel, no-fasttest | ||
# | ||
# Starts the server twice - | ||
# 1st : Start with allow_no_password=1 and create a user with no_password and login as that user will also succeed. | ||
# 2nd : Restart the server with allow_no_password=0. Now login as that user should error and not crash Clickhouse server. | ||
|
||
CURDIR=$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd) | ||
# shellcheck source=../shell_config.sh | ||
. "$CURDIR"/../shell_config.sh | ||
|
||
cp ${CLICKHOUSE_CONFIG_DIR}/users.xml "$CURDIR"/users.xml | ||
sed -i 's/<password><\/password>/<password_sha256_hex>c64c5e4e53ea1a9f1427d2713b3a22bbebe8940bc807adaf654744b1568c70ab<\/password_sha256_hex>/g' "$CURDIR"/users.xml | ||
sed -i 's/<!-- <access_management>1<\/access_management> -->/<access_management>1<\/access_management>/g' "$CURDIR"/users.xml | ||
|
||
# First start the server with allow_no_password=1 | ||
server_opts=( | ||
"--config-file=$CURDIR/03574_no_password_existing_user.config.xml.1" | ||
"--" | ||
# to avoid multiple listen sockets (complexity for port discovering) | ||
"--listen_host=127.1" | ||
# we will discover the real port later. | ||
"--tcp_port=0" | ||
"--shutdown_wait_unfinished=0" | ||
) | ||
|
||
CLICKHOUSE_WATCHDOG_ENABLE=0 $CLICKHOUSE_SERVER_BINARY "${server_opts[@]}" &> clickhouse-server.stderr & | ||
server_pid=$! | ||
|
||
server_port= | ||
i=0 retries=300 | ||
# wait until server will start to listen (max 30 seconds) | ||
while [[ -z $server_port ]] && [[ $i -lt $retries ]]; do | ||
server_port=$(lsof -n -a -P -i tcp -s tcp:LISTEN -p $server_pid 2>/dev/null | awk -F'[ :]' '/LISTEN/ { print $(NF-1) }') | ||
((++i)) | ||
sleep 0.1 | ||
if ! kill -0 $server_pid >& /dev/null; then | ||
echo "No server (pid $server_pid)" | ||
break | ||
fi | ||
done | ||
if [[ -z $server_port ]]; then | ||
echo "Cannot wait for LISTEN socket" >&2 | ||
exit 1 | ||
fi | ||
|
||
# wait for the server to start accepting tcp connections (max 30 seconds) | ||
i=0 retries=300 | ||
while ! $CLICKHOUSE_CLIENT_BINARY -u default --password='1w2swhb1' --host 127.1 --port "$server_port" --format Null -q 'select 1' 2>/dev/null && [[ $i -lt $retries ]]; do | ||
sleep 0.1 | ||
if ! kill -0 $server_pid >& /dev/null; then | ||
echo "No server (pid $server_pid)" | ||
break | ||
fi | ||
done | ||
|
||
|
||
if ! $CLICKHOUSE_CLIENT_BINARY -u default --password='1w2swhb1' --host 127.1 --port "$server_port" --format Null -q 'select 1'; then | ||
echo "Cannot wait until server will start accepting connections on <tcp_port>" >&2 | ||
exit 1 | ||
fi | ||
|
||
$CLICKHOUSE_CLIENT_BINARY -u default --password='1w2swhb1' --host 127.1 --port "$server_port" -q "DROP USER IF EXISTS u_3574;" | ||
$CLICKHOUSE_CLIENT_BINARY -u default --password='1w2swhb1' --host 127.1 --port "$server_port" -q "CREATE USER u_3574 IDENTIFIED WITH no_password;" | ||
# This will work. | ||
$CLICKHOUSE_CLIENT_BINARY -u u_3574 --password "" --host 127.1 --port "$server_port" -q "SELECT user();" | ||
|
||
# send TERM and save the error code to ensure that it is 0 (EXIT_SUCCESS) | ||
kill $server_pid | ||
wait $server_pid | ||
|
||
# start the server again with allow_no_password=0 | ||
server_opts=( | ||
"--config-file=$CURDIR/03574_no_password_existing_user.config.xml.2" | ||
"--" | ||
# to avoid multiple listen sockets (complexity for port discovering) | ||
"--listen_host=127.1" | ||
# we will discover the real port later. | ||
"--tcp_port=0" | ||
"--shutdown_wait_unfinished=0" | ||
) | ||
|
||
CLICKHOUSE_WATCHDOG_ENABLE=0 $CLICKHOUSE_SERVER_BINARY "${server_opts[@]}" &> clickhouse-server.stderr & | ||
server_pid=$! | ||
|
||
server_port= | ||
i=0 retries=300 | ||
# wait until server will start to listen (max 30 seconds) | ||
while [[ -z $server_port ]] && [[ $i -lt $retries ]]; do | ||
server_port=$(lsof -n -a -P -i tcp -s tcp:LISTEN -p $server_pid 2>/dev/null | awk -F'[ :]' '/LISTEN/ { print $(NF-1) }') | ||
((++i)) | ||
sleep 0.1 | ||
if ! kill -0 $server_pid >& /dev/null; then | ||
echo "No server (pid $server_pid)" | ||
break | ||
fi | ||
done | ||
if [[ -z $server_port ]]; then | ||
echo "Cannot wait for LISTEN socket" >&2 | ||
exit 1 | ||
fi | ||
|
||
# wait for the server to start accepting tcp connections (max 30 seconds) | ||
i=0 retries=300 | ||
while ! $CLICKHOUSE_CLIENT_BINARY -u default --password='1w2swhb1' --host 127.1 --port "$server_port" --format Null -q 'select 1' 2>/dev/null && [[ $i -lt $retries ]]; do | ||
sleep 0.1 | ||
if ! kill -0 $server_pid >& /dev/null; then | ||
echo "No server (pid $server_pid)" | ||
break | ||
fi | ||
done | ||
|
||
|
||
if ! $CLICKHOUSE_CLIENT_BINARY -u default --password='1w2swhb1' --host 127.1 --port "$server_port" --format Null -q 'select 1'; then | ||
echo "Cannot wait until server will start accepting connections on <tcp_port>" >&2 | ||
exit 1 | ||
fi | ||
|
||
# This should fail. | ||
$CLICKHOUSE_CLIENT_BINARY -u u_3574 --password "" --host 127.1 --port "$server_port" -q "SELECT user(), ' should not appear '; -- { serverError 516 } --" &> /dev/null ; | ||
|
||
# send TERM and save the error code to ensure that it is 0 (EXIT_SUCCESS) | ||
kill $server_pid | ||
wait $server_pid | ||
return_code=$? | ||
|
||
rm -f clickhouse-server.stderr | ||
rm -f "$CURDIR"/users.xml | ||
|
||
exit $return_code |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.