You've already forked zabbix-ubuntu
extended input validation
This commit is contained in:
@@ -91,7 +91,7 @@ while getopts ":n:p:m:a:h" option; do
|
||||
done
|
||||
|
||||
#
|
||||
# Validate hostname and DB password
|
||||
# Parse and validate input
|
||||
#
|
||||
if [[ -z "$hostname" || -z "$dbpass" ]]; then
|
||||
usage
|
||||
@@ -115,14 +115,14 @@ if [[ "$hostname" =~ [[:space:]/_] ]]; then
|
||||
exit 1
|
||||
fi
|
||||
|
||||
# RFC 1123 validation
|
||||
# Validate domain format (RFC 1123)
|
||||
if [[ ! "$hostname" =~ ^([a-z0-9]+(-[a-z0-9]+)*\.)+[a-z]{2,}$ ]]; then
|
||||
printf "\nERROR: Invalid domain format.\n"
|
||||
printf "Example of valid input: zabbix.example.com\n\n"
|
||||
exit 1
|
||||
fi
|
||||
|
||||
# DB password sanity check
|
||||
# Check for spaces in DB credentials
|
||||
if [[ "$dbpass" =~ [[:space:]] ]]; then
|
||||
printf "\nERROR: Database password cannot contain spaces.\n\n"
|
||||
exit 1
|
||||
|
||||
Reference in New Issue
Block a user