From 7df18932f65282461ee00c1ae17712c490be84d4 Mon Sep 17 00:00:00 2001 From: Jelmer Vernooij Date: Sat, 16 Feb 2008 16:15:21 +0100 Subject: use gmake to handle .py file copies. (This used to be commit 33111f98df7e8f9bb7d62599c6b13a1a4479a2e1) --- source4/scripting/python/config.mk | 4 ++++ 1 file changed, 4 insertions(+) (limited to 'source4/scripting') diff --git a/source4/scripting/python/config.mk b/source4/scripting/python/config.mk index b15e1fcda7..16cd301aad 100644 --- a/source4/scripting/python/config.mk +++ b/source4/scripting/python/config.mk @@ -35,6 +35,10 @@ PYDOCTOR_MODULES=bin/python/ldb.py bin/python/auth.py bin/python/credentials.py pydoctor:: pythonmods LD_LIBRARY_PATH=bin/shared PYTHONPATH=bin/python pydoctor --project-name=Samba --make-html --docformat=restructuredtext --add-package scripting/python/samba/ $(addprefix --add-module , $(PYDOCTOR_MODULES)) +bin/python/%.py: + mkdir -p $(@D) + cp $< $@ + installpython:: pythonmods @$(SHELL) $(srcdir)/script/installpython.sh \ $(INSTALLPERMS) \ -- cgit From b66ee2ed22754dd44b20c06e573072e328d9a3dd Mon Sep 17 00:00:00 2001 From: Jelmer Vernooij Date: Sat, 16 Feb 2008 18:38:02 +0100 Subject: Move responsibilities of build.h to makefile. (This used to be commit a43f6d37bce85748e9cf2675e5beced5db26f1c3) --- source4/scripting/ejs/smbcalls.c | 1 - 1 file changed, 1 deletion(-) (limited to 'source4/scripting') diff --git a/source4/scripting/ejs/smbcalls.c b/source4/scripting/ejs/smbcalls.c index 1f29fce002..da35a6ba8c 100644 --- a/source4/scripting/ejs/smbcalls.c +++ b/source4/scripting/ejs/smbcalls.c @@ -23,7 +23,6 @@ #include "includes.h" #include "param/param.h" #include "scripting/ejs/smbcalls.h" -#include "build.h" #include "version.h" /* -- cgit From 22ef67dd136f0a67885a17be68909643dc97304d Mon Sep 17 00:00:00 2001 From: Jelmer Vernooij Date: Tue, 26 Feb 2008 01:20:55 +0100 Subject: Fix the build (again). (This used to be commit ef00f6b5817107738dc44367838095896af4e77d) --- source4/scripting/ejs/smbcalls.c | 26 ++++++++++++++++++++++++++ 1 file changed, 26 insertions(+) (limited to 'source4/scripting') diff --git a/source4/scripting/ejs/smbcalls.c b/source4/scripting/ejs/smbcalls.c index da35a6ba8c..ac1c20008b 100644 --- a/source4/scripting/ejs/smbcalls.c +++ b/source4/scripting/ejs/smbcalls.c @@ -172,6 +172,32 @@ _PUBLIC_ void ejs_exception(const char *reason) */ void smb_setup_ejs_functions(void (*exception_handler)(const char *)) { + extern NTSTATUS ejs_init_security(void); + extern NTSTATUS ejs_init_initshutdown(void); + extern NTSTATUS smb_setup_ejs_reg(void); + extern NTSTATUS smb_setup_ejs_string(void); + extern NTSTATUS ejs_init_lsarpc(void); + extern NTSTATUS ejs_init_rpcecho(void); + extern NTSTATUS ejs_init_winreg(void); + extern NTSTATUS smb_setup_ejs_random(void); + extern NTSTATUS smb_setup_ejs_config(void); + extern NTSTATUS ejs_init_misc(void); + extern NTSTATUS ejs_init_netdfs(void); + extern NTSTATUS smb_setup_ejs_datablob(void); + extern NTSTATUS smb_setup_ejs_auth(void); + extern NTSTATUS smb_setup_ejs_nss(void); + extern NTSTATUS ejs_init_samr(void); + extern NTSTATUS ejs_init_wkssvc(void); + extern NTSTATUS smb_setup_ejs_system(void); + extern NTSTATUS smb_setup_ejs_ldb(void); + extern NTSTATUS ejs_init_svcctl(void); + extern NTSTATUS smb_setup_ejs_nbt(void); + extern NTSTATUS smb_setup_ejs_net(void); + extern NTSTATUS ejs_init_srvsvc(void); + extern NTSTATUS ejs_init_netlogon(void); + extern NTSTATUS ejs_init_drsuapi(void); + extern NTSTATUS ejs_init_irpc(void); + extern NTSTATUS ejs_init_eventlog(void); init_module_fn static_init[] = { STATIC_smbcalls_MODULES }; init_module_fn *shared_init; -- cgit From ef15b28d244dcaaa38a07055c3a88f6199173611 Mon Sep 17 00:00:00 2001 From: Jelmer Vernooij Date: Tue, 26 Feb 2008 16:02:51 +0100 Subject: use make macro for python. (This used to be commit b0408abb08648c0155d8f5da5fb299b1acbc09b6) --- source4/scripting/python/config.mk | 27 --------------------------- 1 file changed, 27 deletions(-) (limited to 'source4/scripting') diff --git a/source4/scripting/python/config.mk b/source4/scripting/python/config.mk index 16cd301aad..cafbea6b6e 100644 --- a/source4/scripting/python/config.mk +++ b/source4/scripting/python/config.mk @@ -15,36 +15,9 @@ OBJ_FILES = uuidmodule.o PRIVATE_DEPENDENCIES = LIBNDR LIBLDB SAMDB CREDENTIALS SWIG_FILE = misc.i -# Swig extensions -swig:: pythonmods - -.SUFFIXES: _wrap.c .i - -.i_wrap.c: - [ "$(SWIG)" == "no" ] || $(SWIG) -O -Wall -I$(srcdir)/scripting/swig -python -keyword $< - -realdistclean:: - @echo "Removing SWIG output files" - @-rm -f bin/python/* - # FIXME: Remove _wrap.c files - -pythonmods:: $(PYTHON_DSOS) $(PYTHON_PYS) - PYDOCTOR_MODULES=bin/python/ldb.py bin/python/auth.py bin/python/credentials.py bin/python/registry.py bin/python/tdb.py bin/python/security.py bin/python/events.py bin/python/net.py pydoctor:: pythonmods LD_LIBRARY_PATH=bin/shared PYTHONPATH=bin/python pydoctor --project-name=Samba --make-html --docformat=restructuredtext --add-package scripting/python/samba/ $(addprefix --add-module , $(PYDOCTOR_MODULES)) -bin/python/%.py: - mkdir -p $(@D) - cp $< $@ - -installpython:: pythonmods - @$(SHELL) $(srcdir)/script/installpython.sh \ - $(INSTALLPERMS) \ - $(DESTDIR)$(PYTHONDIR) \ - scripting/python bin/python -clean:: - @echo "Removing python modules" - @rm -f bin/python/* -- cgit From 2ca7dfe20c4a86d0abacf5cafc81a2dd97acc7dd Mon Sep 17 00:00:00 2001 From: Jelmer Vernooij Date: Tue, 26 Feb 2008 16:51:50 +0100 Subject: Fix pydoctor. (This used to be commit 023025e4de119aa234f885aa6e5594660bd8f358) --- source4/scripting/python/config.mk | 7 ++----- 1 file changed, 2 insertions(+), 5 deletions(-) (limited to 'source4/scripting') diff --git a/source4/scripting/python/config.mk b/source4/scripting/python/config.mk index cafbea6b6e..56634736bd 100644 --- a/source4/scripting/python/config.mk +++ b/source4/scripting/python/config.mk @@ -15,9 +15,6 @@ OBJ_FILES = uuidmodule.o PRIVATE_DEPENDENCIES = LIBNDR LIBLDB SAMDB CREDENTIALS SWIG_FILE = misc.i -PYDOCTOR_MODULES=bin/python/ldb.py bin/python/auth.py bin/python/credentials.py bin/python/registry.py bin/python/tdb.py bin/python/security.py bin/python/events.py bin/python/net.py - -pydoctor:: pythonmods - LD_LIBRARY_PATH=bin/shared PYTHONPATH=bin/python pydoctor --project-name=Samba --make-html --docformat=restructuredtext --add-package scripting/python/samba/ $(addprefix --add-module , $(PYDOCTOR_MODULES)) - +_PY_FILES = $(shell find scripting/python -name "*.py") +$(foreach pyfile, $(_PY_FILES),$(eval $(call python_py_module_template,$(patsubst scripting/python/%,%,$(pyfile)),$(pyfile)))) -- cgit From b29d47edcf2767d7f9e9f63332079c6e8e89946c Mon Sep 17 00:00:00 2001 From: Jelmer Vernooij Date: Mon, 3 Mar 2008 18:25:28 +0100 Subject: Move object file lists to the Makefile. (This used to be commit a7e6d2a1832db388fdafa1279f84c9a8bbfc87d6) --- source4/scripting/ejs/config.mk | 57 ++++++++++++++++++++-------------- source4/scripting/ejs/ejsnet/config.mk | 14 +++++---- source4/scripting/python/config.mk | 9 ++++-- 3 files changed, 48 insertions(+), 32 deletions(-) (limited to 'source4/scripting') diff --git a/source4/scripting/ejs/config.mk b/source4/scripting/ejs/config.mk index c1f07367fb..6acf902c08 100644 --- a/source4/scripting/ejs/config.mk +++ b/source4/scripting/ejs/config.mk @@ -1,84 +1,85 @@ [SUBSYSTEM::EJSRPC] -OBJ_FILES = \ - ejsrpc.o + +EJSRPC_OBJ_FILES = scripting/ejs/ejsrpc.o [MODULE::smbcalls_config] -OBJ_FILES = smbcalls_config.o OUTPUT_TYPE = MERGED_OBJ SUBSYSTEM = smbcalls INIT_FUNCTION = smb_setup_ejs_config +smbcalls_config_OBJ_FILES = scripting/ejs/smbcalls_config.o + [MODULE::smbcalls_ldb] -OBJ_FILES = smbcalls_ldb.o OUTPUT_TYPE = MERGED_OBJ SUBSYSTEM = smbcalls INIT_FUNCTION = smb_setup_ejs_ldb PRIVATE_DEPENDENCIES = LIBLDB SAMDB LIBNDR +smbcalls_ldb_OBJ_FILES = scripting/ejs/smbcalls_ldb.o + [MODULE::smbcalls_reg] -OBJ_FILES = smbcalls_reg.o SUBSYSTEM = smbcalls OUTPUT_TYPE = MERGED_OBJ INIT_FUNCTION = smb_setup_ejs_reg PRIVATE_DEPENDENCIES = registry SAMDB LIBNDR +smbcalls_reg_OBJ_FILES = scripting/ejs/smbcalls_reg.o + [MODULE::smbcalls_nbt] -OBJ_FILES = smbcalls_nbt.o SUBSYSTEM = smbcalls OUTPUT_TYPE = MERGED_OBJ INIT_FUNCTION = smb_setup_ejs_nbt +smbcalls_nbt_OBJ_FILES = scripting/ejs/smbcalls_nbt.o + [MODULE::smbcalls_rand] -OBJ_FILES = smbcalls_rand.o SUBSYSTEM = smbcalls OUTPUT_TYPE = MERGED_OBJ INIT_FUNCTION = smb_setup_ejs_random +smbcalls_rand_OBJ_FILES = scripting/ejs/smbcalls_rand.o + [MODULE::smbcalls_nss] -OBJ_FILES = smbcalls_nss.o SUBSYSTEM = smbcalls OUTPUT_TYPE = MERGED_OBJ INIT_FUNCTION = smb_setup_ejs_nss PRIVATE_DEPENDENCIES = NSS_WRAPPER +smbcalls_nss_OBJ_FILES = scripting/ejs/smbcalls_nss.o + [MODULE::smbcalls_data] -OBJ_FILES = smbcalls_data.o SUBSYSTEM = smbcalls OUTPUT_TYPE = MERGED_OBJ INIT_FUNCTION = smb_setup_ejs_datablob +smbcalls_data_OBJ_FILES = scripting/ejs/smbcalls_data.o + [MODULE::smbcalls_auth] -OBJ_FILES = smbcalls_auth.o OUTPUT_TYPE = MERGED_OBJ SUBSYSTEM = smbcalls INIT_FUNCTION = smb_setup_ejs_auth PRIVATE_DEPENDENCIES = auth +smbcalls_auth_OBJ_FILES = scripting/ejs/smbcalls_auth.o + [MODULE::smbcalls_string] -OBJ_FILES = smbcalls_string.o SUBSYSTEM = smbcalls OUTPUT_TYPE = MERGED_OBJ INIT_FUNCTION = smb_setup_ejs_string +smbcalls_string_OBJ_FILES = scripting/ejs/smbcalls_string.o + [MODULE::smbcalls_sys] -OBJ_FILES = smbcalls_sys.o SUBSYSTEM = smbcalls OUTPUT_TYPE = MERGED_OBJ INIT_FUNCTION = smb_setup_ejs_system +smbcalls_sys_OBJ_FILES = scripting/ejs/smbcalls_sys.o + mkinclude ejsnet/config.mk [SUBSYSTEM::smbcalls] PRIVATE_PROTO_HEADER = proto.h -OBJ_FILES = \ - smbcalls.o \ - smbcalls_cli.o \ - smbcalls_rpc.o \ - smbcalls_options.o \ - smbcalls_creds.o \ - smbcalls_param.o \ - mprutil.o \ - literal.o PRIVATE_DEPENDENCIES = \ EJS LIBSAMBA-UTIL \ EJSRPC MESSAGING \ @@ -87,12 +88,22 @@ PRIVATE_DEPENDENCIES = \ dcerpc \ NDR_TABLE +smbcalls_OBJ_FILES = $(addprefix scripting/ejs/, \ + smbcalls.o \ + smbcalls_cli.o \ + smbcalls_rpc.o \ + smbcalls_options.o \ + smbcalls_creds.o \ + smbcalls_param.o \ + mprutil.o \ + literal.o) + ####################### # Start BINARY SMBSCRIPT [BINARY::smbscript] INSTALLDIR = BINDIR -OBJ_FILES = \ - smbscript.o PRIVATE_DEPENDENCIES = EJS LIBSAMBA-UTIL smbcalls LIBSAMBA-CONFIG # End BINARY SMBSCRIPT ####################### + +smbscript_OBJ_FILES = scripting/ejs/smbscript.o diff --git a/source4/scripting/ejs/ejsnet/config.mk b/source4/scripting/ejs/ejsnet/config.mk index 249a33121d..85a5b2bf09 100644 --- a/source4/scripting/ejs/ejsnet/config.mk +++ b/source4/scripting/ejs/ejsnet/config.mk @@ -1,11 +1,13 @@ [MODULE::smbcalls_net] -OBJ_FILES = \ - net_ctx.o \ - net_user.o \ - mpr_user.o \ - net_host.o \ - mpr_host.o SUBSYSTEM = smbcalls INIT_FUNCTION = smb_setup_ejs_net PRIVATE_PROTO_HEADER = proto.h PRIVATE_DEPENDENCIES = LIBSAMBA-NET LIBCLI_SMB CREDENTIALS + +smbcalls_net_OBJ_FILES = $(addprefix scripting/ejs/ejsnet/, \ + net_ctx.o \ + net_user.o \ + mpr_user.o \ + net_host.o \ + mpr_host.o) + diff --git a/source4/scripting/python/config.mk b/source4/scripting/python/config.mk index 56634736bd..8a3a637bf5 100644 --- a/source4/scripting/python/config.mk +++ b/source4/scripting/python/config.mk @@ -1,15 +1,18 @@ [BINARY::smbpython] PRIVATE_DEPENDENCIES = LIBPYTHON -OBJ_FILES = smbpython.o + +smbpython_OBJ_FILES = scripting/python/smbpython.o [SUBSYSTEM::LIBPYTHON] PUBLIC_DEPENDENCIES = EXT_LIB_PYTHON INIT_FUNCTION_SENTINEL = { NULL, NULL } -OBJ_FILES = modules.o pytalloc.o + +LIBPYTHON_OBJ_FILES = $(addprefix scripting/python/, modules.o pytalloc.o) [PYTHON::python_uuid] PRIVATE_DEPENDENCIES = LIBNDR -OBJ_FILES = uuidmodule.o + +python_uuid_OBJ_FILES = scripting/python/uuidmodule.o [PYTHON::python_misc] PRIVATE_DEPENDENCIES = LIBNDR LIBLDB SAMDB CREDENTIALS -- cgit From 2d1c06c5781600a0efcf9becd3e2773dbbbf2cc7 Mon Sep 17 00:00:00 2001 From: Jelmer Vernooij Date: Tue, 4 Mar 2008 00:43:24 +0100 Subject: Fix includes. (This used to be commit 99e61dade2bd9ae2a5dfe17f766528012c09e46c) --- source4/scripting/python/config.mk | 2 ++ 1 file changed, 2 insertions(+) (limited to 'source4/scripting') diff --git a/source4/scripting/python/config.mk b/source4/scripting/python/config.mk index 8a3a637bf5..a0f5caad3b 100644 --- a/source4/scripting/python/config.mk +++ b/source4/scripting/python/config.mk @@ -18,6 +18,8 @@ python_uuid_OBJ_FILES = scripting/python/uuidmodule.o PRIVATE_DEPENDENCIES = LIBNDR LIBLDB SAMDB CREDENTIALS SWIG_FILE = misc.i +python_misc_OBJ_FILES = scripting/python/misc_wrap.o + _PY_FILES = $(shell find scripting/python -name "*.py") $(foreach pyfile, $(_PY_FILES),$(eval $(call python_py_module_template,$(patsubst scripting/python/%,%,$(pyfile)),$(pyfile)))) -- cgit From 6a1f56d82a367a2f037e18ed346cf7cce7f377e0 Mon Sep 17 00:00:00 2001 From: Jelmer Vernooij Date: Fri, 7 Mar 2008 20:33:12 +0100 Subject: Fix the build. (This used to be commit 3b7940d531a30098ca9a09e9c83dc4d223d1fe8f) --- source4/scripting/ejs/config.mk | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'source4/scripting') diff --git a/source4/scripting/ejs/config.mk b/source4/scripting/ejs/config.mk index 6acf902c08..0d10fc6e3a 100644 --- a/source4/scripting/ejs/config.mk +++ b/source4/scripting/ejs/config.mk @@ -58,7 +58,7 @@ smbcalls_data_OBJ_FILES = scripting/ejs/smbcalls_data.o OUTPUT_TYPE = MERGED_OBJ SUBSYSTEM = smbcalls INIT_FUNCTION = smb_setup_ejs_auth -PRIVATE_DEPENDENCIES = auth +PRIVATE_DEPENDENCIES = service_auth smbcalls_auth_OBJ_FILES = scripting/ejs/smbcalls_auth.o -- cgit From 2bf39edc9d0abf3306bd25b9c40d88aceb029be7 Mon Sep 17 00:00:00 2001 From: Jelmer Vernooij Date: Sat, 8 Mar 2008 15:28:12 +0100 Subject: Push SOVERSION and VERSION out of perl code. (This used to be commit 0ba8ac6a14c62ff9edfe9f0bf43b8a7406b85291) --- source4/scripting/python/modules.c | 1 - 1 file changed, 1 deletion(-) (limited to 'source4/scripting') diff --git a/source4/scripting/python/modules.c b/source4/scripting/python/modules.c index 2ecad20b8e..2c10a35c60 100644 --- a/source4/scripting/python/modules.c +++ b/source4/scripting/python/modules.c @@ -19,7 +19,6 @@ #include "includes.h" #include -#include "build.h" extern void init_ldb(void); extern void init_security(void); -- cgit From 6267dd78539863a5ec75b6cadba39184a2efc9b5 Mon Sep 17 00:00:00 2001 From: Jelmer Vernooij Date: Sat, 10 May 2008 20:59:17 +0200 Subject: Clean up some git merges gone wrong. (This used to be commit 42eb6b33462228467e65a51bbf624c481802b090) --- source4/scripting/python/modules.c | 2 -- 1 file changed, 2 deletions(-) (limited to 'source4/scripting') diff --git a/source4/scripting/python/modules.c b/source4/scripting/python/modules.c index cbff14c708..0fe15b2fda 100644 --- a/source4/scripting/python/modules.c +++ b/source4/scripting/python/modules.c @@ -39,12 +39,10 @@ extern void initdrsuapi(void); extern void initwinreg(void); extern void initepmapper(void); extern void initinitshutdown(void); -static void initdcerpc_misc(void) {} extern void initmgmt(void); extern void initnet(void); extern void initatsvc(void); extern void initsamr(void); -static void initdcerpc_security(void) {} extern void initlsa(void); extern void initsvcctl(void); extern void initwkssvc(void); -- cgit From 97fbad6480b992421862eab3b347ff6a9bd33e8f Mon Sep 17 00:00:00 2001 From: Jelmer Vernooij Date: Sat, 10 May 2008 23:25:50 +0200 Subject: Install standalone python modules (so we can use stock python rather than smbpython). (This used to be commit bb5c9fc64b6ad275abdd98a19f018953c9d79cbd) --- source4/scripting/python/config.m4 | 5 +++++ source4/scripting/python/config.mk | 6 ------ 2 files changed, 5 insertions(+), 6 deletions(-) (limited to 'source4/scripting') diff --git a/source4/scripting/python/config.m4 b/source4/scripting/python/config.m4 index 3790071ba8..a61d541049 100644 --- a/source4/scripting/python/config.m4 +++ b/source4/scripting/python/config.m4 @@ -71,3 +71,8 @@ else AC_MSG_ERROR([Python not found. Please install Python 2.x and its development headers/libraries.]) fi +AC_MSG_CHECKING(python library directory) +pythondir=`$PYTHON -c "from distutils import sysconfig; print sysconfig.get_python_lib(1, 0, '\\${prefix}')"` +AC_MSG_RESULT($pythondir) + +AC_SUBST(pythondir) diff --git a/source4/scripting/python/config.mk b/source4/scripting/python/config.mk index 15be4ca309..a0f5caad3b 100644 --- a/source4/scripting/python/config.mk +++ b/source4/scripting/python/config.mk @@ -23,9 +23,3 @@ python_misc_OBJ_FILES = scripting/python/misc_wrap.o _PY_FILES = $(shell find scripting/python -name "*.py") $(foreach pyfile, $(_PY_FILES),$(eval $(call python_py_module_template,$(patsubst scripting/python/%,%,$(pyfile)),$(pyfile)))) - -installpython:: pythonmods - @$(SHELL) $(srcdir)/script/installpython.sh \ - $(INSTALLPERMS) \ - $(DESTDIR)$(PYTHONDIR) \ - scripting/python bin/python -- cgit From 5319d9620b9ef68b3687d76aeaba5fa5d5c57a18 Mon Sep 17 00:00:00 2001 From: Jelmer Vernooij Date: Sun, 11 May 2008 03:31:26 +0200 Subject: Use consistent function names with the standard Python uuid module that is available in >= 2.4. (This used to be commit 60d458e3195eef6baf655fee0da7c3f68517e8e6) --- source4/scripting/python/samba/provision.py | 4 ++-- source4/scripting/python/samba/tests/samdb.py | 8 ++++---- source4/scripting/python/uuidmodule.c | 2 +- 3 files changed, 7 insertions(+), 7 deletions(-) (limited to 'source4/scripting') diff --git a/source4/scripting/python/samba/provision.py b/source4/scripting/python/samba/provision.py index 0e8840646c..60fa22e6c4 100644 --- a/source4/scripting/python/samba/provision.py +++ b/source4/scripting/python/samba/provision.py @@ -910,7 +910,7 @@ def provision(setup_dir, message, session_info, domainsid = security.Sid(domainsid) if policyguid is None: - policyguid = uuid.random() + policyguid = uuid.uuid4() if adminpass is None: adminpass = misc.random_password(12) if krbtgtpass is None: @@ -960,7 +960,7 @@ def provision(setup_dir, message, session_info, assert serverrole in ("domain controller", "member server", "standalone") if invocationid is None and serverrole == "domain controller": - invocationid = uuid.random() + invocationid = uuid.uuid4() if not os.path.exists(paths.private_dir): os.mkdir(paths.private_dir) diff --git a/source4/scripting/python/samba/tests/samdb.py b/source4/scripting/python/samba/tests/samdb.py index 0e175bf936..9da3358527 100644 --- a/source4/scripting/python/samba/tests/samdb.py +++ b/source4/scripting/python/samba/tests/samdb.py @@ -29,18 +29,18 @@ import uuid class SamDBTestCase(TestCaseInTempDir): def setUp(self): super(SamDBTestCase, self).setUp() - invocationid = uuid.random() + invocationid = uuid.uuid4() domaindn = "DC=COM,DC=EXAMPLE" self.domaindn = domaindn configdn = "CN=Configuration," + domaindn schemadn = "CN=Schema," + configdn - domainguid = uuid.random() - policyguid = uuid.random() + domainguid = uuid.uuid4() + policyguid = uuid.uuid4() setup_path = lambda x: os.path.join("setup", x) creds = Credentials() creds.set_anonymous() domainsid = security.random_sid() - hostguid = uuid.random() + hostguid = uuid.uuid4() path = os.path.join(self.tempdir, "samdb.ldb") self.samdb = setup_samdb(path, setup_path, system_session(), creds, cmdline_loadparm, schemadn, configdn, diff --git a/source4/scripting/python/uuidmodule.c b/source4/scripting/python/uuidmodule.c index 18cfb6ce32..98ef9adaa9 100644 --- a/source4/scripting/python/uuidmodule.c +++ b/source4/scripting/python/uuidmodule.c @@ -46,7 +46,7 @@ static PyObject *uuid_random(PyObject *self, PyObject *args) } static PyMethodDef methods[] = { - { "random", (PyCFunction)uuid_random, METH_VARARGS, NULL}, + { "uuid4", (PyCFunction)uuid_random, METH_VARARGS, NULL}, { NULL, NULL } }; -- cgit From 8c926a34c8a74e446aa3c07536c1289704c6bc7a Mon Sep 17 00:00:00 2001 From: Jelmer Vernooij Date: Sun, 11 May 2008 04:36:05 +0200 Subject: Complete dependencies for python modules (actually matters when built standalone). (This used to be commit a89b6d8ad71d71271f30d156de20129866ef6aeb) --- source4/scripting/python/config.mk | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) (limited to 'source4/scripting') diff --git a/source4/scripting/python/config.mk b/source4/scripting/python/config.mk index a0f5caad3b..e57ff1d1ac 100644 --- a/source4/scripting/python/config.mk +++ b/source4/scripting/python/config.mk @@ -5,9 +5,15 @@ smbpython_OBJ_FILES = scripting/python/smbpython.o [SUBSYSTEM::LIBPYTHON] PUBLIC_DEPENDENCIES = EXT_LIB_PYTHON +PRIVATE_DEPENDENCIES = PYTALLOC INIT_FUNCTION_SENTINEL = { NULL, NULL } -LIBPYTHON_OBJ_FILES = $(addprefix scripting/python/, modules.o pytalloc.o) +LIBPYTHON_OBJ_FILES = $(addprefix scripting/python/, modules.o) + +[SUBSYSTEM::PYTALLOC] +PUBLIC_DEPENDENCIES = EXT_LIB_PYTHON + +PYTALLOC_OBJ_FILES = $(addprefix scripting/python/, pytalloc.o) [PYTHON::python_uuid] PRIVATE_DEPENDENCIES = LIBNDR -- cgit From 251f6bd99159337b24b8aa8298a5c98de153bce0 Mon Sep 17 00:00:00 2001 From: Jelmer Vernooij Date: Sun, 11 May 2008 04:36:37 +0200 Subject: make sure to always use string version of uuid rather than object. (This used to be commit bcd5fc7dc9899deb9fa84fdeeb21ed2ddb921308) --- source4/scripting/python/samba/provision.py | 5 +++-- source4/scripting/python/samba/tests/samdb.py | 8 ++++---- 2 files changed, 7 insertions(+), 6 deletions(-) (limited to 'source4/scripting') diff --git a/source4/scripting/python/samba/provision.py b/source4/scripting/python/samba/provision.py index 60fa22e6c4..ad8eb8bffd 100644 --- a/source4/scripting/python/samba/provision.py +++ b/source4/scripting/python/samba/provision.py @@ -689,6 +689,7 @@ def setup_self_join(samdb, names, domainsid, invocationid, setup_path, policyguid): """Join a host to its own domain.""" + assert isinstance(invocationid, str) setup_add_ldif(samdb, setup_path("provision_self_join.ldif"), { "CONFIGDN": names.configdn, "SCHEMADN": names.schemadn, @@ -910,7 +911,7 @@ def provision(setup_dir, message, session_info, domainsid = security.Sid(domainsid) if policyguid is None: - policyguid = uuid.uuid4() + policyguid = str(uuid.uuid4()) if adminpass is None: adminpass = misc.random_password(12) if krbtgtpass is None: @@ -960,7 +961,7 @@ def provision(setup_dir, message, session_info, assert serverrole in ("domain controller", "member server", "standalone") if invocationid is None and serverrole == "domain controller": - invocationid = uuid.uuid4() + invocationid = str(uuid.uuid4()) if not os.path.exists(paths.private_dir): os.mkdir(paths.private_dir) diff --git a/source4/scripting/python/samba/tests/samdb.py b/source4/scripting/python/samba/tests/samdb.py index 9da3358527..0d4f7bde0e 100644 --- a/source4/scripting/python/samba/tests/samdb.py +++ b/source4/scripting/python/samba/tests/samdb.py @@ -29,18 +29,18 @@ import uuid class SamDBTestCase(TestCaseInTempDir): def setUp(self): super(SamDBTestCase, self).setUp() - invocationid = uuid.uuid4() + invocationid = str(uuid.uuid4()) domaindn = "DC=COM,DC=EXAMPLE" self.domaindn = domaindn configdn = "CN=Configuration," + domaindn schemadn = "CN=Schema," + configdn - domainguid = uuid.uuid4() - policyguid = uuid.uuid4() + domainguid = str(uuid.uuid4()) + policyguid = str(uuid.uuid4()) setup_path = lambda x: os.path.join("setup", x) creds = Credentials() creds.set_anonymous() domainsid = security.random_sid() - hostguid = uuid.uuid4() + hostguid = str(uuid.uuid4()) path = os.path.join(self.tempdir, "samdb.ldb") self.samdb = setup_samdb(path, setup_path, system_session(), creds, cmdline_loadparm, schemadn, configdn, -- cgit From af683666d6d46169aadef4ea3bf7b430de3021f8 Mon Sep 17 00:00:00 2001 From: Jelmer Vernooij Date: Sun, 11 May 2008 15:15:27 +0200 Subject: Remove obsolete provisioning library. (This used to be commit f123190fb49302968a231639848023a72dfdf2bc) --- source4/scripting/libjs/provision.js | 1254 ---------------------------------- 1 file changed, 1254 deletions(-) delete mode 100644 source4/scripting/libjs/provision.js (limited to 'source4/scripting') diff --git a/source4/scripting/libjs/provision.js b/source4/scripting/libjs/provision.js deleted file mode 100644 index 51e2785762..0000000000 --- a/source4/scripting/libjs/provision.js +++ /dev/null @@ -1,1254 +0,0 @@ -/* - backend code for provisioning a Samba4 server - Copyright Andrew Tridgell 2005 - Released under the GNU GPL version 3 or later -*/ - -sys = sys_init(); - -/* - return true if the current install seems to be OK -*/ -function install_ok(session_info, credentials) -{ - var lp = loadparm_init(); - var ldb = ldb_init(); - ldb.session_info = session_info; - ldb.credentials = credentials; - if (lp.get("realm") == "") { - return false; - } - var ok = ldb.connect(lp.get("sam database")); - if (!ok) { - return false; - } - var res = ldb.search("(cn=Administrator)"); - if (res.error != 0 || res.msgs.length != 1) { - return false; - } - return true; -} - -/* - find a user or group from a list of possibilities -*/ -function findnss() -{ - var i; - assert(arguments.length >= 2); - var nssfn = arguments[0]; - for (i=1;i= 4) { - erase = arguments[3]; - } - if (arguments.length == 5) { - failok = arguments[4]; - } - var ldb = open_ldb(info, dbname, erase); - if (setup_add_ldif(ldif, info, ldb, failok)) { - var commit_ok = ldb.transaction_commit(); - if (!commit_ok) { - info.message("ldb commit failed: " + ldb.errstring() + "\n"); - assert(commit_ok); - } - } -} - -/* - setup a ldb in the private dir - */ -function setup_ldb_modify(ldif, info, ldb) -{ - var lp = loadparm_init(); - - var src = lp.get("setup directory") + "/" + ldif; - - var data = sys.file_load(src); - data = substitute_var(data, info.subobj); - - var mod_res = ldb.modify(data); - if (mod_res.error != 0) { - info.message("ldb load failed: " + mod_res.errstr + "\n"); - return (mod_res.error == 0); - } - return (mod_res.error == 0); -} - -/* - setup a file in the private dir - */ -function setup_file(template, message, fname, subobj) -{ - var lp = loadparm_init(); - var f = fname; - var src = lp.get("setup directory") + "/" + template; - - if (! sys.stat(src)) { - message("Template file not found: %s\n",src); - assert(0); - } - - sys.unlink(f); - - var data = sys.file_load(src); - data = substitute_var(data, subobj); - - ok = sys.file_save(f, data); - if (!ok) { - message("failed to create file: " + f + "\n"); - assert(ok); - } -} - -function provision_default_paths(subobj) -{ - /* subobj.DNSDOMAIN isn't available at this point */ - var dnsdomain = strlower(subobj.REALM); - var lp = loadparm_init(); - var paths = new Object(); - paths.smbconf = lp.filename() - paths.shareconf = lp.get("private dir") + "/" + "share.ldb"; - paths.samdb = lp.get("sam database"); - paths.idmapdb = lp.get("idmap database"); - paths.secrets = lp.get("secrets database"); - paths.templates = lp.get("private dir") + "/" + "templates.ldb"; - paths.keytab = "secrets.keytab"; - paths.dns_keytab = "dns.keytab"; - paths.dns_keytab_abs = lp.get("private dir") + "/" + paths.dns_keytab; - paths.dns = lp.get("private dir") + "/" + dnsdomain + ".zone"; - paths.named_conf = lp.get("private dir") + "/named.conf"; - paths.winsdb = "wins.ldb"; - paths.ldapdir = lp.get("private dir") + "/ldap"; - - paths.s4_ldapi_socket = lp.get("private dir") + "/ldapi"; - paths.phpldapadminconfig = lp.get("private dir") + "/phpldapadmin-config.php"; - - paths.sysvol = lp.get("sysvol", "path"); - - if (paths.sysvol == undefined) { - paths.sysvol = lp.get("lock dir") + "/sysvol"; - } - - paths.netlogon = lp.get("netlogon", "path"); - - if (paths.netlogon == undefined) { - paths.netlogon = paths.sysvol + "/" + dnsdomain + "/scripts"; - } - - return paths; -} - - -/* - setup reasonable name mappings for sam names to unix names -*/ -function setup_name_mappings(info, ldb) -{ - var lp = loadparm_init(); - var attrs = new Array("objectSid"); - var subobj = info.subobj; - - res = ldb.search("objectSid=*", subobj.DOMAINDN, ldb.SCOPE_BASE, attrs); - assert(res.error == 0); - assert(res.msgs.length == 1 && res.msgs[0].objectSid != undefined); - var sid = res.msgs[0].objectSid; - - /* add some foreign sids if they are not present already */ - add_foreign(ldb, subobj, "S-1-5-7", "Anonymous"); - add_foreign(ldb, subobj, "S-1-1-0", "World"); - add_foreign(ldb, subobj, "S-1-5-2", "Network"); - add_foreign(ldb, subobj, "S-1-5-18", "System"); - add_foreign(ldb, subobj, "S-1-5-11", "Authenticated Users"); - - /* some well known sids */ - setup_name_mapping(info, ldb, "S-1-5-7", subobj.NOBODY); - setup_name_mapping(info, ldb, "S-1-1-0", subobj.NOGROUP); - setup_name_mapping(info, ldb, "S-1-5-2", subobj.NOGROUP); - setup_name_mapping(info, ldb, "S-1-5-18", subobj.ROOT); - setup_name_mapping(info, ldb, "S-1-5-11", subobj.USERS); - setup_name_mapping(info, ldb, "S-1-5-32-544", subobj.WHEEL); - setup_name_mapping(info, ldb, "S-1-5-32-545", subobj.USERS); - setup_name_mapping(info, ldb, "S-1-5-32-546", subobj.NOGROUP); - setup_name_mapping(info, ldb, "S-1-5-32-551", subobj.BACKUP); - - /* and some well known domain rids */ - setup_name_mapping(info, ldb, sid + "-500", subobj.ROOT); - setup_name_mapping(info, ldb, sid + "-518", subobj.WHEEL); - setup_name_mapping(info, ldb, sid + "-519", subobj.WHEEL); - setup_name_mapping(info, ldb, sid + "-512", subobj.WHEEL); - setup_name_mapping(info, ldb, sid + "-513", subobj.USERS); - setup_name_mapping(info, ldb, sid + "-520", subobj.WHEEL); - - return true; -} - -function provision_fix_subobj(subobj, paths) -{ - var ldb = ldb_init(); - - subobj.REALM = strupper(subobj.REALM); - subobj.HOSTNAME = strlower(subobj.HOSTNAME); - subobj.DOMAIN = strupper(subobj.DOMAIN); - subobj.NETBIOSNAME = strupper(subobj.HOSTNAME); - subobj.DNSDOMAIN = strlower(subobj.REALM); - subobj.DNSNAME = sprintf("%s.%s", - strlower(subobj.HOSTNAME), - subobj.DNSDOMAIN); - var rdn_list = split(".", subobj.DNSDOMAIN); - subobj.DOMAINDN = "DC=" + join(",DC=", rdn_list); - subobj.ROOTDN = subobj.DOMAINDN; - subobj.CONFIGDN = "CN=Configuration," + subobj.ROOTDN; - subobj.SCHEMADN = "CN=Schema," + subobj.CONFIGDN; - - subobj.MACHINEPASS_B64 = ldb.encode(subobj.MACHINEPASS); - subobj.KRBTGTPASS_B64 = ldb.encode(subobj.KRBTGTPASS); - subobj.ADMINPASS_B64 = ldb.encode(subobj.ADMINPASS); - subobj.DNSPASS_B64 = ldb.encode(subobj.DNSPASS); - - subobj.SAM_LDB = "tdb://" + paths.samdb; - subobj.SECRETS_KEYTAB = paths.keytab; - subobj.DNS_KEYTAB = paths.dns_keytab; - subobj.DNS_KEYTAB_ABS = paths.dns_keytab_abs; - - subobj.LDAPDIR = paths.ldapdir; - var ldap_path_list = split("/", paths.ldapdir); - subobj.LDAPI_URI = "ldapi://" + join("%2F", ldap_path_list) + "%2Fldapi"; - - var s4ldap_path_list = split("/", paths.s4_ldapi_socket); - subobj.S4_LDAPI_URI = "ldapi://" + join("%2F", s4ldap_path_list); - - subobj.LDAPMANAGERDN = "cn=Manager," + subobj.DOMAINDN; - - subobj.NETLOGONPATH = paths.netlogon; - subobj.SYSVOLPATH = paths.sysvol; - - if (subobj.DOMAIN_CONF == undefined) { - subobj.DOMAIN_CONF = subobj.DOMAIN; - } - if (subobj.REALM_CONF == undefined) { - subobj.REALM_CONF = subobj.REALM; - } - if (strlower(subobj.SERVERROLE) != strlower("domain controller")) { - subobj.REALM = subobj.HOSTNAME; - subobj.DOMAIN = subobj.HOSTNAME; - } - - return true; -} - -function provision_become_dc(subobj, message, erase, paths, session_info) -{ - var lp = loadparm_init(); - var sys = sys_init(); - var info = new Object(); - - var ok = provision_fix_subobj(subobj, paths); - assert(ok); - - if (subobj.BACKEND_MOD == undefined) { - subobj.BACKEND_MOD = "repl_meta_data"; - } - - info.subobj = subobj; - info.message = message; - info.session_info = session_info; - - message("Setting up templates into " + paths.templates + "\n"); - setup_ldb("provision_templates.ldif", info, paths.templates); - - /* Also wipes the database */ - message("Setting up " + paths.samdb + " partitions\n"); - setup_ldb("provision_partitions.ldif", info, paths.samdb); - - var samdb = open_ldb(info, paths.samdb, false); - - message("Setting up " + paths.samdb + " attributes\n"); - setup_add_ldif("provision_init.ldif", info, samdb, false); - - message("Setting up " + paths.samdb + " rootDSE\n"); - setup_add_ldif("provision_rootdse_add.ldif", info, samdb, false); - - if (erase) { - message("Erasing data from partitions\n"); - ldb_erase_partitions(info, samdb, undefined); - } - - message("Setting up " + paths.samdb + " indexes\n"); - setup_add_ldif("provision_index.ldif", info, samdb, false); - - ok = samdb.transaction_commit(); - assert(ok); - - message("Setting up " + paths.secrets + "\n"); - setup_ldb("secrets_init.ldif", info, paths.secrets); - - setup_ldb("secrets.ldif", info, paths.secrets, false); - - setup_ldb("secrets_dc.ldif", info, paths.secrets, false); - - return true; -} - -function load_schema(subobj, message, samdb) -{ - var lp = loadparm_init(); - var src = lp.get("setup directory") + "/" + "schema.ldif"; - - if (! sys.stat(src)) { - message("Template file not found: %s\n",src); - assert(0); - } - - var schema_data = sys.file_load(src); - - src = lp.get("setup directory") + "/" + "schema_samba4.ldif"; - - if (! sys.stat(src)) { - message("Template file not found: %s\n",src); - assert(0); - } - - schema_data = schema_data + sys.file_load(src); - - schema_data = substitute_var(schema_data, subobj); - - src = lp.get("setup directory") + "/" + "provision_schema_basedn_modify.ldif"; - - if (! sys.stat(src)) { - message("Template file not found: %s\n",src); - assert(0); - } - - var head_data = sys.file_load(src); - head_data = substitute_var(head_data, subobj); - - var ok = samdb.attach_dsdb_schema_from_ldif(head_data, schema_data); - return ok; -} - - -/* - provision samba4 - caution, this wipes all existing data! -*/ -function provision(subobj, message, blank, paths, session_info, credentials, ldapbackend) -{ - var lp = loadparm_init(); - var sys = sys_init(); - var info = new Object(); - random_init(local); - - var ok = provision_fix_subobj(subobj, paths); - assert(ok); - - if (strlower(subobj.SERVERROLE) == strlower("domain controller")) { - if (subobj.BACKEND_MOD == undefined) { - subobj.BACKEND_MOD = "repl_meta_data"; - } - } else { - if (subobj.BACKEND_MOD == undefined) { - subobj.BACKEND_MOD = "objectguid"; - } - } - - if (subobj.DOMAINGUID != undefined) { - subobj.DOMAINGUID_MOD = sprintf("replace: objectGUID\nobjectGUID: %s\n-", subobj.DOMAINGUID); - } else { - subobj.DOMAINGUID_MOD = ""; - } - - if (subobj.HOSTGUID != undefined) { - subobj.HOSTGUID_ADD = sprintf("objectGUID: %s", subobj.HOSTGUID); - } else { - subobj.HOSTGUID_ADD = ""; - } - - info.subobj = subobj; - info.message = message; - info.credentials = credentials; - info.session_info = session_info; - - /* only install a new smb.conf if there isn't one there already */ - var st = sys.stat(paths.smbconf); - if (st == undefined) { - var smbconfsuffix; - if (strlower(subobj.SERVERROLE) == strlower("domain controller")) { - smbconfsuffix = "dc"; - } else if (strlower(subobj.SERVERROLE) == strlower("member server")) { - smbconfsuffix = "member"; - } else { - smbconfsuffix = subobj.SERVERROLE; - } - message("Setting up " + paths.smbconf +"\n"); - setup_file("provision.smb.conf." + smbconfsuffix, info.message, paths.smbconf, subobj); - lp.reload(); - } - /* only install a new shares config db if there is none */ - st = sys.stat(paths.shareconf); - if (st == undefined) { - message("Setting up share.ldb\n"); - setup_ldb("share.ldif", info, paths.shareconf); - } - - message("Setting up " + paths.secrets + "\n"); - setup_ldb("secrets_init.ldif", info, paths.secrets); - setup_ldb("secrets.ldif", info, paths.secrets, false); - - message("Setting up the registry\n"); - var reg = reg_open(); - reg.apply_patchfile(lp.get("setup directory") + "/provision.reg") - - message("Setting up templates into " + paths.templates + "\n"); - setup_ldb("provision_templates.ldif", info, paths.templates); - - message("Setting up " + paths.idmapdb +"\n"); - setup_ldb("idmap_init.ldif", info, paths.idmapdb); - - message("Setting up sam.ldb partitions\n"); - /* Also wipes the database */ - setup_ldb("provision_partitions.ldif", info, paths.samdb); - - var samdb = open_ldb(info, paths.samdb, false); - - message("Setting up sam.ldb attributes\n"); - setup_add_ldif("provision_init.ldif", info, samdb, false); - - message("Setting up sam.ldb rootDSE\n"); - setup_add_ldif("provision_rootdse_add.ldif", info, samdb, false); - - message("Erasing data from partitions\n"); - ldb_erase_partitions(info, samdb, ldapbackend); - - // (hack) Reload, now we have the partitions and rootdse loaded. - var commit_ok = samdb.transaction_commit(); - if (!commit_ok) { - info.message("samdb commit failed: " + samdb.errstring() + "\n"); - assert(commit_ok); - } - samdb.close(); - - message("Pre-loading the Samba4 and AD schema\n"); - - samdb = open_ldb(info, paths.samdb, false); - - samdb.set_domain_sid(subobj.DOMAINSID); - - if (strlower(subobj.SERVERROLE) == strlower("domain controller")) { - if (subobj.INVOCATIONID == undefined) { - subobj.INVOCATIONID = randguid(); - } - samdb.set_ntds_invocationId(subobj.INVOCATIONID); - if (subobj.BACKEND_MOD == undefined) { - subobj.BACKEND_MOD = "repl_meta_data"; - } - } else { - if (subobj.BACKEND_MOD == undefined) { - subobj.BACKEND_MOD = "objectguid"; - } - } - - var load_schema_ok = load_schema(subobj, message, samdb); - assert(load_schema_ok.is_ok); - - message("Adding DomainDN: " + subobj.DOMAINDN + " (permitted to fail)\n"); - var add_ok = setup_add_ldif("provision_basedn.ldif", info, samdb, true); - message("Modifying DomainDN: " + subobj.DOMAINDN + "\n"); - var modify_basedn_ok = setup_ldb_modify("provision_basedn_modify.ldif", info, samdb); - if (!modify_basedn_ok) { - if (!add_ok) { - message("%s", "Failed to both add and modify " + subobj.DOMAINDN + " in target " + subobj.DOMAINDN_LDB + ": " + samdb.errstring() + "\n"); - message("Perhaps you need to run the provision script with the --ldap-base-dn option, and add this record to the backend manually\n"); - }; - assert(modify_basedn_ok); - }; - - message("Adding configuration container (permitted to fail)\n"); - var add_config_ok = setup_add_ldif("provision_configuration_basedn.ldif", info, samdb, true); - message("Modifying configuration container\n"); - var modify_config_ok = setup_ldb_modify("provision_configuration_basedn_modify.ldif", info, samdb); - if (!modify_config_ok) { - if (!add_config_ok) { - message("%s", "Failed to both add and modify " + subobj.CONFIGDN + " in target " + subobj.CONFIGDN_LDB + ": " + samdb.errstring() + "\n"); - message("Perhaps you need to run the provision script with the --ldap-base-dn option, and add this record to the backend manually\n"); - } - assert(modify_config_ok); - } - - message("Adding schema container (permitted to fail)\n"); - var add_schema_ok = setup_add_ldif("provision_schema_basedn.ldif", info, samdb, true); - message("Modifying schema container\n"); - var modify_schema_ok = setup_ldb_modify("provision_schema_basedn_modify.ldif", info, samdb); - if (!modify_schema_ok) { - if (!add_schema_ok) { - message("%s", "Failed to both add and modify " + subobj.SCHEMADN + " in target " + subobj.SCHEMADN_LDB + ": " + samdb.errstring() + "\n"); - message("Perhaps you need to run the provision script with the --ldap-base-dn option, and add this record to the backend manually\n"); - } - message("Failed to modify the schema container: " + samdb.errstring() + "\n"); - assert(modify_schema_ok); - } - - message("Setting up sam.ldb Samba4 schema\n"); - setup_add_ldif("schema_samba4.ldif", info, samdb, false); - message("Setting up sam.ldb AD schema\n"); - setup_add_ldif("schema.ldif", info, samdb, false); - - message("Setting up sam.ldb configuration data\n"); - setup_add_ldif("provision_configuration.ldif", info, samdb, false); - - message("Setting up display specifiers\n"); - setup_add_ldif("display_specifiers.ldif", info, samdb, false); - - message("Adding users container (permitted to fail)\n"); - var add_users_ok = setup_add_ldif("provision_users_add.ldif", info, samdb, true); - message("Modifying users container\n"); - var modify_users_ok = setup_ldb_modify("provision_users_modify.ldif", info, samdb); - if (!modify_users_ok) { - if (!add_users_ok) { - message("Failed to both add and modify the users container\n"); - } - assert(modify_users_ok); - } - message("Adding computers container (permitted to fail)\n"); - var add_computers_ok = setup_add_ldif("provision_computers_add.ldif", info, samdb, true); - message("Modifying computers container\n"); - var modify_computers_ok = setup_ldb_modify("provision_computers_modify.ldif", info, samdb); - if (!modify_computers_ok) { - if (!add_computers_ok) { - message("Failed to both add and modify the computers container\n"); - } - assert(modify_computers_ok); - } - - message("Setting up sam.ldb data\n"); - setup_add_ldif("provision.ldif", info, samdb, false); - - if (blank != false) { - message("Setting up sam.ldb index\n"); - setup_add_ldif("provision_index.ldif", info, samdb, false); - - message("Setting up sam.ldb rootDSE marking as syncronized\n"); - setup_modify_ldif("provision_rootdse_modify.ldif", info, samdb, false); - - var commit_ok = samdb.transaction_commit(); - if (!commit_ok) { - info.message("ldb commit failed: " + samdb.errstring() + "\n"); - assert(commit_ok); - } - return true; - } - -// message("Activate schema module"); -// setup_modify_ldif("schema_activation.ldif", info, samdb, false); -// -// // (hack) Reload, now we have the schema loaded. -// var commit_ok = samdb.transaction_commit(); -// if (!commit_ok) { -// info.message("samdb commit failed: " + samdb.errstring() + "\n"); -// assert(commit_ok); -// } -// samdb.close(); -// -// samdb = open_ldb(info, paths.samdb, false); -// - message("Setting up sam.ldb users and groups\n"); - setup_add_ldif("provision_users.ldif", info, samdb, false); - - if (strlower(subobj.SERVERROLE) == strlower("domain controller")) { - message("Setting up self join\n"); - setup_add_ldif("provision_self_join.ldif", info, samdb, false); - setup_add_ldif("provision_group_policy.ldif", info, samdb, false); - - sys.mkdir(paths.sysvol, 0755); - sys.mkdir(paths.sysvol + "/"+ subobj.DNSDOMAIN, 0755); - sys.mkdir(paths.sysvol + "/"+ subobj.DNSDOMAIN + "/Policies", 0755); - sys.mkdir(paths.sysvol + "/"+ subobj.DNSDOMAIN + "/Policies/{" + subobj.POLICYGUID + "}", 0755); - sys.mkdir(paths.sysvol + "/"+ subobj.DNSDOMAIN + "/Policies/{" + subobj.POLICYGUID + "}/Machine", 0755); - sys.mkdir(paths.sysvol + "/"+ subobj.DNSDOMAIN + "/Policies/{" + subobj.POLICYGUID + "}/User", 0755); - - sys.mkdir(paths.netlogon, 0755); - - setup_ldb("secrets_dc.ldif", info, paths.secrets, false); - - } - - if (setup_name_mappings(info, samdb) == false) { - return false; - } - - message("Setting up sam.ldb index\n"); - setup_add_ldif("provision_index.ldif", info, samdb, false); - - message("Setting up sam.ldb rootDSE marking as syncronized\n"); - setup_modify_ldif("provision_rootdse_modify.ldif", info, samdb, false); - - var commit_ok = samdb.transaction_commit(); - if (!commit_ok) { - info.message("samdb commit failed: " + samdb.errstring() + "\n"); - assert(commit_ok); - } - - message("Setting up phpLDAPadmin configuration\n"); - setup_file("phpldapadmin-config.php", info.message, paths.phpldapadminconfig, subobj); - message("Please install the phpLDAPadmin configuration located at " + paths.phpldapadminconfig + " into /etc/phpldapadmin/config.php\n"); - - return true; -} - -/* - provision just the schema into a temporary ldb, so we can run ad2oLschema on it -*/ -function provision_schema(subobj, message, tmp_schema_path, paths) -{ - var lp = loadparm_init(); - var sys = sys_init(); - var info = new Object(); - - var ok = provision_fix_subobj(subobj, paths); - assert(ok); - - info.subobj = subobj; - info.message = message; - - message("Setting up sam.ldb partitions\n"); - - /* This will erase anything in the tmp db */ - var samdb = open_ldb(info, tmp_schema_path, true); - - message("Setting up sam.ldb attributes\n"); - setup_add_ldif("provision_init.ldif", info, samdb, false); - - message("Setting up sam.ldb rootDSE\n"); - setup_add_ldif("provision_rootdse_add.ldif", info, samdb, false); - - message("Adding schema container (permitted to fail)\n"); - var add_ok = setup_add_ldif("provision_schema_basedn.ldif", info, samdb, true); - message("Modifying schema container\n"); - var modify_ok = setup_ldb_modify("provision_schema_basedn_modify.ldif", info, samdb); - if (!modify_ok) { - if (!add_ok) { - message("Failed to both add and modify schema dn: " + samdb.errstring() + "\n"); - message("Perhaps you need to run the provision script with the --ldap-base-dn option, and add this record to the backend manually\n"); - assert(modify_ok); - } - message("Failed to modify the schema container: " + samdb.errstring() + "\n"); - assert(modify_ok); - } - - message("Setting up sam.ldb Samba4 schema\n"); - setup_add_ldif("schema_samba4.ldif", info, samdb, false); - message("Setting up sam.ldb AD schema\n"); - setup_add_ldif("schema.ldif", info, samdb, false); - - var commit_ok = samdb.transaction_commit(); - if (!commit_ok) { - info.message("samdb commit failed: " + samdb.errstring() + "\n"); - assert(commit_ok); - } - samdb.close(); -} - -/* Write out a DNS zone file, from the info in the current database */ -function provision_dns(subobj, message, paths, session_info, credentials) -{ - var lp = loadparm_init(); - if (strlower(subobj.SERVERROLE) != strlower("domain controller")) { - message("No DNS zone required for role %s\n", subobj.SERVERROLE); - return; - } - message("Setting up DNS zone: " + subobj.DNSDOMAIN + " \n"); - var ldb = ldb_init(); - ldb.session_info = session_info; - ldb.credentials = credentials; - - /* connect to the sam */ - var ok = ldb.connect(paths.samdb); - assert(ok); - - /* These values may have changed, due to an incoming SamSync, - or may not have been specified, so fetch them from the database */ - - var attrs = new Array("objectGUID"); - res = ldb.search("objectGUID=*", subobj.DOMAINDN, ldb.SCOPE_BASE, attrs); - assert(res.error == 0); - assert(res.msgs.length == 1); - assert(res.msgs[0].objectGUID != undefined); - subobj.DOMAINGUID = res.msgs[0].objectGUID; - - subobj.HOSTGUID = searchone(ldb, subobj.DOMAINDN, "(&(objectClass=computer)(cn=" + subobj.NETBIOSNAME + "))", "objectGUID"); - assert(subobj.HOSTGUID != undefined); - - setup_file("provision.zone", - message, paths.dns, - subobj); - - setup_file("named.conf", - message, paths.named_conf, - subobj); - - message("Please install the zone located in " + paths.dns + " into your DNS server. A sample BIND configuration snippit is at " + paths.named_conf + "\n"); -} - - -/* - guess reasonably default options for provisioning -*/ -function provision_guess() -{ - var subobj = new Object(); - var nss = nss_init(); - var lp = loadparm_init(); - var rdn_list; - random_init(local); - - subobj.SERVERROLE = strlower(lp.get("server role")); - subobj.REALM = strupper(lp.get("realm")); - subobj.DOMAIN = lp.get("workgroup"); - subobj.HOSTNAME = hostname(); - - assert(subobj.REALM); - assert(subobj.DOMAIN); - assert(subobj.HOSTNAME); - - subobj.VERSION = version(); - subobj.HOSTIP = hostip(); - subobj.DOMAINSID = randsid(); - subobj.POLICYGUID = randguid(); - subobj.KRBTGTPASS = randpass(12); - subobj.MACHINEPASS = randpass(12); - subobj.DNSPASS = randpass(12); - subobj.ADMINPASS = randpass(12); - subobj.LDAPMANAGERPASS = randpass(12); - subobj.DEFAULTSITE = "Default-First-Site-Name"; - subobj.DATESTRING = datestring; - subobj.ROOT = findnss(nss.getpwnam, "root"); - subobj.NOBODY = findnss(nss.getpwnam, "nobody"); - subobj.NOGROUP = findnss(nss.getgrnam, "nogroup", "nobody"); - subobj.WHEEL = findnss(nss.getgrnam, "wheel", "root", "staff", "adm"); - subobj.BACKUP = findnss(nss.getgrnam, "backup", "wheel", "root", "staff"); - subobj.USERS = findnss(nss.getgrnam, "users", "guest", "other", "unknown", "usr"); - - //Add modules to the list to activate them by default - //beware often order is important - // - // Some Known ordering constraints: - // - rootdse must be first, as it makes redirects from "" -> cn=rootdse - // - objectclass must be before password_hash, because password_hash checks - // that the objectclass is of type person (filled in by the objectclass - // module when expanding the objectclass list) - // - partition must be last - // - each partition has its own module list then - var modules_list = new Array("rootdse", - "paged_results", - "ranged_results", - "anr", - "server_sort", - "extended_dn", - "asq", - "samldb", - "rdn_name", - "objectclass", - "kludge_acl", - "operational"); - var tdb_modules_list = new Array("subtree_rename", - "subtree_delete", - "linked_attributes"); - var modules_list2 = new Array("show_deleted", - "partition"); - subobj.MODULES_LIST = join(",", modules_list); - subobj.TDB_MODULES_LIST = "," + join(",", tdb_modules_list); - subobj.MODULES_LIST2 = join(",", modules_list2); - subobj.DOMAINDN_LDB = "users.ldb"; - subobj.CONFIGDN_LDB = "configuration.ldb"; - subobj.SCHEMADN_LDB = "schema.ldb"; - subobj.DOMAINDN_MOD = "pdc_fsmo,password_hash,instancetype"; - subobj.CONFIGDN_MOD = "naming_fsmo,instancetype"; - subobj.SCHEMADN_MOD = "schema_fsmo,instancetype"; - - subobj.ACI = "# no aci for local ldb"; - - return subobj; -} - -/* - search for one attribute as a string - */ -function searchone(ldb, basedn, expression, attribute) -{ - var attrs = new Array(attribute); - res = ldb.search(expression, basedn, ldb.SCOPE_SUBTREE, attrs); - if (res.error != 0 || - res.msgs.length != 1 || - res.msgs[0][attribute] == undefined) { - return undefined; - } - return res.msgs[0][attribute]; -} - -/* - modify an account to remove the -*/ -function enable_account(ldb, user_dn) -{ - var attrs = new Array("userAccountControl"); - var res = ldb.search(NULL, user_dn, ldb.SCOPE_ONELEVEL, attrs); - assert(res.error == 0); - assert(res.msgs.length == 1); - var userAccountControl = res.msgs[0].userAccountControl; - userAccountControl = userAccountControl - 2; /* remove disabled bit */ - var mod = sprintf(" -dn: %s -changetype: modify -replace: userAccountControl -userAccountControl: %u -", - user_dn, userAccountControl); - var ok = ldb.modify(mod); - return (ok.error == 0); -} - - -/* - add a new user record -*/ -function newuser(username, unixname, password, message, session_info, credentials) -{ - var lp = loadparm_init(); - var samdb = lp.get("sam database"); - var ldb = ldb_init(); - random_init(local); - ldb.session_info = session_info; - ldb.credentials = credentials; - - /* connect to the sam */ - var ok = ldb.connect(samdb); - assert(ok); - - ldb.transaction_start(); - - /* find the DNs for the domain and the domain users group */ - var attrs = new Array("defaultNamingContext"); - res = ldb.search("defaultNamingContext=*", "", ldb.SCOPE_BASE, attrs); - assert(res.error == 0); - assert(res.msgs.length == 1 && res.msgs[0].defaultNamingContext != undefined); - var domain_dn = res.msgs[0].defaultNamingContext; - assert(domain_dn != undefined); - var dom_users = searchone(ldb, domain_dn, "name=Domain Users", "dn"); - assert(dom_users != undefined); - - var user_dn = sprintf("CN=%s,CN=Users,%s", username, domain_dn); - - - /* - the new user record. note the reliance on the samdb module to fill - in a sid, guid etc - */ - var ldif = sprintf(" -dn: %s -sAMAccountName: %s -unixName: %s -sambaPassword: %s -objectClass: user -", - user_dn, username, - unixname, password); - /* - add the user to the users group as well - */ - var modgroup = sprintf(" -dn: %s -changetype: modify -add: member -member: %s -", - dom_users, user_dn); - - - /* - now the real work - */ - message("Adding user %s\n", user_dn); - ok = ldb.add(ldif); - if (ok.error != 0) { - message("Failed to add %s - %s\n", user_dn, ok.errstr); - return false; - } - - message("Modifying group %s\n", dom_users); - ok = ldb.modify(modgroup); - if (ok.error != 0) { - message("Failed to modify %s - %s\n", dom_users, ok.errstr); - return false; - } - - /* - modify the userAccountControl to remove the disabled bit - */ - ok = enable_account(ldb, user_dn); - if (ok) { - ldb.transaction_commit(); - } - return ok; -} - -// Check whether a name is valid as a NetBIOS name. -// FIXME: There are probably more constraints here. -// crh has a paragraph on this in his book (1.4.1.1) -function valid_netbios_name(name) -{ - if (strlen(name) > 15) return false; - return true; -} - -function provision_validate(subobj, message) -{ - var lp = loadparm_init(); - - if (!valid_netbios_name(subobj.DOMAIN)) { - message("Invalid NetBIOS name for domain\n"); - return false; - } - - if (!valid_netbios_name(subobj.NETBIOSNAME)) { - message("Invalid NetBIOS name for host\n"); - return false; - } - - - if (strupper(lp.get("workgroup")) != strupper(subobj.DOMAIN_CONF)) { - message("workgroup '%s' in smb.conf must match chosen domain '%s'\n", - lp.get("workgroup"), subobj.DOMAIN_CONF); - return false; - } - - if (strupper(lp.get("realm")) != strupper(subobj.REALM_CONF)) { - message("realm '%s' in smb.conf must match chosen realm '%s'\n", - lp.get("realm"), subobj.REALM_CONF); - return false; - } - - if (strlower(lp.get("server role")) != strlower(subobj.SERVERROLE)) { - message("server role '%s' in smb.conf must match chosen role '%s'\n", - lp.get("server role"), subobj.SERVERROLE); - return false; - } - - return true; -} - -function join_domain(domain, netbios_name, join_type, creds, message) -{ - var ctx = NetContext(creds); - var joindom = new Object(); - joindom.domain = domain; - joindom.join_type = join_type; - joindom.netbios_name = netbios_name; - if (!ctx.JoinDomain(joindom)) { - message("Domain Join failed: " + joindom.error_string); - return false; - } - return true; -} - -/* Vampire a remote domain. Session info and credentials are required for for - * access to our local database (might be remote ldap) - */ - -function vampire(domain, session_info, credentials, message) { - var ctx = NetContext(credentials); - var vampire_ctx = new Object(); - var machine_creds = credentials_init(); - machine_creds.set_domain(form.DOMAIN); - if (!machine_creds.set_machine_account()) { - message("Failed to access domain join information!"); - return false; - } - vampire_ctx.machine_creds = machine_creds; - vampire_ctx.session_info = session_info; - if (!ctx.SamSyncLdb(vampire_ctx)) { - message("Migration of remote domain to Samba failed: " + vampire_ctx.error_string); - return false; - } - - return true; -} - -return 0; -- cgit