diff options
| author | Aravinda VK <avishwan@redhat.com> | 2019-03-26 13:20:13 +0530 | 
|---|---|---|
| committer | Amar Tumballi <amarts@redhat.com> | 2019-03-27 14:34:31 +0000 | 
| commit | c574984e19d59e351372eacce0ce11fb36e96dd4 (patch) | |
| tree | c13d37eb9f15be4a60d030590f6bd49143595d87 /geo-replication/syncdaemon | |
| parent | 313dcefe7a62bd16cd794040df068f9bec9c6927 (diff) | |
geo-rep: fix integer config validation
ssh-port validation is mentioned as `validation=int` in template
`gsyncd.conf`, but not handled this during geo-rep config set.
Fixes: bz#1692666
Change-Id: I3f19d9b471b0a3327e4d094dfbefcc58ed2c34f6
Signed-off-by: Aravinda VK <avishwan@redhat.com>
Diffstat (limited to 'geo-replication/syncdaemon')
| -rw-r--r-- | geo-replication/syncdaemon/gsyncdconfig.py | 23 | 
1 files changed, 18 insertions, 5 deletions
diff --git a/geo-replication/syncdaemon/gsyncdconfig.py b/geo-replication/syncdaemon/gsyncdconfig.py index 23a1c5769c7..26fb6a57318 100644 --- a/geo-replication/syncdaemon/gsyncdconfig.py +++ b/geo-replication/syncdaemon/gsyncdconfig.py @@ -313,6 +313,9 @@ class Gconf(object):          if item["validation"] == "unixtime":              return validate_unixtime(value) +        if item["validation"] == "int": +            return validate_int(value) +          return False      def _is_config_changed(self): @@ -326,6 +329,14 @@ class Gconf(object):          return False +def validate_int(value): +    try: +        _ = int(value) +        return True +    except ValueError: +        return False + +  def validate_unixtime(value):      try:          y = datetime.fromtimestamp(int(value)).strftime("%Y") @@ -338,11 +349,13 @@ def validate_unixtime(value):  def validate_minmax(value, minval, maxval): -    value = int(value) -    minval = int(minval) -    maxval = int(maxval) - -    return value >= minval and value <= maxval +    try: +        value = int(value) +        minval = int(minval) +        maxval = int(maxval) +        return value >= minval and value <= maxval +    except ValueError: +        return False  def validate_choice(value, allowed_values):  | 
