summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--BUGS.txt2
-rw-r--r--source4/Makefile59
-rw-r--r--source4/auth/auth.i6
-rw-r--r--source4/auth/auth.py6
-rw-r--r--source4/auth/auth_wrap.c65
-rw-r--r--source4/auth/credentials/credentials.i35
-rw-r--r--source4/auth/credentials/credentials.py95
-rw-r--r--source4/auth/credentials/credentials_wrap.c75
-rw-r--r--source4/build/make/rules.mk2
-rw-r--r--source4/build/make/templates.mk2
-rw-r--r--source4/build/smb_build/config_mk.pm2
-rw-r--r--source4/build/smb_build/makefile.pm4
-rw-r--r--source4/dynconfig/config.mk (renamed from source4/dynconfig.mk)9
-rw-r--r--source4/dynconfig/dynconfig.c (renamed from source4/dynconfig.c)0
-rw-r--r--source4/dynconfig/dynconfig.h (renamed from source4/dynconfig.h)0
-rw-r--r--source4/dynconfig/version.c (renamed from source4/lib/version.c)0
-rwxr-xr-xsource4/heimdal_build/asn1_compile_wrapper.sh28
-rwxr-xr-xsource4/heimdal_build/asn1_deps.pl8
-rw-r--r--source4/heimdal_build/config.mk116
-rwxr-xr-xsource4/heimdal_build/et_compile_wrapper.sh28
-rwxr-xr-xsource4/heimdal_build/et_deps.pl4
-rw-r--r--source4/lib/charset/util_unistr.c2
-rw-r--r--source4/lib/cmdline/popt_common.c2
-rw-r--r--source4/lib/events/events.i7
-rw-r--r--source4/lib/events/events.py23
-rw-r--r--source4/lib/events/events_wrap.c10
-rw-r--r--source4/lib/ldb/config.mk52
-rw-r--r--source4/lib/ldb/ldb.i121
-rw-r--r--source4/lib/ldb/ldb.py242
-rw-r--r--source4/lib/ldb/ldb_ildap/config.mk4
-rw-r--r--source4/lib/ldb/ldb_wrap.c328
-rw-r--r--source4/lib/ldb/python.mk6
-rw-r--r--source4/lib/ldb/tools/config.mk16
-rw-r--r--source4/lib/messaging/config.mk14
-rw-r--r--source4/lib/messaging/irpc.h1
-rw-r--r--source4/lib/messaging/messaging.c5
-rw-r--r--source4/lib/messaging/pymessaging.c559
-rw-r--r--source4/lib/messaging/tests/bindings.py57
-rw-r--r--source4/lib/registry/config.mk9
-rw-r--r--source4/lib/registry/hive.c18
-rw-r--r--source4/lib/registry/interface.c25
-rw-r--r--source4/lib/registry/local.c16
-rw-r--r--source4/lib/registry/patchfile.c27
-rw-r--r--source4/lib/registry/patchfile_dotreg.c10
-rw-r--r--source4/lib/registry/patchfile_preg.c97
-rw-r--r--source4/lib/registry/regf.c64
-rw-r--r--source4/lib/registry/registry.h26
-rw-r--r--source4/lib/registry/registry.i30
-rw-r--r--source4/lib/registry/registry.py64
-rw-r--r--source4/lib/registry/registry_wrap.c30
-rw-r--r--source4/lib/registry/tests/diff.c242
-rw-r--r--source4/lib/registry/tests/hive.c55
-rw-r--r--source4/lib/registry/tests/registry.c8
-rw-r--r--source4/lib/replace/libreplace_network.m42
-rw-r--r--source4/lib/smbreadline/readline.m44
-rw-r--r--source4/lib/tdb/tdb.i43
-rw-r--r--source4/lib/tdb/tdb.py180
-rw-r--r--source4/lib/tdb/tdb_wrap.c218
-rw-r--r--source4/lib/util/debug.c2
-rw-r--r--source4/libcli/config.mk5
-rw-r--r--source4/libcli/nbt/nbtname.c21
-rw-r--r--source4/libcli/raw/interfaces.h37
-rw-r--r--source4/libcli/raw/raweas.c9
-rw-r--r--source4/libcli/raw/rawfile.c4
-rw-r--r--source4/libcli/raw/rawfileinfo.c3
-rw-r--r--source4/libcli/raw/smb.h10
-rw-r--r--source4/libcli/security/security.i13
-rw-r--r--source4/libcli/security/security.py42
-rw-r--r--source4/libcli/security/security_wrap.c90
-rw-r--r--source4/libcli/smb2/create.c15
-rw-r--r--source4/libcli/smb2/util.c10
-rw-r--r--source4/libcli/swig/libcli_smb.py2
-rw-r--r--source4/libcli/swig/libcli_smb_wrap.c65
-rw-r--r--source4/libcli/util/errors.i10
-rw-r--r--source4/libcli/util/pyerrors.h (renamed from source4/scripting/python/pyrpc.h)26
-rw-r--r--source4/libnet/py_net.c5
-rw-r--r--source4/librpc/config.mk172
-rwxr-xr-xsource4/librpc/idl-deps.pl2
-rw-r--r--source4/librpc/idl/echo.idl2
-rw-r--r--source4/librpc/idl/nbt.idl18
-rw-r--r--source4/librpc/idl/security.idl3
-rw-r--r--source4/librpc/idl/xattr.idl3
-rw-r--r--source4/librpc/rpc/dcerpc.h9
-rw-r--r--source4/librpc/rpc/dcerpc.i121
-rw-r--r--source4/librpc/rpc/dcerpc.py79
-rw-r--r--source4/librpc/rpc/dcerpc_wrap.c3395
-rw-r--r--source4/librpc/rpc/pyrpc.c417
-rw-r--r--source4/librpc/rpc/pyrpc.h73
-rwxr-xr-xsource4/librpc/scripts/build_idl.sh2
-rw-r--r--source4/main.mk49
-rw-r--r--source4/nsswitch/wbinfo.c2
-rw-r--r--source4/ntvfs/cifs/vfs_cifs.c10
-rw-r--r--source4/ntvfs/ntvfs_generic.c130
-rw-r--r--source4/ntvfs/posix/pvfs_acl.c2
-rw-r--r--source4/ntvfs/posix/pvfs_fileinfo.c7
-rw-r--r--source4/ntvfs/posix/pvfs_flush.c1
-rw-r--r--source4/ntvfs/posix/pvfs_open.c100
-rw-r--r--source4/ntvfs/posix/pvfs_qfileinfo.c9
-rw-r--r--source4/ntvfs/posix/pvfs_read.c8
-rw-r--r--source4/ntvfs/posix/pvfs_resolve.c8
-rw-r--r--source4/ntvfs/posix/pvfs_streams.c20
-rw-r--r--source4/param/config.mk2
-rw-r--r--source4/param/loadparm.c2
-rw-r--r--source4/param/param.i28
-rw-r--r--source4/param/param.py74
-rw-r--r--source4/param/param_wrap.c50
-rw-r--r--source4/param/util.c2
-rw-r--r--source4/pidl/TODO15
-rw-r--r--source4/pidl/lib/Parse/Pidl/Samba4/Python.pm403
-rw-r--r--source4/samba4-knownfail5
-rwxr-xr-xsource4/scripting/bin/autoidl.py161
-rwxr-xr-xsource4/scripting/bin/minschema.py2
-rwxr-xr-xsource4/scripting/bin/samba3dump4
-rwxr-xr-xsource4/scripting/bin/smbstatus159
-rwxr-xr-xsource4/scripting/bin/winreg107
-rw-r--r--source4/scripting/ejs/config.mk52
-rw-r--r--source4/scripting/ejs/ejsnet/config.mk13
-rw-r--r--source4/scripting/ejs/ejsnet/mpr_host.c74
-rw-r--r--source4/scripting/ejs/ejsnet/mpr_user.c173
-rw-r--r--source4/scripting/ejs/ejsnet/net_ctx.c230
-rw-r--r--source4/scripting/ejs/ejsnet/net_host.c124
-rw-r--r--source4/scripting/ejs/ejsnet/net_user.c359
-rw-r--r--source4/scripting/ejs/ejsrpc.c424
-rw-r--r--source4/scripting/ejs/ejsrpc.h172
-rw-r--r--source4/scripting/ejs/literal.c797
-rw-r--r--source4/scripting/ejs/smbcalls.c4
-rw-r--r--source4/scripting/ejs/smbcalls_cli.c722
-rw-r--r--source4/scripting/ejs/smbcalls_data.c284
-rw-r--r--source4/scripting/ejs/smbcalls_nbt.c93
-rw-r--r--source4/scripting/ejs/smbcalls_nss.c160
-rw-r--r--source4/scripting/ejs/smbcalls_param.c259
-rw-r--r--source4/scripting/ejs/smbcalls_rand.c104
-rw-r--r--source4/scripting/ejs/smbcalls_reg.c90
-rw-r--r--source4/scripting/ejs/smbcalls_rpc.c385
-rw-r--r--source4/scripting/ejs/smbscript.c2
-rw-r--r--source4/scripting/libjs/auth.js18
-rw-r--r--source4/scripting/libjs/base.js53
-rw-r--r--source4/scripting/libjs/encoder.js116
-rw-r--r--source4/scripting/libjs/management.js157
-rw-r--r--source4/scripting/libjs/samr.js170
-rw-r--r--source4/scripting/libjs/server_call.js83
-rw-r--r--source4/scripting/libjs/winreg.js291
-rw-r--r--source4/scripting/python/config.m42
-rw-r--r--source4/scripting/python/config.mk4
-rwxr-xr-xsource4/scripting/python/examples/samr.py114
-rwxr-xr-xsource4/scripting/python/examples/winreg.py (renamed from source4/scripting/bin/winreg.py)2
-rw-r--r--source4/scripting/python/misc.i27
-rw-r--r--source4/scripting/python/misc.py62
-rw-r--r--source4/scripting/python/misc_wrap.c108
-rw-r--r--source4/scripting/python/pytalloc.c11
-rw-r--r--source4/scripting/python/samba/__init__.py10
-rw-r--r--source4/scripting/python/samba/getopt.py15
-rw-r--r--source4/scripting/python/samba/idmap.py2
-rw-r--r--source4/scripting/python/samba/ndr.py28
-rw-r--r--source4/scripting/python/samba/provision.py238
-rw-r--r--source4/scripting/python/samba/samba3.py5
-rw-r--r--source4/scripting/python/samba/samdb.py2
-rw-r--r--source4/scripting/python/samba/tests/dcerpc/bare.py46
-rw-r--r--source4/scripting/python/samba/tests/dcerpc/rpcecho.py25
-rw-r--r--source4/scripting/python/samba/tests/dcerpc/sam.py22
-rw-r--r--source4/scripting/python/samba/upgrade.py2
-rw-r--r--source4/selftest/output/plain.pm4
-rwxr-xr-xsource4/selftest/samba4_tests.sh5
-rwxr-xr-xsource4/selftest/selftest.pl16
-rwxr-xr-xsource4/setup/provision-backend9
-rw-r--r--source4/smb_server/blob.c7
-rw-r--r--source4/smb_server/smb/reply.c5
-rw-r--r--source4/smb_server/smb2/smb2_server.h4
-rw-r--r--source4/smb_server/smb_server.c4
-rw-r--r--source4/static_deps.mk46
-rw-r--r--source4/torture/gentest.c2
-rw-r--r--source4/torture/gentest_smb2.c462
-rw-r--r--source4/torture/locktest.c2
-rw-r--r--source4/torture/masktest.c2
-rw-r--r--source4/torture/raw/read.c17
-rw-r--r--source4/torture/raw/streams.c95
-rw-r--r--source4/torture/smb2/config.mk4
-rw-r--r--source4/torture/smb2/connect.c6
-rw-r--r--source4/torture/smb2/create.c201
-rw-r--r--source4/torture/smb2/getinfo.c12
-rw-r--r--source4/torture/smb2/lock.c110
-rw-r--r--source4/torture/smb2/read.c141
-rw-r--r--source4/torture/smb2/smb2.c2
-rw-r--r--source4/torture/smbtorture.c29
-rw-r--r--source4/web_server/swat/__init__.py27
-rw-r--r--testprogs/ejs/argv.js14
-rwxr-xr-xtestprogs/ejs/echo.js235
-rwxr-xr-xtestprogs/ejs/ejsnet.js46
-rw-r--r--testprogs/ejs/ejsnet/nethost.js45
-rw-r--r--testprogs/ejs/ejsnet/netusr.js86
-rw-r--r--testprogs/ejs/loadparm.js25
-rwxr-xr-xtestprogs/ejs/nbtstats33
-rw-r--r--testprogs/ejs/resolveName.js13
-rwxr-xr-xtestprogs/ejs/samr.js126
194 files changed, 5785 insertions, 11372 deletions
diff --git a/BUGS.txt b/BUGS.txt
index 3ee3d63c56..52e1791928 100644
--- a/BUGS.txt
+++ b/BUGS.txt
@@ -3,4 +3,4 @@ than education you are insane, or perhaps just very interested.
We welcome your testing, please file bug reports at
https://bugzilla.samba.org/, product: Samba4. Please include as much
-information as possible, such as SVN revision number and backtraces.
+information as possible, such as GIT revision number and backtraces.
diff --git a/source4/Makefile b/source4/Makefile
index 0ee36ec830..20a0876962 100644
--- a/source4/Makefile
+++ b/source4/Makefile
@@ -6,7 +6,7 @@ include mkconfig.mk
pidldir := $(srcdir)/pidl
-VPATH = $(builddir):$(srcdir):heimdal_build:heimdal/lib/asn1:heimdal/lib/krb5:heimdal/lib/gssapi:heimdal/lib/hdb:heimdal/lib/roken:heimdal/lib/des
+VPATH = $(builddir):$(srcdir):$(srcdir)/heimdal_build:$(heimdalsrcdir)/lib/asn1:$(heimdalsrcdir)/lib/krb5:$(heimdalsrcdir)/lib/gssapi:$(heimdalsrcdir)/lib/hdb:$(heimdalsrcdir)/lib/roken:$(heimdalsrcdir)/lib/des
BASEDIR = $(prefix)
TORTUREDIR = $(libdir)/torture
@@ -47,8 +47,57 @@ ALL_PREDEP = basics
.NOTPARALLEL:
endif
-include build/make/rules.mk
-include build/make/python.mk
+include $(srcdir)/build/make/rules.mk
+include $(srcdir)/build/make/python.mk
+dynconfigsrcdir := dynconfig
+heimdalsrcdir := heimdal
+dsdbsrcdir := dsdb
+smbdsrcdir := smbd
+clustersrcdir := cluster
+libnetsrcdir := libnet
+authsrcdir := auth
+nsswitchsrcdir := nsswitch
+libsrcdir := lib
+libsocketsrcdir := lib/socket
+libcharsetsrcdir := lib/charset
+ldb_sambasrcdir := lib/ldb-samba
+libtlssrcdir := lib/tls
+libregistrysrcdir := lib/registry
+smbreadlinesrcdir := lib/smbreadline
+libmessagingsrcdir := lib/messaging
+libeventssrcdir := lib/events
+libcmdlinesrcdir := lib/cmdline
+socketwrappersrcdir := lib/socket_wrapper
+nsswrappersrcdir := lib/nss_wrapper
+appwebsrcdir := lib/appweb
+libstreamsrcdir := lib/stream
+libutilsrcdir := lib/util
+libtdrsrcdir := lib/tdr
+libdbwrapsrcdir := lib/dbwrap
+libcryptosrcdir := lib/crypto
+libtorturesrcdir := lib/torture
+smb_serversrcdir := smb_server
+libcompressionsrcdir := lib/compression
+libgencachesrcdir := lib
+paramsrcdir := param
+rpc_serversrcdir := rpc_server
+ldap_serversrcdir := ldap_server
+web_serversrcdir := web_server
+winbindsrcdir := winbind
+nbt_serversrcdir := nbt_server
+wrepl_serversrcdir := wrepl_server
+cldap_serversrcdir := cldap_server
+utilssrcdir := utils
+clientsrcdir := client
+torturesrcdir := torture
+ntvfssrcdir := ntvfs
+ntptrsrcdir := ntptr
+librpcsrcdir := librpc
+libclisrcdir := libcli
+ejsscriptsrcdir := scripting/ejs
+pyscriptsrcdir := $(srcdir)/scripting/python
+kdcsrcdir := kdc
+
include data.mk
BINARIES += $(BIN_PROGS) $(SBIN_PROGS)
@@ -233,8 +282,8 @@ data.mk: config.status $(MK_FILES)
testcov-html::
-include pidl/config.mk
-include selftest/config.mk
+include $(pidldir)/config.mk
+include $(srcdir)/selftest/config.mk
showflags::
@echo ' pwd = '`/bin/pwd`
diff --git a/source4/auth/auth.i b/source4/auth/auth.i
index b1743ef765..67c8137f67 100644
--- a/source4/auth/auth.i
+++ b/source4/auth/auth.i
@@ -16,7 +16,11 @@
along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
-%module(package="samba.auth") auth
+%define DOCSTRING
+"Authentication and authorization support."
+%enddef
+
+%module(docstring=DOCSTRING,package="samba.auth") auth
%{
diff --git a/source4/auth/auth.py b/source4/auth/auth.py
index 88675f3626..226175a75b 100644
--- a/source4/auth/auth.py
+++ b/source4/auth/auth.py
@@ -1,8 +1,12 @@
# 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.
+"""
+Authentication and authorization support.
+"""
+
import _auth
import new
new_instancemethod = new.instancemethod
diff --git a/source4/auth/auth_wrap.c b/source4/auth/auth_wrap.c
index af1827adc9..dea76ef87d 100644
--- a/source4/auth/auth_wrap.c
+++ b/source4/auth/auth_wrap.c
@@ -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;
}
@@ -2505,7 +2523,7 @@ static swig_module_info swig_module = {swig_types, 16, 0, 0, 0, 0};
#define SWIG_name "_auth"
-#define SWIGVERSION 0x010333
+#define SWIGVERSION 0x010335
#define SWIG_VERSION SWIGVERSION
@@ -2733,7 +2751,7 @@ SWIGRUNTIME void
SWIG_InitializeModule(void *clientdata) {
size_t i;
swig_module_info *module_head, *iter;
- int found;
+ int found, init;
clientdata = clientdata;
@@ -2743,6 +2761,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 */
@@ -2771,6 +2792,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);
diff --git a/source4/auth/credentials/credentials.i b/source4/auth/credentials/credentials.i
index 152d2e673c..bb31d6d4c0 100644
--- a/source4/auth/credentials/credentials.i
+++ b/source4/auth/credentials/credentials.i
@@ -16,7 +16,7 @@
along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
-%module(package="samba.credentials") credentials
+%module(docstring="Credentials management.",package="samba.credentials") credentials
%{
@@ -59,36 +59,53 @@ typedef struct cli_credentials {
return cli_credentials_init(NULL);
}
/* username */
+ %feature("docstring") get_username "S.get_username() -> username\nObtain username.";
const char *get_username(void);
+ %feature("docstring") set_username "S.set_username(name, obtained=CRED_SPECIFIED) -> None\nChange username.";
bool set_username(const char *value,
- enum credentials_obtained=CRED_SPECIFIED);
+ enum credentials_obtained obtained=CRED_SPECIFIED);
/* password */
+ %feature("docstring") get_password "S.get_password() -> password\n" \
+ "Obtain password.";
const char *get_password(void);
+ %feature("docstring") set_password "S.set_password(password, obtained=CRED_SPECIFIED) -> None\n" \
+ "Change password.";
bool set_password(const char *val,
- enum credentials_obtained=CRED_SPECIFIED);
+ enum credentials_obtained obtained=CRED_SPECIFIED);
/* domain */
+ %feature("docstring") get_password "S.get_domain() -> domain\nObtain domain name.";
const char *get_domain(void);
+ %feature("docstring") set_domain "S.set_domain(domain, obtained=CRED_SPECIFIED) -> None\n" \
+ "Change domain name.";
bool set_domain(const char *val,
- enum credentials_obtained=CRED_SPECIFIED);
+ enum credentials_obtained obtained=CRED_SPECIFIED);
/* realm */
+ %feature("docstring") get_realm "S.get_realm() -> realm\nObtain realm name.";
const char *get_realm(void);
+ %feature("docstring") set_realm "S.set_realm(realm, obtained=CRED_SPECIFIED) -> None\n" \
+ "Change realm name.";
bool set_realm(const char *val,
- enum credentials_obtained=CRED_SPECIFIED);
+ enum credentials_obtained obtained=CRED_SPECIFIED);
- /* Kerberos */
+ /* Kerberos */
void set_kerberos_state(enum credentials_use_kerberos use_kerberos);
+ %feature("docstring") parse_string "S.parse_string(text, obtained=CRED_SPECIFIED) -> None\n" \
+ "Parse credentials string.";
void parse_string(const char *text,
- enum credentials_obtained=CRED_SPECIFIED);
+ enum credentials_obtained obtained=CRED_SPECIFIED);
/* bind dn */
+ %feature("docstring") get_bind_dn "S.get_bind_dn() -> bind dn\nObtain bind DN.";
const char *get_bind_dn(void);
+ %feature("docstring") set_bind_dn "S.set_bind_dn(bind_dn) -> None\nChange bind DN.";
bool set_bind_dn(const char *bind_dn);
- void set_anonymous();
+ %feature("docstring") set_anonymous "S.set_anonymous() -> None\nUse anonymous credentials.";
+ void set_anonymous();
/* workstation name */
const char *get_workstation(void);
@@ -104,8 +121,10 @@ typedef struct cli_credentials {
bool authentication_requested(void);
+ %feature("docstring") wrong_password "S.wrong_password() -> bool\nIndicate the returned password was incorrect.";
bool wrong_password(void);
+ %feature("docstring") set_cmdline_callbacks "S.set_cmdline_callbacks() -> bool\nUse command-line to obtain credentials not explicitly set.";
bool set_cmdline_callbacks();
}
} cli_credentials;
diff --git a/source4/auth/credentials/credentials.py b/source4/auth/credentials/credentials.py
index b2f2c4ecdd..2cd56c3599 100644
--- a/source4/auth/credentials/credentials.py
+++ b/source4/auth/credentials/credentials.py
@@ -3,6 +3,10 @@
#
# Don't modify this file, modify the SWIG interface instead.
+"""
+Credentials management.
+"""
+
import _credentials
import new
new_instancemethod = new.instancemethod
@@ -66,6 +70,97 @@ class Credentials(object):
__repr__ = _swig_repr
def __init__(self, *args, **kwargs):
_credentials.Credentials_swiginit(self,_credentials.new_Credentials(*args, **kwargs))
+ def get_username(*args, **kwargs):
+ """
+ S.get_username() -> username
+ Obtain username.
+ """
+ return _credentials.Credentials_get_username(*args, **kwargs)
+
+ def set_username(*args, **kwargs):
+ """
+ S.set_username(name, obtained=CRED_SPECIFIED) -> None
+ Change username.
+ """
+ return _credentials.Credentials_set_username(*args, **kwargs)
+
+ def get_password(*args, **kwargs):
+ """
+ S.get_password() -> password
+ Obtain password.
+ """
+ return _credentials.Credentials_get_password(*args, **kwargs)
+
+ def set_password(*args, **kwargs):
+ """
+ S.set_password(password, obtained=CRED_SPECIFIED) -> None
+ Change password.
+ """
+ return _credentials.Credentials_set_password(*args, **kwargs)
+
+ def set_domain(*args, **kwargs):
+ """
+ S.set_domain(domain, obtained=CRED_SPECIFIED) -> None
+ Change domain name.
+ """
+ return _credentials.Credentials_set_domain(*args, **kwargs)
+
+ def get_realm(*args, **kwargs):
+ """
+ S.get_realm() -> realm
+ Obtain realm name.
+ """
+ return _credentials.Credentials_get_realm(*args, **kwargs)
+
+ def set_realm(*args, **kwargs):
+ """
+ S.set_realm(realm, obtained=CRED_SPECIFIED) -> None
+ Change realm name.
+ """
+ return _credentials.Credentials_set_realm(*args, **kwargs)
+
+ def parse_string(*args, **kwargs):
+ """
+ S.parse_string(text, obtained=CRED_SPECIFIED) -> None
+ Parse credentials string.
+ """
+ return _credentials.Credentials_parse_string(*args, **kwargs)
+
+ def get_bind_dn(*args, **kwargs):
+ """
+ S.get_bind_dn() -> bind dn
+ Obtain bind DN.
+ """
+ return _credentials.Credentials_get_bind_dn(*args, **kwargs)
+
+ def set_bind_dn(*args, **kwargs):
+ """
+ S.set_bind_dn(bind_dn) -> None
+ Change bind DN.
+ """
+ return _credentials.Credentials_set_bind_dn(*args, **kwargs)
+
+ def set_anonymous(*args, **kwargs):
+ """
+ S.set_anonymous() -> None
+ Use anonymous credentials.
+ """
+ return _credentials.Credentials_set_anonymous(*args, **kwargs)
+
+ def wrong_password(*args, **kwargs):
+ """
+ S.wrong_password() -> bool
+ Indicate the returned password was incorrect.
+ """
+ return _credentials.Credentials_wrong_password(*args, **kwargs)
+
+ def set_cmdline_callbacks(*args, **kwargs):
+ """
+ S.set_cmdline_callbacks() -> bool
+ Use command-line to obtain credentials not explicitly set.
+ """
+ return _credentials.Credentials_set_cmdline_callbacks(*args, **kwargs)
+
__swig_destroy__ = _credentials.delete_Credentials
Credentials.get_username = new_instancemethod(_credentials.Credentials_get_username,None,Credentials)
Credentials.set_username = new_instancemethod(_credentials.Credentials_set_username,None,Credentials)
diff --git a/source4/auth/credentials/credentials_wrap.c b/source4/auth/credentials/credentials_wrap.c
index d460f31927..81ba426e45 100644
--- a/source4/auth/credentials/credentials_wrap.c
+++ b/source4/auth/credentials/credentials_wrap.c
@@ -2881,7 +2881,7 @@ SWIGINTERN PyObject *_wrap_Credentials_set_username(PyObject *SWIGUNUSEDPARM(sel
PyObject * obj1 = 0 ;
PyObject * obj2 = 0 ;
char * kwnames[] = {
- (char *) "self",(char *) "value",(char *)"arg3", NULL
+ (char *) "self",(char *) "value",(char *) "obtained", NULL
};
arg1 = NULL;
@@ -2962,7 +2962,7 @@ SWIGINTERN PyObject *_wrap_Credentials_set_password(PyObject *SWIGUNUSEDPARM(sel
PyObject * obj1 = 0 ;
PyObject * obj2 = 0 ;
char * kwnames[] = {
- (char *) "self",(char *) "val",(char *)"arg3", NULL
+ (char *) "self",(char *) "val",(char *) "obtained", NULL
};
arg1 = NULL;
@@ -3043,7 +3043,7 @@ SWIGINTERN PyObject *_wrap_Credentials_set_domain(PyObject *SWIGUNUSEDPARM(self)
PyObject * obj1 = 0 ;
PyObject * obj2 = 0 ;
char * kwnames[] = {
- (char *) "self",(char *) "val",(char *)"arg3", NULL
+ (char *) "self",(char *) "val",(char *) "obtained", NULL
};
arg1 = NULL;
@@ -3124,7 +3124,7 @@ SWIGINTERN PyObject *_wrap_Credentials_set_realm(PyObject *SWIGUNUSEDPARM(self),
PyObject * obj1 = 0 ;
PyObject * obj2 = 0 ;
char * kwnames[] = {
- (char *) "self",(char *) "val",(char *)"arg3", NULL
+ (char *) "self",(char *) "val",(char *) "obtained", NULL
};
arg1 = NULL;
@@ -3214,7 +3214,7 @@ SWIGINTERN PyObject *_wrap_Credentials_parse_string(PyObject *SWIGUNUSEDPARM(sel
PyObject * obj1 = 0 ;
PyObject * obj2 = 0 ;
char * kwnames[] = {
- (char *) "self",(char *) "text",(char *)"arg3", NULL
+ (char *) "self",(char *) "text",(char *) "obtained", NULL
};
arg1 = NULL;
@@ -3690,19 +3690,52 @@ SWIGINTERN PyObject *Credentials_swiginit(PyObject *SWIGUNUSEDPARM(self), PyObje
static PyMethodDef SwigMethods[] = {
{ (char *)"new_Credentials", (PyCFunction)_wrap_new_Credentials, METH_NOARGS, NULL},
- { (char *)"Credentials_get_username", (PyCFunction) _wrap_Credentials_get_username, METH_VARARGS | METH_KEYWORDS, NULL},
- { (char *)"Credentials_set_username", (PyCFunction) _wrap_Credentials_set_username, METH_VARARGS | METH_KEYWORDS, NULL},
- { (char *)"Credentials_get_password", (PyCFunction) _wrap_Credentials_get_password, METH_VARARGS | METH_KEYWORDS, NULL},
- { (char *)"Credentials_set_password", (PyCFunction) _wrap_Credentials_set_password, METH_VARARGS | METH_KEYWORDS, NULL},
+ { (char *)"Credentials_get_username", (PyCFunction) _wrap_Credentials_get_username, METH_VARARGS | METH_KEYWORDS, (char *)"\n"
+ "S.get_username() -> username\n"
+ "Obtain username.\n"
+ ""},
+ { (char *)"Credentials_set_username", (PyCFunction) _wrap_Credentials_set_username, METH_VARARGS | METH_KEYWORDS, (char *)"\n"
+ "S.set_username(name, obtained=CRED_SPECIFIED) -> None\n"
+ "Change username.\n"
+ ""},
+ { (char *)"Credentials_get_password", (PyCFunction) _wrap_Credentials_get_password, METH_VARARGS | METH_KEYWORDS, (char *)"\n"
+ "S.get_password() -> password\n"
+ "Obtain password.\n"
+ ""},
+ { (char *)"Credentials_set_password", (PyCFunction) _wrap_Credentials_set_password, METH_VARARGS | METH_KEYWORDS, (char *)"\n"
+ "S.set_password(password, obtained=CRED_SPECIFIED) -> None\n"
+ "Change password.\n"
+ ""},
{ (char *)"Credentials_get_domain", (PyCFunction) _wrap_Credentials_get_domain, METH_VARARGS | METH_KEYWORDS, NULL},
- { (char *)"Credentials_set_domain", (PyCFunction) _wrap_Credentials_set_domain, METH_VARARGS | METH_KEYWORDS, NULL},
- { (char *)"Credentials_get_realm", (PyCFunction) _wrap_Credentials_get_realm, METH_VARARGS | METH_KEYWORDS, NULL},
- { (char *)"Credentials_set_realm", (PyCFunction) _wrap_Credentials_set_realm, METH_VARARGS | METH_KEYWORDS, NULL},
+ { (char *)"Credentials_set_domain", (PyCFunction) _wrap_Credentials_set_domain, METH_VARARGS | METH_KEYWORDS, (char *)"\n"
+ "S.set_domain(domain, obtained=CRED_SPECIFIED) -> None\n"
+ "Change domain name.\n"
+ ""},
+ { (char *)"Credentials_get_realm", (PyCFunction) _wrap_Credentials_get_realm, METH_VARARGS | METH_KEYWORDS, (char *)"\n"
+ "S.get_realm() -> realm\n"
+ "Obtain realm name.\n"
+ ""},
+ { (char *)"Credentials_set_realm", (PyCFunction) _wrap_Credentials_set_realm, METH_VARARGS | METH_KEYWORDS, (char *)"\n"
+ "S.set_realm(realm, obtained=CRED_SPECIFIED) -> None\n"
+ "Change realm name.\n"
+ ""},
{ (char *)"Credentials_set_kerberos_state", (PyCFunction) _wrap_Credentials_set_kerberos_state, METH_VARARGS | METH_KEYWORDS, NULL},
- { (char *)"Credentials_parse_string", (PyCFunction) _wrap_Credentials_parse_string, METH_VARARGS | METH_KEYWORDS, NULL},
- { (char *)"Credentials_get_bind_dn", (PyCFunction) _wrap_Credentials_get_bind_dn, METH_VARARGS | METH_KEYWORDS, NULL},
- { (char *)"Credentials_set_bind_dn", (PyCFunction) _wrap_Credentials_set_bind_dn, METH_VARARGS | METH_KEYWORDS, NULL},
- { (char *)"Credentials_set_anonymous", (PyCFunction) _wrap_Credentials_set_anonymous, METH_VARARGS | METH_KEYWORDS, NULL},
+ { (char *)"Credentials_parse_string", (PyCFunction) _wrap_Credentials_parse_string, METH_VARARGS | METH_KEYWORDS, (char *)"\n"
+ "S.parse_string(text, obtained=CRED_SPECIFIED) -> None\n"
+ "Parse credentials string.\n"
+ ""},
+ { (char *)"Credentials_get_bind_dn", (PyCFunction) _wrap_Credentials_get_bind_dn, METH_VARARGS | METH_KEYWORDS, (char *)"\n"
+ "S.get_bind_dn() -> bind dn\n"
+ "Obtain bind DN.\n"
+ ""},
+ { (char *)"Credentials_set_bind_dn", (PyCFunction) _wrap_Credentials_set_bind_dn, METH_VARARGS | METH_KEYWORDS, (char *)"\n"
+ "S.set_bind_dn(bind_dn) -> None\n"
+ "Change bind DN.\n"
+ ""},
+ { (char *)"Credentials_set_anonymous", (PyCFunction) _wrap_Credentials_set_anonymous, METH_VARARGS | METH_KEYWORDS, (char *)"\n"
+ "S.set_anonymous() -> None\n"
+ "Use anonymous credentials.\n"
+ ""},
{ (char *)"Credentials_get_workstation", (PyCFunction) _wrap_Credentials_get_workstation, METH_VARARGS | METH_KEYWORDS, NULL},
{ (char *)"Credentials_set_workstation", (PyCFunction) _wrap_Credentials_set_workstation, METH_VARARGS | METH_KEYWORDS, NULL},
{ (char *)"Credentials_set_machine_account", (PyCFunction) _wrap_Credentials_set_machine_account, METH_VARARGS | METH_KEYWORDS, NULL},
@@ -3710,8 +3743,14 @@ static PyMethodDef SwigMethods[] = {
{ (char *)"Credentials_is_anonymous", (PyCFunction) _wrap_Credentials_is_anonymous, METH_VARARGS | METH_KEYWORDS, NULL},
{ (char *)"Credentials_get_nt_hash", (PyCFunction) _wrap_Credentials_get_nt_hash, METH_VARARGS | METH_KEYWORDS, NULL},
{ (char *)"Credentials_authentication_requested", (PyCFunction) _wrap_Credentials_authentication_requested, METH_VARARGS | METH_KEYWORDS, NULL},
- { (char *)"Credentials_wrong_password", (PyCFunction) _wrap_Credentials_wrong_password, METH_VARARGS | METH_KEYWORDS, NULL},
- { (char *)"Credentials_set_cmdline_callbacks", (PyCFunction) _wrap_Credentials_set_cmdline_callbacks, METH_VARARGS | METH_KEYWORDS, NULL},
+ { (char *)"Credentials_wrong_password", (PyCFunction) _wrap_Credentials_wrong_password, METH_VARARGS | METH_KEYWORDS, (char *)"\n"
+ "S.wrong_password() -> bool\n"
+ "Indicate the returned password was incorrect.\n"
+ ""},
+ { (char *)"Credentials_set_cmdline_callbacks", (PyCFunction) _wrap_Credentials_set_cmdline_callbacks, METH_VARARGS | METH_KEYWORDS, (char *)"\n"
+ "S.set_cmdline_callbacks() -> bool\n"
+ "Use command-line to obtain credentials not explicitly set.\n"
+ ""},
{ (char *)"delete_Credentials", (PyCFunction) _wrap_delete_Credentials, METH_VARARGS | METH_KEYWORDS, NULL},
{ (char *)"Credentials_swigregister", Credentials_swigregister, METH_VARARGS, NULL},
{ (char *)"Credentials_swiginit", Credentials_swiginit, METH_VARARGS, NULL},
diff --git a/source4/build/make/rules.mk b/source4/build/make/rules.mk
index 176e67a691..27a214459a 100644
--- a/source4/build/make/rules.mk
+++ b/source4/build/make/rules.mk
@@ -86,7 +86,7 @@ unused_macros:
@mkdir -p $(@D)
@$(STLD) $(STLD_FLAGS) $@ $^
-include build/make/templates.mk
+include $(make_utility_dir)/templates.mk
###############################################################################
# File types
diff --git a/source4/build/make/templates.mk b/source4/build/make/templates.mk
index 1c0af4dee6..41a7ccd0a5 100644
--- a/source4/build/make/templates.mk
+++ b/source4/build/make/templates.mk
@@ -92,7 +92,7 @@ PLUGINS += bin/modules/$(2)/$(3).$$(SHLIBEXT)
uninstallplugins::
@-rm $$(DESTDIR)$$(modulesdir)/$(2)/$(3).$$(SHLIBEXT)
installplugins::
- @ln -fs $(basename $(1)) $$(DESTDIR)$$(modulesdir)/$(2)/$(3).$$(SHLIBEXT)
+ @ln -fs $(notdir $(1)) $$(DESTDIR)$$(modulesdir)/$(2)/$(3).$$(SHLIBEXT)
endef
diff --git a/source4/build/smb_build/config_mk.pm b/source4/build/smb_build/config_mk.pm
index 652a52fa60..8c7d75221c 100644
--- a/source4/build/smb_build/config_mk.pm
+++ b/source4/build/smb_build/config_mk.pm
@@ -25,7 +25,6 @@ my $section_types = {
"PUBLIC_DEPENDENCIES" => "list",
"ENABLE" => "bool",
"LDFLAGS" => "list",
- "CFLAGS" => "list",
},
"SUBSYSTEM" => {
"PRIVATE_DEPENDENCIES" => "list",
@@ -60,7 +59,6 @@ my $section_types = {
"ENABLE" => "bool",
"INSTALLDIR" => "string",
- "CFLAGS" => "list",
"LDFLAGS" => "list",
"STANDARD_VISIBILITY" => "string",
diff --git a/source4/build/smb_build/makefile.pm b/source4/build/smb_build/makefile.pm
index 0269cfe8a3..73801c25fd 100644
--- a/source4/build/smb_build/makefile.pm
+++ b/source4/build/smb_build/makefile.pm
@@ -262,6 +262,10 @@ sub CFlags($$)
if($src_ne_build) {
if($flag =~ m#^-I([^/].*$)#) {
my $dir = $1;
+ if ($dir =~ /^\$\(/) {
+ push (@cflags, $flag);
+ next;
+ }
$dir =~ s#^\$\((?:src|build)dir\)/?##;
push(@cflags, "-I$builddir/$dir", "-I$srcdir/$dir");
next;
diff --git a/source4/dynconfig.mk b/source4/dynconfig/config.mk
index f365911c6a..5f2887f8b6 100644
--- a/source4/dynconfig.mk
+++ b/source4/dynconfig/config.mk
@@ -1,6 +1,7 @@
[SUBSYSTEM::DYNCONFIG]
-DYNCONFIG_OBJ_FILES = dynconfig.o
+DYNCONFIG_OBJ_FILES = $(dynconfigsrcdir)/dynconfig.o \
+ $(dynconfigsrcdir)/version.o
# set these to where to find various files
# These can be overridden by command line switches (see smbd(8))
@@ -9,10 +10,7 @@ CONFIGFILE = $(sysconfdir)/smb.conf
PKGCONFIGDIR = $(libdir)/pkgconfig
LMHOSTSFILE = $(sysconfdir)/lmhosts
-dynconfig.o: dynconfig.c Makefile
- @echo Compiling $<
- @$(CC) $(CFLAGS) $(CPPFLAGS) $(PICFLAG) -c $< -o $@ \
- -DCONFIGFILE=\"$(CONFIGFILE)\" -DBINDIR=\"$(bindir)\" \
+$(dynconfigsrcdir)/dynconfig.o: CFLAGS+=-DCONFIGFILE=\"$(CONFIGFILE)\" -DBINDIR=\"$(bindir)\" \
-DLMHOSTSFILE=\"$(LMHOSTSFILE)\" \
-DLOCKDIR=\"$(lockdir)\" -DPIDDIR=\"$(piddir)\" -DDATADIR=\"$(datadir)\" \
-DLOGFILEBASE=\"$(logfilebase)\" \
@@ -23,4 +21,3 @@ dynconfig.o: dynconfig.c Makefile
-DTORTUREDIR=\"$(TORTUREDIR)\" \
-DSETUPDIR=\"$(SETUPDIR)\" -DWINBINDD_SOCKET_DIR=\"$(winbindd_socket_dir)\"
-
diff --git a/source4/dynconfig.c b/source4/dynconfig/dynconfig.c
index 6dbbf872d9..6dbbf872d9 100644
--- a/source4/dynconfig.c
+++ b/source4/dynconfig/dynconfig.c
diff --git a/source4/dynconfig.h b/source4/dynconfig/dynconfig.h
index ac54db63d6..ac54db63d6 100644
--- a/source4/dynconfig.h
+++ b/source4/dynconfig/dynconfig.h
diff --git a/source4/lib/version.c b/source4/dynconfig/version.c
index e81f463586..e81f463586 100644
--- a/source4/lib/version.c
+++ b/source4/dynconfig/version.c
diff --git a/source4/heimdal_build/asn1_compile_wrapper.sh b/source4/heimdal_build/asn1_compile_wrapper.sh
index 96677c7e8e..c449bf8065 100755
--- a/source4/heimdal_build/asn1_compile_wrapper.sh
+++ b/source4/heimdal_build/asn1_compile_wrapper.sh
@@ -4,21 +4,15 @@
SELF=$0
SELFDIR=`dirname ${SELF}`
-SRCDIR=$1
-BUILDDIR=$2
-DESTDIR=$3
+BUILDDIR=$1
+DESTDIR=$2
-CMD=$4
-FILE=$5
-NAME=$6
-shift 6
+CMD=$3
+FILE=$4
+NAME=$5
+shift 5
OPTIONS="$@"
-test -z "${SRCDIR}" && {
- echo "${SELF}:SRCDIR: '${SRCDIR}'" >&2;
- exit 1;
-}
-
test -z "${BUILDDIR}" && {
echo "${SELF}:BUILDDIR: '${BUILDDIR}'" >&2;
exit 1;
@@ -46,14 +40,6 @@ test -z "${NAME}" && {
CURDIR=`pwd`
-cd ${SRCDIR} && {
- ABS_SRCDIR=`pwd`
- cd ${CURDIR}
-} || {
- echo "${SELF}:cannot cd into '${SRCDIR}'" >&2;
- exit 1;
-}
-
cd ${BUILDDIR} && {
ABS_BUILDDIR=`pwd`
cd ${CURDIR}
@@ -63,7 +49,7 @@ cd ${BUILDDIR} && {
}
cd ${DESTDIR} && {
- ${ABS_BUILDDIR}/${CMD} ${OPTIONS} ${ABS_SRCDIR}/${FILE} ${NAME} >&2 || exit 1;
+ ${ABS_BUILDDIR}/${CMD} ${OPTIONS} ${FILE} ${NAME} >&2 || exit 1;
cd ${CURDIR}
} || {
echo "${SELF}:cannot cd into '${BUILDDIR}'" >&2;
diff --git a/source4/heimdal_build/asn1_deps.pl b/source4/heimdal_build/asn1_deps.pl
index a2fbb5e3d0..6121781760 100755
--- a/source4/heimdal_build/asn1_deps.pl
+++ b/source4/heimdal_build/asn1_deps.pl
@@ -29,11 +29,11 @@ if (not defined $options) {
my $header = "$dirname/$prefix.h";
-print "$header: $file bin/asn1_compile\n";
-print "\t\@echo \"Compiling ASN1 file $file\"\n";
-print "\t\@\$(builddir)/heimdal_build/asn1_compile_wrapper.sh \$(srcdir) \$(builddir) $dirname bin/asn1_compile $file $prefix $options\n\n";
+print "$header: \$(heimdalsrcdir)/$file \$(ASN1C)\n";
+print "\t\@echo \"Compiling ASN1 file \$(heimdalsrcdir)/$file\"\n";
+print "\t\@\$(heimdalbuildsrcdir)/asn1_compile_wrapper.sh \$(builddir) $dirname \$(ASN1C) \$(abspath \$(heimdalsrcdir)/$file) $prefix $options\n\n";
-open(IN,$file) or die("Can't open $file: $!");
+open(IN,"heimdal/$file") or die("Can't open heimdal/$file: $!");
my @lines = <IN>;
close(IN);
foreach my $line (@lines) {
diff --git a/source4/heimdal_build/config.mk b/source4/heimdal_build/config.mk
index a4f24c9026..17fc8c93ec 100644
--- a/source4/heimdal_build/config.mk
+++ b/source4/heimdal_build/config.mk
@@ -1,7 +1,9 @@
+heimdalbuildsrcdir = $(heimdalsrcdir)/../heimdal_build
+
#######################
# Start SUBSYSTEM HEIMDAL_KDC
[SUBSYSTEM::HEIMDAL_KDC]
-CFLAGS = -Iheimdal_build -Iheimdal/kdc
+CFLAGS = -I$(heimdalbuildsrcdir) -I$(heimdalsrcdir)/kdc
PRIVATE_DEPENDENCIES = HEIMDAL_ROKEN HEIMDAL_KRB5 HEIMDAL_HDB HEIMDAL_HEIM_ASN1 HEIMDAL_DIGEST_ASN1 HEIMDAL_KX509_ASN1
PUBLIC_DEPENDENCIES = HEIMDAL_NTLM HEIMDAL_HCRYPTO
# End SUBSYSTEM HEIMDAL_KDC
@@ -24,14 +26,14 @@ HEIMDAL_KDC_OBJ_FILES = \
$(heimdalsrcdir)/kdc/kx509.o
[SUBSYSTEM::HEIMDAL_NTLM]
-CFLAGS = -Iheimdal_build -Iheimdal/lib/ntlm
+CFLAGS = -I$(heimdalbuildsrcdir) -I$(heimdalsrcdir)/lib/ntlm
PRIVATE_DEPENDENCIES = HEIMDAL_ROKEN HEIMDAL_HCRYPTO HEIMDAL_KRB5
HEIMDAL_NTLM_OBJ_FILES = \
$(heimdalsrcdir)/lib/ntlm/ntlm.o
[SUBSYSTEM::HEIMDAL_HDB_KEYS]
-CFLAGS = -Iheimdal_build -Iheimdal/lib/hdb
+CFLAGS = -I$(heimdalbuildsrcdir) -I$(heimdalsrcdir)/lib/hdb
PRIVATE_DEPENDENCIES = HEIMDAL_ROKEN HEIMDAL_HCRYPTO HEIMDAL_KRB5 \
HEIMDAL_HDB_ASN1
@@ -40,7 +42,7 @@ HEIMDAL_HDB_KEYS_OBJ_FILES = $(heimdalsrcdir)/lib/hdb/keys.o
#######################
# Start SUBSYSTEM HEIMDAL_HDB
[SUBSYSTEM::HEIMDAL_HDB]
-CFLAGS = -Iheimdal_build -Iheimdal/lib/hdb
+CFLAGS = -I$(heimdalbuildsrcdir) -I$(heimdalsrcdir)/lib/hdb
PRIVATE_DEPENDENCIES = HDB_LDB HEIMDAL_KRB5 HEIMDAL_HDB_KEYS HEIMDAL_ROKEN HEIMDAL_HCRYPTO HEIMDAL_COM_ERR HEIMDAL_HDB_ASN1
# End SUBSYSTEM HEIMDAL_HDB
#######################
@@ -58,7 +60,7 @@ HEIMDAL_HDB_OBJ_FILES = \
#######################
# Start SUBSYSTEM HEIMDAL_GSSAPI
[SUBSYSTEM::HEIMDAL_GSSAPI]
-CFLAGS = -Iheimdal_build -Iheimdal/lib/gssapi -Iheimdal/lib/gssapi/gssapi -Iheimdal/lib/gssapi/spnego -Iheimdal/lib/gssapi/krb5 -Iheimdal/lib/gssapi/mech
+CFLAGS = -I$(heimdalbuildsrcdir) -I$(heimdalsrcdir)/lib/gssapi -I$(heimdalsrcdir)/lib/gssapi/gssapi -I$(heimdalsrcdir)/lib/gssapi/spnego -I$(heimdalsrcdir)/lib/gssapi/krb5 -I$(heimdalsrcdir)/lib/gssapi/mech
PRIVATE_DEPENDENCIES = HEIMDAL_HCRYPTO HEIMDAL_HEIM_ASN1 HEIMDAL_SPNEGO_ASN1
PUBLIC_DEPENDENCIES = HEIMDAL_ROKEN HEIMDAL_KRB5
# End SUBSYSTEM HEIMDAL_GSSAPI
@@ -176,7 +178,7 @@ HEIMDAL_GSSAPI_OBJ_FILES = \
#######################
# Start SUBSYSTEM HEIMDAL_KRB5
[SUBSYSTEM::HEIMDAL_KRB5]
-CFLAGS = -Iheimdal_build -Iheimdal/lib/krb5 -Iheimdal/lib/asn1 -Iheimdal/lib/com_err
+CFLAGS = -I$(heimdalbuildsrcdir) -I$(heimdalsrcdir)/lib/krb5 -I$(heimdalsrcdir)/lib/asn1 -I$(heimdalsrcdir)/lib/com_err
PRIVATE_DEPENDENCIES = HEIMDAL_ROKEN HEIMDAL_PKINIT_ASN1 HEIMDAL_WIND
PUBLIC_DEPENDENCIES = HEIMDAL_KRB5_ASN1 HEIMDAL_GLUE HEIMDAL_HX509 HEIMDAL_HCRYPTO
# End SUBSYSTEM HEIMDAL_KRB5
@@ -273,7 +275,7 @@ HEIMDAL_KRB5_OBJ_FILES = \
#######################
# Start SUBSYSTEM HEIMDAL_HEIM_ASN1
[SUBSYSTEM::HEIMDAL_HEIM_ASN1]
-CFLAGS = -Iheimdal_build -Iheimdal/lib/asn1
+CFLAGS = -I$(heimdalbuildsrcdir) -I$(heimdalsrcdir)/lib/asn1
PRIVATE_DEPENDENCIES = HEIMDAL_ROKEN HEIMDAL_COM_ERR
# End SUBSYSTEM HEIMDAL_KRB5
#######################
@@ -293,7 +295,7 @@ HEIMDAL_HEIM_ASN1_OBJ_FILES = \
#######################
# Start SUBSYSTEM HEIMDAL_HCRYPTO_IMATH
[SUBSYSTEM::HEIMDAL_HCRYPTO_IMATH]
-CFLAGS = -Iheimdal_build -Iheimdal/lib/hcrypto/imath
+CFLAGS = -I$(heimdalbuildsrcdir) -I$(heimdalsrcdir)/lib/hcrypto/imath
PRIVATE_DEPENDENCIES = HEIMDAL_ROKEN
# End SUBSYSTEM HEIMDAL_HCRYPTO_IMATH
#######################
@@ -303,7 +305,7 @@ HEIMDAL_HCRYPTO_IMATH_OBJ_FILES = \
$(heimdalsrcdir)/lib/hcrypto/imath/iprime.o
[SUBSYSTEM::HEIMDAL_HCRYPTO]
-CFLAGS = -Iheimdal_build -Iheimdal/lib/hcrypto -Iheimdal/lib
+CFLAGS = -I$(heimdalbuildsrcdir) -I$(heimdalsrcdir)/lib/hcrypto -I$(heimdalsrcdir)/lib
PRIVATE_DEPENDENCIES = HEIMDAL_ROKEN HEIMDAL_HEIM_ASN1 HEIMDAL_HCRYPTO_IMATH HEIMDAL_RFC2459_ASN1
# End SUBSYSTEM HEIMDAL_HCRYPTO
#######################
@@ -343,7 +345,7 @@ HEIMDAL_HCRYPTO_OBJ_FILES = \
#######################
# Start SUBSYSTEM HEIMDAL_HX509
[SUBSYSTEM::HEIMDAL_HX509]
-CFLAGS = -Iheimdal_build -Iheimdal/lib/hx509
+CFLAGS = -I$(heimdalbuildsrcdir) -I$(heimdalsrcdir)/lib/hx509
PRIVATE_DEPENDENCIES = \
HEIMDAL_ROKEN HEIMDAL_COM_ERR \
HEIMDAL_HEIM_ASN1 HEIMDAL_HCRYPTO \
@@ -383,7 +385,7 @@ HEIMDAL_HX509_OBJ_FILES = \
#######################
# Start SUBSYSTEM HEIMDAL_WIND
[SUBSYSTEM::HEIMDAL_WIND]
-CFLAGS = -Iheimdal_build -Iheimdal/lib/wind
+CFLAGS = -I$(heimdalbuildsrcdir) -I$(heimdalsrcdir)/lib/wind
PRIVATE_DEPENDENCIES = \
HEIMDAL_ROKEN HEIMDAL_COM_ERR
@@ -406,24 +408,24 @@ HEIMDAL_WIND_OBJ_FILES = \
#######################
[SUBSYSTEM::HEIMDAL_ROKEN_GETPROGNAME]
-CFLAGS = -Iheimdal_build -Iheimdal/lib/roken -Ilib/socket_wrapper
HEIMDAL_ROKEN_GETPROGNAME_OBJ_FILES = $(heimdalsrcdir)/lib/roken/getprogname.o
+$(HEIMDAL_ROKEN_GETPROGNAME_OBJ_FILES): CFLAGS+=-I$(heimdalbuildsrcdir) -I$(heimdalsrcdir)/lib/roken -I$(socketwrappersrcdir)
[SUBSYSTEM::HEIMDAL_ROKEN_CLOSEFROM]
-CFLAGS = -Iheimdal_build -Iheimdal/lib/roken -Ilib/socket_wrapper
HEIMDAL_ROKEN_CLOSEFROM_OBJ_FILES = $(heimdalsrcdir)/lib/roken/closefrom.o
+$(HEIMDAL_ROKEN_CLOSEFROM_OBJ_FILES): CFLAGS+=-I$(heimdalbuildsrcdir) -I$(heimdalsrcdir)/lib/roken -I$(socketwrappersrcdir)
[SUBSYSTEM::HEIMDAL_ROKEN_GETPROGNAME_H]
-CFLAGS = -Iheimdal_build -Iheimdal/lib/roken -Ilib/socket_wrapper
HEIMDAL_ROKEN_GETPROGNAME_H_OBJ_FILES = $(heimdalsrcdir)/lib/roken/getprogname.ho
+$(HEIMDAL_ROKEN_GETPROGNAME_H_OBJ_FILES): CFLAGS+=-I$(heimdalbuildsrcdir) -I$(heimdalsrcdir)/lib/roken -I$(socketwrappersrcdir)
#######################
# Start SUBSYSTEM HEIMDAL_ROKEN
[SUBSYSTEM::HEIMDAL_ROKEN]
-CFLAGS = -Iheimdal_build -Iheimdal/lib/roken -Ilib/socket_wrapper
+CFLAGS = -I$(heimdalbuildsrcdir) -I$(heimdalsrcdir)/lib/roken -I$(socketwrappersrcdir)
PUBLIC_DEPENDENCIES = \
HEIMDAL_ROKEN_GETPROGNAME \
HEIMDAL_ROKEN_CLOSEFROM \
@@ -461,22 +463,22 @@ HEIMDAL_ROKEN_OBJ_FILES = \
$(heimdalsrcdir)/lib/roken/simple_exec.o \
$(heimdalsrcdir)/lib/roken/strcollect.o \
$(heimdalsrcdir)/lib/roken/rtbl.o \
- ./heimdal_build/replace.o
+ $(heimdalbuildsrcdir)/replace.o
#######################
# Start SUBSYSTEM HEIMDAL_GLUE
[SUBSYSTEM::HEIMDAL_GLUE]
-CFLAGS = -Iheimdal_build -Iheimdal/lib/krb5 -Iheimdal/lib/asn1 -Iheimdal/lib/com_err
+CFLAGS = -I$(heimdalbuildsrcdir) -I$(heimdalsrcdir)/lib/krb5 -I$(heimdalsrcdir)/lib/asn1 -I$(heimdalsrcdir)/lib/com_err
PUBLIC_DEPENDENCIES = LIBNETIF LIBSAMBA-HOSTCONFIG
# End SUBSYSTEM HEIMDAL_GLUE
#######################
-HEIMDAL_GLUE_OBJ_FILES = heimdal_build/glue.o
+HEIMDAL_GLUE_OBJ_FILES = $(heimdalbuildsrcdir)/glue.o
#######################
# Start SUBSYSTEM HEIMDAL_COM_ERR
[SUBSYSTEM::HEIMDAL_COM_ERR]
-CFLAGS = -Iheimdal_build -Iheimdal/lib/com_err
+CFLAGS = -I$(heimdalbuildsrcdir) -I$(heimdalsrcdir)/lib/com_err
PRIVATE_DEPENDENCIES = HEIMDAL_ROKEN
# End SUBSYSTEM HEIMDAL_COM_ERR
#######################
@@ -488,19 +490,20 @@ HEIMDAL_COM_ERR_OBJ_FILES = \
#######################
# Start SUBSYSTEM HEIMDAL_ASN1_COMPILE_LEX
[SUBSYSTEM::HEIMDAL_ASN1_COMPILE_LEX]
-CFLAGS = -Iheimdal_build -Iheimdal/lib/asn1 -Iheimdal/lib/roken -Ilib/socket_wrapper
# End SUBSYSTEM HEIMDAL_ASN1_COMPILE_LEX
#######################
HEIMDAL_ASN1_COMPILE_LEX_OBJ_FILES = $(heimdalsrcdir)/lib/asn1/lex.ho
+$(HEIMDAL_ASN1_COMPILE_LEX_OBJ_FILES): CFLAGS+=-I$(heimdalbuildsrcdir) -I$(heimdalsrcdir)/lib/asn1 -I$(heimdalsrcdir)/lib/roken -I$(socketwrappersrcdir)
#######################
# Start BINARY asn1_compile
[BINARY::asn1_compile]
-CFLAGS = -Iheimdal_build -Iheimdal/lib/roken
USE_HOSTCC = YES
PRIVATE_DEPENDENCIES = HEIMDAL_ASN1_COMPILE_LEX HEIMDAL_ROKEN_GETPROGNAME_H LIBREPLACE_NETWORK
+ASN1C = $(builddir)/bin/asn1_compile
+
asn1_compile_OBJ_FILES = \
$(heimdalsrcdir)/lib/asn1/main.ho \
$(heimdalsrcdir)/lib/asn1/gen.ho \
@@ -522,8 +525,10 @@ asn1_compile_OBJ_FILES = \
$(heimdalsrcdir)/lib/roken/ecalloc.ho \
$(heimdalsrcdir)/lib/asn1/symbol.ho \
$(heimdalsrcdir)/lib/vers/print_version.ho \
- ./lib/socket_wrapper/socket_wrapper.ho \
- ./heimdal_build/replace.ho
+ $(socketwrappersrcdir)/socket_wrapper.ho \
+ $(heimdalbuildsrcdir)/replace.ho
+
+$(asn1_compile_OBJ_FILES): CFLAGS+=-I$(heimdalbuildsrcdir) -I$(heimdalsrcdir)/lib/roken -I$(heimdalsrcdir)/lib/asn1
# End BINARY asn1_compile
#######################
@@ -531,7 +536,7 @@ asn1_compile_OBJ_FILES = \
#######################
# Start SUBSYSTEM HEIMDAL_COM_ERR_COMPILE_LEX
[SUBSYSTEM::HEIMDAL_COM_ERR_COMPILE_LEX]
-CFLAGS = -Iheimdal_build -Iheimdal/lib/com_err -Iheimdal/lib/roken -Ilib/socket_wrapper
+CFLAGS = -I$(heimdalbuildsrcdir) -I$(heimdalsrcdir)/lib/com_err -I$(heimdalsrcdir)/lib/roken -I$(socketwrappersrcdir)
# End SUBSYSTEM HEIMDAL_COM_ERR_COMPILE_LEX
#######################
@@ -540,12 +545,13 @@ HEIMDAL_COM_ERR_COMPILE_LEX_OBJ_FILES = $(heimdalsrcdir)/lib/com_err/lex.ho
#######################
# Start BINARY compile_et
[BINARY::compile_et]
-CFLAGS = -Iheimdal_build -Iheimdal/lib/roken
USE_HOSTCC = YES
PRIVATE_DEPENDENCIES = HEIMDAL_COM_ERR_COMPILE_LEX HEIMDAL_ROKEN_GETPROGNAME_H LIBREPLACE_NETWORK
# End BINARY compile_et
#######################
+ET_COMPILER = $(builddir)/bin/compile_et
+
compile_et_OBJ_FILES = $(heimdalsrcdir)/lib/vers/print_version.ho \
$(heimdalsrcdir)/lib/com_err/parse.ho \
$(heimdalsrcdir)/lib/com_err/compile_et.ho \
@@ -553,37 +559,38 @@ compile_et_OBJ_FILES = $(heimdalsrcdir)/lib/vers/print_version.ho \
$(heimdalsrcdir)/lib/roken/get_window_size.ho \
$(heimdalsrcdir)/lib/roken/strupr.ho \
$(heimdalsrcdir)/lib/roken/setprogname.ho \
- ./lib/socket_wrapper/socket_wrapper.ho \
- ./heimdal_build/replace.ho
-
-
-mkinclude perl_path_wrapper.sh asn1_deps.pl heimdal/lib/hdb/hdb.asn1 hdb_asn1 heimdal/lib/hdb |
-mkinclude perl_path_wrapper.sh asn1_deps.pl heimdal/lib/gssapi/spnego/spnego.asn1 spnego_asn1 heimdal/lib/gssapi --sequence=MechTypeList |
-mkinclude perl_path_wrapper.sh asn1_deps.pl heimdal/lib/gssapi/mech/gssapi.asn1 gssapi_asn1 heimdal/lib/gssapi|
-mkinclude perl_path_wrapper.sh asn1_deps.pl heimdal/lib/asn1/k5.asn1 krb5_asn1 heimdal/lib/asn1 --encode-rfc1510-bit-string --sequence=KRB5SignedPathPrincipals --sequence=AuthorizationData --sequence=METHOD-DATA|
-mkinclude perl_path_wrapper.sh asn1_deps.pl heimdal/lib/asn1/digest.asn1 digest_asn1 heimdal/lib/asn1|
-mkinclude perl_path_wrapper.sh asn1_deps.pl heimdal/lib/asn1/pkcs8.asn1 pkcs8_asn1 heimdal/lib/asn1|
-mkinclude perl_path_wrapper.sh asn1_deps.pl heimdal/lib/asn1/pkcs9.asn1 pkcs9_asn1 heimdal/lib/asn1|
-mkinclude perl_path_wrapper.sh asn1_deps.pl heimdal/lib/asn1/pkcs12.asn1 pkcs12_asn1 heimdal/lib/asn1|
-mkinclude perl_path_wrapper.sh asn1_deps.pl heimdal/lib/asn1/rfc2459.asn1 rfc2459_asn1 heimdal/lib/asn1 --preserve-binary=TBSCertificate --preserve-binary=TBSCRLCertList --preserve-binary=Name --sequence=GeneralNames --sequence=Extensions --sequence=CRLDistributionPoints|
-mkinclude perl_path_wrapper.sh asn1_deps.pl heimdal/lib/asn1/pkinit.asn1 pkinit_asn1 heimdal/lib/asn1|
-mkinclude perl_path_wrapper.sh asn1_deps.pl heimdal/lib/asn1/CMS.asn1 cms_asn1 heimdal/lib/asn1|
-mkinclude perl_path_wrapper.sh asn1_deps.pl heimdal/lib/hx509/ocsp.asn1 ocsp_asn1 heimdal/lib/hx509 --preserve-binary=OCSPTBSRequest --preserve-binary=OCSPResponseData|
-mkinclude perl_path_wrapper.sh asn1_deps.pl heimdal/lib/asn1/kx509.asn1 kx509_asn1 heimdal/lib/asn1|
-mkinclude perl_path_wrapper.sh asn1_deps.pl heimdal/lib/hx509/pkcs10.asn1 pkcs10_asn1 heimdal/lib/hx509 --preserve-binary=CertificationRequestInfo|
+ $(socketwrappersrcdir)/socket_wrapper.ho \
+ $(heimdalbuildsrcdir)/replace.ho
+
+$(compile_et_OBJ_FILES): CFLAGS+=-I$(heimdalbuildsrcdir) -I$(heimdalsrcdir)/lib/roken
+
+mkinclude perl_path_wrapper.sh asn1_deps.pl lib/hdb/hdb.asn1 hdb_asn1 \$\(heimdalsrcdir\)/lib/hdb |
+mkinclude perl_path_wrapper.sh asn1_deps.pl lib/gssapi/spnego/spnego.asn1 spnego_asn1 \$\(heimdalsrcdir\)/lib/gssapi --sequence=MechTypeList |
+mkinclude perl_path_wrapper.sh asn1_deps.pl lib/gssapi/mech/gssapi.asn1 gssapi_asn1 \$\(heimdalsrcdir\)/lib/gssapi|
+mkinclude perl_path_wrapper.sh asn1_deps.pl lib/asn1/k5.asn1 krb5_asn1 \$\(heimdalsrcdir\)/lib/asn1 --encode-rfc1510-bit-string --sequence=KRB5SignedPathPrincipals --sequence=AuthorizationData --sequence=METHOD-DATA|
+mkinclude perl_path_wrapper.sh asn1_deps.pl lib/asn1/digest.asn1 digest_asn1 \$\(heimdalsrcdir\)/lib/asn1|
+mkinclude perl_path_wrapper.sh asn1_deps.pl lib/asn1/pkcs8.asn1 pkcs8_asn1 \$\(heimdalsrcdir\)/lib/asn1|
+mkinclude perl_path_wrapper.sh asn1_deps.pl lib/asn1/pkcs9.asn1 pkcs9_asn1 \$\(heimdalsrcdir\)/lib/asn1|
+mkinclude perl_path_wrapper.sh asn1_deps.pl lib/asn1/pkcs12.asn1 pkcs12_asn1 \$\(heimdalsrcdir\)/lib/asn1|
+mkinclude perl_path_wrapper.sh asn1_deps.pl lib/asn1/rfc2459.asn1 rfc2459_asn1 \$\(heimdalsrcdir\)/lib/asn1 --preserve-binary=TBSCertificate --preserve-binary=TBSCRLCertList --preserve-binary=Name --sequence=GeneralNames --sequence=Extensions --sequence=CRLDistributionPoints|
+mkinclude perl_path_wrapper.sh asn1_deps.pl lib/asn1/pkinit.asn1 pkinit_asn1 \$\(heimdalsrcdir\)/lib/asn1|
+mkinclude perl_path_wrapper.sh asn1_deps.pl lib/asn1/CMS.asn1 cms_asn1 \$\(heimdalsrcdir\)/lib/asn1|
+mkinclude perl_path_wrapper.sh asn1_deps.pl lib/hx509/ocsp.asn1 ocsp_asn1 \$\(heimdalsrcdir\)/lib/hx509 --preserve-binary=OCSPTBSRequest --preserve-binary=OCSPResponseData|
+mkinclude perl_path_wrapper.sh asn1_deps.pl lib/asn1/kx509.asn1 kx509_asn1 \$\(heimdalsrcdir\)/lib/asn1|
+mkinclude perl_path_wrapper.sh asn1_deps.pl lib/hx509/pkcs10.asn1 pkcs10_asn1 \$\(heimdalsrcdir\)/lib/hx509 --preserve-binary=CertificationRequestInfo|
#
# Ensure to update ./static_deps.mk when you add a new entry here!
#
-mkinclude perl_path_wrapper.sh et_deps.pl heimdal/lib/asn1/asn1_err.et heimdal/lib/asn1|
-mkinclude perl_path_wrapper.sh et_deps.pl heimdal/lib/hdb/hdb_err.et heimdal/lib/hdb|
-mkinclude perl_path_wrapper.sh et_deps.pl heimdal/lib/krb5/heim_err.et heimdal/lib/krb5|
-mkinclude perl_path_wrapper.sh et_deps.pl heimdal/lib/krb5/k524_err.et heimdal/lib/krb5|
-mkinclude perl_path_wrapper.sh et_deps.pl heimdal/lib/krb5/krb_err.et heimdal/lib/krb5|
-mkinclude perl_path_wrapper.sh et_deps.pl heimdal/lib/krb5/krb5_err.et heimdal/lib/krb5|
-mkinclude perl_path_wrapper.sh et_deps.pl heimdal/lib/gssapi/krb5/gkrb5_err.et heimdal/lib/gssapi|
-mkinclude perl_path_wrapper.sh et_deps.pl heimdal/lib/hx509/hx509_err.et heimdal/lib/hx509|
-mkinclude perl_path_wrapper.sh et_deps.pl heimdal/lib/wind/wind_err.et heimdal/lib/wind|
+mkinclude perl_path_wrapper.sh et_deps.pl lib/asn1/asn1_err.et \$\(heimdalsrcdir\)/lib/asn1|
+mkinclude perl_path_wrapper.sh et_deps.pl lib/hdb/hdb_err.et \$\(heimdalsrcdir\)/lib/hdb|
+mkinclude perl_path_wrapper.sh et_deps.pl lib/krb5/heim_err.et \$\(heimdalsrcdir\)/lib/krb5|
+mkinclude perl_path_wrapper.sh et_deps.pl lib/krb5/k524_err.et \$\(heimdalsrcdir\)/lib/krb5|
+mkinclude perl_path_wrapper.sh et_deps.pl lib/krb5/krb_err.et \$\(heimdalsrcdir\)/lib/krb5|
+mkinclude perl_path_wrapper.sh et_deps.pl lib/krb5/krb5_err.et \$\(heimdalsrcdir\)/lib/krb5|
+mkinclude perl_path_wrapper.sh et_deps.pl lib/gssapi/krb5/gkrb5_err.et \$\(heimdalsrcdir\)/lib/gssapi|
+mkinclude perl_path_wrapper.sh et_deps.pl lib/hx509/hx509_err.et \$\(heimdalsrcdir\)/lib/hx509|
+mkinclude perl_path_wrapper.sh et_deps.pl lib/wind/wind_err.et \$\(heimdalsrcdir\)/lib/wind|
clean::
@-rm -f bin/compile_et bin/asn1_compile
@@ -591,7 +598,7 @@ clean::
#######################
# Start SUBSYSTEM HEIMDAL
[SUBSYSTEM::HEIMDAL]
-CFLAGS = -Iheimdal_build
+CFLAGS = -I$(heimdalbuildsrcdir)
PUBLIC_DEPENDENCIES = \
HEIMDAL_GSSAPI HEIMDAL_KRB5
# End SUBSYSTEM HEIMDAL
@@ -602,7 +609,6 @@ HEIMDAL_OBJ_FILES = $(heimdalsrcdir)/lib/vers/print_version.o
#######################
# Start BINARY compile_et
[BINARY::samba4kinit]
-CFLAGS = -Iheimdal_build -Iheimdal/lib/roken
PRIVATE_DEPENDENCIES = HEIMDAL_KRB5 HEIMDAL_NTLM
# End BINARY compile_et
#######################
@@ -612,5 +618,7 @@ samba4kinit_OBJ_FILES = $(heimdalsrcdir)/kuser/kinit.o \
$(heimdalsrcdir)/lib/roken/setprogname.o \
$(heimdalsrcdir)/lib/roken/getarg.o
+$(samba4kinit_OBJ_FILES): CFLAGS+=-I$(heimdalbuildsrcdir) -I$(heimdalsrcdir)/lib/roken
+
dist:: $(heimdalsrcdir)/lib/asn1/lex.c $(heimdalsrcdir)/lib/com_err/lex.c \
$(heimdalsrcdir)/lib/asn1/parse.c $(heimdalsrcdir)/lib/com_err/parse.c
diff --git a/source4/heimdal_build/et_compile_wrapper.sh b/source4/heimdal_build/et_compile_wrapper.sh
index d7d47ba363..ec3b39ff56 100755
--- a/source4/heimdal_build/et_compile_wrapper.sh
+++ b/source4/heimdal_build/et_compile_wrapper.sh
@@ -4,19 +4,13 @@
SELF=$0
SELFDIR=`dirname ${SELF}`
-SRCDIR=$1
-BUILDDIR=$2
-DESTDIR=$3
+BUILDDIR=$1
+DESTDIR=$2
-CMD=$4
-FILE=$5
-SOURCE=$6
-shift 6
-
-test -z "${SRCDIR}" && {
- echo "${SELF}:SRCDIR: '${SRCDIR}'" >&2;
- exit 1;
-}
+CMD=$3
+FILE=$4
+SOURCE=$5
+shift 5
test -z "${BUILDDIR}" && {
echo "${SELF}:BUILDDIR: '${BUILDDIR}'" >&2;
@@ -45,14 +39,6 @@ test -z "${SOURCE}" && {
CURDIR=`pwd`
-cd ${SRCDIR} && {
- ABS_SRCDIR=`pwd`
- cd ${CURDIR}
-} || {
- echo "${SELF}:cannot cd into '${SRCDIR}'" >&2;
- exit 1;
-}
-
cd ${BUILDDIR} && {
ABS_BUILDDIR=`pwd`
cd ${CURDIR}
@@ -62,7 +48,7 @@ cd ${BUILDDIR} && {
}
cd ${DESTDIR} && {
- ${ABS_BUILDDIR}/${CMD} ${ABS_SRCDIR}/${FILE} >&2 || exit 1;
+ ${ABS_BUILDDIR}/${CMD} ${FILE} >&2 || exit 1;
cd ${CURDIR}
TMP="${SOURCE}.$$"
mv ${SOURCE} ${TMP} && {
diff --git a/source4/heimdal_build/et_deps.pl b/source4/heimdal_build/et_deps.pl
index 2385dbd085..6a0485bb54 100755
--- a/source4/heimdal_build/et_deps.pl
+++ b/source4/heimdal_build/et_deps.pl
@@ -8,9 +8,9 @@ my $basename = basename($file);
my $header = "$dirname/$basename"; $header =~ s/\.et$/.h/;
my $source = "$dirname/$basename"; $source =~ s/\.et$/.c/;
-print "$header $source: $file bin/compile_et\n";
+print "$header $source: \$(heimdalsrcdir)/$file \$(ET_COMPILER)\n";
print "\t\@echo \"Compiling error table $file\"\n";
-print "\t\@\$(builddir)/heimdal_build/et_compile_wrapper.sh \$(srcdir) \$(builddir) $dirname bin/compile_et $file $source\n\n";
+print "\t\@\$(heimdalbuildsrcdir)/et_compile_wrapper.sh \$(builddir) $dirname \$(ET_COMPILER) \$(abspath \$(heimdalsrcdir)/$file) $source\n\n";
print "clean:: \n";
print "\t\@rm -f $header $source\n\n";
diff --git a/source4/lib/charset/util_unistr.c b/source4/lib/charset/util_unistr.c
index c496c5d905..19a4f3236c 100644
--- a/source4/lib/charset/util_unistr.c
+++ b/source4/lib/charset/util_unistr.c
@@ -20,7 +20,7 @@
#include "includes.h"
#include "system/locale.h"
-#include "dynconfig.h"
+#include "dynconfig/dynconfig.h"
#include "param/param.h"
/**
diff --git a/source4/lib/cmdline/popt_common.c b/source4/lib/cmdline/popt_common.c
index 73b3eecfbf..96d8b8b40a 100644
--- a/source4/lib/cmdline/popt_common.c
+++ b/source4/lib/cmdline/popt_common.c
@@ -23,7 +23,7 @@
#include "version.h"
#include "lib/cmdline/popt_common.h"
#include "param/param.h"
-#include "dynconfig.h"
+#include "dynconfig/dynconfig.h"
/* Handle command line options:
* -d,--debuglevel
diff --git a/source4/lib/events/events.i b/source4/lib/events/events.i
index c16d482efc..5f790aeac5 100644
--- a/source4/lib/events/events.i
+++ b/source4/lib/events/events.i
@@ -16,7 +16,7 @@
along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
-%module(package="samba.events") events;
+%module(docstring="Event management.",package="samba.events") events;
%import "../talloc/talloc.i";
@@ -27,8 +27,11 @@ typedef struct event_context event;
typedef struct event_context {
%extend {
+ %feature("docstring") event "S.__init__()";
event(TALLOC_CTX *mem_ctx) { return event_context_init(mem_ctx); }
+ %feature("docstring") loop_once "S.loop_once() -> int";
int loop_once(void);
+ %feature("docstring") loop_wait "S.loop_wait() -> int";
int loop_wait(void);
}
} event;
@@ -44,6 +47,8 @@ typedef struct event_context {
struct event_context *event_context_init_byname(TALLOC_CTX *mem_ctx, const char *name);
+%feature("docstring") event_backend_list "event_backend_list() -> list";
const char **event_backend_list(TALLOC_CTX *mem_ctx);
+%feature("docstring") event_set_default_backend "event_set_default_backend(name) -> None";
%rename(set_default_backend) event_set_default_backend;
void event_set_default_backend(const char *backend);
diff --git a/source4/lib/events/events.py b/source4/lib/events/events.py
index 237726897d..90695e3d92 100644
--- a/source4/lib/events/events.py
+++ b/source4/lib/events/events.py
@@ -3,6 +3,10 @@
#
# Don't modify this file, modify the SWIG interface instead.
+"""
+Event management.
+"""
+
import _events
import new
new_instancemethod = new.instancemethod
@@ -61,7 +65,16 @@ class event(object):
thisown = _swig_property(lambda x: x.this.own(), lambda x, v: x.this.own(v), doc='The membership flag')
__repr__ = _swig_repr
def __init__(self, *args, **kwargs):
+ """S.__init__()"""
_events.event_swiginit(self,_events.new_event(*args, **kwargs))
+ def loop_once(*args, **kwargs):
+ """S.loop_once() -> int"""
+ return _events.event_loop_once(*args, **kwargs)
+
+ def loop_wait(*args, **kwargs):
+ """S.loop_wait() -> int"""
+ return _events.event_loop_wait(*args, **kwargs)
+
__swig_destroy__ = _events.delete_event
event.loop_once = new_instancemethod(_events.event_loop_once,None,event)
event.loop_wait = new_instancemethod(_events.event_loop_wait,None,event)
@@ -69,7 +82,13 @@ event_swigregister = _events.event_swigregister
event_swigregister(event)
event_context_init_byname = _events.event_context_init_byname
-event_backend_list = _events.event_backend_list
-set_default_backend = _events.set_default_backend
+
+def event_backend_list(*args):
+ """event_backend_list() -> list"""
+ return _events.event_backend_list(*args)
+
+def set_default_backend(*args, **kwargs):
+ """event_set_default_backend(name) -> None"""
+ return _events.set_default_backend(*args, **kwargs)
diff --git a/source4/lib/events/events_wrap.c b/source4/lib/events/events_wrap.c
index 727485dfdb..ccaeab7ad6 100644
--- a/source4/lib/events/events_wrap.c
+++ b/source4/lib/events/events_wrap.c
@@ -2773,15 +2773,15 @@ fail:
static PyMethodDef SwigMethods[] = {
- { (char *)"new_event", (PyCFunction)_wrap_new_event, METH_NOARGS, NULL},
- { (char *)"event_loop_once", (PyCFunction)_wrap_event_loop_once, METH_O, NULL},
- { (char *)"event_loop_wait", (PyCFunction)_wrap_event_loop_wait, METH_O, NULL},
+ { (char *)"new_event", (PyCFunction)_wrap_new_event, METH_NOARGS, (char *)"S.__init__()"},
+ { (char *)"event_loop_once", (PyCFunction)_wrap_event_loop_once, METH_O, (char *)"S.loop_once() -> int"},
+ { (char *)"event_loop_wait", (PyCFunction)_wrap_event_loop_wait, METH_O, (char *)"S.loop_wait() -> int"},
{ (char *)"delete_event", (PyCFunction)_wrap_delete_event, METH_O, NULL},
{ (char *)"event_swigregister", event_swigregister, METH_VARARGS, NULL},
{ (char *)"event_swiginit", event_swiginit, METH_VARARGS, NULL},
{ (char *)"event_context_init_byname", (PyCFunction) _wrap_event_context_init_byname, METH_VARARGS | METH_KEYWORDS, NULL},
- { (char *)"event_backend_list", (PyCFunction)_wrap_event_backend_list, METH_NOARGS, NULL},
- { (char *)"set_default_backend", (PyCFunction) _wrap_set_default_backend, METH_VARARGS | METH_KEYWORDS, NULL},
+ { (char *)"event_backend_list", (PyCFunction)_wrap_event_backend_list, METH_NOARGS, (char *)"event_backend_list() -> list"},
+ { (char *)"set_default_backend", (PyCFunction) _wrap_set_default_backend, METH_VARARGS | METH_KEYWORDS, (char *)"event_set_default_backend(name) -> None"},
{ NULL, NULL, 0, NULL }
};
diff --git a/source4/lib/ldb/config.mk b/source4/lib/ldb/config.mk
index e8852980f6..cc8f1e36ab 100644
--- a/source4/lib/ldb/config.mk
+++ b/source4/lib/ldb/config.mk
@@ -2,11 +2,11 @@
# Start MODULE ldb_asq
[MODULE::ldb_asq]
PRIVATE_DEPENDENCIES = LIBTALLOC
-CFLAGS = -Ilib/ldb/include
+CFLAGS = -I$(ldbdir)/include
INIT_FUNCTION = LDB_MODULE(asq)
SUBSYSTEM = LIBLDB
-ldb_asq_OBJ_FILES = lib/ldb/modules/asq.o
+ldb_asq_OBJ_FILES = $(ldbdir)/modules/asq.o
# End MODULE ldb_asq
################################################
@@ -14,106 +14,106 @@ ldb_asq_OBJ_FILES = lib/ldb/modules/asq.o
# Start MODULE ldb_server_sort
[MODULE::ldb_server_sort]
PRIVATE_DEPENDENCIES = LIBTALLOC
-CFLAGS = -Ilib/ldb/include
+CFLAGS = -I$(ldbdir)/include
INIT_FUNCTION = LDB_MODULE(server_sort)
SUBSYSTEM = LIBLDB
# End MODULE ldb_sort
################################################
-ldb_server_sort_OBJ_FILES = lib/ldb/modules/sort.o
+ldb_server_sort_OBJ_FILES = $(ldbdir)/modules/sort.o
################################################
# Start MODULE ldb_paged_results
[MODULE::ldb_paged_results]
INIT_FUNCTION = LDB_MODULE(paged_results)
-CFLAGS = -Ilib/ldb/include
+CFLAGS = -I$(ldbdir)/include
PRIVATE_DEPENDENCIES = LIBTALLOC
SUBSYSTEM = LIBLDB
# End MODULE ldb_paged_results
################################################
-ldb_paged_results_OBJ_FILES = lib/ldb/modules/paged_results.o
+ldb_paged_results_OBJ_FILES = $(ldbdir)/modules/paged_results.o
################################################
# Start MODULE ldb_paged_results
[MODULE::ldb_paged_searches]
INIT_FUNCTION = LDB_MODULE(paged_searches)
-CFLAGS = -Ilib/ldb/include
+CFLAGS = -I$(ldbdir)/include
PRIVATE_DEPENDENCIES = LIBTALLOC
SUBSYSTEM = LIBLDB
# End MODULE ldb_paged_results
################################################
-ldb_paged_searches_OBJ_FILES = lib/ldb/modules/paged_searches.o
+ldb_paged_searches_OBJ_FILES = $(ldbdir)/modules/paged_searches.o
################################################
# Start MODULE ldb_operational
[MODULE::ldb_operational]
SUBSYSTEM = LIBLDB
-CFLAGS = -Ilib/ldb/include
+CFLAGS = -I$(ldbdir)/include
PRIVATE_DEPENDENCIES = LIBTALLOC
INIT_FUNCTION = LDB_MODULE(operational)
# End MODULE ldb_operational
################################################
-ldb_operational_OBJ_FILES = lib/ldb/modules/operational.o
+ldb_operational_OBJ_FILES = $(ldbdir)/modules/operational.o
################################################
# Start MODULE ldb_rdn_name
[MODULE::ldb_rdn_name]
SUBSYSTEM = LIBLDB
-CFLAGS = -Ilib/ldb/include
+CFLAGS = -I$(ldbdir)/include
PRIVATE_DEPENDENCIES = LIBTALLOC
INIT_FUNCTION = LDB_MODULE(rdn_name)
# End MODULE ldb_rdn_name
################################################
-ldb_rdn_name_OBJ_FILES = lib/ldb/modules/rdn_name.o
+ldb_rdn_name_OBJ_FILES = $(ldbdir)/modules/rdn_name.o
-ldb_map_OBJ_FILES = $(addprefix lib/ldb/ldb_map/, ldb_map_inbound.o ldb_map_outbound.o ldb_map.o)
+ldb_map_OBJ_FILES = $(addprefix $(ldbdir)/ldb_map/, ldb_map_inbound.o ldb_map_outbound.o ldb_map.o)
-$(ldb_map_OBJ_FILES): CFLAGS+=-Ilib/ldb/ldb_map
+$(ldb_map_OBJ_FILES): CFLAGS+=-I$(ldbdir)/ldb_map
################################################
# Start MODULE ldb_skel
[MODULE::ldb_skel]
SUBSYSTEM = LIBLDB
-CFLAGS = -Ilib/ldb/include
+CFLAGS = -I$(ldbdir)/include
PRIVATE_DEPENDENCIES = LIBTALLOC
INIT_FUNCTION = LDB_MODULE(skel)
# End MODULE ldb_skel
################################################
-ldb_skel_OBJ_FILES = lib/ldb/modules/skel.o
+ldb_skel_OBJ_FILES = $(ldbdir)/modules/skel.o
################################################
# Start MODULE ldb_sqlite3
[MODULE::ldb_sqlite3]
SUBSYSTEM = LIBLDB
-CFLAGS = -Ilib/ldb/include
+CFLAGS = -I$(ldbdir)/include
PRIVATE_DEPENDENCIES = LIBTALLOC SQLITE3 LIBTALLOC
# End MODULE ldb_sqlite3
################################################
-ldb_sqlite3_OBJ_FILES = lib/ldb/ldb_sqlite3/ldb_sqlite3.o
+ldb_sqlite3_OBJ_FILES = $(ldbdir)/ldb_sqlite3/ldb_sqlite3.o
################################################
# Start MODULE ldb_tdb
[MODULE::ldb_tdb]
SUBSYSTEM = LIBLDB
-CFLAGS = -Ilib/ldb/include -Ilib/ldb/ldb_tdb
+CFLAGS = -I$(ldbdir)/include -I$(ldbdir)/ldb_tdb
PRIVATE_DEPENDENCIES = \
LIBTDB LIBTALLOC
# End MODULE ldb_tdb
################################################
-ldb_tdb_OBJ_FILES = $(addprefix lib/ldb/ldb_tdb/, ldb_tdb.o ldb_search.o ldb_pack.o ldb_index.o ldb_cache.o ldb_tdb_wrap.o)
+ldb_tdb_OBJ_FILES = $(addprefix $(ldbdir)/ldb_tdb/, ldb_tdb.o ldb_search.o ldb_pack.o ldb_index.o ldb_cache.o ldb_tdb_wrap.o)
################################################
# Start SUBSYSTEM ldb
[LIBRARY::LIBLDB]
-CFLAGS = -Ilib/ldb/include
+CFLAGS = -I$(ldbdir)/include
INIT_FUNCTION_TYPE = extern const struct ldb_module_ops
PUBLIC_DEPENDENCIES = \
LIBTALLOC
@@ -128,7 +128,9 @@ PC_FILES += $(ldbdir)/ldb.pc
LIBLDB_VERSION = 0.0.1
LIBLDB_SOVERSION = 0
-LIBLDB_OBJ_FILES = $(addprefix lib/ldb/common/, ldb.o ldb_ldif.o ldb_parse.o ldb_msg.o ldb_utf8.o ldb_debug.o ldb_modules.o ldb_match.o ldb_attributes.o attrib_handlers.o ldb_dn.o ldb_controls.o qsort.o) $(ldb_map_OBJ_FILES)
+LIBLDB_OBJ_FILES = $(addprefix $(ldbdir)/common/, ldb.o ldb_ldif.o ldb_parse.o ldb_msg.o ldb_utf8.o ldb_debug.o ldb_modules.o ldb_match.o ldb_attributes.o attrib_handlers.o ldb_dn.o ldb_controls.o qsort.o) $(ldb_map_OBJ_FILES)
+
+$(LIBLDB_OBJ_FILES): CFLAGS+=-I$(ldbdir)/include
PUBLIC_HEADERS += $(ldbdir)/include/ldb.h $(ldbdir)/include/ldb_errors.h
@@ -142,7 +144,7 @@ PRIVATE_DEPENDENCIES = \
# End BINARY ldbtest
################################################
-ldbtest_OBJ_FILES = lib/ldb/tools/ldbtest.o
+ldbtest_OBJ_FILES = $(ldbdir)/tools/ldbtest.o
################################################
# Start BINARY oLschema2ldif
@@ -154,7 +156,7 @@ PRIVATE_DEPENDENCIES = \
################################################
-oLschema2ldif_OBJ_FILES = $(addprefix lib/ldb/tools/, convert.o oLschema2ldif.o)
+oLschema2ldif_OBJ_FILES = $(addprefix $(ldbdir)/tools/, convert.o oLschema2ldif.o)
MANPAGES += $(ldbdir)/man/oLschema2ldif.1
@@ -167,7 +169,7 @@ PRIVATE_DEPENDENCIES = \
# End BINARY ad2oLschema
################################################
-ad2oLschema_OBJ_FILES = $(addprefix lib/ldb/tools/, convert.o ad2oLschema.o)
+ad2oLschema_OBJ_FILES = $(addprefix $(ldbdir)/tools/, convert.o ad2oLschema.o)
MANPAGES += $(ldbdir)/man/ad2oLschema.1
diff --git a/source4/lib/ldb/ldb.i b/source4/lib/ldb/ldb.i
index 18e981f7be..061d13a2dd 100644
--- a/source4/lib/ldb/ldb.i
+++ b/source4/lib/ldb/ldb.i
@@ -25,7 +25,11 @@
License along with this library; if not, see <http://www.gnu.org/licenses/>.
*/
-%module ldb
+%define DOCSTRING
+"An interface to LDB, a LDAP-like API that can either to talk an embedded database (TDB-based) or a standards-compliant LDAP server."
+%enddef
+
+%module(docstring=DOCSTRING) ldb
%{
@@ -40,7 +44,7 @@ typedef struct ldb_message ldb_msg;
typedef struct ldb_context ldb;
typedef struct ldb_dn ldb_dn;
typedef struct ldb_ldif ldb_ldif;
-typedef struct ldb_message_element ldb_msg_element;
+typedef struct ldb_message_element ldb_message_element;
typedef int ldb_error;
typedef int ldb_int_error;
@@ -194,8 +198,11 @@ PyObject *ldb_val_to_py_object(struct ldb_context *ldb_ctx,
%rename(__cmp__) ldb_dn::compare;
%rename(__len__) ldb_dn::get_comp_num;
%rename(Dn) ldb_dn;
+%feature("docstring") ldb_dn "A LDB distinguished name.";
typedef struct ldb_dn {
%extend {
+ %feature("docstring") ldb_dn "S.__init__(ldb, string)\n" \
+ "Create a new DN.";
ldb_dn(ldb *ldb_ctx, const char *str)
{
ldb_dn *ret = ldb_dn_new(ldb_ctx, ldb_ctx, str);
@@ -210,21 +217,37 @@ fail:
return ret;
}
~ldb_dn() { talloc_free($self); }
+ %feature("docstring") validate "S.validate() -> bool\n" \
+ "Validate DN is correct.";
bool validate();
const char *get_casefold();
const char *get_linearized();
+ %feature("docstring") parent "S.parent() -> dn\n" \
+ "Get the parent for this DN.";
ldb_dn *parent() { return ldb_dn_get_parent(NULL, $self); }
int compare(ldb_dn *other);
bool is_valid();
+ %feature("docstring") is_special "S.is_special() -> bool\n" \
+ "Check whether this is a special LDB DN.";
bool is_special();
+ %feature("docstring") is_null "S.is_null() -> bool\n" \
+ "Check whether this is a null DN.";
bool is_null();
bool check_special(const char *name);
int get_comp_num();
+ %feature("docstring") add_child "S.add_child(dn) -> None\n" \
+ "Add a child DN to this DN.";
bool add_child(ldb_dn *child);
+ %feature("docstring") add_base "S.add_base(dn) -> None\n" \
+ "Add a base DN to this DN.";
bool add_base(ldb_dn *base);
+ %feature("docstring") canonical_str "S.canonical_str() -> string\n" \
+ "Canonical version of this DN (like a posix path).";
const char *canonical_str() {
return ldb_dn_canonical_string($self, $self);
}
+ %feature("docstring") canonical_ex_str "S.canonical_ex_str() -> string\n" \
+ "Canonical version of this DN (like a posix path, with terminating newline).";
const char *canonical_ex_str() {
return ldb_dn_canonical_ex_string($self, $self);
}
@@ -289,7 +312,7 @@ int ldb_dn_from_pyobject(TALLOC_CTX *mem_ctx, PyObject *object,
return ret;
}
-ldb_msg_element *ldb_msg_element_from_pyobject(TALLOC_CTX *mem_ctx,
+ldb_message_element *ldb_msg_element_from_pyobject(TALLOC_CTX *mem_ctx,
PyObject *set_obj, int flags,
const char *attr_name)
{
@@ -320,7 +343,7 @@ ldb_msg_element *ldb_msg_element_from_pyobject(TALLOC_CTX *mem_ctx,
}
PyObject *ldb_msg_element_to_set(struct ldb_context *ldb_ctx,
- ldb_msg_element *me)
+ ldb_message_element *me)
{
int i;
PyObject *result;
@@ -340,11 +363,16 @@ PyObject *ldb_msg_element_to_set(struct ldb_context *ldb_ctx,
#endif
/* ldb_message_element */
-%rename(__cmp__) ldb_message_element::compare;
-%rename(MessageElement) ldb_msg_element;
+%rename(MessageElement) ldb_message_element;
+%feature("docstring") ldb_message_element "Message element.";
typedef struct ldb_message_element {
%extend {
#ifdef SWIGPYTHON
+ int __cmp__(ldb_message_element *other)
+ {
+ return ldb_msg_element_compare($self, other);
+ }
+
PyObject *__iter__(void)
{
return PyObject_GetIter(ldb_msg_element_to_set(NULL, $self));
@@ -355,7 +383,7 @@ typedef struct ldb_message_element {
return ldb_msg_element_to_set(NULL, $self);
}
- ldb_msg_element(PyObject *set_obj, int flags=0, const char *name = NULL)
+ ldb_message_element(PyObject *set_obj, int flags=0, const char *name = NULL)
{
return ldb_msg_element_from_pyobject(NULL, set_obj, flags, name);
}
@@ -374,8 +402,7 @@ typedef struct ldb_message_element {
return ldb_val_to_py_object(NULL, $self, &$self->values[i]);
}
- ~ldb_msg_element() { talloc_free($self); }
- int compare(ldb_msg_element *);
+ ~ldb_message_element() { talloc_free($self); }
}
%pythoncode {
def __getitem__(self, i):
@@ -398,21 +425,20 @@ typedef struct ldb_message_element {
return False
return True
}
-} ldb_msg_element;
+} ldb_message_element;
/* ldb_message */
+%feature("docstring") ldb_message "Message.";
%rename(Message) ldb_message;
#ifdef SWIGPYTHON
%rename(__delitem__) ldb_message::remove_attr;
-%typemap(out) ldb_msg_element * {
+%typemap(out) ldb_message_element * {
if ($1 == NULL)
PyErr_SetString(PyExc_KeyError, "no such element");
else
$result = SWIG_NewPointerObj($1, SWIGTYPE_p_ldb_message_element, 0);
}
-//%typemap(out) ldb_msg_element *;
-
%inline {
PyObject *ldb_msg_list_elements(ldb_msg *msg)
@@ -443,10 +469,10 @@ typedef struct ldb_message {
return ret;
}
~ldb_msg() { talloc_free($self); }
- ldb_msg_element *find_element(const char *name);
+ ldb_message_element *find_element(const char *name);
#ifdef SWIGPYTHON
- void __setitem__(const char *attr_name, ldb_msg_element *val)
+ void __setitem__(const char *attr_name, ldb_message_element *val)
{
struct ldb_message_element *el;
@@ -600,6 +626,7 @@ PyObject *PyExc_LdbError;
}
%rename(Ldb) ldb_context;
+%feature("docstring") ldb_context "Connection to a LDB database.";
%typemap(in,noblock=1) struct ldb_dn * {
if (ldb_dn_from_pyobject(NULL, $input, arg1, &$1) != 0) {
@@ -613,7 +640,7 @@ PyObject *PyExc_LdbError;
%typemap(in,numinputs=1) ldb_msg *add_msg {
Py_ssize_t dict_pos, msg_pos;
- ldb_msg_element *msgel;
+ ldb_message_element *msgel;
PyObject *key, *value;
if (PyDict_Check($input)) {
@@ -660,6 +687,8 @@ typedef struct ldb_context {
%extend {
ldb(void) { return ldb_init(NULL); }
+ %feature("docstring") connect "S.connect(url,flags=0,options=None) -> None\n" \
+ "Connect to a LDB URL.";
ldb_error connect(const char *url, unsigned int flags = 0,
const char *options[] = NULL);
@@ -707,11 +736,19 @@ typedef struct ldb_context {
return ret;
}
+ %feature("docstring") delete "S.delete(dn) -> None\n" \
+ "Remove an entry.";
ldb_error delete(ldb_dn *dn);
+ %feature("docstring") rename "S.rename(old_dn, new_dn) -> None\n" \
+ "Rename an entry.";
ldb_error rename(ldb_dn *olddn, ldb_dn *newdn);
struct ldb_control **parse_control_strings(TALLOC_CTX *mem_ctx,
const char * const*control_strings);
+ %feature("docstring") add "S.add(message) -> None\n" \
+ "Add an entry.";
ldb_error add(ldb_msg *add_msg);
+ %feature("docstring") modify "S.modify(message) -> None\n" \
+ "Modify an entry.";
ldb_error modify(ldb_msg *message);
ldb_dn *get_config_basedn();
ldb_dn *get_root_basedn();
@@ -747,20 +784,39 @@ typedef struct ldb_context {
}
const char *errstring();
+ %feature("docstring") set_create_perms "S.set_create_perms(mode) -> None\n" \
+ "Set mode to use when creating new LDB files.";
void set_create_perms(unsigned int perms);
+ %feature("docstring") set_modules_dir "S.set_modules_dir(path) -> None\n" \
+ "Set path LDB should search for modules";
void set_modules_dir(const char *path);
+ %feature("docstring") set_debug "S.set_debug(callback) -> None\n" \
+ "Set callback for LDB debug messages.\n" \
+ "The callback should accept a debug level and debug text.";
ldb_error set_debug(void (*debug)(void *context, enum ldb_debug_level level,
const char *fmt, va_list ap),
void *context);
+ %feature("docstring") set_opaque "S.set_opaque(name, value) -> None\n" \
+ "Set an opaque value on this LDB connection. \n"
+ ":note: Passing incorrect values may cause crashes.";
ldb_error set_opaque(const char *name, void *value);
+ %feature("docstring") get_opaque "S.get_opaque(name) -> value\n" \
+ "Get an opaque value set on this LDB connection. \n"
+ ":note: The returned value may not be useful in Python.";
void *get_opaque(const char *name);
+ %feature("docstring") transaction_start "S.transaction_start() -> None\n" \
+ "Start a new transaction.";
ldb_error transaction_start();
+ %feature("docstring") transaction_commit "S.transaction_commit() -> None\n" \
+ "Commit currently active transaction.";
ldb_error transaction_commit();
+ %feature("docstring") transaction_cancel "S.transaction_cancel() -> None\n" \
+ "Cancel currently active transaction.";
ldb_error transaction_cancel();
void schema_attribute_remove(const char *name);
ldb_error schema_attribute_add(const char *attribute, unsigned flags, const char *syntax);
- ldb_error setup_wellknown_attributes(void);
-
+ ldb_error setup_wellknown_attributes(void);
+
#ifdef SWIGPYTHON
%typemap(in,numinputs=0,noblock=1) struct ldb_result **result_as_bool (struct ldb_result *tmp) { $1 = &tmp; }
%typemap(argout,noblock=1) struct ldb_result **result_as_bool { $result = ((*$1)->count > 0)?Py_True:Py_False; }
@@ -771,6 +827,9 @@ typedef struct ldb_context {
result_as_bool);
}
+ %feature("docstring") parse_ldif "S.parse_ldif(ldif) -> iter(messages)\n" \
+ "Parse a string formatted using LDIF.";
+
PyObject *parse_ldif(const char *s)
{
PyObject *list = PyList_New(0);
@@ -791,12 +850,25 @@ typedef struct ldb_context {
}
%pythoncode {
def __init__(self, url=None, flags=0, options=None):
+ """Create a new LDB object.
+
+ Will also connect to the specified URL if one was given.
+ """
_ldb.Ldb_swiginit(self,_ldb.new_Ldb())
if url is not None:
self.connect(url, flags, options)
def search(self, base=None, scope=SCOPE_DEFAULT, expression=None,
attrs=None, controls=None):
+ """Search in a database.
+
+ :param base: Optional base DN to search
+ :param scope: Search scope (SCOPE_BASE, SCOPE_ONELEVEL or SCOPE_SUBTREE)
+ :param expression: Optional search expression
+ :param attrs: Attributes to return (defaults to all)
+ :param controls: Optional list of controls
+ :return: Iterator over Message objects
+ """
if not (attrs is None or isinstance(attrs, list)):
raise TypeError("attributes not a list")
parsed_controls = None
@@ -816,10 +888,15 @@ typedef struct ldb_context {
%nodefault Dn;
%rename(valid_attr_name) ldb_valid_attr_name;
+%feature("docstring") ldb_valid_attr_name "S.valid_attr_name(name) -> bool\n"
+ "Check whether the supplied name is a valid attribute name.";
int ldb_valid_attr_name(const char *s);
typedef unsigned long time_t;
+%feature("docstring") timestring "S.timestring(int) -> string\n"
+ "Generate a LDAP time string from a UNIX timestamp";
+
%inline %{
static char *timestring(time_t t)
{
@@ -831,6 +908,8 @@ static char *timestring(time_t t)
%}
%rename(string_to_time) ldb_string_to_time;
+%feature("docstring") ldb_string_to_time "S.string_to_time(string) -> int\n"
+ "Parse a LDAP time string into a UNIX timestamp.";
time_t ldb_string_to_time(const char *s);
%typemap(in,noblock=1) const struct ldb_module_ops * {
@@ -839,5 +918,11 @@ time_t ldb_string_to_time(const char *s);
$1->name = (char *)PyObject_GetAttrString($input, (char *)"name");
}
+%feature("docstring") ldb_register_module "S.register_module(module) -> None\n"
+ "Register a LDB module.";
%rename(register_module) ldb_register_module;
ldb_int_error ldb_register_module(const struct ldb_module_ops *);
+
+%pythoncode {
+__docformat__ = "restructuredText"
+}
diff --git a/source4/lib/ldb/ldb.py b/source4/lib/ldb/ldb.py
index e9f4055fbf..ae2c187367 100644
--- a/source4/lib/ldb/ldb.py
+++ b/source4/lib/ldb/ldb.py
@@ -3,6 +3,10 @@
#
# Don't modify this file, modify the SWIG interface instead.
+"""
+An interface to LDB, a LDAP-like API that can either to talk an embedded database (TDB-based) or a standards-compliant LDAP server.
+"""
+
import _ldb
import new
new_instancemethod = new.instancemethod
@@ -67,10 +71,71 @@ CHANGETYPE_DELETE = _ldb.CHANGETYPE_DELETE
CHANGETYPE_MODIFY = _ldb.CHANGETYPE_MODIFY
ldb_val_to_py_object = _ldb.ldb_val_to_py_object
class Dn(object):
+ """A LDB distinguished name."""
thisown = _swig_property(lambda x: x.this.own(), lambda x, v: x.this.own(v), doc='The membership flag')
def __init__(self, *args, **kwargs):
+ """
+ S.__init__(ldb, string)
+ Create a new DN.
+ """
_ldb.Dn_swiginit(self,_ldb.new_Dn(*args, **kwargs))
__swig_destroy__ = _ldb.delete_Dn
+ def validate(*args, **kwargs):
+ """
+ S.validate() -> bool
+ Validate DN is correct.
+ """
+ return _ldb.Dn_validate(*args, **kwargs)
+
+ def parent(*args, **kwargs):
+ """
+ S.parent() -> dn
+ Get the parent for this DN.
+ """
+ return _ldb.Dn_parent(*args, **kwargs)
+
+ def is_special(*args, **kwargs):
+ """
+ S.is_special() -> bool
+ Check whether this is a special LDB DN.
+ """
+ return _ldb.Dn_is_special(*args, **kwargs)
+
+ def is_null(*args, **kwargs):
+ """
+ S.is_null() -> bool
+ Check whether this is a null DN.
+ """
+ return _ldb.Dn_is_null(*args, **kwargs)
+
+ def add_child(*args, **kwargs):
+ """
+ S.add_child(dn) -> None
+ Add a child DN to this DN.
+ """
+ return _ldb.Dn_add_child(*args, **kwargs)
+
+ def add_base(*args, **kwargs):
+ """
+ S.add_base(dn) -> None
+ Add a base DN to this DN.
+ """
+ return _ldb.Dn_add_base(*args, **kwargs)
+
+ def canonical_str(*args, **kwargs):
+ """
+ S.canonical_str() -> string
+ Canonical version of this DN (like a posix path).
+ """
+ return _ldb.Dn_canonical_str(*args, **kwargs)
+
+ def canonical_ex_str(*args, **kwargs):
+ """
+ S.canonical_ex_str() -> string
+ Canonical version of this DN (like a posix path, with terminating newline).
+ """
+ return _ldb.Dn_canonical_ex_str(*args, **kwargs)
+
def __eq__(self, other):
if isinstance(other, self.__class__):
return self.__cmp__(other) == 0
@@ -97,11 +162,14 @@ Dn.__add__ = new_instancemethod(_ldb.Dn___add__,None,Dn)
Dn_swigregister = _ldb.Dn_swigregister
Dn_swigregister(Dn)
-class ldb_msg_element(object):
+class MessageElement(object):
+ """Message element."""
thisown = _swig_property(lambda x: x.this.own(), lambda x, v: x.this.own(v), doc='The membership flag')
- def __init__(self, *args, **kwargs): raise AttributeError, "No constructor defined"
__repr__ = _swig_repr
- __swig_destroy__ = _ldb.delete_ldb_msg_element
+ def __init__(self, *args, **kwargs):
+ """Message element."""
+ _ldb.MessageElement_swiginit(self,_ldb.new_MessageElement(*args, **kwargs))
+ __swig_destroy__ = _ldb.delete_MessageElement
def __getitem__(self, i):
ret = self.get(i)
if ret is None:
@@ -122,20 +190,17 @@ class ldb_msg_element(object):
return False
return True
-ldb_msg_element.__iter__ = new_instancemethod(_ldb.ldb_msg_element___iter__,None,ldb_msg_element)
-ldb_msg_element.__set__ = new_instancemethod(_ldb.ldb_msg_element___set__,None,ldb_msg_element)
-ldb_msg_element.__len__ = new_instancemethod(_ldb.ldb_msg_element___len__,None,ldb_msg_element)
-ldb_msg_element.get = new_instancemethod(_ldb.ldb_msg_element_get,None,ldb_msg_element)
-ldb_msg_element.__cmp__ = new_instancemethod(_ldb.ldb_msg_element___cmp__,None,ldb_msg_element)
-ldb_msg_element_swigregister = _ldb.ldb_msg_element_swigregister
-ldb_msg_element_swigregister(ldb_msg_element)
-
-def MessageElement(*args, **kwargs):
- val = _ldb.new_MessageElement(*args, **kwargs)
- return val
+MessageElement.__cmp__ = new_instancemethod(_ldb.MessageElement___cmp__,None,MessageElement)
+MessageElement.__iter__ = new_instancemethod(_ldb.MessageElement___iter__,None,MessageElement)
+MessageElement.__set__ = new_instancemethod(_ldb.MessageElement___set__,None,MessageElement)
+MessageElement.__len__ = new_instancemethod(_ldb.MessageElement___len__,None,MessageElement)
+MessageElement.get = new_instancemethod(_ldb.MessageElement_get,None,MessageElement)
+MessageElement_swigregister = _ldb.MessageElement_swigregister
+MessageElement_swigregister(MessageElement)
ldb_msg_list_elements = _ldb.ldb_msg_list_elements
class Message(object):
+ """Message."""
thisown = _swig_property(lambda x: x.this.own(), lambda x, v: x.this.own(v), doc='The membership flag')
__repr__ = _swig_repr
dn = _swig_property(_ldb.Message_dn_get, _ldb.Message_dn_set)
@@ -214,17 +279,132 @@ LDB_ERR_OBJECT_CLASS_MODS_PROHIBITED = _ldb.LDB_ERR_OBJECT_CLASS_MODS_PROHIBITED
LDB_ERR_AFFECTS_MULTIPLE_DSAS = _ldb.LDB_ERR_AFFECTS_MULTIPLE_DSAS
LDB_ERR_OTHER = _ldb.LDB_ERR_OTHER
class Ldb(object):
+ """Connection to a LDB database."""
thisown = _swig_property(lambda x: x.this.own(), lambda x, v: x.this.own(v), doc='The membership flag')
def __init__(self, *args, **kwargs):
_ldb.Ldb_swiginit(self,_ldb.new_Ldb(*args, **kwargs))
+ def connect(*args, **kwargs):
+ """
+ S.connect(url,flags=0,options=None) -> None
+ Connect to a LDB URL.
+ """
+ return _ldb.Ldb_connect(*args, **kwargs)
+
__swig_destroy__ = _ldb.delete_Ldb
+ def delete(*args, **kwargs):
+ """
+ S.delete(dn) -> None
+ Remove an entry.
+ """
+ return _ldb.Ldb_delete(*args, **kwargs)
+
+ def rename(*args, **kwargs):
+ """
+ S.rename(old_dn, new_dn) -> None
+ Rename an entry.
+ """
+ return _ldb.Ldb_rename(*args, **kwargs)
+
+ def add(*args, **kwargs):
+ """
+ S.add(message) -> None
+ Add an entry.
+ """
+ return _ldb.Ldb_add(*args, **kwargs)
+
+ def modify(*args, **kwargs):
+ """
+ S.modify(message) -> None
+ Modify an entry.
+ """
+ return _ldb.Ldb_modify(*args, **kwargs)
+
+ def set_create_perms(*args, **kwargs):
+ """
+ S.set_create_perms(mode) -> None
+ Set mode to use when creating new LDB files.
+ """
+ return _ldb.Ldb_set_create_perms(*args, **kwargs)
+
+ def set_modules_dir(*args, **kwargs):
+ """
+ S.set_modules_dir(path) -> None
+ Set path LDB should search for modules
+ """
+ return _ldb.Ldb_set_modules_dir(*args, **kwargs)
+
+ def set_debug(*args, **kwargs):
+ """
+ S.set_debug(callback) -> None
+ Set callback for LDB debug messages.
+ The callback should accept a debug level and debug text.
+ """
+ return _ldb.Ldb_set_debug(*args, **kwargs)
+
+ def set_opaque(*args, **kwargs):
+ """
+ S.set_opaque(name, value) -> None
+ Set an opaque value on this LDB connection.
+ :note: Passing incorrect values may cause crashes.
+ """
+ return _ldb.Ldb_set_opaque(*args, **kwargs)
+
+ def get_opaque(*args, **kwargs):
+ """
+ S.get_opaque(name) -> value
+ Get an opaque value set on this LDB connection.
+ :note: The returned value may not be useful in Python.
+ """
+ return _ldb.Ldb_get_opaque(*args, **kwargs)
+
+ def transaction_start(*args, **kwargs):
+ """
+ S.transaction_start() -> None
+ Start a new transaction.
+ """
+ return _ldb.Ldb_transaction_start(*args, **kwargs)
+
+ def transaction_commit(*args, **kwargs):
+ """
+ S.transaction_commit() -> None
+ Commit currently active transaction.
+ """
+ return _ldb.Ldb_transaction_commit(*args, **kwargs)
+
+ def transaction_cancel(*args, **kwargs):
+ """
+ S.transaction_cancel() -> None
+ Cancel currently active transaction.
+ """
+ return _ldb.Ldb_transaction_cancel(*args, **kwargs)
+
+ def parse_ldif(*args, **kwargs):
+ """
+ S.parse_ldif(ldif) -> iter(messages)
+ Parse a string formatted using LDIF.
+ """
+ return _ldb.Ldb_parse_ldif(*args, **kwargs)
+
def __init__(self, url=None, flags=0, options=None):
+ """Create a new LDB object.
+
+ Will also connect to the specified URL if one was given.
+ """
_ldb.Ldb_swiginit(self,_ldb.new_Ldb())
if url is not None:
self.connect(url, flags, options)
def search(self, base=None, scope=SCOPE_DEFAULT, expression=None,
attrs=None, controls=None):
+ """Search in a database.
+
+ :param base: Optional base DN to search
+ :param scope: Search scope (SCOPE_BASE, SCOPE_ONELEVEL or SCOPE_SUBTREE)
+ :param expression: Optional search expression
+ :param attrs: Attributes to return (defaults to all)
+ :param controls: Optional list of controls
+ :return: Iterator over Message objects
+ """
if not (attrs is None or isinstance(attrs, list)):
raise TypeError("attributes not a list")
parsed_controls = None
@@ -263,9 +443,35 @@ Ldb.__repr__ = new_instancemethod(_ldb.Ldb___repr__,None,Ldb)
Ldb_swigregister = _ldb.Ldb_swigregister
Ldb_swigregister(Ldb)
-valid_attr_name = _ldb.valid_attr_name
-timestring = _ldb.timestring
-string_to_time = _ldb.string_to_time
-register_module = _ldb.register_module
+
+def valid_attr_name(*args, **kwargs):
+ """
+ S.valid_attr_name(name) -> bool
+ Check whether the supplied name is a valid attribute name.
+ """
+ return _ldb.valid_attr_name(*args, **kwargs)
+
+def timestring(*args, **kwargs):
+ """
+ S.timestring(int) -> string
+ Generate a LDAP time string from a UNIX timestamp
+ """
+ return _ldb.timestring(*args, **kwargs)
+
+def string_to_time(*args, **kwargs):
+ """
+ S.string_to_time(string) -> int
+ Parse a LDAP time string into a UNIX timestamp.
+ """
+ return _ldb.string_to_time(*args, **kwargs)
+
+def register_module(*args, **kwargs):
+ """
+ S.register_module(module) -> None
+ Register a LDB module.
+ """
+ return _ldb.register_module(*args, **kwargs)
+__docformat__ = "restructuredText"
+
diff --git a/source4/lib/ldb/ldb_ildap/config.mk b/source4/lib/ldb/ldb_ildap/config.mk
index 1b534645b6..94e3380038 100644
--- a/source4/lib/ldb/ldb_ildap/config.mk
+++ b/source4/lib/ldb/ldb_ildap/config.mk
@@ -2,12 +2,12 @@
# Start MODULE ldb_ildap
[MODULE::ldb_ildap]
SUBSYSTEM = LIBLDB
-CFLAGS = -Ilib/ldb/include
+CFLAGS = -I$(ldbdir)/include
OUTPUT_TYPE = SHARED_LIBRARY
PRIVATE_DEPENDENCIES = LIBTALLOC LIBCLI_LDAP CREDENTIALS
ALIASES = ldapi ldaps ldap
# End MODULE ldb_ildap
################################################
-ldb_ildap_OBJ_FILES = lib/ldb/ldb_ildap/ldb_ildap.o
+ldb_ildap_OBJ_FILES = $(ldbdir)/ldb_ildap/ldb_ildap.o
diff --git a/source4/lib/ldb/ldb_wrap.c b/source4/lib/ldb/ldb_wrap.c
index d787266416..744033cbf6 100644
--- a/source4/lib/ldb/ldb_wrap.c
+++ b/source4/lib/ldb/ldb_wrap.c
@@ -2554,7 +2554,7 @@ typedef struct ldb_message ldb_msg;
typedef struct ldb_context ldb;
typedef struct ldb_dn ldb_dn;
typedef struct ldb_ldif ldb_ldif;
-typedef struct ldb_message_element ldb_msg_element;
+typedef struct ldb_message_element ldb_message_element;
typedef int ldb_error;
typedef int ldb_int_error;
@@ -2761,7 +2761,7 @@ int ldb_dn_from_pyobject(TALLOC_CTX *mem_ctx, PyObject *object,
return ret;
}
-ldb_msg_element *ldb_msg_element_from_pyobject(TALLOC_CTX *mem_ctx,
+ldb_message_element *ldb_msg_element_from_pyobject(TALLOC_CTX *mem_ctx,
PyObject *set_obj, int flags,
const char *attr_name)
{
@@ -2792,7 +2792,7 @@ ldb_msg_element *ldb_msg_element_from_pyobject(TALLOC_CTX *mem_ctx,
}
PyObject *ldb_msg_element_to_set(struct ldb_context *ldb_ctx,
- ldb_msg_element *me)
+ ldb_message_element *me)
{
int i;
PyObject *result;
@@ -2809,10 +2809,13 @@ PyObject *ldb_msg_element_to_set(struct ldb_context *ldb_ctx,
}
-SWIGINTERN PyObject *ldb_msg_element___iter__(ldb_msg_element *self){
+SWIGINTERN int ldb_message_element___cmp__(ldb_message_element *self,ldb_message_element *other){
+ return ldb_msg_element_compare(self, other);
+ }
+SWIGINTERN PyObject *ldb_message_element___iter__(ldb_message_element *self){
return PyObject_GetIter(ldb_msg_element_to_set(NULL, self));
}
-SWIGINTERN PyObject *ldb_msg_element___set__(ldb_msg_element *self){
+SWIGINTERN PyObject *ldb_message_element___set__(ldb_message_element *self){
return ldb_msg_element_to_set(NULL, self);
}
@@ -2960,19 +2963,19 @@ SWIG_AsVal_int (PyObject * obj, int *val)
return res;
}
-SWIGINTERN ldb_msg_element *new_ldb_msg_element(PyObject *set_obj,int flags,char const *name){
+SWIGINTERN ldb_message_element *new_ldb_message_element(PyObject *set_obj,int flags,char const *name){
return ldb_msg_element_from_pyobject(NULL, set_obj, flags, name);
}
-SWIGINTERN int ldb_msg_element___len__(ldb_msg_element *self){
+SWIGINTERN int ldb_message_element___len__(ldb_message_element *self){
return self->num_values;
}
-SWIGINTERN PyObject *ldb_msg_element_get(ldb_msg_element *self,int i){
+SWIGINTERN PyObject *ldb_message_element_get(ldb_message_element *self,int i){
if (i < 0 || i >= self->num_values)
return Py_None;
return ldb_val_to_py_object(NULL, self, &self->values[i]);
}
-SWIGINTERN void delete_ldb_msg_element(ldb_msg_element *self){ talloc_free(self); }
+SWIGINTERN void delete_ldb_message_element(ldb_message_element *self){ talloc_free(self); }
PyObject *ldb_msg_list_elements(ldb_msg *msg)
{
@@ -2995,7 +2998,7 @@ SWIGINTERN ldb_msg *new_ldb_msg(ldb_dn *dn){
return ret;
}
SWIGINTERN void delete_ldb_msg(ldb_msg *self){ talloc_free(self); }
-SWIGINTERN void ldb_msg___setitem____SWIG_0(ldb_msg *self,char const *attr_name,ldb_msg_element *val){
+SWIGINTERN void ldb_msg___setitem____SWIG_0(ldb_msg *self,char const *attr_name,ldb_message_element *val){
struct ldb_message_element *el;
ldb_msg_remove_attr(self, attr_name);
@@ -3763,9 +3766,43 @@ SWIGINTERN PyObject *Dn_swiginit(PyObject *SWIGUNUSEDPARM(self), PyObject *args)
return SWIG_Python_InitShadowInstance(args);
}
-SWIGINTERN PyObject *_wrap_ldb_msg_element___iter__(PyObject *SWIGUNUSEDPARM(self), PyObject *args) {
+SWIGINTERN PyObject *_wrap_MessageElement___cmp__(PyObject *SWIGUNUSEDPARM(self), PyObject *args, PyObject *kwargs) {
PyObject *resultobj = 0;
- ldb_msg_element *arg1 = (ldb_msg_element *) 0 ;
+ ldb_message_element *arg1 = (ldb_message_element *) 0 ;
+ ldb_message_element *arg2 = (ldb_message_element *) 0 ;
+ int result;
+ void *argp1 = 0 ;
+ int res1 = 0 ;
+ void *argp2 = 0 ;
+ int res2 = 0 ;
+ PyObject * obj0 = 0 ;
+ PyObject * obj1 = 0 ;
+ char * kwnames[] = {
+ (char *) "self",(char *) "other", NULL
+ };
+
+ if (!PyArg_ParseTupleAndKeywords(args,kwargs,(char *)"OO:MessageElement___cmp__",kwnames,&obj0,&obj1)) SWIG_fail;
+ res1 = SWIG_ConvertPtr(obj0, &argp1,SWIGTYPE_p_ldb_message_element, 0 | 0 );
+ if (!SWIG_IsOK(res1)) {
+ SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "MessageElement___cmp__" "', argument " "1"" of type '" "ldb_message_element *""'");
+ }
+ arg1 = (ldb_message_element *)(argp1);
+ res2 = SWIG_ConvertPtr(obj1, &argp2,SWIGTYPE_p_ldb_message_element, 0 | 0 );
+ if (!SWIG_IsOK(res2)) {
+ SWIG_exception_fail(SWIG_ArgError(res2), "in method '" "MessageElement___cmp__" "', argument " "2"" of type '" "ldb_message_element *""'");
+ }
+ arg2 = (ldb_message_element *)(argp2);
+ result = (int)ldb_message_element___cmp__(arg1,arg2);
+ resultobj = SWIG_From_int((int)(result));
+ return resultobj;
+fail:
+ return NULL;
+}
+
+
+SWIGINTERN PyObject *_wrap_MessageElement___iter__(PyObject *SWIGUNUSEDPARM(self), PyObject *args) {
+ PyObject *resultobj = 0;
+ ldb_message_element *arg1 = (ldb_message_element *) 0 ;
PyObject *result = 0 ;
void *argp1 = 0 ;
int res1 = 0 ;
@@ -3775,10 +3812,10 @@ SWIGINTERN PyObject *_wrap_ldb_msg_element___iter__(PyObject *SWIGUNUSEDPARM(sel
swig_obj[0] = args;
res1 = SWIG_ConvertPtr(swig_obj[0], &argp1,SWIGTYPE_p_ldb_message_element, 0 | 0 );
if (!SWIG_IsOK(res1)) {
- SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "ldb_msg_element___iter__" "', argument " "1"" of type '" "ldb_msg_element *""'");
+ SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "MessageElement___iter__" "', argument " "1"" of type '" "ldb_message_element *""'");
}
- arg1 = (ldb_msg_element *)(argp1);
- result = (PyObject *)ldb_msg_element___iter__(arg1);
+ arg1 = (ldb_message_element *)(argp1);
+ result = (PyObject *)ldb_message_element___iter__(arg1);
resultobj = result;
return resultobj;
fail:
@@ -3786,9 +3823,9 @@ fail:
}
-SWIGINTERN PyObject *_wrap_ldb_msg_element___set__(PyObject *SWIGUNUSEDPARM(self), PyObject *args) {
+SWIGINTERN PyObject *_wrap_MessageElement___set__(PyObject *SWIGUNUSEDPARM(self), PyObject *args) {
PyObject *resultobj = 0;
- ldb_msg_element *arg1 = (ldb_msg_element *) 0 ;
+ ldb_message_element *arg1 = (ldb_message_element *) 0 ;
PyObject *result = 0 ;
void *argp1 = 0 ;
int res1 = 0 ;
@@ -3798,10 +3835,10 @@ SWIGINTERN PyObject *_wrap_ldb_msg_element___set__(PyObject *SWIGUNUSEDPARM(self
swig_obj[0] = args;
res1 = SWIG_ConvertPtr(swig_obj[0], &argp1,SWIGTYPE_p_ldb_message_element, 0 | 0 );
if (!SWIG_IsOK(res1)) {
- SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "ldb_msg_element___set__" "', argument " "1"" of type '" "ldb_msg_element *""'");
+ SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "MessageElement___set__" "', argument " "1"" of type '" "ldb_message_element *""'");
}
- arg1 = (ldb_msg_element *)(argp1);
- result = (PyObject *)ldb_msg_element___set__(arg1);
+ arg1 = (ldb_message_element *)(argp1);
+ result = (PyObject *)ldb_message_element___set__(arg1);
resultobj = result;
return resultobj;
fail:
@@ -3814,7 +3851,7 @@ SWIGINTERN PyObject *_wrap_new_MessageElement(PyObject *SWIGUNUSEDPARM(self), Py
PyObject *arg1 = (PyObject *) 0 ;
int arg2 = (int) 0 ;
char *arg3 = (char *) NULL ;
- ldb_msg_element *result = 0 ;
+ ldb_message_element *result = 0 ;
int val2 ;
int ecode2 = 0 ;
int res3 ;
@@ -3843,8 +3880,8 @@ SWIGINTERN PyObject *_wrap_new_MessageElement(PyObject *SWIGUNUSEDPARM(self), Py
}
arg3 = (char *)(buf3);
}
- result = (ldb_msg_element *)new_ldb_msg_element(arg1,arg2,(char const *)arg3);
- resultobj = SWIG_NewPointerObj(SWIG_as_voidptr(result), SWIGTYPE_p_ldb_message_element, SWIG_POINTER_OWN | 0 );
+ result = (ldb_message_element *)new_ldb_message_element(arg1,arg2,(char const *)arg3);
+ resultobj = SWIG_NewPointerObj(SWIG_as_voidptr(result), SWIGTYPE_p_ldb_message_element, SWIG_POINTER_NEW | 0 );
if (alloc3 == SWIG_NEWOBJ) free((char*)buf3);
return resultobj;
fail:
@@ -3853,9 +3890,9 @@ fail:
}
-SWIGINTERN PyObject *_wrap_ldb_msg_element___len__(PyObject *SWIGUNUSEDPARM(self), PyObject *args) {
+SWIGINTERN PyObject *_wrap_MessageElement___len__(PyObject *SWIGUNUSEDPARM(self), PyObject *args) {
PyObject *resultobj = 0;
- ldb_msg_element *arg1 = (ldb_msg_element *) 0 ;
+ ldb_message_element *arg1 = (ldb_message_element *) 0 ;
int result;
void *argp1 = 0 ;
int res1 = 0 ;
@@ -3865,10 +3902,10 @@ SWIGINTERN PyObject *_wrap_ldb_msg_element___len__(PyObject *SWIGUNUSEDPARM(self
swig_obj[0] = args;
res1 = SWIG_ConvertPtr(swig_obj[0], &argp1,SWIGTYPE_p_ldb_message_element, 0 | 0 );
if (!SWIG_IsOK(res1)) {
- SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "ldb_msg_element___len__" "', argument " "1"" of type '" "ldb_msg_element *""'");
+ SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "MessageElement___len__" "', argument " "1"" of type '" "ldb_message_element *""'");
}
- arg1 = (ldb_msg_element *)(argp1);
- result = (int)ldb_msg_element___len__(arg1);
+ arg1 = (ldb_message_element *)(argp1);
+ result = (int)ldb_message_element___len__(arg1);
resultobj = SWIG_From_int((int)(result));
return resultobj;
fail:
@@ -3876,9 +3913,9 @@ fail:
}
-SWIGINTERN PyObject *_wrap_ldb_msg_element_get(PyObject *SWIGUNUSEDPARM(self), PyObject *args, PyObject *kwargs) {
+SWIGINTERN PyObject *_wrap_MessageElement_get(PyObject *SWIGUNUSEDPARM(self), PyObject *args, PyObject *kwargs) {
PyObject *resultobj = 0;
- ldb_msg_element *arg1 = (ldb_msg_element *) 0 ;
+ ldb_message_element *arg1 = (ldb_message_element *) 0 ;
int arg2 ;
PyObject *result = 0 ;
void *argp1 = 0 ;
@@ -3891,18 +3928,18 @@ SWIGINTERN PyObject *_wrap_ldb_msg_element_get(PyObject *SWIGUNUSEDPARM(self), P
(char *) "self",(char *) "i", NULL
};
- if (!PyArg_ParseTupleAndKeywords(args,kwargs,(char *)"OO:ldb_msg_element_get",kwnames,&obj0,&obj1)) SWIG_fail;
+ if (!PyArg_ParseTupleAndKeywords(args,kwargs,(char *)"OO:MessageElement_get",kwnames,&obj0,&obj1)) SWIG_fail;
res1 = SWIG_ConvertPtr(obj0, &argp1,SWIGTYPE_p_ldb_message_element, 0 | 0 );
if (!SWIG_IsOK(res1)) {
- SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "ldb_msg_element_get" "', argument " "1"" of type '" "ldb_msg_element *""'");
+ SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "MessageElement_get" "', argument " "1"" of type '" "ldb_message_element *""'");
}
- arg1 = (ldb_msg_element *)(argp1);
+ arg1 = (ldb_message_element *)(argp1);
ecode2 = SWIG_AsVal_int(obj1, &val2);
if (!SWIG_IsOK(ecode2)) {
- SWIG_exception_fail(SWIG_ArgError(ecode2), "in method '" "ldb_msg_element_get" "', argument " "2"" of type '" "int""'");
+ SWIG_exception_fail(SWIG_ArgError(ecode2), "in method '" "MessageElement_get" "', argument " "2"" of type '" "int""'");
}
arg2 = (int)(val2);
- result = (PyObject *)ldb_msg_element_get(arg1,arg2);
+ result = (PyObject *)ldb_message_element_get(arg1,arg2);
resultobj = result;
return resultobj;
fail:
@@ -3910,9 +3947,9 @@ fail:
}
-SWIGINTERN PyObject *_wrap_delete_ldb_msg_element(PyObject *SWIGUNUSEDPARM(self), PyObject *args) {
+SWIGINTERN PyObject *_wrap_delete_MessageElement(PyObject *SWIGUNUSEDPARM(self), PyObject *args) {
PyObject *resultobj = 0;
- ldb_msg_element *arg1 = (ldb_msg_element *) 0 ;
+ ldb_message_element *arg1 = (ldb_message_element *) 0 ;
void *argp1 = 0 ;
int res1 = 0 ;
PyObject *swig_obj[1] ;
@@ -3921,10 +3958,10 @@ SWIGINTERN PyObject *_wrap_delete_ldb_msg_element(PyObject *SWIGUNUSEDPARM(self)
swig_obj[0] = args;
res1 = SWIG_ConvertPtr(swig_obj[0], &argp1,SWIGTYPE_p_ldb_message_element, SWIG_POINTER_DISOWN | 0 );
if (!SWIG_IsOK(res1)) {
- SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "delete_ldb_msg_element" "', argument " "1"" of type '" "ldb_msg_element *""'");
+ SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "delete_MessageElement" "', argument " "1"" of type '" "ldb_message_element *""'");
}
- arg1 = (ldb_msg_element *)(argp1);
- delete_ldb_msg_element(arg1);
+ arg1 = (ldb_message_element *)(argp1);
+ delete_ldb_message_element(arg1);
resultobj = SWIG_Py_Void();
return resultobj;
@@ -3933,47 +3970,17 @@ fail:
}
-SWIGINTERN PyObject *_wrap_ldb_msg_element___cmp__(PyObject *SWIGUNUSEDPARM(self), PyObject *args, PyObject *kwargs) {
- PyObject *resultobj = 0;
- ldb_msg_element *arg1 = (ldb_msg_element *) 0 ;
- ldb_msg_element *arg2 = (ldb_msg_element *) 0 ;
- int result;
- void *argp1 = 0 ;
- int res1 = 0 ;
- void *argp2 = 0 ;
- int res2 = 0 ;
- PyObject * obj0 = 0 ;
- PyObject * obj1 = 0 ;
- char * kwnames[] = {
- (char *) "self",(char *)"arg2", NULL
- };
-
- if (!PyArg_ParseTupleAndKeywords(args,kwargs,(char *)"OO:ldb_msg_element___cmp__",kwnames,&obj0,&obj1)) SWIG_fail;
- res1 = SWIG_ConvertPtr(obj0, &argp1,SWIGTYPE_p_ldb_message_element, 0 | 0 );
- if (!SWIG_IsOK(res1)) {
- SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "ldb_msg_element___cmp__" "', argument " "1"" of type '" "ldb_msg_element *""'");
- }
- arg1 = (ldb_msg_element *)(argp1);
- res2 = SWIG_ConvertPtr(obj1, &argp2,SWIGTYPE_p_ldb_message_element, 0 | 0 );
- if (!SWIG_IsOK(res2)) {
- SWIG_exception_fail(SWIG_ArgError(res2), "in method '" "ldb_msg_element___cmp__" "', argument " "2"" of type '" "ldb_msg_element *""'");
- }
- arg2 = (ldb_msg_element *)(argp2);
- result = (int)ldb_msg_element_compare(arg1,arg2);
- resultobj = SWIG_From_int((int)(result));
- return resultobj;
-fail:
- return NULL;
-}
-
-
-SWIGINTERN PyObject *ldb_msg_element_swigregister(PyObject *SWIGUNUSEDPARM(self), PyObject *args) {
+SWIGINTERN PyObject *MessageElement_swigregister(PyObject *SWIGUNUSEDPARM(self), PyObject *args) {
PyObject *obj;
if (!SWIG_Python_UnpackTuple(args,(char*)"swigregister", 1, 1,&obj)) return NULL;
SWIG_TypeNewClientData(SWIGTYPE_p_ldb_message_element, SWIG_NewClientData(obj));
return SWIG_Py_Void();
}
+SWIGINTERN PyObject *MessageElement_swiginit(PyObject *SWIGUNUSEDPARM(self), PyObject *args) {
+ return SWIG_Python_InitShadowInstance(args);
+}
+
SWIGINTERN PyObject *_wrap_ldb_msg_list_elements(PyObject *SWIGUNUSEDPARM(self), PyObject *args, PyObject *kwargs) {
PyObject *resultobj = 0;
ldb_msg *arg1 = (ldb_msg *) 0 ;
@@ -4118,7 +4125,7 @@ SWIGINTERN PyObject *_wrap_Message_find_element(PyObject *SWIGUNUSEDPARM(self),
PyObject *resultobj = 0;
ldb_msg *arg1 = (ldb_msg *) 0 ;
char *arg2 = (char *) 0 ;
- ldb_msg_element *result = 0 ;
+ ldb_message_element *result = 0 ;
void *argp1 = 0 ;
int res1 = 0 ;
int res2 ;
@@ -4144,7 +4151,7 @@ SWIGINTERN PyObject *_wrap_Message_find_element(PyObject *SWIGUNUSEDPARM(self),
if (arg1 == NULL)
SWIG_exception(SWIG_ValueError,
"Message can not be None");
- result = (ldb_msg_element *)ldb_msg_find_element(arg1,(char const *)arg2);
+ result = (ldb_message_element *)ldb_msg_find_element(arg1,(char const *)arg2);
{
if (result == NULL)
PyErr_SetString(PyExc_KeyError, "no such element");
@@ -4163,7 +4170,7 @@ SWIGINTERN PyObject *_wrap_Message___setitem____SWIG_0(PyObject *SWIGUNUSEDPARM(
PyObject *resultobj = 0;
ldb_msg *arg1 = (ldb_msg *) 0 ;
char *arg2 = (char *) 0 ;
- ldb_msg_element *arg3 = (ldb_msg_element *) 0 ;
+ ldb_message_element *arg3 = (ldb_message_element *) 0 ;
void *argp1 = 0 ;
int res1 = 0 ;
int res2 ;
@@ -4185,9 +4192,9 @@ SWIGINTERN PyObject *_wrap_Message___setitem____SWIG_0(PyObject *SWIGUNUSEDPARM(
arg2 = (char *)(buf2);
res3 = SWIG_ConvertPtr(swig_obj[2], &argp3,SWIGTYPE_p_ldb_message_element, 0 | 0 );
if (!SWIG_IsOK(res3)) {
- SWIG_exception_fail(SWIG_ArgError(res3), "in method '" "Message___setitem__" "', argument " "3"" of type '" "ldb_msg_element *""'");
+ SWIG_exception_fail(SWIG_ArgError(res3), "in method '" "Message___setitem__" "', argument " "3"" of type '" "ldb_message_element *""'");
}
- arg3 = (ldb_msg_element *)(argp3);
+ arg3 = (ldb_message_element *)(argp3);
if (arg1 == NULL)
SWIG_exception(SWIG_ValueError,
"Message can not be None");
@@ -4262,7 +4269,7 @@ check_1:
fail:
SWIG_SetErrorMsg(PyExc_NotImplementedError,"Wrong number of arguments for overloaded function 'Message___setitem__'.\n"
" Possible C/C++ prototypes are:\n"
- " __setitem__(ldb_msg *,char const *,ldb_msg_element *)\n"
+ " __setitem__(ldb_msg *,char const *,ldb_message_element *)\n"
" __setitem__(ldb_msg *,char const *,PyObject *)\n");
return NULL;
}
@@ -4787,7 +4794,7 @@ SWIGINTERN PyObject *_wrap_Ldb_add(PyObject *SWIGUNUSEDPARM(self), PyObject *arg
arg1 = (ldb *)(argp1);
{
Py_ssize_t dict_pos, msg_pos;
- ldb_msg_element *msgel;
+ ldb_message_element *msgel;
PyObject *key, *value;
if (PyDict_Check(obj1)) {
@@ -5723,34 +5730,62 @@ fail:
static PyMethodDef SwigMethods[] = {
{ (char *)"ldb_val_to_py_object", (PyCFunction) _wrap_ldb_val_to_py_object, METH_VARARGS | METH_KEYWORDS, NULL},
- { (char *)"new_Dn", (PyCFunction) _wrap_new_Dn, METH_VARARGS | METH_KEYWORDS, NULL},
+ { (char *)"new_Dn", (PyCFunction) _wrap_new_Dn, METH_VARARGS | METH_KEYWORDS, (char *)"\n"
+ "S.__init__(ldb, string)\n"
+ "Create a new DN.\n"
+ ""},
{ (char *)"delete_Dn", (PyCFunction)_wrap_delete_Dn, METH_O, NULL},
- { (char *)"Dn_validate", (PyCFunction)_wrap_Dn_validate, METH_O, NULL},
+ { (char *)"Dn_validate", (PyCFunction)_wrap_Dn_validate, METH_O, (char *)"\n"
+ "S.validate() -> bool\n"
+ "Validate DN is correct.\n"
+ ""},
{ (char *)"Dn_get_casefold", (PyCFunction)_wrap_Dn_get_casefold, METH_O, NULL},
{ (char *)"Dn___str__", (PyCFunction)_wrap_Dn___str__, METH_O, NULL},
- { (char *)"Dn_parent", (PyCFunction)_wrap_Dn_parent, METH_O, NULL},
+ { (char *)"Dn_parent", (PyCFunction)_wrap_Dn_parent, METH_O, (char *)"\n"
+ "S.parent() -> dn\n"
+ "Get the parent for this DN.\n"
+ ""},
{ (char *)"Dn___cmp__", (PyCFunction) _wrap_Dn___cmp__, METH_VARARGS | METH_KEYWORDS, NULL},
{ (char *)"Dn_is_valid", (PyCFunction)_wrap_Dn_is_valid, METH_O, NULL},
- { (char *)"Dn_is_special", (PyCFunction)_wrap_Dn_is_special, METH_O, NULL},
- { (char *)"Dn_is_null", (PyCFunction)_wrap_Dn_is_null, METH_O, NULL},
+ { (char *)"Dn_is_special", (PyCFunction)_wrap_Dn_is_special, METH_O, (char *)"\n"
+ "S.is_special() -> bool\n"
+ "Check whether this is a special LDB DN.\n"
+ ""},
+ { (char *)"Dn_is_null", (PyCFunction)_wrap_Dn_is_null, METH_O, (char *)"\n"
+ "S.is_null() -> bool\n"
+ "Check whether this is a null DN.\n"
+ ""},
{ (char *)"Dn_check_special", (PyCFunction) _wrap_Dn_check_special, METH_VARARGS | METH_KEYWORDS, NULL},
{ (char *)"Dn___len__", (PyCFunction)_wrap_Dn___len__, METH_O, NULL},
- { (char *)"Dn_add_child", (PyCFunction) _wrap_Dn_add_child, METH_VARARGS | METH_KEYWORDS, NULL},
- { (char *)"Dn_add_base", (PyCFunction) _wrap_Dn_add_base, METH_VARARGS | METH_KEYWORDS, NULL},
- { (char *)"Dn_canonical_str", (PyCFunction)_wrap_Dn_canonical_str, METH_O, NULL},
- { (char *)"Dn_canonical_ex_str", (PyCFunction)_wrap_Dn_canonical_ex_str, METH_O, NULL},
+ { (char *)"Dn_add_child", (PyCFunction) _wrap_Dn_add_child, METH_VARARGS | METH_KEYWORDS, (char *)"\n"
+ "S.add_child(dn) -> None\n"
+ "Add a child DN to this DN.\n"
+ ""},
+ { (char *)"Dn_add_base", (PyCFunction) _wrap_Dn_add_base, METH_VARARGS | METH_KEYWORDS, (char *)"\n"
+ "S.add_base(dn) -> None\n"
+ "Add a base DN to this DN.\n"
+ ""},
+ { (char *)"Dn_canonical_str", (PyCFunction)_wrap_Dn_canonical_str, METH_O, (char *)"\n"
+ "S.canonical_str() -> string\n"
+ "Canonical version of this DN (like a posix path).\n"
+ ""},
+ { (char *)"Dn_canonical_ex_str", (PyCFunction)_wrap_Dn_canonical_ex_str, METH_O, (char *)"\n"
+ "S.canonical_ex_str() -> string\n"
+ "Canonical version of this DN (like a posix path, with terminating newline).\n"
+ ""},
{ (char *)"Dn___repr__", (PyCFunction)_wrap_Dn___repr__, METH_O, NULL},
{ (char *)"Dn___add__", (PyCFunction) _wrap_Dn___add__, METH_VARARGS | METH_KEYWORDS, NULL},
{ (char *)"Dn_swigregister", Dn_swigregister, METH_VARARGS, NULL},
{ (char *)"Dn_swiginit", Dn_swiginit, METH_VARARGS, NULL},
- { (char *)"ldb_msg_element___iter__", (PyCFunction)_wrap_ldb_msg_element___iter__, METH_O, NULL},
- { (char *)"ldb_msg_element___set__", (PyCFunction)_wrap_ldb_msg_element___set__, METH_O, NULL},
- { (char *)"new_MessageElement", (PyCFunction) _wrap_new_MessageElement, METH_VARARGS | METH_KEYWORDS, NULL},
- { (char *)"ldb_msg_element___len__", (PyCFunction)_wrap_ldb_msg_element___len__, METH_O, NULL},
- { (char *)"ldb_msg_element_get", (PyCFunction) _wrap_ldb_msg_element_get, METH_VARARGS | METH_KEYWORDS, NULL},
- { (char *)"delete_ldb_msg_element", (PyCFunction)_wrap_delete_ldb_msg_element, METH_O, NULL},
- { (char *)"ldb_msg_element___cmp__", (PyCFunction) _wrap_ldb_msg_element___cmp__, METH_VARARGS | METH_KEYWORDS, NULL},
- { (char *)"ldb_msg_element_swigregister", ldb_msg_element_swigregister, METH_VARARGS, NULL},
+ { (char *)"MessageElement___cmp__", (PyCFunction) _wrap_MessageElement___cmp__, METH_VARARGS | METH_KEYWORDS, NULL},
+ { (char *)"MessageElement___iter__", (PyCFunction)_wrap_MessageElement___iter__, METH_O, NULL},
+ { (char *)"MessageElement___set__", (PyCFunction)_wrap_MessageElement___set__, METH_O, NULL},
+ { (char *)"new_MessageElement", (PyCFunction) _wrap_new_MessageElement, METH_VARARGS | METH_KEYWORDS, (char *)"Message element."},
+ { (char *)"MessageElement___len__", (PyCFunction)_wrap_MessageElement___len__, METH_O, NULL},
+ { (char *)"MessageElement_get", (PyCFunction) _wrap_MessageElement_get, METH_VARARGS | METH_KEYWORDS, NULL},
+ { (char *)"delete_MessageElement", (PyCFunction)_wrap_delete_MessageElement, METH_O, NULL},
+ { (char *)"MessageElement_swigregister", MessageElement_swigregister, METH_VARARGS, NULL},
+ { (char *)"MessageElement_swiginit", MessageElement_swiginit, METH_VARARGS, NULL},
{ (char *)"ldb_msg_list_elements", (PyCFunction) _wrap_ldb_msg_list_elements, METH_VARARGS | METH_KEYWORDS, NULL},
{ (char *)"Message_dn_set", _wrap_Message_dn_set, METH_VARARGS, NULL},
{ (char *)"Message_dn_get", (PyCFunction)_wrap_Message_dn_get, METH_O, NULL},
@@ -5766,40 +5801,97 @@ static PyMethodDef SwigMethods[] = {
{ (char *)"Message_swiginit", Message_swiginit, METH_VARARGS, NULL},
{ (char *)"ldb_ldif_to_pyobject", (PyCFunction) _wrap_ldb_ldif_to_pyobject, METH_VARARGS | METH_KEYWORDS, NULL},
{ (char *)"new_Ldb", (PyCFunction)_wrap_new_Ldb, METH_NOARGS, NULL},
- { (char *)"Ldb_connect", (PyCFunction) _wrap_Ldb_connect, METH_VARARGS | METH_KEYWORDS, NULL},
+ { (char *)"Ldb_connect", (PyCFunction) _wrap_Ldb_connect, METH_VARARGS | METH_KEYWORDS, (char *)"\n"
+ "S.connect(url,flags=0,options=None) -> None\n"
+ "Connect to a LDB URL.\n"
+ ""},
{ (char *)"delete_Ldb", (PyCFunction)_wrap_delete_Ldb, METH_O, NULL},
{ (char *)"Ldb_search_ex", (PyCFunction) _wrap_Ldb_search_ex, METH_VARARGS | METH_KEYWORDS, NULL},
- { (char *)"Ldb_delete", (PyCFunction) _wrap_Ldb_delete, METH_VARARGS | METH_KEYWORDS, NULL},
- { (char *)"Ldb_rename", (PyCFunction) _wrap_Ldb_rename, METH_VARARGS | METH_KEYWORDS, NULL},
+ { (char *)"Ldb_delete", (PyCFunction) _wrap_Ldb_delete, METH_VARARGS | METH_KEYWORDS, (char *)"\n"
+ "S.delete(dn) -> None\n"
+ "Remove an entry.\n"
+ ""},
+ { (char *)"Ldb_rename", (PyCFunction) _wrap_Ldb_rename, METH_VARARGS | METH_KEYWORDS, (char *)"\n"
+ "S.rename(old_dn, new_dn) -> None\n"
+ "Rename an entry.\n"
+ ""},
{ (char *)"Ldb_parse_control_strings", (PyCFunction) _wrap_Ldb_parse_control_strings, METH_VARARGS | METH_KEYWORDS, NULL},
- { (char *)"Ldb_add", (PyCFunction) _wrap_Ldb_add, METH_VARARGS | METH_KEYWORDS, NULL},
- { (char *)"Ldb_modify", (PyCFunction) _wrap_Ldb_modify, METH_VARARGS | METH_KEYWORDS, NULL},
+ { (char *)"Ldb_add", (PyCFunction) _wrap_Ldb_add, METH_VARARGS | METH_KEYWORDS, (char *)"\n"
+ "S.add(message) -> None\n"
+ "Add an entry.\n"
+ ""},
+ { (char *)"Ldb_modify", (PyCFunction) _wrap_Ldb_modify, METH_VARARGS | METH_KEYWORDS, (char *)"\n"
+ "S.modify(message) -> None\n"
+ "Modify an entry.\n"
+ ""},
{ (char *)"Ldb_get_config_basedn", (PyCFunction)_wrap_Ldb_get_config_basedn, METH_O, NULL},
{ (char *)"Ldb_get_root_basedn", (PyCFunction)_wrap_Ldb_get_root_basedn, METH_O, NULL},
{ (char *)"Ldb_get_schema_basedn", (PyCFunction)_wrap_Ldb_get_schema_basedn, METH_O, NULL},
{ (char *)"Ldb_get_default_basedn", (PyCFunction)_wrap_Ldb_get_default_basedn, METH_O, NULL},
{ (char *)"Ldb_schema_format_value", (PyCFunction) _wrap_Ldb_schema_format_value, METH_VARARGS | METH_KEYWORDS, NULL},
{ (char *)"Ldb_errstring", (PyCFunction)_wrap_Ldb_errstring, METH_O, NULL},
- { (char *)"Ldb_set_create_perms", (PyCFunction) _wrap_Ldb_set_create_perms, METH_VARARGS | METH_KEYWORDS, NULL},
- { (char *)"Ldb_set_modules_dir", (PyCFunction) _wrap_Ldb_set_modules_dir, METH_VARARGS | METH_KEYWORDS, NULL},
- { (char *)"Ldb_set_debug", (PyCFunction) _wrap_Ldb_set_debug, METH_VARARGS | METH_KEYWORDS, NULL},
- { (char *)"Ldb_set_opaque", (PyCFunction) _wrap_Ldb_set_opaque, METH_VARARGS | METH_KEYWORDS, NULL},
- { (char *)"Ldb_get_opaque", (PyCFunction) _wrap_Ldb_get_opaque, METH_VARARGS | METH_KEYWORDS, NULL},
- { (char *)"Ldb_transaction_start", (PyCFunction)_wrap_Ldb_transaction_start, METH_O, NULL},
- { (char *)"Ldb_transaction_commit", (PyCFunction)_wrap_Ldb_transaction_commit, METH_O, NULL},
- { (char *)"Ldb_transaction_cancel", (PyCFunction)_wrap_Ldb_transaction_cancel, METH_O, NULL},
+ { (char *)"Ldb_set_create_perms", (PyCFunction) _wrap_Ldb_set_create_perms, METH_VARARGS | METH_KEYWORDS, (char *)"\n"
+ "S.set_create_perms(mode) -> None\n"
+ "Set mode to use when creating new LDB files.\n"
+ ""},
+ { (char *)"Ldb_set_modules_dir", (PyCFunction) _wrap_Ldb_set_modules_dir, METH_VARARGS | METH_KEYWORDS, (char *)"\n"
+ "S.set_modules_dir(path) -> None\n"
+ "Set path LDB should search for modules\n"
+ ""},
+ { (char *)"Ldb_set_debug", (PyCFunction) _wrap_Ldb_set_debug, METH_VARARGS | METH_KEYWORDS, (char *)"\n"
+ "S.set_debug(callback) -> None\n"
+ "Set callback for LDB debug messages.\n"
+ "The callback should accept a debug level and debug text.\n"
+ ""},
+ { (char *)"Ldb_set_opaque", (PyCFunction) _wrap_Ldb_set_opaque, METH_VARARGS | METH_KEYWORDS, (char *)"\n"
+ "S.set_opaque(name, value) -> None\n"
+ "Set an opaque value on this LDB connection. \n"
+ ":note: Passing incorrect values may cause crashes.\n"
+ ""},
+ { (char *)"Ldb_get_opaque", (PyCFunction) _wrap_Ldb_get_opaque, METH_VARARGS | METH_KEYWORDS, (char *)"\n"
+ "S.get_opaque(name) -> value\n"
+ "Get an opaque value set on this LDB connection. \n"
+ ":note: The returned value may not be useful in Python.\n"
+ ""},
+ { (char *)"Ldb_transaction_start", (PyCFunction)_wrap_Ldb_transaction_start, METH_O, (char *)"\n"
+ "S.transaction_start() -> None\n"
+ "Start a new transaction.\n"
+ ""},
+ { (char *)"Ldb_transaction_commit", (PyCFunction)_wrap_Ldb_transaction_commit, METH_O, (char *)"\n"
+ "S.transaction_commit() -> None\n"
+ "Commit currently active transaction.\n"
+ ""},
+ { (char *)"Ldb_transaction_cancel", (PyCFunction)_wrap_Ldb_transaction_cancel, METH_O, (char *)"\n"
+ "S.transaction_cancel() -> None\n"
+ "Cancel currently active transaction.\n"
+ ""},
{ (char *)"Ldb_schema_attribute_remove", (PyCFunction) _wrap_Ldb_schema_attribute_remove, METH_VARARGS | METH_KEYWORDS, NULL},
{ (char *)"Ldb_schema_attribute_add", (PyCFunction) _wrap_Ldb_schema_attribute_add, METH_VARARGS | METH_KEYWORDS, NULL},
{ (char *)"Ldb_setup_wellknown_attributes", (PyCFunction)_wrap_Ldb_setup_wellknown_attributes, METH_O, NULL},
{ (char *)"Ldb___contains__", (PyCFunction) _wrap_Ldb___contains__, METH_VARARGS | METH_KEYWORDS, NULL},
- { (char *)"Ldb_parse_ldif", (PyCFunction) _wrap_Ldb_parse_ldif, METH_VARARGS | METH_KEYWORDS, NULL},
+ { (char *)"Ldb_parse_ldif", (PyCFunction) _wrap_Ldb_parse_ldif, METH_VARARGS | METH_KEYWORDS, (char *)"\n"
+ "S.parse_ldif(ldif) -> iter(messages)\n"
+ "Parse a string formatted using LDIF.\n"
+ ""},
{ (char *)"Ldb___repr__", (PyCFunction)_wrap_Ldb___repr__, METH_O, NULL},
{ (char *)"Ldb_swigregister", Ldb_swigregister, METH_VARARGS, NULL},
{ (char *)"Ldb_swiginit", Ldb_swiginit, METH_VARARGS, NULL},
- { (char *)"valid_attr_name", (PyCFunction) _wrap_valid_attr_name, METH_VARARGS | METH_KEYWORDS, NULL},
- { (char *)"timestring", (PyCFunction) _wrap_timestring, METH_VARARGS | METH_KEYWORDS, NULL},
- { (char *)"string_to_time", (PyCFunction) _wrap_string_to_time, METH_VARARGS | METH_KEYWORDS, NULL},
- { (char *)"register_module", (PyCFunction) _wrap_register_module, METH_VARARGS | METH_KEYWORDS, NULL},
+ { (char *)"valid_attr_name", (PyCFunction) _wrap_valid_attr_name, METH_VARARGS | METH_KEYWORDS, (char *)"\n"
+ "S.valid_attr_name(name) -> bool\n"
+ "Check whether the supplied name is a valid attribute name.\n"
+ ""},
+ { (char *)"timestring", (PyCFunction) _wrap_timestring, METH_VARARGS | METH_KEYWORDS, (char *)"\n"
+ "S.timestring(int) -> string\n"
+ "Generate a LDAP time string from a UNIX timestamp\n"
+ ""},
+ { (char *)"string_to_time", (PyCFunction) _wrap_string_to_time, METH_VARARGS | METH_KEYWORDS, (char *)"\n"
+ "S.string_to_time(string) -> int\n"
+ "Parse a LDAP time string into a UNIX timestamp.\n"
+ ""},
+ { (char *)"register_module", (PyCFunction) _wrap_register_module, METH_VARARGS | METH_KEYWORDS, (char *)"\n"
+ "S.register_module(module) -> None\n"
+ "Register a LDB module.\n"
+ ""},
{ NULL, NULL, 0, NULL }
};
@@ -5814,7 +5906,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_module_ops = {"_p_ldb_module_ops", "struct ldb_module_ops *", 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_ldb_val = {"_p_ldb_val", "struct ldb_val *", 0, 0, (void*)0, 0};
diff --git a/source4/lib/ldb/python.mk b/source4/lib/ldb/python.mk
index 89aba8f276..5325446e1e 100644
--- a/source4/lib/ldb/python.mk
+++ b/source4/lib/ldb/python.mk
@@ -1,10 +1,10 @@
[PYTHON::swig_ldb]
LIBRARY_REALNAME = _ldb.$(SHLIBEXT)
PUBLIC_DEPENDENCIES = LIBLDB
-CFLAGS = -Ilib/ldb/include
-swig_ldb_OBJ_FILES = lib/ldb/ldb_wrap.o
+swig_ldb_OBJ_FILES = $(ldbdir)/ldb_wrap.o
+$(swig_ldb_OBJ_FILES): CFLAGS+=-I$(ldbdir)/include
-$(eval $(call python_py_module_template,ldb.py,lib/ldb/ldb.py))
+$(eval $(call python_py_module_template,ldb.py,$(ldbdir)/ldb.py))
$(swig_ldb_OBJ_FILES): CFLAGS+=$(CFLAG_NO_UNUSED_MACROS) $(CFLAG_NO_CAST_QUAL)
diff --git a/source4/lib/ldb/tools/config.mk b/source4/lib/ldb/tools/config.mk
index 6729636434..051fd0c57b 100644
--- a/source4/lib/ldb/tools/config.mk
+++ b/source4/lib/ldb/tools/config.mk
@@ -1,13 +1,13 @@
################################################
# Start SUBSYSTEM LIBLDB_CMDLINE
[SUBSYSTEM::LIBLDB_CMDLINE]
-CFLAGS = -Ilib/ldb -Ilib/ldb/include
+CFLAGS = -I$(ldbdir) -I$(ldbdir)/include
PUBLIC_DEPENDENCIES = LIBLDB LIBPOPT
PRIVATE_DEPENDENCIES = LIBSAMBA-UTIL POPT_SAMBA POPT_CREDENTIALS gensec
# End SUBSYSTEM LIBLDB_CMDLINE
################################################
-LIBLDB_CMDLINE_OBJ_FILES = lib/ldb/tools/cmdline.o
+LIBLDB_CMDLINE_OBJ_FILES = $(ldbdir)/tools/cmdline.o
################################################
# Start BINARY ldbadd
@@ -19,7 +19,7 @@ PRIVATE_DEPENDENCIES = \
################################################
-ldbadd_OBJ_FILES = lib/ldb/tools/ldbadd.o
+ldbadd_OBJ_FILES = $(ldbdir)/tools/ldbadd.o
MANPAGES += $(ldbdir)/man/ldbadd.1
@@ -32,7 +32,7 @@ PRIVATE_DEPENDENCIES = \
# End BINARY ldbdel
################################################
-ldbdel_OBJ_FILES = lib/ldb/tools/ldbdel.o
+ldbdel_OBJ_FILES = $(ldbdir)/tools/ldbdel.o
MANPAGES += $(ldbdir)/man/ldbdel.1
@@ -45,7 +45,7 @@ PRIVATE_DEPENDENCIES = \
# End BINARY ldbmodify
################################################
-ldbmodify_OBJ_FILES = lib/ldb/tools/ldbmodify.o
+ldbmodify_OBJ_FILES = $(ldbdir)/tools/ldbmodify.o
MANPAGES += $(ldbdir)/man/ldbmodify.1
################################################
@@ -57,7 +57,7 @@ PRIVATE_DEPENDENCIES = \
# End BINARY ldbsearch
################################################
-ldbsearch_OBJ_FILES = lib/ldb/tools/ldbsearch.o
+ldbsearch_OBJ_FILES = $(ldbdir)/tools/ldbsearch.o
MANPAGES += $(ldbdir)/man/ldbsearch.1
@@ -70,7 +70,7 @@ PRIVATE_DEPENDENCIES = \
# End BINARY ldbedit
################################################
-ldbedit_OBJ_FILES = lib/ldb/tools/ldbedit.o
+ldbedit_OBJ_FILES = $(ldbdir)/tools/ldbedit.o
MANPAGES += $(ldbdir)/man/ldbedit.1
@@ -83,7 +83,7 @@ PRIVATE_DEPENDENCIES = \
# End BINARY ldbrename
################################################
-ldbrename_OBJ_FILES = lib/ldb/tools/ldbrename.o
+ldbrename_OBJ_FILES = $(ldbdir)/tools/ldbrename.o
MANPAGES += $(ldbdir)/man/ldbrename.1
diff --git a/source4/lib/messaging/config.mk b/source4/lib/messaging/config.mk
index eaf7e3581e..e92f78c8e3 100644
--- a/source4/lib/messaging/config.mk
+++ b/source4/lib/messaging/config.mk
@@ -1,6 +1,3 @@
-
-################################################
-# Start SUBSYSTEM MESSAGING
[SUBSYSTEM::MESSAGING]
PUBLIC_DEPENDENCIES = \
LIBSAMBA-UTIL \
@@ -9,8 +6,13 @@ PUBLIC_DEPENDENCIES = \
UNIX_PRIVS \
UTIL_TDB \
CLUSTER \
- LIBNDR
-# End SUBSYSTEM MESSAGING
-################################################
+ LIBNDR \
+ samba-socket
MESSAGING_OBJ_FILES = $(libmessagingsrcdir)/messaging.o
+
+[PYTHON::python_messaging]
+LIBRARY_REALNAME = samba/messaging.$(SHLIBEXT)
+PRIVATE_DEPENDENCIES = MESSAGING LIBEVENTS python_irpc
+
+python_messaging_OBJ_FILES = $(libmessagingsrcdir)/pymessaging.o
diff --git a/source4/lib/messaging/irpc.h b/source4/lib/messaging/irpc.h
index f44c0af3ec..65e98dce2c 100644
--- a/source4/lib/messaging/irpc.h
+++ b/source4/lib/messaging/irpc.h
@@ -125,6 +125,7 @@ NTSTATUS irpc_add_name(struct messaging_context *msg_ctx, const char *name);
struct server_id *irpc_servers_byname(struct messaging_context *msg_ctx, TALLOC_CTX *mem_ctx, const char *name);
void irpc_remove_name(struct messaging_context *msg_ctx, const char *name);
NTSTATUS irpc_send_reply(struct irpc_message *m, NTSTATUS status);
+struct server_id messaging_get_server_id(struct messaging_context *msg_ctx);
#endif
diff --git a/source4/lib/messaging/messaging.c b/source4/lib/messaging/messaging.c
index e7b654894f..4b90e8c4fd 100644
--- a/source4/lib/messaging/messaging.c
+++ b/source4/lib/messaging/messaging.c
@@ -1113,3 +1113,8 @@ void irpc_remove_name(struct messaging_context *msg_ctx, const char *name)
tdb_unlock_bystring(t->tdb, name);
talloc_free(t);
}
+
+struct server_id messaging_get_server_id(struct messaging_context *msg_ctx)
+{
+ return msg_ctx->server_id;
+}
diff --git a/source4/lib/messaging/pymessaging.c b/source4/lib/messaging/pymessaging.c
new file mode 100644
index 0000000000..1c22fb431a
--- /dev/null
+++ b/source4/lib/messaging/pymessaging.c
@@ -0,0 +1,559 @@
+/*
+ Unix SMB/CIFS implementation.
+ Copyright © Jelmer Vernooij <jelmer@samba.org> 2008
+
+ Based on the equivalent for EJS:
+ Copyright © Andrew Tridgell <tridge@samba.org> 2005
+
+ 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 "libcli/util/pyerrors.h"
+#include "librpc/rpc/pyrpc.h"
+#include "lib/messaging/irpc.h"
+#include "lib/messaging/messaging.h"
+#include "lib/events/events.h"
+#include "cluster/cluster.h"
+#include "param/param.h"
+#include "librpc/gen_ndr/py_irpc.h"
+
+PyAPI_DATA(PyTypeObject) messaging_Type;
+PyAPI_DATA(PyTypeObject) irpc_ClientConnectionType;
+
+static bool server_id_from_py(PyObject *object, struct server_id *server_id)
+{
+ if (!PyTuple_Check(object)) {
+ PyErr_SetString(PyExc_ValueError, "Expected tuple");
+ return false;
+ }
+
+ if (PyTuple_Size(object) == 3) {
+ return PyArg_ParseTuple(object, "iii", &server_id->id, &server_id->id2, &server_id->node);
+ } else {
+ int id, id2;
+ if (!PyArg_ParseTuple(object, "ii", &id, &id2))
+ return false;
+ *server_id = cluster_id(id, id2);
+ return true;
+ }
+}
+
+typedef struct {
+ PyObject_HEAD
+ TALLOC_CTX *mem_ctx;
+ struct messaging_context *msg_ctx;
+} messaging_Object;
+
+PyObject *py_messaging_connect(PyTypeObject *self, PyObject *args, PyObject *kwargs)
+{
+ struct event_context *ev;
+ const char *kwnames[] = { "own_id", "messaging_path", NULL };
+ PyObject *own_id = Py_None;
+ const char *messaging_path = NULL;
+ messaging_Object *ret;
+
+ if (!PyArg_ParseTupleAndKeywords(args, kwargs, "|Oz:connect",
+ discard_const_p(char *, kwnames), &own_id, &messaging_path)) {
+ return NULL;
+ }
+
+ ret = PyObject_New(messaging_Object, &messaging_Type);
+ if (ret == NULL)
+ return NULL;
+
+ ret->mem_ctx = talloc_new(NULL);
+
+ ev = event_context_init(ret->mem_ctx);
+
+ if (messaging_path == NULL) {
+ messaging_path = lp_messaging_path(ret, global_loadparm);
+ } else {
+ messaging_path = talloc_strdup(ret->mem_ctx, messaging_path);
+ }
+
+ if (own_id != Py_None) {
+ struct server_id server_id;
+
+ if (!server_id_from_py(own_id, &server_id))
+ return NULL;
+
+ ret->msg_ctx = messaging_init(ret->mem_ctx,
+ messaging_path,
+ server_id,
+ lp_iconv_convenience(global_loadparm),
+ ev);
+ } else {
+ ret->msg_ctx = messaging_client_init(ret->mem_ctx,
+ messaging_path,
+ lp_iconv_convenience(global_loadparm),
+ ev);
+ }
+
+ if (ret->msg_ctx == NULL) {
+ PyErr_SetString(PyExc_RuntimeError, "messaging_connect unable to create a messaging context");
+ talloc_free(ret->mem_ctx);
+ return NULL;
+ }
+
+ return (PyObject *)ret;
+}
+
+static void py_messaging_dealloc(PyObject *self)
+{
+ messaging_Object *iface = (messaging_Object *)self;
+ talloc_free(iface->msg_ctx);
+ PyObject_Del(self);
+}
+
+static PyObject *py_messaging_send(PyObject *self, PyObject *args, PyObject *kwargs)
+{
+ messaging_Object *iface = (messaging_Object *)self;
+ uint32_t msg_type;
+ DATA_BLOB data;
+ PyObject *target;
+ NTSTATUS status;
+ struct server_id server;
+ const char *kwnames[] = { "target", "msg_type", "data", NULL };
+
+ if (!PyArg_ParseTupleAndKeywords(args, kwargs, "Ois#|:send",
+ discard_const_p(char *, kwnames), &target, &msg_type, &data.data, &data.length)) {
+ return NULL;
+ }
+
+ if (!server_id_from_py(target, &server))
+ return NULL;
+
+ status = messaging_send(iface->msg_ctx, server, msg_type, &data);
+ if (NT_STATUS_IS_ERR(status)) {
+ PyErr_SetNTSTATUS(status);
+ return NULL;
+ }
+
+ return Py_None;
+}
+
+static void py_msg_callback_wrapper(struct messaging_context *msg, void *private,
+ uint32_t msg_type,
+ struct server_id server_id, DATA_BLOB *data)
+{
+ PyObject *callback = (PyObject *)private;
+
+ PyObject_CallFunction(callback, discard_const_p(char, "i(iii)s#"), msg_type,
+ server_id.id, server_id.id2, server_id.node,
+ data->data, data->length);
+}
+
+static PyObject *py_messaging_register(PyObject *self, PyObject *args, PyObject *kwargs)
+{
+ messaging_Object *iface = (messaging_Object *)self;
+ uint32_t msg_type = -1;
+ PyObject *callback;
+ NTSTATUS status;
+ const char *kwnames[] = { "callback", "msg_type", NULL };
+
+ if (!PyArg_ParseTupleAndKeywords(args, kwargs, "O|i:send",
+ discard_const_p(char *, kwnames), &callback, &msg_type)) {
+ return NULL;
+ }
+
+ Py_INCREF(callback);
+
+ if (msg_type == -1) {
+ status = messaging_register_tmp(iface->msg_ctx, callback,
+ py_msg_callback_wrapper, &msg_type);
+ } else {
+ status = messaging_register(iface->msg_ctx, callback,
+ msg_type, py_msg_callback_wrapper);
+ }
+ if (NT_STATUS_IS_ERR(status)) {
+ PyErr_SetNTSTATUS(status);
+ return NULL;
+ }
+
+ return PyLong_FromLong(msg_type);
+}
+
+static PyObject *py_messaging_deregister(PyObject *self, PyObject *args, PyObject *kwargs)
+{
+ messaging_Object *iface = (messaging_Object *)self;
+ uint32_t msg_type = -1;
+ PyObject *callback;
+ const char *kwnames[] = { "callback", "msg_type", NULL };
+
+ if (!PyArg_ParseTupleAndKeywords(args, kwargs, "O|i:send",
+ discard_const_p(char *, kwnames), &callback, &msg_type)) {
+ return NULL;
+ }
+
+ messaging_deregister(iface->msg_ctx, msg_type, callback);
+
+ Py_DECREF(callback);
+
+ return Py_None;
+}
+
+static PyObject *py_messaging_add_name(PyObject *self, PyObject *args, PyObject *kwargs)
+{
+ messaging_Object *iface = (messaging_Object *)self;
+ NTSTATUS status;
+ char *name;
+ const char *kwnames[] = { "name", NULL };
+
+ if (!PyArg_ParseTupleAndKeywords(args, kwargs, "s|:send",
+ discard_const_p(char *, kwnames), &name)) {
+ return NULL;
+ }
+
+ status = irpc_add_name(iface->msg_ctx, name);
+ if (NT_STATUS_IS_ERR(status)) {
+ PyErr_SetNTSTATUS(status);
+ return NULL;
+ }
+
+ return Py_None;
+}
+
+
+static PyObject *py_messaging_remove_name(PyObject *self, PyObject *args, PyObject *kwargs)
+{
+ messaging_Object *iface = (messaging_Object *)self;
+ char *name;
+ const char *kwnames[] = { "name", NULL };
+
+ if (!PyArg_ParseTupleAndKeywords(args, kwargs, "s|:send",
+ discard_const_p(char *, kwnames), &name)) {
+ return NULL;
+ }
+
+ irpc_remove_name(iface->msg_ctx, name);
+
+ return Py_None;
+}
+
+static PyMethodDef py_messaging_methods[] = {
+ { "send", (PyCFunction)py_messaging_send, METH_VARARGS|METH_KEYWORDS,
+ "S.send(target, msg_type, data) -> None\nSend a message" },
+ { "register", (PyCFunction)py_messaging_register, METH_VARARGS|METH_KEYWORDS,
+ "S.register(callback, msg_type=None) -> msg_type\nRegister a message handler" },
+ { "deregister", (PyCFunction)py_messaging_deregister, METH_VARARGS|METH_KEYWORDS,
+ "S.deregister(callback, msg_type) -> None\nDeregister a message handler" },
+ { "add_name", (PyCFunction)py_messaging_add_name, METH_VARARGS|METH_KEYWORDS, "S.add_name(name) -> None\nListen on another name" },
+ { "remove_name", (PyCFunction)py_messaging_remove_name, METH_VARARGS|METH_KEYWORDS, "S.remove_name(name) -> None\nStop listening on a name" },
+ { NULL, NULL, 0, NULL }
+};
+
+static PyObject *py_messaging_server_id(PyObject *obj, void *closure)
+{
+ messaging_Object *iface = (messaging_Object *)obj;
+ struct server_id server_id = messaging_get_server_id(iface->msg_ctx);
+
+ return Py_BuildValue("(iii)", server_id.id, server_id.id2,
+ server_id.node);
+}
+
+static PyGetSetDef py_messaging_getset[] = {
+ { discard_const_p(char, "server_id"), py_messaging_server_id, NULL,
+ discard_const_p(char, "local server id") },
+ { NULL },
+};
+
+
+PyTypeObject messaging_Type = {
+ PyObject_HEAD_INIT(NULL) 0,
+ .tp_name = "irpc.Messaging",
+ .tp_basicsize = sizeof(messaging_Object),
+ .tp_flags = Py_TPFLAGS_DEFAULT|Py_TPFLAGS_BASETYPE,
+ .tp_new = py_messaging_connect,
+ .tp_dealloc = py_messaging_dealloc,
+ .tp_methods = py_messaging_methods,
+ .tp_getset = py_messaging_getset,
+ .tp_doc = "Messaging(own_id=None, messaging_path=None)\n" \
+ "Create a new object that can be used to communicate with the peers in the specified messaging path.\n" \
+ "If no path is specified, the default path from smb.conf will be used."
+};
+
+
+/*
+ state of a irpc 'connection'
+*/
+typedef struct {
+ PyObject_HEAD
+ const char *server_name;
+ struct server_id *dest_ids;
+ struct messaging_context *msg_ctx;
+ TALLOC_CTX *mem_ctx;
+} irpc_ClientConnectionObject;
+
+/*
+ setup a context for talking to a irpc server
+ example:
+ status = irpc.connect("smb_server");
+*/
+
+PyObject *py_irpc_connect(PyTypeObject *self, PyObject *args, PyObject *kwargs)
+{
+ struct event_context *ev;
+ const char *kwnames[] = { "server", "own_id", "messaging_path", NULL };
+ char *server;
+ const char *messaging_path = NULL;
+ PyObject *own_id = Py_None;
+ irpc_ClientConnectionObject *ret;
+
+ if (!PyArg_ParseTupleAndKeywords(args, kwargs, "s|Oz:connect",
+ discard_const_p(char *, kwnames), &server, &own_id, &messaging_path)) {
+ return NULL;
+ }
+
+ ret = PyObject_New(irpc_ClientConnectionObject, &irpc_ClientConnectionType);
+ if (ret == NULL)
+ return NULL;
+
+ ret->mem_ctx = talloc_new(NULL);
+
+ ret->server_name = server;
+
+ ev = event_context_init(ret->mem_ctx);
+
+ if (messaging_path == NULL) {
+ messaging_path = lp_messaging_path(ret, global_loadparm);
+ } else {
+ messaging_path = talloc_strdup(ret->mem_ctx, messaging_path);
+ }
+
+ if (own_id != Py_None) {
+ struct server_id server_id;
+
+ if (!server_id_from_py(own_id, &server_id))
+ return NULL;
+
+ ret->msg_ctx = messaging_init(ret->mem_ctx,
+ messaging_path,
+ server_id,
+ lp_iconv_convenience(global_loadparm),
+ ev);
+ } else {
+ ret->msg_ctx = messaging_client_init(ret->mem_ctx,
+ messaging_path,
+ lp_iconv_convenience(global_loadparm),
+ ev);
+ }
+
+ if (ret->msg_ctx == NULL) {
+ PyErr_SetString(PyExc_RuntimeError, "irpc_connect unable to create a messaging context");
+ talloc_free(ret->mem_ctx);
+ return NULL;
+ }
+
+ ret->dest_ids = irpc_servers_byname(ret->msg_ctx, ret->mem_ctx, ret->server_name);
+ if (ret->dest_ids == NULL || ret->dest_ids[0].id == 0) {
+ talloc_free(ret->mem_ctx);
+ PyErr_SetNTSTATUS(NT_STATUS_OBJECT_NAME_NOT_FOUND);
+ return NULL;
+ } else {
+ return (PyObject *)ret;
+ }
+}
+
+typedef struct {
+ PyObject_HEAD
+ struct irpc_request **reqs;
+ int count;
+ int current;
+ TALLOC_CTX *mem_ctx;
+ py_data_unpack_fn unpack_fn;
+} irpc_ResultObject;
+
+
+static PyObject *irpc_result_next(irpc_ResultObject *iterator)
+{
+ NTSTATUS status;
+
+ if (iterator->current >= iterator->count) {
+ PyErr_SetString(PyExc_StopIteration, "No more results");
+ return NULL;
+ }
+
+ status = irpc_call_recv(iterator->reqs[iterator->current]);
+ iterator->current++;
+ if (!NT_STATUS_IS_OK(status)) {
+ PyErr_SetNTSTATUS(status);
+ return NULL;
+ }
+
+ return iterator->unpack_fn(iterator->reqs[iterator->current-1]->r);
+}
+
+static PyObject *irpc_result_len(irpc_ResultObject *self)
+{
+ return PyLong_FromLong(self->count);
+}
+
+static PyMethodDef irpc_result_methods[] = {
+ { "__len__", (PyCFunction)irpc_result_len, METH_NOARGS,
+ "Number of elements returned"},
+ { NULL }
+};
+
+static void irpc_result_dealloc(PyObject *self)
+{
+ talloc_free(((irpc_ResultObject *)self)->mem_ctx);
+ PyObject_Del(self);
+}
+
+PyTypeObject irpc_ResultIteratorType = {
+ PyObject_HEAD_INIT(NULL) 0,
+ .tp_name = "irpc.ResultIterator",
+ .tp_basicsize = sizeof(irpc_ResultObject),
+ .tp_flags = Py_TPFLAGS_DEFAULT|Py_TPFLAGS_BASETYPE,
+ .tp_iternext = (iternextfunc)irpc_result_next,
+ .tp_iter = PyObject_SelfIter,
+ .tp_methods = irpc_result_methods,
+ .tp_dealloc = irpc_result_dealloc,
+};
+
+static PyObject *py_irpc_call(irpc_ClientConnectionObject *p, struct PyNdrRpcMethodDef *method_def, PyObject *args, PyObject *kwargs)
+{
+ void *ptr;
+ struct irpc_request **reqs;
+ int i, count;
+ NTSTATUS status;
+ TALLOC_CTX *mem_ctx = talloc_new(NULL);
+ irpc_ResultObject *ret;
+
+ /* allocate the C structure */
+ ptr = talloc_zero_size(mem_ctx, method_def->table->calls[method_def->opnum].struct_size);
+ if (ptr == NULL) {
+ status = NT_STATUS_NO_MEMORY;
+ goto done;
+ }
+
+ /* convert the mpr object into a C structure */
+ if (!method_def->pack_in_data(args, kwargs, ptr)) {
+ talloc_free(mem_ctx);
+ return NULL;
+ }
+
+ for (count=0;p->dest_ids[count].id;count++) /* noop */ ;
+
+ /* we need to make a call per server */
+ reqs = talloc_array(mem_ctx, struct irpc_request *, count);
+ if (reqs == NULL) {
+ status = NT_STATUS_NO_MEMORY;
+ goto done;
+ }
+
+ /* make the actual calls */
+ for (i=0;i<count;i++) {
+ reqs[i] = irpc_call_send(p->msg_ctx, p->dest_ids[i],
+ method_def->table, method_def->opnum, ptr, ptr);
+ if (reqs[i] == NULL) {
+ status = NT_STATUS_NO_MEMORY;
+ goto done;
+ }
+ talloc_steal(reqs, reqs[i]);
+ }
+
+ ret = PyObject_New(irpc_ResultObject, &irpc_ResultIteratorType);
+ ret->mem_ctx = mem_ctx;
+ ret->reqs = reqs;
+ ret->count = count;
+ ret->current = 0;
+ ret->unpack_fn = method_def->unpack_out_data;
+
+ return (PyObject *)ret;
+done:
+ talloc_free(mem_ctx);
+ PyErr_SetNTSTATUS(status);
+ return NULL;
+}
+
+static PyObject *py_irpc_call_wrapper(PyObject *self, PyObject *args, void *wrapped, PyObject *kwargs)
+{
+ irpc_ClientConnectionObject *iface = (irpc_ClientConnectionObject *)self;
+ struct PyNdrRpcMethodDef *md = wrapped;
+
+ return py_irpc_call(iface, md, args, kwargs);
+}
+
+static void py_irpc_dealloc(PyObject *self)
+{
+ irpc_ClientConnectionObject *iface = (irpc_ClientConnectionObject *)self;
+ talloc_free(iface->mem_ctx);
+ PyObject_Del(self);
+}
+
+PyTypeObject irpc_ClientConnectionType = {
+ PyObject_HEAD_INIT(NULL) 0,
+ .tp_name = "irpc.ClientConnection",
+ .tp_basicsize = sizeof(irpc_ClientConnectionObject),
+ .tp_flags = Py_TPFLAGS_DEFAULT|Py_TPFLAGS_BASETYPE,
+ .tp_new = py_irpc_connect,
+ .tp_dealloc = py_irpc_dealloc,
+ .tp_doc = "ClientConnection(server, own_id=None, messaging_path=None)\n" \
+ "Create a new IRPC client connection to communicate with the servers in the specified path.\n" \
+ "If no path is specified, the default path from smb.conf will be used."
+};
+
+static bool irpc_AddNdrRpcMethods(PyTypeObject *ifacetype, const struct PyNdrRpcMethodDef *mds)
+{
+ int i;
+ for (i = 0; mds[i].name; i++) {
+ PyObject *ret;
+ struct wrapperbase *wb = calloc(sizeof(struct wrapperbase), 1);
+
+ wb->name = discard_const_p(char, mds[i].name);
+ wb->flags = PyWrapperFlag_KEYWORDS;
+ wb->wrapper = (wrapperfunc)py_irpc_call_wrapper;
+ wb->doc = discard_const_p(char, mds[i].doc);
+
+ ret = PyDescr_NewWrapper(ifacetype, wb, discard_const_p(void, &mds[i]));
+
+ PyDict_SetItemString(ifacetype->tp_dict, mds[i].name,
+ (PyObject *)ret);
+ }
+
+ return true;
+}
+
+void initmessaging(void)
+{
+ extern void initirpc(void);
+ PyObject *mod;
+
+ if (PyType_Ready(&irpc_ClientConnectionType) < 0)
+ return;
+
+ if (PyType_Ready(&messaging_Type) < 0)
+ return;
+
+ if (PyType_Ready(&irpc_ResultIteratorType) < 0)
+ return;
+
+ if (!irpc_AddNdrRpcMethods(&irpc_ClientConnectionType, py_ndr_irpc_methods))
+ return;
+
+ mod = Py_InitModule3("messaging", NULL, "Internal RPC");
+ if (mod == NULL)
+ return;
+
+ initirpc();
+
+ Py_INCREF((PyObject *)&irpc_ClientConnectionType);
+ PyModule_AddObject(mod, "ClientConnection", (PyObject *)&irpc_ClientConnectionType);
+
+ Py_INCREF((PyObject *)&messaging_Type);
+ PyModule_AddObject(mod, "Messaging", (PyObject *)&messaging_Type);
+}
diff --git a/source4/lib/messaging/tests/bindings.py b/source4/lib/messaging/tests/bindings.py
new file mode 100644
index 0000000000..c89538ddfa
--- /dev/null
+++ b/source4/lib/messaging/tests/bindings.py
@@ -0,0 +1,57 @@
+#!/usr/bin/python
+# -*- coding: utf-8 -*-
+
+# Unix SMB/CIFS implementation.
+# 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
+# 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.messaging import Messaging
+from unittest import TestCase
+
+class MessagingTests(TestCase):
+ def get_context(self, *args, **kwargs):
+ kwargs["messaging_path"] = "."
+ return Messaging(*args, **kwargs)
+
+ def test_register(self):
+ x = self.get_context()
+ def callback():
+ pass
+ msg_type = x.register(callback)
+ x.deregister(callback, msg_type)
+
+ def test_assign_server_id(self):
+ x = self.get_context()
+ self.assertTrue(isinstance(x.server_id, tuple))
+ self.assertEquals(3, len(x.server_id))
+
+ def test_ping_speed(self):
+ server_ctx = self.get_context((0, 1))
+ def ping_callback(src, data):
+ server_ctx.send(src, data)
+ def exit_callback():
+ print "received exit"
+ msg_ping = server_ctx.register(ping_callback)
+ msg_exit = server_ctx.register(exit_callback)
+
+ def pong_callback():
+ print "received pong"
+ client_ctx = self.get_context((0, 2))
+ msg_pong = client_ctx.register(pong_callback)
+
+ client_ctx.send((0,1), msg_ping, "testing")
+ client_ctx.send((0,1), msg_ping, "")
+
diff --git a/source4/lib/registry/config.mk b/source4/lib/registry/config.mk
index 44adc53524..fd1fd01a09 100644
--- a/source4/lib/registry/config.mk
+++ b/source4/lib/registry/config.mk
@@ -5,12 +5,11 @@ TDR_REGF_OBJ_FILES = $(libregistrysrcdir)/tdr_regf.o
# Special support for external builddirs
$(libregistrysrcdir)/regf.c: $(libregistrysrcdir)/tdr_regf.c
-$(srcdir)/$(libregistrysrcdir)/regf.c: $(libregistrysrcdir)/tdr_regf.c
$(libregistrysrcdir)/tdr_regf.h: $(libregistrysrcdir)/tdr_regf.c
-$(libregistrysrcdir)/tdr_regf.c: $(srcdir)/$(libregistrysrcdir)/regf.idl
- @CPP="$(CPP)" srcdir="$(srcdir)" $(PERL) $(srcdir)/pidl/pidl $(PIDL_ARGS) \
- --header --outputdir=lib/registry \
- --tdr-parser -- $(srcdir)/$(libregistrysrcdir)/regf.idl
+$(libregistrysrcdir)/tdr_regf.c: $(libregistrysrcdir)/regf.idl
+ @CPP="$(CPP)" $(PERL) $(pidldir)/pidl $(PIDL_ARGS) \
+ --header --outputdir=$(libregistrysrcdir) \
+ --tdr-parser -- $(libregistrysrcdir)/regf.idl
clean::
@-rm -f $(libregistrysrcdir)/regf.h $(libregistrysrcdir)/tdr_regf*
diff --git a/source4/lib/registry/hive.c b/source4/lib/registry/hive.c
index 4a2309faee..5105040f30 100644
--- a/source4/lib/registry/hive.c
+++ b/source4/lib/registry/hive.c
@@ -144,6 +144,24 @@ WERROR hive_get_value_by_index(TALLOC_CTX *mem_ctx,
return key->ops->enum_value(mem_ctx, key, idx, name, type, data);
}
+WERROR hive_get_sec_desc(TALLOC_CTX *mem_ctx,
+ struct hive_key *key,
+ struct security_descriptor **security)
+{
+ if (key->ops->get_sec_desc == NULL)
+ return WERR_NOT_SUPPORTED;
+
+ return key->ops->get_sec_desc(mem_ctx, key, security);
+}
+
+WERROR hive_set_sec_desc(struct hive_key *key,
+ const struct security_descriptor *security)
+{
+ if (key->ops->set_sec_desc == NULL)
+ return WERR_NOT_SUPPORTED;
+
+ return key->ops->set_sec_desc(key, security);
+}
WERROR hive_key_del_value(struct hive_key *key, const char *name)
{
diff --git a/source4/lib/registry/interface.c b/source4/lib/registry/interface.c
index ff3ddf0a35..c9b3b06447 100644
--- a/source4/lib/registry/interface.c
+++ b/source4/lib/registry/interface.c
@@ -248,10 +248,10 @@ _PUBLIC_ WERROR reg_get_sec_desc(TALLOC_CTX *ctx,
return WERR_INVALID_PARAM;
/* A 'real' set function has preference */
- if (key->context->ops->get_security == NULL)
+ if (key->context->ops->get_sec_desc == NULL)
return WERR_NOT_SUPPORTED;
- return key->context->ops->get_security(ctx, key, secdesc);
+ return key->context->ops->get_sec_desc(ctx, key, secdesc);
}
/**
@@ -282,27 +282,14 @@ _PUBLIC_ WERROR reg_key_flush(struct registry_key *key)
return key->context->ops->flush_key(key);
}
-_PUBLIC_ WERROR reg_get_security(TALLOC_CTX *mem_ctx,
- const struct registry_key *key,
- struct security_descriptor **security)
-{
- if (key == NULL)
- return WERR_INVALID_PARAM;
-
- if (key->context->ops->get_security == NULL)
- return WERR_NOT_SUPPORTED;
-
- return key->context->ops->get_security(mem_ctx, key, security);
-}
-
-_PUBLIC_ WERROR reg_set_security(struct registry_key *key,
- struct security_descriptor *security)
+_PUBLIC_ WERROR reg_set_sec_desc(struct registry_key *key,
+ const struct security_descriptor *security)
{
if (key == NULL)
return WERR_INVALID_PARAM;
- if (key->context->ops->set_security == NULL)
+ if (key->context->ops->set_sec_desc == NULL)
return WERR_NOT_SUPPORTED;
- return key->context->ops->set_security(key, security);
+ return key->context->ops->set_sec_desc(key, security);
}
diff --git a/source4/lib/registry/local.c b/source4/lib/registry/local.c
index 47d6d4cd32..4af95e2dd6 100644
--- a/source4/lib/registry/local.c
+++ b/source4/lib/registry/local.c
@@ -274,7 +274,21 @@ static WERROR local_get_key_info(TALLOC_CTX *mem_ctx,
last_change_time, max_subkeynamelen,
max_valnamelen, max_valbufsize);
}
+static WERROR local_get_sec_desc(TALLOC_CTX *mem_ctx,
+ const struct registry_key *key,
+ struct security_descriptor **security)
+{
+ const struct local_key *local = (const struct local_key *)key;
+ return hive_get_sec_desc(mem_ctx, local->hive_key, security);
+}
+static WERROR local_set_sec_desc(struct registry_key *key,
+ const struct security_descriptor *security)
+{
+ const struct local_key *local = (const struct local_key *)key;
+
+ return hive_set_sec_desc(local->hive_key, security);
+}
const static struct registry_operations local_ops = {
.name = "local",
.open_key = local_open_key,
@@ -288,6 +302,8 @@ const static struct registry_operations local_ops = {
.delete_value = local_delete_value,
.flush_key = local_flush_key,
.get_key_info = local_get_key_info,
+ .get_sec_desc = local_get_sec_desc,
+ .set_sec_desc = local_set_sec_desc,
};
WERROR reg_open_local(TALLOC_CTX *mem_ctx, struct registry_context **ctx)
diff --git a/source4/lib/registry/patchfile.c b/source4/lib/registry/patchfile.c
index 15e3a158f2..0ede3106f0 100644
--- a/source4/lib/registry/patchfile.c
+++ b/source4/lib/registry/patchfile.c
@@ -45,7 +45,7 @@ WERROR reg_generate_diff_key(struct registry_key *oldkey,
void *callback_data)
{
int i;
- struct registry_key *t1, *t2;
+ struct registry_key *t1 = NULL, *t2 = NULL;
char *tmppath;
const char *keyname1;
WERROR error, error1, error2;
@@ -295,7 +295,7 @@ _PUBLIC_ WERROR reg_diff_load(const char *filename,
/* Reset position in file */
lseek(fd, 0, SEEK_SET);
-#if 0
+#if 0 /* These backends are not supported yet. */
if (strncmp(hdr, "CREG", 4) == 0) {
/* Must be a W9x CREG Config.pol file */
return reg_creg_diff_load(diff, fd);
@@ -320,12 +320,33 @@ static WERROR reg_diff_apply_add_key(void *_ctx, const char *key_name)
{
struct registry_context *ctx = (struct registry_context *)_ctx;
struct registry_key *tmp;
+ char *buf, *buf_ptr;
WERROR error;
+ /* Recursively create the path */
+ buf = talloc_strdup(ctx, key_name);
+ buf_ptr = buf;
+
+ while (*buf_ptr++ != '\0' ) {
+ if (*buf_ptr == '\\') {
+ *buf_ptr = '\0';
+ error = reg_key_add_abs(ctx, ctx, buf, 0, NULL, &tmp);
+
+ if (!W_ERROR_EQUAL(error, WERR_ALREADY_EXISTS) &&
+ !W_ERROR_IS_OK(error)) {
+ DEBUG(0, ("Error adding new key '%s': %s\n",
+ key_name, win_errstr(error)));
+ return error;
+ }
+ *buf_ptr++ = '\\';
+ }
+ }
+
+ /* Add the key */
error = reg_key_add_abs(ctx, ctx, key_name, 0, NULL, &tmp);
if (!W_ERROR_EQUAL(error, WERR_ALREADY_EXISTS) &&
- !W_ERROR_IS_OK(error)) {
+ !W_ERROR_IS_OK(error)) {
DEBUG(0, ("Error adding new key '%s': %s\n",
key_name, win_errstr(error)));
return error;
diff --git a/source4/lib/registry/patchfile_dotreg.c b/source4/lib/registry/patchfile_dotreg.c
index 59f4044713..1bc9c60753 100644
--- a/source4/lib/registry/patchfile_dotreg.c
+++ b/source4/lib/registry/patchfile_dotreg.c
@@ -3,7 +3,7 @@
Reading .REG files
Copyright (C) Jelmer Vernooij 2004-2007
- Copyright (C) Wilco Baan Hofman 2006
+ Copyright (C) Wilco Baan Hofman 2006-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
@@ -20,7 +20,7 @@
Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
*/
-/* FIXME Newer .REG files, created by Windows XP and above use unicode UTF-16 */
+/* FIXME Newer .REG files, created by Windows XP and above use unicode UCS-2 */
#include "includes.h"
#include "lib/registry/registry.h"
@@ -112,8 +112,8 @@ _PUBLIC_ WERROR reg_dotreg_diff_save(TALLOC_CTX *ctx, const char *filename,
data->iconv_convenience = iconv_convenience;
if (filename) {
- data->fd = open(filename, O_CREAT, 0755);
- if (data->fd == -1) {
+ data->fd = open(filename, O_CREAT|O_WRONLY, 0755);
+ if (data->fd < 0) {
DEBUG(0, ("Unable to open %s\n", filename));
return WERR_BADFILE;
}
@@ -121,7 +121,7 @@ _PUBLIC_ WERROR reg_dotreg_diff_save(TALLOC_CTX *ctx, const char *filename,
data->fd = STDOUT_FILENO;
}
- fdprintf(data->fd, "%s\n", HEADER_STRING);
+ fdprintf(data->fd, "%s\n\n", HEADER_STRING);
*callbacks = talloc(ctx, struct reg_diff_callbacks);
diff --git a/source4/lib/registry/patchfile_preg.c b/source4/lib/registry/patchfile_preg.c
index 0fa367bfcb..bb46495c19 100644
--- a/source4/lib/registry/patchfile_preg.c
+++ b/source4/lib/registry/patchfile_preg.c
@@ -2,7 +2,7 @@
Unix SMB/CIFS implementation.
Reading Registry.pol PReg registry files
- Copyright (C) Wilco Baan Hofman 2006
+ Copyright (C) Wilco Baan Hofman 2006-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
@@ -23,9 +23,12 @@
#include "lib/registry/registry.h"
#include "system/filesys.h"
#include "param/param.h"
+#include "librpc/gen_ndr/winreg.h"
struct preg_data {
int fd;
+ TALLOC_CTX *ctx;
+ struct smb_iconv_convenience *ic;
};
static WERROR preg_read_utf16(struct smb_iconv_convenience *ic, int fd, char *c)
@@ -38,14 +41,22 @@ static WERROR preg_read_utf16(struct smb_iconv_convenience *ic, int fd, char *c)
push_codepoint(ic, c, v);
return WERR_OK;
}
-
-/* FIXME These functions need to be implemented */
-static WERROR reg_preg_diff_add_key(void *_data, const char *key_name)
+static WERROR preg_write_utf16(struct smb_iconv_convenience *ic, int fd, const char *string)
{
+ codepoint_t v;
+ uint16_t i;
+ size_t size;
+
+ for (i = 0; i < strlen(string); i+=size) {
+ v = next_codepoint(ic, &string[i], &size);
+ if (write(fd, &v, 2) < 2) {
+ return WERR_GENERAL_FAILURE;
+ }
+ }
return WERR_OK;
}
-
-static WERROR reg_preg_diff_del_key(void *_data, const char *key_name)
+/* PReg does not support adding keys. */
+static WERROR reg_preg_diff_add_key(void *_data, const char *key_name)
{
return WERR_OK;
}
@@ -54,24 +65,73 @@ static WERROR reg_preg_diff_set_value(void *_data, const char *key_name,
const char *value_name,
uint32_t value_type, DATA_BLOB value_data)
{
+ struct preg_data *data = _data;
+ uint32_t buf;
+
+ preg_write_utf16(data->ic, data->fd, "[");
+ preg_write_utf16(data->ic, data->fd, key_name);
+ preg_write_utf16(data->ic, data->fd, ";");
+ preg_write_utf16(data->ic, data->fd, value_name);
+ preg_write_utf16(data->ic, data->fd, ";");
+ SIVAL(&buf, 0, value_type);
+ write(data->fd, &buf, sizeof(uint32_t));
+ preg_write_utf16(data->ic, data->fd, ";");
+ SIVAL(&buf, 0, value_data.length);
+ write(data->fd, &buf, sizeof(uint32_t));
+ preg_write_utf16(data->ic, data->fd, ";");
+ write(data->fd, value_data.data, value_data.length);
+ preg_write_utf16(data->ic, data->fd, "]");
+
return WERR_OK;
}
+static WERROR reg_preg_diff_del_key(void *_data, const char *key_name)
+{
+ struct preg_data *data = _data;
+ char *parent_name;
+ DATA_BLOB blob;
+
+ parent_name = talloc_strndup(data->ctx, key_name, strrchr(key_name, '\\')-key_name);
+ blob.data = (void *)talloc_strndup(data->ctx, key_name+(strrchr(key_name, '\\')-key_name)+1,
+ strlen(key_name)-(strrchr(key_name, '\\')-key_name));
+ blob.length = strlen((char *)blob.data)+1;
+
+
+ /* FIXME: These values should be accumulated to be written at done(). */
+ return reg_preg_diff_set_value(data, parent_name, "**DeleteKeys", REG_SZ, blob);
+}
+
static WERROR reg_preg_diff_del_value(void *_data, const char *key_name,
const char *value_name)
{
- return WERR_OK;
+ struct preg_data *data = _data;
+ char *val;
+ DATA_BLOB blob;
+
+ val = talloc_asprintf(data->ctx, "**Del.%s", value_name);
+
+ blob.data = (void *)talloc(data->ctx, uint32_t);
+ *(uint32_t *)blob.data = 0;
+ blob.length = 4;
+ return reg_preg_diff_set_value(data, key_name, val, REG_DWORD, blob);
}
static WERROR reg_preg_diff_del_all_values(void *_data, const char *key_name)
{
- return WERR_OK;
+ struct preg_data *data = _data;
+ DATA_BLOB blob;
+
+ blob.data = (void *)talloc(data->ctx, uint32_t);
+ *(uint32_t *)blob.data = 0;
+ blob.length = 4;
+
+ return reg_preg_diff_set_value(data, key_name, "**DelVals.", REG_DWORD, blob);
}
static WERROR reg_preg_diff_done(void *_data)
{
struct preg_data *data = (struct preg_data *)_data;
-
+
close(data->fd);
talloc_free(data);
return WERR_OK;
@@ -81,6 +141,7 @@ static WERROR reg_preg_diff_done(void *_data)
* Save registry diff
*/
_PUBLIC_ WERROR reg_preg_diff_save(TALLOC_CTX *ctx, const char *filename,
+ struct smb_iconv_convenience *ic,
struct reg_diff_callbacks **callbacks,
void **callback_data)
{
@@ -95,18 +156,22 @@ _PUBLIC_ WERROR reg_preg_diff_save(TALLOC_CTX *ctx, const char *filename,
*callback_data = data;
if (filename) {
- data->fd = open(filename, O_CREAT, 0755);
- if (data->fd == -1) {
+ data->fd = open(filename, O_CREAT|O_WRONLY, 0755);
+ if (data->fd < 0) {
DEBUG(0, ("Unable to open %s\n", filename));
return WERR_BADFILE;
}
} else {
data->fd = STDOUT_FILENO;
}
- snprintf(preg_header.hdr, 4, "PReg");
+
+ strncpy(preg_header.hdr, "PReg", 4);
SIVAL(&preg_header, 4, 1);
write(data->fd, (uint8_t *)&preg_header,8);
+ data->ctx = ctx;
+ data->ic = ic;
+
*callbacks = talloc(ctx, struct reg_diff_callbacks);
(*callbacks)->add_key = reg_preg_diff_add_key;
@@ -149,6 +214,8 @@ _PUBLIC_ WERROR reg_preg_diff_load(int fd,
ret = WERR_GENERAL_FAILURE;
goto cleanup;
}
+ preg_header.version = IVAL(&preg_header.version, 0);
+
if (strncmp(preg_header.hdr, "PReg", 4) != 0) {
DEBUG(0, ("This file is not a valid preg registry file\n"));
ret = WERR_GENERAL_FAILURE;
@@ -177,7 +244,8 @@ _PUBLIC_ WERROR reg_preg_diff_load(int fd,
*buf_ptr != ';' && buf_ptr-buf < buf_size) {
buf_ptr++;
}
- key = talloc_asprintf(mem_ctx, "\\%s", buf);
+ buf[buf_ptr-buf] = '\0';
+ key = talloc_strdup(mem_ctx, buf);
/* Get the name */
buf_ptr = buf;
@@ -185,6 +253,7 @@ _PUBLIC_ WERROR reg_preg_diff_load(int fd,
*buf_ptr != ';' && buf_ptr-buf < buf_size) {
buf_ptr++;
}
+ buf[buf_ptr-buf] = '\0';
value_name = talloc_strdup(mem_ctx, buf);
/* Get the type */
@@ -193,6 +262,8 @@ _PUBLIC_ WERROR reg_preg_diff_load(int fd,
ret = WERR_GENERAL_FAILURE;
goto cleanup;
}
+ value_type = IVAL(&value_type, 0);
+
/* Read past delimiter */
buf_ptr = buf;
if (!(W_ERROR_IS_OK(preg_read_utf16(iconv_convenience, fd, buf_ptr)) &&
diff --git a/source4/lib/registry/regf.c b/source4/lib/registry/regf.c
index 46ccca922b..57a895aa00 100644
--- a/source4/lib/registry/regf.c
+++ b/source4/lib/registry/regf.c
@@ -25,6 +25,8 @@
#include "librpc/gen_ndr/winreg.h"
#include "param/param.h"
#include "lib/registry/registry.h"
+#include "libcli/security/security.h"
+
static struct hive_operations reg_backend_regf;
@@ -1915,9 +1917,12 @@ WERROR reg_create_regf_file(TALLOC_CTX *parent_ctx,
{
struct regf_data *regf;
struct regf_hdr *regf_hdr;
- int i;
struct nk_block nk;
+ struct sk_block sk;
WERROR error;
+ DATA_BLOB data;
+ struct security_descriptor *sd;
+ uint32_t sk_offset;
regf = (struct regf_data *)talloc_zero(NULL, struct regf_data);
@@ -1945,20 +1950,17 @@ WERROR reg_create_regf_file(TALLOC_CTX *parent_ctx,
regf_hdr->version.minor = minor_version;
regf_hdr->last_block = 0x1000; /* Block size */
regf_hdr->description = talloc_strdup(regf_hdr,
- "registry created by Samba 4");
+ "Registry created by Samba 4");
W_ERROR_HAVE_NO_MEMORY(regf_hdr->description);
regf_hdr->chksum = 0;
regf->header = regf_hdr;
- i = 0;
/* Create all hbin blocks */
regf->hbins = talloc_array(regf, struct hbin_block *, 1);
W_ERROR_HAVE_NO_MEMORY(regf->hbins);
regf->hbins[0] = NULL;
- regf_hdr->data_offset = -1; /* FIXME */
-
nk.header = "nk";
nk.type = REG_SUB_KEY;
unix_to_nt_time(&nk.last_change, time(NULL));
@@ -1971,27 +1973,67 @@ WERROR reg_create_regf_file(TALLOC_CTX *parent_ctx,
nk.num_values = 0;
nk.values_offset = -1;
memset(nk.unk3, 0, 5);
- nk.clsname_offset = -1; /* FIXME: fill in */
+ nk.clsname_offset = -1;
nk.clsname_length = 0;
- nk.key_name = "";
+ nk.sk_offset = 0x80;
+ nk.key_name = "SambaRootKey";
+
+ /*
+ * It should be noted that changing the key_name to something shorter
+ * creates a shorter nk block, which makes the position of the sk block
+ * change. All Windows registries I've seen have the sk at 0x80.
+ * I therefore recommend that our regf files share that offset -- Wilco
+ */
+
+ /* Create a security descriptor. */
+ sd = security_descriptor_dacl_create(regf,
+ 0,
+ NULL, NULL,
+ SID_NT_AUTHENTICATED_USERS,
+ SEC_ACE_TYPE_ACCESS_ALLOWED,
+ SEC_GENERIC_ALL,
+ SEC_ACE_FLAG_OBJECT_INHERIT,
+ NULL);
+
+ /* Push the security descriptor to a blob */
+ if (!NDR_ERR_CODE_IS_SUCCESS(ndr_push_struct_blob(&data, regf, NULL,
+ sd, (ndr_push_flags_fn_t)ndr_push_security_descriptor))) {
+ DEBUG(0, ("Unable to push security descriptor\n"));
+ return WERR_GENERAL_FAILURE;
+ }
- nk.sk_offset = -1; /* FIXME: fill in */
+ ZERO_STRUCT(sk);
+ sk.header = "sk";
+ sk.prev_offset = 0x80;
+ sk.next_offset = 0x80;
+ sk.ref_cnt = 1;
+ sk.rec_size = data.length;
+ sk.sec_desc = data.data;
/* Store the new nk key */
regf->header->data_offset = hbin_store_tdr(regf,
(tdr_push_fn_t)tdr_push_nk_block,
&nk);
+ /* Store the sk block */
+ sk_offset = hbin_store_tdr(regf,
+ (tdr_push_fn_t) tdr_push_sk_block,
+ &sk);
+ if (sk_offset != 0x80) {
+ DEBUG(0, ("Error storing sk block, should be at 0x80, stored at 0x%x\n", nk.sk_offset));
+ return WERR_GENERAL_FAILURE;
+ }
+
*key = (struct hive_key *)regf_get_key(parent_ctx, regf,
regf->header->data_offset);
- /* We can drop our own reference now that *key will have created one */
- talloc_free(regf);
-
error = regf_save_hbin(regf);
if (!W_ERROR_IS_OK(error)) {
return error;
}
+
+ /* We can drop our own reference now that *key will have created one */
+ talloc_free(regf);
return WERR_OK;
}
diff --git a/source4/lib/registry/registry.h b/source4/lib/registry/registry.h
index 9c0f66b6d6..e134e3e532 100644
--- a/source4/lib/registry/registry.h
+++ b/source4/lib/registry/registry.h
@@ -186,6 +186,12 @@ WERROR hive_get_value_by_index(TALLOC_CTX *mem_ctx,
struct hive_key *key, uint32_t idx,
const char **name,
uint32_t *type, DATA_BLOB *data);
+WERROR hive_get_sec_desc(TALLOC_CTX *mem_ctx,
+ struct hive_key *key,
+ struct security_descriptor **security);
+
+WERROR hive_set_sec_desc(struct hive_key *key,
+ const struct security_descriptor *security);
WERROR hive_key_del_value(struct hive_key *key, const char *name);
@@ -314,11 +320,11 @@ struct registry_operations {
uint32_t *type,
DATA_BLOB *data);
- WERROR (*get_security) (TALLOC_CTX *mem_ctx,
+ WERROR (*get_sec_desc) (TALLOC_CTX *mem_ctx,
const struct registry_key *key,
struct security_descriptor **security);
- WERROR (*set_security) (struct registry_key *key,
+ WERROR (*set_sec_desc) (struct registry_key *key,
const struct security_descriptor *security);
WERROR (*load_key) (struct registry_key *key,
@@ -463,12 +469,8 @@ struct registry_key *reg_import_hive_key(struct registry_context *ctx,
struct hive_key *hive,
uint32_t predef_key,
const char **elements);
-WERROR reg_get_security(TALLOC_CTX *mem_ctx,
- const struct registry_key *key,
- struct security_descriptor **security);
-
-WERROR reg_set_security(struct registry_key *key,
- struct security_descriptor *security);
+WERROR reg_set_sec_desc(struct registry_key *key,
+ const struct security_descriptor *security);
struct reg_diff_callbacks {
WERROR (*add_key) (void *callback_data, const char *key_name);
@@ -492,11 +494,19 @@ WERROR reg_dotreg_diff_save(TALLOC_CTX *ctx, const char *filename,
struct smb_iconv_convenience *iconv_convenience,
struct reg_diff_callbacks **callbacks,
void **callback_data);
+WERROR reg_preg_diff_save(TALLOC_CTX *ctx, const char *filename,
+ struct smb_iconv_convenience *ic,
+ struct reg_diff_callbacks **callbacks,
+ void **callback_data);
WERROR reg_generate_diff_key(struct registry_key *oldkey,
struct registry_key *newkey,
const char *path,
const struct reg_diff_callbacks *callbacks,
void *callback_data);
+WERROR reg_diff_load(const char *filename,
+ struct smb_iconv_convenience *iconv_convenience,
+ const struct reg_diff_callbacks *callbacks,
+ void *callback_data);
diff --git a/source4/lib/registry/registry.i b/source4/lib/registry/registry.i
index 5ffee4bb3d..9420ba2014 100644
--- a/source4/lib/registry/registry.i
+++ b/source4/lib/registry/registry.i
@@ -16,7 +16,11 @@
along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
-%module registry
+%define DOCSTRING
+"Access to various registry formats and the Samba registry."
+%enddef
+
+%module(docstring=DOCSTRING) registry
%{
/* Include headers */
@@ -93,11 +97,20 @@ WERROR reg_open_local(TALLOC_CTX *parent_ctx, struct registry_context **ctx);
typedef struct registry_context {
%extend {
+ %feature("docstring") get_predefined_key_by_name "S.get_predefined_key_by_name(name) -> key\n"
+ "Find a predefined key by name";
WERROR get_predefined_key_by_name(const char *name,
struct registry_key **key);
+ %feature("docstring") key_del_abs "S.key_del_abs(name) -> None\n"
+ "Delete a key by absolute path.";
WERROR key_del_abs(const char *path);
+ %feature("docstring") get_predefined_key "S.get_predefined_key(hkey_id) -> key\n"
+ "Find a predefined key by id";
WERROR get_predefined_key(uint32_t hkey_id, struct registry_key **key);
+ %feature("docstring") diff_apply "S.diff_apply(filename) -> None\n"
+ "Apply the diff from the specified file";
+
WERROR diff_apply(const char *filename);
WERROR generate_diff(struct registry_context *ctx2, const struct reg_diff_callbacks *callbacks,
void *callback_data);
@@ -106,6 +119,8 @@ typedef struct registry_context {
const char **elements=NULL);
struct registry_key *import_hive_key(struct hive_key *hive, uint32_t predef_key, const char **elements);
+ %feature("docstring") mount_hive "S.mount_hive(key, predef_name) -> None\n"
+ "Mount the specified key at the specified path.";
WERROR mount_hive(struct hive_key *key, const char *predef_name)
{
int i;
@@ -130,6 +145,7 @@ typedef struct registry_context {
$result = SWIG_NewPointerObj(*$1, SWIGTYPE_p_hive_key, 0);
}
+%feature("docstring") reg_open_hive "S.__init__(location, session_info=None, credentials=None, loadparm_context=None)";
%rename(hive_key) reg_open_hive;
WERROR reg_open_hive(TALLOC_CTX *parent_ctx, const char *location,
struct auth_session_info *session_info,
@@ -138,6 +154,7 @@ WERROR reg_open_hive(TALLOC_CTX *parent_ctx, const char *location,
struct loadparm_context *lp_ctx,
struct hive_key **root);
+%feature("docstring") reg_open_ldb_file "open_ldb(location, session_info=None, credentials=None, loadparm_context=None) -> key";
%rename(open_ldb) reg_open_ldb_file;
WERROR reg_open_ldb_file(TALLOC_CTX *parent_ctx, const char *location,
struct auth_session_info *session_info,
@@ -146,10 +163,12 @@ WERROR reg_open_ldb_file(TALLOC_CTX *parent_ctx, const char *location,
struct loadparm_context *lp_ctx,
struct hive_key **k);
+%feature("docstring") reg_create_directory "create_dir(location) -> key";
%rename(create_dir) reg_create_directory;
WERROR reg_create_directory(TALLOC_CTX *parent_ctx,
const char *location, struct hive_key **key);
+%feature("docstring") reg_open_directory "open_dir(location) -> key";
%rename(open_dir) reg_open_directory;
WERROR reg_open_directory(TALLOC_CTX *parent_ctx,
const char *location, struct hive_key **key);
@@ -158,15 +177,24 @@ WERROR reg_open_directory(TALLOC_CTX *parent_ctx,
typedef struct hive_key {
%extend {
+ %feature("docstring") del "S.del(name) -> None\n"
+ "Delete a subkey";
WERROR del(const char *name);
+ %feature("docstring") flush "S.flush() -> None\n"
+ "Flush this key to disk";
WERROR flush(void);
+ %feature("docstring") del_value "S.del_value(name) -> None\n"
+ "Delete a value";
WERROR del_value(const char *name);
+ %feature("docstring") set_value "S.set_value(name, type, data) -> None\n"
+ "Set a value";
WERROR set_value(const char *name, uint32_t type, const DATA_BLOB data);
}
} hive_key;
%rename(open_samba) reg_open_samba;
+%feature("docstring") reg_open_samba "open_samba() -> reg";
WERROR reg_open_samba(TALLOC_CTX *mem_ctx,
struct registry_context **ctx,
struct event_context *ev_ctx,
diff --git a/source4/lib/registry/registry.py b/source4/lib/registry/registry.py
index cb20d6039d..0aeefb86c1 100644
--- a/source4/lib/registry/registry.py
+++ b/source4/lib/registry/registry.py
@@ -3,6 +3,10 @@
#
# Don't modify this file, modify the SWIG interface instead.
+"""
+Access to various registry formats and the Samba registry.
+"""
+
import _registry
import new
new_instancemethod = new.instancemethod
@@ -66,6 +70,41 @@ Registry = _registry.Registry
class reg(object):
thisown = _swig_property(lambda x: x.this.own(), lambda x, v: x.this.own(v), doc='The membership flag')
__repr__ = _swig_repr
+ def get_predefined_key_by_name(*args, **kwargs):
+ """
+ S.get_predefined_key_by_name(name) -> key
+ Find a predefined key by name
+ """
+ return _registry.reg_get_predefined_key_by_name(*args, **kwargs)
+
+ def key_del_abs(*args, **kwargs):
+ """
+ S.key_del_abs(name) -> None
+ Delete a key by absolute path.
+ """
+ return _registry.reg_key_del_abs(*args, **kwargs)
+
+ def get_predefined_key(*args, **kwargs):
+ """
+ S.get_predefined_key(hkey_id) -> key
+ Find a predefined key by id
+ """
+ return _registry.reg_get_predefined_key(*args, **kwargs)
+
+ def diff_apply(*args, **kwargs):
+ """
+ S.diff_apply(filename) -> None
+ Apply the diff from the specified file
+ """
+ return _registry.reg_diff_apply(*args, **kwargs)
+
+ def mount_hive(*args):
+ """
+ S.mount_hive(key, predef_name) -> None
+ Mount the specified key at the specified path.
+ """
+ return _registry.reg_mount_hive(*args)
+
def __init__(self, *args, **kwargs):
_registry.reg_swiginit(self,_registry.new_reg(*args, **kwargs))
__swig_destroy__ = _registry.delete_reg
@@ -79,11 +118,26 @@ reg.mount_hive = new_instancemethod(_registry.reg_mount_hive,None,reg)
reg_swigregister = _registry.reg_swigregister
reg_swigregister(reg)
-hive_key = _registry.hive_key
-open_ldb = _registry.open_ldb
-create_dir = _registry.create_dir
-open_dir = _registry.open_dir
-open_samba = _registry.open_samba
+
+def hive_key(*args, **kwargs):
+ """S.__init__(location, session_info=None, credentials=None, loadparm_context=None)"""
+ return _registry.hive_key(*args, **kwargs)
+
+def open_ldb(*args, **kwargs):
+ """open_ldb(location, session_info=None, credentials=None, loadparm_context=None) -> key"""
+ return _registry.open_ldb(*args, **kwargs)
+
+def create_dir(*args, **kwargs):
+ """create_dir(location) -> key"""
+ return _registry.create_dir(*args, **kwargs)
+
+def open_dir(*args, **kwargs):
+ """open_dir(location) -> key"""
+ return _registry.open_dir(*args, **kwargs)
+
+def open_samba(*args, **kwargs):
+ """open_samba() -> reg"""
+ return _registry.open_samba(*args, **kwargs)
HKEY_CLASSES_ROOT = _registry.HKEY_CLASSES_ROOT
HKEY_CURRENT_USER = _registry.HKEY_CURRENT_USER
HKEY_LOCAL_MACHINE = _registry.HKEY_LOCAL_MACHINE
diff --git a/source4/lib/registry/registry_wrap.c b/source4/lib/registry/registry_wrap.c
index d9b85ee937..b066e42b41 100644
--- a/source4/lib/registry/registry_wrap.c
+++ b/source4/lib/registry/registry_wrap.c
@@ -3798,10 +3798,22 @@ static PyMethodDef SwigMethods[] = {
{ (char *)"reg_get_predef_name", (PyCFunction) _wrap_reg_get_predef_name, METH_VARARGS | METH_KEYWORDS, NULL},
{ (char *)"str_regtype", (PyCFunction) _wrap_str_regtype, METH_VARARGS | METH_KEYWORDS, NULL},
{ (char *)"Registry", (PyCFunction)_wrap_Registry, METH_NOARGS, NULL},
- { (char *)"reg_get_predefined_key_by_name", (PyCFunction) _wrap_reg_get_predefined_key_by_name, METH_VARARGS | METH_KEYWORDS, NULL},
- { (char *)"reg_key_del_abs", (PyCFunction) _wrap_reg_key_del_abs, METH_VARARGS | METH_KEYWORDS, NULL},
- { (char *)"reg_get_predefined_key", (PyCFunction) _wrap_reg_get_predefined_key, METH_VARARGS | METH_KEYWORDS, NULL},
- { (char *)"reg_diff_apply", (PyCFunction) _wrap_reg_diff_apply, METH_VARARGS | METH_KEYWORDS, NULL},
+ { (char *)"reg_get_predefined_key_by_name", (PyCFunction) _wrap_reg_get_predefined_key_by_name, METH_VARARGS | METH_KEYWORDS, (char *)"\n"
+ "S.get_predefined_key_by_name(name) -> key\n"
+ "Find a predefined key by name\n"
+ ""},
+ { (char *)"reg_key_del_abs", (PyCFunction) _wrap_reg_key_del_abs, METH_VARARGS | METH_KEYWORDS, (char *)"\n"
+ "S.key_del_abs(name) -> None\n"
+ "Delete a key by absolute path.\n"
+ ""},
+ { (char *)"reg_get_predefined_key", (PyCFunction) _wrap_reg_get_predefined_key, METH_VARARGS | METH_KEYWORDS, (char *)"\n"
+ "S.get_predefined_key(hkey_id) -> key\n"
+ "Find a predefined key by id\n"
+ ""},
+ { (char *)"reg_diff_apply", (PyCFunction) _wrap_reg_diff_apply, METH_VARARGS | METH_KEYWORDS, (char *)"\n"
+ "S.diff_apply(filename) -> None\n"
+ "Apply the diff from the specified file\n"
+ ""},
{ (char *)"reg_generate_diff", (PyCFunction) _wrap_reg_generate_diff, METH_VARARGS | METH_KEYWORDS, NULL},
{ (char *)"reg_import_hive_key", (PyCFunction) _wrap_reg_import_hive_key, METH_VARARGS | METH_KEYWORDS, NULL},
{ (char *)"reg_mount_hive", _wrap_reg_mount_hive, METH_VARARGS, NULL},
@@ -3809,11 +3821,11 @@ static PyMethodDef SwigMethods[] = {
{ (char *)"delete_reg", (PyCFunction)_wrap_delete_reg, METH_O, NULL},
{ (char *)"reg_swigregister", reg_swigregister, METH_VARARGS, NULL},
{ (char *)"reg_swiginit", reg_swiginit, METH_VARARGS, NULL},
- { (char *)"hive_key", (PyCFunction) _wrap_hive_key, METH_VARARGS | METH_KEYWORDS, NULL},
- { (char *)"open_ldb", (PyCFunction) _wrap_open_ldb, METH_VARARGS | METH_KEYWORDS, NULL},
- { (char *)"create_dir", (PyCFunction) _wrap_create_dir, METH_VARARGS | METH_KEYWORDS, NULL},
- { (char *)"open_dir", (PyCFunction) _wrap_open_dir, METH_VARARGS | METH_KEYWORDS, NULL},
- { (char *)"open_samba", (PyCFunction) _wrap_open_samba, METH_VARARGS | METH_KEYWORDS, NULL},
+ { (char *)"hive_key", (PyCFunction) _wrap_hive_key, METH_VARARGS | METH_KEYWORDS, (char *)"S.__init__(location, session_info=None, credentials=None, loadparm_context=None)"},
+ { (char *)"open_ldb", (PyCFunction) _wrap_open_ldb, METH_VARARGS | METH_KEYWORDS, (char *)"open_ldb(location, session_info=None, credentials=None, loadparm_context=None) -> key"},
+ { (char *)"create_dir", (PyCFunction) _wrap_create_dir, METH_VARARGS | METH_KEYWORDS, (char *)"create_dir(location) -> key"},
+ { (char *)"open_dir", (PyCFunction) _wrap_open_dir, METH_VARARGS | METH_KEYWORDS, (char *)"open_dir(location) -> key"},
+ { (char *)"open_samba", (PyCFunction) _wrap_open_samba, METH_VARARGS | METH_KEYWORDS, (char *)"open_samba() -> reg"},
{ NULL, NULL, 0, NULL }
};
diff --git a/source4/lib/registry/tests/diff.c b/source4/lib/registry/tests/diff.c
index 690f71fcf7..44ea090527 100644
--- a/source4/lib/registry/tests/diff.c
+++ b/source4/lib/registry/tests/diff.c
@@ -4,6 +4,7 @@
local testing of registry diff functionality
Copyright (C) Jelmer Vernooij 2007
+ Copyright (C) Wilco Baan Hofman 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
@@ -23,28 +24,73 @@
#include "lib/registry/registry.h"
#include "torture/torture.h"
#include "librpc/gen_ndr/winreg.h"
+#include "param/param.h"
-static bool test_generate_diff(struct torture_context *test)
+struct diff_tcase_data {
+ struct registry_context *r1_ctx;
+ struct registry_context *r2_ctx;
+ struct reg_diff_callbacks *callbacks;
+ void *callback_data;
+ char *tempdir;
+ char *filename;
+};
+
+static bool test_generate_diff(struct torture_context *tctx, void *tcase_data)
{
- /* WERROR reg_generate_diff(struct registry_context *ctx1,
- struct registry_context *ctx2,
- const struct reg_diff_callbacks *callbacks,
- void *callback_data)
- */
+ WERROR error;
+ struct diff_tcase_data *td = tcase_data;
+
+ error = reg_generate_diff(td->r1_ctx, td->r2_ctx,
+ td->callbacks,
+ td->callback_data);
+ torture_assert_werr_ok(tctx, error, "reg_generate_diff");
+
return true;
}
-
-static bool test_diff_load(struct torture_context *test)
+#if 0
+static bool test_diff_load(struct torture_context *tctx, void *tcase_data)
{
- /* WERROR reg_diff_load(const char *filename, const struct reg_diff_callbacks *callbacks, void *callback_data) */
+ struct diff_tcase_data *td = tcase_data;
+ struct smb_iconv_convenience *ic;
+ struct reg_diff_callbacks *callbacks;
+ void *data;
+ WERROR error;
+
+ ic = lp_iconv_convenience(tctx->lp_ctx);
+
+ error = reg_diff_load(td->filename, iconv_convenience, callbacks, data);
+ torture_assert_werr_ok(tctx, error, "reg_diff_load");
return true;
}
-
-static bool test_diff_apply(struct torture_context *test)
+#endif
+static bool test_diff_apply(struct torture_context *tctx, void *tcase_data)
{
- /* _PUBLIC_ WERROR reg_diff_apply (const char *filename, struct registry_context *ctx) */
+ struct diff_tcase_data *td = tcase_data;
+ struct registry_key *key;
+ WERROR error;
+
+ error = reg_diff_apply(td->r1_ctx, td->filename);
+ torture_assert_werr_ok(tctx, error, "reg_diff_apply");
+
+ error = td->r1_ctx->ops->get_predefined_key(td->r1_ctx, HKEY_LOCAL_MACHINE, &key);
+ torture_assert_werr_ok(tctx, error, "Opening HKEY_LOCAL_MACHINE failed");
+
+ /* If this generates an error it could be that the apply doesn't work,
+ * but also that the reg_generate_diff didn't work. */
+ error = td->r1_ctx->ops->open_key(td->r1_ctx, key, "Software", &key);
+ torture_assert_werr_ok(tctx, error, "Opening HKLM\\Software failed");
+ error = td->r1_ctx->ops->open_key(td->r1_ctx, key, "Microsoft", &key);
+ torture_assert_werr_ok(tctx, error, "Opening HKLM\\Software\\Microsoft failed");
+ error = td->r1_ctx->ops->open_key(td->r1_ctx, key, "Windows", &key);
+ torture_assert_werr_ok(tctx, error, "Opening HKLM\\..\\Microsoft\\Windows failed");
+ error = td->r1_ctx->ops->open_key(td->r1_ctx, key, "CurrentVersion", &key);
+ torture_assert_werr_ok(tctx, error, "Opening HKLM\\..\\Windows\\CurrentVersion failed");
+ error = td->r1_ctx->ops->open_key(td->r1_ctx, key, "Policies", &key);
+ torture_assert_werr_ok(tctx, error, "Opening HKLM\\..\\CurrentVersion\\Policies failed");
+ error = td->r1_ctx->ops->open_key(td->r1_ctx, key, "Explorer", &key);
+ torture_assert_werr_ok(tctx, error, "Opening HKLM\\..\\Policies\\Explorer failed");
return true;
}
@@ -58,7 +104,7 @@ static WERROR test_add_key(void *callback_data, const char *key_name)
return WERR_OK;
}
-static bool test_generate_diff_key_add(struct torture_context *test)
+static bool test_generate_diff_key_add(struct torture_context *tctx, void *tcase_data)
{
struct reg_diff_callbacks cb;
struct registry_key rk;
@@ -69,15 +115,15 @@ static bool test_generate_diff_key_add(struct torture_context *test)
cb.add_key = test_add_key;
- if (W_ERROR_IS_OK(reg_generate_diff_key(&rk, NULL, "bla", &cb, test)))
+ if (W_ERROR_IS_OK(reg_generate_diff_key(&rk, NULL, "bla", &cb, tctx)))
return false;
- torture_assert_str_equal(test, added_key, "bla", "key added");
+ torture_assert_str_equal(tctx, added_key, "bla", "key added");
return true;
}
-static bool test_generate_diff_key_null(struct torture_context *test)
+static bool test_generate_diff_key_null(struct torture_context *tctx, void *tcase_data)
{
struct reg_diff_callbacks cb;
@@ -89,18 +135,162 @@ static bool test_generate_diff_key_null(struct torture_context *test)
return true;
}
+static void tcase_add_tests (struct torture_tcase *tcase)
+{
+ torture_tcase_add_simple_test(tcase, "test_generate_diff_key_add",
+ test_generate_diff_key_add);
+ torture_tcase_add_simple_test(tcase, "test_generate_diff_key_null",
+ test_generate_diff_key_null);
+ torture_tcase_add_simple_test(tcase, "test_generate_diff",
+ test_generate_diff);
+ torture_tcase_add_simple_test(tcase, "test_diff_apply",
+ test_diff_apply);
+/* torture_tcase_add_simple_test(tcase, "test_diff_load",
+ test_diff_load);
+*/
+}
+
+static bool diff_setup_tcase(struct torture_context *tctx, void **data)
+{
+ struct registry_context *r1_ctx, *r2_ctx;
+ WERROR error;
+ NTSTATUS status;
+ struct hive_key *r1_hklm, *r1_hkcu;
+ struct hive_key *r2_hklm, *r2_hkcu;
+ const char *filename;
+ struct diff_tcase_data *td;
+ struct registry_key *key, *newkey;
+ DATA_BLOB blob;
+
+ td = talloc(tctx, struct diff_tcase_data);
+
+ /* Create two registry contexts */
+ error = reg_open_local(tctx, &r1_ctx);
+ torture_assert_werr_ok(tctx, error, "Opening registry 1 for patch tests failed");
+
+ error = reg_open_local(tctx, &r2_ctx);
+ torture_assert_werr_ok(tctx, error, "Opening registry 2 for patch tests failed");
+
+ /* Create temp directory */
+ status = torture_temp_dir(tctx, "patchfile", &td->tempdir);
+ torture_assert_ntstatus_ok(tctx, status, "Creating temp dir failed");
+
+ /* Create and mount HKLM and HKCU hives for registry 1 */
+ filename = talloc_asprintf(tctx, "%s/r1_local_machine.ldb", td->tempdir);
+ error = reg_open_ldb_file(tctx, filename, NULL, NULL, tctx->ev, tctx->lp_ctx, &r1_hklm);
+ torture_assert_werr_ok(tctx, error, "Opening local machine file failed");
+
+ error = reg_mount_hive(r1_ctx, r1_hklm, HKEY_LOCAL_MACHINE, NULL);
+ torture_assert_werr_ok(tctx, error, "Mounting hive failed");
+
+ filename = talloc_asprintf(tctx, "%s/r1_current_user.ldb", td->tempdir);
+ error = reg_open_ldb_file(tctx, filename, NULL, NULL, tctx->ev, tctx->lp_ctx, &r1_hkcu);
+ torture_assert_werr_ok(tctx, error, "Opening current user file failed");
+
+ error = reg_mount_hive(r1_ctx, r1_hkcu, HKEY_CURRENT_USER, NULL);
+ torture_assert_werr_ok(tctx, error, "Mounting hive failed");
+
+ /* Create and mount HKLM and HKCU hives for registry 2 */
+ filename = talloc_asprintf(tctx, "%s/r2_local_machine.ldb", td->tempdir);
+ error = reg_open_ldb_file(tctx, filename, NULL, NULL, tctx->ev, tctx->lp_ctx, &r2_hklm);
+ torture_assert_werr_ok(tctx, error, "Opening local machine file failed");
+
+ error = reg_mount_hive(r2_ctx, r2_hklm, HKEY_LOCAL_MACHINE, NULL);
+ torture_assert_werr_ok(tctx, error, "Mounting hive failed");
+
+ filename = talloc_asprintf(tctx, "%s/r2_current_user.ldb", td->tempdir);
+ error = reg_open_ldb_file(tctx, filename, NULL, NULL, tctx->ev, tctx->lp_ctx, &r2_hkcu);
+ torture_assert_werr_ok(tctx, error, "Opening current user file failed");
+
+ error = reg_mount_hive(r2_ctx, r2_hkcu, HKEY_CURRENT_USER, NULL);
+ torture_assert_werr_ok(tctx, error, "Mounting hive failed");
+
+ error = r1_ctx->ops->get_predefined_key(r1_ctx, HKEY_CURRENT_USER, &key);
+ torture_assert_werr_ok(tctx, error, "Opening HKEY_CURRENT_USER failed");
+ error = r1_ctx->ops->create_key(r1_ctx, key, "Network", NULL, NULL, &newkey);
+ torture_assert_werr_ok(tctx, error, "Opening HKCU\\Network failed");
+ error = r1_ctx->ops->create_key(r1_ctx, newkey, "L", NULL, NULL, &newkey);
+ torture_assert_werr_ok(tctx, error, "Opening HKCU\\Network\\L failed");
+
+ error = r2_ctx->ops->get_predefined_key(r2_ctx, HKEY_LOCAL_MACHINE, &key);
+ torture_assert_werr_ok(tctx, error, "Opening HKEY_LOCAL_MACHINE failed");
+ error = r2_ctx->ops->create_key(r2_ctx, key, "Software", NULL, NULL, &newkey);
+ torture_assert_werr_ok(tctx, error, "Creating HKLM\\Sofware failed");
+ error = r2_ctx->ops->create_key(r2_ctx, newkey, "Microsoft", NULL, NULL, &newkey);
+ torture_assert_werr_ok(tctx, error, "Creating HKLM\\Software\\Microsoft failed");
+ error = r2_ctx->ops->create_key(r2_ctx, newkey, "Windows", NULL, NULL, &newkey);
+ torture_assert_werr_ok(tctx, error, "Creating HKLM\\Software\\Microsoft\\Windows failed");
+ error = r2_ctx->ops->create_key(r2_ctx, newkey, "CurrentVersion", NULL, NULL, &newkey);
+ torture_assert_werr_ok(tctx, error, "Creating HKLM\\..\\Windows\\CurrentVersion failed");
+ error = r2_ctx->ops->create_key(r2_ctx, newkey, "Policies", NULL, NULL, &newkey);
+ torture_assert_werr_ok(tctx, error, "Creating HKLM\\..\\CurrentVersion\\Policies failed");
+ error = r2_ctx->ops->create_key(r2_ctx, newkey, "Explorer", NULL, NULL, &newkey);
+ torture_assert_werr_ok(tctx, error, "Creating HKLM\\..\\Policies\\Explorer failed");
+
+
+ blob.data = (void *)talloc(r2_ctx, uint32_t);
+ SIVAL(blob.data, 0, 0x03ffffff);
+ blob.length = sizeof(uint32_t);
+
+ r1_ctx->ops->set_value(newkey, "NoDrives", REG_DWORD, blob);
+
+ /* Set test case data */
+ td->r1_ctx = r1_ctx;
+ td->r2_ctx = r2_ctx;
+
+ *data = td;
+
+ return true;
+}
+
+static bool diff_setup_preg_tcase (struct torture_context *tctx, void **data)
+{
+ struct diff_tcase_data *td;
+ struct smb_iconv_convenience *ic;
+ WERROR error;
+
+ diff_setup_tcase(tctx, data);
+ td = *data;
+
+ ic = lp_iconv_convenience(tctx->lp_ctx);
+
+ td->filename = talloc_asprintf(tctx, "%s/test.pol", td->tempdir);
+ error = reg_preg_diff_save(tctx, td->filename, ic, &td->callbacks, &td->callback_data);
+ torture_assert_werr_ok(tctx, error, "reg_preg_diff_save");
+
+ return true;
+}
+
+static bool diff_setup_dotreg_tcase (struct torture_context *tctx, void **data)
+{
+ struct diff_tcase_data *td;
+ struct smb_iconv_convenience *ic;
+ WERROR error;
+
+ diff_setup_tcase(tctx, data);
+ td = *data;
+
+ ic = lp_iconv_convenience(tctx->lp_ctx);
+
+ td->filename = talloc_asprintf(tctx, "%s/test.reg", td->tempdir);
+ error = reg_dotreg_diff_save(tctx, td->filename, ic, &td->callbacks, &td->callback_data);
+ torture_assert_werr_ok(tctx, error, "reg_dotreg_diff_save");
+
+ return true;
+}
+
struct torture_suite *torture_registry_diff(TALLOC_CTX *mem_ctx)
{
+ struct torture_tcase *tcase;
struct torture_suite *suite = torture_suite_create(mem_ctx, "DIFF");
- torture_suite_add_simple_test(suite, "test_generate_diff_key_add",
- test_generate_diff_key_add);
- torture_suite_add_simple_test(suite, "test_generate_diff_key_null",
- test_generate_diff_key_null);
- torture_suite_add_simple_test(suite, "test_diff_apply",
- test_diff_apply);
- torture_suite_add_simple_test(suite, "test_generate_diff",
- test_generate_diff);
- torture_suite_add_simple_test(suite, "test_diff_load",
- test_diff_load);
+
+ tcase = torture_suite_add_tcase(suite, "PReg");
+ torture_tcase_set_fixture(tcase, diff_setup_preg_tcase, NULL);
+ tcase_add_tests(tcase);
+
+ tcase = torture_suite_add_tcase(suite, "dotreg");
+ torture_tcase_set_fixture(tcase, diff_setup_dotreg_tcase, NULL);
+ tcase_add_tests(tcase);
+
return suite;
}
diff --git a/source4/lib/registry/tests/hive.c b/source4/lib/registry/tests/hive.c
index 29f7e685c1..edc97c2468 100644
--- a/source4/lib/registry/tests/hive.c
+++ b/source4/lib/registry/tests/hive.c
@@ -26,6 +26,7 @@
#include "librpc/gen_ndr/winreg.h"
#include "system/filesys.h"
#include "param/param.h"
+#include "libcli/security/security.h"
static bool test_del_nonexistant_key(struct torture_context *tctx,
const void *test_data)
@@ -306,6 +307,56 @@ static bool test_list_values(struct torture_context *tctx,
return true;
}
+static bool test_hive_security(struct torture_context *tctx, const void *_data)
+{
+ struct hive_key *subkey = NULL;
+ const struct hive_key *root = _data;
+ WERROR error;
+ struct security_descriptor *osd, *nsd;
+
+ osd = security_descriptor_dacl_create(tctx,
+ 0,
+ NULL, NULL,
+ SID_NT_AUTHENTICATED_USERS,
+ SEC_ACE_TYPE_ACCESS_ALLOWED,
+ SEC_GENERIC_ALL,
+ SEC_ACE_FLAG_OBJECT_INHERIT,
+ NULL);
+
+
+ error = hive_key_add_name(tctx, root, "SecurityKey", NULL,
+ osd, &subkey);
+ torture_assert_werr_ok(tctx, error, "hive_key_add_name");
+
+ error = hive_get_sec_desc(tctx, subkey, &nsd);
+ torture_assert_werr_ok (tctx, error, "getting security descriptor");
+
+ torture_assert(tctx, security_descriptor_equal(osd, nsd),
+ "security descriptor changed!");
+
+ /* Create a fresh security descriptor */
+ talloc_free(osd);
+ osd = security_descriptor_dacl_create(tctx,
+ 0,
+ NULL, NULL,
+ SID_NT_AUTHENTICATED_USERS,
+ SEC_ACE_TYPE_ACCESS_ALLOWED,
+ SEC_GENERIC_ALL,
+ SEC_ACE_FLAG_OBJECT_INHERIT,
+ NULL);
+
+ error = hive_set_sec_desc(subkey, osd);
+ torture_assert_werr_ok(tctx, error, "setting security descriptor");
+
+ error = hive_get_sec_desc(tctx, subkey, &nsd);
+ torture_assert_werr_ok (tctx, error, "getting security descriptor");
+
+ torture_assert(tctx, security_descriptor_equal(osd, nsd),
+ "security descriptor changed!");
+
+ return true;
+}
+
static void tcase_add_tests(struct torture_tcase *tcase)
{
torture_tcase_add_simple_test_const(tcase, "del_nonexistant_key",
@@ -333,6 +384,8 @@ static void tcase_add_tests(struct torture_tcase *tcase)
test_del_key);
torture_tcase_add_simple_test_const(tcase, "del_value",
test_del_value);
+ torture_tcase_add_simple_test_const(tcase, "check hive security",
+ test_hive_security);
}
static bool hive_setup_dir(struct torture_context *tctx, void **data)
@@ -390,7 +443,7 @@ static bool hive_setup_regf(struct torture_context *tctx, void **data)
char *dirname;
NTSTATUS status;
- status = torture_temp_dir(tctx, "hive-dir", &dirname);
+ status = torture_temp_dir(tctx, "hive-regf", &dirname);
if (!NT_STATUS_IS_OK(status))
return false;
diff --git a/source4/lib/registry/tests/registry.c b/source4/lib/registry/tests/registry.c
index 661d7c2c69..7274bf009d 100644
--- a/source4/lib/registry/tests/registry.c
+++ b/source4/lib/registry/tests/registry.c
@@ -390,11 +390,11 @@ static bool test_security(struct torture_context *tctx, void *_data)
SEC_ACE_FLAG_OBJECT_INHERIT,
NULL);
- error = reg_set_security(subkey, osd);
- torture_assert_werr_ok(tctx, error, "setting security");
+ error = reg_set_sec_desc(subkey, osd);
+ torture_assert_werr_ok(tctx, error, "setting security descriptor");
- error = reg_get_security(tctx, subkey, &nsd);
- torture_assert_werr_ok (tctx, error, "setting security");
+ error = reg_get_sec_desc(tctx, subkey, &nsd);
+ torture_assert_werr_ok (tctx, error, "getting security descriptor");
torture_assert(tctx, security_descriptor_equal(osd, nsd),
"security descriptor changed!");
diff --git a/source4/lib/replace/libreplace_network.m4 b/source4/lib/replace/libreplace_network.m4
index 6cde6b9e0c..4edb55c03a 100644
--- a/source4/lib/replace/libreplace_network.m4
+++ b/source4/lib/replace/libreplace_network.m4
@@ -341,7 +341,7 @@ fi
dnl test for ipv6
AC_CACHE_CHECK([for ipv6 support],libreplace_cv_HAVE_IPV6,[
- AC_TRY_COMPILE([
+ AC_TRY_LINK([
#include <stdlib.h> /* for NULL */
#include <sys/socket.h>
#include <sys/types.h>
diff --git a/source4/lib/smbreadline/readline.m4 b/source4/lib/smbreadline/readline.m4
index ab85bba438..ad6bc66690 100644
--- a/source4/lib/smbreadline/readline.m4
+++ b/source4/lib/smbreadline/readline.m4
@@ -79,10 +79,10 @@ AC_MSG_CHECKING(whether to use extern readline)
if test x"$EXTERNAL_READLINE" = x"yes"; then
AC_MSG_RESULT(yes)
AC_DEFINE(HAVE_LIBREADLINE,1,[Whether the system has readline])
- SMB_SUBSYSTEM(SMBREADLINE, [lib/smbreadline/smbreadline.o], [READLINE])
+ SMB_SUBSYSTEM(SMBREADLINE, [\$(smbreadlinesrcdir)/smbreadline.o], [READLINE])
SMB_EXT_LIB(READLINE, [${TERMLIBS}])
SMB_ENABLE(READLINE,YES)
else
- SMB_SUBSYSTEM(SMBREADLINE, [lib/smbreadline/smbreadline.o], [])
+ SMB_SUBSYSTEM(SMBREADLINE, [\$(smbreadlinesrcdir)/smbreadline.o], [])
AC_MSG_RESULT(no)
fi
diff --git a/source4/lib/tdb/tdb.i b/source4/lib/tdb/tdb.i
index 704f0facc6..5f23568170 100644
--- a/source4/lib/tdb/tdb.i
+++ b/source4/lib/tdb/tdb.i
@@ -24,7 +24,11 @@
License along with this library; if not, see <http://www.gnu.org/licenses/>.
*/
-%module tdb
+%define DOCSTRING
+"TDB is a simple key-value database similar to GDBM that supports multiple writers."
+%enddef
+
+%module(docstring=DOCSTRING) tdb
%{
@@ -138,7 +142,8 @@ enum TDB_ERROR {
$1 = TDB_REPLACE;
}
-%rename(Tdb) tdb;
+%rename(Tdb) tdb_context;
+%feature("docstring") tdb_context "A TDB file.";
%typemap(out,noblock=1) tdb * {
/* Throw an IOError exception from errno if tdb_open() returns NULL */
if ($1 == NULL) {
@@ -150,34 +155,68 @@ enum TDB_ERROR {
typedef struct tdb_context {
%extend {
+ %feature("docstring") tdb "S.__init__(name,hash_size=0,tdb_flags=TDB_DEFAULT,flags=O_RDWR,mode=0600)\n"
+ "Open a TDB file.";
tdb(const char *name, int hash_size, int tdb_flags, int flags, mode_t mode) {
return tdb_open(name, hash_size, tdb_flags, flags, mode);
}
enum TDB_ERROR error();
~tdb() { tdb_close($self); }
+ %feature("docstring") close "S.close() -> None\n"
+ "Close the TDB file.";
int close();
int append(TDB_DATA key, TDB_DATA new_dbuf);
+ %feature("docstring") errorstr "S.errorstr() -> errorstring\n"
+ "Obtain last error message.";
const char *errorstr();
%rename(get) fetch;
+ %feature("docstring") fetch "S.fetch(key) -> value\n"
+ "Fetch a value.";
TDB_DATA fetch(TDB_DATA key);
+ %feature("docstring") delete "S.delete(key) -> None\n"
+ "Delete an entry.";
int delete(TDB_DATA key);
+ %feature("docstring") store "S.store(key, value, flag=TDB_REPLACE) -> None\n"
+ "Store an entry.";
int store(TDB_DATA key, TDB_DATA dbuf, int flag);
int exists(TDB_DATA key);
+ %feature("docstring") firstkey "S.firstkey() -> data\n"
+ "Return the first key in this database.";
TDB_DATA firstkey();
+ %feature("docstring") nextkey "S.nextkey(prev) -> data\n"
+ "Return the next key in this database.";
TDB_DATA nextkey(TDB_DATA key);
+ %feature("docstring") lockall "S.lockall() -> bool";
int lockall();
+ %feature("docstring") unlockall "S.unlockall() -> bool";
int unlockall();
+ %feature("docstring") unlockall "S.lockall_read() -> bool";
int lockall_read();
+ %feature("docstring") unlockall "S.unlockall_read() -> bool";
int unlockall_read();
+ %feature("docstring") reopen "S.reopen() -> bool\n"
+ "Reopen this file.";
int reopen();
+ %feature("docstring") transaction_start "S.transaction_start() -> None\n"
+ "Start a new transaction.";
int transaction_start();
+ %feature("docstring") transaction_commit "S.transaction_commit() -> None\n"
+ "Commit the currently active transaction.";
int transaction_commit();
+ %feature("docstring") transaction_cancel "S.transaction_cancel() -> None\n"
+ "Cancel the currently active transaction.";
int transaction_cancel();
int transaction_recover();
+ %feature("docstring") hash_size "S.hash_size() -> int";
int hash_size();
+ %feature("docstring") map_size "S.map_size() -> int";
size_t map_size();
+ %feature("docstring") get_flags "S.get_flags() -> int";
int get_flags();
+ %feature("docstring") set_max_dead "S.set_max_dead(int) -> None";
void set_max_dead(int max_dead);
+ %feature("docstring") name "S.name() -> path\n" \
+ "Return filename of this TDB file.";
const char *name();
}
diff --git a/source4/lib/tdb/tdb.py b/source4/lib/tdb/tdb.py
index eb76ca6459..a8c1d06e0d 100644
--- a/source4/lib/tdb/tdb.py
+++ b/source4/lib/tdb/tdb.py
@@ -3,6 +3,10 @@
#
# Don't modify this file, modify the SWIG interface instead.
+"""
+TDB is a simple key-value database similar to GDBM that supports multiple writers.
+"""
+
import _tdb
import new
new_instancemethod = new.instancemethod
@@ -78,11 +82,125 @@ TDB_ERR_LOCK_TIMEOUT = _tdb.TDB_ERR_LOCK_TIMEOUT
TDB_ERR_NOEXIST = _tdb.TDB_ERR_NOEXIST
TDB_ERR_EINVAL = _tdb.TDB_ERR_EINVAL
TDB_ERR_RDONLY = _tdb.TDB_ERR_RDONLY
-class tdb(object):
+class Tdb(object):
+ """A TDB file."""
thisown = _swig_property(lambda x: x.this.own(), lambda x, v: x.this.own(v), doc='The membership flag')
- def __init__(self, *args, **kwargs): raise AttributeError, "No constructor defined"
__repr__ = _swig_repr
- __swig_destroy__ = _tdb.delete_tdb
+ def __init__(self, *args, **kwargs):
+ """
+ S.__init__(name,hash_size=0,tdb_flags=TDB_DEFAULT,flags=O_RDWR,mode=0600)
+ Open a TDB file.
+ """
+ _tdb.Tdb_swiginit(self,_tdb.new_Tdb(*args, **kwargs))
+ __swig_destroy__ = _tdb.delete_Tdb
+ def close(*args, **kwargs):
+ """
+ S.close() -> None
+ Close the TDB file.
+ """
+ return _tdb.Tdb_close(*args, **kwargs)
+
+ def errorstr(*args, **kwargs):
+ """
+ S.errorstr() -> errorstring
+ Obtain last error message.
+ """
+ return _tdb.Tdb_errorstr(*args, **kwargs)
+
+ def get(*args, **kwargs):
+ """
+ S.fetch(key) -> value
+ Fetch a value.
+ """
+ return _tdb.Tdb_get(*args, **kwargs)
+
+ def delete(*args, **kwargs):
+ """
+ S.delete(key) -> None
+ Delete an entry.
+ """
+ return _tdb.Tdb_delete(*args, **kwargs)
+
+ def store(*args, **kwargs):
+ """
+ S.store(key, value, flag=TDB_REPLACE) -> None
+ Store an entry.
+ """
+ return _tdb.Tdb_store(*args, **kwargs)
+
+ def firstkey(*args, **kwargs):
+ """
+ S.firstkey() -> data
+ Return the first key in this database.
+ """
+ return _tdb.Tdb_firstkey(*args, **kwargs)
+
+ def nextkey(*args, **kwargs):
+ """
+ S.nextkey(prev) -> data
+ Return the next key in this database.
+ """
+ return _tdb.Tdb_nextkey(*args, **kwargs)
+
+ def lock_all(*args, **kwargs):
+ """S.lockall() -> bool"""
+ return _tdb.Tdb_lock_all(*args, **kwargs)
+
+ def unlock_all(*args, **kwargs):
+ """S.unlockall() -> bool"""
+ return _tdb.Tdb_unlock_all(*args, **kwargs)
+
+ def reopen(*args, **kwargs):
+ """
+ S.reopen() -> bool
+ Reopen this file.
+ """
+ return _tdb.Tdb_reopen(*args, **kwargs)
+
+ def transaction_start(*args, **kwargs):
+ """
+ S.transaction_start() -> None
+ Start a new transaction.
+ """
+ return _tdb.Tdb_transaction_start(*args, **kwargs)
+
+ def transaction_commit(*args, **kwargs):
+ """
+ S.transaction_commit() -> None
+ Commit the currently active transaction.
+ """
+ return _tdb.Tdb_transaction_commit(*args, **kwargs)
+
+ def transaction_cancel(*args, **kwargs):
+ """
+ S.transaction_cancel() -> None
+ Cancel the currently active transaction.
+ """
+ return _tdb.Tdb_transaction_cancel(*args, **kwargs)
+
+ def hash_size(*args, **kwargs):
+ """S.hash_size() -> int"""
+ return _tdb.Tdb_hash_size(*args, **kwargs)
+
+ def map_size(*args, **kwargs):
+ """S.map_size() -> int"""
+ return _tdb.Tdb_map_size(*args, **kwargs)
+
+ def get_flags(*args, **kwargs):
+ """S.get_flags() -> int"""
+ return _tdb.Tdb_get_flags(*args, **kwargs)
+
+ def set_max_dead(*args, **kwargs):
+ """S.set_max_dead(int) -> None"""
+ return _tdb.Tdb_set_max_dead(*args, **kwargs)
+
+ def name(*args, **kwargs):
+ """
+ S.name() -> path
+ Return filename of this TDB file.
+ """
+ return _tdb.Tdb_name(*args, **kwargs)
+
def __repr__(self):
return "Tdb('%s')" % self.name()
@@ -178,36 +296,32 @@ class tdb(object):
-tdb.error = new_instancemethod(_tdb.tdb_error,None,tdb)
-tdb.close = new_instancemethod(_tdb.tdb_close,None,tdb)
-tdb.append = new_instancemethod(_tdb.tdb_append,None,tdb)
-tdb.errorstr = new_instancemethod(_tdb.tdb_errorstr,None,tdb)
-tdb.get = new_instancemethod(_tdb.tdb_get,None,tdb)
-tdb.delete = new_instancemethod(_tdb.tdb_delete,None,tdb)
-tdb.store = new_instancemethod(_tdb.tdb_store,None,tdb)
-tdb.exists = new_instancemethod(_tdb.tdb_exists,None,tdb)
-tdb.firstkey = new_instancemethod(_tdb.tdb_firstkey,None,tdb)
-tdb.nextkey = new_instancemethod(_tdb.tdb_nextkey,None,tdb)
-tdb.lock_all = new_instancemethod(_tdb.tdb_lock_all,None,tdb)
-tdb.unlock_all = new_instancemethod(_tdb.tdb_unlock_all,None,tdb)
-tdb.read_lock_all = new_instancemethod(_tdb.tdb_read_lock_all,None,tdb)
-tdb.read_unlock_all = new_instancemethod(_tdb.tdb_read_unlock_all,None,tdb)
-tdb.reopen = new_instancemethod(_tdb.tdb_reopen,None,tdb)
-tdb.transaction_start = new_instancemethod(_tdb.tdb_transaction_start,None,tdb)
-tdb.transaction_commit = new_instancemethod(_tdb.tdb_transaction_commit,None,tdb)
-tdb.transaction_cancel = new_instancemethod(_tdb.tdb_transaction_cancel,None,tdb)
-tdb.transaction_recover = new_instancemethod(_tdb.tdb_transaction_recover,None,tdb)
-tdb.hash_size = new_instancemethod(_tdb.tdb_hash_size,None,tdb)
-tdb.map_size = new_instancemethod(_tdb.tdb_map_size,None,tdb)
-tdb.get_flags = new_instancemethod(_tdb.tdb_get_flags,None,tdb)
-tdb.set_max_dead = new_instancemethod(_tdb.tdb_set_max_dead,None,tdb)
-tdb.name = new_instancemethod(_tdb.tdb_name,None,tdb)
-tdb_swigregister = _tdb.tdb_swigregister
-tdb_swigregister(tdb)
-
-def Tdb(*args, **kwargs):
- val = _tdb.new_Tdb(*args, **kwargs)
- return val
+Tdb.error = new_instancemethod(_tdb.Tdb_error,None,Tdb)
+Tdb.close = new_instancemethod(_tdb.Tdb_close,None,Tdb)
+Tdb.append = new_instancemethod(_tdb.Tdb_append,None,Tdb)
+Tdb.errorstr = new_instancemethod(_tdb.Tdb_errorstr,None,Tdb)
+Tdb.get = new_instancemethod(_tdb.Tdb_get,None,Tdb)
+Tdb.delete = new_instancemethod(_tdb.Tdb_delete,None,Tdb)
+Tdb.store = new_instancemethod(_tdb.Tdb_store,None,Tdb)
+Tdb.exists = new_instancemethod(_tdb.Tdb_exists,None,Tdb)
+Tdb.firstkey = new_instancemethod(_tdb.Tdb_firstkey,None,Tdb)
+Tdb.nextkey = new_instancemethod(_tdb.Tdb_nextkey,None,Tdb)
+Tdb.lock_all = new_instancemethod(_tdb.Tdb_lock_all,None,Tdb)
+Tdb.unlock_all = new_instancemethod(_tdb.Tdb_unlock_all,None,Tdb)
+Tdb.read_lock_all = new_instancemethod(_tdb.Tdb_read_lock_all,None,Tdb)
+Tdb.read_unlock_all = new_instancemethod(_tdb.Tdb_read_unlock_all,None,Tdb)
+Tdb.reopen = new_instancemethod(_tdb.Tdb_reopen,None,Tdb)
+Tdb.transaction_start = new_instancemethod(_tdb.Tdb_transaction_start,None,Tdb)
+Tdb.transaction_commit = new_instancemethod(_tdb.Tdb_transaction_commit,None,Tdb)
+Tdb.transaction_cancel = new_instancemethod(_tdb.Tdb_transaction_cancel,None,Tdb)
+Tdb.transaction_recover = new_instancemethod(_tdb.Tdb_transaction_recover,None,Tdb)
+Tdb.hash_size = new_instancemethod(_tdb.Tdb_hash_size,None,Tdb)
+Tdb.map_size = new_instancemethod(_tdb.Tdb_map_size,None,Tdb)
+Tdb.get_flags = new_instancemethod(_tdb.Tdb_get_flags,None,Tdb)
+Tdb.set_max_dead = new_instancemethod(_tdb.Tdb_set_max_dead,None,Tdb)
+Tdb.name = new_instancemethod(_tdb.Tdb_name,None,Tdb)
+Tdb_swigregister = _tdb.Tdb_swigregister
+Tdb_swigregister(Tdb)
diff --git a/source4/lib/tdb/tdb_wrap.c b/source4/lib/tdb/tdb_wrap.c
index f36d569937..27da552d33 100644
--- a/source4/lib/tdb/tdb_wrap.c
+++ b/source4/lib/tdb/tdb_wrap.c
@@ -2892,7 +2892,7 @@ fail:
}
-SWIGINTERN PyObject *_wrap_tdb_error(PyObject *SWIGUNUSEDPARM(self), PyObject *args) {
+SWIGINTERN PyObject *_wrap_Tdb_error(PyObject *SWIGUNUSEDPARM(self), PyObject *args) {
PyObject *resultobj = 0;
tdb *arg1 = (tdb *) 0 ;
enum TDB_ERROR result;
@@ -2904,7 +2904,7 @@ SWIGINTERN PyObject *_wrap_tdb_error(PyObject *SWIGUNUSEDPARM(self), PyObject *a
swig_obj[0] = args;
res1 = SWIG_ConvertPtr(swig_obj[0], &argp1,SWIGTYPE_p_tdb_context, 0 | 0 );
if (!SWIG_IsOK(res1)) {
- SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "tdb_error" "', argument " "1"" of type '" "tdb *""'");
+ SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "Tdb_error" "', argument " "1"" of type '" "tdb *""'");
}
arg1 = (tdb *)(argp1);
result = (enum TDB_ERROR)tdb_error(arg1);
@@ -2915,7 +2915,7 @@ fail:
}
-SWIGINTERN PyObject *_wrap_delete_tdb(PyObject *SWIGUNUSEDPARM(self), PyObject *args) {
+SWIGINTERN PyObject *_wrap_delete_Tdb(PyObject *SWIGUNUSEDPARM(self), PyObject *args) {
PyObject *resultobj = 0;
tdb *arg1 = (tdb *) 0 ;
void *argp1 = 0 ;
@@ -2926,7 +2926,7 @@ SWIGINTERN PyObject *_wrap_delete_tdb(PyObject *SWIGUNUSEDPARM(self), PyObject *
swig_obj[0] = args;
res1 = SWIG_ConvertPtr(swig_obj[0], &argp1,SWIGTYPE_p_tdb_context, SWIG_POINTER_DISOWN | 0 );
if (!SWIG_IsOK(res1)) {
- SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "delete_tdb" "', argument " "1"" of type '" "tdb *""'");
+ SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "delete_Tdb" "', argument " "1"" of type '" "tdb *""'");
}
arg1 = (tdb *)(argp1);
delete_tdb(arg1);
@@ -2938,7 +2938,7 @@ fail:
}
-SWIGINTERN PyObject *_wrap_tdb_close(PyObject *SWIGUNUSEDPARM(self), PyObject *args) {
+SWIGINTERN PyObject *_wrap_Tdb_close(PyObject *SWIGUNUSEDPARM(self), PyObject *args) {
PyObject *resultobj = 0;
tdb *arg1 = (tdb *) 0 ;
int result;
@@ -2950,7 +2950,7 @@ SWIGINTERN PyObject *_wrap_tdb_close(PyObject *SWIGUNUSEDPARM(self), PyObject *a
swig_obj[0] = args;
res1 = SWIG_ConvertPtr(swig_obj[0], &argp1,SWIGTYPE_p_tdb_context, 0 | 0 );
if (!SWIG_IsOK(res1)) {
- SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "tdb_close" "', argument " "1"" of type '" "tdb *""'");
+ SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "Tdb_close" "', argument " "1"" of type '" "tdb *""'");
}
arg1 = (tdb *)(argp1);
result = (int)tdb_close(arg1);
@@ -2961,7 +2961,7 @@ fail:
}
-SWIGINTERN PyObject *_wrap_tdb_append(PyObject *SWIGUNUSEDPARM(self), PyObject *args, PyObject *kwargs) {
+SWIGINTERN PyObject *_wrap_Tdb_append(PyObject *SWIGUNUSEDPARM(self), PyObject *args, PyObject *kwargs) {
PyObject *resultobj = 0;
tdb *arg1 = (tdb *) 0 ;
TDB_DATA arg2 ;
@@ -2976,10 +2976,10 @@ SWIGINTERN PyObject *_wrap_tdb_append(PyObject *SWIGUNUSEDPARM(self), PyObject *
(char *) "self",(char *) "key",(char *) "new_dbuf", NULL
};
- if (!PyArg_ParseTupleAndKeywords(args,kwargs,(char *)"OOO:tdb_append",kwnames,&obj0,&obj1,&obj2)) SWIG_fail;
+ if (!PyArg_ParseTupleAndKeywords(args,kwargs,(char *)"OOO:Tdb_append",kwnames,&obj0,&obj1,&obj2)) SWIG_fail;
res1 = SWIG_ConvertPtr(obj0, &argp1,SWIGTYPE_p_tdb_context, 0 | 0 );
if (!SWIG_IsOK(res1)) {
- SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "tdb_append" "', argument " "1"" of type '" "tdb *""'");
+ SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "Tdb_append" "', argument " "1"" of type '" "tdb *""'");
}
arg1 = (tdb *)(argp1);
if (obj1 == Py_None) {
@@ -3010,7 +3010,7 @@ fail:
}
-SWIGINTERN PyObject *_wrap_tdb_errorstr(PyObject *SWIGUNUSEDPARM(self), PyObject *args) {
+SWIGINTERN PyObject *_wrap_Tdb_errorstr(PyObject *SWIGUNUSEDPARM(self), PyObject *args) {
PyObject *resultobj = 0;
tdb *arg1 = (tdb *) 0 ;
char *result = 0 ;
@@ -3022,7 +3022,7 @@ SWIGINTERN PyObject *_wrap_tdb_errorstr(PyObject *SWIGUNUSEDPARM(self), PyObject
swig_obj[0] = args;
res1 = SWIG_ConvertPtr(swig_obj[0], &argp1,SWIGTYPE_p_tdb_context, 0 | 0 );
if (!SWIG_IsOK(res1)) {
- SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "tdb_errorstr" "', argument " "1"" of type '" "tdb *""'");
+ SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "Tdb_errorstr" "', argument " "1"" of type '" "tdb *""'");
}
arg1 = (tdb *)(argp1);
result = (char *)tdb_errorstr(arg1);
@@ -3033,7 +3033,7 @@ fail:
}
-SWIGINTERN PyObject *_wrap_tdb_get(PyObject *SWIGUNUSEDPARM(self), PyObject *args, PyObject *kwargs) {
+SWIGINTERN PyObject *_wrap_Tdb_get(PyObject *SWIGUNUSEDPARM(self), PyObject *args, PyObject *kwargs) {
PyObject *resultobj = 0;
tdb *arg1 = (tdb *) 0 ;
TDB_DATA arg2 ;
@@ -3046,10 +3046,10 @@ SWIGINTERN PyObject *_wrap_tdb_get(PyObject *SWIGUNUSEDPARM(self), PyObject *arg
(char *) "self",(char *) "key", NULL
};
- if (!PyArg_ParseTupleAndKeywords(args,kwargs,(char *)"OO:tdb_get",kwnames,&obj0,&obj1)) SWIG_fail;
+ if (!PyArg_ParseTupleAndKeywords(args,kwargs,(char *)"OO:Tdb_get",kwnames,&obj0,&obj1)) SWIG_fail;
res1 = SWIG_ConvertPtr(obj0, &argp1,SWIGTYPE_p_tdb_context, 0 | 0 );
if (!SWIG_IsOK(res1)) {
- SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "tdb_get" "', argument " "1"" of type '" "tdb *""'");
+ SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "Tdb_get" "', argument " "1"" of type '" "tdb *""'");
}
arg1 = (tdb *)(argp1);
if (obj1 == Py_None) {
@@ -3075,7 +3075,7 @@ fail:
}
-SWIGINTERN PyObject *_wrap_tdb_delete(PyObject *SWIGUNUSEDPARM(self), PyObject *args, PyObject *kwargs) {
+SWIGINTERN PyObject *_wrap_Tdb_delete(PyObject *SWIGUNUSEDPARM(self), PyObject *args, PyObject *kwargs) {
PyObject *resultobj = 0;
tdb *arg1 = (tdb *) 0 ;
TDB_DATA arg2 ;
@@ -3088,10 +3088,10 @@ SWIGINTERN PyObject *_wrap_tdb_delete(PyObject *SWIGUNUSEDPARM(self), PyObject *
(char *) "self",(char *) "key", NULL
};
- if (!PyArg_ParseTupleAndKeywords(args,kwargs,(char *)"OO:tdb_delete",kwnames,&obj0,&obj1)) SWIG_fail;
+ if (!PyArg_ParseTupleAndKeywords(args,kwargs,(char *)"OO:Tdb_delete",kwnames,&obj0,&obj1)) SWIG_fail;
res1 = SWIG_ConvertPtr(obj0, &argp1,SWIGTYPE_p_tdb_context, 0 | 0 );
if (!SWIG_IsOK(res1)) {
- SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "tdb_delete" "', argument " "1"" of type '" "tdb *""'");
+ SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "Tdb_delete" "', argument " "1"" of type '" "tdb *""'");
}
arg1 = (tdb *)(argp1);
if (obj1 == Py_None) {
@@ -3112,7 +3112,7 @@ fail:
}
-SWIGINTERN PyObject *_wrap_tdb_store(PyObject *SWIGUNUSEDPARM(self), PyObject *args, PyObject *kwargs) {
+SWIGINTERN PyObject *_wrap_Tdb_store(PyObject *SWIGUNUSEDPARM(self), PyObject *args, PyObject *kwargs) {
PyObject *resultobj = 0;
tdb *arg1 = (tdb *) 0 ;
TDB_DATA arg2 ;
@@ -3132,10 +3132,10 @@ SWIGINTERN PyObject *_wrap_tdb_store(PyObject *SWIGUNUSEDPARM(self), PyObject *a
};
arg4 = TDB_REPLACE;
- if (!PyArg_ParseTupleAndKeywords(args,kwargs,(char *)"OOO|O:tdb_store",kwnames,&obj0,&obj1,&obj2,&obj3)) SWIG_fail;
+ if (!PyArg_ParseTupleAndKeywords(args,kwargs,(char *)"OOO|O:Tdb_store",kwnames,&obj0,&obj1,&obj2,&obj3)) SWIG_fail;
res1 = SWIG_ConvertPtr(obj0, &argp1,SWIGTYPE_p_tdb_context, 0 | 0 );
if (!SWIG_IsOK(res1)) {
- SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "tdb_store" "', argument " "1"" of type '" "tdb *""'");
+ SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "Tdb_store" "', argument " "1"" of type '" "tdb *""'");
}
arg1 = (tdb *)(argp1);
if (obj1 == Py_None) {
@@ -3161,7 +3161,7 @@ SWIGINTERN PyObject *_wrap_tdb_store(PyObject *SWIGUNUSEDPARM(self), PyObject *a
if (obj3) {
ecode4 = SWIG_AsVal_int(obj3, &val4);
if (!SWIG_IsOK(ecode4)) {
- SWIG_exception_fail(SWIG_ArgError(ecode4), "in method '" "tdb_store" "', argument " "4"" of type '" "int""'");
+ SWIG_exception_fail(SWIG_ArgError(ecode4), "in method '" "Tdb_store" "', argument " "4"" of type '" "int""'");
}
arg4 = (int)(val4);
}
@@ -3173,7 +3173,7 @@ fail:
}
-SWIGINTERN PyObject *_wrap_tdb_exists(PyObject *SWIGUNUSEDPARM(self), PyObject *args, PyObject *kwargs) {
+SWIGINTERN PyObject *_wrap_Tdb_exists(PyObject *SWIGUNUSEDPARM(self), PyObject *args, PyObject *kwargs) {
PyObject *resultobj = 0;
tdb *arg1 = (tdb *) 0 ;
TDB_DATA arg2 ;
@@ -3186,10 +3186,10 @@ SWIGINTERN PyObject *_wrap_tdb_exists(PyObject *SWIGUNUSEDPARM(self), PyObject *
(char *) "self",(char *) "key", NULL
};
- if (!PyArg_ParseTupleAndKeywords(args,kwargs,(char *)"OO:tdb_exists",kwnames,&obj0,&obj1)) SWIG_fail;
+ if (!PyArg_ParseTupleAndKeywords(args,kwargs,(char *)"OO:Tdb_exists",kwnames,&obj0,&obj1)) SWIG_fail;
res1 = SWIG_ConvertPtr(obj0, &argp1,SWIGTYPE_p_tdb_context, 0 | 0 );
if (!SWIG_IsOK(res1)) {
- SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "tdb_exists" "', argument " "1"" of type '" "tdb *""'");
+ SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "Tdb_exists" "', argument " "1"" of type '" "tdb *""'");
}
arg1 = (tdb *)(argp1);
if (obj1 == Py_None) {
@@ -3210,7 +3210,7 @@ fail:
}
-SWIGINTERN PyObject *_wrap_tdb_firstkey(PyObject *SWIGUNUSEDPARM(self), PyObject *args) {
+SWIGINTERN PyObject *_wrap_Tdb_firstkey(PyObject *SWIGUNUSEDPARM(self), PyObject *args) {
PyObject *resultobj = 0;
tdb *arg1 = (tdb *) 0 ;
TDB_DATA result;
@@ -3222,7 +3222,7 @@ SWIGINTERN PyObject *_wrap_tdb_firstkey(PyObject *SWIGUNUSEDPARM(self), PyObject
swig_obj[0] = args;
res1 = SWIG_ConvertPtr(swig_obj[0], &argp1,SWIGTYPE_p_tdb_context, 0 | 0 );
if (!SWIG_IsOK(res1)) {
- SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "tdb_firstkey" "', argument " "1"" of type '" "tdb *""'");
+ SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "Tdb_firstkey" "', argument " "1"" of type '" "tdb *""'");
}
arg1 = (tdb *)(argp1);
result = tdb_firstkey(arg1);
@@ -3238,7 +3238,7 @@ fail:
}
-SWIGINTERN PyObject *_wrap_tdb_nextkey(PyObject *SWIGUNUSEDPARM(self), PyObject *args, PyObject *kwargs) {
+SWIGINTERN PyObject *_wrap_Tdb_nextkey(PyObject *SWIGUNUSEDPARM(self), PyObject *args, PyObject *kwargs) {
PyObject *resultobj = 0;
tdb *arg1 = (tdb *) 0 ;
TDB_DATA arg2 ;
@@ -3251,10 +3251,10 @@ SWIGINTERN PyObject *_wrap_tdb_nextkey(PyObject *SWIGUNUSEDPARM(self), PyObject
(char *) "self",(char *) "key", NULL
};
- if (!PyArg_ParseTupleAndKeywords(args,kwargs,(char *)"OO:tdb_nextkey",kwnames,&obj0,&obj1)) SWIG_fail;
+ if (!PyArg_ParseTupleAndKeywords(args,kwargs,(char *)"OO:Tdb_nextkey",kwnames,&obj0,&obj1)) SWIG_fail;
res1 = SWIG_ConvertPtr(obj0, &argp1,SWIGTYPE_p_tdb_context, 0 | 0 );
if (!SWIG_IsOK(res1)) {
- SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "tdb_nextkey" "', argument " "1"" of type '" "tdb *""'");
+ SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "Tdb_nextkey" "', argument " "1"" of type '" "tdb *""'");
}
arg1 = (tdb *)(argp1);
if (obj1 == Py_None) {
@@ -3280,7 +3280,7 @@ fail:
}
-SWIGINTERN PyObject *_wrap_tdb_lock_all(PyObject *SWIGUNUSEDPARM(self), PyObject *args) {
+SWIGINTERN PyObject *_wrap_Tdb_lock_all(PyObject *SWIGUNUSEDPARM(self), PyObject *args) {
PyObject *resultobj = 0;
tdb *arg1 = (tdb *) 0 ;
int result;
@@ -3292,7 +3292,7 @@ SWIGINTERN PyObject *_wrap_tdb_lock_all(PyObject *SWIGUNUSEDPARM(self), PyObject
swig_obj[0] = args;
res1 = SWIG_ConvertPtr(swig_obj[0], &argp1,SWIGTYPE_p_tdb_context, 0 | 0 );
if (!SWIG_IsOK(res1)) {
- SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "tdb_lock_all" "', argument " "1"" of type '" "tdb *""'");
+ SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "Tdb_lock_all" "', argument " "1"" of type '" "tdb *""'");
}
arg1 = (tdb *)(argp1);
result = (int)tdb_lockall(arg1);
@@ -3303,7 +3303,7 @@ fail:
}
-SWIGINTERN PyObject *_wrap_tdb_unlock_all(PyObject *SWIGUNUSEDPARM(self), PyObject *args) {
+SWIGINTERN PyObject *_wrap_Tdb_unlock_all(PyObject *SWIGUNUSEDPARM(self), PyObject *args) {
PyObject *resultobj = 0;
tdb *arg1 = (tdb *) 0 ;
int result;
@@ -3315,7 +3315,7 @@ SWIGINTERN PyObject *_wrap_tdb_unlock_all(PyObject *SWIGUNUSEDPARM(self), PyObje
swig_obj[0] = args;
res1 = SWIG_ConvertPtr(swig_obj[0], &argp1,SWIGTYPE_p_tdb_context, 0 | 0 );
if (!SWIG_IsOK(res1)) {
- SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "tdb_unlock_all" "', argument " "1"" of type '" "tdb *""'");
+ SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "Tdb_unlock_all" "', argument " "1"" of type '" "tdb *""'");
}
arg1 = (tdb *)(argp1);
result = (int)tdb_unlockall(arg1);
@@ -3326,7 +3326,7 @@ fail:
}
-SWIGINTERN PyObject *_wrap_tdb_read_lock_all(PyObject *SWIGUNUSEDPARM(self), PyObject *args) {
+SWIGINTERN PyObject *_wrap_Tdb_read_lock_all(PyObject *SWIGUNUSEDPARM(self), PyObject *args) {
PyObject *resultobj = 0;
tdb *arg1 = (tdb *) 0 ;
int result;
@@ -3338,7 +3338,7 @@ SWIGINTERN PyObject *_wrap_tdb_read_lock_all(PyObject *SWIGUNUSEDPARM(self), PyO
swig_obj[0] = args;
res1 = SWIG_ConvertPtr(swig_obj[0], &argp1,SWIGTYPE_p_tdb_context, 0 | 0 );
if (!SWIG_IsOK(res1)) {
- SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "tdb_read_lock_all" "', argument " "1"" of type '" "tdb *""'");
+ SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "Tdb_read_lock_all" "', argument " "1"" of type '" "tdb *""'");
}
arg1 = (tdb *)(argp1);
result = (int)tdb_lockall_read(arg1);
@@ -3349,7 +3349,7 @@ fail:
}
-SWIGINTERN PyObject *_wrap_tdb_read_unlock_all(PyObject *SWIGUNUSEDPARM(self), PyObject *args) {
+SWIGINTERN PyObject *_wrap_Tdb_read_unlock_all(PyObject *SWIGUNUSEDPARM(self), PyObject *args) {
PyObject *resultobj = 0;
tdb *arg1 = (tdb *) 0 ;
int result;
@@ -3361,7 +3361,7 @@ SWIGINTERN PyObject *_wrap_tdb_read_unlock_all(PyObject *SWIGUNUSEDPARM(self), P
swig_obj[0] = args;
res1 = SWIG_ConvertPtr(swig_obj[0], &argp1,SWIGTYPE_p_tdb_context, 0 | 0 );
if (!SWIG_IsOK(res1)) {
- SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "tdb_read_unlock_all" "', argument " "1"" of type '" "tdb *""'");
+ SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "Tdb_read_unlock_all" "', argument " "1"" of type '" "tdb *""'");
}
arg1 = (tdb *)(argp1);
result = (int)tdb_unlockall_read(arg1);
@@ -3372,7 +3372,7 @@ fail:
}
-SWIGINTERN PyObject *_wrap_tdb_reopen(PyObject *SWIGUNUSEDPARM(self), PyObject *args) {
+SWIGINTERN PyObject *_wrap_Tdb_reopen(PyObject *SWIGUNUSEDPARM(self), PyObject *args) {
PyObject *resultobj = 0;
tdb *arg1 = (tdb *) 0 ;
int result;
@@ -3384,7 +3384,7 @@ SWIGINTERN PyObject *_wrap_tdb_reopen(PyObject *SWIGUNUSEDPARM(self), PyObject *
swig_obj[0] = args;
res1 = SWIG_ConvertPtr(swig_obj[0], &argp1,SWIGTYPE_p_tdb_context, 0 | 0 );
if (!SWIG_IsOK(res1)) {
- SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "tdb_reopen" "', argument " "1"" of type '" "tdb *""'");
+ SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "Tdb_reopen" "', argument " "1"" of type '" "tdb *""'");
}
arg1 = (tdb *)(argp1);
result = (int)tdb_reopen(arg1);
@@ -3395,7 +3395,7 @@ fail:
}
-SWIGINTERN PyObject *_wrap_tdb_transaction_start(PyObject *SWIGUNUSEDPARM(self), PyObject *args) {
+SWIGINTERN PyObject *_wrap_Tdb_transaction_start(PyObject *SWIGUNUSEDPARM(self), PyObject *args) {
PyObject *resultobj = 0;
tdb *arg1 = (tdb *) 0 ;
int result;
@@ -3407,7 +3407,7 @@ SWIGINTERN PyObject *_wrap_tdb_transaction_start(PyObject *SWIGUNUSEDPARM(self),
swig_obj[0] = args;
res1 = SWIG_ConvertPtr(swig_obj[0], &argp1,SWIGTYPE_p_tdb_context, 0 | 0 );
if (!SWIG_IsOK(res1)) {
- SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "tdb_transaction_start" "', argument " "1"" of type '" "tdb *""'");
+ SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "Tdb_transaction_start" "', argument " "1"" of type '" "tdb *""'");
}
arg1 = (tdb *)(argp1);
result = (int)tdb_transaction_start(arg1);
@@ -3418,7 +3418,7 @@ fail:
}
-SWIGINTERN PyObject *_wrap_tdb_transaction_commit(PyObject *SWIGUNUSEDPARM(self), PyObject *args) {
+SWIGINTERN PyObject *_wrap_Tdb_transaction_commit(PyObject *SWIGUNUSEDPARM(self), PyObject *args) {
PyObject *resultobj = 0;
tdb *arg1 = (tdb *) 0 ;
int result;
@@ -3430,7 +3430,7 @@ SWIGINTERN PyObject *_wrap_tdb_transaction_commit(PyObject *SWIGUNUSEDPARM(self)
swig_obj[0] = args;
res1 = SWIG_ConvertPtr(swig_obj[0], &argp1,SWIGTYPE_p_tdb_context, 0 | 0 );
if (!SWIG_IsOK(res1)) {
- SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "tdb_transaction_commit" "', argument " "1"" of type '" "tdb *""'");
+ SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "Tdb_transaction_commit" "', argument " "1"" of type '" "tdb *""'");
}
arg1 = (tdb *)(argp1);
result = (int)tdb_transaction_commit(arg1);
@@ -3441,7 +3441,7 @@ fail:
}
-SWIGINTERN PyObject *_wrap_tdb_transaction_cancel(PyObject *SWIGUNUSEDPARM(self), PyObject *args) {
+SWIGINTERN PyObject *_wrap_Tdb_transaction_cancel(PyObject *SWIGUNUSEDPARM(self), PyObject *args) {
PyObject *resultobj = 0;
tdb *arg1 = (tdb *) 0 ;
int result;
@@ -3453,7 +3453,7 @@ SWIGINTERN PyObject *_wrap_tdb_transaction_cancel(PyObject *SWIGUNUSEDPARM(self)
swig_obj[0] = args;
res1 = SWIG_ConvertPtr(swig_obj[0], &argp1,SWIGTYPE_p_tdb_context, 0 | 0 );
if (!SWIG_IsOK(res1)) {
- SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "tdb_transaction_cancel" "', argument " "1"" of type '" "tdb *""'");
+ SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "Tdb_transaction_cancel" "', argument " "1"" of type '" "tdb *""'");
}
arg1 = (tdb *)(argp1);
result = (int)tdb_transaction_cancel(arg1);
@@ -3464,7 +3464,7 @@ fail:
}
-SWIGINTERN PyObject *_wrap_tdb_transaction_recover(PyObject *SWIGUNUSEDPARM(self), PyObject *args) {
+SWIGINTERN PyObject *_wrap_Tdb_transaction_recover(PyObject *SWIGUNUSEDPARM(self), PyObject *args) {
PyObject *resultobj = 0;
tdb *arg1 = (tdb *) 0 ;
int result;
@@ -3476,7 +3476,7 @@ SWIGINTERN PyObject *_wrap_tdb_transaction_recover(PyObject *SWIGUNUSEDPARM(self
swig_obj[0] = args;
res1 = SWIG_ConvertPtr(swig_obj[0], &argp1,SWIGTYPE_p_tdb_context, 0 | 0 );
if (!SWIG_IsOK(res1)) {
- SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "tdb_transaction_recover" "', argument " "1"" of type '" "tdb *""'");
+ SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "Tdb_transaction_recover" "', argument " "1"" of type '" "tdb *""'");
}
arg1 = (tdb *)(argp1);
result = (int)tdb_transaction_recover(arg1);
@@ -3487,7 +3487,7 @@ fail:
}
-SWIGINTERN PyObject *_wrap_tdb_hash_size(PyObject *SWIGUNUSEDPARM(self), PyObject *args) {
+SWIGINTERN PyObject *_wrap_Tdb_hash_size(PyObject *SWIGUNUSEDPARM(self), PyObject *args) {
PyObject *resultobj = 0;
tdb *arg1 = (tdb *) 0 ;
int result;
@@ -3499,7 +3499,7 @@ SWIGINTERN PyObject *_wrap_tdb_hash_size(PyObject *SWIGUNUSEDPARM(self), PyObjec
swig_obj[0] = args;
res1 = SWIG_ConvertPtr(swig_obj[0], &argp1,SWIGTYPE_p_tdb_context, 0 | 0 );
if (!SWIG_IsOK(res1)) {
- SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "tdb_hash_size" "', argument " "1"" of type '" "tdb *""'");
+ SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "Tdb_hash_size" "', argument " "1"" of type '" "tdb *""'");
}
arg1 = (tdb *)(argp1);
result = (int)tdb_hash_size(arg1);
@@ -3510,7 +3510,7 @@ fail:
}
-SWIGINTERN PyObject *_wrap_tdb_map_size(PyObject *SWIGUNUSEDPARM(self), PyObject *args) {
+SWIGINTERN PyObject *_wrap_Tdb_map_size(PyObject *SWIGUNUSEDPARM(self), PyObject *args) {
PyObject *resultobj = 0;
tdb *arg1 = (tdb *) 0 ;
size_t result;
@@ -3522,7 +3522,7 @@ SWIGINTERN PyObject *_wrap_tdb_map_size(PyObject *SWIGUNUSEDPARM(self), PyObject
swig_obj[0] = args;
res1 = SWIG_ConvertPtr(swig_obj[0], &argp1,SWIGTYPE_p_tdb_context, 0 | 0 );
if (!SWIG_IsOK(res1)) {
- SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "tdb_map_size" "', argument " "1"" of type '" "tdb *""'");
+ SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "Tdb_map_size" "', argument " "1"" of type '" "tdb *""'");
}
arg1 = (tdb *)(argp1);
result = tdb_map_size(arg1);
@@ -3533,7 +3533,7 @@ fail:
}
-SWIGINTERN PyObject *_wrap_tdb_get_flags(PyObject *SWIGUNUSEDPARM(self), PyObject *args) {
+SWIGINTERN PyObject *_wrap_Tdb_get_flags(PyObject *SWIGUNUSEDPARM(self), PyObject *args) {
PyObject *resultobj = 0;
tdb *arg1 = (tdb *) 0 ;
int result;
@@ -3545,7 +3545,7 @@ SWIGINTERN PyObject *_wrap_tdb_get_flags(PyObject *SWIGUNUSEDPARM(self), PyObjec
swig_obj[0] = args;
res1 = SWIG_ConvertPtr(swig_obj[0], &argp1,SWIGTYPE_p_tdb_context, 0 | 0 );
if (!SWIG_IsOK(res1)) {
- SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "tdb_get_flags" "', argument " "1"" of type '" "tdb *""'");
+ SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "Tdb_get_flags" "', argument " "1"" of type '" "tdb *""'");
}
arg1 = (tdb *)(argp1);
result = (int)tdb_get_flags(arg1);
@@ -3556,7 +3556,7 @@ fail:
}
-SWIGINTERN PyObject *_wrap_tdb_set_max_dead(PyObject *SWIGUNUSEDPARM(self), PyObject *args, PyObject *kwargs) {
+SWIGINTERN PyObject *_wrap_Tdb_set_max_dead(PyObject *SWIGUNUSEDPARM(self), PyObject *args, PyObject *kwargs) {
PyObject *resultobj = 0;
tdb *arg1 = (tdb *) 0 ;
int arg2 ;
@@ -3570,15 +3570,15 @@ SWIGINTERN PyObject *_wrap_tdb_set_max_dead(PyObject *SWIGUNUSEDPARM(self), PyOb
(char *) "self",(char *) "max_dead", NULL
};
- if (!PyArg_ParseTupleAndKeywords(args,kwargs,(char *)"OO:tdb_set_max_dead",kwnames,&obj0,&obj1)) SWIG_fail;
+ if (!PyArg_ParseTupleAndKeywords(args,kwargs,(char *)"OO:Tdb_set_max_dead",kwnames,&obj0,&obj1)) SWIG_fail;
res1 = SWIG_ConvertPtr(obj0, &argp1,SWIGTYPE_p_tdb_context, 0 | 0 );
if (!SWIG_IsOK(res1)) {
- SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "tdb_set_max_dead" "', argument " "1"" of type '" "tdb *""'");
+ SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "Tdb_set_max_dead" "', argument " "1"" of type '" "tdb *""'");
}
arg1 = (tdb *)(argp1);
ecode2 = SWIG_AsVal_int(obj1, &val2);
if (!SWIG_IsOK(ecode2)) {
- SWIG_exception_fail(SWIG_ArgError(ecode2), "in method '" "tdb_set_max_dead" "', argument " "2"" of type '" "int""'");
+ SWIG_exception_fail(SWIG_ArgError(ecode2), "in method '" "Tdb_set_max_dead" "', argument " "2"" of type '" "int""'");
}
arg2 = (int)(val2);
tdb_set_max_dead(arg1,arg2);
@@ -3589,7 +3589,7 @@ fail:
}
-SWIGINTERN PyObject *_wrap_tdb_name(PyObject *SWIGUNUSEDPARM(self), PyObject *args) {
+SWIGINTERN PyObject *_wrap_Tdb_name(PyObject *SWIGUNUSEDPARM(self), PyObject *args) {
PyObject *resultobj = 0;
tdb *arg1 = (tdb *) 0 ;
char *result = 0 ;
@@ -3601,7 +3601,7 @@ SWIGINTERN PyObject *_wrap_tdb_name(PyObject *SWIGUNUSEDPARM(self), PyObject *ar
swig_obj[0] = args;
res1 = SWIG_ConvertPtr(swig_obj[0], &argp1,SWIGTYPE_p_tdb_context, 0 | 0 );
if (!SWIG_IsOK(res1)) {
- SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "tdb_name" "', argument " "1"" of type '" "tdb *""'");
+ SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "Tdb_name" "', argument " "1"" of type '" "tdb *""'");
}
arg1 = (tdb *)(argp1);
result = (char *)tdb_name(arg1);
@@ -3612,41 +3612,85 @@ fail:
}
-SWIGINTERN PyObject *tdb_swigregister(PyObject *SWIGUNUSEDPARM(self), PyObject *args) {
+SWIGINTERN PyObject *Tdb_swigregister(PyObject *SWIGUNUSEDPARM(self), PyObject *args) {
PyObject *obj;
if (!SWIG_Python_UnpackTuple(args,(char*)"swigregister", 1, 1,&obj)) return NULL;
SWIG_TypeNewClientData(SWIGTYPE_p_tdb_context, SWIG_NewClientData(obj));
return SWIG_Py_Void();
}
+SWIGINTERN PyObject *Tdb_swiginit(PyObject *SWIGUNUSEDPARM(self), PyObject *args) {
+ return SWIG_Python_InitShadowInstance(args);
+}
+
static PyMethodDef SwigMethods[] = {
- { (char *)"new_Tdb", (PyCFunction) _wrap_new_Tdb, METH_VARARGS | METH_KEYWORDS, NULL},
- { (char *)"tdb_error", (PyCFunction)_wrap_tdb_error, METH_O, NULL},
- { (char *)"delete_tdb", (PyCFunction)_wrap_delete_tdb, METH_O, NULL},
- { (char *)"tdb_close", (PyCFunction)_wrap_tdb_close, METH_O, NULL},
- { (char *)"tdb_append", (PyCFunction) _wrap_tdb_append, METH_VARARGS | METH_KEYWORDS, NULL},
- { (char *)"tdb_errorstr", (PyCFunction)_wrap_tdb_errorstr, METH_O, NULL},
- { (char *)"tdb_get", (PyCFunction) _wrap_tdb_get, METH_VARARGS | METH_KEYWORDS, NULL},
- { (char *)"tdb_delete", (PyCFunction) _wrap_tdb_delete, METH_VARARGS | METH_KEYWORDS, NULL},
- { (char *)"tdb_store", (PyCFunction) _wrap_tdb_store, METH_VARARGS | METH_KEYWORDS, NULL},
- { (char *)"tdb_exists", (PyCFunction) _wrap_tdb_exists, METH_VARARGS | METH_KEYWORDS, NULL},
- { (char *)"tdb_firstkey", (PyCFunction)_wrap_tdb_firstkey, METH_O, NULL},
- { (char *)"tdb_nextkey", (PyCFunction) _wrap_tdb_nextkey, METH_VARARGS | METH_KEYWORDS, NULL},
- { (char *)"tdb_lock_all", (PyCFunction)_wrap_tdb_lock_all, METH_O, NULL},
- { (char *)"tdb_unlock_all", (PyCFunction)_wrap_tdb_unlock_all, METH_O, NULL},
- { (char *)"tdb_read_lock_all", (PyCFunction)_wrap_tdb_read_lock_all, METH_O, NULL},
- { (char *)"tdb_read_unlock_all", (PyCFunction)_wrap_tdb_read_unlock_all, METH_O, NULL},
- { (char *)"tdb_reopen", (PyCFunction)_wrap_tdb_reopen, METH_O, NULL},
- { (char *)"tdb_transaction_start", (PyCFunction)_wrap_tdb_transaction_start, METH_O, NULL},
- { (char *)"tdb_transaction_commit", (PyCFunction)_wrap_tdb_transaction_commit, METH_O, NULL},
- { (char *)"tdb_transaction_cancel", (PyCFunction)_wrap_tdb_transaction_cancel, METH_O, NULL},
- { (char *)"tdb_transaction_recover", (PyCFunction)_wrap_tdb_transaction_recover, METH_O, NULL},
- { (char *)"tdb_hash_size", (PyCFunction)_wrap_tdb_hash_size, METH_O, NULL},
- { (char *)"tdb_map_size", (PyCFunction)_wrap_tdb_map_size, METH_O, NULL},
- { (char *)"tdb_get_flags", (PyCFunction)_wrap_tdb_get_flags, METH_O, NULL},
- { (char *)"tdb_set_max_dead", (PyCFunction) _wrap_tdb_set_max_dead, METH_VARARGS | METH_KEYWORDS, NULL},
- { (char *)"tdb_name", (PyCFunction)_wrap_tdb_name, METH_O, NULL},
- { (char *)"tdb_swigregister", tdb_swigregister, METH_VARARGS, NULL},
+ { (char *)"new_Tdb", (PyCFunction) _wrap_new_Tdb, METH_VARARGS | METH_KEYWORDS, (char *)"\n"
+ "S.__init__(name,hash_size=0,tdb_flags=TDB_DEFAULT,flags=O_RDWR,mode=0600)\n"
+ "Open a TDB file.\n"
+ ""},
+ { (char *)"Tdb_error", (PyCFunction)_wrap_Tdb_error, METH_O, NULL},
+ { (char *)"delete_Tdb", (PyCFunction)_wrap_delete_Tdb, METH_O, NULL},
+ { (char *)"Tdb_close", (PyCFunction)_wrap_Tdb_close, METH_O, (char *)"\n"
+ "S.close() -> None\n"
+ "Close the TDB file.\n"
+ ""},
+ { (char *)"Tdb_append", (PyCFunction) _wrap_Tdb_append, METH_VARARGS | METH_KEYWORDS, NULL},
+ { (char *)"Tdb_errorstr", (PyCFunction)_wrap_Tdb_errorstr, METH_O, (char *)"\n"
+ "S.errorstr() -> errorstring\n"
+ "Obtain last error message.\n"
+ ""},
+ { (char *)"Tdb_get", (PyCFunction) _wrap_Tdb_get, METH_VARARGS | METH_KEYWORDS, (char *)"\n"
+ "S.fetch(key) -> value\n"
+ "Fetch a value.\n"
+ ""},
+ { (char *)"Tdb_delete", (PyCFunction) _wrap_Tdb_delete, METH_VARARGS | METH_KEYWORDS, (char *)"\n"
+ "S.delete(key) -> None\n"
+ "Delete an entry.\n"
+ ""},
+ { (char *)"Tdb_store", (PyCFunction) _wrap_Tdb_store, METH_VARARGS | METH_KEYWORDS, (char *)"\n"
+ "S.store(key, value, flag=TDB_REPLACE) -> None\n"
+ "Store an entry.\n"
+ ""},
+ { (char *)"Tdb_exists", (PyCFunction) _wrap_Tdb_exists, METH_VARARGS | METH_KEYWORDS, NULL},
+ { (char *)"Tdb_firstkey", (PyCFunction)_wrap_Tdb_firstkey, METH_O, (char *)"\n"
+ "S.firstkey() -> data\n"
+ "Return the first key in this database.\n"
+ ""},
+ { (char *)"Tdb_nextkey", (PyCFunction) _wrap_Tdb_nextkey, METH_VARARGS | METH_KEYWORDS, (char *)"\n"
+ "S.nextkey(prev) -> data\n"
+ "Return the next key in this database.\n"
+ ""},
+ { (char *)"Tdb_lock_all", (PyCFunction)_wrap_Tdb_lock_all, METH_O, (char *)"S.lockall() -> bool"},
+ { (char *)"Tdb_unlock_all", (PyCFunction)_wrap_Tdb_unlock_all, METH_O, (char *)"S.unlockall() -> bool"},
+ { (char *)"Tdb_read_lock_all", (PyCFunction)_wrap_Tdb_read_lock_all, METH_O, NULL},
+ { (char *)"Tdb_read_unlock_all", (PyCFunction)_wrap_Tdb_read_unlock_all, METH_O, NULL},
+ { (char *)"Tdb_reopen", (PyCFunction)_wrap_Tdb_reopen, METH_O, (char *)"\n"
+ "S.reopen() -> bool\n"
+ "Reopen this file.\n"
+ ""},
+ { (char *)"Tdb_transaction_start", (PyCFunction)_wrap_Tdb_transaction_start, METH_O, (char *)"\n"
+ "S.transaction_start() -> None\n"
+ "Start a new transaction.\n"
+ ""},
+ { (char *)"Tdb_transaction_commit", (PyCFunction)_wrap_Tdb_transaction_commit, METH_O, (char *)"\n"
+ "S.transaction_commit() -> None\n"
+ "Commit the currently active transaction.\n"
+ ""},
+ { (char *)"Tdb_transaction_cancel", (PyCFunction)_wrap_Tdb_transaction_cancel, METH_O, (char *)"\n"
+ "S.transaction_cancel() -> None\n"
+ "Cancel the currently active transaction.\n"
+ ""},
+ { (char *)"Tdb_transaction_recover", (PyCFunction)_wrap_Tdb_transaction_recover, METH_O, NULL},
+ { (char *)"Tdb_hash_size", (PyCFunction)_wrap_Tdb_hash_size, METH_O, (char *)"S.hash_size() -> int"},
+ { (char *)"Tdb_map_size", (PyCFunction)_wrap_Tdb_map_size, METH_O, (char *)"S.map_size() -> int"},
+ { (char *)"Tdb_get_flags", (PyCFunction)_wrap_Tdb_get_flags, METH_O, (char *)"S.get_flags() -> int"},
+ { (char *)"Tdb_set_max_dead", (PyCFunction) _wrap_Tdb_set_max_dead, METH_VARARGS | METH_KEYWORDS, (char *)"S.set_max_dead(int) -> None"},
+ { (char *)"Tdb_name", (PyCFunction)_wrap_Tdb_name, METH_O, (char *)"\n"
+ "S.name() -> path\n"
+ "Return filename of this TDB file.\n"
+ ""},
+ { (char *)"Tdb_swigregister", Tdb_swigregister, METH_VARARGS, NULL},
+ { (char *)"Tdb_swiginit", Tdb_swiginit, METH_VARARGS, NULL},
{ NULL, NULL, 0, NULL }
};
diff --git a/source4/lib/util/debug.c b/source4/lib/util/debug.c
index 5c1abf5039..00dcbfc8bd 100644
--- a/source4/lib/util/debug.c
+++ b/source4/lib/util/debug.c
@@ -21,7 +21,7 @@
#include "includes.h"
#include "system/filesys.h"
#include "system/time.h"
-#include "dynconfig.h"
+#include "dynconfig/dynconfig.h"
/**
* @file
diff --git a/source4/libcli/config.mk b/source4/libcli/config.mk
index b24f3eb4af..02711eedb3 100644
--- a/source4/libcli/config.mk
+++ b/source4/libcli/config.mk
@@ -61,15 +61,14 @@ $(eval $(call proto_header_template,$(libclisrcdir)/nbt/nbt_proto.h,$(LIBCLI_NBT
PUBLIC_DEPENDENCIES = LIBNDR \
NDR_SECURITY
-LIBCLI_NDR_NETLOGON_OBJ_FILES = $(addprefix libcli/, \
- ndr_netlogon.o)
+LIBCLI_NDR_NETLOGON_OBJ_FILES = $(addprefix $(libclisrcdir)/, ndr_netlogon.o)
$(eval $(call proto_header_template,$(libclisrcdir)/ndr_netlogon_proto.h,$(LIBCLI_NDR_NETLOGON_OBJ_FILES:.o=.c)))
[SUBSYSTEM::LIBCLI_NETLOGON]
PUBLIC_DEPENDENCIES = LIBSAMBA-UTIL LIBCLI_NDR_NETLOGON
-LIBCLI_NETLOGON_OBJ_FILES = $(addprefix libcli/, \
+LIBCLI_NETLOGON_OBJ_FILES = $(addprefix $(libclisrcdir)/, \
netlogon.o)
$(eval $(call proto_header_template,$(libclisrcdir)/netlogon_proto.h,$(LIBCLI_NETLOGON_OBJ_FILES:.o=.c)))
diff --git a/source4/libcli/nbt/nbtname.c b/source4/libcli/nbt/nbtname.c
index 0d9073ccbb..97ae2e9d72 100644
--- a/source4/libcli/nbt/nbtname.c
+++ b/source4/libcli/nbt/nbtname.c
@@ -626,3 +626,24 @@ _PUBLIC_ void ndr_print_wrepl_nbt_name(struct ndr_print *ndr, const char *name,
ndr_print_string(ndr, name, s);
talloc_free(s);
}
+
+_PUBLIC_ enum ndr_err_code ndr_push_nbt_res_rec(struct ndr_push *ndr, int ndr_flags, const struct nbt_res_rec *r)
+{
+ {
+ uint32_t _flags_save_STRUCT = ndr->flags;
+ ndr_set_flags(&ndr->flags, LIBNDR_PRINT_ARRAY_HEX);
+ if (ndr_flags & NDR_SCALARS) {
+ NDR_CHECK(ndr_push_align(ndr, 4));
+ NDR_CHECK(ndr_push_nbt_name(ndr, NDR_SCALARS, &r->name));
+ NDR_CHECK(ndr_push_nbt_qtype(ndr, NDR_SCALARS, r->rr_type));
+ NDR_CHECK(ndr_push_nbt_qclass(ndr, NDR_SCALARS, r->rr_class));
+ NDR_CHECK(ndr_push_uint32(ndr, NDR_SCALARS, r->ttl));
+ NDR_CHECK(ndr_push_set_switch_value(ndr, &r->rdata, ((((r->rr_type) == NBT_QTYPE_NETBIOS) && ((r->rdata).data.length == 2))?0:r->rr_type)));
+ NDR_CHECK(ndr_push_nbt_rdata(ndr, NDR_SCALARS, &r->rdata));
+ }
+ if (ndr_flags & NDR_BUFFERS) {
+ }
+ ndr->flags = _flags_save_STRUCT;
+ }
+ return NDR_ERR_SUCCESS;
+}
diff --git a/source4/libcli/raw/interfaces.h b/source4/libcli/raw/interfaces.h
index 3370021d48..17c85138ac 100644
--- a/source4/libcli/raw/interfaces.h
+++ b/source4/libcli/raw/interfaces.h
@@ -684,7 +684,8 @@ union smb_fileinfo {
uint32_t ea_size;
uint32_t access_mask;
uint64_t position;
- uint64_t mode;
+ uint32_t mode;
+ uint32_t alignment_requirement;
struct smb_wire_string fname;
} out;
} all_info2;
@@ -1646,7 +1647,7 @@ union smb_read {
struct {
union smb_handle file;
uint64_t offset;
- uint16_t mincnt;
+ uint32_t mincnt; /* enforced on SMB2, 16 bit on SMB */
uint32_t maxcnt;
uint16_t remaining;
bool read_for_execute;
@@ -1918,6 +1919,7 @@ union smb_lock {
#define SMB2_LOCK_FLAG_EXCLUSIVE 0x00000002
#define SMB2_LOCK_FLAG_UNLOCK 0x00000004
#define SMB2_LOCK_FLAG_FAIL_IMMEDIATELY 0x00000010
+#define SMB2_LOCK_FLAG_ALL_MASK 0x00000017
uint32_t flags;
uint32_t reserved;
} *locks;
@@ -1948,23 +1950,43 @@ union smb_lock {
enum smb_close_level {
RAW_CLOSE_CLOSE,
RAW_CLOSE_SPLCLOSE,
- RAW_CLOSE_SMB2
+ RAW_CLOSE_SMB2,
+ RAW_CLOSE_GENERIC,
};
-#define RAW_CLOSE_GENERIC RAW_CLOSE_CLOSE
-
/*
union for close() backend call
*/
union smb_close {
- /* SMBclose (and generic) interface */
+ /* generic interface */
+ struct {
+ enum smb_close_level level;
+ struct {
+ union smb_handle file;
+ time_t write_time;
+#define SMB2_CLOSE_FLAGS_FULL_INFORMATION (1<<0)
+ uint16_t flags; /* SMB2_CLOSE_FLAGS_* */
+ } in;
+ struct {
+ uint16_t flags;
+ NTTIME create_time;
+ NTTIME access_time;
+ NTTIME write_time;
+ NTTIME change_time;
+ uint64_t alloc_size;
+ uint64_t size;
+ uint32_t file_attr;
+ } out;
+ } generic;
+
+ /* SMBclose interface */
struct {
enum smb_close_level level;
struct {
union smb_handle file;
time_t write_time;
} in;
- } close, generic;
+ } close;
/* SMBsplclose interface - empty! */
struct {
@@ -1982,7 +2004,6 @@ union smb_close {
/* static body buffer 24 (0x18) bytes */
/* uint16_t buffer_code; 0x18 */
-#define SMB2_CLOSE_FLAGS_FULL_INFORMATION (1<<0)
uint16_t flags; /* SMB2_CLOSE_FLAGS_* */
uint32_t _pad;
} in;
diff --git a/source4/libcli/raw/raweas.c b/source4/libcli/raw/raweas.c
index 8ea8e621c9..07b517ade3 100644
--- a/source4/libcli/raw/raweas.c
+++ b/source4/libcli/raw/raweas.c
@@ -54,13 +54,13 @@ static uint_t ea_name_list_size(uint_t num_names, struct ea_name *eas)
This assumes the names are strict ascii, which should be a
reasonable assumption
*/
-size_t ea_list_size_chained(uint_t num_eas, struct ea_struct *eas)
+size_t ea_list_size_chained(uint_t num_eas, struct ea_struct *eas, unsigned alignment)
{
uint_t total = 0;
int i;
for (i=0;i<num_eas;i++) {
uint_t len = 8 + strlen(eas[i].name.s)+1 + eas[i].value.length;
- len = (len + 3) & ~3;
+ len = (len + (alignment-1)) & ~(alignment-1);
total += len;
}
return total;
@@ -96,14 +96,15 @@ void ea_put_list(uint8_t *data, uint_t num_eas, struct ea_struct *eas)
put a chained ea_list into a pre-allocated buffer - buffer must be
at least of size ea_list_size()
*/
-void ea_put_list_chained(uint8_t *data, uint_t num_eas, struct ea_struct *eas)
+void ea_put_list_chained(uint8_t *data, uint_t num_eas, struct ea_struct *eas,
+ unsigned alignment)
{
int i;
for (i=0;i<num_eas;i++) {
uint_t nlen = strlen(eas[i].name.s);
uint32_t len = 8+nlen+1+eas[i].value.length;
- uint_t pad = ((len + 3) & ~3) - len;
+ uint_t pad = ((len + (alignment-1)) & ~(alignment-1)) - len;
if (i == num_eas-1) {
SIVAL(data, 0, 0);
} else {
diff --git a/source4/libcli/raw/rawfile.c b/source4/libcli/raw/rawfile.c
index 3c5c1b742b..d39c61551b 100644
--- a/source4/libcli/raw/rawfile.c
+++ b/source4/libcli/raw/rawfile.c
@@ -314,14 +314,14 @@ static struct smbcli_request *smb_raw_nttrans_create_send(struct smbcli_tree *tr
if (parms->ntcreatex.in.ea_list) {
uint32_t ea_size = ea_list_size_chained(parms->ntcreatex.in.ea_list->num_eas,
- parms->ntcreatex.in.ea_list->eas);
+ parms->ntcreatex.in.ea_list->eas, 4);
ea_blob = data_blob_talloc(mem_ctx, NULL, ea_size);
if (ea_blob.data == NULL) {
return NULL;
}
ea_put_list_chained(ea_blob.data,
parms->ntcreatex.in.ea_list->num_eas,
- parms->ntcreatex.in.ea_list->eas);
+ parms->ntcreatex.in.ea_list->eas, 4);
}
nt.in.params = data_blob_talloc(mem_ctx, NULL, 53);
diff --git a/source4/libcli/raw/rawfileinfo.c b/source4/libcli/raw/rawfileinfo.c
index 71900be49c..0ea5a93606 100644
--- a/source4/libcli/raw/rawfileinfo.c
+++ b/source4/libcli/raw/rawfileinfo.c
@@ -243,7 +243,8 @@ NTSTATUS smb_raw_fileinfo_passthru_parse(const DATA_BLOB *blob, TALLOC_CTX *mem_
parms->all_info2.out.ea_size = IVAL(blob->data, 0x48);
parms->all_info2.out.access_mask = IVAL(blob->data, 0x4C);
parms->all_info2.out.position = BVAL(blob->data, 0x50);
- parms->all_info2.out.mode = BVAL(blob->data, 0x58);
+ parms->all_info2.out.mode = IVAL(blob->data, 0x58);
+ parms->all_info2.out.alignment_requirement = IVAL(blob->data, 0x5C);
smbcli_blob_pull_string(NULL, mem_ctx, blob,
&parms->all_info2.out.fname, 0x60, 0x64, STR_UNICODE);
return NT_STATUS_OK;
diff --git a/source4/libcli/raw/smb.h b/source4/libcli/raw/smb.h
index e054ed6522..5a92b99757 100644
--- a/source4/libcli/raw/smb.h
+++ b/source4/libcli/raw/smb.h
@@ -133,6 +133,7 @@
#define NTCREATEX_SHARE_ACCESS_READ 1
#define NTCREATEX_SHARE_ACCESS_WRITE 2
#define NTCREATEX_SHARE_ACCESS_DELETE 4
+#define NTCREATEX_SHARE_ACCESS_MASK 7
/* ntcreatex open_disposition field */
#define NTCREATEX_DISP_SUPERSEDE 0 /* supersede existing file (if it exists) */
@@ -154,14 +155,18 @@
#define NTCREATEX_OPTIONS_RANDOM_ACCESS 0x0800
#define NTCREATEX_OPTIONS_DELETE_ON_CLOSE 0x1000
#define NTCREATEX_OPTIONS_OPEN_BY_FILE_ID 0x2000
-#define NTCREATEX_OPTIONS_UNKNOWN_400000 0x400000
-
+#define NTCREATEX_OPTIONS_BACKUP_INTENT 0x4000
+#define NTCREATEX_OPTIONS_REPARSE_POINT 0x200000
+#define NTCREATEX_OPTIONS_UNKNOWN_400000 0x400000
/* create options these bits are for private use by backends, they are
not valid on the wire */
#define NTCREATEX_OPTIONS_PRIVATE_MASK 0xFF000000
#define NTCREATEX_OPTIONS_PRIVATE_DENY_DOS 0x01000000
#define NTCREATEX_OPTIONS_PRIVATE_DENY_FCB 0x02000000
+#define NTCREATEX_OPTIONS_NOT_SUPPORTED_MASK 0x00DFA188
+
+
/* ntcreatex impersonation field */
#define NTCREATEX_IMPERSONATION_ANONYMOUS 0
@@ -370,6 +375,7 @@
#define FILE_ATTRIBUTE_OFFLINE 0x1000
#define FILE_ATTRIBUTE_NONINDEXED 0x2000
#define FILE_ATTRIBUTE_ENCRYPTED 0x4000
+#define FILE_ATTRIBUTE_ALL_MASK 0x7FFF
/* Flags - combined with attributes. */
#define FILE_FLAG_WRITE_THROUGH 0x80000000L
diff --git a/source4/libcli/security/security.i b/source4/libcli/security/security.i
index 647c9aea09..1d964cc3d5 100644
--- a/source4/libcli/security/security.i
+++ b/source4/libcli/security/security.i
@@ -16,7 +16,7 @@
along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
-%module(package="samba.security") security
+%module(docstring="Security-related classes.",package="samba.security") security
%{
#include "includes.h"
@@ -65,8 +65,14 @@ enum sec_privilege {
typedef struct security_token {
%extend {
security_token(TALLOC_CTX *mem_ctx) { return security_token_initialise(mem_ctx); }
+ %feature("docstring") is_sid "S.is_sid(sid) -> bool\n" \
+ "Check whether this token is of the specified SID.";
bool is_sid(const struct dom_sid *sid);
+ %feature("docstring") is_system "S.is_system() -> bool\n" \
+ "Check whether this is a system token.";
bool is_system();
+ %feature("docstring") is_anonymous "S.is_anonymus() -> bool\n" \
+ "Check whether this is an anonymous token.";
bool is_anonymous();
bool has_sid(const struct dom_sid *sid);
bool has_builtin_administrators();
@@ -81,6 +87,8 @@ typedef struct security_token {
typedef struct security_descriptor {
%extend {
security_descriptor(TALLOC_CTX *mem_ctx) { return security_descriptor_initialise(mem_ctx); }
+ %feature("docstring") sacl_add "S.sacl_add(ace) -> None\n" \
+ "Add a security ace to this security descriptor";
NTSTATUS sacl_add(const struct security_ace *ace);
NTSTATUS dacl_add(const struct security_ace *ace);
NTSTATUS dacl_del(const struct dom_sid *trustee);
@@ -111,6 +119,9 @@ typedef struct dom_sid {
}
} dom_sid;
+%feature("docstring") random_sid "random_sid() -> sid\n" \
+ "Generate a random SID";
+
%inline %{
static struct dom_sid *random_sid(TALLOC_CTX *mem_ctx)
{
diff --git a/source4/libcli/security/security.py b/source4/libcli/security/security.py
index 10b263b27b..065c7a19e4 100644
--- a/source4/libcli/security/security.py
+++ b/source4/libcli/security/security.py
@@ -1,8 +1,12 @@
# 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.
+"""
+Security-related classes.
+"""
+
import _security
import new
new_instancemethod = new.instancemethod
@@ -86,6 +90,27 @@ class SecurityToken(object):
__repr__ = _swig_repr
def __init__(self, *args, **kwargs):
_security.SecurityToken_swiginit(self,_security.new_SecurityToken(*args, **kwargs))
+ def is_sid(*args, **kwargs):
+ """
+ S.is_sid(sid) -> bool
+ Check whether this token is of the specified SID.
+ """
+ return _security.SecurityToken_is_sid(*args, **kwargs)
+
+ def is_system(*args, **kwargs):
+ """
+ S.is_system() -> bool
+ Check whether this is a system token.
+ """
+ return _security.SecurityToken_is_system(*args, **kwargs)
+
+ def is_anonymous(*args, **kwargs):
+ """
+ S.is_anonymus() -> bool
+ Check whether this is an anonymous token.
+ """
+ return _security.SecurityToken_is_anonymous(*args, **kwargs)
+
__swig_destroy__ = _security.delete_SecurityToken
SecurityToken.is_sid = new_instancemethod(_security.SecurityToken_is_sid,None,SecurityToken)
SecurityToken.is_system = new_instancemethod(_security.SecurityToken_is_system,None,SecurityToken)
@@ -103,6 +128,13 @@ class security_descriptor(object):
__repr__ = _swig_repr
def __init__(self, *args, **kwargs):
_security.security_descriptor_swiginit(self,_security.new_security_descriptor(*args, **kwargs))
+ def sacl_add(*args, **kwargs):
+ """
+ S.sacl_add(ace) -> None
+ Add a security ace to this security descriptor
+ """
+ return _security.security_descriptor_sacl_add(*args, **kwargs)
+
__swig_destroy__ = _security.delete_security_descriptor
security_descriptor.sacl_add = new_instancemethod(_security.security_descriptor_sacl_add,None,security_descriptor)
security_descriptor.dacl_add = new_instancemethod(_security.security_descriptor_dacl_add,None,security_descriptor)
@@ -123,7 +155,13 @@ Sid.__eq__ = new_instancemethod(_security.Sid___eq__,None,Sid)
Sid_swigregister = _security.Sid_swigregister
Sid_swigregister(Sid)
-random_sid = _security.random_sid
+
+def random_sid(*args):
+ """
+ random_sid() -> sid
+ Generate a random SID
+ """
+ return _security.random_sid(*args)
privilege_name = _security.privilege_name
privilege_id = _security.privilege_id
diff --git a/source4/libcli/security/security_wrap.c b/source4/libcli/security/security_wrap.c
index eb9e4c45d9..a10626c043 100644
--- a/source4/libcli/security/security_wrap.c
+++ b/source4/libcli/security/security_wrap.c
@@ -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;
}
@@ -2503,7 +2521,7 @@ static swig_module_info swig_module = {swig_types, 14, 0, 0, 0, 0};
#define SWIG_name "_security"
-#define SWIGVERSION 0x010333
+#define SWIGVERSION 0x010335
#define SWIG_VERSION SWIGVERSION
@@ -3509,9 +3527,18 @@ fail:
static PyMethodDef SwigMethods[] = {
{ (char *)"new_SecurityToken", (PyCFunction)_wrap_new_SecurityToken, METH_NOARGS, NULL},
- { (char *)"SecurityToken_is_sid", (PyCFunction) _wrap_SecurityToken_is_sid, METH_VARARGS | METH_KEYWORDS, NULL},
- { (char *)"SecurityToken_is_system", (PyCFunction)_wrap_SecurityToken_is_system, METH_O, NULL},
- { (char *)"SecurityToken_is_anonymous", (PyCFunction)_wrap_SecurityToken_is_anonymous, METH_O, NULL},
+ { (char *)"SecurityToken_is_sid", (PyCFunction) _wrap_SecurityToken_is_sid, METH_VARARGS | METH_KEYWORDS, (char *)"\n"
+ "S.is_sid(sid) -> bool\n"
+ "Check whether this token is of the specified SID.\n"
+ ""},
+ { (char *)"SecurityToken_is_system", (PyCFunction)_wrap_SecurityToken_is_system, METH_O, (char *)"\n"
+ "S.is_system() -> bool\n"
+ "Check whether this is a system token.\n"
+ ""},
+ { (char *)"SecurityToken_is_anonymous", (PyCFunction)_wrap_SecurityToken_is_anonymous, METH_O, (char *)"\n"
+ "S.is_anonymus() -> bool\n"
+ "Check whether this is an anonymous token.\n"
+ ""},
{ (char *)"SecurityToken_has_sid", (PyCFunction) _wrap_SecurityToken_has_sid, METH_VARARGS | METH_KEYWORDS, NULL},
{ (char *)"SecurityToken_has_builtin_administrators", (PyCFunction)_wrap_SecurityToken_has_builtin_administrators, METH_O, NULL},
{ (char *)"SecurityToken_has_nt_authenticated_users", (PyCFunction)_wrap_SecurityToken_has_nt_authenticated_users, METH_O, NULL},
@@ -3521,7 +3548,10 @@ static PyMethodDef SwigMethods[] = {
{ (char *)"SecurityToken_swigregister", SecurityToken_swigregister, METH_VARARGS, NULL},
{ (char *)"SecurityToken_swiginit", SecurityToken_swiginit, METH_VARARGS, NULL},
{ (char *)"new_security_descriptor", (PyCFunction)_wrap_new_security_descriptor, METH_NOARGS, NULL},
- { (char *)"security_descriptor_sacl_add", (PyCFunction) _wrap_security_descriptor_sacl_add, METH_VARARGS | METH_KEYWORDS, NULL},
+ { (char *)"security_descriptor_sacl_add", (PyCFunction) _wrap_security_descriptor_sacl_add, METH_VARARGS | METH_KEYWORDS, (char *)"\n"
+ "S.sacl_add(ace) -> None\n"
+ "Add a security ace to this security descriptor\n"
+ ""},
{ (char *)"security_descriptor_dacl_add", (PyCFunction) _wrap_security_descriptor_dacl_add, METH_VARARGS | METH_KEYWORDS, NULL},
{ (char *)"security_descriptor_dacl_del", (PyCFunction) _wrap_security_descriptor_dacl_del, METH_VARARGS | METH_KEYWORDS, NULL},
{ (char *)"security_descriptor_sacl_del", (PyCFunction) _wrap_security_descriptor_sacl_del, METH_VARARGS | METH_KEYWORDS, NULL},
@@ -3535,7 +3565,10 @@ static PyMethodDef SwigMethods[] = {
{ (char *)"delete_Sid", (PyCFunction)_wrap_delete_Sid, METH_O, NULL},
{ (char *)"Sid_swigregister", Sid_swigregister, METH_VARARGS, NULL},
{ (char *)"Sid_swiginit", Sid_swiginit, METH_VARARGS, NULL},
- { (char *)"random_sid", (PyCFunction)_wrap_random_sid, METH_NOARGS, NULL},
+ { (char *)"random_sid", (PyCFunction)_wrap_random_sid, METH_NOARGS, (char *)"\n"
+ "random_sid() -> sid\n"
+ "Generate a random SID\n"
+ ""},
{ (char *)"privilege_name", (PyCFunction) _wrap_privilege_name, METH_VARARGS | METH_KEYWORDS, NULL},
{ (char *)"privilege_id", (PyCFunction) _wrap_privilege_id, METH_VARARGS | METH_KEYWORDS, NULL},
{ NULL, NULL, 0, NULL }
@@ -3674,7 +3707,7 @@ SWIGRUNTIME void
SWIG_InitializeModule(void *clientdata) {
size_t i;
swig_module_info *module_head, *iter;
- int found;
+ int found, init;
clientdata = clientdata;
@@ -3684,6 +3717,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 */
@@ -3712,6 +3748,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);
diff --git a/source4/libcli/smb2/create.c b/source4/libcli/smb2/create.c
index 6ac32a494f..1901cb4977 100644
--- a/source4/libcli/smb2/create.c
+++ b/source4/libcli/smb2/create.c
@@ -94,6 +94,7 @@ struct smb2_request *smb2_create_send(struct smb2_tree *tree, struct smb2_create
NTSTATUS status;
DATA_BLOB blob = data_blob(NULL, 0);
uint32_t i;
+ struct smb2_create_blobs blobs = io->in.blobs;
req = smb2_request_init_tree(tree, SMB2_OP_CREATE, 0x38, true, 0);
if (req == NULL) return NULL;
@@ -117,9 +118,9 @@ struct smb2_request *smb2_create_send(struct smb2_tree *tree, struct smb2_create
if (io->in.eas.num_eas != 0) {
DATA_BLOB b = data_blob_talloc(req, NULL,
- ea_list_size_chained(io->in.eas.num_eas, io->in.eas.eas));
- ea_put_list_chained(b.data, io->in.eas.num_eas, io->in.eas.eas);
- status = smb2_create_blob_add(req, &io->in.blobs,
+ ea_list_size_chained(io->in.eas.num_eas, io->in.eas.eas, 4));
+ ea_put_list_chained(b.data, io->in.eas.num_eas, io->in.eas.eas, 4);
+ status = smb2_create_blob_add(req, &blobs,
SMB2_CREATE_TAG_EXTA, b);
if (!NT_STATUS_IS_OK(status)) {
talloc_free(req);
@@ -130,22 +131,22 @@ struct smb2_request *smb2_create_send(struct smb2_tree *tree, struct smb2_create
/* an empty MxAc tag seems to be used to ask the server to
return the maximum access mask allowed on the file */
- status = smb2_create_blob_add(req, &io->in.blobs,
+ status = smb2_create_blob_add(req, &blobs,
SMB2_CREATE_TAG_MXAC, data_blob(NULL, 0));
if (!NT_STATUS_IS_OK(status)) {
talloc_free(req);
return NULL;
}
- for (i=0; i < io->in.blobs.num_blobs; i++) {
+ for (i=0; i < blobs.num_blobs; i++) {
bool last = false;
const struct smb2_create_blob *c;
- if ((i + 1) == io->in.blobs.num_blobs) {
+ if ((i + 1) == blobs.num_blobs) {
last = true;
}
- c = &io->in.blobs.blobs[i];
+ c = &blobs.blobs[i];
status = smb2_create_blob_push_one(req, &blob,
c, last);
if (!NT_STATUS_IS_OK(status)) {
diff --git a/source4/libcli/smb2/util.c b/source4/libcli/smb2/util.c
index 9eb344e83f..311cea94a0 100644
--- a/source4/libcli/smb2/util.c
+++ b/source4/libcli/smb2/util.c
@@ -127,6 +127,16 @@ int smb2_deltree(struct smb2_tree *tree, const char *dname)
return 0;
}
+ if (NT_STATUS_EQUAL(status, NT_STATUS_CANNOT_DELETE)) {
+ /* it could be read-only */
+ status = smb2_util_setatr(tree, dname, FILE_ATTRIBUTE_NORMAL);
+ status = smb2_util_unlink(tree, dname);
+ }
+ if (NT_STATUS_IS_OK(status)) {
+ talloc_free(tmp_ctx);
+ return 1;
+ }
+
ZERO_STRUCT(create_parm);
create_parm.in.desired_access = SEC_FLAG_MAXIMUM_ALLOWED;
create_parm.in.share_access =
diff --git a/source4/libcli/swig/libcli_smb.py b/source4/libcli/swig/libcli_smb.py
index 80c4040237..6e4fe036c7 100644
--- a/source4/libcli/swig/libcli_smb.py
+++ b/source4/libcli/swig/libcli_smb.py
@@ -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.
diff --git a/source4/libcli/swig/libcli_smb_wrap.c b/source4/libcli/swig/libcli_smb_wrap.c
index 8b71f2c3be..de8e6ba1e4 100644
--- a/source4/libcli/swig/libcli_smb_wrap.c
+++ b/source4/libcli/swig/libcli_smb_wrap.c
@@ -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;
}
@@ -2495,7 +2513,7 @@ static swig_module_info swig_module = {swig_types, 6, 0, 0, 0, 0};
#define SWIG_name "_libcli_smb"
-#define SWIGVERSION 0x010333
+#define SWIGVERSION 0x010335
#define SWIG_VERSION SWIGVERSION
@@ -2769,7 +2787,7 @@ SWIGRUNTIME void
SWIG_InitializeModule(void *clientdata) {
size_t i;
swig_module_info *module_head, *iter;
- int found;
+ int found, init;
clientdata = clientdata;
@@ -2779,6 +2797,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 */
@@ -2807,6 +2828,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);
diff --git a/source4/libcli/util/errors.i b/source4/libcli/util/errors.i
index 17efcbf62a..1fcde04c85 100644
--- a/source4/libcli/util/errors.i
+++ b/source4/libcli/util/errors.i
@@ -18,10 +18,13 @@
*/
#ifdef SWIGPYTHON
+%{
+#include "libcli/util/pyerrors.h"
+%}
+
%typemap(out,noblock=1) WERROR {
if (!W_ERROR_IS_OK($1)) {
- PyObject *obj = Py_BuildValue((char *)"(i,s)", W_ERROR_V($1), win_errstr($1));
- PyErr_SetObject(PyExc_RuntimeError, obj);
+ PyErr_SetWERROR($1);
SWIG_fail;
} else if ($result == NULL) {
$result = Py_None;
@@ -30,8 +33,7 @@
%typemap(out,noblock=1) NTSTATUS {
if (NT_STATUS_IS_ERR($1)) {
- PyObject *obj = Py_BuildValue((char *)"(i,s)", NT_STATUS_V($1), nt_errstr($1));
- PyErr_SetObject(PyExc_RuntimeError, obj);
+ PyErr_SetNTSTATUS($1);
SWIG_fail;
} else if ($result == NULL) {
$result = Py_None;
diff --git a/source4/scripting/python/pyrpc.h b/source4/libcli/util/pyerrors.h
index 93d583c10a..aaa35b4d26 100644
--- a/source4/scripting/python/pyrpc.h
+++ b/source4/libcli/util/pyerrors.h
@@ -17,23 +17,17 @@
along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
-#ifndef _PYRPC_H_
-#define _PYRPC_H_
+#ifndef __PYERRORS_H__
+#define __PYERRORS_H__
-#define PY_CHECK_TYPE(type, var, fail) \
- if (!type ## _Check(var)) {\
- PyErr_Format(PyExc_TypeError, "Expected type %s", type ## _Type.tp_name); \
- fail; \
- }
+#define PyErr_FromWERROR(err) Py_BuildValue("(i,s)", W_ERROR_V(err), discard_const_p(char, win_errstr(err)))
-#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_sid_Check
+#define PyErr_FromNTSTATUS(status) Py_BuildValue("(i,s)", NT_STATUS_V(status), discard_const_p(char, nt_errstr(status)))
-/* This macro is only provided by Python >= 2.3 */
-#ifndef PyAPI_DATA
-# define PyAPI_DATA(RTYPE) extern RTYPE
-#endif
+#define PyErr_SetWERROR(err) \
+ PyErr_SetObject(PyExc_RuntimeError, PyErr_FromWERROR(err))
-#endif /* _PYRPC_H_ */
+#define PyErr_SetNTSTATUS(status) \
+ PyErr_SetObject(PyExc_RuntimeError, PyErr_FromNTSTATUS(status))
+
+#endif /* __PYERRORS_H__ */
diff --git a/source4/libnet/py_net.c b/source4/libnet/py_net.c
index cf81d8070d..443da299c7 100644
--- a/source4/libnet/py_net.c
+++ b/source4/libnet/py_net.c
@@ -71,8 +71,11 @@ static PyObject *py_net_join(PyObject *cls, PyObject *args, PyObject *kwargs)
return result;
}
+static char py_net_join_doc[] = "join(domain_name, netbios_name, join_type, level) -> (join_password, domain_sid, domain_name)\n\n" \
+"Join the domain with the specified name.";
+
static struct PyMethodDef net_methods[] = {
- {"Join", (PyCFunction)py_net_join, METH_VARARGS|METH_KEYWORDS},
+ {"Join", (PyCFunction)py_net_join, METH_VARARGS|METH_KEYWORDS, py_net_join_doc},
{NULL }
};
diff --git a/source4/librpc/config.mk b/source4/librpc/config.mk
index 09f6f4104b..a83308d66b 100644
--- a/source4/librpc/config.mk
+++ b/source4/librpc/config.mk
@@ -357,7 +357,7 @@ NDR_WINBIND_OBJ_FILES = $(gen_ndrsrcdir)/ndr_winbind.o
#PUBLIC_HEADERS += $(gen_ndrsrcdir)/winbind.h
$(librpcsrcdir)/idl-deps:
- ./$(librpcsrcdir)/idl-deps.pl $(librpcsrcdir)/idl/*.idl >$@
+ $(PERL) $(librpcsrcdir)/idl-deps.pl $(librpcsrcdir)/idl/*.idl >$@
clean::
rm -f $(librpcsrcdir)/idl-deps
@@ -441,6 +441,11 @@ PUBLIC_DEPENDENCIES = dcerpc NDR_UNIXINFO
RPC_NDR_UNIXINFO_OBJ_FILES = $(gen_ndrsrcdir)/ndr_unixinfo_c.o
+[SUBSYSTEM::RPC_NDR_IRPC]
+PUBLIC_DEPENDENCIES = dcerpc NDR_IRPC
+
+RPC_NDR_IRPC_OBJ_FILES = $(gen_ndrsrcdir)/ndr_irpc_c.o
+
[LIBRARY::dcerpc_samr]
PUBLIC_DEPENDENCIES = dcerpc NDR_SAMR
@@ -614,217 +619,114 @@ PUBLIC_HEADERS += $(addprefix $(librpcsrcdir)/, rpc/dcerpc.h \
gen_ndr/epmapper.h gen_ndr/ndr_epmapper.h gen_ndr/ndr_epmapper_c.h)
-[MODULE::RPC_EJS_ECHO]
-INIT_FUNCTION = ejs_init_rpcecho
-SUBSYSTEM = smbcalls
-PRIVATE_DEPENDENCIES = dcerpc NDR_ECHO EJSRPC
-
-RPC_EJS_ECHO_OBJ_FILES = $(gen_ndrsrcdir)/ndr_echo_ejs.o
-
-[MODULE::RPC_EJS_MISC]
-INIT_FUNCTION = ejs_init_misc
-SUBSYSTEM = smbcalls
-PRIVATE_DEPENDENCIES = dcerpc NDR_MISC EJSRPC
-
-RPC_EJS_MISC_OBJ_FILES = $(gen_ndrsrcdir)/ndr_misc_ejs.o
-
-[MODULE::RPC_EJS_SAMR]
-INIT_FUNCTION = ejs_init_samr
-SUBSYSTEM = smbcalls
-PRIVATE_DEPENDENCIES = dcerpc NDR_SAMR EJSRPC RPC_EJS_LSA RPC_EJS_SECURITY RPC_EJS_MISC
-
-RPC_EJS_SAMR_OBJ_FILES = $(gen_ndrsrcdir)/ndr_samr_ejs.o
-
-[MODULE::RPC_EJS_SECURITY]
-INIT_FUNCTION = ejs_init_security
-SUBSYSTEM = smbcalls
-PRIVATE_DEPENDENCIES = dcerpc NDR_SECURITY EJSRPC
-
-RPC_EJS_SECURITY_OBJ_FILES = $(gen_ndrsrcdir)/ndr_security_ejs.o
-
-[MODULE::RPC_EJS_LSA]
-INIT_FUNCTION = ejs_init_lsarpc
-SUBSYSTEM = smbcalls
-PRIVATE_DEPENDENCIES = dcerpc NDR_LSA EJSRPC RPC_EJS_SECURITY RPC_EJS_MISC
-
-RPC_EJS_LSA_OBJ_FILES = $(gen_ndrsrcdir)/ndr_lsa_ejs.o
-
-[MODULE::RPC_EJS_DFS]
-INIT_FUNCTION = ejs_init_netdfs
-SUBSYSTEM = smbcalls
-PRIVATE_DEPENDENCIES = dcerpc NDR_DFS EJSRPC
-
-RPC_EJS_DFS_OBJ_FILES = $(gen_ndrsrcdir)/ndr_dfs_ejs.o
-
-[MODULE::RPC_EJS_DRSUAPI]
-INIT_FUNCTION = ejs_init_drsuapi
-SUBSYSTEM = smbcalls
-PRIVATE_DEPENDENCIES = dcerpc NDR_DRSUAPI EJSRPC RPC_EJS_MISC RPC_EJS_SAMR
-
-RPC_EJS_DRSUAPI_OBJ_FILES = $(gen_ndrsrcdir)/ndr_drsuapi_ejs.o
-
-[MODULE::RPC_EJS_SPOOLSS]
-INIT_FUNCTION = ejs_init_spoolss
-SUBSYSTEM = smbcalls
-ENABLE = NO
-PRIVATE_DEPENDENCIES = dcerpc NDR_SPOOLSS EJSRPC
-
-RPC_EJS_SPOOLSS_OBJ_FILES = $(gen_ndrsrcdir)/ndr_spoolss_ejs.o
-
-[MODULE::RPC_EJS_WKSSVC]
-INIT_FUNCTION = ejs_init_wkssvc
-SUBSYSTEM = smbcalls
-PRIVATE_DEPENDENCIES = dcerpc NDR_WKSSVC EJSRPC RPC_EJS_SRVSVC RPC_EJS_MISC
-
-RPC_EJS_WKSSVC_OBJ_FILES = $(gen_ndrsrcdir)/ndr_wkssvc_ejs.o
+[PYTHON::python_dcerpc]
+LIBRARY_REALNAME = samba/dcerpc/base.$(SHLIBEXT)
+PUBLIC_DEPENDENCIES = LIBCLI_SMB NDR_MISC LIBSAMBA-UTIL LIBSAMBA-HOSTCONFIG dcerpc_samr RPC_NDR_LSA DYNCONFIG swig_credentials param
-[MODULE::RPC_EJS_SRVSVC]
-INIT_FUNCTION = ejs_init_srvsvc
-SUBSYSTEM = smbcalls
-PRIVATE_DEPENDENCIES = dcerpc NDR_SRVSVC EJSRPC RPC_EJS_MISC RPC_EJS_SVCCTL RPC_EJS_SECURITY
-
-RPC_EJS_SRVSVC_OBJ_FILES = $(gen_ndrsrcdir)/ndr_srvsvc_ejs.o
-
-[MODULE::RPC_EJS_EVENTLOG]
-INIT_FUNCTION = ejs_init_eventlog
-SUBSYSTEM = smbcalls
-PRIVATE_DEPENDENCIES = dcerpc NDR_EVENTLOG EJSRPC RPC_EJS_MISC
-
-RPC_EJS_EVENTLOG_OBJ_FILES = $(gen_ndrsrcdir)/ndr_eventlog_ejs.o
-
-[MODULE::RPC_EJS_WINREG]
-INIT_FUNCTION = ejs_init_winreg
-SUBSYSTEM = smbcalls
-PRIVATE_DEPENDENCIES = dcerpc NDR_WINREG EJSRPC RPC_EJS_INITSHUTDOWN \
- RPC_EJS_MISC RPC_EJS_SECURITY
-
-RPC_EJS_WINREG_OBJ_FILES = $(gen_ndrsrcdir)/ndr_winreg_ejs.o
-
-[MODULE::RPC_EJS_INITSHUTDOWN]
-INIT_FUNCTION = ejs_init_initshutdown
-SUBSYSTEM = smbcalls
-PRIVATE_DEPENDENCIES = dcerpc NDR_INITSHUTDOWN EJSRPC
-
-RPC_EJS_INITSHUTDOWN_OBJ_FILES = $(gen_ndrsrcdir)/ndr_initshutdown_ejs.o
-
-[MODULE::RPC_EJS_NETLOGON]
-INIT_FUNCTION = ejs_init_netlogon
-SUBSYSTEM = smbcalls
-PRIVATE_DEPENDENCIES = dcerpc NDR_NETLOGON EJSRPC RPC_EJS_SAMR RPC_EJS_SECURITY RPC_EJS_MISC
-
-RPC_EJS_NETLOGON_OBJ_FILES = $(gen_ndrsrcdir)/ndr_netlogon_ejs.o
-
-[MODULE::RPC_EJS_SVCCTL]
-INIT_FUNCTION = ejs_init_svcctl
-SUBSYSTEM = smbcalls
-PRIVATE_DEPENDENCIES = dcerpc NDR_SVCCTL EJSRPC RPC_EJS_MISC
-
-RPC_EJS_SVCCTL_OBJ_FILES = $(gen_ndrsrcdir)/ndr_svcctl_ejs.o
-
-[MODULE::RPC_EJS_IRPC]
-INIT_FUNCTION = ejs_init_irpc
-SUBSYSTEM = smbcalls
-PRIVATE_DEPENDENCIES = dcerpc NDR_IRPC EJSRPC
-
-RPC_EJS_IRPC_OBJ_FILES = $(gen_ndrsrcdir)/ndr_irpc_ejs.o
-
-[PYTHON::swig_dcerpc]
-LIBRARY_REALNAME = samba/dcerpc/_dcerpc.$(SHLIBEXT)
-PUBLIC_DEPENDENCIES = LIBCLI_SMB NDR_MISC LIBSAMBA-UTIL LIBSAMBA-HOSTCONFIG dcerpc_samr RPC_NDR_LSA DYNCONFIG
-
-swig_dcerpc_OBJ_FILES = $(dcerpcsrcdir)/dcerpc_wrap.o
+python_dcerpc_OBJ_FILES = $(dcerpcsrcdir)/pyrpc.o
$(eval $(call python_py_module_template,samba/dcerpc/__init__.py,$(dcerpcsrcdir)/dcerpc.py))
-$(swig_dcerpc_OBJ_FILES): CFLAGS+=$(CFLAG_NO_UNUSED_MACROS) $(CFLAG_NO_CAST_QUAL)
[PYTHON::python_echo]
LIBRARY_REALNAME = samba/dcerpc/echo.$(SHLIBEXT)
-PRIVATE_DEPENDENCIES = RPC_NDR_ECHO PYTALLOC param swig_credentials
+PRIVATE_DEPENDENCIES = RPC_NDR_ECHO PYTALLOC param swig_credentials python_dcerpc
python_echo_OBJ_FILES = $(gen_ndrsrcdir)/py_echo.o
[PYTHON::python_winreg]
LIBRARY_REALNAME = samba/dcerpc/winreg.$(SHLIBEXT)
-PRIVATE_DEPENDENCIES = RPC_NDR_WINREG python_misc PYTALLOC param swig_credentials python_dcerpc_misc python_lsa
+PRIVATE_DEPENDENCIES = RPC_NDR_WINREG python_misc PYTALLOC param swig_credentials python_dcerpc_misc python_lsa python_dcerpc
python_winreg_OBJ_FILES = $(gen_ndrsrcdir)/py_winreg.o
[PYTHON::python_dcerpc_misc]
LIBRARY_REALNAME = samba/dcerpc/misc.$(SHLIBEXT)
-PRIVATE_DEPENDENCIES = PYTALLOC
+PRIVATE_DEPENDENCIES = PYTALLOC python_dcerpc
python_dcerpc_misc_OBJ_FILES = $(gen_ndrsrcdir)/py_misc.o
[PYTHON::python_initshutdown]
LIBRARY_REALNAME = samba/dcerpc/initshutdown.$(SHLIBEXT)
-PRIVATE_DEPENDENCIES = RPC_NDR_INITSHUTDOWN PYTALLOC param swig_credentials python_lsa python_dcerpc_security
+PRIVATE_DEPENDENCIES = RPC_NDR_INITSHUTDOWN PYTALLOC param swig_credentials python_lsa python_dcerpc_security python_dcerpc
python_initshutdown_OBJ_FILES = $(gen_ndrsrcdir)/py_initshutdown.o
[PYTHON::python_epmapper]
LIBRARY_REALNAME = samba/dcerpc/epmapper.$(SHLIBEXT)
-PRIVATE_DEPENDENCIES = dcerpc PYTALLOC param swig_credentials python_dcerpc_misc
+PRIVATE_DEPENDENCIES = dcerpc PYTALLOC param swig_credentials python_dcerpc_misc python_dcerpc
python_epmapper_OBJ_FILES = $(gen_ndrsrcdir)/py_epmapper.o
[PYTHON::python_mgmt]
LIBRARY_REALNAME = samba/dcerpc/mgmt.$(SHLIBEXT)
-PRIVATE_DEPENDENCIES = PYTALLOC param swig_credentials dcerpc python_dcerpc_misc
+PRIVATE_DEPENDENCIES = PYTALLOC param swig_credentials dcerpc python_dcerpc_misc python_dcerpc
python_mgmt_OBJ_FILES = $(gen_ndrsrcdir)/py_mgmt.o
[PYTHON::python_atsvc]
LIBRARY_REALNAME = samba/dcerpc/atsvc.$(SHLIBEXT)
-PRIVATE_DEPENDENCIES = dcerpc_atsvc PYTALLOC param swig_credentials
+PRIVATE_DEPENDENCIES = dcerpc_atsvc PYTALLOC param swig_credentials python_dcerpc
python_atsvc_OBJ_FILES = $(gen_ndrsrcdir)/py_atsvc.o
+[PYTHON::python_nbt]
+LIBRARY_REALNAME = samba/nbt.$(SHLIBEXT)
+PRIVATE_DEPENDENCIES = NDR_NBT PYTALLOC param swig_credentials python_dcerpc
+
+python_nbt_OBJ_FILES = $(gen_ndrsrcdir)/py_nbt.o
+
[PYTHON::python_samr]
LIBRARY_REALNAME = samba/dcerpc/samr.$(SHLIBEXT)
-PRIVATE_DEPENDENCIES = dcerpc_samr PYTALLOC python_dcerpc_security python_lsa python_dcerpc_misc swig_credentials param
+PRIVATE_DEPENDENCIES = dcerpc_samr PYTALLOC python_dcerpc_security python_lsa python_dcerpc_misc swig_credentials param python_dcerpc
python_samr_OBJ_FILES = $(gen_ndrsrcdir)/py_samr.o
[PYTHON::python_svcctl]
LIBRARY_REALNAME = samba/dcerpc/svcctl.$(SHLIBEXT)
-PRIVATE_DEPENDENCIES = RPC_NDR_SVCCTL PYTALLOC param swig_credentials python_dcerpc_misc
+PRIVATE_DEPENDENCIES = RPC_NDR_SVCCTL PYTALLOC param swig_credentials python_dcerpc_misc python_dcerpc
python_svcctl_OBJ_FILES = $(gen_ndrsrcdir)/py_svcctl.o
[PYTHON::python_lsa]
LIBRARY_REALNAME = samba/dcerpc/lsa.$(SHLIBEXT)
-PRIVATE_DEPENDENCIES = RPC_NDR_LSA PYTALLOC param swig_credentials python_dcerpc_security
+PRIVATE_DEPENDENCIES = RPC_NDR_LSA PYTALLOC param swig_credentials python_dcerpc_security python_dcerpc
python_lsa_OBJ_FILES = $(gen_ndrsrcdir)/py_lsa.o
[PYTHON::python_wkssvc]
LIBRARY_REALNAME = samba/dcerpc/wkssvc.$(SHLIBEXT)
-PRIVATE_DEPENDENCIES = RPC_NDR_WKSSVC PYTALLOC param swig_credentials python_lsa python_dcerpc_security
+PRIVATE_DEPENDENCIES = RPC_NDR_WKSSVC PYTALLOC param swig_credentials python_lsa python_dcerpc_security python_dcerpc
python_wkssvc_OBJ_FILES = $(gen_ndrsrcdir)/py_wkssvc.o
[PYTHON::python_dfs]
LIBRARY_REALNAME = samba/dcerpc/dfs.$(SHLIBEXT)
-PRIVATE_DEPENDENCIES = RPC_NDR_DFS PYTALLOC param swig_credentials python_dcerpc_misc
+PRIVATE_DEPENDENCIES = RPC_NDR_DFS PYTALLOC param swig_credentials python_dcerpc_misc python_dcerpc
python_dfs_OBJ_FILES = $(gen_ndrsrcdir)/py_dfs.o
[PYTHON::python_unixinfo]
LIBRARY_REALNAME = samba/dcerpc/unixinfo.$(SHLIBEXT)
-PRIVATE_DEPENDENCIES = RPC_NDR_UNIXINFO PYTALLOC param swig_credentials python_dcerpc_security python_dcerpc_misc
+PRIVATE_DEPENDENCIES = RPC_NDR_UNIXINFO PYTALLOC param swig_credentials python_dcerpc_security python_dcerpc_misc python_dcerpc
python_unixinfo_OBJ_FILES = $(gen_ndrsrcdir)/py_unixinfo.o
+[PYTHON::python_irpc]
+LIBRARY_REALNAME = samba/irpc.$(SHLIBEXT)
+PRIVATE_DEPENDENCIES = RPC_NDR_IRPC PYTALLOC param swig_credentials python_dcerpc_security python_dcerpc_misc python_dcerpc python_nbt
+
+python_irpc_OBJ_FILES = $(gen_ndrsrcdir)/py_irpc.o
+
[PYTHON::python_drsuapi]
LIBRARY_REALNAME = samba/dcerpc/drsuapi.$(SHLIBEXT)
-PRIVATE_DEPENDENCIES = RPC_NDR_DRSUAPI PYTALLOC param swig_credentials python_dcerpc_misc python_dcerpc_security
+PRIVATE_DEPENDENCIES = RPC_NDR_DRSUAPI PYTALLOC param swig_credentials python_dcerpc_misc python_dcerpc_security python_dcerpc
python_drsuapi_OBJ_FILES = $(gen_ndrsrcdir)/py_drsuapi.o
[PYTHON::python_dcerpc_security]
LIBRARY_REALNAME = samba/dcerpc/security.$(SHLIBEXT)
-PRIVATE_DEPENDENCIES = PYTALLOC python_dcerpc_misc
+PRIVATE_DEPENDENCIES = PYTALLOC python_dcerpc_misc python_dcerpc
python_dcerpc_security_OBJ_FILES = $(gen_ndrsrcdir)/py_security.o
diff --git a/source4/librpc/idl-deps.pl b/source4/librpc/idl-deps.pl
index e630ee4f61..49fba4c935 100755
--- a/source4/librpc/idl-deps.pl
+++ b/source4/librpc/idl-deps.pl
@@ -4,8 +4,8 @@ use strict;
my %vars = ();
foreach(@ARGV) {
- push (@{$vars{IDL_FILES}}, $_);
my $b = $_; $b =~ s/.*\/(.*?).idl$/$1/;
+ push (@{$vars{IDL_FILES}}, "\$(librpcsrcdir)/idl/$b.idl");
push (@{$vars{IDL_HEADER_FILES}}, "\$(librpcsrcdir)/gen_ndr/$b.h");
push (@{$vars{IDL_NDR_PARSE_H_FILES}}, "\$(librpcsrcdir)/gen_ndr/ndr_$b.h");
push (@{$vars{IDL_NDR_PARSE_C_FILES}}, "\$(librpcsrcdir)/gen_ndr/ndr_$b.c");
diff --git a/source4/librpc/idl/echo.idl b/source4/librpc/idl/echo.idl
index 5ea37f1ac1..bf1e318674 100644
--- a/source4/librpc/idl/echo.idl
+++ b/source4/librpc/idl/echo.idl
@@ -38,7 +38,7 @@ interface rpcecho
/* test some alignment issues */
- typedef struct {
+ typedef [public] struct {
uint8 v;
} echo_info1;
diff --git a/source4/librpc/idl/nbt.idl b/source4/librpc/idl/nbt.idl
index 783f04eb42..a6d0245455 100644
--- a/source4/librpc/idl/nbt.idl
+++ b/source4/librpc/idl/nbt.idl
@@ -73,11 +73,11 @@ interface nbt
nbt_name_type type;
} nbt_name;
- typedef [enum16bit] enum {
+ typedef [public,enum16bit] enum {
NBT_QCLASS_IP = 0x01
} nbt_qclass;
- typedef [enum16bit] enum {
+ typedef [public,enum16bit] enum {
NBT_QTYPE_ADDRESS = 0x0001,
NBT_QTYPE_NAMESERVICE = 0x0002,
NBT_QTYPE_NULL = 0x000A,
@@ -160,30 +160,24 @@ interface nbt
uint8 data[length];
} nbt_rdata_data;
- typedef [nodiscriminant] union {
+ typedef [nodiscriminant,public] union {
[case(NBT_QTYPE_NETBIOS)] nbt_rdata_netbios netbios;
[case(NBT_QTYPE_STATUS)] nbt_rdata_status status;
[default] nbt_rdata_data data;
} nbt_rdata;
/*
- * this macro works arround the problem
+ * this macro works around the problem
* that we need to use nbt_rdata_data
* together with NBT_QTYPE_NETBIOS
* for WACK replies
*/
-#define NBT_RES_REC_LEVEL(rr_type, rdata) (\
- (((rr_type) == NBT_QTYPE_NETBIOS) && \
- talloc_check_name(ndr, "struct ndr_push") && \
- ((rdata).data.length == 2)) \
- ? 0 : rr_type)
-
- typedef [flag(LIBNDR_PRINT_ARRAY_HEX)] struct {
+ typedef [flag(LIBNDR_PRINT_ARRAY_HEX),nopush] struct {
nbt_name name;
nbt_qtype rr_type;
nbt_qclass rr_class;
uint32 ttl;
- [switch_is(NBT_RES_REC_LEVEL(rr_type, rdata))] nbt_rdata rdata;
+ [switch_is(rr_type)] nbt_rdata rdata;
} nbt_res_rec;
typedef [flag(NDR_NOALIGN|NDR_BIG_ENDIAN|NDR_PAHEX),public] struct {
diff --git a/source4/librpc/idl/security.idl b/source4/librpc/idl/security.idl
index 314846c53f..f8e9e9e110 100644
--- a/source4/librpc/idl/security.idl
+++ b/source4/librpc/idl/security.idl
@@ -106,6 +106,9 @@ interface security
const int SEC_ADS_LIST_OBJECT = 0x00000080;
const int SEC_ADS_CONTROL_ACCESS = 0x00000100;
+ /* invalid bits */
+ const int SEC_MASK_INVALID = 0x0ce0fe00;
+
/* generic->specific mappings for files */
const int SEC_RIGHTS_FILE_READ = SEC_STD_READ_CONTROL |
SEC_STD_SYNCHRONIZE |
diff --git a/source4/librpc/idl/xattr.idl b/source4/librpc/idl/xattr.idl
index 2010d51ce1..520341e6aa 100644
--- a/source4/librpc/idl/xattr.idl
+++ b/source4/librpc/idl/xattr.idl
@@ -86,7 +86,8 @@ interface xattr
/* stream data is stored in attributes with the given prefix */
const char *XATTR_DOSSTREAM_PREFIX = "user.DosStream.";
- const int XATTR_MAX_STREAM_SIZE = 0x4000;
+ const int XATTR_MAX_STREAM_SIZE = 0x4000;
+ const int XATTR_MAX_STREAM_SIZE_TDB = 0x100000;
typedef struct {
uint32 flags;
diff --git a/source4/librpc/rpc/dcerpc.h b/source4/librpc/rpc/dcerpc.h
index 805f5463a9..487f9f2eda 100644
--- a/source4/librpc/rpc/dcerpc.h
+++ b/source4/librpc/rpc/dcerpc.h
@@ -362,5 +362,14 @@ NTSTATUS dcerpc_binding_from_tower(TALLOC_CTX *mem_ctx,
struct epm_tower *tower,
struct dcerpc_binding **b_out);
+NTSTATUS dcerpc_request(struct dcerpc_pipe *p,
+ struct GUID *object,
+ uint16_t opnum,
+ bool async,
+ TALLOC_CTX *mem_ctx,
+ DATA_BLOB *stub_data_in,
+ DATA_BLOB *stub_data_out);
+
+typedef NTSTATUS (*dcerpc_call_fn) (struct dcerpc_pipe *, TALLOC_CTX *, void *);
#endif /* __DCERPC_H__ */
diff --git a/source4/librpc/rpc/dcerpc.i b/source4/librpc/rpc/dcerpc.i
deleted file mode 100644
index f958d82e2e..0000000000
--- a/source4/librpc/rpc/dcerpc.i
+++ /dev/null
@@ -1,121 +0,0 @@
-/* Tastes like -*- C -*- */
-
-/*
- Unix SMB/CIFS implementation.
-
- Swig interface to librpc functions.
-
- Copyright (C) Tim Potter 2004
- Copyright (C) Jelmer Vernooij 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/>.
-*/
-
-%module dcerpc
-
-%{
-
-/* This symbol is used in both includes.h and Python.h which causes an
- annoying compiler warning. */
-
-#ifdef HAVE_FSTAT
-#undef HAVE_FSTAT
-#endif
-
-#include "includes.h"
-#include "dynconfig.h"
-#include "librpc/rpc/dcerpc.h"
-#include "param/param.h"
-
-#undef strcpy
-
-%}
-
-%import "../../lib/talloc/talloc.i"
-%import "../../auth/credentials/credentials.i"
-
-%typemap(in,noblock=1, numinputs=0) struct dcerpc_pipe **OUT (struct dcerpc_pipe *temp_dcerpc_pipe) {
- $1 = &temp_dcerpc_pipe;
-}
-
-%typemap(argout,noblock=1) struct dcerpc_pipe ** {
- /* Set REF_ALLOC flag so we don't have to do too much extra
- mucking around with ref variables in ndr unmarshalling. */
-
- (*$1)->conn->flags |= DCERPC_NDR_REF_ALLOC;
-
- /* Return swig handle on dcerpc_pipe */
-
- $result = SWIG_NewPointerObj(*$1, SWIGTYPE_p_dcerpc_pipe, 0);
-}
-
-%types(struct dcerpc_pipe *);
-
-%rename(pipe_connect) dcerpc_pipe_connect;
-
-NTSTATUS dcerpc_pipe_connect(TALLOC_CTX *parent_ctx,
- struct dcerpc_pipe **pp,
- const char *binding,
- const struct ndr_interface_table *table,
- struct cli_credentials *credentials,
- struct event_context *ev,
- struct loadparm_context *lp_ctx);
-
-%typemap(in,noblock=1) DATA_BLOB * (DATA_BLOB temp_data_blob) {
- temp_data_blob.data = PyString_AsString($input);
- temp_data_blob.length = PyString_Size($input);
- $1 = &temp_data_blob;
-}
-
-const char *dcerpc_server_name(struct dcerpc_pipe *p);
-
-/* Some typemaps for easier access to resume handles. Really this can
- also be done using the uint32 carray functions, but it's a bit of a
- hassle. TODO: Fix memory leak here. */
-
-%typemap(in,noblock=1) uint32_t *resume_handle {
- $1 = malloc(sizeof(*$1));
- *$1 = PyLong_AsLong($input);
-}
-
-%typemap(out,noblock=1) uint32_t *resume_handle {
- $result = PyLong_FromLong(*$1);
-}
-
-%typemap(in,noblock=1) struct policy_handle * {
-
- if ((SWIG_ConvertPtr($input, (void **) &$1, $1_descriptor,
- SWIG_POINTER_EXCEPTION)) == -1)
- return NULL;
-
- if ($1 == NULL) {
- PyErr_SetString(PyExc_TypeError, "None is not a valid policy handle");
- return NULL;
- }
-}
-
-/* When returning a policy handle to Python we need to make a copy of
- as the talloc context it is created under is destroyed after the
- wrapper function returns. TODO: Fix memory leak created here. */
-
-%typemap(out,noblock=1) struct policy_handle * {
- if ($1) {
- struct policy_handle *temp = (struct policy_handle *)malloc(sizeof(struct policy_handle));
- memcpy(temp, $1, sizeof(struct policy_handle));
- $result = SWIG_NewPointerObj(temp, SWIGTYPE_p_policy_handle, 0);
- } else {
- Py_INCREF(Py_None);
- $result = Py_None;
- }
-}
diff --git a/source4/librpc/rpc/dcerpc.py b/source4/librpc/rpc/dcerpc.py
index db5b95cee8..1a76ecca8e 100644
--- a/source4/librpc/rpc/dcerpc.py
+++ b/source4/librpc/rpc/dcerpc.py
@@ -1,63 +1,20 @@
-# This file was automatically generated by SWIG (http://www.swig.org).
-# Version 1.3.35
+#!/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/>.
#
-# Don't modify this file, modify the SWIG interface instead.
-
-import _dcerpc
-import new
-new_instancemethod = new.instancemethod
-try:
- _swig_property = property
-except NameError:
- pass # Python < 2.2 doesn't have 'property'.
-def _swig_setattr_nondynamic(self,class_type,name,value,static=1):
- if (name == "thisown"): return self.this.own(value)
- if (name == "this"):
- if type(value).__name__ == 'PySwigObject':
- self.__dict__[name] = value
- return
- method = class_type.__swig_setmethods__.get(name,None)
- if method: return method(self,value)
- if (not static) or hasattr(self,name):
- self.__dict__[name] = value
- else:
- raise AttributeError("You cannot add attributes to %s" % self)
-
-def _swig_setattr(self,class_type,name,value):
- return _swig_setattr_nondynamic(self,class_type,name,value,0)
-
-def _swig_getattr(self,class_type,name):
- if (name == "thisown"): return self.this.own()
- method = class_type.__swig_getmethods__.get(name,None)
- if method: return method(self)
- raise AttributeError,name
-
-def _swig_repr(self):
- try: strthis = "proxy of " + self.this.__repr__()
- except: strthis = ""
- return "<%s.%s; %s >" % (self.__class__.__module__, self.__class__.__name__, strthis,)
-
-import types
-try:
- _object = types.ObjectType
- _newclass = 1
-except AttributeError:
- class _object : pass
- _newclass = 0
-del types
-
-
-def _swig_setattr_nondynamic_method(set):
- def set_attr(self,name,value):
- if (name == "thisown"): return self.this.own(value)
- if hasattr(self,name) or (name == "this"):
- set(self,name,value)
- else:
- raise AttributeError("You cannot add attributes to %s" % self)
- return set_attr
-
-
-pipe_connect = _dcerpc.pipe_connect
-dcerpc_server_name = _dcerpc.dcerpc_server_name
-
+from base import *
diff --git a/source4/librpc/rpc/dcerpc_wrap.c b/source4/librpc/rpc/dcerpc_wrap.c
deleted file mode 100644
index ff5cdbd390..0000000000
--- a/source4/librpc/rpc/dcerpc_wrap.c
+++ /dev/null
@@ -1,3395 +0,0 @@
-/* ----------------------------------------------------------------------------
- * This file was automatically generated by SWIG (http://www.swig.org).
- * 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
- * changes to this file unless you know what you are doing--modify the SWIG
- * interface file instead.
- * ----------------------------------------------------------------------------- */
-
-#define SWIGPYTHON
-#define SWIG_PYTHON_NO_BUILD_NONE
-/* -----------------------------------------------------------------------------
- * This section contains generic SWIG labels for method/variable
- * declarations/attributes, and other compiler dependent labels.
- * ----------------------------------------------------------------------------- */
-
-/* template workaround for compilers that cannot correctly implement the C++ standard */
-#ifndef SWIGTEMPLATEDISAMBIGUATOR
-# if defined(__SUNPRO_CC) && (__SUNPRO_CC <= 0x560)
-# define SWIGTEMPLATEDISAMBIGUATOR template
-# elif defined(__HP_aCC)
-/* Needed even with `aCC -AA' when `aCC -V' reports HP ANSI C++ B3910B A.03.55 */
-/* If we find a maximum version that requires this, the test would be __HP_aCC <= 35500 for A.03.55 */
-# define SWIGTEMPLATEDISAMBIGUATOR template
-# else
-# define SWIGTEMPLATEDISAMBIGUATOR
-# endif
-#endif
-
-/* inline attribute */
-#ifndef SWIGINLINE
-# if defined(__cplusplus) || (defined(__GNUC__) && !defined(__STRICT_ANSI__))
-# define SWIGINLINE inline
-# else
-# define SWIGINLINE
-# endif
-#endif
-
-/* attribute recognised by some compilers to avoid 'unused' warnings */
-#ifndef SWIGUNUSED
-# if defined(__GNUC__)
-# if !(defined(__cplusplus)) || (__GNUC__ > 3 || (__GNUC__ == 3 && __GNUC_MINOR__ >= 4))
-# define SWIGUNUSED __attribute__ ((__unused__))
-# else
-# define SWIGUNUSED
-# endif
-# elif defined(__ICC)
-# define SWIGUNUSED __attribute__ ((__unused__))
-# else
-# define SWIGUNUSED
-# endif
-#endif
-
-#ifndef SWIGUNUSEDPARM
-# ifdef __cplusplus
-# define SWIGUNUSEDPARM(p)
-# else
-# define SWIGUNUSEDPARM(p) p SWIGUNUSED
-# endif
-#endif
-
-/* internal SWIG method */
-#ifndef SWIGINTERN
-# define SWIGINTERN static SWIGUNUSED
-#endif
-
-/* internal inline SWIG method */
-#ifndef SWIGINTERNINLINE
-# define SWIGINTERNINLINE SWIGINTERN SWIGINLINE
-#endif
-
-/* exporting methods */
-#if (__GNUC__ >= 4) || (__GNUC__ == 3 && __GNUC_MINOR__ >= 4)
-# ifndef GCC_HASCLASSVISIBILITY
-# define GCC_HASCLASSVISIBILITY
-# endif
-#endif
-
-#ifndef SWIGEXPORT
-# if defined(_WIN32) || defined(__WIN32__) || defined(__CYGWIN__)
-# if defined(STATIC_LINKED)
-# define SWIGEXPORT
-# else
-# define SWIGEXPORT __declspec(dllexport)
-# endif
-# else
-# if defined(__GNUC__) && defined(GCC_HASCLASSVISIBILITY)
-# define SWIGEXPORT __attribute__ ((visibility("default")))
-# else
-# define SWIGEXPORT
-# endif
-# endif
-#endif
-
-/* calling conventions for Windows */
-#ifndef SWIGSTDCALL
-# if defined(_WIN32) || defined(__WIN32__) || defined(__CYGWIN__)
-# define SWIGSTDCALL __stdcall
-# else
-# define SWIGSTDCALL
-# endif
-#endif
-
-/* Deal with Microsoft's attempt at deprecating C standard runtime functions */
-#if !defined(SWIG_NO_CRT_SECURE_NO_DEPRECATE) && defined(_MSC_VER) && !defined(_CRT_SECURE_NO_DEPRECATE)
-# define _CRT_SECURE_NO_DEPRECATE
-#endif
-
-/* Deal with Microsoft's attempt at deprecating methods in the standard C++ library */
-#if !defined(SWIG_NO_SCL_SECURE_NO_DEPRECATE) && defined(_MSC_VER) && !defined(_SCL_SECURE_NO_DEPRECATE)
-# define _SCL_SECURE_NO_DEPRECATE
-#endif
-
-
-
-/* Python.h has to appear first */
-#include <Python.h>
-
-/* -----------------------------------------------------------------------------
- * swigrun.swg
- *
- * This file contains generic CAPI SWIG runtime support for pointer
- * type checking.
- * ----------------------------------------------------------------------------- */
-
-/* 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 "4"
-
-/* define SWIG_TYPE_TABLE_NAME as "SWIG_TYPE_TABLE" */
-#ifdef SWIG_TYPE_TABLE
-# define SWIG_QUOTE_STRING(x) #x
-# define SWIG_EXPAND_AND_QUOTE_STRING(x) SWIG_QUOTE_STRING(x)
-# define SWIG_TYPE_TABLE_NAME SWIG_EXPAND_AND_QUOTE_STRING(SWIG_TYPE_TABLE)
-#else
-# define SWIG_TYPE_TABLE_NAME
-#endif
-
-/*
- You can use the SWIGRUNTIME and SWIGRUNTIMEINLINE macros for
- creating a static or dynamic library from the swig runtime code.
- In 99.9% of the cases, swig just needs to declare them as 'static'.
-
- But only do this if is strictly necessary, ie, if you have problems
- with your compiler or so.
-*/
-
-#ifndef SWIGRUNTIME
-# define SWIGRUNTIME SWIGINTERN
-#endif
-
-#ifndef SWIGRUNTIMEINLINE
-# define SWIGRUNTIMEINLINE SWIGRUNTIME SWIGINLINE
-#endif
-
-/* Generic buffer size */
-#ifndef SWIG_BUFFER_SIZE
-# define SWIG_BUFFER_SIZE 1024
-#endif
-
-/* 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
-
-
-/*
- Flags/methods for returning states.
-
- The swig conversion methods, as ConvertPtr, return and integer
- that tells if the conversion was successful or not. And if not,
- an error code can be returned (see swigerrors.swg for the codes).
-
- Use the following macros/flags to set or process the returning
- states.
-
- In old swig versions, you usually write code as:
-
- if (SWIG_ConvertPtr(obj,vptr,ty.flags) != -1) {
- // success code
- } else {
- //fail code
- }
-
- Now you can be more explicit as:
-
- int res = SWIG_ConvertPtr(obj,vptr,ty.flags);
- if (SWIG_IsOK(res)) {
- // success code
- } else {
- // fail code
- }
-
- that seems to be the same, but now you can also do
-
- Type *ptr;
- int res = SWIG_ConvertPtr(obj,(void **)(&ptr),ty.flags);
- if (SWIG_IsOK(res)) {
- // success code
- if (SWIG_IsNewObj(res) {
- ...
- delete *ptr;
- } else {
- ...
- }
- } else {
- // fail code
- }
-
- I.e., now SWIG_ConvertPtr can return new objects and you can
- identify the case and take care of the deallocation. Of course that
- requires also to SWIG_ConvertPtr to return new result values, as
-
- int SWIG_ConvertPtr(obj, ptr,...) {
- if (<obj is ok>) {
- if (<need new object>) {
- *ptr = <ptr to new allocated object>;
- return SWIG_NEWOBJ;
- } else {
- *ptr = <ptr to old object>;
- return SWIG_OLDOBJ;
- }
- } else {
- return SWIG_BADOBJ;
- }
- }
-
- Of course, returning the plain '0(success)/-1(fail)' still works, but you can be
- more explicit by returning SWIG_BADOBJ, SWIG_ERROR or any of the
- swig errors code.
-
- Finally, if the SWIG_CASTRANK_MODE is enabled, the result code
- allows to return the 'cast rank', for example, if you have this
-
- int food(double)
- int fooi(int);
-
- and you call
-
- food(1) // cast rank '1' (1 -> 1.0)
- fooi(1) // cast rank '0'
-
- just use the SWIG_AddCast()/SWIG_CheckState()
-
-
- */
-#define SWIG_OK (0)
-#define SWIG_ERROR (-1)
-#define SWIG_IsOK(r) (r >= 0)
-#define SWIG_ArgError(r) ((r != SWIG_ERROR) ? r : SWIG_TypeError)
-
-/* The CastRankLimit says how many bits are used for the cast rank */
-#define SWIG_CASTRANKLIMIT (1 << 8)
-/* The NewMask denotes the object was created (using new/malloc) */
-#define SWIG_NEWOBJMASK (SWIG_CASTRANKLIMIT << 1)
-/* The TmpMask is for in/out typemaps that use temporal objects */
-#define SWIG_TMPOBJMASK (SWIG_NEWOBJMASK << 1)
-/* Simple returning values */
-#define SWIG_BADOBJ (SWIG_ERROR)
-#define SWIG_OLDOBJ (SWIG_OK)
-#define SWIG_NEWOBJ (SWIG_OK | SWIG_NEWOBJMASK)
-#define SWIG_TMPOBJ (SWIG_OK | SWIG_TMPOBJMASK)
-/* Check, add and del mask methods */
-#define SWIG_AddNewMask(r) (SWIG_IsOK(r) ? (r | SWIG_NEWOBJMASK) : r)
-#define SWIG_DelNewMask(r) (SWIG_IsOK(r) ? (r & ~SWIG_NEWOBJMASK) : r)
-#define SWIG_IsNewObj(r) (SWIG_IsOK(r) && (r & SWIG_NEWOBJMASK))
-#define SWIG_AddTmpMask(r) (SWIG_IsOK(r) ? (r | SWIG_TMPOBJMASK) : r)
-#define SWIG_DelTmpMask(r) (SWIG_IsOK(r) ? (r & ~SWIG_TMPOBJMASK) : r)
-#define SWIG_IsTmpObj(r) (SWIG_IsOK(r) && (r & SWIG_TMPOBJMASK))
-
-
-/* Cast-Rank Mode */
-#if defined(SWIG_CASTRANK_MODE)
-# ifndef SWIG_TypeRank
-# define SWIG_TypeRank unsigned long
-# endif
-# ifndef SWIG_MAXCASTRANK /* Default cast allowed */
-# define SWIG_MAXCASTRANK (2)
-# endif
-# define SWIG_CASTRANKMASK ((SWIG_CASTRANKLIMIT) -1)
-# define SWIG_CastRank(r) (r & SWIG_CASTRANKMASK)
-SWIGINTERNINLINE int SWIG_AddCast(int r) {
- return SWIG_IsOK(r) ? ((SWIG_CastRank(r) < SWIG_MAXCASTRANK) ? (r + 1) : SWIG_ERROR) : r;
-}
-SWIGINTERNINLINE int SWIG_CheckState(int r) {
- return SWIG_IsOK(r) ? SWIG_CastRank(r) + 1 : 0;
-}
-#else /* no cast-rank mode */
-# define SWIG_AddCast
-# define SWIG_CheckState(r) (SWIG_IsOK(r) ? 1 : 0)
-#endif
-
-
-
-
-#include <string.h>
-
-#ifdef __cplusplus
-extern "C" {
-#endif
-
-typedef void *(*swig_converter_func)(void *, int *);
-typedef struct swig_type_info *(*swig_dycast_func)(void **);
-
-/* 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 */
- swig_dycast_func dcast; /* dynamic cast function down a hierarchy */
- struct swig_cast_info *cast; /* linked list of types that can cast into this type */
- void *clientdata; /* language specific type data */
- int owndata; /* flag if the structure owns the clientdata */
-} swig_type_info;
-
-/* Structure to store a type and conversion function used for casting */
-typedef struct swig_cast_info {
- swig_type_info *type; /* pointer to type that is equivalent to this type */
- swig_converter_func converter; /* function to cast the void pointers */
- struct swig_cast_info *next; /* pointer to next cast in linked list */
- struct swig_cast_info *prev; /* pointer to the previous cast */
-} swig_cast_info;
-
-/* Structure used to store module information
- * Each module generates one structure like this, and the runtime collects
- * all of these structures and stores them in a circularly linked list.*/
-typedef struct swig_module_info {
- swig_type_info **types; /* Array of pointers to swig_type_info structures that are in this module */
- size_t size; /* Number of types in this module */
- struct swig_module_info *next; /* Pointer to next element in circularly linked list */
- swig_type_info **type_initial; /* Array of initially generated type structures */
- swig_cast_info **cast_initial; /* Array of initially generated casting structures */
- void *clientdata; /* Language specific module data */
-} swig_module_info;
-
-/*
- Compare two type names skipping the space characters, therefore
- "char*" == "char *" and "Class<int>" == "Class<int >", etc.
-
- Return 0 when the two name types are equivalent, as in
- strncmp, but skipping ' '.
-*/
-SWIGRUNTIME int
-SWIG_TypeNameComp(const char *f1, const char *l1,
- const char *f2, const char *l2) {
- for (;(f1 != l1) && (f2 != l2); ++f1, ++f2) {
- while ((*f1 == ' ') && (f1 != l1)) ++f1;
- while ((*f2 == ' ') && (f2 != l2)) ++f2;
- if (*f1 != *f2) return (*f1 > *f2) ? 1 : -1;
- }
- return (int)((l1 - f1) - (l2 - f2));
-}
-
-/*
- Check type equivalence in a name list like <name1>|<name2>|...
- Return 0 if not equal, 1 if equal
-*/
-SWIGRUNTIME int
-SWIG_TypeEquiv(const char *nb, const char *tb) {
- int equiv = 0;
- const char* te = tb + strlen(tb);
- const char* ne = nb;
- while (!equiv && *ne) {
- for (nb = ne; *ne; ++ne) {
- if (*ne == '|') break;
- }
- equiv = (SWIG_TypeNameComp(nb, ne, tb, te) == 0) ? 1 : 0;
- if (*ne) ++ne;
- }
- return equiv;
-}
-
-/*
- Check type equivalence in a name list like <name1>|<name2>|...
- Return 0 if equal, -1 if nb < tb, 1 if nb > tb
-*/
-SWIGRUNTIME int
-SWIG_TypeCompare(const char *nb, const char *tb) {
- int equiv = 0;
- const char* te = tb + strlen(tb);
- const char* ne = nb;
- while (!equiv && *ne) {
- for (nb = ne; *ne; ++ne) {
- if (*ne == '|') break;
- }
- equiv = (SWIG_TypeNameComp(nb, ne, tb, te) == 0) ? 1 : 0;
- if (*ne) ++ne;
- }
- return equiv;
-}
-
-
-/* think of this as a c++ template<> or a scheme macro */
-#define SWIG_TypeCheck_Template(comparison, ty) \
- if (ty) { \
- swig_cast_info *iter = ty->cast; \
- while (iter) { \
- if (comparison) { \
- if (iter == ty->cast) return iter; \
- /* Move iter to the top of the linked list */ \
- iter->prev->next = iter->next; \
- if (iter->next) \
- iter->next->prev = iter->prev; \
- iter->next = ty->cast; \
- iter->prev = 0; \
- if (ty->cast) ty->cast->prev = iter; \
- ty->cast = iter; \
- return iter; \
- } \
- iter = iter->next; \
- } \
- } \
- return 0
-
-/*
- Check the typename
-*/
-SWIGRUNTIME swig_cast_info *
-SWIG_TypeCheck(const char *c, swig_type_info *ty) {
- SWIG_TypeCheck_Template(strcmp(iter->type->name, c) == 0, ty);
-}
-
-/* Same as previous function, except strcmp is replaced with a pointer comparison */
-SWIGRUNTIME swig_cast_info *
-SWIG_TypeCheckStruct(swig_type_info *from, swig_type_info *into) {
- SWIG_TypeCheck_Template(iter->type == from, into);
-}
-
-/*
- Cast a pointer up an inheritance hierarchy
-*/
-SWIGRUNTIMEINLINE void *
-SWIG_TypeCast(swig_cast_info *ty, void *ptr, int *newmemory) {
- return ((!ty) || (!ty->converter)) ? ptr : (*ty->converter)(ptr, newmemory);
-}
-
-/*
- Dynamic pointer casting. Down an inheritance hierarchy
-*/
-SWIGRUNTIME swig_type_info *
-SWIG_TypeDynamicCast(swig_type_info *ty, void **ptr) {
- swig_type_info *lastty = ty;
- if (!ty || !ty->dcast) return ty;
- while (ty && (ty->dcast)) {
- ty = (*ty->dcast)(ptr);
- if (ty) lastty = ty;
- }
- return lastty;
-}
-
-/*
- Return the name associated with this type
-*/
-SWIGRUNTIMEINLINE const char *
-SWIG_TypeName(const swig_type_info *ty) {
- return ty->name;
-}
-
-/*
- Return the pretty name associated with this type,
- that is an unmangled type name in a form presentable to the user.
-*/
-SWIGRUNTIME const char *
-SWIG_TypePrettyName(const swig_type_info *type) {
- /* The "str" field contains the equivalent pretty names of the
- type, separated by vertical-bar characters. We choose
- to print the last name, as it is often (?) the most
- specific. */
- if (!type) return NULL;
- if (type->str != NULL) {
- const char *last_name = type->str;
- const char *s;
- for (s = type->str; *s; s++)
- if (*s == '|') last_name = s+1;
- return last_name;
- }
- else
- return type->name;
-}
-
-/*
- Set the clientdata field for a type
-*/
-SWIGRUNTIME void
-SWIG_TypeClientData(swig_type_info *ti, void *clientdata) {
- swig_cast_info *cast = ti->cast;
- /* if (ti->clientdata == clientdata) return; */
- ti->clientdata = clientdata;
-
- while (cast) {
- if (!cast->converter) {
- swig_type_info *tc = cast->type;
- if (!tc->clientdata) {
- SWIG_TypeClientData(tc, clientdata);
- }
- }
- cast = cast->next;
- }
-}
-SWIGRUNTIME void
-SWIG_TypeNewClientData(swig_type_info *ti, void *clientdata) {
- SWIG_TypeClientData(ti, clientdata);
- ti->owndata = 1;
-}
-
-/*
- Search for a swig_type_info structure only by mangled name
- Search is a O(log #types)
-
- We start searching at module start, and finish searching when start == end.
- Note: if start == end at the beginning of the function, we go all the way around
- the circular list.
-*/
-SWIGRUNTIME swig_type_info *
-SWIG_MangledTypeQueryModule(swig_module_info *start,
- swig_module_info *end,
- const char *name) {
- swig_module_info *iter = start;
- do {
- if (iter->size) {
- register size_t l = 0;
- register size_t r = iter->size - 1;
- do {
- /* since l+r >= 0, we can (>> 1) instead (/ 2) */
- register size_t i = (l + r) >> 1;
- const char *iname = iter->types[i]->name;
- if (iname) {
- register int compare = strcmp(name, iname);
- if (compare == 0) {
- return iter->types[i];
- } else if (compare < 0) {
- if (i) {
- r = i - 1;
- } else {
- break;
- }
- } else if (compare > 0) {
- l = i + 1;
- }
- } else {
- break; /* should never happen */
- }
- } while (l <= r);
- }
- iter = iter->next;
- } while (iter != end);
- return 0;
-}
-
-/*
- Search for a swig_type_info structure for either a mangled name or a human readable name.
- It first searches the mangled names of the types, which is a O(log #types)
- If a type is not found it then searches the human readable names, which is O(#types).
-
- We start searching at module start, and finish searching when start == end.
- Note: if start == end at the beginning of the function, we go all the way around
- the circular list.
-*/
-SWIGRUNTIME swig_type_info *
-SWIG_TypeQueryModule(swig_module_info *start,
- swig_module_info *end,
- const char *name) {
- /* STEP 1: Search the name field using binary search */
- swig_type_info *ret = SWIG_MangledTypeQueryModule(start, end, name);
- if (ret) {
- return ret;
- } else {
- /* STEP 2: If the type hasn't been found, do a complete search
- of the str field (the human readable name) */
- swig_module_info *iter = start;
- do {
- register size_t i = 0;
- for (; i < iter->size; ++i) {
- if (iter->types[i]->str && (SWIG_TypeEquiv(iter->types[i]->str, name)))
- return iter->types[i];
- }
- iter = iter->next;
- } while (iter != end);
- }
-
- /* neither found a match */
- return 0;
-}
-
-/*
- Pack binary data into a string
-*/
-SWIGRUNTIME char *
-SWIG_PackData(char *c, void *ptr, size_t sz) {
- static const char hex[17] = "0123456789abcdef";
- register const unsigned char *u = (unsigned char *) ptr;
- register const unsigned char *eu = u + sz;
- for (; u != eu; ++u) {
- register unsigned char uu = *u;
- *(c++) = hex[(uu & 0xf0) >> 4];
- *(c++) = hex[uu & 0xf];
- }
- return c;
-}
-
-/*
- Unpack binary data from a string
-*/
-SWIGRUNTIME const char *
-SWIG_UnpackData(const char *c, void *ptr, size_t sz) {
- register unsigned char *u = (unsigned char *) ptr;
- register const unsigned char *eu = u + sz;
- for (; u != eu; ++u) {
- register char d = *(c++);
- register unsigned char uu;
- if ((d >= '0') && (d <= '9'))
- uu = ((d - '0') << 4);
- else if ((d >= 'a') && (d <= 'f'))
- uu = ((d - ('a'-10)) << 4);
- else
- return (char *) 0;
- d = *(c++);
- if ((d >= '0') && (d <= '9'))
- uu |= (d - '0');
- else if ((d >= 'a') && (d <= 'f'))
- uu |= (d - ('a'-10));
- else
- return (char *) 0;
- *u = uu;
- }
- return c;
-}
-
-/*
- Pack 'void *' into a string buffer.
-*/
-SWIGRUNTIME char *
-SWIG_PackVoidPtr(char *buff, void *ptr, const char *name, size_t bsz) {
- char *r = buff;
- if ((2*sizeof(void *) + 2) > bsz) return 0;
- *(r++) = '_';
- r = SWIG_PackData(r,&ptr,sizeof(void *));
- if (strlen(name) + 1 > (bsz - (r - buff))) return 0;
- strcpy(r,name);
- return buff;
-}
-
-SWIGRUNTIME const char *
-SWIG_UnpackVoidPtr(const char *c, void **ptr, const char *name) {
- if (*c != '_') {
- if (strcmp(c,"NULL") == 0) {
- *ptr = (void *) 0;
- return name;
- } else {
- return 0;
- }
- }
- return SWIG_UnpackData(++c,ptr,sizeof(void *));
-}
-
-SWIGRUNTIME char *
-SWIG_PackDataName(char *buff, void *ptr, size_t sz, const char *name, size_t bsz) {
- char *r = buff;
- size_t lname = (name ? strlen(name) : 0);
- if ((2*sz + 2 + lname) > bsz) return 0;
- *(r++) = '_';
- r = SWIG_PackData(r,ptr,sz);
- if (lname) {
- strncpy(r,name,lname+1);
- } else {
- *r = 0;
- }
- return buff;
-}
-
-SWIGRUNTIME const char *
-SWIG_UnpackDataName(const char *c, void *ptr, size_t sz, const char *name) {
- if (*c != '_') {
- if (strcmp(c,"NULL") == 0) {
- memset(ptr,0,sz);
- return name;
- } else {
- return 0;
- }
- }
- return SWIG_UnpackData(++c,ptr,sz);
-}
-
-#ifdef __cplusplus
-}
-#endif
-
-/* Errors in SWIG */
-#define SWIG_UnknownError -1
-#define SWIG_IOError -2
-#define SWIG_RuntimeError -3
-#define SWIG_IndexError -4
-#define SWIG_TypeError -5
-#define SWIG_DivisionByZero -6
-#define SWIG_OverflowError -7
-#define SWIG_SyntaxError -8
-#define SWIG_ValueError -9
-#define SWIG_SystemError -10
-#define SWIG_AttributeError -11
-#define SWIG_MemoryError -12
-#define SWIG_NullReferenceError -13
-
-
-
-
-/* Add PyOS_snprintf for old Pythons */
-#if PY_VERSION_HEX < 0x02020000
-# if defined(_MSC_VER) || defined(__BORLANDC__) || defined(_WATCOM)
-# define PyOS_snprintf _snprintf
-# else
-# define PyOS_snprintf snprintf
-# endif
-#endif
-
-/* A crude PyString_FromFormat implementation for old Pythons */
-#if PY_VERSION_HEX < 0x02020000
-
-#ifndef SWIG_PYBUFFER_SIZE
-# define SWIG_PYBUFFER_SIZE 1024
-#endif
-
-static PyObject *
-PyString_FromFormat(const char *fmt, ...) {
- va_list ap;
- char buf[SWIG_PYBUFFER_SIZE * 2];
- int res;
- va_start(ap, fmt);
- res = vsnprintf(buf, sizeof(buf), fmt, ap);
- va_end(ap);
- return (res < 0 || res >= (int)sizeof(buf)) ? 0 : PyString_FromString(buf);
-}
-#endif
-
-/* Add PyObject_Del for old Pythons */
-#if PY_VERSION_HEX < 0x01060000
-# define PyObject_Del(op) PyMem_DEL((op))
-#endif
-#ifndef PyObject_DEL
-# define PyObject_DEL PyObject_Del
-#endif
-
-/* A crude PyExc_StopIteration exception for old Pythons */
-#if PY_VERSION_HEX < 0x02020000
-# ifndef PyExc_StopIteration
-# define PyExc_StopIteration PyExc_RuntimeError
-# endif
-# ifndef PyObject_GenericGetAttr
-# define PyObject_GenericGetAttr 0
-# endif
-#endif
-/* Py_NotImplemented is defined in 2.1 and up. */
-#if PY_VERSION_HEX < 0x02010000
-# ifndef Py_NotImplemented
-# define Py_NotImplemented PyExc_RuntimeError
-# endif
-#endif
-
-
-/* A crude PyString_AsStringAndSize implementation for old Pythons */
-#if PY_VERSION_HEX < 0x02010000
-# ifndef PyString_AsStringAndSize
-# define PyString_AsStringAndSize(obj, s, len) {*s = PyString_AsString(obj); *len = *s ? strlen(*s) : 0;}
-# endif
-#endif
-
-/* PySequence_Size for old Pythons */
-#if PY_VERSION_HEX < 0x02000000
-# ifndef PySequence_Size
-# define PySequence_Size PySequence_Length
-# endif
-#endif
-
-
-/* PyBool_FromLong for old Pythons */
-#if PY_VERSION_HEX < 0x02030000
-static
-PyObject *PyBool_FromLong(long ok)
-{
- PyObject *result = ok ? Py_True : Py_False;
- Py_INCREF(result);
- return result;
-}
-#endif
-
-/* Py_ssize_t for old Pythons */
-/* This code is as recommended by: */
-/* http://www.python.org/dev/peps/pep-0353/#conversion-guidelines */
-#if PY_VERSION_HEX < 0x02050000 && !defined(PY_SSIZE_T_MIN)
-typedef int Py_ssize_t;
-# define PY_SSIZE_T_MAX INT_MAX
-# define PY_SSIZE_T_MIN INT_MIN
-#endif
-
-/* -----------------------------------------------------------------------------
- * error manipulation
- * ----------------------------------------------------------------------------- */
-
-SWIGRUNTIME PyObject*
-SWIG_Python_ErrorType(int code) {
- PyObject* type = 0;
- switch(code) {
- case SWIG_MemoryError:
- type = PyExc_MemoryError;
- break;
- case SWIG_IOError:
- type = PyExc_IOError;
- break;
- case SWIG_RuntimeError:
- type = PyExc_RuntimeError;
- break;
- case SWIG_IndexError:
- type = PyExc_IndexError;
- break;
- case SWIG_TypeError:
- type = PyExc_TypeError;
- break;
- case SWIG_DivisionByZero:
- type = PyExc_ZeroDivisionError;
- break;
- case SWIG_OverflowError:
- type = PyExc_OverflowError;
- break;
- case SWIG_SyntaxError:
- type = PyExc_SyntaxError;
- break;
- case SWIG_ValueError:
- type = PyExc_ValueError;
- break;
- case SWIG_SystemError:
- type = PyExc_SystemError;
- break;
- case SWIG_AttributeError:
- type = PyExc_AttributeError;
- break;
- default:
- type = PyExc_RuntimeError;
- }
- return type;
-}
-
-
-SWIGRUNTIME void
-SWIG_Python_AddErrorMsg(const char* mesg)
-{
- PyObject *type = 0;
- PyObject *value = 0;
- PyObject *traceback = 0;
-
- if (PyErr_Occurred()) PyErr_Fetch(&type, &value, &traceback);
- if (value) {
- PyObject *old_str = PyObject_Str(value);
- PyErr_Clear();
- Py_XINCREF(type);
- PyErr_Format(type, "%s %s", PyString_AsString(old_str), mesg);
- Py_DECREF(old_str);
- Py_DECREF(value);
- } else {
- PyErr_SetString(PyExc_RuntimeError, mesg);
- }
-}
-
-
-
-#if defined(SWIG_PYTHON_NO_THREADS)
-# if defined(SWIG_PYTHON_THREADS)
-# undef SWIG_PYTHON_THREADS
-# endif
-#endif
-#if defined(SWIG_PYTHON_THREADS) /* Threading support is enabled */
-# if !defined(SWIG_PYTHON_USE_GIL) && !defined(SWIG_PYTHON_NO_USE_GIL)
-# if (PY_VERSION_HEX >= 0x02030000) /* For 2.3 or later, use the PyGILState calls */
-# define SWIG_PYTHON_USE_GIL
-# endif
-# endif
-# if defined(SWIG_PYTHON_USE_GIL) /* Use PyGILState threads calls */
-# ifndef SWIG_PYTHON_INITIALIZE_THREADS
-# define SWIG_PYTHON_INITIALIZE_THREADS PyEval_InitThreads()
-# endif
-# ifdef __cplusplus /* C++ code */
- class SWIG_Python_Thread_Block {
- bool status;
- PyGILState_STATE state;
- public:
- void end() { if (status) { PyGILState_Release(state); status = false;} }
- SWIG_Python_Thread_Block() : status(true), state(PyGILState_Ensure()) {}
- ~SWIG_Python_Thread_Block() { end(); }
- };
- class SWIG_Python_Thread_Allow {
- bool status;
- PyThreadState *save;
- public:
- void end() { if (status) { PyEval_RestoreThread(save); status = false; }}
- SWIG_Python_Thread_Allow() : status(true), save(PyEval_SaveThread()) {}
- ~SWIG_Python_Thread_Allow() { end(); }
- };
-# define SWIG_PYTHON_THREAD_BEGIN_BLOCK SWIG_Python_Thread_Block _swig_thread_block
-# define SWIG_PYTHON_THREAD_END_BLOCK _swig_thread_block.end()
-# define SWIG_PYTHON_THREAD_BEGIN_ALLOW SWIG_Python_Thread_Allow _swig_thread_allow
-# define SWIG_PYTHON_THREAD_END_ALLOW _swig_thread_allow.end()
-# else /* C code */
-# define SWIG_PYTHON_THREAD_BEGIN_BLOCK PyGILState_STATE _swig_thread_block = PyGILState_Ensure()
-# define SWIG_PYTHON_THREAD_END_BLOCK PyGILState_Release(_swig_thread_block)
-# define SWIG_PYTHON_THREAD_BEGIN_ALLOW PyThreadState *_swig_thread_allow = PyEval_SaveThread()
-# define SWIG_PYTHON_THREAD_END_ALLOW PyEval_RestoreThread(_swig_thread_allow)
-# endif
-# else /* Old thread way, not implemented, user must provide it */
-# if !defined(SWIG_PYTHON_INITIALIZE_THREADS)
-# define SWIG_PYTHON_INITIALIZE_THREADS
-# endif
-# if !defined(SWIG_PYTHON_THREAD_BEGIN_BLOCK)
-# define SWIG_PYTHON_THREAD_BEGIN_BLOCK
-# endif
-# if !defined(SWIG_PYTHON_THREAD_END_BLOCK)
-# define SWIG_PYTHON_THREAD_END_BLOCK
-# endif
-# if !defined(SWIG_PYTHON_THREAD_BEGIN_ALLOW)
-# define SWIG_PYTHON_THREAD_BEGIN_ALLOW
-# endif
-# if !defined(SWIG_PYTHON_THREAD_END_ALLOW)
-# define SWIG_PYTHON_THREAD_END_ALLOW
-# endif
-# endif
-#else /* No thread support */
-# define SWIG_PYTHON_INITIALIZE_THREADS
-# define SWIG_PYTHON_THREAD_BEGIN_BLOCK
-# define SWIG_PYTHON_THREAD_END_BLOCK
-# define SWIG_PYTHON_THREAD_BEGIN_ALLOW
-# define SWIG_PYTHON_THREAD_END_ALLOW
-#endif
-
-/* -----------------------------------------------------------------------------
- * Python API portion that goes into the runtime
- * ----------------------------------------------------------------------------- */
-
-#ifdef __cplusplus
-extern "C" {
-#if 0
-} /* cc-mode */
-#endif
-#endif
-
-/* -----------------------------------------------------------------------------
- * Constant declarations
- * ----------------------------------------------------------------------------- */
-
-/* Constant Types */
-#define SWIG_PY_POINTER 4
-#define SWIG_PY_BINARY 5
-
-/* Constant information structure */
-typedef struct swig_const_info {
- int type;
- char *name;
- long lvalue;
- double dvalue;
- void *pvalue;
- swig_type_info **ptype;
-} swig_const_info;
-
-#ifdef __cplusplus
-#if 0
-{ /* cc-mode */
-#endif
-}
-#endif
-
-
-/* -----------------------------------------------------------------------------
- * See the LICENSE file for information on copyright, usage and redistribution
- * of SWIG, and the README file for authors - http://www.swig.org/release.html.
- *
- * pyrun.swg
- *
- * This file contains the runtime support for Python modules
- * and includes code for managing global variables and pointer
- * type checking.
- *
- * ----------------------------------------------------------------------------- */
-
-/* Common SWIG API */
-
-/* for raw pointers */
-#define SWIG_Python_ConvertPtr(obj, pptr, type, flags) SWIG_Python_ConvertPtrAndOwn(obj, pptr, type, flags, 0)
-#define SWIG_ConvertPtr(obj, pptr, type, flags) SWIG_Python_ConvertPtr(obj, pptr, type, flags)
-#define SWIG_ConvertPtrAndOwn(obj,pptr,type,flags,own) SWIG_Python_ConvertPtrAndOwn(obj, pptr, type, flags, own)
-#define SWIG_NewPointerObj(ptr, type, flags) SWIG_Python_NewPointerObj(ptr, type, flags)
-#define SWIG_CheckImplicit(ty) SWIG_Python_CheckImplicit(ty)
-#define SWIG_AcquirePtr(ptr, src) SWIG_Python_AcquirePtr(ptr, src)
-#define swig_owntype int
-
-/* for raw packed data */
-#define SWIG_ConvertPacked(obj, ptr, sz, ty) SWIG_Python_ConvertPacked(obj, ptr, sz, ty)
-#define SWIG_NewPackedObj(ptr, sz, type) SWIG_Python_NewPackedObj(ptr, sz, type)
-
-/* for class or struct pointers */
-#define SWIG_ConvertInstance(obj, pptr, type, flags) SWIG_ConvertPtr(obj, pptr, type, flags)
-#define SWIG_NewInstanceObj(ptr, type, flags) SWIG_NewPointerObj(ptr, type, flags)
-
-/* for C or C++ function pointers */
-#define SWIG_ConvertFunctionPtr(obj, pptr, type) SWIG_Python_ConvertFunctionPtr(obj, pptr, type)
-#define SWIG_NewFunctionPtrObj(ptr, type) SWIG_Python_NewPointerObj(ptr, type, 0)
-
-/* for C++ member pointers, ie, member methods */
-#define SWIG_ConvertMember(obj, ptr, sz, ty) SWIG_Python_ConvertPacked(obj, ptr, sz, ty)
-#define SWIG_NewMemberObj(ptr, sz, type) SWIG_Python_NewPackedObj(ptr, sz, type)
-
-
-/* Runtime API */
-
-#define SWIG_GetModule(clientdata) SWIG_Python_GetModule()
-#define SWIG_SetModule(clientdata, pointer) SWIG_Python_SetModule(pointer)
-#define SWIG_NewClientData(obj) PySwigClientData_New(obj)
-
-#define SWIG_SetErrorObj SWIG_Python_SetErrorObj
-#define SWIG_SetErrorMsg SWIG_Python_SetErrorMsg
-#define SWIG_ErrorType(code) SWIG_Python_ErrorType(code)
-#define SWIG_Error(code, msg) SWIG_Python_SetErrorMsg(SWIG_ErrorType(code), msg)
-#define SWIG_fail goto fail
-
-
-/* Runtime API implementation */
-
-/* Error manipulation */
-
-SWIGINTERN void
-SWIG_Python_SetErrorObj(PyObject *errtype, PyObject *obj) {
- SWIG_PYTHON_THREAD_BEGIN_BLOCK;
- PyErr_SetObject(errtype, obj);
- Py_DECREF(obj);
- SWIG_PYTHON_THREAD_END_BLOCK;
-}
-
-SWIGINTERN void
-SWIG_Python_SetErrorMsg(PyObject *errtype, const char *msg) {
- SWIG_PYTHON_THREAD_BEGIN_BLOCK;
- PyErr_SetString(errtype, (char *) msg);
- SWIG_PYTHON_THREAD_END_BLOCK;
-}
-
-#define SWIG_Python_Raise(obj, type, desc) SWIG_Python_SetErrorObj(SWIG_Python_ExceptionType(desc), obj)
-
-/* Set a constant value */
-
-SWIGINTERN void
-SWIG_Python_SetConstant(PyObject *d, const char *name, PyObject *obj) {
- PyDict_SetItemString(d, (char*) name, obj);
- Py_DECREF(obj);
-}
-
-/* Append a value to the result obj */
-
-SWIGINTERN PyObject*
-SWIG_Python_AppendOutput(PyObject* result, PyObject* obj) {
-#if !defined(SWIG_PYTHON_OUTPUT_TUPLE)
- if (!result) {
- result = obj;
- } else if (result == Py_None) {
- Py_DECREF(result);
- result = obj;
- } else {
- if (!PyList_Check(result)) {
- PyObject *o2 = result;
- result = PyList_New(1);
- PyList_SetItem(result, 0, o2);
- }
- PyList_Append(result,obj);
- Py_DECREF(obj);
- }
- return result;
-#else
- PyObject* o2;
- PyObject* o3;
- if (!result) {
- result = obj;
- } else if (result == Py_None) {
- Py_DECREF(result);
- result = obj;
- } else {
- if (!PyTuple_Check(result)) {
- o2 = result;
- result = PyTuple_New(1);
- PyTuple_SET_ITEM(result, 0, o2);
- }
- o3 = PyTuple_New(1);
- PyTuple_SET_ITEM(o3, 0, obj);
- o2 = result;
- result = PySequence_Concat(o2, o3);
- Py_DECREF(o2);
- Py_DECREF(o3);
- }
- return result;
-#endif
-}
-
-/* Unpack the argument tuple */
-
-SWIGINTERN int
-SWIG_Python_UnpackTuple(PyObject *args, const char *name, Py_ssize_t min, Py_ssize_t max, PyObject **objs)
-{
- if (!args) {
- if (!min && !max) {
- return 1;
- } else {
- PyErr_Format(PyExc_TypeError, "%s expected %s%d arguments, got none",
- name, (min == max ? "" : "at least "), (int)min);
- return 0;
- }
- }
- if (!PyTuple_Check(args)) {
- PyErr_SetString(PyExc_SystemError, "UnpackTuple() argument list is not a tuple");
- return 0;
- } else {
- register Py_ssize_t l = PyTuple_GET_SIZE(args);
- if (l < min) {
- PyErr_Format(PyExc_TypeError, "%s expected %s%d arguments, got %d",
- name, (min == max ? "" : "at least "), (int)min, (int)l);
- return 0;
- } else if (l > max) {
- PyErr_Format(PyExc_TypeError, "%s expected %s%d arguments, got %d",
- name, (min == max ? "" : "at most "), (int)max, (int)l);
- return 0;
- } else {
- register int i;
- for (i = 0; i < l; ++i) {
- objs[i] = PyTuple_GET_ITEM(args, i);
- }
- for (; l < max; ++l) {
- objs[l] = 0;
- }
- return i + 1;
- }
- }
-}
-
-/* A functor is a function object with one single object argument */
-#if PY_VERSION_HEX >= 0x02020000
-#define SWIG_Python_CallFunctor(functor, obj) PyObject_CallFunctionObjArgs(functor, obj, NULL);
-#else
-#define SWIG_Python_CallFunctor(functor, obj) PyObject_CallFunction(functor, "O", obj);
-#endif
-
-/*
- Helper for static pointer initialization for both C and C++ code, for example
- static PyObject *SWIG_STATIC_POINTER(MyVar) = NewSomething(...);
-*/
-#ifdef __cplusplus
-#define SWIG_STATIC_POINTER(var) var
-#else
-#define SWIG_STATIC_POINTER(var) var = 0; if (!var) var
-#endif
-
-/* -----------------------------------------------------------------------------
- * Pointer declarations
- * ----------------------------------------------------------------------------- */
-
-/* Flags for new pointer objects */
-#define SWIG_POINTER_NOSHADOW (SWIG_POINTER_OWN << 1)
-#define SWIG_POINTER_NEW (SWIG_POINTER_NOSHADOW | SWIG_POINTER_OWN)
-
-#define SWIG_POINTER_IMPLICIT_CONV (SWIG_POINTER_DISOWN << 1)
-
-#ifdef __cplusplus
-extern "C" {
-#if 0
-} /* cc-mode */
-#endif
-#endif
-
-/* How to access Py_None */
-#if defined(_WIN32) || defined(__WIN32__) || defined(__CYGWIN__)
-# ifndef SWIG_PYTHON_NO_BUILD_NONE
-# ifndef SWIG_PYTHON_BUILD_NONE
-# define SWIG_PYTHON_BUILD_NONE
-# endif
-# endif
-#endif
-
-#ifdef SWIG_PYTHON_BUILD_NONE
-# ifdef Py_None
-# undef Py_None
-# define Py_None SWIG_Py_None()
-# endif
-SWIGRUNTIMEINLINE PyObject *
-_SWIG_Py_None(void)
-{
- PyObject *none = Py_BuildValue((char*)"");
- Py_DECREF(none);
- return none;
-}
-SWIGRUNTIME PyObject *
-SWIG_Py_None(void)
-{
- static PyObject *SWIG_STATIC_POINTER(none) = _SWIG_Py_None();
- return none;
-}
-#endif
-
-/* The python void return value */
-
-SWIGRUNTIMEINLINE PyObject *
-SWIG_Py_Void(void)
-{
- PyObject *none = Py_None;
- Py_INCREF(none);
- return none;
-}
-
-/* PySwigClientData */
-
-typedef struct {
- PyObject *klass;
- PyObject *newraw;
- PyObject *newargs;
- PyObject *destroy;
- int delargs;
- int implicitconv;
-} PySwigClientData;
-
-SWIGRUNTIMEINLINE int
-SWIG_Python_CheckImplicit(swig_type_info *ty)
-{
- PySwigClientData *data = (PySwigClientData *)ty->clientdata;
- return data ? data->implicitconv : 0;
-}
-
-SWIGRUNTIMEINLINE PyObject *
-SWIG_Python_ExceptionType(swig_type_info *desc) {
- PySwigClientData *data = desc ? (PySwigClientData *) desc->clientdata : 0;
- PyObject *klass = data ? data->klass : 0;
- return (klass ? klass : PyExc_RuntimeError);
-}
-
-
-SWIGRUNTIME PySwigClientData *
-PySwigClientData_New(PyObject* obj)
-{
- if (!obj) {
- return 0;
- } else {
- PySwigClientData *data = (PySwigClientData *)malloc(sizeof(PySwigClientData));
- /* the klass element */
- data->klass = obj;
- Py_INCREF(data->klass);
- /* the newraw method and newargs arguments used to create a new raw instance */
- if (PyClass_Check(obj)) {
- data->newraw = 0;
- data->newargs = obj;
- Py_INCREF(obj);
- } else {
-#if (PY_VERSION_HEX < 0x02020000)
- data->newraw = 0;
-#else
- data->newraw = PyObject_GetAttrString(data->klass, (char *)"__new__");
-#endif
- if (data->newraw) {
- Py_INCREF(data->newraw);
- data->newargs = PyTuple_New(1);
- PyTuple_SetItem(data->newargs, 0, obj);
- } else {
- data->newargs = obj;
- }
- Py_INCREF(data->newargs);
- }
- /* the destroy method, aka as the C++ delete method */
- data->destroy = PyObject_GetAttrString(data->klass, (char *)"__swig_destroy__");
- if (PyErr_Occurred()) {
- PyErr_Clear();
- data->destroy = 0;
- }
- if (data->destroy) {
- int flags;
- Py_INCREF(data->destroy);
- flags = PyCFunction_GET_FLAGS(data->destroy);
-#ifdef METH_O
- data->delargs = !(flags & (METH_O));
-#else
- data->delargs = 0;
-#endif
- } else {
- data->delargs = 0;
- }
- data->implicitconv = 0;
- return data;
- }
-}
-
-SWIGRUNTIME void
-PySwigClientData_Del(PySwigClientData* data)
-{
- Py_XDECREF(data->newraw);
- Py_XDECREF(data->newargs);
- Py_XDECREF(data->destroy);
-}
-
-/* =============== PySwigObject =====================*/
-
-typedef struct {
- PyObject_HEAD
- void *ptr;
- swig_type_info *ty;
- int own;
- PyObject *next;
-} PySwigObject;
-
-SWIGRUNTIME PyObject *
-PySwigObject_long(PySwigObject *v)
-{
- return PyLong_FromVoidPtr(v->ptr);
-}
-
-SWIGRUNTIME PyObject *
-PySwigObject_format(const char* fmt, PySwigObject *v)
-{
- PyObject *res = NULL;
- PyObject *args = PyTuple_New(1);
- if (args) {
- if (PyTuple_SetItem(args, 0, PySwigObject_long(v)) == 0) {
- PyObject *ofmt = PyString_FromString(fmt);
- if (ofmt) {
- res = PyString_Format(ofmt,args);
- Py_DECREF(ofmt);
- }
- Py_DECREF(args);
- }
- }
- return res;
-}
-
-SWIGRUNTIME PyObject *
-PySwigObject_oct(PySwigObject *v)
-{
- return PySwigObject_format("%o",v);
-}
-
-SWIGRUNTIME PyObject *
-PySwigObject_hex(PySwigObject *v)
-{
- return PySwigObject_format("%x",v);
-}
-
-SWIGRUNTIME PyObject *
-#ifdef METH_NOARGS
-PySwigObject_repr(PySwigObject *v)
-#else
-PySwigObject_repr(PySwigObject *v, PyObject *args)
-#endif
-{
- const char *name = SWIG_TypePrettyName(v->ty);
- PyObject *hex = PySwigObject_hex(v);
- PyObject *repr = PyString_FromFormat("<Swig Object of type '%s' at 0x%s>", name, PyString_AsString(hex));
- Py_DECREF(hex);
- if (v->next) {
-#ifdef METH_NOARGS
- PyObject *nrep = PySwigObject_repr((PySwigObject *)v->next);
-#else
- PyObject *nrep = PySwigObject_repr((PySwigObject *)v->next, args);
-#endif
- PyString_ConcatAndDel(&repr,nrep);
- }
- return repr;
-}
-
-SWIGRUNTIME int
-PySwigObject_print(PySwigObject *v, FILE *fp, int SWIGUNUSEDPARM(flags))
-{
-#ifdef METH_NOARGS
- PyObject *repr = PySwigObject_repr(v);
-#else
- PyObject *repr = PySwigObject_repr(v, NULL);
-#endif
- if (repr) {
- fputs(PyString_AsString(repr), fp);
- Py_DECREF(repr);
- return 0;
- } else {
- return 1;
- }
-}
-
-SWIGRUNTIME PyObject *
-PySwigObject_str(PySwigObject *v)
-{
- char result[SWIG_BUFFER_SIZE];
- return SWIG_PackVoidPtr(result, v->ptr, v->ty->name, sizeof(result)) ?
- PyString_FromString(result) : 0;
-}
-
-SWIGRUNTIME int
-PySwigObject_compare(PySwigObject *v, PySwigObject *w)
-{
- void *i = v->ptr;
- void *j = w->ptr;
- return (i < j) ? -1 : ((i > j) ? 1 : 0);
-}
-
-SWIGRUNTIME PyTypeObject* _PySwigObject_type(void);
-
-SWIGRUNTIME PyTypeObject*
-PySwigObject_type(void) {
- static PyTypeObject *SWIG_STATIC_POINTER(type) = _PySwigObject_type();
- return type;
-}
-
-SWIGRUNTIMEINLINE int
-PySwigObject_Check(PyObject *op) {
- return ((op)->ob_type == PySwigObject_type())
- || (strcmp((op)->ob_type->tp_name,"PySwigObject") == 0);
-}
-
-SWIGRUNTIME PyObject *
-PySwigObject_New(void *ptr, swig_type_info *ty, int own);
-
-SWIGRUNTIME void
-PySwigObject_dealloc(PyObject *v)
-{
- PySwigObject *sobj = (PySwigObject *) v;
- PyObject *next = sobj->next;
- 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;
- if (destroy) {
- /* destroy is always a VARARGS method */
- PyObject *res;
- if (data->delargs) {
- /* we need to create a temporal object to carry the destroy operation */
- PyObject *tmp = PySwigObject_New(sobj->ptr, ty, 0);
- res = SWIG_Python_CallFunctor(destroy, tmp);
- Py_DECREF(tmp);
- } else {
- PyCFunction meth = PyCFunction_GET_FUNCTION(destroy);
- PyObject *mself = PyCFunction_GET_SELF(destroy);
- res = ((*meth)(mself, v));
- }
- Py_XDECREF(res);
- }
-#if !defined(SWIG_PYTHON_SILENT_MEMLEAK)
- 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);
-}
-
-SWIGRUNTIME PyObject*
-PySwigObject_append(PyObject* v, PyObject* next)
-{
- PySwigObject *sobj = (PySwigObject *) v;
-#ifndef METH_O
- PyObject *tmp = 0;
- if (!PyArg_ParseTuple(next,(char *)"O:append", &tmp)) return NULL;
- next = tmp;
-#endif
- if (!PySwigObject_Check(next)) {
- return NULL;
- }
- sobj->next = next;
- Py_INCREF(next);
- return SWIG_Py_Void();
-}
-
-SWIGRUNTIME PyObject*
-#ifdef METH_NOARGS
-PySwigObject_next(PyObject* v)
-#else
-PySwigObject_next(PyObject* v, PyObject *SWIGUNUSEDPARM(args))
-#endif
-{
- PySwigObject *sobj = (PySwigObject *) v;
- if (sobj->next) {
- Py_INCREF(sobj->next);
- return sobj->next;
- } else {
- return SWIG_Py_Void();
- }
-}
-
-SWIGINTERN PyObject*
-#ifdef METH_NOARGS
-PySwigObject_disown(PyObject *v)
-#else
-PySwigObject_disown(PyObject* v, PyObject *SWIGUNUSEDPARM(args))
-#endif
-{
- PySwigObject *sobj = (PySwigObject *)v;
- sobj->own = 0;
- return SWIG_Py_Void();
-}
-
-SWIGINTERN PyObject*
-#ifdef METH_NOARGS
-PySwigObject_acquire(PyObject *v)
-#else
-PySwigObject_acquire(PyObject* v, PyObject *SWIGUNUSEDPARM(args))
-#endif
-{
- PySwigObject *sobj = (PySwigObject *)v;
- sobj->own = SWIG_POINTER_OWN;
- return SWIG_Py_Void();
-}
-
-SWIGINTERN PyObject*
-PySwigObject_own(PyObject *v, PyObject *args)
-{
- PyObject *val = 0;
-#if (PY_VERSION_HEX < 0x02020000)
- if (!PyArg_ParseTuple(args,(char *)"|O:own",&val))
-#else
- if (!PyArg_UnpackTuple(args, (char *)"own", 0, 1, &val))
-#endif
- {
- return NULL;
- }
- else
- {
- PySwigObject *sobj = (PySwigObject *)v;
- PyObject *obj = PyBool_FromLong(sobj->own);
- if (val) {
-#ifdef METH_NOARGS
- if (PyObject_IsTrue(val)) {
- PySwigObject_acquire(v);
- } else {
- PySwigObject_disown(v);
- }
-#else
- if (PyObject_IsTrue(val)) {
- PySwigObject_acquire(v,args);
- } else {
- PySwigObject_disown(v,args);
- }
-#endif
- }
- return obj;
- }
-}
-
-#ifdef METH_O
-static PyMethodDef
-swigobject_methods[] = {
- {(char *)"disown", (PyCFunction)PySwigObject_disown, METH_NOARGS, (char *)"releases ownership of the pointer"},
- {(char *)"acquire", (PyCFunction)PySwigObject_acquire, METH_NOARGS, (char *)"aquires ownership of the pointer"},
- {(char *)"own", (PyCFunction)PySwigObject_own, METH_VARARGS, (char *)"returns/sets ownership of the pointer"},
- {(char *)"append", (PyCFunction)PySwigObject_append, METH_O, (char *)"appends another 'this' object"},
- {(char *)"next", (PyCFunction)PySwigObject_next, METH_NOARGS, (char *)"returns the next 'this' object"},
- {(char *)"__repr__",(PyCFunction)PySwigObject_repr, METH_NOARGS, (char *)"returns object representation"},
- {0, 0, 0, 0}
-};
-#else
-static PyMethodDef
-swigobject_methods[] = {
- {(char *)"disown", (PyCFunction)PySwigObject_disown, METH_VARARGS, (char *)"releases ownership of the pointer"},
- {(char *)"acquire", (PyCFunction)PySwigObject_acquire, METH_VARARGS, (char *)"aquires ownership of the pointer"},
- {(char *)"own", (PyCFunction)PySwigObject_own, METH_VARARGS, (char *)"returns/sets ownership of the pointer"},
- {(char *)"append", (PyCFunction)PySwigObject_append, METH_VARARGS, (char *)"appends another 'this' object"},
- {(char *)"next", (PyCFunction)PySwigObject_next, METH_VARARGS, (char *)"returns the next 'this' object"},
- {(char *)"__repr__",(PyCFunction)PySwigObject_repr, METH_VARARGS, (char *)"returns object representation"},
- {0, 0, 0, 0}
-};
-#endif
-
-#if PY_VERSION_HEX < 0x02020000
-SWIGINTERN PyObject *
-PySwigObject_getattr(PySwigObject *sobj,char *name)
-{
- return Py_FindMethod(swigobject_methods, (PyObject *)sobj, name);
-}
-#endif
-
-SWIGRUNTIME PyTypeObject*
-_PySwigObject_type(void) {
- static char swigobject_doc[] = "Swig object carries a C/C++ instance pointer";
-
- static PyNumberMethods PySwigObject_as_number = {
- (binaryfunc)0, /*nb_add*/
- (binaryfunc)0, /*nb_subtract*/
- (binaryfunc)0, /*nb_multiply*/
- (binaryfunc)0, /*nb_divide*/
- (binaryfunc)0, /*nb_remainder*/
- (binaryfunc)0, /*nb_divmod*/
- (ternaryfunc)0,/*nb_power*/
- (unaryfunc)0, /*nb_negative*/
- (unaryfunc)0, /*nb_positive*/
- (unaryfunc)0, /*nb_absolute*/
- (inquiry)0, /*nb_nonzero*/
- 0, /*nb_invert*/
- 0, /*nb_lshift*/
- 0, /*nb_rshift*/
- 0, /*nb_and*/
- 0, /*nb_xor*/
- 0, /*nb_or*/
- (coercion)0, /*nb_coerce*/
- (unaryfunc)PySwigObject_long, /*nb_int*/
- (unaryfunc)PySwigObject_long, /*nb_long*/
- (unaryfunc)0, /*nb_float*/
- (unaryfunc)PySwigObject_oct, /*nb_oct*/
- (unaryfunc)PySwigObject_hex, /*nb_hex*/
-#if PY_VERSION_HEX >= 0x02050000 /* 2.5.0 */
- 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0 /* nb_inplace_add -> nb_index */
-#elif PY_VERSION_HEX >= 0x02020000 /* 2.2.0 */
- 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0 /* nb_inplace_add -> nb_inplace_true_divide */
-#elif PY_VERSION_HEX >= 0x02000000 /* 2.0.0 */
- 0,0,0,0,0,0,0,0,0,0,0 /* nb_inplace_add -> nb_inplace_or */
-#endif
- };
-
- static PyTypeObject pyswigobject_type;
- static int type_init = 0;
- if (!type_init) {
- const PyTypeObject tmp
- = {
- PyObject_HEAD_INIT(NULL)
- 0, /* ob_size */
- (char *)"PySwigObject", /* tp_name */
- sizeof(PySwigObject), /* tp_basicsize */
- 0, /* tp_itemsize */
- (destructor)PySwigObject_dealloc, /* tp_dealloc */
- (printfunc)PySwigObject_print, /* tp_print */
-#if PY_VERSION_HEX < 0x02020000
- (getattrfunc)PySwigObject_getattr, /* tp_getattr */
-#else
- (getattrfunc)0, /* tp_getattr */
-#endif
- (setattrfunc)0, /* tp_setattr */
- (cmpfunc)PySwigObject_compare, /* tp_compare */
- (reprfunc)PySwigObject_repr, /* tp_repr */
- &PySwigObject_as_number, /* tp_as_number */
- 0, /* tp_as_sequence */
- 0, /* tp_as_mapping */
- (hashfunc)0, /* tp_hash */
- (ternaryfunc)0, /* tp_call */
- (reprfunc)PySwigObject_str, /* tp_str */
- PyObject_GenericGetAttr, /* tp_getattro */
- 0, /* tp_setattro */
- 0, /* tp_as_buffer */
- Py_TPFLAGS_DEFAULT, /* tp_flags */
- swigobject_doc, /* tp_doc */
- 0, /* tp_traverse */
- 0, /* tp_clear */
- 0, /* tp_richcompare */
- 0, /* tp_weaklistoffset */
-#if PY_VERSION_HEX >= 0x02020000
- 0, /* tp_iter */
- 0, /* tp_iternext */
- swigobject_methods, /* tp_methods */
- 0, /* tp_members */
- 0, /* tp_getset */
- 0, /* tp_base */
- 0, /* tp_dict */
- 0, /* tp_descr_get */
- 0, /* tp_descr_set */
- 0, /* tp_dictoffset */
- 0, /* tp_init */
- 0, /* tp_alloc */
- 0, /* tp_new */
- 0, /* tp_free */
- 0, /* tp_is_gc */
- 0, /* tp_bases */
- 0, /* tp_mro */
- 0, /* tp_cache */
- 0, /* tp_subclasses */
- 0, /* tp_weaklist */
-#endif
-#if PY_VERSION_HEX >= 0x02030000
- 0, /* tp_del */
-#endif
-#ifdef COUNT_ALLOCS
- 0,0,0,0 /* tp_alloc -> tp_next */
-#endif
- };
- pyswigobject_type = tmp;
- pyswigobject_type.ob_type = &PyType_Type;
- type_init = 1;
- }
- return &pyswigobject_type;
-}
-
-SWIGRUNTIME PyObject *
-PySwigObject_New(void *ptr, swig_type_info *ty, int own)
-{
- PySwigObject *sobj = PyObject_NEW(PySwigObject, PySwigObject_type());
- if (sobj) {
- sobj->ptr = ptr;
- sobj->ty = ty;
- sobj->own = own;
- sobj->next = 0;
- }
- return (PyObject *)sobj;
-}
-
-/* -----------------------------------------------------------------------------
- * Implements a simple Swig Packed type, and use it instead of string
- * ----------------------------------------------------------------------------- */
-
-typedef struct {
- PyObject_HEAD
- void *pack;
- swig_type_info *ty;
- size_t size;
-} PySwigPacked;
-
-SWIGRUNTIME int
-PySwigPacked_print(PySwigPacked *v, FILE *fp, int SWIGUNUSEDPARM(flags))
-{
- char result[SWIG_BUFFER_SIZE];
- fputs("<Swig Packed ", fp);
- if (SWIG_PackDataName(result, v->pack, v->size, 0, sizeof(result))) {
- fputs("at ", fp);
- fputs(result, fp);
- }
- fputs(v->ty->name,fp);
- fputs(">", fp);
- return 0;
-}
-
-SWIGRUNTIME PyObject *
-PySwigPacked_repr(PySwigPacked *v)
-{
- char result[SWIG_BUFFER_SIZE];
- if (SWIG_PackDataName(result, v->pack, v->size, 0, sizeof(result))) {
- return PyString_FromFormat("<Swig Packed at %s%s>", result, v->ty->name);
- } else {
- return PyString_FromFormat("<Swig Packed %s>", v->ty->name);
- }
-}
-
-SWIGRUNTIME PyObject *
-PySwigPacked_str(PySwigPacked *v)
-{
- char result[SWIG_BUFFER_SIZE];
- if (SWIG_PackDataName(result, v->pack, v->size, 0, sizeof(result))){
- return PyString_FromFormat("%s%s", result, v->ty->name);
- } else {
- return PyString_FromString(v->ty->name);
- }
-}
-
-SWIGRUNTIME int
-PySwigPacked_compare(PySwigPacked *v, PySwigPacked *w)
-{
- size_t i = v->size;
- size_t j = w->size;
- int s = (i < j) ? -1 : ((i > j) ? 1 : 0);
- return s ? s : strncmp((char *)v->pack, (char *)w->pack, 2*v->size);
-}
-
-SWIGRUNTIME PyTypeObject* _PySwigPacked_type(void);
-
-SWIGRUNTIME PyTypeObject*
-PySwigPacked_type(void) {
- static PyTypeObject *SWIG_STATIC_POINTER(type) = _PySwigPacked_type();
- return type;
-}
-
-SWIGRUNTIMEINLINE int
-PySwigPacked_Check(PyObject *op) {
- return ((op)->ob_type == _PySwigPacked_type())
- || (strcmp((op)->ob_type->tp_name,"PySwigPacked") == 0);
-}
-
-SWIGRUNTIME void
-PySwigPacked_dealloc(PyObject *v)
-{
- if (PySwigPacked_Check(v)) {
- PySwigPacked *sobj = (PySwigPacked *) v;
- free(sobj->pack);
- }
- PyObject_DEL(v);
-}
-
-SWIGRUNTIME PyTypeObject*
-_PySwigPacked_type(void) {
- static char swigpacked_doc[] = "Swig object carries a C/C++ instance pointer";
- static PyTypeObject pyswigpacked_type;
- static int type_init = 0;
- if (!type_init) {
- const PyTypeObject tmp
- = {
- PyObject_HEAD_INIT(NULL)
- 0, /* ob_size */
- (char *)"PySwigPacked", /* tp_name */
- sizeof(PySwigPacked), /* tp_basicsize */
- 0, /* tp_itemsize */
- (destructor)PySwigPacked_dealloc, /* tp_dealloc */
- (printfunc)PySwigPacked_print, /* tp_print */
- (getattrfunc)0, /* tp_getattr */
- (setattrfunc)0, /* tp_setattr */
- (cmpfunc)PySwigPacked_compare, /* tp_compare */
- (reprfunc)PySwigPacked_repr, /* tp_repr */
- 0, /* tp_as_number */
- 0, /* tp_as_sequence */
- 0, /* tp_as_mapping */
- (hashfunc)0, /* tp_hash */
- (ternaryfunc)0, /* tp_call */
- (reprfunc)PySwigPacked_str, /* tp_str */
- PyObject_GenericGetAttr, /* tp_getattro */
- 0, /* tp_setattro */
- 0, /* tp_as_buffer */
- Py_TPFLAGS_DEFAULT, /* tp_flags */
- swigpacked_doc, /* tp_doc */
- 0, /* tp_traverse */
- 0, /* tp_clear */
- 0, /* tp_richcompare */
- 0, /* tp_weaklistoffset */
-#if PY_VERSION_HEX >= 0x02020000
- 0, /* tp_iter */
- 0, /* tp_iternext */
- 0, /* tp_methods */
- 0, /* tp_members */
- 0, /* tp_getset */
- 0, /* tp_base */
- 0, /* tp_dict */
- 0, /* tp_descr_get */
- 0, /* tp_descr_set */
- 0, /* tp_dictoffset */
- 0, /* tp_init */
- 0, /* tp_alloc */
- 0, /* tp_new */
- 0, /* tp_free */
- 0, /* tp_is_gc */
- 0, /* tp_bases */
- 0, /* tp_mro */
- 0, /* tp_cache */
- 0, /* tp_subclasses */
- 0, /* tp_weaklist */
-#endif
-#if PY_VERSION_HEX >= 0x02030000
- 0, /* tp_del */
-#endif
-#ifdef COUNT_ALLOCS
- 0,0,0,0 /* tp_alloc -> tp_next */
-#endif
- };
- pyswigpacked_type = tmp;
- pyswigpacked_type.ob_type = &PyType_Type;
- type_init = 1;
- }
- return &pyswigpacked_type;
-}
-
-SWIGRUNTIME PyObject *
-PySwigPacked_New(void *ptr, size_t size, swig_type_info *ty)
-{
- PySwigPacked *sobj = PyObject_NEW(PySwigPacked, PySwigPacked_type());
- if (sobj) {
- void *pack = malloc(size);
- if (pack) {
- memcpy(pack, ptr, size);
- sobj->pack = pack;
- sobj->ty = ty;
- sobj->size = size;
- } else {
- PyObject_DEL((PyObject *) sobj);
- sobj = 0;
- }
- }
- return (PyObject *) sobj;
-}
-
-SWIGRUNTIME swig_type_info *
-PySwigPacked_UnpackData(PyObject *obj, void *ptr, size_t size)
-{
- if (PySwigPacked_Check(obj)) {
- PySwigPacked *sobj = (PySwigPacked *)obj;
- if (sobj->size != size) return 0;
- memcpy(ptr, sobj->pack, size);
- return sobj->ty;
- } else {
- return 0;
- }
-}
-
-/* -----------------------------------------------------------------------------
- * pointers/data manipulation
- * ----------------------------------------------------------------------------- */
-
-SWIGRUNTIMEINLINE PyObject *
-_SWIG_This(void)
-{
- return PyString_FromString("this");
-}
-
-SWIGRUNTIME PyObject *
-SWIG_This(void)
-{
- static PyObject *SWIG_STATIC_POINTER(swig_this) = _SWIG_This();
- return swig_this;
-}
-
-/* #define SWIG_PYTHON_SLOW_GETSET_THIS */
-
-SWIGRUNTIME PySwigObject *
-SWIG_Python_GetSwigThis(PyObject *pyobj)
-{
- if (PySwigObject_Check(pyobj)) {
- return (PySwigObject *) pyobj;
- } else {
- PyObject *obj = 0;
-#if (!defined(SWIG_PYTHON_SLOW_GETSET_THIS) && (PY_VERSION_HEX >= 0x02030000))
- if (PyInstance_Check(pyobj)) {
- obj = _PyInstance_Lookup(pyobj, SWIG_This());
- } else {
- PyObject **dictptr = _PyObject_GetDictPtr(pyobj);
- if (dictptr != NULL) {
- PyObject *dict = *dictptr;
- obj = dict ? PyDict_GetItem(dict, SWIG_This()) : 0;
- } else {
-#ifdef PyWeakref_CheckProxy
- if (PyWeakref_CheckProxy(pyobj)) {
- PyObject *wobj = PyWeakref_GET_OBJECT(pyobj);
- return wobj ? SWIG_Python_GetSwigThis(wobj) : 0;
- }
-#endif
- obj = PyObject_GetAttr(pyobj,SWIG_This());
- if (obj) {
- Py_DECREF(obj);
- } else {
- if (PyErr_Occurred()) PyErr_Clear();
- return 0;
- }
- }
- }
-#else
- obj = PyObject_GetAttr(pyobj,SWIG_This());
- if (obj) {
- Py_DECREF(obj);
- } else {
- if (PyErr_Occurred()) PyErr_Clear();
- return 0;
- }
-#endif
- if (obj && !PySwigObject_Check(obj)) {
- /* a PyObject is called 'this', try to get the 'real this'
- PySwigObject from it */
- return SWIG_Python_GetSwigThis(obj);
- }
- return (PySwigObject *)obj;
- }
-}
-
-/* Acquire a pointer value */
-
-SWIGRUNTIME int
-SWIG_Python_AcquirePtr(PyObject *obj, int own) {
- if (own == SWIG_POINTER_OWN) {
- PySwigObject *sobj = SWIG_Python_GetSwigThis(obj);
- if (sobj) {
- int oldown = sobj->own;
- sobj->own = own;
- return oldown;
- }
- }
- return 0;
-}
-
-/* Convert a pointer value */
-
-SWIGRUNTIME int
-SWIG_Python_ConvertPtrAndOwn(PyObject *obj, void **ptr, swig_type_info *ty, int flags, int *own) {
- if (!obj) return SWIG_ERROR;
- if (obj == Py_None) {
- if (ptr) *ptr = 0;
- return SWIG_OK;
- } else {
- PySwigObject *sobj = SWIG_Python_GetSwigThis(obj);
- if (own)
- *own = 0;
- while (sobj) {
- void *vptr = sobj->ptr;
- if (ty) {
- swig_type_info *to = sobj->ty;
- if (to == ty) {
- /* no type cast needed */
- if (ptr) *ptr = vptr;
- break;
- } else {
- swig_cast_info *tc = SWIG_TypeCheck(to->name,ty);
- if (!tc) {
- sobj = (PySwigObject *)sobj->next;
- } else {
- 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;
- }
- }
- } else {
- if (ptr) *ptr = vptr;
- break;
- }
- }
- if (sobj) {
- if (own)
- *own = *own | sobj->own;
- if (flags & SWIG_POINTER_DISOWN) {
- sobj->own = 0;
- }
- return SWIG_OK;
- } else {
- int res = SWIG_ERROR;
- if (flags & SWIG_POINTER_IMPLICIT_CONV) {
- PySwigClientData *data = ty ? (PySwigClientData *) ty->clientdata : 0;
- if (data && !data->implicitconv) {
- PyObject *klass = data->klass;
- if (klass) {
- PyObject *impconv;
- data->implicitconv = 1; /* avoid recursion and call 'explicit' constructors*/
- impconv = SWIG_Python_CallFunctor(klass, obj);
- data->implicitconv = 0;
- if (PyErr_Occurred()) {
- PyErr_Clear();
- impconv = 0;
- }
- if (impconv) {
- PySwigObject *iobj = SWIG_Python_GetSwigThis(impconv);
- if (iobj) {
- void *vptr;
- res = SWIG_Python_ConvertPtrAndOwn((PyObject*)iobj, &vptr, ty, 0, 0);
- if (SWIG_IsOK(res)) {
- if (ptr) {
- *ptr = vptr;
- /* transfer the ownership to 'ptr' */
- iobj->own = 0;
- res = SWIG_AddCast(res);
- res = SWIG_AddNewMask(res);
- } else {
- res = SWIG_AddCast(res);
- }
- }
- }
- Py_DECREF(impconv);
- }
- }
- }
- }
- return res;
- }
- }
-}
-
-/* Convert a function ptr value */
-
-SWIGRUNTIME int
-SWIG_Python_ConvertFunctionPtr(PyObject *obj, void **ptr, swig_type_info *ty) {
- if (!PyCFunction_Check(obj)) {
- return SWIG_ConvertPtr(obj, ptr, ty, 0);
- } else {
- void *vptr = 0;
-
- /* here we get the method pointer for callbacks */
- const char *doc = (((PyCFunctionObject *)obj) -> m_ml -> ml_doc);
- const char *desc = doc ? strstr(doc, "swig_ptr: ") : 0;
- if (desc) {
- desc = ty ? SWIG_UnpackVoidPtr(desc + 10, &vptr, ty->name) : 0;
- if (!desc) return SWIG_ERROR;
- }
- if (ty) {
- swig_cast_info *tc = SWIG_TypeCheck(desc,ty);
- 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;
- }
- return SWIG_OK;
- }
-}
-
-/* Convert a packed value value */
-
-SWIGRUNTIME int
-SWIG_Python_ConvertPacked(PyObject *obj, void *ptr, size_t sz, swig_type_info *ty) {
- swig_type_info *to = PySwigPacked_UnpackData(obj, ptr, sz);
- if (!to) return SWIG_ERROR;
- if (ty) {
- if (to != ty) {
- /* check type cast? */
- swig_cast_info *tc = SWIG_TypeCheck(to->name,ty);
- if (!tc) return SWIG_ERROR;
- }
- }
- return SWIG_OK;
-}
-
-/* -----------------------------------------------------------------------------
- * Create a new pointer object
- * ----------------------------------------------------------------------------- */
-
-/*
- Create a new instance object, whitout calling __init__, and set the
- 'this' attribute.
-*/
-
-SWIGRUNTIME PyObject*
-SWIG_Python_NewShadowInstance(PySwigClientData *data, PyObject *swig_this)
-{
-#if (PY_VERSION_HEX >= 0x02020000)
- PyObject *inst = 0;
- PyObject *newraw = data->newraw;
- if (newraw) {
- inst = PyObject_Call(newraw, data->newargs, NULL);
- if (inst) {
-#if !defined(SWIG_PYTHON_SLOW_GETSET_THIS)
- PyObject **dictptr = _PyObject_GetDictPtr(inst);
- if (dictptr != NULL) {
- PyObject *dict = *dictptr;
- if (dict == NULL) {
- dict = PyDict_New();
- *dictptr = dict;
- PyDict_SetItem(dict, SWIG_This(), swig_this);
- }
- }
-#else
- PyObject *key = SWIG_This();
- PyObject_SetAttr(inst, key, swig_this);
-#endif
- }
- } else {
- PyObject *dict = PyDict_New();
- PyDict_SetItem(dict, SWIG_This(), swig_this);
- inst = PyInstance_NewRaw(data->newargs, dict);
- Py_DECREF(dict);
- }
- return inst;
-#else
-#if (PY_VERSION_HEX >= 0x02010000)
- PyObject *inst;
- PyObject *dict = PyDict_New();
- PyDict_SetItem(dict, SWIG_This(), swig_this);
- inst = PyInstance_NewRaw(data->newargs, dict);
- Py_DECREF(dict);
- return (PyObject *) inst;
-#else
- PyInstanceObject *inst = PyObject_NEW(PyInstanceObject, &PyInstance_Type);
- if (inst == NULL) {
- return NULL;
- }
- inst->in_class = (PyClassObject *)data->newargs;
- Py_INCREF(inst->in_class);
- inst->in_dict = PyDict_New();
- if (inst->in_dict == NULL) {
- Py_DECREF(inst);
- return NULL;
- }
-#ifdef Py_TPFLAGS_HAVE_WEAKREFS
- inst->in_weakreflist = NULL;
-#endif
-#ifdef Py_TPFLAGS_GC
- PyObject_GC_Init(inst);
-#endif
- PyDict_SetItem(inst->in_dict, SWIG_This(), swig_this);
- return (PyObject *) inst;
-#endif
-#endif
-}
-
-SWIGRUNTIME void
-SWIG_Python_SetSwigThis(PyObject *inst, PyObject *swig_this)
-{
- PyObject *dict;
-#if (PY_VERSION_HEX >= 0x02020000) && !defined(SWIG_PYTHON_SLOW_GETSET_THIS)
- PyObject **dictptr = _PyObject_GetDictPtr(inst);
- if (dictptr != NULL) {
- dict = *dictptr;
- if (dict == NULL) {
- dict = PyDict_New();
- *dictptr = dict;
- }
- PyDict_SetItem(dict, SWIG_This(), swig_this);
- return;
- }
-#endif
- dict = PyObject_GetAttrString(inst, (char*)"__dict__");
- PyDict_SetItem(dict, SWIG_This(), swig_this);
- Py_DECREF(dict);
-}
-
-
-SWIGINTERN PyObject *
-SWIG_Python_InitShadowInstance(PyObject *args) {
- PyObject *obj[2];
- if (!SWIG_Python_UnpackTuple(args,(char*)"swiginit", 2, 2, obj)) {
- return NULL;
- } else {
- PySwigObject *sthis = SWIG_Python_GetSwigThis(obj[0]);
- if (sthis) {
- PySwigObject_append((PyObject*) sthis, obj[1]);
- } else {
- SWIG_Python_SetSwigThis(obj[0], obj[1]);
- }
- return SWIG_Py_Void();
- }
-}
-
-/* Create a new pointer object */
-
-SWIGRUNTIME PyObject *
-SWIG_Python_NewPointerObj(void *ptr, swig_type_info *type, int flags) {
- if (!ptr) {
- return SWIG_Py_Void();
- } else {
- int own = (flags & SWIG_POINTER_OWN) ? SWIG_POINTER_OWN : 0;
- PyObject *robj = PySwigObject_New(ptr, type, own);
- PySwigClientData *clientdata = type ? (PySwigClientData *)(type->clientdata) : 0;
- if (clientdata && !(flags & SWIG_POINTER_NOSHADOW)) {
- PyObject *inst = SWIG_Python_NewShadowInstance(clientdata, robj);
- if (inst) {
- Py_DECREF(robj);
- robj = inst;
- }
- }
- return robj;
- }
-}
-
-/* Create a new packed object */
-
-SWIGRUNTIMEINLINE PyObject *
-SWIG_Python_NewPackedObj(void *ptr, size_t sz, swig_type_info *type) {
- return ptr ? PySwigPacked_New((void *) ptr, sz, type) : SWIG_Py_Void();
-}
-
-/* -----------------------------------------------------------------------------*
- * Get type list
- * -----------------------------------------------------------------------------*/
-
-#ifdef SWIG_LINK_RUNTIME
-void *SWIG_ReturnGlobalTypeList(void *);
-#endif
-
-SWIGRUNTIME swig_module_info *
-SWIG_Python_GetModule(void) {
- static void *type_pointer = (void *)0;
- /* first check if module already created */
- if (!type_pointer) {
-#ifdef SWIG_LINK_RUNTIME
- type_pointer = SWIG_ReturnGlobalTypeList((void *)0);
-#else
- type_pointer = PyCObject_Import((char*)"swig_runtime_data" SWIG_RUNTIME_VERSION,
- (char*)"type_pointer" SWIG_TYPE_TABLE_NAME);
- if (PyErr_Occurred()) {
- PyErr_Clear();
- type_pointer = (void *)0;
- }
-#endif
- }
- return (swig_module_info *) type_pointer;
-}
-
-#if PY_MAJOR_VERSION < 2
-/* PyModule_AddObject function was introduced in Python 2.0. The following function
- is copied out of Python/modsupport.c in python version 2.3.4 */
-SWIGINTERN int
-PyModule_AddObject(PyObject *m, char *name, PyObject *o)
-{
- PyObject *dict;
- if (!PyModule_Check(m)) {
- PyErr_SetString(PyExc_TypeError,
- "PyModule_AddObject() needs module as first arg");
- return SWIG_ERROR;
- }
- if (!o) {
- PyErr_SetString(PyExc_TypeError,
- "PyModule_AddObject() needs non-NULL value");
- return SWIG_ERROR;
- }
-
- dict = PyModule_GetDict(m);
- if (dict == NULL) {
- /* Internal error -- modules must have a dict! */
- PyErr_Format(PyExc_SystemError, "module '%s' has no __dict__",
- PyModule_GetName(m));
- return SWIG_ERROR;
- }
- if (PyDict_SetItemString(dict, name, o))
- return SWIG_ERROR;
- Py_DECREF(o);
- return SWIG_OK;
-}
-#endif
-
-SWIGRUNTIME void
-SWIG_Python_DestroyModule(void *vptr)
-{
- swig_module_info *swig_module = (swig_module_info *) vptr;
- swig_type_info **types = swig_module->types;
- size_t i;
- for (i =0; i < swig_module->size; ++i) {
- swig_type_info *ty = types[i];
- if (ty->owndata) {
- PySwigClientData *data = (PySwigClientData *) ty->clientdata;
- if (data) PySwigClientData_Del(data);
- }
- }
- Py_DECREF(SWIG_This());
-}
-
-SWIGRUNTIME void
-SWIG_Python_SetModule(swig_module_info *swig_module) {
- static PyMethodDef swig_empty_runtime_method_table[] = { {NULL, NULL, 0, NULL} };/* Sentinel */
-
- PyObject *module = Py_InitModule((char*)"swig_runtime_data" SWIG_RUNTIME_VERSION,
- swig_empty_runtime_method_table);
- PyObject *pointer = PyCObject_FromVoidPtr((void *) swig_module, SWIG_Python_DestroyModule);
- if (pointer && module) {
- PyModule_AddObject(module, (char*)"type_pointer" SWIG_TYPE_TABLE_NAME, pointer);
- } else {
- Py_XDECREF(pointer);
- }
-}
-
-/* The python cached type query */
-SWIGRUNTIME PyObject *
-SWIG_Python_TypeCache(void) {
- static PyObject *SWIG_STATIC_POINTER(cache) = PyDict_New();
- return cache;
-}
-
-SWIGRUNTIME swig_type_info *
-SWIG_Python_TypeQuery(const char *type)
-{
- PyObject *cache = SWIG_Python_TypeCache();
- PyObject *key = PyString_FromString(type);
- PyObject *obj = PyDict_GetItem(cache, key);
- swig_type_info *descriptor;
- if (obj) {
- descriptor = (swig_type_info *) PyCObject_AsVoidPtr(obj);
- } else {
- swig_module_info *swig_module = SWIG_Python_GetModule();
- descriptor = SWIG_TypeQueryModule(swig_module, swig_module, type);
- if (descriptor) {
- obj = PyCObject_FromVoidPtr(descriptor, NULL);
- PyDict_SetItem(cache, key, obj);
- Py_DECREF(obj);
- }
- }
- Py_DECREF(key);
- return descriptor;
-}
-
-/*
- For backward compatibility only
-*/
-#define SWIG_POINTER_EXCEPTION 0
-#define SWIG_arg_fail(arg) SWIG_Python_ArgFail(arg)
-#define SWIG_MustGetPtr(p, type, argnum, flags) SWIG_Python_MustGetPtr(p, type, argnum, flags)
-
-SWIGRUNTIME int
-SWIG_Python_AddErrMesg(const char* mesg, int infront)
-{
- if (PyErr_Occurred()) {
- PyObject *type = 0;
- PyObject *value = 0;
- PyObject *traceback = 0;
- PyErr_Fetch(&type, &value, &traceback);
- if (value) {
- PyObject *old_str = PyObject_Str(value);
- Py_XINCREF(type);
- PyErr_Clear();
- if (infront) {
- PyErr_Format(type, "%s %s", mesg, PyString_AsString(old_str));
- } else {
- PyErr_Format(type, "%s %s", PyString_AsString(old_str), mesg);
- }
- Py_DECREF(old_str);
- }
- return 1;
- } else {
- return 0;
- }
-}
-
-SWIGRUNTIME int
-SWIG_Python_ArgFail(int argnum)
-{
- if (PyErr_Occurred()) {
- /* add information about failing argument */
- char mesg[256];
- PyOS_snprintf(mesg, sizeof(mesg), "argument number %d:", argnum);
- return SWIG_Python_AddErrMesg(mesg, 1);
- } else {
- return 0;
- }
-}
-
-SWIGRUNTIMEINLINE const char *
-PySwigObject_GetDesc(PyObject *self)
-{
- PySwigObject *v = (PySwigObject *)self;
- swig_type_info *ty = v ? v->ty : 0;
- return ty ? ty->str : (char*)"";
-}
-
-SWIGRUNTIME void
-SWIG_Python_TypeError(const char *type, PyObject *obj)
-{
- if (type) {
-#if defined(SWIG_COBJECT_TYPES)
- if (obj && PySwigObject_Check(obj)) {
- const char *otype = (const char *) PySwigObject_GetDesc(obj);
- if (otype) {
- PyErr_Format(PyExc_TypeError, "a '%s' is expected, 'PySwigObject(%s)' is received",
- type, otype);
- return;
- }
- } else
-#endif
- {
- const char *otype = (obj ? obj->ob_type->tp_name : 0);
- if (otype) {
- PyObject *str = PyObject_Str(obj);
- const char *cstr = str ? PyString_AsString(str) : 0;
- if (cstr) {
- PyErr_Format(PyExc_TypeError, "a '%s' is expected, '%s(%s)' is received",
- type, otype, cstr);
- } else {
- PyErr_Format(PyExc_TypeError, "a '%s' is expected, '%s' is received",
- type, otype);
- }
- Py_XDECREF(str);
- return;
- }
- }
- PyErr_Format(PyExc_TypeError, "a '%s' is expected", type);
- } else {
- PyErr_Format(PyExc_TypeError, "unexpected type is received");
- }
-}
-
-
-/* Convert a pointer value, signal an exception on a type mismatch */
-SWIGRUNTIME void *
-SWIG_Python_MustGetPtr(PyObject *obj, swig_type_info *ty, int argnum, int flags) {
- void *result;
- if (SWIG_Python_ConvertPtr(obj, &result, ty, flags) == -1) {
- PyErr_Clear();
- if (flags & SWIG_POINTER_EXCEPTION) {
- SWIG_Python_TypeError(SWIG_TypePrettyName(ty), obj);
- SWIG_Python_ArgFail(argnum);
- }
- }
- return result;
-}
-
-
-#ifdef __cplusplus
-#if 0
-{ /* cc-mode */
-#endif
-}
-#endif
-
-
-
-#define SWIG_exception_fail(code, msg) do { SWIG_Error(code, msg); SWIG_fail; } while(0)
-
-#define SWIG_contract_assert(expr, msg) if (!(expr)) { SWIG_Error(SWIG_RuntimeError, msg); SWIG_fail; } else
-
-
-
-/* -------- TYPES TABLE (BEGIN) -------- */
-
-#define SWIGTYPE_p_NTSTATUS swig_types[0]
-#define SWIGTYPE_p_TALLOC_CTX swig_types[1]
-#define SWIGTYPE_p_char swig_types[2]
-#define SWIGTYPE_p_cli_credentials swig_types[3]
-#define SWIGTYPE_p_dcerpc_pipe swig_types[4]
-#define SWIGTYPE_p_event_context swig_types[5]
-#define SWIGTYPE_p_int swig_types[6]
-#define SWIGTYPE_p_loadparm_context swig_types[7]
-#define SWIGTYPE_p_loadparm_service swig_types[8]
-#define SWIGTYPE_p_long_long swig_types[9]
-#define SWIGTYPE_p_ndr_interface_table swig_types[10]
-#define SWIGTYPE_p_p_dcerpc_pipe swig_types[11]
-#define SWIGTYPE_p_param_context swig_types[12]
-#define SWIGTYPE_p_param_opt swig_types[13]
-#define SWIGTYPE_p_param_section swig_types[14]
-#define SWIGTYPE_p_short swig_types[15]
-#define SWIGTYPE_p_signed_char swig_types[16]
-#define SWIGTYPE_p_unsigned_char swig_types[17]
-#define SWIGTYPE_p_unsigned_int swig_types[18]
-#define SWIGTYPE_p_unsigned_long_long swig_types[19]
-#define SWIGTYPE_p_unsigned_short swig_types[20]
-static swig_type_info *swig_types[22];
-static swig_module_info swig_module = {swig_types, 21, 0, 0, 0, 0};
-#define SWIG_TypeQuery(name) SWIG_TypeQueryModule(&swig_module, &swig_module, name)
-#define SWIG_MangledTypeQuery(name) SWIG_MangledTypeQueryModule(&swig_module, &swig_module, name)
-
-/* -------- TYPES TABLE (END) -------- */
-
-#if (PY_VERSION_HEX <= 0x02000000)
-# if !defined(SWIG_PYTHON_CLASSIC)
-# error "This python version requires swig to be run with the '-classic' option"
-# endif
-#endif
-#if (PY_VERSION_HEX <= 0x02020000)
-# error "This python version requires swig to be run with the '-nomodern' option"
-#endif
-#if (PY_VERSION_HEX <= 0x02020000)
-# error "This python version requires swig to be run with the '-nomodernargs' option"
-#endif
-#ifndef METH_O
-# error "This python version requires swig to be run with the '-nofastunpack' option"
-#endif
-#ifdef SWIG_TypeQuery
-# undef SWIG_TypeQuery
-#endif
-#define SWIG_TypeQuery SWIG_Python_TypeQuery
-
-/*-----------------------------------------------
- @(target):= _dcerpc.so
- ------------------------------------------------*/
-#define SWIG_init init_dcerpc
-
-#define SWIG_name "_dcerpc"
-
-#define SWIGVERSION 0x010335
-#define SWIG_VERSION SWIGVERSION
-
-
-#define SWIG_as_voidptr(a) (void *)((const void *)(a))
-#define SWIG_as_voidptrptr(a) ((void)SWIG_as_voidptr(*a),(void**)(a))
-
-
-
-/* This symbol is used in both includes.h and Python.h which causes an
- annoying compiler warning. */
-
-#ifdef HAVE_FSTAT
-#undef HAVE_FSTAT
-#endif
-
-#include "includes.h"
-#include "dynconfig.h"
-#include "librpc/rpc/dcerpc.h"
-#include "param/param.h"
-
-#undef strcpy
-
-
-
-SWIGINTERN swig_type_info*
-SWIG_pchar_descriptor(void)
-{
- static int init = 0;
- static swig_type_info* info = 0;
- if (!init) {
- info = SWIG_TypeQuery("_p_char");
- init = 1;
- }
- return info;
-}
-
-
-SWIGINTERN int
-SWIG_AsCharPtrAndSize(PyObject *obj, char** cptr, size_t* psize, int *alloc)
-{
- if (PyString_Check(obj)) {
- char *cstr; Py_ssize_t len;
- PyString_AsStringAndSize(obj, &cstr, &len);
- if (cptr) {
- if (alloc) {
- /*
- In python the user should not be able to modify the inner
- string representation. To warranty that, if you define
- SWIG_PYTHON_SAFE_CSTRINGS, a new/copy of the python string
- buffer is always returned.
-
- The default behavior is just to return the pointer value,
- so, be careful.
- */
-#if defined(SWIG_PYTHON_SAFE_CSTRINGS)
- if (*alloc != SWIG_OLDOBJ)
-#else
- if (*alloc == SWIG_NEWOBJ)
-#endif
- {
- *cptr = (char *)memcpy((char *)malloc((len + 1)*sizeof(char)), cstr, sizeof(char)*(len + 1));
- *alloc = SWIG_NEWOBJ;
- }
- else {
- *cptr = cstr;
- *alloc = SWIG_OLDOBJ;
- }
- } else {
- *cptr = PyString_AsString(obj);
- }
- }
- if (psize) *psize = len + 1;
- return SWIG_OK;
- } else {
- swig_type_info* pchar_descriptor = SWIG_pchar_descriptor();
- if (pchar_descriptor) {
- void* vptr = 0;
- if (SWIG_ConvertPtr(obj, &vptr, pchar_descriptor, 0) == SWIG_OK) {
- if (cptr) *cptr = (char *) vptr;
- if (psize) *psize = vptr ? (strlen((char *)vptr) + 1) : 0;
- if (alloc) *alloc = SWIG_OLDOBJ;
- return SWIG_OK;
- }
- }
- }
- return SWIG_TypeError;
-}
-
-
-
-
-
-SWIGINTERNINLINE PyObject *
-SWIG_FromCharPtrAndSize(const char* carray, size_t size)
-{
- if (carray) {
- if (size > INT_MAX) {
- swig_type_info* pchar_descriptor = SWIG_pchar_descriptor();
- return pchar_descriptor ?
- SWIG_NewPointerObj((char *)(carray), pchar_descriptor, 0) : SWIG_Py_Void();
- } else {
- return PyString_FromStringAndSize(carray, (int)(size));
- }
- } else {
- return SWIG_Py_Void();
- }
-}
-
-
-SWIGINTERNINLINE PyObject *
-SWIG_FromCharPtr(const char *cptr)
-{
- return SWIG_FromCharPtrAndSize(cptr, (cptr ? strlen(cptr) : 0));
-}
-
-#ifdef __cplusplus
-extern "C" {
-#endif
-SWIGINTERN PyObject *_wrap_pipe_connect(PyObject *SWIGUNUSEDPARM(self), PyObject *args, PyObject *kwargs) {
- PyObject *resultobj = 0;
- TALLOC_CTX *arg1 = (TALLOC_CTX *) 0 ;
- struct dcerpc_pipe **arg2 = (struct dcerpc_pipe **) 0 ;
- char *arg3 = (char *) 0 ;
- struct ndr_interface_table *arg4 = (struct ndr_interface_table *) 0 ;
- struct cli_credentials *arg5 = (struct cli_credentials *) 0 ;
- struct event_context *arg6 = (struct event_context *) 0 ;
- struct loadparm_context *arg7 = (struct loadparm_context *) 0 ;
- NTSTATUS result;
- void *argp2 = 0 ;
- int res2 = 0 ;
- int res3 ;
- char *buf3 = 0 ;
- int alloc3 = 0 ;
- void *argp4 = 0 ;
- int res4 = 0 ;
- void *argp5 = 0 ;
- int res5 = 0 ;
- void *argp6 = 0 ;
- int res6 = 0 ;
- void *argp7 = 0 ;
- int res7 = 0 ;
- PyObject * obj0 = 0 ;
- PyObject * obj1 = 0 ;
- PyObject * obj2 = 0 ;
- PyObject * obj3 = 0 ;
- PyObject * obj4 = 0 ;
- PyObject * obj5 = 0 ;
- char * kwnames[] = {
- (char *) "pp",(char *) "binding",(char *) "table",(char *) "credentials",(char *) "ev",(char *) "lp_ctx", NULL
- };
-
- arg5 = NULL;
- arg7 = loadparm_init(NULL);
- arg1 = NULL;
- if (!PyArg_ParseTupleAndKeywords(args,kwargs,(char *)"OOO|OOO:pipe_connect",kwnames,&obj0,&obj1,&obj2,&obj3,&obj4,&obj5)) SWIG_fail;
- res2 = SWIG_ConvertPtr(obj0, &argp2,SWIGTYPE_p_p_dcerpc_pipe, 0 | 0 );
- if (!SWIG_IsOK(res2)) {
- SWIG_exception_fail(SWIG_ArgError(res2), "in method '" "pipe_connect" "', argument " "2"" of type '" "struct dcerpc_pipe **""'");
- }
- arg2 = (struct dcerpc_pipe **)(argp2);
- res3 = SWIG_AsCharPtrAndSize(obj1, &buf3, NULL, &alloc3);
- if (!SWIG_IsOK(res3)) {
- SWIG_exception_fail(SWIG_ArgError(res3), "in method '" "pipe_connect" "', argument " "3"" of type '" "char const *""'");
- }
- arg3 = (char *)(buf3);
- res4 = SWIG_ConvertPtr(obj2, &argp4,SWIGTYPE_p_ndr_interface_table, 0 | 0 );
- if (!SWIG_IsOK(res4)) {
- SWIG_exception_fail(SWIG_ArgError(res4), "in method '" "pipe_connect" "', argument " "4"" of type '" "struct ndr_interface_table const *""'");
- }
- arg4 = (struct ndr_interface_table *)(argp4);
- if (obj3) {
- res5 = SWIG_ConvertPtr(obj3, &argp5,SWIGTYPE_p_cli_credentials, 0 | 0 );
- if (!SWIG_IsOK(res5)) {
- SWIG_exception_fail(SWIG_ArgError(res5), "in method '" "pipe_connect" "', argument " "5"" of type '" "struct cli_credentials *""'");
- }
- arg5 = (struct cli_credentials *)(argp5);
- }
- if (obj4) {
- res6 = SWIG_ConvertPtr(obj4, &argp6,SWIGTYPE_p_event_context, 0 | 0 );
- if (!SWIG_IsOK(res6)) {
- SWIG_exception_fail(SWIG_ArgError(res6), "in method '" "pipe_connect" "', argument " "6"" of type '" "struct event_context *""'");
- }
- arg6 = (struct event_context *)(argp6);
- }
- if (obj5) {
- res7 = SWIG_ConvertPtr(obj5, &argp7,SWIGTYPE_p_loadparm_context, 0 | 0 );
- if (!SWIG_IsOK(res7)) {
- SWIG_exception_fail(SWIG_ArgError(res7), "in method '" "pipe_connect" "', argument " "7"" of type '" "struct loadparm_context *""'");
- }
- arg7 = (struct loadparm_context *)(argp7);
- }
- result = dcerpc_pipe_connect(arg1,arg2,(char const *)arg3,(struct ndr_interface_table const *)arg4,arg5,arg6,arg7);
- resultobj = SWIG_NewPointerObj((NTSTATUS *)memcpy((NTSTATUS *)malloc(sizeof(NTSTATUS)),&result,sizeof(NTSTATUS)), SWIGTYPE_p_NTSTATUS, SWIG_POINTER_OWN | 0 );
- /* Set REF_ALLOC flag so we don't have to do too much extra
- mucking around with ref variables in ndr unmarshalling. */
-
- (*arg2)->conn->flags |= DCERPC_NDR_REF_ALLOC;
-
- /* Return swig handle on dcerpc_pipe */
-
- resultobj = SWIG_NewPointerObj(*arg2, SWIGTYPE_p_dcerpc_pipe, 0);
- if (alloc3 == SWIG_NEWOBJ) free((char*)buf3);
- return resultobj;
-fail:
- if (alloc3 == SWIG_NEWOBJ) free((char*)buf3);
- return NULL;
-}
-
-
-SWIGINTERN PyObject *_wrap_dcerpc_server_name(PyObject *SWIGUNUSEDPARM(self), PyObject *args, PyObject *kwargs) {
- PyObject *resultobj = 0;
- struct dcerpc_pipe *arg1 = (struct dcerpc_pipe *) 0 ;
- char *result = 0 ;
- void *argp1 = 0 ;
- int res1 = 0 ;
- PyObject * obj0 = 0 ;
- char * kwnames[] = {
- (char *) "p", NULL
- };
-
- if (!PyArg_ParseTupleAndKeywords(args,kwargs,(char *)"O:dcerpc_server_name",kwnames,&obj0)) SWIG_fail;
- res1 = SWIG_ConvertPtr(obj0, &argp1,SWIGTYPE_p_dcerpc_pipe, 0 | 0 );
- if (!SWIG_IsOK(res1)) {
- SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "dcerpc_server_name" "', argument " "1"" of type '" "struct dcerpc_pipe *""'");
- }
- arg1 = (struct dcerpc_pipe *)(argp1);
- result = (char *)dcerpc_server_name(arg1);
- resultobj = SWIG_FromCharPtr((const char *)result);
- return resultobj;
-fail:
- return NULL;
-}
-
-
-static PyMethodDef SwigMethods[] = {
- { (char *)"pipe_connect", (PyCFunction) _wrap_pipe_connect, METH_VARARGS | METH_KEYWORDS, NULL},
- { (char *)"dcerpc_server_name", (PyCFunction) _wrap_dcerpc_server_name, METH_VARARGS | METH_KEYWORDS, NULL},
- { NULL, NULL, 0, NULL }
-};
-
-
-/* -------- TYPE CONVERSION AND EQUIVALENCE RULES (BEGIN) -------- */
-
-static swig_type_info _swigt__p_NTSTATUS = {"_p_NTSTATUS", "NTSTATUS *", 0, 0, (void*)0, 0};
-static swig_type_info _swigt__p_TALLOC_CTX = {"_p_TALLOC_CTX", "TALLOC_CTX *", 0, 0, (void*)0, 0};
-static swig_type_info _swigt__p_char = {"_p_char", "char *", 0, 0, (void*)0, 0};
-static swig_type_info _swigt__p_cli_credentials = {"_p_cli_credentials", "struct cli_credentials *|cli_credentials *", 0, 0, (void*)0, 0};
-static swig_type_info _swigt__p_dcerpc_pipe = {"_p_dcerpc_pipe", "struct dcerpc_pipe *", 0, 0, (void*)0, 0};
-static swig_type_info _swigt__p_event_context = {"_p_event_context", "struct event_context *", 0, 0, (void*)0, 0};
-static swig_type_info _swigt__p_int = {"_p_int", "intptr_t *|int *|int_least32_t *|int_fast32_t *|int32_t *|int_fast16_t *", 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};
-static swig_type_info _swigt__p_long_long = {"_p_long_long", "int_least64_t *|int_fast64_t *|int64_t *|long long *|intmax_t *", 0, 0, (void*)0, 0};
-static swig_type_info _swigt__p_ndr_interface_table = {"_p_ndr_interface_table", "struct ndr_interface_table *", 0, 0, (void*)0, 0};
-static swig_type_info _swigt__p_p_dcerpc_pipe = {"_p_p_dcerpc_pipe", "struct dcerpc_pipe **", 0, 0, (void*)0, 0};
-static swig_type_info _swigt__p_param_context = {"_p_param_context", "struct param_context *|param *", 0, 0, (void*)0, 0};
-static swig_type_info _swigt__p_param_opt = {"_p_param_opt", "struct param_opt *|param_opt *", 0, 0, (void*)0, 0};
-static swig_type_info _swigt__p_param_section = {"_p_param_section", "struct param_section *|param_section *", 0, 0, (void*)0, 0};
-static swig_type_info _swigt__p_short = {"_p_short", "short *|int_least16_t *|int16_t *", 0, 0, (void*)0, 0};
-static swig_type_info _swigt__p_signed_char = {"_p_signed_char", "signed char *|int_least8_t *|int_fast8_t *|int8_t *", 0, 0, (void*)0, 0};
-static swig_type_info _swigt__p_unsigned_char = {"_p_unsigned_char", "unsigned char *|uint_least8_t *|uint_fast8_t *|uint8_t *", 0, 0, (void*)0, 0};
-static swig_type_info _swigt__p_unsigned_int = {"_p_unsigned_int", "uintptr_t *|uint_least32_t *|uint_fast32_t *|uint32_t *|unsigned int *|uint_fast16_t *", 0, 0, (void*)0, 0};
-static swig_type_info _swigt__p_unsigned_long_long = {"_p_unsigned_long_long", "uint_least64_t *|uint_fast64_t *|uint64_t *|unsigned long long *|uintmax_t *", 0, 0, (void*)0, 0};
-static swig_type_info _swigt__p_unsigned_short = {"_p_unsigned_short", "unsigned short *|uint_least16_t *|uint16_t *", 0, 0, (void*)0, 0};
-
-static swig_type_info *swig_type_initial[] = {
- &_swigt__p_NTSTATUS,
- &_swigt__p_TALLOC_CTX,
- &_swigt__p_char,
- &_swigt__p_cli_credentials,
- &_swigt__p_dcerpc_pipe,
- &_swigt__p_event_context,
- &_swigt__p_int,
- &_swigt__p_loadparm_context,
- &_swigt__p_loadparm_service,
- &_swigt__p_long_long,
- &_swigt__p_ndr_interface_table,
- &_swigt__p_p_dcerpc_pipe,
- &_swigt__p_param_context,
- &_swigt__p_param_opt,
- &_swigt__p_param_section,
- &_swigt__p_short,
- &_swigt__p_signed_char,
- &_swigt__p_unsigned_char,
- &_swigt__p_unsigned_int,
- &_swigt__p_unsigned_long_long,
- &_swigt__p_unsigned_short,
-};
-
-static swig_cast_info _swigc__p_NTSTATUS[] = { {&_swigt__p_NTSTATUS, 0, 0, 0},{0, 0, 0, 0}};
-static swig_cast_info _swigc__p_TALLOC_CTX[] = { {&_swigt__p_TALLOC_CTX, 0, 0, 0},{0, 0, 0, 0}};
-static swig_cast_info _swigc__p_char[] = { {&_swigt__p_char, 0, 0, 0},{0, 0, 0, 0}};
-static swig_cast_info _swigc__p_cli_credentials[] = { {&_swigt__p_cli_credentials, 0, 0, 0},{0, 0, 0, 0}};
-static swig_cast_info _swigc__p_dcerpc_pipe[] = { {&_swigt__p_dcerpc_pipe, 0, 0, 0},{0, 0, 0, 0}};
-static swig_cast_info _swigc__p_event_context[] = { {&_swigt__p_event_context, 0, 0, 0},{0, 0, 0, 0}};
-static swig_cast_info _swigc__p_int[] = { {&_swigt__p_int, 0, 0, 0},{0, 0, 0, 0}};
-static swig_cast_info _swigc__p_loadparm_context[] = { {&_swigt__p_loadparm_context, 0, 0, 0},{0, 0, 0, 0}};
-static swig_cast_info _swigc__p_loadparm_service[] = { {&_swigt__p_loadparm_service, 0, 0, 0},{0, 0, 0, 0}};
-static swig_cast_info _swigc__p_long_long[] = { {&_swigt__p_long_long, 0, 0, 0},{0, 0, 0, 0}};
-static swig_cast_info _swigc__p_ndr_interface_table[] = { {&_swigt__p_ndr_interface_table, 0, 0, 0},{0, 0, 0, 0}};
-static swig_cast_info _swigc__p_p_dcerpc_pipe[] = { {&_swigt__p_p_dcerpc_pipe, 0, 0, 0},{0, 0, 0, 0}};
-static swig_cast_info _swigc__p_param_context[] = { {&_swigt__p_param_context, 0, 0, 0},{0, 0, 0, 0}};
-static swig_cast_info _swigc__p_param_opt[] = { {&_swigt__p_param_opt, 0, 0, 0},{0, 0, 0, 0}};
-static swig_cast_info _swigc__p_param_section[] = { {&_swigt__p_param_section, 0, 0, 0},{0, 0, 0, 0}};
-static swig_cast_info _swigc__p_short[] = { {&_swigt__p_short, 0, 0, 0},{0, 0, 0, 0}};
-static swig_cast_info _swigc__p_signed_char[] = { {&_swigt__p_signed_char, 0, 0, 0},{0, 0, 0, 0}};
-static swig_cast_info _swigc__p_unsigned_char[] = { {&_swigt__p_unsigned_char, 0, 0, 0},{0, 0, 0, 0}};
-static swig_cast_info _swigc__p_unsigned_int[] = { {&_swigt__p_unsigned_int, 0, 0, 0},{0, 0, 0, 0}};
-static swig_cast_info _swigc__p_unsigned_long_long[] = { {&_swigt__p_unsigned_long_long, 0, 0, 0},{0, 0, 0, 0}};
-static swig_cast_info _swigc__p_unsigned_short[] = { {&_swigt__p_unsigned_short, 0, 0, 0},{0, 0, 0, 0}};
-
-static swig_cast_info *swig_cast_initial[] = {
- _swigc__p_NTSTATUS,
- _swigc__p_TALLOC_CTX,
- _swigc__p_char,
- _swigc__p_cli_credentials,
- _swigc__p_dcerpc_pipe,
- _swigc__p_event_context,
- _swigc__p_int,
- _swigc__p_loadparm_context,
- _swigc__p_loadparm_service,
- _swigc__p_long_long,
- _swigc__p_ndr_interface_table,
- _swigc__p_p_dcerpc_pipe,
- _swigc__p_param_context,
- _swigc__p_param_opt,
- _swigc__p_param_section,
- _swigc__p_short,
- _swigc__p_signed_char,
- _swigc__p_unsigned_char,
- _swigc__p_unsigned_int,
- _swigc__p_unsigned_long_long,
- _swigc__p_unsigned_short,
-};
-
-
-/* -------- TYPE CONVERSION AND EQUIVALENCE RULES (END) -------- */
-
-static swig_const_info swig_const_table[] = {
-{0, 0, 0, 0.0, 0, 0}};
-
-#ifdef __cplusplus
-}
-#endif
-/* -----------------------------------------------------------------------------
- * Type initialization:
- * This problem is tough by the requirement that no dynamic
- * memory is used. Also, since swig_type_info structures store pointers to
- * swig_cast_info structures and swig_cast_info structures store pointers back
- * to swig_type_info structures, we need some lookup code at initialization.
- * The idea is that swig generates all the structures that are needed.
- * The runtime then collects these partially filled structures.
- * The SWIG_InitializeModule function takes these initial arrays out of
- * swig_module, and does all the lookup, filling in the swig_module.types
- * array with the correct data and linking the correct swig_cast_info
- * structures together.
- *
- * The generated swig_type_info structures are assigned staticly to an initial
- * array. We just loop through that array, and handle each type individually.
- * First we lookup if this type has been already loaded, and if so, use the
- * loaded structure instead of the generated one. Then we have to fill in the
- * cast linked list. The cast data is initially stored in something like a
- * two-dimensional array. Each row corresponds to a type (there are the same
- * number of rows as there are in the swig_type_initial array). Each entry in
- * a column is one of the swig_cast_info structures for that type.
- * The cast_initial array is actually an array of arrays, because each row has
- * a variable number of columns. So to actually build the cast linked list,
- * we find the array of casts associated with the type, and loop through it
- * adding the casts to the list. The one last trick we need to do is making
- * sure the type pointer in the swig_cast_info struct is correct.
- *
- * First off, we lookup the cast->type name to see if it is already loaded.
- * There are three cases to handle:
- * 1) If the cast->type has already been loaded AND the type we are adding
- * casting info to has not been loaded (it is in this module), THEN we
- * replace the cast->type pointer with the type pointer that has already
- * been loaded.
- * 2) If BOTH types (the one we are adding casting info to, and the
- * cast->type) are loaded, THEN the cast info has already been loaded by
- * the previous module so we just ignore it.
- * 3) Finally, if cast->type has not already been loaded, then we add that
- * swig_cast_info to the linked list (because the cast->type) pointer will
- * be correct.
- * ----------------------------------------------------------------------------- */
-
-#ifdef __cplusplus
-extern "C" {
-#if 0
-} /* c-mode */
-#endif
-#endif
-
-#if 0
-#define SWIGRUNTIME_DEBUG
-#endif
-
-
-SWIGRUNTIME void
-SWIG_InitializeModule(void *clientdata) {
- size_t i;
- swig_module_info *module_head, *iter;
- int found, init;
-
- clientdata = clientdata;
-
- /* check to see if the circular list has been setup, if not, set it up */
- if (swig_module.next==0) {
- /* Initialize the swig_module */
- 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 */
- module_head = SWIG_GetModule(clientdata);
- if (!module_head) {
- /* This is the first module loaded for this interpreter */
- /* so set the swig module into the interpreter */
- SWIG_SetModule(clientdata, &swig_module);
- module_head = &swig_module;
- } else {
- /* the interpreter has loaded a SWIG module, but has it loaded this one? */
- found=0;
- iter=module_head;
- do {
- if (iter==&swig_module) {
- found=1;
- break;
- }
- iter=iter->next;
- } while (iter!= module_head);
-
- /* if the is found in the list, then all is done and we may leave */
- if (found) return;
- /* otherwise we must add out module into the list */
- swig_module.next = module_head->next;
- 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);
-#endif
- for (i = 0; i < swig_module.size; ++i) {
- swig_type_info *type = 0;
- swig_type_info *ret;
- swig_cast_info *cast;
-
-#ifdef SWIGRUNTIME_DEBUG
- printf("SWIG_InitializeModule: type %d %s\n", i, swig_module.type_initial[i]->name);
-#endif
-
- /* if there is another module already loaded */
- if (swig_module.next != &swig_module) {
- type = SWIG_MangledTypeQueryModule(swig_module.next, &swig_module, swig_module.type_initial[i]->name);
- }
- if (type) {
- /* Overwrite clientdata field */
-#ifdef SWIGRUNTIME_DEBUG
- printf("SWIG_InitializeModule: found type %s\n", type->name);
-#endif
- if (swig_module.type_initial[i]->clientdata) {
- type->clientdata = swig_module.type_initial[i]->clientdata;
-#ifdef SWIGRUNTIME_DEBUG
- printf("SWIG_InitializeModule: found and overwrite type %s \n", type->name);
-#endif
- }
- } else {
- type = swig_module.type_initial[i];
- }
-
- /* Insert casting types */
- cast = swig_module.cast_initial[i];
- while (cast->type) {
- /* Don't need to add information already in the list */
- ret = 0;
-#ifdef SWIGRUNTIME_DEBUG
- printf("SWIG_InitializeModule: look cast %s\n", cast->type->name);
-#endif
- if (swig_module.next != &swig_module) {
- ret = SWIG_MangledTypeQueryModule(swig_module.next, &swig_module, cast->type->name);
-#ifdef SWIGRUNTIME_DEBUG
- if (ret) printf("SWIG_InitializeModule: found cast %s\n", ret->name);
-#endif
- }
- if (ret) {
- if (type == swig_module.type_initial[i]) {
-#ifdef SWIGRUNTIME_DEBUG
- printf("SWIG_InitializeModule: skip old type %s\n", ret->name);
-#endif
- cast->type = ret;
- ret = 0;
- } else {
- /* Check for casting already in the list */
- swig_cast_info *ocast = SWIG_TypeCheck(ret->name, type);
-#ifdef SWIGRUNTIME_DEBUG
- if (ocast) printf("SWIG_InitializeModule: skip old cast %s\n", ret->name);
-#endif
- if (!ocast) ret = 0;
- }
- }
-
- if (!ret) {
-#ifdef SWIGRUNTIME_DEBUG
- printf("SWIG_InitializeModule: adding cast %s\n", cast->type->name);
-#endif
- if (type->cast) {
- type->cast->prev = cast;
- cast->next = type->cast;
- }
- type->cast = cast;
- }
- cast++;
- }
- /* Set entry in modules->types array equal to the type */
- swig_module.types[i] = type;
- }
- swig_module.types[i] = 0;
-
-#ifdef SWIGRUNTIME_DEBUG
- printf("**** SWIG_InitializeModule: Cast List ******\n");
- for (i = 0; i < swig_module.size; ++i) {
- int j = 0;
- swig_cast_info *cast = swig_module.cast_initial[i];
- printf("SWIG_InitializeModule: type %d %s\n", i, swig_module.type_initial[i]->name);
- while (cast->type) {
- printf("SWIG_InitializeModule: cast type %s\n", cast->type->name);
- cast++;
- ++j;
- }
- printf("---- Total casts: %d\n",j);
- }
- printf("**** SWIG_InitializeModule: Cast List ******\n");
-#endif
-}
-
-/* This function will propagate the clientdata field of type to
-* any new swig_type_info structures that have been added into the list
-* of equivalent types. It is like calling
-* SWIG_TypeClientData(type, clientdata) a second time.
-*/
-SWIGRUNTIME void
-SWIG_PropagateClientData(void) {
- size_t i;
- swig_cast_info *equiv;
- static int init_run = 0;
-
- if (init_run) return;
- init_run = 1;
-
- for (i = 0; i < swig_module.size; i++) {
- if (swig_module.types[i]->clientdata) {
- equiv = swig_module.types[i]->cast;
- while (equiv) {
- if (!equiv->converter) {
- if (equiv->type && !equiv->type->clientdata)
- SWIG_TypeClientData(equiv->type, swig_module.types[i]->clientdata);
- }
- equiv = equiv->next;
- }
- }
- }
-}
-
-#ifdef __cplusplus
-#if 0
-{
- /* c-mode */
-#endif
-}
-#endif
-
-
-
-#ifdef __cplusplus
-extern "C" {
-#endif
-
- /* Python-specific SWIG API */
-#define SWIG_newvarlink() SWIG_Python_newvarlink()
-#define SWIG_addvarlink(p, name, get_attr, set_attr) SWIG_Python_addvarlink(p, name, get_attr, set_attr)
-#define SWIG_InstallConstants(d, constants) SWIG_Python_InstallConstants(d, constants)
-
- /* -----------------------------------------------------------------------------
- * global variable support code.
- * ----------------------------------------------------------------------------- */
-
- typedef struct swig_globalvar {
- char *name; /* Name of global variable */
- PyObject *(*get_attr)(void); /* Return the current value */
- int (*set_attr)(PyObject *); /* Set the value */
- struct swig_globalvar *next;
- } swig_globalvar;
-
- typedef struct swig_varlinkobject {
- PyObject_HEAD
- swig_globalvar *vars;
- } swig_varlinkobject;
-
- SWIGINTERN PyObject *
- swig_varlink_repr(swig_varlinkobject *SWIGUNUSEDPARM(v)) {
- return PyString_FromString("<Swig global variables>");
- }
-
- SWIGINTERN PyObject *
- swig_varlink_str(swig_varlinkobject *v) {
- PyObject *str = PyString_FromString("(");
- swig_globalvar *var;
- for (var = v->vars; var; var=var->next) {
- PyString_ConcatAndDel(&str,PyString_FromString(var->name));
- if (var->next) PyString_ConcatAndDel(&str,PyString_FromString(", "));
- }
- PyString_ConcatAndDel(&str,PyString_FromString(")"));
- return str;
- }
-
- SWIGINTERN int
- swig_varlink_print(swig_varlinkobject *v, FILE *fp, int SWIGUNUSEDPARM(flags)) {
- PyObject *str = swig_varlink_str(v);
- fprintf(fp,"Swig global variables ");
- fprintf(fp,"%s\n", PyString_AsString(str));
- Py_DECREF(str);
- return 0;
- }
-
- SWIGINTERN void
- swig_varlink_dealloc(swig_varlinkobject *v) {
- swig_globalvar *var = v->vars;
- while (var) {
- swig_globalvar *n = var->next;
- free(var->name);
- free(var);
- var = n;
- }
- }
-
- SWIGINTERN PyObject *
- swig_varlink_getattr(swig_varlinkobject *v, char *n) {
- PyObject *res = NULL;
- swig_globalvar *var = v->vars;
- while (var) {
- if (strcmp(var->name,n) == 0) {
- res = (*var->get_attr)();
- break;
- }
- var = var->next;
- }
- if (res == NULL && !PyErr_Occurred()) {
- PyErr_SetString(PyExc_NameError,"Unknown C global variable");
- }
- return res;
- }
-
- SWIGINTERN int
- swig_varlink_setattr(swig_varlinkobject *v, char *n, PyObject *p) {
- int res = 1;
- swig_globalvar *var = v->vars;
- while (var) {
- if (strcmp(var->name,n) == 0) {
- res = (*var->set_attr)(p);
- break;
- }
- var = var->next;
- }
- if (res == 1 && !PyErr_Occurred()) {
- PyErr_SetString(PyExc_NameError,"Unknown C global variable");
- }
- return res;
- }
-
- SWIGINTERN PyTypeObject*
- swig_varlink_type(void) {
- static char varlink__doc__[] = "Swig var link object";
- static PyTypeObject varlink_type;
- static int type_init = 0;
- if (!type_init) {
- const PyTypeObject tmp
- = {
- PyObject_HEAD_INIT(NULL)
- 0, /* Number of items in variable part (ob_size) */
- (char *)"swigvarlink", /* Type name (tp_name) */
- sizeof(swig_varlinkobject), /* Basic size (tp_basicsize) */
- 0, /* Itemsize (tp_itemsize) */
- (destructor) swig_varlink_dealloc, /* Deallocator (tp_dealloc) */
- (printfunc) swig_varlink_print, /* Print (tp_print) */
- (getattrfunc) swig_varlink_getattr, /* get attr (tp_getattr) */
- (setattrfunc) swig_varlink_setattr, /* Set attr (tp_setattr) */
- 0, /* tp_compare */
- (reprfunc) swig_varlink_repr, /* tp_repr */
- 0, /* tp_as_number */
- 0, /* tp_as_sequence */
- 0, /* tp_as_mapping */
- 0, /* tp_hash */
- 0, /* tp_call */
- (reprfunc)swig_varlink_str, /* tp_str */
- 0, /* tp_getattro */
- 0, /* tp_setattro */
- 0, /* tp_as_buffer */
- 0, /* tp_flags */
- varlink__doc__, /* tp_doc */
- 0, /* tp_traverse */
- 0, /* tp_clear */
- 0, /* tp_richcompare */
- 0, /* tp_weaklistoffset */
-#if PY_VERSION_HEX >= 0x02020000
- 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, /* tp_iter -> tp_weaklist */
-#endif
-#if PY_VERSION_HEX >= 0x02030000
- 0, /* tp_del */
-#endif
-#ifdef COUNT_ALLOCS
- 0,0,0,0 /* tp_alloc -> tp_next */
-#endif
- };
- varlink_type = tmp;
- varlink_type.ob_type = &PyType_Type;
- type_init = 1;
- }
- return &varlink_type;
- }
-
- /* Create a variable linking object for use later */
- SWIGINTERN PyObject *
- SWIG_Python_newvarlink(void) {
- swig_varlinkobject *result = PyObject_NEW(swig_varlinkobject, swig_varlink_type());
- if (result) {
- result->vars = 0;
- }
- return ((PyObject*) result);
- }
-
- SWIGINTERN void
- SWIG_Python_addvarlink(PyObject *p, char *name, PyObject *(*get_attr)(void), int (*set_attr)(PyObject *p)) {
- swig_varlinkobject *v = (swig_varlinkobject *) p;
- swig_globalvar *gv = (swig_globalvar *) malloc(sizeof(swig_globalvar));
- if (gv) {
- size_t size = strlen(name)+1;
- gv->name = (char *)malloc(size);
- if (gv->name) {
- strncpy(gv->name,name,size);
- gv->get_attr = get_attr;
- gv->set_attr = set_attr;
- gv->next = v->vars;
- }
- }
- v->vars = gv;
- }
-
- SWIGINTERN PyObject *
- SWIG_globals(void) {
- static PyObject *_SWIG_globals = 0;
- if (!_SWIG_globals) _SWIG_globals = SWIG_newvarlink();
- return _SWIG_globals;
- }
-
- /* -----------------------------------------------------------------------------
- * constants/methods manipulation
- * ----------------------------------------------------------------------------- */
-
- /* Install Constants */
- SWIGINTERN void
- SWIG_Python_InstallConstants(PyObject *d, swig_const_info constants[]) {
- PyObject *obj = 0;
- size_t i;
- for (i = 0; constants[i].type; ++i) {
- switch(constants[i].type) {
- case SWIG_PY_POINTER:
- obj = SWIG_NewPointerObj(constants[i].pvalue, *(constants[i]).ptype,0);
- break;
- case SWIG_PY_BINARY:
- obj = SWIG_NewPackedObj(constants[i].pvalue, constants[i].lvalue, *(constants[i].ptype));
- break;
- default:
- obj = 0;
- break;
- }
- if (obj) {
- PyDict_SetItemString(d, constants[i].name, obj);
- Py_DECREF(obj);
- }
- }
- }
-
- /* -----------------------------------------------------------------------------*/
- /* Fix SwigMethods to carry the callback ptrs when needed */
- /* -----------------------------------------------------------------------------*/
-
- SWIGINTERN void
- SWIG_Python_FixMethods(PyMethodDef *methods,
- swig_const_info *const_table,
- swig_type_info **types,
- swig_type_info **types_initial) {
- size_t i;
- for (i = 0; methods[i].ml_name; ++i) {
- const char *c = methods[i].ml_doc;
- if (c && (c = strstr(c, "swig_ptr: "))) {
- int j;
- swig_const_info *ci = 0;
- const char *name = c + 10;
- for (j = 0; const_table[j].type; ++j) {
- if (strncmp(const_table[j].name, name,
- strlen(const_table[j].name)) == 0) {
- ci = &(const_table[j]);
- break;
- }
- }
- if (ci) {
- size_t shift = (ci->ptype) - types;
- swig_type_info *ty = types_initial[shift];
- size_t ldoc = (c - methods[i].ml_doc);
- size_t lptr = strlen(ty->name)+2*sizeof(void*)+2;
- char *ndoc = (char*)malloc(ldoc + lptr + 10);
- if (ndoc) {
- char *buff = ndoc;
- void *ptr = (ci->type == SWIG_PY_POINTER) ? ci->pvalue : 0;
- if (ptr) {
- strncpy(buff, methods[i].ml_doc, ldoc);
- buff += ldoc;
- strncpy(buff, "swig_ptr: ", 10);
- buff += 10;
- SWIG_PackVoidPtr(buff, ptr, ty->name, lptr);
- methods[i].ml_doc = ndoc;
- }
- }
- }
- }
- }
- }
-
-#ifdef __cplusplus
-}
-#endif
-
-/* -----------------------------------------------------------------------------*
- * Partial Init method
- * -----------------------------------------------------------------------------*/
-
-#ifdef __cplusplus
-extern "C"
-#endif
-SWIGEXPORT void SWIG_init(void) {
- PyObject *m, *d;
-
- /* Fix SwigMethods to carry the callback ptrs when needed */
- SWIG_Python_FixMethods(SwigMethods, swig_const_table, swig_types, swig_type_initial);
-
- m = Py_InitModule((char *) SWIG_name, SwigMethods);
- d = PyModule_GetDict(m);
-
- SWIG_InitializeModule(0);
- SWIG_InstallConstants(d,swig_const_table);
-
-
-}
-
diff --git a/source4/librpc/rpc/pyrpc.c b/source4/librpc/rpc/pyrpc.c
new file mode 100644
index 0000000000..d8344be511
--- /dev/null
+++ b/source4/librpc/rpc/pyrpc.c
@@ -0,0 +1,417 @@
+/*
+ Unix SMB/CIFS implementation.
+ Samba utility functions
+ 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/>.
+*/
+
+#include "includes.h"
+#include <Python.h>
+#include <structmember.h>
+#include "librpc/rpc/pyrpc.h"
+#include "librpc/rpc/dcerpc.h"
+#include "lib/events/events.h"
+
+static PyObject *py_dcerpc_run_function(dcerpc_InterfaceObject *iface, struct PyNdrRpcMethodDef *md, PyObject *args, PyObject *kwargs)
+{
+ TALLOC_CTX *mem_ctx;
+ NTSTATUS status;
+ void *r;
+ PyObject *result = Py_None;
+
+ if (md->pack_in_data == NULL || md->unpack_out_data == NULL) {
+ PyErr_SetString(PyExc_NotImplementedError, "No marshalling code available yet");
+ return NULL;
+ }
+
+ mem_ctx = talloc_new(NULL);
+ if (mem_ctx == NULL)
+ return NULL;
+
+ r = talloc_zero_size(mem_ctx, md->table->calls[md->opnum].struct_size);
+ if (r == NULL)
+ return NULL;
+
+ if (!md->pack_in_data(args, kwargs, r)) {
+ talloc_free(mem_ctx);
+ return NULL;
+ }
+
+ status = md->call(iface->pipe, mem_ctx, r);
+ if (NT_STATUS_IS_ERR(status)) {
+ PyErr_SetDCERPCStatus(iface->pipe, status);
+ talloc_free(mem_ctx);
+ return NULL;
+ }
+
+ result = md->unpack_out_data(r);
+
+ talloc_free(mem_ctx);
+ return result;
+}
+
+static PyObject *py_dcerpc_call_wrapper(PyObject *self, PyObject *args, void *wrapped, PyObject *kwargs)
+{
+ dcerpc_InterfaceObject *iface = (dcerpc_InterfaceObject *)self;
+ struct PyNdrRpcMethodDef *md = wrapped;
+
+ return py_dcerpc_run_function(iface, md, args, kwargs);
+}
+
+
+bool PyInterface_AddNdrRpcMethods(PyTypeObject *ifacetype, const struct PyNdrRpcMethodDef *mds)
+{
+ int i;
+ for (i = 0; mds[i].name; i++) {
+ PyObject *ret;
+ struct wrapperbase *wb = calloc(sizeof(struct wrapperbase), 1);
+
+ wb->name = discard_const_p(char, mds[i].name);
+ wb->flags = PyWrapperFlag_KEYWORDS;
+ wb->wrapper = (wrapperfunc)py_dcerpc_call_wrapper;
+ wb->doc = discard_const_p(char, mds[i].doc);
+
+ ret = PyDescr_NewWrapper(ifacetype, wb, discard_const_p(void, &mds[i]));
+
+ PyDict_SetItemString(ifacetype->tp_dict, mds[i].name,
+ (PyObject *)ret);
+ }
+
+ return true;
+}
+
+static bool PyString_AsGUID(PyObject *object, struct GUID *uuid)
+{
+ NTSTATUS status;
+ status = GUID_from_string(PyString_AsString(object), uuid);
+ if (NT_STATUS_IS_ERR(status)) {
+ PyErr_SetNTSTATUS(status);
+ return false;
+ }
+ return true;
+}
+
+static bool ndr_syntax_from_py_object(PyObject *object, struct ndr_syntax_id *syntax_id)
+{
+ ZERO_STRUCTP(syntax_id);
+
+ if (PyString_Check(object)) {
+ return PyString_AsGUID(object, &syntax_id->uuid);
+ } else if (PyTuple_Check(object)) {
+ if (PyTuple_Size(object) < 1 || PyTuple_Size(object) > 2) {
+ PyErr_SetString(PyExc_ValueError, "Syntax ID tuple has invalid size");
+ return false;
+ }
+
+ if (!PyString_Check(PyTuple_GetItem(object, 0))) {
+ PyErr_SetString(PyExc_ValueError, "Expected GUID as first element in tuple");
+ return false;
+ }
+
+ if (!PyString_AsGUID(PyTuple_GetItem(object, 0), &syntax_id->uuid))
+ return false;
+
+ if (!PyInt_Check(PyTuple_GetItem(object, 1))) {
+ PyErr_SetString(PyExc_ValueError, "Expected version as second element in tuple");
+ return false;
+ }
+
+ syntax_id->if_version = PyInt_AsLong(PyTuple_GetItem(object, 1));
+ return true;
+ }
+
+ PyErr_SetString(PyExc_TypeError, "Expected UUID or syntax id tuple");
+ return false;
+}
+
+static PyObject *py_iface_server_name(PyObject *obj, void *closure)
+{
+ const char *server_name;
+ dcerpc_InterfaceObject *iface = (dcerpc_InterfaceObject *)obj;
+
+ server_name = dcerpc_server_name(iface->pipe);
+ if (server_name == NULL)
+ return Py_None;
+
+ return PyString_FromString(server_name);
+}
+
+static PyObject *py_ndr_syntax_id(struct ndr_syntax_id *syntax_id)
+{
+ PyObject *ret;
+ char *uuid_str;
+
+ uuid_str = GUID_string(NULL, &syntax_id->uuid);
+ if (uuid_str == NULL)
+ return NULL;
+
+ ret = Py_BuildValue("(s,i)", uuid_str, syntax_id->if_version);
+
+ talloc_free(uuid_str);
+
+ return ret;
+}
+
+static PyObject *py_iface_abstract_syntax(PyObject *obj, void *closure)
+{
+ dcerpc_InterfaceObject *iface = (dcerpc_InterfaceObject *)obj;
+
+ return py_ndr_syntax_id(&iface->pipe->syntax);
+}
+
+static PyObject *py_iface_transfer_syntax(PyObject *obj, void *closure)
+{
+ dcerpc_InterfaceObject *iface = (dcerpc_InterfaceObject *)obj;
+
+ return py_ndr_syntax_id(&iface->pipe->transfer_syntax);
+}
+
+static PyGetSetDef dcerpc_interface_getsetters[] = {
+ { discard_const_p(char, "server_name"), py_iface_server_name, NULL,
+ discard_const_p(char, "name of the server, if connected over SMB") },
+ { discard_const_p(char, "abstract_syntax"), py_iface_abstract_syntax, NULL,
+ discard_const_p(char, "syntax id of the abstract syntax") },
+ { discard_const_p(char, "transfer_syntax"), py_iface_transfer_syntax, NULL,
+ discard_const_p(char, "syntax id of the transfersyntax") },
+ { NULL }
+};
+
+static PyMemberDef dcerpc_interface_members[] = {
+ { discard_const_p(char, "request_timeout"), T_INT,
+ offsetof(struct dcerpc_pipe, request_timeout), 0,
+ discard_const_p(char, "request timeout, in seconds") },
+ { NULL }
+};
+
+void PyErr_SetDCERPCStatus(struct dcerpc_pipe *p, NTSTATUS status)
+{
+ if (p != NULL && NT_STATUS_EQUAL(status, NT_STATUS_NET_WRITE_FAULT)) {
+ const char *errstr = dcerpc_errstr(NULL, p->last_fault_code);
+ PyErr_SetObject(PyExc_RuntimeError,
+ Py_BuildValue("(i,s)", p->last_fault_code,
+ errstr));
+ } else {
+ PyErr_SetNTSTATUS(status);
+ }
+}
+
+static PyObject *py_iface_request(PyObject *self, PyObject *args, PyObject *kwargs)
+{
+ dcerpc_InterfaceObject *iface = (dcerpc_InterfaceObject *)self;
+ int opnum;
+ DATA_BLOB data_in, data_out;
+ NTSTATUS status;
+ char *in_data;
+ int in_length;
+ PyObject *ret;
+ PyObject *object = NULL;
+ struct GUID object_guid;
+ TALLOC_CTX *mem_ctx = talloc_new(NULL);
+ const char *kwnames[] = { "opnum", "data", "object", NULL };
+
+ if (!PyArg_ParseTupleAndKeywords(args, kwargs, "is#|O:request",
+ discard_const_p(char *, kwnames), &opnum, &in_data, &in_length, &object)) {
+ return NULL;
+ }
+
+ data_in.data = (uint8_t *)talloc_memdup(mem_ctx, in_data, in_length);
+ data_in.length = in_length;
+
+ ZERO_STRUCT(data_out);
+
+ if (object != NULL && !PyString_AsGUID(object, &object_guid)) {
+ return NULL;
+ }
+
+ status = dcerpc_request(iface->pipe, object?&object_guid:NULL,
+ opnum, false, mem_ctx, &data_in, &data_out);
+
+ if (NT_STATUS_IS_ERR(status)) {
+ PyErr_SetDCERPCStatus(iface->pipe, status);
+ talloc_free(mem_ctx);
+ return NULL;
+ }
+
+ ret = PyString_FromStringAndSize((char *)data_out.data, data_out.length);
+
+ talloc_free(mem_ctx);
+ return ret;
+}
+
+static PyObject *py_iface_later_context(PyObject *self, PyObject *args, PyObject *kwargs)
+{
+ dcerpc_InterfaceObject *iface = (dcerpc_InterfaceObject *)self;
+ NTSTATUS status;
+ const char *kwnames[] = { "abstract_syntax", "transfer_syntax", NULL };
+ PyObject *py_abstract_syntax = Py_None, *py_transfer_syntax = Py_None;
+ struct ndr_syntax_id abstract_syntax, transfer_syntax;
+
+ if (!PyArg_ParseTupleAndKeywords(args, kwargs, "O|O:alter_context",
+ discard_const_p(char *, kwnames), &py_abstract_syntax,
+ &py_transfer_syntax)) {
+ return NULL;
+ }
+
+ if (!ndr_syntax_from_py_object(py_abstract_syntax, &abstract_syntax))
+ return NULL;
+
+ if (py_transfer_syntax == Py_None) {
+ transfer_syntax = ndr_transfer_syntax;
+ } else {
+ if (!ndr_syntax_from_py_object(py_transfer_syntax,
+ &transfer_syntax))
+ return NULL;
+ }
+
+ status = dcerpc_alter_context(iface->pipe, iface->pipe, &abstract_syntax,
+ &transfer_syntax);
+
+ if (NT_STATUS_IS_ERR(status)) {
+ PyErr_SetDCERPCStatus(iface->pipe, status);
+ return NULL;
+ }
+
+ return Py_None;
+}
+
+static PyMethodDef dcerpc_interface_methods[] = {
+ { "request", (PyCFunction)py_iface_request, METH_VARARGS|METH_KEYWORDS, "S.request(opnum, data, object=None) -> data\nMake a raw request" },
+ { "alter_context", (PyCFunction)py_iface_later_context, METH_VARARGS|METH_KEYWORDS, "S.alter_context(syntax)\nChange to a different interface" },
+ { NULL, NULL, 0, NULL },
+};
+
+
+static void dcerpc_interface_dealloc(PyObject* self)
+{
+ dcerpc_InterfaceObject *interface = (dcerpc_InterfaceObject *)self;
+ talloc_free(interface->pipe);
+ PyObject_Del(self);
+}
+
+static PyObject *dcerpc_interface_new(PyTypeObject *self, PyObject *args, PyObject *kwargs)
+{
+ dcerpc_InterfaceObject *ret;
+ const char *binding_string;
+ struct cli_credentials *credentials;
+ struct loadparm_context *lp_ctx = NULL;
+ PyObject *py_lp_ctx = Py_None, *py_credentials = Py_None;
+ TALLOC_CTX *mem_ctx = NULL;
+ struct event_context *event_ctx;
+ NTSTATUS status;
+
+ PyObject *syntax, *py_basis = Py_None;
+ const char *kwnames[] = {
+ "binding", "syntax", "lp_ctx", "credentials", "basis_connection", NULL
+ };
+ extern struct loadparm_context *lp_from_py_object(PyObject *py_obj);
+ extern struct cli_credentials *cli_credentials_from_py_object(PyObject *py_obj);
+ struct ndr_interface_table *table;
+
+ if (!PyArg_ParseTupleAndKeywords(args, kwargs, "sO|OOO:connect", discard_const_p(char *, kwnames), &binding_string, &syntax, &py_lp_ctx, &py_credentials, &py_basis)) {
+ return NULL;
+ }
+
+ lp_ctx = lp_from_py_object(py_lp_ctx);
+ if (lp_ctx == NULL) {
+ PyErr_SetString(PyExc_TypeError, "Expected loadparm context");
+ return NULL;
+ }
+
+ credentials = cli_credentials_from_py_object(py_credentials);
+ if (credentials == NULL) {
+ PyErr_SetString(PyExc_TypeError, "Expected credentials");
+ return NULL;
+ }
+ ret = PyObject_New(dcerpc_InterfaceObject, &dcerpc_InterfaceType);
+
+ event_ctx = event_context_init(mem_ctx);
+
+ /* Create a dummy interface table struct. TODO: In the future, we should rather just allow
+ * connecting without requiring an interface table.
+ */
+
+ table = talloc_zero(mem_ctx, struct ndr_interface_table);
+
+ if (table == NULL) {
+ PyErr_SetString(PyExc_MemoryError, "Allocating interface table");
+ return NULL;
+ }
+
+ if (!ndr_syntax_from_py_object(syntax, &table->syntax_id)) {
+ return NULL;
+ }
+
+ ret->pipe = NULL;
+
+ if (py_basis != Py_None) {
+ struct dcerpc_pipe *base_pipe;
+
+ if (!PyObject_TypeCheck(py_basis, &dcerpc_InterfaceType)) {
+ PyErr_SetString(PyExc_ValueError, "basis_connection must be a DCE/RPC connection");
+ talloc_free(mem_ctx);
+ return NULL;
+ }
+
+ base_pipe = ((dcerpc_InterfaceObject *)py_basis)->pipe;
+
+ status = dcerpc_secondary_context(base_pipe, &ret->pipe,
+ table);
+ ret->pipe = talloc_steal(NULL, ret->pipe);
+ } else {
+ status = dcerpc_pipe_connect(NULL, &ret->pipe, binding_string,
+ table, credentials, event_ctx, lp_ctx);
+ }
+
+ if (NT_STATUS_IS_ERR(status)) {
+ PyErr_SetDCERPCStatus(ret->pipe, status);
+ talloc_free(mem_ctx);
+ return NULL;
+ }
+ ret->pipe->conn->flags |= DCERPC_NDR_REF_ALLOC;
+ return (PyObject *)ret;
+}
+
+PyTypeObject dcerpc_InterfaceType = {
+ PyObject_HEAD_INIT(NULL) 0,
+ .tp_name = "dcerpc.ClientConnection",
+ .tp_basicsize = sizeof(dcerpc_InterfaceObject),
+ .tp_dealloc = dcerpc_interface_dealloc,
+ .tp_getset = dcerpc_interface_getsetters,
+ .tp_members = dcerpc_interface_members,
+ .tp_methods = dcerpc_interface_methods,
+ .tp_doc = "ClientConnection(binding, syntax, lp_ctx=None, credentials=None) -> connection\n"
+"\n"
+"binding should be a DCE/RPC binding string (for example: ncacn_ip_tcp:127.0.0.1)\n"
+"syntax should be a tuple with a GUID and version number of an interface\n"
+"lp_ctx should be a path to a smb.conf file or a param.LoadParm object\n"
+"credentials should be a credentials.Credentials object.\n\n",
+ .tp_flags = Py_TPFLAGS_DEFAULT | Py_TPFLAGS_BASETYPE,
+ .tp_new = dcerpc_interface_new,
+};
+
+void initbase(void)
+{
+ PyObject *m;
+
+ if (PyType_Ready(&dcerpc_InterfaceType) < 0)
+ return;
+
+ m = Py_InitModule3("base", NULL, "DCE/RPC protocol implementation");
+ if (m == NULL)
+ return;
+
+ Py_INCREF((PyObject *)&dcerpc_InterfaceType);
+ PyModule_AddObject(m, "ClientConnection", (PyObject *)&dcerpc_InterfaceType);
+}
diff --git a/source4/librpc/rpc/pyrpc.h b/source4/librpc/rpc/pyrpc.h
new file mode 100644
index 0000000000..af9ca728d8
--- /dev/null
+++ b/source4/librpc/rpc/pyrpc.h
@@ -0,0 +1,73 @@
+/*
+ Unix SMB/CIFS implementation.
+ Samba utility functions
+ 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/>.
+*/
+
+#ifndef _PYRPC_H_
+#define _PYRPC_H_
+
+#include "libcli/util/pyerrors.h"
+#include "librpc/rpc/dcerpc.h"
+
+#define PY_CHECK_TYPE(type, var, fail) \
+ if (!type ## _Check(var)) {\
+ PyErr_Format(PyExc_TypeError, "Expected type %s", type ## _Type.tp_name); \
+ fail; \
+ }
+
+#define dom_sid0_Type dom_sid_Type
+#define dom_sid2_Type dom_sid_Type
+#define dom_sid28_Type dom_sid_Type
+#define dom_sid0_Check dom_sid_Check
+#define dom_sid2_Check dom_sid_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
+
+typedef struct {
+ PyObject_HEAD
+ struct dcerpc_pipe *pipe;
+} dcerpc_InterfaceObject;
+
+PyAPI_DATA(PyTypeObject) dcerpc_InterfaceType;
+
+#define PyErr_FromNdrError(err) PyErr_FromNTSTATUS(ndr_map_error2ntstatus(err))
+
+#define PyErr_SetNdrError(err) \
+ PyErr_SetObject(PyExc_RuntimeError, PyErr_FromNdrError(err))
+
+void PyErr_SetDCERPCStatus(struct dcerpc_pipe *pipe, NTSTATUS status);
+
+typedef bool (*py_data_pack_fn) (PyObject *args, PyObject *kwargs, void *r);
+typedef PyObject *(*py_data_unpack_fn) (void *r);
+
+struct PyNdrRpcMethodDef {
+ const char *name;
+ const char *doc;
+ dcerpc_call_fn call;
+ py_data_pack_fn pack_in_data;
+ py_data_unpack_fn unpack_out_data;
+ uint32_t opnum;
+ const struct ndr_interface_table *table;
+};
+
+bool PyInterface_AddNdrRpcMethods(PyTypeObject *object, const struct PyNdrRpcMethodDef *mds);
+
+#endif /* _PYRPC_H_ */
diff --git a/source4/librpc/scripts/build_idl.sh b/source4/librpc/scripts/build_idl.sh
index 5796f40c61..3f13b64a2e 100755
--- a/source4/librpc/scripts/build_idl.sh
+++ b/source4/librpc/scripts/build_idl.sh
@@ -8,7 +8,7 @@ PIDL_EXTRA_ARGS="$*"
[ -d $OUTDIR ] || mkdir -p $OUTDIR || exit 1
-PIDL="$PIDL --outputdir $OUTDIR --header --ndr-parser --server --client --swig --ejs --python $PIDL_EXTRA_ARGS"
+PIDL="$PIDL --outputdir $OUTDIR --header --ndr-parser --server --client --swig --python $PIDL_EXTRA_ARGS"
if [ x$FULLBUILD = xFULL ]; then
echo Rebuilding all idl files in $IDLDIR
diff --git a/source4/main.mk b/source4/main.mk
index 83f977b9a8..3f3aea87e6 100644
--- a/source4/main.mk
+++ b/source4/main.mk
@@ -1,97 +1,50 @@
-mkinclude dynconfig.mk
-heimdalsrcdir := heimdal
+mkinclude dynconfig/config.mk
mkinclude heimdal_build/config.mk
mkinclude config.mk
-dsdbsrcdir := dsdb
mkinclude dsdb/config.mk
-smbdsrcdir := smbd
mkinclude smbd/config.mk
-clustersrcdir := cluster
mkinclude cluster/config.mk
mkinclude smbd/process_model.mk
-libnetsrcdir := libnet
mkinclude libnet/config.mk
-authsrcdir := auth
mkinclude auth/config.mk
-nsswitchsrcdir := nsswitch
mkinclude nsswitch/config.mk
-libsrcdir := lib
mkinclude lib/samba3/config.mk
-libsocketsrcdir := lib/socket
mkinclude lib/socket/config.mk
-libcharsetsrcdir := lib/charset
mkinclude lib/charset/config.mk
-ldb_sambasrcdir := lib/ldb-samba
mkinclude lib/ldb-samba/config.mk
-libtlssrcdir := lib/tls
mkinclude lib/tls/config.mk
-libregistrysrcdir := lib/registry
mkinclude lib/registry/config.mk
-libmessagingsrcdir := lib/messaging
mkinclude lib/messaging/config.mk
-libeventssrcdir := lib/events
mkinclude lib/events/config.mk
-libcmdlinesrcdir := lib/cmdline
mkinclude lib/cmdline/config.mk
-socketwrappersrcdir := lib/socket_wrapper
mkinclude lib/socket_wrapper/config.mk
-nsswrappersrcdir := lib/nss_wrapper
mkinclude lib/nss_wrapper/config.mk
-appwebsrcdir := lib/appweb
mkinclude lib/appweb/config.mk
-libstreamsrcdir := lib/stream
mkinclude lib/stream/config.mk
-libutilsrcdir := lib/util
mkinclude lib/util/config.mk
-libtdrsrcdir := lib/tdr
mkinclude lib/tdr/config.mk
-libdbwrapsrcdir := lib/dbwrap
mkinclude lib/dbwrap/config.mk
-libcryptosrcdir := lib/crypto
mkinclude lib/crypto/config.mk
-libtorturesrcdir := lib/torture
mkinclude lib/torture/config.mk
-libcompressionsrcdir := lib/compression
-libgencachesrcdir := lib
mkinclude lib/basic.mk
-paramsrcdir := param
mkinclude param/config.mk
-smb_serversrcdir := smb_server
mkinclude smb_server/config.mk
-rpc_serversrcdir := rpc_server
mkinclude rpc_server/config.mk
-ldap_serversrcdir := ldap_server
mkinclude ldap_server/config.mk
-web_serversrcdir := web_server
mkinclude web_server/config.mk
-winbindsrcdir := winbind
mkinclude winbind/config.mk
-nbt_serversrcdir := nbt_server
mkinclude nbt_server/config.mk
-wrepl_serversrcdir := wrepl_server
mkinclude wrepl_server/config.mk
-cldap_serversrcdir := cldap_server
mkinclude cldap_server/config.mk
-ntp_signd_srcdir := ntp_signd
mkinclude ntp_signd/config.mk
-utilssrcdir := utils
mkinclude utils/net/config.mk
mkinclude utils/config.mk
-ntvfssrcdir := ntvfs
mkinclude ntvfs/config.mk
-ntptrsrcdir := ntptr
mkinclude ntptr/config.mk
-torturesrcdir := torture
mkinclude torture/config.mk
-librpcsrcdir := librpc
mkinclude librpc/config.mk
-clientsrcdir := client
mkinclude client/config.mk
-libclisrcdir := libcli
mkinclude libcli/config.mk
-ejsscriptsrcdir := scripting/ejs
mkinclude scripting/ejs/config.mk
-pyscriptsrcdir := scripting/python
mkinclude scripting/python/config.mk
-kdcsrcdir := kdc
mkinclude kdc/config.mk
diff --git a/source4/nsswitch/wbinfo.c b/source4/nsswitch/wbinfo.c
index 7ead27939e..21c178cc7b 100644
--- a/source4/nsswitch/wbinfo.c
+++ b/source4/nsswitch/wbinfo.c
@@ -27,7 +27,7 @@
#include "libcli/auth/libcli_auth.h"
#include "libcli/security/security.h"
#include "lib/cmdline/popt_common.h"
-#include "dynconfig.h"
+#include "dynconfig/dynconfig.h"
#include "param/param.h"
extern int winbindd_fd;
diff --git a/source4/ntvfs/cifs/vfs_cifs.c b/source4/ntvfs/cifs/vfs_cifs.c
index 2b61268733..844fa11cc5 100644
--- a/source4/ntvfs/cifs/vfs_cifs.c
+++ b/source4/ntvfs/cifs/vfs_cifs.c
@@ -769,6 +769,7 @@ static NTSTATUS cvfs_close(struct ntvfs_module_context *ntvfs,
struct cvfs_private *private = ntvfs->private_data;
struct smbcli_request *c_req;
struct cvfs_file *f;
+ union smb_close io2;
SETUP_PID;
@@ -776,6 +777,15 @@ static NTSTATUS cvfs_close(struct ntvfs_module_context *ntvfs,
private->map_generic) {
return ntvfs_map_close(ntvfs, req, io);
}
+
+ if (io->generic.level == RAW_CLOSE_GENERIC) {
+ ZERO_STRUCT(io2);
+ io2.close.level = RAW_CLOSE_CLOSE;
+ io2.close.in.file = io->generic.in.file;
+ io2.close.in.write_time = io->generic.in.write_time;
+ io = &io2;
+ }
+
SETUP_FILE_HERE(f);
/* Note, we aren't free-ing f, or it's h here. Should we?
even if file-close fails, we'll remove it from the list,
diff --git a/source4/ntvfs/ntvfs_generic.c b/source4/ntvfs/ntvfs_generic.c
index a706e621c9..06d89a717b 100644
--- a/source4/ntvfs/ntvfs_generic.c
+++ b/source4/ntvfs/ntvfs_generic.c
@@ -522,6 +522,19 @@ NTSTATUS ntvfs_map_open(struct ntvfs_module_context *ntvfs,
io2->generic.in.fname = io->smb2.in.fname;
io2->generic.in.sec_desc = NULL;
io2->generic.in.ea_list = NULL;
+
+ /* we need to check these bits before we check the private mask */
+ if (io2->generic.in.create_options & NTCREATEX_OPTIONS_NOT_SUPPORTED_MASK) {
+ status = NT_STATUS_NOT_SUPPORTED;
+ break;
+ }
+
+ /* we use a couple of bits of the create options internally */
+ if (io2->generic.in.create_options & NTCREATEX_OPTIONS_PRIVATE_MASK) {
+ status = NT_STATUS_INVALID_PARAMETER;
+ break;
+ }
+
status = ntvfs->ops->open(ntvfs, req, io2);
break;
@@ -1014,7 +1027,7 @@ NTSTATUS ntvfs_map_lock(struct ntvfs_module_context *ntvfs,
case RAW_LOCK_SMB2: {
/* this is only approximate! We need to change the
generic structure to fix this properly */
- int i;
+ int i, j;
if (lck->smb2.in.lock_count < 1) {
return NT_STATUS_INVALID_PARAMETER;
}
@@ -1031,30 +1044,36 @@ NTSTATUS ntvfs_map_lock(struct ntvfs_module_context *ntvfs,
return NT_STATUS_NO_MEMORY;
}
for (i=0;i<lck->smb2.in.lock_count;i++) {
- if (lck->smb2.in.locks[i].flags & SMB2_LOCK_FLAG_UNLOCK) {
- int j = lck2->generic.in.ulock_cnt;
- lck2->generic.in.ulock_cnt++;
- lck2->generic.in.locks[j].pid = 0;
- lck2->generic.in.locks[j].offset = lck->smb2.in.locks[i].offset;
- lck2->generic.in.locks[j].count = lck->smb2.in.locks[i].length;
- lck2->generic.in.locks[j].pid = 0;
+ if (!(lck->smb2.in.locks[i].flags & SMB2_LOCK_FLAG_UNLOCK)) {
+ break;
+ }
+ j = lck2->generic.in.ulock_cnt;
+ if (lck->smb2.in.locks[i].flags &
+ (SMB2_LOCK_FLAG_SHARED|SMB2_LOCK_FLAG_EXCLUSIVE)) {
+ return NT_STATUS_INVALID_PARAMETER;
}
+ lck2->generic.in.ulock_cnt++;
+ lck2->generic.in.locks[j].pid = 0;
+ lck2->generic.in.locks[j].offset = lck->smb2.in.locks[i].offset;
+ lck2->generic.in.locks[j].count = lck->smb2.in.locks[i].length;
+ lck2->generic.in.locks[j].pid = 0;
}
- for (i=0;i<lck->smb2.in.lock_count;i++) {
- if (!(lck->smb2.in.locks[i].flags & SMB2_LOCK_FLAG_UNLOCK)) {
- int j = lck2->generic.in.ulock_cnt +
- lck2->generic.in.lock_cnt;
- lck2->generic.in.lock_cnt++;
- lck2->generic.in.locks[j].pid = 0;
- lck2->generic.in.locks[j].offset = lck->smb2.in.locks[i].offset;
- lck2->generic.in.locks[j].count = lck->smb2.in.locks[i].length;
- lck2->generic.in.locks[j].pid = 0;
- if (!(lck->smb2.in.locks[i].flags & SMB2_LOCK_FLAG_EXCLUSIVE)) {
- lck2->generic.in.mode = LOCKING_ANDX_SHARED_LOCK;
- }
- if (lck->smb2.in.locks[i].flags & SMB2_LOCK_FLAG_FAIL_IMMEDIATELY) {
- lck2->generic.in.timeout = 0;
- }
+ for (;i<lck->smb2.in.lock_count;i++) {
+ if (lck->smb2.in.locks[i].flags & SMB2_LOCK_FLAG_UNLOCK) {
+ /* w2008 requires unlocks to come first */
+ return NT_STATUS_INVALID_PARAMETER;
+ }
+ j = lck2->generic.in.ulock_cnt + lck2->generic.in.lock_cnt;
+ lck2->generic.in.lock_cnt++;
+ lck2->generic.in.locks[j].pid = 0;
+ lck2->generic.in.locks[j].offset = lck->smb2.in.locks[i].offset;
+ lck2->generic.in.locks[j].count = lck->smb2.in.locks[i].length;
+ lck2->generic.in.locks[j].pid = 0;
+ if (!(lck->smb2.in.locks[i].flags & SMB2_LOCK_FLAG_EXCLUSIVE)) {
+ lck2->generic.in.mode = LOCKING_ANDX_SHARED_LOCK;
+ }
+ if (lck->smb2.in.locks[i].flags & SMB2_LOCK_FLAG_FAIL_IMMEDIATELY) {
+ lck2->generic.in.timeout = 0;
}
}
/* initialize output value */
@@ -1367,7 +1386,7 @@ NTSTATUS ntvfs_map_read(struct ntvfs_module_context *ntvfs,
case RAW_READ_SMB2:
rd2->readx.in.file.ntvfs= rd->smb2.in.file.ntvfs;
rd2->readx.in.offset = rd->smb2.in.offset;
- rd2->readx.in.mincnt = rd->smb2.in.length;
+ rd2->readx.in.mincnt = rd->smb2.in.min_count;
rd2->readx.in.maxcnt = rd->smb2.in.length;
rd2->readx.in.remaining = 0;
rd2->readx.out.data = rd->smb2.out.data.data;
@@ -1383,11 +1402,42 @@ done:
/*
NTVFS close generic to any mapper
*/
+static NTSTATUS ntvfs_map_close_finish(struct ntvfs_module_context *ntvfs,
+ struct ntvfs_request *req,
+ union smb_close *cl,
+ union smb_close *cl2,
+ NTSTATUS status)
+{
+ NT_STATUS_NOT_OK_RETURN(status);
+
+ switch (cl->generic.level) {
+ case RAW_CLOSE_SMB2:
+ cl->smb2.out.flags = cl2->generic.out.flags;
+ cl->smb2.out._pad = 0;
+ cl->smb2.out.create_time = cl2->generic.out.create_time;
+ cl->smb2.out.access_time = cl2->generic.out.access_time;
+ cl->smb2.out.write_time = cl2->generic.out.write_time;
+ cl->smb2.out.change_time = cl2->generic.out.change_time;
+ cl->smb2.out.alloc_size = cl2->generic.out.alloc_size;
+ cl->smb2.out.size = cl2->generic.out.size;
+ cl->smb2.out.file_attr = cl2->generic.out.file_attr;
+ break;
+ default:
+ break;
+ }
+
+ return status;
+}
+
+/*
+ NTVFS close generic to any mapper
+*/
NTSTATUS ntvfs_map_close(struct ntvfs_module_context *ntvfs,
struct ntvfs_request *req,
union smb_close *cl)
{
union smb_close *cl2;
+ NTSTATUS status;
cl2 = talloc(req, union smb_close);
if (cl2 == NULL) {
@@ -1395,30 +1445,38 @@ NTSTATUS ntvfs_map_close(struct ntvfs_module_context *ntvfs,
}
switch (cl->generic.level) {
- case RAW_CLOSE_CLOSE:
+ case RAW_CLOSE_GENERIC:
return NT_STATUS_INVALID_LEVEL;
+ case RAW_CLOSE_CLOSE:
+ cl2->generic.level = RAW_CLOSE_GENERIC;
+ cl2->generic.in.file = cl->close.in.file;
+ cl2->generic.in.write_time = cl->close.in.write_time;
+ cl2->generic.in.flags = 0;
+ break;
+
case RAW_CLOSE_SPLCLOSE:
- cl2->generic.level = RAW_CLOSE_CLOSE;
- cl2->generic.in.file.ntvfs = cl->splclose.in.file.ntvfs;
+ cl2->generic.level = RAW_CLOSE_GENERIC;
+ cl2->generic.in.file = cl->splclose.in.file;
cl2->generic.in.write_time = 0;
+ cl2->generic.in.flags = 0;
break;
case RAW_CLOSE_SMB2:
- cl2->generic.level = RAW_CLOSE_CLOSE;
- cl2->generic.in.file.ntvfs = cl->smb2.in.file.ntvfs;
+ cl2->generic.level = RAW_CLOSE_GENERIC;
+ cl2->generic.in.file = cl->smb2.in.file;
cl2->generic.in.write_time = 0;
- /* SMB2 Close has output parameter, but we just zero them */
- ZERO_STRUCT(cl->smb2.out);
+ cl2->generic.in.flags = cl->smb2.in.flags;
break;
}
- /*
- * we don't need to call ntvfs_map_async_setup() here,
- * as close() doesn't have any output fields
- */
+ status = ntvfs_map_async_setup(ntvfs, req, cl, cl2,
+ (second_stage_t)ntvfs_map_close_finish);
+ NT_STATUS_NOT_OK_RETURN(status);
- return ntvfs->ops->close(ntvfs, req, cl2);
+ status = ntvfs->ops->close(ntvfs, req, cl2);
+
+ return ntvfs_map_async_finish(req, status);
}
/*
diff --git a/source4/ntvfs/posix/pvfs_acl.c b/source4/ntvfs/posix/pvfs_acl.c
index f1e469f790..507c22f050 100644
--- a/source4/ntvfs/posix/pvfs_acl.c
+++ b/source4/ntvfs/posix/pvfs_acl.c
@@ -457,7 +457,7 @@ NTSTATUS pvfs_access_check_unix(struct pvfs_state *pvfs,
}
if (uid != 0 && (*access_mask & SEC_FLAG_SYSTEM_SECURITY)) {
- return NT_STATUS_PRIVILEGE_NOT_HELD;
+ return NT_STATUS_ACCESS_DENIED;
}
if (*access_mask & ~max_bits) {
diff --git a/source4/ntvfs/posix/pvfs_fileinfo.c b/source4/ntvfs/posix/pvfs_fileinfo.c
index 4c383ed45d..04f6ad78d0 100644
--- a/source4/ntvfs/posix/pvfs_fileinfo.c
+++ b/source4/ntvfs/posix/pvfs_fileinfo.c
@@ -58,6 +58,8 @@ NTSTATUS pvfs_fill_dos_info(struct pvfs_state *pvfs, struct pvfs_filename *name,
if (S_ISDIR(name->st.st_mode)) {
name->st.st_size = 0;
name->st.st_nlink = 1;
+ } else if (name->stream_id == 0) {
+ name->stream_name = NULL;
}
/* for now just use the simple samba mapping */
@@ -75,6 +77,11 @@ NTSTATUS pvfs_fill_dos_info(struct pvfs_state *pvfs, struct pvfs_filename *name,
name->dos.alloc_size = pvfs_round_alloc_size(pvfs, name->st.st_size);
name->dos.nlink = name->st.st_nlink;
name->dos.ea_size = 4;
+ if (pvfs->ntvfs->ctx->protocol == PROTOCOL_SMB2) {
+ /* SMB2 represents a null EA with zero bytes */
+ name->dos.ea_size = 0;
+ }
+
name->dos.file_id = (((uint64_t)name->st.st_dev)<<32) | name->st.st_ino;
name->dos.flags = 0;
diff --git a/source4/ntvfs/posix/pvfs_flush.c b/source4/ntvfs/posix/pvfs_flush.c
index 61e73cedba..6e09c1f34a 100644
--- a/source4/ntvfs/posix/pvfs_flush.c
+++ b/source4/ntvfs/posix/pvfs_flush.c
@@ -54,6 +54,7 @@ NTSTATUS pvfs_flush(struct ntvfs_module_context *ntvfs,
return NT_STATUS_INVALID_HANDLE;
}
pvfs_flush_file(pvfs, f);
+ io->smb2.out.reserved = 0;
return NT_STATUS_OK;
case RAW_FLUSH_ALL:
diff --git a/source4/ntvfs/posix/pvfs_open.c b/source4/ntvfs/posix/pvfs_open.c
index 67937324cc..49710806c7 100644
--- a/source4/ntvfs/posix/pvfs_open.c
+++ b/source4/ntvfs/posix/pvfs_open.c
@@ -182,12 +182,19 @@ static NTSTATUS pvfs_open_directory(struct pvfs_state *pvfs,
bool del_on_close;
uint32_t create_options;
uint32_t share_access;
+ bool forced;
create_options = io->generic.in.create_options;
share_access = io->generic.in.share_access;
+ forced = (io->generic.in.create_options & NTCREATEX_OPTIONS_DIRECTORY)?true:false;
+
if (name->stream_name) {
- return NT_STATUS_NOT_A_DIRECTORY;
+ if (forced) {
+ return NT_STATUS_NOT_A_DIRECTORY;
+ } else {
+ return NT_STATUS_FILE_IS_A_DIRECTORY;
+ }
}
/* if the client says it must be a directory, and it isn't,
@@ -196,6 +203,13 @@ static NTSTATUS pvfs_open_directory(struct pvfs_state *pvfs,
return NT_STATUS_NOT_A_DIRECTORY;
}
+ /* found with gentest */
+ if (io->ntcreatex.in.access_mask == SEC_FLAG_MAXIMUM_ALLOWED &&
+ (io->ntcreatex.in.create_options & NTCREATEX_OPTIONS_DIRECTORY) &&
+ (io->ntcreatex.in.create_options & NTCREATEX_OPTIONS_DELETE_ON_CLOSE)) {
+ return NT_STATUS_INVALID_PARAMETER;
+ }
+
switch (io->generic.in.open_disposition) {
case NTCREATEX_DISP_OPEN_IF:
break;
@@ -548,11 +562,19 @@ static NTSTATUS pvfs_create_file(struct pvfs_state *pvfs,
uint32_t oplock_level = OPLOCK_NONE, oplock_granted;
bool allow_level_II_oplock = false;
+ if (io->ntcreatex.in.file_attr & ~FILE_ATTRIBUTE_ALL_MASK) {
+ return NT_STATUS_INVALID_PARAMETER;
+ }
+
+ if (io->ntcreatex.in.file_attr & FILE_ATTRIBUTE_ENCRYPTED) {
+ return NT_STATUS_ACCESS_DENIED;
+ }
+
if ((io->ntcreatex.in.file_attr & FILE_ATTRIBUTE_READONLY) &&
(create_options & NTCREATEX_OPTIONS_DELETE_ON_CLOSE)) {
return NT_STATUS_CANNOT_DELETE;
}
-
+
status = pvfs_access_check_create(pvfs, req, name, &access_mask);
NT_STATUS_NOT_OK_RETURN(status);
@@ -1110,6 +1132,41 @@ NTSTATUS pvfs_open(struct ntvfs_module_context *ntvfs,
return ntvfs_map_open(ntvfs, req, io);
}
+ create_options = io->generic.in.create_options;
+ share_access = io->generic.in.share_access;
+ access_mask = io->generic.in.access_mask;
+
+ if (share_access & ~NTCREATEX_SHARE_ACCESS_MASK) {
+ return NT_STATUS_INVALID_PARAMETER;
+ }
+
+ /* some create options are not supported */
+ if (create_options & NTCREATEX_OPTIONS_NOT_SUPPORTED_MASK) {
+ return NT_STATUS_NOT_SUPPORTED;
+ }
+
+ /* other create options are not allowed */
+ if ((create_options & NTCREATEX_OPTIONS_DELETE_ON_CLOSE) &&
+ !(access_mask & SEC_STD_DELETE)) {
+ return NT_STATUS_INVALID_PARAMETER;
+ }
+
+ if (access_mask & SEC_MASK_INVALID) {
+ return NT_STATUS_ACCESS_DENIED;
+ }
+
+ /* what does this bit really mean?? */
+ if (req->ctx->protocol == PROTOCOL_SMB2 &&
+ access_mask == SEC_STD_SYNCHRONIZE) {
+ return NT_STATUS_ACCESS_DENIED;
+ }
+
+ if (io->ntcreatex.in.file_attr & (FILE_ATTRIBUTE_DEVICE|
+ FILE_ATTRIBUTE_VOLUME|
+ (~FILE_ATTRIBUTE_ALL_MASK))) {
+ return NT_STATUS_INVALID_PARAMETER;
+ }
+
/* resolve the cifs name to a posix name */
status = pvfs_resolve_name(pvfs, req, io->ntcreatex.in.fname,
PVFS_RESOLVE_STREAMS, &name);
@@ -1141,16 +1198,6 @@ NTSTATUS pvfs_open(struct ntvfs_module_context *ntvfs,
open doesn't match */
io->generic.in.file_attr &= ~FILE_ATTRIBUTE_DIRECTORY;
- create_options = io->generic.in.create_options;
- share_access = io->generic.in.share_access;
- access_mask = io->generic.in.access_mask;
-
- /* certain create options are not allowed */
- if ((create_options & NTCREATEX_OPTIONS_DELETE_ON_CLOSE) &&
- !(access_mask & SEC_STD_DELETE)) {
- return NT_STATUS_INVALID_PARAMETER;
- }
-
flags = 0;
switch (io->generic.in.open_disposition) {
@@ -1467,21 +1514,44 @@ NTSTATUS pvfs_close(struct ntvfs_module_context *ntvfs,
return NT_STATUS_DOS(ERRSRV, ERRerror);
}
- if (io->generic.level != RAW_CLOSE_CLOSE) {
+ if (io->generic.level != RAW_CLOSE_GENERIC) {
return ntvfs_map_close(ntvfs, req, io);
}
- f = pvfs_find_fd(pvfs, req, io->close.in.file.ntvfs);
+ f = pvfs_find_fd(pvfs, req, io->generic.in.file.ntvfs);
if (!f) {
return NT_STATUS_INVALID_HANDLE;
}
- if (!null_time(io->close.in.write_time)) {
+ if (!null_time(io->generic.in.write_time)) {
unix_times.actime = 0;
unix_times.modtime = io->close.in.write_time;
utime(f->handle->name->full_name, &unix_times);
}
+ if (io->generic.in.flags & SMB2_CLOSE_FLAGS_FULL_INFORMATION) {
+ struct pvfs_filename *name;
+ NTSTATUS status;
+ struct pvfs_file_handle *h = f->handle;
+
+ status = pvfs_resolve_name_handle(pvfs, h);
+ if (!NT_STATUS_IS_OK(status)) {
+ return status;
+ }
+ name = h->name;
+
+ io->generic.out.flags = SMB2_CLOSE_FLAGS_FULL_INFORMATION;
+ io->generic.out.create_time = name->dos.create_time;
+ io->generic.out.access_time = name->dos.access_time;
+ io->generic.out.write_time = name->dos.write_time;
+ io->generic.out.change_time = name->dos.change_time;
+ io->generic.out.alloc_size = name->dos.alloc_size;
+ io->generic.out.size = name->st.st_size;
+ io->generic.out.file_attr = name->dos.attrib;
+ } else {
+ ZERO_STRUCT(io->generic.out);
+ }
+
talloc_free(f);
return NT_STATUS_OK;
diff --git a/source4/ntvfs/posix/pvfs_qfileinfo.c b/source4/ntvfs/posix/pvfs_qfileinfo.c
index 6bc21e5e3e..6e3092b744 100644
--- a/source4/ntvfs/posix/pvfs_qfileinfo.c
+++ b/source4/ntvfs/posix/pvfs_qfileinfo.c
@@ -301,7 +301,14 @@ static NTSTATUS pvfs_map_fileinfo(struct pvfs_state *pvfs,
info->all_info2.out.access_mask = 0; /* only set by qfileinfo */
info->all_info2.out.position = 0; /* only set by qfileinfo */
info->all_info2.out.mode = 0; /* only set by qfileinfo */
- info->all_info2.out.fname.s = name->original_name;
+ /* windows wants the full path on disk for this
+ result, but I really don't want to expose that on
+ the wire, so I'll give the path with a share
+ prefix, which is a good approximation */
+ info->all_info2.out.fname.s = talloc_asprintf(req, "\\%s\\%s",
+ pvfs->share_name,
+ name->original_name);
+ NT_STATUS_HAVE_NO_MEMORY(info->all_info2.out.fname.s);
return NT_STATUS_OK;
}
diff --git a/source4/ntvfs/posix/pvfs_read.c b/source4/ntvfs/posix/pvfs_read.c
index 418b7e09fb..a01a8a57e3 100644
--- a/source4/ntvfs/posix/pvfs_read.c
+++ b/source4/ntvfs/posix/pvfs_read.c
@@ -93,6 +93,14 @@ NTSTATUS pvfs_read(struct ntvfs_module_context *ntvfs,
return pvfs_map_errno(pvfs, errno);
}
+ /* only SMB2 honors mincnt */
+ if (req->ctx->protocol == PROTOCOL_SMB2) {
+ if (rd->readx.in.mincnt > ret ||
+ (ret == 0 && maxcnt > 0)) {
+ return NT_STATUS_END_OF_FILE;
+ }
+ }
+
f->handle->position = f->handle->seek_offset = rd->readx.in.offset + ret;
rd->readx.out.nread = ret;
diff --git a/source4/ntvfs/posix/pvfs_resolve.c b/source4/ntvfs/posix/pvfs_resolve.c
index 325bc74f8f..2e97925c49 100644
--- a/source4/ntvfs/posix/pvfs_resolve.c
+++ b/source4/ntvfs/posix/pvfs_resolve.c
@@ -202,7 +202,13 @@ static NTSTATUS parse_stream_name(struct pvfs_filename *name, const char *s)
}
*p = 0;
if (strcmp(name->stream_name, "") == 0) {
- name->stream_name = NULL;
+ /*
+ * we don't set stream_name to NULL, here
+ * as this would be wrong for directories
+ *
+ * pvfs_fill_dos_info() will set it to NULL
+ * if it's not a directory.
+ */
name->stream_id = 0;
} else {
name->stream_id = pvfs_name_hash(name->stream_name,
diff --git a/source4/ntvfs/posix/pvfs_streams.c b/source4/ntvfs/posix/pvfs_streams.c
index 7e6173ef2f..30d7ce2477 100644
--- a/source4/ntvfs/posix/pvfs_streams.c
+++ b/source4/ntvfs/posix/pvfs_streams.c
@@ -36,6 +36,13 @@ NTSTATUS pvfs_stream_information(struct pvfs_state *pvfs,
int i;
NTSTATUS status;
+ /* directories don't have streams */
+ if (name->dos.attrib & FILE_ATTRIBUTE_DIRECTORY) {
+ info->num_streams = 0;
+ info->streams = NULL;
+ return NT_STATUS_OK;
+ }
+
streams = talloc(mem_ctx, struct xattr_DosStreams);
if (streams == NULL) {
return NT_STATUS_NO_MEMORY;
@@ -269,9 +276,12 @@ ssize_t pvfs_stream_write(struct pvfs_state *pvfs,
if (count == 0) {
return 0;
}
- if (offset > XATTR_MAX_STREAM_SIZE) {
- errno = ENOSPC;
- return -1;
+
+ if (count+offset > XATTR_MAX_STREAM_SIZE) {
+ if (!pvfs->ea_db || count+offset > XATTR_MAX_STREAM_SIZE_TDB) {
+ errno = ENOSPC;
+ return -1;
+ }
}
/* we have to load the existing stream, then modify, then save */
@@ -325,7 +335,9 @@ NTSTATUS pvfs_stream_truncate(struct pvfs_state *pvfs,
DATA_BLOB blob;
if (length > XATTR_MAX_STREAM_SIZE) {
- return NT_STATUS_DISK_FULL;
+ if (!pvfs->ea_db || length > XATTR_MAX_STREAM_SIZE_TDB) {
+ return NT_STATUS_DISK_FULL;
+ }
}
/* we have to load the existing stream, then modify, then save */
diff --git a/source4/param/config.mk b/source4/param/config.mk
index 02474d50b9..c169ce157e 100644
--- a/source4/param/config.mk
+++ b/source4/param/config.mk
@@ -6,7 +6,7 @@ LIBSAMBA-HOSTCONFIG_VERSION = 0.0.1
LIBSAMBA-HOSTCONFIG_SOVERSION = 0
LIBSAMBA-HOSTCONFIG_OBJ_FILES = $(addprefix $(paramsrcdir)/, \
- loadparm.o generic.o util.o) lib/version.o
+ loadparm.o generic.o util.o)
PUBLIC_HEADERS += param/param.h
diff --git a/source4/param/loadparm.c b/source4/param/loadparm.c
index 812162e170..b70e4c19f0 100644
--- a/source4/param/loadparm.c
+++ b/source4/param/loadparm.c
@@ -54,7 +54,7 @@
#include "includes.h"
#include "version.h"
-#include "dynconfig.h"
+#include "dynconfig/dynconfig.h"
#include "system/time.h"
#include "system/locale.h"
#include "system/network.h" /* needed for TCP_NODELAY */
diff --git a/source4/param/param.i b/source4/param/param.i
index 2f62cb2f16..ad42919998 100644
--- a/source4/param/param.i
+++ b/source4/param/param.i
@@ -16,7 +16,7 @@
along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
-%module(package="samba.param") param
+%module(docstring="Parsing and writing Samba configuration files.",package="samba.param") param
%{
#include <stdint.h>
@@ -50,22 +50,36 @@ typedef struct loadparm_context {
%extend {
loadparm_context(TALLOC_CTX *mem_ctx) { return loadparm_init(mem_ctx); }
struct loadparm_service *default_service() { return lp_default_service($self); }
+ %feature("docstring") load "S.load(filename) -> None\n" \
+ "Load specified file.";
bool load(const char *filename) { return lp_load($self, filename); }
+ %feature("docstring") load_default "S.load_default() -> None\n" \
+ "Load default smb.conf file.";
bool load_default() { return lp_load_default($self); }
#ifdef SWIGPYTHON
int __len__() { return lp_numservices($self); }
struct loadparm_service *__getitem__(const char *name) { return lp_service($self, name); }
#endif
+ %feature("docstring") configfile "S.configfile() -> string\n" \
+ "Return name of last config file that was loaded.";
const char *configfile() { return lp_configfile($self); }
+ %feature("docstring") is_mydomain "S.is_mydomain(domain_name) -> bool\n" \
+ "Check whether the specified name matches our domain name.";
bool is_mydomain(const char *domain) { return lp_is_mydomain($self, domain); }
+ %feature("docstring") is_myname "S.is_myname(netbios_name) -> bool\n" \
+ "Check whether the specified name matches one of our netbios names.";
bool is_myname(const char *name) { return lp_is_myname($self, name); }
int use(struct param_context *param_ctx) { return param_use($self, param_ctx); }
+ %feature("docstring") set "S.set(name, value) -> bool\n" \
+ "Change a parameter.";
bool set(const char *parm_name, const char *parm_value) {
if (parm_value == NULL)
return false;
return lp_set_cmdline($self, parm_name, parm_value);
}
+ %feature("docstring") set "S.get(name, service_name) -> value\n" \
+ "Find specified parameter.";
PyObject *get(const char *param_name, const char *service_name)
{
struct parm_struct *parm = NULL;
@@ -180,7 +194,11 @@ typedef struct loadparm_service {
typedef struct param_context {
%extend {
param(TALLOC_CTX *mem_ctx) { return param_init(mem_ctx); }
+ %feature("docstring") add_section "S.get_section(name) -> section\n"
+ "Get an existing section.";
struct param_section *get_section(const char *name);
+ %feature("docstring") add_section "S.add_section(name) -> section\n"
+ "Add a new section.";
struct param_section *add_section(const char *name);
struct param_opt *get(const char *name, const char *section_name="global");
const char *get_string(const char *name, const char *section_name="global");
@@ -198,10 +216,18 @@ typedef struct param_context {
#endif
+ %feature("docstring") first_section "S.first_section() -> section\n"
+ "Find first section";
struct param_section *first_section() { return $self->sections; }
+ %feature("docstring") next_section "S.next_section(prev) -> section\n"
+ "Find next section";
struct param_section *next_section(struct param_section *s) { return s->next; }
+ %feature("docstring") read "S.read(filename) -> bool\n"
+ "Read a filename.";
int read(const char *fn);
+ %feature("docstring") read "S.write(filename) -> bool\n"
+ "Write this object to a file.";
int write(const char *fn);
}
%pythoncode {
diff --git a/source4/param/param.py b/source4/param/param.py
index 0419c75bfa..46c75cef97 100644
--- a/source4/param/param.py
+++ b/source4/param/param.py
@@ -3,6 +3,10 @@
#
# Don't modify this file, modify the SWIG interface instead.
+"""
+Parsing and writing Samba configuration files.
+"""
+
import _param
import new
new_instancemethod = new.instancemethod
@@ -62,6 +66,48 @@ class LoadParm(object):
__repr__ = _swig_repr
def __init__(self, *args, **kwargs):
_param.LoadParm_swiginit(self,_param.new_LoadParm(*args, **kwargs))
+ def load(*args, **kwargs):
+ """
+ S.load(filename) -> None
+ Load specified file.
+ """
+ return _param.LoadParm_load(*args, **kwargs)
+
+ def load_default(*args, **kwargs):
+ """
+ S.load_default() -> None
+ Load default smb.conf file.
+ """
+ return _param.LoadParm_load_default(*args, **kwargs)
+
+ def configfile(*args, **kwargs):
+ """
+ S.configfile() -> string
+ Return name of last config file that was loaded.
+ """
+ return _param.LoadParm_configfile(*args, **kwargs)
+
+ def is_mydomain(*args, **kwargs):
+ """
+ S.is_mydomain(domain_name) -> bool
+ Check whether the specified name matches our domain name.
+ """
+ return _param.LoadParm_is_mydomain(*args, **kwargs)
+
+ def is_myname(*args, **kwargs):
+ """
+ S.is_myname(netbios_name) -> bool
+ Check whether the specified name matches one of our netbios names.
+ """
+ return _param.LoadParm_is_myname(*args, **kwargs)
+
+ def set(*args, **kwargs):
+ """
+ S.set(name, value) -> bool
+ Change a parameter.
+ """
+ return _param.LoadParm_set(*args, **kwargs)
+
__swig_destroy__ = _param.delete_LoadParm
LoadParm.default_service = new_instancemethod(_param.LoadParm_default_service,None,LoadParm)
LoadParm.load = new_instancemethod(_param.LoadParm_load,None,LoadParm)
@@ -92,6 +138,34 @@ class ParamFile(object):
__repr__ = _swig_repr
def __init__(self, *args, **kwargs):
_param.ParamFile_swiginit(self,_param.new_ParamFile(*args, **kwargs))
+ def add_section(*args, **kwargs):
+ """
+ S.add_section(name) -> section
+ Add a new section.
+ """
+ return _param.ParamFile_add_section(*args, **kwargs)
+
+ def first_section(*args, **kwargs):
+ """
+ S.first_section() -> section
+ Find first section
+ """
+ return _param.ParamFile_first_section(*args, **kwargs)
+
+ def next_section(*args, **kwargs):
+ """
+ S.next_section(prev) -> section
+ Find next section
+ """
+ return _param.ParamFile_next_section(*args, **kwargs)
+
+ def read(*args, **kwargs):
+ """
+ S.read(filename) -> bool
+ Read a filename.
+ """
+ return _param.ParamFile_read(*args, **kwargs)
+
def __getitem__(self, name):
ret = self.get_section(name)
if ret is None:
diff --git a/source4/param/param_wrap.c b/source4/param/param_wrap.c
index d07be04a66..aff239312d 100644
--- a/source4/param/param_wrap.c
+++ b/source4/param/param_wrap.c
@@ -4168,15 +4168,33 @@ SWIGINTERN PyObject *Swig_var_default_config_get(void) {
static PyMethodDef SwigMethods[] = {
{ (char *)"new_LoadParm", (PyCFunction)_wrap_new_LoadParm, METH_NOARGS, NULL},
{ (char *)"LoadParm_default_service", (PyCFunction) _wrap_LoadParm_default_service, METH_VARARGS | METH_KEYWORDS, NULL},
- { (char *)"LoadParm_load", (PyCFunction) _wrap_LoadParm_load, METH_VARARGS | METH_KEYWORDS, NULL},
- { (char *)"LoadParm_load_default", (PyCFunction) _wrap_LoadParm_load_default, METH_VARARGS | METH_KEYWORDS, NULL},
+ { (char *)"LoadParm_load", (PyCFunction) _wrap_LoadParm_load, METH_VARARGS | METH_KEYWORDS, (char *)"\n"
+ "S.load(filename) -> None\n"
+ "Load specified file.\n"
+ ""},
+ { (char *)"LoadParm_load_default", (PyCFunction) _wrap_LoadParm_load_default, METH_VARARGS | METH_KEYWORDS, (char *)"\n"
+ "S.load_default() -> None\n"
+ "Load default smb.conf file.\n"
+ ""},
{ (char *)"LoadParm___len__", (PyCFunction) _wrap_LoadParm___len__, METH_VARARGS | METH_KEYWORDS, NULL},
{ (char *)"LoadParm___getitem__", (PyCFunction) _wrap_LoadParm___getitem__, METH_VARARGS | METH_KEYWORDS, NULL},
- { (char *)"LoadParm_configfile", (PyCFunction) _wrap_LoadParm_configfile, METH_VARARGS | METH_KEYWORDS, NULL},
- { (char *)"LoadParm_is_mydomain", (PyCFunction) _wrap_LoadParm_is_mydomain, METH_VARARGS | METH_KEYWORDS, NULL},
- { (char *)"LoadParm_is_myname", (PyCFunction) _wrap_LoadParm_is_myname, METH_VARARGS | METH_KEYWORDS, NULL},
+ { (char *)"LoadParm_configfile", (PyCFunction) _wrap_LoadParm_configfile, METH_VARARGS | METH_KEYWORDS, (char *)"\n"
+ "S.configfile() -> string\n"
+ "Return name of last config file that was loaded.\n"
+ ""},
+ { (char *)"LoadParm_is_mydomain", (PyCFunction) _wrap_LoadParm_is_mydomain, METH_VARARGS | METH_KEYWORDS, (char *)"\n"
+ "S.is_mydomain(domain_name) -> bool\n"
+ "Check whether the specified name matches our domain name.\n"
+ ""},
+ { (char *)"LoadParm_is_myname", (PyCFunction) _wrap_LoadParm_is_myname, METH_VARARGS | METH_KEYWORDS, (char *)"\n"
+ "S.is_myname(netbios_name) -> bool\n"
+ "Check whether the specified name matches one of our netbios names.\n"
+ ""},
{ (char *)"LoadParm_use", (PyCFunction) _wrap_LoadParm_use, METH_VARARGS | METH_KEYWORDS, NULL},
- { (char *)"LoadParm_set", (PyCFunction) _wrap_LoadParm_set, METH_VARARGS | METH_KEYWORDS, NULL},
+ { (char *)"LoadParm_set", (PyCFunction) _wrap_LoadParm_set, METH_VARARGS | METH_KEYWORDS, (char *)"\n"
+ "S.set(name, value) -> bool\n"
+ "Change a parameter.\n"
+ ""},
{ (char *)"LoadParm_get", (PyCFunction) _wrap_LoadParm_get, METH_VARARGS | METH_KEYWORDS, NULL},
{ (char *)"delete_LoadParm", (PyCFunction) _wrap_delete_LoadParm, METH_VARARGS | METH_KEYWORDS, NULL},
{ (char *)"LoadParm_swigregister", LoadParm_swigregister, METH_VARARGS, NULL},
@@ -4187,14 +4205,26 @@ static PyMethodDef SwigMethods[] = {
{ (char *)"loadparm_service_swigregister", loadparm_service_swigregister, METH_VARARGS, NULL},
{ (char *)"new_ParamFile", (PyCFunction)_wrap_new_ParamFile, METH_NOARGS, NULL},
{ (char *)"ParamFile_get_section", (PyCFunction) _wrap_ParamFile_get_section, METH_VARARGS | METH_KEYWORDS, NULL},
- { (char *)"ParamFile_add_section", (PyCFunction) _wrap_ParamFile_add_section, METH_VARARGS | METH_KEYWORDS, NULL},
+ { (char *)"ParamFile_add_section", (PyCFunction) _wrap_ParamFile_add_section, METH_VARARGS | METH_KEYWORDS, (char *)"\n"
+ "S.add_section(name) -> section\n"
+ "Add a new section.\n"
+ ""},
{ (char *)"ParamFile_get", (PyCFunction) _wrap_ParamFile_get, METH_VARARGS | METH_KEYWORDS, NULL},
{ (char *)"ParamFile_get_string", (PyCFunction) _wrap_ParamFile_get_string, METH_VARARGS | METH_KEYWORDS, NULL},
{ (char *)"ParamFile_set_string", (PyCFunction) _wrap_ParamFile_set_string, METH_VARARGS | METH_KEYWORDS, NULL},
{ (char *)"ParamFile_set", (PyCFunction) _wrap_ParamFile_set, METH_VARARGS | METH_KEYWORDS, NULL},
- { (char *)"ParamFile_first_section", (PyCFunction)_wrap_ParamFile_first_section, METH_O, NULL},
- { (char *)"ParamFile_next_section", (PyCFunction) _wrap_ParamFile_next_section, METH_VARARGS | METH_KEYWORDS, NULL},
- { (char *)"ParamFile_read", (PyCFunction) _wrap_ParamFile_read, METH_VARARGS | METH_KEYWORDS, NULL},
+ { (char *)"ParamFile_first_section", (PyCFunction)_wrap_ParamFile_first_section, METH_O, (char *)"\n"
+ "S.first_section() -> section\n"
+ "Find first section\n"
+ ""},
+ { (char *)"ParamFile_next_section", (PyCFunction) _wrap_ParamFile_next_section, METH_VARARGS | METH_KEYWORDS, (char *)"\n"
+ "S.next_section(prev) -> section\n"
+ "Find next section\n"
+ ""},
+ { (char *)"ParamFile_read", (PyCFunction) _wrap_ParamFile_read, METH_VARARGS | METH_KEYWORDS, (char *)"\n"
+ "S.read(filename) -> bool\n"
+ "Read a filename.\n"
+ ""},
{ (char *)"ParamFile_write", (PyCFunction) _wrap_ParamFile_write, METH_VARARGS | METH_KEYWORDS, NULL},
{ (char *)"delete_ParamFile", (PyCFunction)_wrap_delete_ParamFile, METH_O, NULL},
{ (char *)"ParamFile_swigregister", ParamFile_swigregister, METH_VARARGS, NULL},
diff --git a/source4/param/util.c b/source4/param/util.c
index 2baaefda8b..15e3b4768c 100644
--- a/source4/param/util.c
+++ b/source4/param/util.c
@@ -23,7 +23,7 @@
*/
#include "includes.h"
-#include "dynconfig.h"
+#include "dynconfig/dynconfig.h"
#include "system/network.h"
#include "system/filesys.h"
#include "system/dir.h"
diff --git a/source4/pidl/TODO b/source4/pidl/TODO
index f1cca0ab23..bc5c49a46f 100644
--- a/source4/pidl/TODO
+++ b/source4/pidl/TODO
@@ -1,6 +1,3 @@
-- EJS output backend shouldn't use the NDR levels stuff but instead
- as the "C levels" and NDR levels don't necessarily match.
-
- true multiple dimension array / strings in arrays support
- compatibility mode for generating MIDL-readable data:
@@ -31,3 +28,15 @@
- remove NDR_AUTO_REF_ALLOC flag
- automatic test generator based on IDL pointer types
+
+- support converting structs to tuples in Python rather than objects
+- convert structs with a single mattering member to that member directly, e.g.:
+ struct bar {
+ int size;
+ [size_is(size)] uint32 *array;
+ };
+
+ should be converted to an array of uint32's
+
+- python: fill in size members automatically in some places if the struct isn't being returned
+ (so we don't have to cope with the array growing)
diff --git a/source4/pidl/lib/Parse/Pidl/Samba4/Python.pm b/source4/pidl/lib/Parse/Pidl/Samba4/Python.pm
index 884ee1d822..60d0dafc8a 100644
--- a/source4/pidl/lib/Parse/Pidl/Samba4/Python.pm
+++ b/source4/pidl/lib/Parse/Pidl/Samba4/Python.pm
@@ -21,7 +21,8 @@ $VERSION = '0.01';
sub new($) {
my ($class) = @_;
my $self = { res => "", res_hdr => "", tabs => "", constants => {},
- module_methods => [], module_objects => [], module_types => []};
+ module_methods => [], module_objects => [], ready_types => [],
+ readycode => [] };
bless($self, $class);
}
@@ -107,7 +108,7 @@ sub FromUnionToPythonFunction($$$$)
$self->indent;
if ($e->{NAME}) {
- $self->ConvertObjectToPython($mem_ctx, {}, $e, "$name->$e->{NAME}", "ret");
+ $self->ConvertObjectToPython($mem_ctx, {}, $e, "$name->$e->{NAME}", "ret", "return NULL;");
} else {
$self->pidl("ret = Py_None;");
}
@@ -181,7 +182,7 @@ sub PythonStruct($$$$$$)
$self->indent;
$self->pidl("$cname *object = py_talloc_get_ptr(obj);");
$self->pidl("PyObject *py_$e->{NAME};");
- $self->ConvertObjectToPython("py_talloc_get_mem_ctx(obj)", $env, $e, $varname, "py_$e->{NAME}");
+ $self->ConvertObjectToPython("py_talloc_get_mem_ctx(obj)", $env, $e, $varname, "py_$e->{NAME}", "return NULL;");
$self->pidl("return py_$e->{NAME};");
$self->deindent;
$self->pidl("}");
@@ -203,7 +204,7 @@ sub PythonStruct($$$$$$)
$self->pidl("return 0;");
$self->deindent;
$self->pidl("}");
- $self->pidl("");
+ $self->pidl("");
}
$getsetters = "py_$name\_getsetters";
@@ -225,9 +226,64 @@ sub PythonStruct($$$$$$)
$self->pidl("return py_talloc_import(&$name\_Type, ret);");
$self->deindent;
$self->pidl("}");
-
$self->pidl("");
+ my $py_methods = "NULL";
+
+ # If the struct is not public there ndr_pull/ndr_push functions will
+ # be static so not callable from here
+ if (has_property($d, "public")) {
+ $self->pidl("static PyObject *py_$name\_ndr_pack(PyObject *py_obj)");
+ $self->pidl("{");
+ $self->indent;
+ $self->pidl("$cname *object = py_talloc_get_ptr(py_obj);");
+ $self->pidl("DATA_BLOB blob;");
+ $self->pidl("enum ndr_err_code err;");
+ $self->pidl("err = ndr_push_struct_blob(&blob, py_talloc_get_mem_ctx(py_obj), NULL, object, (ndr_push_flags_fn_t)ndr_push_$name);");
+ $self->pidl("if (err != NDR_ERR_SUCCESS) {");
+ $self->indent;
+ $self->pidl("PyErr_SetNdrError(err);");
+ $self->pidl("return NULL;");
+ $self->deindent;
+ $self->pidl("}");
+ $self->pidl("");
+ $self->pidl("return PyString_FromStringAndSize((char *)blob.data, blob.length);");
+ $self->deindent;
+ $self->pidl("}");
+ $self->pidl("");
+
+ $self->pidl("static PyObject *py_$name\_ndr_unpack(PyObject *py_obj, PyObject *args)");
+ $self->pidl("{");
+ $self->indent;
+ $self->pidl("$cname *object = py_talloc_get_ptr(py_obj);");
+ $self->pidl("DATA_BLOB blob;");
+ $self->pidl("enum ndr_err_code err;");
+ $self->pidl("if (!PyArg_ParseTuple(args, \"s#:__ndr_unpack__\", &blob.data, &blob.length))");
+ $self->pidl("\treturn NULL;");
+ $self->pidl("");
+ $self->pidl("err = ndr_pull_struct_blob_all(&blob, py_talloc_get_mem_ctx(py_obj), NULL, object, (ndr_pull_flags_fn_t)ndr_pull_$name);");
+ $self->pidl("if (err != NDR_ERR_SUCCESS) {");
+ $self->indent;
+ $self->pidl("PyErr_SetNdrError(err);");
+ $self->pidl("return NULL;");
+ $self->deindent;
+ $self->pidl("}");
+ $self->pidl("");
+ $self->pidl("return Py_None;");
+ $self->deindent;
+ $self->pidl("}");
+ $self->pidl("");
+ $py_methods = "py_$name\_methods";
+ $self->pidl("static PyMethodDef $py_methods\[] = {");
+ $self->indent;
+ $self->pidl("{ \"__ndr_pack__\", (PyCFunction)py_$name\_ndr_pack, METH_NOARGS, \"S.pack() -> blob\\nNDR pack\" },");
+ $self->pidl("{ \"__ndr_unpack__\", (PyCFunction)py_$name\_ndr_unpack, METH_VARARGS, \"S.unpack(blob) -> None\\nNDR unpack\" },");
+ $self->pidl("{ NULL, NULL, 0, NULL }");
+ $self->deindent;
+ $self->pidl("};");
+ $self->pidl("");
+ }
+
$self->pidl_hdr("PyAPI_DATA(PyTypeObject) $name\_Type;\n");
$self->pidl_hdr("#define $name\_Check(op) PyObject_TypeCheck(op, &$name\_Type)\n");
$self->pidl_hdr("#define $name\_CheckExact(op) ((op)->ob_type == &$name\_Type)\n");
@@ -243,6 +299,7 @@ sub PythonStruct($$$$$$)
$self->pidl(".tp_getset = $getsetters,");
$self->pidl(".tp_repr = py_talloc_default_repr,");
$self->pidl(".tp_doc = $docstring,");
+ $self->pidl(".tp_methods = $py_methods,");
$self->pidl(".tp_flags = Py_TPFLAGS_DEFAULT | Py_TPFLAGS_BASETYPE,");
$self->pidl(".tp_new = py_$name\_new,");
$self->deindent;
@@ -253,102 +310,66 @@ sub PythonStruct($$$$$$)
return "&$typeobject";
}
-sub PythonFunctionBody($$$)
+sub get_metadata_var($)
{
- my ($self, $fn, $iface, $prettyname) = @_;
-
- $self->pidl("$iface\_InterfaceObject *iface = ($iface\_InterfaceObject *)self;");
- $self->pidl("NTSTATUS status;");
- $self->pidl("TALLOC_CTX *mem_ctx = talloc_new(NULL);");
- $self->pidl("struct $fn->{NAME} *r = talloc_zero(mem_ctx, struct $fn->{NAME});");
- $self->pidl("PyObject *result = Py_None;");
-
- my $env = GenerateFunctionInEnv($fn, "r->");
- my $result_size = 0;
+ my ($e) = @_;
+ sub get_var($) { my $x = shift; $x =~ s/\*//g; return $x; }
- my $args_format = "";
- my $args_string = "";
- my $args_names = "";
+ if (has_property($e, "length_is")) {
+ return get_var($e->{PROPERTIES}->{length_is});
+ } elsif (has_property($e, "size_is")) {
+ return get_var($e->{PROPERTIES}->{size_is});
+ }
- my $signature = "S.$prettyname(";
+ return undef;
+}
+sub find_metadata_args($)
+{
+ my ($fn) = @_;
my $metadata_args = { in => {}, out => {} };
- sub get_var($) { my $x = shift; $x =~ s/\*//g; return $x; }
-
# Determine arguments that are metadata for other arguments (size_is/length_is)
foreach my $e (@{$fn->{ELEMENTS}}) {
foreach my $dir (@{$e->{DIRECTION}}) {
- my $main = undef;
- if (has_property($e, "length_is")) {
- $main = get_var($e->{PROPERTIES}->{length_is});
- } elsif (has_property($e, "size_is")) {
- $main = get_var($e->{PROPERTIES}->{size_is});
- }
+ my $main = get_metadata_var($e);
if ($main) {
$metadata_args->{$dir}->{$main} = $e->{NAME};
}
}
}
+ return $metadata_args;
+}
+
+sub PythonFunctionUnpackOut($$$)
+{
+ my ($self, $fn, $fnname) = @_;
+
+ my $outfnname = "unpack_$fnname\_args_out";
+ my $signature = "";
+
+ my $metadata_args = find_metadata_args($fn);
+
+ my $env = GenerateFunctionOutEnv($fn, "r->");
+ my $result_size = 0;
+
+ $self->pidl("static PyObject *$outfnname(struct $fn->{NAME} *r)");
+ $self->pidl("{");
+ $self->indent;
+ $self->pidl("PyObject *result = Py_None;");
foreach my $e (@{$fn->{ELEMENTS}}) {
+ next unless (grep(/out/,@{$e->{DIRECTION}}));
next if (($metadata_args->{in}->{$e->{NAME}} and grep(/in/, @{$e->{DIRECTION}})) or
($metadata_args->{out}->{$e->{NAME}}) and grep(/out/, @{$e->{DIRECTION}}));
$self->pidl("PyObject *py_$e->{NAME};");
- if (grep(/out/,@{$e->{DIRECTION}})) {
- $result_size++;
- }
- if (grep(/in/,@{$e->{DIRECTION}})) {
- $args_format .= "O";
- $args_string .= ", &py_$e->{NAME}";
- $args_names .= "\"$e->{NAME}\", ";
- $signature .= "$e->{NAME}, ";
- }
+ $result_size++;
}
- if (substr($signature, -2) eq ", ") {
- $signature = substr($signature, 0, -2);
- }
- $signature.= ") -> ";
-
- $self->pidl("const char *kwnames[] = {");
- $self->indent;
- $self->pidl($args_names . "NULL");
- $self->deindent;
- $self->pidl("};");
-
- $self->pidl("");
- $self->pidl("if (!PyArg_ParseTupleAndKeywords(args, kwargs, \"$args_format:$fn->{NAME}\", discard_const_p(char *, kwnames)$args_string)) {");
- $self->indent;
- $self->pidl("return NULL;");
- $self->deindent;
- $self->pidl("}");
- $self->pidl("");
if ($fn->{RETURN_TYPE}) {
$result_size++ unless ($fn->{RETURN_TYPE} eq "WERROR" or $fn->{RETURN_TYPE} eq "NTSTATUS");
}
- my $fail = "talloc_free(mem_ctx); return NULL;";
- foreach my $e (@{$fn->{ELEMENTS}}) {
- next unless (grep(/in/,@{$e->{DIRECTION}}));
- if ($metadata_args->{in}->{$e->{NAME}}) {
- my $py_var = "py_".$metadata_args->{in}->{$e->{NAME}};
- $self->pidl("PY_CHECK_TYPE(PyList, $py_var, $fail);");
- my $val = "PyList_Size($py_var)";
- if ($e->{LEVELS}[0]->{TYPE} eq "POINTER") {
- $self->pidl("r->in.$e->{NAME} = talloc_ptrtype(mem_ctx, r->in.$e->{NAME});");
- $self->pidl("*r->in.$e->{NAME} = $val;");
- } else {
- $self->pidl("r->in.$e->{NAME} = $val;");
- }
- } else {
- $self->ConvertObjectFromPython($env, "mem_ctx", $e, "py_$e->{NAME}", "r->in.$e->{NAME}", $fail);
- }
- }
- $self->pidl("status = dcerpc_$fn->{NAME}(iface->pipe, mem_ctx, r);");
- $self->handle_ntstatus("status", "NULL", "mem_ctx");
-
- $env = GenerateFunctionOutEnv($fn, "r->");
my $i = 0;
if ($result_size > 1) {
@@ -362,7 +383,7 @@ sub PythonFunctionBody($$$)
next if ($metadata_args->{out}->{$e->{NAME}});
my $py_name = "py_$e->{NAME}";
if (grep(/out/,@{$e->{DIRECTION}})) {
- $self->ConvertObjectToPython("r", $env, $e, "r->out.$e->{NAME}", $py_name);
+ $self->ConvertObjectToPython("r", $env, $e, "r->out.$e->{NAME}", $py_name, "return NULL;");
if ($result_size > 1) {
$self->pidl("PyTuple_SetItem(result, $i, $py_name);");
$i++;
@@ -375,9 +396,9 @@ sub PythonFunctionBody($$$)
}
if (defined($fn->{RETURN_TYPE}) and $fn->{RETURN_TYPE} eq "NTSTATUS") {
- $self->handle_ntstatus("r->out.result", "NULL", "mem_ctx");
+ $self->handle_ntstatus("r->out.result", "NULL", undef);
} elsif (defined($fn->{RETURN_TYPE}) and $fn->{RETURN_TYPE} eq "WERROR") {
- $self->handle_werror("r->out.result", "NULL", "mem_ctx");
+ $self->handle_werror("r->out.result", "NULL", undef);
} elsif (defined($fn->{RETURN_TYPE})) {
my $conv = $self->ConvertObjectToPythonData("r", $fn->{RETURN_TYPE}, "r->out.result");
if ($result_size > 1) {
@@ -395,10 +416,80 @@ sub PythonFunctionBody($$$)
$signature .= ")";
}
- $self->pidl("talloc_free(mem_ctx);");
$self->pidl("return result;");
+ $self->deindent;
+ $self->pidl("}");
+ $self->pidl("");
+
+ return ($outfnname, $signature);
+}
+
+sub PythonFunctionPackIn($$$)
+{
+ my ($self, $fn, $fnname) = @_;
+ my $metadata_args = find_metadata_args($fn);
+
+ my $infnname = "pack_$fnname\_args_in";
- return $signature;
+ $self->pidl("static bool $infnname(PyObject *args, PyObject *kwargs, struct $fn->{NAME} *r)");
+ $self->pidl("{");
+ $self->indent;
+ my $args_format = "";
+ my $args_string = "";
+ my $args_names = "";
+ my $signature = "";
+
+ foreach my $e (@{$fn->{ELEMENTS}}) {
+ next unless (grep(/in/,@{$e->{DIRECTION}}));
+ next if (($metadata_args->{in}->{$e->{NAME}} and grep(/in/, @{$e->{DIRECTION}})) or
+ ($metadata_args->{out}->{$e->{NAME}}) and grep(/out/, @{$e->{DIRECTION}}));
+ $self->pidl("PyObject *py_$e->{NAME};");
+ $args_format .= "O";
+ $args_string .= ", &py_$e->{NAME}";
+ $args_names .= "\"$e->{NAME}\", ";
+ $signature .= "$e->{NAME}, ";
+ }
+ if (substr($signature, -2) eq ", ") {
+ $signature = substr($signature, 0, -2);
+ }
+ $self->pidl("const char *kwnames[] = {");
+ $self->indent;
+ $self->pidl($args_names . "NULL");
+ $self->deindent;
+ $self->pidl("};");
+
+ $self->pidl("");
+ $self->pidl("if (!PyArg_ParseTupleAndKeywords(args, kwargs, \"$args_format:$fn->{NAME}\", discard_const_p(char *, kwnames)$args_string)) {");
+ $self->indent;
+ $self->pidl("return false;");
+ $self->deindent;
+ $self->pidl("}");
+ $self->pidl("");
+
+ my $env = GenerateFunctionInEnv($fn, "r->");
+
+ my $fail = "return false;";
+ foreach my $e (@{$fn->{ELEMENTS}}) {
+ next unless (grep(/in/,@{$e->{DIRECTION}}));
+ if ($metadata_args->{in}->{$e->{NAME}}) {
+ my $py_var = "py_".$metadata_args->{in}->{$e->{NAME}};
+ $self->pidl("PY_CHECK_TYPE(PyList, $py_var, $fail);");
+ my $val = "PyList_Size($py_var)";
+ if ($e->{LEVELS}[0]->{TYPE} eq "POINTER") {
+ $self->pidl("r->in.$e->{NAME} = talloc_ptrtype(r, r->in.$e->{NAME});");
+ $self->pidl("*r->in.$e->{NAME} = $val;");
+ } else {
+ $self->pidl("r->in.$e->{NAME} = $val;");
+ }
+ } else {
+ $self->ConvertObjectFromPython($env, "r", $e, "py_$e->{NAME}", "r->in.$e->{NAME}", $fail);
+ }
+ }
+ $self->pidl("return true;");
+ $self->deindent;
+ $self->pidl("}");
+ $self->pidl("");
+ return ($infnname, $signature);
}
sub PythonFunction($$$)
@@ -408,16 +499,17 @@ sub PythonFunction($$$)
my $fnname = "py_$fn->{NAME}";
my $docstring = $self->DocString($fn, $fn->{NAME});
- $self->pidl("static PyObject *$fnname(PyObject *self, PyObject *args, PyObject *kwargs)");
- $self->pidl("{");
- $self->indent;
+ my ($insignature, $outsignature);
+ my ($infn, $outfn);
+
if (has_property($fn, "todo")) {
- $self->pidl("PyErr_SetString(PyExc_NotImplementedError, \"No marshalling code available yet for $prettyname\");");
- $self->pidl("return NULL;");
unless ($docstring) { $docstring = "NULL"; }
+ $infn = "NULL";
+ $outfn = "NULL";
} else {
- my $signature = $self->PythonFunctionBody($fn, $iface, $prettyname);
-
+ ($infn, $insignature) = $self->PythonFunctionPackIn($fn, $fnname);
+ ($outfn, $outsignature) = $self->PythonFunctionUnpackOut($fn, $fnname);
+ my $signature = "S.$prettyname($insignature) -> $outsignature";
if ($docstring) {
$docstring = "\"$signature\\n\\n\"$docstring";
} else {
@@ -425,11 +517,7 @@ sub PythonFunction($$$)
}
}
- $self->deindent;
- $self->pidl("}");
- $self->pidl("");
-
- return ($fnname, $docstring);
+ return ($infn, $outfn, $docstring);
}
sub handle_werror($$$$)
@@ -438,7 +526,7 @@ sub handle_werror($$$$)
$self->pidl("if (!W_ERROR_IS_OK($var)) {");
$self->indent;
- $self->pidl("PyErr_SetString(PyExc_RuntimeError, win_errstr($var));");
+ $self->pidl("PyErr_SetWERROR($var);");
$self->pidl("talloc_free($mem_ctx);") if ($mem_ctx);
$self->pidl("return $retval;");
$self->deindent;
@@ -452,7 +540,7 @@ sub handle_ntstatus($$$$)
$self->pidl("if (NT_STATUS_IS_ERR($var)) {");
$self->indent;
- $self->pidl("PyErr_SetString(PyExc_RuntimeError, nt_errstr($var));");
+ $self->pidl("PyErr_SetNTSTATUS($var);");
$self->pidl("talloc_free($mem_ctx);") if ($mem_ctx);
$self->pidl("return $retval;");
$self->deindent;
@@ -544,13 +632,6 @@ sub Interface($$$)
if (defined $interface->{PROPERTIES}->{uuid}) {
$self->pidl_hdr("PyAPI_DATA(PyTypeObject) $interface->{NAME}_InterfaceType;\n");
- $self->pidl("typedef struct {");
- $self->indent;
- $self->pidl("PyObject_HEAD");
- $self->pidl("struct dcerpc_pipe *pipe;");
- $self->deindent;
- $self->pidl("} $interface->{NAME}_InterfaceObject;");
-
$self->pidl("");
my @fns = ();
@@ -564,53 +645,44 @@ sub Interface($$$)
$prettyname =~ s/^$interface->{NAME}_//;
$prettyname =~ s/^$basename\_//;
- my ($fnname, $fndocstring) = $self->PythonFunction($d, $interface->{NAME}, $prettyname);
+ my ($infn, $outfn, $fndocstring) = $self->PythonFunction($d, $interface->{NAME}, $prettyname);
- push (@fns, [$fnname, $prettyname, $fndocstring]);
+ push (@fns, [$infn, $outfn, "dcerpc_$d->{NAME}", $prettyname, $fndocstring, $d->{OPNUM}]);
}
- $self->pidl("static PyMethodDef interface_$interface->{NAME}\_methods[] = {");
+ $self->pidl("const struct PyNdrRpcMethodDef py_ndr_$interface->{NAME}\_methods[] = {");
+ $self->pidl_hdr("extern const struct PyNdrRpcMethodDef py_ndr_$interface->{NAME}\_methods[];");
$self->indent;
foreach my $d (@fns) {
- my ($c_fn, $prettyname, $docstring) = @$d;
- $self->pidl("{ \"$prettyname\", (PyCFunction)$c_fn, METH_VARARGS|METH_KEYWORDS, $docstring },");
+ my ($infn, $outfn, $callfn, $prettyname, $docstring, $opnum) = @$d;
+ $self->pidl("{ \"$prettyname\", $docstring, (dcerpc_call_fn)$callfn, (py_data_pack_fn)$infn, (py_data_unpack_fn)$outfn, $opnum, &ndr_table_$interface->{NAME} },");
}
- $self->pidl("{ NULL, NULL, 0, NULL }");
+ $self->pidl("{ NULL }");
$self->deindent;
$self->pidl("};");
$self->pidl("");
- $self->pidl("static void interface_$interface->{NAME}_dealloc(PyObject* self)");
- $self->pidl("{");
- $self->indent;
- $self->pidl("$interface->{NAME}_InterfaceObject *interface = ($interface->{NAME}_InterfaceObject *)self;");
- $self->pidl("talloc_free(interface->pipe);");
- $self->pidl("PyObject_Del(self);");
- $self->deindent;
- $self->pidl("}");
- $self->pidl("");
-
$self->pidl("static PyObject *interface_$interface->{NAME}_new(PyTypeObject *self, PyObject *args, PyObject *kwargs)");
$self->pidl("{");
$self->indent;
- $self->pidl("$interface->{NAME}_InterfaceObject *ret;");
+ $self->pidl("dcerpc_InterfaceObject *ret;");
$self->pidl("const char *binding_string;");
$self->pidl("struct cli_credentials *credentials;");
$self->pidl("struct loadparm_context *lp_ctx = NULL;");
- $self->pidl("PyObject *py_lp_ctx = Py_None, *py_credentials = Py_None;");
+ $self->pidl("PyObject *py_lp_ctx = Py_None, *py_credentials = Py_None, *py_basis = Py_None;");
$self->pidl("TALLOC_CTX *mem_ctx = NULL;");
$self->pidl("struct event_context *event_ctx;");
$self->pidl("NTSTATUS status;");
$self->pidl("");
$self->pidl("const char *kwnames[] = {");
$self->indent;
- $self->pidl("\"binding\", \"lp_ctx\", \"credentials\", NULL");
+ $self->pidl("\"binding\", \"lp_ctx\", \"credentials\", \"basis_connection\", NULL");
$self->deindent;
$self->pidl("};");
$self->pidl("extern struct loadparm_context *lp_from_py_object(PyObject *py_obj);");
$self->pidl("extern struct cli_credentials *cli_credentials_from_py_object(PyObject *py_obj);");
$self->pidl("");
- $self->pidl("if (!PyArg_ParseTupleAndKeywords(args, kwargs, \"s|OO:$interface->{NAME}\", discard_const_p(char *, kwnames), &binding_string, &py_lp_ctx, &py_credentials)) {");
+ $self->pidl("if (!PyArg_ParseTupleAndKeywords(args, kwargs, \"s|OOO:$interface->{NAME}\", discard_const_p(char *, kwnames), &binding_string, &py_lp_ctx, &py_credentials, &py_basis)) {");
$self->indent;
$self->pidl("return NULL;");
$self->deindent;
@@ -633,13 +705,33 @@ sub Interface($$$)
$self->deindent;
$self->pidl("}");
- $self->pidl("ret = PyObject_New($interface->{NAME}_InterfaceObject, &$interface->{NAME}_InterfaceType);");
+ $self->pidl("ret = PyObject_New(dcerpc_InterfaceObject, &$interface->{NAME}_InterfaceType);");
$self->pidl("");
$self->pidl("event_ctx = event_context_init(mem_ctx);");
$self->pidl("");
+ $self->pidl("if (py_basis != Py_None) {");
+ $self->indent;
+ $self->pidl("struct dcerpc_pipe *base_pipe;");
+ $self->pidl("");
+ $self->pidl("if (!PyObject_TypeCheck(py_basis, &dcerpc_InterfaceType)) {");
+ $self->indent;
+ $self->pidl("PyErr_SetString(PyExc_ValueError, \"basis_connection must be a DCE/RPC connection\");");
+ $self->pidl("talloc_free(mem_ctx);");
+ $self->pidl("return NULL;");
+ $self->deindent;
+ $self->pidl("}");
+ $self->pidl("");
+ $self->pidl("base_pipe = ((dcerpc_InterfaceObject *)py_basis)->pipe;");
+ $self->pidl("");
+ $self->pidl("status = dcerpc_secondary_context(base_pipe, &ret->pipe, &ndr_table_$interface->{NAME});");
+ $self->deindent;
+ $self->pidl("} else {");
+ $self->indent;
$self->pidl("status = dcerpc_pipe_connect(NULL, &ret->pipe, binding_string, ");
$self->pidl(" &ndr_table_$interface->{NAME}, credentials, event_ctx, lp_ctx);");
+ $self->deindent;
+ $self->pidl("}");
$self->handle_ntstatus("status", "NULL", "mem_ctx");
$self->pidl("ret->pipe->conn->flags |= DCERPC_NDR_REF_ALLOC;");
@@ -651,7 +743,7 @@ sub Interface($$$)
$self->pidl("");
my $signature =
-"\"$interface->{NAME}(binding, lp_ctx=None, credentials=None) -> Connection to DCE/RPC interface.\\n\"
+"\"$interface->{NAME}(binding, lp_ctx=None, credentials=None) -> connection\\n\"
\"\\n\"
\"binding should be a DCE/RPC binding string (for example: ncacn_ip_tcp:127.0.0.1)\\n\"
\"lp_ctx should be a path to a smb.conf file or a param.LoadParm object\\n\"
@@ -669,9 +761,8 @@ sub Interface($$$)
$self->indent;
$self->pidl("PyObject_HEAD_INIT(NULL) 0,");
$self->pidl(".tp_name = \"$basename.$interface->{NAME}\",");
- $self->pidl(".tp_basicsize = sizeof($interface->{NAME}_InterfaceObject),");
- $self->pidl(".tp_dealloc = interface_$interface->{NAME}_dealloc,");
- $self->pidl(".tp_methods = interface_$interface->{NAME}_methods,");
+ $self->pidl(".tp_basicsize = sizeof(dcerpc_InterfaceObject),");
+ $self->pidl(".tp_base = &dcerpc_InterfaceType,");
$self->pidl(".tp_doc = $docstring,");
$self->pidl(".tp_flags = Py_TPFLAGS_DEFAULT | Py_TPFLAGS_BASETYPE,");
$self->pidl(".tp_new = interface_$interface->{NAME}_new,");
@@ -681,6 +772,7 @@ sub Interface($$$)
$self->pidl("");
$self->register_module_typeobject($interface->{NAME}, "&$interface->{NAME}_InterfaceType");
+ $self->register_module_readycode(["if (!PyInterface_AddNdrRpcMethods(&$interface->{NAME}_InterfaceType, py_ndr_$interface->{NAME}\_methods))", "\treturn;", ""]);
}
$self->pidl_hdr("\n");
@@ -700,7 +792,20 @@ sub register_module_typeobject($$$)
$self->register_module_object($name, "(PyObject *)$py_name");
- push (@{$self->{module_types}}, [$name, $py_name])
+ $self->check_ready_type($py_name);
+}
+
+sub check_ready_type($$)
+{
+ my ($self, $py_name) = @_;
+ push (@{$self->{ready_types}}, $py_name) unless (grep(/^$py_name$/,@{$self->{ready_types}}));
+}
+
+sub register_module_readycode($$)
+{
+ my ($self, $code) = @_;
+
+ push (@{$self->{readycode}}, @$code);
}
sub register_module_object($$$)
@@ -880,11 +985,11 @@ sub ConvertScalarToPython($$$)
}
if ($ctypename eq "NTSTATUS") {
- return "PyInt_FromLong(NT_STATUS_V($cvar))";
+ return "PyErr_FromNTSTATUS($cvar)";
}
if ($ctypename eq "WERROR") {
- return "PyInt_FromLong(W_ERROR_V($cvar))";
+ return "PyErr_FromWERROR($cvar)";
}
if (($ctypename eq "string" or $ctypename eq "nbt_string" or $ctypename eq "nbt_name" or $ctypename eq "wrepl_nbt_name")) {
@@ -927,14 +1032,24 @@ sub ConvertObjectToPythonData($$$$$)
die("unknown type ".mapTypeName($ctype) . ": $cvar");
}
-sub ConvertObjectToPythonLevel($$$$$)
+sub fail_on_null($$$)
+{
+ my ($self, $var, $fail) = @_;
+ $self->pidl("if ($var == NULL) {");
+ $self->indent;
+ $self->pidl($fail);
+ $self->deindent;
+ $self->pidl("}");
+}
+
+sub ConvertObjectToPythonLevel($$$$$$)
{
- my ($self, $mem_ctx, $env, $e, $l, $var_name, $py_var) = @_;
+ my ($self, $mem_ctx, $env, $e, $l, $var_name, $py_var, $fail) = @_;
my $nl = GetNextLevel($e, $l);
if ($l->{TYPE} eq "POINTER") {
if ($nl->{TYPE} eq "DATA" and Parse::Pidl::Typelist::scalar_is_reference($nl->{DATA_TYPE})) {
- $self->ConvertObjectToPythonLevel($var_name, $env, $e, $nl, $var_name, $py_var);
+ $self->ConvertObjectToPythonLevel($var_name, $env, $e, $nl, $var_name, $py_var, $fail);
return;
}
if ($l->{POINTER_TYPE} ne "ref") {
@@ -945,7 +1060,7 @@ sub ConvertObjectToPythonLevel($$$$$)
$self->pidl("} else {");
$self->indent;
}
- $self->ConvertObjectToPythonLevel($var_name, $env, $e, $nl, get_value_of($var_name), $py_var);
+ $self->ConvertObjectToPythonLevel($var_name, $env, $e, $nl, get_value_of($var_name), $py_var, $fail);
if ($l->{POINTER_TYPE} ne "ref") {
$self->deindent;
$self->pidl("}");
@@ -968,6 +1083,7 @@ sub ConvertObjectToPythonLevel($$$$$)
$length = ParseExpr($length, $env, $e);
$self->pidl("$py_var = PyList_New($length);");
+ $self->fail_on_null($py_var, $fail);
$self->pidl("{");
$self->indent;
my $counter = "$e->{NAME}_cntr_$l->{LEVEL_INDEX}";
@@ -976,7 +1092,7 @@ sub ConvertObjectToPythonLevel($$$$$)
$self->indent;
my $member_var = "py_$e->{NAME}_$l->{LEVEL_INDEX}";
$self->pidl("PyObject *$member_var;");
- $self->ConvertObjectToPythonLevel($var_name, $env, $e, GetNextLevel($e, $l), $var_name."[$counter]", $member_var);
+ $self->ConvertObjectToPythonLevel($var_name, $env, $e, GetNextLevel($e, $l), $var_name."[$counter]", $member_var, $fail);
$self->pidl("PyList_SetItem($py_var, $counter, $member_var);");
$self->deindent;
$self->pidl("}");
@@ -987,6 +1103,8 @@ sub ConvertObjectToPythonLevel($$$$$)
$var_name = get_pointer_to($var_name);
my $switch = ParseExpr($l->{SWITCH_IS}, $env, $e);
$self->pidl("$py_var = py_import_" . GetNextLevel($e, $l)->{DATA_TYPE} . "($mem_ctx, $switch, $var_name);");
+ $self->fail_on_null($py_var, $fail);
+
} elsif ($l->{TYPE} eq "DATA") {
if (not Parse::Pidl::Typelist::is_scalar($l->{DATA_TYPE})) {
$var_name = get_pointer_to($var_name);
@@ -994,7 +1112,7 @@ sub ConvertObjectToPythonLevel($$$$$)
my $conv = $self->ConvertObjectToPythonData($mem_ctx, $l->{DATA_TYPE}, $var_name);
$self->pidl("$py_var = $conv;");
} elsif ($l->{TYPE} eq "SUBCONTEXT") {
- $self->ConvertObjectToPythonLevel($mem_ctx, $env, $e, GetNextLevel($e, $l), $var_name, $py_var);
+ $self->ConvertObjectToPythonLevel($mem_ctx, $env, $e, GetNextLevel($e, $l), $var_name, $py_var, $fail);
} else {
die("Unknown level type $l->{TYPE} $var_name");
}
@@ -1002,9 +1120,9 @@ sub ConvertObjectToPythonLevel($$$$$)
sub ConvertObjectToPython($$$$$$)
{
- my ($self, $mem_ctx, $env, $ctype, $cvar, $py_var) = @_;
+ my ($self, $mem_ctx, $env, $ctype, $cvar, $py_var, $fail) = @_;
- $self->ConvertObjectToPythonLevel($mem_ctx, $env, $ctype, $ctype->{LEVELS}[0], $cvar, $py_var);
+ $self->ConvertObjectToPythonLevel($mem_ctx, $env, $ctype, $ctype->{LEVELS}[0], $cvar, $py_var, $fail);
}
sub Parse($$$$$)
@@ -1022,7 +1140,7 @@ sub Parse($$$$$)
#include <Python.h>
#include \"librpc/rpc/dcerpc.h\"
#include \"scripting/python/pytalloc.h\"
-#include \"scripting/python/pyrpc.h\"
+#include \"librpc/rpc/pyrpc.h\"
#include \"lib/events/events.h\"
#include \"$hdr\"
#include \"$ndr_hdr\"
@@ -1054,12 +1172,13 @@ sub Parse($$$$$)
$self->pidl("PyObject *m;");
$self->pidl("");
- foreach (@{$self->{module_types}}) {
- my ($object_name, $c_name) = @$_;
- $self->pidl("if (PyType_Ready($c_name) < 0)");
+ foreach (@{$self->{ready_types}}) {
+ $self->pidl("if (PyType_Ready($_) < 0)");
$self->pidl("\treturn;");
}
+ $self->pidl($_) foreach (@{$self->{readycode}});
+
$self->pidl("");
$self->pidl("m = Py_InitModule3(\"$basename\", $basename\_methods, \"$basename DCE/RPC\");");
diff --git a/source4/samba4-knownfail b/source4/samba4-knownfail
index 1d8651c80b..d489dd3d70 100644
--- a/source4/samba4-knownfail
+++ b/source4/samba4-knownfail
@@ -4,7 +4,8 @@ base.delaywrite.finfo update on close
base.delete.*.deltest20a
base.delete.*.deltest20b
rpc.winreg.*security
-local.registry.*.security # Not implemented yet
+samba4.local.registry.(dir|ldb).check hive security
+samba4.local.registry.local.security
rpc.wkssvc
rpc.handles.*.lsarpc-shared
rpc.handles.*.mixed-shared
@@ -39,5 +40,3 @@ samba4.winbind.struct.*.SHOW_SEQUENCE # Not yet working in winbind
samba4.winbind.struct.*.GETPWENT # Not yet working in winbind
samba4.winbind.struct.*.SETPWENT # Not yet working in winbind
samba4.winbind.struct.*.LOOKUP_NAME_SID # Not yet working in winbind
-
-
diff --git a/source4/scripting/bin/autoidl.py b/source4/scripting/bin/autoidl.py
new file mode 100755
index 0000000000..eed4ba3a80
--- /dev/null
+++ b/source4/scripting/bin/autoidl.py
@@ -0,0 +1,161 @@
+#!/usr/bin/python
+# -*- coding: utf-8 -*-
+
+# Unix SMB/CIFS implementation.
+# 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
+# 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/>.
+#
+
+import sys
+
+MAX_OPNUM = 1000
+MAX_BASE_SIZE = 0x1000
+MAX_IFACE_VERSION = 1000
+
+DCERPC_FAULT_OP_RNG_ERROR = 0x1c010002
+DCERPC_FAULT_NDR = 0x6f7
+NT_STATUS_NET_WRITE_FAULT = -1073741614
+
+
+sys.path.insert(0, "bin/python")
+
+from samba.dcerpc import ClientConnection
+
+def find_num_funcs(conn):
+ for i in xrange(MAX_OPNUM):
+ try:
+ conn.request(i, "")
+ except RuntimeError, (num, msg):
+ if num == DCERPC_FAULT_OP_RNG_ERROR:
+ return i
+ raise Exception("More than %d functions" % MAX_OPNUM)
+
+class Function:
+ def __init__(self, conn, opnum):
+ self.conn = conn
+ self.opnum = opnum
+
+ def request(self, data):
+ assert isinstance(data, str)
+ self.conn.request(self.opnum, data)
+
+ def valid_ndr(self, data):
+ try:
+ self.request(data)
+ except RuntimeError, (num, msg):
+ if num == DCERPC_FAULT_NDR:
+ return False
+ return True
+
+ def find_base_request(self, start=""):
+ """Find the smallest possible request that we can do that is
+ valid.
+
+ This generally means sending all zeroes so we get NULL pointers where
+ possible."""
+ # TODO: Don't try with just 0's as there may be switch_is() variables
+ # for which 0 is not a valid value or variables with range() set
+ # See how much input bytes we need
+ for i in range(MAX_BASE_SIZE):
+ data = start + chr(0) * i
+ if self.valid_ndr(data):
+ return data
+ return None
+
+ def check_decision_byte(self, base_request, i):
+ """Check whether the specified byte is a possible "decision" byte,
+ e.g. a byte that is part of a pointer, array size variable or
+ discriminant.
+
+ Note that this function only checks if a byte is definitely a decision
+ byte. It may return False in some cases while the byte is actually
+ a decision byte."""
+ data = list(base_request)
+ data[i] = chr(1)
+ return not self.valid_ndr("".join(data))
+
+ def find_deferrant_data(self, base_request, idx):
+ data = list(base_request)
+ data[idx*4] = chr(1)
+ # Just check that this is a pointer to something non-empty:
+ assert not self.valid_ndr("".join(data))
+
+ newdata = self.find_base_request("".join(data))
+
+ if newdata is None:
+ return None
+
+ assert newdata.startswith(data)
+
+ return newdata[len(data):]
+
+ def find_idl(self):
+ base_request = self.find_base_request()
+
+ if base_request is None:
+ raise Exception("Unable to determine base size for opnum %d" % self.opnum)
+
+ print "\tBase request is %r" % base_request
+
+ decision_byte_map = map(lambda x: self.check_decision_byte(base_request, x), range(len(base_request)))
+
+ print decision_byte_map
+
+ # find pointers
+ possible_pointers = map(all,
+ [decision_byte_map[i*4:(i+1)*4] for i in range(int(len(base_request)/4))])
+ print possible_pointers
+
+ pointer_deferrant_bases = map(
+ lambda x: self.find_deferrant_data(base_request, x) if possible_pointers[x] else None, range(len(possible_pointers)))
+
+ print pointer_deferrant_bases
+
+
+if len(sys.argv) < 3:
+ print "Usage: autoidl <binding> <UUID> [<version>]"
+ sys.exit(1)
+
+(binding, uuid) = sys.argv[1:3]
+if len(sys.argv) == 4:
+ version = sys.argv[3]
+else:
+ version = None
+
+if version is None:
+ for i in range(MAX_IFACE_VERSION):
+ try:
+ conn = ClientConnection(binding, (uuid, i))
+ except RuntimeError, (num, msg):
+ if num == NT_STATUS_NET_WRITE_FAULT:
+ continue
+ raise
+ else:
+ break
+else:
+ conn = ClientConnection(binding, (uuid, version))
+
+print "Figuring out number of connections...",
+num_funcs = find_num_funcs(conn)
+print "%d" % num_funcs
+
+# Figure out the syntax for each one
+for i in range(num_funcs):
+ print "Function %d" % i
+ data = Function(conn, i)
+ try:
+ data.find_idl()
+ except Exception, e:
+ print "Error: %r" % e
diff --git a/source4/scripting/bin/minschema.py b/source4/scripting/bin/minschema.py
index 6dd5b42aff..111557126d 100755
--- a/source4/scripting/bin/minschema.py
+++ b/source4/scripting/bin/minschema.py
@@ -5,6 +5,8 @@
import optparse
+import os, sys
+
# Find right directory when running from source tree
sys.path.insert(0, "bin/python")
diff --git a/source4/scripting/bin/samba3dump b/source4/scripting/bin/samba3dump
index d89667233f..c11f8dbd0d 100755
--- a/source4/scripting/bin/samba3dump
+++ b/source4/scripting/bin/samba3dump
@@ -14,7 +14,7 @@ sys.path.insert(0, "bin/python")
import samba
import samba.samba3
-parser = optparse.OptionParser("provision <libdir> [<smb.conf>]")
+parser = optparse.OptionParser("samba3dump <libdir> [<smb.conf>]")
parser.add_option("--format", type="choice", metavar="FORMAT",
choices=["full", "summary"])
@@ -96,7 +96,7 @@ def print_samba3_secrets(secrets):
def print_samba3_regdb(regdb):
print_header("Registry")
- from registry import str_regtype
+ from samba.registry import str_regtype
for k in regdb.keys():
print "[%s]" % k
diff --git a/source4/scripting/bin/smbstatus b/source4/scripting/bin/smbstatus
index 4dfc3365a1..bbd0e84826 100755
--- a/source4/scripting/bin/smbstatus
+++ b/source4/scripting/bin/smbstatus
@@ -1,96 +1,83 @@
-#!/bin/sh
-exec smbscript "$0" ${1+"$@"}
-/*
- provide information on connected users and open files
- Copyright Andrew Tridgell 2005
- Released under the GNU GPL version 3 or later
-*/
+#!/usr/bin/python
+# -*- coding: utf-8 -*-
+#
+# provide information on connected users and open files
+# Copyright ǒ Jelmer Vernooij 2008
+#
+# Based on the original in EJS:
+# Copyright Andrew Tridgell 2005
+# Released under the GNU GPL version 3 or later
+#
-libinclude("base.js");
-libinclude("management.js");
+import os, sys
-var options = new Object();
+sys.path.insert(0, "bin/python")
-options = GetOptions(ARGV,
- "POPT_AUTOHELP",
- "POPT_COMMON_SAMBA",
- "POPT_COMMON_VERSION",
- "nbt");
-if (options == undefined) {
- println("Failed to parse options: " + options.ERROR);
- return -1;
-}
+import optparse
+import samba.getopt as options
+from samba import irpc, messaging
-/*
- show open sessions
-*/
-function show_sessions()
-{
- var sessions = smbsrv_sessions();
- var i;
- var sys = sys_init();
- if (sessions == undefined) {
- println("No sessions open");
- return;
- }
- printf("User Client Connected at\n");
- printf("-------------------------------------------------------------------------------\n");
- for (i=0;i<sessions.length;i++) {
- var info = sessions[i];
- var fulluser = sprintf("%s/%s", info.account_name, info.domain_name);
- printf("%-30s %16s %s\n",
- fulluser, info.client_ip, sys.httptime(info.connect_time));
- }
- printf("\n");
-}
+def show_sessions(conn):
+ """show open sessions"""
-/*
- show open tree connects
-*/
-function show_tcons()
-{
- var tcons = smbsrv_tcons();
- var sys = sys_init();
- if (tcons == undefined) {
- println("No tree connects");
- return;
- }
- printf("Share Client Connected at\n");
- printf("-------------------------------------------------------------------------------\n");
- for (i=0;i<tcons.length;i++) {
- var info = tcons[i];
- printf("%-30s %16s %s\n",
- info.share_name, info.client_ip, sys.httptime(info.connect_time));
- }
-}
+ sessions = conn.smbsrv_information(irpc.SMBSRV_INFO_SESSIONS).next()
+ print "User Client Connected at"
+ print "-------------------------------------------------------------------------------"
+ for session in sessions:
+ fulluser = "%s/%s" % (session.account_name, session.domain_name)
+ print "%-30s %16s %s" % (fulluser, session.client_ip, sys.httptime(session.connect_time))
+ print ""
-/*
- show nbtd information
-*/
-function show_nbt()
-{
- var stats = nbtd_statistics();
- if (stats == undefined) {
- println("nbt server not running");
- return;
- }
- var r;
- println("NBT server statistics:");
- for (r in stats) {
- print("\t" + r + ":\t" + stats[r] + "\n");
- }
- println("");
-}
+def show_tcons(open_connection):
+ """show open tree connects"""
+ conn = open_connection("smb_server")
+ tcons = conn.smbsrv_information(irpc.SMBSRV_INFO_TCONS).next()
+ print "Share Client Connected at"
+ print "-------------------------------------------------------------------------------"
+ for tcon in tcons:
+ print "%-30s %16s %s" % (tcon.share_name, tcon.client_ip, sys.httptime(tcon.connect_time))
-var lp = loadparm_init();
-printf("%s\n\n", lp.get("server string"));
+def show_nbt(open_connection):
+ """show nbtd information"""
+ conn = open_connection("nbt_server")
+ stats = conn.nbtd_information(irpc.NBTD_INFO_STATISTICS).next()
+ print "NBT server statistics:"
+ fields = [("total_received", "Total received"),
+ ("total_sent", "Total sent"),
+ ("query_count", "Query count"),
+ ("register_count", "Register count"),
+ ("release_count", "Release count")]
+ for (field, description) in fields:
+ print "\t%s:\t%s" % (description, getattr(stats, field))
+ print
-if (options['nbt'] != undefined) {
- show_nbt();
-} else {
- show_sessions();
- show_tcons();
-}
+parser = optparse.OptionParser("%s [options]" % sys.argv[0])
+sambaopts = options.SambaOptions(parser)
+parser.add_option_group(sambaopts)
+parser.add_option("--messaging-path", type="string", metavar="PATH",
+ help="messaging path")
+parser.add_option("--nbt", help="show NetBIOS status", action="store_true")
-return 0;
+opts, args = parser.parse_args()
+
+lp = sambaopts.get_loadparm()
+
+print "%s" % lp.get("server string")
+
+messaging_path = (opts.messaging_path or os.path.join(lp.get("private dir"), "smbd.tmp", "messaging"))
+
+def open_connection(name):
+ return messaging.ClientConnection(name, messaging_path=messaging_path)
+
+if opts.nbt:
+ show_nbt(open_connection)
+else:
+ try:
+ conn = open_connection("smb_server")
+ except RuntimeError, (num, msg):
+ if msg == 'NT_STATUS_OBJECT_NAME_NOT_FOUND':
+ print "No active connections"
+ else:
+ show_sessions(conn)
+ show_tcons(conn)
diff --git a/source4/scripting/bin/winreg b/source4/scripting/bin/winreg
deleted file mode 100755
index 883c6d7ee3..0000000000
--- a/source4/scripting/bin/winreg
+++ /dev/null
@@ -1,107 +0,0 @@
-#!/bin/sh
-exec smbscript "$0" ${1+"$@"}
-/*
- tool to manipulate a remote registry
- Copyright Andrew Tridgell 2005
- Released under the GNU GPL version 3 or later
-*/
-
-var options = GetOptions(ARGV,
- "POPT_AUTOHELP",
- "POPT_COMMON_SAMBA",
- "POPT_COMMON_CREDENTIALS",
- "createkey=s");
-if (options == undefined) {
- println("Failed to parse options");
- return -1;
-}
-
-libinclude("base.js");
-libinclude("winreg.js");
-
-if (options.ARGV.length < 1) {
- println("Usage: winreg.js <BINDING> [path]");
- return -1;
-}
-var binding = options.ARGV[0];
-reg = winregObj();
-
-print("Connecting to " + binding + "\n");
-status = reg.connect(binding);
-if (status.is_ok != true) {
- print("Failed to connect to " + binding + " - " + status.errstr + "\n");
- return -1;
-}
-
-function list_values(path) {
- var list = reg.enum_values(path);
- var i;
- if (list == undefined) {
- return;
- }
- for (i=0;i<list.length;i++) {
- var v = list[i];
- printf("\ttype=%-30s size=%4d '%s'\n", reg.typestring(v.type), v.size, v.name);
- if (v.type == reg.REG_SZ || v.type == reg.REG_EXPAND_SZ) {
- printf("\t\t'%s'\n", v.value);
- }
- if (v.type == reg.REG_MULTI_SZ) {
- var j;
- for (j in v.value) {
- printf("\t\t'%s'\n", v.value[j]);
- }
- }
- if (v.type == reg.REG_DWORD || v.type == reg.REG_DWORD_BIG_ENDIAN) {
- printf("\t\t0x%08x (%d)\n", v.value, v.value);
- }
- if (v.type == reg.REG_QWORD) {
- printf("\t\t0x%llx (%lld)\n", v.value, v.value);
- }
- }
-}
-
-function list_path(path) {
- var count = 0;
- var list = reg.enum_path(path);
- if (list == undefined) {
- println("Unable to list " + path);
- return 0;
- }
- var i;
- list_values(path);
- count = count + list.length;
- for (i=0;i<list.length;i++) {
- var npath;
- if (path) {
- npath = path + "\\" + list[i];
- } else {
- npath = list[i];
- }
- println(npath);
- count = count + list_path(npath);
- }
- return count;
-}
-
-var root;
-
-if (options.ARGV.length > 1) {
- root = options.ARGV[1];
-} else {
- root = '';
-}
-
-if (options.createkey) {
- var ok = reg.create_key("HKLM\\SOFTWARE", options.createkey);
- if (!ok) {
- println("Failed to create key");
- }
-} else {
- printf("Listing registry tree '%s'\n", root);
- var count = list_path(root);
- if (count == 0) {
- println("No entries found");
- return 1;
- }
-}
-return 0;
diff --git a/source4/scripting/ejs/config.mk b/source4/scripting/ejs/config.mk
index c1a1ca1f0f..34c0a9678e 100644
--- a/source4/scripting/ejs/config.mk
+++ b/source4/scripting/ejs/config.mk
@@ -1,7 +1,3 @@
-[SUBSYSTEM::EJSRPC]
-
-EJSRPC_OBJ_FILES = $(ejsscriptsrcdir)/ejsrpc.o
-
[MODULE::smbcalls_config]
OUTPUT_TYPE = MERGED_OBJ
SUBSYSTEM = smbcalls
@@ -17,43 +13,6 @@ PRIVATE_DEPENDENCIES = LIBLDB SAMDB LIBNDR
smbcalls_ldb_OBJ_FILES = $(ejsscriptsrcdir)/smbcalls_ldb.o
-[MODULE::smbcalls_reg]
-SUBSYSTEM = smbcalls
-OUTPUT_TYPE = MERGED_OBJ
-INIT_FUNCTION = smb_setup_ejs_reg
-PRIVATE_DEPENDENCIES = registry SAMDB LIBNDR
-
-smbcalls_reg_OBJ_FILES = $(ejsscriptsrcdir)/smbcalls_reg.o
-
-[MODULE::smbcalls_nbt]
-SUBSYSTEM = smbcalls
-OUTPUT_TYPE = MERGED_OBJ
-INIT_FUNCTION = smb_setup_ejs_nbt
-
-smbcalls_nbt_OBJ_FILES = $(ejsscriptsrcdir)/smbcalls_nbt.o
-
-[MODULE::smbcalls_rand]
-SUBSYSTEM = smbcalls
-OUTPUT_TYPE = MERGED_OBJ
-INIT_FUNCTION = smb_setup_ejs_random
-
-smbcalls_rand_OBJ_FILES = $(ejsscriptsrcdir)/smbcalls_rand.o
-
-[MODULE::smbcalls_nss]
-SUBSYSTEM = smbcalls
-OUTPUT_TYPE = MERGED_OBJ
-INIT_FUNCTION = smb_setup_ejs_nss
-PRIVATE_DEPENDENCIES = NSS_WRAPPER
-
-smbcalls_nss_OBJ_FILES = $(ejsscriptsrcdir)/smbcalls_nss.o
-
-[MODULE::smbcalls_data]
-SUBSYSTEM = smbcalls
-OUTPUT_TYPE = MERGED_OBJ
-INIT_FUNCTION = smb_setup_ejs_datablob
-
-smbcalls_data_OBJ_FILES = $(ejsscriptsrcdir)/smbcalls_data.o
-
[MODULE::smbcalls_auth]
OUTPUT_TYPE = MERGED_OBJ
SUBSYSTEM = smbcalls
@@ -78,26 +37,19 @@ INIT_FUNCTION = smb_setup_ejs_system
smbcalls_sys_OBJ_FILES = $(ejsscriptsrcdir)/smbcalls_sys.o
-mkinclude ejsnet/config.mk
-
[SUBSYSTEM::smbcalls]
PRIVATE_DEPENDENCIES = \
EJS LIBSAMBA-UTIL \
- EJSRPC MESSAGING \
+ MESSAGING \
LIBSAMBA-NET LIBCLI_SMB LIBPOPT \
CREDENTIALS POPT_CREDENTIALS POPT_SAMBA \
- dcerpc \
NDR_TABLE
smbcalls_OBJ_FILES = $(addprefix $(ejsscriptsrcdir)/, \
smbcalls.o \
- smbcalls_cli.o \
- smbcalls_rpc.o \
smbcalls_options.o \
smbcalls_creds.o \
- smbcalls_param.o \
- mprutil.o \
- literal.o)
+ mprutil.o)
$(eval $(call proto_header_template,$(ejsscriptsrcdir)/proto.h,$(smbcalls_OBJ_FILES:.o=.c)))
diff --git a/source4/scripting/ejs/ejsnet/config.mk b/source4/scripting/ejs/ejsnet/config.mk
deleted file mode 100644
index 710221e37d..0000000000
--- a/source4/scripting/ejs/ejsnet/config.mk
+++ /dev/null
@@ -1,13 +0,0 @@
-[MODULE::smbcalls_net]
-SUBSYSTEM = smbcalls
-INIT_FUNCTION = smb_setup_ejs_net
-PRIVATE_DEPENDENCIES = LIBSAMBA-NET LIBCLI_SMB CREDENTIALS
-
-smbcalls_net_OBJ_FILES = $(addprefix $(ejsscriptsrcdir)/ejsnet/, \
- net_ctx.o \
- net_user.o \
- mpr_user.o \
- net_host.o \
- mpr_host.o)
-
-$(eval $(call proto_header_template,$(ejsscriptsrcdir)/ejsnet/proto.h,$(smbcalls_net_OBJ_FILES:.o=.c)))
diff --git a/source4/scripting/ejs/ejsnet/mpr_host.c b/source4/scripting/ejs/ejsnet/mpr_host.c
deleted file mode 100644
index 8258ea5256..0000000000
--- a/source4/scripting/ejs/ejsnet/mpr_host.c
+++ /dev/null
@@ -1,74 +0,0 @@
-/*
- Unix SMB/CIFS implementation.
-
- provides interfaces to libnet calls from ejs scripts
-
- Copyright (C) Rafal Szczesniak 2005-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 "lib/appweb/ejs/ejs.h"
-#include "libnet/libnet.h"
-#include "scripting/ejs/smbcalls.h"
-#include "events/events.h"
-#include "auth/credentials/credentials.h"
-
-
-/*
- Properties:
- DomainsList.Domains[0]
- DomainsList.Status
-*/
-struct MprVar mprDomainsList(TALLOC_CTX *mem_ctx, struct libnet_DomainList *list, NTSTATUS result)
-{
- const char *name = "DomainsList";
- NTSTATUS status;
- struct MprVar mprDomainList, mprDomains;
- struct MprVar mprSid, mprDomainName;
- struct MprVar mprDomain;
- int i;
-
- if (list == NULL || mem_ctx == NULL) {
- mprDomainList = mprCreateNullVar();
- goto done;
- }
-
- mprDomains = mprArray("Domains");
- for (i = 0; i < list->out.count; i++) {
- struct domainlist d = list->out.domains[i];
-
- /* get domainlist fields */
- mprSid = mprString(d.sid);
- mprDomainName = mprString(d.name);
-
- mprDomain = mprObject("Domain");
- mprSetVar(&mprDomain, "Name", mprDomainName);
- mprSetVar(&mprDomain, "SID", mprSid);
-
- mprAddArray(&mprDomains, i, mprDomain);
- }
-
- mprDomainList = mprObject(name);
- status = mprSetVar(&mprDomainList, "Domains", mprDomains);
- if (!NT_STATUS_IS_OK(status)) goto done;
- status = mprSetVar(&mprDomainList, "Count", mprCreateIntegerVar(list->out.count));
- if (!NT_STATUS_IS_OK(status)) goto done;
- status = mprSetVar(&mprDomainList, "Status", mprNTSTATUS(result));
-
-done:
- return mprDomainList;
-}
diff --git a/source4/scripting/ejs/ejsnet/mpr_user.c b/source4/scripting/ejs/ejsnet/mpr_user.c
deleted file mode 100644
index 6691a0f955..0000000000
--- a/source4/scripting/ejs/ejsnet/mpr_user.c
+++ /dev/null
@@ -1,173 +0,0 @@
-/*
- Unix SMB/CIFS implementation.
-
- provides interfaces to libnet calls from ejs scripts
-
- Copyright (C) Rafal Szczesniak 2005-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 "lib/appweb/ejs/ejs.h"
-#include "libnet/libnet.h"
-#include "scripting/ejs/smbcalls.h"
-#include "events/events.h"
-#include "auth/credentials/credentials.h"
-
-
-/*
- Properties:
- UserInfo.AccountName
- UserInfo.FullName
- UserInfo.Description
- UserInfo.HomeDirectory
- UserInfo.HomeDrive
- UserInfo.Comment
- UserInfo.LogonScript
- UserInfo.AcctExpiry
- UserInfo.AllowPasswordChange
- UserInfo.ForcePasswordChange
- */
-struct MprVar mprCreateUserInfo(TALLOC_CTX *mem_ctx, struct libnet_UserInfo *info)
-{
- const char *name = "UserInfo";
- NTSTATUS status;
- struct MprVar mprUserInfo;
- struct MprVar mprAccountName, mprFullName, mprDescription;
- struct MprVar mprHomeDir, mprHomeDrive, mprComment;
- struct MprVar mprLogonScript;
- struct MprVar mprAcctExpiry, mprAllowPassChange, mprForcePassChange;
-
- if (info == NULL || mem_ctx == NULL) {
- mprUserInfo = mprCreateNullVar();
- goto done;
- }
-
- mprUserInfo = mprObject(name);
-
- mprAccountName = mprString(info->out.account_name);
- mprFullName = mprString(info->out.full_name);
- mprDescription = mprString(info->out.description);
- mprHomeDir = mprString(info->out.home_directory);
- mprHomeDrive = mprString(info->out.home_drive);
- mprComment = mprString(info->out.comment);
- mprLogonScript = mprString(info->out.logon_script);
- mprAcctExpiry = mprString(timestring(mem_ctx, info->out.acct_expiry->tv_sec));
- mprAllowPassChange = mprString(timestring(mem_ctx, info->out.allow_password_change->tv_sec));
- mprForcePassChange = mprString(timestring(mem_ctx, info->out.force_password_change->tv_sec));
-
- status = mprSetVar(&mprUserInfo, "AccountName", mprAccountName);
- if (!NT_STATUS_IS_OK(status)) goto done;
- status = mprSetVar(&mprUserInfo, "FullName", mprFullName);
- if (!NT_STATUS_IS_OK(status)) goto done;
- status = mprSetVar(&mprUserInfo, "Description", mprDescription);
- if (!NT_STATUS_IS_OK(status)) goto done;
- status = mprSetVar(&mprUserInfo, "HomeDirectory", mprHomeDir);
- if (!NT_STATUS_IS_OK(status)) goto done;
- status = mprSetVar(&mprUserInfo, "HomeDrive", mprHomeDrive);
- if (!NT_STATUS_IS_OK(status)) goto done;
- status = mprSetVar(&mprUserInfo, "Comment", mprComment);
- if (!NT_STATUS_IS_OK(status)) goto done;
- status = mprSetVar(&mprUserInfo, "LogonScript", mprLogonScript);
- if (!NT_STATUS_IS_OK(status)) goto done;
- status = mprSetVar(&mprUserInfo, "AcctExpiry", mprAcctExpiry);
- if (!NT_STATUS_IS_OK(status)) goto done;
- status = mprSetVar(&mprUserInfo, "AllowPasswordChange", mprAllowPassChange);
- if (!NT_STATUS_IS_OK(status)) goto done;
- status = mprSetVar(&mprUserInfo, "ForcePasswordChange", mprForcePassChange);
- if (!NT_STATUS_IS_OK(status)) goto done;
-
-done:
- return mprUserInfo;
-}
-
-
-/*
- Properties:
- UserListCtx.Users[]
- UserListCtx.ResumeIndex
- UserListCtx.Count
- UserListCtx.EndOfList
- UserListCtx.Status
- */
-struct MprVar mprUserListCtx(TALLOC_CTX *mem_ctx, struct libnet_UserList *list, NTSTATUS result)
-{
- const char *name = "UserListCtx";
- NTSTATUS status;
- bool endOfList;
- struct MprVar mprListCtx, mprUserList;
- struct MprVar mprUser, mprSid, mprUsername;
- int i;
-
- if (list == NULL || mem_ctx == NULL) {
- mprListCtx = mprCreateNullVar();
- goto done;
- }
-
- endOfList = (NT_STATUS_EQUAL(result, NT_STATUS_NO_MORE_ENTRIES) ||
- NT_STATUS_IS_OK(result));
-
- mprUserList = mprArray("Users");
- for (i = 0; i < list->out.count; i++) {
- struct userlist u = list->out.users[i];
-
- /* get userlist fields */
- mprSid = mprString(u.sid);
- mprUsername = mprString(u.username);
-
- /* create userlist object */
- mprUser = mprObject("User");
- mprSetVar(&mprUser, "Username", mprUsername);
- mprSetVar(&mprUser, "SID", mprSid);
-
- /* add the object to the array being constructed */
- mprAddArray(&mprUserList, i, mprUser);
- }
-
- mprListCtx = mprObject(name);
- status = mprSetVar(&mprListCtx, "Users", mprUserList);
- if (!NT_STATUS_IS_OK(status)) goto done;
- status = mprSetVar(&mprListCtx, "Count", mprCreateIntegerVar(list->out.count));
- if (!NT_STATUS_IS_OK(status)) goto done;
- status = mprSetVar(&mprListCtx, "ResumeIndex", mprCreateIntegerVar((int)list->out.resume_index));
- if (!NT_STATUS_IS_OK(status)) goto done;
- status = mprSetVar(&mprListCtx, "EndOfList", mprCreateBoolVar(endOfList));
- if (!NT_STATUS_IS_OK(status)) goto done;
- status = mprSetVar(&mprListCtx, "Status", mprNTSTATUS(result));
-
-done:
- return mprListCtx;
-}
-
-
-/*
- Returns UserListCtx.ResumeIndex out of passed UserListCtx
- */
-unsigned int mprListGetResumeIndex(struct MprVar *listCtx)
-{
- NTSTATUS status;
- unsigned int resume = 0;
- struct MprVar *mprResumeIndex;
- if (listCtx == NULL) return 0;
-
- mprResumeIndex = listCtx;
- status = mprGetVar(&mprResumeIndex, "ResumeIndex");
- if (!NT_STATUS_IS_OK(status)) goto done;
-
- resume = (unsigned int) mprVarToInteger(mprResumeIndex);
-
-done:
- return resume;
-}
diff --git a/source4/scripting/ejs/ejsnet/net_ctx.c b/source4/scripting/ejs/ejsnet/net_ctx.c
deleted file mode 100644
index cbe163552e..0000000000
--- a/source4/scripting/ejs/ejsnet/net_ctx.c
+++ /dev/null
@@ -1,230 +0,0 @@
-/*
- Unix SMB/CIFS implementation.
-
- provides interfaces to libnet calls from ejs scripts
-
- Copyright (C) Rafal Szczesniak 2005-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 "lib/appweb/ejs/ejs.h"
-#include "scripting/ejs/smbcalls.h"
-#include "libnet/libnet.h"
-#include "events/events.h"
-#include "auth/credentials/credentials.h"
-
-
-int ejs_net_userman(MprVarHandle eid, int argc, struct MprVar** argv);
-int ejs_net_hostman(MprVarHandle eid, int argc, struct MprVar** argv);
-
-static int ejs_net_join_domain(MprVarHandle eid, int argc, struct MprVar **argv);
-static int ejs_net_samsync_ldb(MprVarHandle eid, int argc, struct MprVar **argv);
-
-/*
- Usage:
- net = NetContext(credentials);
-*/
-
-static int ejs_net_context(MprVarHandle eid, int argc, struct MprVar **argv)
-{
- TALLOC_CTX *event_mem_ctx = talloc_new(mprMemCtx());
- struct cli_credentials *creds;
- struct libnet_context *ctx;
- struct MprVar obj, mprCreds;
- struct event_context *ev;
-
- if (!event_mem_ctx) {
- ejsSetErrorMsg(eid, "talloc_new() failed");
- return -1;
- }
- ev = mprEventCtx();
-
- ctx = libnet_context_init(ev, mprLpCtx());
- /* IF we generated a new event context, it will be under here,
- * and we need it to last as long as the libnet context, so
- * make it a child */
- talloc_steal(ctx, event_mem_ctx);
-
- if (argc == 0 || (argc == 1 && argv[0]->type == MPR_TYPE_NULL)) {
- /*
- create the default credentials
- */
- creds = cli_credentials_init(ctx);
- if (creds == NULL) {
- ejsSetErrorMsg(eid, "cli_credential_init() failed");
- talloc_free(ctx);
- return -1;
- }
- cli_credentials_set_conf(creds, mprLpCtx());
- cli_credentials_set_anonymous(creds);
-
- mprCreds = mprCredentials(creds);
-
- } else if (argc == 1 && argv[0]->type == MPR_TYPE_OBJECT) {
- /*
- get credential values from credentials object
- */
- mprCreds = *(argv[0]);
- creds = (struct cli_credentials *)mprGetPtr(&mprCreds, "creds");
- if (creds == NULL) {
- ejsSetErrorMsg(eid, "invalid credentials parameter");
- talloc_free(ctx);
- return -1;
- }
-
- } else {
- ejsSetErrorMsg(eid, "NetContext invalid arguments, this function requires an object.");
- talloc_free(ctx);
- return -1;
- }
-
- /* setup libnet_context credentials */
- ctx->cred = creds;
-
- /* create the NetContext object */
- obj = mprObject("NetContext");
-
- /* add internal libnet_context pointer to the NetContext object */
- mprSetPtrChild(&obj, "ctx", ctx);
-
- /* add properties publicly available from js code */
- mprCreateProperty(&obj, "credentials", &mprCreds);
-
- /* add methods to the object */
- mprSetCFunction(&obj, "UserMgr", ejs_net_userman);
- mprSetCFunction(&obj, "HostMgr", ejs_net_hostman);
- mprSetCFunction(&obj, "JoinDomain", ejs_net_join_domain);
- mprSetCFunction(&obj, "SamSyncLdb", ejs_net_samsync_ldb);
-
- /* return the object */
- mpr_Return(eid, obj);
-
- return 0;
-}
-
-
-static int ejs_net_join_domain(MprVarHandle eid, int argc, struct MprVar **argv)
-{
- TALLOC_CTX *mem_ctx;
- struct libnet_context *ctx;
- struct libnet_Join *join;
- NTSTATUS status;
- ctx = (struct libnet_context *)mprGetThisPtr(eid, "ctx");
- mem_ctx = talloc_new(mprMemCtx());
-
- join = talloc(mem_ctx, struct libnet_Join);
- if (!join) {
- talloc_free(mem_ctx);
- return -1;
- }
-
- /* prepare parameters for the join */
- join->in.netbios_name = NULL;
- join->in.join_type = SEC_CHAN_WKSTA;
- join->in.domain_name = cli_credentials_get_domain(ctx->cred);
- join->in.level = LIBNET_JOIN_AUTOMATIC;
- join->out.error_string = NULL;
-
- if (argc == 1 && argv[0]->type == MPR_TYPE_OBJECT) {
- MprVar *netbios_name = mprGetProperty(argv[0], "netbios_name", NULL);
- MprVar *domain_name = mprGetProperty(argv[0], "domain_name", NULL);
- MprVar *join_type = mprGetProperty(argv[0], "join_type", NULL);
- if (netbios_name) {
- join->in.netbios_name = mprToString(netbios_name);
- }
- if (domain_name) {
- join->in.domain_name = mprToString(domain_name);
- }
- if (join_type) {
- join->in.join_type = mprToInt(join_type);
- }
- }
-
- if (!join->in.domain_name) {
- ejsSetErrorMsg(eid, "a domain must be specified for to join");
- talloc_free(mem_ctx);
- return -1;
- }
-
- /* do the domain join */
- status = libnet_Join(ctx, join, join);
-
- if (!NT_STATUS_IS_OK(status)) {
- MprVar error_string = mprString(join->out.error_string);
-
- mprSetPropertyValue(argv[0], "error_string", error_string);
- mpr_Return(eid, mprCreateBoolVar(false));
- } else {
- mpr_Return(eid, mprCreateBoolVar(true));
- }
- talloc_free(mem_ctx);
- return 0;
-}
-
-
-static int ejs_net_samsync_ldb(MprVarHandle eid, int argc, struct MprVar **argv)
-{
- TALLOC_CTX *mem_ctx;
- struct libnet_context *ctx;
- struct libnet_samsync_ldb *samsync;
- NTSTATUS status;
- ctx = (struct libnet_context *)mprGetThisPtr(eid, "ctx");
- mem_ctx = talloc_new(mprMemCtx());
-
- samsync = talloc(mem_ctx, struct libnet_samsync_ldb);
- if (!samsync) {
- talloc_free(mem_ctx);
- return -1;
- }
-
- /* prepare parameters for the samsync */
- samsync->in.machine_account = NULL;
- samsync->in.session_info = NULL;
- samsync->in.binding_string = NULL;
- samsync->out.error_string = NULL;
-
- if (argc == 1 && argv[0]->type == MPR_TYPE_OBJECT) {
- MprVar *credentials = mprGetProperty(argv[0], "machine_account", NULL);
- MprVar *session_info = mprGetProperty(argv[0], "session_info", NULL);
- if (credentials) {
- samsync->in.machine_account = talloc_get_type(mprGetPtr(credentials, "creds"), struct cli_credentials);
- }
- if (session_info) {
- samsync->in.session_info = talloc_get_type(mprGetPtr(session_info, "session_info"), struct auth_session_info);
- }
- }
-
- /* do the domain samsync */
- status = libnet_samsync_ldb(ctx, samsync, samsync);
-
- if (!NT_STATUS_IS_OK(status)) {
- MprVar error_string = mprString(samsync->out.error_string);
-
- mprSetPropertyValue(argv[0], "error_string", error_string);
- mpr_Return(eid, mprCreateBoolVar(false));
- } else {
- mpr_Return(eid, mprCreateBoolVar(true));
- }
- talloc_free(mem_ctx);
- return 0;
-}
-
-
-NTSTATUS smb_setup_ejs_net(void)
-{
- ejsDefineCFunction(-1, "NetContext", ejs_net_context, NULL, MPR_VAR_SCRIPT_HANDLE);
- return NT_STATUS_OK;
-}
diff --git a/source4/scripting/ejs/ejsnet/net_host.c b/source4/scripting/ejs/ejsnet/net_host.c
deleted file mode 100644
index 478da19db3..0000000000
--- a/source4/scripting/ejs/ejsnet/net_host.c
+++ /dev/null
@@ -1,124 +0,0 @@
-/*
- Unix SMB/CIFS implementation.
-
- provides interfaces to libnet calls from ejs scripts
-
- Copyright (C) Rafal Szczesniak 2005-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 "lib/appweb/ejs/ejs.h"
-#include "libnet/libnet.h"
-#include "scripting/ejs/ejsnet/proto.h"
-#include "scripting/ejs/smbcalls.h"
-#include "events/events.h"
-#include "auth/credentials/credentials.h"
-
-
-static int ejs_net_domainlist(MprVarHandle eid, int argc, char **argv);
-
-
-/*
- Usage:
- hostCtx = net.HostMgr(hostname = <default from credentials>)
-*/
-int ejs_net_hostman(MprVarHandle eid, int argc, struct MprVar** argv)
-{
- struct libnet_context *ctx;
- const char *hostname;
- struct MprVar obj;
-
- /* libnet context */
- ctx = mprGetThisPtr(eid, "ctx");
- if (ctx == NULL) {
- ejsSetErrorMsg(eid, "ctx property returns null pointer");
- return 0;
- }
-
- /* fetch the arguments: host name */
- if (argc == 0) {
- /* default host (machine) name is supplied in credentials */
- hostname = cli_credentials_get_workstation(ctx->cred);
-
- } else if (argc == 1 && mprVarIsString(argv[0]->type)) {
- /* host name has been specified */
- hostname = mprToString(argv[0]);
-
- } else {
- ejsSetErrorMsg(eid, "too many arguments");
- return 0;
- }
-
- /* create the NetHostCtx object */
- obj = mprObject("NetHostCtx");
-
- /* create a copy of the string for the object */
- hostname = talloc_strdup(ctx, hostname);
-
- /* add internal libnet_context pointer to the NetHostCtx object */
- mprSetPtrChild(&obj, "ctx", ctx);
- mprSetPtrChild(&obj, "hostname", hostname);
-
- /* add methods to the object */
- mprSetStringCFunction(&obj, "DomainList", ejs_net_domainlist);
-
- /* set the object returned by this function */
- mpr_Return(eid, obj);
-
- return 0;
-}
-
-
-static int ejs_net_domainlist(MprVarHandle eid, int argc, char **argv)
-{
- NTSTATUS status;
- TALLOC_CTX *mem_ctx;
- const char* hostname;
- struct libnet_context *ctx;
- struct libnet_DomainList req;
- struct MprVar mprDomains;
-
- mem_ctx = talloc_new(mprMemCtx());
- if (mem_ctx == NULL) {
- ejsSetErrorMsg(eid, "could not create memory context - out of memory");
- goto done;
- }
-
- /* libnet context */
- ctx = mprGetThisPtr(eid, "ctx");
- if (ctx == NULL) {
- ejsSetErrorMsg(eid, "ctx property returns null pointer");
- goto done;
- }
-
- hostname = mprGetThisPtr(eid, "hostname");
- if (hostname == NULL) {
- ejsSetErrorMsg(eid, "hostname property returns null pointer");
- goto done;
- }
-
- /* call the libnet function */
- req.in.hostname = hostname;
-
- status = libnet_DomainList(ctx, mem_ctx, &req);
- mprDomains = mprDomainsList(mem_ctx, &req, status);
-
-done:
- talloc_free(mem_ctx);
- mpr_Return(eid, mprDomains);
- return 0;
-}
diff --git a/source4/scripting/ejs/ejsnet/net_user.c b/source4/scripting/ejs/ejsnet/net_user.c
deleted file mode 100644
index 0c32035c6c..0000000000
--- a/source4/scripting/ejs/ejsnet/net_user.c
+++ /dev/null
@@ -1,359 +0,0 @@
-/*
- Unix SMB/CIFS implementation.
-
- provides interfaces to libnet calls from ejs scripts
-
- Copyright (C) Rafal Szczesniak 2005-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 "lib/appweb/ejs/ejs.h"
-#include "libnet/libnet.h"
-#include "scripting/ejs/ejsnet/proto.h"
-#include "scripting/ejs/smbcalls.h"
-#include "events/events.h"
-#include "auth/credentials/credentials.h"
-
-
-static int ejs_net_createuser(MprVarHandle eid, int argc, char **argv);
-static int ejs_net_deleteuser(MprVarHandle eid, int argc, char **argv);
-static int ejs_net_userinfo(MprVarHandle eid, int argc, char **argv);
-static int ejs_net_userlist(MprVarHandle eid, int argc, struct MprVar **argv);
-
-
-/*
- Usage:
- usrCtx = net.UserMgr(domain = <default from credentials>);
-*/
-int ejs_net_userman(MprVarHandle eid, int argc, struct MprVar **argv)
-{
- struct libnet_context *ctx;
- const char *userman_domain = NULL;
- struct MprVar obj;
-
- /* libnet context */
- ctx = (struct libnet_context *)mprGetThisPtr(eid, "ctx");
- if (ctx == NULL) {
- ejsSetErrorMsg(eid, "ctx property returns null pointer");
- return 0;
- }
-
- /* fetch the arguments: domain name */
- if (argc == 0) {
- /* default domain name is supplied in credentials */
- userman_domain = cli_credentials_get_domain(ctx->cred);
-
- } else if (argc == 1 && mprVarIsString(argv[0]->type)) {
- /* domain name can also be specified explicitly
- (e.g. to connect BUILTIN domain) */
- userman_domain = mprToString(argv[0]);
-
- } else {
- ejsSetErrorMsg(eid, "too many arguments");
- return 0;
- }
-
- /* any domain name must be specified anyway */
- if (userman_domain == NULL) {
- ejsSetErrorMsg(eid, "a domain must be specified for user management");
- return 0;
- }
-
- /* create 'net user' subcontext */
- obj = mprObject("NetUsrCtx");
-
- /* we need to make a copy of the string for this object */
- userman_domain = talloc_strdup(ctx, userman_domain);
-
- /* add properties */
- mprSetPtrChild(&obj, "ctx", ctx);
- mprSetPtrChild(&obj, "domain", userman_domain);
-
- /* add methods */
- mprSetStringCFunction(&obj, "Create", ejs_net_createuser);
- mprSetStringCFunction(&obj, "Delete", ejs_net_deleteuser);
- mprSetStringCFunction(&obj, "Info", ejs_net_userinfo);
- mprSetCFunction(&obj, "List", ejs_net_userlist);
-
- /* set the object returned by this function */
- mpr_Return(eid, obj);
-
- return 0;
-}
-
-
-/*
- Usage:
- NTSTATUS = NetUsrCtx.Create(Username)
-*/
-static int ejs_net_createuser(MprVarHandle eid, int argc, char **argv)
-{
- NTSTATUS status = NT_STATUS_UNSUCCESSFUL;
- TALLOC_CTX *mem_ctx;
- struct libnet_context *ctx;
- const char *userman_domain = NULL;
- const char *username = NULL;
- struct libnet_CreateUser req;
-
- mem_ctx = talloc_new(mprMemCtx());
- if (mem_ctx == NULL) {
- ejsSetErrorMsg(eid, "could not create memory context - out of memory");
- goto done;
- }
-
- /* fetch the arguments: username */
- if (argc == 0) {
- ejsSetErrorMsg(eid, "too little arguments");
- goto done;
-
- } else if (argc == 1) {
- username = argv[0];
-
- } else {
- ejsSetErrorMsg(eid, "too many arguments");
- goto done;
- }
-
- /* libnet context */
- ctx = (struct libnet_context *)mprGetThisPtr(eid, "ctx");
- if (ctx == NULL) {
- ejsSetErrorMsg(eid, "ctx property returns null pointer");
- goto done;
- }
-
- /* domain where the account is to be created */
- userman_domain = (const char *)mprGetThisPtr(eid, "domain");
- if (userman_domain == NULL) {
- ejsSetErrorMsg(eid, "domain property returns null pointer");
- goto done;
- }
-
- /* call the libnet function */
- req.in.domain_name = userman_domain;
- req.in.user_name = argv[0];
-
- status = libnet_CreateUser(ctx, mem_ctx, &req);
- if (!NT_STATUS_IS_OK(status)) {
- ejsSetErrorMsg(eid, "%s", req.out.error_string);
- }
-
-done:
- talloc_free(mem_ctx);
- mpr_Return(eid, mprNTSTATUS(status));
- return 0;
-}
-
-
-/*
- Usage:
- NTSTATUS = NetUsrCtx.Delete(Username)
-*/
-static int ejs_net_deleteuser(MprVarHandle eid, int argc, char **argv)
-{
- NTSTATUS status = NT_STATUS_UNSUCCESSFUL;
- TALLOC_CTX *mem_ctx;
- struct libnet_context *ctx;
- const char *userman_domain = NULL;
- const char *username = NULL;
- struct libnet_DeleteUser req;
-
- mem_ctx = talloc_new(mprMemCtx());
- if (mem_ctx == NULL) {
- ejsSetErrorMsg(eid, "could not create memory context - out of memory");
- goto done;
- }
-
- /* fetch the arguments: username */
- if (argc == 0) {
- ejsSetErrorMsg(eid, "too little arguments");
- goto done;
-
- } else if (argc == 1) {
- username = argv[0];
-
- } else {
- ejsSetErrorMsg(eid, "too many arguments");
- goto done;
- }
-
- /* libnet context */
- ctx = mprGetThisPtr(eid, "ctx");
- if (ctx == NULL) {
- ejsSetErrorMsg(eid, "ctx property returns null pointer");
- goto done;
- }
-
- /* domain where the account is to be deleted */
- userman_domain = mprGetThisPtr(eid, "domain");
- if (!userman_domain) {
- ejsSetErrorMsg(eid, "domain property returns null pointer");
- goto done;
- }
-
- /* call the libnet function */
- req.in.domain_name = userman_domain;
- req.in.user_name = username;
-
- status = libnet_DeleteUser(ctx, mem_ctx, &req);
- if (!NT_STATUS_IS_OK(status)) {
- ejsSetErrorMsg(eid, "%s", req.out.error_string);
- }
-
-done:
- talloc_free(mem_ctx);
- mpr_Return(eid, mprNTSTATUS(status));
- return 0;
-}
-
-
-/*
- Usage:
- UserInfo = NetUsrCtx.Info(Username)
-*/
-static int ejs_net_userinfo(MprVarHandle eid, int argc, char **argv)
-{
- NTSTATUS status = NT_STATUS_UNSUCCESSFUL;
- TALLOC_CTX *mem_ctx;
- struct libnet_context *ctx;
- const char *userman_domain = NULL;
- const char *username = NULL;
- struct libnet_UserInfo req;
- struct MprVar mprUserInfo;
-
- mem_ctx = talloc_new(mprMemCtx());
- if (mem_ctx == NULL) {
- ejsSetErrorMsg(eid, "could not create memory context - out of memory");
- goto done;
- }
-
- /* fetch the arguments: username */
- if (argc == 0) {
- ejsSetErrorMsg(eid, "too little arguments");
- goto done;
-
- } else if (argc == 1) {
- username = argv[0];
-
- } else {
- ejsSetErrorMsg(eid, "too many arguments");
- goto done;
- }
-
- /* libnet context */
- ctx = (struct libnet_context *)mprGetThisPtr(eid, "ctx");
- if (ctx == NULL) {
- ejsSetErrorMsg(eid, "ctx property returns null pointer");
- goto done;
- }
-
- /* domain where the user account is to be queried */
- userman_domain = mprGetThisPtr(eid, "domain");
- if (userman_domain == NULL) {
- ejsSetErrorMsg(eid, "domain property returns null pointer");
- return -1;
- }
-
- /* call the libnet function */
- req.in.domain_name = userman_domain;
- req.in.data.user_name = username;
- req.in.level = USER_INFO_BY_NAME;
-
- status = libnet_UserInfo(ctx, mem_ctx, &req);
- if (!NT_STATUS_IS_OK(status)) {
- ejsSetErrorMsg(eid, "%s", req.out.error_string);
-
- /* create null object to return */
- mprUserInfo = mprCreateNullVar();
- goto done;
- }
-
- /* create UserInfo object */
- mprUserInfo = mprCreateUserInfo(ctx, &req);
-
-done:
- talloc_free(mem_ctx);
- mpr_Return(eid, mprUserInfo);
- return 0;
-}
-
-
-/*
- Usage:
- UserListCtx = NetUsrCtx.List(UserListCtx)
-*/
-static int ejs_net_userlist(MprVarHandle eid, int argc, struct MprVar **argv)
-{
- TALLOC_CTX *mem_ctx;
- NTSTATUS status;
- struct libnet_context *ctx;
- const char *userlist_domain;
- int page_size = 512; /* TODO: this should be specified in a nicer way */
- struct libnet_UserList req;
- struct MprVar mprListCtx, *mprInListCtx;
-
- mem_ctx = talloc_new(mprMemCtx());
- if (mem_ctx == NULL) {
- ejsSetErrorMsg(eid, "could not create memory context - out of memory");
- goto done;
- }
-
- /* fetch the arguments */
- if (argc == 0) {
- ejsSetErrorMsg(eid, "too little arguments");
- goto done;
-
- } else if (argc == 1) {
- if (mprVarIsObject(argv[0]->type)) {
- /* this is a continuation call */
- mprInListCtx = argv[0];
- req.in.resume_index = mprListGetResumeIndex(mprInListCtx);
-
- } else {
- /* this is a first call */
- req.in.resume_index = 0;
- }
-
- } else {
- ejsSetErrorMsg(eid, "too many arguments");
- goto done;
- }
-
- /* libnet context */
- ctx = (struct libnet_context *)mprGetThisPtr(eid, "ctx");
- if (ctx == NULL) {
- ejsSetErrorMsg(eid, "ctx property returns null pointer");
- goto done;
- }
-
- /* domain where user accounts are to be enumerated */
- userlist_domain = mprGetThisPtr(eid, "domain");
- if (userlist_domain == NULL) {
- ejsSetErrorMsg(eid, "domain property returns null pointer");
- goto done;
- }
-
- /* call the libnet function */
- req.in.domain_name = userlist_domain;
- req.in.page_size = page_size;
-
- status = libnet_UserList(ctx, mem_ctx, &req);
- mprListCtx = mprUserListCtx(mem_ctx, &req, status);
-
-done:
- talloc_free(mem_ctx);
- mpr_Return(eid, mprListCtx);
- return 0;
-}
diff --git a/source4/scripting/ejs/ejsrpc.c b/source4/scripting/ejs/ejsrpc.c
deleted file mode 100644
index c7c02dbd64..0000000000
--- a/source4/scripting/ejs/ejsrpc.c
+++ /dev/null
@@ -1,424 +0,0 @@
-/*
- Unix SMB/CIFS implementation.
-
- provide interfaces to rpc calls from ejs scripts
-
- Copyright (C) Andrew Tridgell 2005
-
- 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 "lib/appweb/ejs/ejs.h"
-#include "scripting/ejs/smbcalls.h"
-#include "librpc/gen_ndr/lsa.h"
-#include "librpc/gen_ndr/winreg.h"
-#include "scripting/ejs/ejsrpc.h"
-#include "libcli/security/security.h"
-
-/*
- set the switch var to be used by the next union switch
-*/
-void ejs_set_switch(struct ejs_rpc *ejs, uint32_t switch_var)
-{
- ejs->switch_var = switch_var;
-}
-
-/*
- panic in the ejs wrapper code
- */
-NTSTATUS ejs_panic(struct ejs_rpc *ejs, const char *why)
-{
- ejsSetErrorMsg(ejs->eid, "rpc_call '%s' failed - %s", ejs->callname, why);
- return NT_STATUS_INTERNAL_ERROR;
-}
-
-/*
- start the ejs pull process for a structure
-*/
-NTSTATUS ejs_pull_struct_start(struct ejs_rpc *ejs, struct MprVar **v, const char *name)
-{
- return mprGetVar(v, name);
-}
-
-
-/*
- start the ejs push process for a structure
-*/
-NTSTATUS ejs_push_struct_start(struct ejs_rpc *ejs, struct MprVar **v, const char *name)
-{
- EJS_CHECK(mprSetVar(*v, name, mprObject(name)));
- return mprGetVar(v, name);
-}
-
-/*
- pull a uint8 from a mpr variable to a C element
-*/
-NTSTATUS ejs_pull_uint8(struct ejs_rpc *ejs,
- struct MprVar *v, const char *name, uint8_t *r)
-{
- EJS_CHECK(mprGetVar(&v, name));
- *r = mprVarToInteger(v);
- return NT_STATUS_OK;
-
-}
-
-NTSTATUS ejs_push_uint8(struct ejs_rpc *ejs,
- struct MprVar *v, const char *name, const uint8_t *r)
-{
- return mprSetVar(v, name, mprCreateIntegerVar(*r));
-}
-
-/*
- pull a uint16 from a mpr variable to a C element
-*/
-NTSTATUS ejs_pull_uint16(struct ejs_rpc *ejs,
- struct MprVar *v, const char *name, uint16_t *r)
-{
- EJS_CHECK(mprGetVar(&v, name));
- *r = mprVarToInteger(v);
- return NT_STATUS_OK;
-
-}
-
-NTSTATUS ejs_push_uint16(struct ejs_rpc *ejs,
- struct MprVar *v, const char *name, const uint16_t *r)
-{
- return mprSetVar(v, name, mprCreateIntegerVar(*r));
-}
-
-/*
- pull a uint32 from a mpr variable to a C element
-*/
-NTSTATUS ejs_pull_uint32(struct ejs_rpc *ejs,
- struct MprVar *v, const char *name, uint32_t *r)
-{
- EJS_CHECK(mprGetVar(&v, name));
- *r = mprVarToInteger(v);
- return NT_STATUS_OK;
-}
-
-NTSTATUS ejs_push_uint32(struct ejs_rpc *ejs,
- struct MprVar *v, const char *name, const uint32_t *r)
-{
- return mprSetVar(v, name, mprCreateIntegerVar(*r));
-}
-
-/*
- pull a int32 from a mpr variable to a C element
-*/
-NTSTATUS ejs_pull_int32(struct ejs_rpc *ejs,
- struct MprVar *v, const char *name, int32_t *r)
-{
- EJS_CHECK(mprGetVar(&v, name));
- *r = mprVarToInteger(v);
- return NT_STATUS_OK;
-}
-
-NTSTATUS ejs_push_int32(struct ejs_rpc *ejs,
- struct MprVar *v, const char *name, const int32_t *r)
-{
- return mprSetVar(v, name, mprCreateIntegerVar(*r));
-}
-
-/*
- pull a uint32 from a mpr variable to a C element
-*/
-NTSTATUS ejs_pull_time_t(struct ejs_rpc *ejs,
- struct MprVar *v, const char *name, time_t *r)
-{
- EJS_CHECK(mprGetVar(&v, name));
- *r = mprVarToInteger(v);
- return NT_STATUS_OK;
-}
-
-NTSTATUS ejs_push_time_t(struct ejs_rpc *ejs,
- struct MprVar *v, const char *name, const time_t *r)
-{
- return mprSetVar(v, name, mprCreateIntegerVar(*r));
-}
-
-NTSTATUS ejs_pull_hyper(struct ejs_rpc *ejs,
- struct MprVar *v, const char *name, uint64_t *r)
-{
- EJS_CHECK(mprGetVar(&v, name));
- *r = mprVarToNumber(v);
- return NT_STATUS_OK;
-}
-
-NTSTATUS ejs_push_hyper(struct ejs_rpc *ejs,
- struct MprVar *v, const char *name, const uint64_t *r)
-{
- return mprSetVar(v, name, mprCreateNumberVar(*r));
-}
-
-NTSTATUS ejs_pull_dlong(struct ejs_rpc *ejs,
- struct MprVar *v, const char *name, int64_t *r)
-{
- return ejs_pull_hyper(ejs, v, name, (uint64_t *)r);
-}
-
-NTSTATUS ejs_push_dlong(struct ejs_rpc *ejs,
- struct MprVar *v, const char *name, const int64_t *r)
-{
- return ejs_push_hyper(ejs, v, name, (const uint64_t *)r);
-}
-
-NTSTATUS ejs_pull_udlong(struct ejs_rpc *ejs,
- struct MprVar *v, const char *name, uint64_t *r)
-{
- return ejs_pull_hyper(ejs, v, name, r);
-}
-
-NTSTATUS ejs_push_udlong(struct ejs_rpc *ejs,
- struct MprVar *v, const char *name, const uint64_t *r)
-{
- return ejs_push_hyper(ejs, v, name, r);
-}
-
-NTSTATUS ejs_pull_NTTIME(struct ejs_rpc *ejs,
- struct MprVar *v, const char *name, uint64_t *r)
-{
- return ejs_pull_hyper(ejs, v, name, r);
-}
-
-NTSTATUS ejs_push_NTTIME(struct ejs_rpc *ejs,
- struct MprVar *v, const char *name, const uint64_t *r)
-{
- return ejs_push_hyper(ejs, v, name, r);
-}
-
-NTSTATUS ejs_push_WERROR(struct ejs_rpc *ejs,
- struct MprVar *v, const char *name, const WERROR *r)
-{
- return ejs_push_string(ejs, v, name, win_errstr(*r));
-}
-
-NTSTATUS ejs_push_NTSTATUS(struct ejs_rpc *ejs,
- struct MprVar *v, const char *name, const NTSTATUS *r)
-{
- return ejs_push_string(ejs, v, name, nt_errstr(*r));
-}
-
-
-/*
- pull a enum from a mpr variable to a C element
- a enum is just treating as an unsigned integer at this level
-*/
-NTSTATUS ejs_pull_enum(struct ejs_rpc *ejs,
- struct MprVar *v, const char *name, unsigned *r)
-{
- EJS_CHECK(mprGetVar(&v, name));
- *r = mprVarToInteger(v);
- return NT_STATUS_OK;
-
-}
-
-NTSTATUS ejs_push_enum(struct ejs_rpc *ejs,
- struct MprVar *v, const char *name, const unsigned *r)
-{
- return mprSetVar(v, name, mprCreateIntegerVar(*r));
-}
-
-
-/*
- pull a string
-*/
-NTSTATUS ejs_pull_string(struct ejs_rpc *ejs,
- struct MprVar *v, const char *name, const char **s)
-{
- EJS_CHECK(mprGetVar(&v, name));
- *s = mprToString(v);
- return NT_STATUS_OK;
-}
-
-/*
- push a string
-*/
-NTSTATUS ejs_push_string(struct ejs_rpc *ejs,
- struct MprVar *v, const char *name, const char *s)
-{
- return mprSetVar(v, name, mprString(s));
-}
-
-
-/*
- pull a ipv4address (internally a string)
-*/
-NTSTATUS ejs_pull_ipv4address(struct ejs_rpc *ejs,
- struct MprVar *v, const char *name, const char **s)
-{
- return ejs_pull_string(ejs, v, name, s);
-}
-
-/*
- push a ipv4address (internally a string)
-*/
-NTSTATUS ejs_push_ipv4address(struct ejs_rpc *ejs,
- struct MprVar *v, const char *name, const char *s)
-{
- return ejs_push_string(ejs, v, name, s);
-}
-
-
-NTSTATUS ejs_pull_dom_sid(struct ejs_rpc *ejs,
- struct MprVar *v, const char *name, struct dom_sid *r)
-{
- struct dom_sid *sid;
- EJS_CHECK(mprGetVar(&v, name));
- sid = dom_sid_parse_talloc(ejs, mprToString(v));
- NT_STATUS_HAVE_NO_MEMORY(sid);
- *r = *sid;
- return NT_STATUS_OK;
-}
-
-NTSTATUS ejs_push_dom_sid(struct ejs_rpc *ejs,
- struct MprVar *v, const char *name, const struct dom_sid *r)
-{
- char *sidstr = dom_sid_string(ejs, r);
- NT_STATUS_HAVE_NO_MEMORY(sidstr);
- return mprSetVar(v, name, mprString(sidstr));
-}
-
-NTSTATUS ejs_pull_GUID(struct ejs_rpc *ejs,
- struct MprVar *v, const char *name, struct GUID *r)
-{
- EJS_CHECK(mprGetVar(&v, name));
- return GUID_from_string(mprToString(v), r);
-}
-
-NTSTATUS ejs_push_GUID(struct ejs_rpc *ejs,
- struct MprVar *v, const char *name, const struct GUID *r)
-{
- char *guid = GUID_string(ejs, r);
- NT_STATUS_HAVE_NO_MEMORY(guid);
- return mprSetVar(v, name, mprString(guid));
-}
-
-NTSTATUS ejs_push_null(struct ejs_rpc *ejs, struct MprVar *v, const char *name)
-{
- return mprSetVar(v, name, mprCreatePtrVar(NULL));
-}
-
-bool ejs_pull_null(struct ejs_rpc *ejs, struct MprVar *v, const char *name)
-{
- NTSTATUS status = mprGetVar(&v, name);
- if (!NT_STATUS_IS_OK(status)) {
- return false;
- }
- if (v->type == MPR_TYPE_PTR && v->ptr == NULL) {
- return true;
- }
- return false;
-}
-
-/*
- pull a lsa_String
-*/
-NTSTATUS ejs_pull_lsa_String(struct ejs_rpc *ejs,
- struct MprVar *v, const char *name, struct lsa_String *r)
-{
- return ejs_pull_string(ejs, v, name, &r->string);
-}
-
-/*
- push a lsa_String
-*/
-NTSTATUS ejs_push_lsa_String(struct ejs_rpc *ejs,
- struct MprVar *v, const char *name, const struct lsa_String *r)
-{
- return ejs_push_string(ejs, v, name, r->string);
-}
-
-/*
- pull a winreg_String
-*/
-NTSTATUS ejs_pull_winreg_String(struct ejs_rpc *ejs,
- struct MprVar *v, const char *name, struct winreg_String *r)
-{
- return ejs_pull_string(ejs, v, name, &r->name);
-}
-
-/*
- push a winreg_String
-*/
-NTSTATUS ejs_push_winreg_String(struct ejs_rpc *ejs,
- struct MprVar *v, const char *name, const struct winreg_String *r)
-{
- return ejs_push_string(ejs, v, name, r->name);
-}
-
-NTSTATUS ejs_pull_DATA_BLOB(struct ejs_rpc *ejs,
- struct MprVar *v, const char *name, DATA_BLOB *r)
-{
- return NT_STATUS_NOT_IMPLEMENTED;
-}
-
-NTSTATUS ejs_push_DATA_BLOB(struct ejs_rpc *ejs,
- struct MprVar *v, const char *name,
- const DATA_BLOB *r)
-{
- return NT_STATUS_NOT_IMPLEMENTED;
-}
-
-NTSTATUS ejs_pull_bool(struct ejs_rpc *ejs,
- struct MprVar *v, const char *name, bool *r)
-{
- EJS_CHECK(mprGetVar(&v, name));
- *r = mprVarToBool(v);
- return NT_STATUS_OK;
-}
-
-NTSTATUS ejs_push_bool(struct ejs_rpc *ejs,
- struct MprVar *v, const char *name, const bool *r)
-{
- return mprSetVar(v, name, mprCreateBoolVar(*r));
-}
-
-
-/*
- pull a uint8 array from a mpr variable to a C element - treating as a data blob
-*/
-NTSTATUS ejs_pull_array_uint8(struct ejs_rpc *ejs,
- struct MprVar *v, const char *name,
- uint8_t *r, uint32_t length)
-{
- NTSTATUS status;
- DATA_BLOB *blob;
-
- status = mprGetVar(&v, name);
- NT_STATUS_NOT_OK_RETURN(status);
-
- blob = mprToDataBlob(v);
- if (blob == NULL) {
- return NT_STATUS_OBJECT_NAME_INVALID;
- }
- if (blob->length != length) {
- return NT_STATUS_INFO_LENGTH_MISMATCH;
- }
- memcpy(r, blob->data, length);
- return NT_STATUS_OK;
-
-}
-
-NTSTATUS ejs_push_array_uint8(struct ejs_rpc *ejs,
- struct MprVar *v, const char *name,
- const uint8_t *r, uint32_t length)
-{
- DATA_BLOB blob;
- blob.data = (uint8_t *)discard_const(r);
- blob.length = length;
- mprSetVar(v, name, mprDataBlob(blob));
- return NT_STATUS_OK;
-}
diff --git a/source4/scripting/ejs/ejsrpc.h b/source4/scripting/ejs/ejsrpc.h
deleted file mode 100644
index cc22a26700..0000000000
--- a/source4/scripting/ejs/ejsrpc.h
+++ /dev/null
@@ -1,172 +0,0 @@
-/*
- Unix SMB/CIFS implementation.
-
- ejs <-> rpc interface definitions
-
- Copyright (C) Andrew Tridgell 2005
-
- 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 "librpc/gen_ndr/security.h"
-#include "librpc/rpc/dcerpc.h"
-
-struct ejs_rpc {
- int eid;
- const char *callname;
- /* as ejs does only one pass, we can use a single var for switch
- handling */
- uint32_t switch_var;
-};
-
-typedef NTSTATUS (*ejs_pull_t)(struct ejs_rpc *, struct MprVar *, const char *, void *);
-typedef NTSTATUS (*ejs_push_t)(struct ejs_rpc *, struct MprVar *, const char *, const void *);
-typedef NTSTATUS (*ejs_pull_function_t)(struct ejs_rpc *, struct MprVar *, void *);
-typedef NTSTATUS (*ejs_push_function_t)(struct ejs_rpc *, struct MprVar *, const void *);
-
-NTSTATUS ejs_panic(struct ejs_rpc *ejs, const char *why);
-void ejs_set_switch(struct ejs_rpc *ejs, uint32_t switch_var);
-
-NTSTATUS smbcalls_register_ejs(const char *name, MprCFunction fn);
-
-
-int ejs_rpc_call(int eid, int argc, struct MprVar **argv,
- const struct ndr_interface_table *iface, int callnum,
- ejs_pull_function_t ejs_pull, ejs_push_function_t ejs_push);
-
-NTSTATUS ejs_pull_struct_start(struct ejs_rpc *ejs, struct MprVar **v, const char *name);
-NTSTATUS ejs_push_struct_start(struct ejs_rpc *ejs, struct MprVar **v, const char *name);
-
-NTSTATUS ejs_pull_uint8(struct ejs_rpc *ejs,
- struct MprVar *v, const char *name, uint8_t *r);
-NTSTATUS ejs_push_uint8(struct ejs_rpc *ejs,
- struct MprVar *v, const char *name, const uint8_t *r);
-NTSTATUS ejs_pull_uint16(struct ejs_rpc *ejs,
- struct MprVar *v, const char *name, uint16_t *r);
-NTSTATUS ejs_push_uint16(struct ejs_rpc *ejs,
- struct MprVar *v, const char *name, const uint16_t *r);
-NTSTATUS ejs_pull_uint32(struct ejs_rpc *ejs,
- struct MprVar *v, const char *name, uint32_t *r);
-NTSTATUS ejs_push_int32(struct ejs_rpc *ejs,
- struct MprVar *v, const char *name, const int32_t *r);
-NTSTATUS ejs_pull_int32(struct ejs_rpc *ejs,
- struct MprVar *v, const char *name, int32_t *r);
-NTSTATUS ejs_push_uint32(struct ejs_rpc *ejs,
- struct MprVar *v, const char *name, const uint32_t *r);
-NTSTATUS ejs_pull_hyper(struct ejs_rpc *ejs,
- struct MprVar *v, const char *name, uint64_t *r);
-NTSTATUS ejs_push_hyper(struct ejs_rpc *ejs,
- struct MprVar *v, const char *name, const uint64_t *r);
-NTSTATUS ejs_pull_dlong(struct ejs_rpc *ejs,
- struct MprVar *v, const char *name, int64_t *r);
-NTSTATUS ejs_push_dlong(struct ejs_rpc *ejs,
- struct MprVar *v, const char *name, const int64_t *r);
-NTSTATUS ejs_pull_udlong(struct ejs_rpc *ejs,
- struct MprVar *v, const char *name, uint64_t *r);
-NTSTATUS ejs_push_udlong(struct ejs_rpc *ejs,
- struct MprVar *v, const char *name, const uint64_t *r);
-NTSTATUS ejs_pull_NTTIME(struct ejs_rpc *ejs,
- struct MprVar *v, const char *name, uint64_t *r);
-NTSTATUS ejs_push_NTTIME(struct ejs_rpc *ejs,
- struct MprVar *v, const char *name, const uint64_t *r);
-NTSTATUS ejs_pull_time_t(struct ejs_rpc *ejs,
- struct MprVar *v, const char *name, time_t *r);
-NTSTATUS ejs_push_time_t(struct ejs_rpc *ejs,
- struct MprVar *v, const char *name, const time_t *r);
-NTSTATUS ejs_pull_enum(struct ejs_rpc *ejs,
- struct MprVar *v, const char *name, unsigned *r);
-NTSTATUS ejs_push_enum(struct ejs_rpc *ejs,
- struct MprVar *v, const char *name, const unsigned *r);
-NTSTATUS ejs_pull_string(struct ejs_rpc *ejs,
- struct MprVar *v, const char *name, const char **s);
-NTSTATUS ejs_push_string(struct ejs_rpc *ejs,
- struct MprVar *v, const char *name, const char *s);
-NTSTATUS ejs_pull_ipv4address(struct ejs_rpc *ejs,
- struct MprVar *v, const char *name, const char **s);
-NTSTATUS ejs_push_ipv4address(struct ejs_rpc *ejs,
- struct MprVar *v, const char *name, const char *s);
-void ejs_set_constant_int(int eid, const char *name, int value);
-void ejs_set_constant_string(int eid, const char *name, const char *value);
-
-NTSTATUS ejs_pull_dom_sid(struct ejs_rpc *ejs,
- struct MprVar *v, const char *name, struct dom_sid *r);
-NTSTATUS ejs_push_dom_sid(struct ejs_rpc *ejs,
- struct MprVar *v, const char *name, const struct dom_sid *r);
-NTSTATUS ejs_push_null(struct ejs_rpc *ejs, struct MprVar *v, const char *name);
-bool ejs_pull_null(struct ejs_rpc *ejs, struct MprVar *v, const char *name);
-NTSTATUS ejs_push_WERROR(struct ejs_rpc *ejs,
- struct MprVar *v, const char *name, const WERROR *r);
-NTSTATUS ejs_push_NTSTATUS(struct ejs_rpc *ejs,
- struct MprVar *v, const char *name, const NTSTATUS *r);
-NTSTATUS ejs_pull_DATA_BLOB(struct ejs_rpc *ejs,
- struct MprVar *v, const char *name, DATA_BLOB *r);
-NTSTATUS ejs_push_DATA_BLOB(struct ejs_rpc *ejs,
- struct MprVar *v, const char *name, const DATA_BLOB *r);
-NTSTATUS ejs_pull_bool(struct ejs_rpc *ejs,
- struct MprVar *v, const char *name, bool *r);
-NTSTATUS ejs_push_bool(struct ejs_rpc *ejs,
- struct MprVar *v, const char *name, const bool *r);
-
-NTSTATUS ejs_pull_array_uint8(struct ejs_rpc *ejs,
- struct MprVar *v, const char *name,
- uint8_t *r, uint32_t length);
-NTSTATUS ejs_push_array_uint8(struct ejs_rpc *ejs,
- struct MprVar *v, const char *name,
- const uint8_t *r, uint32_t length);
-
-NTSTATUS ejs_pull_GUID(struct ejs_rpc *ejs,
- struct MprVar *v, const char *name, struct GUID *r);
-NTSTATUS ejs_push_GUID(struct ejs_rpc *ejs,
- struct MprVar *v, const char *name, const struct GUID *r);
-
-struct lsa_String;
-NTSTATUS ejs_pull_lsa_String(struct ejs_rpc *ejs,
- struct MprVar *v, const char *name, struct lsa_String *r);
-NTSTATUS ejs_push_lsa_String(struct ejs_rpc *ejs,
- struct MprVar *v, const char *name, const struct lsa_String *r);
-
-struct winreg_String;
-NTSTATUS ejs_pull_winreg_String(struct ejs_rpc *ejs,
- struct MprVar *v, const char *name, struct winreg_String *r);
-NTSTATUS ejs_push_winreg_String(struct ejs_rpc *ejs,
- struct MprVar *v, const char *name, const struct winreg_String *r);
-
-#define EJS_ALLOC(ejs, s) do { \
- (s) = talloc_ptrtype(ejs, (s)); \
- if (!(s)) return ejs_panic(ejs, "out of memory"); \
-} while (0)
-
-#define EJS_ALLOC_N(ejs, s, n) do { \
- (s) = talloc_array_ptrtype(ejs, (s), n); \
- if (!(s)) return ejs_panic(ejs, "out of memory"); \
-} while (0)
-
-#define EJS_CHECK(cmd) do { \
- NTSTATUS _status; \
- _status = cmd; \
- if (!NT_STATUS_IS_OK(_status)) { \
- return _status; \
- } \
-} while (0)
-
-/* some types are equivalent for ejs */
-#define ejs_pull_dom_sid2 ejs_pull_dom_sid
-#define ejs_push_dom_sid2 ejs_push_dom_sid
-#define ejs_pull_dom_sid28 ejs_pull_dom_sid
-#define ejs_push_dom_sid28 ejs_push_dom_sid
-#define ejs_pull_NTTIME_hyper ejs_pull_NTTIME
-#define ejs_push_NTTIME_hyper ejs_push_NTTIME
-#define ejs_pull_NTTIME_1sec ejs_pull_NTTIME
-#define ejs_push_NTTIME_1sec ejs_push_NTTIME
-
diff --git a/source4/scripting/ejs/literal.c b/source4/scripting/ejs/literal.c
deleted file mode 100644
index 8307c211d3..0000000000
--- a/source4/scripting/ejs/literal.c
+++ /dev/null
@@ -1,797 +0,0 @@
-/*
- * Copyright (c) 2004, 2005 Metaparadigm Pte. Ltd.
- * Michael Clark <michael@metaparadigm.com>
- * Copyright (c) 2006 Derrell Lipman
- *
- * This library is free software; you can redistribute it and/or modify
- * it under the terms of the MIT license. See COPYING for details.
- *
- * Derrell Lipman:
- * This version is modified from the original. It has been modified to
- * natively use EJS variables rather than the original C object interface, and
- * to use the talloc() family of functions for memory allocation.
- */
-
-#include "includes.h"
-#include "scripting/ejs/smbcalls.h"
-
-enum json_tokener_error {
- json_tokener_success,
- json_tokener_error_oom, /* out of memory */
- json_tokener_error_parse_unexpected,
- json_tokener_error_parse_null,
- json_tokener_error_parse_date,
- json_tokener_error_parse_boolean,
- json_tokener_error_parse_number,
- json_tokener_error_parse_array,
- json_tokener_error_parse_object,
- json_tokener_error_parse_string,
- json_tokener_error_parse_comment,
- json_tokener_error_parse_eof
-};
-
-enum json_tokener_state {
- json_tokener_state_eatws,
- json_tokener_state_start,
- json_tokener_state_finish,
- json_tokener_state_null,
- json_tokener_state_date,
- json_tokener_state_comment_start,
- json_tokener_state_comment,
- json_tokener_state_comment_eol,
- json_tokener_state_comment_end,
- json_tokener_state_string,
- json_tokener_state_string_escape,
- json_tokener_state_escape_unicode,
- json_tokener_state_boolean,
- json_tokener_state_number,
- json_tokener_state_array,
- json_tokener_state_datelist,
- json_tokener_state_array_sep,
- json_tokener_state_datelist_sep,
- json_tokener_state_object,
- json_tokener_state_object_field_start,
- json_tokener_state_object_field,
- json_tokener_state_object_field_end,
- json_tokener_state_object_value,
- json_tokener_state_object_sep
-};
-
-enum date_field {
- date_field_year,
- date_field_month,
- date_field_day,
- date_field_hour,
- date_field_minute,
- date_field_second,
- date_field_millisecond
-};
-
-struct json_tokener
-{
- char *source;
- int pos;
- void *ctx;
- void *pb;
-};
-
-static const char *json_number_chars = "0123456789.+-e";
-static const char *json_hex_chars = "0123456789abcdef";
-
-#define hexdigit(x) (((x) <= '9') ? (x) - '0' : ((x) & 7) + 9)
-
-extern struct MprVar json_tokener_parse(char *s);
-static struct MprVar json_tokener_do_parse(struct json_tokener *this,
- enum json_tokener_error *err_p);
-
-/*
- * literal_to_var() parses a string into an ejs variable. The ejs
- * variable is returned. Upon error, the javascript variable will be
- * `undefined`. This was created for parsing JSON, but is generally useful
- * for parsing the literal forms of objects and arrays, since ejs doesn't
- * procide that functionality.
- */
-int literal_to_var(int eid, int argc, char **argv)
-{
- struct json_tokener tok;
- struct MprVar obj;
- enum json_tokener_error err = json_tokener_success;
-
- if (argc != 1) {
- ejsSetErrorMsg(eid,
- "literal_to_var() requires one parameter: "
- "the string to be parsed.");
- return -1;
- }
-
- tok.source = argv[0];
- tok.pos = 0;
- tok.ctx = talloc_new(mprMemCtx());
- if (tok.ctx == NULL) {
- mpr_Return(eid, mprCreateUndefinedVar());
- return 0;
- }
- tok.pb = talloc_zero_size(tok.ctx, 1);
- if (tok.pb == NULL) {
- mpr_Return(eid, mprCreateUndefinedVar());
- return 0;
- }
- obj = json_tokener_do_parse(&tok, &err);
- talloc_free(tok.pb);
- if (err != json_tokener_success) {
- mprDestroyVar(&obj);
- mpr_Return(eid, mprCreateUndefinedVar());
- return 0;
- }
- mpr_Return(eid, obj);
- return 0;
-}
-
-static void *append_string(void *ctx,
- char *orig,
- char *append,
- int size)
-{
- if (!orig) {
- return talloc_strndup(ctx, append, size);
- }
-
- return talloc_strndup_append(orig, append, size);
-}
-
-
-static struct MprVar json_tokener_do_parse(struct json_tokener *this,
- enum json_tokener_error *err_p)
-{
- enum json_tokener_state state;
- enum json_tokener_state saved_state;
- enum date_field date_field;
- struct MprVar current = mprCreateUndefinedVar();
- struct MprVar tempObj;
- struct MprVar obj;
- enum json_tokener_error err = json_tokener_success;
- char date_script[] = "JSON_Date.create(0);";
- char *obj_field_name = NULL;
- char *emsg = NULL;
- char quote_char;
- int deemed_double;
- int start_offset;
- char c;
-
- state = json_tokener_state_eatws;
- saved_state = json_tokener_state_start;
-
-
- do {
- c = this->source[this->pos];
- switch(state) {
-
- case json_tokener_state_eatws:
- if(isspace(c)) {
- this->pos++;
- } else if(c == '/') {
- state = json_tokener_state_comment_start;
- start_offset = this->pos++;
- } else {
- state = saved_state;
- }
- break;
-
- case json_tokener_state_start:
- switch(c) {
- case '{':
- state = json_tokener_state_eatws;
- saved_state = json_tokener_state_object;
- current = mprObject(NULL);
- this->pos++;
- break;
- case '[':
- state = json_tokener_state_eatws;
- saved_state = json_tokener_state_array;
- current = mprArray(NULL);
- this->pos++;
- break;
- case 'N':
- case 'n':
- start_offset = this->pos++;
- if (this->source[this->pos] == 'e') {
- state = json_tokener_state_date;
- } else {
- state = json_tokener_state_null;
- }
- break;
- case '"':
- case '\'':
- quote_char = c;
- talloc_free(this->pb);
- this->pb = talloc_zero_size(this->ctx, 1);
- if (this->pb == NULL) {
- *err_p = json_tokener_error_oom;
- goto out;
- }
- state = json_tokener_state_string;
- start_offset = ++this->pos;
- break;
- case 'T':
- case 't':
- case 'F':
- case 'f':
- state = json_tokener_state_boolean;
- start_offset = this->pos++;
- break;
-#if defined(__GNUC__)
- case '0' ... '9':
-#else
- case '0':
- case '1':
- case '2':
- case '3':
- case '4':
- case '5':
- case '6':
- case '7':
- case '8':
- case '9':
-#endif
- case '-':
- deemed_double = 0;
- state = json_tokener_state_number;
- start_offset = this->pos++;
- break;
- default:
- err = json_tokener_error_parse_unexpected;
- goto out;
- }
- break;
-
- case json_tokener_state_finish:
- goto out;
-
- case json_tokener_state_null:
- if(strncasecmp("null",
- this->source + start_offset,
- this->pos - start_offset)) {
- *err_p = json_tokener_error_parse_null;
- mprDestroyVar(&current);
- return mprCreateUndefinedVar();
- }
-
- if(this->pos - start_offset == 4) {
- mprDestroyVar(&current);
- current = mprCreateNullVar();
- saved_state = json_tokener_state_finish;
- state = json_tokener_state_eatws;
- } else {
- this->pos++;
- }
- break;
-
- case json_tokener_state_date:
- if (this->pos - start_offset <= 18) {
- if (strncasecmp("new Date(Date.UTC(",
- this->source + start_offset,
- this->pos - start_offset)) {
- *err_p = json_tokener_error_parse_date;
- mprDestroyVar(&current);
- return mprCreateUndefinedVar();
- } else {
- this->pos++;
- break;
- }
- }
-
- this->pos--; /* we went one too far */
- state = json_tokener_state_eatws;
- saved_state = json_tokener_state_datelist;
-
- /* Create a JsonDate object */
- if (ejsEvalScript(0,
- date_script,
- &tempObj,
- &emsg) != 0) {
- *err_p = json_tokener_error_parse_date;
- mprDestroyVar(&current);
- return mprCreateUndefinedVar();
- }
- mprDestroyVar(&current);
- mprCopyVar(&current, &tempObj, MPR_DEEP_COPY);
- date_field = date_field_year;
- break;
-
- case json_tokener_state_comment_start:
- if(c == '*') {
- state = json_tokener_state_comment;
- } else if(c == '/') {
- state = json_tokener_state_comment_eol;
- } else {
- err = json_tokener_error_parse_comment;
- goto out;
- }
- this->pos++;
- break;
-
- case json_tokener_state_comment:
- if(c == '*') state = json_tokener_state_comment_end;
- this->pos++;
- break;
-
- case json_tokener_state_comment_eol:
- if(c == '\n') {
- state = json_tokener_state_eatws;
- }
- this->pos++;
- break;
-
- case json_tokener_state_comment_end:
- if(c == '/') {
- state = json_tokener_state_eatws;
- } else {
- state = json_tokener_state_comment;
- }
- this->pos++;
- break;
-
- case json_tokener_state_string:
- if(c == quote_char) {
- this->pb = append_string(
- this->ctx,
- this->pb,
- this->source + start_offset,
- this->pos - start_offset);
- if (this->pb == NULL) {
- err = json_tokener_error_oom;
- goto out;
- }
- current = mprString(this->pb);
- saved_state = json_tokener_state_finish;
- state = json_tokener_state_eatws;
- } else if(c == '\\') {
- saved_state = json_tokener_state_string;
- state = json_tokener_state_string_escape;
- }
- this->pos++;
- break;
-
- case json_tokener_state_string_escape:
- switch(c) {
- case '"':
- case '\\':
- this->pb = append_string(
- this->ctx,
- this->pb,
- this->source + start_offset,
- this->pos - start_offset - 1);
- if (this->pb == NULL) {
- err = json_tokener_error_oom;
- goto out;
- }
- start_offset = this->pos++;
- state = saved_state;
- break;
- case 'b':
- case 'n':
- case 'r':
- case 't':
- this->pb = append_string(
- this->ctx,
- this->pb,
- this->source + start_offset,
- this->pos - start_offset - 1);
- if (this->pb == NULL) {
- err = json_tokener_error_oom;
- goto out;
- }
- if (c == 'b') {
- /*
- * second param to append_string()
- * gets temporarily modified; can't
- * pass string constant.
- */
- char buf[] = "\b";
- this->pb = append_string(this->ctx,
- this->pb,
- buf,
- 1);
- if (this->pb == NULL) {
- err = json_tokener_error_oom;
- goto out;
- }
- } else if (c == 'n') {
- char buf[] = "\n";
- this->pb = append_string(this->ctx,
- this->pb,
- buf,
- 1);
- if (this->pb == NULL) {
- err = json_tokener_error_oom;
- goto out;
- }
- } else if (c == 'r') {
- char buf[] = "\r";
- this->pb = append_string(this->ctx,
- this->pb,
- buf,
- 1);
- if (this->pb == NULL) {
- err = json_tokener_error_oom;
- goto out;
- }
- } else if (c == 't') {
- char buf[] = "\t";
- this->pb = append_string(this->ctx,
- this->pb,
- buf,
- 1);
- if (this->pb == NULL) {
- err = json_tokener_error_oom;
- goto out;
- }
- }
- start_offset = ++this->pos;
- state = saved_state;
- break;
- case 'u':
- this->pb = append_string(
- this->ctx,
- this->pb,
- this->source + start_offset,
- this->pos - start_offset - 1);
- if (this->pb == NULL) {
- err = json_tokener_error_oom;
- goto out;
- }
- start_offset = ++this->pos;
- state = json_tokener_state_escape_unicode;
- break;
- default:
- err = json_tokener_error_parse_string;
- goto out;
- }
- break;
-
- case json_tokener_state_escape_unicode:
- if(strchr(json_hex_chars, c)) {
- this->pos++;
- if(this->pos - start_offset == 4) {
- unsigned char utf_out[3];
- unsigned int ucs_char =
- (hexdigit(*(this->source + start_offset)) << 12) +
- (hexdigit(*(this->source + start_offset + 1)) << 8) +
- (hexdigit(*(this->source + start_offset + 2)) << 4) +
- hexdigit(*(this->source + start_offset + 3));
- if (ucs_char < 0x80) {
- utf_out[0] = ucs_char;
- this->pb = append_string(
- this->ctx,
- this->pb,
- (char *) utf_out,
- 1);
- if (this->pb == NULL) {
- err = json_tokener_error_oom;
- goto out;
- }
- } else if (ucs_char < 0x800) {
- utf_out[0] = 0xc0 | (ucs_char >> 6);
- utf_out[1] = 0x80 | (ucs_char & 0x3f);
- this->pb = append_string(
- this->ctx,
- this->pb,
- (char *) utf_out,
- 2);
- if (this->pb == NULL) {
- err = json_tokener_error_oom;
- goto out;
- }
- } else {
- utf_out[0] = 0xe0 | (ucs_char >> 12);
- utf_out[1] = 0x80 | ((ucs_char >> 6) & 0x3f);
- utf_out[2] = 0x80 | (ucs_char & 0x3f);
- this->pb = append_string(
- this->ctx,
- this->pb,
- (char *) utf_out,
- 3);
- if (this->pb == NULL) {
- err = json_tokener_error_oom;
- goto out;
- }
- }
- start_offset = this->pos;
- state = saved_state;
- }
- } else {
- err = json_tokener_error_parse_string;
- goto out;
- }
- break;
-
- case json_tokener_state_boolean:
- if(strncasecmp("true", this->source + start_offset,
- this->pos - start_offset) == 0) {
- if(this->pos - start_offset == 4) {
- current = mprCreateBoolVar(1);
- saved_state = json_tokener_state_finish;
- state = json_tokener_state_eatws;
- } else {
- this->pos++;
- }
- } else if(strncasecmp("false", this->source + start_offset,
- this->pos - start_offset) == 0) {
- if(this->pos - start_offset == 5) {
- current = mprCreateBoolVar(0);
- saved_state = json_tokener_state_finish;
- state = json_tokener_state_eatws;
- } else {
- this->pos++;
- }
- } else {
- err = json_tokener_error_parse_boolean;
- goto out;
- }
- break;
-
- case json_tokener_state_number:
- if(!c || !strchr(json_number_chars, c)) {
- int numi;
- double numd;
- char *tmp = talloc_strndup(
- this->ctx,
- this->source + start_offset,
- this->pos - start_offset);
- if (tmp == NULL) {
- err = json_tokener_error_oom;
- goto out;
- }
- if(!deemed_double && sscanf(tmp, "%d", &numi) == 1) {
- current = mprCreateIntegerVar(numi);
- } else if(deemed_double && sscanf(tmp, "%lf", &numd) == 1) {
- current = mprCreateFloatVar(numd);
- } else {
- talloc_free(tmp);
- err = json_tokener_error_parse_number;
- goto out;
- }
- talloc_free(tmp);
- saved_state = json_tokener_state_finish;
- state = json_tokener_state_eatws;
- } else {
- if(c == '.' || c == 'e') deemed_double = 1;
- this->pos++;
- }
- break;
-
- case json_tokener_state_array:
- if(c == ']') {
- this->pos++;
- saved_state = json_tokener_state_finish;
- state = json_tokener_state_eatws;
- } else {
- int oldlen;
- char idx[16];
-
- obj = json_tokener_do_parse(this, &err);
- if (err != json_tokener_success) {
- goto out;
- }
- oldlen = mprToInt(mprGetProperty(&current,
- "length",
- NULL));
- mprItoa(oldlen, idx, sizeof(idx));
- mprSetVar(&current, idx, obj);
- saved_state = json_tokener_state_array_sep;
- state = json_tokener_state_eatws;
- }
- break;
-
- case json_tokener_state_datelist:
- if(c == ')') {
- if (this->source[this->pos+1] == ')') {
- this->pos += 2;
- saved_state = json_tokener_state_finish;
- state = json_tokener_state_eatws;
- } else {
- err = json_tokener_error_parse_date;
- goto out;
- }
- } else {
- obj = json_tokener_do_parse(this, &err);
- if (err != json_tokener_success) {
- goto out;
- }
-
- /* date list items must be integers */
- if (obj.type != MPR_TYPE_INT) {
- err = json_tokener_error_parse_date;
- goto out;
- }
-
- switch(date_field) {
- case date_field_year:
- mprSetVar(&current, "year", obj);
- break;
- case date_field_month:
- mprSetVar(&current, "month", obj);
- break;
- case date_field_day:
- mprSetVar(&current, "day", obj);
- break;
- case date_field_hour:
- mprSetVar(&current, "hour", obj);
- break;
- case date_field_minute:
- mprSetVar(&current, "minute", obj);
- break;
- case date_field_second:
- mprSetVar(&current, "second", obj);
- break;
- case date_field_millisecond:
- mprSetVar(&current, "millisecond", obj);
- break;
- default:
- err = json_tokener_error_parse_date;
- goto out;
- }
-
- /* advance to the next date field */
- date_field++;
-
- saved_state = json_tokener_state_datelist_sep;
- state = json_tokener_state_eatws;
- }
- break;
-
- case json_tokener_state_array_sep:
- if(c == ']') {
- this->pos++;
- saved_state = json_tokener_state_finish;
- state = json_tokener_state_eatws;
- } else if(c == ',') {
- this->pos++;
- saved_state = json_tokener_state_array;
- state = json_tokener_state_eatws;
- } else {
- *err_p = json_tokener_error_parse_array;
- mprDestroyVar(&current);
- return mprCreateUndefinedVar();
- }
- break;
-
- case json_tokener_state_datelist_sep:
- if(c == ')') {
- if (this->source[this->pos+1] == ')') {
- this->pos += 2;
- saved_state = json_tokener_state_finish;
- state = json_tokener_state_eatws;
- } else {
- err = json_tokener_error_parse_date;
- goto out;
- }
- } else if(c == ',') {
- this->pos++;
- saved_state = json_tokener_state_datelist;
- state = json_tokener_state_eatws;
- } else {
- *err_p = json_tokener_error_parse_date;
- mprDestroyVar(&current);
- return mprCreateUndefinedVar();
- }
- break;
-
- case json_tokener_state_object:
- state = json_tokener_state_object_field_start;
- start_offset = this->pos;
- break;
-
- case json_tokener_state_object_field_start:
- if(c == '}') {
- this->pos++;
- saved_state = json_tokener_state_finish;
- state = json_tokener_state_eatws;
- } else if (c == '"' || c == '\'') {
- quote_char = c;
- talloc_free(this->pb);
- this->pb = talloc_zero_size(this->ctx, 1);
- if (this->pb == NULL) {
- *err_p = json_tokener_error_oom;
- goto out;
- }
- state = json_tokener_state_object_field;
- start_offset = ++this->pos;
- } else {
- err = json_tokener_error_parse_object;
- goto out;
- }
- break;
-
- case json_tokener_state_object_field:
- if(c == quote_char) {
- this->pb = append_string(
- this->ctx,
- this->pb,
- this->source + start_offset,
- this->pos - start_offset);
- if (this->pb == NULL) {
- err = json_tokener_error_oom;
- goto out;
- }
- obj_field_name = talloc_strdup(this->ctx,
- this->pb);
- if (obj_field_name == NULL) {
- err = json_tokener_error_oom;
- goto out;
- }
- saved_state = json_tokener_state_object_field_end;
- state = json_tokener_state_eatws;
- } else if(c == '\\') {
- saved_state = json_tokener_state_object_field;
- state = json_tokener_state_string_escape;
- }
- this->pos++;
- break;
-
- case json_tokener_state_object_field_end:
- if(c == ':') {
- this->pos++;
- saved_state = json_tokener_state_object_value;
- state = json_tokener_state_eatws;
- } else {
- *err_p = json_tokener_error_parse_object;
- mprDestroyVar(&current);
- return mprCreateUndefinedVar();
- }
- break;
-
- case json_tokener_state_object_value:
- obj = json_tokener_do_parse(this, &err);
- if (err != json_tokener_success) {
- goto out;
- }
- mprSetVar(&current, obj_field_name, obj);
- talloc_free(obj_field_name);
- obj_field_name = NULL;
- saved_state = json_tokener_state_object_sep;
- state = json_tokener_state_eatws;
- break;
-
- case json_tokener_state_object_sep:
- if(c == '}') {
- this->pos++;
- saved_state = json_tokener_state_finish;
- state = json_tokener_state_eatws;
- } else if(c == ',') {
- this->pos++;
- saved_state = json_tokener_state_object;
- state = json_tokener_state_eatws;
- } else {
- err = json_tokener_error_parse_object;
- goto out;
- }
- break;
-
- }
- } while(c);
-
- if(state != json_tokener_state_finish &&
- saved_state != json_tokener_state_finish)
- err = json_tokener_error_parse_eof;
-
-out:
- talloc_free(obj_field_name);
- if(err == json_tokener_success) {
- return current;
- } else {
- mprDestroyVar(&current);
- *err_p = err;
- return mprCreateUndefinedVar();
- }
-}
-
-
-void smb_setup_ejs_literal(void)
-{
- ejsDefineStringCFunction(-1,
- "literal_to_var",
- literal_to_var,
- NULL,
- MPR_VAR_SCRIPT_HANDLE);
-}
diff --git a/source4/scripting/ejs/smbcalls.c b/source4/scripting/ejs/smbcalls.c
index 98d6be07bf..4314b51455 100644
--- a/source4/scripting/ejs/smbcalls.c
+++ b/source4/scripting/ejs/smbcalls.c
@@ -191,7 +191,6 @@ void smb_setup_ejs_functions(void (*exception_handler)(const char *))
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);
@@ -203,11 +202,8 @@ void smb_setup_ejs_functions(void (*exception_handler)(const char *))
ejs_exception_handler = exception_handler;
- smb_setup_ejs_cli();
smb_setup_ejs_options();
smb_setup_ejs_credentials();
- smb_setup_ejs_param();
- smb_setup_ejs_literal();
shared_init = load_samba_modules(NULL, mprLpCtx(), "smbcalls");
diff --git a/source4/scripting/ejs/smbcalls_cli.c b/source4/scripting/ejs/smbcalls_cli.c
deleted file mode 100644
index dbb36312da..0000000000
--- a/source4/scripting/ejs/smbcalls_cli.c
+++ /dev/null
@@ -1,722 +0,0 @@
-/*
- Unix SMB/CIFS implementation.
-
- provide hooks into smbd C calls from ejs scripts
-
- Copyright (C) Tim Potter 2005
-
- 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 "scripting/ejs/smbcalls.h"
-#include "lib/appweb/ejs/ejs.h"
-#include "libcli/raw/libcliraw.h"
-#include "libcli/composite/composite.h"
-#include "libcli/smb_composite/smb_composite.h"
-#include "libcli/libcli.h"
-#include "libcli/resolve/resolve.h"
-#include "auth/credentials/credentials.h"
-#include "param/param.h"
-
-#if 0
-
-#include "librpc/gen_ndr/ndr_nbt.h"
-
-/* Connect to a server */
-
-static int ejs_cli_connect(MprVarHandle eid, int argc, char **argv)
-{
- struct smbcli_socket *sock;
- struct smbcli_transport *transport;
- struct nbt_name calling, called;
- NTSTATUS result;
-
- if (argc != 1) {
- ejsSetErrorMsg(eid, "connect invalid arguments");
- return -1;
- }
-
- /* Socket connect */
-
- sock = smbcli_sock_init(NULL, NULL);
-
- if (!sock) {
- ejsSetErrorMsg(eid, "socket initialisation failed");
- return -1;
- }
-
- if (!smbcli_sock_connect_byname(sock, argv[0], 0)) {
- ejsSetErrorMsg(eid, "socket connect failed");
- return -1;
- }
-
- transport = smbcli_transport_init(sock, sock, false);
-
- if (!transport) {
- ejsSetErrorMsg(eid, "transport init failed");
- return -1;
- }
-
- /* Send a netbios session request */
-
- make_nbt_name_client(&calling, lp_netbios_name());
-
- nbt_choose_called_name(NULL, &called, argv[0], NBT_NAME_SERVER);
-
- if (!smbcli_transport_connect(transport, &calling, &called)) {
- ejsSetErrorMsg(eid, "transport establishment failed");
- return -1;
- }
-
- result = smb_raw_negotiate(transport, lp_maxprotocol());
-
- if (!NT_STATUS_IS_OK(result)) {
- mpr_Return(eid, mprNTSTATUS(result));
- return 0;
- }
-
- /* Return a socket object */
-
- mpr_Return(eid, mprCreatePtrVar(transport));
-
- return 0;
-}
-
-/* Perform a session setup:
-
- session_setup(conn, "DOMAIN\\USERNAME%PASSWORD");
- session_setup(conn, USERNAME, PASSWORD);
- session_setup(conn, DOMAIN, USERNAME, PASSWORD);
- session_setup(conn); // anonymous
-
- */
-
-static int ejs_cli_ssetup(MprVarHandle eid, int argc, MprVar **argv)
-{
- struct smbcli_transport *transport;
- struct smbcli_session *session;
- struct smb_composite_sesssetup setup;
- struct cli_credentials *creds;
- NTSTATUS status;
- int result = -1;
-
- /* Argument parsing */
-
- if (argc < 1 || argc > 4) {
- ejsSetErrorMsg(eid, "session_setup invalid arguments");
- return -1;
- }
-
- if (!mprVarIsPtr(argv[0]->type)) {
- ejsSetErrorMsg(eid, "first arg is not a connect handle");
- return -1;
- }
-
- transport = argv[0]->ptr;
- creds = cli_credentials_init(transport);
- cli_credentials_set_conf(creds);
-
- if (argc == 4) {
-
- /* DOMAIN, USERNAME, PASSWORD form */
-
- if (!mprVarIsString(argv[1]->type)) {
- ejsSetErrorMsg(eid, "arg 1 must be a string");
- goto done;
- }
-
- cli_credentials_set_domain(creds, argv[1]->string,
- CRED_SPECIFIED);
-
- if (!mprVarIsString(argv[2]->type)) {
- ejsSetErrorMsg(eid, "arg 2 must be a string");
- goto done;
- }
-
- cli_credentials_set_username(creds, argv[2]->string,
- CRED_SPECIFIED);
-
- if (!mprVarIsString(argv[3]->type)) {
- ejsSetErrorMsg(eid, "arg 3 must be a string");
- goto done;
- }
-
- cli_credentials_set_password(creds, argv[3]->string,
- CRED_SPECIFIED);
-
- } else if (argc == 3) {
-
- /* USERNAME, PASSWORD form */
-
- if (!mprVarIsString(argv[1]->type)) {
- ejsSetErrorMsg(eid, "arg1 must be a string");
- goto done;
- }
-
- cli_credentials_set_username(creds, argv[1]->string,
- CRED_SPECIFIED);
-
- if (!mprVarIsString(argv[2]->type)) {
-
- ejsSetErrorMsg(eid, "arg2 must be a string");
- goto done;
- }
-
- cli_credentials_set_password(creds, argv[2]->string,
- CRED_SPECIFIED);
-
- } else if (argc == 2) {
-
- /* DOMAIN/USERNAME%PASSWORD form */
-
- cli_credentials_parse_string(creds, argv[1]->string,
- CRED_SPECIFIED);
-
- } else {
-
- /* Anonymous connection */
-
- cli_credentials_set_anonymous(creds);
- }
-
- /* Do session setup */
-
- session = smbcli_session_init(transport, transport, false);
-
- if (!session) {
- ejsSetErrorMsg(eid, "session init failed");
- return -1;
- }
-
- setup.in.sesskey = transport->negotiate.sesskey;
- setup.in.capabilities = transport->negotiate.capabilities;
- setup.in.credentials = creds;
- setup.in.workgroup = lp_workgroup();
-
- status = smb_composite_sesssetup(session, &setup);
-
- if (!NT_STATUS_IS_OK(status)) {
- ejsSetErrorMsg(eid, "session_setup: %s", nt_errstr(status));
- return -1;
- }
-
- session->vuid = setup.out.vuid;
-
- /* Return a session object */
-
- mpr_Return(eid, mprCreatePtrVar(session));
-
- result = 0;
-
- done:
- talloc_free(creds);
- return result;
-}
-
-/* Perform a tree connect
-
- tree_connect(session, SHARE);
-
- */
-
-static int ejs_cli_tree_connect(MprVarHandle eid, int argc, MprVar **argv)
-{
- struct smbcli_session *session;
- struct smbcli_tree *tree;
- union smb_tcon tcon;
- TALLOC_CTX *mem_ctx;
- NTSTATUS status;
- const char *password = "";
-
- /* Argument parsing */
-
- if (argc != 2) {
- ejsSetErrorMsg(eid, "tree_connect invalid arguments");
- return -1;
- }
-
- if (!mprVarIsPtr(argv[0]->type)) {
- ejsSetErrorMsg(eid, "first arg is not a session handle");
- return -1;
- }
-
- session = argv[0]->ptr;
- tree = smbcli_tree_init(session, session, false);
-
- if (!tree) {
- ejsSetErrorMsg(eid, "tree init failed");
- return -1;
- }
-
- mem_ctx = talloc_init("tcon");
- if (!mem_ctx) {
- ejsSetErrorMsg(eid, "talloc_init failed");
- return -1;
- }
-
- /* Do tree connect */
-
- tcon.generic.level = RAW_TCON_TCONX;
- tcon.tconx.in.flags = 0;
-
- if (session->transport->negotiate.sec_mode & NEGOTIATE_SECURITY_USER_LEVEL) {
- tcon.tconx.in.password = data_blob(NULL, 0);
- } else if (session->transport->negotiate.sec_mode & NEGOTIATE_SECURITY_CHALLENGE_RESPONSE) {
- tcon.tconx.in.password = data_blob_talloc(mem_ctx, NULL, 24);
- if (session->transport->negotiate.secblob.length < 8) {
- ejsSetErrorMsg(eid, "invalid security blob");
- return -1;
- }
- SMBencrypt(password, session->transport->negotiate.secblob.data, tcon.tconx.in.password.data);
- } else {
- tcon.tconx.in.password = data_blob_talloc(mem_ctx, password, strlen(password)+1);
- }
-
- tcon.tconx.in.path = argv[1]->string;
- tcon.tconx.in.device = "?????";
-
- status = smb_tree_connect(tree, mem_ctx, &tcon);
-
- if (!NT_STATUS_IS_OK(status)) {
- ejsSetErrorMsg(eid, "tree_connect: %s", nt_errstr(status));
- return -1;
- }
-
- tree->tid = tcon.tconx.out.tid;
-
- talloc_free(mem_ctx);
-
- mpr_Return(eid, mprCreatePtrVar(tree));
-
- return 0;
-}
-
-/* Perform a tree disconnect
-
- tree_disconnect(tree);
-
- */
-static int ejs_cli_tree_disconnect(MprVarHandle eid, int argc, MprVar **argv)
-{
- struct smbcli_tree *tree;
- NTSTATUS status;
-
- /* Argument parsing */
-
- if (argc != 1) {
- ejsSetErrorMsg(eid, "tree_disconnect invalid arguments");
- return -1;
- }
-
- if (!mprVarIsPtr(argv[0]->type)) {
- ejsSetErrorMsg(eid, "first arg is not a tree handle");
- return -1;
- }
-
- tree = argv[0]->ptr;
-
- status = smb_tree_disconnect(tree);
-
- if (!NT_STATUS_IS_OK(status)) {
- ejsSetErrorMsg(eid, "tree_disconnect: %s", nt_errstr(status));
- return -1;
- }
-
- talloc_free(tree);
-
- return 0;
-}
-
-/* Perform a ulogoff
-
- session_logoff(session);
-
- */
-static int ejs_cli_session_logoff(MprVarHandle eid, int argc, MprVar **argv)
-{
- struct smbcli_session *session;
- NTSTATUS status;
-
- /* Argument parsing */
-
- if (argc != 1) {
- ejsSetErrorMsg(eid, "session_logoff invalid arguments");
- return -1;
- }
-
- if (!mprVarIsPtr(argv[0]->type)) {
- ejsSetErrorMsg(eid, "first arg is not a session handle");
- return -1;
- }
-
- session = argv[0]->ptr;
-
- status = smb_raw_ulogoff(session);
-
- if (!NT_STATUS_IS_OK(status)) {
- ejsSetErrorMsg(eid, "session_logoff: %s", nt_errstr(status));
- return -1;
- }
-
- talloc_free(session);
-
- return 0;
-}
-
-/* Perform a connection close
-
- disconnect(conn);
-
- */
-static int ejs_cli_disconnect(MprVarHandle eid, int argc, MprVar **argv)
-{
- struct smbcli_sock *sock;
-
- /* Argument parsing */
-
- if (argc != 1) {
- ejsSetErrorMsg(eid, "disconnect invalid arguments");
- return -1;
- }
-
- if (!mprVarIsPtr(argv[0]->type)) {
- ejsSetErrorMsg(eid, "first arg is not a connect handle");
- return -1;
- }
-
- sock = argv[0]->ptr;
-
- talloc_free(sock);
-
- return 0;
-}
-
-#endif
-
-/* Perform a tree connect:
-
- tree_handle = tree_connect("\\\\frogurt\\homes", "user%pass");
- */
-
-static int ejs_tree_connect(MprVarHandle eid, int argc, char **argv)
-{
- struct cli_credentials *creds;
- struct smb_composite_connect io;
- struct smbcli_tree *tree;
- char *hostname, *sharename;
- NTSTATUS result;
- TALLOC_CTX *mem_ctx;
-
- if (argc != 2) {
- ejsSetErrorMsg(eid, "tree_connect(): invalid number of args");
- return -1;
- }
-
- /* Set up host, share destination */
-
- mem_ctx = talloc_new(mprMemCtx());
- smbcli_parse_unc(argv[0], mem_ctx, &hostname, &sharename);
-
- /* Set up credentials */
-
- creds = cli_credentials_init(NULL);
- cli_credentials_set_conf(creds, mprLpCtx());
- cli_credentials_parse_string(creds, argv[1], CRED_SPECIFIED);
-
- /* Do connect */
-
- io.in.dest_host = hostname;
- io.in.dest_ports = lp_smb_ports(mprLpCtx());
- io.in.called_name = strupper_talloc(mem_ctx, hostname);
- io.in.service = sharename;
- io.in.service_type = "?????";
- io.in.credentials = creds;
- io.in.fallback_to_anonymous = false;
- io.in.workgroup = lp_workgroup(mprLpCtx());
- lp_smbcli_options(mprLpCtx(), &io.in.options);
-
- result = smb_composite_connect(&io, mem_ctx,
- lp_resolve_context(mprLpCtx()),
- NULL);
- tree = io.out.tree;
-
- talloc_free(mem_ctx);
-
- if (!NT_STATUS_IS_OK(result)) {
- mpr_Return(eid, mprNTSTATUS(result));
- return 0;
- }
-
- mpr_Return(eid, mprCreatePtrVar(tree));
-
- return 0;
-}
-
-#define IS_TREE_HANDLE(x) (mprVarIsPtr((x)->type) && \
- talloc_check_name((x)->ptr, "struct smbcli_tree"))
-
-/* Perform a tree disconnect:
-
- tree_disconnect(tree_handle);
- */
-
-static int ejs_tree_disconnect(MprVarHandle eid, int argc, MprVar **argv)
-{
- struct smbcli_tree *tree;
- NTSTATUS result;
-
- if (argc != 1) {
- ejsSetErrorMsg(eid,
- "tree_disconnect(): invalid number of args");
- return -1;
- }
-
- if (!IS_TREE_HANDLE(argv[0])) {
- ejsSetErrorMsg(eid, "first arg is not a tree handle");
- return -1;
- }
-
- tree = talloc_get_type(argv[0]->ptr, struct smbcli_tree);
-
- result = smb_tree_disconnect(tree);
-
- mpr_Return(eid, mprNTSTATUS(result));
-
- return 0;
-}
-
-/* Create a directory:
-
- result = mkdir(tree_handle, DIRNAME);
- */
-
-static int ejs_mkdir(MprVarHandle eid, int argc, MprVar **argv)
-{
- struct smbcli_tree *tree;
- NTSTATUS result;
-
- if (argc != 2) {
- ejsSetErrorMsg(eid, "mkdir(): invalid number of args");
- return -1;
- }
-
- if (!IS_TREE_HANDLE(argv[0])) {
- ejsSetErrorMsg(eid, "first arg is not a tree handle");
- return -1;
- }
-
- tree = (struct smbcli_tree *)argv[0]->ptr;
-
- if (!mprVarIsString(argv[1]->type)) {
- ejsSetErrorMsg(eid, "arg 2 must be a string");
- return -1;
- }
-
- result = smbcli_mkdir(tree, argv[1]->string);
-
- mpr_Return(eid, mprNTSTATUS(result));
-
- return 0;
-}
-
-/* Remove a directory:
-
- result = rmdir(tree_handle, DIRNAME);
- */
-
-static int ejs_rmdir(MprVarHandle eid, int argc, MprVar **argv)
-{
- struct smbcli_tree *tree;
- NTSTATUS result;
-
- if (argc != 2) {
- ejsSetErrorMsg(eid, "rmdir(): invalid number of args");
- return -1;
- }
-
- if (!IS_TREE_HANDLE(argv[0])) {
- ejsSetErrorMsg(eid, "first arg is not a tree handle");
- return -1;
- }
-
- tree = (struct smbcli_tree *)argv[0]->ptr;
-
- if (!mprVarIsString(argv[1]->type)) {
- ejsSetErrorMsg(eid, "arg 2 must be a string");
- return -1;
- }
-
- result = smbcli_rmdir(tree, argv[1]->string);
-
- mpr_Return(eid, mprNTSTATUS(result));
-
- return 0;
-}
-
-/* Rename a file or directory:
-
- result = rename(tree_handle, SRCFILE, DESTFILE);
- */
-
-static int ejs_rename(MprVarHandle eid, int argc, MprVar **argv)
-{
- struct smbcli_tree *tree;
- NTSTATUS result;
-
- if (argc != 3) {
- ejsSetErrorMsg(eid, "rename(): invalid number of args");
- return -1;
- }
-
- if (!IS_TREE_HANDLE(argv[0])) {
- ejsSetErrorMsg(eid, "first arg is not a tree handle");
- return -1;
- }
-
- tree = (struct smbcli_tree *)argv[0]->ptr;
-
- if (!mprVarIsString(argv[1]->type)) {
- ejsSetErrorMsg(eid, "arg 2 must be a string");
- return -1;
- }
-
- if (!mprVarIsString(argv[2]->type)) {
- ejsSetErrorMsg(eid, "arg 3 must be a string");
- return -1;
- }
-
- result = smbcli_rename(tree, argv[1]->string, argv[2]->string);
-
- mpr_Return(eid, mprNTSTATUS(result));
-
- return 0;
-}
-
-/* Unlink a file or directory:
-
- result = unlink(tree_handle, FILENAME);
- */
-
-static int ejs_unlink(MprVarHandle eid, int argc, MprVar **argv)
-{
- struct smbcli_tree *tree;
- NTSTATUS result;
-
- if (argc != 2) {
- ejsSetErrorMsg(eid, "unlink(): invalid number of args");
- return -1;
- }
-
- if (!IS_TREE_HANDLE(argv[0])) {
- ejsSetErrorMsg(eid, "first arg is not a tree handle");
- return -1;
- }
-
- tree = (struct smbcli_tree *)argv[0]->ptr;
-
- if (!mprVarIsString(argv[1]->type)) {
- ejsSetErrorMsg(eid, "arg 2 must be a string");
- return -1;
- }
-
- result = smbcli_unlink(tree, argv[1]->string);
-
- mpr_Return(eid, mprNTSTATUS(result));
-
- return 0;
-}
-
-/* List directory contents
-
- result = list(tree_handle, ARG1, ...);
- */
-
-static void ejs_list_helper(struct clilist_file_info *info, const char *mask,
- void *state)
-
-{
- MprVar *result = (MprVar *)state;
- char idx[16];
-
- mprItoa(result->properties->numDataItems, idx, sizeof(idx));
- mprSetVar(result, idx, mprString(info->name));
-}
-
-static int ejs_list(MprVarHandle eid, int argc, MprVar **argv)
-{
- struct smbcli_tree *tree;
- char *mask;
- uint16_t attribute;
- MprVar result;
-
- if (argc != 3) {
- ejsSetErrorMsg(eid, "list(): invalid number of args");
- return -1;
- }
-
- if (!IS_TREE_HANDLE(argv[0])) {
- ejsSetErrorMsg(eid, "first arg is not a tree handle");
- return -1;
- }
-
- tree = (struct smbcli_tree *)argv[0]->ptr;
-
- if (!mprVarIsString(argv[1]->type)) {
- ejsSetErrorMsg(eid, "arg 2 must be a string");
- return -1;
- }
-
- mask = argv[1]->string;
-
- if (!mprVarIsNumber(argv[2]->type)) {
- ejsSetErrorMsg(eid, "arg 3 must be a number");
- return -1;
- }
-
- attribute = mprVarToInteger(argv[2]);
-
- result = mprObject("list");
-
- smbcli_list(tree, mask, attribute, ejs_list_helper, &result);
-
- mpr_Return(eid, result);
-
- return 0;
-}
-
-/*
- setup C functions that be called from ejs
-*/
-void smb_setup_ejs_cli(void)
-{
- ejsDefineStringCFunction(-1, "tree_connect", ejs_tree_connect, NULL, MPR_VAR_SCRIPT_HANDLE);
- ejsDefineCFunction(-1, "tree_disconnect", ejs_tree_disconnect, NULL, MPR_VAR_SCRIPT_HANDLE);
-
- ejsDefineCFunction(-1, "mkdir", ejs_mkdir, NULL, MPR_VAR_SCRIPT_HANDLE);
- ejsDefineCFunction(-1, "rmdir", ejs_rmdir, NULL, MPR_VAR_SCRIPT_HANDLE);
- ejsDefineCFunction(-1, "rename", ejs_rename, NULL, MPR_VAR_SCRIPT_HANDLE);
- ejsDefineCFunction(-1, "unlink", ejs_unlink, NULL, MPR_VAR_SCRIPT_HANDLE);
- ejsDefineCFunction(-1, "list", ejs_list, NULL, MPR_VAR_SCRIPT_HANDLE);
-
-
-#if 0
- ejsDefineStringCFunction(-1, "connect", ejs_cli_connect, NULL, MPR_VAR_SCRIPT_HANDLE);
- ejsDefineCFunction(-1, "session_setup", ejs_cli_ssetup, NULL, MPR_VAR_SCRIPT_HANDLE);
- ejsDefineCFunction(-1, "tree_connect", ejs_cli_tree_connect, NULL, MPR_VAR_SCRIPT_HANDLE);
- ejsDefineCFunction(-1, "tree_disconnect", ejs_cli_tree_disconnect, NULL, MPR_VAR_SCRIPT_HANDLE);
- ejsDefineCFunction(-1, "session_logoff", ejs_cli_session_logoff, NULL, MPR_VAR_SCRIPT_HANDLE);
- ejsDefineCFunction(-1, "disconnect", ejs_cli_disconnect, NULL, MPR_VAR_SCRIPT_HANDLE);
-#endif
-}
diff --git a/source4/scripting/ejs/smbcalls_data.c b/source4/scripting/ejs/smbcalls_data.c
deleted file mode 100644
index 19e1e173d6..0000000000
--- a/source4/scripting/ejs/smbcalls_data.c
+++ /dev/null
@@ -1,284 +0,0 @@
-/*
- Unix SMB/CIFS implementation.
-
- provide access to data blobs
-
- Copyright (C) Andrew Tridgell 2005
-
- 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 "scripting/ejs/smbcalls.h"
-#include "lib/appweb/ejs/ejs.h"
-#include "librpc/gen_ndr/winreg.h"
-
-/*
- create a data blob object from a ejs array of integers
-*/
-static int ejs_blobFromArray(MprVarHandle eid, int argc, struct MprVar **argv)
-{
- struct MprVar *array, *v;
- unsigned length, i;
- DATA_BLOB blob;
-
- if (argc != 1) {
- ejsSetErrorMsg(eid, "blobFromArray invalid arguments");
- return -1;
- }
- array = argv[0];
-
- v = mprGetProperty(array, "length", NULL);
- if (v == NULL) {
- goto failed;
- }
- length = mprToInt(v);
-
- blob = data_blob_talloc(mprMemCtx(), NULL, length);
- if (length != 0 && blob.data == NULL) {
- goto failed;
- }
-
- for (i=0;i<length;i++) {
- struct MprVar *vs;
- char idx[16];
- mprItoa(i, idx, sizeof(idx));
- vs = mprGetProperty(array, idx, NULL);
- if (vs == NULL) {
- goto failed;
- }
- blob.data[i] = mprVarToNumber(vs);
- }
-
- mpr_Return(eid, mprDataBlob(blob));
- return 0;
-
-failed:
- mpr_Return(eid, mprCreateUndefinedVar());
- return 0;
-}
-
-/*
- create a ejs array of integers from a data blob
-*/
-static int ejs_blobToArray(MprVarHandle eid, int argc, struct MprVar **argv)
-{
- DATA_BLOB *blob;
- struct MprVar array;
- int i;
-
- if (argc != 1) {
- ejsSetErrorMsg(eid, "blobToArray invalid arguments");
- return -1;
- }
- blob = mprToDataBlob(argv[0]);
- if (blob == NULL) {
- goto failed;
- }
-
- array = mprArray("array");
-
- for (i=0;i<blob->length;i++) {
- mprAddArray(&array, i, mprCreateNumberVar(blob->data[i]));
- }
- mpr_Return(eid, array);
- return 0;
-
-failed:
- mpr_Return(eid, mprCreateUndefinedVar());
- return 0;
-}
-
-
-/*
- compare two data blobs
-*/
-static int ejs_blobCompare(MprVarHandle eid, int argc, struct MprVar **argv)
-{
- DATA_BLOB *blob1, *blob2;
- bool ret = false;
-
- if (argc != 2) {
- ejsSetErrorMsg(eid, "blobCompare invalid arguments");
- return -1;
- }
-
- blob1 = mprToDataBlob(argv[0]);
- blob2 = mprToDataBlob(argv[1]);
-
- if (blob1 == blob2) {
- ret = true;
- goto done;
- }
- if (blob1 == NULL || blob2 == NULL) {
- ret = false;
- goto done;
- }
-
- if (blob1->length != blob2->length) {
- ret = false;
- goto done;
- }
-
- if (memcmp(blob1->data, blob2->data, blob1->length) != 0) {
- ret = false;
- goto done;
- }
- ret = true;
-
-done:
- mpr_Return(eid, mprCreateBoolVar(ret));
- return 0;
-}
-
-
-/*
- convert a blob in winreg format to a mpr variable
-
- usage:
- v = data.regToVar(blob, type);
-*/
-static int ejs_regToVar(MprVarHandle eid, int argc, struct MprVar **argv)
-{
- DATA_BLOB *blob;
- enum winreg_Type type;
- struct MprVar v;
-
- if (argc != 2) {
- ejsSetErrorMsg(eid, "regToVar invalid arguments");
- return -1;
- }
-
- blob = mprToDataBlob(argv[0]);
- type = mprToInt(argv[1]);
-
- if (blob == NULL) {
- ejsSetErrorMsg(eid, "regToVar null data");
- return -1;
- }
-
- switch (type) {
- case REG_NONE:
- v = mprCreateUndefinedVar();
- break;
-
- case REG_SZ:
- case REG_EXPAND_SZ: {
- char *s;
- ssize_t len;
- len = convert_string_talloc(mprMemCtx(), lp_iconv_convenience(mprLpCtx()), CH_UTF16, CH_UNIX,
- blob->data, blob->length, (void **)&s);
- if (len == -1) {
- ejsSetErrorMsg(eid, "regToVar invalid REG_SZ string");
- return -1;
- }
- v = mprString(s);
- talloc_free(s);
- break;
- }
-
- case REG_DWORD: {
- if (blob->length != 4) {
- ejsSetErrorMsg(eid, "regToVar invalid REG_DWORD length %ld", (long)blob->length);
- return -1;
- }
- v = mprCreateNumberVar(IVAL(blob->data, 0));
- break;
- }
-
- case REG_DWORD_BIG_ENDIAN: {
- if (blob->length != 4) {
- ejsSetErrorMsg(eid, "regToVar invalid REG_DWORD_BIG_ENDIAN length %ld", (long)blob->length);
- return -1;
- }
- v = mprCreateNumberVar(RIVAL(blob->data, 0));
- break;
- }
-
- case REG_QWORD: {
- if (blob->length != 8) {
- ejsSetErrorMsg(eid, "regToVar invalid REG_QWORD length %ld", (long)blob->length);
- return -1;
- }
- v = mprCreateNumberVar(BVAL(blob->data, 0));
- break;
- }
-
- case REG_MULTI_SZ: {
- DATA_BLOB b = *blob;
- const char **list = NULL;
- while (b.length > 0) {
- char *s;
- ssize_t len;
- size_t slen = utf16_len_n(b.data, b.length);
- if (slen == 2 && b.length == 2 && SVAL(b.data, 0) == 0) {
- break;
- }
- len = convert_string_talloc(mprMemCtx(), lp_iconv_convenience(mprLpCtx()), CH_UTF16, CH_UNIX,
- b.data, slen, (void **)&s);
- if (len == -1) {
- ejsSetErrorMsg(eid, "regToVar invalid REG_MULTI_SZ string");
- return -1;
- }
- list = str_list_add(list, s);
- talloc_free(s);
- talloc_steal(mprMemCtx(), list);
- b.data += slen;
- b.length -= slen;
- }
- v = mprList("REG_MULTI_SZ", list);
- talloc_free(list);
- break;
- }
-
-
- case REG_FULL_RESOURCE_DESCRIPTOR:
- case REG_RESOURCE_LIST:
- case REG_BINARY:
- case REG_RESOURCE_REQUIREMENTS_LIST:
- case REG_LINK:
- return ejs_blobToArray(eid, 1, argv);
-
- default:
- ejsSetErrorMsg(eid, "regToVar invalid type %d", type);
- return -1;
- }
-
- mpr_Return(eid, v);
- return 0;
-}
-
-/*
- initialise datablob ejs subsystem
-*/
-static int ejs_datablob_init(MprVarHandle eid, int argc, struct MprVar **argv)
-{
- struct MprVar *obj = mprInitObject(eid, "datablob", argc, argv);
-
- mprSetCFunction(obj, "blobFromArray", ejs_blobFromArray);
- mprSetCFunction(obj, "blobToArray", ejs_blobToArray);
- mprSetCFunction(obj, "blobCompare", ejs_blobCompare);
- mprSetCFunction(obj, "regToVar", ejs_regToVar);
-
- return 0;
-}
-
-/*
- setup C functions that be called from ejs
-*/
-NTSTATUS smb_setup_ejs_datablob(void)
-{
- ejsDefineCFunction(-1, "datablob_init", ejs_datablob_init, NULL, MPR_VAR_SCRIPT_HANDLE);
- return NT_STATUS_OK;
-}
diff --git a/source4/scripting/ejs/smbcalls_nbt.c b/source4/scripting/ejs/smbcalls_nbt.c
deleted file mode 100644
index 8c555bf821..0000000000
--- a/source4/scripting/ejs/smbcalls_nbt.c
+++ /dev/null
@@ -1,93 +0,0 @@
-/*
- Unix SMB/CIFS implementation.
-
- provide hooks into smbd C calls from ejs scripts
-
- Copyright (C) Tim Potter 2005
-
- 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 "scripting/ejs/smbcalls.h"
-#include "lib/appweb/ejs/ejs.h"
-#include "librpc/gen_ndr/nbt.h"
-#include "lib/events/events.h"
-#include "libcli/resolve/resolve.h"
-
-/*
- look up a netbios name
-
- syntax:
- resolveName(result, "frogurt");
- resolveName(result, "frogurt", 0x1c);
-*/
-
-static int ejs_resolve_name(MprVarHandle eid, int argc, struct MprVar **argv)
-{
- int result = -1;
- struct nbt_name name;
- TALLOC_CTX *tmp_ctx = talloc_new(mprMemCtx());
- NTSTATUS nt_status;
- const char *reply_addr;
-
- /* validate arguments */
- if (argc < 2 || argc > 3) {
- ejsSetErrorMsg(eid, "resolveName invalid arguments");
- goto done;
- }
-
- if (argv[0]->type != MPR_TYPE_OBJECT) {
- ejsSetErrorMsg(eid, "resolvename invalid arguments");
- goto done;
- }
-
- if (argv[1]->type != MPR_TYPE_STRING) {
- ejsSetErrorMsg(eid, "resolveName invalid arguments");
- goto done;
- }
-
- if (argc == 2) {
- make_nbt_name_client(&name, mprToString(argv[1]));
- } else {
- if (!mprVarIsNumber(argv[1]->type)) {
- ejsSetErrorMsg(eid, "resolveName invalid arguments");
- goto done;
- }
- make_nbt_name(&name, mprToString(argv[1]), mprToInt(argv[2]));
- }
-
- result = 0;
-
- nt_status = resolve_name(lp_resolve_context(mprLpCtx()), &name, tmp_ctx, &reply_addr, mprEventCtx());
-
- if (NT_STATUS_IS_OK(nt_status)) {
- mprSetPropertyValue(argv[0], "value", mprString(reply_addr));
- }
-
- mpr_Return(eid, mprNTSTATUS(nt_status));
-
- done:
- talloc_free(tmp_ctx);
- return result;
-}
-
-/*
- setup C functions that be called from ejs
-*/
-NTSTATUS smb_setup_ejs_nbt(void)
-{
- ejsDefineCFunction(-1, "resolveName", ejs_resolve_name, NULL, MPR_VAR_SCRIPT_HANDLE);
- return NT_STATUS_OK;
-}
diff --git a/source4/scripting/ejs/smbcalls_nss.c b/source4/scripting/ejs/smbcalls_nss.c
deleted file mode 100644
index 58f86d3b6c..0000000000
--- a/source4/scripting/ejs/smbcalls_nss.c
+++ /dev/null
@@ -1,160 +0,0 @@
-/*
- Unix SMB/CIFS implementation.
-
- provide access to getpwnam() and related calls
-
- Copyright (C) Andrew Tridgell 2005
-
- 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 "scripting/ejs/smbcalls.h"
-#include "lib/appweb/ejs/ejs.h"
-#include "system/passwd.h"
-
-
-/*
- return a struct passwd as an object
-*/
-static struct MprVar mpr_passwd(struct passwd *pwd)
-{
- struct MprVar ret;
- if (pwd == NULL) {
- return mprCreateUndefinedVar();
- }
- ret = mprObject("passwd");
-
- mprSetVar(&ret, "pw_name", mprString(pwd->pw_name));
- mprSetVar(&ret, "pw_passwd", mprString(pwd->pw_passwd));
- mprSetVar(&ret, "pw_uid", mprCreateIntegerVar(pwd->pw_uid));
- mprSetVar(&ret, "pw_gid", mprCreateIntegerVar(pwd->pw_gid));
- mprSetVar(&ret, "pw_gecos", mprString(pwd->pw_gecos));
- mprSetVar(&ret, "pw_dir", mprString(pwd->pw_dir));
- mprSetVar(&ret, "pw_shell", mprString(pwd->pw_shell));
- return ret;
-}
-
-/*
- return a struct passwd as an object
-*/
-static struct MprVar mpr_group(struct group *grp)
-{
- struct MprVar ret;
- if (grp == NULL) {
- return mprCreateUndefinedVar();
- }
- ret = mprObject("group");
-
- mprSetVar(&ret, "gr_name", mprString(grp->gr_name));
- mprSetVar(&ret, "gr_passwd", mprString(grp->gr_passwd));
- mprSetVar(&ret, "gr_gid", mprCreateIntegerVar(grp->gr_gid));
- mprSetVar(&ret, "gr_mem", mprList("gr_mem", (const char **)grp->gr_mem));
- return ret;
-}
-
-
-/*
- usage:
- var pw = nss.getpwnam("root");
-
- returns an object containing struct passwd entries
-*/
-static int ejs_getpwnam(MprVarHandle eid, int argc, struct MprVar **argv)
-{
- /* validate arguments */
- if (argc != 1 || argv[0]->type != MPR_TYPE_STRING) {
- ejsSetErrorMsg(eid, "getpwnam invalid arguments");
- return -1;
- }
-
- mpr_Return(eid, mpr_passwd(getpwnam(mprToString(argv[0]))));
- return 0;
-}
-
-/*
- usage:
- var pw = nss.getpwuid(0);
-
- returns an object containing struct passwd entries
-*/
-static int ejs_getpwuid(MprVarHandle eid, int argc, struct MprVar **argv)
-{
- /* validate arguments */
- if (argc != 1 || !mprVarIsNumber(argv[0]->type)) {
- ejsSetErrorMsg(eid, "getpwuid invalid arguments");
- return -1;
- }
- mpr_Return(eid, mpr_passwd(getpwuid(mprToInt(argv[0]))));
- return 0;
-}
-
-/*
- usage:
- var pw = nss.getgrnam("users");
-
- returns an object containing struct group entries
-*/
-static int ejs_getgrnam(MprVarHandle eid, int argc, struct MprVar **argv)
-{
- /* validate arguments */
- if (argc != 1 || argv[0]->type != MPR_TYPE_STRING) {
- ejsSetErrorMsg(eid, "getgrnam invalid arguments");
- return -1;
- }
- mpr_Return(eid, mpr_group(getgrnam(mprToString(argv[0]))));
- return 0;
-}
-
-/*
- usage:
- var pw = nss.getgrgid(0);
-
- returns an object containing struct group entries
-*/
-static int ejs_getgrgid(MprVarHandle eid, int argc, struct MprVar **argv)
-{
- /* validate arguments */
- if (argc != 1 || argv[0]->type != MPR_TYPE_STRING) {
- ejsSetErrorMsg(eid, "getgrgid invalid arguments");
- return -1;
- }
- mpr_Return(eid, mpr_group(getgrgid(mprToInt(argv[0]))));
- return 0;
-}
-
-
-/*
- initialise nss ejs subsystem
-*/
-static int ejs_nss_init(MprVarHandle eid, int argc, struct MprVar **argv)
-{
- struct MprVar *nss = mprInitObject(eid, "nss", argc, argv);
-
- mprSetCFunction(nss, "getpwnam", ejs_getpwnam);
- mprSetCFunction(nss, "getpwuid", ejs_getpwuid);
- mprSetCFunction(nss, "getgrnam", ejs_getgrnam);
- mprSetCFunction(nss, "getgrgid", ejs_getgrgid);
-
- return 0;
-}
-
-/*
- setup C functions that be called from ejs
-*/
-NTSTATUS smb_setup_ejs_nss(void)
-{
- ejsDefineCFunction(-1, "nss_init", ejs_nss_init, NULL, MPR_VAR_SCRIPT_HANDLE);
- return NT_STATUS_OK;
-}
diff --git a/source4/scripting/ejs/smbcalls_param.c b/source4/scripting/ejs/smbcalls_param.c
deleted file mode 100644
index 5fbb0bb017..0000000000
--- a/source4/scripting/ejs/smbcalls_param.c
+++ /dev/null
@@ -1,259 +0,0 @@
-/*
- Unix SMB/CIFS implementation.
-
- provide hooks into smbd C calls from ejs scripts
-
- Copyright (C) Jelmer Vernooij 2005
-
- 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 "param/param.h"
-#include "scripting/ejs/smbcalls.h"
-#include "lib/appweb/ejs/ejs.h"
-
-/*
- get parameter
-
- value = param.get("name");
- value = param.get("section", "name");
-*/
-static int ejs_param_get(MprVarHandle eid, int argc, char **argv)
-{
- struct param_context *ctx;
- const char *ret;
- if (argc != 1 && argc != 2) {
- ejsSetErrorMsg(eid, "param.get invalid argument count");
- return -1;
- }
-
- ctx = (struct param_context *)mprGetThisPtr(eid, "param");
- mprAssert(ctx);
-
- if (argc == 2) {
- ret = param_get_string(ctx, argv[0], argv[1]);
- } else {
- ret = param_get_string(ctx, argv[0], NULL);
- }
-
- if (ret) {
- mpr_Return(eid, mprString(ret));
- } else {
- mpr_Return(eid, mprCreateUndefinedVar());
- }
- return 0;
-}
-
-/*
- get list parameter
-
- ok = param.get_list("name");
- ok = param.get_list("section", "name");
-*/
-static int ejs_param_get_list(MprVarHandle eid, int argc, char **argv)
-{
- struct param_context *ctx;
- const char **ret;
-
- if (argc != 1 && argc != 2) {
- ejsSetErrorMsg(eid, "param.get_list invalid argument count");
- return -1;
- }
-
- ctx = (struct param_context *)mprGetThisPtr(eid, "param");
- mprAssert(ctx);
-
- if (argc == 2) {
- ret = param_get_string_list(ctx, argv[0], argv[1], NULL);
- } else {
- ret = param_get_string_list(ctx, argv[0], NULL, NULL);
- }
-
- if (ret != NULL) {
- mpr_Return(eid, mprList("array", ret));
- } else {
- mpr_Return(eid, mprCreateUndefinedVar());
- }
- return 0;
-}
-
-/*
- set parameter
-
- ok = param.set("name", "value");
- ok = param.set("section", "name", "value");
-*/
-static int ejs_param_set(MprVarHandle eid, int argc, struct MprVar **argv)
-{
- struct param_context *ctx;
- const char **list;
- const char *section, *paramname;
- struct MprVar *value;
- bool ret;
- if (argc != 2 && argc != 3) {
- ejsSetErrorMsg(eid, "param.set invalid argument count");
- return -1;
- }
-
- ctx = (struct param_context *)mprGetThisPtr(eid, "param");
- mprAssert(ctx);
-
-
- if (argc == 3) {
- section = mprToString(argv[0]);
- paramname = mprToString(argv[1]);
- value = argv[2];
- } else {
- section = NULL;
- paramname = mprToString(argv[0]);
- value = argv[1];
- }
-
- list = mprToList(mprMemCtx(), value);
- if (list) {
- ret = param_set_string_list(ctx, paramname, list, section);
- } else {
- ret = param_set_string(ctx, paramname, mprToString(value), section);
- }
-
- mpr_Return(eid, mprCreateBoolVar(ret));
- return 0;
-}
-
-/*
- param data as a two-level array
-
- data = param.data;
- */
-static int ejs_param_data(MprVarHandle eid, int argc, char **argv)
-{
- struct param_context *ctx;
- struct MprVar ret;
- struct param_section *sec;
-
- if (argc != 0) {
- ejsSetErrorMsg(eid, "param.data does not take arguments");
- return -1;
- }
-
- ctx = (struct param_context *)mprGetThisPtr(eid, "param");
- mprAssert(ctx);
-
- ret = mprObject("array");
-
- for (sec = ctx->sections; sec; sec = sec->next) {
- struct MprVar ps = mprObject("array");
- struct param_opt *p;
-
- for (p = sec->parameters; p; p = p->next) {
- mprSetVar(&ps, p->key, mprString(p->value));
- }
-
- mprSetVar(&ret, sec->name, ps);
- }
-
- mpr_Return(eid, ret);
-
- return 0;
-}
-
-/*
- load file
-
- ok = param.load(file);
-*/
-static int ejs_param_load(MprVarHandle eid, int argc, char **argv)
-{
- struct param_context *ctx;
- bool ret;
-
- if (argc != 1) {
- ejsSetErrorMsg(eid, "param.load invalid argument count");
- return -1;
- }
-
- ctx = (struct param_context *)mprGetThisPtr(eid, "param");
- mprAssert(ctx);
-
- ret = param_read(ctx, argv[0]);
-
- mpr_Return(eid, mprCreateBoolVar(ret));
- return 0;
-}
-
-
-/*
- save file
-
- ok = param.save(file);
-*/
-static int ejs_param_save(MprVarHandle eid, int argc, char **argv)
-{
- struct param_context *ctx;
- bool ret;
-
- if (argc != 1) {
- ejsSetErrorMsg(eid, "param.save invalid argument count");
- return -1;
- }
-
- ctx = (struct param_context *)mprGetThisPtr(eid, "param");
- mprAssert(ctx);
-
- ret = param_write(ctx, argv[0]);
-
- mpr_Return(eid, mprCreateBoolVar(ret));
- return 0;
-}
-
-static void param_add_members(struct MprVar *obj)
-{
- mprSetStringCFunction(obj, "get", ejs_param_get);
- mprSetStringCFunction(obj, "get_list", ejs_param_get_list);
- mprSetCFunction(obj, "set", ejs_param_set);
- mprSetStringCFunction(obj, "load", ejs_param_load);
- mprSetStringCFunction(obj, "save", ejs_param_save);
- mprSetStringCFunction(obj, "data", ejs_param_data);
-}
-
-/*
- initialise param ejs subsystem
-*/
-static int ejs_param_init(MprVarHandle eid, int argc, struct MprVar **argv)
-{
- struct MprVar *obj = mprInitObject(eid, "param", argc, argv);
-
- mprSetPtrChild(obj, "param", param_init(mprMemCtx()));
-
- param_add_members(obj);
-
- return 0;
-}
-
-struct MprVar mprParam(struct param_context *ctx)
-{
- struct MprVar mpv = mprObject("param");
- mprSetPtrChild(&mpv, "param", ctx);
- param_add_members(&mpv);
- return mpv;
-}
-
-/*
- setup C functions that be called from ejs
-*/
-void smb_setup_ejs_param(void)
-{
- ejsDefineCFunction(-1, "param_init", ejs_param_init, NULL, MPR_VAR_SCRIPT_HANDLE);
-}
diff --git a/source4/scripting/ejs/smbcalls_rand.c b/source4/scripting/ejs/smbcalls_rand.c
deleted file mode 100644
index 58e0fa1fd1..0000000000
--- a/source4/scripting/ejs/smbcalls_rand.c
+++ /dev/null
@@ -1,104 +0,0 @@
-/*
- Unix SMB/CIFS implementation.
-
- provide access to randomisation functions
-
- Copyright (C) Andrew Tridgell 2005
-
- 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 "scripting/ejs/smbcalls.h"
-#include "lib/appweb/ejs/ejs.h"
-#include "librpc/gen_ndr/ndr_misc.h"
-#include "librpc/ndr/libndr.h"
-
-/*
- usage:
- var i = random();
-*/
-static int ejs_random(MprVarHandle eid, int argc, struct MprVar **argv)
-{
- mpr_Return(eid, mprCreateIntegerVar(generate_random()));
- return 0;
-}
-
-/*
- usage:
- var s = randpass(len);
-*/
-static int ejs_randpass(MprVarHandle eid, int argc, struct MprVar **argv)
-{
- char *s;
- if (argc != 1 || !mprVarIsNumber(argv[0]->type)) {
- ejsSetErrorMsg(eid, "randpass invalid arguments");
- return -1;
- }
- s = generate_random_str(mprMemCtx(), mprToInt(argv[0]));
- mpr_Return(eid, mprString(s));
- talloc_free(s);
- return 0;
-}
-
-/*
- usage:
- var guid = randguid();
-*/
-static int ejs_randguid(MprVarHandle eid, int argc, struct MprVar **argv)
-{
- struct GUID guid = GUID_random();
- char *s = GUID_string(mprMemCtx(), &guid);
- mpr_Return(eid, mprString(s));
- talloc_free(s);
- return 0;
-}
-
-/*
- usage:
- var sid = randsid();
-*/
-static int ejs_randsid(MprVarHandle eid, int argc, struct MprVar **argv)
-{
- char *s = talloc_asprintf(mprMemCtx(), "S-1-5-21-%u-%u-%u",
- (unsigned)generate_random(),
- (unsigned)generate_random(),
- (unsigned)generate_random());
- mpr_Return(eid, mprString(s));
- talloc_free(s);
- return 0;
-}
-
-/*
- initialise random ejs subsystem
-*/
-static int ejs_random_init(MprVarHandle eid, int argc, struct MprVar **argv)
-{
- struct MprVar *obj = mprInitObject(eid, "random", argc, argv);
-
- mprSetCFunction(obj, "random", ejs_random);
- mprSetCFunction(obj, "randpass", ejs_randpass);
- mprSetCFunction(obj, "randguid", ejs_randguid);
- mprSetCFunction(obj, "randsid", ejs_randsid);
- return 0;
-}
-
-/*
- setup C functions that be called from ejs
-*/
-NTSTATUS smb_setup_ejs_random(void)
-{
- ejsDefineCFunction(-1, "random_init", ejs_random_init, NULL, MPR_VAR_SCRIPT_HANDLE);
- return NT_STATUS_OK;
-}
diff --git a/source4/scripting/ejs/smbcalls_reg.c b/source4/scripting/ejs/smbcalls_reg.c
deleted file mode 100644
index ed8653d3a7..0000000000
--- a/source4/scripting/ejs/smbcalls_reg.c
+++ /dev/null
@@ -1,90 +0,0 @@
-/*
- Unix SMB/CIFS implementation.
-
- provide hooks into smbd C calls from ejs scripts
-
- Copyright (C) Jelmer Vernooij 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 "scripting/ejs/smbcalls.h"
-#include "lib/appweb/ejs/ejs.h"
-#include "dsdb/samdb/samdb.h"
-#include "librpc/ndr/libndr.h"
-#include "lib/registry/registry.h"
-
-/*
- get the connected db
- */
-static struct registry_context *ejs_get_reg_context(int eid)
-{
- struct registry_context *rctx = (struct registry_context *)mprGetThisPtr(eid, "registry");
- if (rctx == NULL) {
- ejsSetErrorMsg(eid, "unable to find registry");
- }
- return rctx;
-}
-
-static int ejs_apply_patchfile(MprVarHandle eid, int argc, struct MprVar **argv)
-{
- struct registry_context *rctx;
- WERROR error;
-
- /* validate arguments */
- if (argc != 1) {
- ejsSetErrorMsg(eid, "reg.apply_patchfile invalid number of arguments");
- return -1;
- }
-
- rctx = ejs_get_reg_context(eid);
- if (rctx == NULL) {
- return -1;
- }
-
- error = reg_diff_apply(rctx, mprToString(argv[0]));
-
- mpr_Return(eid, mprWERROR(error));
-
- return 0;
-}
-
-/*
- initialise registry ejs subsystem
-*/
-static int ejs_reg_open(MprVarHandle eid, int argc, struct MprVar **argv)
-{
- struct MprVar *reg = mprInitObject(eid, "registry", argc, argv);
- struct registry_context *rctx;
- WERROR error;
-
- error = reg_open_samba(mprMemCtx(), &rctx, mprEventCtx(), mprLpCtx(), NULL, NULL);
- SMB_ASSERT(W_ERROR_IS_OK(error));
-
- mprSetPtrChild(reg, "registry", rctx);
- mprSetCFunction(reg, "apply_patchfile", ejs_apply_patchfile);
-
- return 0;
-}
-
-
-/*
- setup C functions that be called from ejs
-*/
-NTSTATUS smb_setup_ejs_reg(void)
-{
- ejsDefineCFunction(-1, "reg_open", ejs_reg_open, NULL, MPR_VAR_SCRIPT_HANDLE);
- return NT_STATUS_OK;
-}
diff --git a/source4/scripting/ejs/smbcalls_rpc.c b/source4/scripting/ejs/smbcalls_rpc.c
deleted file mode 100644
index 94774d708b..0000000000
--- a/source4/scripting/ejs/smbcalls_rpc.c
+++ /dev/null
@@ -1,385 +0,0 @@
-/*
- Unix SMB/CIFS implementation.
-
- provide interfaces to rpc calls from ejs scripts
-
- Copyright (C) Andrew Tridgell 2005
-
- 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 "scripting/ejs/smbcalls.h"
-#include "lib/appweb/ejs/ejs.h"
-#include "librpc/gen_ndr/echo.h"
-#include "lib/cmdline/popt_common.h"
-#include "lib/messaging/irpc.h"
-#include "scripting/ejs/ejsrpc.h"
-#include "lib/util/dlinklist.h"
-#include "lib/events/events.h"
-#include "librpc/ndr/ndr_table.h"
-#include "auth/credentials/credentials.h"
-#include "librpc/rpc/dcerpc.h"
-#include "cluster/cluster.h"
-
-/*
- state of a irpc 'connection'
-*/
-struct ejs_irpc_connection {
- const char *server_name;
- struct server_id *dest_ids;
- struct messaging_context *msg_ctx;
-};
-
-/*
- messaging clients need server IDs as well ...
- */
-#define EJS_ID_BASE 0x30000000
-
-/*
- setup a context for talking to a irpc server
- example:
- status = irpc.connect("smb_server");
-*/
-static int ejs_irpc_connect(MprVarHandle eid, int argc, char **argv)
-{
- NTSTATUS status;
- int i;
- struct event_context *ev;
- struct ejs_irpc_connection *p;
- struct MprVar *this = mprGetProperty(ejsGetLocalObject(eid), "this", 0);
-
- /* validate arguments */
- if (argc != 1) {
- ejsSetErrorMsg(eid, "rpc_connect invalid arguments");
- return -1;
- }
-
- p = talloc(this, struct ejs_irpc_connection);
- if (p == NULL) {
- return -1;
- }
-
- p->server_name = argv[0];
-
- ev = mprEventCtx();
-
- /* create a messaging context, looping as we have no way to
- allocate temporary server ids automatically */
- for (i=0;i<10000;i++) {
- p->msg_ctx = messaging_init(p,
- lp_messaging_path(p, mprLpCtx()),
- cluster_id(EJS_ID_BASE, i),
- lp_iconv_convenience(mprLpCtx()),
- ev);
- if (p->msg_ctx) break;
- }
- if (p->msg_ctx == NULL) {
- ejsSetErrorMsg(eid, "irpc_connect unable to create a messaging context");
- talloc_free(p);
- return -1;
- }
-
- p->dest_ids = irpc_servers_byname(p->msg_ctx, p, p->server_name);
- if (p->dest_ids == NULL || p->dest_ids[0].id == 0) {
- talloc_free(p);
- status = NT_STATUS_OBJECT_NAME_NOT_FOUND;
- } else {
- mprSetPtrChild(this, "irpc", p);
- status = NT_STATUS_OK;
- }
-
- mpr_Return(eid, mprNTSTATUS(status));
- return 0;
-}
-
-
-/*
- connect to an rpc server
- examples:
- status = rpc.connect("ncacn_ip_tcp:localhost");
- status = rpc.connect("ncacn_ip_tcp:localhost", "pipe_name");
-*/
-static int ejs_rpc_connect(MprVarHandle eid, int argc, char **argv)
-{
- const char *binding, *pipe_name;
- const struct ndr_interface_table *iface;
- NTSTATUS status;
- struct dcerpc_pipe *p;
- struct cli_credentials *creds;
- struct event_context *ev;
- struct MprVar *this = mprGetProperty(ejsGetLocalObject(eid), "this", 0);
- struct MprVar *credentials;
-
- /* validate arguments */
- if (argc < 1) {
- ejsSetErrorMsg(eid, "rpc_connect invalid arguments");
- return -1;
- }
-
- binding = argv[0];
- if (strchr(binding, ':') == NULL) {
- /* its an irpc connect */
- return ejs_irpc_connect(eid, argc, argv);
- }
-
- if (argc > 1) {
- pipe_name = argv[1];
- } else {
- pipe_name = mprToString(mprGetProperty(this, "pipe_name", NULL));
- }
-
- iface = ndr_table_by_name(pipe_name);
- if (iface == NULL) {
- status = NT_STATUS_OBJECT_NAME_INVALID;
- goto done;
- }
-
- credentials = mprGetProperty(this, "credentials", NULL);
- if (credentials) {
- creds = (struct cli_credentials *)
- mprGetPtr(credentials, "creds");
- } else {
- creds = cmdline_credentials;
- }
- if (creds == NULL) {
- creds = cli_credentials_init(mprMemCtx());
- cli_credentials_set_anonymous(creds);
- }
-
- ev = mprEventCtx();
-
- status = dcerpc_pipe_connect(this, &p, binding, iface, creds, ev,
- mprLpCtx());
- if (!NT_STATUS_IS_OK(status)) goto done;
-
- /* callers don't allocate ref vars in the ejs interface */
- p->conn->flags |= DCERPC_NDR_REF_ALLOC;
-
- /* by making the pipe a child of the connection variable, it will
- auto close when it goes out of scope in the script */
- mprSetPtrChild(this, "pipe", p);
-
-done:
- mpr_Return(eid, mprNTSTATUS(status));
- return 0;
-}
-
-
-/*
- make an irpc call - called via the same interface as rpc
-*/
-static int ejs_irpc_call(int eid, struct MprVar *io,
- const struct ndr_interface_table *iface, int callnum,
- ejs_pull_function_t ejs_pull, ejs_push_function_t ejs_push)
-{
- NTSTATUS status;
- void *ptr;
- struct ejs_rpc *ejs;
- const struct ndr_interface_call *call;
- struct ejs_irpc_connection *p;
- struct irpc_request **reqs;
- int i, count;
- struct MprVar *results;
-
- p = (struct ejs_irpc_connection *)mprGetThisPtr(eid, "irpc");
-
- ejs = talloc(mprMemCtx(), struct ejs_rpc);
- if (ejs == NULL) {
- status = NT_STATUS_NO_MEMORY;
- goto done;
- }
-
- call = &iface->calls[callnum];
-
- ejs->eid = eid;
- ejs->callname = call->name;
-
- /* allocate the C structure */
- ptr = talloc_zero_size(ejs, call->struct_size);
- if (ptr == NULL) {
- status = NT_STATUS_NO_MEMORY;
- goto done;
- }
-
- /* convert the mpr object into a C structure */
- status = ejs_pull(ejs, io, ptr);
- if (!NT_STATUS_IS_OK(status)) {
- goto done;
- }
-
- for (count=0;p->dest_ids[count].id;count++) /* noop */ ;
-
- /* we need to make a call per server */
- reqs = talloc_array(ejs, struct irpc_request *, count);
- if (reqs == NULL) {
- status = NT_STATUS_NO_MEMORY;
- goto done;
- }
-
- /* make the actual calls */
- for (i=0;i<count;i++) {
- reqs[i] = irpc_call_send(p->msg_ctx, p->dest_ids[i],
- iface, callnum, ptr, ptr);
- if (reqs[i] == NULL) {
- status = NT_STATUS_NO_MEMORY;
- goto done;
- }
- talloc_steal(reqs, reqs[i]);
- }
-
- mprSetVar(io, "results", mprObject("results"));
- results = mprGetProperty(io, "results", NULL);
-
- /* and receive the results, placing them in io.results[i] */
- for (i=0;i<count;i++) {
- struct MprVar *output;
-
- status = irpc_call_recv(reqs[i]);
- if (!NT_STATUS_IS_OK(status)) {
- goto done;
- }
- status = ejs_push(ejs, io, ptr);
- if (!NT_STATUS_IS_OK(status)) {
- goto done;
- }
-
- /* add to the results array */
- output = mprGetProperty(io, "output", NULL);
- if (output) {
- char idx[16];
- mprItoa(i, idx, sizeof(idx));
- mprSetProperty(results, idx, output);
- mprDeleteProperty(io, "output");
- }
- }
- mprSetVar(results, "length", mprCreateIntegerVar(i));
-
-done:
- talloc_free(ejs);
- mpr_Return(eid, mprNTSTATUS(status));
- if (NT_STATUS_EQUAL(status, NT_STATUS_INTERNAL_ERROR)) {
- return -1;
- }
- return 0;
-}
-
-
-/*
- backend code for making an rpc call - this is called from the pidl generated ejs
- code
-*/
- int ejs_rpc_call(int eid, int argc, struct MprVar **argv,
- const struct ndr_interface_table *iface, int callnum,
- ejs_pull_function_t ejs_pull, ejs_push_function_t ejs_push)
-{
- struct MprVar *io;
- struct dcerpc_pipe *p;
- NTSTATUS status;
- void *ptr;
- struct rpc_request *req;
- struct ejs_rpc *ejs;
- const struct ndr_interface_call *call;
-
- if (argc != 1 || argv[0]->type != MPR_TYPE_OBJECT) {
- ejsSetErrorMsg(eid, "rpc_call invalid arguments");
- return -1;
- }
-
- io = argv[0];
-
- if (mprGetThisPtr(eid, "irpc")) {
- /* its an irpc call */
- return ejs_irpc_call(eid, io, iface, callnum, ejs_pull, ejs_push);
- }
-
- /* get the pipe info */
- p = mprGetThisPtr(eid, "pipe");
- if (p == NULL) {
- ejsSetErrorMsg(eid, "rpc_call invalid pipe");
- return -1;
- }
-
- ejs = talloc(mprMemCtx(), struct ejs_rpc);
- if (ejs == NULL) {
- status = NT_STATUS_NO_MEMORY;
- goto done;
- }
-
- call = &iface->calls[callnum];
-
- ejs->eid = eid;
- ejs->callname = call->name;
-
- /* allocate the C structure */
- ptr = talloc_zero_size(ejs, call->struct_size);
- if (ptr == NULL) {
- status = NT_STATUS_NO_MEMORY;
- goto done;
- }
-
- /* convert the mpr object into a C structure */
- status = ejs_pull(ejs, io, ptr);
- if (!NT_STATUS_IS_OK(status)) {
- goto done;
- }
-
- /* make the actual call */
- req = dcerpc_ndr_request_send(p, NULL, iface, callnum, ptr, ptr);
-
- /* if requested, print the structure */
- if (p->conn->flags & DCERPC_DEBUG_PRINT_IN) {
- ndr_print_function_debug(call->ndr_print, call->name, NDR_IN, ptr);
- }
-
- if (req == NULL) {
- status = NT_STATUS_NO_MEMORY;
- goto done;
- }
-
- status = dcerpc_ndr_request_recv(req);
- if (!NT_STATUS_IS_OK(status)) {
- goto done;
- }
-
- /* print the 'out' structure, if needed */
- if (p->conn->flags & DCERPC_DEBUG_PRINT_OUT) {
- ndr_print_function_debug(call->ndr_print, call->name, NDR_OUT, ptr);
- }
-
- status = ejs_push(ejs, io, ptr);
-
-done:
- talloc_free(ejs);
- mpr_Return(eid, mprNTSTATUS(status));
- if (NT_STATUS_EQUAL(status, NT_STATUS_INTERNAL_ERROR)) {
- return -1;
- }
- return 0;
-}
-
-/*
- hook called by generated RPC interfaces at the end of their init routines
- used to add generic operations on the pipe
-*/
-int ejs_rpc_init(struct MprVar *obj, const char *name)
-{
- ndr_table_init();
-
- mprSetStringCFunction(obj, "connect", ejs_rpc_connect);
- if (mprGetProperty(obj, "pipe_name", NULL) == NULL) {
- mprSetVar(obj, "pipe_name", mprString(name));
- }
- return 0;
-}
diff --git a/source4/scripting/ejs/smbscript.c b/source4/scripting/ejs/smbscript.c
index 9ed4aa490f..db9fc9affa 100644
--- a/source4/scripting/ejs/smbscript.c
+++ b/source4/scripting/ejs/smbscript.c
@@ -26,7 +26,7 @@
#include "scripting/ejs/smbcalls.h"
#include "auth/gensec/gensec.h"
#include "ldb/include/ldb.h"
-#include "dynconfig.h"
+#include "dynconfig/dynconfig.h"
static EjsId eid;
diff --git a/source4/scripting/libjs/auth.js b/source4/scripting/libjs/auth.js
deleted file mode 100644
index 3fe81d0ea7..0000000000
--- a/source4/scripting/libjs/auth.js
+++ /dev/null
@@ -1,18 +0,0 @@
-/*
- auth js library functions
- Copyright Andrew Tridgell 2005
- released under the GNU GPL version 3 or later
-*/
-
-
-/*
- get a list of domains for SWAT authentication
-*/
-function getDomainList()
-{
- var ret = new Array(2);
- var lp = loadparm_init();
- ret[0] = "System User";
- ret[1] = lp.get("workgroup");
- return ret;
-}
diff --git a/source4/scripting/libjs/base.js b/source4/scripting/libjs/base.js
index d861073a07..790dfeb3e0 100644
--- a/source4/scripting/libjs/base.js
+++ b/source4/scripting/libjs/base.js
@@ -21,48 +21,6 @@ function printf()
}
/*
- helper function to setup a rpc io object, ready for input
-*/
-function irpcObj()
-{
- var o = new Object();
- o.input = new Object();
- return o;
-}
-
-/*
- check that a status result is OK
-*/
-function check_status_ok(status)
-{
- if (status.is_ok != true) {
- printVars(status);
- }
- assert(status.is_ok == true);
-}
-
-/*
- check that two arrays are equal
-*/
-function check_array_equal(a1, a2)
-{
- assert(a1.length == a2.length);
- for (i=0; i<a1.length; i++) {
- assert(a1[i] == a2[i]);
- }
-}
-
-/*
- check that an array is all zeros
-*/
-function check_array_zero(a)
-{
- for (i=0; i<a.length; i++) {
- assert(a[i] == 0);
- }
-}
-
-/*
substitute strings of the form ${NAME} in str, replacing
with substitutions from subobj
*/
@@ -90,14 +48,3 @@ function substitute_var(str, subobj)
}
return join("", list);
}
-
-/*
- return "s" if a number should be shown as plural
-*/
-function plural(n)
-{
- if (n == 1) {
- return "";
- }
- return "s";
-}
diff --git a/source4/scripting/libjs/encoder.js b/source4/scripting/libjs/encoder.js
deleted file mode 100644
index 6cb780c00d..0000000000
--- a/source4/scripting/libjs/encoder.js
+++ /dev/null
@@ -1,116 +0,0 @@
-/*
- server side js functions for encoding/decoding objects into linear strings
-
- Copyright Andrew Tridgell 2005
- released under the GNU GPL Version 3 or later
-*/
-/*
- usage:
-
- enc = encodeObject(obj);
- obj = decodeObject(enc);
-
- The encoded format of the object is a string that is safe to
- use in URLs
-
- Note that only data elements are encoded, not functions
-*/
-
-function __count_members(o) {
- var i, count = 0;
- for (i in o) {
- count++;
- }
- if (o.length != undefined) {
- count++;
- }
- return count;
-}
-
-function __replace(str, old, rep) {
- var s = string_init();
- var a = s.split(old, str);
- var j = s.join(rep, a);
- return s.join(rep, a);
-}
-
-function encodeElement(e, name) {
- var t = typeof(e);
- var r;
- var s = string_init();
- if (t == 'object' && e == null) {
- t = 'null';
- }
- if (t == 'object') {
- r = s.sprintf("%s:%s:%s", name, t, encodeObject(e));
- } else if (t == "string") {
- var enc = s.encodeURIComponent(e);
- var rep = __replace(enc, '%', '#');
- r = s.sprintf("%s:%s:%s:",
- name, t, __replace(s.encodeURIComponent(e),'%','#'));
- } else if (t == "boolean" || t == "number") {
- r = s.sprintf("%s:%s:%s:", name, t, "" + e);
- } else if (t == "undefined" || t == "null") {
- r = s.sprintf("%s:%s:", name, t);
- } else if (t == "pointer") {
- r = s.sprintf("%s:string:(POINTER):", name);
- } else {
- println("Unable to linearise type " + t);
- r = "";
- }
- return r;
-}
-
-function encodeObject(o) {
- var s = string_init();
- var i, r = s.sprintf("%u:", __count_members(o));
- for (i in o) {
- r = r + encodeElement(o[i], i);
- }
- if (o.length != undefined) {
- r = r + encodeElement(o.length, 'length');
- }
- return r;
-}
-
-function decodeObjectArray(a) {
- var s = string_init();
- var o = new Object();
- var i, count = a[a.i]; a.i++;
- for (i=0;i<count;i++) {
- var name = a[a.i]; a.i++;
- var type = a[a.i]; a.i++;
- var value;
- if (type == 'object') {
- o[name] = decodeObjectArray(a);
- } else if (type == "string") {
- value = s.decodeURIComponent(__replace(a[a.i],'#','%')); a.i++;
- o[name] = value;
- } else if (type == "boolean") {
- value = a[a.i]; a.i++;
- if (value == 'true') {
- o[name] = true;
- } else {
- o[name] = false;
- }
- } else if (type == "undefined") {
- o[name] = undefined;
- } else if (type == "null") {
- o[name] = null;
- } else if (type == "number") {
- value = a[a.i]; a.i++;
- o[name] = value + 0;
- } else {
- println("Unable to delinearise type " + t);
- assert(t == "supported type");
- }
- }
- return o;
-}
-
-function decodeObject(str) {
- var s = string_init();
- var a = s.split(':', str);
- a.i = 0;
- return decodeObjectArray(a);
-}
diff --git a/source4/scripting/libjs/management.js b/source4/scripting/libjs/management.js
deleted file mode 100644
index 4a43275156..0000000000
--- a/source4/scripting/libjs/management.js
+++ /dev/null
@@ -1,157 +0,0 @@
-/*
- backend code for Samba4 management
- Copyright Andrew Tridgell 2005
- Released under the GNU GPL version 3 or later
-*/
-
-
-/*
- return a list of current sessions
-*/
-function smbsrv_sessions()
-{
- var irpc = irpc_init();
- status = irpc.connect("smb_server");
- if (status.is_ok != true) {
- return undefined;
- }
-
- var io = irpcObj();
- io.input.level = irpc.SMBSRV_INFO_SESSIONS;
- status = irpc.smbsrv_information(io);
- if (status.is_ok != true) {
- return undefined;
- }
-
- /* gather the results into a single array */
- var i, count=0, ret = new Array(0);
- for (i=0;i<io.results.length;i++) {
- var sessions = io.results[i].info.sessions.sessions;
- var j;
- for (j=0;j<sessions.length;j++) {
- ret[count] = sessions[j];
- count++;
- }
- }
- return ret;
-}
-
-/*
- return a list of current tree connects
-*/
-function smbsrv_tcons()
-{
- var irpc = irpc_init();
- status = irpc.connect("smb_server");
- if (status.is_ok != true) {
- return undefined;
- }
-
- var io = irpcObj();
- io.input.level = irpc.SMBSRV_INFO_TCONS;
- status = irpc.smbsrv_information(io);
- if (status.is_ok != true) {
- return undefined;
- }
-
- /* gather the results into a single array */
- var i, count=0, ret = new Object();
- for (i=0;i<io.results.length;i++) {
- var tcons = io.results[i].info.tcons.tcons;
- var j;
- for (j=0;j<tcons.length;j++) {
- ret[count] = tcons[j];
- count++;
- }
- }
- ret.length = count;
- return ret;
-}
-
-/*
- return nbtd statistics
-*/
-function nbtd_statistics()
-{
- var irpc = irpc_init();
- status = irpc.connect("nbt_server");
- if (status.is_ok != true) {
- return undefined;
- }
-
- var io = irpcObj();
- io.input.level = irpc.NBTD_INFO_STATISTICS;
- status = irpc.nbtd_information(io);
- if (status.is_ok != true) {
- return undefined;
- }
- return io.results[0].info.stats;
-}
-
-/*
- see if a service is enabled
-*/
-function service_enabled(name)
-{
- var lp = loadparm_init();
- var services = lp.get("server services");
- var i;
- for (i=0;i<services.length;i++) {
- if (services[i] == name) {
- return true;
- }
- }
- return false;
-}
-
-/*
- show status of a server
-*/
-function server_status(name)
-{
- var i;
- var io;
- var irpc = irpc_init();
-
- if (!service_enabled(name)) {
- return "DISABLED";
- }
-
- status = irpc.connect(name + "_server");
- if (status.is_ok != true) {
- return "DOWN";
- }
-
- var io = irpcObj();
- status = irpc.irpc_uptime(io);
- if (status.is_ok != true) {
- return "NOT RESPONDING";
- }
-
- return "RUNNING";
-}
-
-/*
- show status of a stream server
-*/
-function stream_server_status(name)
-{
- var irpc = irpc_init();
-
- if (!service_enabled(name)) {
- return "DISABLED";
- }
- status = irpc.connect(name + "_server");
- if (status.is_ok != true) {
- return "0 connections";
- }
-
- var io = irpcObj();
- status = irpc.irpc_uptime(io);
- if (status.is_ok != true) {
- return "NOT RESPONDING";
- }
-
- var n = io.results.length;
- return sprintf("%u connection%s", n, plural(n));
-}
diff --git a/source4/scripting/libjs/samr.js b/source4/scripting/libjs/samr.js
deleted file mode 100644
index 6e8c70af3c..0000000000
--- a/source4/scripting/libjs/samr.js
+++ /dev/null
@@ -1,170 +0,0 @@
-/*
- samr rpc utility functions
- Copyright Andrew Tridgell 2005
- released under the GNU GPL version 3 or later
-*/
-
-if (global["HAVE_SAMR_JS"] != undefined) {
- return;
-}
-HAVE_SAMR_JS=1
-
-/*
- return a list of names and indexes from a samArray
-*/
-function samArray(output)
-{
- var list = new Array(output.num_entries);
- if (output.sam == NULL) {
- return list;
- }
- var i, entries = output.sam.entries;
- for (i=0;i<output.num_entries;i++) {
- list[i] = new Object();
- list[i].name = entries[i].name;
- list[i].idx = entries[i].idx;
- }
- return list;
-}
-
-/*
- connect to the sam database
-*/
-function samrConnect(conn)
-{
- security_init(conn);
- var io = irpcObj();
- io.input.system_name = NULL;
- io.input.access_mask = conn.SEC_FLAG_MAXIMUM_ALLOWED;
- var status = conn.samr_Connect2(io);
- check_status_ok(status);
- return io.output.connect_handle;
-}
-
-/*
- close a handle
-*/
-function samrClose(conn, handle)
-{
- var io = irpcObj();
- io.input.handle = handle;
- var status = conn.samr_Close(io);
- check_status_ok(status);
-}
-
-/*
- get the sid for a domain
-*/
-function samrLookupDomain(conn, handle, domain)
-{
- var io = irpcObj();
- io.input.connect_handle = handle;
- io.input.domain_name = domain;
- var status = conn.samr_LookupDomain(io);
- check_status_ok(status);
- return io.output.sid;
-}
-
-/*
- open a domain by sid
-*/
-function samrOpenDomain(conn, handle, sid)
-{
- var io = irpcObj();
- io.input.connect_handle = handle;
- io.input.access_mask = conn.SEC_FLAG_MAXIMUM_ALLOWED;
- io.input.sid = sid;
- var status = conn.samr_OpenDomain(io);
- check_status_ok(status);
- return io.output.domain_handle;
-}
-
-/*
- open a user by rid
-*/
-function samrOpenUser(conn, handle, rid)
-{
- var io = irpcObj();
- io.input.domain_handle = handle;
- io.input.access_mask = conn.SEC_FLAG_MAXIMUM_ALLOWED;
- io.input.rid = rid;
- var status = conn.samr_OpenUser(io);
- check_status_ok(status);
- return io.output.user_handle;
-}
-
-/*
- return a list of all users
-*/
-function samrEnumDomainUsers(conn, dom_handle)
-{
- var io = irpcObj();
- io.input.domain_handle = dom_handle;
- io.input.resume_handle = 0;
- io.input.acct_flags = 0;
- io.input.max_size = -1;
- var status = conn.samr_EnumDomainUsers(io);
- check_status_ok(status);
- return samArray(io.output);
-}
-
-/*
- return a list of all groups
-*/
-function samrEnumDomainGroups(conn, dom_handle)
-{
- var io = irpcObj();
- io.input.domain_handle = dom_handle;
- io.input.resume_handle = 0;
- io.input.acct_flags = 0;
- io.input.max_size = -1;
- var status = conn.samr_EnumDomainGroups(io);
- check_status_ok(status);
- return samArray(io.output);
-}
-
-/*
- return a list of domains
-*/
-function samrEnumDomains(conn, handle)
-{
- var io = irpcObj();
- io.input.connect_handle = handle;
- io.input.resume_handle = 0;
- io.input.buf_size = -1;
- var status = conn.samr_EnumDomains(io);
- check_status_ok(status);
- return samArray(io.output);
-}
-
-/*
- return information about a user
-*/
-function samrQueryUserInfo(conn, user_handle, level)
-{
- var r, io = irpcObj();
- io.input.user_handle = user_handle;
- io.input.level = level;
- var status = conn.samr_QueryUserInfo(io);
- check_status_ok(status);
- return io.output.info.info3;
-}
-
-
-/*
- fill a user array with user information from samrQueryUserInfo
-*/
-function samrFillUserInfo(conn, dom_handle, users, level)
-{
- var i;
- for (i=0;i<users.length;i++) {
- var r, user_handle, info;
- user_handle = samrOpenUser(conn, dom_handle, users[i].idx);
- info = samrQueryUserInfo(conn, user_handle, level);
- info.name = users[i].name;
- info.idx = users[i].idx;
- users[i] = info;
- samrClose(conn, user_handle);
- }
-}
-
diff --git a/source4/scripting/libjs/server_call.js b/source4/scripting/libjs/server_call.js
deleted file mode 100644
index 46414a90dd..0000000000
--- a/source4/scripting/libjs/server_call.js
+++ /dev/null
@@ -1,83 +0,0 @@
-/*
- server side js functions for handling async calls from js clients
-
- Copyright Andrew Tridgell 2005
- released under the GNU GPL Version 3 or later
-*/
-
-libinclude("encoder.js");
-
-/*
- register a new call
-*/
-function __register_call(name, func)
-{
- var c = this;
- c.calls[name] = func;
-}
-
-/*
- run a call sent from the client, and output the returned object (if any)
-*/
-function __run_call() {
- var c = this;
- var name = form['ajaj_func'];
- if (name == undefined) {
- /* no function to run */
- return;
- }
- var args = form['ajaj_args'];
- if (args == undefined) {
- println("no function arguments given in run_call");
- exit(0);
- }
- args = decodeObject(args);
- if (c.calls[name] == undefined) {
- println("undefined remote call " + name);
- exit(0);
- }
- var f = c.calls[name];
- var res;
- /* oh what a hack - should write a varargs ejs helper */
- if (args.length == 0) {
- res = f();
- } else if (args.length == 1) {
- res = f(args[0]);
- } else if (args.length == 2) {
- res = f(args[0], args[1]);
- } else if (args.length == 3) {
- res = f(args[0], args[1], args[2]);
- } else if (args.length == 4) {
- res = f(args[0], args[1], args[2], args[3]);
- } else if (args.length == 5) {
- res = f(args[0], args[1], args[2], args[3], args[4]);
- } else if (args.length == 6) {
- res = f(args[0], args[1], args[2], args[3], args[4], args[5]);
- } else if (args.length == 7) {
- res = f(args[0], args[1], args[2], args[3], args[4], args[5], args[6]);
- } else if (args.length == 8) {
- res = f(args[0], args[1], args[2], args[3], args[4], args[5], args[6], args[7]);
- } else {
- println("too many arguments for remote call: " + name);
- exit(0);
- }
- var repobj = new Object();
- repobj.res = res;
- write(encodeObject(repobj));
- exit(0);
-}
-
-
-
-/*
- initialise a server call object
-*/
-function servCallObj()
-{
- var c = new Object();
- c.add = __register_call;
- c.run = __run_call;
- c.calls = new Object();
- return c;
-}
-
diff --git a/source4/scripting/libjs/winreg.js b/source4/scripting/libjs/winreg.js
deleted file mode 100644
index 9db415694d..0000000000
--- a/source4/scripting/libjs/winreg.js
+++ /dev/null
@@ -1,291 +0,0 @@
-/*
- winreg rpc utility functions
- Copyright Andrew Tridgell 2005
- released under the GNU GPL version 3 or later
-*/
-
-libinclude("base.js");
-
-/*
- close a handle
-*/
-function __winreg_close(handle)
-{
- var io = irpcObj();
- io.input.handle = handle;
- this.winreg_CloseKey(io);
-}
-
-
-/*
- open a hive
-*/
-function __winreg_open_hive(hive)
-{
- var io = irpcObj();
- io.input.system_name = NULL;
- io.input.access_mask = this.SEC_FLAG_MAXIMUM_ALLOWED;
- var status;
- if (hive == "HKLM") {
- status = this.winreg_OpenHKLM(io);
- } else if (hive == "HKCR") {
- status = this.winreg_OpenHKCR(io);
- } else if (hive == "HKPD") {
- status = this.winreg_OpenHKPD(io);
- } else if (hive == "HKU") {
- status = this.winreg_OpenHKU(io);
- } else {
- this._last_error = "Unknown hive " + hive;
- return undefined;
- }
- if (!status.is_ok) {
- return undefined;
- }
- return io.output.handle;
-}
-
-/*
- open a handle to a path
-*/
-function __winreg_open_path(path)
-{
- var s = string_init();
- var i, components = s.split('\\', path);
-
- /* cope with a leading slash */
- if (components[0] == '') {
- for (i=0;i<(components.length-1);i++) {
- components[i] = components[i+1];
- }
- delete(components[i]);
- }
-
- if (components.length == 0) {
- return undefined;
- }
-
- var handle = this.open_hive(components[0]);
- if (handle == undefined) {
- return undefined;
- }
-
- if (components.length == 1) {
- return handle;
- }
-
- var hpath = components[1];
-
- for (i=2;i<components.length;i++) {
- hpath = hpath + "\\" + components[i];
- }
-
- io = irpcObj();
- io.input.parent_handle = handle;
- io.input.keyname = hpath;
- io.input.unknown = 0;
- io.input.access_mask = this.SEC_FLAG_MAXIMUM_ALLOWED;
- var status = this.winreg_OpenKey(io);
-
- this.close(handle);
-
- if (!status.is_ok) {
- return undefined;
- }
- if (io.output.result != "WERR_OK") {
- return undefined;
- }
-
- return io.output.handle;
-}
-
-/*
- return a list of keys for a winreg server given a path
- usage:
- list = reg.enum_path(path);
-*/
-function __winreg_enum_path(path)
-{
- var list = new Array(0);
-
- if (path == null || path == "\\" || path == "") {
- return new Array("HKLM", "HKU");
- }
-
- var handle = this.open_path(path);
- if (handle == undefined) {
- return undefined;
- }
-
- var io = irpcObj();
- io.input.handle = handle;
- io.input.name = new Object();
- io.input.name.length = 0;
- io.input.name.size = 32;
- io.input.name.name = NULL;
- io.input.keyclass = new Object();
- io.input.keyclass.length = 0;
- io.input.keyclass.size = 1024;
- io.input.keyclass.name = NULL;
- io.input.last_changed_time = 0;
-
- var idx = 0;
- for (idx=0;idx >= 0;idx++) {
- io.input.enum_index = idx;
- var status = this.winreg_EnumKey(io);
- if (!status.is_ok) {
- this.close(handle);
- return list;
- }
- var out = io.output;
- if (out.result == "WERR_MORE_DATA") {
- io.input.name.size = io.input.name.size * 2;
- idx--;
- if (io.input.name.size > 32000) {
- this.close(handle);
- return list;
- }
- continue;
- }
- if (out.result != "WERR_OK") {
- this.close(handle);
- return list;
- }
- list[list.length] = out.name.name;
- }
-
- this.close(handle);
- return list;
-}
-
-
-/*
- return a list of values for a winreg server given a path
- usage:
- list = reg.enum_values(path);
-
- each returned list element is an object containing a name, a
- type and a value
-*/
-function __winreg_enum_values(path)
-{
- var data = datablob_init();
- var list = new Array(0);
-
- var handle = this.open_path(path);
- if (handle == undefined) {
- return undefined;
- }
-
- var io = irpcObj();
- io.input.handle = handle;
- io.input.name = new Object();
- io.input.name.length = 0;
- io.input.name.size = 128;
- io.input.name.name = "";
- io.input.type = 0;
- io.input.value = new Array(0);
- io.input.size = 1024;
- io.input.length = 0;
-
- var idx;
- for (idx=0;idx >= 0;idx++) {
- io.input.enum_index = idx;
- var status = this.winreg_EnumValue(io);
- if (!status.is_ok) {
- this.close(handle);
- return list;
- }
- var out = io.output;
- if (out.result == "WERR_MORE_DATA") {
- io.input.size = io.input.size * 2;
- io.input.name.size = io.input.name.size * 2;
- idx--;
- /* limit blobs to 1M */
- if (io.input.size > 1000000) {
- this.close(handle);
- return list;
- }
- continue;
- }
- if (out.result != "WERR_OK") {
- this.close(handle);
- return list;
- }
- var el = new Object();
- el.name = out.name.name;
- el.type = out.type;
- el.rawvalue = out.value;
- el.value = data.regToVar(el.rawvalue, el.type);
- el.size = out.size;
- list[list.length] = el;
- }
-
- this.close(handle);
- return list;
-}
-
-
-/*
- create a new key
- ok = reg.create_key(path, key);
-*/
-function __winreg_create_key(path, key)
-{
- var handle = this.open_path(path);
- if (handle == undefined) {
- return undefined;
- }
-
- var io = irpcObj();
- io.input.handle = handle;
- io.input.name = key;
- io.input.keyclass = NULL;
- io.input.options = 0;
- io.input.access_mask = this.SEC_FLAG_MAXIMUM_ALLOWED;
- io.input.secdesc = NULL;
- io.input.action_taken = 0;
-
- var status = this.winreg_CreateKey(io);
- this.close(handle);
- if (!status.is_ok) {
- return false;
- }
- if (io.output.result != "WERR_OK") {
- return false;
- }
- this.close(io.output.new_handle);
- return true;
-}
-
-
-/*
- return a string for a winreg type
-*/
-function __winreg_typestring(type)
-{
- return this.typenames[type];
-}
-
-/*
- initialise the winreg lib, returning an object
-*/
-function winregObj()
-{
- var reg = winreg_init();
- security_init(reg);
-
- reg.typenames = new Array("REG_NONE", "REG_SZ", "REG_EXPAND_SZ", "REG_BINARY",
- "REG_DWORD", "REG_DWORD_BIG_ENDIAN", "REG_LINK", "REG_MULTI_SZ",
- "REG_RESOURCE_LIST", "REG_FULL_RESOURCE_DESCRIPTOR",
- "REG_RESOURCE_REQUIREMENTS_LIST", "REG_QWORD");
-
- reg.close = __winreg_close;
- reg.open_hive = __winreg_open_hive;
- reg.open_path = __winreg_open_path;
- reg.enum_path = __winreg_enum_path;
- reg.enum_values = __winreg_enum_values;
- reg.create_key = __winreg_create_key;
- reg.typestring = __winreg_typestring;
-
- return reg;
-}
diff --git a/source4/scripting/python/config.m4 b/source4/scripting/python/config.m4
index 1a86951bfb..b599aaefb0 100644
--- a/source4/scripting/python/config.m4
+++ b/source4/scripting/python/config.m4
@@ -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
diff --git a/source4/scripting/python/config.mk b/source4/scripting/python/config.mk
index 73607eb76c..b494ee6e8d 100644
--- a/source4/scripting/python/config.mk
+++ b/source4/scripting/python/config.mk
@@ -29,7 +29,9 @@ $(foreach pyfile, $(_PY_FILES),$(eval $(call python_py_module_template,$(patsubs
$(eval $(call python_py_module_template,samba/misc.py,$(pyscriptsrcdir)/misc.py))
+EPYDOC_OPTIONS = --no-private --url http://www.samba.org/ --no-sourcecode
+
epydoc:: pythonmods
- PYTHONPATH=$(pythonbuilddir) epydoc --no-private samba dcerpc tdb ldb subunit
+ PYTHONPATH=$(pythonbuilddir) epydoc $(EPYDOC_OPTIONS) samba tdb ldb subunit
install:: installpython
diff --git a/source4/scripting/python/examples/samr.py b/source4/scripting/python/examples/samr.py
new file mode 100755
index 0000000000..1f2afbe688
--- /dev/null
+++ b/source4/scripting/python/examples/samr.py
@@ -0,0 +1,114 @@
+#!/usr/bin/python
+# -*- coding: utf-8 -*-
+
+# Unix SMB/CIFS implementation.
+# Copyright © Jelmer Vernooij <jelmer@samba.org> 2008
+#
+# Based on samr.js © Andrew Tridgell <tridge@samba.org>
+#
+# 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/>.
+#
+
+import sys
+
+sys.path.insert(0, "bin/python")
+
+from samba.dcerpc import samr, security, lsa
+
+def FillUserInfo(samr, dom_handle, users, level):
+ """fill a user array with user information from samrQueryUserInfo"""
+ for i in range(len(users)):
+ user_handle = samr.OpenUser(handle, security.SEC_FLAG_MAXIMUM_ALLOWED, users[i].idx)
+ info = samr.QueryUserInfo(user_handle, level)
+ info.name = users[i].name
+ info.idx = users[i].idx
+ users[i] = info
+ samr.Close(user_handle)
+
+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
+
+
+def test_Connect(samr):
+ """test the samr_Connect interface"""
+ print "Testing samr_Connect"
+ return samr.Connect2(None, security.SEC_FLAG_MAXIMUM_ALLOWED)
+
+def test_LookupDomain(samr, handle, domain):
+ """test the samr_LookupDomain interface"""
+ print "Testing samr_LookupDomain"
+ return samr.LookupDomain(handle, domain)
+
+def test_OpenDomain(samr, handle, sid):
+ """test the samr_OpenDomain interface"""
+ print "Testing samr_OpenDomain"
+ return samr.OpenDomain(handle, security.SEC_FLAG_MAXIMUM_ALLOWED, sid)
+
+def test_EnumDomainUsers(samr, dom_handle):
+ """test the samr_EnumDomainUsers interface"""
+ print "Testing samr_EnumDomainUsers"
+ users = toArray(samr.EnumDomainUsers(dom_handle, 0, 0, -1))
+ print "Found %d users" % len(users)
+ for idx, user in users:
+ print "\t%s\t(%d)" % (user, idx)
+
+def test_EnumDomainGroups(samr, dom_handle):
+ """test the samr_EnumDomainGroups interface"""
+ print "Testing samr_EnumDomainGroups"
+ groups = toArray(samr.EnumDomainGroups(dom_handle, 0, 0))
+ print "Found %d groups" % len(groups)
+ for idx, group in groups:
+ print "\t%s\t(%d)" % (group, idx)
+
+def test_domain_ops(samr, dom_handle):
+ """test domain specific ops"""
+ test_EnumDomainUsers(samr, dom_handle)
+ test_EnumDomainGroups(samr, dom_handle)
+
+def test_EnumDomains(samr, handle):
+ """test the samr_EnumDomains interface"""
+ print "Testing samr_EnumDomains"
+
+ domains = toArray(samr.EnumDomains(handle, 0, -1))
+ print "Found %d domains" % len(domains)
+ for idx, domain in domains:
+ print "\t%s (%d)" % (domain, idx)
+ for idx, domain in domains:
+ print "Testing domain %s" % domain
+ sid = samr.LookupDomain(handle, domain)
+ dom_handle = test_OpenDomain(samr, handle, sid)
+ test_domain_ops(samr, dom_handle)
+ samr.Close(dom_handle)
+
+if len(sys.argv) != 2:
+ print "Usage: samr.js <BINDING>"
+ sys.exit(1)
+
+binding = sys.argv[1]
+
+print "Connecting to %s" % binding
+try:
+ samr = samr.samr(binding)
+except Exception, e:
+ print "Failed to connect to %s: %s" % (binding, e.message)
+ sys.exit(1)
+
+handle = test_Connect(samr)
+test_EnumDomains(samr, handle)
+samr.Close(handle)
+
+print "All OK"
diff --git a/source4/scripting/bin/winreg.py b/source4/scripting/python/examples/winreg.py
index 19d39e56ab..80b48ecfd7 100755
--- a/source4/scripting/bin/winreg.py
+++ b/source4/scripting/python/examples/winreg.py
@@ -11,7 +11,7 @@ import sys
# Find right directory when running from source tree
sys.path.insert(0, "bin/python")
-import winreg
+from samba.dcerpc import winreg
import optparse
import samba.getopt as options
diff --git a/source4/scripting/python/misc.i b/source4/scripting/python/misc.i
index 6fa3bc93e3..1d331215b5 100644
--- a/source4/scripting/python/misc.i
+++ b/source4/scripting/python/misc.i
@@ -16,7 +16,7 @@
along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
-%module(package="samba.misc") misc
+%module(docstring="Python bindings for miscellaneous Samba functions.",package="samba.misc") misc
%{
#include "includes.h"
@@ -35,11 +35,23 @@
%import "../../auth/credentials/credentials.i"
%import "../../param/param.i"
%import "../../libcli/security/security.i"
-%import "../../libcli/util/errors.i"
+%include "../../libcli/util/errors.i"
+
+%feature("docstring") generate_random_str "S.random_password(len) -> string\n" \
+ "Generate random password with specified length.";
%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 +70,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 %{
@@ -79,7 +97,6 @@ bool dsdb_set_ntds_invocation_id(struct ldb_context *ldb, const char *guid)
}
%}
-char *private_path(TALLOC_CTX* mem_ctx,
- struct loadparm_context *lp_ctx,
- const char *name);
+char *private_path(TALLOC_CTX* mem_ctx, struct loadparm_context *lp_ctx,
+ const char *name);
diff --git a/source4/scripting/python/misc.py b/source4/scripting/python/misc.py
index f1da4c687a..0c14944001 100644
--- a/source4/scripting/python/misc.py
+++ b/source4/scripting/python/misc.py
@@ -1,8 +1,12 @@
# 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.
+"""
+Python bindings for miscellaneous Samba functions.
+"""
+
import _misc
import new
new_instancemethod = new.instancemethod
@@ -61,15 +65,57 @@ import ldb
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 random_password(*args, **kwargs):
+ """
+ S.random_password(len) -> string
+ Generate random password with specified length.
+ """
+ return _misc.random_password(*args, **kwargs)
+
+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
diff --git a/source4/scripting/python/misc_wrap.c b/source4/scripting/python/misc_wrap.c
index 4944515d15..888918ef53 100644
--- a/source4/scripting/python/misc_wrap.c
+++ b/source4/scripting/python/misc_wrap.c
@@ -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
@@ -2536,6 +2554,9 @@ static swig_module_info swig_module = {swig_types, 27, 0, 0, 0, 0};
#include "librpc/ndr/libndr.h"
+#include "libcli/util/pyerrors.h"
+
+
SWIGINTERN int
SWIG_AsVal_double (PyObject *obj, double *val)
{
@@ -3028,8 +3049,7 @@ SWIGINTERN PyObject *_wrap_dsdb_attach_schema_from_ldif_file(PyObject *SWIGUNUSE
"ldb context must be non-NULL");
result = dsdb_attach_schema_from_ldif_file(arg1,(char const *)arg2,(char const *)arg3);
if (!W_ERROR_IS_OK(result)) {
- PyObject *obj = Py_BuildValue((char *)"(i,s)", W_ERROR_V(result), win_errstr(result));
- PyErr_SetObject(PyExc_RuntimeError, obj);
+ PyErr_SetWERROR(result);
SWIG_fail;
} else if (resultobj == NULL) {
resultobj = Py_None;
@@ -3198,15 +3218,36 @@ fail:
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 *)"random_password", (PyCFunction) _wrap_random_password, METH_VARARGS | METH_KEYWORDS, (char *)"\n"
+ "S.random_password(len) -> string\n"
+ "Generate random password with specified length.\n"
+ ""},
+ { (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 }
@@ -3225,7 +3266,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};
@@ -3397,7 +3438,7 @@ SWIGRUNTIME void
SWIG_InitializeModule(void *clientdata) {
size_t i;
swig_module_info *module_head, *iter;
- int found;
+ int found, init;
clientdata = clientdata;
@@ -3407,6 +3448,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 */
@@ -3435,6 +3479,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);
diff --git a/source4/scripting/python/pytalloc.c b/source4/scripting/python/pytalloc.c
index aa0ae9bf90..ca476e9604 100644
--- a/source4/scripting/python/pytalloc.c
+++ b/source4/scripting/python/pytalloc.c
@@ -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;
}
@@ -41,5 +48,5 @@ 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("<%s>", type->tp_name);
+ return PyString_FromFormat("<%s talloc object at 0x%x>", type->tp_name, (intptr_t)py_obj);
}
diff --git a/source4/scripting/python/samba/__init__.py b/source4/scripting/python/samba/__init__.py
index 29afdb931d..e191227108 100644
--- a/source4/scripting/python/samba/__init__.py
+++ b/source4/scripting/python/samba/__init__.py
@@ -20,6 +20,10 @@
# along with this program. If not, see <http://www.gnu.org/licenses/>.
#
+"""Samba 4."""
+
+__docformat__ = "restructuredText"
+
import os
def _in_source_tree():
@@ -71,15 +75,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
diff --git a/source4/scripting/python/samba/getopt.py b/source4/scripting/python/samba/getopt.py
index 7ec684a9d6..9ecb66e21c 100644
--- a/source4/scripting/python/samba/getopt.py
+++ b/source4/scripting/python/samba/getopt.py
@@ -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,12 +34,14 @@ 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):
+ """Return a loadparm object with data specified on the command line. """
import os, param
lp = param.LoadParm()
if self._configfile is not None:
@@ -45,12 +52,15 @@ class SambaOptions(optparse.OptionGroup):
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")
@@ -91,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()
diff --git a/source4/scripting/python/samba/idmap.py b/source4/scripting/python/samba/idmap.py
index 16efcd0470..755ec52c7b 100644
--- a/source4/scripting/python/samba/idmap.py
+++ b/source4/scripting/python/samba/idmap.py
@@ -20,6 +20,8 @@
"""Convenience functions for using the idmap database."""
+__docformat__ = "restructuredText"
+
import samba
import misc
import ldb
diff --git a/source4/scripting/python/samba/ndr.py b/source4/scripting/python/samba/ndr.py
new file mode 100644
index 0000000000..e718ff3422
--- /dev/null
+++ b/source4/scripting/python/samba/ndr.py
@@ -0,0 +1,28 @@
+#!/usr/bin/python
+# -*- coding: utf-8 -*-
+
+# Unix SMB/CIFS implementation.
+# 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
+# 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/>.
+#
+
+def ndr_pack(object):
+ return object.__ndr_pack__()
+
+
+def ndr_unpack(cls, data):
+ object = cls()
+ object.__ndr_unpack__(data)
+ return object
diff --git a/source4/scripting/python/samba/provision.py b/source4/scripting/python/samba/provision.py
index 69c7e8846d..3914fa8376 100644
--- a/source4/scripting/python/samba/provision.py
+++ b/source4/scripting/python/samba/provision.py
@@ -22,6 +22,8 @@
# along with this program. If not, see <http://www.gnu.org/licenses/>.
#
+"""Functions for setting up a Samba configuration."""
+
from base64 import b64encode
import os
import pwd
@@ -41,11 +43,12 @@ import urllib
from ldb import SCOPE_SUBTREE, SCOPE_ONELEVEL, SCOPE_BASE, LdbError, \
LDB_ERR_NO_SUCH_OBJECT, timestring, CHANGETYPE_MODIFY, CHANGETYPE_NONE
-"""Functions for setting up a Samba configuration."""
+__docformat__ = "restructuredText"
DEFAULTSITE = "Default-First-Site-Name"
class InvalidNetbiosName(Exception):
+ """A specified name was not a valid NetBIOS name."""
def __init__(self, name):
super(InvalidNetbiosName, self).__init__("The name '%r' is not a valid NetBIOS name" % name)
@@ -104,7 +107,7 @@ def check_install(lp, session_info, credentials):
:param credentials: Credentials
"""
if lp.get("realm") == "":
- raise Error("Realm empty")
+ raise Exception("Realm empty")
ldb = Ldb(lp.get("sam database"), session_info=session_info,
credentials=credentials, lp=lp)
if len(ldb.search("(cn=Administrator)")) != 1:
@@ -126,6 +129,10 @@ def findnss(nssfn, names):
raise KeyError("Unable to find user/group %r" % names)
+findnss_uid = lambda names: findnss(pwd.getpwnam, names)[2]
+findnss_gid = lambda names: findnss(grp.getgrnam, names)[2]
+
+
def open_ldb(session_info, credentials, lp, dbname):
"""Open a LDB, thrashing it if it is corrupt.
@@ -299,13 +306,13 @@ def guess_names(lp=None, hostname=None, domain=None, dnsdomain=None, serverrole=
dnsdomain = dnsdomain.lower()
- if (serverrole == "domain controller"):
+ if serverrole == "domain controller":
if domain is None:
domain = lp.get("workgroup")
if domaindn is None:
domaindn = "DC=" + dnsdomain.replace(".", ",DC=")
if lp.get("workgroup").upper() != domain.upper():
- raise Error("workgroup '%s' in smb.conf must match chosen domain '%s'",
+ raise Exception("workgroup '%s' in smb.conf must match chosen domain '%s'",
lp.get("workgroup"), domain)
else:
domain = netbiosname
@@ -345,67 +352,53 @@ def guess_names(lp=None, hostname=None, domain=None, dnsdomain=None, serverrole=
return names
-def load_or_make_smbconf(smbconf, setup_path, hostname, domain, realm, serverrole, targetdir):
- if targetdir is not None:
- if not os.path.exists(targetdir):
- os.mkdir(targetdir)
- if not os.path.exists(os.path.join(targetdir, "etc")):
- os.mkdir(os.path.join(targetdir, "etc"))
+def make_smbconf(smbconf, setup_path, hostname, domain, realm, serverrole,
+ targetdir):
+ if hostname is None:
+ hostname = socket.gethostname().split(".")[0].lower()
- smbconf = os.path.join(targetdir, "etc", "smb.conf")
+ if serverrole is None:
+ serverrole = "standalone"
- # only install a new smb.conf if there isn't one there already
+ assert serverrole in ("domain controller", "member server", "standalone")
+ if serverrole == "domain controller":
+ smbconfsuffix = "dc"
+ elif serverrole == "member server":
+ smbconfsuffix = "member"
+ elif serverrole == "standalone":
+ smbconfsuffix = "standalone"
- if not os.path.exists(smbconf):
- if hostname is None:
- hostname = socket.gethostname().split(".")[0].lower()
+ assert domain is not None
+ assert realm is not None
- if serverrole is None:
- serverrole = "standalone"
+ default_lp = param.LoadParm()
+ #Load non-existant file
+ default_lp.load(smbconf)
+
+ if targetdir is not None:
+ privatedir_line = "private dir = " + os.path.abspath(os.path.join(targetdir, "private"))
+ lockdir_line = "lock dir = " + os.path.abspath(targetdir)
- assert serverrole in ("domain controller", "member server", "standalone")
- if serverrole == "domain controller":
- smbconfsuffix = "dc"
- elif serverrole == "member server":
- smbconfsuffix = "member"
- elif serverrole == "standalone":
- smbconfsuffix = "standalone"
-
- assert domain is not None
- assert realm is not None
-
- default_lp = param.LoadParm()
- #Load non-existant file
- default_lp.load(smbconf)
-
- if targetdir is not None:
- privatedir_line = "private dir = " + os.path.abspath(os.path.join(targetdir, "private"))
- lockdir_line = "lock dir = " + os.path.abspath(targetdir)
+ default_lp.set("lock dir", os.path.abspath(targetdir))
+ else:
+ privatedir_line = ""
+ lockdir_line = ""
- default_lp.set("lock dir", os.path.abspath(targetdir))
- else:
- privatedir_line = ""
- lockdir_line = ""
-
- sysvol = os.path.join(default_lp.get("lock dir"), "sysvol")
- netlogon = os.path.join(sysvol, realm.lower(), "scripts")
-
- setup_file(setup_path("provision.smb.conf.%s" % smbconfsuffix),
- smbconf, {
- "HOSTNAME": hostname,
- "DOMAIN": domain,
- "REALM": realm,
- "SERVERROLE": serverrole,
- "NETLOGONPATH": netlogon,
- "SYSVOLPATH": sysvol,
- "PRIVATEDIR_LINE": privatedir_line,
- "LOCKDIR_LINE": lockdir_line
- })
+ sysvol = os.path.join(default_lp.get("lock dir"), "sysvol")
+ netlogon = os.path.join(sysvol, realm.lower(), "scripts")
- lp = param.LoadParm()
- lp.load(smbconf)
+ setup_file(setup_path("provision.smb.conf.%s" % smbconfsuffix),
+ smbconf, {
+ "HOSTNAME": hostname,
+ "DOMAIN": domain,
+ "REALM": realm,
+ "SERVERROLE": serverrole,
+ "NETLOGONPATH": netlogon,
+ "SYSVOLPATH": sysvol,
+ "PRIVATEDIR_LINE": privatedir_line,
+ "LOCKDIR_LINE": lockdir_line
+ })
- return lp
def setup_name_mappings(samdb, idmap, sid, domaindn, root_uid, nobody_uid,
@@ -500,8 +493,8 @@ def setup_samdb_partitions(samdb_path, setup_path, message, lp, session_info,
schemadn_ldb = "schema.ldb"
if ldap_backend is not None:
schema_ldb = ldap_backend
- schemadn_ldb = ldap_backend
-
+ schemadn_ldb = ldap_backend
+
if ldap_backend_type == "fedora-ds":
backend_modules = ["nsuniqueid", "paged_searches"]
# We can handle linked attributes here, as we don't have directory-side subtree operations
@@ -748,7 +741,8 @@ def setup_samdb(path, setup_path, session_info, credentials, lp,
if serverrole == "domain controller":
samdb.set_invocation_id(invocationid)
- load_schema(setup_path, samdb, names.schemadn, names.netbiosname, names.configdn, names.sitename)
+ load_schema(setup_path, samdb, names.schemadn, names.netbiosname,
+ names.configdn, names.sitename)
samdb.transaction_start()
@@ -922,26 +916,27 @@ def provision(setup_dir, message, session_info,
machinepass = misc.random_password(12)
if dnspass is None:
dnspass = misc.random_password(12)
- if root is None:
- root_uid = findnss(pwd.getpwnam, ["root"])[2]
- else:
- root_uid = findnss(pwd.getpwnam, [root])[2]
- if nobody is None:
- nobody_uid = findnss(pwd.getpwnam, ["nobody"])[2]
- else:
- nobody_uid = findnss(pwd.getpwnam, [nobody])[2]
- if users is None:
- users_gid = findnss(grp.getgrnam, ["users"])[2]
- else:
- users_gid = findnss(grp.getgrnam, [users])[2]
+ root_uid = findnss_uid([root or "root"])
+ nobody_uid = findnss_uid([nobody or "nobody"])
+ users_gid = findnss_gid([users or "users"])
if wheel is None:
- wheel_gid = findnss(grp.getgrnam, ["wheel", "adm"])[2]
+ wheel_gid = findnss_gid(["wheel", "adm"])
else:
- wheel_gid = findnss(grp.getgrnam, [wheel])[2]
+ wheel_gid = findnss_gid([wheel])
if aci is None:
aci = "# no aci for local ldb"
- lp = load_or_make_smbconf(smbconf, setup_path, hostname, domain, realm, serverrole, targetdir)
+ if smbconf is None:
+ os.makedirs(os.path.join(targetdir, "etc"))
+ smbconf = os.path.join(targetdir, "etc", "smb.conf")
+
+ # only install a new smb.conf if there isn't one there already
+ if not os.path.exists(smbconf):
+ make_smbconf(smbconf, setup_path, hostname, domain, realm, serverrole,
+ targetdir)
+
+ lp = param.LoadParm()
+ lp.load(smbconf)
names = guess_names(lp=lp, hostname=hostname, domain=domain,
dnsdomain=realm, serverrole=serverrole, sitename=sitename,
@@ -956,7 +951,8 @@ def provision(setup_dir, message, session_info,
if hostip6 is None:
try:
hostip6 = socket.getaddrinfo(names.hostname, None, socket.AF_INET6, socket.AI_CANONNAME, socket.IPPROTO_IP)[0][-1][0]
- except socket.gaierror: pass
+ except socket.gaierror:
+ pass
if serverrole is None:
serverrole = lp.get("server role")
@@ -1110,13 +1106,13 @@ def provision_become_dc(setup_dir=None,
ldap_backend=None, ldap_backend_type=None, sitename=None):
def message(text):
- """print a message if quiet is not set."""
+ """print a message if quiet is not set."""
print text
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, serverdn=serverdn,
- domain=domain, hostname=hostname, hostip="127.0.0.1", domainsid=domainsid, machinepass=machinepass, serverrole="domain controller", sitename=sitename);
+ domain=domain, hostname=hostname, hostip="127.0.0.1", domainsid=domainsid, machinepass=machinepass, serverrole="domain controller", sitename=sitename)
def setup_db_config(setup_path, dbdir):
@@ -1125,9 +1121,9 @@ def setup_db_config(setup_path, dbdir):
: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);
+ os.makedirs(os.path.join(dbdir, "bdb-logs"), 0700)
if not os.path.isdir(os.path.join(dbdir, "tmp")):
- os.makedirs(os.path.join(dbdir, "tmp"), 0700);
+ os.makedirs(os.path.join(dbdir, "tmp"), 0700)
setup_file(setup_path("DB_CONFIG"), os.path.join(dbdir, "DB_CONFIG"),
{"LDAPDBDIR": dbdir})
@@ -1149,11 +1145,23 @@ def provision_backend(setup_dir=None, message=None,
if root is None:
root = findnss(pwd.getpwnam, ["root"])[0]
- lp = load_or_make_smbconf(smbconf, setup_path, hostname, domain, realm, serverrole, targetdir)
+ if smbconf is None:
+ etcdir = os.path.join(targetdir, "etc")
+ os.makedirs(etcdir)
+ smbconf = os.path.join(etcdir, "smb.conf")
+
+ # only install a new smb.conf if there isn't one there already
+ if not os.path.exists(smbconf):
+ make_smbconf(smbconf, setup_path, hostname, domain, realm,
+ serverrole, targetdir)
+
+ lp = param.LoadParm()
+ lp.load(smbconf)
names = guess_names(lp=lp, hostname=hostname, domain=domain,
dnsdomain=realm, serverrole=serverrole,
- rootdn=rootdn, domaindn=domaindn, configdn=configdn, schemadn=schemadn)
+ rootdn=rootdn, domaindn=domaindn, configdn=configdn,
+ schemadn=schemadn)
paths = provision_paths_from_lp(lp, names.dnsdomain)
@@ -1214,21 +1222,19 @@ def provision_backend(setup_dir=None, message=None,
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);
-
- memberof_config = "# Generated from schema in " + schemadb_path + "\n";
- refint_attributes = "";
- for i in range (0, len(res)):
- linkid = res[i]["linkID"][0]
- linkid = str(int(linkid) + 1)
- expression = "(&(objectclass=attributeSchema)(linkID=" + (linkid) + "))"
+ res = schemadb.search(expression="(&(&(linkID=*)(!(linkID:1.2.840.113556.1.4.803:=1)))(objectclass=attributeSchema))", base=names.schemadn, scope=SCOPE_SUBTREE, attrs=attrs)
+
+ memberof_config = "# Generated from schema in %s\n" % schemadb_path
+ refint_attributes = ""
+ for i in range (0, len(res)):
+ expression = "(&(objectclass=attributeSchema)(linkID=%d))" % (int(res[i]["linkID"][0])+1)
target = schemadb.searchone(basedn=names.schemadn,
expression=expression,
attribute="lDAPDisplayName",
- scope=SCOPE_SUBTREE);
+ scope=SCOPE_SUBTREE)
if target is not None:
- refint_attributes = refint_attributes + " " + target + " " + res[i]["lDAPDisplayName"][0];
- memberof_config = memberof_config + """overlay memberof
+ refint_attributes = refint_attributes + " " + target + " " + res[i]["lDAPDisplayName"][0]
+ memberof_config += """overlay memberof
memberof-dangling error
memberof-refint TRUE
memberof-group-oc top
@@ -1236,13 +1242,13 @@ memberof-member-ad """ + res[i]["lDAPDisplayName"][0] + """
memberof-memberof-ad """ + target + """
memberof-dangling-error 32
-""";
+"""
- memberof_config = memberof_config + """
+ memberof_config += """
overlay refint
-refint_attributes""" + refint_attributes + "\n";
-
- setup_file(setup_path("slapd.conf"), paths.slapdconf,
+refint_attributes""" + refint_attributes + "\n"
+
+ setup_file(setup_path("slapd.conf"), paths.slapdconf,
{"DNSDOMAIN": names.dnsdomain,
"LDAPDIR": paths.ldapdir,
"DOMAINDN": names.domaindn,
@@ -1251,28 +1257,28 @@ refint_attributes""" + refint_attributes + "\n";
"LDAPMANAGERDN": names.ldapmanagerdn,
"LDAPMANAGERPASS": adminpass,
"MEMBEROF_CONFIG": memberof_config})
- setup_file(setup_path("modules.conf"), paths.modulesconf,
+ setup_file(setup_path("modules.conf"), paths.modulesconf,
{"REALM": names.realm})
- 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="")
- 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
+ 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="")
+ 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);
+ 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("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)
@@ -1314,8 +1320,8 @@ def create_zone_file(path, setup_path, dnsdomain, domaindn,
hostip6_host_line = ""
if hostip6 is not None:
- hostip6_base_line = " IN AAAA " + hostip6
- hostip6_host_line = hostname + " IN AAAA " + hostip6
+ hostip6_base_line = " IN AAAA " + hostip6
+ hostip6_host_line = hostname + " IN AAAA " + hostip6
setup_file(setup_path("provision.zone"), path, {
"DNSPASS_B64": b64encode(dnspass),
@@ -1331,6 +1337,7 @@ def create_zone_file(path, setup_path, 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
@@ -1369,6 +1376,7 @@ def create_krb5_conf(path, setup_path, dnsdomain, hostname, realm):
"REALM": realm,
})
+
def load_schema(setup_path, samdb, schemadn, netbiosname, configdn, sitename):
"""Load schema for the SamDB.
diff --git a/source4/scripting/python/samba/samba3.py b/source4/scripting/python/samba/samba3.py
index cffedb54af..c1340b7760 100644
--- a/source4/scripting/python/samba/samba3.py
+++ b/source4/scripting/python/samba/samba3.py
@@ -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
diff --git a/source4/scripting/python/samba/samdb.py b/source4/scripting/python/samba/samdb.py
index 198d1e9f5c..6465f49519 100644
--- a/source4/scripting/python/samba/samdb.py
+++ b/source4/scripting/python/samba/samdb.py
@@ -28,6 +28,8 @@ import ldb
from samba.idmap import IDmapDB
import pwd
+__docformat__ = "restructuredText"
+
class SamDB(samba.Ldb):
"""The SAM database."""
diff --git a/source4/scripting/python/samba/tests/dcerpc/bare.py b/source4/scripting/python/samba/tests/dcerpc/bare.py
new file mode 100644
index 0000000000..d75ffc381e
--- /dev/null
+++ b/source4/scripting/python/samba/tests/dcerpc/bare.py
@@ -0,0 +1,46 @@
+#!/usr/bin/python
+# -*- coding: utf-8 -*-
+
+# Unix SMB/CIFS implementation.
+# 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
+# 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 ClientConnection
+from unittest import TestCase
+
+class BareTestCase(TestCase):
+ def test_bare(self):
+ # Connect to the echo pipe
+ x = ClientConnection("ncalrpc:localhost[DEFAULT]",
+ ("60a15ec5-4de8-11d7-a637-005056a20182", 1))
+ self.assertEquals("\x01\x00\x00\x00", x.request(0, chr(0) * 4))
+
+ def test_alter_context(self):
+ x = ClientConnection("ncalrpc:localhost[DEFAULT]",
+ ("12345778-1234-abcd-ef00-0123456789ac", 1))
+ y = ClientConnection("ncalrpc:localhost",
+ ("60a15ec5-4de8-11d7-a637-005056a20182", 1),
+ basis_connection=x)
+ x.alter_context(("60a15ec5-4de8-11d7-a637-005056a20182", 1))
+ # FIXME: self.assertEquals("\x01\x00\x00\x00", x.request(0, chr(0) * 4))
+
+ def test_two_connections(self):
+ x = ClientConnection("ncalrpc:localhost[DEFAULT]",
+ ("60a15ec5-4de8-11d7-a637-005056a20182", 1))
+ y = ClientConnection("ncalrpc:localhost",
+ ("60a15ec5-4de8-11d7-a637-005056a20182", 1),
+ basis_connection=x)
+ self.assertEquals("\x01\x00\x00\x00", y.request(0, chr(0) * 4))
diff --git a/source4/scripting/python/samba/tests/dcerpc/rpcecho.py b/source4/scripting/python/samba/tests/dcerpc/rpcecho.py
index 3b37f8a9bc..bbbd0d76ec 100644
--- a/source4/scripting/python/samba/tests/dcerpc/rpcecho.py
+++ b/source4/scripting/python/samba/tests/dcerpc/rpcecho.py
@@ -18,6 +18,7 @@
#
from samba.dcerpc import echo
+from samba.ndr import ndr_pack, ndr_unpack
import unittest
from samba.tests import RpcInterfaceTestCase
@@ -25,6 +26,14 @@ class RpcEchoTests(RpcInterfaceTestCase):
def setUp(self):
self.conn = echo.rpcecho("ncalrpc:", self.get_loadparm())
+ def test_two_contexts(self):
+ self.conn2 = echo.rpcecho("ncalrpc:", basis_connection=self.conn)
+ self.assertEquals(3, self.conn2.AddOne(2))
+
+ def test_abstract_syntax(self):
+ self.assertEquals(("60a15ec5-4de8-11d7-a637-005056a20182", 1),
+ self.conn.abstract_syntax)
+
def test_addone(self):
self.assertEquals(2, self.conn.AddOne(1))
@@ -40,3 +49,19 @@ class RpcEchoTests(RpcInterfaceTestCase):
surrounding_struct.surrounding = [1,2,3,4]
y = self.conn.TestSurrounding(surrounding_struct)
self.assertEquals(8 * [0], y.surrounding)
+
+ def test_manual_request(self):
+ self.assertEquals("\x01\x00\x00\x00", self.conn.request(0, chr(0) * 4))
+
+ def test_server_name(self):
+ self.assertEquals(None, self.conn.server_name)
+
+class NdrEchoTests(unittest.TestCase):
+ def test_info1_push(self):
+ x = echo.info1()
+ x.v = 42
+ self.assertEquals("\x2a", ndr_pack(x))
+
+ def test_info1_pull(self):
+ x = ndr_unpack(echo.info1, "\x42")
+ self.assertEquals(x.v, 66)
diff --git a/source4/scripting/python/samba/tests/dcerpc/sam.py b/source4/scripting/python/samba/tests/dcerpc/sam.py
index a6816153c0..50e00a3f9e 100644
--- a/source4/scripting/python/samba/tests/dcerpc/sam.py
+++ b/source4/scripting/python/samba/tests/dcerpc/sam.py
@@ -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,12 +18,29 @@
# along with this program. If not, see <http://www.gnu.org/licenses/>.
#
-from samba.dcerpc import samr
+from samba.dcerpc import samr, security
from samba.tests import RpcInterfaceTestCase
+# 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:", 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)
+
diff --git a/source4/scripting/python/samba/upgrade.py b/source4/scripting/python/samba/upgrade.py
index f40f2cffe7..0c83604e82 100644
--- a/source4/scripting/python/samba/upgrade.py
+++ b/source4/scripting/python/samba/upgrade.py
@@ -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
diff --git a/source4/selftest/output/plain.pm b/source4/selftest/output/plain.pm
index f14e26b38d..4bec4e0fdc 100644
--- a/source4/selftest/output/plain.pm
+++ b/source4/selftest/output/plain.pm
@@ -123,7 +123,9 @@ sub end_test($$$$$)
return;
}
- $append = "UNEXPECTED($result): $testname\n";
+ my $fullname = join(".", @$parents).".$testname";
+
+ $append = "UNEXPECTED($result): $testname ($fullname)\n";
$self->{test_output}->{$self->{NAME}} .= $append;
diff --git a/source4/selftest/samba4_tests.sh b/source4/selftest/samba4_tests.sh
index 2f65561ceb..1771a0da5c 100755
--- a/source4/selftest/samba4_tests.sh
+++ b/source4/selftest/samba4_tests.sh
@@ -64,9 +64,6 @@ SCRIPTDIR=$samba4srcdir/../testprogs/ejs
smb4torture="$samba4bindir/smbtorture $TORTURE_OPTIONS"
plantest "js.base" dc "$SCRIPTDIR/base.js" $CONFIGURATION
-plantest "js.samr" dc "$SCRIPTDIR/samr.js" $CONFIGURATION ncalrpc: -U\$USERNAME%\$PASSWORD
-plantest "js.echo" dc "$SCRIPTDIR/echo.js" $CONFIGURATION ncalrpc: -U\$USERNAME%\$PASSWORD
-#plantest "ejsnet.js" dc "$SCRIPTDIR/ejsnet.js" $CONFIGURATION -U\$USERNAME%\$PASSWORD \$DOMAIN ejstestuser
plantest "js.ldb" none "$SCRIPTDIR/ldb.js" `pwd` $CONFIGURATION -d 10
plantest "js.winreg" dc $samba4srcdir/scripting/bin/winreg $CONFIGURATION ncalrpc: 'HKLM' -U\$USERNAME%\$PASSWORD
@@ -342,9 +339,11 @@ plantest "samba.python" none $SUBUNITRUN samba.tests
plantest "provision.python" none $SUBUNITRUN samba.tests.provision
plantest "samba3.python" none $SUBUNITRUN samba.tests.samba3
plantest "samr.python" dc $SUBUNITRUN samba.tests.dcerpc.sam
+plantest "dcerpc.bare.python" dc $SUBUNITRUN samba.tests.dcerpc.bare
plantest "samdb.python" dc $SUBUNITRUN samba.tests.samdb
plantest "unixinfo.python" dc $SUBUNITRUN samba.tests.dcerpc.unix
plantest "events.python" none PYTHONPATH="$PYTHONPATH:lib/events" $SUBUNITRUN tests
+plantest "messaging.python" none PYTHONPATH="$PYTHONPATH:lib/messaging/tests" $SUBUNITRUN bindings
plantest "samba3sam.python" none PYTHONPATH="$PYTHONPATH:dsdb/samdb/ldb_modules/tests" $SUBUNITRUN samba3sam
plantest "rpcecho.python" dc $SUBUNITRUN samba.tests.dcerpc.rpcecho
plantest "winreg.python" dc $SUBUNITRUN -U\$USERNAME%\$PASSWORD samba.tests.dcerpc.registry
diff --git a/source4/selftest/selftest.pl b/source4/selftest/selftest.pl
index 385d31bbfd..5854a94b8d 100755
--- a/source4/selftest/selftest.pl
+++ b/source4/selftest/selftest.pl
@@ -407,13 +407,19 @@ my $tls_enabled = not $opt_quick;
$ENV{TLS_ENABLED} = ($tls_enabled?"yes":"no");
$ENV{LDB_MODULES_PATH} = "$old_pwd/bin/modules/ldb";
$ENV{LD_SAMBA_MODULE_PATH} = "$old_pwd/bin/modules";
-if (defined($ENV{PKG_CONFIG_PATH})) {
- $ENV{PKG_CONFIG_PATH} = "$old_pwd/bin/pkgconfig:$ENV{PKG_CONFIG_PATH}";
-} else {
- $ENV{PKG_CONFIG_PATH} = "$old_pwd/bin/pkgconfig";
+sub prefix_pathvar($$)
+{
+ my ($name, $newpath) = @_;
+ if (defined($ENV{$name})) {
+ $ENV{$name} = "$newpath:$ENV{$name}";
+ } else {
+ $ENV{$name} = $newpath;
+ }
}
+prefix_pathvar("PKG_CONFIG_PATH", "$old_pwd/bin/pkgconfig");
# Required for smbscript:
-$ENV{PATH} = "$old_pwd/bin:$old_pwd:$ENV{PATH}";
+prefix_pathvar("PATH", "$old_pwd/bin");
+prefix_pathvar("PYTHONPATH", "$old_pwd/bin/python");
if ($opt_socket_wrapper_keep_pcap) {
# Socket wrapper keep pcap implies socket wrapper pcap
diff --git a/source4/setup/provision-backend b/source4/setup/provision-backend
index 4f222c467a..54dc5839bf 100755
--- a/source4/setup/provision-backend
+++ b/source4/setup/provision-backend
@@ -22,14 +22,17 @@
# along with this program. If not, see <http://www.gnu.org/licenses/>.
#
+import os, sys
+
+sys.path.insert(0, "bin/python")
+
import getopt
import optparse
-import os, sys
import samba
-import param
+from samba import param
-from auth import system_session
+from samba.auth import system_session
import samba.getopt as options
from samba.provision import (provision_backend)
diff --git a/source4/smb_server/blob.c b/source4/smb_server/blob.c
index 8834c4483c..368b81d18e 100644
--- a/source4/smb_server/blob.c
+++ b/source4/smb_server/blob.c
@@ -476,12 +476,12 @@ NTSTATUS smbsrv_push_passthru_fileinfo(TALLOC_CTX *mem_ctx,
}
list_size = ea_list_size_chained(st->all_eas.out.num_eas,
- st->all_eas.out.eas);
+ st->all_eas.out.eas, 4);
BLOB_CHECK(smbsrv_blob_grow_data(mem_ctx, blob, list_size));
ea_put_list_chained(blob->data,
st->all_eas.out.num_eas,
- st->all_eas.out.eas);
+ st->all_eas.out.eas, 4);
return NT_STATUS_OK;
case RAW_FILEINFO_SMB2_ALL_INFORMATION:
@@ -503,7 +503,8 @@ NTSTATUS smbsrv_push_passthru_fileinfo(TALLOC_CTX *mem_ctx,
SIVAL(blob->data, 0x48, st->all_info2.out.ea_size);
SIVAL(blob->data, 0x4C, st->all_info2.out.access_mask);
SBVAL(blob->data, 0x50, st->all_info2.out.position);
- SBVAL(blob->data, 0x58, st->all_info2.out.mode);
+ SIVAL(blob->data, 0x58, st->all_info2.out.mode);
+ SIVAL(blob->data, 0x5C, st->all_info2.out.alignment_requirement);
BLOB_CHECK(smbsrv_blob_append_string(mem_ctx, blob,
st->all_info2.out.fname.s,
0x60, default_str_flags,
diff --git a/source4/smb_server/smb/reply.c b/source4/smb_server/smb/reply.c
index 40cad91062..d28f4b6072 100644
--- a/source4/smb_server/smb/reply.c
+++ b/source4/smb_server/smb/reply.c
@@ -2193,6 +2193,11 @@ void smbsrv_reply_ntcreate_and_X(struct smbsrv_request *req)
io->ntcreatex.in.ea_list = NULL;
io->ntcreatex.in.sec_desc = NULL;
+ /* we use a couple of bits of the create options internally */
+ if (io->ntcreatex.in.create_options & NTCREATEX_OPTIONS_PRIVATE_MASK) {
+ return NT_STATUS_INVALID_PARAMETER;
+ }
+
/* we need a neater way to handle this alignment */
if ((req->flags2 & FLAGS2_UNICODE_STRINGS) &&
ucs2_align(req->in.buffer, req->in.data, STR_TERMINATE|STR_UNICODE)) {
diff --git a/source4/smb_server/smb2/smb2_server.h b/source4/smb_server/smb2/smb2_server.h
index fc40a92efc..ae4abbd71e 100644
--- a/source4/smb_server/smb2/smb2_server.h
+++ b/source4/smb_server/smb2/smb2_server.h
@@ -78,13 +78,13 @@ struct smbsrv_request;
if (is_size < (size)) { \
DEBUG(0,("%s: buffer too small 0x%x. Expected 0x%x\n", \
__location__, (unsigned)is_size, (unsigned)want_size)); \
- smb2srv_send_error(req, NT_STATUS_FOOBAR); \
+ smb2srv_send_error(req, NT_STATUS_INVALID_PARAMETER); \
return; \
}\
if (field_size != want_size) { \
DEBUG(0,("%s: unexpected fixed body size 0x%x. Expected 0x%x\n", \
__location__, (unsigned)field_size, (unsigned)want_size)); \
- smb2srv_send_error(req, NT_STATUS_FOOBAR); \
+ smb2srv_send_error(req, NT_STATUS_INVALID_PARAMETER); \
return; \
} \
} while (0)
diff --git a/source4/smb_server/smb_server.c b/source4/smb_server/smb_server.c
index 367557dbb7..6eccb836d6 100644
--- a/source4/smb_server/smb_server.c
+++ b/source4/smb_server/smb_server.c
@@ -150,12 +150,12 @@ static void smbsrv_accept(struct stream_connection *conn)
smb_conn->connection = conn;
conn->private = smb_conn;
- irpc_add_name(conn->msg_ctx, "smb_server");
-
smb_conn->statistics.connect_time = timeval_current();
smbsrv_management_init(smb_conn);
+ irpc_add_name(conn->msg_ctx, "smb_server");
+
if (!NT_STATUS_IS_OK(share_get_context_by_name(smb_conn, lp_share_backend(smb_conn->lp_ctx),
smb_conn->connection->event.ctx,
smb_conn->lp_ctx, &(smb_conn->share_context)))) {
diff --git a/source4/static_deps.mk b/source4/static_deps.mk
index 7eb8fa10fe..de59d76e28 100644
--- a/source4/static_deps.mk
+++ b/source4/static_deps.mk
@@ -14,29 +14,29 @@ include/includes.h: \
librpc/gen_ndr/misc.h
heimdal_basics: \
- heimdal/lib/hdb/hdb_asn1.h \
- heimdal/lib/gssapi/spnego_asn1.h \
- heimdal/lib/gssapi/gssapi_asn1.h \
- heimdal/lib/asn1/krb5_asn1.h \
- heimdal/lib/asn1/asn1_err.h \
- heimdal/lib/asn1/digest_asn1.h \
- heimdal/lib/asn1/pkcs8_asn1.h \
- heimdal/lib/asn1/pkcs9_asn1.h \
- heimdal/lib/asn1/pkcs12_asn1.h \
- heimdal/lib/asn1/cms_asn1.h \
- heimdal/lib/asn1/rfc2459_asn1.h \
- heimdal/lib/asn1/pkinit_asn1.h \
- heimdal/lib/asn1/kx509_asn1.h \
- heimdal/lib/hx509/ocsp_asn1.h \
- heimdal/lib/hx509/pkcs10_asn1.h \
- heimdal/lib/hdb/hdb_err.h \
- heimdal/lib/krb5/heim_err.h \
- heimdal/lib/krb5/k524_err.h \
- heimdal/lib/krb5/krb_err.h \
- heimdal/lib/krb5/krb5_err.h \
- heimdal/lib/gssapi/gkrb5_err.h \
- heimdal/lib/hx509/hx509_err.h \
- heimdal/lib/wind/wind_err.h
+ $(heimdalsrcdir)/lib/hdb/hdb_asn1.h \
+ $(heimdalsrcdir)/lib/gssapi/spnego_asn1.h \
+ $(heimdalsrcdir)/lib/gssapi/gssapi_asn1.h \
+ $(heimdalsrcdir)/lib/asn1/krb5_asn1.h \
+ $(heimdalsrcdir)/lib/asn1/asn1_err.h \
+ $(heimdalsrcdir)/lib/asn1/digest_asn1.h \
+ $(heimdalsrcdir)/lib/asn1/pkcs8_asn1.h \
+ $(heimdalsrcdir)/lib/asn1/pkcs9_asn1.h \
+ $(heimdalsrcdir)/lib/asn1/pkcs12_asn1.h \
+ $(heimdalsrcdir)/lib/asn1/cms_asn1.h \
+ $(heimdalsrcdir)/lib/asn1/rfc2459_asn1.h \
+ $(heimdalsrcdir)/lib/asn1/pkinit_asn1.h \
+ $(heimdalsrcdir)/lib/asn1/kx509_asn1.h \
+ $(heimdalsrcdir)/lib/hx509/ocsp_asn1.h \
+ $(heimdalsrcdir)/lib/hx509/pkcs10_asn1.h \
+ $(heimdalsrcdir)/lib/hdb/hdb_err.h \
+ $(heimdalsrcdir)/lib/krb5/heim_err.h \
+ $(heimdalsrcdir)/lib/krb5/k524_err.h \
+ $(heimdalsrcdir)/lib/krb5/krb_err.h \
+ $(heimdalsrcdir)/lib/krb5/krb5_err.h \
+ $(heimdalsrcdir)/lib/gssapi/gkrb5_err.h \
+ $(heimdalsrcdir)/lib/hx509/hx509_err.h \
+ $(heimdalsrcdir)/lib/wind/wind_err.h
proto::
basics:: include/includes.h idl proto heimdal_basics
diff --git a/source4/torture/gentest.c b/source4/torture/gentest.c
index ae18fe809c..cd33074b4f 100644
--- a/source4/torture/gentest.c
+++ b/source4/torture/gentest.c
@@ -30,7 +30,7 @@
#include "libcli/resolve/resolve.h"
#include "auth/gensec/gensec.h"
#include "param/param.h"
-#include "dynconfig.h"
+#include "dynconfig/dynconfig.h"
#define NSERVERS 2
#define NINSTANCES 2
diff --git a/source4/torture/gentest_smb2.c b/source4/torture/gentest_smb2.c
index fc6dbcbb9a..3e705dc60d 100644
--- a/source4/torture/gentest_smb2.c
+++ b/source4/torture/gentest_smb2.c
@@ -34,7 +34,7 @@
#include "libcli/resolve/resolve.h"
#include "auth/gensec/gensec.h"
#include "param/param.h"
-#include "dynconfig.h"
+#include "dynconfig/dynconfig.h"
#define NSERVERS 2
#define NINSTANCES 2
@@ -53,6 +53,9 @@ static struct gentest_options {
const char *seeds_file;
int use_preset_seeds;
int fast_reconnect;
+ int mask_indexing;
+ int no_eas;
+ int skip_cleanup;
} options;
/* mapping between open handles on the server and local handles */
@@ -110,7 +113,8 @@ static struct smb2_handle bad_smb2_handle;
#define BAD_HANDLE 0xFFFE
-static bool oplock_handler(struct smbcli_transport *transport, uint16_t tid, uint16_t fnum, uint8_t level, void *private);
+static bool oplock_handler(struct smb2_transport *transport, const struct smb2_handle *handle,
+ uint8_t level, void *private_data);
static void idle_func(struct smb2_transport *transport, void *private);
/*
@@ -206,7 +210,8 @@ static bool connect_servers(struct event_context *ev,
return false;
}
-// smb2_oplock_handler(servers[i].cli[j]->transport, oplock_handler, NULL);
+ servers[i].tree[j]->session->transport->oplock.handler = oplock_handler;
+ servers[i].tree[j]->session->transport->oplock.private_data = (void *)(uintptr_t)((i<<8)|j);
smb2_transport_idle_handler(servers[i].tree[j]->session->transport, idle_func, 50000, NULL);
}
}
@@ -510,24 +515,37 @@ static uint32_t gen_bits_mask2(uint32_t mask1, uint32_t mask2)
}
/*
- generate a boolean
-*/
-static bool gen_bool(void)
+ generate reserved values
+ */
+static uint64_t gen_reserved8(void)
{
- return gen_bits_mask2(0x1, 0xFF);
+ return gen_bits_mask(0xFF);
}
-/*
- generate ntrename flags
-*/
-static uint16_t gen_rename_flags(void)
+static uint64_t gen_reserved16(void)
{
- if (gen_chance(30)) return RENAME_FLAG_RENAME;
- if (gen_chance(30)) return RENAME_FLAG_HARD_LINK;
- if (gen_chance(30)) return RENAME_FLAG_COPY;
return gen_bits_mask(0xFFFF);
}
+static uint64_t gen_reserved32(void)
+{
+ return gen_bits_mask(0xFFFFFFFF);
+}
+
+static uint64_t gen_reserved64(void)
+{
+ return gen_bits_mask(0xFFFFFFFF) | (((uint64_t)gen_bits_mask(0xFFFFFFFF))<<32);
+}
+
+
+
+/*
+ generate a boolean
+*/
+static bool gen_bool(void)
+{
+ return gen_bits_mask2(0x1, 0xFF);
+}
/*
return a set of lock flags
@@ -543,15 +561,6 @@ static uint16_t gen_lock_flags(void)
}
/*
- generate a pid
-*/
-static uint16_t gen_pid(void)
-{
- if (gen_chance(10)) return gen_bits_mask(0xFFFF);
- return getpid();
-}
-
-/*
generate a lock count
*/
static off_t gen_lock_count(void)
@@ -560,15 +569,6 @@ static off_t gen_lock_count(void)
}
/*
- generate a ntcreatex flags field
-*/
-static uint32_t gen_ntcreatex_flags(void)
-{
- if (gen_chance(70)) return NTCREATEX_FLAGS_EXTENDED;
- return gen_bits_mask2(0x1F, 0xFFFFFFFF);
-}
-
-/*
generate a NT access mask
*/
static uint32_t gen_access_mask(void)
@@ -599,34 +599,6 @@ static uint32_t gen_open_disp(void)
}
/*
- generate an openx open mode
-*/
-static uint16_t gen_openx_mode(void)
-{
- if (gen_chance(20)) return gen_bits_mask(0xFFFF);
- if (gen_chance(20)) return gen_bits_mask(0xFF);
- return OPENX_MODE_DENY_NONE | gen_bits_mask(0x3);
-}
-
-/*
- generate an openx flags field
-*/
-static uint16_t gen_openx_flags(void)
-{
- if (gen_chance(20)) return gen_bits_mask(0xFFFF);
- return gen_bits_mask(0x7);
-}
-
-/*
- generate an openx open function
-*/
-static uint16_t gen_openx_func(void)
-{
- if (gen_chance(20)) return gen_bits_mask(0xFFFF);
- return gen_bits_mask(0x13);
-}
-
-/*
generate a file attrib combination
*/
static uint32_t gen_attrib(void)
@@ -655,15 +627,6 @@ static NTTIME gen_nttime(void)
}
/*
- generate a milliseconds protocol timeout
-*/
-static uint32_t gen_timeout(void)
-{
- if (gen_chance(98)) return 0;
- return random() % 50;
-}
-
-/*
generate a file allocation size
*/
static uint_t gen_alloc_size(void)
@@ -721,6 +684,126 @@ static struct ea_struct gen_ea_struct(void)
}
/*
+ generate an ea_struct
+*/
+static struct smb_ea_list gen_ea_list(void)
+{
+ struct smb_ea_list eas;
+ int i;
+ if (options.no_eas) {
+ ZERO_STRUCT(eas);
+ return eas;
+ }
+ eas.num_eas = gen_int_range(0, 3);
+ eas.eas = talloc_array(current_op.mem_ctx, struct ea_struct, eas.num_eas);
+ for (i=0;i<eas.num_eas;i++) {
+ eas.eas[i] = gen_ea_struct();
+ }
+ return eas;
+}
+
+static void oplock_handler_close_recv(struct smb2_request *req)
+{
+ NTSTATUS status;
+ struct smb2_close io;
+ status = smb2_close_recv(req, &io);
+ if (!NT_STATUS_IS_OK(status)) {
+ printf("close failed in oplock_handler\n");
+ smb_panic("close failed in oplock_handler");
+ }
+}
+
+static void oplock_handler_ack_callback(struct smb2_request *req)
+{
+ NTSTATUS status;
+ struct smb2_break br;
+
+ status = smb2_break_recv(req, &br);
+ if (!NT_STATUS_IS_OK(status)) {
+ printf("oplock break ack failed in oplock_handler\n");
+ smb_panic("oplock break ack failed in oplock_handler");
+ }
+}
+
+static bool send_oplock_ack(struct smb2_tree *tree, struct smb2_handle handle,
+ uint8_t level)
+{
+ struct smb2_break br;
+ struct smb2_request *req;
+
+ ZERO_STRUCT(br);
+ br.in.file.handle = handle;
+ br.in.oplock_level = level;
+ br.in.reserved = gen_reserved8();
+ br.in.reserved2 = gen_reserved32();
+
+ req = smb2_break_send(tree, &br);
+ if (req == NULL) return false;
+ req->async.fn = oplock_handler_ack_callback;
+ req->async.private_data = NULL;
+ return true;
+}
+
+/*
+ the oplock handler will either ack the break or close the file
+*/
+static bool oplock_handler(struct smb2_transport *transport, const struct smb2_handle *handle,
+ uint8_t level, void *private_data)
+{
+ struct smb2_close io;
+ unsigned i, j;
+ bool do_close;
+ struct smb2_tree *tree = NULL;
+ struct smb2_request *req;
+
+ srandom(current_op.seed);
+ do_close = gen_chance(50);
+
+ i = ((uintptr_t)private_data) >> 8;
+ j = ((uintptr_t)private_data) & 0xFF;
+
+ if (i >= NSERVERS || j >= NINSTANCES) {
+ printf("Bad private_data in oplock_handler\n");
+ return false;
+ }
+
+ oplocks[i][j].got_break = true;
+ oplocks[i][j].server_handle = *handle;
+ oplocks[i][j].handle = fnum_to_handle(i, j, *handle);
+ oplocks[i][j].level = level;
+ oplocks[i][j].do_close = do_close;
+ tree = talloc_get_type(servers[i].tree[j], struct smb2_tree);
+
+ if (!tree) {
+ printf("Oplock break not for one of our trees!?\n");
+ return false;
+ }
+
+ if (!do_close) {
+ printf("oplock ack handle=%d\n", oplocks[i][j].handle);
+ return send_oplock_ack(tree, *handle, level);
+ }
+
+ printf("oplock close fnum=%d\n", oplocks[i][j].handle);
+
+ ZERO_STRUCT(io);
+ io.in.file.handle = *handle;
+ io.in.flags = 0;
+ req = smb2_close_send(tree, &io);
+
+ if (req == NULL) {
+ printf("WARNING: close failed in oplock_handler_close\n");
+ return false;
+ }
+
+ req->async.fn = oplock_handler_close_recv;
+ req->async.private_data = NULL;
+
+ return true;
+}
+
+
+/*
the idle function tries to cope with getting an oplock break on a connection, and
an operation on another connection blocking until that break is acked
we check for operations on all transports in the idle function
@@ -758,7 +841,7 @@ static bool compare_status(NTSTATUS status1, NTSTATUS status2)
return false;
}
-
+#if 0
/*
check for pending packets on all connections
*/
@@ -774,6 +857,7 @@ static void check_pending(void)
}
}
}
+#endif
/*
check that the same oplock breaks have been received by all instances
@@ -953,6 +1037,16 @@ again:
#define CHECK_EQUAL(field) do { \
if (parm[0].field != parm[1].field && !ignore_pattern(#field)) { \
+ printf("Mismatch in %s - 0x%llx 0x%llx\n", #field, \
+ (unsigned long long)parm[0].field, (unsigned long long)parm[1].field); \
+ return false; \
+ } \
+} while(0)
+
+#define CHECK_ATTRIB(field) do { \
+ if (!options.mask_indexing) { \
+ CHECK_EQUAL(field); \
+ } else if ((~FILE_ATTRIBUTE_NONINDEXED & parm[0].field) != (~FILE_ATTRIBUTE_NONINDEXED & parm[1].field) && !ignore_pattern(#field)) { \
printf("Mismatch in %s - 0x%x 0x%x\n", #field, \
(int)parm[0].field, (int)parm[1].field); \
return false; \
@@ -980,15 +1074,6 @@ again:
CHECK_EQUAL(field.length); \
} while(0)
-#define CHECK_TIMES_EQUAL(field) do { \
- if (labs(parm[0].field - parm[1].field) > time_skew() && \
- !ignore_pattern(#field)) { \
- printf("Mismatch in %s - 0x%x 0x%x\n", #field, \
- (int)parm[0].field, (int)parm[1].field); \
- return false; \
- } \
-} while(0)
-
#define CHECK_NTTIMES_EQUAL(field) do { \
if (labs(nt_time_to_unix(parm[0].field) - \
nt_time_to_unix(parm[1].field)) > time_skew() && \
@@ -1016,22 +1101,20 @@ static bool handler_create(int instance)
if (gen_chance(2)) {
parm[0].in.create_flags |= gen_bits_mask(0xFFFFFFFF);
}
- parm[0].in.reserved = gen_bits_levels(2, 95, 0x0, 100, 0xFFFFFFFF);
- if (gen_chance(2)) {
- parm[0].in.reserved |= gen_bits_mask(0xFFFFFFFF);
- }
+ parm[0].in.reserved = gen_reserved64();
parm[0].in.desired_access = gen_access_mask();
parm[0].in.file_attributes = gen_attrib();
parm[0].in.share_access = gen_bits_mask2(0x7, 0xFFFFFFFF);
parm[0].in.create_disposition = gen_open_disp();
parm[0].in.create_options = gen_create_options();
parm[0].in.fname = gen_fname_open(instance);
+ parm[0].in.eas = gen_ea_list();
if (!options.use_oplocks) {
/* mask out oplocks */
parm[0].in.oplock_level = 0;
}
-
+
GEN_COPY_PARM;
GEN_CALL(smb2_create(tree, current_op.mem_ctx, &parm[i]));
@@ -1044,7 +1127,7 @@ static bool handler_create(int instance)
CHECK_NTTIMES_EQUAL(out.change_time);
CHECK_EQUAL(out.alloc_size);
CHECK_EQUAL(out.size);
- CHECK_EQUAL(out.file_attr);
+ CHECK_ATTRIB(out.file_attr);
CHECK_EQUAL(out.reserved2);
/* ntcreatex creates a new file handle */
@@ -1077,7 +1160,7 @@ static bool handler_close(int instance)
CHECK_NTTIMES_EQUAL(out.change_time);
CHECK_EQUAL(out.alloc_size);
CHECK_EQUAL(out.size);
- CHECK_EQUAL(out.file_attr);
+ CHECK_ATTRIB(out.file_attr);
REMOVE_HANDLE(in.file.handle);
@@ -1093,7 +1176,7 @@ static bool handler_read(int instance)
NTSTATUS status[NSERVERS];
parm[0].in.file.handle.data[0] = gen_fnum(instance);
- parm[0].in.reserved = gen_bits_mask2(0x0, 0xFF);
+ parm[0].in.reserved = gen_reserved8();
parm[0].in.length = gen_io_count();
parm[0].in.offset = gen_offset();
parm[0].in.min_count = gen_io_count();
@@ -1151,7 +1234,7 @@ static bool handler_lock(int instance)
parm[0].level = RAW_LOCK_LOCKX;
parm[0].in.file.handle.data[0] = gen_fnum(instance);
parm[0].in.lock_count = gen_lock_count();
- parm[0].in.reserved = gen_bits_mask2(0, 0xFFFFFFFF);
+ parm[0].in.reserved = gen_reserved32();
parm[0].in.locks = talloc_array(current_op.mem_ctx,
struct smb2_lock_element,
@@ -1182,8 +1265,8 @@ static bool handler_flush(int instance)
ZERO_STRUCT(parm[0]);
parm[0].in.file.handle.data[0] = gen_fnum(instance);
- parm[0].in.reserved1 = gen_bits_mask2(0x0, 0xFFFF);
- parm[0].in.reserved2 = gen_bits_mask2(0x0, 0xFFFFFFFF);
+ parm[0].in.reserved1 = gen_reserved16();
+ parm[0].in.reserved2 = gen_reserved32();
GEN_COPY_PARM;
GEN_SET_FNUM(in.file.handle);
@@ -1194,7 +1277,19 @@ static bool handler_flush(int instance)
return true;
}
-#if 0
+/*
+ generate echo operations
+*/
+static bool handler_echo(int instance)
+{
+ NTSTATUS status[NSERVERS];
+
+ GEN_CALL(smb2_keepalive(tree->session->transport));
+
+ return true;
+}
+
+
/*
generate a fileinfo query structure
@@ -1207,16 +1302,13 @@ static void gen_fileinfo(int instance, union smb_fileinfo *info)
enum smb_fileinfo_level level;
const char *name;
} levels[] = {
- LVL(GETATTR), LVL(GETATTRE), LVL(STANDARD),
- LVL(EA_SIZE), LVL(ALL_EAS), LVL(IS_NAME_VALID),
- LVL(BASIC_INFO), LVL(STANDARD_INFO), LVL(EA_INFO),
- LVL(NAME_INFO), LVL(ALL_INFO), LVL(ALT_NAME_INFO),
- LVL(STREAM_INFO), LVL(COMPRESSION_INFO), LVL(BASIC_INFORMATION),
+ LVL(BASIC_INFORMATION),
LVL(STANDARD_INFORMATION), LVL(INTERNAL_INFORMATION), LVL(EA_INFORMATION),
LVL(ACCESS_INFORMATION), LVL(NAME_INFORMATION), LVL(POSITION_INFORMATION),
- LVL(MODE_INFORMATION), LVL(ALIGNMENT_INFORMATION), LVL(ALL_INFORMATION),
+ LVL(MODE_INFORMATION), LVL(ALIGNMENT_INFORMATION), LVL(SMB2_ALL_INFORMATION),
LVL(ALT_NAME_INFORMATION), LVL(STREAM_INFORMATION), LVL(COMPRESSION_INFORMATION),
- LVL(NETWORK_OPEN_INFORMATION), LVL(ATTRIBUTE_TAG_INFORMATION)
+ LVL(NETWORK_OPEN_INFORMATION), LVL(ATTRIBUTE_TAG_INFORMATION),
+ LVL(SMB2_ALL_EAS), LVL(SMB2_ALL_INFORMATION),
};
do {
i = gen_int_range(0, ARRAY_SIZE(levels)-1);
@@ -1238,62 +1330,31 @@ static bool cmp_fileinfo(int instance,
case RAW_FILEINFO_GENERIC:
return false;
+ /* SMB1 specific values */
case RAW_FILEINFO_GETATTR:
- CHECK_EQUAL(getattr.out.attrib);
- CHECK_EQUAL(getattr.out.size);
- CHECK_TIMES_EQUAL(getattr.out.write_time);
- break;
-
case RAW_FILEINFO_GETATTRE:
- CHECK_TIMES_EQUAL(getattre.out.create_time);
- CHECK_TIMES_EQUAL(getattre.out.access_time);
- CHECK_TIMES_EQUAL(getattre.out.write_time);
- CHECK_EQUAL(getattre.out.size);
- CHECK_EQUAL(getattre.out.alloc_size);
- CHECK_EQUAL(getattre.out.attrib);
- break;
-
case RAW_FILEINFO_STANDARD:
- CHECK_TIMES_EQUAL(standard.out.create_time);
- CHECK_TIMES_EQUAL(standard.out.access_time);
- CHECK_TIMES_EQUAL(standard.out.write_time);
- CHECK_EQUAL(standard.out.size);
- CHECK_EQUAL(standard.out.alloc_size);
- CHECK_EQUAL(standard.out.attrib);
- break;
-
case RAW_FILEINFO_EA_SIZE:
- CHECK_TIMES_EQUAL(ea_size.out.create_time);
- CHECK_TIMES_EQUAL(ea_size.out.access_time);
- CHECK_TIMES_EQUAL(ea_size.out.write_time);
- CHECK_EQUAL(ea_size.out.size);
- CHECK_EQUAL(ea_size.out.alloc_size);
- CHECK_EQUAL(ea_size.out.attrib);
- CHECK_EQUAL(ea_size.out.ea_size);
- break;
-
case RAW_FILEINFO_ALL_EAS:
- CHECK_EQUAL(all_eas.out.num_eas);
- for (i=0;i<parm[0].all_eas.out.num_eas;i++) {
- CHECK_EQUAL(all_eas.out.eas[i].flags);
- CHECK_WSTR_EQUAL(all_eas.out.eas[i].name);
- CHECK_BLOB_EQUAL(all_eas.out.eas[i].value);
- }
- break;
-
case RAW_FILEINFO_IS_NAME_VALID:
- break;
-
case RAW_FILEINFO_BASIC_INFO:
+ case RAW_FILEINFO_STANDARD_INFO:
+ case RAW_FILEINFO_EA_INFO:
+ case RAW_FILEINFO_NAME_INFO:
+ case RAW_FILEINFO_ALL_INFO:
+ case RAW_FILEINFO_ALT_NAME_INFO:
+ case RAW_FILEINFO_STREAM_INFO:
+ case RAW_FILEINFO_COMPRESSION_INFO:
+ return false;
+
case RAW_FILEINFO_BASIC_INFORMATION:
CHECK_NTTIMES_EQUAL(basic_info.out.create_time);
CHECK_NTTIMES_EQUAL(basic_info.out.access_time);
CHECK_NTTIMES_EQUAL(basic_info.out.write_time);
CHECK_NTTIMES_EQUAL(basic_info.out.change_time);
- CHECK_EQUAL(basic_info.out.attrib);
+ CHECK_ATTRIB(basic_info.out.attrib);
break;
- case RAW_FILEINFO_STANDARD_INFO:
case RAW_FILEINFO_STANDARD_INFORMATION:
CHECK_EQUAL(standard_info.out.alloc_size);
CHECK_EQUAL(standard_info.out.size);
@@ -1302,38 +1363,18 @@ static bool cmp_fileinfo(int instance,
CHECK_EQUAL(standard_info.out.directory);
break;
- case RAW_FILEINFO_EA_INFO:
case RAW_FILEINFO_EA_INFORMATION:
CHECK_EQUAL(ea_info.out.ea_size);
break;
- case RAW_FILEINFO_NAME_INFO:
case RAW_FILEINFO_NAME_INFORMATION:
CHECK_WSTR_EQUAL(name_info.out.fname);
break;
- case RAW_FILEINFO_ALL_INFO:
- case RAW_FILEINFO_ALL_INFORMATION:
- CHECK_NTTIMES_EQUAL(all_info.out.create_time);
- CHECK_NTTIMES_EQUAL(all_info.out.access_time);
- CHECK_NTTIMES_EQUAL(all_info.out.write_time);
- CHECK_NTTIMES_EQUAL(all_info.out.change_time);
- CHECK_EQUAL(all_info.out.attrib);
- CHECK_EQUAL(all_info.out.alloc_size);
- CHECK_EQUAL(all_info.out.size);
- CHECK_EQUAL(all_info.out.nlink);
- CHECK_EQUAL(all_info.out.delete_pending);
- CHECK_EQUAL(all_info.out.directory);
- CHECK_EQUAL(all_info.out.ea_size);
- CHECK_WSTR_EQUAL(all_info.out.fname);
- break;
-
- case RAW_FILEINFO_ALT_NAME_INFO:
case RAW_FILEINFO_ALT_NAME_INFORMATION:
CHECK_WSTR_EQUAL(alt_name_info.out.fname);
break;
- case RAW_FILEINFO_STREAM_INFO:
case RAW_FILEINFO_STREAM_INFORMATION:
CHECK_EQUAL(stream_info.out.num_streams);
for (i=0;i<parm[0].stream_info.out.num_streams;i++) {
@@ -1343,7 +1384,6 @@ static bool cmp_fileinfo(int instance,
}
break;
- case RAW_FILEINFO_COMPRESSION_INFO:
case RAW_FILEINFO_COMPRESSION_INFORMATION:
CHECK_EQUAL(compression_info.out.compressed_size);
CHECK_EQUAL(compression_info.out.format);
@@ -1379,22 +1419,51 @@ static bool cmp_fileinfo(int instance,
CHECK_NTTIMES_EQUAL(network_open_information.out.change_time);
CHECK_EQUAL(network_open_information.out.alloc_size);
CHECK_EQUAL(network_open_information.out.size);
- CHECK_EQUAL(network_open_information.out.attrib);
+ CHECK_ATTRIB(network_open_information.out.attrib);
break;
case RAW_FILEINFO_ATTRIBUTE_TAG_INFORMATION:
- CHECK_EQUAL(attribute_tag_information.out.attrib);
+ CHECK_ATTRIB(attribute_tag_information.out.attrib);
CHECK_EQUAL(attribute_tag_information.out.reparse_tag);
break;
+ case RAW_FILEINFO_ALL_INFORMATION:
+ case RAW_FILEINFO_SMB2_ALL_INFORMATION:
+ CHECK_NTTIMES_EQUAL(all_info2.out.create_time);
+ CHECK_NTTIMES_EQUAL(all_info2.out.access_time);
+ CHECK_NTTIMES_EQUAL(all_info2.out.write_time);
+ CHECK_NTTIMES_EQUAL(all_info2.out.change_time);
+ CHECK_ATTRIB(all_info2.out.attrib);
+ CHECK_EQUAL(all_info2.out.unknown1);
+ CHECK_EQUAL(all_info2.out.alloc_size);
+ CHECK_EQUAL(all_info2.out.size);
+ CHECK_EQUAL(all_info2.out.nlink);
+ CHECK_EQUAL(all_info2.out.delete_pending);
+ CHECK_EQUAL(all_info2.out.directory);
+ CHECK_EQUAL(all_info2.out.file_id);
+ CHECK_EQUAL(all_info2.out.ea_size);
+ CHECK_EQUAL(all_info2.out.access_mask);
+ CHECK_EQUAL(all_info2.out.position);
+ CHECK_EQUAL(all_info2.out.mode);
+ CHECK_EQUAL(all_info2.out.alignment_requirement);
+ CHECK_WSTR_EQUAL(all_info2.out.fname);
+ break;
+
+ case RAW_FILEINFO_SMB2_ALL_EAS:
+ CHECK_EQUAL(all_eas.out.num_eas);
+ for (i=0;i<parm[0].all_eas.out.num_eas;i++) {
+ CHECK_EQUAL(all_eas.out.eas[i].flags);
+ CHECK_WSTR_EQUAL(all_eas.out.eas[i].name);
+ CHECK_BLOB_EQUAL(all_eas.out.eas[i].value);
+ }
+ break;
+
/* Unhandled levels */
case RAW_FILEINFO_SEC_DESC:
case RAW_FILEINFO_EA_LIST:
case RAW_FILEINFO_UNIX_BASIC:
case RAW_FILEINFO_UNIX_LINK:
- case RAW_FILEINFO_SMB2_ALL_EAS:
- case RAW_FILEINFO_SMB2_ALL_INFORMATION:
case RAW_FILEINFO_UNIX_INFO2:
break;
}
@@ -1410,13 +1479,13 @@ static bool handler_qfileinfo(int instance)
union smb_fileinfo parm[NSERVERS];
NTSTATUS status[NSERVERS];
- parm[0].generic.in.file.fnum = gen_fnum(instance);
+ parm[0].generic.in.file.handle.data[0] = gen_fnum(instance);
gen_fileinfo(instance, &parm[0]);
GEN_COPY_PARM;
- GEN_SET_FNUM(generic.in.file.fnum);
- GEN_CALL(smb_raw_fileinfo(tree, current_op.mem_ctx, &parm[i]));
+ GEN_SET_FNUM(generic.in.file.handle);
+ GEN_CALL(smb2_getinfo_file(tree, current_op.mem_ctx, &parm[i]));
return cmp_fileinfo(instance, parm, status);
}
@@ -1434,12 +1503,7 @@ static void gen_setfileinfo(int instance, union smb_setfileinfo *info)
enum smb_setfileinfo_level level;
const char *name;
} levels[] = {
-#if 0
- /* disabled until win2003 can handle them ... */
- LVL(EA_SET), LVL(BASIC_INFO), LVL(DISPOSITION_INFO),
- LVL(STANDARD), LVL(ALLOCATION_INFO), LVL(END_OF_FILE_INFO),
-#endif
- LVL(SETATTR), LVL(SETATTRE), LVL(BASIC_INFORMATION),
+ LVL(BASIC_INFORMATION),
LVL(RENAME_INFORMATION), LVL(DISPOSITION_INFORMATION),
LVL(POSITION_INFORMATION), LVL(MODE_INFORMATION),
LVL(ALLOCATION_INFORMATION), LVL(END_OF_FILE_INFORMATION),
@@ -1453,27 +1517,15 @@ static void gen_setfileinfo(int instance, union smb_setfileinfo *info)
switch (info->generic.level) {
case RAW_SFILEINFO_SETATTR:
- info->setattr.in.attrib = gen_attrib();
- info->setattr.in.write_time = gen_timet();
- break;
case RAW_SFILEINFO_SETATTRE:
- info->setattre.in.create_time = gen_timet();
- info->setattre.in.access_time = gen_timet();
- info->setattre.in.write_time = gen_timet();
- break;
case RAW_SFILEINFO_STANDARD:
- info->standard.in.create_time = gen_timet();
- info->standard.in.access_time = gen_timet();
- info->standard.in.write_time = gen_timet();
- break;
- case RAW_SFILEINFO_EA_SET: {
- static struct ea_struct ea;
- info->ea_set.in.num_eas = 1;
- info->ea_set.in.eas = &ea;
- info->ea_set.in.eas[0] = gen_ea_struct();
- }
- break;
+ case RAW_SFILEINFO_EA_SET:
case RAW_SFILEINFO_BASIC_INFO:
+ case RAW_SFILEINFO_DISPOSITION_INFO:
+ case RAW_SFILEINFO_END_OF_FILE_INFO:
+ case RAW_SFILEINFO_ALLOCATION_INFO:
+ break;
+
case RAW_SFILEINFO_BASIC_INFORMATION:
info->basic_info.in.create_time = gen_nttime();
info->basic_info.in.access_time = gen_nttime();
@@ -1481,15 +1533,12 @@ static void gen_setfileinfo(int instance, union smb_setfileinfo *info)
info->basic_info.in.change_time = gen_nttime();
info->basic_info.in.attrib = gen_attrib();
break;
- case RAW_SFILEINFO_DISPOSITION_INFO:
case RAW_SFILEINFO_DISPOSITION_INFORMATION:
info->disposition_info.in.delete_on_close = gen_bool();
break;
- case RAW_SFILEINFO_ALLOCATION_INFO:
case RAW_SFILEINFO_ALLOCATION_INFORMATION:
info->allocation_info.in.alloc_size = gen_alloc_size();
break;
- case RAW_SFILEINFO_END_OF_FILE_INFO:
case RAW_SFILEINFO_END_OF_FILE_INFORMATION:
info->end_of_file_info.in.size = gen_offset();
break;
@@ -1507,16 +1556,16 @@ static void gen_setfileinfo(int instance, union smb_setfileinfo *info)
break;
case RAW_SFILEINFO_GENERIC:
case RAW_SFILEINFO_SEC_DESC:
- case RAW_SFILEINFO_UNIX_BASIC:
- case RAW_SFILEINFO_UNIX_LINK:
- case RAW_SFILEINFO_UNIX_HLINK:
case RAW_SFILEINFO_1023:
case RAW_SFILEINFO_1025:
case RAW_SFILEINFO_1029:
case RAW_SFILEINFO_1032:
case RAW_SFILEINFO_1039:
case RAW_SFILEINFO_1040:
+ case RAW_SFILEINFO_UNIX_BASIC:
case RAW_SFILEINFO_UNIX_INFO2:
+ case RAW_SFILEINFO_UNIX_LINK:
+ case RAW_SFILEINFO_UNIX_HLINK:
/* Untested */
break;
}
@@ -1535,15 +1584,12 @@ static bool handler_sfileinfo(int instance)
gen_setfileinfo(instance, &parm[0]);
GEN_COPY_PARM;
- GEN_SET_FNUM(generic.in.file.fnum);
- GEN_CALL(smb_raw_setfileinfo(tree, &parm[i]));
+ GEN_SET_FNUM(generic.in.file.handle);
+ GEN_CALL(smb2_setinfo_file(tree, &parm[i]));
return true;
}
-#endif
-
-
/*
wipe any relevant files
*/
@@ -1552,6 +1598,10 @@ static void wipe_files(void)
int i;
NTSTATUS status;
+ if (options.skip_cleanup) {
+ return;
+ }
+
for (i=0;i<NSERVERS;i++) {
int n = smb2_deltree(servers[i].tree[0], "gentest");
if (n == -1) {
@@ -1606,6 +1656,9 @@ static struct {
{"WRITE", handler_write},
{"LOCK", handler_lock},
{"FLUSH", handler_flush},
+ {"ECHO", handler_echo},
+ {"QFILEINFO", handler_qfileinfo},
+ {"SFILEINFO", handler_sfileinfo},
};
@@ -1870,6 +1923,9 @@ static bool split_unc_name(const char *unc, char **server, char **share)
{"unclist", 0, POPT_ARG_STRING, NULL, OPT_UNCLIST, "unclist", NULL},
{"seedsfile", 0, POPT_ARG_STRING, &options.seeds_file, 0, "seed file", NULL},
{ "user", 'U', POPT_ARG_STRING, NULL, 'U', "Set the network username", "[DOMAIN/]USERNAME[%PASSWORD]" },
+ {"maskindexing", 0, POPT_ARG_NONE, &options.mask_indexing, 0, "mask out the indexed file attrib", NULL},
+ {"noeas", 0, POPT_ARG_NONE, &options.no_eas, 0, "don't use extended attributes", NULL},
+ {"skip-cleanup", 0, POPT_ARG_NONE, &options.skip_cleanup, 0, "don't delete files at start", NULL},
POPT_COMMON_SAMBA
POPT_COMMON_CONNECTION
POPT_COMMON_CREDENTIALS
diff --git a/source4/torture/locktest.c b/source4/torture/locktest.c
index 8959232edb..4a0dfc2a6f 100644
--- a/source4/torture/locktest.c
+++ b/source4/torture/locktest.c
@@ -27,7 +27,7 @@
#include "auth/gensec/gensec.h"
#include "libcli/libcli.h"
#include "param/param.h"
-#include "dynconfig.h"
+#include "dynconfig/dynconfig.h"
#include "libcli/resolve/resolve.h"
static int numops = 1000;
diff --git a/source4/torture/masktest.c b/source4/torture/masktest.c
index 39b1296dbe..255d94382c 100644
--- a/source4/torture/masktest.c
+++ b/source4/torture/masktest.c
@@ -28,7 +28,7 @@
#include "auth/credentials/credentials.h"
#include "auth/gensec/gensec.h"
#include "param/param.h"
-#include "dynconfig.h"
+#include "dynconfig/dynconfig.h"
#include "libcli/resolve/resolve.h"
#include "lib/events/events.h"
diff --git a/source4/torture/raw/read.c b/source4/torture/raw/read.c
index c8420c279e..ada9b1f432 100644
--- a/source4/torture/raw/read.c
+++ b/source4/torture/raw/read.c
@@ -460,6 +460,23 @@ static bool test_readx(struct torture_context *tctx, struct smbcli_state *cli)
CHECK_VALUE(io.readx.out.compaction_mode, 0);
}
+ printf("Trying mincnt past EOF\n");
+ memset(buf, 0, maxsize);
+ io.readx.in.offset = 0;
+ io.readx.in.mincnt = 100;
+ io.readx.in.maxcnt = 110;
+ status = smb_raw_read(cli->tree, &io);
+ CHECK_STATUS(status, NT_STATUS_OK);
+ CHECK_VALUE(io.readx.out.remaining, 0xFFFF);
+ CHECK_VALUE(io.readx.out.compaction_mode, 0);
+ CHECK_VALUE(io.readx.out.nread, strlen(test_data));
+ if (memcmp(buf, test_data, strlen(test_data)) != 0) {
+ ret = false;
+ printf("incorrect data at %d!? (%s:%s)\n", __LINE__, test_data, buf);
+ goto done;
+ }
+
+
setup_buffer(buf, seed, maxsize);
smbcli_write(cli->tree, fnum, 0, buf, 0, maxsize);
memset(buf, 0, maxsize);
diff --git a/source4/torture/raw/streams.c b/source4/torture/raw/streams.c
index 1dab36c28b..8b2d327653 100644
--- a/source4/torture/raw/streams.c
+++ b/source4/torture/raw/streams.c
@@ -135,6 +135,11 @@ static bool check_stream_list(struct smbcli_state *cli, const char *fname,
goto fail;
}
+ if (num_exp == 0) {
+ ret = true;
+ goto fail;
+ }
+
exp_sort = talloc_memdup(tmp_ctx, exp, num_exp * sizeof(*exp));
if (exp_sort == NULL) {
@@ -170,7 +175,81 @@ static bool check_stream_list(struct smbcli_state *cli, const char *fname,
}
/*
- test basic io on streams
+ test bahavior of streams on directories
+*/
+static bool test_stream_dir(struct torture_context *tctx,
+ struct smbcli_state *cli, TALLOC_CTX *mem_ctx)
+{
+ NTSTATUS status;
+ union smb_open io;
+ const char *fname = BASEDIR "\\stream.txt";
+ const char *sname1;
+ bool ret = true;
+ const char *basedir_data;
+
+ basedir_data = talloc_asprintf(mem_ctx, "%s::$DATA", BASEDIR);
+ sname1 = talloc_asprintf(mem_ctx, "%s:%s", fname, "Stream One");
+
+ printf("(%s) opening non-existant directory stream\n", __location__);
+ io.generic.level = RAW_OPEN_NTCREATEX;
+ io.ntcreatex.in.root_fid = 0;
+ io.ntcreatex.in.flags = 0;
+ io.ntcreatex.in.access_mask = SEC_FILE_WRITE_DATA;
+ io.ntcreatex.in.create_options = NTCREATEX_OPTIONS_DIRECTORY;
+ io.ntcreatex.in.file_attr = FILE_ATTRIBUTE_NORMAL;
+ io.ntcreatex.in.share_access = 0;
+ io.ntcreatex.in.alloc_size = 0;
+ io.ntcreatex.in.open_disposition = NTCREATEX_DISP_CREATE;
+ io.ntcreatex.in.impersonation = NTCREATEX_IMPERSONATION_ANONYMOUS;
+ io.ntcreatex.in.security_flags = 0;
+ io.ntcreatex.in.fname = sname1;
+ status = smb_raw_open(cli->tree, mem_ctx, &io);
+ CHECK_STATUS(status, NT_STATUS_NOT_A_DIRECTORY);
+
+ printf("(%s) opening basedir stream\n", __location__);
+ io.generic.level = RAW_OPEN_NTCREATEX;
+ io.ntcreatex.in.root_fid = 0;
+ io.ntcreatex.in.flags = 0;
+ io.ntcreatex.in.access_mask = SEC_FILE_WRITE_DATA;
+ io.ntcreatex.in.create_options = NTCREATEX_OPTIONS_DIRECTORY;
+ io.ntcreatex.in.file_attr = FILE_ATTRIBUTE_DIRECTORY;
+ io.ntcreatex.in.share_access = 0;
+ io.ntcreatex.in.alloc_size = 0;
+ io.ntcreatex.in.open_disposition = NTCREATEX_DISP_OPEN;
+ io.ntcreatex.in.impersonation = NTCREATEX_IMPERSONATION_ANONYMOUS;
+ io.ntcreatex.in.security_flags = 0;
+ io.ntcreatex.in.fname = basedir_data;
+ status = smb_raw_open(cli->tree, mem_ctx, &io);
+ CHECK_STATUS(status, NT_STATUS_NOT_A_DIRECTORY);
+
+ printf("(%s) opening basedir ::$DATA stream\n", __location__);
+ io.generic.level = RAW_OPEN_NTCREATEX;
+ io.ntcreatex.in.root_fid = 0;
+ io.ntcreatex.in.flags = 0x10;
+ io.ntcreatex.in.access_mask = SEC_FILE_WRITE_DATA;
+ io.ntcreatex.in.create_options = 0;
+ io.ntcreatex.in.file_attr = 0;
+ io.ntcreatex.in.share_access = 0;
+ io.ntcreatex.in.alloc_size = 0;
+ io.ntcreatex.in.open_disposition = NTCREATEX_DISP_OPEN;
+ io.ntcreatex.in.impersonation = NTCREATEX_IMPERSONATION_ANONYMOUS;
+ io.ntcreatex.in.security_flags = 0;
+ io.ntcreatex.in.fname = basedir_data;
+ status = smb_raw_open(cli->tree, mem_ctx, &io);
+ if (torture_setting_bool(tctx, "samba3", false)) {
+ CHECK_STATUS(status, NT_STATUS_OBJECT_NAME_NOT_FOUND);
+ } else {
+ CHECK_STATUS(status, NT_STATUS_FILE_IS_A_DIRECTORY);
+ }
+
+ printf("(%s) list the streams on the basedir\n", __location__);
+ ret &= check_stream_list(cli, BASEDIR, 0, NULL);
+done:
+ return ret;
+}
+
+/*
+ test basic behavior of streams on directories
*/
static bool test_stream_io(struct torture_context *tctx,
struct smbcli_state *cli, TALLOC_CTX *mem_ctx)
@@ -191,12 +270,12 @@ static bool test_stream_io(struct torture_context *tctx,
sname1 = talloc_asprintf(mem_ctx, "%s:%s", fname, "Stream One");
sname2 = talloc_asprintf(mem_ctx, "%s:%s:$DaTa", fname, "Second Stream");
- printf("(%s) opening non-existant directory stream\n", __location__);
+ printf("(%s) creating a stream on a non-existant file\n", __location__);
io.generic.level = RAW_OPEN_NTCREATEX;
io.ntcreatex.in.root_fid = 0;
io.ntcreatex.in.flags = 0;
io.ntcreatex.in.access_mask = SEC_FILE_WRITE_DATA;
- io.ntcreatex.in.create_options = NTCREATEX_OPTIONS_DIRECTORY;
+ io.ntcreatex.in.create_options = 0;
io.ntcreatex.in.file_attr = FILE_ATTRIBUTE_NORMAL;
io.ntcreatex.in.share_access = 0;
io.ntcreatex.in.alloc_size = 0;
@@ -205,12 +284,6 @@ static bool test_stream_io(struct torture_context *tctx,
io.ntcreatex.in.security_flags = 0;
io.ntcreatex.in.fname = sname1;
status = smb_raw_open(cli->tree, mem_ctx, &io);
- CHECK_STATUS(status, NT_STATUS_NOT_A_DIRECTORY);
-
- printf("(%s) creating a stream on a non-existant file\n", __location__);
- io.ntcreatex.in.create_options = 0;
- io.ntcreatex.in.fname = sname1;
- status = smb_raw_open(cli->tree, mem_ctx, &io);
CHECK_STATUS(status, NT_STATUS_OK);
fnum = io.ntcreatex.out.file.fnum;
@@ -423,7 +496,7 @@ static bool test_stream_delete(struct torture_context *tctx,
sname1 = talloc_asprintf(mem_ctx, "%s:%s", fname, "Stream One");
- printf("(%s) opening non-existant directory stream\n", __location__);
+ printf("(%s) opening non-existant file stream\n", __location__);
io.generic.level = RAW_OPEN_NTCREATEX;
io.ntcreatex.in.root_fid = 0;
io.ntcreatex.in.flags = 0;
@@ -559,6 +632,8 @@ bool torture_raw_streams(struct torture_context *torture,
return false;
}
+ ret &= test_stream_dir(torture, cli, torture);
+ smb_raw_exit(cli->session);
ret &= test_stream_io(torture, cli, torture);
smb_raw_exit(cli->session);
ret &= test_stream_sharemodes(torture, cli, torture);
diff --git a/source4/torture/smb2/config.mk b/source4/torture/smb2/config.mk
index 11c4e1fa2c..9785303629 100644
--- a/source4/torture/smb2/config.mk
+++ b/source4/torture/smb2/config.mk
@@ -20,7 +20,9 @@ TORTURE_SMB2_OBJ_FILES = $(addprefix $(torturesrcdir)/smb2/, \
notify.o \
smb2.o \
persistent_handles.o \
- oplocks.o)
+ oplocks.o \
+ create.o \
+ read.o)
$(eval $(call proto_header_template,$(torturesrcdir)/smb2/proto.h,$(TORTURE_SMB2_OBJ_FILES:.o=.c)))
diff --git a/source4/torture/smb2/connect.c b/source4/torture/smb2/connect.c
index 0004ea958e..826bb2d719 100644
--- a/source4/torture/smb2/connect.c
+++ b/source4/torture/smb2/connect.c
@@ -139,7 +139,7 @@ static NTSTATUS torture_smb2_write(struct torture_context *tctx, struct smb2_tre
/*
send a create
*/
-static struct smb2_handle torture_smb2_create(struct smb2_tree *tree,
+static struct smb2_handle torture_smb2_createfile(struct smb2_tree *tree,
const char *fname)
{
struct smb2_create io;
@@ -200,8 +200,8 @@ bool torture_smb2_connect(struct torture_context *torture)
return false;
}
- h1 = torture_smb2_create(tree, "test9.dat");
- h2 = torture_smb2_create(tree, "test9.dat");
+ h1 = torture_smb2_createfile(tree, "test9.dat");
+ h2 = torture_smb2_createfile(tree, "test9.dat");
status = torture_smb2_write(torture, tree, h1);
if (!NT_STATUS_IS_OK(status)) {
printf("Write failed - %s\n", nt_errstr(status));
diff --git a/source4/torture/smb2/create.c b/source4/torture/smb2/create.c
new file mode 100644
index 0000000000..9c9e7e2997
--- /dev/null
+++ b/source4/torture/smb2/create.c
@@ -0,0 +1,201 @@
+/*
+ Unix SMB/CIFS implementation.
+
+ SMB2 create test suite
+
+ Copyright (C) Andrew Tridgell 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/>.
+*/
+
+#include "includes.h"
+#include "libcli/smb2/smb2.h"
+#include "libcli/smb2/smb2_calls.h"
+#include "torture/torture.h"
+#include "torture/smb2/proto.h"
+#include "param/param.h"
+#include "librpc/gen_ndr/ndr_security.h"
+
+#define FNAME "test_create.dat"
+
+#define CHECK_STATUS(status, correct) do { \
+ if (!NT_STATUS_EQUAL(status, correct)) { \
+ printf("(%s) Incorrect status %s - should be %s\n", \
+ __location__, nt_errstr(status), nt_errstr(correct)); \
+ return false; \
+ }} while (0)
+
+#define CHECK_EQUAL(v, correct) do { \
+ if (v != correct) { \
+ printf("(%s) Incorrect value for %s 0x%08x - should be 0x%08x\n", \
+ __location__, #v, v, correct); \
+ return false; \
+ }} while (0)
+
+/*
+ test some interesting combinations found by gentest
+ */
+bool torture_smb2_create_gentest(struct torture_context *torture, struct smb2_tree *tree)
+{
+ struct smb2_create io;
+ NTSTATUS status;
+ TALLOC_CTX *tmp_ctx = talloc_new(tree);
+ uint32_t access_mask, file_attributes, denied_mask;
+
+ ZERO_STRUCT(io);
+ io.in.desired_access = SEC_FLAG_MAXIMUM_ALLOWED;
+ io.in.file_attributes = FILE_ATTRIBUTE_NORMAL;
+ io.in.create_disposition = NTCREATEX_DISP_OVERWRITE_IF;
+ io.in.share_access =
+ NTCREATEX_SHARE_ACCESS_DELETE|
+ NTCREATEX_SHARE_ACCESS_READ|
+ NTCREATEX_SHARE_ACCESS_WRITE;
+ io.in.create_options = 0;
+ io.in.fname = FNAME;
+
+ status = smb2_create(tree, tmp_ctx, &io);
+ CHECK_STATUS(status, NT_STATUS_OK);
+
+ status = smb2_util_close(tree, io.out.file.handle);
+ CHECK_STATUS(status, NT_STATUS_OK);
+
+ io.in.create_options = 0xF0000000;
+ status = smb2_create(tree, tmp_ctx, &io);
+ CHECK_STATUS(status, NT_STATUS_INVALID_PARAMETER);
+
+ io.in.create_options = 0x00100000;
+ status = smb2_create(tree, tmp_ctx, &io);
+ CHECK_STATUS(status, NT_STATUS_NOT_SUPPORTED);
+
+ io.in.create_options = 0xF0100000;
+ status = smb2_create(tree, tmp_ctx, &io);
+ CHECK_STATUS(status, NT_STATUS_NOT_SUPPORTED);
+
+ io.in.create_options = 0;
+
+ io.in.file_attributes = FILE_ATTRIBUTE_DEVICE;
+ status = smb2_create(tree, tmp_ctx, &io);
+ CHECK_STATUS(status, NT_STATUS_INVALID_PARAMETER);
+
+ io.in.file_attributes = FILE_ATTRIBUTE_VOLUME;
+ status = smb2_create(tree, tmp_ctx, &io);
+ CHECK_STATUS(status, NT_STATUS_INVALID_PARAMETER);
+
+ io.in.create_disposition = NTCREATEX_DISP_OPEN;
+ io.in.file_attributes = FILE_ATTRIBUTE_VOLUME;
+ status = smb2_create(tree, tmp_ctx, &io);
+ CHECK_STATUS(status, NT_STATUS_INVALID_PARAMETER);
+
+ io.in.create_disposition = NTCREATEX_DISP_CREATE;
+ io.in.desired_access = 0x08000000;
+ status = smb2_create(tree, tmp_ctx, &io);
+ CHECK_STATUS(status, NT_STATUS_ACCESS_DENIED);
+
+ io.in.desired_access = 0x04000000;
+ status = smb2_create(tree, tmp_ctx, &io);
+ CHECK_STATUS(status, NT_STATUS_ACCESS_DENIED);
+
+ io.in.create_disposition = NTCREATEX_DISP_OPEN_IF;
+ io.in.file_attributes = 0;
+ access_mask = 0;
+ {
+ int i;
+ for (i=0;i<32;i++) {
+ io.in.desired_access = 1<<i;
+ status = smb2_create(tree, tmp_ctx, &io);
+ if (NT_STATUS_EQUAL(status, NT_STATUS_ACCESS_DENIED)) {
+ access_mask |= io.in.desired_access;
+ } else {
+ CHECK_STATUS(status, NT_STATUS_OK);
+ status = smb2_util_close(tree, io.out.file.handle);
+ CHECK_STATUS(status, NT_STATUS_OK);
+ }
+ }
+ }
+
+ CHECK_EQUAL(access_mask, 0x0df0fe00);
+
+ io.in.create_disposition = NTCREATEX_DISP_OPEN_IF;
+ io.in.desired_access = SEC_FLAG_MAXIMUM_ALLOWED;
+ io.in.file_attributes = 0;
+ file_attributes = 0;
+ denied_mask = 0;
+ {
+ int i;
+ for (i=0;i<32;i++) {
+ io.in.file_attributes = 1<<i;
+ smb2_deltree(tree, FNAME);
+ status = smb2_create(tree, tmp_ctx, &io);
+ if (NT_STATUS_EQUAL(status, NT_STATUS_INVALID_PARAMETER)) {
+ file_attributes |= io.in.file_attributes;
+ } else if (NT_STATUS_EQUAL(status, NT_STATUS_ACCESS_DENIED)) {
+ denied_mask |= io.in.file_attributes;
+ } else {
+ CHECK_STATUS(status, NT_STATUS_OK);
+ status = smb2_util_close(tree, io.out.file.handle);
+ CHECK_STATUS(status, NT_STATUS_OK);
+ }
+ }
+ }
+
+ CHECK_EQUAL(file_attributes, 0xffff8048);
+ CHECK_EQUAL(denied_mask, 0x4000);
+
+ smb2_deltree(tree, FNAME);
+
+ ZERO_STRUCT(io);
+ io.in.desired_access = SEC_FLAG_MAXIMUM_ALLOWED;
+ io.in.file_attributes = 0;
+ io.in.create_disposition = NTCREATEX_DISP_OVERWRITE_IF;
+ io.in.share_access =
+ NTCREATEX_SHARE_ACCESS_READ|
+ NTCREATEX_SHARE_ACCESS_WRITE;
+ io.in.create_options = 0;
+ io.in.fname = FNAME ":stream1";
+ status = smb2_create(tree, tmp_ctx, &io);
+ CHECK_STATUS(status, NT_STATUS_OK);
+
+ io.in.fname = FNAME;
+ io.in.file_attributes = 0x8040;
+ io.in.share_access =
+ NTCREATEX_SHARE_ACCESS_READ;
+ status = smb2_create(tree, tmp_ctx, &io);
+ CHECK_STATUS(status, NT_STATUS_INVALID_PARAMETER);
+
+ talloc_free(tmp_ctx);
+
+ return true;
+}
+
+/*
+ basic testing of SMB2 create calls
+*/
+bool torture_smb2_create(struct torture_context *torture)
+{
+ TALLOC_CTX *mem_ctx = talloc_new(NULL);
+ struct smb2_tree *tree;
+ bool ret = true;
+
+ if (!torture_smb2_connection(torture, &tree)) {
+ return false;
+ }
+
+ ret &= torture_smb2_create_gentest(torture, tree);
+
+ smb2_deltree(tree, FNAME);
+
+ talloc_free(mem_ctx);
+
+ return ret;
+}
diff --git a/source4/torture/smb2/getinfo.c b/source4/torture/smb2/getinfo.c
index c47a26277c..906d6e4f8d 100644
--- a/source4/torture/smb2/getinfo.c
+++ b/source4/torture/smb2/getinfo.c
@@ -51,9 +51,9 @@ static struct {
{ LEVEL(RAW_FILEINFO_COMPRESSION_INFORMATION) },
{ LEVEL(RAW_FILEINFO_NETWORK_OPEN_INFORMATION) },
{ LEVEL(RAW_FILEINFO_ATTRIBUTE_TAG_INFORMATION) },
-/*
-disabled until we know how the alignment now works
-{ LEVEL(RAW_FILEINFO_SMB2_ALL_EAS) }, */
+/*
+ { LEVEL(RAW_FILEINFO_SMB2_ALL_EAS) },
+*/
{ LEVEL(RAW_FILEINFO_SMB2_ALL_INFORMATION) },
{ LEVEL(RAW_FILEINFO_SEC_DESC) }
};
@@ -107,9 +107,6 @@ static bool torture_smb2_fileinfo(struct torture_context *tctx, struct smb2_tree
file_levels[i].dinfo.query_secdesc.in.secinfo_flags = 0x7;
}
if (file_levels[i].level == RAW_FILEINFO_SMB2_ALL_EAS) {
- if (torture_setting_bool(tctx, "samba4", false)) {
- continue;
- }
file_levels[i].finfo.all_eas.in.continue_flags =
SMB2_CONTINUE_FLAG_RESTART;
file_levels[i].dinfo.all_eas.in.continue_flags =
@@ -183,6 +180,9 @@ bool torture_smb2_getinfo(struct torture_context *torture)
return false;
}
+ smb2_deltree(tree, FNAME);
+ smb2_deltree(tree, DNAME);
+
status = torture_setup_complex_file(tree, FNAME);
if (!NT_STATUS_IS_OK(status)) {
return false;
diff --git a/source4/torture/smb2/lock.c b/source4/torture/smb2/lock.c
index e81647b497..4e21045a33 100644
--- a/source4/torture/smb2/lock.c
+++ b/source4/torture/smb2/lock.c
@@ -51,7 +51,7 @@ static bool test_valid_request(struct torture_context *torture, struct smb2_tree
struct smb2_handle h;
uint8_t buf[200];
struct smb2_lock lck;
- struct smb2_lock_element el[1];
+ struct smb2_lock_element el[2];
ZERO_STRUCT(buf);
@@ -90,7 +90,7 @@ static bool test_valid_request(struct torture_context *torture, struct smb2_tree
lck.in.file.handle.data[0] -=1;
lck.in.lock_count = 0x0001;
- lck.in.reserved = 0xFFFFFFFF;
+ lck.in.reserved = 0x123ab1;
lck.in.file.handle = h;
el[0].offset = UINT64_MAX;
el[0].length = UINT64_MAX;
@@ -100,16 +100,20 @@ static bool test_valid_request(struct torture_context *torture, struct smb2_tree
CHECK_STATUS(status, NT_STATUS_OK);
CHECK_VALUE(lck.out.reserved, 0);
+ lck.in.reserved = 0x123ab2;
status = smb2_lock(tree, &lck);
CHECK_STATUS(status, NT_STATUS_LOCK_NOT_GRANTED);
+ lck.in.reserved = 0x123ab3;
status = smb2_lock(tree, &lck);
CHECK_STATUS(status, NT_STATUS_OK);
CHECK_VALUE(lck.out.reserved, 0);
+ lck.in.reserved = 0x123ab4;
status = smb2_lock(tree, &lck);
CHECK_STATUS(status, NT_STATUS_LOCK_NOT_GRANTED);
+ lck.in.reserved = 0x123ab5;
status = smb2_lock(tree, &lck);
CHECK_STATUS(status, NT_STATUS_OK);
CHECK_VALUE(lck.out.reserved, 0);
@@ -162,27 +166,123 @@ static bool test_valid_request(struct torture_context *torture, struct smb2_tree
lck.in.file.handle = h;
el[0].offset = 0x00000000FFFFFFFF;
el[0].length = 0x00000000FFFFFFFF;
- el[0].reserved = 0x12345678;
+ el[0].reserved = 0x1234567;
el[0].flags = SMB2_LOCK_FLAG_UNLOCK;
status = smb2_lock(tree, &lck);
- CHECK_STATUS(status, NT_STATUS_RANGE_NOT_LOCKED);
+ CHECK_STATUS(status, NT_STATUS_OK);
lck.in.lock_count = 0x0001;
- lck.in.reserved = 0x12345678;
+ lck.in.reserved = 0x1234567;
lck.in.file.handle = h;
el[0].offset = 0x00000000FFFFFFFF;
el[0].length = 0x00000000FFFFFFFF;
el[0].reserved = 0x00000000;
el[0].flags = SMB2_LOCK_FLAG_UNLOCK;
status = smb2_lock(tree, &lck);
+ CHECK_STATUS(status, NT_STATUS_OK);
+
+ status = smb2_lock(tree, &lck);
+ CHECK_STATUS(status, NT_STATUS_OK);
+ status = smb2_lock(tree, &lck);
+ CHECK_STATUS(status, NT_STATUS_OK);
+ status = smb2_lock(tree, &lck);
+ CHECK_STATUS(status, NT_STATUS_OK);
+ status = smb2_lock(tree, &lck);
CHECK_STATUS(status, NT_STATUS_RANGE_NOT_LOCKED);
+ lck.in.lock_count = 0x0001;
+ lck.in.reserved = 0;
+ lck.in.file.handle = h;
+ el[0].offset = 1;
+ el[0].length = 1;
+ el[0].reserved = 0x00000000;
+ el[0].flags = ~SMB2_LOCK_FLAG_ALL_MASK;
+
+ status = smb2_lock(tree, &lck);
+ CHECK_STATUS(status, NT_STATUS_OK);
+
+ el[0].flags = SMB2_LOCK_FLAG_UNLOCK;
+ status = smb2_lock(tree, &lck);
+ CHECK_STATUS(status, NT_STATUS_OK);
+
+ el[0].flags = SMB2_LOCK_FLAG_UNLOCK;
status = smb2_lock(tree, &lck);
CHECK_STATUS(status, NT_STATUS_RANGE_NOT_LOCKED);
+
+ el[0].flags = SMB2_LOCK_FLAG_UNLOCK | SMB2_LOCK_FLAG_EXCLUSIVE;
+ status = smb2_lock(tree, &lck);
+ CHECK_STATUS(status, NT_STATUS_INVALID_PARAMETER);
+
+ el[0].flags = SMB2_LOCK_FLAG_UNLOCK | SMB2_LOCK_FLAG_SHARED;
+ status = smb2_lock(tree, &lck);
+ CHECK_STATUS(status, NT_STATUS_INVALID_PARAMETER);
+
+ el[0].flags = SMB2_LOCK_FLAG_UNLOCK | SMB2_LOCK_FLAG_FAIL_IMMEDIATELY;
status = smb2_lock(tree, &lck);
CHECK_STATUS(status, NT_STATUS_RANGE_NOT_LOCKED);
+
+ lck.in.lock_count = 2;
+ lck.in.reserved = 0;
+ lck.in.file.handle = h;
+ el[0].offset = 9999;
+ el[0].length = 1;
+ el[0].reserved = 0x00000000;
+ el[1].offset = 9999;
+ el[1].length = 1;
+ el[1].reserved = 0x00000000;
+
+ lck.in.lock_count = 2;
+ el[0].flags = 0;
+ el[1].flags = SMB2_LOCK_FLAG_UNLOCK;
+ status = smb2_lock(tree, &lck);
+ CHECK_STATUS(status, NT_STATUS_INVALID_PARAMETER);
+
+ lck.in.lock_count = 2;
+ el[0].flags = 0;
+ el[1].flags = 0;
+ status = smb2_lock(tree, &lck);
+ CHECK_STATUS(status, NT_STATUS_OK);
+
+ lck.in.lock_count = 2;
+ el[0].flags = SMB2_LOCK_FLAG_UNLOCK;
+ el[1].flags = 0;
+ status = smb2_lock(tree, &lck);
+ CHECK_STATUS(status, NT_STATUS_OK);
+
+ lck.in.lock_count = 1;
+ el[0].flags = SMB2_LOCK_FLAG_UNLOCK;
+ status = smb2_lock(tree, &lck);
+ CHECK_STATUS(status, NT_STATUS_OK);
+
+ lck.in.lock_count = 1;
+ el[0].flags = SMB2_LOCK_FLAG_UNLOCK;
+ status = smb2_lock(tree, &lck);
+ CHECK_STATUS(status, NT_STATUS_OK);
+
+ lck.in.lock_count = 1;
+ el[0].flags = SMB2_LOCK_FLAG_UNLOCK;
+ status = smb2_lock(tree, &lck);
+ CHECK_STATUS(status, NT_STATUS_RANGE_NOT_LOCKED);
+
+ lck.in.lock_count = 1;
+ el[0].flags = 0;
+ status = smb2_lock(tree, &lck);
+ CHECK_STATUS(status, NT_STATUS_OK);
+
+ status = smb2_lock(tree, &lck);
+ CHECK_STATUS(status, NT_STATUS_OK);
+
+ lck.in.lock_count = 2;
+ el[0].flags = SMB2_LOCK_FLAG_UNLOCK;
+ el[1].flags = SMB2_LOCK_FLAG_UNLOCK;
+ status = smb2_lock(tree, &lck);
+ CHECK_STATUS(status, NT_STATUS_OK);
+
+ lck.in.lock_count = 1;
+ el[0].flags = SMB2_LOCK_FLAG_UNLOCK;
status = smb2_lock(tree, &lck);
CHECK_STATUS(status, NT_STATUS_RANGE_NOT_LOCKED);
+
done:
return ret;
diff --git a/source4/torture/smb2/read.c b/source4/torture/smb2/read.c
new file mode 100644
index 0000000000..3e1d077b7d
--- /dev/null
+++ b/source4/torture/smb2/read.c
@@ -0,0 +1,141 @@
+/*
+ Unix SMB/CIFS implementation.
+
+ SMB2 read test suite
+
+ Copyright (C) Andrew Tridgell 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/>.
+*/
+
+#include "includes.h"
+#include "libcli/smb2/smb2.h"
+#include "libcli/smb2/smb2_calls.h"
+
+#include "torture/torture.h"
+#include "torture/smb2/proto.h"
+
+#include "librpc/gen_ndr/ndr_security.h"
+
+#define CHECK_STATUS(status, correct) do { \
+ if (!NT_STATUS_EQUAL(status, correct)) { \
+ printf("(%s) Incorrect status %s - should be %s\n", \
+ __location__, nt_errstr(status), nt_errstr(correct)); \
+ ret = false; \
+ goto done; \
+ }} while (0)
+
+#define CHECK_VALUE(v, correct) do { \
+ if ((v) != (correct)) { \
+ printf("(%s) Incorrect value %s=%d - should be %d\n", \
+ __location__, #v, v, correct); \
+ ret = false; \
+ goto done; \
+ }} while (0)
+
+static bool test_read(struct torture_context *torture, struct smb2_tree *tree)
+{
+ bool ret = true;
+ NTSTATUS status;
+ struct smb2_handle h;
+ uint8_t buf[70000];
+ struct smb2_read rd;
+ TALLOC_CTX *tmp_ctx = talloc_new(tree);
+
+ ZERO_STRUCT(buf);
+
+ status = torture_smb2_testfile(tree, "lock1.txt", &h);
+ CHECK_STATUS(status, NT_STATUS_OK);
+
+ status = smb2_util_write(tree, h, buf, 0, ARRAY_SIZE(buf));
+ CHECK_STATUS(status, NT_STATUS_OK);
+
+ ZERO_STRUCT(rd);
+ rd.in.file.handle = h;
+ rd.in.length = 10;
+ rd.in.offset = 0;
+ rd.in.min_count = 1;
+
+ status = smb2_read(tree, tmp_ctx, &rd);
+ CHECK_STATUS(status, NT_STATUS_OK);
+ CHECK_VALUE(rd.out.data.length, 10);
+
+ rd.in.min_count = 0;
+ rd.in.length = 10;
+ rd.in.offset = sizeof(buf);
+ status = smb2_read(tree, tmp_ctx, &rd);
+ CHECK_STATUS(status, NT_STATUS_END_OF_FILE);
+
+ rd.in.min_count = 0;
+ rd.in.length = 0;
+ rd.in.offset = sizeof(buf);
+ status = smb2_read(tree, tmp_ctx, &rd);
+ CHECK_STATUS(status, NT_STATUS_OK);
+ CHECK_VALUE(rd.out.data.length, 0);
+
+ rd.in.min_count = 1;
+ rd.in.length = 0;
+ rd.in.offset = sizeof(buf);
+ status = smb2_read(tree, tmp_ctx, &rd);
+ CHECK_STATUS(status, NT_STATUS_END_OF_FILE);
+
+ rd.in.min_count = 0;
+ rd.in.length = 2;
+ rd.in.offset = sizeof(buf) - 1;
+ status = smb2_read(tree, tmp_ctx, &rd);
+ CHECK_STATUS(status, NT_STATUS_OK);
+ CHECK_VALUE(rd.out.data.length, 1);
+
+ rd.in.min_count = 2;
+ rd.in.length = 1;
+ rd.in.offset = sizeof(buf) - 1;
+ status = smb2_read(tree, tmp_ctx, &rd);
+ CHECK_STATUS(status, NT_STATUS_END_OF_FILE);
+
+ rd.in.min_count = 0x10000;
+ rd.in.length = 1;
+ rd.in.offset = 0;
+ status = smb2_read(tree, tmp_ctx, &rd);
+ CHECK_STATUS(status, NT_STATUS_END_OF_FILE);
+
+ rd.in.min_count = 0x10000 - 2;
+ rd.in.length = 1;
+ rd.in.offset = 0;
+ status = smb2_read(tree, tmp_ctx, &rd);
+ CHECK_STATUS(status, NT_STATUS_END_OF_FILE);
+
+ rd.in.min_count = 10;
+ rd.in.length = 5;
+ rd.in.offset = 0;
+ status = smb2_read(tree, tmp_ctx, &rd);
+ CHECK_STATUS(status, NT_STATUS_END_OF_FILE);
+
+done:
+ talloc_free(tmp_ctx);
+ return ret;
+}
+
+/* basic testing of SMB2 read
+*/
+struct torture_suite *torture_smb2_read_init(void)
+{
+ struct torture_suite *suite = torture_suite_create(talloc_autofree_context(), "READ");
+
+ torture_suite_add_1smb2_test(suite, "READ", test_read);
+
+ suite->description = talloc_strdup(suite, "SMB2-READ tests");
+
+ return suite;
+}
+
diff --git a/source4/torture/smb2/smb2.c b/source4/torture/smb2/smb2.c
index 37eadcf7fd..f813148e1d 100644
--- a/source4/torture/smb2/smb2.c
+++ b/source4/torture/smb2/smb2.c
@@ -135,7 +135,9 @@ NTSTATUS torture_smb2_init(void)
torture_suite_add_simple_test(suite, "GETINFO", torture_smb2_getinfo);
torture_suite_add_simple_test(suite, "SETINFO", torture_smb2_setinfo);
torture_suite_add_simple_test(suite, "FIND", torture_smb2_find);
+ torture_suite_add_simple_test(suite, "CREATE", torture_smb2_create);
torture_suite_add_suite(suite, torture_smb2_lock_init());
+ torture_suite_add_suite(suite, torture_smb2_read_init());
torture_suite_add_simple_test(suite, "NOTIFY", torture_smb2_notify);
torture_suite_add_2smb2_test(suite, "PERSISTENT-HANDLES1", torture_smb2_persistent_handles1);
torture_suite_add_1smb2_test(suite, "OPLOCK-BATCH1", torture_smb2_oplock_batch1);
diff --git a/source4/torture/smbtorture.c b/source4/torture/smbtorture.c
index 418f933993..e1e84247b4 100644
--- a/source4/torture/smbtorture.c
+++ b/source4/torture/smbtorture.c
@@ -2,7 +2,7 @@
Unix SMB/CIFS implementation.
SMB torture tester
Copyright (C) Andrew Tridgell 1997-2003
- Copyright (C) Jelmer Vernooij 2006
+ Copyright (C) Jelmer Vernooij 2006-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
@@ -28,7 +28,7 @@
#include "libcli/libcli.h"
#include "lib/ldb/include/ldb.h"
#include "lib/events/events.h"
-#include "dynconfig.h"
+#include "dynconfig/dynconfig.h"
#include "torture/smbtorture.h"
#include "lib/util/dlinklist.h"
@@ -375,11 +375,24 @@ static void subunit_suite_start(struct torture_context *ctx,
{
}
+static void subunit_print_testname(struct torture_context *ctx,
+ struct torture_tcase *tcase,
+ struct torture_test *test)
+{
+ if (!strcmp(tcase->name, test->name)) {
+ printf("%s", test->name);
+ } else {
+ printf("%s.%s", tcase->name, test->name);
+ }
+}
+
static void subunit_test_start(struct torture_context *ctx,
struct torture_tcase *tcase,
struct torture_test *test)
{
- printf("test: %s\n", test->name);
+ printf("test: ");
+ subunit_print_testname(ctx, tcase, test);
+ printf("\n");
}
static void subunit_test_result(struct torture_context *context,
@@ -387,18 +400,20 @@ static void subunit_test_result(struct torture_context *context,
{
switch (res) {
case TORTURE_OK:
- printf("success: %s", context->active_test->name);
+ printf("success: ");
break;
case TORTURE_FAIL:
- printf("failure: %s", context->active_test->name);
+ printf("failure: ");
break;
case TORTURE_ERROR:
- printf("error: %s", context->active_test->name);
+ printf("error: ");
break;
case TORTURE_SKIP:
- printf("skip: %s", context->active_test->name);
+ printf("skip: ");
break;
}
+ subunit_print_testname(context, context->active_tcase, context->active_test);
+
if (reason)
printf(" [\n%s\n]", reason);
printf("\n");
diff --git a/source4/web_server/swat/__init__.py b/source4/web_server/swat/__init__.py
new file mode 100644
index 0000000000..e0d85dbe2c
--- /dev/null
+++ b/source4/web_server/swat/__init__.py
@@ -0,0 +1,27 @@
+#!/usr/bin/python
+
+# Unix SMB/CIFS implementation.
+# Copyright © Jelmer Vernooij <jelmer@samba.org> 2008
+#
+# Implementation of SWAT that uses WSGI
+#
+# 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/>.
+#
+
+def SWAT(environ, start_response):
+ status = '200 OK'
+ response_headers = [('Content-type','text/plain')]
+ start_response(status, response_headers)
+ return ['Hello world!\n']
+
diff --git a/testprogs/ejs/argv.js b/testprogs/ejs/argv.js
deleted file mode 100644
index ffb6e007eb..0000000000
--- a/testprogs/ejs/argv.js
+++ /dev/null
@@ -1,14 +0,0 @@
-/*
- demonstrate use of GetOptions
-*/
-
-var options = GetOptions(ARGV,
- "POPT_AUTOHELP",
- "POPT_COMMON_SAMBA",
- "myopt=s",
- "intopt=i",
- "noopt");
-
-println("You called this script with arguments:");
-
-printVars(options);
diff --git a/testprogs/ejs/echo.js b/testprogs/ejs/echo.js
deleted file mode 100755
index 3750baf0fb..0000000000
--- a/testprogs/ejs/echo.js
+++ /dev/null
@@ -1,235 +0,0 @@
-#!/usr/bin/env smbscript
-/*
- test echo pipe calls from ejs
-*/
-
-var options = GetOptions(ARGV,
- "POPT_AUTOHELP",
- "POPT_COMMON_SAMBA",
- "POPT_COMMON_CREDENTIALS");
-if (options == undefined) {
- println("Failed to parse options");
- return -1;
-}
-
-libinclude("base.js");
-
-/*
- generate a ramp as an integer array
- */
-function ramp_array(N)
-{
- var a = new Array(N);
- var data = datablob_init();
- for (i=0;i<N;i++) {
- a[i] = i;
- }
- return data.blobFromArray(a);
-}
-
-
-/*
- test the echo_AddOne interface
-*/
-function test_AddOne(echo)
-{
- var io = irpcObj();
-
- print("Testing echo_AddOne\n");
-
- for (i=0;i<10;i++) {
- io.input.in_data = i;
- status = echo.echo_AddOne(io);
- check_status_ok(status);
- assert(io.output.out_data == i + 1);
- }
-}
-
-/*
- test the echo_EchoData interface
-*/
-function test_EchoData(echo)
-{
- var io = irpcObj();
-
- print("Testing echo_EchoData\n");
-
- for (i=0; i<30; i=i+5) {
- io.input.len = i;
- io.input.in_data = ramp_array(i);
- status = echo.echo_EchoData(io);
- check_status_ok(status);
- assert(true == echo.blobCompare(io.input.in_data, io.output.out_data));
- }
-}
-
-
-/*
- test the echo_SinkData interface
-*/
-function test_SinkData(echo)
-{
- var io = irpcObj();
-
- print("Testing echo_SinkData\n");
-
- for (i=0; i<30; i=i+5) {
- io.input.len = i;
- io.input.data = ramp_array(i);
- status = echo.echo_SinkData(io);
- check_status_ok(status);
- }
-}
-
-
-/*
- test the echo_SourceData interface
-*/
-function test_SourceData(echo)
-{
- var io = irpcObj();
-
- print("Testing echo_SourceData\n");
-
- for (i=0; i<30; i=i+5) {
- io.input.len = i;
- status = echo.echo_SourceData(io);
- check_status_ok(status);
- correct = ramp_array(i);
- assert(true == echo.blobCompare(correct, io.output.data));
- }
-}
-
-
-/*
- test the echo_TestCall interface
-*/
-function test_TestCall(echo)
-{
- var io = irpcObj();
-
- print("Testing echo_TestCall\n");
-
- io.input.s1 = "my test string";
- status = echo.echo_TestCall(io);
- check_status_ok(status);
- assert("this is a test string" == io.output.s2);
-}
-
-/*
- test the echo_TestCall2 interface
-*/
-function test_TestCall2(echo)
-{
- var io = irpcObj();
-
- print("Testing echo_TestCall2\n");
-
- for (i=1;i<=7;i++) {
- io.input.level = i;
- status = echo.echo_TestCall2(io);
- check_status_ok(status);
- }
-}
-
-/*
- test the echo_TestSleep interface
-*/
-function test_TestSleep(echo)
-{
- var io = irpcObj();
-
- print("Testing echo_TestSleep\n");
-
- io.input.seconds = 1;
- status = echo.echo_TestSleep(io);
- check_status_ok(status);
-}
-
-/*
- test the echo_TestEnum interface
-*/
-function test_TestEnum(echo)
-{
- var io = irpcObj();
-
- print("Testing echo_TestEnum\n");
-
- io.input.foo1 = echo.ECHO_ENUM1;
- io.input.foo2 = new Object();
- io.input.foo2.e1 = echo.ECHO_ENUM1;
- io.input.foo2.e2 = echo.ECHO_ENUM1_32;
- io.input.foo3 = new Object();
- io.input.foo3.e1 = echo.ECHO_ENUM2;
- status = echo.echo_TestEnum(io);
- check_status_ok(status);
- assert(io.output.foo1 == echo.ECHO_ENUM1);
- assert(io.output.foo2.e1 == echo.ECHO_ENUM2);
- assert(io.output.foo2.e2 == echo.ECHO_ENUM1_32);
- assert(io.output.foo3.e1 == echo.ECHO_ENUM2);
-}
-
-/*
- test the echo_TestSurrounding interface
-*/
-function test_TestSurrounding(echo)
-{
- var io = irpcObj();
-
- print("Testing echo_TestSurrounding\n");
-
- io.input.data = new Object();
- io.input.data.x = 10;
- io.input.data.surrounding = new Array(10);
- status = echo.echo_TestSurrounding(io);
- check_status_ok(status);
- assert(io.output.data.surrounding.length == 20);
- check_array_zero(io.output.data.surrounding);
-}
-
-/*
- test the echo_TestDoublePointer interface
-*/
-function test_TestDoublePointer(echo)
-{
- var io = irpcObj();
-
- print("Testing echo_TestDoublePointer\n");
-
- io.input.data = 7;
- status = echo.echo_TestDoublePointer(io);
- check_status_ok(status);
- assert(io.input.data == io.input.data);
-}
-
-
-if (options.ARGV.length != 1) {
- println("Usage: echo.js <BINDING>");
- return -1;
-}
-var binding = options.ARGV[0];
-var echo = rpcecho_init();
-datablob_init(echo);
-
-print("Connecting to " + binding + "\n");
-status = echo.connect(binding);
-if (status.is_ok != true) {
- printf("Failed to connect to %s - %s\n", binding, status.errstr);
- return;
-}
-
-test_AddOne(echo);
-test_EchoData(echo);
-test_SinkData(echo);
-test_SourceData(echo);
-
-print("SKIPPING test_TestCall as pidl cannot generate code for it\n");
-/* test_TestCall(echo); */
-test_TestCall2(echo);
-test_TestSleep(echo);
-test_TestEnum(echo);
-test_TestSurrounding(echo);
-test_TestDoublePointer(echo);
-
-println("All OK\n");
-return 0;
diff --git a/testprogs/ejs/ejsnet.js b/testprogs/ejs/ejsnet.js
deleted file mode 100755
index a5570de34c..0000000000
--- a/testprogs/ejs/ejsnet.js
+++ /dev/null
@@ -1,46 +0,0 @@
-#!/usr/bin/env smbscript
-
-libinclude("base.js");
-
-/* note: these require specifying a proper path in "js include" parameter */
-libinclude("ejsnet/netusr.js");
-libinclude("ejsnet/nethost.js");
-
-function PrintNetHelp()
-{
- println("Usage: ejsnet.js <cmd> [options]");
-}
-
-/* here we start */
-
-var options = GetOptions(ARGV,
- "POPT_AUTOHELP",
- "POPT_COMMON_SAMBA",
- "POPT_COMMON_CREDENTIALS");
-if (options == undefined) {
- PrintNetHelp();
- return -1;
-}
-
-if (options.ARGV.length < 1) {
- PrintNetHelp();
- return -1;
-}
-
-/* use command line creds if available */
-var creds = options.get_credentials();
-var ctx = NetContext(creds);
-
-var cmd = options.ARGV[0];
-if (cmd == "user") {
- UserManager(ctx, options);
-
-} else if (cmd == "host") {
- HostManager(ctx, options);
-
-} else {
- PrintNetHelp();
- return -1;
-}
-
-return 0;
diff --git a/testprogs/ejs/ejsnet/nethost.js b/testprogs/ejs/ejsnet/nethost.js
deleted file mode 100644
index 9e11ae89c5..0000000000
--- a/testprogs/ejs/ejsnet/nethost.js
+++ /dev/null
@@ -1,45 +0,0 @@
-function PrintNetHostHelp()
-{
- println("Host management - available commands:");
- println("\t domainlist - list users in specified domain");
-}
-
-
-function ListDomains(hostCtx)
-{
- var domain;
-
- var list = hostCtx.DomainList();
- if (list == undefined) {
- println("Error when listing domains");
- return -1;
- }
-
- for (var i = 0; i < list.Count; i++) {
- domain = list.Domains[i];
- printf("%s\n", domain.Name);
- }
-
- printf("\nResult: %s\n", list.Status.errstr);
-}
-
-
-function HostManager(ctx, options)
-{
- var hostCtx;
-
- if (options.ARGV.length < 2) {
- PrintNetHostHelp();
- return -1;
- }
-
- var hostCmd = options.ARGV[1];
-
- if (hostCmd == "domainlist") {
- hostCtx = ctx.HostMgr();
- ListDomains(hostCtx);
-
- } else {
- println("unknown command");
- }
-}
diff --git a/testprogs/ejs/ejsnet/netusr.js b/testprogs/ejs/ejsnet/netusr.js
deleted file mode 100644
index da6e851ce7..0000000000
--- a/testprogs/ejs/ejsnet/netusr.js
+++ /dev/null
@@ -1,86 +0,0 @@
-function PrintNetUsrHelp(options)
-{
- println("User management - available commands:");
- println("\t list - list users in specified domain");
- println("\t info - display user account information");
-}
-
-
-function ListUsers(usrCtx)
-{
- var list, user;
- var finished = false;
-
- for (list = usrCtx.List(list); list.Status.is_ok && !finished; list = usrCtx.List(list)) {
- for (i = 0; i < list.Count; i++) {
- user = list.Users[i];
- printf("%s\n", user.Username);
- }
-
- finished = list.EndOfList;
- }
-
- printf("\nResult: %s\n", list.Status.errstr);
-}
-
-
-function UserInfo(usrCtx, username)
-{
- var info;
-
- info = usrCtx.Info(username);
- if (info == null) {
- println("Account unknown");
- return -1;
- }
-
- println("User account info:\n");
- printf("AccountName = %s\n", info.AccountName);
- printf("Description = %s\n", info.Description);
- printf("FullName = %s\n", info.FullName);
- printf("AcctExpiry = %s\n", info.AcctExpiry);
-}
-
-
-function UserManager(ctx, options)
-{
- var usrCtx;
-
- if (options.ARGV.length < 2) {
- PrintNetUsrHelp(options);
- return -1;
-
- }
-
- var usrCmd = options.ARGV[1];
-
- if (usrCmd == "create") {
-
- } else if (usrCmd == "info") {
- var userName;
-
- if (options.ARGV.length > 2) {
- userName = options.ARGV[2];
- } else {
- println("No username provided");
- return -1;
- }
- usrCtx = ctx.UserMgr();
-
- UserInfo(usrCtx, userName);
-
- } else if (usrCmd == "list") {
-
- if (options.ARGV.length > 2) {
- usrCtx = ctx.UserMgr(options.ARGV[2]);
- } else {
- usrCtx = ctx.UserMgr();
- }
-
- ListUsers(usrCtx);
-
- } else {
- println("Unknown command specified.");
- PrintNetUsrHelp(options);
- }
-}
diff --git a/testprogs/ejs/loadparm.js b/testprogs/ejs/loadparm.js
deleted file mode 100644
index f56ca9f7fc..0000000000
--- a/testprogs/ejs/loadparm.js
+++ /dev/null
@@ -1,25 +0,0 @@
-/*
- demonstrate access to loadparm functions from ejs
-*/
-
-loadparm_init(local);
-
-function showParameter(name) {
- print(name + ": ");
- printVars(get(name));
-}
-
-for (v in ARGV) {
- showParameter(ARGV[v]);
-}
-
-print("defined services: ");
-printVars(services());
-
-showParameter("server services");
-showParameter("netbios name");
-showParameter("security");
-showParameter("workgroup");
-showParameter("log level");
-showParameter("server signing");
-showParameter("interfaces");
diff --git a/testprogs/ejs/nbtstats b/testprogs/ejs/nbtstats
deleted file mode 100755
index 1c8a6a5e7e..0000000000
--- a/testprogs/ejs/nbtstats
+++ /dev/null
@@ -1,33 +0,0 @@
-#!/usr/bin/env smbscript
-/*
- demonstrate access to irpc calls from ejs
-*/
-
-var options = GetOptions(ARGV,
- "POPT_AUTOHELP",
- "POPT_COMMON_SAMBA");
-if (options == undefined) {
- println("Failed to parse options");
- return -1;
-}
-
-var conn = new Object();
-var irpc = irpc_init();
-
-status = irpc_connect(conn, "nbt_server");
-assert(status.is_ok == true);
-
-io = new Object();
-io.input = new Object();
-io.input.level = irpc.NBTD_INFO_STATISTICS;
-status = irpc.nbtd_information(conn, io);
-assert(status.is_ok == true);
-assert(io.results.length == 1);
-
-print("nbt_server statistics:\n");
-stats = io.results[0].info.stats;
-
-for (r in stats) {
- print("\t" + r + ":\t" + stats[r] + "\n");
-}
-return 0;
diff --git a/testprogs/ejs/resolveName.js b/testprogs/ejs/resolveName.js
deleted file mode 100644
index 1619b69d69..0000000000
--- a/testprogs/ejs/resolveName.js
+++ /dev/null
@@ -1,13 +0,0 @@
-/*
- Demonstrate use of resolveName() js function
-*/
-
-var result = new Object();
-
-res = resolveName(result, ARGV[0]);
-
-if (res.is_ok) {
- println(result.value);
-} else {
- println(res.errstr);
-}
diff --git a/testprogs/ejs/samr.js b/testprogs/ejs/samr.js
deleted file mode 100755
index fbdae974be..0000000000
--- a/testprogs/ejs/samr.js
+++ /dev/null
@@ -1,126 +0,0 @@
-#!/usr/bin/env smbscript
-/*
- test samr calls from ejs
-*/
-
-var options = GetOptions(ARGV,
- "POPT_AUTOHELP",
- "POPT_COMMON_SAMBA",
- "POPT_COMMON_CREDENTIALS");
-if (options == undefined) {
- println("Failed to parse options");
- return -1;
-}
-
-libinclude("base.js");
-libinclude("samr.js");
-
-
-/*
- test the samr_Connect interface
-*/
-function test_Connect(samr)
-{
- print("Testing samr_Connect\n");
- return samrConnect(samr);
-}
-
-
-/*
- test the samr_LookupDomain interface
-*/
-function test_LookupDomain(samr, handle, domain)
-{
- print("Testing samr_LookupDomain\n");
- return samrLookupDomain(samr, handle, domain);
-}
-
-/*
- test the samr_OpenDomain interface
-*/
-function test_OpenDomain(samr, handle, sid)
-{
- print("Testing samr_OpenDomain\n");
- return samrOpenDomain(samr, handle, sid);
-}
-
-/*
- test the samr_EnumDomainUsers interface
-*/
-function test_EnumDomainUsers(samr, dom_handle)
-{
- var i, users;
- print("Testing samr_EnumDomainUsers\n");
- users = samrEnumDomainUsers(samr, dom_handle);
- print("Found " + users.length + " users\n");
- for (i=0;i<users.length;i++) {
- println("\t" + users[i].name + "\t(" + users[i].idx + ")");
- }
-}
-
-/*
- test the samr_EnumDomainGroups interface
-*/
-function test_EnumDomainGroups(samr, dom_handle)
-{
- print("Testing samr_EnumDomainGroups\n");
- var i, groups = samrEnumDomainGroups(samr, dom_handle);
- print("Found " + groups.length + " groups\n");
- for (i=0;i<groups.length;i++) {
- println("\t" + groups[i].name + "\t(" + groups[i].idx + ")");
- }
-}
-
-/*
- test domain specific ops
-*/
-function test_domain_ops(samr, dom_handle)
-{
- test_EnumDomainUsers(samr, dom_handle);
- test_EnumDomainGroups(samr, dom_handle);
-}
-
-
-
-/*
- test the samr_EnumDomains interface
-*/
-function test_EnumDomains(samr, handle)
-{
- var i, domains;
- print("Testing samr_EnumDomains\n");
-
- domains = samrEnumDomains(samr, handle);
- print("Found " + domains.length + " domains\n");
- for (i=0;i<domains.length;i++) {
- print("\t" + domains[i].name + "\n");
- }
- for (i=0;i<domains.length;i++) {
- print("Testing domain " + domains[i].name + "\n");
- sid = samrLookupDomain(samr, handle, domains[i].name);
- dom_handle = test_OpenDomain(samr, handle, sid);
- test_domain_ops(samr, dom_handle);
- samrClose(samr, dom_handle);
- }
-}
-
-if (options.ARGV.length != 1) {
- println("Usage: samr.js <BINDING>");
- return -1;
-}
-var binding = options.ARGV[0];
-var samr = samr_init();
-
-print("Connecting to " + binding + "\n");
-status = samr.connect(binding);
-if (status.is_ok != true) {
- print("Failed to connect to " + binding + " - " + status.errstr + "\n");
- return -1;
-}
-
-handle = test_Connect(samr);
-test_EnumDomains(samr, handle);
-samrClose(samr, handle);
-
-print("All OK\n");
-return 0;