postgresql_pg_hba: Exception when two lines with same weight are compared (#59198)
This commit is contained in:
parent
8a13b41823
commit
d0538c0d7a
3 changed files with 7 additions and 6 deletions
|
@ -573,11 +573,11 @@ class PgHbaRule(dict):
|
||||||
return myweight < hisweight
|
return myweight < hisweight
|
||||||
try:
|
try:
|
||||||
return self['src'] < other['src']
|
return self['src'] < other['src']
|
||||||
except (TypeError, KeyError):
|
except TypeError:
|
||||||
return self.source_type_weight() < other.source_type_weight()
|
return self.source_type_weight() < other.source_type_weight()
|
||||||
errormessage = 'We have two rules ({1}, {2})'.format(self, other)
|
except Exception:
|
||||||
errormessage += ' with exact same weight. Please file a bug.'
|
# When all else fails, just compare the exact line.
|
||||||
raise PgHbaValueError(errormessage)
|
return self.line() < other.line()
|
||||||
|
|
||||||
def source_weight(self):
|
def source_weight(self):
|
||||||
"""Report the weight of this source net.
|
"""Report the weight of this source net.
|
||||||
|
|
|
@ -12,7 +12,7 @@ db_session_role2: 'session_role2'
|
||||||
|
|
||||||
pg_hba_test_ips:
|
pg_hba_test_ips:
|
||||||
- contype: local
|
- contype: local
|
||||||
users: 'all,postgres'
|
users: 'all,postgres,test'
|
||||||
- source: '0000:ffff::'
|
- source: '0000:ffff::'
|
||||||
netmask: 'ffff:fff0::'
|
netmask: 'ffff:fff0::'
|
||||||
- source: '192.168.0.0/24'
|
- source: '192.168.0.0/24'
|
||||||
|
|
|
@ -143,8 +143,9 @@
|
||||||
- assert:
|
- assert:
|
||||||
that:
|
that:
|
||||||
- 'pg_hba.pg_hba == [
|
- 'pg_hba.pg_hba == [
|
||||||
{ "db": "all", "method": "md5", "type": "local", "usr": "postgres" },
|
|
||||||
{ "db": "all", "method": "ldap", "type": "local", "usr": "+some", "options": "ldapserver=example.com ldapport=389 ldapprefix=\"cn=\"" },
|
{ "db": "all", "method": "ldap", "type": "local", "usr": "+some", "options": "ldapserver=example.com ldapport=389 ldapprefix=\"cn=\"" },
|
||||||
|
{ "db": "all", "method": "md5", "type": "local", "usr": "postgres" },
|
||||||
|
{ "db": "all", "method": "md5", "type": "local", "usr": "test" },
|
||||||
{ "db": "all", "method": "md5", "type": "local", "usr": "all" },
|
{ "db": "all", "method": "md5", "type": "local", "usr": "all" },
|
||||||
{ "db": "all", "method": "cert", "src": "blue", "type": "hostssl", "usr": "+some", "options": "clientcert=1 map=mymap" },
|
{ "db": "all", "method": "cert", "src": "blue", "type": "hostssl", "usr": "+some", "options": "clientcert=1 map=mymap" },
|
||||||
{ "db": "all", "method": "cert", "src": "red", "type": "hostssl", "usr": "+some", "options": "clientcert=1 map=mymap" },
|
{ "db": "all", "method": "cert", "src": "red", "type": "hostssl", "usr": "+some", "options": "clientcert=1 map=mymap" },
|
||||||
|
|
Loading…
Reference in a new issue