mirror of
https://github.com/samba-team/samba.git
synced 2025-07-22 16:59:09 +03:00
Merge branch 'v4-0-test' of ssh://git.samba.org/data/git/samba into v4-0-wsgi
Conflicts:
source/scripting/python/samba/provision.py
(This used to be commit d27de63365
)
This commit is contained in:
@ -5,7 +5,7 @@ AC_ARG_VAR([PYTHON_VERSION],[The installed Python
|
||||
will be appended to the Python interpreter
|
||||
canonical name.])
|
||||
|
||||
AC_PROG_SWIG(1.3.31)
|
||||
AC_PROG_SWIG(1.3.35)
|
||||
|
||||
AC_PATH_PROG([PYTHON],[python[$PYTHON_VERSION]])
|
||||
if test -z "$PYTHON"; then
|
||||
@ -64,10 +64,14 @@ SMB_EXT_LIB(EXT_LIB_PYTHON, [$PYTHON_LDFLAGS], [$PYTHON_CFLAGS])
|
||||
AC_MSG_CHECKING(working python module support)
|
||||
if test $working_python = yes; then
|
||||
SMB_ENABLE(EXT_LIB_PYTHON,YES)
|
||||
SMB_ENABLE(smbpython,YES)
|
||||
SMB_ENABLE(LIBPYTHON,YES)
|
||||
AC_MSG_RESULT([yes])
|
||||
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)
|
||||
|
@ -1,49 +1,37 @@
|
||||
[BINARY::smbpython]
|
||||
PRIVATE_DEPENDENCIES = LIBPYTHON
|
||||
OBJ_FILES = smbpython.o
|
||||
|
||||
[SUBSYSTEM::LIBPYTHON]
|
||||
PUBLIC_DEPENDENCIES = EXT_LIB_PYTHON
|
||||
PRIVATE_DEPENDENCIES = PYTALLOC
|
||||
INIT_FUNCTION_SENTINEL = { NULL, NULL }
|
||||
OBJ_FILES = modules.o pytalloc.o
|
||||
|
||||
LIBPYTHON_OBJ_FILES = $(addprefix $(pyscriptsrcdir)/, modules.o)
|
||||
|
||||
[SUBSYSTEM::PYTALLOC]
|
||||
PUBLIC_DEPENDENCIES = EXT_LIB_PYTHON LIBTALLOC
|
||||
|
||||
PYTALLOC_OBJ_FILES = $(addprefix $(pyscriptsrcdir)/, pytalloc.o)
|
||||
|
||||
[PYTHON::python_uuid]
|
||||
PRIVATE_DEPENDENCIES = LIBNDR
|
||||
OBJ_FILES = uuidmodule.o
|
||||
|
||||
python_uuid_OBJ_FILES = $(pyscriptsrcdir)/uuidmodule.o
|
||||
|
||||
[PYTHON::python_misc]
|
||||
LIBRARY_REALNAME = samba/_misc.$(SHLIBEXT)
|
||||
PRIVATE_DEPENDENCIES = LIBNDR LIBLDB SAMDB CREDENTIALS
|
||||
SWIG_FILE = misc.i
|
||||
|
||||
# Swig extensions
|
||||
swig:: pythonmods
|
||||
python_misc_OBJ_FILES = $(pyscriptsrcdir)/misc_wrap.o
|
||||
|
||||
.SUFFIXES: _wrap.c .i
|
||||
$(python_misc_OBJ_FILES): CFLAGS+=$(CFLAG_NO_UNUSED_MACROS) $(CFLAG_NO_CAST_QUAL)
|
||||
|
||||
.i_wrap.c:
|
||||
[ "$(SWIG)" = "no" ] || $(SWIG) -O -Wall -I$(srcdir)/scripting/swig -python -keyword $<
|
||||
_PY_FILES = $(shell find $(pyscriptsrcdir)/samba $(pyscriptsrcdir)/subunit -name "*.py")
|
||||
|
||||
realdistclean::
|
||||
@echo "Removing SWIG output files"
|
||||
# FIXME: Remove _wrap.c files
|
||||
$(foreach pyfile, $(_PY_FILES),$(eval $(call python_py_module_template,$(patsubst $(pyscriptsrcdir)/%,%,$(pyfile)),$(pyfile))))
|
||||
|
||||
pythonmods:: $(PYTHON_DSOS) $(PYTHON_PYS)
|
||||
$(eval $(call python_py_module_template,samba/misc.py,$(pyscriptsrcdir)/misc.py))
|
||||
|
||||
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
|
||||
EPYDOC_OPTIONS = --no-private --url http://www.samba.org/ --no-sourcecode
|
||||
|
||||
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))
|
||||
epydoc:: pythonmods
|
||||
PYTHONPATH=$(pythonbuilddir) epydoc $(EPYDOC_OPTIONS) samba tdb ldb subunit
|
||||
|
||||
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 -rf bin/python/*
|
||||
install:: installpython
|
||||
|
@ -40,6 +40,15 @@
|
||||
%rename(random_password) generate_random_str;
|
||||
char *generate_random_str(TALLOC_CTX *mem_ctx, size_t len);
|
||||
|
||||
%feature("docstring") ldb_set_credentials "S.set_credentials(credentials)\n"
|
||||
"Set credentials to use when connecting.";
|
||||
|
||||
%feature("docstring") ldb_set_session_info "S.set_session_info(session_info)\n"
|
||||
"Set session info to use when connecting.";
|
||||
|
||||
%feature("docstring") ldb_set_loadparm "S.set_loadparm(session_info)\n"
|
||||
"Set loadparm context to use when connecting.";
|
||||
|
||||
%inline %{
|
||||
void ldb_set_credentials(struct ldb_context *ldb, struct cli_credentials *creds)
|
||||
{
|
||||
@ -58,14 +67,20 @@ void ldb_set_loadparm(struct ldb_context *ldb, struct loadparm_context *lp_ctx)
|
||||
|
||||
%}
|
||||
|
||||
%feature("docstring") samdb_set_domain_sid "S.set_domain_sid(sid)\n"
|
||||
"Set SID of domain to use.";
|
||||
bool samdb_set_domain_sid(struct ldb_context *ldb,
|
||||
const struct dom_sid *dom_sid_in);
|
||||
|
||||
WERROR dsdb_attach_schema_from_ldif_file(struct ldb_context *ldb, const char *pf, const char *df);
|
||||
|
||||
%feature("docstring") samba_version_string "version()\n"
|
||||
"Obtain the Samba version.";
|
||||
%rename(version) samba_version_string;
|
||||
const char *samba_version_string(void);
|
||||
int dsdb_set_global_schema(struct ldb_context *ldb);
|
||||
%feature("docstring") ldb_register_samba_handlers "register_samba_handlers()\n"
|
||||
"Register Samba-specific LDB modules and schemas.";
|
||||
int ldb_register_samba_handlers(struct ldb_context *ldb);
|
||||
|
||||
%inline %{
|
||||
@ -78,3 +93,8 @@ bool dsdb_set_ntds_invocation_id(struct ldb_context *ldb, const char *guid)
|
||||
return samdb_set_ntds_invocation_id(ldb, &invocation_id_in);
|
||||
}
|
||||
%}
|
||||
|
||||
char *private_path(TALLOC_CTX* mem_ctx,
|
||||
struct loadparm_context *lp_ctx,
|
||||
const char *name);
|
||||
|
||||
|
@ -1,5 +1,5 @@
|
||||
# This file was automatically generated by SWIG (http://www.swig.org).
|
||||
# Version 1.3.33
|
||||
# Version 1.3.35
|
||||
#
|
||||
# Don't modify this file, modify the SWIG interface instead.
|
||||
|
||||
@ -62,14 +62,51 @@ import credentials
|
||||
import param
|
||||
import security
|
||||
random_password = _misc.random_password
|
||||
ldb_set_credentials = _misc.ldb_set_credentials
|
||||
ldb_set_session_info = _misc.ldb_set_session_info
|
||||
ldb_set_loadparm = _misc.ldb_set_loadparm
|
||||
samdb_set_domain_sid = _misc.samdb_set_domain_sid
|
||||
|
||||
def ldb_set_credentials(*args, **kwargs):
|
||||
"""
|
||||
S.set_credentials(credentials)
|
||||
Set credentials to use when connecting.
|
||||
"""
|
||||
return _misc.ldb_set_credentials(*args, **kwargs)
|
||||
|
||||
def ldb_set_session_info(*args, **kwargs):
|
||||
"""
|
||||
S.set_session_info(session_info)
|
||||
Set session info to use when connecting.
|
||||
"""
|
||||
return _misc.ldb_set_session_info(*args, **kwargs)
|
||||
|
||||
def ldb_set_loadparm(*args, **kwargs):
|
||||
"""
|
||||
S.set_loadparm(session_info)
|
||||
Set loadparm context to use when connecting.
|
||||
"""
|
||||
return _misc.ldb_set_loadparm(*args, **kwargs)
|
||||
|
||||
def samdb_set_domain_sid(*args, **kwargs):
|
||||
"""
|
||||
S.set_domain_sid(sid)
|
||||
Set SID of domain to use.
|
||||
"""
|
||||
return _misc.samdb_set_domain_sid(*args, **kwargs)
|
||||
dsdb_attach_schema_from_ldif_file = _misc.dsdb_attach_schema_from_ldif_file
|
||||
version = _misc.version
|
||||
|
||||
def version(*args):
|
||||
"""
|
||||
version()
|
||||
Obtain the Samba version.
|
||||
"""
|
||||
return _misc.version(*args)
|
||||
dsdb_set_global_schema = _misc.dsdb_set_global_schema
|
||||
ldb_register_samba_handlers = _misc.ldb_register_samba_handlers
|
||||
|
||||
def ldb_register_samba_handlers(*args, **kwargs):
|
||||
"""
|
||||
register_samba_handlers()
|
||||
Register Samba-specific LDB modules and schemas.
|
||||
"""
|
||||
return _misc.ldb_register_samba_handlers(*args, **kwargs)
|
||||
dsdb_set_ntds_invocation_id = _misc.dsdb_set_ntds_invocation_id
|
||||
private_path = _misc.private_path
|
||||
|
||||
|
||||
|
@ -1,6 +1,6 @@
|
||||
/* ----------------------------------------------------------------------------
|
||||
* This file was automatically generated by SWIG (http://www.swig.org).
|
||||
* Version 1.3.33
|
||||
* Version 1.3.35
|
||||
*
|
||||
* This file is not intended to be easily readable and contains a number of
|
||||
* coding conventions designed to improve portability and efficiency. Do not make
|
||||
@ -126,7 +126,7 @@
|
||||
|
||||
/* This should only be incremented when either the layout of swig_type_info changes,
|
||||
or for whatever reason, the runtime changes incompatibly */
|
||||
#define SWIG_RUNTIME_VERSION "3"
|
||||
#define SWIG_RUNTIME_VERSION "4"
|
||||
|
||||
/* define SWIG_TYPE_TABLE_NAME as "SWIG_TYPE_TABLE" */
|
||||
#ifdef SWIG_TYPE_TABLE
|
||||
@ -161,6 +161,7 @@
|
||||
|
||||
/* Flags for pointer conversions */
|
||||
#define SWIG_POINTER_DISOWN 0x1
|
||||
#define SWIG_CAST_NEW_MEMORY 0x2
|
||||
|
||||
/* Flags for new pointer objects */
|
||||
#define SWIG_POINTER_OWN 0x1
|
||||
@ -301,10 +302,10 @@ SWIGINTERNINLINE int SWIG_CheckState(int r) {
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
typedef void *(*swig_converter_func)(void *);
|
||||
typedef void *(*swig_converter_func)(void *, int *);
|
||||
typedef struct swig_type_info *(*swig_dycast_func)(void **);
|
||||
|
||||
/* Structure to store inforomation on one type */
|
||||
/* Structure to store information on one type */
|
||||
typedef struct swig_type_info {
|
||||
const char *name; /* mangled name of this type */
|
||||
const char *str; /* human readable name of this type */
|
||||
@ -431,8 +432,8 @@ SWIG_TypeCheckStruct(swig_type_info *from, swig_type_info *into) {
|
||||
Cast a pointer up an inheritance hierarchy
|
||||
*/
|
||||
SWIGRUNTIMEINLINE void *
|
||||
SWIG_TypeCast(swig_cast_info *ty, void *ptr) {
|
||||
return ((!ty) || (!ty->converter)) ? ptr : (*ty->converter)(ptr);
|
||||
SWIG_TypeCast(swig_cast_info *ty, void *ptr, int *newmemory) {
|
||||
return ((!ty) || (!ty->converter)) ? ptr : (*ty->converter)(ptr, newmemory);
|
||||
}
|
||||
|
||||
/*
|
||||
@ -856,7 +857,7 @@ SWIG_Python_AddErrorMsg(const char* mesg)
|
||||
Py_DECREF(old_str);
|
||||
Py_DECREF(value);
|
||||
} else {
|
||||
PyErr_Format(PyExc_RuntimeError, mesg);
|
||||
PyErr_SetString(PyExc_RuntimeError, mesg);
|
||||
}
|
||||
}
|
||||
|
||||
@ -1416,7 +1417,7 @@ PySwigObject_dealloc(PyObject *v)
|
||||
{
|
||||
PySwigObject *sobj = (PySwigObject *) v;
|
||||
PyObject *next = sobj->next;
|
||||
if (sobj->own) {
|
||||
if (sobj->own == SWIG_POINTER_OWN) {
|
||||
swig_type_info *ty = sobj->ty;
|
||||
PySwigClientData *data = ty ? (PySwigClientData *) ty->clientdata : 0;
|
||||
PyObject *destroy = data ? data->destroy : 0;
|
||||
@ -1434,12 +1435,13 @@ PySwigObject_dealloc(PyObject *v)
|
||||
res = ((*meth)(mself, v));
|
||||
}
|
||||
Py_XDECREF(res);
|
||||
} else {
|
||||
const char *name = SWIG_TypePrettyName(ty);
|
||||
}
|
||||
#if !defined(SWIG_PYTHON_SILENT_MEMLEAK)
|
||||
printf("swig/python detected a memory leak of type '%s', no destructor found.\n", name);
|
||||
#endif
|
||||
else {
|
||||
const char *name = SWIG_TypePrettyName(ty);
|
||||
printf("swig/python detected a memory leak of type '%s', no destructor found.\n", (name ? name : "unknown"));
|
||||
}
|
||||
#endif
|
||||
}
|
||||
Py_XDECREF(next);
|
||||
PyObject_DEL(v);
|
||||
@ -1944,7 +1946,7 @@ SWIG_Python_GetSwigThis(PyObject *pyobj)
|
||||
|
||||
SWIGRUNTIME int
|
||||
SWIG_Python_AcquirePtr(PyObject *obj, int own) {
|
||||
if (own) {
|
||||
if (own == SWIG_POINTER_OWN) {
|
||||
PySwigObject *sobj = SWIG_Python_GetSwigThis(obj);
|
||||
if (sobj) {
|
||||
int oldown = sobj->own;
|
||||
@ -1965,6 +1967,8 @@ SWIG_Python_ConvertPtrAndOwn(PyObject *obj, void **ptr, swig_type_info *ty, int
|
||||
return SWIG_OK;
|
||||
} else {
|
||||
PySwigObject *sobj = SWIG_Python_GetSwigThis(obj);
|
||||
if (own)
|
||||
*own = 0;
|
||||
while (sobj) {
|
||||
void *vptr = sobj->ptr;
|
||||
if (ty) {
|
||||
@ -1978,7 +1982,15 @@ SWIG_Python_ConvertPtrAndOwn(PyObject *obj, void **ptr, swig_type_info *ty, int
|
||||
if (!tc) {
|
||||
sobj = (PySwigObject *)sobj->next;
|
||||
} else {
|
||||
if (ptr) *ptr = SWIG_TypeCast(tc,vptr);
|
||||
if (ptr) {
|
||||
int newmemory = 0;
|
||||
*ptr = SWIG_TypeCast(tc,vptr,&newmemory);
|
||||
if (newmemory == SWIG_CAST_NEW_MEMORY) {
|
||||
assert(own);
|
||||
if (own)
|
||||
*own = *own | SWIG_CAST_NEW_MEMORY;
|
||||
}
|
||||
}
|
||||
break;
|
||||
}
|
||||
}
|
||||
@ -1988,7 +2000,8 @@ SWIG_Python_ConvertPtrAndOwn(PyObject *obj, void **ptr, swig_type_info *ty, int
|
||||
}
|
||||
}
|
||||
if (sobj) {
|
||||
if (own) *own = sobj->own;
|
||||
if (own)
|
||||
*own = *own | sobj->own;
|
||||
if (flags & SWIG_POINTER_DISOWN) {
|
||||
sobj->own = 0;
|
||||
}
|
||||
@ -2053,8 +2066,13 @@ SWIG_Python_ConvertFunctionPtr(PyObject *obj, void **ptr, swig_type_info *ty) {
|
||||
}
|
||||
if (ty) {
|
||||
swig_cast_info *tc = SWIG_TypeCheck(desc,ty);
|
||||
if (!tc) return SWIG_ERROR;
|
||||
*ptr = SWIG_TypeCast(tc,vptr);
|
||||
if (tc) {
|
||||
int newmemory = 0;
|
||||
*ptr = SWIG_TypeCast(tc,vptr,&newmemory);
|
||||
assert(!newmemory); /* newmemory handling not yet implemented */
|
||||
} else {
|
||||
return SWIG_ERROR;
|
||||
}
|
||||
} else {
|
||||
*ptr = vptr;
|
||||
}
|
||||
@ -2519,7 +2537,7 @@ static swig_module_info swig_module = {swig_types, 27, 0, 0, 0, 0};
|
||||
|
||||
#define SWIG_name "_misc"
|
||||
|
||||
#define SWIGVERSION 0x010333
|
||||
#define SWIGVERSION 0x010335
|
||||
#define SWIG_VERSION SWIGVERSION
|
||||
|
||||
|
||||
@ -3153,17 +3171,80 @@ fail:
|
||||
}
|
||||
|
||||
|
||||
SWIGINTERN PyObject *_wrap_private_path(PyObject *SWIGUNUSEDPARM(self), PyObject *args, PyObject *kwargs) {
|
||||
PyObject *resultobj = 0;
|
||||
TALLOC_CTX *arg1 = (TALLOC_CTX *) 0 ;
|
||||
struct loadparm_context *arg2 = (struct loadparm_context *) 0 ;
|
||||
char *arg3 = (char *) 0 ;
|
||||
char *result = 0 ;
|
||||
void *argp2 = 0 ;
|
||||
int res2 = 0 ;
|
||||
int res3 ;
|
||||
char *buf3 = 0 ;
|
||||
int alloc3 = 0 ;
|
||||
PyObject * obj0 = 0 ;
|
||||
PyObject * obj1 = 0 ;
|
||||
char * kwnames[] = {
|
||||
(char *) "lp_ctx",(char *) "name", NULL
|
||||
};
|
||||
|
||||
arg2 = loadparm_init(NULL);
|
||||
arg1 = NULL;
|
||||
if (!PyArg_ParseTupleAndKeywords(args,kwargs,(char *)"|OO:private_path",kwnames,&obj0,&obj1)) SWIG_fail;
|
||||
if (obj0) {
|
||||
res2 = SWIG_ConvertPtr(obj0, &argp2,SWIGTYPE_p_loadparm_context, 0 | 0 );
|
||||
if (!SWIG_IsOK(res2)) {
|
||||
SWIG_exception_fail(SWIG_ArgError(res2), "in method '" "private_path" "', argument " "2"" of type '" "struct loadparm_context *""'");
|
||||
}
|
||||
arg2 = (struct loadparm_context *)(argp2);
|
||||
}
|
||||
if (obj1) {
|
||||
res3 = SWIG_AsCharPtrAndSize(obj1, &buf3, NULL, &alloc3);
|
||||
if (!SWIG_IsOK(res3)) {
|
||||
SWIG_exception_fail(SWIG_ArgError(res3), "in method '" "private_path" "', argument " "3"" of type '" "char const *""'");
|
||||
}
|
||||
arg3 = (char *)(buf3);
|
||||
}
|
||||
result = (char *)private_path(arg1,arg2,(char const *)arg3);
|
||||
resultobj = SWIG_FromCharPtr((const char *)result);
|
||||
if (alloc3 == SWIG_NEWOBJ) free((char*)buf3);
|
||||
return resultobj;
|
||||
fail:
|
||||
if (alloc3 == SWIG_NEWOBJ) free((char*)buf3);
|
||||
return NULL;
|
||||
}
|
||||
|
||||
|
||||
static PyMethodDef SwigMethods[] = {
|
||||
{ (char *)"random_password", (PyCFunction) _wrap_random_password, METH_VARARGS | METH_KEYWORDS, NULL},
|
||||
{ (char *)"ldb_set_credentials", (PyCFunction) _wrap_ldb_set_credentials, METH_VARARGS | METH_KEYWORDS, NULL},
|
||||
{ (char *)"ldb_set_session_info", (PyCFunction) _wrap_ldb_set_session_info, METH_VARARGS | METH_KEYWORDS, NULL},
|
||||
{ (char *)"ldb_set_loadparm", (PyCFunction) _wrap_ldb_set_loadparm, METH_VARARGS | METH_KEYWORDS, NULL},
|
||||
{ (char *)"samdb_set_domain_sid", (PyCFunction) _wrap_samdb_set_domain_sid, METH_VARARGS | METH_KEYWORDS, NULL},
|
||||
{ (char *)"ldb_set_credentials", (PyCFunction) _wrap_ldb_set_credentials, METH_VARARGS | METH_KEYWORDS, (char *)"\n"
|
||||
"S.set_credentials(credentials)\n"
|
||||
"Set credentials to use when connecting.\n"
|
||||
""},
|
||||
{ (char *)"ldb_set_session_info", (PyCFunction) _wrap_ldb_set_session_info, METH_VARARGS | METH_KEYWORDS, (char *)"\n"
|
||||
"S.set_session_info(session_info)\n"
|
||||
"Set session info to use when connecting.\n"
|
||||
""},
|
||||
{ (char *)"ldb_set_loadparm", (PyCFunction) _wrap_ldb_set_loadparm, METH_VARARGS | METH_KEYWORDS, (char *)"\n"
|
||||
"S.set_loadparm(session_info)\n"
|
||||
"Set loadparm context to use when connecting.\n"
|
||||
""},
|
||||
{ (char *)"samdb_set_domain_sid", (PyCFunction) _wrap_samdb_set_domain_sid, METH_VARARGS | METH_KEYWORDS, (char *)"\n"
|
||||
"S.set_domain_sid(sid)\n"
|
||||
"Set SID of domain to use.\n"
|
||||
""},
|
||||
{ (char *)"dsdb_attach_schema_from_ldif_file", (PyCFunction) _wrap_dsdb_attach_schema_from_ldif_file, METH_VARARGS | METH_KEYWORDS, NULL},
|
||||
{ (char *)"version", (PyCFunction)_wrap_version, METH_NOARGS, NULL},
|
||||
{ (char *)"version", (PyCFunction)_wrap_version, METH_NOARGS, (char *)"\n"
|
||||
"version()\n"
|
||||
"Obtain the Samba version.\n"
|
||||
""},
|
||||
{ (char *)"dsdb_set_global_schema", (PyCFunction) _wrap_dsdb_set_global_schema, METH_VARARGS | METH_KEYWORDS, NULL},
|
||||
{ (char *)"ldb_register_samba_handlers", (PyCFunction) _wrap_ldb_register_samba_handlers, METH_VARARGS | METH_KEYWORDS, NULL},
|
||||
{ (char *)"ldb_register_samba_handlers", (PyCFunction) _wrap_ldb_register_samba_handlers, METH_VARARGS | METH_KEYWORDS, (char *)"\n"
|
||||
"register_samba_handlers()\n"
|
||||
"Register Samba-specific LDB modules and schemas.\n"
|
||||
""},
|
||||
{ (char *)"dsdb_set_ntds_invocation_id", (PyCFunction) _wrap_dsdb_set_ntds_invocation_id, METH_VARARGS | METH_KEYWORDS, NULL},
|
||||
{ (char *)"private_path", (PyCFunction) _wrap_private_path, METH_VARARGS | METH_KEYWORDS, NULL},
|
||||
{ NULL, NULL, 0, NULL }
|
||||
};
|
||||
|
||||
@ -3180,7 +3261,7 @@ static swig_type_info _swigt__p_ldb_context = {"_p_ldb_context", "struct ldb_con
|
||||
static swig_type_info _swigt__p_ldb_dn = {"_p_ldb_dn", "struct ldb_dn *|ldb_dn *", 0, 0, (void*)0, 0};
|
||||
static swig_type_info _swigt__p_ldb_ldif = {"_p_ldb_ldif", "struct ldb_ldif *|ldb_ldif *", 0, 0, (void*)0, 0};
|
||||
static swig_type_info _swigt__p_ldb_message = {"_p_ldb_message", "ldb_msg *|struct ldb_message *", 0, 0, (void*)0, 0};
|
||||
static swig_type_info _swigt__p_ldb_message_element = {"_p_ldb_message_element", "struct ldb_message_element *|ldb_msg_element *", 0, 0, (void*)0, 0};
|
||||
static swig_type_info _swigt__p_ldb_message_element = {"_p_ldb_message_element", "struct ldb_message_element *|ldb_message_element *", 0, 0, (void*)0, 0};
|
||||
static swig_type_info _swigt__p_ldb_result = {"_p_ldb_result", "struct ldb_result *", 0, 0, (void*)0, 0};
|
||||
static swig_type_info _swigt__p_loadparm_context = {"_p_loadparm_context", "struct loadparm_context *|loadparm_context *", 0, 0, (void*)0, 0};
|
||||
static swig_type_info _swigt__p_loadparm_service = {"_p_loadparm_service", "struct loadparm_service *|loadparm_service *", 0, 0, (void*)0, 0};
|
||||
@ -3352,7 +3433,7 @@ SWIGRUNTIME void
|
||||
SWIG_InitializeModule(void *clientdata) {
|
||||
size_t i;
|
||||
swig_module_info *module_head, *iter;
|
||||
int found;
|
||||
int found, init;
|
||||
|
||||
clientdata = clientdata;
|
||||
|
||||
@ -3362,6 +3443,9 @@ SWIG_InitializeModule(void *clientdata) {
|
||||
swig_module.type_initial = swig_type_initial;
|
||||
swig_module.cast_initial = swig_cast_initial;
|
||||
swig_module.next = &swig_module;
|
||||
init = 1;
|
||||
} else {
|
||||
init = 0;
|
||||
}
|
||||
|
||||
/* Try and load any already created modules */
|
||||
@ -3390,6 +3474,12 @@ SWIG_InitializeModule(void *clientdata) {
|
||||
module_head->next = &swig_module;
|
||||
}
|
||||
|
||||
/* When multiple interpeters are used, a module could have already been initialized in
|
||||
a different interpreter, but not yet have a pointer in this interpreter.
|
||||
In this case, we do not want to continue adding types... everything should be
|
||||
set up already */
|
||||
if (init == 0) return;
|
||||
|
||||
/* Now work on filling in swig_module.types */
|
||||
#ifdef SWIGRUNTIME_DEBUG
|
||||
printf("SWIG_InitializeModule: size %d\n", swig_module.size);
|
||||
|
@ -19,7 +19,6 @@
|
||||
|
||||
#include "includes.h"
|
||||
#include <Python.h>
|
||||
#include "build.h"
|
||||
|
||||
extern void init_ldb(void);
|
||||
extern void init_security(void);
|
||||
@ -35,17 +34,19 @@ extern void init_events(void);
|
||||
extern void inituuid(void);
|
||||
extern void init_net(void);
|
||||
extern void initecho(void);
|
||||
extern void initdfs(void);
|
||||
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);
|
||||
extern void initunixinfo(void);
|
||||
extern void init_libcli_nbt(void);
|
||||
extern void init_libcli_smb(void);
|
||||
|
||||
|
@ -17,6 +17,9 @@
|
||||
along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
#ifndef _PYRPC_H_
|
||||
#define _PYRPC_H_
|
||||
|
||||
#define PY_CHECK_TYPE(type, var, fail) \
|
||||
if (!type ## _Check(var)) {\
|
||||
PyErr_Format(PyExc_TypeError, "Expected type %s", type ## _Type.tp_name); \
|
||||
@ -26,9 +29,11 @@
|
||||
#define dom_sid2_Type dom_sid_Type
|
||||
#define dom_sid28_Type dom_sid_Type
|
||||
#define dom_sid2_Check dom_sid_Check
|
||||
#define dom_sid28_Check dom_sid28_Check
|
||||
#define dom_sid28_Check dom_sid_Check
|
||||
|
||||
/* This macro is only provided by Python >= 2.3 */
|
||||
#ifndef PyAPI_DATA
|
||||
# define PyAPI_DATA(RTYPE) extern RTYPE
|
||||
#endif
|
||||
|
||||
#endif /* _PYRPC_H_ */
|
||||
|
@ -24,6 +24,7 @@ void py_talloc_dealloc(PyObject* self)
|
||||
{
|
||||
py_talloc_Object *obj = (py_talloc_Object *)self;
|
||||
talloc_free(obj->talloc_ctx);
|
||||
obj->talloc_ctx = NULL;
|
||||
PyObject_Del(self);
|
||||
}
|
||||
|
||||
@ -31,7 +32,13 @@ PyObject *py_talloc_import_ex(PyTypeObject *py_type, TALLOC_CTX *mem_ctx,
|
||||
void *ptr)
|
||||
{
|
||||
py_talloc_Object *ret = PyObject_New(py_talloc_Object, py_type);
|
||||
ret->talloc_ctx = talloc_reference(NULL, mem_ctx);
|
||||
ret->talloc_ctx = talloc_new(NULL);
|
||||
if (ret->talloc_ctx == NULL) {
|
||||
return NULL;
|
||||
}
|
||||
if (talloc_reference(ret->talloc_ctx, mem_ctx) == NULL) {
|
||||
return NULL;
|
||||
}
|
||||
ret->ptr = ptr;
|
||||
return (PyObject *)ret;
|
||||
}
|
||||
@ -39,7 +46,7 @@ PyObject *py_talloc_import_ex(PyTypeObject *py_type, TALLOC_CTX *mem_ctx,
|
||||
PyObject *py_talloc_default_repr(PyObject *py_obj)
|
||||
{
|
||||
py_talloc_Object *obj = (py_talloc_Object *)py_obj;
|
||||
PyTypeObject *type = (PyTypeObject*)PyObject_Type((PyObject *)obj);
|
||||
|
||||
return PyString_FromFormat("<talloc: %s>",
|
||||
talloc_get_name(obj->talloc_ctx));
|
||||
return PyString_FromFormat("<%s talloc object at 0x%x>", type->tp_name, (intptr_t)py_obj);
|
||||
}
|
||||
|
@ -20,6 +20,8 @@
|
||||
# along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
#
|
||||
|
||||
__docformat__ = "restructuredText"
|
||||
|
||||
import os
|
||||
|
||||
def _in_source_tree():
|
||||
@ -33,6 +35,8 @@ if _in_source_tree():
|
||||
srcdir = "%s/../../.." % os.path.dirname(__file__)
|
||||
sys.path.append("%s/bin/python" % srcdir)
|
||||
default_ldb_modules_dir = "%s/bin/modules/ldb" % srcdir
|
||||
else:
|
||||
default_ldb_modules_dir = None
|
||||
|
||||
|
||||
import ldb
|
||||
@ -69,15 +73,15 @@ class Ldb(ldb.Ldb):
|
||||
self.set_modules_dir(default_ldb_modules_dir)
|
||||
|
||||
if credentials is not None:
|
||||
self.set_credentials(self, credentials)
|
||||
self.set_credentials(credentials)
|
||||
|
||||
if session_info is not None:
|
||||
self.set_session_info(self, session_info)
|
||||
self.set_session_info(session_info)
|
||||
|
||||
assert misc.ldb_register_samba_handlers(self) == 0
|
||||
|
||||
if lp is not None:
|
||||
self.set_loadparm(self, lp)
|
||||
self.set_loadparm(lp)
|
||||
|
||||
def msg(l,text):
|
||||
print text
|
||||
|
@ -17,10 +17,15 @@
|
||||
# along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
#
|
||||
|
||||
"""Support for parsing Samba-related command-line options."""
|
||||
|
||||
import optparse
|
||||
from credentials import Credentials, AUTO_USE_KERBEROS, DONT_USE_KERBEROS, MUST_USE_KERBEROS
|
||||
|
||||
__docformat__ = "restructuredText"
|
||||
|
||||
class SambaOptions(optparse.OptionGroup):
|
||||
"""General Samba-related command line options."""
|
||||
def __init__(self, parser):
|
||||
optparse.OptionGroup.__init__(self, parser, "Samba Common Options")
|
||||
self.add_option("-s", "--configfile", action="callback",
|
||||
@ -29,26 +34,33 @@ class SambaOptions(optparse.OptionGroup):
|
||||
self._configfile = None
|
||||
|
||||
def get_loadparm_path(self):
|
||||
"""Return the path to the smb.conf file specified on the command line. """
|
||||
return self._configfile
|
||||
|
||||
def _load_configfile(self, option, opt_str, arg, parser):
|
||||
self._configfile = arg
|
||||
|
||||
def get_loadparm(self):
|
||||
import param
|
||||
"""Return a loadparm object with data specified on the command line. """
|
||||
import os, param
|
||||
lp = param.LoadParm()
|
||||
if self._configfile is None:
|
||||
lp.load_default()
|
||||
else:
|
||||
if self._configfile is not None:
|
||||
lp.load(self._configfile)
|
||||
elif os.getenv("SMB_CONF_PATH") is not None:
|
||||
lp.load(os.getenv("SMB_CONF_PATH"))
|
||||
else:
|
||||
lp.load_default()
|
||||
return lp
|
||||
|
||||
|
||||
class VersionOptions(optparse.OptionGroup):
|
||||
"""Command line option for printing Samba version."""
|
||||
def __init__(self, parser):
|
||||
optparse.OptionGroup.__init__(self, parser, "Version Options")
|
||||
|
||||
|
||||
class CredentialsOptions(optparse.OptionGroup):
|
||||
"""Command line options for specifying credentials."""
|
||||
def __init__(self, parser):
|
||||
self.no_pass = False
|
||||
optparse.OptionGroup.__init__(self, parser, "Credentials Options")
|
||||
@ -89,6 +101,11 @@ class CredentialsOptions(optparse.OptionGroup):
|
||||
self.creds.set_bind_dn(arg)
|
||||
|
||||
def get_credentials(self, lp):
|
||||
"""Obtain the credentials set on the command-line.
|
||||
|
||||
:param lp: Loadparm object to use.
|
||||
:return: Credentials object
|
||||
"""
|
||||
self.creds.guess(lp)
|
||||
if not self.no_pass:
|
||||
self.creds.set_cmdline_callbacks()
|
||||
|
@ -20,7 +20,10 @@
|
||||
|
||||
"""Convenience functions for using the idmap database."""
|
||||
|
||||
__docformat__ = "restructuredText"
|
||||
|
||||
import samba
|
||||
import misc
|
||||
import ldb
|
||||
|
||||
class IDmapDB(samba.Ldb):
|
||||
@ -37,11 +40,17 @@ class IDmapDB(samba.Ldb):
|
||||
|
||||
:param url: URL of the database.
|
||||
"""
|
||||
self.lp = lp
|
||||
|
||||
super(IDmapDB, self).__init__(session_info=session_info, credentials=credentials,
|
||||
modules_dir=modules_dir, lp=lp)
|
||||
if url:
|
||||
self.connect(url)
|
||||
else:
|
||||
self.connect(lp.get("idmap database"))
|
||||
|
||||
def connect(self, url):
|
||||
super(IDmapDB, self).connect(misc.private_path(self.lp, url))
|
||||
|
||||
def setup_name_mapping(self, sid, type, unixid):
|
||||
"""Setup a mapping between a sam name and a unix name.
|
||||
|
@ -43,6 +43,8 @@ from ldb import SCOPE_SUBTREE, SCOPE_ONELEVEL, SCOPE_BASE, LdbError, \
|
||||
|
||||
"""Functions for setting up a Samba configuration."""
|
||||
|
||||
__docformat__ = "restructuredText"
|
||||
|
||||
DEFAULTSITE = "Default-First-Site-Name"
|
||||
|
||||
class InvalidNetbiosName(Exception):
|
||||
@ -87,6 +89,7 @@ class ProvisionNames:
|
||||
self.domain = None
|
||||
self.hostname = None
|
||||
self.sitename = None
|
||||
self.smbconf = None
|
||||
|
||||
class ProvisionResult:
|
||||
def __init__(self):
|
||||
@ -239,6 +242,8 @@ def provision_paths_from_lp(lp, dnsdomain):
|
||||
paths.secrets = os.path.join(paths.private_dir, lp.get("secrets database") or "secrets.ldb")
|
||||
paths.templates = os.path.join(paths.private_dir, "templates.ldb")
|
||||
paths.dns = os.path.join(paths.private_dir, dnsdomain + ".zone")
|
||||
paths.namedconf = os.path.join(paths.private_dir, "named.conf")
|
||||
paths.krb5conf = os.path.join(paths.private_dir, "krb5.conf")
|
||||
paths.winsdb = os.path.join(paths.private_dir, "wins.ldb")
|
||||
paths.s4_ldapi_path = os.path.join(paths.private_dir, "ldapi")
|
||||
paths.phpldapadminconfig = os.path.join(paths.private_dir,
|
||||
@ -266,12 +271,15 @@ def provision_paths_from_lp(lp, dnsdomain):
|
||||
|
||||
paths.netlogon = lp.get("path", "netlogon")
|
||||
|
||||
paths.smbconf = lp.configfile()
|
||||
|
||||
return paths
|
||||
|
||||
|
||||
def guess_names(lp=None, hostname=None, domain=None, dnsdomain=None,
|
||||
serverrole=None, rootdn=None, domaindn=None, configdn=None,
|
||||
schemadn=None, sitename=None):
|
||||
def guess_names(lp=None, hostname=None, domain=None, dnsdomain=None, serverrole=None,
|
||||
rootdn=None, domaindn=None, configdn=None, schemadn=None, serverdn=None,
|
||||
sitename=None):
|
||||
"""Guess configuration settings to use."""
|
||||
|
||||
if hostname is None:
|
||||
hostname = socket.gethostname().split(".")[0].lower()
|
||||
@ -292,8 +300,8 @@ def guess_names(lp=None, hostname=None, domain=None, dnsdomain=None,
|
||||
realm = dnsdomain.upper()
|
||||
|
||||
if lp.get("realm").upper() != realm:
|
||||
raise Exception("realm '%s' must match chosen realm '%s'" %
|
||||
(lp.get("realm"), realm))
|
||||
raise Exception("realm '%s' in %s must match chosen realm '%s'" %
|
||||
(lp.get("realm"), lp.configfile(), realm))
|
||||
|
||||
dnsdomain = dnsdomain.lower()
|
||||
|
||||
@ -338,6 +346,7 @@ def guess_names(lp=None, hostname=None, domain=None, dnsdomain=None,
|
||||
names.netbiosname = netbiosname
|
||||
names.hostname = hostname
|
||||
names.sitename = sitename
|
||||
names.serverdn = "CN=%s,CN=Servers,CN=%s,CN=Sites,%s" % (netbiosname, sitename, configdn)
|
||||
|
||||
return names
|
||||
|
||||
@ -390,6 +399,7 @@ def make_smbconf(smbconf, setup_path, hostname, domain, realm, serverrole,
|
||||
})
|
||||
|
||||
|
||||
|
||||
def setup_name_mappings(samdb, idmap, sid, domaindn, root_uid, nobody_uid,
|
||||
users_gid, wheel_gid):
|
||||
"""setup reasonable name mappings for sam names to unix names.
|
||||
@ -536,10 +546,7 @@ def setup_samdb_partitions(samdb_path, setup_path, message, lp, session_info,
|
||||
samdb.load_ldif_file_add(setup_path("provision_init.ldif"))
|
||||
|
||||
message("Setting up sam.ldb rootDSE")
|
||||
setup_samdb_rootdse(samdb, setup_path, names.schemadn, names.domaindn,
|
||||
names.hostname, names.dnsdomain, names.realm,
|
||||
names.rootdn, names.configdn, names.netbiosname,
|
||||
names.sitename)
|
||||
setup_samdb_rootdse(samdb, setup_path, names)
|
||||
|
||||
if erase:
|
||||
message("Erasing data from partitions")
|
||||
@ -652,25 +659,22 @@ def setup_idmapdb(path, setup_path, session_info, credentials, lp):
|
||||
return idmap_ldb
|
||||
|
||||
|
||||
def setup_samdb_rootdse(samdb, setup_path, schemadn, domaindn, hostname,
|
||||
dnsdomain, realm, rootdn, configdn, netbiosname,
|
||||
sitename):
|
||||
def setup_samdb_rootdse(samdb, setup_path, names):
|
||||
"""Setup the SamDB rootdse.
|
||||
|
||||
:param samdb: Sam Database handle
|
||||
:param setup_path: Obtain setup path
|
||||
"""
|
||||
setup_add_ldif(samdb, setup_path("provision_rootdse_add.ldif"), {
|
||||
"SCHEMADN": schemadn,
|
||||
"NETBIOSNAME": netbiosname,
|
||||
"DNSDOMAIN": dnsdomain,
|
||||
"DEFAULTSITE": sitename,
|
||||
"REALM": realm,
|
||||
"DNSNAME": "%s.%s" % (hostname, dnsdomain),
|
||||
"DOMAINDN": domaindn,
|
||||
"ROOTDN": rootdn,
|
||||
"CONFIGDN": configdn,
|
||||
"VERSION": samba.version(),
|
||||
"SCHEMADN": names.schemadn,
|
||||
"NETBIOSNAME": names.netbiosname,
|
||||
"DNSDOMAIN": names.dnsdomain,
|
||||
"REALM": names.realm,
|
||||
"DNSNAME": "%s.%s" % (names.hostname, names.dnsdomain),
|
||||
"DOMAINDN": names.domaindn,
|
||||
"ROOTDN": names.rootdn,
|
||||
"CONFIGDN": names.configdn,
|
||||
"SERVERDN": names.serverdn,
|
||||
})
|
||||
|
||||
|
||||
@ -679,10 +683,12 @@ 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,
|
||||
"DOMAINDN": names.domaindn,
|
||||
"SERVERDN": names.serverdn,
|
||||
"INVOCATIONID": invocationid,
|
||||
"NETBIOSNAME": names.netbiosname,
|
||||
"DEFAULTSITE": names.sitename,
|
||||
@ -730,8 +736,6 @@ def setup_samdb(path, setup_path, session_info, credentials, lp,
|
||||
return samdb
|
||||
|
||||
message("Pre-loading the Samba 4 and AD schema")
|
||||
samdb = SamDB(path, session_info=session_info,
|
||||
credentials=credentials, lp=lp)
|
||||
samdb.set_domain_sid(domainsid)
|
||||
if serverrole == "domain controller":
|
||||
samdb.set_invocation_id(invocationid)
|
||||
@ -767,6 +771,7 @@ def setup_samdb(path, setup_path, session_info, credentials, lp,
|
||||
"NETBIOSNAME": names.netbiosname,
|
||||
"DEFAULTSITE": names.sitename,
|
||||
"CONFIGDN": names.configdn,
|
||||
"SERVERDN": names.serverdn,
|
||||
"POLICYGUID": policyguid,
|
||||
"DOMAINDN": names.domaindn,
|
||||
"DOMAINGUID_MOD": domainguid_mod,
|
||||
@ -797,6 +802,7 @@ def setup_samdb(path, setup_path, session_info, credentials, lp,
|
||||
"NETBIOSNAME": names.netbiosname,
|
||||
"DEFAULTSITE": names.sitename,
|
||||
"CONFIGDN": names.configdn,
|
||||
"SERVERDN": names.serverdn
|
||||
})
|
||||
|
||||
message("Setting up sam.ldb Samba4 schema")
|
||||
@ -815,6 +821,7 @@ def setup_samdb(path, setup_path, session_info, credentials, lp,
|
||||
"DOMAIN": names.domain,
|
||||
"SCHEMADN": names.schemadn,
|
||||
"DOMAINDN": names.domaindn,
|
||||
"SERVERDN": names.serverdn
|
||||
})
|
||||
|
||||
message("Setting up display specifiers")
|
||||
@ -839,6 +846,7 @@ def setup_samdb(path, setup_path, session_info, credentials, lp,
|
||||
"NETBIOSNAME": names.netbiosname,
|
||||
"DEFAULTSITE": names.sitename,
|
||||
"CONFIGDN": names.configdn,
|
||||
"SERVERDN": names.serverdn
|
||||
})
|
||||
|
||||
if fill == FILL_FULL:
|
||||
@ -875,15 +883,15 @@ FILL_NT4SYNC = "NT4SYNC"
|
||||
FILL_DRS = "DRS"
|
||||
|
||||
def provision(setup_dir, message, session_info,
|
||||
credentials, smbconf=None, targetdir=None, samdb_fill=FILL_FULL,
|
||||
realm=None, rootdn=None, domaindn=None, schemadn=None,
|
||||
configdn=None, domain=None, hostname=None, hostip=None,
|
||||
hostip6=None, domainsid=None, adminpass=None, krbtgtpass=None,
|
||||
domainguid=None, policyguid=None, invocationid=None,
|
||||
machinepass=None, dnspass=None, root=None, nobody=None,
|
||||
nogroup=None, users=None, wheel=None, backup=None, aci=None,
|
||||
serverrole=None, ldap_backend=None, ldap_backend_type=None,
|
||||
sitename=None):
|
||||
credentials, smbconf=None, targetdir=None, samdb_fill=FILL_FULL, realm=None,
|
||||
rootdn=None, domaindn=None, schemadn=None, configdn=None,
|
||||
serverdn=None,
|
||||
domain=None, hostname=None, hostip=None, hostip6=None,
|
||||
domainsid=None, adminpass=None, krbtgtpass=None, domainguid=None,
|
||||
policyguid=None, invocationid=None, machinepass=None,
|
||||
dnspass=None, root=None, nobody=None, nogroup=None, users=None,
|
||||
wheel=None, backup=None, aci=None, serverrole=None,
|
||||
ldap_backend=None, ldap_backend_type=None, sitename=None):
|
||||
"""Provision samba4
|
||||
|
||||
:note: caution, this wipes all existing data!
|
||||
@ -898,7 +906,7 @@ def provision(setup_dir, message, session_info,
|
||||
domainsid = security.Sid(domainsid)
|
||||
|
||||
if policyguid is None:
|
||||
policyguid = uuid.random()
|
||||
policyguid = str(uuid.uuid4())
|
||||
if adminpass is None:
|
||||
adminpass = misc.random_password(12)
|
||||
if krbtgtpass is None:
|
||||
@ -930,9 +938,9 @@ def provision(setup_dir, message, session_info,
|
||||
lp.load(smbconf)
|
||||
|
||||
names = guess_names(lp=lp, hostname=hostname, domain=domain,
|
||||
dnsdomain=realm, serverrole=serverrole,
|
||||
sitename=sitename, rootdn=rootdn, domaindn=domaindn,
|
||||
configdn=configdn, schemadn=schemadn)
|
||||
dnsdomain=realm, serverrole=serverrole, sitename=sitename,
|
||||
rootdn=rootdn, domaindn=domaindn, configdn=configdn, schemadn=schemadn,
|
||||
serverdn=serverdn)
|
||||
|
||||
paths = provision_paths_from_lp(lp, names.dnsdomain)
|
||||
|
||||
@ -950,7 +958,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 = str(uuid.uuid4())
|
||||
|
||||
if not os.path.exists(paths.private_dir):
|
||||
os.mkdir(paths.private_dir)
|
||||
@ -1000,20 +1008,25 @@ def provision(setup_dir, message, session_info,
|
||||
ldap_backend_type=ldap_backend_type)
|
||||
|
||||
if lp.get("server role") == "domain controller":
|
||||
policy_path = os.path.join(paths.sysvol, names.dnsdomain, "Policies",
|
||||
"{" + policyguid + "}")
|
||||
os.makedirs(policy_path, 0755)
|
||||
os.makedirs(os.path.join(policy_path, "Machine"), 0755)
|
||||
os.makedirs(os.path.join(policy_path, "User"), 0755)
|
||||
if not os.path.isdir(paths.netlogon):
|
||||
if paths.netlogon is None:
|
||||
message("Existing smb.conf does not have a [netlogon] share, but you are configuring a DC.")
|
||||
message("Please either remove %s or see the template at %s" %
|
||||
( paths.smbconf, setup_path("provision.smb.conf.dc")))
|
||||
assert(paths.netlogon is not None)
|
||||
|
||||
if paths.sysvol is None:
|
||||
message("Existing smb.conf does not have a [sysvol] share, but you are configuring a DC.")
|
||||
message("Please either remove %s or see the template at %s" %
|
||||
(paths.smbconf, setup_path("provision.smb.conf.dc")))
|
||||
assert(paths.sysvol is not None)
|
||||
|
||||
policy_path = os.path.join(paths.sysvol, names.dnsdomain, "Policies",
|
||||
"{" + policyguid + "}")
|
||||
os.makedirs(policy_path, 0755)
|
||||
os.makedirs(os.path.join(policy_path, "Machine"), 0755)
|
||||
os.makedirs(os.path.join(policy_path, "User"), 0755)
|
||||
if not os.path.isdir(paths.netlogon):
|
||||
os.makedirs(paths.netlogon, 0755)
|
||||
secrets_ldb = Ldb(paths.secrets, session_info=session_info,
|
||||
credentials=credentials, lp=lp)
|
||||
secretsdb_become_dc(secrets_ldb, setup_path, domain=domain, realm=names.realm,
|
||||
netbiosname=names.netbiosname, domainsid=domainsid,
|
||||
keytab_path=paths.keytab, samdb_url=paths.samdb,
|
||||
dns_keytab_path=paths.dns_keytab, dnspass=dnspass,
|
||||
machinepass=machinepass, dnsdomain=names.dnsdomain)
|
||||
|
||||
if samdb_fill == FILL_FULL:
|
||||
setup_name_mappings(samdb, idmap, str(domainsid), names.domaindn,
|
||||
@ -1025,6 +1038,14 @@ def provision(setup_dir, message, session_info,
|
||||
|
||||
# Only make a zone file on the first DC, it should be replicated with DNS replication
|
||||
if serverrole == "domain controller":
|
||||
secrets_ldb = Ldb(paths.secrets, session_info=session_info,
|
||||
credentials=credentials, lp=lp)
|
||||
secretsdb_become_dc(secrets_ldb, setup_path, domain=domain, realm=names.realm,
|
||||
netbiosname=names.netbiosname, domainsid=domainsid,
|
||||
keytab_path=paths.keytab, samdb_url=paths.samdb,
|
||||
dns_keytab_path=paths.dns_keytab, dnspass=dnspass,
|
||||
machinepass=machinepass, dnsdomain=names.dnsdomain)
|
||||
|
||||
samdb = SamDB(paths.samdb, session_info=session_info,
|
||||
credentials=credentials, lp=lp)
|
||||
|
||||
@ -1034,21 +1055,30 @@ def provision(setup_dir, message, session_info,
|
||||
expression="(&(objectClass=computer)(cn=%s))" % names.hostname,
|
||||
scope=SCOPE_SUBTREE)
|
||||
assert isinstance(hostguid, str)
|
||||
|
||||
create_zone_file(paths.dns, setup_path, samdb,
|
||||
hostname=names.hostname, hostip=hostip,
|
||||
hostip6=hostip6, dnsdomain=names.dnsdomain,
|
||||
domaindn=names.domaindn, dnspass=dnspass, realm=names.realm,
|
||||
|
||||
create_zone_file(paths.dns, setup_path, dnsdomain=names.dnsdomain,
|
||||
domaindn=names.domaindn, hostip=hostip,
|
||||
hostip6=hostip6, hostname=names.hostname,
|
||||
dnspass=dnspass, realm=names.realm,
|
||||
domainguid=domainguid, hostguid=hostguid)
|
||||
message("Please install the zone located in %s into your DNS server" % paths.dns)
|
||||
|
||||
|
||||
create_named_conf(paths.namedconf, setup_path, realm=names.realm,
|
||||
dnsdomain=names.dnsdomain, private_dir=paths.private_dir,
|
||||
keytab_name=paths.dns_keytab)
|
||||
message("See %s for example configuration statements for secure GSS-TSIG updates" % paths.namedconf)
|
||||
|
||||
create_krb5_conf(paths.krb5conf, setup_path, dnsdomain=names.dnsdomain,
|
||||
hostname=names.hostname, realm=names.realm)
|
||||
message("A Kerberos configuration suitable for Samba 4 has been generated at %s" % paths.krb5conf)
|
||||
|
||||
create_phpldapadmin_config(paths.phpldapadminconfig, setup_path,
|
||||
ldapi_url)
|
||||
|
||||
message("Please install the phpLDAPadmin configuration located at %s into /etc/phpldapadmin/config.php" % paths.phpldapadminconfig)
|
||||
|
||||
message("Once the above files are installed, your server will be ready to use")
|
||||
message("Server Type: %s" % serverrole)
|
||||
message("Once the above files are installed, your Samba4 server will be ready to use")
|
||||
message("Server Role: %s" % serverrole)
|
||||
message("Hostname: %s" % names.hostname)
|
||||
message("NetBIOS Domain: %s" % names.domain)
|
||||
message("DNS Domain: %s" % names.dnsdomain)
|
||||
@ -1062,27 +1092,33 @@ def provision(setup_dir, message, session_info,
|
||||
result.samdb = samdb
|
||||
return result
|
||||
|
||||
|
||||
def provision_become_dc(setup_dir=None,
|
||||
smbconf=None, targetdir=None, realm=None,
|
||||
rootdn=None, domaindn=None, schemadn=None, configdn=None,
|
||||
serverdn=None,
|
||||
domain=None, hostname=None, domainsid=None,
|
||||
adminpass=None, krbtgtpass=None, domainguid=None,
|
||||
policyguid=None, invocationid=None, machinepass=None,
|
||||
dnspass=None, root=None, nobody=None, nogroup=None, users=None,
|
||||
wheel=None, backup=None, aci=None, serverrole=None,
|
||||
ldap_backend=None, ldap_backend_type=None, sitename=DEFAULTSITE):
|
||||
ldap_backend=None, ldap_backend_type=None, sitename=None):
|
||||
|
||||
def message(text):
|
||||
"""print a message if quiet is not set."""
|
||||
print text
|
||||
|
||||
provision(setup_dir, message, system_session(), None,
|
||||
return provision(setup_dir, message, system_session(), None,
|
||||
smbconf=smbconf, targetdir=targetdir, samdb_fill=FILL_DRS, realm=realm,
|
||||
rootdn=rootdn, domaindn=domaindn, schemadn=schemadn, configdn=configdn,
|
||||
rootdn=rootdn, domaindn=domaindn, schemadn=schemadn, configdn=configdn, serverdn=serverdn,
|
||||
domain=domain, hostname=hostname, hostip="127.0.0.1", domainsid=domainsid, machinepass=machinepass, serverrole="domain controller", sitename=sitename);
|
||||
|
||||
|
||||
def setup_db_config(setup_path, file, dbdir):
|
||||
def setup_db_config(setup_path, dbdir):
|
||||
"""Setup a Berkeley database.
|
||||
|
||||
:param setup_path: Setup path function.
|
||||
:param dbdir: Database directory."""
|
||||
if not os.path.isdir(os.path.join(dbdir, "bdb-logs")):
|
||||
os.makedirs(os.path.join(dbdir, "bdb-logs"), 0700);
|
||||
if not os.path.isdir(os.path.join(dbdir, "tmp")):
|
||||
@ -1097,7 +1133,7 @@ def provision_backend(setup_dir=None, message=None,
|
||||
smbconf=None, targetdir=None, realm=None,
|
||||
rootdn=None, domaindn=None, schemadn=None, configdn=None,
|
||||
domain=None, hostname=None, adminpass=None, root=None, serverrole=None,
|
||||
ldap_backend_type=None):
|
||||
ldap_backend_type=None, ldap_backend_port=None):
|
||||
|
||||
def setup_path(file):
|
||||
return os.path.join(setup_dir, file)
|
||||
@ -1148,6 +1184,7 @@ def provision_backend(setup_dir=None, message=None,
|
||||
"NETBIOSNAME": names.netbiosname,
|
||||
"DEFAULTSITE": DEFAULTSITE,
|
||||
"CONFIGDN": names.configdn,
|
||||
"SERVERDN": names.serverdn
|
||||
})
|
||||
|
||||
setup_add_ldif(schemadb, setup_path("schema_samba4.ldif"),
|
||||
@ -1156,7 +1193,12 @@ def provision_backend(setup_dir=None, message=None,
|
||||
{"SCHEMADN": names.schemadn})
|
||||
|
||||
if ldap_backend_type == "fedora-ds":
|
||||
setup_file(setup_path("fedora-ds.inf"), paths.fedoradsinf,
|
||||
if ldap_backend_port is not None:
|
||||
serverport = "ServerPort=%d" % ldap_backend_port
|
||||
else:
|
||||
serverport = ""
|
||||
|
||||
setup_file(setup_path("fedorads.inf"), paths.fedoradsinf,
|
||||
{"ROOT": root,
|
||||
"HOSTNAME": hostname,
|
||||
"DNSDOMAIN": names.dnsdomain,
|
||||
@ -1164,19 +1206,18 @@ def provision_backend(setup_dir=None, message=None,
|
||||
"DOMAINDN": names.domaindn,
|
||||
"LDAPMANAGERDN": names.ldapmanagerdn,
|
||||
"LDAPMANAGERPASS": adminpass,
|
||||
"SERVERPORT": ""})
|
||||
"SERVERPORT": serverport})
|
||||
|
||||
setup_file(setup_path("fedora-partitions.ldif"), paths.fedoradspartitions,
|
||||
setup_file(setup_path("fedorads-partitions.ldif"), paths.fedoradspartitions,
|
||||
{"CONFIGDN": names.configdn,
|
||||
"SCHEMADN": names.schemadn,
|
||||
})
|
||||
|
||||
setup_file(setup_path("fedora-partitions.ldif"), paths.fedoradspartitions,
|
||||
{"CONFIGDN": names.configdn,
|
||||
"SCHEMADN": names.schemadn,
|
||||
})
|
||||
mapping = "schema-map-fedora-ds-1.0"
|
||||
backend_schema = "99_ad.ldif"
|
||||
|
||||
slapdcommand="Initailise Fedora DS with: setup-ds.pl --file=%s" % paths.fedoradsinf
|
||||
|
||||
elif ldap_backend_type == "openldap":
|
||||
attrs = ["linkID", "lDAPDisplayName"]
|
||||
res = schemadb.search(expression="(&(&(linkID=*)(!(linkID:1.2.840.113556.1.4.803:=1)))(objectclass=attributeSchema))", base=names.schemadn, scope=SCOPE_SUBTREE, attrs=attrs);
|
||||
@ -1219,22 +1260,33 @@ refint_attributes""" + refint_attributes + "\n";
|
||||
setup_file(setup_path("modules.conf"), paths.modulesconf,
|
||||
{"REALM": names.realm})
|
||||
|
||||
setup_db_config(setup_path, file, os.path.join(paths.ldapdir, "db", "user"))
|
||||
setup_db_config(setup_path, file, os.path.join(paths.ldapdir, "db", "config"))
|
||||
setup_db_config(setup_path, file, os.path.join(paths.ldapdir, "db", "schema"))
|
||||
mapping = "schema-map-openldap-2.3"
|
||||
backend_schema = "backend-schema.schema"
|
||||
|
||||
setup_db_config(setup_path, os.path.join(paths.ldapdir, os.path.join("db", "user")))
|
||||
setup_db_config(setup_path, os.path.join(paths.ldapdir, os.path.join("db", "config")))
|
||||
setup_db_config(setup_path, os.path.join(paths.ldapdir, os.path.join("db", "schema")))
|
||||
mapping = "schema-map-openldap-2.3"
|
||||
backend_schema = "backend-schema.schema"
|
||||
|
||||
ldapi_uri = "ldapi://" + urllib.quote(os.path.join(paths.private_dir, "ldap", "ldapi"), safe="")
|
||||
message("Start slapd with: slapd -f " + paths.ldapdir + "/slapd.conf -h " + ldapi_uri)
|
||||
|
||||
ldapi_uri = "ldapi://" + urllib.quote(os.path.join(paths.private_dir, "ldap", "ldapi"), safe="")
|
||||
if ldap_backend_port is not None:
|
||||
server_port_string = " -h ldap://0.0.0.0:%d" % ldap_backend_port
|
||||
else:
|
||||
server_port_string = ""
|
||||
slapdcommand="Start slapd with: slapd -f " + paths.ldapdir + "/slapd.conf -h " + ldapi_uri + server_port_string
|
||||
|
||||
schema_command = "bin/ad2oLschema --option=convert:target=" + ldap_backend_type + " -I " + setup_path(mapping) + " -H tdb://" + schemadb_path + " -O " + os.path.join(paths.ldapdir, backend_schema);
|
||||
|
||||
os.system(schema_command)
|
||||
|
||||
|
||||
message("Your %s Backend for Samba4 is now configured, and is ready to be started" % ( ldap_backend_type) )
|
||||
message("Server Role: %s" % serverrole)
|
||||
message("Hostname: %s" % names.hostname)
|
||||
message("DNS Domain: %s" % names.dnsdomain)
|
||||
message("Base DN: %s" % names.domaindn)
|
||||
message("LDAP admin DN: %s" % names.ldapmanagerdn)
|
||||
message("LDAP admin password: %s" % adminpass)
|
||||
message(slapdcommand)
|
||||
|
||||
|
||||
def create_phpldapadmin_config(path, setup_path, ldapi_uri):
|
||||
"""Create a PHP LDAP admin configuration file.
|
||||
@ -1246,13 +1298,12 @@ def create_phpldapadmin_config(path, setup_path, ldapi_uri):
|
||||
{"S4_LDAPI_URI": ldapi_uri})
|
||||
|
||||
|
||||
def create_zone_file(path, setup_path, samdb, dnsdomain, domaindn,
|
||||
hostip, hostip6, hostname, dnspass, realm, domainguid, hostguid):
|
||||
def create_zone_file(path, setup_path, dnsdomain, domaindn,
|
||||
hostip, hostip6, hostname, dnspass, realm, domainguid, hostguid):
|
||||
"""Write out a DNS zone file, from the info in the current database.
|
||||
|
||||
:param path: Path of the new file.
|
||||
:param setup_path": Setup path function.
|
||||
:param samdb: SamDB object
|
||||
|
||||
:param path: Path of the new zone file.
|
||||
:param setup_path: Setup path function.
|
||||
:param dnsdomain: DNS Domain name
|
||||
:param domaindn: DN of the Domain
|
||||
:param hostip: Local IPv4 IP
|
||||
@ -1286,6 +1337,44 @@ def create_zone_file(path, setup_path, samdb, dnsdomain, domaindn,
|
||||
"HOSTIP6_HOST_LINE": hostip6_host_line,
|
||||
})
|
||||
|
||||
def create_named_conf(path, setup_path, realm, dnsdomain,
|
||||
private_dir, keytab_name):
|
||||
"""Write out a file containing zone statements suitable for inclusion in a
|
||||
named.conf file (including GSS-TSIG configuration).
|
||||
|
||||
:param path: Path of the new named.conf file.
|
||||
:param setup_path: Setup path function.
|
||||
:param realm: Realm name
|
||||
:param dnsdomain: DNS Domain name
|
||||
:param private_dir: Path to private directory
|
||||
:param keytab_name: File name of DNS keytab file
|
||||
"""
|
||||
|
||||
setup_file(setup_path("named.conf"), path, {
|
||||
"DNSDOMAIN": dnsdomain,
|
||||
"REALM": realm,
|
||||
"REALM_WC": "*." + ".".join(realm.split(".")[1:]),
|
||||
"DNS_KEYTAB": keytab_name,
|
||||
"DNS_KEYTAB_ABS": os.path.join(private_dir, keytab_name),
|
||||
})
|
||||
|
||||
def create_krb5_conf(path, setup_path, dnsdomain, hostname, realm):
|
||||
"""Write out a file containing zone statements suitable for inclusion in a
|
||||
named.conf file (including GSS-TSIG configuration).
|
||||
|
||||
:param path: Path of the new named.conf file.
|
||||
:param setup_path: Setup path function.
|
||||
:param dnsdomain: DNS Domain name
|
||||
:param hostname: Local hostname
|
||||
:param realm: Realm name
|
||||
"""
|
||||
|
||||
setup_file(setup_path("krb5.conf"), path, {
|
||||
"DNSDOMAIN": dnsdomain,
|
||||
"HOSTNAME": hostname,
|
||||
"REALM": realm,
|
||||
})
|
||||
|
||||
def load_schema(setup_path, samdb, schemadn, netbiosname, configdn, sitename):
|
||||
"""Load schema for the SamDB.
|
||||
|
||||
|
@ -19,6 +19,8 @@
|
||||
|
||||
"""Support for reading Samba 3 data files."""
|
||||
|
||||
__docformat__ = "restructuredText"
|
||||
|
||||
REGISTRY_VALUE_PREFIX = "SAMBA_REGVAL"
|
||||
REGISTRY_DB_VERSION = 1
|
||||
|
||||
@ -307,6 +309,7 @@ class ShareInfoDatabase(TdbDatabase):
|
||||
|
||||
|
||||
class Shares:
|
||||
"""Container for share objects."""
|
||||
def __init__(self, lp, shareinfo):
|
||||
self.lp = lp
|
||||
self.shareinfo = shareinfo
|
||||
@ -492,6 +495,7 @@ class TdbSam(TdbDatabase):
|
||||
assert self.version in (0, 1, 2)
|
||||
|
||||
def usernames(self):
|
||||
"""Iterate over the usernames in this Tdb database."""
|
||||
for k in self.tdb.keys():
|
||||
if k.startswith(TDBSAM_USER_PREFIX):
|
||||
yield k[len(TDBSAM_USER_PREFIX):].rstrip("\0")
|
||||
@ -633,6 +637,7 @@ class WinsDatabase:
|
||||
return iter(self.entries)
|
||||
|
||||
def items(self):
|
||||
"""Return the entries in this WINS database."""
|
||||
return self.entries.items()
|
||||
|
||||
def close(self): # for consistency
|
||||
|
@ -25,20 +25,31 @@
|
||||
import samba
|
||||
import misc
|
||||
import ldb
|
||||
from samba.idmap import IDmapDB
|
||||
import pwd
|
||||
|
||||
__docformat__ = "restructuredText"
|
||||
|
||||
class SamDB(samba.Ldb):
|
||||
"""The SAM database."""
|
||||
|
||||
def __init__(self, url=None, session_info=None, credentials=None,
|
||||
modules_dir=None, lp=None):
|
||||
"""Open the Sam Database.
|
||||
|
||||
:param url: URL of the database.
|
||||
"""
|
||||
self.lp = lp
|
||||
super(SamDB, self).__init__(session_info=session_info, credentials=credentials,
|
||||
modules_dir=modules_dir, lp=lp)
|
||||
assert misc.dsdb_set_global_schema(self) == 0
|
||||
if url:
|
||||
self.connect(url)
|
||||
else:
|
||||
self.connect(lp.get("sam database"))
|
||||
|
||||
def connect(self, url):
|
||||
super(SamDB, self).connect(misc.private_path(self.lp, url))
|
||||
|
||||
def add_foreign(self, domaindn, sid, desc):
|
||||
"""Add a foreign security principle."""
|
||||
@ -101,10 +112,27 @@ userAccountControl: %u
|
||||
# now the real work
|
||||
self.add({"dn": user_dn,
|
||||
"sAMAccountName": username,
|
||||
"unixName": unixname,
|
||||
"sambaPassword": password,
|
||||
"objectClass": "user"})
|
||||
|
||||
res = self.search(user_dn, scope=ldb.SCOPE_BASE,
|
||||
expression="objectclass=*",
|
||||
attrs=["objectSid"])
|
||||
assert(len(res) == 1)
|
||||
user_sid = self.schema_format_value("objectSid", res[0]["objectSid"][0])
|
||||
|
||||
|
||||
try:
|
||||
idmap = IDmapDB(lp=self.lp)
|
||||
|
||||
user = pwd.getpwnam(unixname)
|
||||
# setup ID mapping for this UID
|
||||
|
||||
idmap.setup_name_mapping(user_sid, idmap.TYPE_UID, user[2])
|
||||
|
||||
except KeyError:
|
||||
pass
|
||||
|
||||
# modify the userAccountControl to remove the disabled bit
|
||||
self.enable_account(user_dn)
|
||||
self.transaction_commit()
|
||||
|
@ -85,8 +85,13 @@ class LdbExtensionTests(TestCaseInTempDir):
|
||||
os.unlink(path)
|
||||
|
||||
|
||||
def get_loadparm():
|
||||
import param
|
||||
lp = param.LoadParm()
|
||||
lp.load(os.getenv("SMB_CONF_PATH"))
|
||||
return lp
|
||||
cmdline_loadparm = None
|
||||
cmdline_credentials = None
|
||||
|
||||
class RpcInterfaceTestCase(unittest.TestCase):
|
||||
def get_loadparm(self):
|
||||
assert cmdline_loadparm is not None
|
||||
return cmdline_loadparm
|
||||
|
||||
def get_credentials(self):
|
||||
return cmdline_credentials
|
||||
|
@ -17,15 +17,14 @@
|
||||
# along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
#
|
||||
|
||||
import winreg
|
||||
from param import LoadParm
|
||||
from samba.dcerpc import winreg
|
||||
import unittest
|
||||
from samba.tests import get_loadparm
|
||||
from samba.tests import RpcInterfaceTestCase
|
||||
|
||||
class WinregTests(unittest.TestCase):
|
||||
class WinregTests(RpcInterfaceTestCase):
|
||||
def setUp(self):
|
||||
lp_ctx = get_loadparm()
|
||||
self.conn = winreg.winreg("ncalrpc:", lp_ctx)
|
||||
self.conn = winreg.winreg("ncalrpc:", self.get_loadparm(),
|
||||
self.get_credentials())
|
||||
|
||||
def get_hklm(self):
|
||||
return self.conn.OpenHKLM(None,
|
||||
|
@ -17,20 +17,19 @@
|
||||
# along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
#
|
||||
|
||||
import echo
|
||||
from samba.dcerpc import echo
|
||||
import unittest
|
||||
from samba.tests import get_loadparm
|
||||
from samba.tests import RpcInterfaceTestCase
|
||||
|
||||
class RpcEchoTests(unittest.TestCase):
|
||||
class RpcEchoTests(RpcInterfaceTestCase):
|
||||
def setUp(self):
|
||||
lp_ctx = get_loadparm()
|
||||
self.conn = echo.rpcecho("ncalrpc:", lp_ctx)
|
||||
self.conn = echo.rpcecho("ncalrpc:", self.get_loadparm())
|
||||
|
||||
def test_addone(self):
|
||||
self.assertEquals(2, self.conn.AddOne(1))
|
||||
|
||||
def test_echodata(self):
|
||||
self.assertEquals([1,2,3], self.conn.EchoData(3, [1, 2, 3]))
|
||||
self.assertEquals([1,2,3], self.conn.EchoData([1, 2, 3]))
|
||||
|
||||
def test_call(self):
|
||||
self.assertEquals(u"foobar", self.conn.TestCall(u"foobar"))
|
||||
|
@ -1,7 +1,8 @@
|
||||
#!/usr/bin/python
|
||||
# -*- coding: utf-8 -*-
|
||||
|
||||
# Unix SMB/CIFS implementation.
|
||||
# Copyright (C) Jelmer Vernooij <jelmer@samba.org> 2008
|
||||
# Copyright © Jelmer Vernooij <jelmer@samba.org> 2008
|
||||
#
|
||||
# This program is free software; you can redistribute it and/or modify
|
||||
# it under the terms of the GNU General Public License as published by
|
||||
@ -17,13 +18,29 @@
|
||||
# along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
#
|
||||
|
||||
import samr
|
||||
import unittest
|
||||
from samba.tests import get_loadparm
|
||||
from samba.dcerpc import samr, security
|
||||
from samba.tests import RpcInterfaceTestCase
|
||||
|
||||
class SamrTests(unittest.TestCase):
|
||||
# FIXME: Pidl should be doing this for us
|
||||
def toArray((handle, array, num_entries)):
|
||||
ret = []
|
||||
for x in range(num_entries):
|
||||
ret.append((array.entries[x].idx, array.entries[x].name))
|
||||
return ret
|
||||
|
||||
|
||||
class SamrTests(RpcInterfaceTestCase):
|
||||
def setUp(self):
|
||||
self.conn = samr.samr("ncalrpc:", get_loadparm())
|
||||
self.conn = samr.samr("ncalrpc:", self.get_loadparm())
|
||||
|
||||
def test_connect5(self):
|
||||
(level, info, handle) = self.conn.Connect5(None, 0, 1, samr.ConnectInfo1())
|
||||
|
||||
def test_connect2(self):
|
||||
handle = self.conn.Connect2(None, security.SEC_FLAG_MAXIMUM_ALLOWED)
|
||||
|
||||
def test_EnumDomains(self):
|
||||
handle = self.conn.Connect2(None, security.SEC_FLAG_MAXIMUM_ALLOWED)
|
||||
domains = toArray(self.conn.EnumDomains(handle, 0, -1))
|
||||
self.conn.Close(handle)
|
||||
|
||||
|
37
source4/scripting/python/samba/tests/dcerpc/unix.py
Normal file
37
source4/scripting/python/samba/tests/dcerpc/unix.py
Normal file
@ -0,0 +1,37 @@
|
||||
#!/usr/bin/python
|
||||
|
||||
# Unix SMB/CIFS implementation.
|
||||
# Copyright (C) Jelmer Vernooij <jelmer@samba.org> 2008
|
||||
#
|
||||
# This program is free software; you can redistribute it and/or modify
|
||||
# it under the terms of the GNU General Public License as published by
|
||||
# the Free Software Foundation; either version 3 of the License, or
|
||||
# (at your option) any later version.
|
||||
#
|
||||
# This program is distributed in the hope that it will be useful,
|
||||
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
# GNU General Public License for more details.
|
||||
#
|
||||
# You should have received a copy of the GNU General Public License
|
||||
# along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
#
|
||||
|
||||
from samba.dcerpc import unixinfo
|
||||
from samba.tests import RpcInterfaceTestCase
|
||||
|
||||
class UnixinfoTests(RpcInterfaceTestCase):
|
||||
def setUp(self):
|
||||
self.conn = unixinfo.unixinfo("ncalrpc:", self.get_loadparm())
|
||||
|
||||
def test_getpwuid(self):
|
||||
infos = self.conn.GetPWUid(range(512))
|
||||
self.assertEquals(512, len(infos))
|
||||
self.assertEquals("/bin/false", infos[0].shell)
|
||||
self.assertTrue(isinstance(infos[0].homedir, unicode))
|
||||
|
||||
def test_gidtosid(self):
|
||||
self.conn.GidToSid(1000)
|
||||
|
||||
def test_uidtosid(self):
|
||||
self.conn.UidToSid(1000)
|
@ -21,10 +21,10 @@ import os
|
||||
from samba.provision import setup_secretsdb, secretsdb_become_dc, findnss
|
||||
import samba.tests
|
||||
from ldb import Dn
|
||||
import param
|
||||
from samba import param
|
||||
import unittest
|
||||
|
||||
lp = samba.tests.get_loadparm()
|
||||
lp = samba.tests.cmdline_loadparm
|
||||
|
||||
setup_dir = "setup"
|
||||
def setup_path(file):
|
||||
|
@ -21,7 +21,7 @@ from credentials import Credentials
|
||||
import os
|
||||
from samba.provision import setup_samdb
|
||||
from samba.samdb import SamDB
|
||||
from samba.tests import get_loadparm, TestCaseInTempDir
|
||||
from samba.tests import cmdline_loadparm, TestCaseInTempDir
|
||||
import security
|
||||
from unittest import TestCase
|
||||
import uuid
|
||||
@ -29,21 +29,21 @@ import uuid
|
||||
class SamDBTestCase(TestCaseInTempDir):
|
||||
def setUp(self):
|
||||
super(SamDBTestCase, self).setUp()
|
||||
invocationid = uuid.random()
|
||||
invocationid = str(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 = 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.random()
|
||||
hostguid = str(uuid.uuid4())
|
||||
path = os.path.join(self.tempdir, "samdb.ldb")
|
||||
self.samdb = setup_samdb(path, setup_path, system_session(), creds,
|
||||
get_loadparm(), schemadn, configdn,
|
||||
cmdline_loadparm, schemadn, configdn,
|
||||
self.domaindn, "example.com", "EXAMPLE.COM",
|
||||
"FOO", lambda x: None, "foo", domaindn,
|
||||
False, domainsid, "# no aci", domainguid,
|
||||
|
@ -7,6 +7,8 @@
|
||||
|
||||
"""Support code for upgrading from Samba 3 to Samba 4."""
|
||||
|
||||
__docformat__ = "restructuredText"
|
||||
|
||||
from provision import findnss, provision, FILL_DRS
|
||||
import grp
|
||||
import ldb
|
||||
|
@ -1,34 +0,0 @@
|
||||
/*
|
||||
Unix SMB/CIFS implementation.
|
||||
Samba utility functions
|
||||
Copyright (C) Jelmer Vernooij <jelmer@samba.org> 2007
|
||||
|
||||
This program is free software; you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
the Free Software Foundation; either version 3 of the License, or
|
||||
(at your option) any later version.
|
||||
|
||||
This program is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
#include "includes.h"
|
||||
#include <Python.h>
|
||||
#include "scripting/python/modules.h"
|
||||
|
||||
int main(int argc, char **argv)
|
||||
{
|
||||
py_load_samba_modules();
|
||||
Py_Initialize();
|
||||
if (strchr(argv[0], '/') != NULL) {
|
||||
char *bindir = strndup(argv[0], strrchr(argv[0], '/')-argv[0]);
|
||||
py_update_path(bindir);
|
||||
free(bindir);
|
||||
}
|
||||
return Py_Main(argc,argv);
|
||||
}
|
@ -27,7 +27,7 @@ static PyObject *uuid_random(PyObject *self, PyObject *args)
|
||||
PyObject *pyobj;
|
||||
char *str;
|
||||
|
||||
if (!PyArg_ParseTuple(args, (char *)""))
|
||||
if (!PyArg_ParseTuple(args, ""))
|
||||
return NULL;
|
||||
|
||||
guid = GUID_random();
|
||||
@ -46,13 +46,13 @@ 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 }
|
||||
};
|
||||
|
||||
void inituuid(void)
|
||||
{
|
||||
PyObject *mod = Py_InitModule3((char *)"uuid", methods, "UUID helper routines");
|
||||
PyObject *mod = Py_InitModule3("uuid", methods, "UUID helper routines");
|
||||
if (mod == NULL)
|
||||
return;
|
||||
}
|
||||
|
Reference in New Issue
Block a user