s4-scripting Rename passdb upgrade routine to avoid conflict with upgradeprovision
authorAndrew Bartlett <abartlet@samba.org>
Thu, 11 Aug 2011 06:19:24 +0000 (16:19 +1000)
committerAndrew Bartlett <abartlet@samba.org>
Sat, 13 Aug 2011 02:30:49 +0000 (12:30 +1000)
source3/passdb/pdb_samba4.c
source4/scripting/python/samba/upgrade.py
source4/setup/upgrade_from_s3

index 35316d71d4bdf0236fd739b8c6a9e84fde5c4677..df51dc16602c5df9cea8828152bc6a6ad7576558 100644 (file)
@@ -33,6 +33,7 @@
 #include "source4/auth/session.h"
 #include "source4/auth/system_session_proto.h"
 #include "source4/param/param.h"
 #include "source4/auth/session.h"
 #include "source4/auth/system_session_proto.h"
 #include "source4/param/param.h"
+#include "source4/dsdb/common/util.h"
 
 struct pdb_samba4_state {
        struct tevent_context *ev;
 
 struct pdb_samba4_state {
        struct tevent_context *ev;
@@ -338,7 +339,7 @@ static int pdb_samba4_replace_by_sam(struct pdb_samba4_state *state,
        const char *pw;
        struct ldb_message *msg;
        struct ldb_request *req;
        const char *pw;
        struct ldb_message *msg;
        struct ldb_request *req;
-       unsigned int j;
+       uint32_t dsdb_flags = 0;
        /* TODO: All fields :-) */
 
        msg = ldb_msg_new(talloc_tos());
        /* TODO: All fields :-) */
 
        msg = ldb_msg_new(talloc_tos());
@@ -350,7 +351,8 @@ static int pdb_samba4_replace_by_sam(struct pdb_samba4_state *state,
 
        /* build modify request */
        ret = ldb_build_mod_req(&req, state->ldb, talloc_tos(), msg, NULL, NULL,
 
        /* build modify request */
        ret = ldb_build_mod_req(&req, state->ldb, talloc_tos(), msg, NULL, NULL,
-                               NULL, NULL);
+                               ldb_op_default_callback,
+                               NULL);
         if (ret != LDB_SUCCESS) {
                talloc_free(msg);
                return ret;
         if (ret != LDB_SUCCESS) {
                talloc_free(msg);
                return ret;
@@ -455,9 +457,8 @@ static int pdb_samba4_replace_by_sam(struct pdb_samba4_state *state,
                        changed_history = true;
                }
                if (changed_lm_pw || changed_nt_pw || changed_history) {
                        changed_history = true;
                }
                if (changed_lm_pw || changed_nt_pw || changed_history) {
-                       ret |= ldb_request_add_control(req,
-                                                      DSDB_CONTROL_BYPASS_PASSWORD_HASH_OID,
-                                                      true, NULL);
+                       /* These attributes can only be modified directly by using a special control */
+                       dsdb_flags = DSDB_BYPASS_PASSWORD_HASH;
                }
        }
 
                }
        }
 
@@ -577,15 +578,7 @@ static int pdb_samba4_replace_by_sam(struct pdb_samba4_state *state,
                return LDB_SUCCESS;
        }
 
                return LDB_SUCCESS;
        }
 
-       /* mark everything here as a replace */
-       for (j=0;j<msg->num_elements;j++) {
-               msg->elements[j].flags = LDB_FLAG_MOD_REPLACE;
-       }
-
-       ret = ldb_request(state->ldb, req);
-       if (ret == LDB_SUCCESS) {
-               ret = ldb_wait(req->handle, LDB_WAIT_ALL);
-       }
+       ret = dsdb_replace(state->ldb, msg, dsdb_flags);
 
        if (ret != LDB_SUCCESS) {
                DEBUG(0,("Failed to modify account record %s to set user attributes: %s\n",
 
        if (ret != LDB_SUCCESS) {
                DEBUG(0,("Failed to modify account record %s to set user attributes: %s\n",
index 0f7511aa179f768c17f2f6aec1b94a8541149637..1002af53ef733d2e1205f905c789f04a4e70fb03 100644 (file)
@@ -375,8 +375,8 @@ def import_registry(samba4_registry, samba3_regdb):
             key_handle.set_value(value_name, value_type, value_data)
 
 
             key_handle.set_value(value_name, value_type, value_data)
 
 
-def upgrade_provision(samba3, logger, credentials, session_info,
-                      smbconf, targetdir):
+def upgrade_from_passdb(samba3, logger, credentials, session_info,
+                        smbconf, targetdir):
     oldconf = samba3.get_conf()
 
     if oldconf.get("domain logons") == "True":
     oldconf = samba3.get_conf()
 
     if oldconf.get("domain logons") == "True":
index e0d4604b6e627e61671d96f16e8a2a061f72443c..e3af2019e6f581f5ccf2b22bb94fa215afbe6412 100755 (executable)
@@ -26,7 +26,7 @@ sys.path.insert(0, "bin/python")
 import samba
 import samba.getopt as options
 from samba.auth import system_session
 import samba
 import samba.getopt as options
 from samba.auth import system_session
-from samba.upgrade import upgrade_provision
+from samba.upgrade import upgrade_from_passdb
 from samba.samba3 import Samba3
 parser = optparse.OptionParser("upgrade_from_s3 [options] <libdir> <smbconf>")
 sambaopts = options.SambaOptions(parser)
 from samba.samba3 import Samba3
 parser = optparse.OptionParser("upgrade_from_s3 [options] <libdir> <smbconf>")
 sambaopts = options.SambaOptions(parser)
@@ -73,6 +73,6 @@ lp = sambaopts.get_loadparm()
 smbconf = lp.configfile
 creds = credopts.get_credentials(lp)
 
 smbconf = lp.configfile
 creds = credopts.get_credentials(lp)
 
-upgrade_provision(samba3, logger, credentials=creds,
-                  session_info=system_session(), smbconf=smbconf,
-                  targetdir=opts.targetdir)
+upgrade_from_passdb(samba3, logger, credentials=creds,
+                   session_info=system_session(), smbconf=smbconf,
+                   targetdir=opts.targetdir)