diff --git a/agent/alpine/docker-entrypoint.sh b/agent/alpine/docker-entrypoint.sh index 6e11befc2..ee8579425 100755 --- a/agent/alpine/docker-entrypoint.sh +++ b/agent/alpine/docker-entrypoint.sh @@ -49,6 +49,23 @@ prepare_system() { fi } +escape_spec_char() { + local var_value=$1 + + var_value="${var_value//\\/\\\\}" + var_value="${var_value//[$'\n']/}" + var_value="${var_value//\//\\/}" + var_value="${var_value//./\\.}" + var_value="${var_value//\*/\\*}" + var_value="${var_value//^/\\^}" + var_value="${var_value//\$/\\\$}" + var_value="${var_value//\&/\\\&}" + var_value="${var_value//\[/\\[}" + var_value="${var_value//\[/\\]}" + + echo $var_value +} + update_config_var() { local config_path=$1 local var_name=$2 @@ -81,8 +98,8 @@ update_config_var() { var_value=$ZABBIX_USER_HOME_DIR/enc/$var_value fi - # Escaping "/" character in parameter value - var_value=${var_value//\//\\/} + # Escaping characters in parameter value + var_value=$(escape_spec_char "$var_value") if [ "$(grep -E "^$var_name=" $config_path)" ] && [ "$is_multiple" != "true" ]; then sed -i -e "/^$var_name=/s/=.*/=$var_value/" "$config_path" @@ -703,15 +720,17 @@ prepare_zbx_web_config() { echo "**** Zabbix related PHP configuration file not found" fi - # Escaping "/" character in parameter value - server_name=${ZBX_SERVER_NAME//\//\\/} + # Escaping characters in parameter value + server_name=$(escape_spec_char "${ZBX_SERVER_NAME}") + server_user=$(escape_spec_char "${DB_SERVER_ZBX_USER}") + server_pass=$(escape_spec_char "${DB_SERVER_ZBX_PASS}") sed -i \ -e "s/{DB_SERVER_HOST}/${DB_SERVER_HOST}/g" \ -e "s/{DB_SERVER_PORT}/${DB_SERVER_PORT}/g" \ -e "s/{DB_SERVER_DBNAME}/${DB_SERVER_DBNAME}/g" \ - -e "s/{DB_SERVER_USER}/${DB_SERVER_ZBX_USER}/g" \ - -e "s/{DB_SERVER_PASS}/${DB_SERVER_ZBX_PASS}/g" \ + -e "s/{DB_SERVER_USER}/$server_user/g" \ + -e "s/{DB_SERVER_PASS}/$server_pass/g" \ -e "s/{ZBX_SERVER_HOST}/${ZBX_SERVER_HOST}/g" \ -e "s/{ZBX_SERVER_PORT}/${ZBX_SERVER_PORT}/g" \ -e "s/{ZBX_SERVER_NAME}/$server_name/g" \ diff --git a/agent/centos/docker-entrypoint.sh b/agent/centos/docker-entrypoint.sh index 6e11befc2..ee8579425 100755 --- a/agent/centos/docker-entrypoint.sh +++ b/agent/centos/docker-entrypoint.sh @@ -49,6 +49,23 @@ prepare_system() { fi } +escape_spec_char() { + local var_value=$1 + + var_value="${var_value//\\/\\\\}" + var_value="${var_value//[$'\n']/}" + var_value="${var_value//\//\\/}" + var_value="${var_value//./\\.}" + var_value="${var_value//\*/\\*}" + var_value="${var_value//^/\\^}" + var_value="${var_value//\$/\\\$}" + var_value="${var_value//\&/\\\&}" + var_value="${var_value//\[/\\[}" + var_value="${var_value//\[/\\]}" + + echo $var_value +} + update_config_var() { local config_path=$1 local var_name=$2 @@ -81,8 +98,8 @@ update_config_var() { var_value=$ZABBIX_USER_HOME_DIR/enc/$var_value fi - # Escaping "/" character in parameter value - var_value=${var_value//\//\\/} + # Escaping characters in parameter value + var_value=$(escape_spec_char "$var_value") if [ "$(grep -E "^$var_name=" $config_path)" ] && [ "$is_multiple" != "true" ]; then sed -i -e "/^$var_name=/s/=.*/=$var_value/" "$config_path" @@ -703,15 +720,17 @@ prepare_zbx_web_config() { echo "**** Zabbix related PHP configuration file not found" fi - # Escaping "/" character in parameter value - server_name=${ZBX_SERVER_NAME//\//\\/} + # Escaping characters in parameter value + server_name=$(escape_spec_char "${ZBX_SERVER_NAME}") + server_user=$(escape_spec_char "${DB_SERVER_ZBX_USER}") + server_pass=$(escape_spec_char "${DB_SERVER_ZBX_PASS}") sed -i \ -e "s/{DB_SERVER_HOST}/${DB_SERVER_HOST}/g" \ -e "s/{DB_SERVER_PORT}/${DB_SERVER_PORT}/g" \ -e "s/{DB_SERVER_DBNAME}/${DB_SERVER_DBNAME}/g" \ - -e "s/{DB_SERVER_USER}/${DB_SERVER_ZBX_USER}/g" \ - -e "s/{DB_SERVER_PASS}/${DB_SERVER_ZBX_PASS}/g" \ + -e "s/{DB_SERVER_USER}/$server_user/g" \ + -e "s/{DB_SERVER_PASS}/$server_pass/g" \ -e "s/{ZBX_SERVER_HOST}/${ZBX_SERVER_HOST}/g" \ -e "s/{ZBX_SERVER_PORT}/${ZBX_SERVER_PORT}/g" \ -e "s/{ZBX_SERVER_NAME}/$server_name/g" \ diff --git a/agent/ubuntu/docker-entrypoint.sh b/agent/ubuntu/docker-entrypoint.sh index 6e11befc2..ee8579425 100755 --- a/agent/ubuntu/docker-entrypoint.sh +++ b/agent/ubuntu/docker-entrypoint.sh @@ -49,6 +49,23 @@ prepare_system() { fi } +escape_spec_char() { + local var_value=$1 + + var_value="${var_value//\\/\\\\}" + var_value="${var_value//[$'\n']/}" + var_value="${var_value//\//\\/}" + var_value="${var_value//./\\.}" + var_value="${var_value//\*/\\*}" + var_value="${var_value//^/\\^}" + var_value="${var_value//\$/\\\$}" + var_value="${var_value//\&/\\\&}" + var_value="${var_value//\[/\\[}" + var_value="${var_value//\[/\\]}" + + echo $var_value +} + update_config_var() { local config_path=$1 local var_name=$2 @@ -81,8 +98,8 @@ update_config_var() { var_value=$ZABBIX_USER_HOME_DIR/enc/$var_value fi - # Escaping "/" character in parameter value - var_value=${var_value//\//\\/} + # Escaping characters in parameter value + var_value=$(escape_spec_char "$var_value") if [ "$(grep -E "^$var_name=" $config_path)" ] && [ "$is_multiple" != "true" ]; then sed -i -e "/^$var_name=/s/=.*/=$var_value/" "$config_path" @@ -703,15 +720,17 @@ prepare_zbx_web_config() { echo "**** Zabbix related PHP configuration file not found" fi - # Escaping "/" character in parameter value - server_name=${ZBX_SERVER_NAME//\//\\/} + # Escaping characters in parameter value + server_name=$(escape_spec_char "${ZBX_SERVER_NAME}") + server_user=$(escape_spec_char "${DB_SERVER_ZBX_USER}") + server_pass=$(escape_spec_char "${DB_SERVER_ZBX_PASS}") sed -i \ -e "s/{DB_SERVER_HOST}/${DB_SERVER_HOST}/g" \ -e "s/{DB_SERVER_PORT}/${DB_SERVER_PORT}/g" \ -e "s/{DB_SERVER_DBNAME}/${DB_SERVER_DBNAME}/g" \ - -e "s/{DB_SERVER_USER}/${DB_SERVER_ZBX_USER}/g" \ - -e "s/{DB_SERVER_PASS}/${DB_SERVER_ZBX_PASS}/g" \ + -e "s/{DB_SERVER_USER}/$server_user/g" \ + -e "s/{DB_SERVER_PASS}/$server_pass/g" \ -e "s/{ZBX_SERVER_HOST}/${ZBX_SERVER_HOST}/g" \ -e "s/{ZBX_SERVER_PORT}/${ZBX_SERVER_PORT}/g" \ -e "s/{ZBX_SERVER_NAME}/$server_name/g" \ diff --git a/java-gateway/alpine/docker-entrypoint.sh b/java-gateway/alpine/docker-entrypoint.sh index 6e11befc2..ee8579425 100755 --- a/java-gateway/alpine/docker-entrypoint.sh +++ b/java-gateway/alpine/docker-entrypoint.sh @@ -49,6 +49,23 @@ prepare_system() { fi } +escape_spec_char() { + local var_value=$1 + + var_value="${var_value//\\/\\\\}" + var_value="${var_value//[$'\n']/}" + var_value="${var_value//\//\\/}" + var_value="${var_value//./\\.}" + var_value="${var_value//\*/\\*}" + var_value="${var_value//^/\\^}" + var_value="${var_value//\$/\\\$}" + var_value="${var_value//\&/\\\&}" + var_value="${var_value//\[/\\[}" + var_value="${var_value//\[/\\]}" + + echo $var_value +} + update_config_var() { local config_path=$1 local var_name=$2 @@ -81,8 +98,8 @@ update_config_var() { var_value=$ZABBIX_USER_HOME_DIR/enc/$var_value fi - # Escaping "/" character in parameter value - var_value=${var_value//\//\\/} + # Escaping characters in parameter value + var_value=$(escape_spec_char "$var_value") if [ "$(grep -E "^$var_name=" $config_path)" ] && [ "$is_multiple" != "true" ]; then sed -i -e "/^$var_name=/s/=.*/=$var_value/" "$config_path" @@ -703,15 +720,17 @@ prepare_zbx_web_config() { echo "**** Zabbix related PHP configuration file not found" fi - # Escaping "/" character in parameter value - server_name=${ZBX_SERVER_NAME//\//\\/} + # Escaping characters in parameter value + server_name=$(escape_spec_char "${ZBX_SERVER_NAME}") + server_user=$(escape_spec_char "${DB_SERVER_ZBX_USER}") + server_pass=$(escape_spec_char "${DB_SERVER_ZBX_PASS}") sed -i \ -e "s/{DB_SERVER_HOST}/${DB_SERVER_HOST}/g" \ -e "s/{DB_SERVER_PORT}/${DB_SERVER_PORT}/g" \ -e "s/{DB_SERVER_DBNAME}/${DB_SERVER_DBNAME}/g" \ - -e "s/{DB_SERVER_USER}/${DB_SERVER_ZBX_USER}/g" \ - -e "s/{DB_SERVER_PASS}/${DB_SERVER_ZBX_PASS}/g" \ + -e "s/{DB_SERVER_USER}/$server_user/g" \ + -e "s/{DB_SERVER_PASS}/$server_pass/g" \ -e "s/{ZBX_SERVER_HOST}/${ZBX_SERVER_HOST}/g" \ -e "s/{ZBX_SERVER_PORT}/${ZBX_SERVER_PORT}/g" \ -e "s/{ZBX_SERVER_NAME}/$server_name/g" \ diff --git a/java-gateway/centos/docker-entrypoint.sh b/java-gateway/centos/docker-entrypoint.sh index 6e11befc2..ee8579425 100755 --- a/java-gateway/centos/docker-entrypoint.sh +++ b/java-gateway/centos/docker-entrypoint.sh @@ -49,6 +49,23 @@ prepare_system() { fi } +escape_spec_char() { + local var_value=$1 + + var_value="${var_value//\\/\\\\}" + var_value="${var_value//[$'\n']/}" + var_value="${var_value//\//\\/}" + var_value="${var_value//./\\.}" + var_value="${var_value//\*/\\*}" + var_value="${var_value//^/\\^}" + var_value="${var_value//\$/\\\$}" + var_value="${var_value//\&/\\\&}" + var_value="${var_value//\[/\\[}" + var_value="${var_value//\[/\\]}" + + echo $var_value +} + update_config_var() { local config_path=$1 local var_name=$2 @@ -81,8 +98,8 @@ update_config_var() { var_value=$ZABBIX_USER_HOME_DIR/enc/$var_value fi - # Escaping "/" character in parameter value - var_value=${var_value//\//\\/} + # Escaping characters in parameter value + var_value=$(escape_spec_char "$var_value") if [ "$(grep -E "^$var_name=" $config_path)" ] && [ "$is_multiple" != "true" ]; then sed -i -e "/^$var_name=/s/=.*/=$var_value/" "$config_path" @@ -703,15 +720,17 @@ prepare_zbx_web_config() { echo "**** Zabbix related PHP configuration file not found" fi - # Escaping "/" character in parameter value - server_name=${ZBX_SERVER_NAME//\//\\/} + # Escaping characters in parameter value + server_name=$(escape_spec_char "${ZBX_SERVER_NAME}") + server_user=$(escape_spec_char "${DB_SERVER_ZBX_USER}") + server_pass=$(escape_spec_char "${DB_SERVER_ZBX_PASS}") sed -i \ -e "s/{DB_SERVER_HOST}/${DB_SERVER_HOST}/g" \ -e "s/{DB_SERVER_PORT}/${DB_SERVER_PORT}/g" \ -e "s/{DB_SERVER_DBNAME}/${DB_SERVER_DBNAME}/g" \ - -e "s/{DB_SERVER_USER}/${DB_SERVER_ZBX_USER}/g" \ - -e "s/{DB_SERVER_PASS}/${DB_SERVER_ZBX_PASS}/g" \ + -e "s/{DB_SERVER_USER}/$server_user/g" \ + -e "s/{DB_SERVER_PASS}/$server_pass/g" \ -e "s/{ZBX_SERVER_HOST}/${ZBX_SERVER_HOST}/g" \ -e "s/{ZBX_SERVER_PORT}/${ZBX_SERVER_PORT}/g" \ -e "s/{ZBX_SERVER_NAME}/$server_name/g" \ diff --git a/java-gateway/ubuntu/conf/etc/supervisor/conf.d/supervisord_zabbix.conf b/java-gateway/ubuntu/conf/etc/supervisor/conf.d/supervisord_zabbix.conf deleted file mode 100644 index df9514bd1..000000000 --- a/java-gateway/ubuntu/conf/etc/supervisor/conf.d/supervisord_zabbix.conf +++ /dev/null @@ -1,17 +0,0 @@ -[supervisord] -nodaemon = true - -[program:zabbix_java_gateway] -command = /bin/bash /usr/sbin/%(program_name)s -user = zabbix -auto_start = true -autorestart = true - -startsecs=3 -startretries=3 -stopsignal=INT -stopwaitsecs=2 - -redirect_stderr=true -stdout_logfile = /dev/stdout -stdout_logfile_maxbytes = 0 diff --git a/java-gateway/ubuntu/conf/etc/supervisor/supervisord.conf b/java-gateway/ubuntu/conf/etc/supervisor/supervisord.conf deleted file mode 100644 index 925bb1838..000000000 --- a/java-gateway/ubuntu/conf/etc/supervisor/supervisord.conf +++ /dev/null @@ -1,35 +0,0 @@ -; supervisor config file - -[unix_http_server] -file = /var/run/supervisor.sock ; (the path to the socket file) -chmod = 0700 ; sockef file mode (default 0700) -username = zbx -password = password - -[supervisord] -logfile = /dev/stdout ; (main log file;default $CWD/supervisord.log) -pidfile = /var/run/supervisord.pid ; (supervisord pidfile;default supervisord.pid) -childlogdir = /tmp ; ('AUTO' child log dir, default $TEMP) -critical = critical -user = root -logfile_maxbytes = 0 -logfile_backupcount = 0 -loglevel = info - -; the below section must remain in the config file for RPC -; (supervisorctl/web interface) to work, additional interfaces may be -; added by defining them in separate rpcinterface: sections -[rpcinterface:supervisor] -supervisor.rpcinterface_factory = supervisor.rpcinterface:make_main_rpcinterface - -[supervisorctl] -serverurl = unix:///var/run/supervisor.sock ; use a unix:// URL for a unix socket - -; The [include] section can just contain the "files" setting. This -; setting can list multiple files (separated by whitespace or -; newlines). It can also contain wildcards. The filenames are -; interpreted as relative to this file. Included files *cannot* -; include files themselves. - -[include] -files = /etc/supervisor/conf.d/*.conf diff --git a/java-gateway/ubuntu/docker-entrypoint.sh b/java-gateway/ubuntu/docker-entrypoint.sh index 6e11befc2..ee8579425 100755 --- a/java-gateway/ubuntu/docker-entrypoint.sh +++ b/java-gateway/ubuntu/docker-entrypoint.sh @@ -49,6 +49,23 @@ prepare_system() { fi } +escape_spec_char() { + local var_value=$1 + + var_value="${var_value//\\/\\\\}" + var_value="${var_value//[$'\n']/}" + var_value="${var_value//\//\\/}" + var_value="${var_value//./\\.}" + var_value="${var_value//\*/\\*}" + var_value="${var_value//^/\\^}" + var_value="${var_value//\$/\\\$}" + var_value="${var_value//\&/\\\&}" + var_value="${var_value//\[/\\[}" + var_value="${var_value//\[/\\]}" + + echo $var_value +} + update_config_var() { local config_path=$1 local var_name=$2 @@ -81,8 +98,8 @@ update_config_var() { var_value=$ZABBIX_USER_HOME_DIR/enc/$var_value fi - # Escaping "/" character in parameter value - var_value=${var_value//\//\\/} + # Escaping characters in parameter value + var_value=$(escape_spec_char "$var_value") if [ "$(grep -E "^$var_name=" $config_path)" ] && [ "$is_multiple" != "true" ]; then sed -i -e "/^$var_name=/s/=.*/=$var_value/" "$config_path" @@ -703,15 +720,17 @@ prepare_zbx_web_config() { echo "**** Zabbix related PHP configuration file not found" fi - # Escaping "/" character in parameter value - server_name=${ZBX_SERVER_NAME//\//\\/} + # Escaping characters in parameter value + server_name=$(escape_spec_char "${ZBX_SERVER_NAME}") + server_user=$(escape_spec_char "${DB_SERVER_ZBX_USER}") + server_pass=$(escape_spec_char "${DB_SERVER_ZBX_PASS}") sed -i \ -e "s/{DB_SERVER_HOST}/${DB_SERVER_HOST}/g" \ -e "s/{DB_SERVER_PORT}/${DB_SERVER_PORT}/g" \ -e "s/{DB_SERVER_DBNAME}/${DB_SERVER_DBNAME}/g" \ - -e "s/{DB_SERVER_USER}/${DB_SERVER_ZBX_USER}/g" \ - -e "s/{DB_SERVER_PASS}/${DB_SERVER_ZBX_PASS}/g" \ + -e "s/{DB_SERVER_USER}/$server_user/g" \ + -e "s/{DB_SERVER_PASS}/$server_pass/g" \ -e "s/{ZBX_SERVER_HOST}/${ZBX_SERVER_HOST}/g" \ -e "s/{ZBX_SERVER_PORT}/${ZBX_SERVER_PORT}/g" \ -e "s/{ZBX_SERVER_NAME}/$server_name/g" \ diff --git a/proxy-mysql/alpine/docker-entrypoint.sh b/proxy-mysql/alpine/docker-entrypoint.sh index 6e11befc2..ee8579425 100755 --- a/proxy-mysql/alpine/docker-entrypoint.sh +++ b/proxy-mysql/alpine/docker-entrypoint.sh @@ -49,6 +49,23 @@ prepare_system() { fi } +escape_spec_char() { + local var_value=$1 + + var_value="${var_value//\\/\\\\}" + var_value="${var_value//[$'\n']/}" + var_value="${var_value//\//\\/}" + var_value="${var_value//./\\.}" + var_value="${var_value//\*/\\*}" + var_value="${var_value//^/\\^}" + var_value="${var_value//\$/\\\$}" + var_value="${var_value//\&/\\\&}" + var_value="${var_value//\[/\\[}" + var_value="${var_value//\[/\\]}" + + echo $var_value +} + update_config_var() { local config_path=$1 local var_name=$2 @@ -81,8 +98,8 @@ update_config_var() { var_value=$ZABBIX_USER_HOME_DIR/enc/$var_value fi - # Escaping "/" character in parameter value - var_value=${var_value//\//\\/} + # Escaping characters in parameter value + var_value=$(escape_spec_char "$var_value") if [ "$(grep -E "^$var_name=" $config_path)" ] && [ "$is_multiple" != "true" ]; then sed -i -e "/^$var_name=/s/=.*/=$var_value/" "$config_path" @@ -703,15 +720,17 @@ prepare_zbx_web_config() { echo "**** Zabbix related PHP configuration file not found" fi - # Escaping "/" character in parameter value - server_name=${ZBX_SERVER_NAME//\//\\/} + # Escaping characters in parameter value + server_name=$(escape_spec_char "${ZBX_SERVER_NAME}") + server_user=$(escape_spec_char "${DB_SERVER_ZBX_USER}") + server_pass=$(escape_spec_char "${DB_SERVER_ZBX_PASS}") sed -i \ -e "s/{DB_SERVER_HOST}/${DB_SERVER_HOST}/g" \ -e "s/{DB_SERVER_PORT}/${DB_SERVER_PORT}/g" \ -e "s/{DB_SERVER_DBNAME}/${DB_SERVER_DBNAME}/g" \ - -e "s/{DB_SERVER_USER}/${DB_SERVER_ZBX_USER}/g" \ - -e "s/{DB_SERVER_PASS}/${DB_SERVER_ZBX_PASS}/g" \ + -e "s/{DB_SERVER_USER}/$server_user/g" \ + -e "s/{DB_SERVER_PASS}/$server_pass/g" \ -e "s/{ZBX_SERVER_HOST}/${ZBX_SERVER_HOST}/g" \ -e "s/{ZBX_SERVER_PORT}/${ZBX_SERVER_PORT}/g" \ -e "s/{ZBX_SERVER_NAME}/$server_name/g" \ diff --git a/proxy-mysql/centos/docker-entrypoint.sh b/proxy-mysql/centos/docker-entrypoint.sh index 6e11befc2..ee8579425 100755 --- a/proxy-mysql/centos/docker-entrypoint.sh +++ b/proxy-mysql/centos/docker-entrypoint.sh @@ -49,6 +49,23 @@ prepare_system() { fi } +escape_spec_char() { + local var_value=$1 + + var_value="${var_value//\\/\\\\}" + var_value="${var_value//[$'\n']/}" + var_value="${var_value//\//\\/}" + var_value="${var_value//./\\.}" + var_value="${var_value//\*/\\*}" + var_value="${var_value//^/\\^}" + var_value="${var_value//\$/\\\$}" + var_value="${var_value//\&/\\\&}" + var_value="${var_value//\[/\\[}" + var_value="${var_value//\[/\\]}" + + echo $var_value +} + update_config_var() { local config_path=$1 local var_name=$2 @@ -81,8 +98,8 @@ update_config_var() { var_value=$ZABBIX_USER_HOME_DIR/enc/$var_value fi - # Escaping "/" character in parameter value - var_value=${var_value//\//\\/} + # Escaping characters in parameter value + var_value=$(escape_spec_char "$var_value") if [ "$(grep -E "^$var_name=" $config_path)" ] && [ "$is_multiple" != "true" ]; then sed -i -e "/^$var_name=/s/=.*/=$var_value/" "$config_path" @@ -703,15 +720,17 @@ prepare_zbx_web_config() { echo "**** Zabbix related PHP configuration file not found" fi - # Escaping "/" character in parameter value - server_name=${ZBX_SERVER_NAME//\//\\/} + # Escaping characters in parameter value + server_name=$(escape_spec_char "${ZBX_SERVER_NAME}") + server_user=$(escape_spec_char "${DB_SERVER_ZBX_USER}") + server_pass=$(escape_spec_char "${DB_SERVER_ZBX_PASS}") sed -i \ -e "s/{DB_SERVER_HOST}/${DB_SERVER_HOST}/g" \ -e "s/{DB_SERVER_PORT}/${DB_SERVER_PORT}/g" \ -e "s/{DB_SERVER_DBNAME}/${DB_SERVER_DBNAME}/g" \ - -e "s/{DB_SERVER_USER}/${DB_SERVER_ZBX_USER}/g" \ - -e "s/{DB_SERVER_PASS}/${DB_SERVER_ZBX_PASS}/g" \ + -e "s/{DB_SERVER_USER}/$server_user/g" \ + -e "s/{DB_SERVER_PASS}/$server_pass/g" \ -e "s/{ZBX_SERVER_HOST}/${ZBX_SERVER_HOST}/g" \ -e "s/{ZBX_SERVER_PORT}/${ZBX_SERVER_PORT}/g" \ -e "s/{ZBX_SERVER_NAME}/$server_name/g" \ diff --git a/proxy-mysql/ubuntu/docker-entrypoint.sh b/proxy-mysql/ubuntu/docker-entrypoint.sh index 6e11befc2..ee8579425 100755 --- a/proxy-mysql/ubuntu/docker-entrypoint.sh +++ b/proxy-mysql/ubuntu/docker-entrypoint.sh @@ -49,6 +49,23 @@ prepare_system() { fi } +escape_spec_char() { + local var_value=$1 + + var_value="${var_value//\\/\\\\}" + var_value="${var_value//[$'\n']/}" + var_value="${var_value//\//\\/}" + var_value="${var_value//./\\.}" + var_value="${var_value//\*/\\*}" + var_value="${var_value//^/\\^}" + var_value="${var_value//\$/\\\$}" + var_value="${var_value//\&/\\\&}" + var_value="${var_value//\[/\\[}" + var_value="${var_value//\[/\\]}" + + echo $var_value +} + update_config_var() { local config_path=$1 local var_name=$2 @@ -81,8 +98,8 @@ update_config_var() { var_value=$ZABBIX_USER_HOME_DIR/enc/$var_value fi - # Escaping "/" character in parameter value - var_value=${var_value//\//\\/} + # Escaping characters in parameter value + var_value=$(escape_spec_char "$var_value") if [ "$(grep -E "^$var_name=" $config_path)" ] && [ "$is_multiple" != "true" ]; then sed -i -e "/^$var_name=/s/=.*/=$var_value/" "$config_path" @@ -703,15 +720,17 @@ prepare_zbx_web_config() { echo "**** Zabbix related PHP configuration file not found" fi - # Escaping "/" character in parameter value - server_name=${ZBX_SERVER_NAME//\//\\/} + # Escaping characters in parameter value + server_name=$(escape_spec_char "${ZBX_SERVER_NAME}") + server_user=$(escape_spec_char "${DB_SERVER_ZBX_USER}") + server_pass=$(escape_spec_char "${DB_SERVER_ZBX_PASS}") sed -i \ -e "s/{DB_SERVER_HOST}/${DB_SERVER_HOST}/g" \ -e "s/{DB_SERVER_PORT}/${DB_SERVER_PORT}/g" \ -e "s/{DB_SERVER_DBNAME}/${DB_SERVER_DBNAME}/g" \ - -e "s/{DB_SERVER_USER}/${DB_SERVER_ZBX_USER}/g" \ - -e "s/{DB_SERVER_PASS}/${DB_SERVER_ZBX_PASS}/g" \ + -e "s/{DB_SERVER_USER}/$server_user/g" \ + -e "s/{DB_SERVER_PASS}/$server_pass/g" \ -e "s/{ZBX_SERVER_HOST}/${ZBX_SERVER_HOST}/g" \ -e "s/{ZBX_SERVER_PORT}/${ZBX_SERVER_PORT}/g" \ -e "s/{ZBX_SERVER_NAME}/$server_name/g" \ diff --git a/proxy-sqlite3/alpine/docker-entrypoint.sh b/proxy-sqlite3/alpine/docker-entrypoint.sh index 6e11befc2..ee8579425 100755 --- a/proxy-sqlite3/alpine/docker-entrypoint.sh +++ b/proxy-sqlite3/alpine/docker-entrypoint.sh @@ -49,6 +49,23 @@ prepare_system() { fi } +escape_spec_char() { + local var_value=$1 + + var_value="${var_value//\\/\\\\}" + var_value="${var_value//[$'\n']/}" + var_value="${var_value//\//\\/}" + var_value="${var_value//./\\.}" + var_value="${var_value//\*/\\*}" + var_value="${var_value//^/\\^}" + var_value="${var_value//\$/\\\$}" + var_value="${var_value//\&/\\\&}" + var_value="${var_value//\[/\\[}" + var_value="${var_value//\[/\\]}" + + echo $var_value +} + update_config_var() { local config_path=$1 local var_name=$2 @@ -81,8 +98,8 @@ update_config_var() { var_value=$ZABBIX_USER_HOME_DIR/enc/$var_value fi - # Escaping "/" character in parameter value - var_value=${var_value//\//\\/} + # Escaping characters in parameter value + var_value=$(escape_spec_char "$var_value") if [ "$(grep -E "^$var_name=" $config_path)" ] && [ "$is_multiple" != "true" ]; then sed -i -e "/^$var_name=/s/=.*/=$var_value/" "$config_path" @@ -703,15 +720,17 @@ prepare_zbx_web_config() { echo "**** Zabbix related PHP configuration file not found" fi - # Escaping "/" character in parameter value - server_name=${ZBX_SERVER_NAME//\//\\/} + # Escaping characters in parameter value + server_name=$(escape_spec_char "${ZBX_SERVER_NAME}") + server_user=$(escape_spec_char "${DB_SERVER_ZBX_USER}") + server_pass=$(escape_spec_char "${DB_SERVER_ZBX_PASS}") sed -i \ -e "s/{DB_SERVER_HOST}/${DB_SERVER_HOST}/g" \ -e "s/{DB_SERVER_PORT}/${DB_SERVER_PORT}/g" \ -e "s/{DB_SERVER_DBNAME}/${DB_SERVER_DBNAME}/g" \ - -e "s/{DB_SERVER_USER}/${DB_SERVER_ZBX_USER}/g" \ - -e "s/{DB_SERVER_PASS}/${DB_SERVER_ZBX_PASS}/g" \ + -e "s/{DB_SERVER_USER}/$server_user/g" \ + -e "s/{DB_SERVER_PASS}/$server_pass/g" \ -e "s/{ZBX_SERVER_HOST}/${ZBX_SERVER_HOST}/g" \ -e "s/{ZBX_SERVER_PORT}/${ZBX_SERVER_PORT}/g" \ -e "s/{ZBX_SERVER_NAME}/$server_name/g" \ diff --git a/proxy-sqlite3/centos/docker-entrypoint.sh b/proxy-sqlite3/centos/docker-entrypoint.sh index 6e11befc2..ee8579425 100755 --- a/proxy-sqlite3/centos/docker-entrypoint.sh +++ b/proxy-sqlite3/centos/docker-entrypoint.sh @@ -49,6 +49,23 @@ prepare_system() { fi } +escape_spec_char() { + local var_value=$1 + + var_value="${var_value//\\/\\\\}" + var_value="${var_value//[$'\n']/}" + var_value="${var_value//\//\\/}" + var_value="${var_value//./\\.}" + var_value="${var_value//\*/\\*}" + var_value="${var_value//^/\\^}" + var_value="${var_value//\$/\\\$}" + var_value="${var_value//\&/\\\&}" + var_value="${var_value//\[/\\[}" + var_value="${var_value//\[/\\]}" + + echo $var_value +} + update_config_var() { local config_path=$1 local var_name=$2 @@ -81,8 +98,8 @@ update_config_var() { var_value=$ZABBIX_USER_HOME_DIR/enc/$var_value fi - # Escaping "/" character in parameter value - var_value=${var_value//\//\\/} + # Escaping characters in parameter value + var_value=$(escape_spec_char "$var_value") if [ "$(grep -E "^$var_name=" $config_path)" ] && [ "$is_multiple" != "true" ]; then sed -i -e "/^$var_name=/s/=.*/=$var_value/" "$config_path" @@ -703,15 +720,17 @@ prepare_zbx_web_config() { echo "**** Zabbix related PHP configuration file not found" fi - # Escaping "/" character in parameter value - server_name=${ZBX_SERVER_NAME//\//\\/} + # Escaping characters in parameter value + server_name=$(escape_spec_char "${ZBX_SERVER_NAME}") + server_user=$(escape_spec_char "${DB_SERVER_ZBX_USER}") + server_pass=$(escape_spec_char "${DB_SERVER_ZBX_PASS}") sed -i \ -e "s/{DB_SERVER_HOST}/${DB_SERVER_HOST}/g" \ -e "s/{DB_SERVER_PORT}/${DB_SERVER_PORT}/g" \ -e "s/{DB_SERVER_DBNAME}/${DB_SERVER_DBNAME}/g" \ - -e "s/{DB_SERVER_USER}/${DB_SERVER_ZBX_USER}/g" \ - -e "s/{DB_SERVER_PASS}/${DB_SERVER_ZBX_PASS}/g" \ + -e "s/{DB_SERVER_USER}/$server_user/g" \ + -e "s/{DB_SERVER_PASS}/$server_pass/g" \ -e "s/{ZBX_SERVER_HOST}/${ZBX_SERVER_HOST}/g" \ -e "s/{ZBX_SERVER_PORT}/${ZBX_SERVER_PORT}/g" \ -e "s/{ZBX_SERVER_NAME}/$server_name/g" \ diff --git a/proxy-sqlite3/ubuntu/conf/etc/supervisor/conf.d/supervisord_zabbix.conf b/proxy-sqlite3/ubuntu/conf/etc/supervisor/conf.d/supervisord_zabbix.conf deleted file mode 100644 index 782a907a0..000000000 --- a/proxy-sqlite3/ubuntu/conf/etc/supervisor/conf.d/supervisord_zabbix.conf +++ /dev/null @@ -1,18 +0,0 @@ -[supervisord] -nodaemon = true - -[program:zabbix_proxy] -command = /usr/sbin/%(program_name)s --foreground -c /etc/zabbix/zabbix_proxy.conf -user = zabbix -auto_start = true -autorestart = true - -startsecs=5 -startretries=3 -stopsignal=INT -stopwaitsecs=5 - -redirect_stderr=true - -stdout_logfile = /dev/stdout -stdout_logfile_maxbytes = 0 diff --git a/proxy-sqlite3/ubuntu/conf/etc/supervisor/supervisord.conf b/proxy-sqlite3/ubuntu/conf/etc/supervisor/supervisord.conf deleted file mode 100644 index 925bb1838..000000000 --- a/proxy-sqlite3/ubuntu/conf/etc/supervisor/supervisord.conf +++ /dev/null @@ -1,35 +0,0 @@ -; supervisor config file - -[unix_http_server] -file = /var/run/supervisor.sock ; (the path to the socket file) -chmod = 0700 ; sockef file mode (default 0700) -username = zbx -password = password - -[supervisord] -logfile = /dev/stdout ; (main log file;default $CWD/supervisord.log) -pidfile = /var/run/supervisord.pid ; (supervisord pidfile;default supervisord.pid) -childlogdir = /tmp ; ('AUTO' child log dir, default $TEMP) -critical = critical -user = root -logfile_maxbytes = 0 -logfile_backupcount = 0 -loglevel = info - -; the below section must remain in the config file for RPC -; (supervisorctl/web interface) to work, additional interfaces may be -; added by defining them in separate rpcinterface: sections -[rpcinterface:supervisor] -supervisor.rpcinterface_factory = supervisor.rpcinterface:make_main_rpcinterface - -[supervisorctl] -serverurl = unix:///var/run/supervisor.sock ; use a unix:// URL for a unix socket - -; The [include] section can just contain the "files" setting. This -; setting can list multiple files (separated by whitespace or -; newlines). It can also contain wildcards. The filenames are -; interpreted as relative to this file. Included files *cannot* -; include files themselves. - -[include] -files = /etc/supervisor/conf.d/*.conf diff --git a/proxy-sqlite3/ubuntu/docker-entrypoint.sh b/proxy-sqlite3/ubuntu/docker-entrypoint.sh index 6e11befc2..ee8579425 100755 --- a/proxy-sqlite3/ubuntu/docker-entrypoint.sh +++ b/proxy-sqlite3/ubuntu/docker-entrypoint.sh @@ -49,6 +49,23 @@ prepare_system() { fi } +escape_spec_char() { + local var_value=$1 + + var_value="${var_value//\\/\\\\}" + var_value="${var_value//[$'\n']/}" + var_value="${var_value//\//\\/}" + var_value="${var_value//./\\.}" + var_value="${var_value//\*/\\*}" + var_value="${var_value//^/\\^}" + var_value="${var_value//\$/\\\$}" + var_value="${var_value//\&/\\\&}" + var_value="${var_value//\[/\\[}" + var_value="${var_value//\[/\\]}" + + echo $var_value +} + update_config_var() { local config_path=$1 local var_name=$2 @@ -81,8 +98,8 @@ update_config_var() { var_value=$ZABBIX_USER_HOME_DIR/enc/$var_value fi - # Escaping "/" character in parameter value - var_value=${var_value//\//\\/} + # Escaping characters in parameter value + var_value=$(escape_spec_char "$var_value") if [ "$(grep -E "^$var_name=" $config_path)" ] && [ "$is_multiple" != "true" ]; then sed -i -e "/^$var_name=/s/=.*/=$var_value/" "$config_path" @@ -703,15 +720,17 @@ prepare_zbx_web_config() { echo "**** Zabbix related PHP configuration file not found" fi - # Escaping "/" character in parameter value - server_name=${ZBX_SERVER_NAME//\//\\/} + # Escaping characters in parameter value + server_name=$(escape_spec_char "${ZBX_SERVER_NAME}") + server_user=$(escape_spec_char "${DB_SERVER_ZBX_USER}") + server_pass=$(escape_spec_char "${DB_SERVER_ZBX_PASS}") sed -i \ -e "s/{DB_SERVER_HOST}/${DB_SERVER_HOST}/g" \ -e "s/{DB_SERVER_PORT}/${DB_SERVER_PORT}/g" \ -e "s/{DB_SERVER_DBNAME}/${DB_SERVER_DBNAME}/g" \ - -e "s/{DB_SERVER_USER}/${DB_SERVER_ZBX_USER}/g" \ - -e "s/{DB_SERVER_PASS}/${DB_SERVER_ZBX_PASS}/g" \ + -e "s/{DB_SERVER_USER}/$server_user/g" \ + -e "s/{DB_SERVER_PASS}/$server_pass/g" \ -e "s/{ZBX_SERVER_HOST}/${ZBX_SERVER_HOST}/g" \ -e "s/{ZBX_SERVER_PORT}/${ZBX_SERVER_PORT}/g" \ -e "s/{ZBX_SERVER_NAME}/$server_name/g" \ diff --git a/server-mysql/alpine/docker-entrypoint.sh b/server-mysql/alpine/docker-entrypoint.sh index 6e11befc2..ee8579425 100755 --- a/server-mysql/alpine/docker-entrypoint.sh +++ b/server-mysql/alpine/docker-entrypoint.sh @@ -49,6 +49,23 @@ prepare_system() { fi } +escape_spec_char() { + local var_value=$1 + + var_value="${var_value//\\/\\\\}" + var_value="${var_value//[$'\n']/}" + var_value="${var_value//\//\\/}" + var_value="${var_value//./\\.}" + var_value="${var_value//\*/\\*}" + var_value="${var_value//^/\\^}" + var_value="${var_value//\$/\\\$}" + var_value="${var_value//\&/\\\&}" + var_value="${var_value//\[/\\[}" + var_value="${var_value//\[/\\]}" + + echo $var_value +} + update_config_var() { local config_path=$1 local var_name=$2 @@ -81,8 +98,8 @@ update_config_var() { var_value=$ZABBIX_USER_HOME_DIR/enc/$var_value fi - # Escaping "/" character in parameter value - var_value=${var_value//\//\\/} + # Escaping characters in parameter value + var_value=$(escape_spec_char "$var_value") if [ "$(grep -E "^$var_name=" $config_path)" ] && [ "$is_multiple" != "true" ]; then sed -i -e "/^$var_name=/s/=.*/=$var_value/" "$config_path" @@ -703,15 +720,17 @@ prepare_zbx_web_config() { echo "**** Zabbix related PHP configuration file not found" fi - # Escaping "/" character in parameter value - server_name=${ZBX_SERVER_NAME//\//\\/} + # Escaping characters in parameter value + server_name=$(escape_spec_char "${ZBX_SERVER_NAME}") + server_user=$(escape_spec_char "${DB_SERVER_ZBX_USER}") + server_pass=$(escape_spec_char "${DB_SERVER_ZBX_PASS}") sed -i \ -e "s/{DB_SERVER_HOST}/${DB_SERVER_HOST}/g" \ -e "s/{DB_SERVER_PORT}/${DB_SERVER_PORT}/g" \ -e "s/{DB_SERVER_DBNAME}/${DB_SERVER_DBNAME}/g" \ - -e "s/{DB_SERVER_USER}/${DB_SERVER_ZBX_USER}/g" \ - -e "s/{DB_SERVER_PASS}/${DB_SERVER_ZBX_PASS}/g" \ + -e "s/{DB_SERVER_USER}/$server_user/g" \ + -e "s/{DB_SERVER_PASS}/$server_pass/g" \ -e "s/{ZBX_SERVER_HOST}/${ZBX_SERVER_HOST}/g" \ -e "s/{ZBX_SERVER_PORT}/${ZBX_SERVER_PORT}/g" \ -e "s/{ZBX_SERVER_NAME}/$server_name/g" \ diff --git a/server-mysql/centos/docker-entrypoint.sh b/server-mysql/centos/docker-entrypoint.sh index 6e11befc2..ee8579425 100755 --- a/server-mysql/centos/docker-entrypoint.sh +++ b/server-mysql/centos/docker-entrypoint.sh @@ -49,6 +49,23 @@ prepare_system() { fi } +escape_spec_char() { + local var_value=$1 + + var_value="${var_value//\\/\\\\}" + var_value="${var_value//[$'\n']/}" + var_value="${var_value//\//\\/}" + var_value="${var_value//./\\.}" + var_value="${var_value//\*/\\*}" + var_value="${var_value//^/\\^}" + var_value="${var_value//\$/\\\$}" + var_value="${var_value//\&/\\\&}" + var_value="${var_value//\[/\\[}" + var_value="${var_value//\[/\\]}" + + echo $var_value +} + update_config_var() { local config_path=$1 local var_name=$2 @@ -81,8 +98,8 @@ update_config_var() { var_value=$ZABBIX_USER_HOME_DIR/enc/$var_value fi - # Escaping "/" character in parameter value - var_value=${var_value//\//\\/} + # Escaping characters in parameter value + var_value=$(escape_spec_char "$var_value") if [ "$(grep -E "^$var_name=" $config_path)" ] && [ "$is_multiple" != "true" ]; then sed -i -e "/^$var_name=/s/=.*/=$var_value/" "$config_path" @@ -703,15 +720,17 @@ prepare_zbx_web_config() { echo "**** Zabbix related PHP configuration file not found" fi - # Escaping "/" character in parameter value - server_name=${ZBX_SERVER_NAME//\//\\/} + # Escaping characters in parameter value + server_name=$(escape_spec_char "${ZBX_SERVER_NAME}") + server_user=$(escape_spec_char "${DB_SERVER_ZBX_USER}") + server_pass=$(escape_spec_char "${DB_SERVER_ZBX_PASS}") sed -i \ -e "s/{DB_SERVER_HOST}/${DB_SERVER_HOST}/g" \ -e "s/{DB_SERVER_PORT}/${DB_SERVER_PORT}/g" \ -e "s/{DB_SERVER_DBNAME}/${DB_SERVER_DBNAME}/g" \ - -e "s/{DB_SERVER_USER}/${DB_SERVER_ZBX_USER}/g" \ - -e "s/{DB_SERVER_PASS}/${DB_SERVER_ZBX_PASS}/g" \ + -e "s/{DB_SERVER_USER}/$server_user/g" \ + -e "s/{DB_SERVER_PASS}/$server_pass/g" \ -e "s/{ZBX_SERVER_HOST}/${ZBX_SERVER_HOST}/g" \ -e "s/{ZBX_SERVER_PORT}/${ZBX_SERVER_PORT}/g" \ -e "s/{ZBX_SERVER_NAME}/$server_name/g" \ diff --git a/server-mysql/ubuntu/docker-entrypoint.sh b/server-mysql/ubuntu/docker-entrypoint.sh index 6e11befc2..ee8579425 100755 --- a/server-mysql/ubuntu/docker-entrypoint.sh +++ b/server-mysql/ubuntu/docker-entrypoint.sh @@ -49,6 +49,23 @@ prepare_system() { fi } +escape_spec_char() { + local var_value=$1 + + var_value="${var_value//\\/\\\\}" + var_value="${var_value//[$'\n']/}" + var_value="${var_value//\//\\/}" + var_value="${var_value//./\\.}" + var_value="${var_value//\*/\\*}" + var_value="${var_value//^/\\^}" + var_value="${var_value//\$/\\\$}" + var_value="${var_value//\&/\\\&}" + var_value="${var_value//\[/\\[}" + var_value="${var_value//\[/\\]}" + + echo $var_value +} + update_config_var() { local config_path=$1 local var_name=$2 @@ -81,8 +98,8 @@ update_config_var() { var_value=$ZABBIX_USER_HOME_DIR/enc/$var_value fi - # Escaping "/" character in parameter value - var_value=${var_value//\//\\/} + # Escaping characters in parameter value + var_value=$(escape_spec_char "$var_value") if [ "$(grep -E "^$var_name=" $config_path)" ] && [ "$is_multiple" != "true" ]; then sed -i -e "/^$var_name=/s/=.*/=$var_value/" "$config_path" @@ -703,15 +720,17 @@ prepare_zbx_web_config() { echo "**** Zabbix related PHP configuration file not found" fi - # Escaping "/" character in parameter value - server_name=${ZBX_SERVER_NAME//\//\\/} + # Escaping characters in parameter value + server_name=$(escape_spec_char "${ZBX_SERVER_NAME}") + server_user=$(escape_spec_char "${DB_SERVER_ZBX_USER}") + server_pass=$(escape_spec_char "${DB_SERVER_ZBX_PASS}") sed -i \ -e "s/{DB_SERVER_HOST}/${DB_SERVER_HOST}/g" \ -e "s/{DB_SERVER_PORT}/${DB_SERVER_PORT}/g" \ -e "s/{DB_SERVER_DBNAME}/${DB_SERVER_DBNAME}/g" \ - -e "s/{DB_SERVER_USER}/${DB_SERVER_ZBX_USER}/g" \ - -e "s/{DB_SERVER_PASS}/${DB_SERVER_ZBX_PASS}/g" \ + -e "s/{DB_SERVER_USER}/$server_user/g" \ + -e "s/{DB_SERVER_PASS}/$server_pass/g" \ -e "s/{ZBX_SERVER_HOST}/${ZBX_SERVER_HOST}/g" \ -e "s/{ZBX_SERVER_PORT}/${ZBX_SERVER_PORT}/g" \ -e "s/{ZBX_SERVER_NAME}/$server_name/g" \ diff --git a/server-pgsql/alpine/docker-entrypoint.sh b/server-pgsql/alpine/docker-entrypoint.sh index 6e11befc2..ee8579425 100755 --- a/server-pgsql/alpine/docker-entrypoint.sh +++ b/server-pgsql/alpine/docker-entrypoint.sh @@ -49,6 +49,23 @@ prepare_system() { fi } +escape_spec_char() { + local var_value=$1 + + var_value="${var_value//\\/\\\\}" + var_value="${var_value//[$'\n']/}" + var_value="${var_value//\//\\/}" + var_value="${var_value//./\\.}" + var_value="${var_value//\*/\\*}" + var_value="${var_value//^/\\^}" + var_value="${var_value//\$/\\\$}" + var_value="${var_value//\&/\\\&}" + var_value="${var_value//\[/\\[}" + var_value="${var_value//\[/\\]}" + + echo $var_value +} + update_config_var() { local config_path=$1 local var_name=$2 @@ -81,8 +98,8 @@ update_config_var() { var_value=$ZABBIX_USER_HOME_DIR/enc/$var_value fi - # Escaping "/" character in parameter value - var_value=${var_value//\//\\/} + # Escaping characters in parameter value + var_value=$(escape_spec_char "$var_value") if [ "$(grep -E "^$var_name=" $config_path)" ] && [ "$is_multiple" != "true" ]; then sed -i -e "/^$var_name=/s/=.*/=$var_value/" "$config_path" @@ -703,15 +720,17 @@ prepare_zbx_web_config() { echo "**** Zabbix related PHP configuration file not found" fi - # Escaping "/" character in parameter value - server_name=${ZBX_SERVER_NAME//\//\\/} + # Escaping characters in parameter value + server_name=$(escape_spec_char "${ZBX_SERVER_NAME}") + server_user=$(escape_spec_char "${DB_SERVER_ZBX_USER}") + server_pass=$(escape_spec_char "${DB_SERVER_ZBX_PASS}") sed -i \ -e "s/{DB_SERVER_HOST}/${DB_SERVER_HOST}/g" \ -e "s/{DB_SERVER_PORT}/${DB_SERVER_PORT}/g" \ -e "s/{DB_SERVER_DBNAME}/${DB_SERVER_DBNAME}/g" \ - -e "s/{DB_SERVER_USER}/${DB_SERVER_ZBX_USER}/g" \ - -e "s/{DB_SERVER_PASS}/${DB_SERVER_ZBX_PASS}/g" \ + -e "s/{DB_SERVER_USER}/$server_user/g" \ + -e "s/{DB_SERVER_PASS}/$server_pass/g" \ -e "s/{ZBX_SERVER_HOST}/${ZBX_SERVER_HOST}/g" \ -e "s/{ZBX_SERVER_PORT}/${ZBX_SERVER_PORT}/g" \ -e "s/{ZBX_SERVER_NAME}/$server_name/g" \ diff --git a/server-pgsql/centos/docker-entrypoint.sh b/server-pgsql/centos/docker-entrypoint.sh index 6e11befc2..ee8579425 100755 --- a/server-pgsql/centos/docker-entrypoint.sh +++ b/server-pgsql/centos/docker-entrypoint.sh @@ -49,6 +49,23 @@ prepare_system() { fi } +escape_spec_char() { + local var_value=$1 + + var_value="${var_value//\\/\\\\}" + var_value="${var_value//[$'\n']/}" + var_value="${var_value//\//\\/}" + var_value="${var_value//./\\.}" + var_value="${var_value//\*/\\*}" + var_value="${var_value//^/\\^}" + var_value="${var_value//\$/\\\$}" + var_value="${var_value//\&/\\\&}" + var_value="${var_value//\[/\\[}" + var_value="${var_value//\[/\\]}" + + echo $var_value +} + update_config_var() { local config_path=$1 local var_name=$2 @@ -81,8 +98,8 @@ update_config_var() { var_value=$ZABBIX_USER_HOME_DIR/enc/$var_value fi - # Escaping "/" character in parameter value - var_value=${var_value//\//\\/} + # Escaping characters in parameter value + var_value=$(escape_spec_char "$var_value") if [ "$(grep -E "^$var_name=" $config_path)" ] && [ "$is_multiple" != "true" ]; then sed -i -e "/^$var_name=/s/=.*/=$var_value/" "$config_path" @@ -703,15 +720,17 @@ prepare_zbx_web_config() { echo "**** Zabbix related PHP configuration file not found" fi - # Escaping "/" character in parameter value - server_name=${ZBX_SERVER_NAME//\//\\/} + # Escaping characters in parameter value + server_name=$(escape_spec_char "${ZBX_SERVER_NAME}") + server_user=$(escape_spec_char "${DB_SERVER_ZBX_USER}") + server_pass=$(escape_spec_char "${DB_SERVER_ZBX_PASS}") sed -i \ -e "s/{DB_SERVER_HOST}/${DB_SERVER_HOST}/g" \ -e "s/{DB_SERVER_PORT}/${DB_SERVER_PORT}/g" \ -e "s/{DB_SERVER_DBNAME}/${DB_SERVER_DBNAME}/g" \ - -e "s/{DB_SERVER_USER}/${DB_SERVER_ZBX_USER}/g" \ - -e "s/{DB_SERVER_PASS}/${DB_SERVER_ZBX_PASS}/g" \ + -e "s/{DB_SERVER_USER}/$server_user/g" \ + -e "s/{DB_SERVER_PASS}/$server_pass/g" \ -e "s/{ZBX_SERVER_HOST}/${ZBX_SERVER_HOST}/g" \ -e "s/{ZBX_SERVER_PORT}/${ZBX_SERVER_PORT}/g" \ -e "s/{ZBX_SERVER_NAME}/$server_name/g" \ diff --git a/server-pgsql/ubuntu/docker-entrypoint.sh b/server-pgsql/ubuntu/docker-entrypoint.sh index 6e11befc2..ee8579425 100755 --- a/server-pgsql/ubuntu/docker-entrypoint.sh +++ b/server-pgsql/ubuntu/docker-entrypoint.sh @@ -49,6 +49,23 @@ prepare_system() { fi } +escape_spec_char() { + local var_value=$1 + + var_value="${var_value//\\/\\\\}" + var_value="${var_value//[$'\n']/}" + var_value="${var_value//\//\\/}" + var_value="${var_value//./\\.}" + var_value="${var_value//\*/\\*}" + var_value="${var_value//^/\\^}" + var_value="${var_value//\$/\\\$}" + var_value="${var_value//\&/\\\&}" + var_value="${var_value//\[/\\[}" + var_value="${var_value//\[/\\]}" + + echo $var_value +} + update_config_var() { local config_path=$1 local var_name=$2 @@ -81,8 +98,8 @@ update_config_var() { var_value=$ZABBIX_USER_HOME_DIR/enc/$var_value fi - # Escaping "/" character in parameter value - var_value=${var_value//\//\\/} + # Escaping characters in parameter value + var_value=$(escape_spec_char "$var_value") if [ "$(grep -E "^$var_name=" $config_path)" ] && [ "$is_multiple" != "true" ]; then sed -i -e "/^$var_name=/s/=.*/=$var_value/" "$config_path" @@ -703,15 +720,17 @@ prepare_zbx_web_config() { echo "**** Zabbix related PHP configuration file not found" fi - # Escaping "/" character in parameter value - server_name=${ZBX_SERVER_NAME//\//\\/} + # Escaping characters in parameter value + server_name=$(escape_spec_char "${ZBX_SERVER_NAME}") + server_user=$(escape_spec_char "${DB_SERVER_ZBX_USER}") + server_pass=$(escape_spec_char "${DB_SERVER_ZBX_PASS}") sed -i \ -e "s/{DB_SERVER_HOST}/${DB_SERVER_HOST}/g" \ -e "s/{DB_SERVER_PORT}/${DB_SERVER_PORT}/g" \ -e "s/{DB_SERVER_DBNAME}/${DB_SERVER_DBNAME}/g" \ - -e "s/{DB_SERVER_USER}/${DB_SERVER_ZBX_USER}/g" \ - -e "s/{DB_SERVER_PASS}/${DB_SERVER_ZBX_PASS}/g" \ + -e "s/{DB_SERVER_USER}/$server_user/g" \ + -e "s/{DB_SERVER_PASS}/$server_pass/g" \ -e "s/{ZBX_SERVER_HOST}/${ZBX_SERVER_HOST}/g" \ -e "s/{ZBX_SERVER_PORT}/${ZBX_SERVER_PORT}/g" \ -e "s/{ZBX_SERVER_NAME}/$server_name/g" \ diff --git a/web-apache-mysql/alpine/docker-entrypoint.sh b/web-apache-mysql/alpine/docker-entrypoint.sh index 6e11befc2..ee8579425 100755 --- a/web-apache-mysql/alpine/docker-entrypoint.sh +++ b/web-apache-mysql/alpine/docker-entrypoint.sh @@ -49,6 +49,23 @@ prepare_system() { fi } +escape_spec_char() { + local var_value=$1 + + var_value="${var_value//\\/\\\\}" + var_value="${var_value//[$'\n']/}" + var_value="${var_value//\//\\/}" + var_value="${var_value//./\\.}" + var_value="${var_value//\*/\\*}" + var_value="${var_value//^/\\^}" + var_value="${var_value//\$/\\\$}" + var_value="${var_value//\&/\\\&}" + var_value="${var_value//\[/\\[}" + var_value="${var_value//\[/\\]}" + + echo $var_value +} + update_config_var() { local config_path=$1 local var_name=$2 @@ -81,8 +98,8 @@ update_config_var() { var_value=$ZABBIX_USER_HOME_DIR/enc/$var_value fi - # Escaping "/" character in parameter value - var_value=${var_value//\//\\/} + # Escaping characters in parameter value + var_value=$(escape_spec_char "$var_value") if [ "$(grep -E "^$var_name=" $config_path)" ] && [ "$is_multiple" != "true" ]; then sed -i -e "/^$var_name=/s/=.*/=$var_value/" "$config_path" @@ -703,15 +720,17 @@ prepare_zbx_web_config() { echo "**** Zabbix related PHP configuration file not found" fi - # Escaping "/" character in parameter value - server_name=${ZBX_SERVER_NAME//\//\\/} + # Escaping characters in parameter value + server_name=$(escape_spec_char "${ZBX_SERVER_NAME}") + server_user=$(escape_spec_char "${DB_SERVER_ZBX_USER}") + server_pass=$(escape_spec_char "${DB_SERVER_ZBX_PASS}") sed -i \ -e "s/{DB_SERVER_HOST}/${DB_SERVER_HOST}/g" \ -e "s/{DB_SERVER_PORT}/${DB_SERVER_PORT}/g" \ -e "s/{DB_SERVER_DBNAME}/${DB_SERVER_DBNAME}/g" \ - -e "s/{DB_SERVER_USER}/${DB_SERVER_ZBX_USER}/g" \ - -e "s/{DB_SERVER_PASS}/${DB_SERVER_ZBX_PASS}/g" \ + -e "s/{DB_SERVER_USER}/$server_user/g" \ + -e "s/{DB_SERVER_PASS}/$server_pass/g" \ -e "s/{ZBX_SERVER_HOST}/${ZBX_SERVER_HOST}/g" \ -e "s/{ZBX_SERVER_PORT}/${ZBX_SERVER_PORT}/g" \ -e "s/{ZBX_SERVER_NAME}/$server_name/g" \ diff --git a/web-apache-mysql/centos/docker-entrypoint.sh b/web-apache-mysql/centos/docker-entrypoint.sh index 6e11befc2..ee8579425 100755 --- a/web-apache-mysql/centos/docker-entrypoint.sh +++ b/web-apache-mysql/centos/docker-entrypoint.sh @@ -49,6 +49,23 @@ prepare_system() { fi } +escape_spec_char() { + local var_value=$1 + + var_value="${var_value//\\/\\\\}" + var_value="${var_value//[$'\n']/}" + var_value="${var_value//\//\\/}" + var_value="${var_value//./\\.}" + var_value="${var_value//\*/\\*}" + var_value="${var_value//^/\\^}" + var_value="${var_value//\$/\\\$}" + var_value="${var_value//\&/\\\&}" + var_value="${var_value//\[/\\[}" + var_value="${var_value//\[/\\]}" + + echo $var_value +} + update_config_var() { local config_path=$1 local var_name=$2 @@ -81,8 +98,8 @@ update_config_var() { var_value=$ZABBIX_USER_HOME_DIR/enc/$var_value fi - # Escaping "/" character in parameter value - var_value=${var_value//\//\\/} + # Escaping characters in parameter value + var_value=$(escape_spec_char "$var_value") if [ "$(grep -E "^$var_name=" $config_path)" ] && [ "$is_multiple" != "true" ]; then sed -i -e "/^$var_name=/s/=.*/=$var_value/" "$config_path" @@ -703,15 +720,17 @@ prepare_zbx_web_config() { echo "**** Zabbix related PHP configuration file not found" fi - # Escaping "/" character in parameter value - server_name=${ZBX_SERVER_NAME//\//\\/} + # Escaping characters in parameter value + server_name=$(escape_spec_char "${ZBX_SERVER_NAME}") + server_user=$(escape_spec_char "${DB_SERVER_ZBX_USER}") + server_pass=$(escape_spec_char "${DB_SERVER_ZBX_PASS}") sed -i \ -e "s/{DB_SERVER_HOST}/${DB_SERVER_HOST}/g" \ -e "s/{DB_SERVER_PORT}/${DB_SERVER_PORT}/g" \ -e "s/{DB_SERVER_DBNAME}/${DB_SERVER_DBNAME}/g" \ - -e "s/{DB_SERVER_USER}/${DB_SERVER_ZBX_USER}/g" \ - -e "s/{DB_SERVER_PASS}/${DB_SERVER_ZBX_PASS}/g" \ + -e "s/{DB_SERVER_USER}/$server_user/g" \ + -e "s/{DB_SERVER_PASS}/$server_pass/g" \ -e "s/{ZBX_SERVER_HOST}/${ZBX_SERVER_HOST}/g" \ -e "s/{ZBX_SERVER_PORT}/${ZBX_SERVER_PORT}/g" \ -e "s/{ZBX_SERVER_NAME}/$server_name/g" \ diff --git a/web-apache-mysql/ubuntu/docker-entrypoint.sh b/web-apache-mysql/ubuntu/docker-entrypoint.sh index 6e11befc2..ee8579425 100755 --- a/web-apache-mysql/ubuntu/docker-entrypoint.sh +++ b/web-apache-mysql/ubuntu/docker-entrypoint.sh @@ -49,6 +49,23 @@ prepare_system() { fi } +escape_spec_char() { + local var_value=$1 + + var_value="${var_value//\\/\\\\}" + var_value="${var_value//[$'\n']/}" + var_value="${var_value//\//\\/}" + var_value="${var_value//./\\.}" + var_value="${var_value//\*/\\*}" + var_value="${var_value//^/\\^}" + var_value="${var_value//\$/\\\$}" + var_value="${var_value//\&/\\\&}" + var_value="${var_value//\[/\\[}" + var_value="${var_value//\[/\\]}" + + echo $var_value +} + update_config_var() { local config_path=$1 local var_name=$2 @@ -81,8 +98,8 @@ update_config_var() { var_value=$ZABBIX_USER_HOME_DIR/enc/$var_value fi - # Escaping "/" character in parameter value - var_value=${var_value//\//\\/} + # Escaping characters in parameter value + var_value=$(escape_spec_char "$var_value") if [ "$(grep -E "^$var_name=" $config_path)" ] && [ "$is_multiple" != "true" ]; then sed -i -e "/^$var_name=/s/=.*/=$var_value/" "$config_path" @@ -703,15 +720,17 @@ prepare_zbx_web_config() { echo "**** Zabbix related PHP configuration file not found" fi - # Escaping "/" character in parameter value - server_name=${ZBX_SERVER_NAME//\//\\/} + # Escaping characters in parameter value + server_name=$(escape_spec_char "${ZBX_SERVER_NAME}") + server_user=$(escape_spec_char "${DB_SERVER_ZBX_USER}") + server_pass=$(escape_spec_char "${DB_SERVER_ZBX_PASS}") sed -i \ -e "s/{DB_SERVER_HOST}/${DB_SERVER_HOST}/g" \ -e "s/{DB_SERVER_PORT}/${DB_SERVER_PORT}/g" \ -e "s/{DB_SERVER_DBNAME}/${DB_SERVER_DBNAME}/g" \ - -e "s/{DB_SERVER_USER}/${DB_SERVER_ZBX_USER}/g" \ - -e "s/{DB_SERVER_PASS}/${DB_SERVER_ZBX_PASS}/g" \ + -e "s/{DB_SERVER_USER}/$server_user/g" \ + -e "s/{DB_SERVER_PASS}/$server_pass/g" \ -e "s/{ZBX_SERVER_HOST}/${ZBX_SERVER_HOST}/g" \ -e "s/{ZBX_SERVER_PORT}/${ZBX_SERVER_PORT}/g" \ -e "s/{ZBX_SERVER_NAME}/$server_name/g" \ diff --git a/web-apache-pgsql/alpine/docker-entrypoint.sh b/web-apache-pgsql/alpine/docker-entrypoint.sh index 6e11befc2..ee8579425 100755 --- a/web-apache-pgsql/alpine/docker-entrypoint.sh +++ b/web-apache-pgsql/alpine/docker-entrypoint.sh @@ -49,6 +49,23 @@ prepare_system() { fi } +escape_spec_char() { + local var_value=$1 + + var_value="${var_value//\\/\\\\}" + var_value="${var_value//[$'\n']/}" + var_value="${var_value//\//\\/}" + var_value="${var_value//./\\.}" + var_value="${var_value//\*/\\*}" + var_value="${var_value//^/\\^}" + var_value="${var_value//\$/\\\$}" + var_value="${var_value//\&/\\\&}" + var_value="${var_value//\[/\\[}" + var_value="${var_value//\[/\\]}" + + echo $var_value +} + update_config_var() { local config_path=$1 local var_name=$2 @@ -81,8 +98,8 @@ update_config_var() { var_value=$ZABBIX_USER_HOME_DIR/enc/$var_value fi - # Escaping "/" character in parameter value - var_value=${var_value//\//\\/} + # Escaping characters in parameter value + var_value=$(escape_spec_char "$var_value") if [ "$(grep -E "^$var_name=" $config_path)" ] && [ "$is_multiple" != "true" ]; then sed -i -e "/^$var_name=/s/=.*/=$var_value/" "$config_path" @@ -703,15 +720,17 @@ prepare_zbx_web_config() { echo "**** Zabbix related PHP configuration file not found" fi - # Escaping "/" character in parameter value - server_name=${ZBX_SERVER_NAME//\//\\/} + # Escaping characters in parameter value + server_name=$(escape_spec_char "${ZBX_SERVER_NAME}") + server_user=$(escape_spec_char "${DB_SERVER_ZBX_USER}") + server_pass=$(escape_spec_char "${DB_SERVER_ZBX_PASS}") sed -i \ -e "s/{DB_SERVER_HOST}/${DB_SERVER_HOST}/g" \ -e "s/{DB_SERVER_PORT}/${DB_SERVER_PORT}/g" \ -e "s/{DB_SERVER_DBNAME}/${DB_SERVER_DBNAME}/g" \ - -e "s/{DB_SERVER_USER}/${DB_SERVER_ZBX_USER}/g" \ - -e "s/{DB_SERVER_PASS}/${DB_SERVER_ZBX_PASS}/g" \ + -e "s/{DB_SERVER_USER}/$server_user/g" \ + -e "s/{DB_SERVER_PASS}/$server_pass/g" \ -e "s/{ZBX_SERVER_HOST}/${ZBX_SERVER_HOST}/g" \ -e "s/{ZBX_SERVER_PORT}/${ZBX_SERVER_PORT}/g" \ -e "s/{ZBX_SERVER_NAME}/$server_name/g" \ diff --git a/web-apache-pgsql/centos/docker-entrypoint.sh b/web-apache-pgsql/centos/docker-entrypoint.sh index 6e11befc2..ee8579425 100755 --- a/web-apache-pgsql/centos/docker-entrypoint.sh +++ b/web-apache-pgsql/centos/docker-entrypoint.sh @@ -49,6 +49,23 @@ prepare_system() { fi } +escape_spec_char() { + local var_value=$1 + + var_value="${var_value//\\/\\\\}" + var_value="${var_value//[$'\n']/}" + var_value="${var_value//\//\\/}" + var_value="${var_value//./\\.}" + var_value="${var_value//\*/\\*}" + var_value="${var_value//^/\\^}" + var_value="${var_value//\$/\\\$}" + var_value="${var_value//\&/\\\&}" + var_value="${var_value//\[/\\[}" + var_value="${var_value//\[/\\]}" + + echo $var_value +} + update_config_var() { local config_path=$1 local var_name=$2 @@ -81,8 +98,8 @@ update_config_var() { var_value=$ZABBIX_USER_HOME_DIR/enc/$var_value fi - # Escaping "/" character in parameter value - var_value=${var_value//\//\\/} + # Escaping characters in parameter value + var_value=$(escape_spec_char "$var_value") if [ "$(grep -E "^$var_name=" $config_path)" ] && [ "$is_multiple" != "true" ]; then sed -i -e "/^$var_name=/s/=.*/=$var_value/" "$config_path" @@ -703,15 +720,17 @@ prepare_zbx_web_config() { echo "**** Zabbix related PHP configuration file not found" fi - # Escaping "/" character in parameter value - server_name=${ZBX_SERVER_NAME//\//\\/} + # Escaping characters in parameter value + server_name=$(escape_spec_char "${ZBX_SERVER_NAME}") + server_user=$(escape_spec_char "${DB_SERVER_ZBX_USER}") + server_pass=$(escape_spec_char "${DB_SERVER_ZBX_PASS}") sed -i \ -e "s/{DB_SERVER_HOST}/${DB_SERVER_HOST}/g" \ -e "s/{DB_SERVER_PORT}/${DB_SERVER_PORT}/g" \ -e "s/{DB_SERVER_DBNAME}/${DB_SERVER_DBNAME}/g" \ - -e "s/{DB_SERVER_USER}/${DB_SERVER_ZBX_USER}/g" \ - -e "s/{DB_SERVER_PASS}/${DB_SERVER_ZBX_PASS}/g" \ + -e "s/{DB_SERVER_USER}/$server_user/g" \ + -e "s/{DB_SERVER_PASS}/$server_pass/g" \ -e "s/{ZBX_SERVER_HOST}/${ZBX_SERVER_HOST}/g" \ -e "s/{ZBX_SERVER_PORT}/${ZBX_SERVER_PORT}/g" \ -e "s/{ZBX_SERVER_NAME}/$server_name/g" \ diff --git a/web-apache-pgsql/ubuntu/docker-entrypoint.sh b/web-apache-pgsql/ubuntu/docker-entrypoint.sh index 6e11befc2..ee8579425 100755 --- a/web-apache-pgsql/ubuntu/docker-entrypoint.sh +++ b/web-apache-pgsql/ubuntu/docker-entrypoint.sh @@ -49,6 +49,23 @@ prepare_system() { fi } +escape_spec_char() { + local var_value=$1 + + var_value="${var_value//\\/\\\\}" + var_value="${var_value//[$'\n']/}" + var_value="${var_value//\//\\/}" + var_value="${var_value//./\\.}" + var_value="${var_value//\*/\\*}" + var_value="${var_value//^/\\^}" + var_value="${var_value//\$/\\\$}" + var_value="${var_value//\&/\\\&}" + var_value="${var_value//\[/\\[}" + var_value="${var_value//\[/\\]}" + + echo $var_value +} + update_config_var() { local config_path=$1 local var_name=$2 @@ -81,8 +98,8 @@ update_config_var() { var_value=$ZABBIX_USER_HOME_DIR/enc/$var_value fi - # Escaping "/" character in parameter value - var_value=${var_value//\//\\/} + # Escaping characters in parameter value + var_value=$(escape_spec_char "$var_value") if [ "$(grep -E "^$var_name=" $config_path)" ] && [ "$is_multiple" != "true" ]; then sed -i -e "/^$var_name=/s/=.*/=$var_value/" "$config_path" @@ -703,15 +720,17 @@ prepare_zbx_web_config() { echo "**** Zabbix related PHP configuration file not found" fi - # Escaping "/" character in parameter value - server_name=${ZBX_SERVER_NAME//\//\\/} + # Escaping characters in parameter value + server_name=$(escape_spec_char "${ZBX_SERVER_NAME}") + server_user=$(escape_spec_char "${DB_SERVER_ZBX_USER}") + server_pass=$(escape_spec_char "${DB_SERVER_ZBX_PASS}") sed -i \ -e "s/{DB_SERVER_HOST}/${DB_SERVER_HOST}/g" \ -e "s/{DB_SERVER_PORT}/${DB_SERVER_PORT}/g" \ -e "s/{DB_SERVER_DBNAME}/${DB_SERVER_DBNAME}/g" \ - -e "s/{DB_SERVER_USER}/${DB_SERVER_ZBX_USER}/g" \ - -e "s/{DB_SERVER_PASS}/${DB_SERVER_ZBX_PASS}/g" \ + -e "s/{DB_SERVER_USER}/$server_user/g" \ + -e "s/{DB_SERVER_PASS}/$server_pass/g" \ -e "s/{ZBX_SERVER_HOST}/${ZBX_SERVER_HOST}/g" \ -e "s/{ZBX_SERVER_PORT}/${ZBX_SERVER_PORT}/g" \ -e "s/{ZBX_SERVER_NAME}/$server_name/g" \ diff --git a/web-nginx-mysql/alpine/docker-entrypoint.sh b/web-nginx-mysql/alpine/docker-entrypoint.sh index 6e11befc2..ee8579425 100755 --- a/web-nginx-mysql/alpine/docker-entrypoint.sh +++ b/web-nginx-mysql/alpine/docker-entrypoint.sh @@ -49,6 +49,23 @@ prepare_system() { fi } +escape_spec_char() { + local var_value=$1 + + var_value="${var_value//\\/\\\\}" + var_value="${var_value//[$'\n']/}" + var_value="${var_value//\//\\/}" + var_value="${var_value//./\\.}" + var_value="${var_value//\*/\\*}" + var_value="${var_value//^/\\^}" + var_value="${var_value//\$/\\\$}" + var_value="${var_value//\&/\\\&}" + var_value="${var_value//\[/\\[}" + var_value="${var_value//\[/\\]}" + + echo $var_value +} + update_config_var() { local config_path=$1 local var_name=$2 @@ -81,8 +98,8 @@ update_config_var() { var_value=$ZABBIX_USER_HOME_DIR/enc/$var_value fi - # Escaping "/" character in parameter value - var_value=${var_value//\//\\/} + # Escaping characters in parameter value + var_value=$(escape_spec_char "$var_value") if [ "$(grep -E "^$var_name=" $config_path)" ] && [ "$is_multiple" != "true" ]; then sed -i -e "/^$var_name=/s/=.*/=$var_value/" "$config_path" @@ -703,15 +720,17 @@ prepare_zbx_web_config() { echo "**** Zabbix related PHP configuration file not found" fi - # Escaping "/" character in parameter value - server_name=${ZBX_SERVER_NAME//\//\\/} + # Escaping characters in parameter value + server_name=$(escape_spec_char "${ZBX_SERVER_NAME}") + server_user=$(escape_spec_char "${DB_SERVER_ZBX_USER}") + server_pass=$(escape_spec_char "${DB_SERVER_ZBX_PASS}") sed -i \ -e "s/{DB_SERVER_HOST}/${DB_SERVER_HOST}/g" \ -e "s/{DB_SERVER_PORT}/${DB_SERVER_PORT}/g" \ -e "s/{DB_SERVER_DBNAME}/${DB_SERVER_DBNAME}/g" \ - -e "s/{DB_SERVER_USER}/${DB_SERVER_ZBX_USER}/g" \ - -e "s/{DB_SERVER_PASS}/${DB_SERVER_ZBX_PASS}/g" \ + -e "s/{DB_SERVER_USER}/$server_user/g" \ + -e "s/{DB_SERVER_PASS}/$server_pass/g" \ -e "s/{ZBX_SERVER_HOST}/${ZBX_SERVER_HOST}/g" \ -e "s/{ZBX_SERVER_PORT}/${ZBX_SERVER_PORT}/g" \ -e "s/{ZBX_SERVER_NAME}/$server_name/g" \ diff --git a/web-nginx-mysql/centos/docker-entrypoint.sh b/web-nginx-mysql/centos/docker-entrypoint.sh index 6e11befc2..ee8579425 100755 --- a/web-nginx-mysql/centos/docker-entrypoint.sh +++ b/web-nginx-mysql/centos/docker-entrypoint.sh @@ -49,6 +49,23 @@ prepare_system() { fi } +escape_spec_char() { + local var_value=$1 + + var_value="${var_value//\\/\\\\}" + var_value="${var_value//[$'\n']/}" + var_value="${var_value//\//\\/}" + var_value="${var_value//./\\.}" + var_value="${var_value//\*/\\*}" + var_value="${var_value//^/\\^}" + var_value="${var_value//\$/\\\$}" + var_value="${var_value//\&/\\\&}" + var_value="${var_value//\[/\\[}" + var_value="${var_value//\[/\\]}" + + echo $var_value +} + update_config_var() { local config_path=$1 local var_name=$2 @@ -81,8 +98,8 @@ update_config_var() { var_value=$ZABBIX_USER_HOME_DIR/enc/$var_value fi - # Escaping "/" character in parameter value - var_value=${var_value//\//\\/} + # Escaping characters in parameter value + var_value=$(escape_spec_char "$var_value") if [ "$(grep -E "^$var_name=" $config_path)" ] && [ "$is_multiple" != "true" ]; then sed -i -e "/^$var_name=/s/=.*/=$var_value/" "$config_path" @@ -703,15 +720,17 @@ prepare_zbx_web_config() { echo "**** Zabbix related PHP configuration file not found" fi - # Escaping "/" character in parameter value - server_name=${ZBX_SERVER_NAME//\//\\/} + # Escaping characters in parameter value + server_name=$(escape_spec_char "${ZBX_SERVER_NAME}") + server_user=$(escape_spec_char "${DB_SERVER_ZBX_USER}") + server_pass=$(escape_spec_char "${DB_SERVER_ZBX_PASS}") sed -i \ -e "s/{DB_SERVER_HOST}/${DB_SERVER_HOST}/g" \ -e "s/{DB_SERVER_PORT}/${DB_SERVER_PORT}/g" \ -e "s/{DB_SERVER_DBNAME}/${DB_SERVER_DBNAME}/g" \ - -e "s/{DB_SERVER_USER}/${DB_SERVER_ZBX_USER}/g" \ - -e "s/{DB_SERVER_PASS}/${DB_SERVER_ZBX_PASS}/g" \ + -e "s/{DB_SERVER_USER}/$server_user/g" \ + -e "s/{DB_SERVER_PASS}/$server_pass/g" \ -e "s/{ZBX_SERVER_HOST}/${ZBX_SERVER_HOST}/g" \ -e "s/{ZBX_SERVER_PORT}/${ZBX_SERVER_PORT}/g" \ -e "s/{ZBX_SERVER_NAME}/$server_name/g" \ diff --git a/web-nginx-mysql/ubuntu/docker-entrypoint.sh b/web-nginx-mysql/ubuntu/docker-entrypoint.sh index 6e11befc2..ee8579425 100755 --- a/web-nginx-mysql/ubuntu/docker-entrypoint.sh +++ b/web-nginx-mysql/ubuntu/docker-entrypoint.sh @@ -49,6 +49,23 @@ prepare_system() { fi } +escape_spec_char() { + local var_value=$1 + + var_value="${var_value//\\/\\\\}" + var_value="${var_value//[$'\n']/}" + var_value="${var_value//\//\\/}" + var_value="${var_value//./\\.}" + var_value="${var_value//\*/\\*}" + var_value="${var_value//^/\\^}" + var_value="${var_value//\$/\\\$}" + var_value="${var_value//\&/\\\&}" + var_value="${var_value//\[/\\[}" + var_value="${var_value//\[/\\]}" + + echo $var_value +} + update_config_var() { local config_path=$1 local var_name=$2 @@ -81,8 +98,8 @@ update_config_var() { var_value=$ZABBIX_USER_HOME_DIR/enc/$var_value fi - # Escaping "/" character in parameter value - var_value=${var_value//\//\\/} + # Escaping characters in parameter value + var_value=$(escape_spec_char "$var_value") if [ "$(grep -E "^$var_name=" $config_path)" ] && [ "$is_multiple" != "true" ]; then sed -i -e "/^$var_name=/s/=.*/=$var_value/" "$config_path" @@ -703,15 +720,17 @@ prepare_zbx_web_config() { echo "**** Zabbix related PHP configuration file not found" fi - # Escaping "/" character in parameter value - server_name=${ZBX_SERVER_NAME//\//\\/} + # Escaping characters in parameter value + server_name=$(escape_spec_char "${ZBX_SERVER_NAME}") + server_user=$(escape_spec_char "${DB_SERVER_ZBX_USER}") + server_pass=$(escape_spec_char "${DB_SERVER_ZBX_PASS}") sed -i \ -e "s/{DB_SERVER_HOST}/${DB_SERVER_HOST}/g" \ -e "s/{DB_SERVER_PORT}/${DB_SERVER_PORT}/g" \ -e "s/{DB_SERVER_DBNAME}/${DB_SERVER_DBNAME}/g" \ - -e "s/{DB_SERVER_USER}/${DB_SERVER_ZBX_USER}/g" \ - -e "s/{DB_SERVER_PASS}/${DB_SERVER_ZBX_PASS}/g" \ + -e "s/{DB_SERVER_USER}/$server_user/g" \ + -e "s/{DB_SERVER_PASS}/$server_pass/g" \ -e "s/{ZBX_SERVER_HOST}/${ZBX_SERVER_HOST}/g" \ -e "s/{ZBX_SERVER_PORT}/${ZBX_SERVER_PORT}/g" \ -e "s/{ZBX_SERVER_NAME}/$server_name/g" \ diff --git a/web-nginx-pgsql/alpine/docker-entrypoint.sh b/web-nginx-pgsql/alpine/docker-entrypoint.sh index 6e11befc2..ee8579425 100755 --- a/web-nginx-pgsql/alpine/docker-entrypoint.sh +++ b/web-nginx-pgsql/alpine/docker-entrypoint.sh @@ -49,6 +49,23 @@ prepare_system() { fi } +escape_spec_char() { + local var_value=$1 + + var_value="${var_value//\\/\\\\}" + var_value="${var_value//[$'\n']/}" + var_value="${var_value//\//\\/}" + var_value="${var_value//./\\.}" + var_value="${var_value//\*/\\*}" + var_value="${var_value//^/\\^}" + var_value="${var_value//\$/\\\$}" + var_value="${var_value//\&/\\\&}" + var_value="${var_value//\[/\\[}" + var_value="${var_value//\[/\\]}" + + echo $var_value +} + update_config_var() { local config_path=$1 local var_name=$2 @@ -81,8 +98,8 @@ update_config_var() { var_value=$ZABBIX_USER_HOME_DIR/enc/$var_value fi - # Escaping "/" character in parameter value - var_value=${var_value//\//\\/} + # Escaping characters in parameter value + var_value=$(escape_spec_char "$var_value") if [ "$(grep -E "^$var_name=" $config_path)" ] && [ "$is_multiple" != "true" ]; then sed -i -e "/^$var_name=/s/=.*/=$var_value/" "$config_path" @@ -703,15 +720,17 @@ prepare_zbx_web_config() { echo "**** Zabbix related PHP configuration file not found" fi - # Escaping "/" character in parameter value - server_name=${ZBX_SERVER_NAME//\//\\/} + # Escaping characters in parameter value + server_name=$(escape_spec_char "${ZBX_SERVER_NAME}") + server_user=$(escape_spec_char "${DB_SERVER_ZBX_USER}") + server_pass=$(escape_spec_char "${DB_SERVER_ZBX_PASS}") sed -i \ -e "s/{DB_SERVER_HOST}/${DB_SERVER_HOST}/g" \ -e "s/{DB_SERVER_PORT}/${DB_SERVER_PORT}/g" \ -e "s/{DB_SERVER_DBNAME}/${DB_SERVER_DBNAME}/g" \ - -e "s/{DB_SERVER_USER}/${DB_SERVER_ZBX_USER}/g" \ - -e "s/{DB_SERVER_PASS}/${DB_SERVER_ZBX_PASS}/g" \ + -e "s/{DB_SERVER_USER}/$server_user/g" \ + -e "s/{DB_SERVER_PASS}/$server_pass/g" \ -e "s/{ZBX_SERVER_HOST}/${ZBX_SERVER_HOST}/g" \ -e "s/{ZBX_SERVER_PORT}/${ZBX_SERVER_PORT}/g" \ -e "s/{ZBX_SERVER_NAME}/$server_name/g" \ diff --git a/web-nginx-pgsql/centos/docker-entrypoint.sh b/web-nginx-pgsql/centos/docker-entrypoint.sh index 6e11befc2..ee8579425 100755 --- a/web-nginx-pgsql/centos/docker-entrypoint.sh +++ b/web-nginx-pgsql/centos/docker-entrypoint.sh @@ -49,6 +49,23 @@ prepare_system() { fi } +escape_spec_char() { + local var_value=$1 + + var_value="${var_value//\\/\\\\}" + var_value="${var_value//[$'\n']/}" + var_value="${var_value//\//\\/}" + var_value="${var_value//./\\.}" + var_value="${var_value//\*/\\*}" + var_value="${var_value//^/\\^}" + var_value="${var_value//\$/\\\$}" + var_value="${var_value//\&/\\\&}" + var_value="${var_value//\[/\\[}" + var_value="${var_value//\[/\\]}" + + echo $var_value +} + update_config_var() { local config_path=$1 local var_name=$2 @@ -81,8 +98,8 @@ update_config_var() { var_value=$ZABBIX_USER_HOME_DIR/enc/$var_value fi - # Escaping "/" character in parameter value - var_value=${var_value//\//\\/} + # Escaping characters in parameter value + var_value=$(escape_spec_char "$var_value") if [ "$(grep -E "^$var_name=" $config_path)" ] && [ "$is_multiple" != "true" ]; then sed -i -e "/^$var_name=/s/=.*/=$var_value/" "$config_path" @@ -703,15 +720,17 @@ prepare_zbx_web_config() { echo "**** Zabbix related PHP configuration file not found" fi - # Escaping "/" character in parameter value - server_name=${ZBX_SERVER_NAME//\//\\/} + # Escaping characters in parameter value + server_name=$(escape_spec_char "${ZBX_SERVER_NAME}") + server_user=$(escape_spec_char "${DB_SERVER_ZBX_USER}") + server_pass=$(escape_spec_char "${DB_SERVER_ZBX_PASS}") sed -i \ -e "s/{DB_SERVER_HOST}/${DB_SERVER_HOST}/g" \ -e "s/{DB_SERVER_PORT}/${DB_SERVER_PORT}/g" \ -e "s/{DB_SERVER_DBNAME}/${DB_SERVER_DBNAME}/g" \ - -e "s/{DB_SERVER_USER}/${DB_SERVER_ZBX_USER}/g" \ - -e "s/{DB_SERVER_PASS}/${DB_SERVER_ZBX_PASS}/g" \ + -e "s/{DB_SERVER_USER}/$server_user/g" \ + -e "s/{DB_SERVER_PASS}/$server_pass/g" \ -e "s/{ZBX_SERVER_HOST}/${ZBX_SERVER_HOST}/g" \ -e "s/{ZBX_SERVER_PORT}/${ZBX_SERVER_PORT}/g" \ -e "s/{ZBX_SERVER_NAME}/$server_name/g" \ diff --git a/web-nginx-pgsql/ubuntu/docker-entrypoint.sh b/web-nginx-pgsql/ubuntu/docker-entrypoint.sh index 6e11befc2..ee8579425 100755 --- a/web-nginx-pgsql/ubuntu/docker-entrypoint.sh +++ b/web-nginx-pgsql/ubuntu/docker-entrypoint.sh @@ -49,6 +49,23 @@ prepare_system() { fi } +escape_spec_char() { + local var_value=$1 + + var_value="${var_value//\\/\\\\}" + var_value="${var_value//[$'\n']/}" + var_value="${var_value//\//\\/}" + var_value="${var_value//./\\.}" + var_value="${var_value//\*/\\*}" + var_value="${var_value//^/\\^}" + var_value="${var_value//\$/\\\$}" + var_value="${var_value//\&/\\\&}" + var_value="${var_value//\[/\\[}" + var_value="${var_value//\[/\\]}" + + echo $var_value +} + update_config_var() { local config_path=$1 local var_name=$2 @@ -81,8 +98,8 @@ update_config_var() { var_value=$ZABBIX_USER_HOME_DIR/enc/$var_value fi - # Escaping "/" character in parameter value - var_value=${var_value//\//\\/} + # Escaping characters in parameter value + var_value=$(escape_spec_char "$var_value") if [ "$(grep -E "^$var_name=" $config_path)" ] && [ "$is_multiple" != "true" ]; then sed -i -e "/^$var_name=/s/=.*/=$var_value/" "$config_path" @@ -703,15 +720,17 @@ prepare_zbx_web_config() { echo "**** Zabbix related PHP configuration file not found" fi - # Escaping "/" character in parameter value - server_name=${ZBX_SERVER_NAME//\//\\/} + # Escaping characters in parameter value + server_name=$(escape_spec_char "${ZBX_SERVER_NAME}") + server_user=$(escape_spec_char "${DB_SERVER_ZBX_USER}") + server_pass=$(escape_spec_char "${DB_SERVER_ZBX_PASS}") sed -i \ -e "s/{DB_SERVER_HOST}/${DB_SERVER_HOST}/g" \ -e "s/{DB_SERVER_PORT}/${DB_SERVER_PORT}/g" \ -e "s/{DB_SERVER_DBNAME}/${DB_SERVER_DBNAME}/g" \ - -e "s/{DB_SERVER_USER}/${DB_SERVER_ZBX_USER}/g" \ - -e "s/{DB_SERVER_PASS}/${DB_SERVER_ZBX_PASS}/g" \ + -e "s/{DB_SERVER_USER}/$server_user/g" \ + -e "s/{DB_SERVER_PASS}/$server_pass/g" \ -e "s/{ZBX_SERVER_HOST}/${ZBX_SERVER_HOST}/g" \ -e "s/{ZBX_SERVER_PORT}/${ZBX_SERVER_PORT}/g" \ -e "s/{ZBX_SERVER_NAME}/$server_name/g" \