Skip to content

Commit

Permalink
Test fix for machines that do not define localhost.
Browse files Browse the repository at this point in the history
  • Loading branch information
hannosch committed Nov 2, 2014
1 parent 0b0406d commit 7b9fb00
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 7 deletions.
3 changes: 1 addition & 2 deletions CHANGES.txt
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,7 @@ For changes before verison 3.0, see ``HISTORY.txt``.
3.0.10 (unreleased)
-------------------

- ...

- Test fix for machines that do not define `localhost`.

3.0.9 (2014-08-08)
------------------
Expand Down
14 changes: 9 additions & 5 deletions src/AccessControl/users.py
Original file line number Diff line number Diff line change
Expand Up @@ -432,14 +432,18 @@ def domainSpecMatch(spec, request):

if not host:
try:
host=socket.gethostbyaddr(addr)[0]
except:
host = socket.gethostbyaddr(addr)[0]
except Exception:
pass

if not addr:
try:
addr=socket.gethostbyname(host)
except:
pass
addr = socket.gethostbyname(host)
except Exception:
# always define localhost, even if the underlying system
# doesn't know about it, this fixes tests on travis
if host == 'localhost':
addr = '127.0.0.1'

_host = host.split('.')
_addr = addr.split('.')
Expand Down

0 comments on commit 7b9fb00

Please sign in to comment.