summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAndrew Tridgell <tridge@samba.org>2011-06-07 12:55:31 +1000
committerAndrew Tridgell <tridge@samba.org>2011-06-07 06:07:24 +0200
commit8acbc3a17435ef330910993aa40b5ec1e4c1dab2 (patch)
tree16bced3d28ab62c606a91f61dcc3376cb9c12a9d
parent3ccb72d7496aadbdf35b0aee3b2384466d9dd3b8 (diff)
downloadsamba-8acbc3a17435ef330910993aa40b5ec1e4c1dab2.tar.gz
samba-8acbc3a17435ef330910993aa40b5ec1e4c1dab2.tar.bz2
samba-8acbc3a17435ef330910993aa40b5ec1e4c1dab2.zip
s4-provision: fixed detection of V4/V6 addresses
Autobuild-User: Andrew Tridgell <tridge@samba.org> Autobuild-Date: Tue Jun 7 06:07:24 CEST 2011 on sn-devel-104
-rw-r--r--source4/scripting/python/samba/provision/__init__.py31
1 files changed, 29 insertions, 2 deletions
diff --git a/source4/scripting/python/samba/provision/__init__.py b/source4/scripting/python/samba/provision/__init__.py
index eb6e01f389..324e76f374 100644
--- a/source4/scripting/python/samba/provision/__init__.py
+++ b/source4/scripting/python/samba/provision/__init__.py
@@ -1465,6 +1465,25 @@ def setsysvolacl(samdb, netlogon, sysvol, gid, domainsid, dnsdomain, domaindn,
set_gpos_acl(sysvol, dnsdomain, domainsid, domaindn, samdb, lp)
+def interface_ips_v4(lp):
+ '''return only IPv4 IPs'''
+ ips = samba.interface_ips(lp, False)
+ ret = []
+ for i in ips:
+ if i.find(':') == -1:
+ ret.append(i)
+ return ret
+
+def interface_ips_v6(lp, linklocal=False):
+ '''return only IPv6 IPs'''
+ ips = samba.interface_ips(lp, False)
+ ret = []
+ for i in ips:
+ if i.find(':') != -1 and (linklocal or i.find('%') == -1):
+ ret.append(i)
+ return ret
+
+
def provision(logger, session_info, credentials, smbconf=None,
targetdir=None, samdb_fill=FILL_FULL, realm=None, rootdn=None,
domaindn=None, schemadn=None, configdn=None, serverdn=None,
@@ -1565,16 +1584,24 @@ def provision(logger, session_info, credentials, smbconf=None,
if hostip is None:
logger.info("Looking up IPv4 addresses")
- hostips = samba.interface_ips(lp, False)
+ hostips = interface_ips_v4(lp)
if len(hostips) == 0:
logger.warning("No external IPv4 address has been found. Using loopback.")
hostip = '127.0.0.1'
else:
hostip = hostips[0]
if len(hostips) > 1:
- logger.warning("More than one IPv4 address found. Using %s.",
+ logger.warning("More than one IPv4 address found. Using %s",
hostip)
+ if hostip6 is None:
+ logger.info("Looking up IPv6 addresses")
+ hostips = interface_ips_v6(lp, linklocal=False)
+ if hostips:
+ hostip6 = hostips[0]
+ if len(hostips) > 1:
+ logger.warning("More than one IPv6 address found. Using %s", hostip6)
+
if serverrole is None:
serverrole = lp.get("server role")