The branch, master has been updated
       via  fed8b65... s4:upgradeschema.py Update to reflect recent change in 
provision
       via  604c291... s4:upgradeschema.py Cleanup
      from  1ad2383... Remove call into reduce_name if case sensitive. This 
allows us to pass RAW-CHKPATH when case sensitive = yes, but isn't the correct 
way to do it. I'm testing a larger patch to smbd/filename.c that should fix 
this correctly, and will add a torture test to ensure RAW-CHKPATH is run 
against a case sensitive share once this is done. Jeremy.

http://gitweb.samba.org/?p=samba.git;a=shortlog;h=master


- Log -----------------------------------------------------------------
commit fed8b652bf4e66b893f3fe230e2fe9bdbed3f94f
Author: Matthieu Patou <[email protected]>
Date:   Tue Nov 24 18:52:36 2009 +0300

    s4:upgradeschema.py Update to reflect recent change in provision
    
    - define which modules we want to use when loading the ldb
    - move partition in sam.ldb.d dir
    
    Changes have been suggested by Andrew Bartlett.
    
    (commit message clarified by Andrew Bartlett)
    Signed-off-by: Andrew Bartlett <[email protected]>

commit 604c291bdd4aae8e9be734967db3a0a64c2e0f38
Author: Matthieu Patou <[email protected]>
Date:   Tue Nov 24 17:02:59 2009 +0300

    s4:upgradeschema.py Cleanup
    
    - remove some useless comments
    - remove hardcoded paths
    
    (commit message clarified by Andrew Bartlett)
    Signed-off-by: Andrew Bartlett <[email protected]>

-----------------------------------------------------------------------

Summary of changes:
 source4/scripting/bin/upgradeschema.py |   65 ++++++++++++++++----------------
 1 files changed, 32 insertions(+), 33 deletions(-)


Changeset truncated at 500 lines:

diff --git a/source4/scripting/bin/upgradeschema.py 
b/source4/scripting/bin/upgradeschema.py
index cf8262a..8cdee55 100755
--- a/source4/scripting/bin/upgradeschema.py
+++ b/source4/scripting/bin/upgradeschema.py
@@ -129,7 +129,6 @@ setup_dir = opts.setupdir
 if setup_dir is None:
     setup_dir = find_setup_dir()
 
-setup_dir = "/usr/local/src/samba4/source4/setup"
 session = system_session()
 
 # Create an array of backlinked attributes
@@ -171,18 +170,17 @@ def 
guess_names_from_current_provision(credentials,session_info,paths):
        names.dnsdomain = names.realm
        names.realm = string.upper(names.realm)
        # netbiosname
-       secrets_ldb = Ldb(paths.secrets, session_info=session_info, 
credentials=credentials,lp=lp)
+       secrets_ldb = Ldb(paths.secrets, session_info=session_info, 
credentials=credentials,lp=lp, options=["modules:samba_secrets"])
        # Get the netbiosname first (could be obtained from smb.conf in theory)
        attrs = ["sAMAccountName"]
        res = 
