Don't show server properties by default and obscure passwords (#1670)

This commit is contained in:
Geoff Bourne 2022-08-14 14:14:57 -05:00 committed by GitHub
parent 7a85cb5f39
commit 05b8899de6
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -15,11 +15,16 @@ function setServerPropValue {
TRUE|FALSE) TRUE|FALSE)
value=${value,,} ;; value=${value,,} ;;
esac esac
if [[ $prop =~ password ]]; then
showValue="*****"
else
showValue="$value"
fi
if grep "${prop}" "$SERVER_PROPERTIES" > /dev/null; then if grep "${prop}" "$SERVER_PROPERTIES" > /dev/null; then
log "Setting ${prop} to '${value}' in ${SERVER_PROPERTIES}" debug "Setting ${prop} to '${showValue}' in ${SERVER_PROPERTIES}"
sed -i "/^${prop}\s*=/ c ${prop}=${value//\\/\\\\}" "$SERVER_PROPERTIES" sed -i "/^${prop}\s*=/ c ${prop}=${value//\\/\\\\}" "$SERVER_PROPERTIES"
else else
log "Adding ${prop} with '${value}' in ${SERVER_PROPERTIES}" debug "Adding ${prop} with '${showValue}' in ${SERVER_PROPERTIES}"
echo "${prop}=${value}" >> "$SERVER_PROPERTIES" echo "${prop}=${value}" >> "$SERVER_PROPERTIES"
fi fi
} }
@ -207,12 +212,13 @@ fi
if ! isTrue "${SKIP_SERVER_PROPERTIES:-false}"; then if ! isTrue "${SKIP_SERVER_PROPERTIES:-false}"; then
if [ ! -e "$SERVER_PROPERTIES" ]; then if [ ! -e "$SERVER_PROPERTIES" ]; then
log "Creating server.properties in ${SERVER_PROPERTIES}" log "Creating server properties in ${SERVER_PROPERTIES}"
cp /tmp/server.properties "$SERVER_PROPERTIES" cp /tmp/server.properties "$SERVER_PROPERTIES"
customizeServerProps customizeServerProps
elif [ -n "${OVERRIDE_SERVER_PROPERTIES}" ]; then elif [ -n "${OVERRIDE_SERVER_PROPERTIES}" ]; then
case ${OVERRIDE_SERVER_PROPERTIES^^} in case ${OVERRIDE_SERVER_PROPERTIES^^} in
TRUE|1) TRUE|1)
log "Updating server properties in ${SERVER_PROPERTIES}"
customizeServerProps customizeServerProps
;; ;;
*) *)
@ -235,7 +241,7 @@ if isTrue "${ENABLE_AUTOPAUSE}"; then
fi fi
fi fi
if isDebugging && [ -f "${SERVER_PROPERTIES}" ]; then if isTrue "${DUMP_SERVER_PROPERTIES:-false}"; then
log "DEBUG Dumping server.properties" log "DEBUG Dumping server.properties"
cat "${SERVER_PROPERTIES}" cat "${SERVER_PROPERTIES}"
fi fi