HADOOP-13030. Handle special characters in passwords in KMS startup script. Contributed by Xiao Chen.
This commit is contained in:
parent
4289cb8b36
commit
7271e91b79
|
@ -26,6 +26,14 @@ while [ -h "${PRG}" ]; do
|
||||||
fi
|
fi
|
||||||
done
|
done
|
||||||
|
|
||||||
|
function hadoop_escape() {
|
||||||
|
# Escape special chars for the later sed which saves the text as xml attribute
|
||||||
|
local ret
|
||||||
|
ret=$(sed 's/[\/&]/\\&/g' <<< "$1" | sed 's/&/\&/g' | sed 's/"/\\\"/g' \
|
||||||
|
| sed "s/'/\\\\\'/g" | sed 's/</\\\</g' | sed 's/>/\\\>/g')
|
||||||
|
echo "$ret"
|
||||||
|
}
|
||||||
|
|
||||||
BASEDIR=`dirname ${PRG}`
|
BASEDIR=`dirname ${PRG}`
|
||||||
BASEDIR=`cd ${BASEDIR}/..;pwd`
|
BASEDIR=`cd ${BASEDIR}/..;pwd`
|
||||||
|
|
||||||
|
@ -76,9 +84,11 @@ fi
|
||||||
if [ ! "${KMS_SSL_KEYSTORE_PASS}" = "" ] || [ ! "${KMS_SSL_TRUSTSTORE_PASS}" = "" ]; then
|
if [ ! "${KMS_SSL_KEYSTORE_PASS}" = "" ] || [ ! "${KMS_SSL_TRUSTSTORE_PASS}" = "" ]; then
|
||||||
# Set a KEYSTORE_PASS if not already set
|
# Set a KEYSTORE_PASS if not already set
|
||||||
KMS_SSL_KEYSTORE_PASS=${KMS_SSL_KEYSTORE_PASS:-password}
|
KMS_SSL_KEYSTORE_PASS=${KMS_SSL_KEYSTORE_PASS:-password}
|
||||||
|
KMS_SSL_KEYSTORE_PASS_ESCAPED=$(hadoop_escape "$KMS_SSL_KEYSTORE_PASS")
|
||||||
|
KMS_SSL_TRUSTSTORE_PASS_ESCAPED=$(hadoop_escape "$KMS_SSL_TRUSTSTORE_PASS")
|
||||||
cat ${CATALINA_BASE}/conf/ssl-server.xml.conf \
|
cat ${CATALINA_BASE}/conf/ssl-server.xml.conf \
|
||||||
| sed 's/_kms_ssl_keystore_pass_/'${KMS_SSL_KEYSTORE_PASS}'/g' \
|
| sed 's/"_kms_ssl_keystore_pass_"/'"\"${KMS_SSL_KEYSTORE_PASS_ESCAPED}\""'/g' \
|
||||||
| sed 's/_kms_ssl_truststore_pass_/'${KMS_SSL_TRUSTSTORE_PASS}'/g' > ${CATALINA_BASE}/conf/ssl-server.xml
|
| sed 's/"_kms_ssl_truststore_pass_"/'"\"${KMS_SSL_TRUSTSTORE_PASS_ESCAPED}\""'/g' > ${CATALINA_BASE}/conf/ssl-server.xml
|
||||||
fi
|
fi
|
||||||
|
|
||||||
exec ${KMS_CATALINA_HOME}/bin/catalina.sh "$@"
|
exec ${KMS_CATALINA_HOME}/bin/catalina.sh "$@"
|
||||||
|
|
Loading…
Reference in New Issue