diff options
author | Matthias Dieter Wallnöfer <mwallnoefer@yahoo.de> | 2009-11-27 15:50:26 +0100 |
---|---|---|
committer | Matthias Dieter Wallnöfer <mwallnoefer@yahoo.de> | 2009-11-27 16:06:07 +0100 |
commit | 0cc45b47dc787abb2c3c31e4fc824798d9f3efe9 (patch) | |
tree | 21bda0714d9a43a8116a33212c35f7fd82b4fe0b /source4/scripting/python | |
parent | bd6c133e506fdb5dee13e0a144ef99c6d452be42 (diff) | |
download | samba-0cc45b47dc787abb2c3c31e4fc824798d9f3efe9.tar.gz samba-0cc45b47dc787abb2c3c31e4fc824798d9f3efe9.tar.bz2 samba-0cc45b47dc787abb2c3c31e4fc824798d9f3efe9.zip |
s4:upgrade.py - rework to make the upgrade s3 -> s4 possible again
Able to read basic settings "workgroup", "realm", "netbios name" and the
function mode from the s3 "smb.conf" and use them for the provision of s4.
Diffstat (limited to 'source4/scripting/python')
-rw-r--r-- | source4/scripting/python/samba/upgrade.py | 144 |
1 files changed, 72 insertions, 72 deletions
diff --git a/source4/scripting/python/samba/upgrade.py b/source4/scripting/python/samba/upgrade.py index 89cf767dae..44b43a1a82 100644 --- a/source4/scripting/python/samba/upgrade.py +++ b/source4/scripting/python/samba/upgrade.py @@ -2,6 +2,7 @@ # # backend code for upgrading from Samba3 # Copyright Jelmer Vernooij 2005-2007 +# Copyright Matthias Dieter Wallnöfer 2009 # Released under the GNU GPL v3 or later # @@ -9,7 +10,7 @@ __docformat__ = "restructuredText" -from provision import provision, FILL_DRS +from provision import provision import grp import ldb import time @@ -92,7 +93,6 @@ def import_sam_account(samldb,acc,domaindn,domainsid): "ntPwdHash:": acc.nt_password, }) - def import_sam_group(samldb, sid, gid, sid_name_use, nt_name, comment, domaindn): """Upgrade a SAM group. @@ -132,7 +132,6 @@ def import_sam_group(samldb, sid, gid, sid_name_use, nt_name, comment, domaindn) "samba3SidNameUse": str(sid_name_use) }) - def import_idmap(samdb,samba3_idmap,domaindn): """Import idmap data. @@ -157,7 +156,6 @@ def import_idmap(samdb,samba3_idmap,domaindn): "type": "group", "unixID": str(gid)}) - def import_wins(samba4_winsdb, samba3_winsdb): """Import settings from a Samba3 WINS database. @@ -208,73 +206,6 @@ def import_wins(samba4_winsdb, samba3_winsdb): "objectClass": "winsMaxVersion", "maxVersion": str(version_id)}) -def upgrade_provision(samba3, setup_dir, message, credentials, session_info, smbconf, targetdir): - oldconf = samba3.get_conf() - - if oldconf.get("domain logons") == "True": - serverrole = "domain controller" - else: - if oldconf.get("security") == "user": - serverrole = "standalone" - else: - serverrole = "member server" - - domainname = oldconf.get("workgroup") - if domainname: - domainname = str(domainname) - realm = oldconf.get("realm") - netbiosname = oldconf.get("netbios name") - - secrets_db = samba3.get_secrets_db() - - if domainname is None: - domainname = secrets_db.domains()[0] - message("No domain specified in smb.conf file, assuming '%s'" % domainname) - - if realm is None: - realm = domainname.lower() - message("No realm specified in smb.conf file, assuming '%s'\n" % realm) - - domainguid = secrets_db.get_domain_guid(domainname) - domainsid = secrets_db.get_sid(domainname) - if domainsid is None: - message("Can't find domain secrets for '%s'; using random SID\n" % domainname) - - if netbiosname is not None: - machinepass = secrets_db.get_machine_password(netbiosname) - else: - machinepass = None - - result = provision(setup_dir=setup_dir, message=message, - samdb_fill=FILL_DRS, smbconf=smbconf, session_info=session_info, - credentials=credentials, realm=realm, - domain=domainname, domainsid=domainsid, domainguid=domainguid, - machinepass=machinepass, serverrole=serverrole, targetdir=targetdir) - - # FIXME: import_wins(Ldb(result.paths.winsdb), samba3.get_wins_db()) - - # FIXME: import_registry(registry.Registry(), samba3.get_registry()) - - # FIXME: import_idmap(samdb,samba3.get_idmap_db(),domaindn) - - groupdb = samba3.get_groupmapping_db() - for sid in groupdb.groupsids(): - (gid, sid_name_use, nt_name, comment) = groupdb.get_group(sid) - # FIXME: import_sam_group(samdb, sid, gid, sid_name_use, nt_name, comment, domaindn) - - # FIXME: Aliases - - passdb = samba3.get_sam_db() - for name in passdb: - user = passdb[name] - #FIXME: import_sam_account(result.samdb, user, domaindn, domainsid) - - if hasattr(passdb, 'ldap_url'): - message("Enabling Samba3 LDAP mappings for SAM database") - - enable_samba3sam(result.samdb, passdb.ldap_url) - - def enable_samba3sam(samdb, ldapurl): """Enable Samba 3 LDAP URL database. @@ -290,7 +221,6 @@ replace: @LIST samdb.add({"dn": "@MAP=samba3sam", "@MAP_URL": ldapurl}) - smbconf_keep = [ "dos charset", "unix charset", @@ -434,3 +364,73 @@ def import_registry(samba4_registry, samba3_regdb): key_handle.set_value(value_name, value_type, value_data) +def upgrade_provision(samba3, setup_dir, message, credentials, session_info, + smbconf, targetdir): + oldconf = samba3.get_conf() + + if oldconf.get("domain logons") == "True": + serverrole = "domain controller" + else: + if oldconf.get("security") == "user": + serverrole = "standalone" + else: + serverrole = "member server" + + domainname = oldconf.get("workgroup") + realm = oldconf.get("realm") + netbiosname = oldconf.get("netbios name") + + secrets_db = samba3.get_secrets_db() + + if domainname is None: + domainname = secrets_db.domains()[0] + message("No domain specified in smb.conf file, assuming '%s'" % domainname) + + if realm is None: + if oldconf.get("domain logons") == "True": + message("No realm specified in smb.conf file and being a DC. That upgrade path doesn't work! Please add a 'realm' directive to your old smb.conf to let us know which one you want to use (generally it's the upcased DNS domainname).") + return + else: + realm = domainname.upper() + message("No realm specified in smb.conf file, assuming '%s'" % realm) + + domainguid = secrets_db.get_domain_guid(domainname) + domainsid = secrets_db.get_sid(domainname) + if domainsid is None: + message("Can't find domain secrets for '%s'; using random SID" % domainname) + + if netbiosname is not None: + machinepass = secrets_db.get_machine_password(netbiosname) + else: + machinepass = None + + result = provision(setup_dir=setup_dir, message=message, + session_info=session_info, credentials=credentials, + targetdir=targetdir, realm=realm, domain=domainname, + domainguid=domainguid, domainsid=domainsid, + hostname=netbiosname, machinepass=machinepass, + serverrole=serverrole) + + # FIXME: import_wins(Ldb(result.paths.winsdb), samba3.get_wins_db()) + + # FIXME: import_registry(registry.Registry(), samba3.get_registry()) + + # FIXME: import_idmap(samdb,samba3.get_idmap_db(),domaindn) + + groupdb = samba3.get_groupmapping_db() + for sid in groupdb.groupsids(): + (gid, sid_name_use, nt_name, comment) = groupdb.get_group(sid) + # FIXME: import_sam_group(samdb, sid, gid, sid_name_use, nt_name, comment, domaindn) + + # FIXME: Aliases + + passdb = samba3.get_sam_db() + for name in passdb: + user = passdb[name] + #FIXME: import_sam_account(result.samdb, user, domaindn, domainsid) + + if hasattr(passdb, 'ldap_url'): + message("Enabling Samba3 LDAP mappings for SAM database") + + enable_samba3sam(result.samdb, passdb.ldap_url) + |