fix: Strictly validate service names
We previously allowed a wide range of service names. As the service name is sometimes used to name databases, the name was actually more restricted than any character, resulting in services that wouldn't start. Going forward, only alphanumeric and underscore characters are allowed. This only impacts service creation. Any services with invalid names should be migrated to a new service, with the data exported and imported as normal. Closes dokku/dokku-redis#99 Closes dokku/dokku-mysql#47 Closes dokku/dokku-mongo#86 Closes dokku/dokku-redis#81
This commit is contained in:
@@ -21,6 +21,7 @@ service_connect() {
|
||||
|
||||
service_create() {
|
||||
local SERVICE="$1"
|
||||
is_valid_service_name "$SERVICE" || dokku_log_fail "Please specify a valid name for the service. Valid characters are: [A-Za-z0-9_]+"
|
||||
[[ -z "$SERVICE" ]] && dokku_log_fail "Please specify a name for the service"
|
||||
[[ ! -d "$PLUGIN_DATA_ROOT/$SERVICE" ]] || dokku_log_fail "$PLUGIN_SERVICE service $SERVICE already exists"
|
||||
SERVICE_ROOT="$PLUGIN_DATA_ROOT/$SERVICE"; LINKS_FILE="$SERVICE_ROOT/LINKS"
|
||||
|
||||
Reference in New Issue
Block a user