|
|
@ -32,3 +32,38 @@ connection_type_equiv = { |
|
|
|
u'hostnossl' : (u'host', u'hostnossl',), |
|
|
|
} |
|
|
|
|
|
|
|
class Rule(object): |
|
|
|
""" |
|
|
|
A single HBA rule. |
|
|
|
(?# CONNECTION_TYPE DATABASES USERS CIDR-ADDRESS? METHOD OPTION?) |
|
|
|
""" |
|
|
|
def __init__(self, |
|
|
|
ctype, method, users, databases, |
|
|
|
cidr = None, options = None, comment = None, |
|
|
|
): |
|
|
|
if ctype is not None and ctype not in connection_types: |
|
|
|
raise ValueError("unknown connection type, '%s'" %(ctype,)) |
|
|
|
if ctype == 'local': |
|
|
|
if cidr is not None: |
|
|
|
raise ValueError("cidr must be None for local rules") |
|
|
|
self.cidr = None |
|
|
|
else: |
|
|
|
self.cidr = cidr |
|
|
|
|
|
|
|
self.ctype = ctype |
|
|
|
|
|
|
|
if u'all' in users: |
|
|
|
self.users = (u'all',) |
|
|
|
else: |
|
|
|
self.users = users |
|
|
|
|
|
|
|
if u'all' in databases: |
|
|
|
self.databases = (u'all',) |
|
|
|
else: |
|
|
|
self.databases = databases |
|
|
|
|
|
|
|
self.method = method |
|
|
|
self.options = options |
|
|
|
self.comment = comment |
|
|
|
self.line = None |
|
|
|
|