Merge branch 'v4-0-test' of ssh://git.samba.org/data/git/samba into v4-0-wsgi
authorJelmer Vernooij <jelmer@samba.org>
Fri, 23 May 2008 14:24:07 +0000 (16:24 +0200)
committerJelmer Vernooij <jelmer@samba.org>
Fri, 23 May 2008 14:24:07 +0000 (16:24 +0200)
Conflicts:

source/scripting/python/samba/provision.py
(This used to be commit d27de633656f8a699222df77c4c58326890889a2)

1  2 
source4/scripting/python/samba/provision.py

@@@ -342,54 -347,69 +351,55 @@@ def guess_names(lp=None, hostname=None
      return names
      
  
 -def load_or_make_smbconf(smbconf, setup_path, hostname, domain, realm, serverrole, targetdir):
 -    if targetdir is not None:
 -        if not os.path.exists(targetdir):
 -            os.mkdir(targetdir)
 -        if not os.path.exists(os.path.join(targetdir, "etc")):
 -           os.mkdir(os.path.join(targetdir, "etc"))
 +def make_smbconf(smbconf, setup_path, hostname, domain, realm, serverrole, 
 +                 targetdir):
 +    if hostname is None:
 +        hostname = socket.gethostname().split(".")[0].lower()
  
 -        smbconf = os.path.join(targetdir, "etc", "smb.conf")
 +    if serverrole is None:
 +        serverrole = "standalone"
  
 -    # only install a new smb.conf if there isn't one there already
 +    assert serverrole in ("domain controller", "member server", "standalone")
 +    if serverrole == "domain controller":
 +        smbconfsuffix = "dc"
 +    elif serverrole == "member server":
 +        smbconfsuffix = "member"
 +    elif serverrole == "standalone":
 +        smbconfsuffix = "standalone"
  
 -    if not os.path.exists(smbconf):
 -        if hostname is None:
 -            hostname = socket.gethostname().split(".")[0].lower()
 +    assert domain is not None
 +    assert realm is not None
  
 -        if serverrole is None:
 -            serverrole = "standalone"
 +    default_lp = param.LoadParm()
 +    #Load non-existant file
 +    default_lp.load(smbconf)
 +    
 +    if targetdir is not None:
 +        privatedir_line = "private dir = " + os.path.abspath(os.path.join(targetdir, "private"))
 +        lockdir_line = "lock dir = " + os.path.abspath(targetdir)
  
 -        assert serverrole in ("domain controller", "member server", "standalone")
 -        if serverrole == "domain controller":
 -            smbconfsuffix = "dc"
 -        elif serverrole == "member server":
 -            smbconfsuffix = "member"
 -        elif serverrole == "standalone":
 -            smbconfsuffix = "standalone"
 -
 -        assert domain is not None
 -        assert realm is not None
 -
 -        default_lp = param.LoadParm()
 -        #Load non-existant file
 -        default_lp.load(smbconf)
 -        
 -        if targetdir is not None:
 -            privatedir_line = "private dir = " + os.path.abspath(os.path.join(targetdir, "private"))
 -            lockdir_line = "lock dir = " + os.path.abspath(targetdir)
 +        default_lp.set("lock dir", os.path.abspath(targetdir))
 +    else:
 +        privatedir_line = ""
 +        lockdir_line = ""
  
 -            default_lp.set("lock dir", os.path.abspath(targetdir))
 -        else:
 -          privatedir_line = ""
 -          lockdir_line = ""
 -
 -        sysvol = os.path.join(default_lp.get("lock dir"), "sysvol")
 -        netlogon = os.path.join(sysvol, realm.lower(), "scripts")
 -
 -        setup_file(setup_path("provision.smb.conf.%s" % smbconfsuffix), 
 -                   smbconf, {
 -                "HOSTNAME": hostname,
 -                "DOMAIN": domain,
 -                "REALM": realm,
 -                "SERVERROLE": serverrole,
 -                "NETLOGONPATH": netlogon,
 -                "SYSVOLPATH": sysvol,
 -                "PRIVATEDIR_LINE": privatedir_line,
 -                "LOCKDIR_LINE": lockdir_line
 -                })
 +    sysvol = os.path.join(default_lp.get("lock dir"), "sysvol")
 +    netlogon = os.path.join(sysvol, realm.lower(), "scripts")
  
 -    lp = param.LoadParm()
 -    lp.load(smbconf)
 +    setup_file(setup_path("provision.smb.conf.%s" % smbconfsuffix), 
 +               smbconf, {
 +            "HOSTNAME": hostname,
 +            "DOMAIN": domain,
 +            "REALM": realm,
 +            "SERVERROLE": serverrole,
 +            "NETLOGONPATH": netlogon,
 +            "SYSVOLPATH": sysvol,
 +            "PRIVATEDIR_LINE": privatedir_line,
 +            "LOCKDIR_LINE": lockdir_line
 +            })
  
 -    return lp
  
  def setup_name_mappings(samdb, idmap, sid, domaindn, root_uid, nobody_uid,
                          users_gid, wheel_gid):
      """setup reasonable name mappings for sam names to unix names.
@@@ -917,22 -943,12 +925,22 @@@ def provision(setup_dir, message, sessi
      if aci is None:
          aci = "# no aci for local ldb"
  
 -    lp = load_or_make_smbconf(smbconf, setup_path, hostname, domain, realm, serverrole, targetdir)
 +    if smbconf is None:
 +        os.makedirs(os.path.join(targetdir, "etc"))
 +        smbconf = os.path.join(targetdir, "etc", "smb.conf")
 +
 +    # only install a new smb.conf if there isn't one there already
 +    if not os.path.exists(smbconf):
 +        make_smbconf(smbconf, setup_path, hostname, domain, realm, serverrole, 
 +                     targetdir)
 +
 +    lp = param.LoadParm()
 +    lp.load(smbconf)
  
      names = guess_names(lp=lp, hostname=hostname, domain=domain, 
-                         dnsdomain=realm, serverrole=serverrole, 
-                         sitename=sitename, rootdn=rootdn, domaindn=domaindn, 
-                         configdn=configdn, schemadn=schemadn)
+                         dnsdomain=realm, serverrole=serverrole, sitename=sitename,
+                         rootdn=rootdn, domaindn=domaindn, configdn=configdn, schemadn=schemadn,
+                         serverdn=serverdn)
  
      paths = provision_paths_from_lp(lp, names.dnsdomain)
  
@@@ -1070,15 -1109,15 +1102,15 @@@ def provision_become_dc(setup_dir=None
                          policyguid=None, invocationid=None, machinepass=None, 
                          dnspass=None, root=None, nobody=None, nogroup=None, users=None, 
                          wheel=None, backup=None, aci=None, serverrole=None, 
-                         ldap_backend=None, ldap_backend_type=None, sitename=DEFAULTSITE):
+                         ldap_backend=None, ldap_backend_type=None, sitename=None):
  
      def message(text):
 -      """print a message if quiet is not set."""
 +        """print a message if quiet is not set."""
          print text
  
-     provision(setup_dir, message, system_session(), None,
+     return provision(setup_dir, message, system_session(), None,
                smbconf=smbconf, targetdir=targetdir, samdb_fill=FILL_DRS, realm=realm, 
-               rootdn=rootdn, domaindn=domaindn, schemadn=schemadn, configdn=configdn, 
+               rootdn=rootdn, domaindn=domaindn, schemadn=schemadn, configdn=configdn, serverdn=serverdn,
                domain=domain, hostname=hostname, hostip="127.0.0.1", domainsid=domainsid, machinepass=machinepass, serverrole="domain controller", sitename=sitename);
      
  
@@@ -1171,19 -1209,18 +1213,18 @@@ def provision_backend(setup_dir=None, m
                      "SCHEMADN": names.schemadn,
                      })
          
-         setup_file(setup_path("fedora-partitions.ldif"), paths.fedoradspartitions, 
-                    {"CONFIGDN": names.configdn,
-                     "SCHEMADN": names.schemadn,
-                     })
          mapping = "schema-map-fedora-ds-1.0"
          backend_schema = "99_ad.ldif"
+         
+         slapdcommand="Initailise Fedora DS with: setup-ds.pl --file=%s" % paths.fedoradsinf
+        
      elif ldap_backend_type == "openldap":
          attrs = ["linkID", "lDAPDisplayName"]
 -      res = schemadb.search(expression="(&(&(linkID=*)(!(linkID:1.2.840.113556.1.4.803:=1)))(objectclass=attributeSchema))", base=names.schemadn, scope=SCOPE_SUBTREE, attrs=attrs);
 +    res = schemadb.search(expression="(&(&(linkID=*)(!(linkID:1.2.840.113556.1.4.803:=1)))(objectclass=attributeSchema))", base=names.schemadn, scope=SCOPE_SUBTREE, attrs=attrs);
  
 -      memberof_config = "# Generated from schema in " + schemadb_path + "\n";
 -      refint_attributes = "";
 -      for i in range (0, len(res)):
 +    memberof_config = "# Generated from schema in " + schemadb_path + "\n";
 +    refint_attributes = "";
 +    for i in range (0, len(res)):
              linkid = res[i]["linkID"][0]
              linkid = str(int(linkid) + 1)
              expression = "(&(objectclass=attributeSchema)(linkID=" + (linkid) + "))"
@@@ -1216,19 -1253,21 +1257,21 @@@ refint_attributes""" + refint_attribute
                      "LDAPMANAGERDN": names.ldapmanagerdn,
                      "LDAPMANAGERPASS": adminpass,
                      "MEMBEROF_CONFIG": memberof_config})
 -        setup_file(setup_path("modules.conf"), paths.modulesconf,
 +    setup_file(setup_path("modules.conf"), paths.modulesconf,
                     {"REALM": names.realm})
          
-     setup_db_config(setup_path, file, os.path.join(paths.ldapdir, "db", "user"))
-     setup_db_config(setup_path, file, os.path.join(paths.ldapdir, "db", "config"))
-     setup_db_config(setup_path, file, os.path.join(paths.ldapdir, "db", "schema"))
-     mapping = "schema-map-openldap-2.3"
-     backend_schema = "backend-schema.schema"
-         
-     ldapi_uri = "ldapi://" + urllib.quote(os.path.join(paths.private_dir, "ldap", "ldapi"), safe="")
-     message("Start slapd with: slapd -f " + paths.ldapdir + "/slapd.conf -h " + ldapi_uri)
-                 
+         setup_db_config(setup_path, os.path.join(paths.ldapdir, os.path.join("db", "user")))
+         setup_db_config(setup_path, os.path.join(paths.ldapdir, os.path.join("db", "config")))
+         setup_db_config(setup_path, os.path.join(paths.ldapdir, os.path.join("db", "schema")))
+         mapping = "schema-map-openldap-2.3"
+         backend_schema = "backend-schema.schema"
+         ldapi_uri = "ldapi://" + urllib.quote(os.path.join(paths.private_dir, "ldap", "ldapi"), safe="")
+         if ldap_backend_port is not None:
+             server_port_string = " -h ldap://0.0.0.0:%d" % ldap_backend_port
+         else:
+             server_port_string = ""
+         slapdcommand="Start slapd with:    slapd -f " + paths.ldapdir + "/slapd.conf -h " + ldapi_uri + server_port_string
  
      schema_command = "bin/ad2oLschema --option=convert:target=" + ldap_backend_type + " -I " + setup_path(mapping) + " -H tdb://" + schemadb_path + " -O " + os.path.join(paths.ldapdir, backend_schema);