valid port syntax in service allow

This commit is contained in:
Chai Feng 2018-10-03 09:10:57 +08:00
parent b557b56a03
commit a91e864cfe
No known key found for this signature in database
GPG Key ID: 2DCD9A24E523FFD2

View File

@ -124,6 +124,12 @@ function ufw-docker--service-allow() {
service_name="$1" service_name="$1"
service_port="$2" service_port="$2"
if [[ -n "$service_port" ]] &&
! grep -E '^[0-9]+(/(tcp|udp))?$' <<< "$service_port" &>/dev/null; then
die "Invalid port syntax: $service_port"
return 1
fi
} }
function ufw-docker--install() { function ufw-docker--install() {