SOLR-7826: Refuse "bin/solr create" if run as root, unless -force is specified

This commit is contained in:
Jan Høydahl 2016-09-21 22:23:49 +02:00
parent b894ab292d
commit 7561461f73
2 changed files with 12 additions and 0 deletions

View File

@ -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 Fixes

View File

@ -696,6 +696,7 @@ if [[ "$SCRIPT_CMD" == "create" || "$SCRIPT_CMD" == "create_core" || "$SCRIPT_CM
CREATE_NUM_SHARDS=1
CREATE_REPFACT=1
FORCE=false
if [ $# -gt 0 ]; then
while true; do
@ -748,6 +749,10 @@ if [[ "$SCRIPT_CMD" == "create" || "$SCRIPT_CMD" == "create_core" || "$SCRIPT_CM
CREATE_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_CM
exit 1
fi
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
fi
if [ "$SCRIPT_CMD" == "create_core" ]; then
run_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"