prevent the command "cassandra start" from starting a cluster

patch by Robert Stupp; reviewed by Michael Shuler for CASSANDRA-8142
This commit is contained in:
Robert Stupp 2015-12-05 08:25:27 +01:00
parent 2f6a9f0bed
commit 425dc5f7dc
3 changed files with 20 additions and 2 deletions

View File

@ -1,4 +1,5 @@
3.2
* Prevent running Cassandra as root (CASSANDRA-8142)
* bound maximum in-flight commit log replay mutation bytes to 64 megabytes (CASSANDRA-8639)
* Normalize all scripts (CASSANDRA-10679)
* Make compression ratio much more accurate (CASSANDRA-10225)

View File

@ -25,6 +25,7 @@ New features
Upgrading
---------
- The compression ratio metrics computation has been modified to be more accurate.
- Running Cassandra as root is prevented by default.
3.1

View File

@ -211,7 +211,7 @@ launch_service()
}
# Parse any command line options.
args=`getopt vfhp:bD:H:E: "$@"`
args=`getopt vRfhp:bD:H:E: "$@"`
eval set -- "$args"
classname="org.apache.cassandra.service.CassandraDaemon"
@ -234,6 +234,10 @@ while true; do
"$JAVA" -cp "$CLASSPATH" org.apache.cassandra.tools.GetVersion
exit 0
;;
-R)
allow_root="yes"
shift
;;
-D)
properties="$properties -D$2"
shift 2
@ -248,15 +252,27 @@ while true; do
;;
--)
shift
if [ "x$*" != "x" ] ; then
echo "Error parsing arguments! Unknown argument \"$*\"" >&2
exit 1
fi
break
;;
*)
echo "Error parsing arguments!" >&2
echo "Error parsing arguments! Unknown argument \"$1\"" >&2
exit 1
;;
esac
done
if [ "x$allow_root" != "xyes" ] ; then
if [ "`id -u`" = "1" ] || [ "`id -g`" = "0" ] ; then
echo "Running Cassandra as root user or group is not recommended - please start Cassandra using a different system user."
echo "If you really want to force running Cassandra as root, use -R command line option."
exit 1
fi
fi
# see CASSANDRA-7254
"$JAVA" -cp "$CLASSPATH" $JVM_OPTS 2>&1 | grep -q 'Error: Exception thrown by the agent : java.lang.NullPointerException'
if [ $? -ne "1" ]; then