summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAndrew Bartlett <abartlet@samba.org>2012-08-27 22:37:19 +1000
committerAndrew Bartlett <abartlet@samba.org>2012-08-28 07:57:30 +1000
commit5aa9a6c936cbf4fb8a7a9d9a03b1678d6419e78f (patch)
treeca29b1cd80c7ac285a6f4ea382b34631c5ff32e6
parentf873d422b153c55754c0d1e83670cda7c3a7f7e3 (diff)
downloadsamba-5aa9a6c936cbf4fb8a7a9d9a03b1678d6419e78f.tar.gz
samba-5aa9a6c936cbf4fb8a7a9d9a03b1678d6419e78f.tar.bz2
samba-5aa9a6c936cbf4fb8a7a9d9a03b1678d6419e78f.zip
s3-passdb: Allow reload of the static passdb from python
This is then used in provision when the passdb backend is forced. Andrew Bartlett
-rw-r--r--source3/passdb/pdb_interface.c5
-rw-r--r--source3/passdb/py_passdb.c18
-rw-r--r--source4/scripting/python/samba/provision/__init__.py2
3 files changed, 23 insertions, 2 deletions
diff --git a/source3/passdb/pdb_interface.c b/source3/passdb/pdb_interface.c
index d24301ab97..767808c851 100644
--- a/source3/passdb/pdb_interface.c
+++ b/source3/passdb/pdb_interface.c
@@ -1299,11 +1299,12 @@ bool pdb_new_rid(uint32_t *rid)
bool initialize_password_db(bool reload, struct tevent_context *tevent_ctx)
{
- pdb_tevent_ctx = tevent_ctx;
+ if (tevent_ctx) {
+ pdb_tevent_ctx = tevent_ctx;
+ }
return (pdb_get_methods_reload(reload) != NULL);
}
-
/***************************************************************************
Default implementations of some functions.
****************************************************************************/
diff --git a/source3/passdb/py_passdb.c b/source3/passdb/py_passdb.c
index bd332e17d1..6984061714 100644
--- a/source3/passdb/py_passdb.c
+++ b/source3/passdb/py_passdb.c
@@ -3645,8 +3645,23 @@ static PyObject *py_set_secrets_dir(PyObject *self, PyObject *args)
return NULL;
}
+ talloc_free(frame);
Py_RETURN_NONE;
+}
+
+static PyObject *py_reload_static_pdb(PyObject *self, PyObject *args)
+{
+ TALLOC_CTX *frame = talloc_stackframe();
+
+ /* Initialize secrets database */
+ if (!initialize_password_db(true, NULL)) {
+ PyErr_Format(py_pdb_error, "Cannot re-open passdb backend %s", lp_passdb_backend());
+ talloc_free(frame);
+ return NULL;
+ }
+
talloc_free(frame);
+ Py_RETURN_NONE;
}
static PyObject *py_get_global_sam_sid(PyObject *self)
@@ -3684,6 +3699,9 @@ static PyMethodDef py_passdb_methods[] = {
{ "get_global_sam_sid", (PyCFunction)py_get_global_sam_sid, METH_NOARGS,
"get_global_sam_sid() -> dom_sid\n\n \
Return domain SID." },
+ { "reload_static_pdb", (PyCFunction)py_reload_static_pdb, METH_NOARGS,
+ "reload_static_pdb() -> None\n\n \
+ Re-initalise the static pdb used internally. Needed if 'passdb backend' is changed." },
{ NULL },
};
diff --git a/source4/scripting/python/samba/provision/__init__.py b/source4/scripting/python/samba/provision/__init__.py
index ed46b4040d..e39a6c45ae 100644
--- a/source4/scripting/python/samba/provision/__init__.py
+++ b/source4/scripting/python/samba/provision/__init__.py
@@ -1417,6 +1417,8 @@ def setsysvolacl(samdb, netlogon, sysvol, uid, gid, domainsid, dnsdomain, domain
s3conf.load(lp.configfile)
# ensure we are using the right samba4 passdb backend, no matter what
s3conf.set("passdb backend", "samba4:%s" % samdb.url)
+ passdb.reload_static_pdb()
+
# ensure that we init the samba4 backend, so the domain sid is marked in secrets.tdb
s4_passdb = passdb.PDB(s3conf.get("passdb backend"))