Apache Lucene open-source search software
SOLR-7826: Refuse "bin/solr create" if run as root, unless -force is specified
Jan Høydahl7561461f738a
diff --git a/solr/CHANGES.txt b/solr/CHANGES.txtindex bf81f39a77a..0119917c778 100644--- a/solr/CHANGES.txt+++ b/solr/CHANGES.txt@@ -152,6 +152,8 @@ Other Changes* SOLR-9508: Install script install_solr_service.sh now checks existence of tools.New option -n to avoid starting service after installation (janhoy)+* SOLR-7826: Refuse "bin/solr create" if run as root, unless -force is specified (janhoy, Binoy Dalal)+================== 6.2.1 ==================Bug Fixesdiff --git a/solr/bin/solr b/solr/bin/solrindex 46903e7c3a1..e2a665d92cb 100755--- a/solr/bin/solr+++ b/solr/bin/solr@@ -696,6 +696,7 @@ if [[ "$SCRIPT_CMD" == "create" || "$SCRIPT_CMD" == "create_core" || "$SCRIPT_CMCREATE_NUM_SHARDS=1CREATE_REPFACT=1+ FORCE=falseif [ $# -gt 0 ]; thenwhile true; do@@ -748,6 +749,10 @@ if [[ "$SCRIPT_CMD" == "create" || "$SCRIPT_CMD" == "create_core" || "$SCRIPT_CMCREATE_PORT="$2"shift 2;;+ -force)+ FORCE=true+ shift+ ;;-help|-usage)print_usage "$SCRIPT_CMD"exit 0@@ -805,6 +810,11 @@ if [[ "$SCRIPT_CMD" == "create" || "$SCRIPT_CMD" == "create_core" || "$SCRIPT_CMexit 1fi+ if [[ "$(whoami)" == "root" ]] && [[ "$FORCE" == "false" ]] ; then+ echo "WARNING: Creating cores as the root user can cause Solr to fail and is not advisable. Exiting."+ echo " If you started Solr as root (not advisable either), force core creation by adding argument -force"+ exit 1+ fiif [ "$SCRIPT_CMD" == "create_core" ]; thenrun_tool create_core -name "$CREATE_NAME" -solrUrl "$SOLR_URL_SCHEME://$SOLR_TOOL_HOST:$CREATE_PORT/solr" \-confdir "$CREATE_CONFDIR" -configsetsDir "$SOLR_TIP/server/solr/configsets"