secrets_ldb.search(expression="(flatname=%s)"%names.domain,base="CN=Primary 
Domains", scope=SCOPE_SUBTREE, attrs=attrs)
        names.netbiosname = str(res[0]["sAMAccountName"]).replace("$","")
 
-       #partitions = get_partitions(credentials,session_info,paths,lp)
        names.smbconf = smbconf
-       samdb = SamDB(paths.samdb, session_info=session_info,
-                                                               
credentials=credentials, lp=lp)
+       #It's important here to let ldb load with the old module or it's quite 
certain that the LDB won't load ... 
+       samdb = Ldb(paths.samdb, session_info=session_info,
+                   credentials=credentials, lp=lp)
        
-       # partitions (schema,config,root)
        # That's a bit simplistic but it's ok as long as we have only 3 
partitions 
        attrs2 = 
["schemaNamingContext","configurationNamingContext","rootDomainNamingContext"]
        res2 = samdb.search(expression="(objectClass=*)",base="", 
scope=SCOPE_BASE, attrs=attrs2)
@@ -348,7 +346,6 @@ def 
handle_security_desc(ischema,att,msgElt,hashallSD,old,new):
 # if it has a certain value or if it's for a certain object or 
 # a class of object. 
 # It can be also if we want to do a merge of value instead of a simple replace 
-
 def handle_special_case(att,delta,new,old,ischema):
        flag = delta.get(att).flags()
        if (att == "gPLink" or att == "gPCFileSysPath") and flag ==  
ldb.FLAG_MOD_REPLACE and str(new[0].dn).lower() == str(old[0].dn).lower():
@@ -393,18 +390,18 @@ def handle_special_case(att,delta,new,old,ischema):
        return 0
 
 def update_secrets(newpaths,paths,creds,session):
-       newsam_ldb = Ldb(newpaths.secrets, session_info=session, 
credentials=creds,lp=lp)
-       sam_ldb = Ldb(paths.secrets, session_info=session, 
credentials=creds,lp=lp)
-       res = newsam_ldb.search(expression="d...@modules",base="", 
scope=SCOPE_SUBTREE)
-       res2 = sam_ldb.search(expression="d...@modules",base="", 
scope=SCOPE_SUBTREE)
-       delta = sam_ldb.msg_diff(res2[0],res[0])
+       newsecrets_ldb = Ldb(newpaths.secrets, session_info=session, 
credentials=creds,lp=lp)
+       secrets_ldb = Ldb(paths.secrets, session_info=session, 
credentials=creds,lp=lp, options=["modules:samba_secrets"])
+       res = newsecrets_ldb.search(expression="d...@modules",base="", 
scope=SCOPE_SUBTREE)
+       res2 = secrets_ldb.search(expression="d...@modules",base="", 
scope=SCOPE_SUBTREE)
+       delta = secrets_ldb.msg_diff(res2[0],res[0])
        delta.dn = res2[0].dn
-       sam_ldb.modify(delta)   
+       secrets_ldb.modify(delta)       
 
-       newsam_ldb = Ldb(newpaths.secrets, session_info=session, 
credentials=creds,lp=lp)
-       sam_ldb = Ldb(paths.secrets, session_info=session, 
credentials=creds,lp=lp)
-       res = newsam_ldb.search(expression="objectClass=top",base="", 
scope=SCOPE_SUBTREE,attrs=["dn"])
-       res2 = sam_ldb.search(expression="objectClass=top",base="", 
scope=SCOPE_SUBTREE,attrs=["dn"])
+       newsecrets_ldb = Ldb(newpaths.secrets, session_info=session, 
credentials=creds,lp=lp)
+       secrets_ldb = Ldb(paths.secrets, session_info=session, 
credentials=creds,lp=lp)
+       res = newsecrets_ldb.search(expression="objectClass=top",base="", 
scope=SCOPE_SUBTREE,attrs=["dn"])
+       res2 = secrets_ldb.search(expression="objectClass=top",base="", 
scope=SCOPE_SUBTREE,attrs=["dn"])
        hash_new = {}
        hash = {}
        listMissing = []
@@ -424,21 +421,21 @@ def update_secrets(newpaths,paths,creds,session):
                else:
                        listPresent.append(hash_new[k])
        for entry in listMissing:
-               res = newsam_ldb.search(expression="dn=%s"%entry,base="", 
scope=SCOPE_SUBTREE)
-               res2 = sam_ldb.search(expression="dn=%s"%entry,base="", 
scope=SCOPE_SUBTREE)
-               delta = sam_ldb.msg_diff(empty,res[0])
+               res = newsecrets_ldb.search(expression="dn=%s"%entry,base="", 
scope=SCOPE_SUBTREE)
+               res2 = secrets_ldb.search(expression="dn=%s"%entry,base="", 
scope=SCOPE_SUBTREE)
+               delta = secrets_ldb.msg_diff(empty,res[0])
                for att in hashAttrNotCopied.keys():
                        delta.remove(att)
                message(CHANGE,"Entry %s is missing from secrets.ldb"%res[0].dn)
                for att in delta:
                        message(CHANGE," Adding attribute %s"%att)
                delta.dn = res[0].dn
-               sam_ldb.add(delta)      
+               secrets_ldb.add(delta)  
 
        for entry in listPresent:
-               res = newsam_ldb.search(expression="dn=%s"%entry,base="", 
scope=SCOPE_SUBTREE)
-               res2 = sam_ldb.search(expression="dn=%s"%entry,base="", 
scope=SCOPE_SUBTREE)
-               delta = sam_ldb.msg_diff(res2[0],res[0])
+               res = newsecrets_ldb.search(expression="dn=%s"%entry,base="", 
scope=SCOPE_SUBTREE)
+               res2 = secrets_ldb.search(expression="dn=%s"%entry,base="", 
scope=SCOPE_SUBTREE)
+               delta = secrets_ldb.msg_diff(res2[0],res[0])
                i=0
                for att in hashAttrNotCopied.keys():
                        delta.remove(att)
@@ -448,7 +445,8 @@ def update_secrets(newpaths,paths,creds,session):
                                message(CHANGE," Adding/Changing attribute %s 
to %s"%(att,res2[0].dn))
                                
                delta.dn = res2[0].dn
-               sam_ldb.modify(delta)   
+               secrets_ldb.modify(delta)       
+
 # Check difference between the current provision and the reference provision.
 # It looks for all object which base DN is name if ischema is false then scan 
is done in 
 # cross partition mode.
@@ -463,7 +461,7 @@ def 
check_diff_name(newpaths,paths,creds,session,basedn,names,ischema):
        res2 = []
        # Connect to the reference provision and get all the attribute in the 
partition referred by name
        newsam_ldb = Ldb(newpaths.samdb, session_info=session, 
credentials=creds,lp=lp)
-       sam_ldb = Ldb(paths.samdb, session_info=session, 
credentials=creds,lp=lp)
+       sam_ldb = Ldb(paths.samdb, session_info=session, 
credentials=creds,lp=lp, options=["modules:samba_dsdb"])
        if ischema:
                res = newsam_ldb.search(expression="objectClass=*",base=basedn, 
scope=SCOPE_SUBTREE,attrs=["dn"])
                res2 = sam_ldb.search(expression="objectClass=*",base=basedn, 
scope=SCOPE_SUBTREE,attrs=["dn"])
@@ -510,7 +508,6 @@ def 
check_diff_name(newpaths,paths,creds,session,basedn,names,ischema):
        print "There are %d missing objects"%(len(listMissing))
        for dn in listMissing:
                res = 
newsam_ldb.search(expression="dn=%s"%(str(dn)),base=basedn, 
scope=SCOPE_SUBTREE,controls=["search_options:1:2"])
-               #print >>sys.stderr, "@@@"+str(dn)
                delta = sam_ldb.msg_diff(empty,res[0])
                for att in hashAttrNotCopied.keys():
                        delta.remove(att)
@@ -642,8 +639,6 @@ def rmall(topdir):
 # For each partition check the differences
 
 def check_diff(newpaths,paths,creds,session,names):
-       #for name in [str(names.schemadn), str(names.configdn), 
str(names.rootdn)] :
-       #for name in [str(names.configdn)] :
        print "Copy samdb"
        shutil.copy(newpaths.samdb,paths.samdb)
 
@@ -651,14 +646,19 @@ def check_diff(newpaths,paths,creds,session,names):
        schemaldb=os.path.join(paths.private_dir,"schema.ldb")
        configldb=os.path.join(paths.private_dir,"configuration.ldb")
        usersldb=os.path.join(paths.private_dir,"users.ldb")
+       samldbdir=os.path.join(paths.private_dir,"sam.ldb.d")
+
+       if not os.path.isdir(samldbdir):
+               os.mkdir(samldbdir)
+               os.chmod(samldbdir,0700)
        if os.path.isfile(schemaldb):
-               
shutil.copy(schemaldb,os.path.join(paths.private_dir,"%s.ldb"%str(names.schemadn).upper()))
+               
shutil.copy(schemaldb,os.path.join(samldbdir,"%s.ldb"%str(names.schemadn).upper()))
                os.remove(schemaldb)
        if os.path.isfile(usersldb):
-               
shutil.copy(usersldb,os.path.join(paths.private_dir,"%s.ldb"%str(names.rootdn).upper()))
+               
shutil.copy(usersldb,os.path.join(samldbdir,"%s.ldb"%str(names.rootdn).upper()))
                os.remove(usersldb)
        if os.path.isfile(configldb):
-               
shutil.copy(configldb,os.path.join(paths.private_dir,"%s.ldb"%str(names.configdn).upper()))
+               
shutil.copy(configldb,os.path.join(samldbdir,"%s.ldb"%str(names.configdn).upper()))
                os.remove(configldb)
        
shutil.copy(os.path.join(newpaths.private_dir,"privilege.ldb"),os.path.join(paths.private_dir,"privilege.ldb"))
 
@@ -685,7 +685,6 @@ names = 
guess_names_from_current_provision(creds,session,paths)
 print_names(names)
 # With all this information let's create a fresh new provision used as 
reference
 provisiondir = newprovision(names,setup_dir,creds,session,smbconf)
-#provisiondir = "/home/mat/provision12962"
 # Get file paths of this new provision
 newpaths = get_paths(targetdir=provisiondir)
 populate_backlink(newpaths,creds,session,names.schemadn)


-- 
Samba Shared Repository

Reply via email to