summaryrefslogtreecommitdiff
path: root/source4
diff options
context:
space:
mode:
authorAmitay Isaacs <amitay@gmail.com>2011-09-12 13:14:42 +1000
committerAndrew Bartlett <abartlet@samba.org>2011-09-12 20:42:18 +1000
commitc7c29a3523a721737aa647b2e40e23a0775b3958 (patch)
treec8045ebc63a913c136aa058d6dad30d06abd921e /source4
parentc6a40942b2c5b2f330b73a5513927ffe9ed1af20 (diff)
downloadsamba-c7c29a3523a721737aa647b2e40e23a0775b3958.tar.gz
samba-c7c29a3523a721737aa647b2e40e23a0775b3958.tar.bz2
samba-c7c29a3523a721737aa647b2e40e23a0775b3958.zip
s4-provision: Create private dir for dns in a separate function
Signed-off-by: Andrew Bartlett <abartlet@samba.org>
Diffstat (limited to 'source4')
-rw-r--r--source4/scripting/python/samba/provision/__init__.py41
1 files changed, 29 insertions, 12 deletions
diff --git a/source4/scripting/python/samba/provision/__init__.py b/source4/scripting/python/samba/provision/__init__.py
index 47b7e63619..9f49f44952 100644
--- a/source4/scripting/python/samba/provision/__init__.py
+++ b/source4/scripting/python/samba/provision/__init__.py
@@ -1795,6 +1795,8 @@ def provision(logger, session_info, credentials, smbconf=None,
attribute="objectGUID")
assert isinstance(domainguid, str)
+ create_dns_dir(logger, paths)
+
# Only make a zone file on the first DC, it should be
# replicated with DNS replication
if dns_backend == "BIND9":
@@ -1945,6 +1947,32 @@ def create_phpldapadmin_config(path, ldapi_uri):
{"S4_LDAPI_URI": ldapi_uri})
+def create_dns_dir(logger, paths):
+ """Write out a DNS zone file, from the info in the current database.
+
+ :param logger: Logger object
+ :param paths: paths object
+ """
+ dns_dir = os.path.dirname(paths.dns)
+
+ try:
+ shutil.rmtree(dns_dir, True)
+ except OSError:
+ pass
+
+ os.mkdir(dns_dir, 0770)
+
+ if paths.bind_gid is not None:
+ try:
+ os.chown(dns_dir, -1, paths.bind_gid)
+ # chmod needed to cope with umask
+ os.chmod(dns_dir, 0770)
+ except OSError:
+ if not os.environ.has_key('SAMBA_SELFTEST'):
+ logger.error("Failed to chown %s to bind gid %u" % (
+ dns_dir, paths.bind_gid))
+
+
def create_zone_file(lp, logger, paths, targetdir, dnsdomain,
hostip, hostip6, hostname, realm, domainguid,
ntdsguid):
@@ -1980,15 +2008,6 @@ def create_zone_file(lp, logger, paths, targetdir, dnsdomain,
hostip_host_line = ""
gc_msdcs_ip_line = ""
- dns_dir = os.path.dirname(paths.dns)
-
- try:
- shutil.rmtree(dns_dir, True)
- except OSError:
- pass
-
- os.mkdir(dns_dir, 0775)
-
# we need to freeze the zone while we update the contents
if targetdir is None:
rndc = ' '.join(lp.get("rndc command"))
@@ -2012,15 +2031,13 @@ def create_zone_file(lp, logger, paths, targetdir, dnsdomain,
if paths.bind_gid is not None:
try:
- os.chown(dns_dir, -1, paths.bind_gid)
os.chown(paths.dns, -1, paths.bind_gid)
# chmod needed to cope with umask
- os.chmod(dns_dir, 0775)
os.chmod(paths.dns, 0664)
except OSError:
if not os.environ.has_key('SAMBA_SELFTEST'):
logger.error("Failed to chown %s to bind gid %u" % (
- dns_dir, paths.bind_gid))
+ paths.dns, paths.bind_gid))
if targetdir is None:
os.system(rndc + " unfreeze " + lp.get("realm"))