summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMatthias Dieter Wallnöfer <mwallnoefer@yahoo.de>2010-02-21 21:30:42 +0100
committerMatthias Dieter Wallnöfer <mwallnoefer@yahoo.de>2010-02-21 21:39:47 +0100
commitf2eac3b6ea6103823dfe034cb30a610599df44ce (patch)
treea7ba96968f9b878c517de024e614e61bd09c19fc
parent017e401dedcd22feeb28c49aee9592befdce1e69 (diff)
downloadsamba-f2eac3b6ea6103823dfe034cb30a610599df44ce.tar.gz
samba-f2eac3b6ea6103823dfe034cb30a610599df44ce.tar.bz2
samba-f2eac3b6ea6103823dfe034cb30a610599df44ce.zip
s4:provision.py - try to use other addresses than "127.0.0.x" and "::1"
On production systems a user for sure strongly disagrees to use local IP addresses (how should the server be accessible?). Therefore if the user didn't specify an IP as provision option and in the "/etc/hosts" file we have at least one not-local IP which resolves to our hostname use this or one of them. Notice: if a host has more public IP addresses with the same name assigned the behaviour is non-deterministic (well, okay - by the entries order it is). But then the user is invited to specify the host IP manually. This should address bug #5484.
-rw-r--r--source4/scripting/python/samba/provision.py12
1 files changed, 10 insertions, 2 deletions
diff --git a/source4/scripting/python/samba/provision.py b/source4/scripting/python/samba/provision.py
index 1e1bf480f5..900df89484 100644
--- a/source4/scripting/python/samba/provision.py
+++ b/source4/scripting/python/samba/provision.py
@@ -1213,13 +1213,21 @@ def provision(setup_dir, message, session_info,
if hostip is None:
try:
- hostip = socket.getaddrinfo(names.hostname, None, socket.AF_INET, socket.AI_CANONNAME, socket.IPPROTO_IP)[0][-1][0]
+ 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
if hostip6 is None:
try:
- hostip6 = socket.getaddrinfo(names.hostname, None, socket.AF_INET6, socket.AI_CANONNAME, socket.IPPROTO_IP)[0][-1][0]
+ for ip in socket.getaddrinfo(names.hostname, None, socket.AF_INET6, socket.AI_CANONNAME, socket.IPPROTO_IP):
+ if hostip6 is None:
+ hostip6 = ip[-1][0]
+ if hostip6 == '::1' and ip[-1][0] != '::1':
+ hostip6 = ip[-1][0]
except socket.gaierror, (socket.EAI_NODATA, msg):
hostip6 = None