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
|
done
|
||||||
|
|
||||||
#
|
#
|
||||||
# Validate hostname and DB password
|
# Parse and validate input
|
||||||
#
|
#
|
||||||
if [[ -z "$hostname" || -z "$dbpass" ]]; then
|
if [[ -z "$hostname" || -z "$dbpass" ]]; then
|
||||||
usage
|
usage
|
||||||
@@ -115,14 +115,14 @@ if [[ "$hostname" =~ [[:space:]/_] ]]; then
|
|||||||
exit 1
|
exit 1
|
||||||
fi
|
fi
|
||||||
|
|
||||||
# RFC 1123 validation
|
# Validate domain format (RFC 1123)
|
||||||
if [[ ! "$hostname" =~ ^([a-z0-9]+(-[a-z0-9]+)*\.)+[a-z]{2,}$ ]]; then
|
if [[ ! "$hostname" =~ ^([a-z0-9]+(-[a-z0-9]+)*\.)+[a-z]{2,}$ ]]; then
|
||||||
printf "\nERROR: Invalid domain format.\n"
|
printf "\nERROR: Invalid domain format.\n"
|
||||||
printf "Example of valid input: zabbix.example.com\n\n"
|
printf "Example of valid input: zabbix.example.com\n\n"
|
||||||
exit 1
|
exit 1
|
||||||
fi
|
fi
|
||||||
|
|
||||||
# DB password sanity check
|
# Check for spaces in DB credentials
|
||||||
if [[ "$dbpass" =~ [[:space:]] ]]; then
|
if [[ "$dbpass" =~ [[:space:]] ]]; then
|
||||||
printf "\nERROR: Database password cannot contain spaces.\n\n"
|
printf "\nERROR: Database password cannot contain spaces.\n\n"
|
||||||
exit 1
|
exit 1
|
||||||
|
|||||||
Reference in New Issue
Block a user