enforce strict service name rules

Signed-off-by: fbt <fbt@fleshless.org>
This commit is contained in:
Jack L. Frost 2018-03-06 19:30:04 +03:00
parent bf85069b32
commit da1ffe1a7b

5
ssm
View File

@ -767,6 +767,11 @@ flag_edit_service && { edit; die $?; }
service_name = "${1##*/}"
readonly service_name
# Enforce service_name to conform to BASH's name constraints
[[ $service_name =~ ^[a-zA-Z_][a-zA-Z0-9_]+?$ ]] || {
die 77 "Invalid service name: '$service_name'"
}
# These depend on the service_name and make little sense to reconfigure.
service_ready_flag := "$rundir/$service_name.ready"
service_enabled_flag := "$rundir/$service_name.enabled"