1
0
mirror of https://github.com/samba-team/samba.git synced 2025-08-03 04:22:09 +03:00

s4-scripting Rename passdb upgrade routine to avoid conflict with upgradeprovision

This commit is contained in:
Andrew Bartlett
2011-08-11 16:19:24 +10:00
parent 00364e4e0d
commit 93e8d3b381
3 changed files with 13 additions and 20 deletions

View File

@ -33,6 +33,7 @@
#include "source4/auth/session.h" #include "source4/auth/session.h"
#include "source4/auth/system_session_proto.h" #include "source4/auth/system_session_proto.h"
#include "source4/param/param.h" #include "source4/param/param.h"
#include "source4/dsdb/common/util.h"
struct pdb_samba4_state { struct pdb_samba4_state {
struct tevent_context *ev; struct tevent_context *ev;
@ -338,7 +339,7 @@ static int pdb_samba4_replace_by_sam(struct pdb_samba4_state *state,
const char *pw; const char *pw;
struct ldb_message *msg; struct ldb_message *msg;
struct ldb_request *req; struct ldb_request *req;
unsigned int j; uint32_t dsdb_flags = 0;
/* TODO: All fields :-) */ /* TODO: All fields :-) */
msg = ldb_msg_new(talloc_tos()); 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 */ /* build modify request */
ret = ldb_build_mod_req(&req, state->ldb, talloc_tos(), msg, NULL, NULL, ret = ldb_build_mod_req(&req, state->ldb, talloc_tos(), msg, NULL, NULL,
NULL, NULL); ldb_op_default_callback,
NULL);
if (ret != LDB_SUCCESS) { if (ret != LDB_SUCCESS) {
talloc_free(msg); talloc_free(msg);
return ret; return ret;
@ -455,9 +457,8 @@ static int pdb_samba4_replace_by_sam(struct pdb_samba4_state *state,
changed_history = true; changed_history = true;
} }
if (changed_lm_pw || changed_nt_pw || changed_history) { if (changed_lm_pw || changed_nt_pw || changed_history) {
ret |= ldb_request_add_control(req, /* These attributes can only be modified directly by using a special control */
DSDB_CONTROL_BYPASS_PASSWORD_HASH_OID, dsdb_flags = DSDB_BYPASS_PASSWORD_HASH;
true, NULL);
} }
} }
@ -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 */ ret = dsdb_replace(state->ldb, msg, dsdb_flags);
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);
}
if (ret != LDB_SUCCESS) { if (ret != LDB_SUCCESS) {
DEBUG(0,("Failed to modify account record %s to set user attributes: %s\n", DEBUG(0,("Failed to modify account record %s to set user attributes: %s\n",

View 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, def upgrade_from_passdb(samba3, logger, credentials, session_info,
smbconf, targetdir): smbconf, targetdir):
oldconf = samba3.get_conf() oldconf = samba3.get_conf()
if oldconf.get("domain logons") == "True": if oldconf.get("domain logons") == "True":

View File

@ -26,7 +26,7 @@ sys.path.insert(0, "bin/python")
import samba import samba
import samba.getopt as options import samba.getopt as options
from samba.auth import system_session from samba.auth import system_session
from samba.upgrade import upgrade_provision from samba.upgrade import upgrade_from_passdb
from samba.samba3 import Samba3 from samba.samba3 import Samba3
parser = optparse.OptionParser("upgrade_from_s3 [options] <libdir> <smbconf>") parser = optparse.OptionParser("upgrade_from_s3 [options] <libdir> <smbconf>")
sambaopts = options.SambaOptions(parser) sambaopts = options.SambaOptions(parser)
@ -73,6 +73,6 @@ lp = sambaopts.get_loadparm()
smbconf = lp.configfile smbconf = lp.configfile
creds = credopts.get_credentials(lp) creds = credopts.get_credentials(lp)
upgrade_provision(samba3, logger, credentials=creds, upgrade_from_passdb(samba3, logger, credentials=creds,
session_info=system_session(), smbconf=smbconf, session_info=system_session(), smbconf=smbconf,
targetdir=opts.targetdir) targetdir=opts.targetdir)