Skip to content
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

Fix MySQL ONLY_FULL_GROUP_BY #80

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion docker-compose.yml
Original file line number Diff line number Diff line change
Expand Up @@ -45,9 +45,10 @@ services:
# Database Configuration (And their defaults)
# - "MYSQL_HOST=db"
# - "MYSQL_USER=misp"
# - "MYSQL_PASSWORD=example" # NOTE: This should be AlphaNum with no Special Chars. Otherwise, edit config files after first run.
# - "MYSQL_PASSWORD=example" # NOTE: This should be AlphaNum with no Special Chars. Otherwise, edit config files after first run.
# - "MYSQL_DATABASE=misp"
# Optional Settings
# - "MYSQL_ROOT_PASSWORD=password" # Enable to allow fixing ONLY_FULL_GROUP_BY MySQL defaults
# - "NOREDIR=true" # Do not redirect port 80
# - "DISIPV6=true" # Disable IPV6 in nginx
# - "SECURESSL=true" # Enable higher security SSL in nginx
Expand Down
14 changes: 14 additions & 0 deletions server/files/entrypoint_nginx.sh
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ MISP_APP_CONFIG_PATH=/var/www/MISP/app/Config
[ -z "$REDIS_FQDN" ] && REDIS_FQDN=redis
[ -z "$MISP_MODULES_FQDN" ] && MISP_MODULES_FQDN="http://misp-modules"
[ -z "$MYSQLCMD" ] && MYSQLCMD="mysql -u $MYSQL_USER -p$MYSQL_PASSWORD -P $MYSQL_PORT -h $MYSQL_HOST -r -N $MYSQL_DATABASE"
[ -z "$MYSQLROOTCMD" ] && MYSQLROOTCMD="mysql -u root -p$MYSQL_ROOT_PASSWORD -P $MYSQL_PORT -h $MYSQL_HOST -r -N $MYSQL_DATABASE"

ENTRYPOINT_PID_FILE="/entrypoint_apache.install"
[ ! -f $ENTRYPOINT_PID_FILE ] && touch $ENTRYPOINT_PID_FILE
Expand Down Expand Up @@ -92,6 +93,19 @@ init_mysql(){
exit 1
fi

# If we're given the root password, disable the default sql_mode ONLY_FULL_GROUP_BY
# in MySQL. Required until https://github.com/MISP/MISP/issues/1894 is fixed
if [ -n "$MYSQL_ROOT_PASSWORD" ]; then
echo -n "Checking if ONLY_FULL_GROUP_BY mode is enabled..."
sql_mode=$(echo "SELECT @@sql_mode" | $MYSQLROOTCMD | grep "ONLY_FULL_GROUP_BY")
if [ -n "$sql_mode" ]; then
echo -e "\nDisabling MySQL default ONLY_FULL_GROUP_BY"
echo "SET GLOBAL sql_mode=(SELECT REPLACE(@@sql_mode,'ONLY_FULL_GROUP_BY',''));" | $MYSQLROOTCMD 1>/dev/null
else
echo " OK"
fi
fi

if [ $(isDBinitDone) -eq 0 ]; then
echo "Database has already been initialized"
else
Expand Down