You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@solr.apache.org by ep...@apache.org on 2024/02/26 20:41:12 UTC
(solr) branch branch_9x updated: SOLR-16780: Prevent ZK subcommands from being run without the bin/solr zk prefix (#2297)
This is an automated email from the ASF dual-hosted git repository.
epugh pushed a commit to branch branch_9x
in repository https://gitbox.apache.org/repos/asf/solr.git
The following commit(s) were added to refs/heads/branch_9x by this push:
new f03f3281148 SOLR-16780: Prevent ZK subcommands from being run without the bin/solr zk prefix (#2297)
f03f3281148 is described below
commit f03f3281148c46c5ee9a9f9f632acbc6ff91c8a2
Author: Eric Pugh <ep...@opensourceconnections.com>
AuthorDate: Mon Feb 26 15:38:58 2024 -0500
SOLR-16780: Prevent ZK subcommands from being run without the bin/solr zk prefix (#2297)
* Prevent zk subcommands to being run without the zk prefix!
---
solr/bin/solr | 6 ++++++
solr/packaging/test/test_zk.bats | 9 +++++++--
2 files changed, 13 insertions(+), 2 deletions(-)
diff --git a/solr/bin/solr b/solr/bin/solr
index f6ce4027f56..3de4c3ee938 100755
--- a/solr/bin/solr
+++ b/solr/bin/solr
@@ -1353,6 +1353,12 @@ if [[ "$SCRIPT_CMD" == "delete" ]]; then
exit $?
fi
+# Prevent any zk subcommands from going through with out invoking zk command
+if [[ "$SCRIPT_CMD" == "upconfig" || $SCRIPT_CMD == "downconfig" || $SCRIPT_CMD == "cp" || $SCRIPT_CMD == "rm" || $SCRIPT_CMD == "mv" || $SCRIPT_CMD == "ls" || $SCRIPT_CMD == "mkroot" ]]; then
+ print_short_zk_usage "You must invoke this subcommand using the zk command. bin/solr zk $SCRIPT_CMD."
+ exit $?
+fi
+
ZK_RECURSE=false
# Zookeeper file maintenance (upconfig, downconfig, files up/down etc.)
# It's a little clumsy to have the parsing go round and round for upconfig and downconfig, but that's
diff --git a/solr/packaging/test/test_zk.bats b/solr/packaging/test/test_zk.bats
index 06c0d75012d..65cb75a1390 100644
--- a/solr/packaging/test/test_zk.bats
+++ b/solr/packaging/test/test_zk.bats
@@ -36,6 +36,11 @@ teardown() {
save_home_on_failure
}
+@test "running subcommands with zk is prevented" {
+ run solr ls / -z localhost:${ZK_PORT}
+ assert_output --partial "You must invoke this subcommand using the zk command"
+}
+
@test "listing out files" {
sleep 1
run solr zk ls / -z localhost:${ZK_PORT}
@@ -44,8 +49,8 @@ teardown() {
@test "copying files around" {
touch myfile.txt
- # Umm, what is solr cp? It's like bin/solr zk cp but not?
- run solr cp -src myfile.txt -dst zk:/myfile.txt -z localhost:${ZK_PORT}
+
+ run solr zk cp myfile.txt zk:/myfile.txt -z localhost:${ZK_PORT}
assert_output --partial "Copying from 'myfile.txt' to 'zk:/myfile.txt'. ZooKeeper at localhost:${ZK_PORT}"
sleep 1
run solr zk ls / -z localhost:${ZK_PORT}