diff options
author | Matthias Dieter Wallnöfer <mwallnoefer@yahoo.de> | 2010-03-04 10:29:33 +0100 |
---|---|---|
committer | Matthias Dieter Wallnöfer <mwallnoefer@yahoo.de> | 2010-03-04 10:38:36 +0100 |
commit | af6f59468ab157d125e14a649ee1d55bd17e8d1a (patch) | |
tree | 09954db83d14c5272afaa1f1f1faf0f9a1dd642d /source4 | |
parent | 8a8c2de29f95ac81e9899264cf86ebea22053782 (diff) | |
download | samba-af6f59468ab157d125e14a649ee1d55bd17e8d1a.tar.gz samba-af6f59468ab157d125e14a649ee1d55bd17e8d1a.tar.bz2 samba-af6f59468ab157d125e14a649ee1d55bd17e8d1a.zip |
s4:provision - use the new "interface_ips" python call to detect the right host IPv4 address
Inform the user when there are more possibilities (so he can check for the
right address and otherwise he is able to do an immediate reprovision) and no
possibility at all (then we fall back to the loopback address "127.0.0.1" - this
is thought for testing purposes).
I think this should be enough for closing bug #5484.
Diffstat (limited to 'source4')
-rw-r--r-- | source4/scripting/python/samba/provision.py | 16 |
1 files changed, 8 insertions, 8 deletions
diff --git a/source4/scripting/python/samba/provision.py b/source4/scripting/python/samba/provision.py index 450881c41f..cb90141730 100644 --- a/source4/scripting/python/samba/provision.py +++ b/source4/scripting/python/samba/provision.py @@ -1182,14 +1182,14 @@ def provision(setup_dir, message, session_info, paths.bind_gid = bind_gid if hostip is None: - try: - for ip in socket.getaddrinfo(names.hostname, None, socket.AF_INET, socket.AI_CANONNAME, socket.IPPROTO_IP): - if hostip is None: - hostip = ip[-1][0] - if hostip.startswith('127.0.0.') and (not ip[-1][0].startswith('127.0.0.')): - hostip = ip[-1][0] - except socket.gaierror, (socket.EAI_NODATA, msg): - hostip = None + hostips = glue.interface_ips(lp) + if len(hostips) == 0: + message("No external IPv4 address has been found: I use the loopback.") + hostip = '127.0.0.1' + else: + hostip = hostips[0] + if len(hostips) > 1: + message("More than one IPv4 address found: I use " + hostip + ".") if hostip6 is None: try: |