Noam Slomianko has uploaded a new change for review.

Change subject: tools: notifier - add aditional validation
......................................................................

tools: notifier - add aditional validation

Check for valid email (simple @ validation)
Check for valid port number (1-65536)
Check for true or false in HTML_MESSAGE_FORMAT

Change-Id: Id97cb5bd1903991717e653cf2ca4ca16f362f8e6
Bug-Url: https://bugzilla.redhat.com/883417
Signed-off-by: Noam Slomianko <[email protected]>
---
M 
backend/manager/tools/engine-notifier/engine-notifier-resources/src/main/resources/notifier.sh
1 file changed, 21 insertions(+), 0 deletions(-)


  git pull ssh://gerrit.ovirt.org:29418/ovirt-engine refs/changes/49/11549/1

diff --git 
a/backend/manager/tools/engine-notifier/engine-notifier-resources/src/main/resources/notifier.sh
 
b/backend/manager/tools/engine-notifier/engine-notifier-resources/src/main/resources/notifier.sh
index 4acb836..21dc484 100755
--- 
a/backend/manager/tools/engine-notifier/engine-notifier-resources/src/main/resources/notifier.sh
+++ 
b/backend/manager/tools/engine-notifier/engine-notifier-resources/src/main/resources/notifier.sh
@@ -28,6 +28,25 @@
     fi
 }
 
+check_port_number(){
+    #exit with a message if the property is not a valid port number
+    if ! [[ "${!1}" =~ ^-?[0-9]+$ ]] ; then
+       die "Error: $1 must be a valid port number"
+    elif [ ${!1} -lt 1 ]  ||  [ ${!1} -gt 65536 ] ;  then
+       die "Error: $1 must be a number between 0 and 65536"
+    fi
+
+
+}
+
+check_boolean(){
+    #exit with a message if the property is not true or false
+    if ! [[ ${!1} = "true" ]] ||  [[ ${!1} = "false" ]] ;  then
+       die "Error: $1 must be true or false"
+    fi
+
+}
+
 if [ "$1" == "--help" -o "$1" == "-h" ]; then
     usage
     exit 0
@@ -78,6 +97,7 @@
     if [ -z "$MAIL_PORT" ]; then
         die_no_propset \$MAIL_PORT
     fi
+    check_port_number "MAIL_PORT"
 fi
 
 # MAIL_USER if defined can not be empty
@@ -116,6 +136,7 @@
     if [ -z "$HTML_MESSAGE_FORMAT" ]; then
         die_no_propset \$HTML_MESSAGE_FORMAT
     fi
+    check_boolean "HTML_MESSAGE_FORMAT"
 fi
 
 # MAIL_FROM if defined can not be empty


--
To view, visit http://gerrit.ovirt.org/11549
To unsubscribe, visit http://gerrit.ovirt.org/settings

Gerrit-MessageType: newchange
Gerrit-Change-Id: Id97cb5bd1903991717e653cf2ca4ca16f362f8e6
Gerrit-PatchSet: 1
Gerrit-Project: ovirt-engine
Gerrit-Branch: master
Gerrit-Owner: Noam Slomianko <[email protected]>
_______________________________________________
Engine-patches mailing list
[email protected]
http://lists.ovirt.org/mailman/listinfo/engine-patches

Reply via email to