mirror of
https://github.com/hackacad/bastille.git
synced 2025-12-18 16:21:32 +01:00
Improve name validation for create and rename, add error_notify function
This commit is contained in:
@@ -42,6 +42,14 @@ error_notify() {
|
||||
exit 1
|
||||
}
|
||||
|
||||
validate_name() {
|
||||
local NAME_VERIFY=${NAME}
|
||||
local NAME_SANITY=$(echo "${NAME_VERIFY}" | tr -c -d 'a-zA-Z0-9-_')
|
||||
if [ "${NAME_VERIFY}" != "${NAME_SANITY}" ]; then
|
||||
error_notify "${COLOR_RED}Container names may not contain special characters!${COLOR_RESET}"
|
||||
fi
|
||||
}
|
||||
|
||||
# Handle special-case commands first
|
||||
case "$1" in
|
||||
help|-h|--help)
|
||||
@@ -132,4 +140,9 @@ elif [ -d "${bastille_jailsdir}/${NEWNAME}" ]; then
|
||||
error_notify "${COLOR_RED}Jail: ${NEWNAME} already exist.${COLOR_RESET}"
|
||||
fi
|
||||
|
||||
## validate jail name
|
||||
if [ -n "${NAME}" ]; then
|
||||
validate_name
|
||||
fi
|
||||
|
||||
change_name
|
||||
|
||||
Reference in New Issue
Block a user