Changeset - f6b064773072
[Not reviewed]
0 2 0
Branko Majic (branko) - 10 years ago 2015-03-08 11:19:36
branko@majic.rs
MAR-1: Construct error messages in a safer way.
2 files changed with 6 insertions and 20 deletions:
0 comments (0 inline, 0 general)
roles/ldap_server/library/ldap_entry.py
Show inline comments
 
@@ -261,12 +261,7 @@ def main():
 
                                         module.params["bind_dn"],
 
                                         module.params["bind_password"])
 
    except ldap.LDAPError as e:
 
        if e.info:
 
            error_message = "%s: %s" % (e.desc, e.info)
 
        else:
 
            error_message = "%s" % e.desc
 

	
 
        module.fail_json(msg=error_message)
 
        module.fail_json(msg="LDAP error: %s" % str(e))
 

	
 
    entry = LDAPEntry(module.params["dn"],
 
                      attributes,
 
@@ -279,7 +274,7 @@ def main():
 
        else:
 
            changed = entry.remove()
 
    except ldap.LDAPError as e:
 
        module.fail_json(msg=str(e))
 
        module.fail_json(msg="LDAP error: %s" % str(e))
 

	
 
    module.exit_json(changed=changed)
 

	
roles/ldap_server/library/ldap_permissions.py
Show inline comments
 
@@ -277,12 +277,7 @@ def main():
 
                                         module.params["bind_dn"],
 
                                         module.params["bind_password"])
 
    except ldap.LDAPError as e:
 
        if e.info:
 
            error_message = "%s: %s" % (e.desc, e.info)
 
        else:
 
            error_message = "%s" % e.desc
 

	
 
        module.fail_json(msg=error_message)
 
        module.fail_json(msg="LDAP error: %s" % str(error_message))
 

	
 
    ldap_permissions = LDAPPermissions(module.params["filter"],
 
                                       module.params["rules"],
 
@@ -290,16 +285,12 @@ def main():
 

	
 
    try:
 
        changed = ldap_permissions.update()
 
    except ldap.LDAPError as e:
 
        if e.info:
 
            error_message = "%s: %s" % (e.desc, e.info)
 
        else:
 
            error_message = "%s" % e.desc
 

	
 
        module.fail_json(msg=error_message)
 
    except ldap.LDAPError as e:
 
        module.fail_json(msg="LDAP error: %s" % str(e))
 

	
 
    except DatabaseFilteringError as e:
 
        module.fail_json(msg=DatabaseFilteringError)
 
        module.fail_json(msg="Module error: %s" % str(e))
 

	
 
    module.exit_json(changed=changed)
 

	
0 comments (0 inline, 0 general)