From 75eef34a23ac60b9218a6fa3da80f579b6830303 Mon Sep 17 00:00:00 2001 From: Tim Potter Date: Wed, 28 Apr 2004 10:10:52 +0000 Subject: r383: Scripting extensions using swig. This commit includes only a (LGPL) python interface to tdb and a rudimentary build system. Configure with --with-python and make swig to build and append $(builddir)/scripting/swig/python to PYTHONPATH. (This used to be commit bbc15d6f84b6a247ae87b253752a86a38f1d6798) --- source4/scripting/config.m4 | 27 +++++++++ source4/scripting/swig/samba.i | 33 +++++++++++ source4/scripting/swig/tdb.i | 132 +++++++++++++++++++++++++++++++++++++++++ 3 files changed, 192 insertions(+) create mode 100644 source4/scripting/config.m4 create mode 100644 source4/scripting/swig/samba.i create mode 100644 source4/scripting/swig/tdb.i (limited to 'source4/scripting') diff --git a/source4/scripting/config.m4 b/source4/scripting/config.m4 new file mode 100644 index 0000000000..02a563e167 --- /dev/null +++ b/source4/scripting/config.m4 @@ -0,0 +1,27 @@ +dnl # Scripting subsystem + +# Check for python support + +PYTHON= + +AC_ARG_WITH(python, +[ --with-python=PYTHONNAME build Python libraries], +[ case "${withval-python}" in + yes) + PYTHON=python + ;; + no) + PYTHON= + ;; + *) + PYTHON=${withval-python} + ;; + esac ]) + +if test x"$PYTHON" != "x"; then + incdir=`python -c 'import sys; print "%s/include/python%d.%d" % (sys.prefix, sys.version_info[[0]], sys.version_info[[1]])'` + CPPFLAGS="$CPPFLAGS -I $incdir" +fi + +AC_SUBST(PYTHON) + diff --git a/source4/scripting/swig/samba.i b/source4/scripting/swig/samba.i new file mode 100644 index 0000000000..edb038bd5b --- /dev/null +++ b/source4/scripting/swig/samba.i @@ -0,0 +1,33 @@ +/* + Unix SMB/CIFS implementation. + + Common swig definitions + + Copyright (C) 2004 Tim Potter + + ** NOTE! The following LGPL license applies to the tdb + ** library. This does NOT imply that all of Samba is released + ** under the LGPL + + This library is free software; you can redistribute it and/or + modify it under the terms of the GNU Lesser General Public + License as published by the Free Software Foundation; either + version 2 of the License, or (at your option) any later version. + + This library 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 + Lesser General Public License for more details. + + You should have received a copy of the GNU Lesser General Public + License along with this library; if not, write to the Free Software + Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA +*/ + +%typemap(in) uint32 { + if (!PyInt_Check($input)) { + PyErr_SetString(PyExc_TypeError, "integer expected"); + return NULL; + } + $1 = (uint32)PyInt_AsLong($input); +} diff --git a/source4/scripting/swig/tdb.i b/source4/scripting/swig/tdb.i new file mode 100644 index 0000000000..9f8961c248 --- /dev/null +++ b/source4/scripting/swig/tdb.i @@ -0,0 +1,132 @@ +/* + Unix SMB/CIFS implementation. + + Swig interface to tdb. + + Copyright (C) 2004 Tim Potter + + ** NOTE! The following LGPL license applies to the tdb + ** library. This does NOT imply that all of Samba is released + ** under the LGPL + + This library is free software; you can redistribute it and/or + modify it under the terms of the GNU Lesser General Public + License as published by the Free Software Foundation; either + version 2 of the License, or (at your option) any later version. + + This library 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 + Lesser General Public License for more details. + + You should have received a copy of the GNU Lesser General Public + License along with this library; if not, write to the Free Software + Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA +*/ + +%module tdb + +%{ + +/* The tdb_set_lock_alarm() function requires the SIG_ATOMIC_T + function from includes.h */ + +#include "include/config.h" +#if defined(HAVE_SIG_ATOMIC_T_TYPE) +typedef sig_atomic_t SIG_ATOMIC_T; +#else +typedef int SIG_ATOMIC_T; +#endif + +/* Include tdb headers */ + +#include "tdb/tdb.h" + +%} + +/* The tdb functions will crash if a NULL tdb is passed */ + +%include exception.i + +%typemap(check) TDB_CONTEXT* { + if ($1 == NULL) + SWIG_exception(SWIG_ValueError, + "tdb context must be non-NULL"); +} + +/* In and out typemaps for the TDB_DATA structure. This is converted to + and from the Python string type. */ + +%typemap(in) TDB_DATA { + if (!PyString_Check($input)) { + PyErr_SetString(PyExc_TypeError, "string arg expected"); + return NULL; + } + $1.dsize = PyString_Size($input); + $1.dptr = PyString_AsString($input); +} + +%typemap(out) TDB_DATA { + if ($1.dptr == NULL && $1.dsize == 0) { + $result = Py_None; + } else { + $result = PyString_FromStringAndSize($1.dptr, $1.dsize); + free($1.dptr); + } +} + +/* Treat a mode_t as an unsigned integer */ + +typedef unsigned int mode_t; + +/* flags to tdb_store() */ + +#define TDB_REPLACE 1 +#define TDB_INSERT 2 +#define TDB_MODIFY 3 + +/* flags for tdb_open() */ + +#define TDB_DEFAULT 0 /* just a readability place holder */ +#define TDB_CLEAR_IF_FIRST 1 +#define TDB_INTERNAL 2 /* don't store on disk */ +#define TDB_NOLOCK 4 /* don't do any locking */ +#define TDB_NOMMAP 8 /* don't use mmap */ +#define TDB_CONVERT 16 /* convert endian (internal use) */ +#define TDB_BIGENDIAN 32 /* header is big-endian (internal use) */ + +TDB_CONTEXT *tdb_open(const char *name, int hash_size, int tdb_flags, + int open_flags, mode_t mode); + +TDB_CONTEXT *tdb_open_ex(const char *name, int hash_size, int tdb_flags, + int open_flags, mode_t mode, + tdb_log_func log_fn); + +int tdb_reopen(TDB_CONTEXT *tdb); +int tdb_reopen_all(void); + +void tdb_logging_function(TDB_CONTEXT *tdb, tdb_log_func); +enum TDB_ERROR tdb_error(TDB_CONTEXT *tdb); +const char *tdb_errorstr(TDB_CONTEXT *tdb); +TDB_DATA tdb_fetch(TDB_CONTEXT *tdb, TDB_DATA key); +int tdb_delete(TDB_CONTEXT *tdb, TDB_DATA key); +int tdb_store(TDB_CONTEXT *tdb, TDB_DATA key, TDB_DATA dbuf, int flag = TDB_REPLACE); +int tdb_append(TDB_CONTEXT *tdb, TDB_DATA key, TDB_DATA new_dbuf); +int tdb_close(TDB_CONTEXT *tdb); +TDB_DATA tdb_firstkey(TDB_CONTEXT *tdb); +TDB_DATA tdb_nextkey(TDB_CONTEXT *tdb, TDB_DATA key); +int tdb_traverse(TDB_CONTEXT *tdb, tdb_traverse_func fn, void *state); +int tdb_exists(TDB_CONTEXT *tdb, TDB_DATA key); +int tdb_lockkeys(TDB_CONTEXT *tdb, u32 number, TDB_DATA keys[]); +void tdb_unlockkeys(TDB_CONTEXT *tdb); +int tdb_lockall(TDB_CONTEXT *tdb); +void tdb_unlockall(TDB_CONTEXT *tdb); + +/* Low level locking functions: use with care */ +void tdb_set_lock_alarm(SIG_ATOMIC_T *palarm); +int tdb_chainlock(TDB_CONTEXT *tdb, TDB_DATA key); +int tdb_chainunlock(TDB_CONTEXT *tdb, TDB_DATA key); + +/* Debug functions. Not used in production. */ +void tdb_dump_all(TDB_CONTEXT *tdb); +int tdb_printfreelist(TDB_CONTEXT *tdb); -- cgit From f2ad98a165cdec6d344a96aeb21a38518a10720a Mon Sep 17 00:00:00 2001 From: Stefan Metzmacher Date: Tue, 25 May 2004 16:50:09 +0000 Subject: r888: more ..int32 -> ..int32_t stuff metze (This used to be commit f3b1d3bdc74f08ee2a1d22102d57bff94f71f5a5) --- source4/scripting/swig/samba.i | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'source4/scripting') diff --git a/source4/scripting/swig/samba.i b/source4/scripting/swig/samba.i index edb038bd5b..60f2efcc19 100644 --- a/source4/scripting/swig/samba.i +++ b/source4/scripting/swig/samba.i @@ -29,5 +29,5 @@ PyErr_SetString(PyExc_TypeError, "integer expected"); return NULL; } - $1 = (uint32)PyInt_AsLong($input); + $1 = (uint32_t)PyInt_AsLong($input); } -- cgit From fa2e9ec311b99dee2fbff5ee5fa2c743298dacad Mon Sep 17 00:00:00 2001 From: Stefan Metzmacher Date: Tue, 1 Jun 2004 08:12:45 +0000 Subject: r960: convert 'unsigned int' to uint_t in the most places metze (This used to be commit 18062d2ed9fc9224c43143c10efbf2f6f1f5bbe0) --- source4/scripting/swig/tdb.i | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'source4/scripting') diff --git a/source4/scripting/swig/tdb.i b/source4/scripting/swig/tdb.i index 9f8961c248..e645dfaf79 100644 --- a/source4/scripting/swig/tdb.i +++ b/source4/scripting/swig/tdb.i @@ -77,7 +77,7 @@ typedef int SIG_ATOMIC_T; /* Treat a mode_t as an unsigned integer */ -typedef unsigned int mode_t; +typedef uint_t mode_t; /* flags to tdb_store() */ -- cgit From b575ce6b4b09db7b8ea6b25cdee4364df8511b94 Mon Sep 17 00:00:00 2001 From: Tim Potter Date: Sat, 4 Sep 2004 22:55:33 +0000 Subject: r2226: A bunch of fixes to get python tdb module building again. I'm not sure how this can be integrated into the build system properly though. Editing makefile.pl is the wrong way to do this. (This used to be commit e6a42f7880993271f2610584182f7d47538b6747) --- source4/scripting/swig/tdb.i | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) (limited to 'source4/scripting') diff --git a/source4/scripting/swig/tdb.i b/source4/scripting/swig/tdb.i index e645dfaf79..f4a3f53c4b 100644 --- a/source4/scripting/swig/tdb.i +++ b/source4/scripting/swig/tdb.i @@ -40,7 +40,7 @@ typedef int SIG_ATOMIC_T; /* Include tdb headers */ -#include "tdb/tdb.h" +#include "lib/tdb/include/tdb.h" %} @@ -100,7 +100,8 @@ TDB_CONTEXT *tdb_open(const char *name, int hash_size, int tdb_flags, TDB_CONTEXT *tdb_open_ex(const char *name, int hash_size, int tdb_flags, int open_flags, mode_t mode, - tdb_log_func log_fn); + tdb_log_func log_fn, + tdb_hash_func hash_fn); int tdb_reopen(TDB_CONTEXT *tdb); int tdb_reopen_all(void); -- cgit From 5230295b6b927649cb304790f781fdff18fc162d Mon Sep 17 00:00:00 2001 From: Tim Potter Date: Sat, 4 Sep 2004 23:04:31 +0000 Subject: r2227: Get rid of annoying compiler warning. (This used to be commit 64f961f039545c9948eb7d7652b7494be2443174) --- source4/scripting/swig/tdb.i | 8 ++++++++ 1 file changed, 8 insertions(+) (limited to 'source4/scripting') diff --git a/source4/scripting/swig/tdb.i b/source4/scripting/swig/tdb.i index f4a3f53c4b..0c756765de 100644 --- a/source4/scripting/swig/tdb.i +++ b/source4/scripting/swig/tdb.i @@ -28,6 +28,13 @@ %{ +/* This symbol is used in both includes.h and Python.h which causes an + annoying compiler warning. */ + +#ifdef HAVE_FSTAT +#undef HAVE_FSTAT +#endif + /* The tdb_set_lock_alarm() function requires the SIG_ATOMIC_T function from includes.h */ @@ -44,6 +51,7 @@ typedef int SIG_ATOMIC_T; %} + /* The tdb functions will crash if a NULL tdb is passed */ %include exception.i -- cgit From 779b89cfc8e65b8e6a4ad2d868ab04f014a4bc20 Mon Sep 17 00:00:00 2001 From: Tim Potter Date: Sun, 5 Sep 2004 02:06:11 +0000 Subject: r2228: Finally commit bits of old workareas together to get dcerpc python bindings happening. This commit lets python call dcerpc_pipe_connect() and open the samr pipe. (This used to be commit f5852bf3e2064f03aa9b63af4aa1b4f9e39bdb24) --- source4/scripting/swig/dcerpc.i | 68 +++++++++++++++++++++++++++++++++++++++++ source4/scripting/swig/samba.i | 6 ++++ source4/scripting/swig/samr.i | 25 +++++++++++++++ 3 files changed, 99 insertions(+) create mode 100644 source4/scripting/swig/dcerpc.i create mode 100644 source4/scripting/swig/samr.i (limited to 'source4/scripting') diff --git a/source4/scripting/swig/dcerpc.i b/source4/scripting/swig/dcerpc.i new file mode 100644 index 0000000000..9ecc2702bb --- /dev/null +++ b/source4/scripting/swig/dcerpc.i @@ -0,0 +1,68 @@ +/* + Unix SMB/CIFS implementation. + + Swig interface to librpc functions. + + Copyright (C) Tim Potter 2004 + + 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 2 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, write to the Free Software + Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. +*/ + +%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" + +#undef strcpy + +%} + +%include "samba.i" + +%init %{ +/* setup_logging("python", DEBUG_STDOUT); */ + lp_load(dyn_CONFIGFILE, True, False, False); + load_interfaces(); +%} + +%typemap(in, numinputs=0) struct dcerpc_pipe **OUT (struct dcerpc_pipe *temp) { + $1 = &temp; +} + +%typemap(argout) struct dcerpc_pipe ** { + PyObject *o = PyTuple_New(2); + PyTuple_SetItem(o, 0, resultobj); + PyTuple_SetItem(o, 1, SWIG_NewPointerObj(*$1, SWIGTYPE_p_dcerpc_pipe, 0)); + resultobj = o; +} + +%types(struct dcerpc_pipe *); + +NTSTATUS dcerpc_pipe_connect(struct dcerpc_pipe **OUT, + const char *binding, + const char *pipe_uuid, + uint32 pipe_version, + const char *domain, + const char *username, + const char *password); +%include "samr.i" diff --git a/source4/scripting/swig/samba.i b/source4/scripting/swig/samba.i index 60f2efcc19..8e0eb88533 100644 --- a/source4/scripting/swig/samba.i +++ b/source4/scripting/swig/samba.i @@ -31,3 +31,9 @@ } $1 = (uint32_t)PyInt_AsLong($input); } + +/* For the moment treat NTSTATUS as an integer */ + +%typemap(out) NTSTATUS { + $result = PyInt_FromLong(NT_STATUS_V($1)); +} diff --git a/source4/scripting/swig/samr.i b/source4/scripting/swig/samr.i new file mode 100644 index 0000000000..ceb21db17a --- /dev/null +++ b/source4/scripting/swig/samr.i @@ -0,0 +1,25 @@ +/* + Unix SMB/CIFS implementation. + + Swig interface to librpc functions. + + Copyright (C) Tim Potter 2004 + + 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 2 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, write to the Free Software + Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. +*/ + +#define DCERPC_SAMR_UUID "12345778-1234-abcd-ef00-0123456789ac" +const int DCERPC_SAMR_VERSION = 1.0; +#define DCERPC_SAMR_NAME "samr" -- cgit From 86bf5cefa9798378ffb881a9a668c852fe56b2e2 Mon Sep 17 00:00:00 2001 From: Tim Potter Date: Sun, 5 Sep 2004 02:39:47 +0000 Subject: r2229: Have dcerpc_pipe_connect() throw an exception if non-zero NTSTATUS is returned from the C function. This way we can return the struct dcerpc_pipe object instead of a tuple of (NTSTATUS, dcerpc_pipe) which is a bad interface. (This used to be commit a3a85bd419e38f0dce138e67174517e23a361010) --- source4/scripting/swig/dcerpc.i | 26 ++++++++++++++++++++++---- 1 file changed, 22 insertions(+), 4 deletions(-) (limited to 'source4/scripting') diff --git a/source4/scripting/swig/dcerpc.i b/source4/scripting/swig/dcerpc.i index 9ecc2702bb..6130f85a60 100644 --- a/source4/scripting/swig/dcerpc.i +++ b/source4/scripting/swig/dcerpc.i @@ -35,6 +35,21 @@ #undef strcpy +PyObject *ntstatus_exception; + +/* Set up return of a dcerpc.NTSTATUS exception */ + +void set_ntstatus_exception(int status) +{ + PyObject *obj = PyTuple_New(2); + + PyTuple_SetItem(obj, 0, PyInt_FromLong(status)); + PyTuple_SetItem(obj, 1, + PyString_FromString(nt_errstr(NT_STATUS(status)))); + + PyErr_SetObject(ntstatus_exception, obj); +} + %} %include "samba.i" @@ -43,6 +58,7 @@ /* setup_logging("python", DEBUG_STDOUT); */ lp_load(dyn_CONFIGFILE, True, False, False); load_interfaces(); + ntstatus_exception = PyErr_NewException("dcerpc.NTSTATUS", NULL, NULL); %} %typemap(in, numinputs=0) struct dcerpc_pipe **OUT (struct dcerpc_pipe *temp) { @@ -50,10 +66,12 @@ } %typemap(argout) struct dcerpc_pipe ** { - PyObject *o = PyTuple_New(2); - PyTuple_SetItem(o, 0, resultobj); - PyTuple_SetItem(o, 1, SWIG_NewPointerObj(*$1, SWIGTYPE_p_dcerpc_pipe, 0)); - resultobj = o; + long status = PyLong_AsLong(resultobj); + if (status != 0) { + set_ntstatus_exception(status); + return NULL; + } + resultobj = SWIG_NewPointerObj(*$1, SWIGTYPE_p_dcerpc_pipe, 0); } %types(struct dcerpc_pipe *); -- cgit From 65b5a2297c766f5dcaf087800993554729aa6c69 Mon Sep 17 00:00:00 2001 From: Tim Potter Date: Sun, 5 Sep 2004 04:05:45 +0000 Subject: r2230: Wrapper for dcerpc_samr_Connect2(). All this glue code should be automatically generated but at the moment it's hand coded. (This used to be commit e1a368050d3abb6a6ca6529315dc4228e8590c7f) --- source4/scripting/swig/dcerpc.i | 28 ++++++++++++++++++++++++++-- source4/scripting/swig/samr.i | 13 +++++++++++++ 2 files changed, 39 insertions(+), 2 deletions(-) (limited to 'source4/scripting') diff --git a/source4/scripting/swig/dcerpc.i b/source4/scripting/swig/dcerpc.i index 6130f85a60..c843ec3c36 100644 --- a/source4/scripting/swig/dcerpc.i +++ b/source4/scripting/swig/dcerpc.i @@ -50,6 +50,26 @@ void set_ntstatus_exception(int status) PyErr_SetObject(ntstatus_exception, obj); } +char *get_string_property(PyObject *dict, char *key) +{ + PyObject *item = PyDict_GetItem(dict, PyString_FromString(key)); + + if (!item) + return 0; /* TODO: throw exception */ + + return PyString_AsString(item); +} + +uint32 get_uint32_property(PyObject *dict, char *key) +{ + PyObject *item = PyDict_GetItem(dict, PyString_FromString(key)); + + if (!item) + return 0; /* TODO: throw exception */ + + return (uint32)PyInt_AsLong(item); +} + %} %include "samba.i" @@ -61,8 +81,12 @@ void set_ntstatus_exception(int status) ntstatus_exception = PyErr_NewException("dcerpc.NTSTATUS", NULL, NULL); %} -%typemap(in, numinputs=0) struct dcerpc_pipe **OUT (struct dcerpc_pipe *temp) { - $1 = &temp; +%typemap(in, numinputs=0) struct dcerpc_pipe **OUT (struct dcerpc_pipe *temp_dcerpc_pipe) { + $1 = &temp_dcerpc_pipe; +} + +%typemap(in, numinputs=0) TALLOC_CTX * { + $1 = talloc_init("foo"); } %typemap(argout) struct dcerpc_pipe ** { diff --git a/source4/scripting/swig/samr.i b/source4/scripting/swig/samr.i index ceb21db17a..030f5defc2 100644 --- a/source4/scripting/swig/samr.i +++ b/source4/scripting/swig/samr.i @@ -23,3 +23,16 @@ #define DCERPC_SAMR_UUID "12345778-1234-abcd-ef00-0123456789ac" const int DCERPC_SAMR_VERSION = 1.0; #define DCERPC_SAMR_NAME "samr" + +%typemap(in) struct samr_Connect2 * (struct samr_Connect2 temp) { + if (!PyDict_Check($input)) { + PyErr_SetString(PyExc_TypeError, "dict arg expected"); + return NULL; + } + temp.in.system_name = get_string_property($input, "system_name"); + temp.in.access_mask = get_uint32_property($input, "access_mask"); + $1 = &temp; +} + +%rename(samr_Connect2) dcerpc_samr_Connect2; +NTSTATUS dcerpc_samr_Connect2(struct dcerpc_pipe *p, TALLOC_CTX *mem_ctx, struct samr_Connect2 *r); -- cgit From 0a3a76fe969fc56a033af1745374b90fd4aff6c7 Mon Sep 17 00:00:00 2001 From: Tim Potter Date: Mon, 6 Sep 2004 11:01:10 +0000 Subject: r2235: When creating exception data, use Py_BuildValue instead of doing it all by hand. Use $symname to name TALLOC_CTX's created in wrapper function. Also, make sure to free context afterwards. Set the DCERPC_NDR_REF_ALLOC flag in the dcerpc_pipe struct to save use lots of initialisation. (This used to be commit 5fead63618b5ee76cadc4719d933ea9cee7538b5) --- source4/scripting/swig/dcerpc.i | 24 ++++++++++++++++++------ 1 file changed, 18 insertions(+), 6 deletions(-) (limited to 'source4/scripting') diff --git a/source4/scripting/swig/dcerpc.i b/source4/scripting/swig/dcerpc.i index c843ec3c36..afa968a640 100644 --- a/source4/scripting/swig/dcerpc.i +++ b/source4/scripting/swig/dcerpc.i @@ -41,11 +41,8 @@ PyObject *ntstatus_exception; void set_ntstatus_exception(int status) { - PyObject *obj = PyTuple_New(2); - - PyTuple_SetItem(obj, 0, PyInt_FromLong(status)); - PyTuple_SetItem(obj, 1, - PyString_FromString(nt_errstr(NT_STATUS(status)))); + PyObject *obj = Py_BuildValue("(i,s)", status, + nt_errstr(NT_STATUS(status))); PyErr_SetObject(ntstatus_exception, obj); } @@ -86,15 +83,30 @@ uint32 get_uint32_property(PyObject *dict, char *key) } %typemap(in, numinputs=0) TALLOC_CTX * { - $1 = talloc_init("foo"); + $1 = talloc_init("$symname"); +} + +%typemap(freearg) TALLOC_CTX * { + talloc_free($1); } %typemap(argout) struct dcerpc_pipe ** { long status = PyLong_AsLong(resultobj); + + /* Throw exception if result was not OK */ + if (status != 0) { set_ntstatus_exception(status); return NULL; } + + /* Set REF_ALLOC flag so we don't have to do too much extra + mucking around with ref variables in ndr unmarshalling. */ + + (*$1)->flags |= DCERPC_NDR_REF_ALLOC; + + /* Return swig handle on dcerpc_pipe */ + resultobj = SWIG_NewPointerObj(*$1, SWIGTYPE_p_dcerpc_pipe, 0); } -- cgit From 68aad436e61fa0a429ee1aaf51f43e091f195fe5 Mon Sep 17 00:00:00 2001 From: Tim Potter Date: Mon, 6 Sep 2004 11:09:27 +0000 Subject: r2236: Zero request structure to let the REF_ALLOC flag work its magic. Add argout typemap which throws an exception if NTSTATUS != OK and creates a dictionary of return values. samr_Connect2 function now works! (This used to be commit fdfabbd4a597b0d9b44832fdbfc200f857728c2b) --- source4/scripting/swig/samr.i | 21 +++++++++++++++++++++ 1 file changed, 21 insertions(+) (limited to 'source4/scripting') diff --git a/source4/scripting/swig/samr.i b/source4/scripting/swig/samr.i index 030f5defc2..89144a29d0 100644 --- a/source4/scripting/swig/samr.i +++ b/source4/scripting/swig/samr.i @@ -29,10 +29,31 @@ const int DCERPC_SAMR_VERSION = 1.0; PyErr_SetString(PyExc_TypeError, "dict arg expected"); return NULL; } + memset(&temp, 0, sizeof(temp)); temp.in.system_name = get_string_property($input, "system_name"); temp.in.access_mask = get_uint32_property($input, "access_mask"); $1 = &temp; } +%typemap(argout) struct samr_Connect2 * { + long status = PyLong_AsLong(resultobj); + PyObject *dict; + + /* Throw exception if result was not OK */ + + if (status != 0) { + set_ntstatus_exception(status); + return NULL; + } + + dict = PyDict_New(); + + PyDict_SetItem(dict, PyString_FromString("handle"), + PyString_FromStringAndSize($1->out.handle, + sizeof(*($1->out.handle)))); + + resultobj = dict; +} + %rename(samr_Connect2) dcerpc_samr_Connect2; NTSTATUS dcerpc_samr_Connect2(struct dcerpc_pipe *p, TALLOC_CTX *mem_ctx, struct samr_Connect2 *r); -- cgit From 915f2e539d4b2f5f4eb87a1f64f50f3d9a17743a Mon Sep 17 00:00:00 2001 From: Tim Potter Date: Tue, 7 Sep 2004 23:12:29 +0000 Subject: r2243: Include definition for PRINTF_ATTRIBUTE in Python tdb wrapper. (This used to be commit 301bb069c31ee7ce09bdd6cd2dd4b7fa0441e1a1) --- source4/scripting/swig/tdb.i | 10 ++++++++++ 1 file changed, 10 insertions(+) (limited to 'source4/scripting') diff --git a/source4/scripting/swig/tdb.i b/source4/scripting/swig/tdb.i index 0c756765de..404f498c26 100644 --- a/source4/scripting/swig/tdb.i +++ b/source4/scripting/swig/tdb.i @@ -45,6 +45,16 @@ typedef sig_atomic_t SIG_ATOMIC_T; typedef int SIG_ATOMIC_T; #endif +#if (__GNUC__ >= 3) +/** Use gcc attribute to check printf fns. a1 is the 1-based index of + * the parameter containing the format, and a2 the index of the first + * argument. Note that some gcc 2.x versions don't handle this + * properly **/ +#define PRINTF_ATTRIBUTE(a1, a2) __attribute__ ((format (__printf__, a1, a2))) +#else +#define PRINTF_ATTRIBUTE(a1, a2) +#endif + /* Include tdb headers */ #include "lib/tdb/include/tdb.h" -- cgit From 3f7bf05f75c050c5132168b7eea6a346abfb482c Mon Sep 17 00:00:00 2001 From: Tim Potter Date: Wed, 8 Sep 2004 11:54:01 +0000 Subject: r2253: Add test program, as small example of what's going on. (This used to be commit fd31ae38dfe2d005b3e01ac059c2e15fa389aad4) --- source4/scripting/swig/dcerpc.i | 2 ++ source4/scripting/swig/test | 13 +++++++++++++ 2 files changed, 15 insertions(+) create mode 100755 source4/scripting/swig/test (limited to 'source4/scripting') diff --git a/source4/scripting/swig/dcerpc.i b/source4/scripting/swig/dcerpc.i index afa968a640..6769b4efc1 100644 --- a/source4/scripting/swig/dcerpc.i +++ b/source4/scripting/swig/dcerpc.i @@ -112,6 +112,8 @@ uint32 get_uint32_property(PyObject *dict, char *key) %types(struct dcerpc_pipe *); +%rename(pipe_connect) dcerpc_pipe_connect; + NTSTATUS dcerpc_pipe_connect(struct dcerpc_pipe **OUT, const char *binding, const char *pipe_uuid, diff --git a/source4/scripting/swig/test b/source4/scripting/swig/test new file mode 100755 index 0000000000..479f447860 --- /dev/null +++ b/source4/scripting/swig/test @@ -0,0 +1,13 @@ +#!/usr/bin/python + +import dcerpc +import gc +gc.set_debug(gc.DEBUG_LEAK) + +handle = dcerpc.pipe_connect("ncacn_np:win2k3dc", + dcerpc.DCERPC_SAMR_UUID, dcerpc.DCERPC_SAMR_VERSION, + "win2k3dom", "administrator", "penguin") + +connect = {"system_name": "win2k3dc", "access_mask": 12345} + +print dcerpc.samr_Connect2(handle, connect) -- cgit From ec952cde0501b15c5e14a3c06333f97dc77dc1f0 Mon Sep 17 00:00:00 2001 From: Tim Potter Date: Wed, 8 Sep 2004 12:56:57 +0000 Subject: r2256: Include autogenerated interfaces for lsa and samr pipes. Typemaps are currently not working though. (This used to be commit 55bd2dc02de13ee3da1cde20694f452df0899a9f) --- source4/scripting/swig/dcerpc.i | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) (limited to 'source4/scripting') diff --git a/source4/scripting/swig/dcerpc.i b/source4/scripting/swig/dcerpc.i index 6769b4efc1..5ace564359 100644 --- a/source4/scripting/swig/dcerpc.i +++ b/source4/scripting/swig/dcerpc.i @@ -121,4 +121,6 @@ NTSTATUS dcerpc_pipe_connect(struct dcerpc_pipe **OUT, const char *domain, const char *username, const char *password); -%include "samr.i" + +%include "librpc/gen_ndr/samr.i" +%include "librpc/gen_ndr/lsa.i" -- cgit From 91222c6029274623d8f595dbedfa06e5fa7830a8 Mon Sep 17 00:00:00 2001 From: Tim Potter Date: Fri, 10 Sep 2004 12:16:42 +0000 Subject: r2276: Remove garbage collection debugs. (This used to be commit b7ebafbbe0ada17748ad4bb36da4c0d63a2b10f5) --- source4/scripting/swig/test | 2 -- 1 file changed, 2 deletions(-) (limited to 'source4/scripting') diff --git a/source4/scripting/swig/test b/source4/scripting/swig/test index 479f447860..c3c5c3a82b 100755 --- a/source4/scripting/swig/test +++ b/source4/scripting/swig/test @@ -1,8 +1,6 @@ #!/usr/bin/python import dcerpc -import gc -gc.set_debug(gc.DEBUG_LEAK) handle = dcerpc.pipe_connect("ncacn_np:win2k3dc", dcerpc.DCERPC_SAMR_UUID, dcerpc.DCERPC_SAMR_VERSION, -- cgit From 56d7b0dc8af0339ba08458ecc64c91928fdf53a7 Mon Sep 17 00:00:00 2001 From: Tim Potter Date: Fri, 10 Sep 2004 12:20:25 +0000 Subject: r2278: Add some more helper functions. (This used to be commit 5a64449599beb7b46484f1c3aef10f7e7b878319) --- source4/scripting/swig/dcerpc.i | 50 ++++++++++++++++++++++++++++++++--------- 1 file changed, 40 insertions(+), 10 deletions(-) (limited to 'source4/scripting') diff --git a/source4/scripting/swig/dcerpc.i b/source4/scripting/swig/dcerpc.i index 5ace564359..10dc4721e6 100644 --- a/source4/scripting/swig/dcerpc.i +++ b/source4/scripting/swig/dcerpc.i @@ -47,24 +47,54 @@ void set_ntstatus_exception(int status) PyErr_SetObject(ntstatus_exception, obj); } -char *get_string_property(PyObject *dict, char *key) +uint8 uint8_from_python(PyObject *obj) { - PyObject *item = PyDict_GetItem(dict, PyString_FromString(key)); + return (uint8)PyInt_AsLong(obj); +} + +uint16 uint16_from_python(PyObject *obj) +{ + return (uint16)PyInt_AsLong(obj); +} + +uint32 uint32_from_python(PyObject *obj) +{ + return (uint32)PyInt_AsLong(obj); +} + +int64 int64_from_python(PyObject *obj) +{ + return (int64)PyLong_AsLong(obj); +} - if (!item) - return 0; /* TODO: throw exception */ +uint64 uint64_from_python(PyObject *obj) +{ + return (uint64)PyLong_AsLong(obj); +} + +NTTIME NTTIME_from_python(PyObject *obj) +{ + return (NTTIME)PyLong_AsLong(obj); +} - return PyString_AsString(item); +HYPER_T HYPER_T_from_python(PyObject *obj) +{ + return (HYPER_T)PyLong_AsLong(obj); } -uint32 get_uint32_property(PyObject *dict, char *key) +struct policy_handle *policy_handle_from_python(PyObject *obj) { - PyObject *item = PyDict_GetItem(dict, PyString_FromString(key)); + return (struct policy_handle *)PyString_AsString(obj); +} - if (!item) - return 0; /* TODO: throw exception */ +struct security_descriptor *security_descriptor_from_python(PyObject *obj) +{ + return NULL; +} - return (uint32)PyInt_AsLong(item); +char *string_from_python(PyObject *obj) +{ + return NULL; } %} -- cgit From b5119cd6629e1fd5d52161253c16d3bf79d13df8 Mon Sep 17 00:00:00 2001 From: Tim Potter Date: Sun, 12 Sep 2004 10:13:24 +0000 Subject: r2295: Convert simple scalar types and policy handles between dcerpc function call request and response structures. (This used to be commit d31d23b944b7e4ef300d75dad5038727e9133af1) --- source4/scripting/swig/dcerpc.i | 40 ++++++++++++++++++++++++++++++++++++++++ 1 file changed, 40 insertions(+) (limited to 'source4/scripting') diff --git a/source4/scripting/swig/dcerpc.i b/source4/scripting/swig/dcerpc.i index 10dc4721e6..fb4870d819 100644 --- a/source4/scripting/swig/dcerpc.i +++ b/source4/scripting/swig/dcerpc.i @@ -52,41 +52,81 @@ uint8 uint8_from_python(PyObject *obj) return (uint8)PyInt_AsLong(obj); } +PyObject *uint8_to_python(uint8 obj) +{ + return PyInt_FromLong(obj); +} + uint16 uint16_from_python(PyObject *obj) { return (uint16)PyInt_AsLong(obj); } +PyObject *uint16_to_python(uint16 obj) +{ + return PyInt_FromLong(obj); +} + uint32 uint32_from_python(PyObject *obj) { return (uint32)PyInt_AsLong(obj); } +PyObject *uint32_to_python(uint32 obj) +{ + return PyInt_FromLong(obj); +} + int64 int64_from_python(PyObject *obj) { return (int64)PyLong_AsLong(obj); } +PyObject *int64_to_python(int64 obj) +{ + return PyLong_FromLong(obj); +} + uint64 uint64_from_python(PyObject *obj) { return (uint64)PyLong_AsLong(obj); } +PyObject *uint64_to_python(uint64 obj) +{ + return PyLong_FromLong(obj); +} + NTTIME NTTIME_from_python(PyObject *obj) { return (NTTIME)PyLong_AsLong(obj); } +PyObject *NTTIME_to_python(NTTIME obj) +{ + return PyLong_FromLong(obj); +} + HYPER_T HYPER_T_from_python(PyObject *obj) { return (HYPER_T)PyLong_AsLong(obj); } +PyObject *HYPER_T_to_python(HYPER_T obj) +{ + return PyLong_FromLong(obj); +} + struct policy_handle *policy_handle_from_python(PyObject *obj) { return (struct policy_handle *)PyString_AsString(obj); } +PyObject *policy_handle_to_python(struct policy_handle *handle) +{ + return PyString_FromStringAndSize((char *)handle, sizeof(*handle)); +} + struct security_descriptor *security_descriptor_from_python(PyObject *obj) { return NULL; -- cgit From 4c017a95294b6745ea90692168066dad256995c7 Mon Sep 17 00:00:00 2001 From: Tim Potter Date: Sun, 12 Sep 2004 10:49:41 +0000 Subject: r2296: Correct setting of access_mask in test program. (This used to be commit e4a5840ff84553c67c87e002e9e074095f4d18c5) --- source4/scripting/swig/test | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'source4/scripting') diff --git a/source4/scripting/swig/test b/source4/scripting/swig/test index c3c5c3a82b..f90cef747f 100755 --- a/source4/scripting/swig/test +++ b/source4/scripting/swig/test @@ -6,6 +6,6 @@ handle = dcerpc.pipe_connect("ncacn_np:win2k3dc", dcerpc.DCERPC_SAMR_UUID, dcerpc.DCERPC_SAMR_VERSION, "win2k3dom", "administrator", "penguin") -connect = {"system_name": "win2k3dc", "access_mask": 12345} +connect = {"system_name": "win2k3dc", "access_mask": 0x02000000} print dcerpc.samr_Connect2(handle, connect) -- cgit From 23492b303309327bc84788432f2a2cd4e99ef093 Mon Sep 17 00:00:00 2001 From: Tim Potter Date: Sun, 12 Sep 2004 10:50:23 +0000 Subject: r2297: Add string conversion functions. (This used to be commit cbfb177394aaf2a382b481ffb3152ad3fe81de5a) --- source4/scripting/swig/dcerpc.i | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) (limited to 'source4/scripting') diff --git a/source4/scripting/swig/dcerpc.i b/source4/scripting/swig/dcerpc.i index fb4870d819..10c20d201f 100644 --- a/source4/scripting/swig/dcerpc.i +++ b/source4/scripting/swig/dcerpc.i @@ -134,7 +134,12 @@ struct security_descriptor *security_descriptor_from_python(PyObject *obj) char *string_from_python(PyObject *obj) { - return NULL; + return PyString_AsString(obj); +} + +PyObject *string_to_python(char *obj) +{ + return PyString_FromString(obj); } %} -- cgit From a34ddd04ca89c4bff68dbfb873dcc1dfdbc096ef Mon Sep 17 00:00:00 2001 From: Tim Potter Date: Sun, 12 Sep 2004 11:45:37 +0000 Subject: r2299: Map a (C) NULL pointer to (Python) None and vice versa. (This used to be commit 05cff58070b7070157aea47c5da8512145c2774a) --- source4/scripting/swig/dcerpc.i | 6 ++++++ 1 file changed, 6 insertions(+) (limited to 'source4/scripting') diff --git a/source4/scripting/swig/dcerpc.i b/source4/scripting/swig/dcerpc.i index 10c20d201f..9d5e9f295d 100644 --- a/source4/scripting/swig/dcerpc.i +++ b/source4/scripting/swig/dcerpc.i @@ -134,11 +134,17 @@ struct security_descriptor *security_descriptor_from_python(PyObject *obj) char *string_from_python(PyObject *obj) { + if (obj == Py_None) + return NULL; + return PyString_AsString(obj); } PyObject *string_to_python(char *obj) { + if (obj == NULL) + return Py_None; + return PyString_FromString(obj); } -- cgit From 984e71e5e51bb7b7abc390f95691affa2d9c0f33 Mon Sep 17 00:00:00 2001 From: Tim Potter Date: Sun, 12 Sep 2004 11:47:24 +0000 Subject: r2300: Start writing a Python torture test suite based on the smbtorture rpc tests. (This used to be commit 73e087f11e401ef8da7c53148444b2745a94dbaf) --- source4/scripting/swig/test | 11 ------- source4/scripting/swig/torture/samr.py | 52 ++++++++++++++++++++++++++++++++++ 2 files changed, 52 insertions(+), 11 deletions(-) delete mode 100755 source4/scripting/swig/test create mode 100755 source4/scripting/swig/torture/samr.py (limited to 'source4/scripting') diff --git a/source4/scripting/swig/test b/source4/scripting/swig/test deleted file mode 100755 index f90cef747f..0000000000 --- a/source4/scripting/swig/test +++ /dev/null @@ -1,11 +0,0 @@ -#!/usr/bin/python - -import dcerpc - -handle = dcerpc.pipe_connect("ncacn_np:win2k3dc", - dcerpc.DCERPC_SAMR_UUID, dcerpc.DCERPC_SAMR_VERSION, - "win2k3dom", "administrator", "penguin") - -connect = {"system_name": "win2k3dc", "access_mask": 0x02000000} - -print dcerpc.samr_Connect2(handle, connect) diff --git a/source4/scripting/swig/torture/samr.py b/source4/scripting/swig/torture/samr.py new file mode 100755 index 0000000000..d7edbbcef5 --- /dev/null +++ b/source4/scripting/swig/torture/samr.py @@ -0,0 +1,52 @@ +#!/usr/bin/python + +import dcerpc + +def test_Connect(handle): + + print 'testing samr_Connect' + + r = {} + r['system_name'] = '\0\0' + r['access_mask'] = 0x02000000 + + result = dcerpc.samr_Connect(pipe, r) + + dcerpc.samr_Close(pipe, result) + + print 'testing samr_Connect2' + + r = {} + r['system_name'] = None + r['access_mask'] = 0x02000000 + + result = dcerpc.samr_Connect2(pipe, r) + dcerpc.samr_Close(pipe, result) + + print 'testing samr_Connect3' + + r = {} + r['system_name'] = None + r['unknown'] = 0 + r['access_mask'] = 0x02000000 + + result = dcerpc.samr_Connect3(pipe, r) + dcerpc.samr_Close(pipe, result) + + print 'testing samr_Connect4' + + r = {} + r['system_name'] = None + r['unknown'] = 0 + r['access_mask'] = 0x02000000 + + result = dcerpc.samr_Connect4(pipe, r) + dcerpc.samr_Close(pipe, result) + +# Connect to server + +pipe = dcerpc.pipe_connect('ncacn_np:win2k3dc', + dcerpc.DCERPC_SAMR_UUID, dcerpc.DCERPC_SAMR_VERSION, + 'win2k3dom', 'administrator', 'penguin') + +test_Connect(pipe) -- cgit From 12b29d8bb7e0b984dc51644763cd544dbe350172 Mon Sep 17 00:00:00 2001 From: Tim Potter Date: Mon, 13 Sep 2004 12:42:25 +0000 Subject: r2324: Add hand-written versions of functions from misc.idl. (This used to be commit d6876701cc027ec2b14923e3483e0432e7011138) --- source4/scripting/swig/dcerpc.i | 27 ++++++++++++++++++++++++++- 1 file changed, 26 insertions(+), 1 deletion(-) (limited to 'source4/scripting') diff --git a/source4/scripting/swig/dcerpc.i b/source4/scripting/swig/dcerpc.i index 9d5e9f295d..6ad8f8b631 100644 --- a/source4/scripting/swig/dcerpc.i +++ b/source4/scripting/swig/dcerpc.i @@ -127,11 +127,26 @@ PyObject *policy_handle_to_python(struct policy_handle *handle) return PyString_FromStringAndSize((char *)handle, sizeof(*handle)); } -struct security_descriptor *security_descriptor_from_python(PyObject *obj) +struct security_descriptor *security_descriptor_from_python(TALLOC_CTX *mem_ctx, PyObject *obj) { return NULL; } +PyObject *security_descriptor_to_python(struct security_descriptor *obj) +{ + return Py_None; +} + +struct dom_sid2 *dom_sid2_from_python(TALLOC_CTX *mem_ctx, PyObject *obj) +{ + return NULL; +} + +PyObject *dom_sid2_to_python(struct dom_sid2 *obj) +{ + return Py_None; +} + char *string_from_python(PyObject *obj) { if (obj == Py_None) @@ -148,6 +163,16 @@ PyObject *string_to_python(char *obj) return PyString_FromString(obj); } +struct samr_Password *samr_Password_from_python(TALLOC_CTX *mem_ctx, PyObject *obj) +{ + return NULL; +} + +PyObject *samr_Password_to_python(struct samr_Password *obj) +{ + return NULL; +} + %} %include "samba.i" -- cgit From 31288d654552736ee96a0c7edbbc0b0cdcf1a3f5 Mon Sep 17 00:00:00 2001 From: Tim Potter Date: Tue, 14 Sep 2004 12:19:59 +0000 Subject: r2336: Add another conversion function to allow union arms that contain structures not pointers to structures. Do some renaming of hand-written functions as a result. Include lsa interface before samr interface as samr depends on some lsa structures. Build up a nice hashed index of interfaces, functions, structs and unions. Add test for samr_Connect5() function which contains a union. (This used to be commit 30f068164a5125f84a34f28ed0f2586a2bdec7e4) --- source4/scripting/swig/dcerpc.i | 8 ++++---- source4/scripting/swig/torture/samr.py | 13 +++++++++++++ 2 files changed, 17 insertions(+), 4 deletions(-) (limited to 'source4/scripting') diff --git a/source4/scripting/swig/dcerpc.i b/source4/scripting/swig/dcerpc.i index 6ad8f8b631..7679b773f4 100644 --- a/source4/scripting/swig/dcerpc.i +++ b/source4/scripting/swig/dcerpc.i @@ -127,7 +127,7 @@ PyObject *policy_handle_to_python(struct policy_handle *handle) return PyString_FromStringAndSize((char *)handle, sizeof(*handle)); } -struct security_descriptor *security_descriptor_from_python(TALLOC_CTX *mem_ctx, PyObject *obj) +struct security_descriptor *security_descriptor_ptr_from_python(TALLOC_CTX *mem_ctx, PyObject *obj) { return NULL; } @@ -137,7 +137,7 @@ PyObject *security_descriptor_to_python(struct security_descriptor *obj) return Py_None; } -struct dom_sid2 *dom_sid2_from_python(TALLOC_CTX *mem_ctx, PyObject *obj) +struct dom_sid2 *dom_sid2_ptr_from_python(TALLOC_CTX *mem_ctx, PyObject *obj) { return NULL; } @@ -163,7 +163,7 @@ PyObject *string_to_python(char *obj) return PyString_FromString(obj); } -struct samr_Password *samr_Password_from_python(TALLOC_CTX *mem_ctx, PyObject *obj) +struct samr_Password *samr_Password_ptr_from_python(TALLOC_CTX *mem_ctx, PyObject *obj) { return NULL; } @@ -228,5 +228,5 @@ NTSTATUS dcerpc_pipe_connect(struct dcerpc_pipe **OUT, const char *username, const char *password); -%include "librpc/gen_ndr/samr.i" %include "librpc/gen_ndr/lsa.i" +%include "librpc/gen_ndr/samr.i" diff --git a/source4/scripting/swig/torture/samr.py b/source4/scripting/swig/torture/samr.py index d7edbbcef5..ca9c7e9597 100755 --- a/source4/scripting/swig/torture/samr.py +++ b/source4/scripting/swig/torture/samr.py @@ -42,6 +42,19 @@ def test_Connect(handle): result = dcerpc.samr_Connect4(pipe, r) dcerpc.samr_Close(pipe, result) + + print 'testing samr_Connect5' + + r = {} + r['system_name'] = None + r['access_mask'] = 0x02000000 + r['level'] = 1 + r['info'] = {} + r['info']['info1'] = {} + r['info']['info1']['unknown1'] = 0 + r['info']['info1']['unknown2'] = 0 + + result = dcerpc.samr_Connect5(pipe, r) # Connect to server -- cgit From d97f808cb695886f1fefc6c58b2b955fc78302b9 Mon Sep 17 00:00:00 2001 From: Andrew Tridgell Date: Wed, 15 Sep 2004 04:36:13 +0000 Subject: r2339: my first python commit! added command line options for binding string, domain, username and password (This used to be commit e94bec1079f266fdb869642eab24f542a81f8e5a) --- source4/scripting/swig/torture/samr.py | 30 +++++++++++++++++++++++++++--- 1 file changed, 27 insertions(+), 3 deletions(-) (limited to 'source4/scripting') diff --git a/source4/scripting/swig/torture/samr.py b/source4/scripting/swig/torture/samr.py index ca9c7e9597..91b612dd72 100755 --- a/source4/scripting/swig/torture/samr.py +++ b/source4/scripting/swig/torture/samr.py @@ -1,6 +1,7 @@ #!/usr/bin/python import dcerpc +from optparse import OptionParser def test_Connect(handle): @@ -55,11 +56,34 @@ def test_Connect(handle): r['info']['info1']['unknown2'] = 0 result = dcerpc.samr_Connect5(pipe, r) - + + print result + +# parse command line +parser = OptionParser() +parser.add_option("-b", "--binding", action="store", type="string", dest="binding") +parser.add_option("-d", "--domain", action="store", type="string", dest="domain") +parser.add_option("-u", "--username", action="store", type="string", dest="username") +parser.add_option("-p", "--password", action="store", type="string", dest="password") + +(options, args) = parser.parse_args() + +if not options.binding: + parser.error('You must supply a binding string') + +if not options.username or not options.password or not options.domain: + parser.error('You must supply a domain, username and password') + + +binding=options.binding +domain=options.domain +username=options.username +password=options.password + # Connect to server -pipe = dcerpc.pipe_connect('ncacn_np:win2k3dc', +pipe = dcerpc.pipe_connect(binding, dcerpc.DCERPC_SAMR_UUID, dcerpc.DCERPC_SAMR_VERSION, - 'win2k3dom', 'administrator', 'penguin') + domain, username, password) test_Connect(pipe) -- cgit From 8d14c2a39fea4e5763728cc45d9339b92893dbba Mon Sep 17 00:00:00 2001 From: Tim Potter Date: Wed, 15 Sep 2004 12:12:48 +0000 Subject: r2342: Remove obsolete file. (This used to be commit b7ef3d0a006ab8c07354ca83fcaf6018c3b595af) --- source4/scripting/swig/samr.i | 59 ------------------------------------------- 1 file changed, 59 deletions(-) delete mode 100644 source4/scripting/swig/samr.i (limited to 'source4/scripting') diff --git a/source4/scripting/swig/samr.i b/source4/scripting/swig/samr.i deleted file mode 100644 index 89144a29d0..0000000000 --- a/source4/scripting/swig/samr.i +++ /dev/null @@ -1,59 +0,0 @@ -/* - Unix SMB/CIFS implementation. - - Swig interface to librpc functions. - - Copyright (C) Tim Potter 2004 - - 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 2 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, write to the Free Software - Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. -*/ - -#define DCERPC_SAMR_UUID "12345778-1234-abcd-ef00-0123456789ac" -const int DCERPC_SAMR_VERSION = 1.0; -#define DCERPC_SAMR_NAME "samr" - -%typemap(in) struct samr_Connect2 * (struct samr_Connect2 temp) { - if (!PyDict_Check($input)) { - PyErr_SetString(PyExc_TypeError, "dict arg expected"); - return NULL; - } - memset(&temp, 0, sizeof(temp)); - temp.in.system_name = get_string_property($input, "system_name"); - temp.in.access_mask = get_uint32_property($input, "access_mask"); - $1 = &temp; -} - -%typemap(argout) struct samr_Connect2 * { - long status = PyLong_AsLong(resultobj); - PyObject *dict; - - /* Throw exception if result was not OK */ - - if (status != 0) { - set_ntstatus_exception(status); - return NULL; - } - - dict = PyDict_New(); - - PyDict_SetItem(dict, PyString_FromString("handle"), - PyString_FromStringAndSize($1->out.handle, - sizeof(*($1->out.handle)))); - - resultobj = dict; -} - -%rename(samr_Connect2) dcerpc_samr_Connect2; -NTSTATUS dcerpc_samr_Connect2(struct dcerpc_pipe *p, TALLOC_CTX *mem_ctx, struct samr_Connect2 *r); -- cgit From 2cfd0b654c693ef90b54cf309f816ed62c94b545 Mon Sep 17 00:00:00 2001 From: Tim Potter Date: Wed, 15 Sep 2004 12:24:53 +0000 Subject: r2344: Return PyDict_New() in stub functions instead of Py_None to avoid crashing in garbage collector (hmm - all that was required was probably a Py_INCREF(Py_None) though). (This used to be commit a3eac318a624d214084741839faa2ad485902f6f) --- source4/scripting/swig/dcerpc.i | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'source4/scripting') diff --git a/source4/scripting/swig/dcerpc.i b/source4/scripting/swig/dcerpc.i index 7679b773f4..75b078ad16 100644 --- a/source4/scripting/swig/dcerpc.i +++ b/source4/scripting/swig/dcerpc.i @@ -134,7 +134,7 @@ struct security_descriptor *security_descriptor_ptr_from_python(TALLOC_CTX *mem_ PyObject *security_descriptor_to_python(struct security_descriptor *obj) { - return Py_None; + return PyDict_New(); } struct dom_sid2 *dom_sid2_ptr_from_python(TALLOC_CTX *mem_ctx, PyObject *obj) @@ -144,7 +144,7 @@ struct dom_sid2 *dom_sid2_ptr_from_python(TALLOC_CTX *mem_ctx, PyObject *obj) PyObject *dom_sid2_to_python(struct dom_sid2 *obj) { - return Py_None; + return PyDict_New(); } char *string_from_python(PyObject *obj) -- cgit From 3791d88b87c490c5093c964ec71989ee62b1faa4 Mon Sep 17 00:00:00 2001 From: Tim Potter Date: Wed, 15 Sep 2004 12:25:51 +0000 Subject: r2345: Add test for samr_QuerySecurity() (This used to be commit f6978a007a79c97910856b3c639844495f16ebab) --- source4/scripting/swig/torture/samr.py | 47 +++++++++++++++++++++++++--------- 1 file changed, 35 insertions(+), 12 deletions(-) (limited to 'source4/scripting') diff --git a/source4/scripting/swig/torture/samr.py b/source4/scripting/swig/torture/samr.py index 91b612dd72..e7ee4e8796 100755 --- a/source4/scripting/swig/torture/samr.py +++ b/source4/scripting/swig/torture/samr.py @@ -57,14 +57,34 @@ def test_Connect(handle): result = dcerpc.samr_Connect5(pipe, r) - print result + return result['handle'] + +def test_QuerySecurity(pipe, handle): + + print 'testing samr_QuerySecurity' + + r = {} + r['handle'] = handle + r['sec_info'] = 7 + + result = dcerpc.samr_QuerySecurity(pipe, r) + print result + +# Parse command line -# parse command line parser = OptionParser() -parser.add_option("-b", "--binding", action="store", type="string", dest="binding") -parser.add_option("-d", "--domain", action="store", type="string", dest="domain") -parser.add_option("-u", "--username", action="store", type="string", dest="username") -parser.add_option("-p", "--password", action="store", type="string", dest="password") + +parser.add_option("-b", "--binding", action="store", type="string", + dest="binding") + +parser.add_option("-d", "--domain", action="store", type="string", + dest="domain") + +parser.add_option("-u", "--username", action="store", type="string", + dest="username") + +parser.add_option("-p", "--password", action="store", type="string", + dest="password") (options, args) = parser.parse_args() @@ -75,15 +95,18 @@ if not options.username or not options.password or not options.domain: parser.error('You must supply a domain, username and password') -binding=options.binding -domain=options.domain -username=options.username -password=options.password +binding = options.binding +domain = options.domain +username = options.username +password = options.password -# Connect to server +print 'Connecting...' pipe = dcerpc.pipe_connect(binding, dcerpc.DCERPC_SAMR_UUID, dcerpc.DCERPC_SAMR_VERSION, domain, username, password) -test_Connect(pipe) +handle = test_Connect(pipe) +test_QuerySecurity(pipe, handle) + +print 'Done' -- cgit From dabb37c547dd44a5eb0b11c516208d4416c6655f Mon Sep 17 00:00:00 2001 From: Tim Potter Date: Wed, 15 Sep 2004 21:17:26 +0000 Subject: r2357: Start coding conversion routines for security descriptors, acls and sids. (This used to be commit c8d13a809b5b01823a62e5868bac47e1f2f25092) --- source4/scripting/swig/dcerpc.i | 59 ++++++++++++++++++++++++++++++++++++++--- 1 file changed, 56 insertions(+), 3 deletions(-) (limited to 'source4/scripting') diff --git a/source4/scripting/swig/dcerpc.i b/source4/scripting/swig/dcerpc.i index 75b078ad16..ea7b3d79a2 100644 --- a/source4/scripting/swig/dcerpc.i +++ b/source4/scripting/swig/dcerpc.i @@ -132,9 +132,62 @@ struct security_descriptor *security_descriptor_ptr_from_python(TALLOC_CTX *mem_ return NULL; } -PyObject *security_descriptor_to_python(struct security_descriptor *obj) +PyObject *dom_sid_to_python(struct dom_sid *obj) { - return PyDict_New(); + return PyString_FromString(""); +} + +PyObject *security_acl_to_python(struct security_acl *obj) +{ + PyObject *result = PyDict_New(); + PyObject *ace_list; + int i; + + if (!obj) { + Py_INCREF(Py_None); + return Py_None; + } + + PyDict_SetItem(result, PyString_FromString("revision"), PyInt_FromLong(obj->revision)); + PyDict_SetItem(result, PyString_FromString("size"), PyInt_FromLong(obj->size)); + + ace_list = PyList_New(obj->num_aces); + + for(i = 0; i < obj->num_aces; i++) { + PyObject *ace = PyDict_New(); + + PyDict_SetItem(ace, PyString_FromString("type"), PyInt_FromLong(obj->aces[i].type)); + PyDict_SetItem(ace, PyString_FromString("flags"), PyInt_FromLong(obj->aces[i].flags)); + PyDict_SetItem(ace, PyString_FromString("access_mask"), PyInt_FromLong(obj->aces[i].access_mask)); + PyDict_SetItem(ace, PyString_FromString("trustee"), dom_sid_to_python(&obj->aces[i].trustee)); + + PyList_SetItem(ace_list, i, ace); + } + + PyDict_SetItem(result, PyString_FromString("aces"), ace_list); + + return result; +} + +PyObject *security_descriptor_to_python(TALLOC_CTX *mem_ctx, struct security_descriptor *obj) +{ + PyObject *result = PyDict_New(); + + if (!obj) { + Py_INCREF(Py_None); + return Py_None; + } + + PyDict_SetItem(result, PyString_FromString("revision"), PyInt_FromLong(obj->revision)); + PyDict_SetItem(result, PyString_FromString("type"), PyInt_FromLong(obj->type)); + + PyDict_SetItem(result, PyString_FromString("owner_sid"), dom_sid_to_python(obj->owner_sid)); + PyDict_SetItem(result, PyString_FromString("group_sid"), dom_sid_to_python(obj->group_sid)); + + PyDict_SetItem(result, PyString_FromString("sacl"), security_acl_to_python(obj->sacl)); + PyDict_SetItem(result, PyString_FromString("dacl"), security_acl_to_python(obj->dacl)); + + return result; } struct dom_sid2 *dom_sid2_ptr_from_python(TALLOC_CTX *mem_ctx, PyObject *obj) @@ -142,7 +195,7 @@ struct dom_sid2 *dom_sid2_ptr_from_python(TALLOC_CTX *mem_ctx, PyObject *obj) return NULL; } -PyObject *dom_sid2_to_python(struct dom_sid2 *obj) +PyObject *dom_sid2_to_python(TALLOC_CTX *mem_ctx, struct dom_sid2 *obj) { return PyDict_New(); } -- cgit From aa60dc1630c1e28d4e60af9d04ea77477d0f7921 Mon Sep 17 00:00:00 2001 From: Tim Potter Date: Wed, 15 Sep 2004 22:03:53 +0000 Subject: r2358: More renaming of functions to keep things consistent. (This used to be commit 84513e4ed14e60b4cd09fcc2e596bc72d3a8807c) --- source4/scripting/swig/dcerpc.i | 69 +++++++++++++++++++++++------------------ 1 file changed, 39 insertions(+), 30 deletions(-) (limited to 'source4/scripting') diff --git a/source4/scripting/swig/dcerpc.i b/source4/scripting/swig/dcerpc.i index ea7b3d79a2..169cc6404a 100644 --- a/source4/scripting/swig/dcerpc.i +++ b/source4/scripting/swig/dcerpc.i @@ -47,6 +47,8 @@ void set_ntstatus_exception(int status) PyErr_SetObject(ntstatus_exception, obj); } +/* Conversion functions for scalar types */ + uint8 uint8_from_python(PyObject *obj) { return (uint8)PyInt_AsLong(obj); @@ -117,12 +119,33 @@ PyObject *HYPER_T_to_python(HYPER_T obj) return PyLong_FromLong(obj); } -struct policy_handle *policy_handle_from_python(PyObject *obj) +/* Conversion functions for types that we don't want generated automatically. + This is mostly security realted stuff in misc.idl */ + +char *string_ptr_from_python(PyObject *obj) +{ + if (obj == Py_None) + return NULL; + + return PyString_AsString(obj); +} + +PyObject *string_ptr_to_python(char *obj) +{ + if (obj == NULL) { + Py_INCREF(Py_None); + return Py_None; + } + + return PyString_FromString(obj); +} + +struct policy_handle *policy_handle_ptr_from_python(PyObject *obj) { return (struct policy_handle *)PyString_AsString(obj); } -PyObject *policy_handle_to_python(struct policy_handle *handle) +PyObject *policy_handle_ptr_to_python(struct policy_handle *handle) { return PyString_FromStringAndSize((char *)handle, sizeof(*handle)); } @@ -132,12 +155,12 @@ struct security_descriptor *security_descriptor_ptr_from_python(TALLOC_CTX *mem_ return NULL; } -PyObject *dom_sid_to_python(struct dom_sid *obj) +PyObject *dom_sid_ptr_to_python(struct dom_sid *obj) { return PyString_FromString(""); } -PyObject *security_acl_to_python(struct security_acl *obj) +PyObject *security_acl_ptr_to_python(struct security_acl *obj) { PyObject *result = PyDict_New(); PyObject *ace_list; @@ -159,7 +182,7 @@ PyObject *security_acl_to_python(struct security_acl *obj) PyDict_SetItem(ace, PyString_FromString("type"), PyInt_FromLong(obj->aces[i].type)); PyDict_SetItem(ace, PyString_FromString("flags"), PyInt_FromLong(obj->aces[i].flags)); PyDict_SetItem(ace, PyString_FromString("access_mask"), PyInt_FromLong(obj->aces[i].access_mask)); - PyDict_SetItem(ace, PyString_FromString("trustee"), dom_sid_to_python(&obj->aces[i].trustee)); + PyDict_SetItem(ace, PyString_FromString("trustee"), dom_sid_ptr_to_python(&obj->aces[i].trustee)); PyList_SetItem(ace_list, i, ace); } @@ -169,7 +192,7 @@ PyObject *security_acl_to_python(struct security_acl *obj) return result; } -PyObject *security_descriptor_to_python(TALLOC_CTX *mem_ctx, struct security_descriptor *obj) +PyObject *security_descriptor_ptr_to_python(TALLOC_CTX *mem_ctx, struct security_descriptor *obj) { PyObject *result = PyDict_New(); @@ -181,11 +204,11 @@ PyObject *security_descriptor_to_python(TALLOC_CTX *mem_ctx, struct security_des PyDict_SetItem(result, PyString_FromString("revision"), PyInt_FromLong(obj->revision)); PyDict_SetItem(result, PyString_FromString("type"), PyInt_FromLong(obj->type)); - PyDict_SetItem(result, PyString_FromString("owner_sid"), dom_sid_to_python(obj->owner_sid)); - PyDict_SetItem(result, PyString_FromString("group_sid"), dom_sid_to_python(obj->group_sid)); + PyDict_SetItem(result, PyString_FromString("owner_sid"), dom_sid_ptr_to_python(obj->owner_sid)); + PyDict_SetItem(result, PyString_FromString("group_sid"), dom_sid_ptr_to_python(obj->group_sid)); - PyDict_SetItem(result, PyString_FromString("sacl"), security_acl_to_python(obj->sacl)); - PyDict_SetItem(result, PyString_FromString("dacl"), security_acl_to_python(obj->dacl)); + PyDict_SetItem(result, PyString_FromString("sacl"), security_acl_ptr_to_python(obj->sacl)); + PyDict_SetItem(result, PyString_FromString("dacl"), security_acl_ptr_to_python(obj->dacl)); return result; } @@ -195,25 +218,10 @@ struct dom_sid2 *dom_sid2_ptr_from_python(TALLOC_CTX *mem_ctx, PyObject *obj) return NULL; } -PyObject *dom_sid2_to_python(TALLOC_CTX *mem_ctx, struct dom_sid2 *obj) -{ - return PyDict_New(); -} - -char *string_from_python(PyObject *obj) +PyObject *dom_sid2_ptr_to_python(TALLOC_CTX *mem_ctx, struct dom_sid2 *obj) { - if (obj == Py_None) - return NULL; - - return PyString_AsString(obj); -} - -PyObject *string_to_python(char *obj) -{ - if (obj == NULL) - return Py_None; - - return PyString_FromString(obj); + Py_INCREF(Py_None); + return Py_None; } struct samr_Password *samr_Password_ptr_from_python(TALLOC_CTX *mem_ctx, PyObject *obj) @@ -221,9 +229,10 @@ struct samr_Password *samr_Password_ptr_from_python(TALLOC_CTX *mem_ctx, PyObjec return NULL; } -PyObject *samr_Password_to_python(struct samr_Password *obj) +PyObject *samr_Password_ptr_to_python(struct samr_Password *obj) { - return NULL; + Py_INCREF(Py_None); + return Py_None; } %} -- cgit From d46b1885607dd85cfe3538ed92d4ad43c86e381b Mon Sep 17 00:00:00 2001 From: Tim Potter Date: Wed, 15 Sep 2004 22:35:15 +0000 Subject: r2359: More consistency fixes: pass a talloc context to every function that doesn't convert scalar types, more renaming of function names. Implement conversion fns for dom_sid, dom_sid2 (to struct version stubbed out). Also from Python conversions for security_acl and security_descriptors. (This used to be commit 945a4681051132c13f9235f676464fffb3bfadc8) --- source4/scripting/swig/dcerpc.i | 83 ++++++++++++++++++++++++++++++----------- 1 file changed, 61 insertions(+), 22 deletions(-) (limited to 'source4/scripting') diff --git a/source4/scripting/swig/dcerpc.i b/source4/scripting/swig/dcerpc.i index 169cc6404a..3b596e85e1 100644 --- a/source4/scripting/swig/dcerpc.i +++ b/source4/scripting/swig/dcerpc.i @@ -122,7 +122,7 @@ PyObject *HYPER_T_to_python(HYPER_T obj) /* Conversion functions for types that we don't want generated automatically. This is mostly security realted stuff in misc.idl */ -char *string_ptr_from_python(PyObject *obj) +char *string_ptr_from_python(TALLOC_CTX *mem_ctx, PyObject *obj) { if (obj == Py_None) return NULL; @@ -130,7 +130,7 @@ char *string_ptr_from_python(PyObject *obj) return PyString_AsString(obj); } -PyObject *string_ptr_to_python(char *obj) +PyObject *string_ptr_to_python(TALLOC_CTX *mem_ctx, char *obj) { if (obj == NULL) { Py_INCREF(Py_None); @@ -140,27 +140,35 @@ PyObject *string_ptr_to_python(char *obj) return PyString_FromString(obj); } -struct policy_handle *policy_handle_ptr_from_python(PyObject *obj) +struct policy_handle *policy_handle_ptr_from_python(TALLOC_CTX *mem_ctx, PyObject *obj) { return (struct policy_handle *)PyString_AsString(obj); } -PyObject *policy_handle_ptr_to_python(struct policy_handle *handle) +PyObject *policy_handle_ptr_to_python(TALLOC_CTX *mem_ctx, struct policy_handle *handle) { return PyString_FromStringAndSize((char *)handle, sizeof(*handle)); } -struct security_descriptor *security_descriptor_ptr_from_python(TALLOC_CTX *mem_ctx, PyObject *obj) +PyObject *dom_sid_ptr_to_python(TALLOC_CTX *mem_ctx, struct dom_sid *obj) { - return NULL; + return PyString_FromString(dom_sid_string(mem_ctx, obj)); } -PyObject *dom_sid_ptr_to_python(struct dom_sid *obj) +struct dom_sid *dom_sid_ptr_from_python(TALLOC_CTX *mem_ctx, PyObject *obj) { - return PyString_FromString(""); + return dom_sid_parse_talloc(mem_ctx, PyString_AsString(obj)); } -PyObject *security_acl_ptr_to_python(struct security_acl *obj) +#define dom_sid2_ptr_to_python dom_sid_ptr_to_python +#define dom_sid2_ptr_from_python dom_sid_ptr_from_python + +void dom_sid_from_python(TALLOC_CTX *mem_ctx, struct dom_sid *sid, PyObject *obj) +{ + memset(sid, 0, sizeof(struct dom_sid)); // XXX +} + +PyObject *security_acl_ptr_to_python(TALLOC_CTX *mem_ctx, struct security_acl *obj) { PyObject *result = PyDict_New(); PyObject *ace_list; @@ -182,7 +190,7 @@ PyObject *security_acl_ptr_to_python(struct security_acl *obj) PyDict_SetItem(ace, PyString_FromString("type"), PyInt_FromLong(obj->aces[i].type)); PyDict_SetItem(ace, PyString_FromString("flags"), PyInt_FromLong(obj->aces[i].flags)); PyDict_SetItem(ace, PyString_FromString("access_mask"), PyInt_FromLong(obj->aces[i].access_mask)); - PyDict_SetItem(ace, PyString_FromString("trustee"), dom_sid_ptr_to_python(&obj->aces[i].trustee)); + PyDict_SetItem(ace, PyString_FromString("trustee"), dom_sid_ptr_to_python(mem_ctx, &obj->aces[i].trustee)); PyList_SetItem(ace_list, i, ace); } @@ -192,6 +200,32 @@ PyObject *security_acl_ptr_to_python(struct security_acl *obj) return result; } +struct security_acl *security_acl_ptr_from_python(TALLOC_CTX *mem_ctx, PyObject *obj) +{ + struct security_acl *acl = talloc(mem_ctx, sizeof(struct security_acl)); + PyObject *ace_list; + int i, len; + + acl->revision = PyInt_AsLong(PyDict_GetItem(obj, PyString_FromString("revision"))); + acl->size = PyInt_AsLong(PyDict_GetItem(obj, PyString_FromString("size"))); + ace_list = PyDict_GetItem(obj, PyString_FromString("aces")); + + len = PyList_Size(ace_list); + acl->num_aces = len; + acl->aces = talloc(mem_ctx, len * sizeof(struct security_ace)); + + for (i = 0; i < len; i++) { + acl->aces[i].type = PyInt_AsLong(PyDict_GetItem(obj, PyString_FromString("type"))); + acl->aces[i].flags = PyInt_AsLong(PyDict_GetItem(obj, PyString_FromString("flags"))); + acl->aces[i].size = 0; + acl->aces[i].access_mask = PyInt_AsLong(PyDict_GetItem(obj, PyString_FromString("access_mask"))); + + dom_sid_from_python(mem_ctx, &acl->aces[i].trustee, PyDict_GetItem(obj, PyString_FromString("trustee"))); + } + + return acl; +} + PyObject *security_descriptor_ptr_to_python(TALLOC_CTX *mem_ctx, struct security_descriptor *obj) { PyObject *result = PyDict_New(); @@ -204,24 +238,29 @@ PyObject *security_descriptor_ptr_to_python(TALLOC_CTX *mem_ctx, struct security PyDict_SetItem(result, PyString_FromString("revision"), PyInt_FromLong(obj->revision)); PyDict_SetItem(result, PyString_FromString("type"), PyInt_FromLong(obj->type)); - PyDict_SetItem(result, PyString_FromString("owner_sid"), dom_sid_ptr_to_python(obj->owner_sid)); - PyDict_SetItem(result, PyString_FromString("group_sid"), dom_sid_ptr_to_python(obj->group_sid)); + PyDict_SetItem(result, PyString_FromString("owner_sid"), dom_sid_ptr_to_python(mem_ctx, obj->owner_sid)); + PyDict_SetItem(result, PyString_FromString("group_sid"), dom_sid_ptr_to_python(mem_ctx, obj->group_sid)); - PyDict_SetItem(result, PyString_FromString("sacl"), security_acl_ptr_to_python(obj->sacl)); - PyDict_SetItem(result, PyString_FromString("dacl"), security_acl_ptr_to_python(obj->dacl)); + PyDict_SetItem(result, PyString_FromString("sacl"), security_acl_ptr_to_python(mem_ctx, obj->sacl)); + PyDict_SetItem(result, PyString_FromString("dacl"), security_acl_ptr_to_python(mem_ctx, obj->dacl)); return result; } -struct dom_sid2 *dom_sid2_ptr_from_python(TALLOC_CTX *mem_ctx, PyObject *obj) +struct security_descriptor *security_descriptor_ptr_from_python(TALLOC_CTX *mem_ctx, PyObject *obj) { - return NULL; -} + struct security_descriptor *sd = talloc(mem_ctx, sizeof(struct security_descriptor)); -PyObject *dom_sid2_ptr_to_python(TALLOC_CTX *mem_ctx, struct dom_sid2 *obj) -{ - Py_INCREF(Py_None); - return Py_None; + sd->revision = PyInt_AsLong(PyDict_GetItem(obj, PyString_FromString("revision"))); + sd->type = PyInt_AsLong(PyDict_GetItem(obj, PyString_FromString("type"))); + + sd->owner_sid = security_descriptor_ptr_from_python(mem_ctx, PyDict_GetItem(obj, PyString_FromString("owner_sid"))); + sd->group_sid = security_descriptor_ptr_from_python(mem_ctx, PyDict_GetItem(obj, PyString_FromString("group_sid"))); + + sd->sacl = security_acl_ptr_from_python(mem_ctx, PyDict_GetItem(obj, PyString_FromString("sacl"))); + sd->dacl = security_acl_ptr_from_python(mem_ctx, PyDict_GetItem(obj, PyString_FromString("dacl"))); + + return sd; } struct samr_Password *samr_Password_ptr_from_python(TALLOC_CTX *mem_ctx, PyObject *obj) @@ -229,7 +268,7 @@ struct samr_Password *samr_Password_ptr_from_python(TALLOC_CTX *mem_ctx, PyObjec return NULL; } -PyObject *samr_Password_ptr_to_python(struct samr_Password *obj) +PyObject *samr_Password_ptr_to_python(TALLOC_CTX *mem_ctx, struct samr_Password *obj) { Py_INCREF(Py_None); return Py_None; -- cgit From b02b2fa3473a8249a8a69eb5cc08ab207503ecd0 Mon Sep 17 00:00:00 2001 From: Tim Potter Date: Sat, 18 Sep 2004 08:41:26 +0000 Subject: r2408: Tridge suggested that all the structures from misc.idl (policy handles, sids, security descriptors and acls) can be automatically generated instead of hand-written. Fix up the swig wrapper generator and helper routines to do this. (Only works for policy handles right now though and arrays are to be converted into lists instead of being binary blobs). Fix up wrapper generation for modules that don't define an interface (e.g misc.idl). (This used to be commit 160dc90921ecc136a25ae88e5c28800ddda5722a) --- source4/scripting/swig/dcerpc.i | 134 +--------------------------------------- 1 file changed, 2 insertions(+), 132 deletions(-) (limited to 'source4/scripting') diff --git a/source4/scripting/swig/dcerpc.i b/source4/scripting/swig/dcerpc.i index 3b596e85e1..64d757c634 100644 --- a/source4/scripting/swig/dcerpc.i +++ b/source4/scripting/swig/dcerpc.i @@ -140,146 +140,15 @@ PyObject *string_ptr_to_python(TALLOC_CTX *mem_ctx, char *obj) return PyString_FromString(obj); } -struct policy_handle *policy_handle_ptr_from_python(TALLOC_CTX *mem_ctx, PyObject *obj) -{ - return (struct policy_handle *)PyString_AsString(obj); -} - -PyObject *policy_handle_ptr_to_python(TALLOC_CTX *mem_ctx, struct policy_handle *handle) -{ - return PyString_FromStringAndSize((char *)handle, sizeof(*handle)); -} - -PyObject *dom_sid_ptr_to_python(TALLOC_CTX *mem_ctx, struct dom_sid *obj) -{ - return PyString_FromString(dom_sid_string(mem_ctx, obj)); -} - -struct dom_sid *dom_sid_ptr_from_python(TALLOC_CTX *mem_ctx, PyObject *obj) -{ - return dom_sid_parse_talloc(mem_ctx, PyString_AsString(obj)); -} - #define dom_sid2_ptr_to_python dom_sid_ptr_to_python #define dom_sid2_ptr_from_python dom_sid_ptr_from_python -void dom_sid_from_python(TALLOC_CTX *mem_ctx, struct dom_sid *sid, PyObject *obj) -{ - memset(sid, 0, sizeof(struct dom_sid)); // XXX -} - -PyObject *security_acl_ptr_to_python(TALLOC_CTX *mem_ctx, struct security_acl *obj) -{ - PyObject *result = PyDict_New(); - PyObject *ace_list; - int i; - - if (!obj) { - Py_INCREF(Py_None); - return Py_None; - } - - PyDict_SetItem(result, PyString_FromString("revision"), PyInt_FromLong(obj->revision)); - PyDict_SetItem(result, PyString_FromString("size"), PyInt_FromLong(obj->size)); - - ace_list = PyList_New(obj->num_aces); - - for(i = 0; i < obj->num_aces; i++) { - PyObject *ace = PyDict_New(); - - PyDict_SetItem(ace, PyString_FromString("type"), PyInt_FromLong(obj->aces[i].type)); - PyDict_SetItem(ace, PyString_FromString("flags"), PyInt_FromLong(obj->aces[i].flags)); - PyDict_SetItem(ace, PyString_FromString("access_mask"), PyInt_FromLong(obj->aces[i].access_mask)); - PyDict_SetItem(ace, PyString_FromString("trustee"), dom_sid_ptr_to_python(mem_ctx, &obj->aces[i].trustee)); - - PyList_SetItem(ace_list, i, ace); - } - - PyDict_SetItem(result, PyString_FromString("aces"), ace_list); - - return result; -} - -struct security_acl *security_acl_ptr_from_python(TALLOC_CTX *mem_ctx, PyObject *obj) -{ - struct security_acl *acl = talloc(mem_ctx, sizeof(struct security_acl)); - PyObject *ace_list; - int i, len; - - acl->revision = PyInt_AsLong(PyDict_GetItem(obj, PyString_FromString("revision"))); - acl->size = PyInt_AsLong(PyDict_GetItem(obj, PyString_FromString("size"))); - ace_list = PyDict_GetItem(obj, PyString_FromString("aces")); - - len = PyList_Size(ace_list); - acl->num_aces = len; - acl->aces = talloc(mem_ctx, len * sizeof(struct security_ace)); - - for (i = 0; i < len; i++) { - acl->aces[i].type = PyInt_AsLong(PyDict_GetItem(obj, PyString_FromString("type"))); - acl->aces[i].flags = PyInt_AsLong(PyDict_GetItem(obj, PyString_FromString("flags"))); - acl->aces[i].size = 0; - acl->aces[i].access_mask = PyInt_AsLong(PyDict_GetItem(obj, PyString_FromString("access_mask"))); - - dom_sid_from_python(mem_ctx, &acl->aces[i].trustee, PyDict_GetItem(obj, PyString_FromString("trustee"))); - } - - return acl; -} - -PyObject *security_descriptor_ptr_to_python(TALLOC_CTX *mem_ctx, struct security_descriptor *obj) -{ - PyObject *result = PyDict_New(); - - if (!obj) { - Py_INCREF(Py_None); - return Py_None; - } - - PyDict_SetItem(result, PyString_FromString("revision"), PyInt_FromLong(obj->revision)); - PyDict_SetItem(result, PyString_FromString("type"), PyInt_FromLong(obj->type)); - - PyDict_SetItem(result, PyString_FromString("owner_sid"), dom_sid_ptr_to_python(mem_ctx, obj->owner_sid)); - PyDict_SetItem(result, PyString_FromString("group_sid"), dom_sid_ptr_to_python(mem_ctx, obj->group_sid)); - - PyDict_SetItem(result, PyString_FromString("sacl"), security_acl_ptr_to_python(mem_ctx, obj->sacl)); - PyDict_SetItem(result, PyString_FromString("dacl"), security_acl_ptr_to_python(mem_ctx, obj->dacl)); - - return result; -} - -struct security_descriptor *security_descriptor_ptr_from_python(TALLOC_CTX *mem_ctx, PyObject *obj) -{ - struct security_descriptor *sd = talloc(mem_ctx, sizeof(struct security_descriptor)); - - sd->revision = PyInt_AsLong(PyDict_GetItem(obj, PyString_FromString("revision"))); - sd->type = PyInt_AsLong(PyDict_GetItem(obj, PyString_FromString("type"))); - - sd->owner_sid = security_descriptor_ptr_from_python(mem_ctx, PyDict_GetItem(obj, PyString_FromString("owner_sid"))); - sd->group_sid = security_descriptor_ptr_from_python(mem_ctx, PyDict_GetItem(obj, PyString_FromString("group_sid"))); - - sd->sacl = security_acl_ptr_from_python(mem_ctx, PyDict_GetItem(obj, PyString_FromString("sacl"))); - sd->dacl = security_acl_ptr_from_python(mem_ctx, PyDict_GetItem(obj, PyString_FromString("dacl"))); - - return sd; -} - -struct samr_Password *samr_Password_ptr_from_python(TALLOC_CTX *mem_ctx, PyObject *obj) -{ - return NULL; -} - -PyObject *samr_Password_ptr_to_python(TALLOC_CTX *mem_ctx, struct samr_Password *obj) -{ - Py_INCREF(Py_None); - return Py_None; -} - %} %include "samba.i" %init %{ -/* setup_logging("python", DEBUG_STDOUT); */ + setup_logging("python", DEBUG_STDOUT); lp_load(dyn_CONFIGFILE, True, False, False); load_interfaces(); ntstatus_exception = PyErr_NewException("dcerpc.NTSTATUS", NULL, NULL); @@ -329,5 +198,6 @@ NTSTATUS dcerpc_pipe_connect(struct dcerpc_pipe **OUT, const char *username, const char *password); +%include "librpc/gen_ndr/misc.i" %include "librpc/gen_ndr/lsa.i" %include "librpc/gen_ndr/samr.i" -- cgit From fba4af3a1bdc350b51e61d173730b1542377dd88 Mon Sep 17 00:00:00 2001 From: Tim Potter Date: Sat, 18 Sep 2004 12:47:57 +0000 Subject: r2410: Add test for samr_SetSecurity(). (This used to be commit e822979e84d33015c937e22174288a3f2c2ff04b) --- source4/scripting/swig/torture/samr.py | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) (limited to 'source4/scripting') diff --git a/source4/scripting/swig/torture/samr.py b/source4/scripting/swig/torture/samr.py index e7ee4e8796..f3be954d65 100755 --- a/source4/scripting/swig/torture/samr.py +++ b/source4/scripting/swig/torture/samr.py @@ -12,7 +12,6 @@ def test_Connect(handle): r['access_mask'] = 0x02000000 result = dcerpc.samr_Connect(pipe, r) - dcerpc.samr_Close(pipe, result) print 'testing samr_Connect2' @@ -68,7 +67,13 @@ def test_QuerySecurity(pipe, handle): r['sec_info'] = 7 result = dcerpc.samr_QuerySecurity(pipe, r) - print result + + r = {} + r['handle'] = handle + r['sec_info'] = 7 + r['sdbuf'] = result['sdbuf'] + + result = dcerpc.samr_SetSecurity(pipe, r) # Parse command line -- cgit From a50931e7288131b92161a56dc52e22fa2fe6050b Mon Sep 17 00:00:00 2001 From: Tim Potter Date: Sun, 19 Sep 2004 04:59:56 +0000 Subject: r2414: samr_Connect.system_name is now an array. (This used to be commit e1166c210004b090c5922b2f9b10b86ebc3fc11d) --- source4/scripting/swig/torture/samr.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'source4/scripting') diff --git a/source4/scripting/swig/torture/samr.py b/source4/scripting/swig/torture/samr.py index f3be954d65..d3b9a4dd47 100755 --- a/source4/scripting/swig/torture/samr.py +++ b/source4/scripting/swig/torture/samr.py @@ -8,7 +8,7 @@ def test_Connect(handle): print 'testing samr_Connect' r = {} - r['system_name'] = '\0\0' + r['system_name'] = [0] r['access_mask'] = 0x02000000 result = dcerpc.samr_Connect(pipe, r) -- cgit From d384984e3541a527f36174459714a5f0cdbd8182 Mon Sep 17 00:00:00 2001 From: Tim Potter Date: Sun, 19 Sep 2004 05:28:59 +0000 Subject: r2415: Throw a TypeError exception if a scalar value doesn't have the correct type, or the argument to a to_python function isn't a dictionary. (This used to be commit 0f58ffb142a9b8c5c745b3a2c93a1659ea8282e5) --- source4/scripting/swig/dcerpc.i | 56 +++++++++++++++++++++++++++++++++++------ 1 file changed, 48 insertions(+), 8 deletions(-) (limited to 'source4/scripting') diff --git a/source4/scripting/swig/dcerpc.i b/source4/scripting/swig/dcerpc.i index 64d757c634..a09c3f2377 100644 --- a/source4/scripting/swig/dcerpc.i +++ b/source4/scripting/swig/dcerpc.i @@ -49,8 +49,13 @@ void set_ntstatus_exception(int status) /* Conversion functions for scalar types */ -uint8 uint8_from_python(PyObject *obj) +uint8 uint8_from_python(PyObject *obj, char *name) { + if (!PyInt_Check(obj)) { + PyErr_Format(PyExc_TypeError, "Expecting int value for %s", name); + return 0; + } + return (uint8)PyInt_AsLong(obj); } @@ -59,8 +64,13 @@ PyObject *uint8_to_python(uint8 obj) return PyInt_FromLong(obj); } -uint16 uint16_from_python(PyObject *obj) +uint16 uint16_from_python(PyObject *obj, char *name) { + if (!PyInt_Check(obj)) { + PyErr_Format(PyExc_TypeError, "Expecting int value for %s", name); + return 0; + } + return (uint16)PyInt_AsLong(obj); } @@ -69,8 +79,13 @@ PyObject *uint16_to_python(uint16 obj) return PyInt_FromLong(obj); } -uint32 uint32_from_python(PyObject *obj) +uint32 uint32_from_python(PyObject *obj, char *name) { + if (!PyInt_Check(obj)) { + PyErr_Format(PyExc_TypeError, "Expecting int value for %s", name); + return 0; + } + return (uint32)PyInt_AsLong(obj); } @@ -79,8 +94,13 @@ PyObject *uint32_to_python(uint32 obj) return PyInt_FromLong(obj); } -int64 int64_from_python(PyObject *obj) +int64 int64_from_python(PyObject *obj, char *name) { + if (!PyInt_Check(obj)) { + PyErr_Format(PyExc_TypeError, "Expecting int value for %s", name); + return 0; + } + return (int64)PyLong_AsLong(obj); } @@ -89,8 +109,13 @@ PyObject *int64_to_python(int64 obj) return PyLong_FromLong(obj); } -uint64 uint64_from_python(PyObject *obj) +uint64 uint64_from_python(PyObject *obj, char *name) { + if (!PyInt_Check(obj)) { + PyErr_Format(PyExc_TypeError, "Expecting int value for %s", name); + return 0; + } + return (uint64)PyLong_AsLong(obj); } @@ -99,8 +124,13 @@ PyObject *uint64_to_python(uint64 obj) return PyLong_FromLong(obj); } -NTTIME NTTIME_from_python(PyObject *obj) +NTTIME NTTIME_from_python(PyObject *obj, char *name) { + if (!PyInt_Check(obj)) { + PyErr_Format(PyExc_TypeError, "Expecting integer value for %s", name); + return 0; + } + return (NTTIME)PyLong_AsLong(obj); } @@ -109,8 +139,13 @@ PyObject *NTTIME_to_python(NTTIME obj) return PyLong_FromLong(obj); } -HYPER_T HYPER_T_from_python(PyObject *obj) +HYPER_T HYPER_T_from_python(PyObject *obj, char *name) { + if (!PyInt_Check(obj)) { + PyErr_Format(PyExc_TypeError, "Expecting integer value for %s", name); + return 0; + } + return (HYPER_T)PyLong_AsLong(obj); } @@ -122,11 +157,16 @@ PyObject *HYPER_T_to_python(HYPER_T obj) /* Conversion functions for types that we don't want generated automatically. This is mostly security realted stuff in misc.idl */ -char *string_ptr_from_python(TALLOC_CTX *mem_ctx, PyObject *obj) +char *string_ptr_from_python(TALLOC_CTX *mem_ctx, PyObject *obj, char *name) { if (obj == Py_None) return NULL; + if (!PyString_Check(obj)) { + PyErr_Format(PyExc_TypeError, "Expecting string value for %s", name); + return 0; + } + return PyString_AsString(obj); } -- cgit From 6bc08531b22895cf7ac7c0579a9445491b315b18 Mon Sep 17 00:00:00 2001 From: Tim Potter Date: Sun, 19 Sep 2004 08:58:56 +0000 Subject: r2416: More argument checks. Raise an exception instead of segfaulting if a dictionary does not contain a required key. (This used to be commit fc5443af9c271baf189ebe0b098e190b5eda4e14) --- source4/scripting/swig/dcerpc.i | 42 ++++++++++++++++++++++++++++++++++++++++- 1 file changed, 41 insertions(+), 1 deletion(-) (limited to 'source4/scripting') diff --git a/source4/scripting/swig/dcerpc.i b/source4/scripting/swig/dcerpc.i index a09c3f2377..a90ac90b5a 100644 --- a/source4/scripting/swig/dcerpc.i +++ b/source4/scripting/swig/dcerpc.i @@ -51,6 +51,11 @@ void set_ntstatus_exception(int status) uint8 uint8_from_python(PyObject *obj, char *name) { + if (obj == NULL) { + PyErr_Format(PyExc_ValueError, "Expecting key %s", name); + return 0; + } + if (!PyInt_Check(obj)) { PyErr_Format(PyExc_TypeError, "Expecting int value for %s", name); return 0; @@ -66,6 +71,11 @@ PyObject *uint8_to_python(uint8 obj) uint16 uint16_from_python(PyObject *obj, char *name) { + if (obj == NULL) { + PyErr_Format(PyExc_ValueError, "Expecting key %s", name); + return 0; + } + if (!PyInt_Check(obj)) { PyErr_Format(PyExc_TypeError, "Expecting int value for %s", name); return 0; @@ -81,6 +91,11 @@ PyObject *uint16_to_python(uint16 obj) uint32 uint32_from_python(PyObject *obj, char *name) { + if (obj == NULL) { + PyErr_Format(PyExc_ValueError, "Expecting key %s", name); + return 0; + } + if (!PyInt_Check(obj)) { PyErr_Format(PyExc_TypeError, "Expecting int value for %s", name); return 0; @@ -96,6 +111,11 @@ PyObject *uint32_to_python(uint32 obj) int64 int64_from_python(PyObject *obj, char *name) { + if (obj == NULL) { + PyErr_Format(PyExc_ValueError, "Expecting key %s", name); + return 0; + } + if (!PyInt_Check(obj)) { PyErr_Format(PyExc_TypeError, "Expecting int value for %s", name); return 0; @@ -111,6 +131,11 @@ PyObject *int64_to_python(int64 obj) uint64 uint64_from_python(PyObject *obj, char *name) { + if (obj == NULL) { + PyErr_Format(PyExc_ValueError, "Expecting key %s", name); + return 0; + } + if (!PyInt_Check(obj)) { PyErr_Format(PyExc_TypeError, "Expecting int value for %s", name); return 0; @@ -126,6 +151,11 @@ PyObject *uint64_to_python(uint64 obj) NTTIME NTTIME_from_python(PyObject *obj, char *name) { + if (obj == NULL) { + PyErr_Format(PyExc_ValueError, "Expecting key %s", name); + return 0; + } + if (!PyInt_Check(obj)) { PyErr_Format(PyExc_TypeError, "Expecting integer value for %s", name); return 0; @@ -141,6 +171,11 @@ PyObject *NTTIME_to_python(NTTIME obj) HYPER_T HYPER_T_from_python(PyObject *obj, char *name) { + if (obj == NULL) { + PyErr_Format(PyExc_ValueError, "Expecting key %s", name); + return 0; + } + if (!PyInt_Check(obj)) { PyErr_Format(PyExc_TypeError, "Expecting integer value for %s", name); return 0; @@ -159,12 +194,17 @@ PyObject *HYPER_T_to_python(HYPER_T obj) char *string_ptr_from_python(TALLOC_CTX *mem_ctx, PyObject *obj, char *name) { + if (obj == NULL) { + PyErr_Format(PyExc_ValueError, "Expecting key %s", name); + return NULL; + } + if (obj == Py_None) return NULL; if (!PyString_Check(obj)) { PyErr_Format(PyExc_TypeError, "Expecting string value for %s", name); - return 0; + return NULL; } return PyString_AsString(obj); -- cgit From 6feaf61b61d8f76faeab176af79e1d6e6bea419f Mon Sep 17 00:00:00 2001 From: Tim Potter Date: Sun, 19 Sep 2004 12:38:06 +0000 Subject: r2419: Write tests for samr_EnumDomains() and samr_LookupDomain(). (This used to be commit aa15fd1ecba2163a077f398cecfb49d71a49cc9d) --- source4/scripting/swig/torture/samr.py | 42 ++++++++++++++++++++++++++++++---- 1 file changed, 38 insertions(+), 4 deletions(-) (limited to 'source4/scripting') diff --git a/source4/scripting/swig/torture/samr.py b/source4/scripting/swig/torture/samr.py index d3b9a4dd47..00e4db1958 100755 --- a/source4/scripting/swig/torture/samr.py +++ b/source4/scripting/swig/torture/samr.py @@ -8,7 +8,7 @@ def test_Connect(handle): print 'testing samr_Connect' r = {} - r['system_name'] = [0] + r['system_name'] = 0; r['access_mask'] = 0x02000000 result = dcerpc.samr_Connect(pipe, r) @@ -68,12 +68,43 @@ def test_QuerySecurity(pipe, handle): result = dcerpc.samr_QuerySecurity(pipe, r) + s = {} + s['handle'] = handle + s['sec_info'] = 7 + s['sdbuf'] = result['sdbuf'] + + result = dcerpc.samr_SetSecurity(pipe, s) + + result = dcerpc.samr_QuerySecurity(pipe, r) + +def test_LookupDomain(pipe, handle, domain): + + print 'testing samr_LookupDomain' + r = {} r['handle'] = handle - r['sec_info'] = 7 - r['sdbuf'] = result['sdbuf'] + r['domain'] = {} + r['domain']['name_len'] = 0 + r['domain']['name_size'] = 0 + r['domain']['name'] = domain + + result = dcerpc.samr_LookupDomain(pipe, r) + + print result - result = dcerpc.samr_SetSecurity(pipe, r) +def test_EnumDomains(pipe, handle): + + print 'testing samr_EnumDomains' + + r = {} + r['handle'] = handle + r['resume_handle'] = 0 + r['buf_size'] = -1 + + result = dcerpc.samr_EnumDomains(pipe, r) + + for domain in result['sam']['entries']: + test_LookupDomain(pipe, handle, domain['name']['name']) # Parse command line @@ -112,6 +143,9 @@ pipe = dcerpc.pipe_connect(binding, domain, username, password) handle = test_Connect(pipe) + test_QuerySecurity(pipe, handle) +test_EnumDomains(pipe, handle) + print 'Done' -- cgit From fa8c1abcc833953d69f732d3577d6492148121a7 Mon Sep 17 00:00:00 2001 From: Tim Potter Date: Sun, 19 Sep 2004 22:22:51 +0000 Subject: r2421: Fix test for lookupdomain for a non-existent domain. Export NTSTATUS exception from wrapper module so it can be used by scripts. (This used to be commit 57edfd605bffcf8a0feb5ccc5ec69cf5f35b677b) --- source4/scripting/swig/dcerpc.i | 9 ++++++++- source4/scripting/swig/torture/samr.py | 8 +++++++- 2 files changed, 15 insertions(+), 2 deletions(-) (limited to 'source4/scripting') diff --git a/source4/scripting/swig/dcerpc.i b/source4/scripting/swig/dcerpc.i index a90ac90b5a..bded875b10 100644 --- a/source4/scripting/swig/dcerpc.i +++ b/source4/scripting/swig/dcerpc.i @@ -1,3 +1,5 @@ +/* Tastes like -*- C -*- */ + /* Unix SMB/CIFS implementation. @@ -227,11 +229,16 @@ PyObject *string_ptr_to_python(TALLOC_CTX *mem_ctx, char *obj) %include "samba.i" +%pythoncode %{ + NTSTATUS = _dcerpc.NTSTATUS +%} + %init %{ setup_logging("python", DEBUG_STDOUT); lp_load(dyn_CONFIGFILE, True, False, False); load_interfaces(); - ntstatus_exception = PyErr_NewException("dcerpc.NTSTATUS", NULL, NULL); + ntstatus_exception = PyErr_NewException("_dcerpc.NTSTATUS", NULL, NULL); + PyDict_SetItemString(d, "NTSTATUS", ntstatus_exception); %} %typemap(in, numinputs=0) struct dcerpc_pipe **OUT (struct dcerpc_pipe *temp_dcerpc_pipe) { diff --git a/source4/scripting/swig/torture/samr.py b/source4/scripting/swig/torture/samr.py index 00e4db1958..1f3b60eed4 100755 --- a/source4/scripting/swig/torture/samr.py +++ b/source4/scripting/swig/torture/samr.py @@ -90,7 +90,13 @@ def test_LookupDomain(pipe, handle, domain): result = dcerpc.samr_LookupDomain(pipe, r) - print result + r['domain']['name'] = 'xxNODOMAINxx' + + try: + result = dcerpc.samr_LookupDomain(pipe, r) + except dcerpc.NTSTATUS, arg: + if arg[0] != 0xc00000df: + raise dcerpc.NTSTATUS(arg) def test_EnumDomains(pipe, handle): -- cgit From cb3cacdf402d91722b67b494f36abac0280fc5b9 Mon Sep 17 00:00:00 2001 From: Tim Potter Date: Sun, 19 Sep 2004 23:34:20 +0000 Subject: r2423: Add some instructions for building extensions. (This used to be commit 7a7cf9f3521535da47895d1a516c8572f7f34e40) --- source4/scripting/swig/README | 37 +++++++++++++++++++++++++++++++++++++ 1 file changed, 37 insertions(+) create mode 100644 source4/scripting/swig/README (limited to 'source4/scripting') diff --git a/source4/scripting/swig/README b/source4/scripting/swig/README new file mode 100644 index 0000000000..561c5ab279 --- /dev/null +++ b/source4/scripting/swig/README @@ -0,0 +1,37 @@ +README for Samba SWIG Python extensions +--------------------------------------- + +Instructions for building: + +1. Run configure with the --with-python option to enable python + extensions. + +2. Edit the script/build_idl.sh script to pass the --swig option to + pidl. Here's a patch: + +Index: script/build_idl.sh +=================================================================== +--- script/build_idl.sh (revision 2413) ++++ script/build_idl.sh (working copy) +@@ -4,7 +4,7 @@ + + [ -d librpc/gen_ndr ] || mkdir -p librpc/gen_ndr || exit 1 + +-PIDL="$PERL ./build/pidl/pidl.pl --output librpc/gen_ndr/ndr_ --parse --header --parser --server" ++PIDL="$PERL ./build/pidl/pidl.pl --output librpc/gen_ndr/ndr_ --parse --header --parser --server --swig" + TABLES="$PERL ./build/pidl/tables.pl --output librpc/gen_ndr/tables" + + if [ x$FULLBUILD = xFULL ]; then + +3. Run 'make idl_full swig' to build extensions. + +4. At some stage there will be a proper system for installing the + extensions, but right now it's easier to run them in place. Set + your PYTHONPATH to include the modules. From the Samba source + directory, run: + + export PYTHONPATH=`pwd`/scripting/swig + +Now you can go nuts and use the extensions. Check the +scripting/swig/torture directory for a testsuite. There will +hopefully be a bunch of usage examples somewhere. \ No newline at end of file -- cgit From 6d82eaa7e9597ebaf292e21e00345be0c50287bf Mon Sep 17 00:00:00 2001 From: Tim Potter Date: Mon, 20 Sep 2004 00:55:53 +0000 Subject: r2424: Refactor handling of non-OK NTSTATUS returns to be more swiggish. (This used to be commit aaef6eaf6e0c38fb277d1be0617dfdff559a0115) --- source4/scripting/swig/dcerpc.i | 10 ++++++++++ 1 file changed, 10 insertions(+) (limited to 'source4/scripting') diff --git a/source4/scripting/swig/dcerpc.i b/source4/scripting/swig/dcerpc.i index bded875b10..9677d4e62d 100644 --- a/source4/scripting/swig/dcerpc.i +++ b/source4/scripting/swig/dcerpc.i @@ -285,6 +285,16 @@ NTSTATUS dcerpc_pipe_connect(struct dcerpc_pipe **OUT, const char *username, const char *password); +/* Run this test after each wrapped function */ + +%exception { + $action + if (!NT_STATUS_IS_OK(result)) { + set_ntstatus_exception(NT_STATUS_V(result)); + return NULL; + } +} + %include "librpc/gen_ndr/misc.i" %include "librpc/gen_ndr/lsa.i" %include "librpc/gen_ndr/samr.i" -- cgit From b653d8775a524fe727a61a297d03cf7a12d5c380 Mon Sep 17 00:00:00 2001 From: Tim Potter Date: Mon, 20 Sep 2004 02:51:54 +0000 Subject: r2427: Add tests for samr_GetDomPwInfo, samr_RemoveMemberFromForeignDomain, samr_LookupName, samr_OpenUser, samr_DeleteUser, samr_CreateUse and samr_OpenDomain. (This used to be commit 086740c178c80ccb8d8eaff9f97007cb021bca20) --- source4/scripting/swig/torture/samr.py | 152 ++++++++++++++++++++++++++++++++- 1 file changed, 150 insertions(+), 2 deletions(-) (limited to 'source4/scripting') diff --git a/source4/scripting/swig/torture/samr.py b/source4/scripting/swig/torture/samr.py index 1f3b60eed4..abf505e919 100755 --- a/source4/scripting/swig/torture/samr.py +++ b/source4/scripting/swig/torture/samr.py @@ -77,6 +77,142 @@ def test_QuerySecurity(pipe, handle): result = dcerpc.samr_QuerySecurity(pipe, r) +def test_GetDomPwInfo(pipe, domain): + + print 'testing samr_GetDomPwInfo' + + r = {} + r['handle'] = handle + r['name'] = {} + r['name']['name_len'] = 0 + r['name']['name_size'] = 0 + r['name']['name'] = domain + + result = dcerpc.samr_GetDomPwInfo(pipe, r) + + r['name']['name'] = '\\\\%s' % domain + + result = dcerpc.samr_GetDomPwInfo(pipe, r) + + r['name']['name'] = '\\\\__NONAME__' + + result = dcerpc.samr_GetDomPwInfo(pipe, r) + + r['name']['name'] = '\\\\Builtin' + + result = dcerpc.samr_GetDomPwInfo(pipe, r) + +def test_RemoveMemberFromForeignDomain(pipe, domain_handle): + + r = {} + r['handle'] = domain_handle + r['sid'] = {} + r['sid']['sid_rev_num'] = 1 + r['sid']['id_auth'] = [1, 2, 3, 4, 5, 6] + r['sid']['num_auths'] = 4 + r['sid']['sub_auths'] = [7, 8, 9, 10] + + result = dcerpc.samr_RemoveMemberFromForeignDomain(pipe, r) + +def test_CreateUser2(pipe, domain_handle): + pass + +def test_LookupName(pipe, domain_handle, name): + + r = {} + r['handle'] = domain_handle + r['num_names'] = 1 + r['names'] = [] + r['names'].append({'name_len': 0, 'name_size': 0, 'name': name}) + + result = dcerpc.samr_LookupNames(pipe, r) + + rid = result['rids']['ids'][0] + + r['num_names'] = 2 + r['names'].append({'name_len': 0, 'name_size': 0, 'name': 'xxNONAMExx'}) + + + try: + result = dcerpc.samr_LookupNames(pipe, r) + except dcerpc.NTSTATUS, arg: + if arg[0] != 0x00000107: + raise dcerpc.NTSTATUS(arg) + + r['num_names'] = 0 + + result = dcerpc.samr_LookupNames(pipe, r) + + return rid + +def test_OpenUser_byname(pipe, domain_handle, name): + + rid = test_LookupName(pipe, domain_handle, name) + + r = {} + r['handle'] = domain_handle + r['access_mask'] = 0x02000000 + r['rid'] = rid + + result = dcerpc.samr_OpenUser(pipe, r) + + return result['acct_handle'] + +def test_DeleteUser_byname(pipe, domain_handle, name): + + user_handle = test_OpenUser_byname(pipe, domain_handle, name) + + r = {} + r['handle'] = user_handle + + dcerpc.samr_DeleteUser(pipe, r) + +def test_CreateUser(pipe, domain_handle): + + r = {} + r['handle'] = domain_handle + r['account_name'] = {} + r['account_name']['name_len'] = 0 + r['account_name']['name_size'] = 0 + r['account_name']['name'] = 'samrtorturetest' + r['access_mask'] = 0x02000000 + + try: + result = dcerpc.samr_CreateUser(pipe, r) + except dcerpc.NTSTATUS, arg: + if arg[0] == 0xc0000022: + return + elif arg[0] == 0xc0000063: + test_DeleteUser_byname(pipe, domain_handle, 'samrtorturetest') + result = dcerpc.samr_CreateUser(pipe, r) + else: + raise dcerpc.NTSTATUS(arg) + + user_handle = result['acct_handle'] + + # samr_QueryUserInfo(), etc + +def test_OpenDomain(pipe, handle, domain_sid): + + print 'testing samr_OpenDomain' + + r = {} + r['handle'] = handle + r['access_mask'] = 0x02000000 + r['sid'] = domain_sid + + result = dcerpc.samr_OpenDomain(pipe, r) + + domain_handle = result['domain_handle'] + + test_QuerySecurity(pipe, domain_handle) + + test_RemoveMemberFromForeignDomain(pipe, domain_handle) + + test_CreateUser2(pipe, domain_handle) + + test_CreateUser(pipe, domain_handle) + def test_LookupDomain(pipe, handle, domain): print 'testing samr_LookupDomain' @@ -86,9 +222,13 @@ def test_LookupDomain(pipe, handle, domain): r['domain'] = {} r['domain']['name_len'] = 0 r['domain']['name_size'] = 0 - r['domain']['name'] = domain + r['domain']['name'] = None - result = dcerpc.samr_LookupDomain(pipe, r) + try: + result = dcerpc.samr_LookupDomain(pipe, r) + except dcerpc.NTSTATUS, arg: + if arg[0] != 0xc000000d: + raise dcerpc.NTSTATUS(arg) r['domain']['name'] = 'xxNODOMAINxx' @@ -98,6 +238,14 @@ def test_LookupDomain(pipe, handle, domain): if arg[0] != 0xc00000df: raise dcerpc.NTSTATUS(arg) + r['domain']['name'] = domain + + result = dcerpc.samr_LookupDomain(pipe, r) + + test_GetDomPwInfo(pipe, domain) + + test_OpenDomain(pipe, handle, result['sid']) + def test_EnumDomains(pipe, handle): print 'testing samr_EnumDomains' -- cgit From 67cb7c9451f310ee6ae66c916b6b25a5914e46f1 Mon Sep 17 00:00:00 2001 From: Tim Potter Date: Mon, 20 Sep 2004 06:31:59 +0000 Subject: r2429: Add tests for samr_QueryUserInfo(), samr_QueryUserInfo2(), samr_GetUserPwInfo(), samr_TestPrivateFunctionsUser(). Add stubs for the rest of the functions in test_OpenDomain() from smbtorture. (This used to be commit 1dc86e466dc546a5509fe5195444e48dc026e9a1) --- source4/scripting/swig/torture/samr.py | 177 ++++++++++++++++++++++++++++++++- 1 file changed, 174 insertions(+), 3 deletions(-) (limited to 'source4/scripting') diff --git a/source4/scripting/swig/torture/samr.py b/source4/scripting/swig/torture/samr.py index abf505e919..e726c0229a 100755 --- a/source4/scripting/swig/torture/samr.py +++ b/source4/scripting/swig/torture/samr.py @@ -1,6 +1,6 @@ #!/usr/bin/python -import dcerpc +import sys, dcerpc from optparse import OptionParser def test_Connect(handle): @@ -167,6 +167,63 @@ def test_DeleteUser_byname(pipe, domain_handle, name): dcerpc.samr_DeleteUser(pipe, r) +def test_QueryUserInfo(pipe, user_handle): + + levels = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 16, 17, 20, 21] + + for level in levels: + r = {} + r['handle'] = user_handle + r['level'] = level + + result = dcerpc.samr_QueryUserInfo(pipe, r) + +def test_QueryUserInfo2(pipe, user_handle): + + levels = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 16, 17, 20, 21] + + for level in levels: + r = {} + r['handle'] = user_handle + r['level'] = level + + result = dcerpc.samr_QueryUserInfo2(pipe, r) + +def test_SetUserInfo(pipe, user_handle): + pass + +def test_GetUserPwInfo(pipe, user_handle): + + r = {} + r['handle'] = user_handle + + result = dcerpc.samr_GetUserPwInfo(pipe, r) + +def test_TestPrivateFunctionsUser(pipe, user_handle): + + r = {} + r['handle'] = user_handle + + try: + result = dcerpc.samr_TestPrivateFunctionsUser(pipe, r) + except dcerpc.NTSTATUS, arg: + if arg[0] != 0xc0000002: + raise dcerpc.NTSTATUS(arg) + +def test_user_ops(pipe, user_handle): + + test_QuerySecurity(pipe, user_handle) + + test_QueryUserInfo(pipe, user_handle) + + test_QueryUserInfo2(pipe, user_handle) + + test_SetUserInfo(pipe, user_handle) + + test_GetUserPwInfo(pipe, user_handle) + + test_TestPrivateFunctionsUser(pipe, user_handle) + def test_CreateUser(pipe, domain_handle): r = {} @@ -190,7 +247,81 @@ def test_CreateUser(pipe, domain_handle): user_handle = result['acct_handle'] - # samr_QueryUserInfo(), etc + q = {} + q['handle'] = user_handle + q['level'] = 16 + + result = dcerpc.samr_QueryUserInfo(pipe, q) + + test_user_ops(pipe, user_handle) + + return user_handle + +def test_CreateAlias(pipe, domain_handle): + pass + +def test_CreateDomainGroup(pipe, domain_handle): + pass + +def test_CreateAlias(pipe, domain_handle): + pass + +def test_CreateDomainGroup(pipe, domain_handle): + pass + +def test_QueryDomainInfo(pipe, domain_handle): + pass + +def test_QueryDomainInfo2(pipe, domain_handle): + pass + +def test_EnumDomainUsers(pipe, domain_handle): + pass + +def test_EnumDomainGroups(pipe, domain_handle): + pass + +def test_EnumDomainAliases(pipe, domain_handle): + pass + +def test_QueryDisplayInfo(pipe, domain_handle): + pass + +def test_QueryDisplayInfo2(pipe, domain_handle): + pass + +def test_QueryDisplayInfo3(pipe, domain_handle): + pass + +def test_GetDisplayEnumerationIndex(pipe, domain_handle): + pass + +def test_GetDisplayEnumerationIndex2(pipe, domain_handle): + pass + +def test_GroupList(pipe, domain_handle): + pass + +def test_TestPrivateFunctionsDomain(pipe, domain_handle): + pass + +def test_RidToSid(pipe, domain_handle): + pass + +def test_GetBootKeyInformation(pipe, domain_handle): + pass + +def test_DeleteUser(pipe, user_handle): + pass + +def test_DeleteAlias(pipe, alias_handle): + pass + +def test_DeleteDomainGroup(pipe, group_handle): + pass + +def test_Close(pipe, domain_handle): + pass def test_OpenDomain(pipe, handle, domain_sid): @@ -211,7 +342,47 @@ def test_OpenDomain(pipe, handle, domain_sid): test_CreateUser2(pipe, domain_handle) - test_CreateUser(pipe, domain_handle) + user_handle = test_CreateUser(pipe, domain_handle) + + alias_handle = test_CreateAlias(pipe, domain_handle) + + group_handle = test_CreateDomainGroup(pipe, domain_handle) + + test_QueryDomainInfo(pipe, domain_handle) + + test_QueryDomainInfo2(pipe, domain_handle) + + test_EnumDomainUsers(pipe, domain_handle) + + test_EnumDomainGroups(pipe, domain_handle) + + test_EnumDomainAliases(pipe, domain_handle) + + test_QueryDisplayInfo(pipe, domain_handle) + + test_QueryDisplayInfo2(pipe, domain_handle) + + test_QueryDisplayInfo3(pipe, domain_handle) + + test_GetDisplayEnumerationIndex(pipe, domain_handle) + + test_GetDisplayEnumerationIndex2(pipe, domain_handle) + + test_GroupList(pipe, domain_handle) + + test_TestPrivateFunctionsDomain(pipe, domain_handle) + + test_RidToSid(pipe, domain_handle) + + test_GetBootKeyInformation(pipe, domain_handle) + + test_DeleteUser(pipe, user_handle) + + test_DeleteAlias(pipe, alias_handle) + + test_DeleteDomainGroup(pipe, group_handle) + + test_Close(pipe, domain_handle) def test_LookupDomain(pipe, handle, domain): -- cgit From 851e54de66381193c209ed7674c60208d844045f Mon Sep 17 00:00:00 2001 From: Tim Potter Date: Tue, 21 Sep 2004 04:11:41 +0000 Subject: r2461: Update samr.py torture test after policy handle parameter renames. I thought of another exception to the policy name rule - samr_Close can operate on any kind of samr handle. (This used to be commit 632b7cc0d6b8349a9db1e57c305c359aa500c9e6) --- source4/scripting/swig/torture/samr.py | 131 +++++++++++++++++++++++++-------- 1 file changed, 99 insertions(+), 32 deletions(-) (limited to 'source4/scripting') diff --git a/source4/scripting/swig/torture/samr.py b/source4/scripting/swig/torture/samr.py index e726c0229a..8ee7dfdc34 100755 --- a/source4/scripting/swig/torture/samr.py +++ b/source4/scripting/swig/torture/samr.py @@ -12,7 +12,11 @@ def test_Connect(handle): r['access_mask'] = 0x02000000 result = dcerpc.samr_Connect(pipe, r) - dcerpc.samr_Close(pipe, result) + + s = {} + s['handle'] = result['connect_handle'] + + dcerpc.samr_Close(pipe, s) print 'testing samr_Connect2' @@ -21,7 +25,11 @@ def test_Connect(handle): r['access_mask'] = 0x02000000 result = dcerpc.samr_Connect2(pipe, r) - dcerpc.samr_Close(pipe, result) + + s = {} + s['handle'] = result['connect_handle'] + + dcerpc.samr_Close(pipe, s) print 'testing samr_Connect3' @@ -31,7 +39,11 @@ def test_Connect(handle): r['access_mask'] = 0x02000000 result = dcerpc.samr_Connect3(pipe, r) - dcerpc.samr_Close(pipe, result) + + s = {} + s['handle'] = result['connect_handle'] + + dcerpc.samr_Close(pipe, s) print 'testing samr_Connect4' @@ -41,7 +53,11 @@ def test_Connect(handle): r['access_mask'] = 0x02000000 result = dcerpc.samr_Connect4(pipe, r) - dcerpc.samr_Close(pipe, result) + + s = {} + s['handle'] = result['connect_handle'] + + dcerpc.samr_Close(pipe, s) print 'testing samr_Connect5' @@ -56,7 +72,7 @@ def test_Connect(handle): result = dcerpc.samr_Connect5(pipe, r) - return result['handle'] + return result['connect_handle'] def test_QuerySecurity(pipe, handle): @@ -105,7 +121,7 @@ def test_GetDomPwInfo(pipe, domain): def test_RemoveMemberFromForeignDomain(pipe, domain_handle): r = {} - r['handle'] = domain_handle + r['domain_handle'] = domain_handle r['sid'] = {} r['sid']['sid_rev_num'] = 1 r['sid']['id_auth'] = [1, 2, 3, 4, 5, 6] @@ -120,7 +136,7 @@ def test_CreateUser2(pipe, domain_handle): def test_LookupName(pipe, domain_handle, name): r = {} - r['handle'] = domain_handle + r['domain_handle'] = domain_handle r['num_names'] = 1 r['names'] = [] r['names'].append({'name_len': 0, 'name_size': 0, 'name': name}) @@ -145,25 +161,25 @@ def test_LookupName(pipe, domain_handle, name): return rid -def test_OpenUser_byname(pipe, domain_handle, name): +def test_OpenUser_byname(pipe, domain_handle, user_name): - rid = test_LookupName(pipe, domain_handle, name) + rid = test_LookupName(pipe, domain_handle, user_name) r = {} - r['handle'] = domain_handle + r['domain_handle'] = domain_handle r['access_mask'] = 0x02000000 r['rid'] = rid result = dcerpc.samr_OpenUser(pipe, r) - return result['acct_handle'] + return result['user_handle'] -def test_DeleteUser_byname(pipe, domain_handle, name): +def test_DeleteUser_byname(pipe, domain_handle, user_name): - user_handle = test_OpenUser_byname(pipe, domain_handle, name) + user_handle = test_OpenUser_byname(pipe, domain_handle, user_name) r = {} - r['handle'] = user_handle + r['user_handle'] = user_handle dcerpc.samr_DeleteUser(pipe, r) @@ -173,7 +189,7 @@ def test_QueryUserInfo(pipe, user_handle): for level in levels: r = {} - r['handle'] = user_handle + r['user_handle'] = user_handle r['level'] = level result = dcerpc.samr_QueryUserInfo(pipe, r) @@ -184,7 +200,7 @@ def test_QueryUserInfo2(pipe, user_handle): for level in levels: r = {} - r['handle'] = user_handle + r['user_handle'] = user_handle r['level'] = level result = dcerpc.samr_QueryUserInfo2(pipe, r) @@ -195,14 +211,14 @@ def test_SetUserInfo(pipe, user_handle): def test_GetUserPwInfo(pipe, user_handle): r = {} - r['handle'] = user_handle + r['user_handle'] = user_handle result = dcerpc.samr_GetUserPwInfo(pipe, r) def test_TestPrivateFunctionsUser(pipe, user_handle): r = {} - r['handle'] = user_handle + r['user_handle'] = user_handle try: result = dcerpc.samr_TestPrivateFunctionsUser(pipe, r) @@ -227,7 +243,7 @@ def test_user_ops(pipe, user_handle): def test_CreateUser(pipe, domain_handle): r = {} - r['handle'] = domain_handle + r['domain_handle'] = domain_handle r['account_name'] = {} r['account_name']['name_len'] = 0 r['account_name']['name_size'] = 0 @@ -245,10 +261,10 @@ def test_CreateUser(pipe, domain_handle): else: raise dcerpc.NTSTATUS(arg) - user_handle = result['acct_handle'] + user_handle = result['user_handle'] q = {} - q['handle'] = user_handle + q['user_handle'] = user_handle q['level'] = 16 result = dcerpc.samr_QueryUserInfo(pipe, q) @@ -257,14 +273,62 @@ def test_CreateUser(pipe, domain_handle): return user_handle -def test_CreateAlias(pipe, domain_handle): +def test_DeleteAlias_byname(pipe, domain_handle, alias_name): + + rid = test_LookupName(pipe, domain_handle, alias_name) + + r = {} + r['domain_handle'] = domain_handle + r['access_mask'] = 0x02000000 + r['rid'] = rid + + result = dcerpc.samr_OpenAlias(pipe, r) + + s = {} + s['alias_handle'] = result['alias_handle'] + + dcerpc.samr_DeleteDomAlias(pipe, s) + +def test_alias_ops(pipe, alias_handle, domain_handle, domain_sid): pass +def test_CreateAlias(pipe, domain_handle, domain_sid): + + r = {} + r['domain_handle'] = domain_handle + r['aliasname'] = {} + r['aliasname']['name_len'] = 0 + r['aliasname']['name_size'] = 0 + r['aliasname']['name'] = 'samrtorturetestalias' + r['access_mask'] = 0x02000000 + + try: + result = dcerpc.samr_CreateDomAlias(pipe, r) + except dcerpc.NTSTATUS, arg: + if arg[0] != 0xc0000154: + raise dcerpc.NTSTATUS(arg) + test_DeleteAlias_byname(pipe, domain_handle, 'samrtorturetestalias') + result = dcerpc.samr_CreateDomAlias(pipe, r) + + alias_handle = result['alias_handle'] + + test_alias_ops(pipe, alias_handle, domain_handle, domain_sid) + + return result['alias_handle'] + def test_CreateDomainGroup(pipe, domain_handle): - pass -def test_CreateAlias(pipe, domain_handle): - pass + r = {} + r['domain_handle'] = domain_handle + r['name'] = {} + r['name']['name_len'] = 0 + r['name']['name_size'] = 0 + r['name']['name'] = 'samrtorturetestgroup' + r['access_mask'] = 0x02000000 + + result = dcerpc.samr_CreateDomGroup(pipe, r) + + return result['group_handle'] def test_CreateDomainGroup(pipe, domain_handle): pass @@ -323,12 +387,12 @@ def test_DeleteDomainGroup(pipe, group_handle): def test_Close(pipe, domain_handle): pass -def test_OpenDomain(pipe, handle, domain_sid): +def test_OpenDomain(pipe, connect_handle, domain_sid): print 'testing samr_OpenDomain' r = {} - r['handle'] = handle + r['connect_handle'] = connect_handle r['access_mask'] = 0x02000000 r['sid'] = domain_sid @@ -344,7 +408,10 @@ def test_OpenDomain(pipe, handle, domain_sid): user_handle = test_CreateUser(pipe, domain_handle) - alias_handle = test_CreateAlias(pipe, domain_handle) + alias_handle = test_CreateAlias(pipe, domain_handle, domain_sid) + + print alias_handle + sys.exit(1) group_handle = test_CreateDomainGroup(pipe, domain_handle) @@ -384,12 +451,12 @@ def test_OpenDomain(pipe, handle, domain_sid): test_Close(pipe, domain_handle) -def test_LookupDomain(pipe, handle, domain): +def test_LookupDomain(pipe, connect_handle, domain): print 'testing samr_LookupDomain' r = {} - r['handle'] = handle + r['connect_handle'] = connect_handle r['domain'] = {} r['domain']['name_len'] = 0 r['domain']['name_size'] = 0 @@ -417,12 +484,12 @@ def test_LookupDomain(pipe, handle, domain): test_OpenDomain(pipe, handle, result['sid']) -def test_EnumDomains(pipe, handle): +def test_EnumDomains(pipe, connect_handle): print 'testing samr_EnumDomains' r = {} - r['handle'] = handle + r['connect_handle'] = handle r['resume_handle'] = 0 r['buf_size'] = -1 -- cgit From 46efd4d31b9a73255ea7960eb16c1ec53dfe6478 Mon Sep 17 00:00:00 2001 From: Tim Potter Date: Wed, 22 Sep 2004 02:39:38 +0000 Subject: r2486: Use correct type checks when checking 64-bit quantities (int64, uint64, NTTIME and HYPER_T). Also use the correct conversion routines when creating 64 bit objects. (This used to be commit f09fee92395e89c768e221728d5b0114d78f59fe) --- source4/scripting/swig/dcerpc.i | 32 ++++++++++++++++---------------- 1 file changed, 16 insertions(+), 16 deletions(-) (limited to 'source4/scripting') diff --git a/source4/scripting/swig/dcerpc.i b/source4/scripting/swig/dcerpc.i index 9677d4e62d..08b47d6329 100644 --- a/source4/scripting/swig/dcerpc.i +++ b/source4/scripting/swig/dcerpc.i @@ -118,17 +118,17 @@ int64 int64_from_python(PyObject *obj, char *name) return 0; } - if (!PyInt_Check(obj)) { - PyErr_Format(PyExc_TypeError, "Expecting int value for %s", name); + if (!PyLong_Check(obj)) { + PyErr_Format(PyExc_TypeError, "Expecting long value for %s", name); return 0; } - return (int64)PyLong_AsLong(obj); + return (int64)PyLong_AsLongLong(obj); } PyObject *int64_to_python(int64 obj) { - return PyLong_FromLong(obj); + return PyLong_FromLongLong(obj); } uint64 uint64_from_python(PyObject *obj, char *name) @@ -138,17 +138,17 @@ uint64 uint64_from_python(PyObject *obj, char *name) return 0; } - if (!PyInt_Check(obj)) { - PyErr_Format(PyExc_TypeError, "Expecting int value for %s", name); + if (!PyLong_Check(obj)) { + PyErr_Format(PyExc_TypeError, "Expecting long value for %s", name); return 0; } - return (uint64)PyLong_AsLong(obj); + return (uint64)PyLong_AsUnsignedLongLong(obj); } PyObject *uint64_to_python(uint64 obj) { - return PyLong_FromLong(obj); + return PyLong_FromUnsignedLongLong(obj); } NTTIME NTTIME_from_python(PyObject *obj, char *name) @@ -158,17 +158,17 @@ NTTIME NTTIME_from_python(PyObject *obj, char *name) return 0; } - if (!PyInt_Check(obj)) { - PyErr_Format(PyExc_TypeError, "Expecting integer value for %s", name); + if (!PyLong_Check(obj)) { + PyErr_Format(PyExc_TypeError, "Expecting long value for %s", name); return 0; } - return (NTTIME)PyLong_AsLong(obj); + return (NTTIME)PyLong_AsUnsignedLongLong(obj); } PyObject *NTTIME_to_python(NTTIME obj) { - return PyLong_FromLong(obj); + return PyLong_FromUnsignedLongLong(obj); } HYPER_T HYPER_T_from_python(PyObject *obj, char *name) @@ -178,17 +178,17 @@ HYPER_T HYPER_T_from_python(PyObject *obj, char *name) return 0; } - if (!PyInt_Check(obj)) { - PyErr_Format(PyExc_TypeError, "Expecting integer value for %s", name); + if (!PyLong_Check(obj)) { + PyErr_Format(PyExc_TypeError, "Expecting long value for %s", name); return 0; } - return (HYPER_T)PyLong_AsLong(obj); + return (HYPER_T)PyLong_AsUnsignedLongLong(obj); } PyObject *HYPER_T_to_python(HYPER_T obj) { - return PyLong_FromLong(obj); + return PyLong_FromUnsignedLongLong(obj); } /* Conversion functions for types that we don't want generated automatically. -- cgit From 99721cc7c827457814f97c401462243c3584f480 Mon Sep 17 00:00:00 2001 From: Tim Potter Date: Wed, 22 Sep 2004 03:42:58 +0000 Subject: r2490: Some changes to take into account non-error NTSTATUS codes being returned: - Only throw an exception if NT_STATUS_IS_ERR() instead of !NT_STATUS_IS_OK(). - Add the NTSTATUS value to the returned dictionary under a key of 'result' so calling functions can access it. (This used to be commit 4ddcae90a2e9b93e58bd57932cd9ae4c95be6ae8) --- source4/scripting/swig/dcerpc.i | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'source4/scripting') diff --git a/source4/scripting/swig/dcerpc.i b/source4/scripting/swig/dcerpc.i index 08b47d6329..125b32df78 100644 --- a/source4/scripting/swig/dcerpc.i +++ b/source4/scripting/swig/dcerpc.i @@ -289,7 +289,7 @@ NTSTATUS dcerpc_pipe_connect(struct dcerpc_pipe **OUT, %exception { $action - if (!NT_STATUS_IS_OK(result)) { + if (NT_STATUS_IS_ERR(result)) { set_ntstatus_exception(NT_STATUS_V(result)); return NULL; } -- cgit From b3a11c86e1ca199de9daa8c5f8d7967746db3c77 Mon Sep 17 00:00:00 2001 From: Tim Potter Date: Wed, 22 Sep 2004 04:17:25 +0000 Subject: r2492: Some cleanups. Add tests for samr_CreateDomainGroup, samr_DeleteDomainGroup, samr_QueryDomainInfo, samr_SetDomainInfo, samr_EnumDomainUsers, samr_EnumDomainAliases, samr_EnumDomainGroups. (This used to be commit 991d783c1ade19443c92b85f2b5763b5f51c6d61) --- source4/scripting/swig/torture/samr.py | 174 +++++++++++++++++++++++++++------ 1 file changed, 145 insertions(+), 29 deletions(-) (limited to 'source4/scripting') diff --git a/source4/scripting/swig/torture/samr.py b/source4/scripting/swig/torture/samr.py index 8ee7dfdc34..ebb7e07d9e 100755 --- a/source4/scripting/swig/torture/samr.py +++ b/source4/scripting/swig/torture/samr.py @@ -89,9 +89,9 @@ def test_QuerySecurity(pipe, handle): s['sec_info'] = 7 s['sdbuf'] = result['sdbuf'] - result = dcerpc.samr_SetSecurity(pipe, s) + dcerpc.samr_SetSecurity(pipe, s) - result = dcerpc.samr_QuerySecurity(pipe, r) + dcerpc.samr_QuerySecurity(pipe, r) def test_GetDomPwInfo(pipe, domain): @@ -104,22 +104,24 @@ def test_GetDomPwInfo(pipe, domain): r['name']['name_size'] = 0 r['name']['name'] = domain - result = dcerpc.samr_GetDomPwInfo(pipe, r) + dcerpc.samr_GetDomPwInfo(pipe, r) r['name']['name'] = '\\\\%s' % domain - result = dcerpc.samr_GetDomPwInfo(pipe, r) + dcerpc.samr_GetDomPwInfo(pipe, r) r['name']['name'] = '\\\\__NONAME__' - result = dcerpc.samr_GetDomPwInfo(pipe, r) + dcerpc.samr_GetDomPwInfo(pipe, r) r['name']['name'] = '\\\\Builtin' - result = dcerpc.samr_GetDomPwInfo(pipe, r) + dcerpc.samr_GetDomPwInfo(pipe, r) def test_RemoveMemberFromForeignDomain(pipe, domain_handle): + print 'test samr_RemoveMemberFromForeignDomain' + r = {} r['domain_handle'] = domain_handle r['sid'] = {} @@ -128,13 +130,15 @@ def test_RemoveMemberFromForeignDomain(pipe, domain_handle): r['sid']['num_auths'] = 4 r['sid']['sub_auths'] = [7, 8, 9, 10] - result = dcerpc.samr_RemoveMemberFromForeignDomain(pipe, r) + dcerpc.samr_RemoveMemberFromForeignDomain(pipe, r) def test_CreateUser2(pipe, domain_handle): pass def test_LookupName(pipe, domain_handle, name): + print 'test samr_LookupNames' + r = {} r['domain_handle'] = domain_handle r['num_names'] = 1 @@ -150,14 +154,14 @@ def test_LookupName(pipe, domain_handle, name): try: - result = dcerpc.samr_LookupNames(pipe, r) + dcerpc.samr_LookupNames(pipe, r) except dcerpc.NTSTATUS, arg: if arg[0] != 0x00000107: raise dcerpc.NTSTATUS(arg) r['num_names'] = 0 - result = dcerpc.samr_LookupNames(pipe, r) + dcerpc.samr_LookupNames(pipe, r) return rid @@ -185,6 +189,8 @@ def test_DeleteUser_byname(pipe, domain_handle, user_name): def test_QueryUserInfo(pipe, user_handle): + print 'test samr_QueryUserInfo' + levels = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 16, 17, 20, 21] for level in levels: @@ -192,10 +198,12 @@ def test_QueryUserInfo(pipe, user_handle): r['user_handle'] = user_handle r['level'] = level - result = dcerpc.samr_QueryUserInfo(pipe, r) + dcerpc.samr_QueryUserInfo(pipe, r) def test_QueryUserInfo2(pipe, user_handle): + print 'test samr_QueryUserInfo2' + levels = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 16, 17, 20, 21] for level in levels: @@ -203,25 +211,29 @@ def test_QueryUserInfo2(pipe, user_handle): r['user_handle'] = user_handle r['level'] = level - result = dcerpc.samr_QueryUserInfo2(pipe, r) + dcerpc.samr_QueryUserInfo2(pipe, r) def test_SetUserInfo(pipe, user_handle): pass def test_GetUserPwInfo(pipe, user_handle): + print 'test samr_GetUserpwInfo' + r = {} r['user_handle'] = user_handle - result = dcerpc.samr_GetUserPwInfo(pipe, r) + dcerpc.samr_GetUserPwInfo(pipe, r) def test_TestPrivateFunctionsUser(pipe, user_handle): + print 'test samr.TestPrivateFunctionsUser' + r = {} r['user_handle'] = user_handle try: - result = dcerpc.samr_TestPrivateFunctionsUser(pipe, r) + dcerpc.samr_TestPrivateFunctionsUser(pipe, r) except dcerpc.NTSTATUS, arg: if arg[0] != 0xc0000002: raise dcerpc.NTSTATUS(arg) @@ -242,6 +254,8 @@ def test_user_ops(pipe, user_handle): def test_CreateUser(pipe, domain_handle): + print 'test samr_CreateUser' + r = {} r['domain_handle'] = domain_handle r['account_name'] = {} @@ -267,7 +281,7 @@ def test_CreateUser(pipe, domain_handle): q['user_handle'] = user_handle q['level'] = 16 - result = dcerpc.samr_QueryUserInfo(pipe, q) + dcerpc.samr_QueryUserInfo(pipe, q) test_user_ops(pipe, user_handle) @@ -294,6 +308,8 @@ def test_alias_ops(pipe, alias_handle, domain_handle, domain_sid): def test_CreateAlias(pipe, domain_handle, domain_sid): + print 'test samr_CreateAlias' + r = {} r['domain_handle'] = domain_handle r['aliasname'] = {} @@ -314,10 +330,28 @@ def test_CreateAlias(pipe, domain_handle, domain_sid): test_alias_ops(pipe, alias_handle, domain_handle, domain_sid) - return result['alias_handle'] + return alias_handle + +def test_DeleteGroup_byname(pipe, domain_handle, group_name): + + rid = test_LookupName(pipe, domain_handle, group_name) + + r = {} + r['domain_handle'] = domain_handle + r['access_mask'] = 0x02000000 + r['rid'] = rid + + result = dcerpc.samr_OpenGroup(pipe, r) + + s = {} + s['group_handle'] = result['group_handle'] + + dcerpc.samr_DeleteDomainGroup(pipe, s) def test_CreateDomainGroup(pipe, domain_handle): + print 'testing samr_CreateDomainGroup' + r = {} r['domain_handle'] = domain_handle r['name'] = {} @@ -326,27 +360,110 @@ def test_CreateDomainGroup(pipe, domain_handle): r['name']['name'] = 'samrtorturetestgroup' r['access_mask'] = 0x02000000 - result = dcerpc.samr_CreateDomGroup(pipe, r) + try: + result = dcerpc.samr_CreateDomainGroup(pipe, r) + except dcerpc.NTSTATUS, arg: + if arg[0] != 0xc0000065: + raise dcerpc.NTSTATUS(arg) - return result['group_handle'] + test_DeleteGroup_byname(pipe, domain_handle, 'samrtorturetestgroup') -def test_CreateDomainGroup(pipe, domain_handle): - pass + result = dcerpc.samr_CreateDomainGroup(pipe, r) + + return result['group_handle'] def test_QueryDomainInfo(pipe, domain_handle): - pass + + print 'testing samr_QueryDomainInfo' + + levels = [1, 2, 3, 4, 5, 6, 7, 8, 9, 11, 12, 13] + set_ok = [1, 0, 1, 1, 0, 1, 1, 0, 1, 0, 1, 0] + for i in range(0, len(levels)): + + r = {} + r['domain_handle'] = domain_handle + r['level'] = levels[i] + + result = dcerpc.samr_QueryDomainInfo(pipe, r) + + s = {} + s['domain_handle'] = domain_handle + s['level'] = levels[i] + s['info'] = result['info'] + + try: + dcerpc.samr_SetDomainInfo(pipe, s) + except dcerpc.NTSTATUS, arg: + if set_ok[i]: + raise dcerpc.NTSTATUS(arg) + if arg[0] != 0xc0000003: + raise dcerpc.NTSTATUS(arg) + def test_QueryDomainInfo2(pipe, domain_handle): - pass + + print 'testing samr_QueryDomainInfo' + + levels = [1, 2, 3, 4, 5, 6, 7, 8, 9, 11, 12, 13] + + for i in range(0, len(levels)): + + r = {} + r['domain_handle'] = domain_handle + r['level'] = levels[i] + + dcerpc.samr_QueryDomainInfo2(pipe, r) def test_EnumDomainUsers(pipe, domain_handle): - pass + + print 'testing samr_EnumDomainUsers' + + r = {} + r['domain_handle'] = domain_handle + r['resume_handle'] = 0 + r['acct_flags'] = 0 + r['max_size'] = -1 + + while 1: + result = dcerpc.samr_EnumDomainUsers(pipe, r) + if result['result'] == 0x00000105: + r['resume_handle'] = result['resume_handle'] + continue + break def test_EnumDomainGroups(pipe, domain_handle): - pass + + print 'testing samr_EnumDomainGroups' + + r = {} + r['domain_handle'] = domain_handle + r['resume_handle'] = 0 + r['acct_flags'] = 0 + r['max_size'] = -1 + + while 1: + result = dcerpc.samr_EnumDomainGroups(pipe, r) + if result['result'] == 0x00000105: + r['resume_handle'] = result['resume_handle'] + continue + break def test_EnumDomainAliases(pipe, domain_handle): - pass + + print 'testing samr_EnumDomainAliases' + + r = {} + r['domain_handle'] = domain_handle + r['resume_handle'] = 0 + r['acct_flags'] = 0 + r['max_size'] = -1 + + while 1: + result = dcerpc.samr_EnumDomainAliases(pipe, r) + if result['result'] == 0x00000105: + r['resume_handle'] = result['resume_handle'] + continue + break def test_QueryDisplayInfo(pipe, domain_handle): pass @@ -410,9 +527,6 @@ def test_OpenDomain(pipe, connect_handle, domain_sid): alias_handle = test_CreateAlias(pipe, domain_handle, domain_sid) - print alias_handle - sys.exit(1) - group_handle = test_CreateDomainGroup(pipe, domain_handle) test_QueryDomainInfo(pipe, domain_handle) @@ -425,6 +539,8 @@ def test_OpenDomain(pipe, connect_handle, domain_sid): test_EnumDomainAliases(pipe, domain_handle) + sys.exit(1) + test_QueryDisplayInfo(pipe, domain_handle) test_QueryDisplayInfo2(pipe, domain_handle) @@ -463,7 +579,7 @@ def test_LookupDomain(pipe, connect_handle, domain): r['domain']['name'] = None try: - result = dcerpc.samr_LookupDomain(pipe, r) + dcerpc.samr_LookupDomain(pipe, r) except dcerpc.NTSTATUS, arg: if arg[0] != 0xc000000d: raise dcerpc.NTSTATUS(arg) @@ -471,7 +587,7 @@ def test_LookupDomain(pipe, connect_handle, domain): r['domain']['name'] = 'xxNODOMAINxx' try: - result = dcerpc.samr_LookupDomain(pipe, r) + dcerpc.samr_LookupDomain(pipe, r) except dcerpc.NTSTATUS, arg: if arg[0] != 0xc00000df: raise dcerpc.NTSTATUS(arg) -- cgit From c9d96e9c44eefb6107bf4632ae7a5f43035a957d Mon Sep 17 00:00:00 2001 From: Tim Potter Date: Wed, 22 Sep 2004 07:04:44 +0000 Subject: r2502: Finish off samr torture test: samr_CreateUser2, samr_SetUserInfo, samr_QueryAliasInfo, samr_SetAliasInfo, samr_AddMemberToAlias, samr_AddMultipleMembersToAlias, samr_QueryDisplayInfo, samr_QueryDisplayInfo2, samr_QueryDisplayInfo3, samr_GetDisplayEnumerationIndex, samr_GetDisplayEnumerationIndex2, samr_TestPrivateFunctionsDomain, samr_RidToSid, samr_GetBootKeyInformation, samr_DeleteUser, samr_DeleteAlias, samr_Close. (This used to be commit 808e0708a9601bb94246311e03a1d5adcf654022) --- source4/scripting/swig/torture/samr.py | 318 +++++++++++++++++++++++++++++---- 1 file changed, 288 insertions(+), 30 deletions(-) (limited to 'source4/scripting') diff --git a/source4/scripting/swig/torture/samr.py b/source4/scripting/swig/torture/samr.py index ebb7e07d9e..9bf50cbefb 100755 --- a/source4/scripting/swig/torture/samr.py +++ b/source4/scripting/swig/torture/samr.py @@ -133,7 +133,28 @@ def test_RemoveMemberFromForeignDomain(pipe, domain_handle): dcerpc.samr_RemoveMemberFromForeignDomain(pipe, r) def test_CreateUser2(pipe, domain_handle): - pass + + print 'test samr_CreateUser2' + + r = {} + r['domain_handle'] = domain_handle + r['access_mask'] = 0x02000000 + r['account_name'] = {} + r['account_name']['name_len'] = 0 + r['account_name']['name_size'] = 0 + r['account_name']['name'] = 'samrtorturemach$' + r['acct_flags'] = 0x0080 # WSTRUST + + try: + dcerpc.samr_CreateUser2(pipe, r) + except dcerpc.NTSTATUS, arg: + if arg[0] == 0xc0000022: + return + elif arg[0] == 0xc0000063: + test_DeleteUser_byname(pipe, domain_handle, 'samrtorturemach$') + result = dcerpc.samr_CreateUser(pipe, r) + else: + raise dcerpc.NTSTATUS(arg) def test_LookupName(pipe, domain_handle, name): @@ -214,7 +235,24 @@ def test_QueryUserInfo2(pipe, user_handle): dcerpc.samr_QueryUserInfo2(pipe, r) def test_SetUserInfo(pipe, user_handle): - pass + + r = {} + r['user_handle'] = user_handle + r['level'] = 2 + r['info'] = {} + r['info']['info2'] = {} + r['info']['info2']['comment'] = {} + r['info']['info2']['comment']['name_len'] = 0 + r['info']['info2']['comment']['name_size'] = 0 + r['info']['info2']['comment']['name'] = 'hello' + r['info']['info2']['unknown'] = {} + r['info']['info2']['unknown']['name_len'] = 0 + r['info']['info2']['unknown']['name_size'] = 0 + r['info']['info2']['unknown']['name'] = None + r['info']['info2']['country_code'] = 0 + r['info']['info2']['code_page'] = 0 + + dcerpc.samr_SetUserInfo(pipe, r) def test_GetUserPwInfo(pipe, user_handle): @@ -303,32 +341,114 @@ def test_DeleteAlias_byname(pipe, domain_handle, alias_name): dcerpc.samr_DeleteDomAlias(pipe, s) -def test_alias_ops(pipe, alias_handle, domain_handle, domain_sid): - pass +def test_QueryAliasInfo(pipe, alias_handle): + + levels = [1, 2, 3] + + for i in range(0, len(levels)): + + r = {} + r['alias_handle'] = alias_handle + r['level'] = levels[i] + + dcerpc.samr_QueryAliasInfo(pipe, r) + +def test_SetAliasInfo(pipe, alias_handle): + + r = {} + r['alias_handle'] = alias_handle + r['level'] = 2 + r['info'] = {} + r['info']['name'] = {} + r['info']['name']['name_len'] = 0 + r['info']['name']['name_size'] = 0 + r['info']['name']['name'] = 'hello' + + dcerpc.samr_SetAliasInfo(pipe, r) + + del(r['info']['name']) + + r['level'] = 3 + r['info']['description'] = {} + r['info']['description']['name_len'] = 0 + r['info']['description']['name_size'] = 0 + r['info']['description']['name'] = 'this is a description' + + dcerpc.samr_SetAliasInfo(pipe, r) + +def test_AddMemberToAlias(pipe, alias_handle, domain_sid): + + r = {} + r['alias_handle'] = alias_handle + r['sid'] = domain_sid + + r['sid']['num_auths'] = r['sid']['num_auths'] + 1 + r['sid']['sub_auths'].append(512) + + dcerpc.samr_AddAliasMember(pipe, r) + + dcerpc.samr_DeleteAliasMember(pipe, r) + +def test_AddMultipleMembersToAlias(pipe, alias_handle): + + r = {} + r['alias_handle'] = alias_handle + r['sids'] = {} + r['sids']['num_sids'] = 2 + r['sids']['sids'] = [] + + for i in range(0,2): + sid = {} + sid['sid_rev_num'] = 1 + sid['id_auth'] = [0, 0, 0, 0, 0, 5] + sid['num_auths'] = 5 + sid['sub_auths'] = [21, 737922324, -1292160505, 1285293260, 512 + i] + + r['sids']['sids'].append({'sid': sid}) + + dcerpc.samr_AddMultipleMembersToAlias(pipe, r) + + dcerpc.samr_RemoveMultipleMembersFromAlias(pipe, r) + +def test_alias_ops(pipe, alias_handle, domain_sid): + + test_QuerySecurity(pipe, alias_handle) + + test_QueryAliasInfo(pipe, alias_handle) + + test_SetAliasInfo(pipe, alias_handle) + + test_AddMemberToAlias(pipe, alias_handle, domain_sid) + + test_AddMultipleMembersToAlias(pipe, alias_handle) def test_CreateAlias(pipe, domain_handle, domain_sid): print 'test samr_CreateAlias' + alias_name = 'samrtorturetestalias' + r = {} r['domain_handle'] = domain_handle r['aliasname'] = {} r['aliasname']['name_len'] = 0 r['aliasname']['name_size'] = 0 - r['aliasname']['name'] = 'samrtorturetestalias' + r['aliasname']['name'] = alias_name r['access_mask'] = 0x02000000 try: result = dcerpc.samr_CreateDomAlias(pipe, r) except dcerpc.NTSTATUS, arg: - if arg[0] != 0xc0000154: + if arg[0] == 0xc0000022: + return + if arg[0] != 0xc0000063: raise dcerpc.NTSTATUS(arg) - test_DeleteAlias_byname(pipe, domain_handle, 'samrtorturetestalias') + test_DeleteAlias_byname(pipe, domain_handle, alias_name) result = dcerpc.samr_CreateDomAlias(pipe, r) alias_handle = result['alias_handle'] - test_alias_ops(pipe, alias_handle, domain_handle, domain_sid) + test_alias_ops(pipe, alias_handle, domain_sid) return alias_handle @@ -363,6 +483,8 @@ def test_CreateDomainGroup(pipe, domain_handle): try: result = dcerpc.samr_CreateDomainGroup(pipe, r) except dcerpc.NTSTATUS, arg: + if arg[0] == 0xc0000022: + return if arg[0] != 0xc0000065: raise dcerpc.NTSTATUS(arg) @@ -466,43 +588,180 @@ def test_EnumDomainAliases(pipe, domain_handle): break def test_QueryDisplayInfo(pipe, domain_handle): - pass + + print 'testing samr_QueryDisplayInfo' + + levels = [1, 2, 3, 4, 5] + + for i in range(0, len(levels)): + + r = {} + r['domain_handle'] = domain_handle + r['level'] = levels[i] + r['start_idx'] = 0 + r['max_entries'] = 1000 + r['buf_size'] = -1 + + dcerpc.samr_QueryDisplayInfo(pipe, r) def test_QueryDisplayInfo2(pipe, domain_handle): - pass + + print 'testing samr_QueryDisplayInfo2' + + levels = [1, 2, 3, 4, 5] + + for i in range(0, len(levels)): + + r = {} + r['domain_handle'] = domain_handle + r['level'] = levels[i] + r['start_idx'] = 0 + r['max_entries'] = 1000 + r['buf_size'] = -1 + + dcerpc.samr_QueryDisplayInfo2(pipe, r) def test_QueryDisplayInfo3(pipe, domain_handle): - pass + + print 'testing samr_QueryDisplayInfo3' + + levels = [1, 2, 3, 4, 5] + + for i in range(0, len(levels)): + + r = {} + r['domain_handle'] = domain_handle + r['level'] = levels[i] + r['start_idx'] = 0 + r['max_entries'] = 1000 + r['buf_size'] = -1 + + dcerpc.samr_QueryDisplayInfo3(pipe, r) def test_GetDisplayEnumerationIndex(pipe, domain_handle): - pass + + print 'testing samr_GetDisplayEnumerationIndex' + + levels = [1, 2, 3, 4, 5] + ok_lvl = [1, 1, 1, 0, 0] + + for i in range(0, len(levels)): + + r = {} + r['domain_handle'] = domain_handle + r['level'] = levels[i] + r['name'] = {} + r['name']['name_len'] = 0 + r['name']['name_size'] = 0 + r['name']['name'] = 'samrtorturetest' + + try: + dcerpc.samr_GetDisplayEnumerationIndex(pipe, r) + except dcerpc.NTSTATUS, arg: + if ok_lvl[i]: + raise dcerpc.NTSTATUS(arg) + + r['name']['name'] = 'zzzzzzzz' + + try: + dcerpc.samr_GetDisplayEnumerationIndex(pipe, r) + except dcerpc.NTSTATUS, arg: + if ok_lvl[i]: + raise dcerpc.NTSTATUS(arg) def test_GetDisplayEnumerationIndex2(pipe, domain_handle): - pass -def test_GroupList(pipe, domain_handle): - pass + print 'testing samr_GetDisplayEnumerationIndex2' + + levels = [1, 2, 3, 4, 5] + ok_lvl = [1, 1, 1, 0, 0] + + for i in range(0, len(levels)): + + r = {} + r['domain_handle'] = domain_handle + r['level'] = levels[i] + r['name'] = {} + r['name']['name_len'] = 0 + r['name']['name_size'] = 0 + r['name']['name'] = 'samrtorturetest' + + try: + dcerpc.samr_GetDisplayEnumerationIndex2(pipe, r) + except dcerpc.NTSTATUS, arg: + if ok_lvl[i]: + raise dcerpc.NTSTATUS(arg) + + r['name']['name'] = 'zzzzzzzz' + + try: + dcerpc.samr_GetDisplayEnumerationIndex2(pipe, r) + except dcerpc.NTSTATUS, arg: + if ok_lvl[i]: + raise dcerpc.NTSTATUS(arg) def test_TestPrivateFunctionsDomain(pipe, domain_handle): - pass + + print 'test samr.TestPrivateFunctionsDomain' + + r = {} + r['domain_handle'] = domain_handle + + try: + dcerpc.samr_TestPrivateFunctionsDomain(pipe, r) + except dcerpc.NTSTATUS, arg: + if arg[0] != 0xc0000002: + raise dcerpc.NTSTATUS(arg) def test_RidToSid(pipe, domain_handle): - pass + + print 'testing samr_RidToSid' + + r = {} + r['domain_handle'] = domain_handle + r['rid'] = 512 + + dcerpc.samr_RidToSid(pipe, r) def test_GetBootKeyInformation(pipe, domain_handle): - pass + + print 'testing samr_GetBootKeyInformation' + + r = {} + r['domain_handle'] = domain_handle + + try: + dcerpc.samr_GetBootKeyInformation(pipe, r) + except dcerpc.NTSTATUS, arg: + pass def test_DeleteUser(pipe, user_handle): - pass + + r = {} + r['user_handle'] = user_handle + + dcerpc.samr_DeleteUser(pipe, r) def test_DeleteAlias(pipe, alias_handle): - pass + r = {} + r['alias_handle'] = alias_handle + + dcerpc.samr_DeleteDomAlias(pipe, r) + def test_DeleteDomainGroup(pipe, group_handle): - pass -def test_Close(pipe, domain_handle): - pass + r = {} + r['group_handle'] = group_handle + + dcerpc.samr_DeleteDomainGroup(pipe, r) + +def test_Close(pipe, handle): + + r = {} + r['handle'] = handle + + dcerpc.samr_Close(pipe, r) def test_OpenDomain(pipe, connect_handle, domain_sid): @@ -539,8 +798,6 @@ def test_OpenDomain(pipe, connect_handle, domain_sid): test_EnumDomainAliases(pipe, domain_handle) - sys.exit(1) - test_QueryDisplayInfo(pipe, domain_handle) test_QueryDisplayInfo2(pipe, domain_handle) @@ -551,19 +808,20 @@ def test_OpenDomain(pipe, connect_handle, domain_sid): test_GetDisplayEnumerationIndex2(pipe, domain_handle) - test_GroupList(pipe, domain_handle) - test_TestPrivateFunctionsDomain(pipe, domain_handle) test_RidToSid(pipe, domain_handle) test_GetBootKeyInformation(pipe, domain_handle) - test_DeleteUser(pipe, user_handle) + if user_handle != None: + test_DeleteUser(pipe, user_handle) - test_DeleteAlias(pipe, alias_handle) + if alias_handle != None: + test_DeleteAlias(pipe, alias_handle) - test_DeleteDomainGroup(pipe, group_handle) + if group_handle != None: + test_DeleteDomainGroup(pipe, group_handle) test_Close(pipe, domain_handle) -- cgit From 15568d45e1d8cc3928647476baecab2d5d7d852e Mon Sep 17 00:00:00 2001 From: Tim Potter Date: Wed, 22 Sep 2004 11:48:10 +0000 Subject: r2511: Add NT status codes. (This used to be commit 471b13da2b0893a58977154dbe4d004d5c06aed4) --- source4/scripting/swig/dcerpc.i | 520 +++++++++++++++++++++++++++++++++ source4/scripting/swig/torture/samr.py | 34 +-- 2 files changed, 537 insertions(+), 17 deletions(-) (limited to 'source4/scripting') diff --git a/source4/scripting/swig/dcerpc.i b/source4/scripting/swig/dcerpc.i index 125b32df78..7a8a0e4a83 100644 --- a/source4/scripting/swig/dcerpc.i +++ b/source4/scripting/swig/dcerpc.i @@ -229,6 +229,526 @@ PyObject *string_ptr_to_python(TALLOC_CTX *mem_ctx, char *obj) %include "samba.i" +/* Win32 status codes */ + +#define STATUS_BUFFER_OVERFLOW 0x80000005 +#define STATUS_NO_MORE_FILES 0x80000006 +#define NT_STATUS_NO_MORE_ENTRIES 0x8000001a + +#define STATUS_MORE_ENTRIES 0x0105 +#define STATUS_SOME_UNMAPPED 0x0107 +#define ERROR_INVALID_PARAMETER 0x0057 +#define ERROR_INSUFFICIENT_BUFFER 0x007a +#define STATUS_NOTIFY_ENUM_DIR 0x010c +#define ERROR_INVALID_DATATYPE 0x070c + +/* NT status codes */ + +#define NT_STATUS_OK 0x00000000 +#define NT_STATUS_UNSUCCESSFUL 0xC0000001 +#define NT_STATUS_NOT_IMPLEMENTED 0xC0000002 +#define NT_STATUS_INVALID_INFO_CLASS 0xC0000003 +#define NT_STATUS_INFO_LENGTH_MISMATCH 0xC0000004 +#define NT_STATUS_ACCESS_VIOLATION 0xC0000005 +#define NT_STATUS_IN_PAGE_ERROR 0xC0000006 +#define NT_STATUS_PAGEFILE_QUOTA 0xC0000007 +#define NT_STATUS_INVALID_HANDLE 0xC0000008 +#define NT_STATUS_BAD_INITIAL_STACK 0xC0000009 +#define NT_STATUS_BAD_INITIAL_PC 0xC000000a +#define NT_STATUS_INVALID_CID 0xC000000b +#define NT_STATUS_TIMER_NOT_CANCELED 0xC000000c +#define NT_STATUS_INVALID_PARAMETER 0xC000000d +#define NT_STATUS_NO_SUCH_DEVICE 0xC000000e +#define NT_STATUS_NO_SUCH_FILE 0xC000000f +#define NT_STATUS_INVALID_DEVICE_REQUEST 0xC0000010 +#define NT_STATUS_END_OF_FILE 0xC0000011 +#define NT_STATUS_WRONG_VOLUME 0xC0000012 +#define NT_STATUS_NO_MEDIA_IN_DEVICE 0xC0000013 +#define NT_STATUS_UNRECOGNIZED_MEDIA 0xC0000014 +#define NT_STATUS_NONEXISTENT_SECTOR 0xC0000015 +#define NT_STATUS_MORE_PROCESSING_REQUIRED 0xC0000016 +#define NT_STATUS_NO_MEMORY 0xC0000017 +#define NT_STATUS_CONFLICTING_ADDRESSES 0xC0000018 +#define NT_STATUS_NOT_MAPPED_VIEW 0xC0000019 +#define NT_STATUS_UNABLE_TO_FREE_VM 0xC000001a +#define NT_STATUS_UNABLE_TO_DELETE_SECTION 0xC000001b +#define NT_STATUS_INVALID_SYSTEM_SERVICE 0xC000001c +#define NT_STATUS_ILLEGAL_INSTRUCTION 0xC000001d +#define NT_STATUS_INVALID_LOCK_SEQUENCE 0xC000001e +#define NT_STATUS_INVALID_VIEW_SIZE 0xC000001f +#define NT_STATUS_INVALID_FILE_FOR_SECTION 0xC0000020 +#define NT_STATUS_ALREADY_COMMITTED 0xC0000021 +#define NT_STATUS_ACCESS_DENIED 0xC0000022 +#define NT_STATUS_BUFFER_TOO_SMALL 0xC0000023 +#define NT_STATUS_OBJECT_TYPE_MISMATCH 0xC0000024 +#define NT_STATUS_NONCONTINUABLE_EXCEPTION 0xC0000025 +#define NT_STATUS_INVALID_DISPOSITION 0xC0000026 +#define NT_STATUS_UNWIND 0xC0000027 +#define NT_STATUS_BAD_STACK 0xC0000028 +#define NT_STATUS_INVALID_UNWIND_TARGET 0xC0000029 +#define NT_STATUS_NOT_LOCKED 0xC000002a +#define NT_STATUS_PARITY_ERROR 0xC000002b +#define NT_STATUS_UNABLE_TO_DECOMMIT_VM 0xC000002c +#define NT_STATUS_NOT_COMMITTED 0xC000002d +#define NT_STATUS_INVALID_PORT_ATTRIBUTES 0xC000002e +#define NT_STATUS_PORT_MESSAGE_TOO_LONG 0xC000002f +#define NT_STATUS_INVALID_PARAMETER_MIX 0xC0000030 +#define NT_STATUS_INVALID_QUOTA_LOWER 0xC0000031 +#define NT_STATUS_DISK_CORRUPT_ERROR 0xC0000032 +#define NT_STATUS_OBJECT_NAME_INVALID 0xC0000033 +#define NT_STATUS_OBJECT_NAME_NOT_FOUND 0xC0000034 +#define NT_STATUS_OBJECT_NAME_COLLISION 0xC0000035 +#define NT_STATUS_HANDLE_NOT_WAITABLE 0xC0000036 +#define NT_STATUS_PORT_DISCONNECTED 0xC0000037 +#define NT_STATUS_DEVICE_ALREADY_ATTACHED 0xC0000038 +#define NT_STATUS_OBJECT_PATH_INVALID 0xC0000039 +#define NT_STATUS_OBJECT_PATH_NOT_FOUND 0xC000003a +#define NT_STATUS_OBJECT_PATH_SYNTAX_BAD 0xC000003b +#define NT_STATUS_DATA_OVERRUN 0xC000003c +#define NT_STATUS_DATA_LATE_ERROR 0xC000003d +#define NT_STATUS_DATA_ERROR 0xC000003e +#define NT_STATUS_CRC_ERROR 0xC000003f +#define NT_STATUS_SECTION_TOO_BIG 0xC0000040 +#define NT_STATUS_PORT_CONNECTION_REFUSED 0xC0000041 +#define NT_STATUS_INVALID_PORT_HANDLE 0xC0000042 +#define NT_STATUS_SHARING_VIOLATION 0xC0000043 +#define NT_STATUS_QUOTA_EXCEEDED 0xC0000044 +#define NT_STATUS_INVALID_PAGE_PROTECTION 0xC0000045 +#define NT_STATUS_MUTANT_NOT_OWNED 0xC0000046 +#define NT_STATUS_SEMAPHORE_LIMIT_EXCEEDED 0xC0000047 +#define NT_STATUS_PORT_ALREADY_SET 0xC0000048 +#define NT_STATUS_SECTION_NOT_IMAGE 0xC0000049 +#define NT_STATUS_SUSPEND_COUNT_EXCEEDED 0xC000004a +#define NT_STATUS_THREAD_IS_TERMINATING 0xC000004b +#define NT_STATUS_BAD_WORKING_SET_LIMIT 0xC000004c +#define NT_STATUS_INCOMPATIBLE_FILE_MAP 0xC000004d +#define NT_STATUS_SECTION_PROTECTION 0xC000004e +#define NT_STATUS_EAS_NOT_SUPPORTED 0xC000004f +#define NT_STATUS_EA_TOO_LARGE 0xC0000050 +#define NT_STATUS_NONEXISTENT_EA_ENTRY 0xC0000051 +#define NT_STATUS_NO_EAS_ON_FILE 0xC0000052 +#define NT_STATUS_EA_CORRUPT_ERROR 0xC0000053 +#define NT_STATUS_FILE_LOCK_CONFLICT 0xC0000054 +#define NT_STATUS_LOCK_NOT_GRANTED 0xC0000055 +#define NT_STATUS_DELETE_PENDING 0xC0000056 +#define NT_STATUS_CTL_FILE_NOT_SUPPORTED 0xC0000057 +#define NT_STATUS_UNKNOWN_REVISION 0xC0000058 +#define NT_STATUS_REVISION_MISMATCH 0xC0000059 +#define NT_STATUS_INVALID_OWNER 0xC000005a +#define NT_STATUS_INVALID_PRIMARY_GROUP 0xC000005b +#define NT_STATUS_NO_IMPERSONATION_TOKEN 0xC000005c +#define NT_STATUS_CANT_DISABLE_MANDATORY 0xC000005d +#define NT_STATUS_NO_LOGON_SERVERS 0xC000005e +#define NT_STATUS_NO_SUCH_LOGON_SESSION 0xC000005f +#define NT_STATUS_NO_SUCH_PRIVILEGE 0xC0000060 +#define NT_STATUS_PRIVILEGE_NOT_HELD 0xC0000061 +#define NT_STATUS_INVALID_ACCOUNT_NAME 0xC0000062 +#define NT_STATUS_USER_EXISTS 0xC0000063 +#define NT_STATUS_NO_SUCH_USER 0xC0000064 +#define NT_STATUS_GROUP_EXISTS 0xC0000065 +#define NT_STATUS_NO_SUCH_GROUP 0xC0000066 +#define NT_STATUS_MEMBER_IN_GROUP 0xC0000067 +#define NT_STATUS_MEMBER_NOT_IN_GROUP 0xC0000068 +#define NT_STATUS_LAST_ADMIN 0xC0000069 +#define NT_STATUS_WRONG_PASSWORD 0xC000006a +#define NT_STATUS_ILL_FORMED_PASSWORD 0xC000006b +#define NT_STATUS_PASSWORD_RESTRICTION 0xC000006c +#define NT_STATUS_LOGON_FAILURE 0xC000006d +#define NT_STATUS_ACCOUNT_RESTRICTION 0xC000006e +#define NT_STATUS_INVALID_LOGON_HOURS 0xC000006f +#define NT_STATUS_INVALID_WORKSTATION 0xC0000070 +#define NT_STATUS_PASSWORD_EXPIRED 0xC0000071 +#define NT_STATUS_ACCOUNT_DISABLED 0xC0000072 +#define NT_STATUS_NONE_MAPPED 0xC0000073 +#define NT_STATUS_TOO_MANY_LUIDS_REQUESTED 0xC0000074 +#define NT_STATUS_LUIDS_EXHAUSTED 0xC0000075 +#define NT_STATUS_INVALID_SUB_AUTHORITY 0xC0000076 +#define NT_STATUS_INVALID_ACL 0xC0000077 +#define NT_STATUS_INVALID_SID 0xC0000078 +#define NT_STATUS_INVALID_SECURITY_DESCR 0xC0000079 +#define NT_STATUS_PROCEDURE_NOT_FOUND 0xC000007a +#define NT_STATUS_INVALID_IMAGE_FORMAT 0xC000007b +#define NT_STATUS_NO_TOKEN 0xC000007c +#define NT_STATUS_BAD_INHERITANCE_ACL 0xC000007d +#define NT_STATUS_RANGE_NOT_LOCKED 0xC000007e +#define NT_STATUS_DISK_FULL 0xC000007f +#define NT_STATUS_SERVER_DISABLED 0xC0000080 +#define NT_STATUS_SERVER_NOT_DISABLED 0xC0000081 +#define NT_STATUS_TOO_MANY_GUIDS_REQUESTED 0xC0000082 +#define NT_STATUS_GUIDS_EXHAUSTED 0xC0000083 +#define NT_STATUS_INVALID_ID_AUTHORITY 0xC0000084 +#define NT_STATUS_AGENTS_EXHAUSTED 0xC0000085 +#define NT_STATUS_INVALID_VOLUME_LABEL 0xC0000086 +#define NT_STATUS_SECTION_NOT_EXTENDED 0xC0000087 +#define NT_STATUS_NOT_MAPPED_DATA 0xC0000088 +#define NT_STATUS_RESOURCE_DATA_NOT_FOUND 0xC0000089 +#define NT_STATUS_RESOURCE_TYPE_NOT_FOUND 0xC000008a +#define NT_STATUS_RESOURCE_NAME_NOT_FOUND 0xC000008b +#define NT_STATUS_ARRAY_BOUNDS_EXCEEDED 0xC000008c +#define NT_STATUS_FLOAT_DENORMAL_OPERAND 0xC000008d +#define NT_STATUS_FLOAT_DIVIDE_BY_ZERO 0xC000008e +#define NT_STATUS_FLOAT_INEXACT_RESULT 0xC000008f +#define NT_STATUS_FLOAT_INVALID_OPERATION 0xC0000090 +#define NT_STATUS_FLOAT_OVERFLOW 0xC0000091 +#define NT_STATUS_FLOAT_STACK_CHECK 0xC0000092 +#define NT_STATUS_FLOAT_UNDERFLOW 0xC0000093 +#define NT_STATUS_INTEGER_DIVIDE_BY_ZERO 0xC0000094 +#define NT_STATUS_INTEGER_OVERFLOW 0xC0000095 +#define NT_STATUS_PRIVILEGED_INSTRUCTION 0xC0000096 +#define NT_STATUS_TOO_MANY_PAGING_FILES 0xC0000097 +#define NT_STATUS_FILE_INVALID 0xC0000098 +#define NT_STATUS_ALLOTTED_SPACE_EXCEEDED 0xC0000099 +#define NT_STATUS_INSUFFICIENT_RESOURCES 0xC000009a +#define NT_STATUS_DFS_EXIT_PATH_FOUND 0xC000009b +#define NT_STATUS_DEVICE_DATA_ERROR 0xC000009c +#define NT_STATUS_DEVICE_NOT_CONNECTED 0xC000009d +#define NT_STATUS_DEVICE_POWER_FAILURE 0xC000009e +#define NT_STATUS_FREE_VM_NOT_AT_BASE 0xC000009f +#define NT_STATUS_MEMORY_NOT_ALLOCATED 0xC00000a0 +#define NT_STATUS_WORKING_SET_QUOTA 0xC00000a1 +#define NT_STATUS_MEDIA_WRITE_PROTECTED 0xC00000a2 +#define NT_STATUS_DEVICE_NOT_READY 0xC00000a3 +#define NT_STATUS_INVALID_GROUP_ATTRIBUTES 0xC00000a4 +#define NT_STATUS_BAD_IMPERSONATION_LEVEL 0xC00000a5 +#define NT_STATUS_CANT_OPEN_ANONYMOUS 0xC00000a6 +#define NT_STATUS_BAD_VALIDATION_CLASS 0xC00000a7 +#define NT_STATUS_BAD_TOKEN_TYPE 0xC00000a8 +#define NT_STATUS_BAD_MASTER_BOOT_RECORD 0xC00000a9 +#define NT_STATUS_INSTRUCTION_MISALIGNMENT 0xC00000aa +#define NT_STATUS_INSTANCE_NOT_AVAILABLE 0xC00000ab +#define NT_STATUS_PIPE_NOT_AVAILABLE 0xC00000ac +#define NT_STATUS_INVALID_PIPE_STATE 0xC00000ad +#define NT_STATUS_PIPE_BUSY 0xC00000ae +#define NT_STATUS_ILLEGAL_FUNCTION 0xC00000af +#define NT_STATUS_PIPE_DISCONNECTED 0xC00000b0 +#define NT_STATUS_PIPE_CLOSING 0xC00000b1 +#define NT_STATUS_PIPE_CONNECTED 0xC00000b2 +#define NT_STATUS_PIPE_LISTENING 0xC00000b3 +#define NT_STATUS_INVALID_READ_MODE 0xC00000b4 +#define NT_STATUS_IO_TIMEOUT 0xC00000b5 +#define NT_STATUS_FILE_FORCED_CLOSED 0xC00000b6 +#define NT_STATUS_PROFILING_NOT_STARTED 0xC00000b7 +#define NT_STATUS_PROFILING_NOT_STOPPED 0xC00000b8 +#define NT_STATUS_COULD_NOT_INTERPRET 0xC00000b9 +#define NT_STATUS_FILE_IS_A_DIRECTORY 0xC00000ba +#define NT_STATUS_NOT_SUPPORTED 0xC00000bb +#define NT_STATUS_REMOTE_NOT_LISTENING 0xC00000bc +#define NT_STATUS_DUPLICATE_NAME 0xC00000bd +#define NT_STATUS_BAD_NETWORK_PATH 0xC00000be +#define NT_STATUS_NETWORK_BUSY 0xC00000bf +#define NT_STATUS_DEVICE_DOES_NOT_EXIST 0xC00000c0 +#define NT_STATUS_TOO_MANY_COMMANDS 0xC00000c1 +#define NT_STATUS_ADAPTER_HARDWARE_ERROR 0xC00000c2 +#define NT_STATUS_INVALID_NETWORK_RESPONSE 0xC00000c3 +#define NT_STATUS_UNEXPECTED_NETWORK_ERROR 0xC00000c4 +#define NT_STATUS_BAD_REMOTE_ADAPTER 0xC00000c5 +#define NT_STATUS_PRINT_QUEUE_FULL 0xC00000c6 +#define NT_STATUS_NO_SPOOL_SPACE 0xC00000c7 +#define NT_STATUS_PRINT_CANCELLED 0xC00000c8 +#define NT_STATUS_NETWORK_NAME_DELETED 0xC00000c9 +#define NT_STATUS_NETWORK_ACCESS_DENIED 0xC00000ca +#define NT_STATUS_BAD_DEVICE_TYPE 0xC00000cb +#define NT_STATUS_BAD_NETWORK_NAME 0xC00000cc +#define NT_STATUS_TOO_MANY_NAMES 0xC00000cd +#define NT_STATUS_TOO_MANY_SESSIONS 0xC00000ce +#define NT_STATUS_SHARING_PAUSED 0xC00000cf +#define NT_STATUS_REQUEST_NOT_ACCEPTED 0xC00000d0 +#define NT_STATUS_REDIRECTOR_PAUSED 0xC00000d1 +#define NT_STATUS_NET_WRITE_FAULT 0xC00000d2 +#define NT_STATUS_PROFILING_AT_LIMIT 0xC00000d3 +#define NT_STATUS_NOT_SAME_DEVICE 0xC00000d4 +#define NT_STATUS_FILE_RENAMED 0xC00000d5 +#define NT_STATUS_VIRTUAL_CIRCUIT_CLOSED 0xC00000d6 +#define NT_STATUS_NO_SECURITY_ON_OBJECT 0xC00000d7 +#define NT_STATUS_CANT_WAIT 0xC00000d8 +#define NT_STATUS_PIPE_EMPTY 0xC00000d9 +#define NT_STATUS_CANT_ACCESS_DOMAIN_INFO 0xC00000da +#define NT_STATUS_CANT_TERMINATE_SELF 0xC00000db +#define NT_STATUS_INVALID_SERVER_STATE 0xC00000dc +#define NT_STATUS_INVALID_DOMAIN_STATE 0xC00000dd +#define NT_STATUS_INVALID_DOMAIN_ROLE 0xC00000de +#define NT_STATUS_NO_SUCH_DOMAIN 0xC00000df +#define NT_STATUS_DOMAIN_EXISTS 0xC00000e0 +#define NT_STATUS_DOMAIN_LIMIT_EXCEEDED 0xC00000e1 +#define NT_STATUS_OPLOCK_NOT_GRANTED 0xC00000e2 +#define NT_STATUS_INVALID_OPLOCK_PROTOCOL 0xC00000e3 +#define NT_STATUS_INTERNAL_DB_CORRUPTION 0xC00000e4 +#define NT_STATUS_INTERNAL_ERROR 0xC00000e5 +#define NT_STATUS_GENERIC_NOT_MAPPED 0xC00000e6 +#define NT_STATUS_BAD_DESCRIPTOR_FORMAT 0xC00000e7 +#define NT_STATUS_INVALID_USER_BUFFER 0xC00000e8 +#define NT_STATUS_UNEXPECTED_IO_ERROR 0xC00000e9 +#define NT_STATUS_UNEXPECTED_MM_CREATE_ERR 0xC00000ea +#define NT_STATUS_UNEXPECTED_MM_MAP_ERROR 0xC00000eb +#define NT_STATUS_UNEXPECTED_MM_EXTEND_ERR 0xC00000ec +#define NT_STATUS_NOT_LOGON_PROCESS 0xC00000ed +#define NT_STATUS_LOGON_SESSION_EXISTS 0xC00000ee +#define NT_STATUS_INVALID_PARAMETER_1 0xC00000ef +#define NT_STATUS_INVALID_PARAMETER_2 0xC00000f0 +#define NT_STATUS_INVALID_PARAMETER_3 0xC00000f1 +#define NT_STATUS_INVALID_PARAMETER_4 0xC00000f2 +#define NT_STATUS_INVALID_PARAMETER_5 0xC00000f3 +#define NT_STATUS_INVALID_PARAMETER_6 0xC00000f4 +#define NT_STATUS_INVALID_PARAMETER_7 0xC00000f5 +#define NT_STATUS_INVALID_PARAMETER_8 0xC00000f6 +#define NT_STATUS_INVALID_PARAMETER_9 0xC00000f7 +#define NT_STATUS_INVALID_PARAMETER_10 0xC00000f8 +#define NT_STATUS_INVALID_PARAMETER_11 0xC00000f9 +#define NT_STATUS_INVALID_PARAMETER_12 0xC00000fa +#define NT_STATUS_REDIRECTOR_NOT_STARTED 0xC00000fb +#define NT_STATUS_REDIRECTOR_STARTED 0xC00000fc +#define NT_STATUS_STACK_OVERFLOW 0xC00000fd +#define NT_STATUS_NO_SUCH_PACKAGE 0xC00000fe +#define NT_STATUS_BAD_FUNCTION_TABLE 0xC00000ff +#define NT_STATUS_DIRECTORY_NOT_EMPTY 0xC0000101 +#define NT_STATUS_FILE_CORRUPT_ERROR 0xC0000102 +#define NT_STATUS_NOT_A_DIRECTORY 0xC0000103 +#define NT_STATUS_BAD_LOGON_SESSION_STATE 0xC0000104 +#define NT_STATUS_LOGON_SESSION_COLLISION 0xC0000105 +#define NT_STATUS_NAME_TOO_LONG 0xC0000106 +#define NT_STATUS_FILES_OPEN 0xC0000107 +#define NT_STATUS_CONNECTION_IN_USE 0xC0000108 +#define NT_STATUS_MESSAGE_NOT_FOUND 0xC0000109 +#define NT_STATUS_PROCESS_IS_TERMINATING 0xC000010a +#define NT_STATUS_INVALID_LOGON_TYPE 0xC000010b +#define NT_STATUS_NO_GUID_TRANSLATION 0xC000010c +#define NT_STATUS_CANNOT_IMPERSONATE 0xC000010d +#define NT_STATUS_IMAGE_ALREADY_LOADED 0xC000010e +#define NT_STATUS_ABIOS_NOT_PRESENT 0xC000010f +#define NT_STATUS_ABIOS_LID_NOT_EXIST 0xC0000110 +#define NT_STATUS_ABIOS_LID_ALREADY_OWNED 0xC0000111 +#define NT_STATUS_ABIOS_NOT_LID_OWNER 0xC0000112 +#define NT_STATUS_ABIOS_INVALID_COMMAND 0xC0000113 +#define NT_STATUS_ABIOS_INVALID_LID 0xC0000114 +#define NT_STATUS_ABIOS_SELECTOR_NOT_AVAILABLE 0xC0000115 +#define NT_STATUS_ABIOS_INVALID_SELECTOR 0xC0000116 +#define NT_STATUS_NO_LDT 0xC0000117 +#define NT_STATUS_INVALID_LDT_SIZE 0xC0000118 +#define NT_STATUS_INVALID_LDT_OFFSET 0xC0000119 +#define NT_STATUS_INVALID_LDT_DESCRIPTOR 0xC000011a +#define NT_STATUS_INVALID_IMAGE_NE_FORMAT 0xC000011b +#define NT_STATUS_RXACT_INVALID_STATE 0xC000011c +#define NT_STATUS_RXACT_COMMIT_FAILURE 0xC000011d +#define NT_STATUS_MAPPED_FILE_SIZE_ZERO 0xC000011e +#define NT_STATUS_TOO_MANY_OPENED_FILES 0xC000011f +#define NT_STATUS_CANCELLED 0xC0000120 +#define NT_STATUS_CANNOT_DELETE 0xC0000121 +#define NT_STATUS_INVALID_COMPUTER_NAME 0xC0000122 +#define NT_STATUS_FILE_DELETED 0xC0000123 +#define NT_STATUS_SPECIAL_ACCOUNT 0xC0000124 +#define NT_STATUS_SPECIAL_GROUP 0xC0000125 +#define NT_STATUS_SPECIAL_USER 0xC0000126 +#define NT_STATUS_MEMBERS_PRIMARY_GROUP 0xC0000127 +#define NT_STATUS_FILE_CLOSED 0xC0000128 +#define NT_STATUS_TOO_MANY_THREADS 0xC0000129 +#define NT_STATUS_THREAD_NOT_IN_PROCESS 0xC000012a +#define NT_STATUS_TOKEN_ALREADY_IN_USE 0xC000012b +#define NT_STATUS_PAGEFILE_QUOTA_EXCEEDED 0xC000012c +#define NT_STATUS_COMMITMENT_LIMIT 0xC000012d +#define NT_STATUS_INVALID_IMAGE_LE_FORMAT 0xC000012e +#define NT_STATUS_INVALID_IMAGE_NOT_MZ 0xC000012f +#define NT_STATUS_INVALID_IMAGE_PROTECT 0xC0000130 +#define NT_STATUS_INVALID_IMAGE_WIN_16 0xC0000131 +#define NT_STATUS_LOGON_SERVER_CONFLICT 0xC0000132 +#define NT_STATUS_TIME_DIFFERENCE_AT_DC 0xC0000133 +#define NT_STATUS_SYNCHRONIZATION_REQUIRED 0xC0000134 +#define NT_STATUS_DLL_NOT_FOUND 0xC0000135 +#define NT_STATUS_OPEN_FAILED 0xC0000136 +#define NT_STATUS_IO_PRIVILEGE_FAILED 0xC0000137 +#define NT_STATUS_ORDINAL_NOT_FOUND 0xC0000138 +#define NT_STATUS_ENTRYPOINT_NOT_FOUND 0xC0000139 +#define NT_STATUS_CONTROL_C_EXIT 0xC000013a +#define NT_STATUS_LOCAL_DISCONNECT 0xC000013b +#define NT_STATUS_REMOTE_DISCONNECT 0xC000013c +#define NT_STATUS_REMOTE_RESOURCES 0xC000013d +#define NT_STATUS_LINK_FAILED 0xC000013e +#define NT_STATUS_LINK_TIMEOUT 0xC000013f +#define NT_STATUS_INVALID_CONNECTION 0xC0000140 +#define NT_STATUS_INVALID_ADDRESS 0xC0000141 +#define NT_STATUS_DLL_INIT_FAILED 0xC0000142 +#define NT_STATUS_MISSING_SYSTEMFILE 0xC0000143 +#define NT_STATUS_UNHANDLED_EXCEPTION 0xC0000144 +#define NT_STATUS_APP_INIT_FAILURE 0xC0000145 +#define NT_STATUS_PAGEFILE_CREATE_FAILED 0xC0000146 +#define NT_STATUS_NO_PAGEFILE 0xC0000147 +#define NT_STATUS_INVALID_LEVEL 0xC0000148 +#define NT_STATUS_WRONG_PASSWORD_CORE 0xC0000149 +#define NT_STATUS_ILLEGAL_FLOAT_CONTEXT 0xC000014a +#define NT_STATUS_PIPE_BROKEN 0xC000014b +#define NT_STATUS_REGISTRY_CORRUPT 0xC000014c +#define NT_STATUS_REGISTRY_IO_FAILED 0xC000014d +#define NT_STATUS_NO_EVENT_PAIR 0xC000014e +#define NT_STATUS_UNRECOGNIZED_VOLUME 0xC000014f +#define NT_STATUS_SERIAL_NO_DEVICE_INITED 0xC0000150 +#define NT_STATUS_NO_SUCH_ALIAS 0xC0000151 +#define NT_STATUS_MEMBER_NOT_IN_ALIAS 0xC0000152 +#define NT_STATUS_MEMBER_IN_ALIAS 0xC0000153 +#define NT_STATUS_ALIAS_EXISTS 0xC0000154 +#define NT_STATUS_LOGON_NOT_GRANTED 0xC0000155 +#define NT_STATUS_TOO_MANY_SECRETS 0xC0000156 +#define NT_STATUS_SECRET_TOO_LONG 0xC0000157 +#define NT_STATUS_INTERNAL_DB_ERROR 0xC0000158 +#define NT_STATUS_FULLSCREEN_MODE 0xC0000159 +#define NT_STATUS_TOO_MANY_CONTEXT_IDS 0xC000015a +#define NT_STATUS_LOGON_TYPE_NOT_GRANTED 0xC000015b +#define NT_STATUS_NOT_REGISTRY_FILE 0xC000015c +#define NT_STATUS_NT_CROSS_ENCRYPTION_REQUIRED 0xC000015d +#define NT_STATUS_DOMAIN_CTRLR_CONFIG_ERROR 0xC000015e +#define NT_STATUS_FT_MISSING_MEMBER 0xC000015f +#define NT_STATUS_ILL_FORMED_SERVICE_ENTRY 0xC0000160 +#define NT_STATUS_ILLEGAL_CHARACTER 0xC0000161 +#define NT_STATUS_UNMAPPABLE_CHARACTER 0xC0000162 +#define NT_STATUS_UNDEFINED_CHARACTER 0xC0000163 +#define NT_STATUS_FLOPPY_VOLUME 0xC0000164 +#define NT_STATUS_FLOPPY_ID_MARK_NOT_FOUND 0xC0000165 +#define NT_STATUS_FLOPPY_WRONG_CYLINDER 0xC0000166 +#define NT_STATUS_FLOPPY_UNKNOWN_ERROR 0xC0000167 +#define NT_STATUS_FLOPPY_BAD_REGISTERS 0xC0000168 +#define NT_STATUS_DISK_RECALIBRATE_FAILED 0xC0000169 +#define NT_STATUS_DISK_OPERATION_FAILED 0xC000016a +#define NT_STATUS_DISK_RESET_FAILED 0xC000016b +#define NT_STATUS_SHARED_IRQ_BUSY 0xC000016c +#define NT_STATUS_FT_ORPHANING 0xC000016d +#define NT_STATUS_PARTITION_FAILURE 0xC0000172 +#define NT_STATUS_INVALID_BLOCK_LENGTH 0xC0000173 +#define NT_STATUS_DEVICE_NOT_PARTITIONED 0xC0000174 +#define NT_STATUS_UNABLE_TO_LOCK_MEDIA 0xC0000175 +#define NT_STATUS_UNABLE_TO_UNLOAD_MEDIA 0xC0000176 +#define NT_STATUS_EOM_OVERFLOW 0xC0000177 +#define NT_STATUS_NO_MEDIA 0xC0000178 +#define NT_STATUS_NO_SUCH_MEMBER 0xC000017a +#define NT_STATUS_INVALID_MEMBER 0xC000017b +#define NT_STATUS_KEY_DELETED 0xC000017c +#define NT_STATUS_NO_LOG_SPACE 0xC000017d +#define NT_STATUS_TOO_MANY_SIDS 0xC000017e +#define NT_STATUS_LM_CROSS_ENCRYPTION_REQUIRED 0xC000017f +#define NT_STATUS_KEY_HAS_CHILDREN 0xC0000180 +#define NT_STATUS_CHILD_MUST_BE_VOLATILE 0xC0000181 +#define NT_STATUS_DEVICE_CONFIGURATION_ERROR 0xC0000182 +#define NT_STATUS_DRIVER_INTERNAL_ERROR 0xC0000183 +#define NT_STATUS_INVALID_DEVICE_STATE 0xC0000184 +#define NT_STATUS_IO_DEVICE_ERROR 0xC0000185 +#define NT_STATUS_DEVICE_PROTOCOL_ERROR 0xC0000186 +#define NT_STATUS_BACKUP_CONTROLLER 0xC0000187 +#define NT_STATUS_LOG_FILE_FULL 0xC0000188 +#define NT_STATUS_TOO_LATE 0xC0000189 +#define NT_STATUS_NO_TRUST_LSA_SECRET 0xC000018a +#define NT_STATUS_NO_TRUST_SAM_ACCOUNT 0xC000018b +#define NT_STATUS_TRUSTED_DOMAIN_FAILURE 0xC000018c +#define NT_STATUS_TRUSTED_RELATIONSHIP_FAILURE 0xC000018d +#define NT_STATUS_EVENTLOG_FILE_CORRUPT 0xC000018e +#define NT_STATUS_EVENTLOG_CANT_START 0xC000018f +#define NT_STATUS_TRUST_FAILURE 0xC0000190 +#define NT_STATUS_MUTANT_LIMIT_EXCEEDED 0xC0000191 +#define NT_STATUS_NETLOGON_NOT_STARTED 0xC0000192 +#define NT_STATUS_ACCOUNT_EXPIRED 0xC0000193 +#define NT_STATUS_POSSIBLE_DEADLOCK 0xC0000194 +#define NT_STATUS_NETWORK_CREDENTIAL_CONFLICT 0xC0000195 +#define NT_STATUS_REMOTE_SESSION_LIMIT 0xC0000196 +#define NT_STATUS_EVENTLOG_FILE_CHANGED 0xC0000197 +#define NT_STATUS_NOLOGON_INTERDOMAIN_TRUST_ACCOUNT 0xC0000198 +#define NT_STATUS_NOLOGON_WORKSTATION_TRUST_ACCOUNT 0xC0000199 +#define NT_STATUS_NOLOGON_SERVER_TRUST_ACCOUNT 0xC000019a +#define NT_STATUS_DOMAIN_TRUST_INCONSISTENT 0xC000019b +#define NT_STATUS_FS_DRIVER_REQUIRED 0xC000019c +#define NT_STATUS_NO_USER_SESSION_KEY 0xC0000202 +#define NT_STATUS_USER_SESSION_DELETED 0xC0000203 +#define NT_STATUS_RESOURCE_LANG_NOT_FOUND 0xC0000204 +#define NT_STATUS_INSUFF_SERVER_RESOURCES 0xC0000205 +#define NT_STATUS_INVALID_BUFFER_SIZE 0xC0000206 +#define NT_STATUS_INVALID_ADDRESS_COMPONENT 0xC0000207 +#define NT_STATUS_INVALID_ADDRESS_WILDCARD 0xC0000208 +#define NT_STATUS_TOO_MANY_ADDRESSES 0xC0000209 +#define NT_STATUS_ADDRESS_ALREADY_EXISTS 0xC000020a +#define NT_STATUS_ADDRESS_CLOSED 0xC000020b +#define NT_STATUS_CONNECTION_DISCONNECTED 0xC000020c +#define NT_STATUS_CONNECTION_RESET 0xC000020d +#define NT_STATUS_TOO_MANY_NODES 0xC000020e +#define NT_STATUS_TRANSACTION_ABORTED 0xC000020f +#define NT_STATUS_TRANSACTION_TIMED_OUT 0xC0000210 +#define NT_STATUS_TRANSACTION_NO_RELEASE 0xC0000211 +#define NT_STATUS_TRANSACTION_NO_MATCH 0xC0000212 +#define NT_STATUS_TRANSACTION_RESPONDED 0xC0000213 +#define NT_STATUS_TRANSACTION_INVALID_ID 0xC0000214 +#define NT_STATUS_TRANSACTION_INVALID_TYPE 0xC0000215 +#define NT_STATUS_NOT_SERVER_SESSION 0xC0000216 +#define NT_STATUS_NOT_CLIENT_SESSION 0xC0000217 +#define NT_STATUS_CANNOT_LOAD_REGISTRY_FILE 0xC0000218 +#define NT_STATUS_DEBUG_ATTACH_FAILED 0xC0000219 +#define NT_STATUS_SYSTEM_PROCESS_TERMINATED 0xC000021a +#define NT_STATUS_DATA_NOT_ACCEPTED 0xC000021b +#define NT_STATUS_NO_BROWSER_SERVERS_FOUND 0xC000021c +#define NT_STATUS_VDM_HARD_ERROR 0xC000021d +#define NT_STATUS_DRIVER_CANCEL_TIMEOUT 0xC000021e +#define NT_STATUS_REPLY_MESSAGE_MISMATCH 0xC000021f +#define NT_STATUS_MAPPED_ALIGNMENT 0xC0000220 +#define NT_STATUS_IMAGE_CHECKSUM_MISMATCH 0xC0000221 +#define NT_STATUS_LOST_WRITEBEHIND_DATA 0xC0000222 +#define NT_STATUS_CLIENT_SERVER_PARAMETERS_INVALID 0xC0000223 +#define NT_STATUS_PASSWORD_MUST_CHANGE 0xC0000224 +#define NT_STATUS_NOT_FOUND 0xC0000225 +#define NT_STATUS_NOT_TINY_STREAM 0xC0000226 +#define NT_STATUS_RECOVERY_FAILURE 0xC0000227 +#define NT_STATUS_STACK_OVERFLOW_READ 0xC0000228 +#define NT_STATUS_FAIL_CHECK 0xC0000229 +#define NT_STATUS_DUPLICATE_OBJECTID 0xC000022a +#define NT_STATUS_OBJECTID_EXISTS 0xC000022b +#define NT_STATUS_CONVERT_TO_LARGE 0xC000022c +#define NT_STATUS_RETRY 0xC000022d +#define NT_STATUS_FOUND_OUT_OF_SCOPE 0xC000022e +#define NT_STATUS_ALLOCATE_BUCKET 0xC000022f +#define NT_STATUS_PROPSET_NOT_FOUND 0xC0000230 +#define NT_STATUS_MARSHALL_OVERFLOW 0xC0000231 +#define NT_STATUS_INVALID_VARIANT 0xC0000232 +#define NT_STATUS_DOMAIN_CONTROLLER_NOT_FOUND 0xC0000233 +#define NT_STATUS_ACCOUNT_LOCKED_OUT 0xC0000234 +#define NT_STATUS_HANDLE_NOT_CLOSABLE 0xC0000235 +#define NT_STATUS_CONNECTION_REFUSED 0xC0000236 +#define NT_STATUS_GRACEFUL_DISCONNECT 0xC0000237 +#define NT_STATUS_ADDRESS_ALREADY_ASSOCIATED 0xC0000238 +#define NT_STATUS_ADDRESS_NOT_ASSOCIATED 0xC0000239 +#define NT_STATUS_CONNECTION_INVALID 0xC000023a +#define NT_STATUS_CONNECTION_ACTIVE 0xC000023b +#define NT_STATUS_NETWORK_UNREACHABLE 0xC000023c +#define NT_STATUS_HOST_UNREACHABLE 0xC000023d +#define NT_STATUS_PROTOCOL_UNREACHABLE 0xC000023e +#define NT_STATUS_PORT_UNREACHABLE 0xC000023f +#define NT_STATUS_REQUEST_ABORTED 0xC0000240 +#define NT_STATUS_CONNECTION_ABORTED 0xC0000241 +#define NT_STATUS_BAD_COMPRESSION_BUFFER 0xC0000242 +#define NT_STATUS_USER_MAPPED_FILE 0xC0000243 +#define NT_STATUS_AUDIT_FAILED 0xC0000244 +#define NT_STATUS_TIMER_RESOLUTION_NOT_SET 0xC0000245 +#define NT_STATUS_CONNECTION_COUNT_LIMIT 0xC0000246 +#define NT_STATUS_LOGIN_TIME_RESTRICTION 0xC0000247 +#define NT_STATUS_LOGIN_WKSTA_RESTRICTION 0xC0000248 +#define NT_STATUS_IMAGE_MP_UP_MISMATCH 0xC0000249 +#define NT_STATUS_INSUFFICIENT_LOGON_INFO 0xC0000250 +#define NT_STATUS_BAD_DLL_ENTRYPOINT 0xC0000251 +#define NT_STATUS_BAD_SERVICE_ENTRYPOINT 0xC0000252 +#define NT_STATUS_LPC_REPLY_LOST 0xC0000253 +#define NT_STATUS_IP_ADDRESS_CONFLICT1 0xC0000254 +#define NT_STATUS_IP_ADDRESS_CONFLICT2 0xC0000255 +#define NT_STATUS_REGISTRY_QUOTA_LIMIT 0xC0000256 +#define NT_STATUS_PATH_NOT_COVERED 0xC0000257 +#define NT_STATUS_NO_CALLBACK_ACTIVE 0xC0000258 +#define NT_STATUS_LICENSE_QUOTA_EXCEEDED 0xC0000259 +#define NT_STATUS_PWD_TOO_SHORT 0xC000025a +#define NT_STATUS_PWD_TOO_RECENT 0xC000025b +#define NT_STATUS_PWD_HISTORY_CONFLICT 0xC000025c +#define NT_STATUS_PLUGPLAY_NO_DEVICE 0xC000025e +#define NT_STATUS_UNSUPPORTED_COMPRESSION 0xC000025f +#define NT_STATUS_INVALID_HW_PROFILE 0xC0000260 +#define NT_STATUS_INVALID_PLUGPLAY_DEVICE_PATH 0xC0000261 +#define NT_STATUS_DRIVER_ORDINAL_NOT_FOUND 0xC0000262 +#define NT_STATUS_DRIVER_ENTRYPOINT_NOT_FOUND 0xC0000263 +#define NT_STATUS_RESOURCE_NOT_OWNED 0xC0000264 +#define NT_STATUS_TOO_MANY_LINKS 0xC0000265 +#define NT_STATUS_QUOTA_LIST_INCONSISTENT 0xC0000266 +#define NT_STATUS_FILE_IS_OFFLINE 0xC0000267 +#define NT_STATUS_NOT_A_REPARSE_POINT 0xC0000275 +#define NT_STATUS_NO_SUCH_JOB 0xC0000EDE + %pythoncode %{ NTSTATUS = _dcerpc.NTSTATUS %} diff --git a/source4/scripting/swig/torture/samr.py b/source4/scripting/swig/torture/samr.py index 9bf50cbefb..68b065b677 100755 --- a/source4/scripting/swig/torture/samr.py +++ b/source4/scripting/swig/torture/samr.py @@ -148,9 +148,9 @@ def test_CreateUser2(pipe, domain_handle): try: dcerpc.samr_CreateUser2(pipe, r) except dcerpc.NTSTATUS, arg: - if arg[0] == 0xc0000022: + if arg[0] == dcerpc.NT_STATUS_ACCESS_DENIED: return - elif arg[0] == 0xc0000063: + elif arg[0] == dcerpc.NT_STATUS_USER_EXISTS: test_DeleteUser_byname(pipe, domain_handle, 'samrtorturemach$') result = dcerpc.samr_CreateUser(pipe, r) else: @@ -177,7 +177,7 @@ def test_LookupName(pipe, domain_handle, name): try: dcerpc.samr_LookupNames(pipe, r) except dcerpc.NTSTATUS, arg: - if arg[0] != 0x00000107: + if arg[0] != dcerpc.STATUS_SOME_UNMAPPED: raise dcerpc.NTSTATUS(arg) r['num_names'] = 0 @@ -273,7 +273,7 @@ def test_TestPrivateFunctionsUser(pipe, user_handle): try: dcerpc.samr_TestPrivateFunctionsUser(pipe, r) except dcerpc.NTSTATUS, arg: - if arg[0] != 0xc0000002: + if arg[0] != dcerpc.NT_STATUS_NOT_IMPLEMENTED: raise dcerpc.NTSTATUS(arg) def test_user_ops(pipe, user_handle): @@ -305,9 +305,9 @@ def test_CreateUser(pipe, domain_handle): try: result = dcerpc.samr_CreateUser(pipe, r) except dcerpc.NTSTATUS, arg: - if arg[0] == 0xc0000022: + if arg[0] == dcerpc.NT_STATUS_ACCESS_DENIED: return - elif arg[0] == 0xc0000063: + elif arg[0] == dcerpc.NT_STATUS_USER_EXISTS: test_DeleteUser_byname(pipe, domain_handle, 'samrtorturetest') result = dcerpc.samr_CreateUser(pipe, r) else: @@ -439,9 +439,9 @@ def test_CreateAlias(pipe, domain_handle, domain_sid): try: result = dcerpc.samr_CreateDomAlias(pipe, r) except dcerpc.NTSTATUS, arg: - if arg[0] == 0xc0000022: + if arg[0] == dcerpc.NT_STATUS_ACCESS_DENIED: return - if arg[0] != 0xc0000063: + if arg[0] != dcerpc.NT_STATUS_USER_EXISTS: raise dcerpc.NTSTATUS(arg) test_DeleteAlias_byname(pipe, domain_handle, alias_name) result = dcerpc.samr_CreateDomAlias(pipe, r) @@ -483,9 +483,9 @@ def test_CreateDomainGroup(pipe, domain_handle): try: result = dcerpc.samr_CreateDomainGroup(pipe, r) except dcerpc.NTSTATUS, arg: - if arg[0] == 0xc0000022: + if arg[0] == dcerpc.NT_STATUS_ACCESS_DENIED: return - if arg[0] != 0xc0000065: + if arg[0] != dcerpc.NT_STATUS_GROUP_EXISTS: raise dcerpc.NTSTATUS(arg) test_DeleteGroup_byname(pipe, domain_handle, 'samrtorturetestgroup') @@ -519,7 +519,7 @@ def test_QueryDomainInfo(pipe, domain_handle): except dcerpc.NTSTATUS, arg: if set_ok[i]: raise dcerpc.NTSTATUS(arg) - if arg[0] != 0xc0000003: + if arg[0] != dcerpc.NT_STATUS_INVALID_INFO_CLASS: raise dcerpc.NTSTATUS(arg) def test_QueryDomainInfo2(pipe, domain_handle): @@ -548,7 +548,7 @@ def test_EnumDomainUsers(pipe, domain_handle): while 1: result = dcerpc.samr_EnumDomainUsers(pipe, r) - if result['result'] == 0x00000105: + if result['result'] == dcerpc.STATUS_MORE_ENTRIES: r['resume_handle'] = result['resume_handle'] continue break @@ -565,7 +565,7 @@ def test_EnumDomainGroups(pipe, domain_handle): while 1: result = dcerpc.samr_EnumDomainGroups(pipe, r) - if result['result'] == 0x00000105: + if result['result'] == dcerpc.STATUS_MORE_ENTRIES: r['resume_handle'] = result['resume_handle'] continue break @@ -582,7 +582,7 @@ def test_EnumDomainAliases(pipe, domain_handle): while 1: result = dcerpc.samr_EnumDomainAliases(pipe, r) - if result['result'] == 0x00000105: + if result['result'] == dcerpc.STATUS_MORE_ENTRIES: r['resume_handle'] = result['resume_handle'] continue break @@ -710,7 +710,7 @@ def test_TestPrivateFunctionsDomain(pipe, domain_handle): try: dcerpc.samr_TestPrivateFunctionsDomain(pipe, r) except dcerpc.NTSTATUS, arg: - if arg[0] != 0xc0000002: + if arg[0] != dcerpc.NT_STATUS_NOT_IMPLEMENTED: raise dcerpc.NTSTATUS(arg) def test_RidToSid(pipe, domain_handle): @@ -839,7 +839,7 @@ def test_LookupDomain(pipe, connect_handle, domain): try: dcerpc.samr_LookupDomain(pipe, r) except dcerpc.NTSTATUS, arg: - if arg[0] != 0xc000000d: + if arg[0] != dcerpc.NT_STATUS_INVALID_PARAMETER: raise dcerpc.NTSTATUS(arg) r['domain']['name'] = 'xxNODOMAINxx' @@ -847,7 +847,7 @@ def test_LookupDomain(pipe, connect_handle, domain): try: dcerpc.samr_LookupDomain(pipe, r) except dcerpc.NTSTATUS, arg: - if arg[0] != 0xc00000df: + if arg[0] != dcerpc.NT_STATUS_NO_SUCH_DOMAIN: raise dcerpc.NTSTATUS(arg) r['domain']['name'] = domain -- cgit From 169627d7f55f9f58a6564a9efe659a529bbf348a Mon Sep 17 00:00:00 2001 From: Tim Potter Date: Thu, 23 Sep 2004 02:21:11 +0000 Subject: r2555: Start of a rpcclient type program. (This used to be commit c9d682731226b7ef222f588c43df5a1f62c21555) --- source4/scripting/swig/rpcclient | 154 ++++++++++++++++++++++++++++++++++++ source4/scripting/swig/samr.py | 165 +++++++++++++++++++++++++++++++++++++++ 2 files changed, 319 insertions(+) create mode 100755 source4/scripting/swig/rpcclient create mode 100644 source4/scripting/swig/samr.py (limited to 'source4/scripting') diff --git a/source4/scripting/swig/rpcclient b/source4/scripting/swig/rpcclient new file mode 100755 index 0000000000..2a3d12cc8e --- /dev/null +++ b/source4/scripting/swig/rpcclient @@ -0,0 +1,154 @@ +#!/usr/bin/python + +import sys, os, string +from cmd import Cmd +from optparse import OptionParser + + +import dcerpc, samr + +class rpcclient(Cmd): + + prompt = 'rpcclient$ ' + + def __init__(self, binding, domain, username, password): + Cmd.__init__(self) + self.binding = binding + self.domain = domain + self.username = username + self.password = password + + def emptyline(self): + + # Default for empty line is to repeat last command - yuck + + pass + + def onecmd(self, line): + + # Override the onecmd() method so we can trap error returns + + try: + Cmd.onecmd(self, line) + except dcerpc.NTSTATUS, arg: + print 'The command returned an error: %s' % arg[1] + + # Command handlers + + def do_help(self, line): + """Displays on-line help for rpcclient commands.""" + Cmd.do_help(self, line) + + def do_shell(self, line): + + status = os.system(line) + + if os.WIFEXITED(status): + if os.WEXITSTATUS(status) != 0: + print 'Command exited with code %d' % os.WEXITSTATUS(status) + else: + print 'Command exited with signal %d' % os.WTERMSIG(status) + + def do_EOF(self, line): + """Exits rpcclient.""" + print + sys.exit(0) + + # SAMR pipe commands + + def do_SamrEnumDomains(self, line): + """Enumerate domain names.""" + + usage = 'usage: SamrEnumDomains' + + if line != '': + print usage + return + + pipe = dcerpc.pipe_connect( + self.binding, + dcerpc.DCERPC_SAMR_UUID, dcerpc.DCERPC_SAMR_VERSION, + self.domain, self.username, self.password) + + connect_handle = samr.Connect(pipe) + + for i in connect_handle.EnumDomains(): + print i + + def do_SamrLookupDomain(self, line): + """Return the SID for a domain.""" + + usage = 'SamrLookupDomain DOMAIN' + + parser = OptionParser(usage) + options, args = parser.parse_args(string.split(line)) + + if len(args) != 1: + print 'usage:', usage + return + + pipe = dcerpc.pipe_connect( + self.binding, + dcerpc.DCERPC_SAMR_UUID, dcerpc.DCERPC_SAMR_VERSION, + self.domain, self.username, self.password) + + connect_handle = samr.Connect(pipe) + + print connect_handle.LookupDomain(args[0]) + +if __name__ == '__main__': + + # Parse command line + + usage = 'rpcclient BINDING [options]' + + if len(sys.argv) == 1: + print usage + sys.exit(1) + + binding = sys.argv[1] + del(sys.argv[1]) + + if string.find(binding, ':') == -1: + binding = 'ncacn_np:' + binding + + parser = OptionParser(usage) + + parser.add_option('-U', '--username', action='store', type='string', + help='Use given credentials when connecting', + metavar='DOMAIN\\username%password', + dest='username') + + parser.add_option('-c', '--command', action='store', type='string', + help='Execute COMMAND', dest='command') + + options, args = parser.parse_args() + + # Break --username up into domain, usernamd and password + + if not options.username: + options.username = '%' + + domain = '' + if string.find(options.username, '\\') != -1: + domain, options.username = string.split(options.username, '\\') + + password = '' + if string.find(options.username, '%') != -1: + options.username, password = string.split(options.username, '%') + + username = options.username + + # Run command loop + + c = rpcclient(binding, domain, username, password) + + if options.command: + c.onecmd(options.command) + sys.exit(0) + + while 1: + try: + c.cmdloop() + except KeyboardInterrupt: + print 'KeyboardInterrupt' diff --git a/source4/scripting/swig/samr.py b/source4/scripting/swig/samr.py new file mode 100644 index 0000000000..5fd87da3ad --- /dev/null +++ b/source4/scripting/swig/samr.py @@ -0,0 +1,165 @@ +import dcerpc + +def sid_to_string(sid): + """Convert a Python dictionary SID to a string SID.""" + + result = 'S-%d' % sid['sid_rev_num'] + + ia = sid['id_auth'] + + result = result + '-%u' % (ia[5] + (ia[4] << 8) + (ia[3] << 16) + \ + (ia[2] << 24)) + + for i in range(0, sid['num_auths']): + result = result + '-%u' % sid['sub_auths'][i] + + return result + +def string_to_sid(string): + """Convert a string SID to a Python dictionary SID. Throws a + ValueError if the SID string was badly formed.""" + + if string[0] != 'S': + raise ValueError('Bad SID format') + + string = string[1:] + + import re + + match = re.match('-\d+', string) + + if not match: + raise ValueError('Bad SID format') + + try: + sid_rev_num = int(string[match.start()+1:match.end()]) + except ValueError: + raise ValueError('Bad SID format') + + string = string[match.end():] + + match = re.match('-\d+', string) + + if not match: + raise ValueError('Bad SID format') + + try: + ia = int(string[match.start()+1:match.end()]) + except ValueError: + raise ValueError('Bad SID format') + + string = string[match.end():] + + id_auth = [0, 0, (ia >> 24) & 0xff, (ia >> 16) & 0xff, + (ia >> 8) & 0xff, ia & 0xff] + + num_auths = 0 + sub_auths = [] + + while len(string): + + match = re.match('-\d+', string) + + if not match: + raise ValueError('Bad SID format') + + try: + sa = int(string[match.start() + 1 : match.end()]) + except ValueError: + raise ValueError('Bad SID format') + + num_auths = num_auths + 1 + sub_auths.append(int(sa)) + + string = string[match.end():] + + print map(type, sub_auths) + + return {'sid_rev_num': sid_rev_num, 'id_auth': id_auth, + 'num_auths': num_auths, 'sub_auths': sub_auths} + +class SamrHandle: + + def __init__(self, pipe, handle): + + self.pipe = pipe + self.handle = handle + + def __del__(self): + + r = {} + r['handle'] = self.handle + + dcerpc.samr_Close(self.pipe, r) + +class ConnectHandle(SamrHandle): + + def EnumDomains(self): + + r = {} + r['connect_handle'] = self.handle + r['resume_handle'] = 0 + r['buf_size'] = -1 + + domains = [] + + while 1: + + result = dcerpc.samr_EnumDomains(self.pipe, r) + + domains = domains + result['sam']['entries'] + + if result['result'] == dcerpc.STATUS_MORE_ENTRIES: + r['resume_handle'] = result['resume_handle'] + continue + + break + + return map(lambda x: x['name']['name'], domains) + + def LookupDomain(self, domain_name): + + r = {} + r['connect_handle'] = self.handle + r['domain'] = {} + r['domain']['name_len'] = 0 + r['domain']['name_size'] = 0 + r['domain']['name'] = domain_name + + result = dcerpc.samr_LookupDomain(self.pipe, r) + + return sid_to_string(result['sid']) + + def OpenDomain(self, domain_sid, access_mask = 0x02000000): + + r = {} + r['connect_handle'] = self.handle + r['access_mask'] = access_mask + r['sid'] = string_to_sid(domain_sid) + + result = dcerpc.samr_OpenDomain(self.pipe, r) + + return DomainHandle(pipe, result['domain_handle']) + +class DomainHandle(SamrHandle): + + def QueryDomainInfo(self, level = 2): + + r = {} + r['domain_handle'] = self.domain_handle + r['level'] = level + + result = dcerpc.samr_QueryDomainInfo(pipe, r) + + return result + +def Connect(pipe, system_name = None, access_mask = 0x02000000): + """Connect to the SAMR pipe.""" + + r = {} + r['system_name'] = system_name + r['access_mask'] = access_mask + + result = dcerpc.samr_Connect2(pipe, r) + + return ConnectHandle(pipe, result['connect_handle']) -- cgit From 46cbe76a2c8c60bf14df941b2fcf6b8c5cad10e5 Mon Sep 17 00:00:00 2001 From: Tim Potter Date: Thu, 23 Sep 2004 03:26:14 +0000 Subject: r2559: Python ints can't hold the full range of uint32 values so store them as Python longs. Also allow shorter width integer types to be initialised from long values. Their values are truncated if they are too long. (This used to be commit e9eb231d6441774d1b5227962bbe94aa29e20995) --- source4/scripting/swig/dcerpc.i | 65 ++++++++++++++++++++++------------ source4/scripting/swig/torture/samr.py | 12 +++++++ 2 files changed, 55 insertions(+), 22 deletions(-) (limited to 'source4/scripting') diff --git a/source4/scripting/swig/dcerpc.i b/source4/scripting/swig/dcerpc.i index 7a8a0e4a83..eb8b065e33 100644 --- a/source4/scripting/swig/dcerpc.i +++ b/source4/scripting/swig/dcerpc.i @@ -58,12 +58,15 @@ uint8 uint8_from_python(PyObject *obj, char *name) return 0; } - if (!PyInt_Check(obj)) { - PyErr_Format(PyExc_TypeError, "Expecting int value for %s", name); + if (!PyInt_Check(obj) && !PyLong_Check(obj)) { + PyErr_Format(PyExc_TypeError, "Expecting int or long value for %s", name); return 0; } - return (uint8)PyInt_AsLong(obj); + if (PyLong_Check(obj)) + return (uint8)PyLong_AsLong(obj); + else + return (uint8)PyInt_AsLong(obj); } PyObject *uint8_to_python(uint8 obj) @@ -78,12 +81,15 @@ uint16 uint16_from_python(PyObject *obj, char *name) return 0; } - if (!PyInt_Check(obj)) { - PyErr_Format(PyExc_TypeError, "Expecting int value for %s", name); + if (!PyInt_Check(obj) && !PyLong_Check(obj)) { + PyErr_Format(PyExc_TypeError, "Expecting int or long value for %s", name); return 0; } - return (uint16)PyInt_AsLong(obj); + if (PyLong_Check(obj)) + return (uint16)PyLong_AsLong(obj); + else + return (uint16)PyInt_AsLong(obj); } PyObject *uint16_to_python(uint16 obj) @@ -98,17 +104,20 @@ uint32 uint32_from_python(PyObject *obj, char *name) return 0; } - if (!PyInt_Check(obj)) { - PyErr_Format(PyExc_TypeError, "Expecting int value for %s", name); + if (!PyLong_Check(obj) && !PyInt_Check(obj)) { + PyErr_Format(PyExc_TypeError, "Expecting int or long value for %s", name); return 0; } - return (uint32)PyInt_AsLong(obj); + if (PyLong_Check(obj)) + return (uint32)PyLong_AsLong(obj); + else + return (uint32)PyInt_AsLong(obj); } PyObject *uint32_to_python(uint32 obj) { - return PyInt_FromLong(obj); + return PyLong_FromLong(obj); } int64 int64_from_python(PyObject *obj, char *name) @@ -118,12 +127,15 @@ int64 int64_from_python(PyObject *obj, char *name) return 0; } - if (!PyLong_Check(obj)) { - PyErr_Format(PyExc_TypeError, "Expecting long value for %s", name); + if (!PyLong_Check(obj) && !PyInt_Check(obj)) { + PyErr_Format(PyExc_TypeError, "Expecting int or long value for %s", name); return 0; } - return (int64)PyLong_AsLongLong(obj); + if (PyLong_Check(obj)) + return (int64)PyLong_AsLongLong(obj); + else + return (int64)PyInt_AsLong(obj); } PyObject *int64_to_python(int64 obj) @@ -138,12 +150,15 @@ uint64 uint64_from_python(PyObject *obj, char *name) return 0; } - if (!PyLong_Check(obj)) { - PyErr_Format(PyExc_TypeError, "Expecting long value for %s", name); + if (!PyLong_Check(obj) && !PyInt_Check(obj)) { + PyErr_Format(PyExc_TypeError, "Expecting int or long value for %s", name); return 0; } - return (uint64)PyLong_AsUnsignedLongLong(obj); + if (PyLong_Check(obj)) + return (uint64)PyLong_AsUnsignedLongLong(obj); + else + return (uint64)PyInt_AsLong(obj); } PyObject *uint64_to_python(uint64 obj) @@ -158,12 +173,15 @@ NTTIME NTTIME_from_python(PyObject *obj, char *name) return 0; } - if (!PyLong_Check(obj)) { - PyErr_Format(PyExc_TypeError, "Expecting long value for %s", name); + if (!PyLong_Check(obj) && !PyInt_Check(obj)) { + PyErr_Format(PyExc_TypeError, "Expecting int or long value for %s", name); return 0; } - return (NTTIME)PyLong_AsUnsignedLongLong(obj); + if (PyLong_Check(obj)) + return (NTTIME)PyLong_AsUnsignedLongLong(obj); + else + return (NTTIME)PyInt_AsUnsignedLongMask(obj); } PyObject *NTTIME_to_python(NTTIME obj) @@ -178,12 +196,15 @@ HYPER_T HYPER_T_from_python(PyObject *obj, char *name) return 0; } - if (!PyLong_Check(obj)) { - PyErr_Format(PyExc_TypeError, "Expecting long value for %s", name); + if (!PyLong_Check(obj) && !PyInt_Check(obj)) { + PyErr_Format(PyExc_TypeError, "Expecting int or long value for %s", name); return 0; } - return (HYPER_T)PyLong_AsUnsignedLongLong(obj); + if (PyLong_Check(obj)) + return (HYPER_T)PyLong_AsUnsignedLongLong(obj); + else + return (HYPER_T)PyInt_AsUnsignedLongMask(obj); } PyObject *HYPER_T_to_python(HYPER_T obj) diff --git a/source4/scripting/swig/torture/samr.py b/source4/scripting/swig/torture/samr.py index 68b065b677..e462087ca0 100755 --- a/source4/scripting/swig/torture/samr.py +++ b/source4/scripting/swig/torture/samr.py @@ -872,6 +872,16 @@ def test_EnumDomains(pipe, connect_handle): for domain in result['sam']['entries']: test_LookupDomain(pipe, handle, domain['name']['name']) +def test_LongInt(pipe): + + # Check that we can use long values for shorter width types + + r = {} + r['system_name'] = 0L; + r['access_mask'] = 0x02000000L + + result = dcerpc.samr_Connect(pipe, r) + # Parse command line parser = OptionParser() @@ -908,6 +918,8 @@ pipe = dcerpc.pipe_connect(binding, dcerpc.DCERPC_SAMR_UUID, dcerpc.DCERPC_SAMR_VERSION, domain, username, password) +test_LongInt(pipe) + handle = test_Connect(pipe) test_QuerySecurity(pipe, handle) -- cgit From 5821c39553f1d9899f6bcfb703876de767ccebf4 Mon Sep 17 00:00:00 2001 From: Tim Potter Date: Thu, 23 Sep 2004 03:32:46 +0000 Subject: r2560: Don't require structure fields that have the pidl value() property to be set. They can be if you want, but will be overwritten by the pidl push code. (This used to be commit 3170f6ed84e0514bf18d2a346f153bf0231b245b) --- source4/scripting/swig/torture/samr.py | 28 ++-------------------------- 1 file changed, 2 insertions(+), 26 deletions(-) (limited to 'source4/scripting') diff --git a/source4/scripting/swig/torture/samr.py b/source4/scripting/swig/torture/samr.py index e462087ca0..07bbaf3a93 100755 --- a/source4/scripting/swig/torture/samr.py +++ b/source4/scripting/swig/torture/samr.py @@ -100,8 +100,6 @@ def test_GetDomPwInfo(pipe, domain): r = {} r['handle'] = handle r['name'] = {} - r['name']['name_len'] = 0 - r['name']['name_size'] = 0 r['name']['name'] = domain dcerpc.samr_GetDomPwInfo(pipe, r) @@ -140,8 +138,6 @@ def test_CreateUser2(pipe, domain_handle): r['domain_handle'] = domain_handle r['access_mask'] = 0x02000000 r['account_name'] = {} - r['account_name']['name_len'] = 0 - r['account_name']['name_size'] = 0 r['account_name']['name'] = 'samrtorturemach$' r['acct_flags'] = 0x0080 # WSTRUST @@ -164,14 +160,14 @@ def test_LookupName(pipe, domain_handle, name): r['domain_handle'] = domain_handle r['num_names'] = 1 r['names'] = [] - r['names'].append({'name_len': 0, 'name_size': 0, 'name': name}) + r['names'].append({'name': name}) result = dcerpc.samr_LookupNames(pipe, r) rid = result['rids']['ids'][0] r['num_names'] = 2 - r['names'].append({'name_len': 0, 'name_size': 0, 'name': 'xxNONAMExx'}) + r['names'].append({'name': 'xxNONAMExx'}) try: @@ -242,12 +238,8 @@ def test_SetUserInfo(pipe, user_handle): r['info'] = {} r['info']['info2'] = {} r['info']['info2']['comment'] = {} - r['info']['info2']['comment']['name_len'] = 0 - r['info']['info2']['comment']['name_size'] = 0 r['info']['info2']['comment']['name'] = 'hello' r['info']['info2']['unknown'] = {} - r['info']['info2']['unknown']['name_len'] = 0 - r['info']['info2']['unknown']['name_size'] = 0 r['info']['info2']['unknown']['name'] = None r['info']['info2']['country_code'] = 0 r['info']['info2']['code_page'] = 0 @@ -297,8 +289,6 @@ def test_CreateUser(pipe, domain_handle): r = {} r['domain_handle'] = domain_handle r['account_name'] = {} - r['account_name']['name_len'] = 0 - r['account_name']['name_size'] = 0 r['account_name']['name'] = 'samrtorturetest' r['access_mask'] = 0x02000000 @@ -360,8 +350,6 @@ def test_SetAliasInfo(pipe, alias_handle): r['level'] = 2 r['info'] = {} r['info']['name'] = {} - r['info']['name']['name_len'] = 0 - r['info']['name']['name_size'] = 0 r['info']['name']['name'] = 'hello' dcerpc.samr_SetAliasInfo(pipe, r) @@ -370,8 +358,6 @@ def test_SetAliasInfo(pipe, alias_handle): r['level'] = 3 r['info']['description'] = {} - r['info']['description']['name_len'] = 0 - r['info']['description']['name_size'] = 0 r['info']['description']['name'] = 'this is a description' dcerpc.samr_SetAliasInfo(pipe, r) @@ -431,8 +417,6 @@ def test_CreateAlias(pipe, domain_handle, domain_sid): r = {} r['domain_handle'] = domain_handle r['aliasname'] = {} - r['aliasname']['name_len'] = 0 - r['aliasname']['name_size'] = 0 r['aliasname']['name'] = alias_name r['access_mask'] = 0x02000000 @@ -475,8 +459,6 @@ def test_CreateDomainGroup(pipe, domain_handle): r = {} r['domain_handle'] = domain_handle r['name'] = {} - r['name']['name_len'] = 0 - r['name']['name_size'] = 0 r['name']['name'] = 'samrtorturetestgroup' r['access_mask'] = 0x02000000 @@ -651,8 +633,6 @@ def test_GetDisplayEnumerationIndex(pipe, domain_handle): r['domain_handle'] = domain_handle r['level'] = levels[i] r['name'] = {} - r['name']['name_len'] = 0 - r['name']['name_size'] = 0 r['name']['name'] = 'samrtorturetest' try: @@ -682,8 +662,6 @@ def test_GetDisplayEnumerationIndex2(pipe, domain_handle): r['domain_handle'] = domain_handle r['level'] = levels[i] r['name'] = {} - r['name']['name_len'] = 0 - r['name']['name_size'] = 0 r['name']['name'] = 'samrtorturetest' try: @@ -832,8 +810,6 @@ def test_LookupDomain(pipe, connect_handle, domain): r = {} r['connect_handle'] = connect_handle r['domain'] = {} - r['domain']['name_len'] = 0 - r['domain']['name_size'] = 0 r['domain']['name'] = None try: -- cgit From 83d0f6ffae928e8d8571216542cfb580accff028 Mon Sep 17 00:00:00 2001 From: Tim Potter Date: Tue, 28 Sep 2004 12:49:05 +0000 Subject: r2728: Break arg parsing stuff out of samr.py into a standalone program. (This used to be commit 799b377badebf9a3f388b7d3fdc36484aa5e3376) --- source4/scripting/swig/torture/pytorture | 37 +++++++++++++++++++ source4/scripting/swig/torture/samr.py | 63 ++++++++------------------------ 2 files changed, 53 insertions(+), 47 deletions(-) create mode 100755 source4/scripting/swig/torture/pytorture (limited to 'source4/scripting') diff --git a/source4/scripting/swig/torture/pytorture b/source4/scripting/swig/torture/pytorture new file mode 100755 index 0000000000..89ecfbabcf --- /dev/null +++ b/source4/scripting/swig/torture/pytorture @@ -0,0 +1,37 @@ +#!/usr/bin/python + +from optparse import OptionParser + +# Parse command line + +parser = OptionParser() + +parser.add_option("-b", "--binding", action="store", type="string", + dest="binding") + +parser.add_option("-d", "--domain", action="store", type="string", + dest="domain") + +parser.add_option("-u", "--username", action="store", type="string", + dest="username") + +parser.add_option("-p", "--password", action="store", type="string", + dest="password") + +(options, args) = parser.parse_args() + +if not options.binding: + parser.error('You must supply a binding string') + +if not options.username or not options.password or not options.domain: + parser.error('You must supply a domain, username and password') + +binding = options.binding +domain = options.domain +username = options.username +password = options.password + +# Run tests + +import samr +samr.runtests(binding, domain, username, password) diff --git a/source4/scripting/swig/torture/samr.py b/source4/scripting/swig/torture/samr.py index 07bbaf3a93..ba650dfe75 100755 --- a/source4/scripting/swig/torture/samr.py +++ b/source4/scripting/swig/torture/samr.py @@ -1,9 +1,8 @@ #!/usr/bin/python -import sys, dcerpc -from optparse import OptionParser +import dcerpc -def test_Connect(handle): +def test_Connect(pipe): print 'testing samr_Connect' @@ -93,7 +92,7 @@ def test_QuerySecurity(pipe, handle): dcerpc.samr_QuerySecurity(pipe, r) -def test_GetDomPwInfo(pipe, domain): +def test_GetDomPwInfo(pipe, handle, domain): print 'testing samr_GetDomPwInfo' @@ -830,23 +829,23 @@ def test_LookupDomain(pipe, connect_handle, domain): result = dcerpc.samr_LookupDomain(pipe, r) - test_GetDomPwInfo(pipe, domain) + test_GetDomPwInfo(pipe, connect_handle, domain) - test_OpenDomain(pipe, handle, result['sid']) + test_OpenDomain(pipe, connect_handle, result['sid']) def test_EnumDomains(pipe, connect_handle): print 'testing samr_EnumDomains' r = {} - r['connect_handle'] = handle + r['connect_handle'] = connect_handle r['resume_handle'] = 0 r['buf_size'] = -1 result = dcerpc.samr_EnumDomains(pipe, r) for domain in result['sam']['entries']: - test_LookupDomain(pipe, handle, domain['name']['name']) + test_LookupDomain(pipe, connect_handle, domain['name']['name']) def test_LongInt(pipe): @@ -858,48 +857,18 @@ def test_LongInt(pipe): result = dcerpc.samr_Connect(pipe, r) -# Parse command line - -parser = OptionParser() - -parser.add_option("-b", "--binding", action="store", type="string", - dest="binding") - -parser.add_option("-d", "--domain", action="store", type="string", - dest="domain") - -parser.add_option("-u", "--username", action="store", type="string", - dest="username") - -parser.add_option("-p", "--password", action="store", type="string", - dest="password") - -(options, args) = parser.parse_args() - -if not options.binding: - parser.error('You must supply a binding string') - -if not options.username or not options.password or not options.domain: - parser.error('You must supply a domain, username and password') - - -binding = options.binding -domain = options.domain -username = options.username -password = options.password - -print 'Connecting...' +def runtests(binding, domain, username, password): -pipe = dcerpc.pipe_connect(binding, - dcerpc.DCERPC_SAMR_UUID, dcerpc.DCERPC_SAMR_VERSION, - domain, username, password) + print 'Testing SAMR pipe' -test_LongInt(pipe) + pipe = dcerpc.pipe_connect(binding, + dcerpc.DCERPC_SAMR_UUID, dcerpc.DCERPC_SAMR_VERSION, + domain, username, password) -handle = test_Connect(pipe) + test_LongInt(pipe) -test_QuerySecurity(pipe, handle) + handle = test_Connect(pipe) -test_EnumDomains(pipe, handle) + test_QuerySecurity(pipe, handle) -print 'Done' + test_EnumDomains(pipe, handle) -- cgit From 096d2d68de721774a4c0493863ba47cd240ff35e Mon Sep 17 00:00:00 2001 From: Tim Potter Date: Tue, 28 Sep 2004 21:44:05 +0000 Subject: r2739: Start of torture test for winreg wrappers. (This used to be commit cf9b984b8457843d2b6bb1c4ac90d52c9b802d89) --- source4/scripting/swig/torture/winreg.py | 23 +++++++++++++++++++++++ 1 file changed, 23 insertions(+) create mode 100755 source4/scripting/swig/torture/winreg.py (limited to 'source4/scripting') diff --git a/source4/scripting/swig/torture/winreg.py b/source4/scripting/swig/torture/winreg.py new file mode 100755 index 0000000000..4f3b592065 --- /dev/null +++ b/source4/scripting/swig/torture/winreg.py @@ -0,0 +1,23 @@ +#!/usr/bin/python + +import dcerpc + +def test_OpenHKLM(pipe): + + r = {} + r['unknown'] = {} + r['unknown']['unknown0'] = 0x84e0 + r['unknown']['unknown1'] = 0 + r['access_required'] = 0x02000000 + + dcerpc.winreg_OpenHKLM(pipe, r) + +def runtests(binding, domain, username, password): + + print 'Testing WINREG pipe' + + pipe = dcerpc.pipe_connect(binding, + dcerpc.DCERPC_WINREG_UUID, dcerpc.DCERPC_WINREG_VERSION, + domain, username, password) + + test_OpenHKLM(pipe) -- cgit From b11be587e06705ef68da91e3ff766595d3c62c20 Mon Sep 17 00:00:00 2001 From: Tim Potter Date: Fri, 1 Oct 2004 07:36:47 +0000 Subject: r2765: Allow functions containing WERROR values to be compiled. Add winreg.i to list of extensions. (This used to be commit 6f3f6de058e806f13f48d3d1300db3784d2f470c) --- source4/scripting/swig/dcerpc.i | 1 + source4/scripting/swig/samba.i | 3 +++ 2 files changed, 4 insertions(+) (limited to 'source4/scripting') diff --git a/source4/scripting/swig/dcerpc.i b/source4/scripting/swig/dcerpc.i index eb8b065e33..6be0b639f0 100644 --- a/source4/scripting/swig/dcerpc.i +++ b/source4/scripting/swig/dcerpc.i @@ -839,3 +839,4 @@ NTSTATUS dcerpc_pipe_connect(struct dcerpc_pipe **OUT, %include "librpc/gen_ndr/misc.i" %include "librpc/gen_ndr/lsa.i" %include "librpc/gen_ndr/samr.i" +%include "librpc/gen_ndr/winreg.i" diff --git a/source4/scripting/swig/samba.i b/source4/scripting/swig/samba.i index 8e0eb88533..faa46dc348 100644 --- a/source4/scripting/swig/samba.i +++ b/source4/scripting/swig/samba.i @@ -34,6 +34,9 @@ /* For the moment treat NTSTATUS as an integer */ +#define WERROR NTSTATUS + %typemap(out) NTSTATUS { $result = PyInt_FromLong(NT_STATUS_V($1)); } + -- cgit From 76a8fe491e568cb97d5ed54de6cb2882574421c1 Mon Sep 17 00:00:00 2001 From: Tim Potter Date: Fri, 1 Oct 2004 07:37:37 +0000 Subject: r2766: Test OpenKey, QueryInfoKey, EnumKey, CloseKey functions. The IDL for EnumValue is wrong - can't figure it out right now. (This used to be commit 37af942d08da9ba9dcf351853f9064b5d179d5e4) --- source4/scripting/swig/torture/winreg.py | 107 +++++++++++++++++++++++++++++-- 1 file changed, 102 insertions(+), 5 deletions(-) (limited to 'source4/scripting') diff --git a/source4/scripting/swig/torture/winreg.py b/source4/scripting/swig/torture/winreg.py index 4f3b592065..abc9fa2245 100755 --- a/source4/scripting/swig/torture/winreg.py +++ b/source4/scripting/swig/torture/winreg.py @@ -1,16 +1,110 @@ #!/usr/bin/python -import dcerpc +import sys, dcerpc def test_OpenHKLM(pipe): r = {} r['unknown'] = {} - r['unknown']['unknown0'] = 0x84e0 - r['unknown']['unknown1'] = 0 + r['unknown']['unknown0'] = 0x9038 + r['unknown']['unknown1'] = 0x0000 r['access_required'] = 0x02000000 - dcerpc.winreg_OpenHKLM(pipe, r) + result = dcerpc.winreg_OpenHKLM(pipe, r) + + return result['handle'] + +def test_QueryInfoKey(pipe, handle): + + r = {} + r['handle'] = handle + r['class'] = {} + r['class']['name'] = None + + return dcerpc.winreg_QueryInfoKey(pipe, r) + +def test_CloseKey(pipe, handle): + + r = {} + r['handle'] = handle + + dcerpc.winreg_CloseKey(pipe, r) + +def test_Enum(pipe, handle, depth = 0): + + if depth > 2: + return + + keyinfo = test_QueryInfoKey(pipe, handle) + + # Enumerate keys + + r = {} + r['handle'] = handle + r['key_name_len'] = 0 + r['unknown'] = 0x0414 + r['in_name'] = {} + r['in_name']['unknown'] = 0x20a + r['in_name']['key_name'] = {} + r['in_name']['key_name']['name'] = None + r['class'] = {} + r['class']['name'] = None + r['last_changed_time'] = {} + r['last_changed_time']['low'] = 0 + r['last_changed_time']['high'] = 0 + + for i in range(0, keyinfo['num_subkeys']): + + r['enum_index'] = i + + subkey = dcerpc.winreg_EnumKey(pipe, r) + + s = {} + s['handle'] = handle + s['keyname'] = {} + s['keyname']['name'] = subkey['out_name']['name'] + s['unknown'] = 0 + s['access_mask'] = 0x02000000 + + result = dcerpc.winreg_OpenKey(pipe, s) + + test_Enum(pipe, result['handle'], depth + 1) + + test_CloseKey(pipe, result['handle']) + + # Enumerate values + + return + + r = {} + r['handle'] = handle + r['name'] = {} + r['name']['len'] = 0 + r['name']['max_len'] = 0 + r['name']['name'] = {} + r['name']['name']['max_len'] = 0 + r['name']['name']['offset'] = 0 + r['name']['name']['len'] = 0 + r['name']['name']['buffer'] = None + r['type'] = 0 + r['value'] = {} + r['value']['max_len'] = 0 + r['value']['offset'] = 0 + r['value']['len'] = 0 + r['value']['buffer'] = [] + r['returned_len'] = 0 + + for i in range(0, keyinfo['num_values']): + + r['enum_index'] = i + + print dcerpc.winreg_EnumValue(pipe, r) + + sys.exit(1) + +def test_Key(pipe, handle): + + test_Enum(pipe, handle) def runtests(binding, domain, username, password): @@ -20,4 +114,7 @@ def runtests(binding, domain, username, password): dcerpc.DCERPC_WINREG_UUID, dcerpc.DCERPC_WINREG_VERSION, domain, username, password) - test_OpenHKLM(pipe) + handle = test_OpenHKLM(pipe) + + test_Key(pipe, handle) + -- cgit From 7cef5fd077cb99343df3fff0c9145e15bce563d7 Mon Sep 17 00:00:00 2001 From: Tim Potter Date: Sat, 2 Oct 2004 11:22:20 +0000 Subject: r2780: Add conversion routines for DATA_BLOB. I'm not convinced that DATA_BLOB's should be treated as scalar types though. (This used to be commit c9e96038f821783c30b5cf509334176f982403d9) --- source4/scripting/swig/dcerpc.i | 29 +++++++++++++++++++++++++++++ 1 file changed, 29 insertions(+) (limited to 'source4/scripting') diff --git a/source4/scripting/swig/dcerpc.i b/source4/scripting/swig/dcerpc.i index 6be0b639f0..5c3ce0ceec 100644 --- a/source4/scripting/swig/dcerpc.i +++ b/source4/scripting/swig/dcerpc.i @@ -246,6 +246,35 @@ PyObject *string_ptr_to_python(TALLOC_CTX *mem_ctx, char *obj) #define dom_sid2_ptr_to_python dom_sid_ptr_to_python #define dom_sid2_ptr_from_python dom_sid_ptr_from_python +DATA_BLOB DATA_BLOB_from_python(PyObject *obj, char *name) +{ + DATA_BLOB ret; + + /* Because we treat DATA_BLOB as a scalar type (why?) there + doesn't seem to be a way to pass back when an error has + occured. */ + + if (obj == NULL) { + PyErr_Format(PyExc_ValueError, "Expecting key %s", name); + return; + } + + if (!PyString_Check(obj)) { + PyErr_Format(PyExc_TypeError, "Expecting string value for key '%s'", name); + return; + } + + ret.length = PyString_Size(obj); + ret.data = PyString_AsString(obj); + + return ret; +} + +PyObject *DATA_BLOB_to_python(DATA_BLOB obj) +{ + return PyString_FromStringAndSize(obj.data, obj.length); +} + %} %include "samba.i" -- cgit From 710ad9613b909332b13620aa8022e8870170418d Mon Sep 17 00:00:00 2001 From: Tim Potter Date: Sat, 2 Oct 2004 11:26:58 +0000 Subject: r2781: Got winreg_EnumValue() working. Check it in so I don't break it trying to clean it up. (-: (This used to be commit cc646f73b873292eaba152770be9500beff1c988) --- source4/scripting/swig/torture/winreg.py | 34 +++++++++++++++++++++----------- 1 file changed, 22 insertions(+), 12 deletions(-) (limited to 'source4/scripting') diff --git a/source4/scripting/swig/torture/winreg.py b/source4/scripting/swig/torture/winreg.py index abc9fa2245..acf319d6f9 100755 --- a/source4/scripting/swig/torture/winreg.py +++ b/source4/scripting/swig/torture/winreg.py @@ -74,30 +74,40 @@ def test_Enum(pipe, handle, depth = 0): # Enumerate values - return - r = {} r['handle'] = handle - r['name'] = {} - r['name']['len'] = 0 - r['name']['max_len'] = 0 - r['name']['name'] = {} - r['name']['name']['max_len'] = 0 - r['name']['name']['offset'] = 0 - r['name']['name']['len'] = 0 - r['name']['name']['buffer'] = None + + keyinfo['max_valnamelen'] = 18 + keyinfo['max_valbufsize'] = 0x31f5 + + r['foo'] = {} + r['foo']['len'] = 0 + r['foo']['max_len'] = keyinfo['max_valnamelen'] * 2 + r['foo']['buffer'] = {} + r['foo']['buffer']['max_len'] = keyinfo['max_valnamelen'] + r['foo']['buffer']['offset'] = 0 + r['foo']['buffer']['len'] = 0 + r['foo']['buffer']['buffer'] = '' r['type'] = 0 r['value'] = {} - r['value']['max_len'] = 0 + r['value']['max_len'] = keyinfo['max_valbufsize'] r['value']['offset'] = 0 r['value']['len'] = 0 r['value']['buffer'] = [] r['returned_len'] = 0 + r['foo2'] = {} + r['foo2']['max_len'] = keyinfo['max_valbufsize'] + r['foo2']['offset'] = 0 + r['foo2']['len'] = 0 + r['foo2']['buffer'] = '' + r['value1'] = keyinfo['max_valbufsize'] + r['value2'] = 0 for i in range(0, keyinfo['num_values']): r['enum_index'] = i - + + print keyinfo print dcerpc.winreg_EnumValue(pipe, r) sys.exit(1) -- cgit From a248164de5f89cef824f5a1f7d8618fbe81ae0c4 Mon Sep 17 00:00:00 2001 From: Tim Potter Date: Sat, 2 Oct 2004 23:35:50 +0000 Subject: r2790: Add code to generate WERROR exceptions. Arrange inclusion of autogenerated interface files to divvy them up into pipes that return WERRORs and pipes that return NTSTATUS values. (This used to be commit 294d1ae35c09432a41e5a07a3aa1884bfb9a93be) --- source4/scripting/swig/dcerpc.i | 29 ++++++++++++++++++++++++++--- 1 file changed, 26 insertions(+), 3 deletions(-) (limited to 'source4/scripting') diff --git a/source4/scripting/swig/dcerpc.i b/source4/scripting/swig/dcerpc.i index 5c3ce0ceec..9508dc805e 100644 --- a/source4/scripting/swig/dcerpc.i +++ b/source4/scripting/swig/dcerpc.i @@ -37,7 +37,7 @@ #undef strcpy -PyObject *ntstatus_exception; +PyObject *ntstatus_exception, *werror_exception; /* Set up return of a dcerpc.NTSTATUS exception */ @@ -49,6 +49,14 @@ void set_ntstatus_exception(int status) PyErr_SetObject(ntstatus_exception, obj); } +void set_werror_exception(int status) +{ + PyObject *obj = Py_BuildValue("(i,s)", status, + win_errstr(W_ERROR(status))); + + PyErr_SetObject(werror_exception, obj); +} + /* Conversion functions for scalar types */ uint8 uint8_from_python(PyObject *obj, char *name) @@ -801,6 +809,7 @@ PyObject *DATA_BLOB_to_python(DATA_BLOB obj) %pythoncode %{ NTSTATUS = _dcerpc.NTSTATUS + WERROR = _dcerpc.WERROR %} %init %{ @@ -808,7 +817,9 @@ PyObject *DATA_BLOB_to_python(DATA_BLOB obj) lp_load(dyn_CONFIGFILE, True, False, False); load_interfaces(); ntstatus_exception = PyErr_NewException("_dcerpc.NTSTATUS", NULL, NULL); + werror_exception = PyErr_NewException("_dcerpc.WERROR", NULL, NULL); PyDict_SetItemString(d, "NTSTATUS", ntstatus_exception); + PyDict_SetItemString(d, "WERROR", werror_exception); %} %typemap(in, numinputs=0) struct dcerpc_pipe **OUT (struct dcerpc_pipe *temp_dcerpc_pipe) { @@ -855,7 +866,9 @@ NTSTATUS dcerpc_pipe_connect(struct dcerpc_pipe **OUT, const char *username, const char *password); -/* Run this test after each wrapped function */ +%include "librpc/gen_ndr/misc.i" + +/* Wrapped functions returning NTSTATUS */ %exception { $action @@ -865,7 +878,17 @@ NTSTATUS dcerpc_pipe_connect(struct dcerpc_pipe **OUT, } } -%include "librpc/gen_ndr/misc.i" %include "librpc/gen_ndr/lsa.i" %include "librpc/gen_ndr/samr.i" + +/* Wrapped functions returning WERROR */ + +%exception { + $action + if (!W_ERROR_IS_OK(arg3->out.result)) { + set_werror_exception(W_ERROR_V(arg3->out.result)); + return NULL; + } +} + %include "librpc/gen_ndr/winreg.i" -- cgit From 68d2ce3320a5ad33c08a705cb5f551a21efa611e Mon Sep 17 00:00:00 2001 From: Tim Potter Date: Sun, 3 Oct 2004 07:00:17 +0000 Subject: r2795: Split status code constants into a separate file. (This used to be commit 12a3f75c1cf39c74952077cc00fd86a4e935f74b) --- source4/scripting/swig/dcerpc.i | 521 +------------------------------- source4/scripting/swig/status_codes.i | 552 ++++++++++++++++++++++++++++++++++ 2 files changed, 553 insertions(+), 520 deletions(-) create mode 100644 source4/scripting/swig/status_codes.i (limited to 'source4/scripting') diff --git a/source4/scripting/swig/dcerpc.i b/source4/scripting/swig/dcerpc.i index 9508dc805e..a560cca570 100644 --- a/source4/scripting/swig/dcerpc.i +++ b/source4/scripting/swig/dcerpc.i @@ -286,526 +286,7 @@ PyObject *DATA_BLOB_to_python(DATA_BLOB obj) %} %include "samba.i" - -/* Win32 status codes */ - -#define STATUS_BUFFER_OVERFLOW 0x80000005 -#define STATUS_NO_MORE_FILES 0x80000006 -#define NT_STATUS_NO_MORE_ENTRIES 0x8000001a - -#define STATUS_MORE_ENTRIES 0x0105 -#define STATUS_SOME_UNMAPPED 0x0107 -#define ERROR_INVALID_PARAMETER 0x0057 -#define ERROR_INSUFFICIENT_BUFFER 0x007a -#define STATUS_NOTIFY_ENUM_DIR 0x010c -#define ERROR_INVALID_DATATYPE 0x070c - -/* NT status codes */ - -#define NT_STATUS_OK 0x00000000 -#define NT_STATUS_UNSUCCESSFUL 0xC0000001 -#define NT_STATUS_NOT_IMPLEMENTED 0xC0000002 -#define NT_STATUS_INVALID_INFO_CLASS 0xC0000003 -#define NT_STATUS_INFO_LENGTH_MISMATCH 0xC0000004 -#define NT_STATUS_ACCESS_VIOLATION 0xC0000005 -#define NT_STATUS_IN_PAGE_ERROR 0xC0000006 -#define NT_STATUS_PAGEFILE_QUOTA 0xC0000007 -#define NT_STATUS_INVALID_HANDLE 0xC0000008 -#define NT_STATUS_BAD_INITIAL_STACK 0xC0000009 -#define NT_STATUS_BAD_INITIAL_PC 0xC000000a -#define NT_STATUS_INVALID_CID 0xC000000b -#define NT_STATUS_TIMER_NOT_CANCELED 0xC000000c -#define NT_STATUS_INVALID_PARAMETER 0xC000000d -#define NT_STATUS_NO_SUCH_DEVICE 0xC000000e -#define NT_STATUS_NO_SUCH_FILE 0xC000000f -#define NT_STATUS_INVALID_DEVICE_REQUEST 0xC0000010 -#define NT_STATUS_END_OF_FILE 0xC0000011 -#define NT_STATUS_WRONG_VOLUME 0xC0000012 -#define NT_STATUS_NO_MEDIA_IN_DEVICE 0xC0000013 -#define NT_STATUS_UNRECOGNIZED_MEDIA 0xC0000014 -#define NT_STATUS_NONEXISTENT_SECTOR 0xC0000015 -#define NT_STATUS_MORE_PROCESSING_REQUIRED 0xC0000016 -#define NT_STATUS_NO_MEMORY 0xC0000017 -#define NT_STATUS_CONFLICTING_ADDRESSES 0xC0000018 -#define NT_STATUS_NOT_MAPPED_VIEW 0xC0000019 -#define NT_STATUS_UNABLE_TO_FREE_VM 0xC000001a -#define NT_STATUS_UNABLE_TO_DELETE_SECTION 0xC000001b -#define NT_STATUS_INVALID_SYSTEM_SERVICE 0xC000001c -#define NT_STATUS_ILLEGAL_INSTRUCTION 0xC000001d -#define NT_STATUS_INVALID_LOCK_SEQUENCE 0xC000001e -#define NT_STATUS_INVALID_VIEW_SIZE 0xC000001f -#define NT_STATUS_INVALID_FILE_FOR_SECTION 0xC0000020 -#define NT_STATUS_ALREADY_COMMITTED 0xC0000021 -#define NT_STATUS_ACCESS_DENIED 0xC0000022 -#define NT_STATUS_BUFFER_TOO_SMALL 0xC0000023 -#define NT_STATUS_OBJECT_TYPE_MISMATCH 0xC0000024 -#define NT_STATUS_NONCONTINUABLE_EXCEPTION 0xC0000025 -#define NT_STATUS_INVALID_DISPOSITION 0xC0000026 -#define NT_STATUS_UNWIND 0xC0000027 -#define NT_STATUS_BAD_STACK 0xC0000028 -#define NT_STATUS_INVALID_UNWIND_TARGET 0xC0000029 -#define NT_STATUS_NOT_LOCKED 0xC000002a -#define NT_STATUS_PARITY_ERROR 0xC000002b -#define NT_STATUS_UNABLE_TO_DECOMMIT_VM 0xC000002c -#define NT_STATUS_NOT_COMMITTED 0xC000002d -#define NT_STATUS_INVALID_PORT_ATTRIBUTES 0xC000002e -#define NT_STATUS_PORT_MESSAGE_TOO_LONG 0xC000002f -#define NT_STATUS_INVALID_PARAMETER_MIX 0xC0000030 -#define NT_STATUS_INVALID_QUOTA_LOWER 0xC0000031 -#define NT_STATUS_DISK_CORRUPT_ERROR 0xC0000032 -#define NT_STATUS_OBJECT_NAME_INVALID 0xC0000033 -#define NT_STATUS_OBJECT_NAME_NOT_FOUND 0xC0000034 -#define NT_STATUS_OBJECT_NAME_COLLISION 0xC0000035 -#define NT_STATUS_HANDLE_NOT_WAITABLE 0xC0000036 -#define NT_STATUS_PORT_DISCONNECTED 0xC0000037 -#define NT_STATUS_DEVICE_ALREADY_ATTACHED 0xC0000038 -#define NT_STATUS_OBJECT_PATH_INVALID 0xC0000039 -#define NT_STATUS_OBJECT_PATH_NOT_FOUND 0xC000003a -#define NT_STATUS_OBJECT_PATH_SYNTAX_BAD 0xC000003b -#define NT_STATUS_DATA_OVERRUN 0xC000003c -#define NT_STATUS_DATA_LATE_ERROR 0xC000003d -#define NT_STATUS_DATA_ERROR 0xC000003e -#define NT_STATUS_CRC_ERROR 0xC000003f -#define NT_STATUS_SECTION_TOO_BIG 0xC0000040 -#define NT_STATUS_PORT_CONNECTION_REFUSED 0xC0000041 -#define NT_STATUS_INVALID_PORT_HANDLE 0xC0000042 -#define NT_STATUS_SHARING_VIOLATION 0xC0000043 -#define NT_STATUS_QUOTA_EXCEEDED 0xC0000044 -#define NT_STATUS_INVALID_PAGE_PROTECTION 0xC0000045 -#define NT_STATUS_MUTANT_NOT_OWNED 0xC0000046 -#define NT_STATUS_SEMAPHORE_LIMIT_EXCEEDED 0xC0000047 -#define NT_STATUS_PORT_ALREADY_SET 0xC0000048 -#define NT_STATUS_SECTION_NOT_IMAGE 0xC0000049 -#define NT_STATUS_SUSPEND_COUNT_EXCEEDED 0xC000004a -#define NT_STATUS_THREAD_IS_TERMINATING 0xC000004b -#define NT_STATUS_BAD_WORKING_SET_LIMIT 0xC000004c -#define NT_STATUS_INCOMPATIBLE_FILE_MAP 0xC000004d -#define NT_STATUS_SECTION_PROTECTION 0xC000004e -#define NT_STATUS_EAS_NOT_SUPPORTED 0xC000004f -#define NT_STATUS_EA_TOO_LARGE 0xC0000050 -#define NT_STATUS_NONEXISTENT_EA_ENTRY 0xC0000051 -#define NT_STATUS_NO_EAS_ON_FILE 0xC0000052 -#define NT_STATUS_EA_CORRUPT_ERROR 0xC0000053 -#define NT_STATUS_FILE_LOCK_CONFLICT 0xC0000054 -#define NT_STATUS_LOCK_NOT_GRANTED 0xC0000055 -#define NT_STATUS_DELETE_PENDING 0xC0000056 -#define NT_STATUS_CTL_FILE_NOT_SUPPORTED 0xC0000057 -#define NT_STATUS_UNKNOWN_REVISION 0xC0000058 -#define NT_STATUS_REVISION_MISMATCH 0xC0000059 -#define NT_STATUS_INVALID_OWNER 0xC000005a -#define NT_STATUS_INVALID_PRIMARY_GROUP 0xC000005b -#define NT_STATUS_NO_IMPERSONATION_TOKEN 0xC000005c -#define NT_STATUS_CANT_DISABLE_MANDATORY 0xC000005d -#define NT_STATUS_NO_LOGON_SERVERS 0xC000005e -#define NT_STATUS_NO_SUCH_LOGON_SESSION 0xC000005f -#define NT_STATUS_NO_SUCH_PRIVILEGE 0xC0000060 -#define NT_STATUS_PRIVILEGE_NOT_HELD 0xC0000061 -#define NT_STATUS_INVALID_ACCOUNT_NAME 0xC0000062 -#define NT_STATUS_USER_EXISTS 0xC0000063 -#define NT_STATUS_NO_SUCH_USER 0xC0000064 -#define NT_STATUS_GROUP_EXISTS 0xC0000065 -#define NT_STATUS_NO_SUCH_GROUP 0xC0000066 -#define NT_STATUS_MEMBER_IN_GROUP 0xC0000067 -#define NT_STATUS_MEMBER_NOT_IN_GROUP 0xC0000068 -#define NT_STATUS_LAST_ADMIN 0xC0000069 -#define NT_STATUS_WRONG_PASSWORD 0xC000006a -#define NT_STATUS_ILL_FORMED_PASSWORD 0xC000006b -#define NT_STATUS_PASSWORD_RESTRICTION 0xC000006c -#define NT_STATUS_LOGON_FAILURE 0xC000006d -#define NT_STATUS_ACCOUNT_RESTRICTION 0xC000006e -#define NT_STATUS_INVALID_LOGON_HOURS 0xC000006f -#define NT_STATUS_INVALID_WORKSTATION 0xC0000070 -#define NT_STATUS_PASSWORD_EXPIRED 0xC0000071 -#define NT_STATUS_ACCOUNT_DISABLED 0xC0000072 -#define NT_STATUS_NONE_MAPPED 0xC0000073 -#define NT_STATUS_TOO_MANY_LUIDS_REQUESTED 0xC0000074 -#define NT_STATUS_LUIDS_EXHAUSTED 0xC0000075 -#define NT_STATUS_INVALID_SUB_AUTHORITY 0xC0000076 -#define NT_STATUS_INVALID_ACL 0xC0000077 -#define NT_STATUS_INVALID_SID 0xC0000078 -#define NT_STATUS_INVALID_SECURITY_DESCR 0xC0000079 -#define NT_STATUS_PROCEDURE_NOT_FOUND 0xC000007a -#define NT_STATUS_INVALID_IMAGE_FORMAT 0xC000007b -#define NT_STATUS_NO_TOKEN 0xC000007c -#define NT_STATUS_BAD_INHERITANCE_ACL 0xC000007d -#define NT_STATUS_RANGE_NOT_LOCKED 0xC000007e -#define NT_STATUS_DISK_FULL 0xC000007f -#define NT_STATUS_SERVER_DISABLED 0xC0000080 -#define NT_STATUS_SERVER_NOT_DISABLED 0xC0000081 -#define NT_STATUS_TOO_MANY_GUIDS_REQUESTED 0xC0000082 -#define NT_STATUS_GUIDS_EXHAUSTED 0xC0000083 -#define NT_STATUS_INVALID_ID_AUTHORITY 0xC0000084 -#define NT_STATUS_AGENTS_EXHAUSTED 0xC0000085 -#define NT_STATUS_INVALID_VOLUME_LABEL 0xC0000086 -#define NT_STATUS_SECTION_NOT_EXTENDED 0xC0000087 -#define NT_STATUS_NOT_MAPPED_DATA 0xC0000088 -#define NT_STATUS_RESOURCE_DATA_NOT_FOUND 0xC0000089 -#define NT_STATUS_RESOURCE_TYPE_NOT_FOUND 0xC000008a -#define NT_STATUS_RESOURCE_NAME_NOT_FOUND 0xC000008b -#define NT_STATUS_ARRAY_BOUNDS_EXCEEDED 0xC000008c -#define NT_STATUS_FLOAT_DENORMAL_OPERAND 0xC000008d -#define NT_STATUS_FLOAT_DIVIDE_BY_ZERO 0xC000008e -#define NT_STATUS_FLOAT_INEXACT_RESULT 0xC000008f -#define NT_STATUS_FLOAT_INVALID_OPERATION 0xC0000090 -#define NT_STATUS_FLOAT_OVERFLOW 0xC0000091 -#define NT_STATUS_FLOAT_STACK_CHECK 0xC0000092 -#define NT_STATUS_FLOAT_UNDERFLOW 0xC0000093 -#define NT_STATUS_INTEGER_DIVIDE_BY_ZERO 0xC0000094 -#define NT_STATUS_INTEGER_OVERFLOW 0xC0000095 -#define NT_STATUS_PRIVILEGED_INSTRUCTION 0xC0000096 -#define NT_STATUS_TOO_MANY_PAGING_FILES 0xC0000097 -#define NT_STATUS_FILE_INVALID 0xC0000098 -#define NT_STATUS_ALLOTTED_SPACE_EXCEEDED 0xC0000099 -#define NT_STATUS_INSUFFICIENT_RESOURCES 0xC000009a -#define NT_STATUS_DFS_EXIT_PATH_FOUND 0xC000009b -#define NT_STATUS_DEVICE_DATA_ERROR 0xC000009c -#define NT_STATUS_DEVICE_NOT_CONNECTED 0xC000009d -#define NT_STATUS_DEVICE_POWER_FAILURE 0xC000009e -#define NT_STATUS_FREE_VM_NOT_AT_BASE 0xC000009f -#define NT_STATUS_MEMORY_NOT_ALLOCATED 0xC00000a0 -#define NT_STATUS_WORKING_SET_QUOTA 0xC00000a1 -#define NT_STATUS_MEDIA_WRITE_PROTECTED 0xC00000a2 -#define NT_STATUS_DEVICE_NOT_READY 0xC00000a3 -#define NT_STATUS_INVALID_GROUP_ATTRIBUTES 0xC00000a4 -#define NT_STATUS_BAD_IMPERSONATION_LEVEL 0xC00000a5 -#define NT_STATUS_CANT_OPEN_ANONYMOUS 0xC00000a6 -#define NT_STATUS_BAD_VALIDATION_CLASS 0xC00000a7 -#define NT_STATUS_BAD_TOKEN_TYPE 0xC00000a8 -#define NT_STATUS_BAD_MASTER_BOOT_RECORD 0xC00000a9 -#define NT_STATUS_INSTRUCTION_MISALIGNMENT 0xC00000aa -#define NT_STATUS_INSTANCE_NOT_AVAILABLE 0xC00000ab -#define NT_STATUS_PIPE_NOT_AVAILABLE 0xC00000ac -#define NT_STATUS_INVALID_PIPE_STATE 0xC00000ad -#define NT_STATUS_PIPE_BUSY 0xC00000ae -#define NT_STATUS_ILLEGAL_FUNCTION 0xC00000af -#define NT_STATUS_PIPE_DISCONNECTED 0xC00000b0 -#define NT_STATUS_PIPE_CLOSING 0xC00000b1 -#define NT_STATUS_PIPE_CONNECTED 0xC00000b2 -#define NT_STATUS_PIPE_LISTENING 0xC00000b3 -#define NT_STATUS_INVALID_READ_MODE 0xC00000b4 -#define NT_STATUS_IO_TIMEOUT 0xC00000b5 -#define NT_STATUS_FILE_FORCED_CLOSED 0xC00000b6 -#define NT_STATUS_PROFILING_NOT_STARTED 0xC00000b7 -#define NT_STATUS_PROFILING_NOT_STOPPED 0xC00000b8 -#define NT_STATUS_COULD_NOT_INTERPRET 0xC00000b9 -#define NT_STATUS_FILE_IS_A_DIRECTORY 0xC00000ba -#define NT_STATUS_NOT_SUPPORTED 0xC00000bb -#define NT_STATUS_REMOTE_NOT_LISTENING 0xC00000bc -#define NT_STATUS_DUPLICATE_NAME 0xC00000bd -#define NT_STATUS_BAD_NETWORK_PATH 0xC00000be -#define NT_STATUS_NETWORK_BUSY 0xC00000bf -#define NT_STATUS_DEVICE_DOES_NOT_EXIST 0xC00000c0 -#define NT_STATUS_TOO_MANY_COMMANDS 0xC00000c1 -#define NT_STATUS_ADAPTER_HARDWARE_ERROR 0xC00000c2 -#define NT_STATUS_INVALID_NETWORK_RESPONSE 0xC00000c3 -#define NT_STATUS_UNEXPECTED_NETWORK_ERROR 0xC00000c4 -#define NT_STATUS_BAD_REMOTE_ADAPTER 0xC00000c5 -#define NT_STATUS_PRINT_QUEUE_FULL 0xC00000c6 -#define NT_STATUS_NO_SPOOL_SPACE 0xC00000c7 -#define NT_STATUS_PRINT_CANCELLED 0xC00000c8 -#define NT_STATUS_NETWORK_NAME_DELETED 0xC00000c9 -#define NT_STATUS_NETWORK_ACCESS_DENIED 0xC00000ca -#define NT_STATUS_BAD_DEVICE_TYPE 0xC00000cb -#define NT_STATUS_BAD_NETWORK_NAME 0xC00000cc -#define NT_STATUS_TOO_MANY_NAMES 0xC00000cd -#define NT_STATUS_TOO_MANY_SESSIONS 0xC00000ce -#define NT_STATUS_SHARING_PAUSED 0xC00000cf -#define NT_STATUS_REQUEST_NOT_ACCEPTED 0xC00000d0 -#define NT_STATUS_REDIRECTOR_PAUSED 0xC00000d1 -#define NT_STATUS_NET_WRITE_FAULT 0xC00000d2 -#define NT_STATUS_PROFILING_AT_LIMIT 0xC00000d3 -#define NT_STATUS_NOT_SAME_DEVICE 0xC00000d4 -#define NT_STATUS_FILE_RENAMED 0xC00000d5 -#define NT_STATUS_VIRTUAL_CIRCUIT_CLOSED 0xC00000d6 -#define NT_STATUS_NO_SECURITY_ON_OBJECT 0xC00000d7 -#define NT_STATUS_CANT_WAIT 0xC00000d8 -#define NT_STATUS_PIPE_EMPTY 0xC00000d9 -#define NT_STATUS_CANT_ACCESS_DOMAIN_INFO 0xC00000da -#define NT_STATUS_CANT_TERMINATE_SELF 0xC00000db -#define NT_STATUS_INVALID_SERVER_STATE 0xC00000dc -#define NT_STATUS_INVALID_DOMAIN_STATE 0xC00000dd -#define NT_STATUS_INVALID_DOMAIN_ROLE 0xC00000de -#define NT_STATUS_NO_SUCH_DOMAIN 0xC00000df -#define NT_STATUS_DOMAIN_EXISTS 0xC00000e0 -#define NT_STATUS_DOMAIN_LIMIT_EXCEEDED 0xC00000e1 -#define NT_STATUS_OPLOCK_NOT_GRANTED 0xC00000e2 -#define NT_STATUS_INVALID_OPLOCK_PROTOCOL 0xC00000e3 -#define NT_STATUS_INTERNAL_DB_CORRUPTION 0xC00000e4 -#define NT_STATUS_INTERNAL_ERROR 0xC00000e5 -#define NT_STATUS_GENERIC_NOT_MAPPED 0xC00000e6 -#define NT_STATUS_BAD_DESCRIPTOR_FORMAT 0xC00000e7 -#define NT_STATUS_INVALID_USER_BUFFER 0xC00000e8 -#define NT_STATUS_UNEXPECTED_IO_ERROR 0xC00000e9 -#define NT_STATUS_UNEXPECTED_MM_CREATE_ERR 0xC00000ea -#define NT_STATUS_UNEXPECTED_MM_MAP_ERROR 0xC00000eb -#define NT_STATUS_UNEXPECTED_MM_EXTEND_ERR 0xC00000ec -#define NT_STATUS_NOT_LOGON_PROCESS 0xC00000ed -#define NT_STATUS_LOGON_SESSION_EXISTS 0xC00000ee -#define NT_STATUS_INVALID_PARAMETER_1 0xC00000ef -#define NT_STATUS_INVALID_PARAMETER_2 0xC00000f0 -#define NT_STATUS_INVALID_PARAMETER_3 0xC00000f1 -#define NT_STATUS_INVALID_PARAMETER_4 0xC00000f2 -#define NT_STATUS_INVALID_PARAMETER_5 0xC00000f3 -#define NT_STATUS_INVALID_PARAMETER_6 0xC00000f4 -#define NT_STATUS_INVALID_PARAMETER_7 0xC00000f5 -#define NT_STATUS_INVALID_PARAMETER_8 0xC00000f6 -#define NT_STATUS_INVALID_PARAMETER_9 0xC00000f7 -#define NT_STATUS_INVALID_PARAMETER_10 0xC00000f8 -#define NT_STATUS_INVALID_PARAMETER_11 0xC00000f9 -#define NT_STATUS_INVALID_PARAMETER_12 0xC00000fa -#define NT_STATUS_REDIRECTOR_NOT_STARTED 0xC00000fb -#define NT_STATUS_REDIRECTOR_STARTED 0xC00000fc -#define NT_STATUS_STACK_OVERFLOW 0xC00000fd -#define NT_STATUS_NO_SUCH_PACKAGE 0xC00000fe -#define NT_STATUS_BAD_FUNCTION_TABLE 0xC00000ff -#define NT_STATUS_DIRECTORY_NOT_EMPTY 0xC0000101 -#define NT_STATUS_FILE_CORRUPT_ERROR 0xC0000102 -#define NT_STATUS_NOT_A_DIRECTORY 0xC0000103 -#define NT_STATUS_BAD_LOGON_SESSION_STATE 0xC0000104 -#define NT_STATUS_LOGON_SESSION_COLLISION 0xC0000105 -#define NT_STATUS_NAME_TOO_LONG 0xC0000106 -#define NT_STATUS_FILES_OPEN 0xC0000107 -#define NT_STATUS_CONNECTION_IN_USE 0xC0000108 -#define NT_STATUS_MESSAGE_NOT_FOUND 0xC0000109 -#define NT_STATUS_PROCESS_IS_TERMINATING 0xC000010a -#define NT_STATUS_INVALID_LOGON_TYPE 0xC000010b -#define NT_STATUS_NO_GUID_TRANSLATION 0xC000010c -#define NT_STATUS_CANNOT_IMPERSONATE 0xC000010d -#define NT_STATUS_IMAGE_ALREADY_LOADED 0xC000010e -#define NT_STATUS_ABIOS_NOT_PRESENT 0xC000010f -#define NT_STATUS_ABIOS_LID_NOT_EXIST 0xC0000110 -#define NT_STATUS_ABIOS_LID_ALREADY_OWNED 0xC0000111 -#define NT_STATUS_ABIOS_NOT_LID_OWNER 0xC0000112 -#define NT_STATUS_ABIOS_INVALID_COMMAND 0xC0000113 -#define NT_STATUS_ABIOS_INVALID_LID 0xC0000114 -#define NT_STATUS_ABIOS_SELECTOR_NOT_AVAILABLE 0xC0000115 -#define NT_STATUS_ABIOS_INVALID_SELECTOR 0xC0000116 -#define NT_STATUS_NO_LDT 0xC0000117 -#define NT_STATUS_INVALID_LDT_SIZE 0xC0000118 -#define NT_STATUS_INVALID_LDT_OFFSET 0xC0000119 -#define NT_STATUS_INVALID_LDT_DESCRIPTOR 0xC000011a -#define NT_STATUS_INVALID_IMAGE_NE_FORMAT 0xC000011b -#define NT_STATUS_RXACT_INVALID_STATE 0xC000011c -#define NT_STATUS_RXACT_COMMIT_FAILURE 0xC000011d -#define NT_STATUS_MAPPED_FILE_SIZE_ZERO 0xC000011e -#define NT_STATUS_TOO_MANY_OPENED_FILES 0xC000011f -#define NT_STATUS_CANCELLED 0xC0000120 -#define NT_STATUS_CANNOT_DELETE 0xC0000121 -#define NT_STATUS_INVALID_COMPUTER_NAME 0xC0000122 -#define NT_STATUS_FILE_DELETED 0xC0000123 -#define NT_STATUS_SPECIAL_ACCOUNT 0xC0000124 -#define NT_STATUS_SPECIAL_GROUP 0xC0000125 -#define NT_STATUS_SPECIAL_USER 0xC0000126 -#define NT_STATUS_MEMBERS_PRIMARY_GROUP 0xC0000127 -#define NT_STATUS_FILE_CLOSED 0xC0000128 -#define NT_STATUS_TOO_MANY_THREADS 0xC0000129 -#define NT_STATUS_THREAD_NOT_IN_PROCESS 0xC000012a -#define NT_STATUS_TOKEN_ALREADY_IN_USE 0xC000012b -#define NT_STATUS_PAGEFILE_QUOTA_EXCEEDED 0xC000012c -#define NT_STATUS_COMMITMENT_LIMIT 0xC000012d -#define NT_STATUS_INVALID_IMAGE_LE_FORMAT 0xC000012e -#define NT_STATUS_INVALID_IMAGE_NOT_MZ 0xC000012f -#define NT_STATUS_INVALID_IMAGE_PROTECT 0xC0000130 -#define NT_STATUS_INVALID_IMAGE_WIN_16 0xC0000131 -#define NT_STATUS_LOGON_SERVER_CONFLICT 0xC0000132 -#define NT_STATUS_TIME_DIFFERENCE_AT_DC 0xC0000133 -#define NT_STATUS_SYNCHRONIZATION_REQUIRED 0xC0000134 -#define NT_STATUS_DLL_NOT_FOUND 0xC0000135 -#define NT_STATUS_OPEN_FAILED 0xC0000136 -#define NT_STATUS_IO_PRIVILEGE_FAILED 0xC0000137 -#define NT_STATUS_ORDINAL_NOT_FOUND 0xC0000138 -#define NT_STATUS_ENTRYPOINT_NOT_FOUND 0xC0000139 -#define NT_STATUS_CONTROL_C_EXIT 0xC000013a -#define NT_STATUS_LOCAL_DISCONNECT 0xC000013b -#define NT_STATUS_REMOTE_DISCONNECT 0xC000013c -#define NT_STATUS_REMOTE_RESOURCES 0xC000013d -#define NT_STATUS_LINK_FAILED 0xC000013e -#define NT_STATUS_LINK_TIMEOUT 0xC000013f -#define NT_STATUS_INVALID_CONNECTION 0xC0000140 -#define NT_STATUS_INVALID_ADDRESS 0xC0000141 -#define NT_STATUS_DLL_INIT_FAILED 0xC0000142 -#define NT_STATUS_MISSING_SYSTEMFILE 0xC0000143 -#define NT_STATUS_UNHANDLED_EXCEPTION 0xC0000144 -#define NT_STATUS_APP_INIT_FAILURE 0xC0000145 -#define NT_STATUS_PAGEFILE_CREATE_FAILED 0xC0000146 -#define NT_STATUS_NO_PAGEFILE 0xC0000147 -#define NT_STATUS_INVALID_LEVEL 0xC0000148 -#define NT_STATUS_WRONG_PASSWORD_CORE 0xC0000149 -#define NT_STATUS_ILLEGAL_FLOAT_CONTEXT 0xC000014a -#define NT_STATUS_PIPE_BROKEN 0xC000014b -#define NT_STATUS_REGISTRY_CORRUPT 0xC000014c -#define NT_STATUS_REGISTRY_IO_FAILED 0xC000014d -#define NT_STATUS_NO_EVENT_PAIR 0xC000014e -#define NT_STATUS_UNRECOGNIZED_VOLUME 0xC000014f -#define NT_STATUS_SERIAL_NO_DEVICE_INITED 0xC0000150 -#define NT_STATUS_NO_SUCH_ALIAS 0xC0000151 -#define NT_STATUS_MEMBER_NOT_IN_ALIAS 0xC0000152 -#define NT_STATUS_MEMBER_IN_ALIAS 0xC0000153 -#define NT_STATUS_ALIAS_EXISTS 0xC0000154 -#define NT_STATUS_LOGON_NOT_GRANTED 0xC0000155 -#define NT_STATUS_TOO_MANY_SECRETS 0xC0000156 -#define NT_STATUS_SECRET_TOO_LONG 0xC0000157 -#define NT_STATUS_INTERNAL_DB_ERROR 0xC0000158 -#define NT_STATUS_FULLSCREEN_MODE 0xC0000159 -#define NT_STATUS_TOO_MANY_CONTEXT_IDS 0xC000015a -#define NT_STATUS_LOGON_TYPE_NOT_GRANTED 0xC000015b -#define NT_STATUS_NOT_REGISTRY_FILE 0xC000015c -#define NT_STATUS_NT_CROSS_ENCRYPTION_REQUIRED 0xC000015d -#define NT_STATUS_DOMAIN_CTRLR_CONFIG_ERROR 0xC000015e -#define NT_STATUS_FT_MISSING_MEMBER 0xC000015f -#define NT_STATUS_ILL_FORMED_SERVICE_ENTRY 0xC0000160 -#define NT_STATUS_ILLEGAL_CHARACTER 0xC0000161 -#define NT_STATUS_UNMAPPABLE_CHARACTER 0xC0000162 -#define NT_STATUS_UNDEFINED_CHARACTER 0xC0000163 -#define NT_STATUS_FLOPPY_VOLUME 0xC0000164 -#define NT_STATUS_FLOPPY_ID_MARK_NOT_FOUND 0xC0000165 -#define NT_STATUS_FLOPPY_WRONG_CYLINDER 0xC0000166 -#define NT_STATUS_FLOPPY_UNKNOWN_ERROR 0xC0000167 -#define NT_STATUS_FLOPPY_BAD_REGISTERS 0xC0000168 -#define NT_STATUS_DISK_RECALIBRATE_FAILED 0xC0000169 -#define NT_STATUS_DISK_OPERATION_FAILED 0xC000016a -#define NT_STATUS_DISK_RESET_FAILED 0xC000016b -#define NT_STATUS_SHARED_IRQ_BUSY 0xC000016c -#define NT_STATUS_FT_ORPHANING 0xC000016d -#define NT_STATUS_PARTITION_FAILURE 0xC0000172 -#define NT_STATUS_INVALID_BLOCK_LENGTH 0xC0000173 -#define NT_STATUS_DEVICE_NOT_PARTITIONED 0xC0000174 -#define NT_STATUS_UNABLE_TO_LOCK_MEDIA 0xC0000175 -#define NT_STATUS_UNABLE_TO_UNLOAD_MEDIA 0xC0000176 -#define NT_STATUS_EOM_OVERFLOW 0xC0000177 -#define NT_STATUS_NO_MEDIA 0xC0000178 -#define NT_STATUS_NO_SUCH_MEMBER 0xC000017a -#define NT_STATUS_INVALID_MEMBER 0xC000017b -#define NT_STATUS_KEY_DELETED 0xC000017c -#define NT_STATUS_NO_LOG_SPACE 0xC000017d -#define NT_STATUS_TOO_MANY_SIDS 0xC000017e -#define NT_STATUS_LM_CROSS_ENCRYPTION_REQUIRED 0xC000017f -#define NT_STATUS_KEY_HAS_CHILDREN 0xC0000180 -#define NT_STATUS_CHILD_MUST_BE_VOLATILE 0xC0000181 -#define NT_STATUS_DEVICE_CONFIGURATION_ERROR 0xC0000182 -#define NT_STATUS_DRIVER_INTERNAL_ERROR 0xC0000183 -#define NT_STATUS_INVALID_DEVICE_STATE 0xC0000184 -#define NT_STATUS_IO_DEVICE_ERROR 0xC0000185 -#define NT_STATUS_DEVICE_PROTOCOL_ERROR 0xC0000186 -#define NT_STATUS_BACKUP_CONTROLLER 0xC0000187 -#define NT_STATUS_LOG_FILE_FULL 0xC0000188 -#define NT_STATUS_TOO_LATE 0xC0000189 -#define NT_STATUS_NO_TRUST_LSA_SECRET 0xC000018a -#define NT_STATUS_NO_TRUST_SAM_ACCOUNT 0xC000018b -#define NT_STATUS_TRUSTED_DOMAIN_FAILURE 0xC000018c -#define NT_STATUS_TRUSTED_RELATIONSHIP_FAILURE 0xC000018d -#define NT_STATUS_EVENTLOG_FILE_CORRUPT 0xC000018e -#define NT_STATUS_EVENTLOG_CANT_START 0xC000018f -#define NT_STATUS_TRUST_FAILURE 0xC0000190 -#define NT_STATUS_MUTANT_LIMIT_EXCEEDED 0xC0000191 -#define NT_STATUS_NETLOGON_NOT_STARTED 0xC0000192 -#define NT_STATUS_ACCOUNT_EXPIRED 0xC0000193 -#define NT_STATUS_POSSIBLE_DEADLOCK 0xC0000194 -#define NT_STATUS_NETWORK_CREDENTIAL_CONFLICT 0xC0000195 -#define NT_STATUS_REMOTE_SESSION_LIMIT 0xC0000196 -#define NT_STATUS_EVENTLOG_FILE_CHANGED 0xC0000197 -#define NT_STATUS_NOLOGON_INTERDOMAIN_TRUST_ACCOUNT 0xC0000198 -#define NT_STATUS_NOLOGON_WORKSTATION_TRUST_ACCOUNT 0xC0000199 -#define NT_STATUS_NOLOGON_SERVER_TRUST_ACCOUNT 0xC000019a -#define NT_STATUS_DOMAIN_TRUST_INCONSISTENT 0xC000019b -#define NT_STATUS_FS_DRIVER_REQUIRED 0xC000019c -#define NT_STATUS_NO_USER_SESSION_KEY 0xC0000202 -#define NT_STATUS_USER_SESSION_DELETED 0xC0000203 -#define NT_STATUS_RESOURCE_LANG_NOT_FOUND 0xC0000204 -#define NT_STATUS_INSUFF_SERVER_RESOURCES 0xC0000205 -#define NT_STATUS_INVALID_BUFFER_SIZE 0xC0000206 -#define NT_STATUS_INVALID_ADDRESS_COMPONENT 0xC0000207 -#define NT_STATUS_INVALID_ADDRESS_WILDCARD 0xC0000208 -#define NT_STATUS_TOO_MANY_ADDRESSES 0xC0000209 -#define NT_STATUS_ADDRESS_ALREADY_EXISTS 0xC000020a -#define NT_STATUS_ADDRESS_CLOSED 0xC000020b -#define NT_STATUS_CONNECTION_DISCONNECTED 0xC000020c -#define NT_STATUS_CONNECTION_RESET 0xC000020d -#define NT_STATUS_TOO_MANY_NODES 0xC000020e -#define NT_STATUS_TRANSACTION_ABORTED 0xC000020f -#define NT_STATUS_TRANSACTION_TIMED_OUT 0xC0000210 -#define NT_STATUS_TRANSACTION_NO_RELEASE 0xC0000211 -#define NT_STATUS_TRANSACTION_NO_MATCH 0xC0000212 -#define NT_STATUS_TRANSACTION_RESPONDED 0xC0000213 -#define NT_STATUS_TRANSACTION_INVALID_ID 0xC0000214 -#define NT_STATUS_TRANSACTION_INVALID_TYPE 0xC0000215 -#define NT_STATUS_NOT_SERVER_SESSION 0xC0000216 -#define NT_STATUS_NOT_CLIENT_SESSION 0xC0000217 -#define NT_STATUS_CANNOT_LOAD_REGISTRY_FILE 0xC0000218 -#define NT_STATUS_DEBUG_ATTACH_FAILED 0xC0000219 -#define NT_STATUS_SYSTEM_PROCESS_TERMINATED 0xC000021a -#define NT_STATUS_DATA_NOT_ACCEPTED 0xC000021b -#define NT_STATUS_NO_BROWSER_SERVERS_FOUND 0xC000021c -#define NT_STATUS_VDM_HARD_ERROR 0xC000021d -#define NT_STATUS_DRIVER_CANCEL_TIMEOUT 0xC000021e -#define NT_STATUS_REPLY_MESSAGE_MISMATCH 0xC000021f -#define NT_STATUS_MAPPED_ALIGNMENT 0xC0000220 -#define NT_STATUS_IMAGE_CHECKSUM_MISMATCH 0xC0000221 -#define NT_STATUS_LOST_WRITEBEHIND_DATA 0xC0000222 -#define NT_STATUS_CLIENT_SERVER_PARAMETERS_INVALID 0xC0000223 -#define NT_STATUS_PASSWORD_MUST_CHANGE 0xC0000224 -#define NT_STATUS_NOT_FOUND 0xC0000225 -#define NT_STATUS_NOT_TINY_STREAM 0xC0000226 -#define NT_STATUS_RECOVERY_FAILURE 0xC0000227 -#define NT_STATUS_STACK_OVERFLOW_READ 0xC0000228 -#define NT_STATUS_FAIL_CHECK 0xC0000229 -#define NT_STATUS_DUPLICATE_OBJECTID 0xC000022a -#define NT_STATUS_OBJECTID_EXISTS 0xC000022b -#define NT_STATUS_CONVERT_TO_LARGE 0xC000022c -#define NT_STATUS_RETRY 0xC000022d -#define NT_STATUS_FOUND_OUT_OF_SCOPE 0xC000022e -#define NT_STATUS_ALLOCATE_BUCKET 0xC000022f -#define NT_STATUS_PROPSET_NOT_FOUND 0xC0000230 -#define NT_STATUS_MARSHALL_OVERFLOW 0xC0000231 -#define NT_STATUS_INVALID_VARIANT 0xC0000232 -#define NT_STATUS_DOMAIN_CONTROLLER_NOT_FOUND 0xC0000233 -#define NT_STATUS_ACCOUNT_LOCKED_OUT 0xC0000234 -#define NT_STATUS_HANDLE_NOT_CLOSABLE 0xC0000235 -#define NT_STATUS_CONNECTION_REFUSED 0xC0000236 -#define NT_STATUS_GRACEFUL_DISCONNECT 0xC0000237 -#define NT_STATUS_ADDRESS_ALREADY_ASSOCIATED 0xC0000238 -#define NT_STATUS_ADDRESS_NOT_ASSOCIATED 0xC0000239 -#define NT_STATUS_CONNECTION_INVALID 0xC000023a -#define NT_STATUS_CONNECTION_ACTIVE 0xC000023b -#define NT_STATUS_NETWORK_UNREACHABLE 0xC000023c -#define NT_STATUS_HOST_UNREACHABLE 0xC000023d -#define NT_STATUS_PROTOCOL_UNREACHABLE 0xC000023e -#define NT_STATUS_PORT_UNREACHABLE 0xC000023f -#define NT_STATUS_REQUEST_ABORTED 0xC0000240 -#define NT_STATUS_CONNECTION_ABORTED 0xC0000241 -#define NT_STATUS_BAD_COMPRESSION_BUFFER 0xC0000242 -#define NT_STATUS_USER_MAPPED_FILE 0xC0000243 -#define NT_STATUS_AUDIT_FAILED 0xC0000244 -#define NT_STATUS_TIMER_RESOLUTION_NOT_SET 0xC0000245 -#define NT_STATUS_CONNECTION_COUNT_LIMIT 0xC0000246 -#define NT_STATUS_LOGIN_TIME_RESTRICTION 0xC0000247 -#define NT_STATUS_LOGIN_WKSTA_RESTRICTION 0xC0000248 -#define NT_STATUS_IMAGE_MP_UP_MISMATCH 0xC0000249 -#define NT_STATUS_INSUFFICIENT_LOGON_INFO 0xC0000250 -#define NT_STATUS_BAD_DLL_ENTRYPOINT 0xC0000251 -#define NT_STATUS_BAD_SERVICE_ENTRYPOINT 0xC0000252 -#define NT_STATUS_LPC_REPLY_LOST 0xC0000253 -#define NT_STATUS_IP_ADDRESS_CONFLICT1 0xC0000254 -#define NT_STATUS_IP_ADDRESS_CONFLICT2 0xC0000255 -#define NT_STATUS_REGISTRY_QUOTA_LIMIT 0xC0000256 -#define NT_STATUS_PATH_NOT_COVERED 0xC0000257 -#define NT_STATUS_NO_CALLBACK_ACTIVE 0xC0000258 -#define NT_STATUS_LICENSE_QUOTA_EXCEEDED 0xC0000259 -#define NT_STATUS_PWD_TOO_SHORT 0xC000025a -#define NT_STATUS_PWD_TOO_RECENT 0xC000025b -#define NT_STATUS_PWD_HISTORY_CONFLICT 0xC000025c -#define NT_STATUS_PLUGPLAY_NO_DEVICE 0xC000025e -#define NT_STATUS_UNSUPPORTED_COMPRESSION 0xC000025f -#define NT_STATUS_INVALID_HW_PROFILE 0xC0000260 -#define NT_STATUS_INVALID_PLUGPLAY_DEVICE_PATH 0xC0000261 -#define NT_STATUS_DRIVER_ORDINAL_NOT_FOUND 0xC0000262 -#define NT_STATUS_DRIVER_ENTRYPOINT_NOT_FOUND 0xC0000263 -#define NT_STATUS_RESOURCE_NOT_OWNED 0xC0000264 -#define NT_STATUS_TOO_MANY_LINKS 0xC0000265 -#define NT_STATUS_QUOTA_LIST_INCONSISTENT 0xC0000266 -#define NT_STATUS_FILE_IS_OFFLINE 0xC0000267 -#define NT_STATUS_NOT_A_REPARSE_POINT 0xC0000275 -#define NT_STATUS_NO_SUCH_JOB 0xC0000EDE +%include "status_codes.i" %pythoncode %{ NTSTATUS = _dcerpc.NTSTATUS diff --git a/source4/scripting/swig/status_codes.i b/source4/scripting/swig/status_codes.i new file mode 100644 index 0000000000..dccbfab61d --- /dev/null +++ b/source4/scripting/swig/status_codes.i @@ -0,0 +1,552 @@ +/* Win32 status codes */ + +#define STATUS_BUFFER_OVERFLOW 0x80000005 +#define STATUS_NO_MORE_FILES 0x80000006 +#define NT_STATUS_NO_MORE_ENTRIES 0x8000001a + +#define STATUS_MORE_ENTRIES 0x0105 +#define STATUS_SOME_UNMAPPED 0x0107 +#define ERROR_INVALID_PARAMETER 0x0057 +#define ERROR_INSUFFICIENT_BUFFER 0x007a +#define STATUS_NOTIFY_ENUM_DIR 0x010c +#define ERROR_INVALID_DATATYPE 0x070c + +/* NT status codes */ + +#define NT_STATUS_OK 0x00000000 +#define NT_STATUS_UNSUCCESSFUL 0xC0000001 +#define NT_STATUS_NOT_IMPLEMENTED 0xC0000002 +#define NT_STATUS_INVALID_INFO_CLASS 0xC0000003 +#define NT_STATUS_INFO_LENGTH_MISMATCH 0xC0000004 +#define NT_STATUS_ACCESS_VIOLATION 0xC0000005 +#define NT_STATUS_IN_PAGE_ERROR 0xC0000006 +#define NT_STATUS_PAGEFILE_QUOTA 0xC0000007 +#define NT_STATUS_INVALID_HANDLE 0xC0000008 +#define NT_STATUS_BAD_INITIAL_STACK 0xC0000009 +#define NT_STATUS_BAD_INITIAL_PC 0xC000000a +#define NT_STATUS_INVALID_CID 0xC000000b +#define NT_STATUS_TIMER_NOT_CANCELED 0xC000000c +#define NT_STATUS_INVALID_PARAMETER 0xC000000d +#define NT_STATUS_NO_SUCH_DEVICE 0xC000000e +#define NT_STATUS_NO_SUCH_FILE 0xC000000f +#define NT_STATUS_INVALID_DEVICE_REQUEST 0xC0000010 +#define NT_STATUS_END_OF_FILE 0xC0000011 +#define NT_STATUS_WRONG_VOLUME 0xC0000012 +#define NT_STATUS_NO_MEDIA_IN_DEVICE 0xC0000013 +#define NT_STATUS_UNRECOGNIZED_MEDIA 0xC0000014 +#define NT_STATUS_NONEXISTENT_SECTOR 0xC0000015 +#define NT_STATUS_MORE_PROCESSING_REQUIRED 0xC0000016 +#define NT_STATUS_NO_MEMORY 0xC0000017 +#define NT_STATUS_CONFLICTING_ADDRESSES 0xC0000018 +#define NT_STATUS_NOT_MAPPED_VIEW 0xC0000019 +#define NT_STATUS_UNABLE_TO_FREE_VM 0xC000001a +#define NT_STATUS_UNABLE_TO_DELETE_SECTION 0xC000001b +#define NT_STATUS_INVALID_SYSTEM_SERVICE 0xC000001c +#define NT_STATUS_ILLEGAL_INSTRUCTION 0xC000001d +#define NT_STATUS_INVALID_LOCK_SEQUENCE 0xC000001e +#define NT_STATUS_INVALID_VIEW_SIZE 0xC000001f +#define NT_STATUS_INVALID_FILE_FOR_SECTION 0xC0000020 +#define NT_STATUS_ALREADY_COMMITTED 0xC0000021 +#define NT_STATUS_ACCESS_DENIED 0xC0000022 +#define NT_STATUS_BUFFER_TOO_SMALL 0xC0000023 +#define NT_STATUS_OBJECT_TYPE_MISMATCH 0xC0000024 +#define NT_STATUS_NONCONTINUABLE_EXCEPTION 0xC0000025 +#define NT_STATUS_INVALID_DISPOSITION 0xC0000026 +#define NT_STATUS_UNWIND 0xC0000027 +#define NT_STATUS_BAD_STACK 0xC0000028 +#define NT_STATUS_INVALID_UNWIND_TARGET 0xC0000029 +#define NT_STATUS_NOT_LOCKED 0xC000002a +#define NT_STATUS_PARITY_ERROR 0xC000002b +#define NT_STATUS_UNABLE_TO_DECOMMIT_VM 0xC000002c +#define NT_STATUS_NOT_COMMITTED 0xC000002d +#define NT_STATUS_INVALID_PORT_ATTRIBUTES 0xC000002e +#define NT_STATUS_PORT_MESSAGE_TOO_LONG 0xC000002f +#define NT_STATUS_INVALID_PARAMETER_MIX 0xC0000030 +#define NT_STATUS_INVALID_QUOTA_LOWER 0xC0000031 +#define NT_STATUS_DISK_CORRUPT_ERROR 0xC0000032 +#define NT_STATUS_OBJECT_NAME_INVALID 0xC0000033 +#define NT_STATUS_OBJECT_NAME_NOT_FOUND 0xC0000034 +#define NT_STATUS_OBJECT_NAME_COLLISION 0xC0000035 +#define NT_STATUS_HANDLE_NOT_WAITABLE 0xC0000036 +#define NT_STATUS_PORT_DISCONNECTED 0xC0000037 +#define NT_STATUS_DEVICE_ALREADY_ATTACHED 0xC0000038 +#define NT_STATUS_OBJECT_PATH_INVALID 0xC0000039 +#define NT_STATUS_OBJECT_PATH_NOT_FOUND 0xC000003a +#define NT_STATUS_OBJECT_PATH_SYNTAX_BAD 0xC000003b +#define NT_STATUS_DATA_OVERRUN 0xC000003c +#define NT_STATUS_DATA_LATE_ERROR 0xC000003d +#define NT_STATUS_DATA_ERROR 0xC000003e +#define NT_STATUS_CRC_ERROR 0xC000003f +#define NT_STATUS_SECTION_TOO_BIG 0xC0000040 +#define NT_STATUS_PORT_CONNECTION_REFUSED 0xC0000041 +#define NT_STATUS_INVALID_PORT_HANDLE 0xC0000042 +#define NT_STATUS_SHARING_VIOLATION 0xC0000043 +#define NT_STATUS_QUOTA_EXCEEDED 0xC0000044 +#define NT_STATUS_INVALID_PAGE_PROTECTION 0xC0000045 +#define NT_STATUS_MUTANT_NOT_OWNED 0xC0000046 +#define NT_STATUS_SEMAPHORE_LIMIT_EXCEEDED 0xC0000047 +#define NT_STATUS_PORT_ALREADY_SET 0xC0000048 +#define NT_STATUS_SECTION_NOT_IMAGE 0xC0000049 +#define NT_STATUS_SUSPEND_COUNT_EXCEEDED 0xC000004a +#define NT_STATUS_THREAD_IS_TERMINATING 0xC000004b +#define NT_STATUS_BAD_WORKING_SET_LIMIT 0xC000004c +#define NT_STATUS_INCOMPATIBLE_FILE_MAP 0xC000004d +#define NT_STATUS_SECTION_PROTECTION 0xC000004e +#define NT_STATUS_EAS_NOT_SUPPORTED 0xC000004f +#define NT_STATUS_EA_TOO_LARGE 0xC0000050 +#define NT_STATUS_NONEXISTENT_EA_ENTRY 0xC0000051 +#define NT_STATUS_NO_EAS_ON_FILE 0xC0000052 +#define NT_STATUS_EA_CORRUPT_ERROR 0xC0000053 +#define NT_STATUS_FILE_LOCK_CONFLICT 0xC0000054 +#define NT_STATUS_LOCK_NOT_GRANTED 0xC0000055 +#define NT_STATUS_DELETE_PENDING 0xC0000056 +#define NT_STATUS_CTL_FILE_NOT_SUPPORTED 0xC0000057 +#define NT_STATUS_UNKNOWN_REVISION 0xC0000058 +#define NT_STATUS_REVISION_MISMATCH 0xC0000059 +#define NT_STATUS_INVALID_OWNER 0xC000005a +#define NT_STATUS_INVALID_PRIMARY_GROUP 0xC000005b +#define NT_STATUS_NO_IMPERSONATION_TOKEN 0xC000005c +#define NT_STATUS_CANT_DISABLE_MANDATORY 0xC000005d +#define NT_STATUS_NO_LOGON_SERVERS 0xC000005e +#define NT_STATUS_NO_SUCH_LOGON_SESSION 0xC000005f +#define NT_STATUS_NO_SUCH_PRIVILEGE 0xC0000060 +#define NT_STATUS_PRIVILEGE_NOT_HELD 0xC0000061 +#define NT_STATUS_INVALID_ACCOUNT_NAME 0xC0000062 +#define NT_STATUS_USER_EXISTS 0xC0000063 +#define NT_STATUS_NO_SUCH_USER 0xC0000064 +#define NT_STATUS_GROUP_EXISTS 0xC0000065 +#define NT_STATUS_NO_SUCH_GROUP 0xC0000066 +#define NT_STATUS_MEMBER_IN_GROUP 0xC0000067 +#define NT_STATUS_MEMBER_NOT_IN_GROUP 0xC0000068 +#define NT_STATUS_LAST_ADMIN 0xC0000069 +#define NT_STATUS_WRONG_PASSWORD 0xC000006a +#define NT_STATUS_ILL_FORMED_PASSWORD 0xC000006b +#define NT_STATUS_PASSWORD_RESTRICTION 0xC000006c +#define NT_STATUS_LOGON_FAILURE 0xC000006d +#define NT_STATUS_ACCOUNT_RESTRICTION 0xC000006e +#define NT_STATUS_INVALID_LOGON_HOURS 0xC000006f +#define NT_STATUS_INVALID_WORKSTATION 0xC0000070 +#define NT_STATUS_PASSWORD_EXPIRED 0xC0000071 +#define NT_STATUS_ACCOUNT_DISABLED 0xC0000072 +#define NT_STATUS_NONE_MAPPED 0xC0000073 +#define NT_STATUS_TOO_MANY_LUIDS_REQUESTED 0xC0000074 +#define NT_STATUS_LUIDS_EXHAUSTED 0xC0000075 +#define NT_STATUS_INVALID_SUB_AUTHORITY 0xC0000076 +#define NT_STATUS_INVALID_ACL 0xC0000077 +#define NT_STATUS_INVALID_SID 0xC0000078 +#define NT_STATUS_INVALID_SECURITY_DESCR 0xC0000079 +#define NT_STATUS_PROCEDURE_NOT_FOUND 0xC000007a +#define NT_STATUS_INVALID_IMAGE_FORMAT 0xC000007b +#define NT_STATUS_NO_TOKEN 0xC000007c +#define NT_STATUS_BAD_INHERITANCE_ACL 0xC000007d +#define NT_STATUS_RANGE_NOT_LOCKED 0xC000007e +#define NT_STATUS_DISK_FULL 0xC000007f +#define NT_STATUS_SERVER_DISABLED 0xC0000080 +#define NT_STATUS_SERVER_NOT_DISABLED 0xC0000081 +#define NT_STATUS_TOO_MANY_GUIDS_REQUESTED 0xC0000082 +#define NT_STATUS_GUIDS_EXHAUSTED 0xC0000083 +#define NT_STATUS_INVALID_ID_AUTHORITY 0xC0000084 +#define NT_STATUS_AGENTS_EXHAUSTED 0xC0000085 +#define NT_STATUS_INVALID_VOLUME_LABEL 0xC0000086 +#define NT_STATUS_SECTION_NOT_EXTENDED 0xC0000087 +#define NT_STATUS_NOT_MAPPED_DATA 0xC0000088 +#define NT_STATUS_RESOURCE_DATA_NOT_FOUND 0xC0000089 +#define NT_STATUS_RESOURCE_TYPE_NOT_FOUND 0xC000008a +#define NT_STATUS_RESOURCE_NAME_NOT_FOUND 0xC000008b +#define NT_STATUS_ARRAY_BOUNDS_EXCEEDED 0xC000008c +#define NT_STATUS_FLOAT_DENORMAL_OPERAND 0xC000008d +#define NT_STATUS_FLOAT_DIVIDE_BY_ZERO 0xC000008e +#define NT_STATUS_FLOAT_INEXACT_RESULT 0xC000008f +#define NT_STATUS_FLOAT_INVALID_OPERATION 0xC0000090 +#define NT_STATUS_FLOAT_OVERFLOW 0xC0000091 +#define NT_STATUS_FLOAT_STACK_CHECK 0xC0000092 +#define NT_STATUS_FLOAT_UNDERFLOW 0xC0000093 +#define NT_STATUS_INTEGER_DIVIDE_BY_ZERO 0xC0000094 +#define NT_STATUS_INTEGER_OVERFLOW 0xC0000095 +#define NT_STATUS_PRIVILEGED_INSTRUCTION 0xC0000096 +#define NT_STATUS_TOO_MANY_PAGING_FILES 0xC0000097 +#define NT_STATUS_FILE_INVALID 0xC0000098 +#define NT_STATUS_ALLOTTED_SPACE_EXCEEDED 0xC0000099 +#define NT_STATUS_INSUFFICIENT_RESOURCES 0xC000009a +#define NT_STATUS_DFS_EXIT_PATH_FOUND 0xC000009b +#define NT_STATUS_DEVICE_DATA_ERROR 0xC000009c +#define NT_STATUS_DEVICE_NOT_CONNECTED 0xC000009d +#define NT_STATUS_DEVICE_POWER_FAILURE 0xC000009e +#define NT_STATUS_FREE_VM_NOT_AT_BASE 0xC000009f +#define NT_STATUS_MEMORY_NOT_ALLOCATED 0xC00000a0 +#define NT_STATUS_WORKING_SET_QUOTA 0xC00000a1 +#define NT_STATUS_MEDIA_WRITE_PROTECTED 0xC00000a2 +#define NT_STATUS_DEVICE_NOT_READY 0xC00000a3 +#define NT_STATUS_INVALID_GROUP_ATTRIBUTES 0xC00000a4 +#define NT_STATUS_BAD_IMPERSONATION_LEVEL 0xC00000a5 +#define NT_STATUS_CANT_OPEN_ANONYMOUS 0xC00000a6 +#define NT_STATUS_BAD_VALIDATION_CLASS 0xC00000a7 +#define NT_STATUS_BAD_TOKEN_TYPE 0xC00000a8 +#define NT_STATUS_BAD_MASTER_BOOT_RECORD 0xC00000a9 +#define NT_STATUS_INSTRUCTION_MISALIGNMENT 0xC00000aa +#define NT_STATUS_INSTANCE_NOT_AVAILABLE 0xC00000ab +#define NT_STATUS_PIPE_NOT_AVAILABLE 0xC00000ac +#define NT_STATUS_INVALID_PIPE_STATE 0xC00000ad +#define NT_STATUS_PIPE_BUSY 0xC00000ae +#define NT_STATUS_ILLEGAL_FUNCTION 0xC00000af +#define NT_STATUS_PIPE_DISCONNECTED 0xC00000b0 +#define NT_STATUS_PIPE_CLOSING 0xC00000b1 +#define NT_STATUS_PIPE_CONNECTED 0xC00000b2 +#define NT_STATUS_PIPE_LISTENING 0xC00000b3 +#define NT_STATUS_INVALID_READ_MODE 0xC00000b4 +#define NT_STATUS_IO_TIMEOUT 0xC00000b5 +#define NT_STATUS_FILE_FORCED_CLOSED 0xC00000b6 +#define NT_STATUS_PROFILING_NOT_STARTED 0xC00000b7 +#define NT_STATUS_PROFILING_NOT_STOPPED 0xC00000b8 +#define NT_STATUS_COULD_NOT_INTERPRET 0xC00000b9 +#define NT_STATUS_FILE_IS_A_DIRECTORY 0xC00000ba +#define NT_STATUS_NOT_SUPPORTED 0xC00000bb +#define NT_STATUS_REMOTE_NOT_LISTENING 0xC00000bc +#define NT_STATUS_DUPLICATE_NAME 0xC00000bd +#define NT_STATUS_BAD_NETWORK_PATH 0xC00000be +#define NT_STATUS_NETWORK_BUSY 0xC00000bf +#define NT_STATUS_DEVICE_DOES_NOT_EXIST 0xC00000c0 +#define NT_STATUS_TOO_MANY_COMMANDS 0xC00000c1 +#define NT_STATUS_ADAPTER_HARDWARE_ERROR 0xC00000c2 +#define NT_STATUS_INVALID_NETWORK_RESPONSE 0xC00000c3 +#define NT_STATUS_UNEXPECTED_NETWORK_ERROR 0xC00000c4 +#define NT_STATUS_BAD_REMOTE_ADAPTER 0xC00000c5 +#define NT_STATUS_PRINT_QUEUE_FULL 0xC00000c6 +#define NT_STATUS_NO_SPOOL_SPACE 0xC00000c7 +#define NT_STATUS_PRINT_CANCELLED 0xC00000c8 +#define NT_STATUS_NETWORK_NAME_DELETED 0xC00000c9 +#define NT_STATUS_NETWORK_ACCESS_DENIED 0xC00000ca +#define NT_STATUS_BAD_DEVICE_TYPE 0xC00000cb +#define NT_STATUS_BAD_NETWORK_NAME 0xC00000cc +#define NT_STATUS_TOO_MANY_NAMES 0xC00000cd +#define NT_STATUS_TOO_MANY_SESSIONS 0xC00000ce +#define NT_STATUS_SHARING_PAUSED 0xC00000cf +#define NT_STATUS_REQUEST_NOT_ACCEPTED 0xC00000d0 +#define NT_STATUS_REDIRECTOR_PAUSED 0xC00000d1 +#define NT_STATUS_NET_WRITE_FAULT 0xC00000d2 +#define NT_STATUS_PROFILING_AT_LIMIT 0xC00000d3 +#define NT_STATUS_NOT_SAME_DEVICE 0xC00000d4 +#define NT_STATUS_FILE_RENAMED 0xC00000d5 +#define NT_STATUS_VIRTUAL_CIRCUIT_CLOSED 0xC00000d6 +#define NT_STATUS_NO_SECURITY_ON_OBJECT 0xC00000d7 +#define NT_STATUS_CANT_WAIT 0xC00000d8 +#define NT_STATUS_PIPE_EMPTY 0xC00000d9 +#define NT_STATUS_CANT_ACCESS_DOMAIN_INFO 0xC00000da +#define NT_STATUS_CANT_TERMINATE_SELF 0xC00000db +#define NT_STATUS_INVALID_SERVER_STATE 0xC00000dc +#define NT_STATUS_INVALID_DOMAIN_STATE 0xC00000dd +#define NT_STATUS_INVALID_DOMAIN_ROLE 0xC00000de +#define NT_STATUS_NO_SUCH_DOMAIN 0xC00000df +#define NT_STATUS_DOMAIN_EXISTS 0xC00000e0 +#define NT_STATUS_DOMAIN_LIMIT_EXCEEDED 0xC00000e1 +#define NT_STATUS_OPLOCK_NOT_GRANTED 0xC00000e2 +#define NT_STATUS_INVALID_OPLOCK_PROTOCOL 0xC00000e3 +#define NT_STATUS_INTERNAL_DB_CORRUPTION 0xC00000e4 +#define NT_STATUS_INTERNAL_ERROR 0xC00000e5 +#define NT_STATUS_GENERIC_NOT_MAPPED 0xC00000e6 +#define NT_STATUS_BAD_DESCRIPTOR_FORMAT 0xC00000e7 +#define NT_STATUS_INVALID_USER_BUFFER 0xC00000e8 +#define NT_STATUS_UNEXPECTED_IO_ERROR 0xC00000e9 +#define NT_STATUS_UNEXPECTED_MM_CREATE_ERR 0xC00000ea +#define NT_STATUS_UNEXPECTED_MM_MAP_ERROR 0xC00000eb +#define NT_STATUS_UNEXPECTED_MM_EXTEND_ERR 0xC00000ec +#define NT_STATUS_NOT_LOGON_PROCESS 0xC00000ed +#define NT_STATUS_LOGON_SESSION_EXISTS 0xC00000ee +#define NT_STATUS_INVALID_PARAMETER_1 0xC00000ef +#define NT_STATUS_INVALID_PARAMETER_2 0xC00000f0 +#define NT_STATUS_INVALID_PARAMETER_3 0xC00000f1 +#define NT_STATUS_INVALID_PARAMETER_4 0xC00000f2 +#define NT_STATUS_INVALID_PARAMETER_5 0xC00000f3 +#define NT_STATUS_INVALID_PARAMETER_6 0xC00000f4 +#define NT_STATUS_INVALID_PARAMETER_7 0xC00000f5 +#define NT_STATUS_INVALID_PARAMETER_8 0xC00000f6 +#define NT_STATUS_INVALID_PARAMETER_9 0xC00000f7 +#define NT_STATUS_INVALID_PARAMETER_10 0xC00000f8 +#define NT_STATUS_INVALID_PARAMETER_11 0xC00000f9 +#define NT_STATUS_INVALID_PARAMETER_12 0xC00000fa +#define NT_STATUS_REDIRECTOR_NOT_STARTED 0xC00000fb +#define NT_STATUS_REDIRECTOR_STARTED 0xC00000fc +#define NT_STATUS_STACK_OVERFLOW 0xC00000fd +#define NT_STATUS_NO_SUCH_PACKAGE 0xC00000fe +#define NT_STATUS_BAD_FUNCTION_TABLE 0xC00000ff +#define NT_STATUS_DIRECTORY_NOT_EMPTY 0xC0000101 +#define NT_STATUS_FILE_CORRUPT_ERROR 0xC0000102 +#define NT_STATUS_NOT_A_DIRECTORY 0xC0000103 +#define NT_STATUS_BAD_LOGON_SESSION_STATE 0xC0000104 +#define NT_STATUS_LOGON_SESSION_COLLISION 0xC0000105 +#define NT_STATUS_NAME_TOO_LONG 0xC0000106 +#define NT_STATUS_FILES_OPEN 0xC0000107 +#define NT_STATUS_CONNECTION_IN_USE 0xC0000108 +#define NT_STATUS_MESSAGE_NOT_FOUND 0xC0000109 +#define NT_STATUS_PROCESS_IS_TERMINATING 0xC000010a +#define NT_STATUS_INVALID_LOGON_TYPE 0xC000010b +#define NT_STATUS_NO_GUID_TRANSLATION 0xC000010c +#define NT_STATUS_CANNOT_IMPERSONATE 0xC000010d +#define NT_STATUS_IMAGE_ALREADY_LOADED 0xC000010e +#define NT_STATUS_ABIOS_NOT_PRESENT 0xC000010f +#define NT_STATUS_ABIOS_LID_NOT_EXIST 0xC0000110 +#define NT_STATUS_ABIOS_LID_ALREADY_OWNED 0xC0000111 +#define NT_STATUS_ABIOS_NOT_LID_OWNER 0xC0000112 +#define NT_STATUS_ABIOS_INVALID_COMMAND 0xC0000113 +#define NT_STATUS_ABIOS_INVALID_LID 0xC0000114 +#define NT_STATUS_ABIOS_SELECTOR_NOT_AVAILABLE 0xC0000115 +#define NT_STATUS_ABIOS_INVALID_SELECTOR 0xC0000116 +#define NT_STATUS_NO_LDT 0xC0000117 +#define NT_STATUS_INVALID_LDT_SIZE 0xC0000118 +#define NT_STATUS_INVALID_LDT_OFFSET 0xC0000119 +#define NT_STATUS_INVALID_LDT_DESCRIPTOR 0xC000011a +#define NT_STATUS_INVALID_IMAGE_NE_FORMAT 0xC000011b +#define NT_STATUS_RXACT_INVALID_STATE 0xC000011c +#define NT_STATUS_RXACT_COMMIT_FAILURE 0xC000011d +#define NT_STATUS_MAPPED_FILE_SIZE_ZERO 0xC000011e +#define NT_STATUS_TOO_MANY_OPENED_FILES 0xC000011f +#define NT_STATUS_CANCELLED 0xC0000120 +#define NT_STATUS_CANNOT_DELETE 0xC0000121 +#define NT_STATUS_INVALID_COMPUTER_NAME 0xC0000122 +#define NT_STATUS_FILE_DELETED 0xC0000123 +#define NT_STATUS_SPECIAL_ACCOUNT 0xC0000124 +#define NT_STATUS_SPECIAL_GROUP 0xC0000125 +#define NT_STATUS_SPECIAL_USER 0xC0000126 +#define NT_STATUS_MEMBERS_PRIMARY_GROUP 0xC0000127 +#define NT_STATUS_FILE_CLOSED 0xC0000128 +#define NT_STATUS_TOO_MANY_THREADS 0xC0000129 +#define NT_STATUS_THREAD_NOT_IN_PROCESS 0xC000012a +#define NT_STATUS_TOKEN_ALREADY_IN_USE 0xC000012b +#define NT_STATUS_PAGEFILE_QUOTA_EXCEEDED 0xC000012c +#define NT_STATUS_COMMITMENT_LIMIT 0xC000012d +#define NT_STATUS_INVALID_IMAGE_LE_FORMAT 0xC000012e +#define NT_STATUS_INVALID_IMAGE_NOT_MZ 0xC000012f +#define NT_STATUS_INVALID_IMAGE_PROTECT 0xC0000130 +#define NT_STATUS_INVALID_IMAGE_WIN_16 0xC0000131 +#define NT_STATUS_LOGON_SERVER_CONFLICT 0xC0000132 +#define NT_STATUS_TIME_DIFFERENCE_AT_DC 0xC0000133 +#define NT_STATUS_SYNCHRONIZATION_REQUIRED 0xC0000134 +#define NT_STATUS_DLL_NOT_FOUND 0xC0000135 +#define NT_STATUS_OPEN_FAILED 0xC0000136 +#define NT_STATUS_IO_PRIVILEGE_FAILED 0xC0000137 +#define NT_STATUS_ORDINAL_NOT_FOUND 0xC0000138 +#define NT_STATUS_ENTRYPOINT_NOT_FOUND 0xC0000139 +#define NT_STATUS_CONTROL_C_EXIT 0xC000013a +#define NT_STATUS_LOCAL_DISCONNECT 0xC000013b +#define NT_STATUS_REMOTE_DISCONNECT 0xC000013c +#define NT_STATUS_REMOTE_RESOURCES 0xC000013d +#define NT_STATUS_LINK_FAILED 0xC000013e +#define NT_STATUS_LINK_TIMEOUT 0xC000013f +#define NT_STATUS_INVALID_CONNECTION 0xC0000140 +#define NT_STATUS_INVALID_ADDRESS 0xC0000141 +#define NT_STATUS_DLL_INIT_FAILED 0xC0000142 +#define NT_STATUS_MISSING_SYSTEMFILE 0xC0000143 +#define NT_STATUS_UNHANDLED_EXCEPTION 0xC0000144 +#define NT_STATUS_APP_INIT_FAILURE 0xC0000145 +#define NT_STATUS_PAGEFILE_CREATE_FAILED 0xC0000146 +#define NT_STATUS_NO_PAGEFILE 0xC0000147 +#define NT_STATUS_INVALID_LEVEL 0xC0000148 +#define NT_STATUS_WRONG_PASSWORD_CORE 0xC0000149 +#define NT_STATUS_ILLEGAL_FLOAT_CONTEXT 0xC000014a +#define NT_STATUS_PIPE_BROKEN 0xC000014b +#define NT_STATUS_REGISTRY_CORRUPT 0xC000014c +#define NT_STATUS_REGISTRY_IO_FAILED 0xC000014d +#define NT_STATUS_NO_EVENT_PAIR 0xC000014e +#define NT_STATUS_UNRECOGNIZED_VOLUME 0xC000014f +#define NT_STATUS_SERIAL_NO_DEVICE_INITED 0xC0000150 +#define NT_STATUS_NO_SUCH_ALIAS 0xC0000151 +#define NT_STATUS_MEMBER_NOT_IN_ALIAS 0xC0000152 +#define NT_STATUS_MEMBER_IN_ALIAS 0xC0000153 +#define NT_STATUS_ALIAS_EXISTS 0xC0000154 +#define NT_STATUS_LOGON_NOT_GRANTED 0xC0000155 +#define NT_STATUS_TOO_MANY_SECRETS 0xC0000156 +#define NT_STATUS_SECRET_TOO_LONG 0xC0000157 +#define NT_STATUS_INTERNAL_DB_ERROR 0xC0000158 +#define NT_STATUS_FULLSCREEN_MODE 0xC0000159 +#define NT_STATUS_TOO_MANY_CONTEXT_IDS 0xC000015a +#define NT_STATUS_LOGON_TYPE_NOT_GRANTED 0xC000015b +#define NT_STATUS_NOT_REGISTRY_FILE 0xC000015c +#define NT_STATUS_NT_CROSS_ENCRYPTION_REQUIRED 0xC000015d +#define NT_STATUS_DOMAIN_CTRLR_CONFIG_ERROR 0xC000015e +#define NT_STATUS_FT_MISSING_MEMBER 0xC000015f +#define NT_STATUS_ILL_FORMED_SERVICE_ENTRY 0xC0000160 +#define NT_STATUS_ILLEGAL_CHARACTER 0xC0000161 +#define NT_STATUS_UNMAPPABLE_CHARACTER 0xC0000162 +#define NT_STATUS_UNDEFINED_CHARACTER 0xC0000163 +#define NT_STATUS_FLOPPY_VOLUME 0xC0000164 +#define NT_STATUS_FLOPPY_ID_MARK_NOT_FOUND 0xC0000165 +#define NT_STATUS_FLOPPY_WRONG_CYLINDER 0xC0000166 +#define NT_STATUS_FLOPPY_UNKNOWN_ERROR 0xC0000167 +#define NT_STATUS_FLOPPY_BAD_REGISTERS 0xC0000168 +#define NT_STATUS_DISK_RECALIBRATE_FAILED 0xC0000169 +#define NT_STATUS_DISK_OPERATION_FAILED 0xC000016a +#define NT_STATUS_DISK_RESET_FAILED 0xC000016b +#define NT_STATUS_SHARED_IRQ_BUSY 0xC000016c +#define NT_STATUS_FT_ORPHANING 0xC000016d +#define NT_STATUS_PARTITION_FAILURE 0xC0000172 +#define NT_STATUS_INVALID_BLOCK_LENGTH 0xC0000173 +#define NT_STATUS_DEVICE_NOT_PARTITIONED 0xC0000174 +#define NT_STATUS_UNABLE_TO_LOCK_MEDIA 0xC0000175 +#define NT_STATUS_UNABLE_TO_UNLOAD_MEDIA 0xC0000176 +#define NT_STATUS_EOM_OVERFLOW 0xC0000177 +#define NT_STATUS_NO_MEDIA 0xC0000178 +#define NT_STATUS_NO_SUCH_MEMBER 0xC000017a +#define NT_STATUS_INVALID_MEMBER 0xC000017b +#define NT_STATUS_KEY_DELETED 0xC000017c +#define NT_STATUS_NO_LOG_SPACE 0xC000017d +#define NT_STATUS_TOO_MANY_SIDS 0xC000017e +#define NT_STATUS_LM_CROSS_ENCRYPTION_REQUIRED 0xC000017f +#define NT_STATUS_KEY_HAS_CHILDREN 0xC0000180 +#define NT_STATUS_CHILD_MUST_BE_VOLATILE 0xC0000181 +#define NT_STATUS_DEVICE_CONFIGURATION_ERROR 0xC0000182 +#define NT_STATUS_DRIVER_INTERNAL_ERROR 0xC0000183 +#define NT_STATUS_INVALID_DEVICE_STATE 0xC0000184 +#define NT_STATUS_IO_DEVICE_ERROR 0xC0000185 +#define NT_STATUS_DEVICE_PROTOCOL_ERROR 0xC0000186 +#define NT_STATUS_BACKUP_CONTROLLER 0xC0000187 +#define NT_STATUS_LOG_FILE_FULL 0xC0000188 +#define NT_STATUS_TOO_LATE 0xC0000189 +#define NT_STATUS_NO_TRUST_LSA_SECRET 0xC000018a +#define NT_STATUS_NO_TRUST_SAM_ACCOUNT 0xC000018b +#define NT_STATUS_TRUSTED_DOMAIN_FAILURE 0xC000018c +#define NT_STATUS_TRUSTED_RELATIONSHIP_FAILURE 0xC000018d +#define NT_STATUS_EVENTLOG_FILE_CORRUPT 0xC000018e +#define NT_STATUS_EVENTLOG_CANT_START 0xC000018f +#define NT_STATUS_TRUST_FAILURE 0xC0000190 +#define NT_STATUS_MUTANT_LIMIT_EXCEEDED 0xC0000191 +#define NT_STATUS_NETLOGON_NOT_STARTED 0xC0000192 +#define NT_STATUS_ACCOUNT_EXPIRED 0xC0000193 +#define NT_STATUS_POSSIBLE_DEADLOCK 0xC0000194 +#define NT_STATUS_NETWORK_CREDENTIAL_CONFLICT 0xC0000195 +#define NT_STATUS_REMOTE_SESSION_LIMIT 0xC0000196 +#define NT_STATUS_EVENTLOG_FILE_CHANGED 0xC0000197 +#define NT_STATUS_NOLOGON_INTERDOMAIN_TRUST_ACCOUNT 0xC0000198 +#define NT_STATUS_NOLOGON_WORKSTATION_TRUST_ACCOUNT 0xC0000199 +#define NT_STATUS_NOLOGON_SERVER_TRUST_ACCOUNT 0xC000019a +#define NT_STATUS_DOMAIN_TRUST_INCONSISTENT 0xC000019b +#define NT_STATUS_FS_DRIVER_REQUIRED 0xC000019c +#define NT_STATUS_NO_USER_SESSION_KEY 0xC0000202 +#define NT_STATUS_USER_SESSION_DELETED 0xC0000203 +#define NT_STATUS_RESOURCE_LANG_NOT_FOUND 0xC0000204 +#define NT_STATUS_INSUFF_SERVER_RESOURCES 0xC0000205 +#define NT_STATUS_INVALID_BUFFER_SIZE 0xC0000206 +#define NT_STATUS_INVALID_ADDRESS_COMPONENT 0xC0000207 +#define NT_STATUS_INVALID_ADDRESS_WILDCARD 0xC0000208 +#define NT_STATUS_TOO_MANY_ADDRESSES 0xC0000209 +#define NT_STATUS_ADDRESS_ALREADY_EXISTS 0xC000020a +#define NT_STATUS_ADDRESS_CLOSED 0xC000020b +#define NT_STATUS_CONNECTION_DISCONNECTED 0xC000020c +#define NT_STATUS_CONNECTION_RESET 0xC000020d +#define NT_STATUS_TOO_MANY_NODES 0xC000020e +#define NT_STATUS_TRANSACTION_ABORTED 0xC000020f +#define NT_STATUS_TRANSACTION_TIMED_OUT 0xC0000210 +#define NT_STATUS_TRANSACTION_NO_RELEASE 0xC0000211 +#define NT_STATUS_TRANSACTION_NO_MATCH 0xC0000212 +#define NT_STATUS_TRANSACTION_RESPONDED 0xC0000213 +#define NT_STATUS_TRANSACTION_INVALID_ID 0xC0000214 +#define NT_STATUS_TRANSACTION_INVALID_TYPE 0xC0000215 +#define NT_STATUS_NOT_SERVER_SESSION 0xC0000216 +#define NT_STATUS_NOT_CLIENT_SESSION 0xC0000217 +#define NT_STATUS_CANNOT_LOAD_REGISTRY_FILE 0xC0000218 +#define NT_STATUS_DEBUG_ATTACH_FAILED 0xC0000219 +#define NT_STATUS_SYSTEM_PROCESS_TERMINATED 0xC000021a +#define NT_STATUS_DATA_NOT_ACCEPTED 0xC000021b +#define NT_STATUS_NO_BROWSER_SERVERS_FOUND 0xC000021c +#define NT_STATUS_VDM_HARD_ERROR 0xC000021d +#define NT_STATUS_DRIVER_CANCEL_TIMEOUT 0xC000021e +#define NT_STATUS_REPLY_MESSAGE_MISMATCH 0xC000021f +#define NT_STATUS_MAPPED_ALIGNMENT 0xC0000220 +#define NT_STATUS_IMAGE_CHECKSUM_MISMATCH 0xC0000221 +#define NT_STATUS_LOST_WRITEBEHIND_DATA 0xC0000222 +#define NT_STATUS_CLIENT_SERVER_PARAMETERS_INVALID 0xC0000223 +#define NT_STATUS_PASSWORD_MUST_CHANGE 0xC0000224 +#define NT_STATUS_NOT_FOUND 0xC0000225 +#define NT_STATUS_NOT_TINY_STREAM 0xC0000226 +#define NT_STATUS_RECOVERY_FAILURE 0xC0000227 +#define NT_STATUS_STACK_OVERFLOW_READ 0xC0000228 +#define NT_STATUS_FAIL_CHECK 0xC0000229 +#define NT_STATUS_DUPLICATE_OBJECTID 0xC000022a +#define NT_STATUS_OBJECTID_EXISTS 0xC000022b +#define NT_STATUS_CONVERT_TO_LARGE 0xC000022c +#define NT_STATUS_RETRY 0xC000022d +#define NT_STATUS_FOUND_OUT_OF_SCOPE 0xC000022e +#define NT_STATUS_ALLOCATE_BUCKET 0xC000022f +#define NT_STATUS_PROPSET_NOT_FOUND 0xC0000230 +#define NT_STATUS_MARSHALL_OVERFLOW 0xC0000231 +#define NT_STATUS_INVALID_VARIANT 0xC0000232 +#define NT_STATUS_DOMAIN_CONTROLLER_NOT_FOUND 0xC0000233 +#define NT_STATUS_ACCOUNT_LOCKED_OUT 0xC0000234 +#define NT_STATUS_HANDLE_NOT_CLOSABLE 0xC0000235 +#define NT_STATUS_CONNECTION_REFUSED 0xC0000236 +#define NT_STATUS_GRACEFUL_DISCONNECT 0xC0000237 +#define NT_STATUS_ADDRESS_ALREADY_ASSOCIATED 0xC0000238 +#define NT_STATUS_ADDRESS_NOT_ASSOCIATED 0xC0000239 +#define NT_STATUS_CONNECTION_INVALID 0xC000023a +#define NT_STATUS_CONNECTION_ACTIVE 0xC000023b +#define NT_STATUS_NETWORK_UNREACHABLE 0xC000023c +#define NT_STATUS_HOST_UNREACHABLE 0xC000023d +#define NT_STATUS_PROTOCOL_UNREACHABLE 0xC000023e +#define NT_STATUS_PORT_UNREACHABLE 0xC000023f +#define NT_STATUS_REQUEST_ABORTED 0xC0000240 +#define NT_STATUS_CONNECTION_ABORTED 0xC0000241 +#define NT_STATUS_BAD_COMPRESSION_BUFFER 0xC0000242 +#define NT_STATUS_USER_MAPPED_FILE 0xC0000243 +#define NT_STATUS_AUDIT_FAILED 0xC0000244 +#define NT_STATUS_TIMER_RESOLUTION_NOT_SET 0xC0000245 +#define NT_STATUS_CONNECTION_COUNT_LIMIT 0xC0000246 +#define NT_STATUS_LOGIN_TIME_RESTRICTION 0xC0000247 +#define NT_STATUS_LOGIN_WKSTA_RESTRICTION 0xC0000248 +#define NT_STATUS_IMAGE_MP_UP_MISMATCH 0xC0000249 +#define NT_STATUS_INSUFFICIENT_LOGON_INFO 0xC0000250 +#define NT_STATUS_BAD_DLL_ENTRYPOINT 0xC0000251 +#define NT_STATUS_BAD_SERVICE_ENTRYPOINT 0xC0000252 +#define NT_STATUS_LPC_REPLY_LOST 0xC0000253 +#define NT_STATUS_IP_ADDRESS_CONFLICT1 0xC0000254 +#define NT_STATUS_IP_ADDRESS_CONFLICT2 0xC0000255 +#define NT_STATUS_REGISTRY_QUOTA_LIMIT 0xC0000256 +#define NT_STATUS_PATH_NOT_COVERED 0xC0000257 +#define NT_STATUS_NO_CALLBACK_ACTIVE 0xC0000258 +#define NT_STATUS_LICENSE_QUOTA_EXCEEDED 0xC0000259 +#define NT_STATUS_PWD_TOO_SHORT 0xC000025a +#define NT_STATUS_PWD_TOO_RECENT 0xC000025b +#define NT_STATUS_PWD_HISTORY_CONFLICT 0xC000025c +#define NT_STATUS_PLUGPLAY_NO_DEVICE 0xC000025e +#define NT_STATUS_UNSUPPORTED_COMPRESSION 0xC000025f +#define NT_STATUS_INVALID_HW_PROFILE 0xC0000260 +#define NT_STATUS_INVALID_PLUGPLAY_DEVICE_PATH 0xC0000261 +#define NT_STATUS_DRIVER_ORDINAL_NOT_FOUND 0xC0000262 +#define NT_STATUS_DRIVER_ENTRYPOINT_NOT_FOUND 0xC0000263 +#define NT_STATUS_RESOURCE_NOT_OWNED 0xC0000264 +#define NT_STATUS_TOO_MANY_LINKS 0xC0000265 +#define NT_STATUS_QUOTA_LIST_INCONSISTENT 0xC0000266 +#define NT_STATUS_FILE_IS_OFFLINE 0xC0000267 +#define NT_STATUS_NOT_A_REPARSE_POINT 0xC0000275 +#define NT_STATUS_NO_SUCH_JOB 0xC0000EDE + +#define WERR_OK 0 +#define WERR_BADFUNC 1 +#define WERR_BADFILE 2 +#define WERR_ACCESS_DENIED 5 +#define WERR_BADFID 6 +#define WERR_NOMEM 8 +#define WERR_GENERAL_FAILURE 31 +#define WERR_NOT_SUPPORTED 50 +#define WERR_BAD_NETPATH 53 +#define WERR_PRINTQ_FULL 61 +#define WERR_NO_SPOOL_SPACE 62 +#define WERR_NO_SUCH_SHARE 67 +#define WERR_ALREADY_EXISTS 80 +#define WERR_BAD_PASSWORD 86 +#define WERR_INVALID_PARAM 87 +#define WERR_INSUFFICIENT_BUFFER 122 +#define WERR_INVALID_NAME 123 +#define WERR_UNKNOWN_LEVEL 124 +#define WERR_OBJECT_PATH_INVALID 161 +#define WERR_NO_MORE_ITEMS 259 +#define WERR_MORE_DATA 234 +#define WERR_INVALID_OWNER 1307 +#define WERR_CAN_NOT_COMPLETE 1003 +#define WERR_INVALID_SECURITY_DESCRIPTOR 1338 +#define WERR_SERVER_UNAVAILABLE 1722 +#define WERR_INVALID_FORM_NAME 1902 +#define WERR_INVALID_FORM_SIZE 1903 +#define WERR_BUF_TOO_SMALL 2123 +#define WERR_JOB_NOT_FOUND 2151 +#define WERR_DEST_NOT_FOUND 2152 +#define WERR_NOT_LOCAL_DOMAIN 2320 +#define WERR_STATUS_MORE_ENTRIES 0x0105 -- cgit From 985abd104dc1011b8553986ddd1fe6f4c64705c7 Mon Sep 17 00:00:00 2001 From: Tim Potter Date: Sun, 3 Oct 2004 08:50:31 +0000 Subject: r2801: Wrapped functions that return a DOS error code can return DCERPC faults if they are badly formed. Handle this by checking the value of NTSTATUS as well as WERROR. (This used to be commit bb1be7819741f6c7dc1ee982cb2a255b6d776b79) --- source4/scripting/swig/dcerpc.i | 4 ++++ 1 file changed, 4 insertions(+) (limited to 'source4/scripting') diff --git a/source4/scripting/swig/dcerpc.i b/source4/scripting/swig/dcerpc.i index a560cca570..d8589693ac 100644 --- a/source4/scripting/swig/dcerpc.i +++ b/source4/scripting/swig/dcerpc.i @@ -366,6 +366,10 @@ NTSTATUS dcerpc_pipe_connect(struct dcerpc_pipe **OUT, %exception { $action + if (NT_STATUS_IS_ERR(result)) { + set_ntstatus_exception(NT_STATUS_V(result)); + return NULL; + } if (!W_ERROR_IS_OK(arg3->out.result)) { set_werror_exception(W_ERROR_V(arg3->out.result)); return NULL; -- cgit From 263212aba5d05367cc9ff92daf6b1047ea699ac3 Mon Sep 17 00:00:00 2001 From: Tim Potter Date: Sun, 3 Oct 2004 11:07:04 +0000 Subject: r2807: OK I think winreg_EnumValue() finally works. The previous version didn't work with non-NULL registry value names. Update testsuite to enumerate all keys and values two levels deep. (This used to be commit c09f0f355ba6a589121588492aa2db5deb7121e0) --- source4/scripting/swig/torture/winreg.py | 60 +++++++++++++------------------- 1 file changed, 25 insertions(+), 35 deletions(-) (limited to 'source4/scripting') diff --git a/source4/scripting/swig/torture/winreg.py b/source4/scripting/swig/torture/winreg.py index acf319d6f9..b7a42042a8 100755 --- a/source4/scripting/swig/torture/winreg.py +++ b/source4/scripting/swig/torture/winreg.py @@ -30,12 +30,16 @@ def test_CloseKey(pipe, handle): dcerpc.winreg_CloseKey(pipe, r) -def test_Enum(pipe, handle, depth = 0): +def test_Enum(pipe, handle, name, depth = 0): if depth > 2: return - keyinfo = test_QueryInfoKey(pipe, handle) + try: + keyinfo = test_QueryInfoKey(pipe, handle) + except dcerpc.WERROR, arg: + if arg[0] == dcerpc.WERR_ACCESS_DENIED: + return # Enumerate keys @@ -68,7 +72,8 @@ def test_Enum(pipe, handle, depth = 0): result = dcerpc.winreg_OpenKey(pipe, s) - test_Enum(pipe, result['handle'], depth + 1) + test_Enum(pipe, result['handle'], name + '/' + s['keyname']['name'], + depth + 1) test_CloseKey(pipe, result['handle']) @@ -77,44 +82,30 @@ def test_Enum(pipe, handle, depth = 0): r = {} r['handle'] = handle - keyinfo['max_valnamelen'] = 18 - keyinfo['max_valbufsize'] = 0x31f5 - - r['foo'] = {} - r['foo']['len'] = 0 - r['foo']['max_len'] = keyinfo['max_valnamelen'] * 2 - r['foo']['buffer'] = {} - r['foo']['buffer']['max_len'] = keyinfo['max_valnamelen'] - r['foo']['buffer']['offset'] = 0 - r['foo']['buffer']['len'] = 0 - r['foo']['buffer']['buffer'] = '' + r['name_in'] = {} + r['name_in']['len'] = 0 + r['name_in']['max_len'] = (keyinfo['max_valnamelen'] + 1) * 2 + r['name_in']['buffer'] = {} + r['name_in']['buffer']['max_len'] = keyinfo['max_valnamelen'] + 1 + r['name_in']['buffer']['offset'] = 0 + r['name_in']['buffer']['len'] = 0 r['type'] = 0 - r['value'] = {} - r['value']['max_len'] = keyinfo['max_valbufsize'] - r['value']['offset'] = 0 - r['value']['len'] = 0 - r['value']['buffer'] = [] - r['returned_len'] = 0 - r['foo2'] = {} - r['foo2']['max_len'] = keyinfo['max_valbufsize'] - r['foo2']['offset'] = 0 - r['foo2']['len'] = 0 - r['foo2']['buffer'] = '' - r['value1'] = keyinfo['max_valbufsize'] - r['value2'] = 0 + r['value_in'] = {} + r['value_in']['max_len'] = keyinfo['max_valbufsize'] + r['value_in']['offset'] = 0 + r['value_in']['len'] = 0 + r['value_len1'] = keyinfo['max_valbufsize'] + r['value_len2'] = 0 for i in range(0, keyinfo['num_values']): r['enum_index'] = i - print keyinfo - print dcerpc.winreg_EnumValue(pipe, r) + dcerpc.winreg_EnumValue(pipe, r) - sys.exit(1) +def test_Key(pipe, handle, name): -def test_Key(pipe, handle): - - test_Enum(pipe, handle) + test_Enum(pipe, handle, name) def runtests(binding, domain, username, password): @@ -126,5 +117,4 @@ def runtests(binding, domain, username, password): handle = test_OpenHKLM(pipe) - test_Key(pipe, handle) - + test_Key(pipe, handle, 'HKLM') -- cgit From 94ae449f33e45aa6cfa4946fac7c8c5409590ad7 Mon Sep 17 00:00:00 2001 From: Tim Potter Date: Mon, 4 Oct 2004 06:29:06 +0000 Subject: r2817: Get winreg_GetKeySecurity() working but use data blob instead of security descriptor. (This used to be commit bc5165e40a716fb7c612b32c0b6f03cb2d331d11) --- source4/scripting/swig/torture/winreg.py | 109 ++++++++++++++++++++++--------- 1 file changed, 77 insertions(+), 32 deletions(-) (limited to 'source4/scripting') diff --git a/source4/scripting/swig/torture/winreg.py b/source4/scripting/swig/torture/winreg.py index b7a42042a8..eb60b9847e 100755 --- a/source4/scripting/swig/torture/winreg.py +++ b/source4/scripting/swig/torture/winreg.py @@ -30,7 +30,49 @@ def test_CloseKey(pipe, handle): dcerpc.winreg_CloseKey(pipe, r) -def test_Enum(pipe, handle, name, depth = 0): +def test_FlushKey(pipe, handle): + + r = {} + r['handle'] = handle + + dcerpc.winreg_FlushKey(pipe, r) + +def test_GetVersion(pipe, handle): + + r = {} + r['handle'] = handle + + dcerpc.winreg_GetVersion(pipe, r) + +def test_GetKeySecurity(pipe, handle): + + r = {} + r['handle'] = handle + r['unknown'] = 4 + r['size'] = None + r['data'] = {} + r['data']['max_len'] = 0 + r['data']['data'] = '' + + result = dcerpc.winreg_GetKeySecurity(pipe, r) + + print result + + if result['result'] == dcerpc.WERR_INSUFFICIENT_BUFFER: + r['size'] = {} + r['size']['max_len'] = result['data']['max_len'] + r['size']['offset'] = 0 + r['size']['len'] = result['data']['max_len'] + + result = dcerpc.winreg_GetKeySecurity(pipe, r) + + print result + + sys.exit(1) + +def test_Key(pipe, handle, name, depth = 0): + + # Don't descend too far. Registries can be very deep. if depth > 2: return @@ -41,7 +83,38 @@ def test_Enum(pipe, handle, name, depth = 0): if arg[0] == dcerpc.WERR_ACCESS_DENIED: return - # Enumerate keys + test_GetVersion(pipe, handle) + + test_FlushKey(pipe, handle) + + test_GetKeySecurity(pipe, handle) + + # Enumerate values in this key + + r = {} + r['handle'] = handle + r['name_in'] = {} + r['name_in']['len'] = 0 + r['name_in']['max_len'] = (keyinfo['max_valnamelen'] + 1) * 2 + r['name_in']['buffer'] = {} + r['name_in']['buffer']['max_len'] = keyinfo['max_valnamelen'] + 1 + r['name_in']['buffer']['offset'] = 0 + r['name_in']['buffer']['len'] = 0 + r['type'] = 0 + r['value_in'] = {} + r['value_in']['max_len'] = keyinfo['max_valbufsize'] + r['value_in']['offset'] = 0 + r['value_in']['len'] = 0 + r['value_len1'] = keyinfo['max_valbufsize'] + r['value_len2'] = 0 + + for i in range(0, keyinfo['num_values']): + + r['enum_index'] = i + + dcerpc.winreg_EnumValue(pipe, r) + + # Recursively test subkeys of this key r = {} r['handle'] = handle @@ -72,41 +145,13 @@ def test_Enum(pipe, handle, name, depth = 0): result = dcerpc.winreg_OpenKey(pipe, s) - test_Enum(pipe, result['handle'], name + '/' + s['keyname']['name'], - depth + 1) + test_Key(pipe, result['handle'], name + '/' + s['keyname']['name'], + depth + 1) test_CloseKey(pipe, result['handle']) # Enumerate values - r = {} - r['handle'] = handle - - r['name_in'] = {} - r['name_in']['len'] = 0 - r['name_in']['max_len'] = (keyinfo['max_valnamelen'] + 1) * 2 - r['name_in']['buffer'] = {} - r['name_in']['buffer']['max_len'] = keyinfo['max_valnamelen'] + 1 - r['name_in']['buffer']['offset'] = 0 - r['name_in']['buffer']['len'] = 0 - r['type'] = 0 - r['value_in'] = {} - r['value_in']['max_len'] = keyinfo['max_valbufsize'] - r['value_in']['offset'] = 0 - r['value_in']['len'] = 0 - r['value_len1'] = keyinfo['max_valbufsize'] - r['value_len2'] = 0 - - for i in range(0, keyinfo['num_values']): - - r['enum_index'] = i - - dcerpc.winreg_EnumValue(pipe, r) - -def test_Key(pipe, handle, name): - - test_Enum(pipe, handle, name) - def runtests(binding, domain, username, password): print 'Testing WINREG pipe' -- cgit From 913d5df89e759d858bc7704b8aa50d63ce67a0c1 Mon Sep 17 00:00:00 2001 From: Tim Potter Date: Thu, 14 Oct 2004 06:45:25 +0000 Subject: r2964: Add spoolss to list of wrapped client functions. (This used to be commit 96d31ff19d2fa5b0c5a0ee23000a97cb77637968) --- source4/scripting/swig/dcerpc.i | 1 + 1 file changed, 1 insertion(+) (limited to 'source4/scripting') diff --git a/source4/scripting/swig/dcerpc.i b/source4/scripting/swig/dcerpc.i index d8589693ac..606f236f35 100644 --- a/source4/scripting/swig/dcerpc.i +++ b/source4/scripting/swig/dcerpc.i @@ -377,3 +377,4 @@ NTSTATUS dcerpc_pipe_connect(struct dcerpc_pipe **OUT, } %include "librpc/gen_ndr/winreg.i" +%include "librpc/gen_ndr/spoolss.i" -- cgit From e3627c2c6eaf8b0ede0b014aacb3478d25faf1b8 Mon Sep 17 00:00:00 2001 From: Tim Potter Date: Thu, 14 Oct 2004 07:25:47 +0000 Subject: r2965: Ignore *.pyc files in torture directory. Allow test module name to be specified on command line for pytorture module. Start spoolss torture test. (This used to be commit 44bab84f765f6a4d37733a353fc6b74b09c1b39a) --- source4/scripting/swig/torture/pytorture | 20 +++++++++++++++++--- source4/scripting/swig/torture/spoolss.py | 24 ++++++++++++++++++++++++ 2 files changed, 41 insertions(+), 3 deletions(-) create mode 100644 source4/scripting/swig/torture/spoolss.py (limited to 'source4/scripting') diff --git a/source4/scripting/swig/torture/pytorture b/source4/scripting/swig/torture/pytorture index 89ecfbabcf..8a8f4d8bdf 100755 --- a/source4/scripting/swig/torture/pytorture +++ b/source4/scripting/swig/torture/pytorture @@ -1,5 +1,6 @@ #!/usr/bin/python +import sys from optparse import OptionParser # Parse command line @@ -31,7 +32,20 @@ domain = options.domain username = options.username password = options.password -# Run tests +if len(args) == 0: + parser.error('You must supply the name of a module to test') -import samr -samr.runtests(binding, domain, username, password) +# Import and test + +for test in args: + + try: + module = __import__(test) + except ImportError: + print 'No such module "%s"' % test + sys.exit(1) + + if not hasattr(module, 'runtests'): + print 'Module "%s" does not have a runtests function' % test + + module.runtests(binding, domain, username, password) diff --git a/source4/scripting/swig/torture/spoolss.py b/source4/scripting/swig/torture/spoolss.py new file mode 100644 index 0000000000..78d573a7cd --- /dev/null +++ b/source4/scripting/swig/torture/spoolss.py @@ -0,0 +1,24 @@ +import dcerpc + +def test_EnumPrinters(pipe): + + r = {} + r['flags'] = 0x02 + r['server'] = None + r['level'] = 1 + r['buffer'] = 392 * '\x00' + r['buf_size'] = 392 + + result = dcerpc.spoolss_EnumPrinters(pipe, r) + + print result + +def runtests(binding, domain, username, password): + + print 'Testing SPOOLSS pipe' + + pipe = dcerpc.pipe_connect(binding, + dcerpc.DCERPC_SPOOLSS_UUID, dcerpc.DCERPC_SPOOLSS_VERSION, + domain, username, password) + + test_EnumPrinters(pipe) -- cgit From 1c4b87c78847542a14d88966f854aa1b38162b88 Mon Sep 17 00:00:00 2001 From: Tim Potter Date: Thu, 14 Oct 2004 07:33:09 +0000 Subject: r2966: Handle conversion of DATA_BLOB fields from Python in a slightly nicer manner. I'm hoping to get rid of DATA_BLOB's but for the moment they make it easy to get some spoolss action happening quickly. (This used to be commit 15f8f73f8bfec099973fb8bf167020ae50346cf6) --- source4/scripting/swig/dcerpc.i | 20 ++++++++++---------- 1 file changed, 10 insertions(+), 10 deletions(-) (limited to 'source4/scripting') diff --git a/source4/scripting/swig/dcerpc.i b/source4/scripting/swig/dcerpc.i index 606f236f35..918445d7e3 100644 --- a/source4/scripting/swig/dcerpc.i +++ b/source4/scripting/swig/dcerpc.i @@ -254,28 +254,28 @@ PyObject *string_ptr_to_python(TALLOC_CTX *mem_ctx, char *obj) #define dom_sid2_ptr_to_python dom_sid_ptr_to_python #define dom_sid2_ptr_from_python dom_sid_ptr_from_python -DATA_BLOB DATA_BLOB_from_python(PyObject *obj, char *name) +void DATA_BLOB_ptr_from_python(TALLOC_CTX *mem_ctx, DATA_BLOB **s, + PyObject *obj, char *name) { - DATA_BLOB ret; - - /* Because we treat DATA_BLOB as a scalar type (why?) there - doesn't seem to be a way to pass back when an error has - occured. */ - if (obj == NULL) { PyErr_Format(PyExc_ValueError, "Expecting key %s", name); return; } + if (obj == Py_None) { + *s = NULL; + return; + } + if (!PyString_Check(obj)) { PyErr_Format(PyExc_TypeError, "Expecting string value for key '%s'", name); return; } - ret.length = PyString_Size(obj); - ret.data = PyString_AsString(obj); + *s = talloc(mem_ctx, sizeof(DATA_BLOB)); - return ret; + (*s)->length = PyString_Size(obj); + (*s)->data = PyString_AsString(obj); } PyObject *DATA_BLOB_to_python(DATA_BLOB obj) -- cgit From acf657a7c228a920efe942b8776bf1bb1446f59c Mon Sep 17 00:00:00 2001 From: Tim Potter Date: Thu, 14 Oct 2004 13:09:59 +0000 Subject: r2975: Try to emulate NT_STATUS_IS_ERR() functionality for WERRORs. Unfortunately this means enumerating all the ones we don't think are errors. (This used to be commit a079e044f0ef23c6c4307c9da35019ec3e8f1d2a) --- source4/scripting/swig/dcerpc.i | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) (limited to 'source4/scripting') diff --git a/source4/scripting/swig/dcerpc.i b/source4/scripting/swig/dcerpc.i index 918445d7e3..f91f664820 100644 --- a/source4/scripting/swig/dcerpc.i +++ b/source4/scripting/swig/dcerpc.i @@ -286,7 +286,6 @@ PyObject *DATA_BLOB_to_python(DATA_BLOB obj) %} %include "samba.i" -%include "status_codes.i" %pythoncode %{ NTSTATUS = _dcerpc.NTSTATUS @@ -370,7 +369,8 @@ NTSTATUS dcerpc_pipe_connect(struct dcerpc_pipe **OUT, set_ntstatus_exception(NT_STATUS_V(result)); return NULL; } - if (!W_ERROR_IS_OK(arg3->out.result)) { + if (!W_ERROR_IS_OK(arg3->out.result) && + !(W_ERROR_EQUAL(arg3->out.result, WERR_INSUFFICIENT_BUFFER))) { set_werror_exception(W_ERROR_V(arg3->out.result)); return NULL; } @@ -378,3 +378,5 @@ NTSTATUS dcerpc_pipe_connect(struct dcerpc_pipe **OUT, %include "librpc/gen_ndr/winreg.i" %include "librpc/gen_ndr/spoolss.i" + +%include "status_codes.i" -- cgit From dc2df2530fc729e5fa858fdab3c4355e27ece310 Mon Sep 17 00:00:00 2001 From: Tim Potter Date: Fri, 15 Oct 2004 07:17:51 +0000 Subject: r2986: Add correct value to dict when generating wrapper for functions that return WERROR values. Clean up WERROR vs NTSTATUS handling a bit. (This used to be commit e6756e3ee0af3e7e98f6deaf9dc83af9aac1b586) --- source4/scripting/swig/dcerpc.i | 8 ++++++++ source4/scripting/swig/samba.i | 4 ---- 2 files changed, 8 insertions(+), 4 deletions(-) (limited to 'source4/scripting') diff --git a/source4/scripting/swig/dcerpc.i b/source4/scripting/swig/dcerpc.i index f91f664820..5248164881 100644 --- a/source4/scripting/swig/dcerpc.i +++ b/source4/scripting/swig/dcerpc.i @@ -352,6 +352,7 @@ NTSTATUS dcerpc_pipe_connect(struct dcerpc_pipe **OUT, %exception { $action + if (NT_STATUS_IS_ERR(result)) { set_ntstatus_exception(NT_STATUS_V(result)); return NULL; @@ -365,10 +366,14 @@ NTSTATUS dcerpc_pipe_connect(struct dcerpc_pipe **OUT, %exception { $action + if (NT_STATUS_IS_ERR(result)) { set_ntstatus_exception(NT_STATUS_V(result)); return NULL; } + + /* Emulate NT_STATUS_IS_ERR() */ + if (!W_ERROR_IS_OK(arg3->out.result) && !(W_ERROR_EQUAL(arg3->out.result, WERR_INSUFFICIENT_BUFFER))) { set_werror_exception(W_ERROR_V(arg3->out.result)); @@ -379,4 +384,7 @@ NTSTATUS dcerpc_pipe_connect(struct dcerpc_pipe **OUT, %include "librpc/gen_ndr/winreg.i" %include "librpc/gen_ndr/spoolss.i" +/* The status codes must be included last otherwise the automatically + generated .i files get confused. This is kind of yucky. */ + %include "status_codes.i" diff --git a/source4/scripting/swig/samba.i b/source4/scripting/swig/samba.i index faa46dc348..6a34f9b148 100644 --- a/source4/scripting/swig/samba.i +++ b/source4/scripting/swig/samba.i @@ -32,10 +32,6 @@ $1 = (uint32_t)PyInt_AsLong($input); } -/* For the moment treat NTSTATUS as an integer */ - -#define WERROR NTSTATUS - %typemap(out) NTSTATUS { $result = PyInt_FromLong(NT_STATUS_V($1)); } -- cgit From 8f00427136cd52e0e1cd1b12267515d872798c56 Mon Sep 17 00:00:00 2001 From: Tim Potter Date: Fri, 15 Oct 2004 12:21:49 +0000 Subject: r2994: More cleanups. Move the generation of NTSTATUS and WERROR exceptions from inside a swig %exception block and into the argout typemap. This will allow us to wrap functions that don't require exception handling, and also get rid of some ugly code in dcerpc.i (This used to be commit 558076cc8ddbdb563869f7d35150310217f30c31) --- source4/scripting/swig/dcerpc.i | 32 -------------------------------- 1 file changed, 32 deletions(-) (limited to 'source4/scripting') diff --git a/source4/scripting/swig/dcerpc.i b/source4/scripting/swig/dcerpc.i index 5248164881..ab53a1dc51 100644 --- a/source4/scripting/swig/dcerpc.i +++ b/source4/scripting/swig/dcerpc.i @@ -347,40 +347,8 @@ NTSTATUS dcerpc_pipe_connect(struct dcerpc_pipe **OUT, const char *password); %include "librpc/gen_ndr/misc.i" - -/* Wrapped functions returning NTSTATUS */ - -%exception { - $action - - if (NT_STATUS_IS_ERR(result)) { - set_ntstatus_exception(NT_STATUS_V(result)); - return NULL; - } -} - %include "librpc/gen_ndr/lsa.i" %include "librpc/gen_ndr/samr.i" - -/* Wrapped functions returning WERROR */ - -%exception { - $action - - if (NT_STATUS_IS_ERR(result)) { - set_ntstatus_exception(NT_STATUS_V(result)); - return NULL; - } - - /* Emulate NT_STATUS_IS_ERR() */ - - if (!W_ERROR_IS_OK(arg3->out.result) && - !(W_ERROR_EQUAL(arg3->out.result, WERR_INSUFFICIENT_BUFFER))) { - set_werror_exception(W_ERROR_V(arg3->out.result)); - return NULL; - } -} - %include "librpc/gen_ndr/winreg.i" %include "librpc/gen_ndr/spoolss.i" -- cgit From addb2a9fd45ad4df21f22d1b712e37ff0a5affd4 Mon Sep 17 00:00:00 2001 From: Tim Potter Date: Sat, 16 Oct 2004 00:19:33 +0000 Subject: r3001: Expose unmarshalling functions for structures marked "public" in the idl. This allows us to pass a buffer of bytes returned from a spoolss call and convert it to a Python dictionary. Works for enumprinters level 1! (This used to be commit 4bc497a2994b12845a46b2d19f60bb81c9869fc9) --- source4/scripting/swig/dcerpc.i | 6 ++++++ source4/scripting/swig/torture/spoolss.py | 2 +- 2 files changed, 7 insertions(+), 1 deletion(-) (limited to 'source4/scripting') diff --git a/source4/scripting/swig/dcerpc.i b/source4/scripting/swig/dcerpc.i index ab53a1dc51..1222d54766 100644 --- a/source4/scripting/swig/dcerpc.i +++ b/source4/scripting/swig/dcerpc.i @@ -346,6 +346,12 @@ NTSTATUS dcerpc_pipe_connect(struct dcerpc_pipe **OUT, const char *username, const char *password); +%typemap(in) 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; +} + %include "librpc/gen_ndr/misc.i" %include "librpc/gen_ndr/lsa.i" %include "librpc/gen_ndr/samr.i" diff --git a/source4/scripting/swig/torture/spoolss.py b/source4/scripting/swig/torture/spoolss.py index 78d573a7cd..e29178a0b6 100644 --- a/source4/scripting/swig/torture/spoolss.py +++ b/source4/scripting/swig/torture/spoolss.py @@ -11,7 +11,7 @@ def test_EnumPrinters(pipe): result = dcerpc.spoolss_EnumPrinters(pipe, r) - print result + print dcerpc.unmarshall_spoolss_PrinterInfo1(result['buffer']) def runtests(binding, domain, username, password): -- cgit From 71aaba4ea7e0e95c7a976e2a163e0ff25689dcd4 Mon Sep 17 00:00:00 2001 From: Tim Potter Date: Sun, 17 Oct 2004 00:20:57 +0000 Subject: r3007: uint32 values need to be stored in Python longs, as on 32-bit machines Python ints can only hold int32 values. (This used to be commit 7c5ada63bf5d876a1b67df2cf7bd44942e4b0a98) --- source4/scripting/swig/samba.i | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) (limited to 'source4/scripting') diff --git a/source4/scripting/swig/samba.i b/source4/scripting/swig/samba.i index 6a34f9b148..065cc7269f 100644 --- a/source4/scripting/swig/samba.i +++ b/source4/scripting/swig/samba.i @@ -29,7 +29,11 @@ PyErr_SetString(PyExc_TypeError, "integer expected"); return NULL; } - $1 = (uint32_t)PyInt_AsLong($input); + $1 = (uint32_t)PyLong_AsLong($input); +} + +%typemap(out) uint32 { + $1 = PyLong_FromLong($input); } %typemap(out) NTSTATUS { -- cgit From c7a762bc748c63049d237de176167a13d1b8b0de Mon Sep 17 00:00:00 2001 From: Tim Potter Date: Sun, 17 Oct 2004 00:27:40 +0000 Subject: r3009: Fix up unmarshall functions to return Python dict instead of a NTSTATUS. We can now unmarshall a single printer returned from an EnumPrinters. (This used to be commit 89da7a9196d40699881f12c9a5fe62301aafd4cf) --- source4/scripting/swig/torture/spoolss.py | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) (limited to 'source4/scripting') diff --git a/source4/scripting/swig/torture/spoolss.py b/source4/scripting/swig/torture/spoolss.py index e29178a0b6..d7a16917f9 100644 --- a/source4/scripting/swig/torture/spoolss.py +++ b/source4/scripting/swig/torture/spoolss.py @@ -6,11 +6,17 @@ def test_EnumPrinters(pipe): r['flags'] = 0x02 r['server'] = None r['level'] = 1 - r['buffer'] = 392 * '\x00' - r['buf_size'] = 392 + r['buffer'] = None + r['buf_size'] = 0 result = dcerpc.spoolss_EnumPrinters(pipe, r) + if result['result'] == dcerpc.WERR_INSUFFICIENT_BUFFER: + r['buffer'] = result['buf_size'] * '\x00' + r['buf_size'] = result['buf_size'] + + result = dcerpc.spoolss_EnumPrinters(pipe, r) + print dcerpc.unmarshall_spoolss_PrinterInfo1(result['buffer']) def runtests(binding, domain, username, password): -- cgit From 85a2db200a11ebc4f325f9da8bfda29c3fa403c6 Mon Sep 17 00:00:00 2001 From: Tim Potter Date: Sun, 17 Oct 2004 00:37:36 +0000 Subject: r3010: Do some more PyInt vs PyLong checks. (This used to be commit b19dc6cd9c1ac44d970b092f09cf96c737a90fdd) --- source4/scripting/swig/samba.i | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) (limited to 'source4/scripting') diff --git a/source4/scripting/swig/samba.i b/source4/scripting/swig/samba.i index 065cc7269f..38a5251a08 100644 --- a/source4/scripting/swig/samba.i +++ b/source4/scripting/swig/samba.i @@ -25,7 +25,7 @@ */ %typemap(in) uint32 { - if (!PyInt_Check($input)) { + if (!PyInt_Check($input) && !PyLong_Check($input)) { PyErr_SetString(PyExc_TypeError, "integer expected"); return NULL; } @@ -37,6 +37,5 @@ } %typemap(out) NTSTATUS { - $result = PyInt_FromLong(NT_STATUS_V($1)); + $result = PyLong_FromLong(NT_STATUS_V($1)); } - -- cgit From 266e36aa54dc82a48655d6c64cb8cd3fbfdf4fa9 Mon Sep 17 00:00:00 2001 From: Tim Potter Date: Mon, 25 Oct 2004 07:31:59 +0000 Subject: r3204: Got unpacking of an array of PrinterInfo union elements working. Phew. (This used to be commit f490cd719cc02589e73e26fa983aff90708d1926) --- source4/scripting/swig/torture/spoolss.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'source4/scripting') diff --git a/source4/scripting/swig/torture/spoolss.py b/source4/scripting/swig/torture/spoolss.py index d7a16917f9..8336a027df 100644 --- a/source4/scripting/swig/torture/spoolss.py +++ b/source4/scripting/swig/torture/spoolss.py @@ -17,7 +17,7 @@ def test_EnumPrinters(pipe): result = dcerpc.spoolss_EnumPrinters(pipe, r) - print dcerpc.unmarshall_spoolss_PrinterInfo1(result['buffer']) + print dcerpc.unmarshall_spoolss_PrinterInfo_array(result['buffer'], r['level'], result['count']) def runtests(binding, domain, username, password): -- cgit From 974d048493c77c0bc2d7a99c1e16d0ee9643c5ab Mon Sep 17 00:00:00 2001 From: Tim Potter Date: Mon, 25 Oct 2004 12:54:52 +0000 Subject: r3216: Add tests for OpenPrinterEx and ClosePrinter. (This used to be commit b7ff5f0deded4bcf6695dac0683fd9d271d9c255) --- source4/scripting/swig/torture/spoolss.py | 71 +++++++++++++++++++++++++++---- 1 file changed, 63 insertions(+), 8 deletions(-) (limited to 'source4/scripting') diff --git a/source4/scripting/swig/torture/spoolss.py b/source4/scripting/swig/torture/spoolss.py index 8336a027df..a18b9c61a7 100644 --- a/source4/scripting/swig/torture/spoolss.py +++ b/source4/scripting/swig/torture/spoolss.py @@ -1,23 +1,78 @@ +import string import dcerpc +def test_OpenPrinterEx(pipe, printer): + + print 'testing spoolss_OpenPrinterEx(%s)' % printer + + r = {} + r['printername'] = '\\\\win2k3dc\\%s' % printer + r['datatype'] = None + r['devmode_ctr'] = {} + r['devmode_ctr']['size'] = 0 + r['devmode_ctr']['devmode'] = None + r['access_mask'] = 0x02000000 + r['level'] = 1 + r['userlevel'] = {} + r['userlevel']['level1'] = {} + r['userlevel']['level1']['size'] = 0 + r['userlevel']['level1']['client'] = None + r['userlevel']['level1']['user'] = None + r['userlevel']['level1']['build'] = 1381 + r['userlevel']['level1']['major'] = 2 + r['userlevel']['level1']['minor'] = 0 + r['userlevel']['level1']['processor'] = 0 + + result = dcerpc.spoolss_OpenPrinterEx(pipe, r) + + return result['handle'] + + +def test_ClosePrinter(pipe, handle): + + r = {} + r['handle'] = handle + + dcerpc.spoolss_ClosePrinter(pipe, r) + + def test_EnumPrinters(pipe): + print 'testing spoolss_EnumPrinters' + + printer_names = None + r = {} r['flags'] = 0x02 r['server'] = None - r['level'] = 1 - r['buffer'] = None - r['buf_size'] = 0 - result = dcerpc.spoolss_EnumPrinters(pipe, r) + for level in [1, 2, 4, 5]: - if result['result'] == dcerpc.WERR_INSUFFICIENT_BUFFER: - r['buffer'] = result['buf_size'] * '\x00' - r['buf_size'] = result['buf_size'] + r['level'] = level + r['buf_size'] = 0 + r['buffer'] = None result = dcerpc.spoolss_EnumPrinters(pipe, r) - print dcerpc.unmarshall_spoolss_PrinterInfo_array(result['buffer'], r['level'], result['count']) + if result['result'] == dcerpc.WERR_INSUFFICIENT_BUFFER: + r['buffer'] = result['buf_size'] * '\x00' + r['buf_size'] = result['buf_size'] + + result = dcerpc.spoolss_EnumPrinters(pipe, r) + + printers = dcerpc.unmarshall_spoolss_PrinterInfo_array( + result['buffer'], r['level'], result['count']) + + if printer_names is None: + printer_names = map( + lambda x: string.split(x['info1']['name'], ',')[0], printers) + + for printer in printer_names: + + handle = test_OpenPrinterEx(pipe, printer) + + test_ClosePrinter(pipe, handle) + def runtests(binding, domain, username, password): -- cgit From 8ade4d978506f6b2fab2ccd194f8b62d5d97d168 Mon Sep 17 00:00:00 2001 From: Tim Potter Date: Mon, 25 Oct 2004 13:06:31 +0000 Subject: r3217: Start of a spoolss_GetPrinter test. (This used to be commit 994fe92febe38f06d69f43b01c80e8350e902986) --- source4/scripting/swig/torture/spoolss.py | 26 ++++++++++++++++++++++++++ 1 file changed, 26 insertions(+) (limited to 'source4/scripting') diff --git a/source4/scripting/swig/torture/spoolss.py b/source4/scripting/swig/torture/spoolss.py index a18b9c61a7..240d815fb4 100644 --- a/source4/scripting/swig/torture/spoolss.py +++ b/source4/scripting/swig/torture/spoolss.py @@ -36,6 +36,30 @@ def test_ClosePrinter(pipe, handle): dcerpc.spoolss_ClosePrinter(pipe, r) +def test_GetPrinter(pipe, handle): + + r = {} + r['handle'] = handle + + for level in [1, 2, 3]: + + r['level'] = level + r['buffer'] = None + r['buf_size'] = 0 + + result = dcerpc.spoolss_GetPrinter(pipe, r) + + print result + + if result['result'] == dcerpc.WERR_INSUFFICIENT_BUFFER: + r['buffer'] = result['buf_size'] * '\x00' + r['buf_size'] = result['buf_size'] + + result = dcerpc.spoolss_GetPrinter(pipe, r) + + print result + + def test_EnumPrinters(pipe): print 'testing spoolss_EnumPrinters' @@ -71,6 +95,8 @@ def test_EnumPrinters(pipe): handle = test_OpenPrinterEx(pipe, printer) + test_GetPrinter(pipe, handle) + test_ClosePrinter(pipe, handle) -- cgit From fe54d8bc99f4ccfcaba2116430213161ebb6bf39 Mon Sep 17 00:00:00 2001 From: Tim Potter Date: Thu, 28 Oct 2004 03:40:35 +0000 Subject: r3302: The security descriptors in spoolss_PrinterInfo2 and spoolss_PrinterInfo3 need to be marked as subcontext(0). GetPrinter tests now work for all info levels! (This used to be commit 53bd02960e17f7517e0d6c4f489d27b8bdcc7582) --- source4/scripting/swig/torture/spoolss.py | 59 +++++++++++++++++++++++++++---- 1 file changed, 53 insertions(+), 6 deletions(-) (limited to 'source4/scripting') diff --git a/source4/scripting/swig/torture/spoolss.py b/source4/scripting/swig/torture/spoolss.py index 240d815fb4..91e785ca75 100644 --- a/source4/scripting/swig/torture/spoolss.py +++ b/source4/scripting/swig/torture/spoolss.py @@ -6,7 +6,8 @@ def test_OpenPrinterEx(pipe, printer): print 'testing spoolss_OpenPrinterEx(%s)' % printer r = {} - r['printername'] = '\\\\win2k3dc\\%s' % printer + r['printername'] = '\\\\%s\\%s' % \ + (dcerpc.dcerpc_server_name(pipe), printer) r['datatype'] = None r['devmode_ctr'] = {} r['devmode_ctr']['size'] = 0 @@ -41,7 +42,9 @@ def test_GetPrinter(pipe, handle): r = {} r['handle'] = handle - for level in [1, 2, 3]: + for level in [0, 1, 2, 3, 4, 5, 6, 7]: + + print 'test_GetPrinter(level = %d)' % level r['level'] = level r['buffer'] = None @@ -49,8 +52,6 @@ def test_GetPrinter(pipe, handle): result = dcerpc.spoolss_GetPrinter(pipe, r) - print result - if result['result'] == dcerpc.WERR_INSUFFICIENT_BUFFER: r['buffer'] = result['buf_size'] * '\x00' r['buf_size'] = result['buf_size'] @@ -59,6 +60,47 @@ def test_GetPrinter(pipe, handle): print result +def test_EnumForms(pipe, handle): + + print 'testing spoolss_EnumForms' + + r = {} + r['handle'] = handle + r['level'] = 1 + r['buffer'] = None + r['buf_size'] = 0 + + result = dcerpc.spoolss_EnumForms(pipe, r) + + if result['result'] == dcerpc.WERR_INSUFFICIENT_BUFFER: + r['buffer'] = result['buf_size'] * '\x00' + r['buf_size'] = result['buf_size'] + + result = dcerpc.spoolss_EnumForms(pipe, r) + + print result + + +def test_EnumPorts(pipe, handle): + + print 'testing spoolss_EnumPorts' + + r = {} + r['handle'] = handle + r['level'] = 1 + r['buffer'] = None + r['buf_size'] = 0 + + result = dcerpc.spoolss_EnumPorts(pipe, r) + + if result['result'] == dcerpc.WERR_INSUFFICIENT_BUFFER: + r['buffer'] = result['buf_size'] * '\x00' + r['buf_size'] = result['buf_size'] + + result = dcerpc.spoolss_EnumPorts(pipe, r) + + print result + def test_EnumPrinters(pipe): @@ -70,7 +112,9 @@ def test_EnumPrinters(pipe): r['flags'] = 0x02 r['server'] = None - for level in [1, 2, 4, 5]: + for level in [0, 1, 4, 5]: + + print 'test_EnumPrinters(level = %d)' % level r['level'] = level r['buf_size'] = 0 @@ -87,7 +131,10 @@ def test_EnumPrinters(pipe): printers = dcerpc.unmarshall_spoolss_PrinterInfo_array( result['buffer'], r['level'], result['count']) - if printer_names is None: + from pprint import pprint + pprint(printers) + + if level == 1: printer_names = map( lambda x: string.split(x['info1']['name'], ',')[0], printers) -- cgit From 08dd85d26b8bdcd0ad95d855279294f3248c463f Mon Sep 17 00:00:00 2001 From: Tim Potter Date: Thu, 28 Oct 2004 06:13:42 +0000 Subject: r3308: Handle servers that don't have samr_Connect5. (This used to be commit 52af866ffb427427d21daf11a4ca9a8b9881f1d5) --- source4/scripting/swig/torture/samr.py | 15 +++++++++++---- 1 file changed, 11 insertions(+), 4 deletions(-) (limited to 'source4/scripting') diff --git a/source4/scripting/swig/torture/samr.py b/source4/scripting/swig/torture/samr.py index ba650dfe75..435b3a81db 100755 --- a/source4/scripting/swig/torture/samr.py +++ b/source4/scripting/swig/torture/samr.py @@ -15,8 +15,8 @@ def test_Connect(pipe): s = {} s['handle'] = result['connect_handle'] - dcerpc.samr_Close(pipe, s) - + handle = result['connect_handle'] + print 'testing samr_Connect2' r = {} @@ -69,9 +69,16 @@ def test_Connect(pipe): r['info']['info1']['unknown1'] = 0 r['info']['info1']['unknown2'] = 0 - result = dcerpc.samr_Connect5(pipe, r) + try: + result = dcerpc.samr_Connect5(pipe, r) + s = {} + s['handle'] = result['connect_handle'] + dcerpc.samr_Close(pipe, s) + except dcerpc.NTSTATUS, arg: + if arg[0] != dcerpc.NT_STATUS_NET_WRITE_FAULT: + raise - return result['connect_handle'] + return handle def test_QuerySecurity(pipe, handle): -- cgit From d718b7f683cc4947acde79ab6ef04eb27a5a44bf Mon Sep 17 00:00:00 2001 From: Tim Potter Date: Thu, 28 Oct 2004 06:14:10 +0000 Subject: r3309: Add wrapper for dcerpc_server_name() function. (This used to be commit 2d60a04f21da9dbe32c85b11afa98df74f5fd763) --- source4/scripting/swig/dcerpc.i | 2 ++ 1 file changed, 2 insertions(+) (limited to 'source4/scripting') diff --git a/source4/scripting/swig/dcerpc.i b/source4/scripting/swig/dcerpc.i index 1222d54766..796384d6e7 100644 --- a/source4/scripting/swig/dcerpc.i +++ b/source4/scripting/swig/dcerpc.i @@ -352,6 +352,8 @@ NTSTATUS dcerpc_pipe_connect(struct dcerpc_pipe **OUT, $1 = &temp_data_blob; } +const char *dcerpc_server_name(struct dcerpc_pipe *p); + %include "librpc/gen_ndr/misc.i" %include "librpc/gen_ndr/lsa.i" %include "librpc/gen_ndr/samr.i" -- cgit From c69b5f76427e7a73403acf16921c4084f4c281bb Mon Sep 17 00:00:00 2001 From: Tim Potter Date: Thu, 28 Oct 2004 06:17:38 +0000 Subject: r3311: Consistency updates for form name members. Add tests for EnumForms, GetForm, AddForm, DeleteForm. (This used to be commit 6c49ce976a5c6982fa83de4ea723cef5597c29ef) --- source4/scripting/swig/torture/spoolss.py | 127 ++++++++++++++++++++++-------- 1 file changed, 94 insertions(+), 33 deletions(-) (limited to 'source4/scripting') diff --git a/source4/scripting/swig/torture/spoolss.py b/source4/scripting/swig/torture/spoolss.py index 91e785ca75..c1859bf2d4 100644 --- a/source4/scripting/swig/torture/spoolss.py +++ b/source4/scripting/swig/torture/spoolss.py @@ -1,6 +1,23 @@ -import string +import sys, string import dcerpc + +def ResizeBufferCall(fn, pipe, r): + + r['buffer'] = None + r['buf_size'] = 0 + + result = fn(pipe, r) + + if result['result'] == dcerpc.WERR_INSUFFICIENT_BUFFER: + r['buffer'] = result['buf_size'] * '\x00' + r['buf_size'] = result['buf_size'] + + result = fn(pipe, r) + + return result + + def test_OpenPrinterEx(pipe, printer): print 'testing spoolss_OpenPrinterEx(%s)' % printer @@ -50,15 +67,8 @@ def test_GetPrinter(pipe, handle): r['buffer'] = None r['buf_size'] = 0 - result = dcerpc.spoolss_GetPrinter(pipe, r) - - if result['result'] == dcerpc.WERR_INSUFFICIENT_BUFFER: - r['buffer'] = result['buf_size'] * '\x00' - r['buf_size'] = result['buf_size'] + result = ResizeBufferCall(dcerpc.spoolss_GetPrinter, pipe, r) - result = dcerpc.spoolss_GetPrinter(pipe, r) - - print result def test_EnumForms(pipe, handle): @@ -70,16 +80,20 @@ def test_EnumForms(pipe, handle): r['buffer'] = None r['buf_size'] = 0 - result = dcerpc.spoolss_EnumForms(pipe, r) + result = ResizeBufferCall(dcerpc.spoolss_EnumForms, pipe, r) - if result['result'] == dcerpc.WERR_INSUFFICIENT_BUFFER: - r['buffer'] = result['buf_size'] * '\x00' - r['buf_size'] = result['buf_size'] + forms = dcerpc.unmarshall_spoolss_FormInfo_array( + result['buffer'], r['level'], result['count']) - result = dcerpc.spoolss_EnumForms(pipe, r) + for form in forms: + + r = {} + r['handle'] = handle + r['formname'] = form['info1']['formname'] + r['level'] = 1 + + result = ResizeBufferCall(dcerpc.spoolss_GetForm, pipe, r) - print result - def test_EnumPorts(pipe, handle): @@ -91,16 +105,68 @@ def test_EnumPorts(pipe, handle): r['buffer'] = None r['buf_size'] = 0 - result = dcerpc.spoolss_EnumPorts(pipe, r) + result = ResizeBufferCall(dcerpc.spoolss_EnumPorts, pipe, r) - if result['result'] == dcerpc.WERR_INSUFFICIENT_BUFFER: - r['buffer'] = result['buf_size'] * '\x00' - r['buf_size'] = result['buf_size'] - result = dcerpc.spoolss_EnumPorts(pipe, r) +def test_DeleteForm(pipe, handle, formname): + + r = {} + r['handle'] = handle + r['formname'] = formname + + dcerpc.spoolss_DeleteForm(pipe, r) + + +def test_GetForm(pipe, handle, formname): + + r = {} + r['handle'] = handle + r['formname'] = formname + r['level'] = 1 + + result = ResizeBufferCall(dcerpc.spoolss_GetForm, pipe, r) + + return result['info']['info1'] + + +def test_AddForm(pipe, handle): + + print 'testing spoolss_AddForm' + + formname = '__testform__' + + r = {} + r['handle'] = handle + r['level'] = 1 + r['info'] = {} + r['info']['info1'] = {} + r['info']['info1']['formname'] = formname + r['info']['info1']['flags'] = 0 + r['info']['info1']['width'] = 1 + r['info']['info1']['length'] = 2 + r['info']['info1']['left'] = 3 + r['info']['info1']['top'] = 4 + r['info']['info1']['right'] = 5 + r['info']['info1']['bottom'] = 6 + + try: + result = dcerpc.spoolss_AddForm(pipe, r) + except dcerpc.WERROR, arg: + if arg[0] == dcerpc.WERR_ALREADY_EXISTS: + test_DeleteForm(pipe, handle, formname) + result = dcerpc.spoolss_AddForm(pipe, r) + + f = test_GetForm(pipe, handle, formname) + + if r['info']['info1'] != f: + print 'Form type mismatch: %s != %s' % \ + (r['info']['info1'], f) + sys.exit(1) + + # TODO: test spoolss_SetForm() + + test_DeleteForm(pipe, handle, formname) - print result - def test_EnumPrinters(pipe): @@ -120,20 +186,11 @@ def test_EnumPrinters(pipe): r['buf_size'] = 0 r['buffer'] = None - result = dcerpc.spoolss_EnumPrinters(pipe, r) - - if result['result'] == dcerpc.WERR_INSUFFICIENT_BUFFER: - r['buffer'] = result['buf_size'] * '\x00' - r['buf_size'] = result['buf_size'] - - result = dcerpc.spoolss_EnumPrinters(pipe, r) + result = ResizeBufferCall(dcerpc.spoolss_EnumPrinters,pipe, r) printers = dcerpc.unmarshall_spoolss_PrinterInfo_array( result['buffer'], r['level'], result['count']) - from pprint import pprint - pprint(printers) - if level == 1: printer_names = map( lambda x: string.split(x['info1']['name'], ',')[0], printers) @@ -144,6 +201,10 @@ def test_EnumPrinters(pipe): test_GetPrinter(pipe, handle) + test_EnumForms(pipe, handle) + + test_AddForm(pipe, handle) + test_ClosePrinter(pipe, handle) -- cgit From 89665e87b47e5cc3299c3234bf3c8b0266f9bab2 Mon Sep 17 00:00:00 2001 From: Tim Potter Date: Sat, 30 Oct 2004 23:35:34 +0000 Subject: r3396: Rename form_name -> formname. This time, check smbtorture builds before committing. (-: (This used to be commit c776232d0130638a85cc8ce75e4bbef75952e856) --- source4/scripting/swig/torture/spoolss.py | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) (limited to 'source4/scripting') diff --git a/source4/scripting/swig/torture/spoolss.py b/source4/scripting/swig/torture/spoolss.py index c1859bf2d4..78c74569f5 100644 --- a/source4/scripting/swig/torture/spoolss.py +++ b/source4/scripting/swig/torture/spoolss.py @@ -163,7 +163,10 @@ def test_AddForm(pipe, handle): (r['info']['info1'], f) sys.exit(1) - # TODO: test spoolss_SetForm() + r['formname'] = formname + r['info']['info1']['unknown'] = 1 + + dcerpc.spoolss_SetForm(pipe, r) test_DeleteForm(pipe, handle, formname) -- cgit From 75f1497c32bbae1d603b80810412a544303fce94 Mon Sep 17 00:00:00 2001 From: Tim Potter Date: Sun, 31 Oct 2004 03:54:20 +0000 Subject: r3401: Fix IDL for SetForm RPC. (This used to be commit 206f3de297c397c8894f9855ea8571c68823e1fc) --- source4/scripting/swig/torture/spoolss.py | 39 +++++++++++++++++++++++-------- 1 file changed, 29 insertions(+), 10 deletions(-) (limited to 'source4/scripting') diff --git a/source4/scripting/swig/torture/spoolss.py b/source4/scripting/swig/torture/spoolss.py index 78c74569f5..4c65669d8f 100644 --- a/source4/scripting/swig/torture/spoolss.py +++ b/source4/scripting/swig/torture/spoolss.py @@ -129,6 +129,26 @@ def test_GetForm(pipe, handle, formname): return result['info']['info1'] +def test_SetForm(pipe, handle, form): + + print 'testing spoolss_SetForm' + + r = {} + r['handle'] = handle + r['level'] = 1 + r['formname'] = form['info1']['formname'] + r['info'] = form + + dcerpc.spoolss_SetForm(pipe, r) + + newform = test_GetForm(pipe, handle, r['formname']) + + if form['info1'] != newform: + print 'SetForm: mismatch: %s != %s' % \ + (r['info']['info1'], f) + sys.exit(1) + + def test_AddForm(pipe, handle): print 'testing spoolss_AddForm' @@ -141,13 +161,13 @@ def test_AddForm(pipe, handle): r['info'] = {} r['info']['info1'] = {} r['info']['info1']['formname'] = formname - r['info']['info1']['flags'] = 0 - r['info']['info1']['width'] = 1 - r['info']['info1']['length'] = 2 - r['info']['info1']['left'] = 3 - r['info']['info1']['top'] = 4 - r['info']['info1']['right'] = 5 - r['info']['info1']['bottom'] = 6 + r['info']['info1']['flags'] = 0x0002 + r['info']['info1']['width'] = 100 + r['info']['info1']['length'] = 100 + r['info']['info1']['left'] = 0 + r['info']['info1']['top'] = 1000 + r['info']['info1']['right'] = 2000 + r['info']['info1']['bottom'] = 3000 try: result = dcerpc.spoolss_AddForm(pipe, r) @@ -159,14 +179,13 @@ def test_AddForm(pipe, handle): f = test_GetForm(pipe, handle, formname) if r['info']['info1'] != f: - print 'Form type mismatch: %s != %s' % \ + print 'AddForm: mismatch: %s != %s' % \ (r['info']['info1'], f) sys.exit(1) r['formname'] = formname - r['info']['info1']['unknown'] = 1 - dcerpc.spoolss_SetForm(pipe, r) + test_SetForm(pipe, handle, r['info']) test_DeleteForm(pipe, handle, formname) -- cgit From 0e082a5c9d3faf11dd7f8813d4777597819c41da Mon Sep 17 00:00:00 2001 From: Tim Potter Date: Sun, 31 Oct 2004 04:41:57 +0000 Subject: r3403: Add test for operations on print server handle. Add tests for EnumJobs, GetJob. Oops - forgot to EnumPrinters at level2. (This used to be commit 930d57964b69fda59f473914ac4633984f259c86) --- source4/scripting/swig/torture/spoolss.py | 87 +++++++++++++++++++++++++------ 1 file changed, 72 insertions(+), 15 deletions(-) (limited to 'source4/scripting') diff --git a/source4/scripting/swig/torture/spoolss.py b/source4/scripting/swig/torture/spoolss.py index 4c65669d8f..1b19bd8f1a 100644 --- a/source4/scripting/swig/torture/spoolss.py +++ b/source4/scripting/swig/torture/spoolss.py @@ -22,9 +22,13 @@ def test_OpenPrinterEx(pipe, printer): print 'testing spoolss_OpenPrinterEx(%s)' % printer + printername = '\\\\%s' % dcerpc.dcerpc_server_name(pipe) + + if printer is not None: + printername = printername + '\\%s' % printer + r = {} - r['printername'] = '\\\\%s\\%s' % \ - (dcerpc.dcerpc_server_name(pipe), printer) + r['printername'] = printername r['datatype'] = None r['devmode_ctr'] = {} r['devmode_ctr']['size'] = 0 @@ -190,6 +194,38 @@ def test_AddForm(pipe, handle): test_DeleteForm(pipe, handle, formname) +def test_EnumJobs(pipe, handle): + + print 'testing spoolss_EnumJobs' + + r = {} + r['handle'] = handle + r['firstjob'] = 0 + r['numjobs'] = 0xffffffff + r['level'] = 1 + + result = ResizeBufferCall(dcerpc.spoolss_EnumJobs, pipe, r) + + if result['buffer'] is None: + return + + jobs = dcerpc.unmarshall_spoolss_JobInfo_array( + result['buffer'], r['level'], result['count']) + + for job in jobs: + + s = {} + s['handle'] = handle + s['job_id'] = job['info1']['job_id'] + s['level'] = 1 + + result = ResizeBufferCall(dcerpc.spoolss_GetJob, pipe, s) + + if result['info'] != job: + print 'EnumJobs: mismatch: %s != %s' % (result['info'], job) + sys.exit(1) + + def test_EnumPrinters(pipe): print 'testing spoolss_EnumPrinters' @@ -200,35 +236,55 @@ def test_EnumPrinters(pipe): r['flags'] = 0x02 r['server'] = None - for level in [0, 1, 4, 5]: + for level in [0, 1, 2, 4, 5]: print 'test_EnumPrinters(level = %d)' % level r['level'] = level - r['buf_size'] = 0 - r['buffer'] = None - result = ResizeBufferCall(dcerpc.spoolss_EnumPrinters,pipe, r) + result = ResizeBufferCall(dcerpc.spoolss_EnumPrinters, pipe, r) printers = dcerpc.unmarshall_spoolss_PrinterInfo_array( result['buffer'], r['level'], result['count']) - if level == 1: - printer_names = map( - lambda x: string.split(x['info1']['name'], ',')[0], printers) + if level == 2: + for p in printers: - for printer in printer_names: + # A nice check is for the specversion in the + # devicemode. This has always been observed to be + # 1025. - handle = test_OpenPrinterEx(pipe, printer) + if p['info2']['devmode']['specversion'] != 1025: + print 'test_EnumPrinters: specversion != 1025' + sys.exit(1) - test_GetPrinter(pipe, handle) + r['level'] = 1 + result = ResizeBufferCall(dcerpc.spoolss_EnumPrinters, pipe, r) + + for printer in dcerpc.unmarshall_spoolss_PrinterInfo_array( + result['buffer'], r['level'], result['count']): - test_EnumForms(pipe, handle) + if string.find(printer['info1']['name'], '\\\\') == 0: + print 'Skipping remote printer %s' % printer['info1']['name'] + continue - test_AddForm(pipe, handle) + printername = string.split(printer['info1']['name'], ',')[0] + + handle = test_OpenPrinterEx(pipe, printername) + test_GetPrinter(pipe, handle) + test_EnumForms(pipe, handle) + test_AddForm(pipe, handle) + test_EnumJobs(pipe, handle) test_ClosePrinter(pipe, handle) - + + +def test_PrintServer(pipe): + + handle = test_OpenPrinterEx(pipe, None) + + test_ClosePrinter(pipe, handle) + def runtests(binding, domain, username, password): @@ -239,3 +295,4 @@ def runtests(binding, domain, username, password): domain, username, password) test_EnumPrinters(pipe) + test_PrintServer(pipe) -- cgit From 5d7c6d7bbdbf9e796fa4d21aa47f177b6c81367e Mon Sep 17 00:00:00 2001 From: Tim Potter Date: Sun, 31 Oct 2004 05:45:52 +0000 Subject: r3405: Test EnumPrinterData and GetPrinterData. (This used to be commit a4facee8602cfb9b2599e0068dd42933ed94655e) --- source4/scripting/swig/torture/spoolss.py | 49 ++++++++++++++++++++++++++++++- 1 file changed, 48 insertions(+), 1 deletion(-) (limited to 'source4/scripting') diff --git a/source4/scripting/swig/torture/spoolss.py b/source4/scripting/swig/torture/spoolss.py index 1b19bd8f1a..4779c278f2 100644 --- a/source4/scripting/swig/torture/spoolss.py +++ b/source4/scripting/swig/torture/spoolss.py @@ -9,7 +9,8 @@ def ResizeBufferCall(fn, pipe, r): result = fn(pipe, r) - if result['result'] == dcerpc.WERR_INSUFFICIENT_BUFFER: + if result['result'] == dcerpc.WERR_INSUFFICIENT_BUFFER or \ + result['result'] == dcerpc.WERR_MORE_DATA: r['buffer'] = result['buf_size'] * '\x00' r['buf_size'] = result['buf_size'] @@ -226,6 +227,49 @@ def test_EnumJobs(pipe, handle): sys.exit(1) + # TODO: AddJob, DeleteJob, ScheduleJob + + +def test_EnumPrinterData(pipe, handle): + + print 'test_EnumPrinterData' + + enum_index = 0 + + while 1: + + r = {} + r['handle'] = handle + r['enum_index'] = enum_index + + r['value_offered'] = 0 + r['data_size'] = 0 + + result = dcerpc.spoolss_EnumPrinterData(pipe, r) + + r['value_offered'] = result['value_needed'] + r['data_size'] = result['data_size'] + + result = dcerpc.spoolss_EnumPrinterData(pipe, r) + + if result['result'] == dcerpc.WERR_NO_MORE_ITEMS: + break + + s = {} + s['handle'] = handle + s['value_name'] = result['value_name'] + + result2 = ResizeBufferCall(dcerpc.spoolss_GetPrinterData, pipe, s) + + if result['buffer'][:result2['buf_size']] != result2['buffer']: + print 'EnumPrinterData/GetPrinterData mismatch' + sys.exit(1) + + enum_index += 1 + + sys.exit(1) + + def test_EnumPrinters(pipe): print 'testing spoolss_EnumPrinters' @@ -276,6 +320,7 @@ def test_EnumPrinters(pipe): test_EnumForms(pipe, handle) test_AddForm(pipe, handle) test_EnumJobs(pipe, handle) + test_EnumPrinterData(pipe, handle) test_ClosePrinter(pipe, handle) @@ -283,6 +328,8 @@ def test_PrintServer(pipe): handle = test_OpenPrinterEx(pipe, None) + # EnumForms and AddForm tests return WERR_BADFID here (??) + test_ClosePrinter(pipe, handle) -- cgit From 751b412326e77ee4bea0c521906e6f83a8bedd07 Mon Sep 17 00:00:00 2001 From: Tim Potter Date: Sun, 31 Oct 2004 11:33:40 +0000 Subject: r3410: Handle conversion of DATA_BLOBs and pointers to DATA_BLOBs from python. (This used to be commit 12e037dbe3d497aff2415c0a22fab20a7932ab7a) --- source4/scripting/swig/dcerpc.i | 17 +++++++++++++++++ source4/scripting/swig/torture/spoolss.py | 27 ++++++++++++++++++++++++++- 2 files changed, 43 insertions(+), 1 deletion(-) (limited to 'source4/scripting') diff --git a/source4/scripting/swig/dcerpc.i b/source4/scripting/swig/dcerpc.i index 796384d6e7..c7e2d79c12 100644 --- a/source4/scripting/swig/dcerpc.i +++ b/source4/scripting/swig/dcerpc.i @@ -254,6 +254,23 @@ PyObject *string_ptr_to_python(TALLOC_CTX *mem_ctx, char *obj) #define dom_sid2_ptr_to_python dom_sid_ptr_to_python #define dom_sid2_ptr_from_python dom_sid_ptr_from_python +void DATA_BLOB_from_python(TALLOC_CTX *mem_ctx, DATA_BLOB *s, + PyObject *obj, char name) +{ + if (obj == NULL) { + PyErr_Format(PyExc_ValueError, "Expecting key %s", name); + return; + } + + if (!PyString_Check(obj)) { + PyErr_Format(PyExc_TypeError, "Expecting string value for key '%s'", name); + return; + } + + s->length = PyString_Size(obj); + s->data = PyString_AsString(obj); +} + void DATA_BLOB_ptr_from_python(TALLOC_CTX *mem_ctx, DATA_BLOB **s, PyObject *obj, char *name) { diff --git a/source4/scripting/swig/torture/spoolss.py b/source4/scripting/swig/torture/spoolss.py index 4779c278f2..ef8b3150e1 100644 --- a/source4/scripting/swig/torture/spoolss.py +++ b/source4/scripting/swig/torture/spoolss.py @@ -267,7 +267,31 @@ def test_EnumPrinterData(pipe, handle): enum_index += 1 - sys.exit(1) +def test_SetPrinterData(pipe, handle): + + print 'testing spoolss_SetPrinterData' + + valuename = '__printerdatatest__' + data = '12345' + + r = {} + r['handle'] = handle + r['value_name'] = valuename + r['type'] = 3 # REG_BINARY + r['buffer'] = data + r['real_len'] = 5 + + dcerpc.spoolss_SetPrinterData(pipe, r) + + s = {} + s['handle'] = handle + s['value_name'] = valuename + + result = ResizeBufferCall(dcerpc.spoolss_GetPrinterData, pipe, r) + + if result['buffer'] != data: + print 'SetPrinterData: mismatch' + sys.exit(1) def test_EnumPrinters(pipe): @@ -321,6 +345,7 @@ def test_EnumPrinters(pipe): test_AddForm(pipe, handle) test_EnumJobs(pipe, handle) test_EnumPrinterData(pipe, handle) + test_SetPrinterData(pipe, handle) test_ClosePrinter(pipe, handle) -- cgit From 9ebf74c5765299492c116004c59c8368dab0b71b Mon Sep 17 00:00:00 2001 From: Tim Potter Date: Sun, 31 Oct 2004 11:35:31 +0000 Subject: r3411: Ignore some autogenerated files. (This used to be commit f6428f2d01a4bd8d4acadf96e33957371cdb2021) --- source4/scripting/swig/torture/spoolss.py | 3 +++ 1 file changed, 3 insertions(+) (limited to 'source4/scripting') diff --git a/source4/scripting/swig/torture/spoolss.py b/source4/scripting/swig/torture/spoolss.py index ef8b3150e1..70450a9b12 100644 --- a/source4/scripting/swig/torture/spoolss.py +++ b/source4/scripting/swig/torture/spoolss.py @@ -267,6 +267,7 @@ def test_EnumPrinterData(pipe, handle): enum_index += 1 + def test_SetPrinterData(pipe, handle): print 'testing spoolss_SetPrinterData' @@ -293,6 +294,8 @@ def test_SetPrinterData(pipe, handle): print 'SetPrinterData: mismatch' sys.exit(1) + dcerpc.spoolss_DeletePrinterData(pipe, r) + def test_EnumPrinters(pipe): -- cgit From 8c1edd1674fd073f3b4274a940f598e33319dd12 Mon Sep 17 00:00:00 2001 From: Tim Potter Date: Mon, 1 Nov 2004 11:51:35 +0000 Subject: r3430: Add tests for EnumPrinterDataEx, SetPrinterDataEx (doesn't work), EnumPrinterDrivers. (This used to be commit fe381c3ebc64a7d067832c7d2aebeb35b1f3923b) --- source4/scripting/swig/torture/spoolss.py | 75 ++++++++++++++++++++++++++----- 1 file changed, 65 insertions(+), 10 deletions(-) (limited to 'source4/scripting') diff --git a/source4/scripting/swig/torture/spoolss.py b/source4/scripting/swig/torture/spoolss.py index 70450a9b12..a4fdbbb107 100644 --- a/source4/scripting/swig/torture/spoolss.py +++ b/source4/scripting/swig/torture/spoolss.py @@ -21,7 +21,7 @@ def ResizeBufferCall(fn, pipe, r): def test_OpenPrinterEx(pipe, printer): - print 'testing spoolss_OpenPrinterEx(%s)' % printer + print 'spoolss_OpenPrinterEx(%s)' % printer printername = '\\\\%s' % dcerpc.dcerpc_server_name(pipe) @@ -66,7 +66,7 @@ def test_GetPrinter(pipe, handle): for level in [0, 1, 2, 3, 4, 5, 6, 7]: - print 'test_GetPrinter(level = %d)' % level + print 'spoolss_GetPrinter(level = %d)' % level r['level'] = level r['buffer'] = None @@ -77,7 +77,7 @@ def test_GetPrinter(pipe, handle): def test_EnumForms(pipe, handle): - print 'testing spoolss_EnumForms' + print 'spoolss_EnumForms()' r = {} r['handle'] = handle @@ -102,7 +102,7 @@ def test_EnumForms(pipe, handle): def test_EnumPorts(pipe, handle): - print 'testing spoolss_EnumPorts' + print 'spoolss_EnumPorts()' r = {} r['handle'] = handle @@ -136,7 +136,7 @@ def test_GetForm(pipe, handle, formname): def test_SetForm(pipe, handle, form): - print 'testing spoolss_SetForm' + print 'spoolss_SetForm()' r = {} r['handle'] = handle @@ -156,7 +156,7 @@ def test_SetForm(pipe, handle, form): def test_AddForm(pipe, handle): - print 'testing spoolss_AddForm' + print 'spoolss_AddForm()' formname = '__testform__' @@ -197,7 +197,7 @@ def test_AddForm(pipe, handle): def test_EnumJobs(pipe, handle): - print 'testing spoolss_EnumJobs' + print 'spoolss_EnumJobs()' r = {} r['handle'] = handle @@ -232,7 +232,7 @@ def test_EnumJobs(pipe, handle): def test_EnumPrinterData(pipe, handle): - print 'test_EnumPrinterData' + print 'test_EnumPrinterData()' enum_index = 0 @@ -268,9 +268,42 @@ def test_EnumPrinterData(pipe, handle): enum_index += 1 +def test_SetPrinterDataEx(pipe, handle): + + valuename = '__printerdataextest__' + data = '12345' + + r = {} + r['handle'] = handle + r['key_name'] = 'DsSpooler' + r['value_name'] = valuename + r['type'] = 3 + r['buffer'] = data + r['buf_size'] = len(data) + + result = dcerpc.spoolss_SetPrinterDataEx(pipe, r) + + +def test_EnumPrinterDataEx(pipe, handle): + + r = {} + r['handle'] = handle + r['key_name'] = 'DsSpooler' + r['buf_size'] = 0 + + result = dcerpc.spoolss_EnumPrinterDataEx(pipe, r) + + if result['result'] == dcerpc.WERR_MORE_DATA: + r['buf_size'] = result['buf_size'] + + result = dcerpc.spoolss_EnumPrinterDataEx(pipe, r) + + # TODO: test spoolss_GetPrinterDataEx() + + def test_SetPrinterData(pipe, handle): - print 'testing spoolss_SetPrinterData' + print 'testing spoolss_SetPrinterData()' valuename = '__printerdatatest__' data = '12345' @@ -299,7 +332,7 @@ def test_SetPrinterData(pipe, handle): def test_EnumPrinters(pipe): - print 'testing spoolss_EnumPrinters' + print 'testing spoolss_EnumPrinters()' printer_names = None @@ -348,10 +381,31 @@ def test_EnumPrinters(pipe): test_AddForm(pipe, handle) test_EnumJobs(pipe, handle) test_EnumPrinterData(pipe, handle) + test_EnumPrinterDataEx(pipe, handle) test_SetPrinterData(pipe, handle) +# test_SetPrinterDataEx(pipe, handle) test_ClosePrinter(pipe, handle) +def test_EnumPrinterDrivers(pipe): + + print 'test spoolss_EnumPrinterDrivers()' + + for level in [1, 2, 3]: + + r = {} + r['server'] = None + r['environment'] = None + r['level'] = level + + result = ResizeBufferCall(dcerpc.spoolss_EnumPrinterDrivers, pipe, r) + + for driver in dcerpc.unmarshall_spoolss_DriverInfo_array( + result['buffer'], r['level'], result['count']): + + print driver + + def test_PrintServer(pipe): handle = test_OpenPrinterEx(pipe, None) @@ -370,4 +424,5 @@ def runtests(binding, domain, username, password): domain, username, password) test_EnumPrinters(pipe) + test_EnumPrinterDrivers(pipe) test_PrintServer(pipe) -- cgit From 2f7d7e47e38d88655baddad4e2e0572d4c158f70 Mon Sep 17 00:00:00 2001 From: Tim Potter Date: Tue, 2 Nov 2004 03:47:24 +0000 Subject: r3456: Add appropriate #includes to fix Python extensions build. (This used to be commit 7e94d5bd3dd7b7055e9b70496207713f94446f98) --- source4/scripting/swig/dcerpc.i | 8 ++++++++ 1 file changed, 8 insertions(+) (limited to 'source4/scripting') diff --git a/source4/scripting/swig/dcerpc.i b/source4/scripting/swig/dcerpc.i index c7e2d79c12..6bb30847eb 100644 --- a/source4/scripting/swig/dcerpc.i +++ b/source4/scripting/swig/dcerpc.i @@ -371,6 +371,14 @@ NTSTATUS dcerpc_pipe_connect(struct dcerpc_pipe **OUT, const char *dcerpc_server_name(struct dcerpc_pipe *p); +%{ +#include "librpc/gen_ndr/ndr_misc.h" +#include "librpc/gen_ndr/ndr_lsa.h" +#include "librpc/gen_ndr/ndr_samr.h" +#include "librpc/gen_ndr/ndr_winreg.h" +#include "librpc/gen_ndr/ndr_spoolss.h" +%} + %include "librpc/gen_ndr/misc.i" %include "librpc/gen_ndr/lsa.i" %include "librpc/gen_ndr/samr.i" -- cgit From 6afe281de820f3d3a557259386b91530432dde90 Mon Sep 17 00:00:00 2001 From: Tim Potter Date: Tue, 2 Nov 2004 04:22:57 +0000 Subject: r3459: Fix cut&paste error in copyright header. (This used to be commit 922ea35a4b6ea02e888a98aee241f1b9f6fca420) --- source4/scripting/swig/samba.i | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'source4/scripting') diff --git a/source4/scripting/swig/samba.i b/source4/scripting/swig/samba.i index 38a5251a08..9d73207705 100644 --- a/source4/scripting/swig/samba.i +++ b/source4/scripting/swig/samba.i @@ -5,8 +5,8 @@ Copyright (C) 2004 Tim Potter - ** NOTE! The following LGPL license applies to the tdb - ** library. This does NOT imply that all of Samba is released + ** NOTE! The following LGPL license applies to the swig + ** definitions. This does NOT imply that all of Samba is released ** under the LGPL This library is free software; you can redistribute it and/or -- cgit From 5f68ab2538a6ef3c57c716f753663dc930b9d74b Mon Sep 17 00:00:00 2001 From: Tim Potter Date: Tue, 2 Nov 2004 11:06:00 +0000 Subject: r3474: Add conversion functions for the time_t type. (This used to be commit caa563faaa264c41afdb60d64dc9566fcd31518e) --- source4/scripting/swig/dcerpc.i | 23 +++++++++++++++++++++++ 1 file changed, 23 insertions(+) (limited to 'source4/scripting') diff --git a/source4/scripting/swig/dcerpc.i b/source4/scripting/swig/dcerpc.i index 6bb30847eb..0a820c0a3c 100644 --- a/source4/scripting/swig/dcerpc.i +++ b/source4/scripting/swig/dcerpc.i @@ -197,6 +197,29 @@ PyObject *NTTIME_to_python(NTTIME obj) return PyLong_FromUnsignedLongLong(obj); } +time_t time_t_from_python(PyObject *obj, char *name) +{ + if (obj == NULL) { + PyErr_Format(PyExc_ValueError, "Expecting key %s", name); + return 0; + } + + if (!PyLong_Check(obj) && !PyInt_Check(obj)) { + PyErr_Format(PyExc_TypeError, "Expecting int or long value for %s", name); + return 0; + } + + if (PyLong_Check(obj)) + return (time_t)PyLong_AsUnsignedLongLong(obj); + else + return (time_t)PyInt_AsUnsignedLongMask(obj); +} + +PyObject *time_t_to_python(time_t obj) +{ + return PyLong_FromUnsignedLongLong(obj); +} + HYPER_T HYPER_T_from_python(PyObject *obj, char *name) { if (obj == NULL) { -- cgit From e3e5ef95addf3ca6b99166323adee4eada18d213 Mon Sep 17 00:00:00 2001 From: Tim Potter Date: Wed, 3 Nov 2004 06:12:42 +0000 Subject: r3505: #include dynconfig.h (This used to be commit 336eba61e99cd96fe4abc8476b998d079fbb5770) --- source4/scripting/swig/dcerpc.i | 1 + 1 file changed, 1 insertion(+) (limited to 'source4/scripting') diff --git a/source4/scripting/swig/dcerpc.i b/source4/scripting/swig/dcerpc.i index 0a820c0a3c..560345525f 100644 --- a/source4/scripting/swig/dcerpc.i +++ b/source4/scripting/swig/dcerpc.i @@ -34,6 +34,7 @@ #endif #include "includes.h" +#include "dynconfig.h" #undef strcpy -- cgit From 90a8c4acc7e673e6439197776d19cc4b095ac322 Mon Sep 17 00:00:00 2001 From: Tim Potter Date: Wed, 3 Nov 2004 06:29:22 +0000 Subject: r3506: Test EnumPorts function. (This used to be commit 354068aae16b7e0c13416cfcdf9bdef5138dccc0) --- source4/scripting/swig/torture/spoolss.py | 20 ++++++++++++++------ 1 file changed, 14 insertions(+), 6 deletions(-) (limited to 'source4/scripting') diff --git a/source4/scripting/swig/torture/spoolss.py b/source4/scripting/swig/torture/spoolss.py index a4fdbbb107..35a0a6039f 100644 --- a/source4/scripting/swig/torture/spoolss.py +++ b/source4/scripting/swig/torture/spoolss.py @@ -104,13 +104,20 @@ def test_EnumPorts(pipe, handle): print 'spoolss_EnumPorts()' - r = {} - r['handle'] = handle - r['level'] = 1 - r['buffer'] = None - r['buf_size'] = 0 + for level in [1, 2]: + + r = {} + r['handle'] = handle + r['servername'] = None + r['level'] = level + + result = ResizeBufferCall(dcerpc.spoolss_EnumPorts, pipe, r) + + ports = dcerpc.unmarshall_spoolss_PortInfo_array( + result['buffer'], r['level'], result['count']) - result = ResizeBufferCall(dcerpc.spoolss_EnumPorts, pipe, r) + if level == 1: + port_names = map(lambda x: x['info1']['port_name'], ports) def test_DeleteForm(pipe, handle, formname): @@ -377,6 +384,7 @@ def test_EnumPrinters(pipe): handle = test_OpenPrinterEx(pipe, printername) test_GetPrinter(pipe, handle) + test_EnumPorts(pipe, handle) test_EnumForms(pipe, handle) test_AddForm(pipe, handle) test_EnumJobs(pipe, handle) -- cgit From 500ce03f7cb1cb2468b856cc9352422141cc9904 Mon Sep 17 00:00:00 2001 From: Tim Potter Date: Thu, 4 Nov 2004 06:40:28 +0000 Subject: r3521: Collect printer driver names in EnumPrinterDrivers. (This used to be commit 86f54db1ef96fbffc6f1c7948d8bc849009a536d) --- source4/scripting/swig/torture/spoolss.py | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) (limited to 'source4/scripting') diff --git a/source4/scripting/swig/torture/spoolss.py b/source4/scripting/swig/torture/spoolss.py index 35a0a6039f..a75385e079 100644 --- a/source4/scripting/swig/torture/spoolss.py +++ b/source4/scripting/swig/torture/spoolss.py @@ -408,11 +408,12 @@ def test_EnumPrinterDrivers(pipe): result = ResizeBufferCall(dcerpc.spoolss_EnumPrinterDrivers, pipe, r) - for driver in dcerpc.unmarshall_spoolss_DriverInfo_array( - result['buffer'], r['level'], result['count']): - - print driver + drivers = dcerpc.unmarshall_spoolss_DriverInfo_array( + result['buffer'], r['level'], result['count']) + if level == 1: + driver_names = map(lambda x: x['info1']['driver_name'], drivers) + def test_PrintServer(pipe): -- cgit From 3503373ba5af647a6da14b80385a5c1084c3112f Mon Sep 17 00:00:00 2001 From: Tim Potter Date: Sun, 7 Nov 2004 00:41:43 +0000 Subject: r3588: Fix bug in converting SIDs containing large unsigned integers from Python. (This used to be commit a46aba43549e5221ec0c15d4133444d8ef77a4fb) --- source4/scripting/swig/dcerpc.i | 6 +++--- source4/scripting/swig/torture/samr.py | 12 ++++++++++++ 2 files changed, 15 insertions(+), 3 deletions(-) (limited to 'source4/scripting') diff --git a/source4/scripting/swig/dcerpc.i b/source4/scripting/swig/dcerpc.i index 560345525f..27afb6471c 100644 --- a/source4/scripting/swig/dcerpc.i +++ b/source4/scripting/swig/dcerpc.i @@ -119,9 +119,9 @@ uint32 uint32_from_python(PyObject *obj, char *name) } if (PyLong_Check(obj)) - return (uint32)PyLong_AsLong(obj); - else - return (uint32)PyInt_AsLong(obj); + return (uint32)PyLong_AsUnsignedLongMask(obj); + + return (uint32)PyInt_AsLong(obj); } PyObject *uint32_to_python(uint32 obj) diff --git a/source4/scripting/swig/torture/samr.py b/source4/scripting/swig/torture/samr.py index 435b3a81db..f7c33baeb3 100755 --- a/source4/scripting/swig/torture/samr.py +++ b/source4/scripting/swig/torture/samr.py @@ -864,6 +864,18 @@ def test_LongInt(pipe): result = dcerpc.samr_Connect(pipe, r) + # Test that we can parse a SID that contains a sub_auth that can't + # be held in a python int. + + r = {} + r['connect_handle'] = result['connect_handle'] + r['access_mask'] = 0x02000000 + r['sid'] = {'sid_rev_num': 1, 'id_auth': [0, 0, 0, 0, 0, 5], + 'num_auths': 4, + 'sub_auths': [21, 737922324, 3002806791L, 1285293260]} + + result = dcerpc.samr_OpenDomain(pipe, r) + def runtests(binding, domain, username, password): print 'Testing SAMR pipe' -- cgit From 6c32daf320b1c70db38199ffcdb0e1c25a207a13 Mon Sep 17 00:00:00 2001 From: Tim Potter Date: Sun, 7 Nov 2004 01:09:14 +0000 Subject: r3589: Add some extra status codes. (This used to be commit 6d918f15951f38061128e141bbcc161d8956977e) --- source4/scripting/swig/status_codes.i | 2 ++ 1 file changed, 2 insertions(+) (limited to 'source4/scripting') diff --git a/source4/scripting/swig/status_codes.i b/source4/scripting/swig/status_codes.i index dccbfab61d..cf13ac9852 100644 --- a/source4/scripting/swig/status_codes.i +++ b/source4/scripting/swig/status_codes.i @@ -543,6 +543,8 @@ #define WERR_CAN_NOT_COMPLETE 1003 #define WERR_INVALID_SECURITY_DESCRIPTOR 1338 #define WERR_SERVER_UNAVAILABLE 1722 +#define WERR_UNKNOWN_PRINTER_DRIVER 1797 +#define WERR_INVALID_ENVIRONMENT 1805 #define WERR_INVALID_FORM_NAME 1902 #define WERR_INVALID_FORM_SIZE 1903 #define WERR_BUF_TOO_SMALL 2123 -- cgit From e34ee4fdaa4f8b6ae7167b663c2acda2654f2895 Mon Sep 17 00:00:00 2001 From: Tim Potter Date: Sun, 7 Nov 2004 01:11:11 +0000 Subject: r3590: Add some more commands to rpcclient from a patch by jbm. Add SamrQueryDomInfo, SamrQueryDomInfo2, SamrEnumDomainAliases, and SamrEnumDomainUsers. (This used to be commit 91eb405354a65bfd94bf59c21fe21f68fff7b9fd) --- source4/scripting/swig/rpcclient | 133 ++++++++++++++++++++++++++++++++++++++- source4/scripting/swig/samr.py | 59 +++++++++++++++-- 2 files changed, 186 insertions(+), 6 deletions(-) (limited to 'source4/scripting') diff --git a/source4/scripting/swig/rpcclient b/source4/scripting/swig/rpcclient index 2a3d12cc8e..aad4597053 100755 --- a/source4/scripting/swig/rpcclient +++ b/source4/scripting/swig/rpcclient @@ -3,7 +3,7 @@ import sys, os, string from cmd import Cmd from optparse import OptionParser - +from pprint import pprint import dcerpc, samr @@ -96,6 +96,137 @@ class rpcclient(Cmd): print connect_handle.LookupDomain(args[0]) + def do_SamrQueryDomInfo(self, line): + """Return information about a domain designated by its SID.""" + + usage = 'SamrQueryDomInfo DOMAIN_SID [info_level]' + + parser = OptionParser(usage) + options, args = parser.parse_args(string.split(line)) + + if (len(args) == 0) or (len(args) > 2): + print 'usage:', usage + return + + pipe = dcerpc.pipe_connect( + self.binding, + dcerpc.DCERPC_SAMR_UUID, dcerpc.DCERPC_SAMR_VERSION, + self.domain, self.username, self.password) + + connect_handle = samr.Connect(pipe) + domain_handle = connect_handle.OpenDomain(args[0]) + + if (len(args) == 2): + result = domain_handle.QueryDomainInfo(int(args[1])) + else: + result = domain_handle.QueryDomainInfo() + + pprint(result['info']) + + def do_SamrQueryDomInfo2(self, line): + """Return information about a domain designated by its SID. (Windows 2000 and >)""" + + usage = 'SamrQueryDomInfo2 DOMAIN_SID [info_level] (Windows 2000 and >)' + parser = OptionParser(usage) + options, args = parser.parse_args(string.split(line)) + + if (len(args) == 0) or (len(args) > 2): + print 'usage:', usage + return + + pipe = dcerpc.pipe_connect( + self.binding, + dcerpc.DCERPC_SAMR_UUID, dcerpc.DCERPC_SAMR_VERSION, + self.domain, self.username, self.password) + + connect_handle = samr.Connect(pipe) + domain_handle = connect_handle.OpenDomain(args[0]) + + if (len(args) == 2): + result = domain_handle.QueryDomainInfo2(int(args[1])) + else: + result = domain_handle.QueryDomainInfo2() + + pprint(result['info']) + + def do_SamrEnumDomainGroups(self, line): + """Return the list of groups of a domain designated by its SID.""" + + usage = 'SamrEnumDomainGroups DOMAIN_SID' + + parser = OptionParser(usage) + options, args = parser.parse_args(string.split(line)) + + if len(args) != 1: + print 'usage:', usage + return + + pipe = dcerpc.pipe_connect( + self.binding, + dcerpc.DCERPC_SAMR_UUID, dcerpc.DCERPC_SAMR_VERSION, + self.domain, self.username, self.password) + + connect_handle = samr.Connect(pipe) + domain_handle = connect_handle.OpenDomain(args[0]) + + result = domain_handle.EnumDomainGroups() + + for r in result['sam']['entries']: + print r['name']['name'] + + def do_SamrEnumDomainAliases(self, line): + """Return the list of aliases (local groups) of a domain designated by its SID.""" + + usage = 'SamrEnumDomainAliases DOMAIN_SID' + + parser = OptionParser(usage) + options, args = parser.parse_args(string.split(line)) + + if len(args) != 1: + print 'usage:', usage + return + + pipe = dcerpc.pipe_connect( + self.binding, + dcerpc.DCERPC_SAMR_UUID, dcerpc.DCERPC_SAMR_VERSION, + self.domain, self.username, self.password) + + connect_handle = samr.Connect(pipe) + domain_handle = connect_handle.OpenDomain(args[0]) + + result = domain_handle.EnumDomainAliases() + + for r in result['sam']['entries']: + print r['name']['name'] + + def do_SamrEnumDomainUsers(self, line): + """Return the list of users of a domain designated by its SID.""" + + usage = 'SamrEnumDomainUsers DOMAIN_SID [user_account_flags]' + + parser = OptionParser(usage) + options, args = parser.parse_args(string.split(line)) + + if (len(args) == 0) or (len(args) > 2): + print 'usage:', usage + return + + pipe = dcerpc.pipe_connect( + self.binding, + dcerpc.DCERPC_SAMR_UUID, dcerpc.DCERPC_SAMR_VERSION, + self.domain, self.username, self.password) + + connect_handle = samr.Connect(pipe) + domain_handle = connect_handle.OpenDomain(args[0]) + + if (len(args) == 2): + result = domain_handle.EnumDomainUsers(int(args[1])) + else: + result = domain_handle.EnumDomainUsers() + + for r in result['sam']['entries']: + print r['name']['name'] + if __name__ == '__main__': # Parse command line diff --git a/source4/scripting/swig/samr.py b/source4/scripting/swig/samr.py index 5fd87da3ad..d29b7f6682 100644 --- a/source4/scripting/swig/samr.py +++ b/source4/scripting/swig/samr.py @@ -73,11 +73,10 @@ def string_to_sid(string): string = string[match.end():] - print map(type, sub_auths) - return {'sid_rev_num': sid_rev_num, 'id_auth': id_auth, 'num_auths': num_auths, 'sub_auths': sub_auths} + class SamrHandle: def __init__(self, pipe, handle): @@ -92,6 +91,7 @@ class SamrHandle: dcerpc.samr_Close(self.pipe, r) + class ConnectHandle(SamrHandle): def EnumDomains(self): @@ -139,20 +139,69 @@ class ConnectHandle(SamrHandle): result = dcerpc.samr_OpenDomain(self.pipe, r) - return DomainHandle(pipe, result['domain_handle']) + return DomainHandle(self.pipe, result['domain_handle']) + class DomainHandle(SamrHandle): def QueryDomainInfo(self, level = 2): r = {} - r['domain_handle'] = self.domain_handle + r['domain_handle'] = self.handle r['level'] = level - result = dcerpc.samr_QueryDomainInfo(pipe, r) + result = dcerpc.samr_QueryDomainInfo(self.pipe, r) return result + def QueryDomainInfo2(self, level = 2): + + r = {} + r['domain_handle'] = self.handle + r['level'] = level + + result = dcerpc.samr_QueryDomainInfo2(self.pipe, r) + + return result + + def EnumDomainGroups(self): + + r = {} + r['domain_handle'] = self.handle + r['resume_handle'] = 0 + r['max_size'] = 1000 + + result = dcerpc.samr_EnumDomainGroups(self.pipe, r) + + return result + + def EnumDomainAliases(self): + + r = {} + r['domain_handle'] = self.handle + r['resume_handle'] = 0 + # acct_flags in SamrEnumerateAliasesInDomain has probably + # no meaning so use 0xffffffff like W2K + r['acct_flags'] = 0xffffffff + r['max_size'] = 1000 + + result = dcerpc.samr_EnumDomainAliases(self.pipe, r) + + return result + + def EnumDomainUsers(self, user_account_flags = 16): + + r = {} + r['domain_handle'] = self.handle + r['resume_handle'] = 0 + r['acct_flags'] = user_account_flags + r['max_size'] = 1000 + + result = dcerpc.samr_EnumDomainUsers(self.pipe, r) + + return result + + def Connect(pipe, system_name = None, access_mask = 0x02000000): """Connect to the SAMR pipe.""" -- cgit From e0586efe7abfa427918779042024d7e529f92f49 Mon Sep 17 00:00:00 2001 From: Tim Potter Date: Sun, 7 Nov 2004 22:05:18 +0000 Subject: r3607: EnumDomainAlises doesn't take a max_size parameter. (This used to be commit 996d042bf701860fcc9a9b424118c02addb2119b) --- source4/scripting/swig/samr.py | 1 - 1 file changed, 1 deletion(-) (limited to 'source4/scripting') diff --git a/source4/scripting/swig/samr.py b/source4/scripting/swig/samr.py index d29b7f6682..6295517132 100644 --- a/source4/scripting/swig/samr.py +++ b/source4/scripting/swig/samr.py @@ -183,7 +183,6 @@ class DomainHandle(SamrHandle): # acct_flags in SamrEnumerateAliasesInDomain has probably # no meaning so use 0xffffffff like W2K r['acct_flags'] = 0xffffffff - r['max_size'] = 1000 result = dcerpc.samr_EnumDomainAliases(self.pipe, r) -- cgit From c20a32675237b7e64e7aebbbde79e1994ac5269d Mon Sep 17 00:00:00 2001 From: Tim Potter Date: Fri, 19 Nov 2004 02:57:35 +0000 Subject: r3870: Delete wrappers for tdb_lockkeys() and tdb_unlockkeys(). (This used to be commit 5af52c559e731d55ccd019a2b06f486a2f86e6ce) --- source4/scripting/swig/tdb.i | 2 -- 1 file changed, 2 deletions(-) (limited to 'source4/scripting') diff --git a/source4/scripting/swig/tdb.i b/source4/scripting/swig/tdb.i index 404f498c26..0b169510c1 100644 --- a/source4/scripting/swig/tdb.i +++ b/source4/scripting/swig/tdb.i @@ -136,8 +136,6 @@ TDB_DATA tdb_firstkey(TDB_CONTEXT *tdb); TDB_DATA tdb_nextkey(TDB_CONTEXT *tdb, TDB_DATA key); int tdb_traverse(TDB_CONTEXT *tdb, tdb_traverse_func fn, void *state); int tdb_exists(TDB_CONTEXT *tdb, TDB_DATA key); -int tdb_lockkeys(TDB_CONTEXT *tdb, u32 number, TDB_DATA keys[]); -void tdb_unlockkeys(TDB_CONTEXT *tdb); int tdb_lockall(TDB_CONTEXT *tdb); void tdb_unlockall(TDB_CONTEXT *tdb); -- cgit From 66bd6142a2fc4679e1d6cc98237a23927dda5f63 Mon Sep 17 00:00:00 2001 From: Tim Potter Date: Thu, 6 Jan 2005 02:10:33 +0000 Subject: r4546: Use talloc_p() instad of talloc() (This used to be commit 2ec3a137d7fd8a912bc70e865f7a7798190b8869) --- source4/scripting/swig/dcerpc.i | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'source4/scripting') diff --git a/source4/scripting/swig/dcerpc.i b/source4/scripting/swig/dcerpc.i index 27afb6471c..487876c2fb 100644 --- a/source4/scripting/swig/dcerpc.i +++ b/source4/scripting/swig/dcerpc.i @@ -313,7 +313,7 @@ void DATA_BLOB_ptr_from_python(TALLOC_CTX *mem_ctx, DATA_BLOB **s, return; } - *s = talloc(mem_ctx, sizeof(DATA_BLOB)); + *s = talloc_p(mem_ctx, DATA_BLOB); (*s)->length = PyString_Size(obj); (*s)->data = PyString_AsString(obj); -- cgit From 29589f38950b1ec8e5d984a2e92fef577f26d743 Mon Sep 17 00:00:00 2001 From: Tim Potter Date: Tue, 25 Jan 2005 10:20:24 +0000 Subject: r4981: Fix swig build. (This used to be commit b44ab87c83ad094ce4595c9702d6a21f30c1de26) --- source4/scripting/swig/dcerpc.i | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) (limited to 'source4/scripting') diff --git a/source4/scripting/swig/dcerpc.i b/source4/scripting/swig/dcerpc.i index 487876c2fb..89599367ed 100644 --- a/source4/scripting/swig/dcerpc.i +++ b/source4/scripting/swig/dcerpc.i @@ -368,7 +368,7 @@ PyObject *DATA_BLOB_to_python(DATA_BLOB obj) /* Set REF_ALLOC flag so we don't have to do too much extra mucking around with ref variables in ndr unmarshalling. */ - (*$1)->flags |= DCERPC_NDR_REF_ALLOC; + (*$1)->conn->flags |= DCERPC_NDR_REF_ALLOC; /* Return swig handle on dcerpc_pipe */ @@ -399,14 +399,12 @@ const char *dcerpc_server_name(struct dcerpc_pipe *p); #include "librpc/gen_ndr/ndr_misc.h" #include "librpc/gen_ndr/ndr_lsa.h" #include "librpc/gen_ndr/ndr_samr.h" -#include "librpc/gen_ndr/ndr_winreg.h" #include "librpc/gen_ndr/ndr_spoolss.h" %} %include "librpc/gen_ndr/misc.i" %include "librpc/gen_ndr/lsa.i" %include "librpc/gen_ndr/samr.i" -%include "librpc/gen_ndr/winreg.i" %include "librpc/gen_ndr/spoolss.i" /* The status codes must be included last otherwise the automatically -- cgit From 8fb54d162b449244e5380aa1e00d99b5e23e9443 Mon Sep 17 00:00:00 2001 From: Tim Potter Date: Tue, 25 Jan 2005 11:21:25 +0000 Subject: r4982: Start to move swig dependencies into new build system. Unfortunately I can only get something useful happening by using the BINARY keyword as nothing else seems to generate dependency lists that can be used when linking the swig shared libraries. Anyway this is a lot nicer than having lots of junk in makefile.pm. (This used to be commit 71a22f5206086c5ab7315d38934d65483aff7a70) --- source4/scripting/swig/config.mk | 7 +++++++ source4/scripting/swig/dummymain.c | 9 +++++++++ 2 files changed, 16 insertions(+) create mode 100644 source4/scripting/swig/config.mk create mode 100644 source4/scripting/swig/dummymain.c (limited to 'source4/scripting') diff --git a/source4/scripting/swig/config.mk b/source4/scripting/swig/config.mk new file mode 100644 index 0000000000..8a5b743cac --- /dev/null +++ b/source4/scripting/swig/config.mk @@ -0,0 +1,7 @@ +[BINARY::swig_tdb] +OBJ_FILES = scripting/swig/dummymain.o +REQUIRED_SUBSYSTEMS = LIBTDB + +[BINARY::swig_dcerpc] +OBJ_FILES = scripting/swig/dummymain.o +REQUIRED_SUBSYSTEMS = LIBCLI NDR_MISC LIBBASIC CONFIG RPC_NDR_SAMR diff --git a/source4/scripting/swig/dummymain.c b/source4/scripting/swig/dummymain.c new file mode 100644 index 0000000000..ac39144cd9 --- /dev/null +++ b/source4/scripting/swig/dummymain.c @@ -0,0 +1,9 @@ +/* + * Dummy main function as the build system doesn't seem to create a + * dependency list for a subsystem. + */ + +int main(void) +{ + return 0; +} -- cgit From 5e679708899b1da6a705c5263d8c3aa5c66d95a0 Mon Sep 17 00:00:00 2001 From: Tim Potter Date: Wed, 26 Jan 2005 20:40:59 +0000 Subject: r5016: Use LIBRARY instead of BINARY for inserting the swig stuff into the build system. This still generates bogus targets (i.e bin/swig_dcerpc.so.0.0.1) and the subsystem initialisation needs to be done by hand but it is less of a hack. (This used to be commit e9b69d19a84b31966fb6e66e9d8682b0f9b40a47) --- source4/scripting/swig/config.mk | 12 ++++++++---- source4/scripting/swig/dummymain.c | 9 --------- 2 files changed, 8 insertions(+), 13 deletions(-) delete mode 100644 source4/scripting/swig/dummymain.c (limited to 'source4/scripting') diff --git a/source4/scripting/swig/config.mk b/source4/scripting/swig/config.mk index 8a5b743cac..70dab7c28d 100644 --- a/source4/scripting/swig/config.mk +++ b/source4/scripting/swig/config.mk @@ -1,7 +1,11 @@ -[BINARY::swig_tdb] -OBJ_FILES = scripting/swig/dummymain.o +[LIBRARY::swig_tdb] +MAJOR_VERSION = 0 +MINOR_VERSION = 0 +RELEASE_VERSION = 1 REQUIRED_SUBSYSTEMS = LIBTDB -[BINARY::swig_dcerpc] -OBJ_FILES = scripting/swig/dummymain.o +[LIBRARY::swig_dcerpc] +MAJOR_VERSION = 0 +MINOR_VERSION = 0 +RELEASE_VERSION = 1 REQUIRED_SUBSYSTEMS = LIBCLI NDR_MISC LIBBASIC CONFIG RPC_NDR_SAMR diff --git a/source4/scripting/swig/dummymain.c b/source4/scripting/swig/dummymain.c deleted file mode 100644 index ac39144cd9..0000000000 --- a/source4/scripting/swig/dummymain.c +++ /dev/null @@ -1,9 +0,0 @@ -/* - * Dummy main function as the build system doesn't seem to create a - * dependency list for a subsystem. - */ - -int main(void) -{ - return 0; -} -- cgit From b10b7a360a4bbed8fc7654d9f7c70625a48f3513 Mon Sep 17 00:00:00 2001 From: Tim Potter Date: Wed, 26 Jan 2005 20:41:58 +0000 Subject: r5017: Fix bug in output typemap for uint32 (!) (This used to be commit dc845154ca1738f4c3959a1799cbbd6ce65b7d02) --- source4/scripting/swig/samba.i | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'source4/scripting') diff --git a/source4/scripting/swig/samba.i b/source4/scripting/swig/samba.i index 9d73207705..a989a468b9 100644 --- a/source4/scripting/swig/samba.i +++ b/source4/scripting/swig/samba.i @@ -33,7 +33,7 @@ } %typemap(out) uint32 { - $1 = PyLong_FromLong($input); + $result = PyLong_FromLong($1); } %typemap(out) NTSTATUS { -- cgit From 07b65ce281504bff7ba08ef57e3c15301dbd8255 Mon Sep 17 00:00:00 2001 From: Tim Potter Date: Wed, 26 Jan 2005 20:43:55 +0000 Subject: r5018: Initialise required subsystems (by hand, generated by substituting BINARY for LIBRARY in config.mk). Cut things down to just the samr pipe for the moment. (This used to be commit 95d2a58e5b2cfc30304ca390de7073c214850984) --- source4/scripting/swig/dcerpc.i | 48 ++++++++++++++++++++++++++++++++++------- 1 file changed, 40 insertions(+), 8 deletions(-) (limited to 'source4/scripting') diff --git a/source4/scripting/swig/dcerpc.i b/source4/scripting/swig/dcerpc.i index 89599367ed..041235efef 100644 --- a/source4/scripting/swig/dcerpc.i +++ b/source4/scripting/swig/dcerpc.i @@ -341,6 +341,46 @@ PyObject *DATA_BLOB_to_python(DATA_BLOB obj) werror_exception = PyErr_NewException("_dcerpc.WERROR", NULL, NULL); PyDict_SetItemString(d, "NTSTATUS", ntstatus_exception); PyDict_SetItemString(d, "WERROR", werror_exception); + +/* BINARY swig_dcerpc INIT */ + + extern NTSTATUS dcerpc_misc_init(void); + extern NTSTATUS dcerpc_krb5pac_init(void); + extern NTSTATUS dcerpc_samr_init(void); + extern NTSTATUS dcerpc_dcerpc_init(void); + extern NTSTATUS auth_sam_init(void); + extern NTSTATUS dcerpc_lsa_init(void); + extern NTSTATUS dcerpc_netlogon_init(void); + extern NTSTATUS gensec_init(void); + extern NTSTATUS auth_developer_init(void); + extern NTSTATUS gensec_spnego_init(void); + extern NTSTATUS auth_winbind_init(void); + extern NTSTATUS gensec_gssapi_init(void); + extern NTSTATUS gensec_ntlmssp_init(void); + extern NTSTATUS dcerpc_nbt_init(void); + extern NTSTATUS auth_anonymous_init(void); + extern NTSTATUS gensec_krb5_init(void); + extern NTSTATUS dcerpc_schannel_init(void); + extern NTSTATUS dcerpc_epmapper_init(void); + if (NT_STATUS_IS_ERR(dcerpc_misc_init())) exit(1); + if (NT_STATUS_IS_ERR(dcerpc_krb5pac_init())) exit(1); + if (NT_STATUS_IS_ERR(dcerpc_samr_init())) exit(1); + if (NT_STATUS_IS_ERR(dcerpc_dcerpc_init())) exit(1); + if (NT_STATUS_IS_ERR(auth_sam_init())) exit(1); + if (NT_STATUS_IS_ERR(dcerpc_lsa_init())) exit(1); + if (NT_STATUS_IS_ERR(dcerpc_netlogon_init())) exit(1); + if (NT_STATUS_IS_ERR(gensec_init())) exit(1); + if (NT_STATUS_IS_ERR(auth_developer_init())) exit(1); + if (NT_STATUS_IS_ERR(gensec_spnego_init())) exit(1); + if (NT_STATUS_IS_ERR(auth_winbind_init())) exit(1); + if (NT_STATUS_IS_ERR(gensec_gssapi_init())) exit(1); + if (NT_STATUS_IS_ERR(gensec_ntlmssp_init())) exit(1); + if (NT_STATUS_IS_ERR(dcerpc_nbt_init())) exit(1); + if (NT_STATUS_IS_ERR(auth_anonymous_init())) exit(1); + if (NT_STATUS_IS_ERR(gensec_krb5_init())) exit(1); + if (NT_STATUS_IS_ERR(dcerpc_schannel_init())) exit(1); + if (NT_STATUS_IS_ERR(dcerpc_epmapper_init())) exit(1); + %} %typemap(in, numinputs=0) struct dcerpc_pipe **OUT (struct dcerpc_pipe *temp_dcerpc_pipe) { @@ -402,12 +442,4 @@ const char *dcerpc_server_name(struct dcerpc_pipe *p); #include "librpc/gen_ndr/ndr_spoolss.h" %} -%include "librpc/gen_ndr/misc.i" -%include "librpc/gen_ndr/lsa.i" %include "librpc/gen_ndr/samr.i" -%include "librpc/gen_ndr/spoolss.i" - -/* The status codes must be included last otherwise the automatically - generated .i files get confused. This is kind of yucky. */ - -%include "status_codes.i" -- cgit From d5b8ec7b0e970d37653ea08da573e7145eb638e7 Mon Sep 17 00:00:00 2001 From: Tim Potter Date: Sat, 29 Jan 2005 01:42:09 +0000 Subject: r5074: Remove dead code. (This used to be commit 36b46bb05aeffb2ba708e4653c131cecece01984) --- source4/scripting/swig/dcerpc.i | 266 ---------------------------------------- 1 file changed, 266 deletions(-) (limited to 'source4/scripting') diff --git a/source4/scripting/swig/dcerpc.i b/source4/scripting/swig/dcerpc.i index 041235efef..ecf50079ff 100644 --- a/source4/scripting/swig/dcerpc.i +++ b/source4/scripting/swig/dcerpc.i @@ -58,272 +58,6 @@ void set_werror_exception(int status) PyErr_SetObject(werror_exception, obj); } -/* Conversion functions for scalar types */ - -uint8 uint8_from_python(PyObject *obj, char *name) -{ - if (obj == NULL) { - PyErr_Format(PyExc_ValueError, "Expecting key %s", name); - return 0; - } - - if (!PyInt_Check(obj) && !PyLong_Check(obj)) { - PyErr_Format(PyExc_TypeError, "Expecting int or long value for %s", name); - return 0; - } - - if (PyLong_Check(obj)) - return (uint8)PyLong_AsLong(obj); - else - return (uint8)PyInt_AsLong(obj); -} - -PyObject *uint8_to_python(uint8 obj) -{ - return PyInt_FromLong(obj); -} - -uint16 uint16_from_python(PyObject *obj, char *name) -{ - if (obj == NULL) { - PyErr_Format(PyExc_ValueError, "Expecting key %s", name); - return 0; - } - - if (!PyInt_Check(obj) && !PyLong_Check(obj)) { - PyErr_Format(PyExc_TypeError, "Expecting int or long value for %s", name); - return 0; - } - - if (PyLong_Check(obj)) - return (uint16)PyLong_AsLong(obj); - else - return (uint16)PyInt_AsLong(obj); -} - -PyObject *uint16_to_python(uint16 obj) -{ - return PyInt_FromLong(obj); -} - -uint32 uint32_from_python(PyObject *obj, char *name) -{ - if (obj == NULL) { - PyErr_Format(PyExc_ValueError, "Expecting key %s", name); - return 0; - } - - if (!PyLong_Check(obj) && !PyInt_Check(obj)) { - PyErr_Format(PyExc_TypeError, "Expecting int or long value for %s", name); - return 0; - } - - if (PyLong_Check(obj)) - return (uint32)PyLong_AsUnsignedLongMask(obj); - - return (uint32)PyInt_AsLong(obj); -} - -PyObject *uint32_to_python(uint32 obj) -{ - return PyLong_FromLong(obj); -} - -int64 int64_from_python(PyObject *obj, char *name) -{ - if (obj == NULL) { - PyErr_Format(PyExc_ValueError, "Expecting key %s", name); - return 0; - } - - if (!PyLong_Check(obj) && !PyInt_Check(obj)) { - PyErr_Format(PyExc_TypeError, "Expecting int or long value for %s", name); - return 0; - } - - if (PyLong_Check(obj)) - return (int64)PyLong_AsLongLong(obj); - else - return (int64)PyInt_AsLong(obj); -} - -PyObject *int64_to_python(int64 obj) -{ - return PyLong_FromLongLong(obj); -} - -uint64 uint64_from_python(PyObject *obj, char *name) -{ - if (obj == NULL) { - PyErr_Format(PyExc_ValueError, "Expecting key %s", name); - return 0; - } - - if (!PyLong_Check(obj) && !PyInt_Check(obj)) { - PyErr_Format(PyExc_TypeError, "Expecting int or long value for %s", name); - return 0; - } - - if (PyLong_Check(obj)) - return (uint64)PyLong_AsUnsignedLongLong(obj); - else - return (uint64)PyInt_AsLong(obj); -} - -PyObject *uint64_to_python(uint64 obj) -{ - return PyLong_FromUnsignedLongLong(obj); -} - -NTTIME NTTIME_from_python(PyObject *obj, char *name) -{ - if (obj == NULL) { - PyErr_Format(PyExc_ValueError, "Expecting key %s", name); - return 0; - } - - if (!PyLong_Check(obj) && !PyInt_Check(obj)) { - PyErr_Format(PyExc_TypeError, "Expecting int or long value for %s", name); - return 0; - } - - if (PyLong_Check(obj)) - return (NTTIME)PyLong_AsUnsignedLongLong(obj); - else - return (NTTIME)PyInt_AsUnsignedLongMask(obj); -} - -PyObject *NTTIME_to_python(NTTIME obj) -{ - return PyLong_FromUnsignedLongLong(obj); -} - -time_t time_t_from_python(PyObject *obj, char *name) -{ - if (obj == NULL) { - PyErr_Format(PyExc_ValueError, "Expecting key %s", name); - return 0; - } - - if (!PyLong_Check(obj) && !PyInt_Check(obj)) { - PyErr_Format(PyExc_TypeError, "Expecting int or long value for %s", name); - return 0; - } - - if (PyLong_Check(obj)) - return (time_t)PyLong_AsUnsignedLongLong(obj); - else - return (time_t)PyInt_AsUnsignedLongMask(obj); -} - -PyObject *time_t_to_python(time_t obj) -{ - return PyLong_FromUnsignedLongLong(obj); -} - -HYPER_T HYPER_T_from_python(PyObject *obj, char *name) -{ - if (obj == NULL) { - PyErr_Format(PyExc_ValueError, "Expecting key %s", name); - return 0; - } - - if (!PyLong_Check(obj) && !PyInt_Check(obj)) { - PyErr_Format(PyExc_TypeError, "Expecting int or long value for %s", name); - return 0; - } - - if (PyLong_Check(obj)) - return (HYPER_T)PyLong_AsUnsignedLongLong(obj); - else - return (HYPER_T)PyInt_AsUnsignedLongMask(obj); -} - -PyObject *HYPER_T_to_python(HYPER_T obj) -{ - return PyLong_FromUnsignedLongLong(obj); -} - -/* Conversion functions for types that we don't want generated automatically. - This is mostly security realted stuff in misc.idl */ - -char *string_ptr_from_python(TALLOC_CTX *mem_ctx, PyObject *obj, char *name) -{ - if (obj == NULL) { - PyErr_Format(PyExc_ValueError, "Expecting key %s", name); - return NULL; - } - - if (obj == Py_None) - return NULL; - - if (!PyString_Check(obj)) { - PyErr_Format(PyExc_TypeError, "Expecting string value for %s", name); - return NULL; - } - - return PyString_AsString(obj); -} - -PyObject *string_ptr_to_python(TALLOC_CTX *mem_ctx, char *obj) -{ - if (obj == NULL) { - Py_INCREF(Py_None); - return Py_None; - } - - return PyString_FromString(obj); -} - -#define dom_sid2_ptr_to_python dom_sid_ptr_to_python -#define dom_sid2_ptr_from_python dom_sid_ptr_from_python - -void DATA_BLOB_from_python(TALLOC_CTX *mem_ctx, DATA_BLOB *s, - PyObject *obj, char name) -{ - if (obj == NULL) { - PyErr_Format(PyExc_ValueError, "Expecting key %s", name); - return; - } - - if (!PyString_Check(obj)) { - PyErr_Format(PyExc_TypeError, "Expecting string value for key '%s'", name); - return; - } - - s->length = PyString_Size(obj); - s->data = PyString_AsString(obj); -} - -void DATA_BLOB_ptr_from_python(TALLOC_CTX *mem_ctx, DATA_BLOB **s, - PyObject *obj, char *name) -{ - if (obj == NULL) { - PyErr_Format(PyExc_ValueError, "Expecting key %s", name); - return; - } - - if (obj == Py_None) { - *s = NULL; - return; - } - - if (!PyString_Check(obj)) { - PyErr_Format(PyExc_TypeError, "Expecting string value for key '%s'", name); - return; - } - - *s = talloc_p(mem_ctx, DATA_BLOB); - - (*s)->length = PyString_Size(obj); - (*s)->data = PyString_AsString(obj); -} - -PyObject *DATA_BLOB_to_python(DATA_BLOB obj) -{ - return PyString_FromStringAndSize(obj.data, obj.length); -} - %} %include "samba.i" -- cgit From 7e877072bd7ad52dad43abd85545571d79e7c45c Mon Sep 17 00:00:00 2001 From: Tim Potter Date: Sat, 29 Jan 2005 05:04:23 +0000 Subject: r5094: Use builtin swig types for converting between fixed width integer types. (This used to be commit f2a1b237bcc824bd3e84da69f472ffb3c9055d00) --- source4/scripting/swig/samba.i | 19 ++++++++----------- 1 file changed, 8 insertions(+), 11 deletions(-) (limited to 'source4/scripting') diff --git a/source4/scripting/swig/samba.i b/source4/scripting/swig/samba.i index a989a468b9..6cdf424095 100644 --- a/source4/scripting/swig/samba.i +++ b/source4/scripting/swig/samba.i @@ -24,17 +24,14 @@ Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ -%typemap(in) uint32 { - if (!PyInt_Check($input) && !PyLong_Check($input)) { - PyErr_SetString(PyExc_TypeError, "integer expected"); - return NULL; - } - $1 = (uint32_t)PyLong_AsLong($input); -} - -%typemap(out) uint32 { - $result = PyLong_FromLong($1); -} +%apply unsigned char { uint8_t }; +%apply char { int8_t }; +%apply unsigned int { uint16_t }; +%apply int { int16_t }; +%apply unsigned long { uint32_t }; +%apply long { int32_t }; +%apply unsigned long long { uint64_t }; +%apply long long { int64_t }; %typemap(out) NTSTATUS { $result = PyLong_FromLong(NT_STATUS_V($1)); -- cgit From 5540449f1cd9d9a6efab59f2bf47be4e1487ffc2 Mon Sep 17 00:00:00 2001 From: Tim Potter Date: Sat, 29 Jan 2005 05:05:17 +0000 Subject: r5095: uint32 -> uint32_t %include misc.i to get definition of struct policy_handle Remove #includes we aren't using just now. (This used to be commit e561bc3efa2a5307a3940a32058ca00d5dfc2fc5) --- source4/scripting/swig/dcerpc.i | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) (limited to 'source4/scripting') diff --git a/source4/scripting/swig/dcerpc.i b/source4/scripting/swig/dcerpc.i index ecf50079ff..52cd833508 100644 --- a/source4/scripting/swig/dcerpc.i +++ b/source4/scripting/swig/dcerpc.i @@ -156,7 +156,7 @@ void set_werror_exception(int status) NTSTATUS dcerpc_pipe_connect(struct dcerpc_pipe **OUT, const char *binding, const char *pipe_uuid, - uint32 pipe_version, + uint32_t pipe_version, const char *domain, const char *username, const char *password); @@ -171,9 +171,8 @@ const char *dcerpc_server_name(struct dcerpc_pipe *p); %{ #include "librpc/gen_ndr/ndr_misc.h" -#include "librpc/gen_ndr/ndr_lsa.h" #include "librpc/gen_ndr/ndr_samr.h" -#include "librpc/gen_ndr/ndr_spoolss.h" %} +%include "librpc/gen_ndr/misc.i" %include "librpc/gen_ndr/samr.i" -- cgit From 05db954edd562a4fa064e951051fbc31a210baba Mon Sep 17 00:00:00 2001 From: Tim Potter Date: Fri, 4 Feb 2005 06:35:45 +0000 Subject: r5224: Add in/out typemaps for resume handles. This saves us having to much around with pointers to just one uint32. Add an output typemap to copy a policy handle as the talloc context is destroyed before the wrapper function returns. More work here needed to avoid memory leaks. Use the swig carrays.i file to create accessor and setter functions for fixed width integer types. Also add functions for struct samr_SamEntry as it's returned by the LookupDomain RPC. This really needs to be done by pidl so I don't have to go through and find all the structures that are returned in arrays. Include security.i to give us SIDs and security descriptors. (This used to be commit 5a1f6c999ef5e84e93ec8f07b9751d795c4566a5) --- source4/scripting/swig/dcerpc.i | 39 +++++++++++++++++++++++++++++++++++++++ 1 file changed, 39 insertions(+) (limited to 'source4/scripting') diff --git a/source4/scripting/swig/dcerpc.i b/source4/scripting/swig/dcerpc.i index 52cd833508..53aaf29b1f 100644 --- a/source4/scripting/swig/dcerpc.i +++ b/source4/scripting/swig/dcerpc.i @@ -169,10 +169,49 @@ NTSTATUS dcerpc_pipe_connect(struct dcerpc_pipe **OUT, 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) uint32_t *resume_handle { + $1 = malloc(sizeof(*$1)); + *$1 = PyLong_AsLong($input); +} + +%typemap(out) uint32_t *resume_handle { + $result = PyLong_FromLong(*$1); +} + +/* 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) struct policy_handle * { + 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); +} + %{ #include "librpc/gen_ndr/ndr_misc.h" +#include "librpc/gen_ndr/ndr_security.h" #include "librpc/gen_ndr/ndr_samr.h" %} +%include "carrays.i" + +/* Some functions for accessing arrays of fixed-width integers. */ + +%array_functions(uint8_t, uint8_array); +%array_functions(uint16_t, uint16_array); +%array_functions(uint32_t, uint32_array); + +/* Functions for handling arrays of structures. It would be nice for + pidl to automatically generating these instead of having to find + them all by hand. */ + +%array_functions(struct samr_SamEntry, samr_SamEntry_array); + %include "librpc/gen_ndr/misc.i" +%include "librpc/gen_ndr/security.i" %include "librpc/gen_ndr/samr.i" -- cgit From a36c43bc2161086a229b620a01eb071f05eda878 Mon Sep 17 00:00:00 2001 From: Tim Potter Date: Sun, 6 Feb 2005 00:34:44 +0000 Subject: r5242: Check that argument is an integer or a long for uint32_t input typemap. The uint32_t output typemap must return a Python long as an unsigned uint32_t cannot be fully represented by a Python int. Likewise for the NTSTATUS typemap. (This used to be commit 6dba5d6fb43f87bedc380c4f82b1d5f90b70325a) --- source4/scripting/swig/samba.i | 19 ++++++++++++++++--- 1 file changed, 16 insertions(+), 3 deletions(-) (limited to 'source4/scripting') diff --git a/source4/scripting/swig/samba.i b/source4/scripting/swig/samba.i index 6cdf424095..db48b3c4ba 100644 --- a/source4/scripting/swig/samba.i +++ b/source4/scripting/swig/samba.i @@ -28,11 +28,24 @@ %apply char { int8_t }; %apply unsigned int { uint16_t }; %apply int { int16_t }; -%apply unsigned long { uint32_t }; -%apply long { int32_t }; %apply unsigned long long { uint64_t }; %apply long long { int64_t }; +%typemap(in) uint32_t { + if (PyLong_Check($input)) + $1 = PyLong_AsUnsignedLong($input); + else if (PyInt_Check($input)) + $1 = PyInt_AsLong($input); + else { + PyErr_SetString(PyExc_TypeError,"Expected a long or an int"); + return NULL; + } +} + +%typemap(out) uint32_t { + $result = PyLong_FromUnsignedLong($1); +} + %typemap(out) NTSTATUS { - $result = PyLong_FromLong(NT_STATUS_V($1)); + $result = PyLong_FromUnsignedLong(NT_STATUS_V($1)); } -- cgit From e282b83381d21577a6fe770deb36a570461d8e57 Mon Sep 17 00:00:00 2001 From: Tim Potter Date: Sun, 6 Feb 2005 00:35:58 +0000 Subject: r5243: Woohoo - memory leak city! Comment out talloc_free() call until I figure out a better way to pass tallocated memory around with SWIG. (This used to be commit c63668cbbe393a78ccd9a86a33fb4bd7bb9af16d) --- source4/scripting/swig/dcerpc.i | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'source4/scripting') diff --git a/source4/scripting/swig/dcerpc.i b/source4/scripting/swig/dcerpc.i index 53aaf29b1f..471140c499 100644 --- a/source4/scripting/swig/dcerpc.i +++ b/source4/scripting/swig/dcerpc.i @@ -126,7 +126,7 @@ void set_werror_exception(int status) } %typemap(freearg) TALLOC_CTX * { - talloc_free($1); +// talloc_free($1); } %typemap(argout) struct dcerpc_pipe ** { -- cgit From d8e1c7f0a77fb737ddc1c065681eff1f3449a218 Mon Sep 17 00:00:00 2001 From: Tim Potter Date: Sun, 6 Feb 2005 00:38:10 +0000 Subject: r5244: Convert this module to use the new structure mapping SWIG stuff instead of the old dictionary based routines. The SAMR connect, close, enumdomains, opendomain, enum{users,aliases,groups} functions now work again! (This used to be commit 53b361657fe892ad7b9d781450ad841a6b1072e5) --- source4/scripting/swig/samr.py | 175 ++++++++++++++++++++++++----------------- 1 file changed, 103 insertions(+), 72 deletions(-) (limited to 'source4/scripting') diff --git a/source4/scripting/swig/samr.py b/source4/scripting/swig/samr.py index 6295517132..3c36c9980b 100644 --- a/source4/scripting/swig/samr.py +++ b/source4/scripting/swig/samr.py @@ -3,18 +3,21 @@ import dcerpc def sid_to_string(sid): """Convert a Python dictionary SID to a string SID.""" - result = 'S-%d' % sid['sid_rev_num'] + result = 'S-%d' % sid.sid_rev_num - ia = sid['id_auth'] + result = result + '-%u' % \ + (dcerpc.uint8_array_getitem(sid.id_auth, 5) + + (dcerpc.uint8_array_getitem(sid.id_auth, 4) << 8) + + (dcerpc.uint8_array_getitem(sid.id_auth, 3) << 16) + + (dcerpc.uint8_array_getitem(sid.id_auth, 2) << 24)) - result = result + '-%u' % (ia[5] + (ia[4] << 8) + (ia[3] << 16) + \ - (ia[2] << 24)) - - for i in range(0, sid['num_auths']): - result = result + '-%u' % sid['sub_auths'][i] + for i in range(0, sid.num_auths): + result = result + '-%u' % \ + dcerpc.uint32_array_getitem(sid.sub_auths, i) return result + def string_to_sid(string): """Convert a string SID to a Python dictionary SID. Throws a ValueError if the SID string was badly formed.""" @@ -72,9 +75,18 @@ def string_to_sid(string): sub_auths.append(int(sa)) string = string[match.end():] - - return {'sid_rev_num': sid_rev_num, 'id_auth': id_auth, - 'num_auths': num_auths, 'sub_auths': sub_auths} + + sid = dcerpc.dom_sid() + sid.sid_rev_num = sid_rev_num + sid.id_auth = dcerpc.new_uint8_array(6) + for i in range(6): + dcerpc.uint8_array_setitem(sid.id_auth, i, id_auth[i]) + sid.num_auths = num_auths + sid.sub_auths = dcerpc.new_uint32_array(num_auths) + for i in range(num_auths): + dcerpc.uint32_array_setitem(sid.sub_auths, i, sub_auths[i]) + + return sid class SamrHandle: @@ -86,128 +98,147 @@ class SamrHandle: def __del__(self): - r = {} - r['handle'] = self.handle + r = dcerpc.samr_Close() + r.data_in.handle = self.handle - dcerpc.samr_Close(self.pipe, r) + dcerpc.dcerpc_samr_Close(self.pipe, r) class ConnectHandle(SamrHandle): def EnumDomains(self): - r = {} - r['connect_handle'] = self.handle - r['resume_handle'] = 0 - r['buf_size'] = -1 + r = dcerpc.samr_EnumDomains() + r.data_in.connect_handle = self.handle + r.data_in.resume_handle = 1 + r.data_in.buf_size = -1 domains = [] while 1: - result = dcerpc.samr_EnumDomains(self.pipe, r) + result = dcerpc.dcerpc_samr_EnumDomains(self.pipe, r) - domains = domains + result['sam']['entries'] + for i in range(r.data_out.sam.count): + domains.append(dcerpc.samr_SamEntry_array_getitem( + r.data_out.sam.entries, i).name.string) - if result['result'] == dcerpc.STATUS_MORE_ENTRIES: - r['resume_handle'] = result['resume_handle'] - continue + # TODO: Handle more entries here break - return map(lambda x: x['name']['name'], domains) + return domains def LookupDomain(self, domain_name): - r = {} - r['connect_handle'] = self.handle - r['domain'] = {} - r['domain']['name_len'] = 0 - r['domain']['name_size'] = 0 - r['domain']['name'] = domain_name + r = dcerpc.samr_LookupDomain() + r.data_in.connect_handle = self.handle + r.data_in.domain = dcerpc.samr_String() + r.data_in.domain.string = domain_name - result = dcerpc.samr_LookupDomain(self.pipe, r) + result = dcerpc.dcerpc_samr_LookupDomain(self.pipe, r) - return sid_to_string(result['sid']) + return sid_to_string(r.data_out.sid); def OpenDomain(self, domain_sid, access_mask = 0x02000000): - r = {} - r['connect_handle'] = self.handle - r['access_mask'] = access_mask - r['sid'] = string_to_sid(domain_sid) + r = dcerpc.samr_OpenDomain() + r.data_in.connect_handle = self.handle + r.data_in.access_mask = access_mask + r.data_in.sid = string_to_sid(domain_sid) - result = dcerpc.samr_OpenDomain(self.pipe, r) + result = dcerpc.dcerpc_samr_OpenDomain(self.pipe, r) - return DomainHandle(self.pipe, result['domain_handle']) + return DomainHandle(self.pipe, r.data_out.domain_handle) class DomainHandle(SamrHandle): def QueryDomainInfo(self, level = 2): - r = {} - r['domain_handle'] = self.handle - r['level'] = level + r = dcerpc.samr_QueryDomainInfo() + r.data_in.domain_handle = self.handle + r.data_in.level = level - result = dcerpc.samr_QueryDomainInfo(self.pipe, r) + result = dcerpc.dcerpc_samr_QueryDomainInfo(self.pipe, r) - return result + return getattr(r.data_out.info, 'info%d' % level) def QueryDomainInfo2(self, level = 2): - r = {} - r['domain_handle'] = self.handle - r['level'] = level + r = dcerpc.samr_QueryDomainInfo2() + r.data_in.domain_handle = self.handle + r.data_in.level = level - result = dcerpc.samr_QueryDomainInfo2(self.pipe, r) + result = dcerpc.dcerpc_samr_QueryDomainInfo2(self.pipe, r) - return result + return getattr(r.data_out.info, 'info%d' % level) def EnumDomainGroups(self): - r = {} - r['domain_handle'] = self.handle - r['resume_handle'] = 0 - r['max_size'] = 1000 + r = dcerpc.samr_EnumDomainGroups() + r.data_in.domain_handle = self.handle + r.data_in.resume_handle = 0 + r.data_in.max_size = 1000 + + result = dcerpc.dcerpc_samr_EnumDomainGroups(self.pipe, r) - result = dcerpc.samr_EnumDomainGroups(self.pipe, r) + groups = [] - return result + if r.data_out.sam.entries: + for i in range(r.data_out.sam.count): + groups.append(dcerpc.samr_SamEntry_array_getitem( + r.data_out.sam.entries, i).name.string) + + return groups def EnumDomainAliases(self): - r = {} - r['domain_handle'] = self.handle - r['resume_handle'] = 0 + r = dcerpc.samr_EnumDomainAliases() + r.data_in.domain_handle = self.handle + r.data_in.resume_handle = 0 # acct_flags in SamrEnumerateAliasesInDomain has probably # no meaning so use 0xffffffff like W2K - r['acct_flags'] = 0xffffffff + r.data_in.acct_flags = 0xffffffffL + + result = dcerpc.dcerpc_samr_EnumDomainAliases(self.pipe, r) + + aliases = [] - result = dcerpc.samr_EnumDomainAliases(self.pipe, r) + if r.data_out.sam.entries: + for i in range(r.data_out.sam.count): + aliases.append(dcerpc.samr_SamEntry_array_getitem( + r.data_out.sam.entries, i).name.string) - return result + return aliases def EnumDomainUsers(self, user_account_flags = 16): - r = {} - r['domain_handle'] = self.handle - r['resume_handle'] = 0 - r['acct_flags'] = user_account_flags - r['max_size'] = 1000 + r = dcerpc.samr_EnumDomainUsers() + r.data_in.domain_handle = self.handle + r.data_in.resume_handle = 0 + r.data_in.acct_flags = user_account_flags + r.data_in.max_size = 1000 + + result = dcerpc.dcerpc_samr_EnumDomainUsers(self.pipe, r) + + users = [] - result = dcerpc.samr_EnumDomainUsers(self.pipe, r) + if r.data_out.sam.entries: + for i in range(r.data_out.sam.count): + users.append(dcerpc.samr_SamEntry_array_getitem( + r.data_out.sam.entries, i).name.string) - return result + return users -def Connect(pipe, system_name = None, access_mask = 0x02000000): +def Connect(pipe, system_name = '', access_mask = 0x02000000): """Connect to the SAMR pipe.""" - r = {} - r['system_name'] = system_name - r['access_mask'] = access_mask + r = dcerpc.samr_Connect2() + r.data_in.system_name = system_name + r.data_in.access_mask = access_mask - result = dcerpc.samr_Connect2(pipe, r) + result = dcerpc.dcerpc_samr_Connect2(pipe, r) - return ConnectHandle(pipe, result['connect_handle']) + return ConnectHandle(pipe, r.data_out.connect_handle) -- cgit From 7411bf6775e317a0395178ea829f0db70c942ebb Mon Sep 17 00:00:00 2001 From: Tim Potter Date: Sun, 6 Feb 2005 04:34:29 +0000 Subject: r5247: Fix rpcclient to work with new swig interface. (This used to be commit ad12a90d0e0fe7106b1845097d8fc71be3b8e378) --- source4/scripting/swig/rpcclient | 52 ++++++++++++++++++++++++++-------------- 1 file changed, 34 insertions(+), 18 deletions(-) (limited to 'source4/scripting') diff --git a/source4/scripting/swig/rpcclient b/source4/scripting/swig/rpcclient index aad4597053..8f33a6133b 100755 --- a/source4/scripting/swig/rpcclient +++ b/source4/scripting/swig/rpcclient @@ -7,6 +7,23 @@ from pprint import pprint import dcerpc, samr +def swig2dict(obj): + """Convert a swig object to a dictionary.""" + + result = {} + + for attr in filter(lambda x: type(x) == str, dir(obj)): + + if attr[:2] == '__' and attr[-2:] == '__': + continue + + if attr == 'this' or attr == 'thisown': + continue + + result[attr] = getattr(obj, attr) + + return result + class rpcclient(Cmd): prompt = 'rpcclient$ ' @@ -67,7 +84,7 @@ class rpcclient(Cmd): pipe = dcerpc.pipe_connect( self.binding, - dcerpc.DCERPC_SAMR_UUID, dcerpc.DCERPC_SAMR_VERSION, + dcerpc.DCERPC_SAMR_UUID, int(dcerpc.DCERPC_SAMR_VERSION), self.domain, self.username, self.password) connect_handle = samr.Connect(pipe) @@ -89,7 +106,7 @@ class rpcclient(Cmd): pipe = dcerpc.pipe_connect( self.binding, - dcerpc.DCERPC_SAMR_UUID, dcerpc.DCERPC_SAMR_VERSION, + dcerpc.DCERPC_SAMR_UUID, int(dcerpc.DCERPC_SAMR_VERSION), self.domain, self.username, self.password) connect_handle = samr.Connect(pipe) @@ -110,7 +127,7 @@ class rpcclient(Cmd): pipe = dcerpc.pipe_connect( self.binding, - dcerpc.DCERPC_SAMR_UUID, dcerpc.DCERPC_SAMR_VERSION, + dcerpc.DCERPC_SAMR_UUID, int(dcerpc.DCERPC_SAMR_VERSION), self.domain, self.username, self.password) connect_handle = samr.Connect(pipe) @@ -121,22 +138,23 @@ class rpcclient(Cmd): else: result = domain_handle.QueryDomainInfo() - pprint(result['info']) + pprint(swig2dict(result)) def do_SamrQueryDomInfo2(self, line): - """Return information about a domain designated by its SID. (Windows 2000 and >)""" + """Return information about a domain designated by its SID. + (Windows 2000 and >)""" usage = 'SamrQueryDomInfo2 DOMAIN_SID [info_level] (Windows 2000 and >)' parser = OptionParser(usage) options, args = parser.parse_args(string.split(line)) - if (len(args) == 0) or (len(args) > 2): + if len(args) == 0 or len(args) > 2: print 'usage:', usage return pipe = dcerpc.pipe_connect( self.binding, - dcerpc.DCERPC_SAMR_UUID, dcerpc.DCERPC_SAMR_VERSION, + dcerpc.DCERPC_SAMR_UUID, int(dcerpc.DCERPC_SAMR_VERSION), self.domain, self.username, self.password) connect_handle = samr.Connect(pipe) @@ -147,7 +165,7 @@ class rpcclient(Cmd): else: result = domain_handle.QueryDomainInfo2() - pprint(result['info']) + pprint(swig2dict(result)) def do_SamrEnumDomainGroups(self, line): """Return the list of groups of a domain designated by its SID.""" @@ -163,7 +181,7 @@ class rpcclient(Cmd): pipe = dcerpc.pipe_connect( self.binding, - dcerpc.DCERPC_SAMR_UUID, dcerpc.DCERPC_SAMR_VERSION, + dcerpc.DCERPC_SAMR_UUID, int(dcerpc.DCERPC_SAMR_VERSION), self.domain, self.username, self.password) connect_handle = samr.Connect(pipe) @@ -171,11 +189,11 @@ class rpcclient(Cmd): result = domain_handle.EnumDomainGroups() - for r in result['sam']['entries']: - print r['name']['name'] + pprint(result) def do_SamrEnumDomainAliases(self, line): - """Return the list of aliases (local groups) of a domain designated by its SID.""" + """Return the list of aliases (local groups) of a domain designated + by its SID.""" usage = 'SamrEnumDomainAliases DOMAIN_SID' @@ -188,7 +206,7 @@ class rpcclient(Cmd): pipe = dcerpc.pipe_connect( self.binding, - dcerpc.DCERPC_SAMR_UUID, dcerpc.DCERPC_SAMR_VERSION, + dcerpc.DCERPC_SAMR_UUID, int(dcerpc.DCERPC_SAMR_VERSION), self.domain, self.username, self.password) connect_handle = samr.Connect(pipe) @@ -196,8 +214,7 @@ class rpcclient(Cmd): result = domain_handle.EnumDomainAliases() - for r in result['sam']['entries']: - print r['name']['name'] + pprint(result) def do_SamrEnumDomainUsers(self, line): """Return the list of users of a domain designated by its SID.""" @@ -213,7 +230,7 @@ class rpcclient(Cmd): pipe = dcerpc.pipe_connect( self.binding, - dcerpc.DCERPC_SAMR_UUID, dcerpc.DCERPC_SAMR_VERSION, + dcerpc.DCERPC_SAMR_UUID, int(dcerpc.DCERPC_SAMR_VERSION), self.domain, self.username, self.password) connect_handle = samr.Connect(pipe) @@ -224,8 +241,7 @@ class rpcclient(Cmd): else: result = domain_handle.EnumDomainUsers() - for r in result['sam']['entries']: - print r['name']['name'] + pprint(result) if __name__ == '__main__': -- cgit From 57f69e6f37949636ae14c646517792fa40c9c75b Mon Sep 17 00:00:00 2001 From: Tim Potter Date: Thu, 10 Feb 2005 03:19:21 +0000 Subject: r5293: Map an empty policy handle to None when creating policy handles, and refuse to accept None as a policy handle when accepting them. Now we don't segfault after running the samr_Shutdown() test. (This used to be commit 2f0419c4d8100864ddddf5629d1808b655da9d76) --- source4/scripting/swig/dcerpc.i | 23 ++++++++++++++++++++--- 1 file changed, 20 insertions(+), 3 deletions(-) (limited to 'source4/scripting') diff --git a/source4/scripting/swig/dcerpc.i b/source4/scripting/swig/dcerpc.i index 471140c499..3d9d076e58 100644 --- a/source4/scripting/swig/dcerpc.i +++ b/source4/scripting/swig/dcerpc.i @@ -182,14 +182,31 @@ const char *dcerpc_server_name(struct dcerpc_pipe *p); $result = PyLong_FromLong(*$1); } +%typemap(in) 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) struct policy_handle * { - 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); + 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; + } } %{ -- cgit From 4180eedd6d8a926d7a2f25b14b7a2cad084b44a9 Mon Sep 17 00:00:00 2001 From: Tim Potter Date: Fri, 11 Feb 2005 11:18:19 +0000 Subject: r5335: Add a Close() method to SamrHandle object. Add methods for {Query,Set}Security, Shutdown, CreateUser, Open{User,Group,Alias} and RidToSid. Time for a torture test I think! (This used to be commit 94a3ff2380071efccf19ca51488753d3513ab63c) --- source4/scripting/swig/samr.py | 149 ++++++++++++++++++++++++++++++++++++++++- 1 file changed, 148 insertions(+), 1 deletion(-) (limited to 'source4/scripting') diff --git a/source4/scripting/swig/samr.py b/source4/scripting/swig/samr.py index 3c36c9980b..ae3f9c77f1 100644 --- a/source4/scripting/swig/samr.py +++ b/source4/scripting/swig/samr.py @@ -98,11 +98,34 @@ class SamrHandle: def __del__(self): + if self.handle is not None: + self.Close() + + def Close(self): + r = dcerpc.samr_Close() r.data_in.handle = self.handle dcerpc.dcerpc_samr_Close(self.pipe, r) + self.handle = None + + def QuerySecurity(self, sec_info = 7): + + r = dcerpc.samr_QuerySecurity() + r.data_in.handle = self.handle + r.data_in.sec_info = sec_info + + result = dcerpc.dcerpc_samr_QuerySecurity(self.pipe, r) + + return r.data_out.sdbuf.sd + + def SetSecurity(self, sec_info = 7): + + r = dcerpc.samr_SetSecurity() + r.data_in.handle = self.handle + r.data_in.sec_info = sec_info + class ConnectHandle(SamrHandle): @@ -151,6 +174,13 @@ class ConnectHandle(SamrHandle): return DomainHandle(self.pipe, r.data_out.domain_handle) + def Shutdown(self): + + r = dcerpc.samr_Shutdown() + r.data_in.connect_handle = self.handle + + result = dcerpc.dcerpc_samr_Shutdown(self.pipe, r) + class DomainHandle(SamrHandle): @@ -231,8 +261,75 @@ class DomainHandle(SamrHandle): return users + def CreateUser(self, account_name, access_mask = 0x02000000): + + r = dcerpc.samr_CreateUser() + r.data_in.domain_handle = self.handle + r.data_in.account_name = dcerpc.samr_String() + r.data_in.account_name.string = account_name + r.data_in.access_mask = access_mask + + result = dcerpc.dcerpc_samr_CreateUser(self.pipe, r) + + return (r.data_out.user_handle, + dcerpc.uint32_array_getitem(r.data_out.rid, 0)) + + def OpenUser(self, rid, access_mask = 0x02000000): + + r = dcerpc.samr_OpenUser() + r.data_in.domain_handle = self.handle + r.data_in.access_mask = access_mask + r.data_in.rid = rid + + result = dcerpc.dcerpc_samr_OpenUser(self.pipe, r) + + return UserHandle(pipe, r.data_out.user_handle) + + def OpenGroup(self, rid, access_mask = 0x02000000): -def Connect(pipe, system_name = '', access_mask = 0x02000000): + r = dcerpc.samr_OpenGroup() + r.data_in.domain_handle = self.handle + r.data_in.access_mask = access_mask + r.data_in.rid = rid + + result = dcerpc.dcerpc_samr_OpenGroup(self.pipe, r) + + return GroupHandle(pipe, r.data_out.group_handle) + + def OpenAlias(self, rid, access_mask = 0x02000000): + + r = dcerpc.samr_OpenAlias() + r.data_in.domain_handle = self.handle + r.data_in.access_mask = access_mask + r.data_in.rid = rid + + result = dcerpc.dcerpc_samr_OpenAlias(self.pipe, r) + + return AliasHandle(pipe, r.data_out.group_handle) + + def RidToSid(self, rid): + + r = dcerpc.samr_RidToSid() + r.data_in.domain_handle = self.handle + + result = dcerpc.dcerpc_samr_RidToSid(self.pipe, r) + + return sid_to_string(r.data_out.sid) + + +class UserHandle(SamrHandle): + pass + + +class GroupHandle(SamrHandle): + pass + + +class AliasHandle(SamrHandle): + pass + + +def Connect2(pipe, system_name = '', access_mask = 0x02000000): """Connect to the SAMR pipe.""" r = dcerpc.samr_Connect2() @@ -242,3 +339,53 @@ def Connect(pipe, system_name = '', access_mask = 0x02000000): result = dcerpc.dcerpc_samr_Connect2(pipe, r) return ConnectHandle(pipe, r.data_out.connect_handle) + +# CreateDomainGroup +# CreateDomAlias +# GetAliasMembership +# LookupNames +# QueryGroupInfo +# SetGroupInfo +# AddGroupMember +# DeleteDomainGroup +# DeleteGroupMember +# QueryGroupMember +# SetMemberAttributesofGroup +# QueryAliasInfo +# SetAliasInfo +# DeleteDomAlias +# AddAliasMember +# DeleteAliasMember +# GetMembersinAlias +# DeleteUser +# QueryUserInfo +# SetUserInfo +# ChangePasswordUser +# GetGroupsForUser +# QueryDisplayInfo +# GetDisplayEnumerationIndex +# TestPrivateFunctionsDomain +# TestPrivateFunctionsUser +# GetUserPwInfo +# RemoveMemberFromForeignDomain +# QueryDomainInfo2 +# QueryUserInfo2 +# QueryDisplayInfo2 +# GetDisplayEnumerationIndex2 +# CreateUser2 +# QueryDisplayInfo3 +# AddMultipleMembersToAlias +# RemoveMultipleMembersFromAlias +# OemChangePasswordUser2 +# ChangePasswordUser2 +# GetDomPwInfo +# Connect +# SetUserInfo2 +# SetBootKeyInformation +# GetBootKeyInformation +# Connect3 +# Connect4 +# ChangePasswordUser3 +# Connect5 +# SetDsrmPassword +# ValidatePassword -- cgit From 8cd9d7095bb431d78ed146f1e03a6a036cf66249 Mon Sep 17 00:00:00 2001 From: Tim Potter Date: Sat, 12 Feb 2005 00:40:00 +0000 Subject: r5348: Implement the remaining samr connect functions and fix up setsecurity. (This used to be commit 4b2c3c7ac56e1e428dec6205e4e69268be84cac6) --- source4/scripting/swig/samr.py | 59 +++++++++++++++++++++++++++++++++++++----- 1 file changed, 53 insertions(+), 6 deletions(-) (limited to 'source4/scripting') diff --git a/source4/scripting/swig/samr.py b/source4/scripting/swig/samr.py index ae3f9c77f1..7f82babee3 100644 --- a/source4/scripting/swig/samr.py +++ b/source4/scripting/swig/samr.py @@ -118,15 +118,18 @@ class SamrHandle: result = dcerpc.dcerpc_samr_QuerySecurity(self.pipe, r) - return r.data_out.sdbuf.sd + return r.data_out.sdbuf - def SetSecurity(self, sec_info = 7): + def SetSecurity(self, sdbuf, sec_info = 7): r = dcerpc.samr_SetSecurity() r.data_in.handle = self.handle r.data_in.sec_info = sec_info + r.data_in.sdbuf = sdbuf + result = dcerpc.dcerpc_samr_SetSecurity(self.pipe, r) + class ConnectHandle(SamrHandle): def EnumDomains(self): @@ -329,6 +332,17 @@ class AliasHandle(SamrHandle): pass +def Connect(pipe, access_mask = 0x02000000): + + r = dcerpc.samr_Connect() + r.data_in.system_name = dcerpc.new_uint16_array(1) + dcerpc.uint16_array_setitem(r.data_in.system_name, 0, ord('\\')) + r.data_in.access_mask = access_mask + + result = dcerpc.dcerpc_samr_Connect(pipe, r) + + return ConnectHandle(pipe, r.data_out.connect_handle) + def Connect2(pipe, system_name = '', access_mask = 0x02000000): """Connect to the SAMR pipe.""" @@ -340,6 +354,43 @@ def Connect2(pipe, system_name = '', access_mask = 0x02000000): return ConnectHandle(pipe, r.data_out.connect_handle) +def Connect3(pipe, system_name = '', access_mask = 0x02000000): + + r = dcerpc.samr_Connect3() + r.data_in.system_name = system_name + r.data_in.unknown = 0 + r.data_in.access_mask = access_mask + + result = dcerpc.dcerpc_samr_Connect3(pipe, r) + + return ConnectHandle(pipe, r.data_out.connect_handle) + +def Connect4(pipe, system_name = '', access_mask = 0x02000000): + + r = dcerpc.samr_Connect4() + r.data_in.system_name = system_name + r.data_in.unknown = 0 + r.data_in.access_mask = access_mask + + result = dcerpc.dcerpc_samr_Connect4(pipe, r) + + return ConnectHandle(pipe, r.data_out.connect_handle) + +def Connect5(pipe, system_name = '', access_mask = 0x02000000): + + r = dcerpc.samr_Connect5() + r.data_in.system_name = system_name + r.data_in.access_mask = access_mask + r.data_in.level = 1 + r.data_in.info = dcerpc.new_samr_ConnectInfo_array(1) + r.data_in.info.unknown1 = 0 + r.data_in.info.unknown2 = 0 + + result = dcerpc.dcerpc_samr_Connect5(pipe, r) + + return ConnectHandle(pipe, r.data_out.connect_handle) + + # CreateDomainGroup # CreateDomAlias # GetAliasMembership @@ -379,13 +430,9 @@ def Connect2(pipe, system_name = '', access_mask = 0x02000000): # OemChangePasswordUser2 # ChangePasswordUser2 # GetDomPwInfo -# Connect # SetUserInfo2 # SetBootKeyInformation # GetBootKeyInformation -# Connect3 -# Connect4 # ChangePasswordUser3 -# Connect5 # SetDsrmPassword # ValidatePassword -- cgit From 55006da0436b108f9f56b8736e58eee2777bd361 Mon Sep 17 00:00:00 2001 From: Tim Potter Date: Sat, 12 Feb 2005 00:53:32 +0000 Subject: r5350: Implement an input typemap for NTSTATUS. (This used to be commit 076ec6008e4dbd130044893f34c3fd7212bf667d) --- source4/scripting/swig/samba.i | 11 +++++++++++ 1 file changed, 11 insertions(+) (limited to 'source4/scripting') diff --git a/source4/scripting/swig/samba.i b/source4/scripting/swig/samba.i index db48b3c4ba..c7b8b46e66 100644 --- a/source4/scripting/swig/samba.i +++ b/source4/scripting/swig/samba.i @@ -46,6 +46,17 @@ $result = PyLong_FromUnsignedLong($1); } +%typemap(in) NTSTATUS { + if (PyLong_Check($input)) + $1 = NT_STATUS(PyLong_AsUnsignedLong($input)); + else if (PyInt_Check($input)) + $1 = NT_STATUS(PyInt_AsLong($input)); + else { + PyErr_SetString(PyExc_TypeError, "Expected a long or an int"); + return NULL; + } +} + %typemap(out) NTSTATUS { $result = PyLong_FromUnsignedLong(NT_STATUS_V($1)); } -- cgit From 49568fab37d3a8fc3727ec5972cecdaf35e904b5 Mon Sep 17 00:00:00 2001 From: Tim Potter Date: Sat, 12 Feb 2005 00:54:11 +0000 Subject: r5351: Add wrapper for nt_errstr and array functions for samr_ConnectInfo. (This used to be commit be37749ac7d128fcabf82bad104d87098e2d9f55) --- source4/scripting/swig/dcerpc.i | 3 +++ 1 file changed, 3 insertions(+) (limited to 'source4/scripting') diff --git a/source4/scripting/swig/dcerpc.i b/source4/scripting/swig/dcerpc.i index 3d9d076e58..a1261f997d 100644 --- a/source4/scripting/swig/dcerpc.i +++ b/source4/scripting/swig/dcerpc.i @@ -169,6 +169,8 @@ NTSTATUS dcerpc_pipe_connect(struct dcerpc_pipe **OUT, const char *dcerpc_server_name(struct dcerpc_pipe *p); +char *nt_errstr(NTSTATUS nt_code); + /* 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. */ @@ -228,6 +230,7 @@ const char *dcerpc_server_name(struct dcerpc_pipe *p); them all by hand. */ %array_functions(struct samr_SamEntry, samr_SamEntry_array); +%array_functions(union samr_ConnectInfo, samr_ConnectInfo_array); %include "librpc/gen_ndr/misc.i" %include "librpc/gen_ndr/security.i" -- cgit From 12ccb3c453626181dcdae6ae52abf9aeb2eb8855 Mon Sep 17 00:00:00 2001 From: Tim Potter Date: Sat, 12 Feb 2005 01:05:16 +0000 Subject: r5353: Throw a NTSTATUS exception if a NT error code is returned. (This used to be commit 4a9677833167b3b26117ab1b4e7c682d9524a206) --- source4/scripting/swig/samr.py | 54 +++++++++++++++++++++++++----------------- 1 file changed, 32 insertions(+), 22 deletions(-) (limited to 'source4/scripting') diff --git a/source4/scripting/swig/samr.py b/source4/scripting/swig/samr.py index 7f82babee3..951ca30aa3 100644 --- a/source4/scripting/swig/samr.py +++ b/source4/scripting/swig/samr.py @@ -89,6 +89,16 @@ def string_to_sid(string): return sid +def call_fn(fn, pipe, args): + """Wrap up a RPC call and throw an exception is an error was returned.""" + + result = fn(pipe, args); + if result & 0xc0000000: + raise dcerpc.NTSTATUS(result, dcerpc.nt_errstr(result)); + + return result; + + class SamrHandle: def __init__(self, pipe, handle): @@ -106,7 +116,7 @@ class SamrHandle: r = dcerpc.samr_Close() r.data_in.handle = self.handle - dcerpc.dcerpc_samr_Close(self.pipe, r) + call_fn(dcerpc.dcerpc_samr_Close, self.pipe, r) self.handle = None @@ -116,7 +126,7 @@ class SamrHandle: r.data_in.handle = self.handle r.data_in.sec_info = sec_info - result = dcerpc.dcerpc_samr_QuerySecurity(self.pipe, r) + call_fn(dcerpc.dcerpc_samr_QuerySecurity, self.pipe, r) return r.data_out.sdbuf @@ -127,7 +137,7 @@ class SamrHandle: r.data_in.sec_info = sec_info r.data_in.sdbuf = sdbuf - result = dcerpc.dcerpc_samr_SetSecurity(self.pipe, r) + call_fn(dcerpc.dcerpc_samr_SetSecurity, self.pipe, r) class ConnectHandle(SamrHandle): @@ -143,7 +153,7 @@ class ConnectHandle(SamrHandle): while 1: - result = dcerpc.dcerpc_samr_EnumDomains(self.pipe, r) + call_fn(dcerpc.dcerpc_samr_EnumDomains, self.pipe, r) for i in range(r.data_out.sam.count): domains.append(dcerpc.samr_SamEntry_array_getitem( @@ -162,7 +172,7 @@ class ConnectHandle(SamrHandle): r.data_in.domain = dcerpc.samr_String() r.data_in.domain.string = domain_name - result = dcerpc.dcerpc_samr_LookupDomain(self.pipe, r) + call_fn(dcerpc.dcerpc_samr_LookupDomain, self.pipe, r) return sid_to_string(r.data_out.sid); @@ -173,7 +183,7 @@ class ConnectHandle(SamrHandle): r.data_in.access_mask = access_mask r.data_in.sid = string_to_sid(domain_sid) - result = dcerpc.dcerpc_samr_OpenDomain(self.pipe, r) + call_fn(dcerpc.dcerpc_samr_OpenDomain, self.pipe, r) return DomainHandle(self.pipe, r.data_out.domain_handle) @@ -182,7 +192,7 @@ class ConnectHandle(SamrHandle): r = dcerpc.samr_Shutdown() r.data_in.connect_handle = self.handle - result = dcerpc.dcerpc_samr_Shutdown(self.pipe, r) + call_fn(dcerpc.dcerpc_samr_Shutdown, self.pipe, r) class DomainHandle(SamrHandle): @@ -193,7 +203,7 @@ class DomainHandle(SamrHandle): r.data_in.domain_handle = self.handle r.data_in.level = level - result = dcerpc.dcerpc_samr_QueryDomainInfo(self.pipe, r) + call_fn(dcerpc.dcerpc_samr_QueryDomainInfo, self.pipe, r) return getattr(r.data_out.info, 'info%d' % level) @@ -203,7 +213,7 @@ class DomainHandle(SamrHandle): r.data_in.domain_handle = self.handle r.data_in.level = level - result = dcerpc.dcerpc_samr_QueryDomainInfo2(self.pipe, r) + call_fn(dcerpc.dcerpc_samr_QueryDomainInfo2, self.pipe, r) return getattr(r.data_out.info, 'info%d' % level) @@ -214,7 +224,7 @@ class DomainHandle(SamrHandle): r.data_in.resume_handle = 0 r.data_in.max_size = 1000 - result = dcerpc.dcerpc_samr_EnumDomainGroups(self.pipe, r) + call_fn(dcerpc.dcerpc_samr_EnumDomainGroups, self.pipe, r) groups = [] @@ -234,7 +244,7 @@ class DomainHandle(SamrHandle): # no meaning so use 0xffffffff like W2K r.data_in.acct_flags = 0xffffffffL - result = dcerpc.dcerpc_samr_EnumDomainAliases(self.pipe, r) + call_fn(dcerpc.dcerpc_samr_EnumDomainAliases, self.pipe, r) aliases = [] @@ -253,7 +263,7 @@ class DomainHandle(SamrHandle): r.data_in.acct_flags = user_account_flags r.data_in.max_size = 1000 - result = dcerpc.dcerpc_samr_EnumDomainUsers(self.pipe, r) + call_fn(dcerpc.dcerpc_samr_EnumDomainUsers, self.pipe, r) users = [] @@ -272,7 +282,7 @@ class DomainHandle(SamrHandle): r.data_in.account_name.string = account_name r.data_in.access_mask = access_mask - result = dcerpc.dcerpc_samr_CreateUser(self.pipe, r) + call_fn(dcerpc.dcerpc_samr_CreateUser, self.pipe, r) return (r.data_out.user_handle, dcerpc.uint32_array_getitem(r.data_out.rid, 0)) @@ -284,7 +294,7 @@ class DomainHandle(SamrHandle): r.data_in.access_mask = access_mask r.data_in.rid = rid - result = dcerpc.dcerpc_samr_OpenUser(self.pipe, r) + call_fn(dcerpc.dcerpc_samr_OpenUser, self.pipe, r) return UserHandle(pipe, r.data_out.user_handle) @@ -295,7 +305,7 @@ class DomainHandle(SamrHandle): r.data_in.access_mask = access_mask r.data_in.rid = rid - result = dcerpc.dcerpc_samr_OpenGroup(self.pipe, r) + call_fn(dcerpc.dcerpc_samr_OpenGroup, self.pipe, r) return GroupHandle(pipe, r.data_out.group_handle) @@ -306,7 +316,7 @@ class DomainHandle(SamrHandle): r.data_in.access_mask = access_mask r.data_in.rid = rid - result = dcerpc.dcerpc_samr_OpenAlias(self.pipe, r) + call_fn(dcerpc.dcerpc_samr_OpenAlias, self.pipe, r) return AliasHandle(pipe, r.data_out.group_handle) @@ -315,7 +325,7 @@ class DomainHandle(SamrHandle): r = dcerpc.samr_RidToSid() r.data_in.domain_handle = self.handle - result = dcerpc.dcerpc_samr_RidToSid(self.pipe, r) + call_fn(dcerpc.dcerpc_samr_RidToSid, self.pipe, r) return sid_to_string(r.data_out.sid) @@ -339,7 +349,7 @@ def Connect(pipe, access_mask = 0x02000000): dcerpc.uint16_array_setitem(r.data_in.system_name, 0, ord('\\')) r.data_in.access_mask = access_mask - result = dcerpc.dcerpc_samr_Connect(pipe, r) + call_fn(dcerpc.dcerpc_samr_Connect, pipe, r) return ConnectHandle(pipe, r.data_out.connect_handle) @@ -350,7 +360,7 @@ def Connect2(pipe, system_name = '', access_mask = 0x02000000): r.data_in.system_name = system_name r.data_in.access_mask = access_mask - result = dcerpc.dcerpc_samr_Connect2(pipe, r) + call_fn(dcerpc.dcerpc_samr_Connect2, pipe, r) return ConnectHandle(pipe, r.data_out.connect_handle) @@ -361,7 +371,7 @@ def Connect3(pipe, system_name = '', access_mask = 0x02000000): r.data_in.unknown = 0 r.data_in.access_mask = access_mask - result = dcerpc.dcerpc_samr_Connect3(pipe, r) + call_fn(dcerpc.dcerpc_samr_Connect3, pipe, r) return ConnectHandle(pipe, r.data_out.connect_handle) @@ -372,7 +382,7 @@ def Connect4(pipe, system_name = '', access_mask = 0x02000000): r.data_in.unknown = 0 r.data_in.access_mask = access_mask - result = dcerpc.dcerpc_samr_Connect4(pipe, r) + call_fn(dcerpc.dcerpc_samr_Connect4, pipe, r) return ConnectHandle(pipe, r.data_out.connect_handle) @@ -386,7 +396,7 @@ def Connect5(pipe, system_name = '', access_mask = 0x02000000): r.data_in.info.unknown1 = 0 r.data_in.info.unknown2 = 0 - result = dcerpc.dcerpc_samr_Connect5(pipe, r) + call_fn(dcerpc.dcerpc_samr_Connect5, pipe, r) return ConnectHandle(pipe, r.data_out.connect_handle) -- cgit From 74e9fce454aa55bc2b08da6341f2851e1b8b12b7 Mon Sep 17 00:00:00 2001 From: Tim Potter Date: Sun, 13 Feb 2005 00:58:28 +0000 Subject: r5368: Fix ups for domain_name field name change. Implement GetDomPwInfo(), CreateUser2(), RemoveMemberFromForeignDomain(), DeleteUser(). (This used to be commit f9ba35ff839fb612f53d8c2e6c5a64aaddc3d6a1) --- source4/scripting/swig/samr.py | 58 ++++++++++++++++++++++++++++++++++++------ 1 file changed, 50 insertions(+), 8 deletions(-) (limited to 'source4/scripting') diff --git a/source4/scripting/swig/samr.py b/source4/scripting/swig/samr.py index 951ca30aa3..22b591930c 100644 --- a/source4/scripting/swig/samr.py +++ b/source4/scripting/swig/samr.py @@ -93,6 +93,7 @@ def call_fn(fn, pipe, args): """Wrap up a RPC call and throw an exception is an error was returned.""" result = fn(pipe, args); + if result & 0xc0000000: raise dcerpc.NTSTATUS(result, dcerpc.nt_errstr(result)); @@ -146,7 +147,7 @@ class ConnectHandle(SamrHandle): r = dcerpc.samr_EnumDomains() r.data_in.connect_handle = self.handle - r.data_in.resume_handle = 1 + r.data_in.resume_handle = 0 r.data_in.buf_size = -1 domains = [] @@ -169,8 +170,8 @@ class ConnectHandle(SamrHandle): r = dcerpc.samr_LookupDomain() r.data_in.connect_handle = self.handle - r.data_in.domain = dcerpc.samr_String() - r.data_in.domain.string = domain_name + r.data_in.domain_name = dcerpc.samr_String() + r.data_in.domain_name.string = domain_name call_fn(dcerpc.dcerpc_samr_LookupDomain, self.pipe, r) @@ -194,6 +195,16 @@ class ConnectHandle(SamrHandle): call_fn(dcerpc.dcerpc_samr_Shutdown, self.pipe, r) + def GetDomPwInfo(self, system_name): + + r = dcerpc.samr_GetDomPwInfo() + r.data_in.domain_name = dcerpc.samr_String() + r.data_in.domain_name.string = system_name + + call_fn(dcerpc.dcerpc_samr_GetDomPwInfo, self.pipe, r) + + return r.data_out.info + class DomainHandle(SamrHandle): @@ -286,7 +297,23 @@ class DomainHandle(SamrHandle): return (r.data_out.user_handle, dcerpc.uint32_array_getitem(r.data_out.rid, 0)) - + + def CreateUser2(self, account_name, acct_flags = 0x00000010, + access_mask = 0x02000000): + + r = dcerpc.samr_CreateUser2() + r.data_in.domain_handle = self.handle + r.data_in.account_name = dcerpc.samr_String() + r.data_in.account_name.string = account_name + r.data_in.acct_flags = acct_flags + r.data_in.access_mask = access_mask + + call_fn(dcerpc.dcerpc_samr_CreateUser2, self.pipe, r) + + return (r.data_out.user_handle, + dcerpc.uint32_array_getitem(r.data_out.access_granted, 0), + dcerpc.uint32_array_getitem(r.data_out.rid, 0)) + def OpenUser(self, rid, access_mask = 0x02000000): r = dcerpc.samr_OpenUser() @@ -329,9 +356,23 @@ class DomainHandle(SamrHandle): return sid_to_string(r.data_out.sid) + def RemoveMemberFromForeignDomain(self, sid): + + r = dcerpc.samr_RemoveMemberFromForeignDomain() + r.data_in.domain_handle = self.handle + r.data_in.sid = sid + + call_fn(dcerpc.dcerpc_samr_RemoveMemberFromForeignDomain, self.pipe, r) + class UserHandle(SamrHandle): - pass + + def DeleteUser(self): + + r = dcerpc.samr_DeleteUser() + r.data_in.user_handle = self.handle + + call_fn(dcerpc.dcerpc_samr_DeleteUser, self.pipe, r) class GroupHandle(SamrHandle): @@ -353,6 +394,7 @@ def Connect(pipe, access_mask = 0x02000000): return ConnectHandle(pipe, r.data_out.connect_handle) + def Connect2(pipe, system_name = '', access_mask = 0x02000000): """Connect to the SAMR pipe.""" @@ -364,6 +406,7 @@ def Connect2(pipe, system_name = '', access_mask = 0x02000000): return ConnectHandle(pipe, r.data_out.connect_handle) + def Connect3(pipe, system_name = '', access_mask = 0x02000000): r = dcerpc.samr_Connect3() @@ -375,6 +418,7 @@ def Connect3(pipe, system_name = '', access_mask = 0x02000000): return ConnectHandle(pipe, r.data_out.connect_handle) + def Connect4(pipe, system_name = '', access_mask = 0x02000000): r = dcerpc.samr_Connect4() @@ -386,6 +430,7 @@ def Connect4(pipe, system_name = '', access_mask = 0x02000000): return ConnectHandle(pipe, r.data_out.connect_handle) + def Connect5(pipe, system_name = '', access_mask = 0x02000000): r = dcerpc.samr_Connect5() @@ -418,7 +463,6 @@ def Connect5(pipe, system_name = '', access_mask = 0x02000000): # AddAliasMember # DeleteAliasMember # GetMembersinAlias -# DeleteUser # QueryUserInfo # SetUserInfo # ChangePasswordUser @@ -433,13 +477,11 @@ def Connect5(pipe, system_name = '', access_mask = 0x02000000): # QueryUserInfo2 # QueryDisplayInfo2 # GetDisplayEnumerationIndex2 -# CreateUser2 # QueryDisplayInfo3 # AddMultipleMembersToAlias # RemoveMultipleMembersFromAlias # OemChangePasswordUser2 # ChangePasswordUser2 -# GetDomPwInfo # SetUserInfo2 # SetBootKeyInformation # GetBootKeyInformation -- cgit From 11e6c958fdfda9c42f0e69f59af7f1d2bdca010c Mon Sep 17 00:00:00 2001 From: Tim Potter Date: Sun, 13 Feb 2005 00:59:26 +0000 Subject: r5369: Rename torture modules so they don't conflict with files in scripting/swig. Start porting samr torture test to new API. (This used to be commit 14593939830e130ae306b82a6c063ec9d7f36b93) --- source4/scripting/swig/torture/pytorture | 2 +- source4/scripting/swig/torture/samr.py | 893 ------------------------- source4/scripting/swig/torture/torture_samr.py | 736 ++++++++++++++++++++ 3 files changed, 737 insertions(+), 894 deletions(-) delete mode 100755 source4/scripting/swig/torture/samr.py create mode 100755 source4/scripting/swig/torture/torture_samr.py (limited to 'source4/scripting') diff --git a/source4/scripting/swig/torture/pytorture b/source4/scripting/swig/torture/pytorture index 8a8f4d8bdf..fd4a92eeb4 100755 --- a/source4/scripting/swig/torture/pytorture +++ b/source4/scripting/swig/torture/pytorture @@ -40,7 +40,7 @@ if len(args) == 0: for test in args: try: - module = __import__(test) + module = __import__('torture_%s' % test) except ImportError: print 'No such module "%s"' % test sys.exit(1) diff --git a/source4/scripting/swig/torture/samr.py b/source4/scripting/swig/torture/samr.py deleted file mode 100755 index f7c33baeb3..0000000000 --- a/source4/scripting/swig/torture/samr.py +++ /dev/null @@ -1,893 +0,0 @@ -#!/usr/bin/python - -import dcerpc - -def test_Connect(pipe): - - print 'testing samr_Connect' - - r = {} - r['system_name'] = 0; - r['access_mask'] = 0x02000000 - - result = dcerpc.samr_Connect(pipe, r) - - s = {} - s['handle'] = result['connect_handle'] - - handle = result['connect_handle'] - - print 'testing samr_Connect2' - - r = {} - r['system_name'] = None - r['access_mask'] = 0x02000000 - - result = dcerpc.samr_Connect2(pipe, r) - - s = {} - s['handle'] = result['connect_handle'] - - dcerpc.samr_Close(pipe, s) - - print 'testing samr_Connect3' - - r = {} - r['system_name'] = None - r['unknown'] = 0 - r['access_mask'] = 0x02000000 - - result = dcerpc.samr_Connect3(pipe, r) - - s = {} - s['handle'] = result['connect_handle'] - - dcerpc.samr_Close(pipe, s) - - print 'testing samr_Connect4' - - r = {} - r['system_name'] = None - r['unknown'] = 0 - r['access_mask'] = 0x02000000 - - result = dcerpc.samr_Connect4(pipe, r) - - s = {} - s['handle'] = result['connect_handle'] - - dcerpc.samr_Close(pipe, s) - - print 'testing samr_Connect5' - - r = {} - r['system_name'] = None - r['access_mask'] = 0x02000000 - r['level'] = 1 - r['info'] = {} - r['info']['info1'] = {} - r['info']['info1']['unknown1'] = 0 - r['info']['info1']['unknown2'] = 0 - - try: - result = dcerpc.samr_Connect5(pipe, r) - s = {} - s['handle'] = result['connect_handle'] - dcerpc.samr_Close(pipe, s) - except dcerpc.NTSTATUS, arg: - if arg[0] != dcerpc.NT_STATUS_NET_WRITE_FAULT: - raise - - return handle - -def test_QuerySecurity(pipe, handle): - - print 'testing samr_QuerySecurity' - - r = {} - r['handle'] = handle - r['sec_info'] = 7 - - result = dcerpc.samr_QuerySecurity(pipe, r) - - s = {} - s['handle'] = handle - s['sec_info'] = 7 - s['sdbuf'] = result['sdbuf'] - - dcerpc.samr_SetSecurity(pipe, s) - - dcerpc.samr_QuerySecurity(pipe, r) - -def test_GetDomPwInfo(pipe, handle, domain): - - print 'testing samr_GetDomPwInfo' - - r = {} - r['handle'] = handle - r['name'] = {} - r['name']['name'] = domain - - dcerpc.samr_GetDomPwInfo(pipe, r) - - r['name']['name'] = '\\\\%s' % domain - - dcerpc.samr_GetDomPwInfo(pipe, r) - - r['name']['name'] = '\\\\__NONAME__' - - dcerpc.samr_GetDomPwInfo(pipe, r) - - r['name']['name'] = '\\\\Builtin' - - dcerpc.samr_GetDomPwInfo(pipe, r) - -def test_RemoveMemberFromForeignDomain(pipe, domain_handle): - - print 'test samr_RemoveMemberFromForeignDomain' - - r = {} - r['domain_handle'] = domain_handle - r['sid'] = {} - r['sid']['sid_rev_num'] = 1 - r['sid']['id_auth'] = [1, 2, 3, 4, 5, 6] - r['sid']['num_auths'] = 4 - r['sid']['sub_auths'] = [7, 8, 9, 10] - - dcerpc.samr_RemoveMemberFromForeignDomain(pipe, r) - -def test_CreateUser2(pipe, domain_handle): - - print 'test samr_CreateUser2' - - r = {} - r['domain_handle'] = domain_handle - r['access_mask'] = 0x02000000 - r['account_name'] = {} - r['account_name']['name'] = 'samrtorturemach$' - r['acct_flags'] = 0x0080 # WSTRUST - - try: - dcerpc.samr_CreateUser2(pipe, r) - except dcerpc.NTSTATUS, arg: - if arg[0] == dcerpc.NT_STATUS_ACCESS_DENIED: - return - elif arg[0] == dcerpc.NT_STATUS_USER_EXISTS: - test_DeleteUser_byname(pipe, domain_handle, 'samrtorturemach$') - result = dcerpc.samr_CreateUser(pipe, r) - else: - raise dcerpc.NTSTATUS(arg) - -def test_LookupName(pipe, domain_handle, name): - - print 'test samr_LookupNames' - - r = {} - r['domain_handle'] = domain_handle - r['num_names'] = 1 - r['names'] = [] - r['names'].append({'name': name}) - - result = dcerpc.samr_LookupNames(pipe, r) - - rid = result['rids']['ids'][0] - - r['num_names'] = 2 - r['names'].append({'name': 'xxNONAMExx'}) - - - try: - dcerpc.samr_LookupNames(pipe, r) - except dcerpc.NTSTATUS, arg: - if arg[0] != dcerpc.STATUS_SOME_UNMAPPED: - raise dcerpc.NTSTATUS(arg) - - r['num_names'] = 0 - - dcerpc.samr_LookupNames(pipe, r) - - return rid - -def test_OpenUser_byname(pipe, domain_handle, user_name): - - rid = test_LookupName(pipe, domain_handle, user_name) - - r = {} - r['domain_handle'] = domain_handle - r['access_mask'] = 0x02000000 - r['rid'] = rid - - result = dcerpc.samr_OpenUser(pipe, r) - - return result['user_handle'] - -def test_DeleteUser_byname(pipe, domain_handle, user_name): - - user_handle = test_OpenUser_byname(pipe, domain_handle, user_name) - - r = {} - r['user_handle'] = user_handle - - dcerpc.samr_DeleteUser(pipe, r) - -def test_QueryUserInfo(pipe, user_handle): - - print 'test samr_QueryUserInfo' - - levels = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 16, 17, 20, 21] - - for level in levels: - r = {} - r['user_handle'] = user_handle - r['level'] = level - - dcerpc.samr_QueryUserInfo(pipe, r) - -def test_QueryUserInfo2(pipe, user_handle): - - print 'test samr_QueryUserInfo2' - - levels = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 16, 17, 20, 21] - - for level in levels: - r = {} - r['user_handle'] = user_handle - r['level'] = level - - dcerpc.samr_QueryUserInfo2(pipe, r) - -def test_SetUserInfo(pipe, user_handle): - - r = {} - r['user_handle'] = user_handle - r['level'] = 2 - r['info'] = {} - r['info']['info2'] = {} - r['info']['info2']['comment'] = {} - r['info']['info2']['comment']['name'] = 'hello' - r['info']['info2']['unknown'] = {} - r['info']['info2']['unknown']['name'] = None - r['info']['info2']['country_code'] = 0 - r['info']['info2']['code_page'] = 0 - - dcerpc.samr_SetUserInfo(pipe, r) - -def test_GetUserPwInfo(pipe, user_handle): - - print 'test samr_GetUserpwInfo' - - r = {} - r['user_handle'] = user_handle - - dcerpc.samr_GetUserPwInfo(pipe, r) - -def test_TestPrivateFunctionsUser(pipe, user_handle): - - print 'test samr.TestPrivateFunctionsUser' - - r = {} - r['user_handle'] = user_handle - - try: - dcerpc.samr_TestPrivateFunctionsUser(pipe, r) - except dcerpc.NTSTATUS, arg: - if arg[0] != dcerpc.NT_STATUS_NOT_IMPLEMENTED: - raise dcerpc.NTSTATUS(arg) - -def test_user_ops(pipe, user_handle): - - test_QuerySecurity(pipe, user_handle) - - test_QueryUserInfo(pipe, user_handle) - - test_QueryUserInfo2(pipe, user_handle) - - test_SetUserInfo(pipe, user_handle) - - test_GetUserPwInfo(pipe, user_handle) - - test_TestPrivateFunctionsUser(pipe, user_handle) - -def test_CreateUser(pipe, domain_handle): - - print 'test samr_CreateUser' - - r = {} - r['domain_handle'] = domain_handle - r['account_name'] = {} - r['account_name']['name'] = 'samrtorturetest' - r['access_mask'] = 0x02000000 - - try: - result = dcerpc.samr_CreateUser(pipe, r) - except dcerpc.NTSTATUS, arg: - if arg[0] == dcerpc.NT_STATUS_ACCESS_DENIED: - return - elif arg[0] == dcerpc.NT_STATUS_USER_EXISTS: - test_DeleteUser_byname(pipe, domain_handle, 'samrtorturetest') - result = dcerpc.samr_CreateUser(pipe, r) - else: - raise dcerpc.NTSTATUS(arg) - - user_handle = result['user_handle'] - - q = {} - q['user_handle'] = user_handle - q['level'] = 16 - - dcerpc.samr_QueryUserInfo(pipe, q) - - test_user_ops(pipe, user_handle) - - return user_handle - -def test_DeleteAlias_byname(pipe, domain_handle, alias_name): - - rid = test_LookupName(pipe, domain_handle, alias_name) - - r = {} - r['domain_handle'] = domain_handle - r['access_mask'] = 0x02000000 - r['rid'] = rid - - result = dcerpc.samr_OpenAlias(pipe, r) - - s = {} - s['alias_handle'] = result['alias_handle'] - - dcerpc.samr_DeleteDomAlias(pipe, s) - -def test_QueryAliasInfo(pipe, alias_handle): - - levels = [1, 2, 3] - - for i in range(0, len(levels)): - - r = {} - r['alias_handle'] = alias_handle - r['level'] = levels[i] - - dcerpc.samr_QueryAliasInfo(pipe, r) - -def test_SetAliasInfo(pipe, alias_handle): - - r = {} - r['alias_handle'] = alias_handle - r['level'] = 2 - r['info'] = {} - r['info']['name'] = {} - r['info']['name']['name'] = 'hello' - - dcerpc.samr_SetAliasInfo(pipe, r) - - del(r['info']['name']) - - r['level'] = 3 - r['info']['description'] = {} - r['info']['description']['name'] = 'this is a description' - - dcerpc.samr_SetAliasInfo(pipe, r) - -def test_AddMemberToAlias(pipe, alias_handle, domain_sid): - - r = {} - r['alias_handle'] = alias_handle - r['sid'] = domain_sid - - r['sid']['num_auths'] = r['sid']['num_auths'] + 1 - r['sid']['sub_auths'].append(512) - - dcerpc.samr_AddAliasMember(pipe, r) - - dcerpc.samr_DeleteAliasMember(pipe, r) - -def test_AddMultipleMembersToAlias(pipe, alias_handle): - - r = {} - r['alias_handle'] = alias_handle - r['sids'] = {} - r['sids']['num_sids'] = 2 - r['sids']['sids'] = [] - - for i in range(0,2): - sid = {} - sid['sid_rev_num'] = 1 - sid['id_auth'] = [0, 0, 0, 0, 0, 5] - sid['num_auths'] = 5 - sid['sub_auths'] = [21, 737922324, -1292160505, 1285293260, 512 + i] - - r['sids']['sids'].append({'sid': sid}) - - dcerpc.samr_AddMultipleMembersToAlias(pipe, r) - - dcerpc.samr_RemoveMultipleMembersFromAlias(pipe, r) - -def test_alias_ops(pipe, alias_handle, domain_sid): - - test_QuerySecurity(pipe, alias_handle) - - test_QueryAliasInfo(pipe, alias_handle) - - test_SetAliasInfo(pipe, alias_handle) - - test_AddMemberToAlias(pipe, alias_handle, domain_sid) - - test_AddMultipleMembersToAlias(pipe, alias_handle) - -def test_CreateAlias(pipe, domain_handle, domain_sid): - - print 'test samr_CreateAlias' - - alias_name = 'samrtorturetestalias' - - r = {} - r['domain_handle'] = domain_handle - r['aliasname'] = {} - r['aliasname']['name'] = alias_name - r['access_mask'] = 0x02000000 - - try: - result = dcerpc.samr_CreateDomAlias(pipe, r) - except dcerpc.NTSTATUS, arg: - if arg[0] == dcerpc.NT_STATUS_ACCESS_DENIED: - return - if arg[0] != dcerpc.NT_STATUS_USER_EXISTS: - raise dcerpc.NTSTATUS(arg) - test_DeleteAlias_byname(pipe, domain_handle, alias_name) - result = dcerpc.samr_CreateDomAlias(pipe, r) - - alias_handle = result['alias_handle'] - - test_alias_ops(pipe, alias_handle, domain_sid) - - return alias_handle - -def test_DeleteGroup_byname(pipe, domain_handle, group_name): - - rid = test_LookupName(pipe, domain_handle, group_name) - - r = {} - r['domain_handle'] = domain_handle - r['access_mask'] = 0x02000000 - r['rid'] = rid - - result = dcerpc.samr_OpenGroup(pipe, r) - - s = {} - s['group_handle'] = result['group_handle'] - - dcerpc.samr_DeleteDomainGroup(pipe, s) - -def test_CreateDomainGroup(pipe, domain_handle): - - print 'testing samr_CreateDomainGroup' - - r = {} - r['domain_handle'] = domain_handle - r['name'] = {} - r['name']['name'] = 'samrtorturetestgroup' - r['access_mask'] = 0x02000000 - - try: - result = dcerpc.samr_CreateDomainGroup(pipe, r) - except dcerpc.NTSTATUS, arg: - if arg[0] == dcerpc.NT_STATUS_ACCESS_DENIED: - return - if arg[0] != dcerpc.NT_STATUS_GROUP_EXISTS: - raise dcerpc.NTSTATUS(arg) - - test_DeleteGroup_byname(pipe, domain_handle, 'samrtorturetestgroup') - - result = dcerpc.samr_CreateDomainGroup(pipe, r) - - return result['group_handle'] - -def test_QueryDomainInfo(pipe, domain_handle): - - print 'testing samr_QueryDomainInfo' - - levels = [1, 2, 3, 4, 5, 6, 7, 8, 9, 11, 12, 13] - set_ok = [1, 0, 1, 1, 0, 1, 1, 0, 1, 0, 1, 0] - - for i in range(0, len(levels)): - - r = {} - r['domain_handle'] = domain_handle - r['level'] = levels[i] - - result = dcerpc.samr_QueryDomainInfo(pipe, r) - - s = {} - s['domain_handle'] = domain_handle - s['level'] = levels[i] - s['info'] = result['info'] - - try: - dcerpc.samr_SetDomainInfo(pipe, s) - except dcerpc.NTSTATUS, arg: - if set_ok[i]: - raise dcerpc.NTSTATUS(arg) - if arg[0] != dcerpc.NT_STATUS_INVALID_INFO_CLASS: - raise dcerpc.NTSTATUS(arg) - -def test_QueryDomainInfo2(pipe, domain_handle): - - print 'testing samr_QueryDomainInfo' - - levels = [1, 2, 3, 4, 5, 6, 7, 8, 9, 11, 12, 13] - - for i in range(0, len(levels)): - - r = {} - r['domain_handle'] = domain_handle - r['level'] = levels[i] - - dcerpc.samr_QueryDomainInfo2(pipe, r) - -def test_EnumDomainUsers(pipe, domain_handle): - - print 'testing samr_EnumDomainUsers' - - r = {} - r['domain_handle'] = domain_handle - r['resume_handle'] = 0 - r['acct_flags'] = 0 - r['max_size'] = -1 - - while 1: - result = dcerpc.samr_EnumDomainUsers(pipe, r) - if result['result'] == dcerpc.STATUS_MORE_ENTRIES: - r['resume_handle'] = result['resume_handle'] - continue - break - -def test_EnumDomainGroups(pipe, domain_handle): - - print 'testing samr_EnumDomainGroups' - - r = {} - r['domain_handle'] = domain_handle - r['resume_handle'] = 0 - r['acct_flags'] = 0 - r['max_size'] = -1 - - while 1: - result = dcerpc.samr_EnumDomainGroups(pipe, r) - if result['result'] == dcerpc.STATUS_MORE_ENTRIES: - r['resume_handle'] = result['resume_handle'] - continue - break - -def test_EnumDomainAliases(pipe, domain_handle): - - print 'testing samr_EnumDomainAliases' - - r = {} - r['domain_handle'] = domain_handle - r['resume_handle'] = 0 - r['acct_flags'] = 0 - r['max_size'] = -1 - - while 1: - result = dcerpc.samr_EnumDomainAliases(pipe, r) - if result['result'] == dcerpc.STATUS_MORE_ENTRIES: - r['resume_handle'] = result['resume_handle'] - continue - break - -def test_QueryDisplayInfo(pipe, domain_handle): - - print 'testing samr_QueryDisplayInfo' - - levels = [1, 2, 3, 4, 5] - - for i in range(0, len(levels)): - - r = {} - r['domain_handle'] = domain_handle - r['level'] = levels[i] - r['start_idx'] = 0 - r['max_entries'] = 1000 - r['buf_size'] = -1 - - dcerpc.samr_QueryDisplayInfo(pipe, r) - -def test_QueryDisplayInfo2(pipe, domain_handle): - - print 'testing samr_QueryDisplayInfo2' - - levels = [1, 2, 3, 4, 5] - - for i in range(0, len(levels)): - - r = {} - r['domain_handle'] = domain_handle - r['level'] = levels[i] - r['start_idx'] = 0 - r['max_entries'] = 1000 - r['buf_size'] = -1 - - dcerpc.samr_QueryDisplayInfo2(pipe, r) - -def test_QueryDisplayInfo3(pipe, domain_handle): - - print 'testing samr_QueryDisplayInfo3' - - levels = [1, 2, 3, 4, 5] - - for i in range(0, len(levels)): - - r = {} - r['domain_handle'] = domain_handle - r['level'] = levels[i] - r['start_idx'] = 0 - r['max_entries'] = 1000 - r['buf_size'] = -1 - - dcerpc.samr_QueryDisplayInfo3(pipe, r) - -def test_GetDisplayEnumerationIndex(pipe, domain_handle): - - print 'testing samr_GetDisplayEnumerationIndex' - - levels = [1, 2, 3, 4, 5] - ok_lvl = [1, 1, 1, 0, 0] - - for i in range(0, len(levels)): - - r = {} - r['domain_handle'] = domain_handle - r['level'] = levels[i] - r['name'] = {} - r['name']['name'] = 'samrtorturetest' - - try: - dcerpc.samr_GetDisplayEnumerationIndex(pipe, r) - except dcerpc.NTSTATUS, arg: - if ok_lvl[i]: - raise dcerpc.NTSTATUS(arg) - - r['name']['name'] = 'zzzzzzzz' - - try: - dcerpc.samr_GetDisplayEnumerationIndex(pipe, r) - except dcerpc.NTSTATUS, arg: - if ok_lvl[i]: - raise dcerpc.NTSTATUS(arg) - -def test_GetDisplayEnumerationIndex2(pipe, domain_handle): - - print 'testing samr_GetDisplayEnumerationIndex2' - - levels = [1, 2, 3, 4, 5] - ok_lvl = [1, 1, 1, 0, 0] - - for i in range(0, len(levels)): - - r = {} - r['domain_handle'] = domain_handle - r['level'] = levels[i] - r['name'] = {} - r['name']['name'] = 'samrtorturetest' - - try: - dcerpc.samr_GetDisplayEnumerationIndex2(pipe, r) - except dcerpc.NTSTATUS, arg: - if ok_lvl[i]: - raise dcerpc.NTSTATUS(arg) - - r['name']['name'] = 'zzzzzzzz' - - try: - dcerpc.samr_GetDisplayEnumerationIndex2(pipe, r) - except dcerpc.NTSTATUS, arg: - if ok_lvl[i]: - raise dcerpc.NTSTATUS(arg) - -def test_TestPrivateFunctionsDomain(pipe, domain_handle): - - print 'test samr.TestPrivateFunctionsDomain' - - r = {} - r['domain_handle'] = domain_handle - - try: - dcerpc.samr_TestPrivateFunctionsDomain(pipe, r) - except dcerpc.NTSTATUS, arg: - if arg[0] != dcerpc.NT_STATUS_NOT_IMPLEMENTED: - raise dcerpc.NTSTATUS(arg) - -def test_RidToSid(pipe, domain_handle): - - print 'testing samr_RidToSid' - - r = {} - r['domain_handle'] = domain_handle - r['rid'] = 512 - - dcerpc.samr_RidToSid(pipe, r) - -def test_GetBootKeyInformation(pipe, domain_handle): - - print 'testing samr_GetBootKeyInformation' - - r = {} - r['domain_handle'] = domain_handle - - try: - dcerpc.samr_GetBootKeyInformation(pipe, r) - except dcerpc.NTSTATUS, arg: - pass - -def test_DeleteUser(pipe, user_handle): - - r = {} - r['user_handle'] = user_handle - - dcerpc.samr_DeleteUser(pipe, r) - -def test_DeleteAlias(pipe, alias_handle): - - r = {} - r['alias_handle'] = alias_handle - - dcerpc.samr_DeleteDomAlias(pipe, r) - -def test_DeleteDomainGroup(pipe, group_handle): - - r = {} - r['group_handle'] = group_handle - - dcerpc.samr_DeleteDomainGroup(pipe, r) - -def test_Close(pipe, handle): - - r = {} - r['handle'] = handle - - dcerpc.samr_Close(pipe, r) - -def test_OpenDomain(pipe, connect_handle, domain_sid): - - print 'testing samr_OpenDomain' - - r = {} - r['connect_handle'] = connect_handle - r['access_mask'] = 0x02000000 - r['sid'] = domain_sid - - result = dcerpc.samr_OpenDomain(pipe, r) - - domain_handle = result['domain_handle'] - - test_QuerySecurity(pipe, domain_handle) - - test_RemoveMemberFromForeignDomain(pipe, domain_handle) - - test_CreateUser2(pipe, domain_handle) - - user_handle = test_CreateUser(pipe, domain_handle) - - alias_handle = test_CreateAlias(pipe, domain_handle, domain_sid) - - group_handle = test_CreateDomainGroup(pipe, domain_handle) - - test_QueryDomainInfo(pipe, domain_handle) - - test_QueryDomainInfo2(pipe, domain_handle) - - test_EnumDomainUsers(pipe, domain_handle) - - test_EnumDomainGroups(pipe, domain_handle) - - test_EnumDomainAliases(pipe, domain_handle) - - test_QueryDisplayInfo(pipe, domain_handle) - - test_QueryDisplayInfo2(pipe, domain_handle) - - test_QueryDisplayInfo3(pipe, domain_handle) - - test_GetDisplayEnumerationIndex(pipe, domain_handle) - - test_GetDisplayEnumerationIndex2(pipe, domain_handle) - - test_TestPrivateFunctionsDomain(pipe, domain_handle) - - test_RidToSid(pipe, domain_handle) - - test_GetBootKeyInformation(pipe, domain_handle) - - if user_handle != None: - test_DeleteUser(pipe, user_handle) - - if alias_handle != None: - test_DeleteAlias(pipe, alias_handle) - - if group_handle != None: - test_DeleteDomainGroup(pipe, group_handle) - - test_Close(pipe, domain_handle) - -def test_LookupDomain(pipe, connect_handle, domain): - - print 'testing samr_LookupDomain' - - r = {} - r['connect_handle'] = connect_handle - r['domain'] = {} - r['domain']['name'] = None - - try: - dcerpc.samr_LookupDomain(pipe, r) - except dcerpc.NTSTATUS, arg: - if arg[0] != dcerpc.NT_STATUS_INVALID_PARAMETER: - raise dcerpc.NTSTATUS(arg) - - r['domain']['name'] = 'xxNODOMAINxx' - - try: - dcerpc.samr_LookupDomain(pipe, r) - except dcerpc.NTSTATUS, arg: - if arg[0] != dcerpc.NT_STATUS_NO_SUCH_DOMAIN: - raise dcerpc.NTSTATUS(arg) - - r['domain']['name'] = domain - - result = dcerpc.samr_LookupDomain(pipe, r) - - test_GetDomPwInfo(pipe, connect_handle, domain) - - test_OpenDomain(pipe, connect_handle, result['sid']) - -def test_EnumDomains(pipe, connect_handle): - - print 'testing samr_EnumDomains' - - r = {} - r['connect_handle'] = connect_handle - r['resume_handle'] = 0 - r['buf_size'] = -1 - - result = dcerpc.samr_EnumDomains(pipe, r) - - for domain in result['sam']['entries']: - test_LookupDomain(pipe, connect_handle, domain['name']['name']) - -def test_LongInt(pipe): - - # Check that we can use long values for shorter width types - - r = {} - r['system_name'] = 0L; - r['access_mask'] = 0x02000000L - - result = dcerpc.samr_Connect(pipe, r) - - # Test that we can parse a SID that contains a sub_auth that can't - # be held in a python int. - - r = {} - r['connect_handle'] = result['connect_handle'] - r['access_mask'] = 0x02000000 - r['sid'] = {'sid_rev_num': 1, 'id_auth': [0, 0, 0, 0, 0, 5], - 'num_auths': 4, - 'sub_auths': [21, 737922324, 3002806791L, 1285293260]} - - result = dcerpc.samr_OpenDomain(pipe, r) - -def runtests(binding, domain, username, password): - - print 'Testing SAMR pipe' - - pipe = dcerpc.pipe_connect(binding, - dcerpc.DCERPC_SAMR_UUID, dcerpc.DCERPC_SAMR_VERSION, - domain, username, password) - - test_LongInt(pipe) - - handle = test_Connect(pipe) - - test_QuerySecurity(pipe, handle) - - test_EnumDomains(pipe, handle) diff --git a/source4/scripting/swig/torture/torture_samr.py b/source4/scripting/swig/torture/torture_samr.py new file mode 100755 index 0000000000..929420695d --- /dev/null +++ b/source4/scripting/swig/torture/torture_samr.py @@ -0,0 +1,736 @@ +#!/usr/bin/python + +import sys +import dcerpc, samr + +def test_Connect(pipe): + + print 'testing Connect' + + handle = samr.Connect(pipe) + handle = samr.Connect2(pipe) + handle = samr.Connect3(pipe) + handle = samr.Connect4(pipe) + handle = samr.Connect5(pipe) + + return handle + +def test_QuerySecurity(pipe, handle): + + print 'testing QuerySecurity' + + sdbuf = handle.QuerySecurity() + handle.SetSecurity(sdbuf) + + +def test_GetDomPwInfo(pipe, handle, domain): + + print 'testing GetDomPwInfo' + + handle.GetDomPwInfo(domain) + handle.GetDomPwInfo('__NONAME__') + handle.GetDomPwInfo('Builtin') + +def test_RemoveMemberFromForeignDomain(pipe, domain_handle): + + print 'test RemoveMemberFromForeignDomain' + + sid = samr.string_to_sid('S-1-5-32-12-34-56-78-9') + + domain_handle.RemoveMemberFromForeignDomain(sid) + +def test_CreateUser2(pipe, domain_handle): + + print 'test CreateUser2' + + username = 'samrtorturemach$' + + try: + return domain_handle.CreateUser2(username, 0x0080) # WSTRUST + except dcerpc.NTSTATUS, arg: + if arg[0] == 0x0c0000063L: + domain_handle.OpenUser(username).DeleteUser() + return domain_handle.CreateUser2(username) + raise + +def test_LookupName(pipe, domain_handle, name): + + print 'test samr_LookupNames' + + r = {} + r['domain_handle'] = domain_handle + r['num_names'] = 1 + r['names'] = [] + r['names'].append({'name': name}) + + result = dcerpc.samr_LookupNames(pipe, r) + + rid = result['rids']['ids'][0] + + r['num_names'] = 2 + r['names'].append({'name': 'xxNONAMExx'}) + + + try: + dcerpc.samr_LookupNames(pipe, r) + except dcerpc.NTSTATUS, arg: + if arg[0] != dcerpc.STATUS_SOME_UNMAPPED: + raise dcerpc.NTSTATUS(arg) + + r['num_names'] = 0 + + dcerpc.samr_LookupNames(pipe, r) + + return rid + +def test_OpenUser_byname(pipe, domain_handle, user_name): + + rid = test_LookupName(pipe, domain_handle, user_name) + + r = {} + r['domain_handle'] = domain_handle + r['access_mask'] = 0x02000000 + r['rid'] = rid + + result = dcerpc.samr_OpenUser(pipe, r) + + return result['user_handle'] + +def test_DeleteUser_byname(pipe, domain_handle, user_name): + + user_handle = test_OpenUser_byname(pipe, domain_handle, user_name) + + r = {} + r['user_handle'] = user_handle + + dcerpc.samr_DeleteUser(pipe, r) + +def test_QueryUserInfo(pipe, user_handle): + + print 'test samr_QueryUserInfo' + + levels = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 16, 17, 20, 21] + + for level in levels: + r = {} + r['user_handle'] = user_handle + r['level'] = level + + dcerpc.samr_QueryUserInfo(pipe, r) + +def test_QueryUserInfo2(pipe, user_handle): + + print 'test samr_QueryUserInfo2' + + levels = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 16, 17, 20, 21] + + for level in levels: + r = {} + r['user_handle'] = user_handle + r['level'] = level + + dcerpc.samr_QueryUserInfo2(pipe, r) + +def test_SetUserInfo(pipe, user_handle): + + r = {} + r['user_handle'] = user_handle + r['level'] = 2 + r['info'] = {} + r['info']['info2'] = {} + r['info']['info2']['comment'] = {} + r['info']['info2']['comment']['name'] = 'hello' + r['info']['info2']['unknown'] = {} + r['info']['info2']['unknown']['name'] = None + r['info']['info2']['country_code'] = 0 + r['info']['info2']['code_page'] = 0 + + dcerpc.samr_SetUserInfo(pipe, r) + +def test_GetUserPwInfo(pipe, user_handle): + + print 'test samr_GetUserpwInfo' + + r = {} + r['user_handle'] = user_handle + + dcerpc.samr_GetUserPwInfo(pipe, r) + +def test_TestPrivateFunctionsUser(pipe, user_handle): + + print 'test samr.TestPrivateFunctionsUser' + + r = {} + r['user_handle'] = user_handle + + try: + dcerpc.samr_TestPrivateFunctionsUser(pipe, r) + except dcerpc.NTSTATUS, arg: + if arg[0] != dcerpc.NT_STATUS_NOT_IMPLEMENTED: + raise dcerpc.NTSTATUS(arg) + +def test_user_ops(pipe, user_handle): + + test_QuerySecurity(pipe, user_handle) + + test_QueryUserInfo(pipe, user_handle) + + test_QueryUserInfo2(pipe, user_handle) + + test_SetUserInfo(pipe, user_handle) + + test_GetUserPwInfo(pipe, user_handle) + + test_TestPrivateFunctionsUser(pipe, user_handle) + +def test_CreateUser(pipe, domain_handle): + + print 'test samr_CreateUser' + + r = {} + r['domain_handle'] = domain_handle + r['account_name'] = {} + r['account_name']['name'] = 'samrtorturetest' + r['access_mask'] = 0x02000000 + + try: + result = dcerpc.samr_CreateUser(pipe, r) + except dcerpc.NTSTATUS, arg: + if arg[0] == dcerpc.NT_STATUS_ACCESS_DENIED: + return + elif arg[0] == dcerpc.NT_STATUS_USER_EXISTS: + test_DeleteUser_byname(pipe, domain_handle, 'samrtorturetest') + result = dcerpc.samr_CreateUser(pipe, r) + else: + raise dcerpc.NTSTATUS(arg) + + user_handle = result['user_handle'] + + q = {} + q['user_handle'] = user_handle + q['level'] = 16 + + dcerpc.samr_QueryUserInfo(pipe, q) + + test_user_ops(pipe, user_handle) + + return user_handle + +def test_DeleteAlias_byname(pipe, domain_handle, alias_name): + + rid = test_LookupName(pipe, domain_handle, alias_name) + + r = {} + r['domain_handle'] = domain_handle + r['access_mask'] = 0x02000000 + r['rid'] = rid + + result = dcerpc.samr_OpenAlias(pipe, r) + + s = {} + s['alias_handle'] = result['alias_handle'] + + dcerpc.samr_DeleteDomAlias(pipe, s) + +def test_QueryAliasInfo(pipe, alias_handle): + + levels = [1, 2, 3] + + for i in range(0, len(levels)): + + r = {} + r['alias_handle'] = alias_handle + r['level'] = levels[i] + + dcerpc.samr_QueryAliasInfo(pipe, r) + +def test_SetAliasInfo(pipe, alias_handle): + + r = {} + r['alias_handle'] = alias_handle + r['level'] = 2 + r['info'] = {} + r['info']['name'] = {} + r['info']['name']['name'] = 'hello' + + dcerpc.samr_SetAliasInfo(pipe, r) + + del(r['info']['name']) + + r['level'] = 3 + r['info']['description'] = {} + r['info']['description']['name'] = 'this is a description' + + dcerpc.samr_SetAliasInfo(pipe, r) + +def test_AddMemberToAlias(pipe, alias_handle, domain_sid): + + r = {} + r['alias_handle'] = alias_handle + r['sid'] = domain_sid + + r['sid']['num_auths'] = r['sid']['num_auths'] + 1 + r['sid']['sub_auths'].append(512) + + dcerpc.samr_AddAliasMember(pipe, r) + + dcerpc.samr_DeleteAliasMember(pipe, r) + +def test_AddMultipleMembersToAlias(pipe, alias_handle): + + r = {} + r['alias_handle'] = alias_handle + r['sids'] = {} + r['sids']['num_sids'] = 2 + r['sids']['sids'] = [] + + for i in range(0,2): + sid = {} + sid['sid_rev_num'] = 1 + sid['id_auth'] = [0, 0, 0, 0, 0, 5] + sid['num_auths'] = 5 + sid['sub_auths'] = [21, 737922324, -1292160505, 1285293260, 512 + i] + + r['sids']['sids'].append({'sid': sid}) + + dcerpc.samr_AddMultipleMembersToAlias(pipe, r) + + dcerpc.samr_RemoveMultipleMembersFromAlias(pipe, r) + +def test_alias_ops(pipe, alias_handle, domain_sid): + + test_QuerySecurity(pipe, alias_handle) + + test_QueryAliasInfo(pipe, alias_handle) + + test_SetAliasInfo(pipe, alias_handle) + + test_AddMemberToAlias(pipe, alias_handle, domain_sid) + + test_AddMultipleMembersToAlias(pipe, alias_handle) + +def test_CreateAlias(pipe, domain_handle, domain_sid): + + print 'test samr_CreateAlias' + + alias_name = 'samrtorturetestalias' + + r = {} + r['domain_handle'] = domain_handle + r['aliasname'] = {} + r['aliasname']['name'] = alias_name + r['access_mask'] = 0x02000000 + + try: + result = dcerpc.samr_CreateDomAlias(pipe, r) + except dcerpc.NTSTATUS, arg: + if arg[0] == dcerpc.NT_STATUS_ACCESS_DENIED: + return + if arg[0] != dcerpc.NT_STATUS_USER_EXISTS: + raise dcerpc.NTSTATUS(arg) + test_DeleteAlias_byname(pipe, domain_handle, alias_name) + result = dcerpc.samr_CreateDomAlias(pipe, r) + + alias_handle = result['alias_handle'] + + test_alias_ops(pipe, alias_handle, domain_sid) + + return alias_handle + +def test_DeleteGroup_byname(pipe, domain_handle, group_name): + + rid = test_LookupName(pipe, domain_handle, group_name) + + r = {} + r['domain_handle'] = domain_handle + r['access_mask'] = 0x02000000 + r['rid'] = rid + + result = dcerpc.samr_OpenGroup(pipe, r) + + s = {} + s['group_handle'] = result['group_handle'] + + dcerpc.samr_DeleteDomainGroup(pipe, s) + +def test_CreateDomainGroup(pipe, domain_handle): + + print 'testing samr_CreateDomainGroup' + + r = {} + r['domain_handle'] = domain_handle + r['name'] = {} + r['name']['name'] = 'samrtorturetestgroup' + r['access_mask'] = 0x02000000 + + try: + result = dcerpc.samr_CreateDomainGroup(pipe, r) + except dcerpc.NTSTATUS, arg: + if arg[0] == dcerpc.NT_STATUS_ACCESS_DENIED: + return + if arg[0] != dcerpc.NT_STATUS_GROUP_EXISTS: + raise dcerpc.NTSTATUS(arg) + + test_DeleteGroup_byname(pipe, domain_handle, 'samrtorturetestgroup') + + result = dcerpc.samr_CreateDomainGroup(pipe, r) + + return result['group_handle'] + +def test_QueryDomainInfo(pipe, domain_handle): + + print 'testing samr_QueryDomainInfo' + + levels = [1, 2, 3, 4, 5, 6, 7, 8, 9, 11, 12, 13] + set_ok = [1, 0, 1, 1, 0, 1, 1, 0, 1, 0, 1, 0] + + for i in range(0, len(levels)): + + r = {} + r['domain_handle'] = domain_handle + r['level'] = levels[i] + + result = dcerpc.samr_QueryDomainInfo(pipe, r) + + s = {} + s['domain_handle'] = domain_handle + s['level'] = levels[i] + s['info'] = result['info'] + + try: + dcerpc.samr_SetDomainInfo(pipe, s) + except dcerpc.NTSTATUS, arg: + if set_ok[i]: + raise dcerpc.NTSTATUS(arg) + if arg[0] != dcerpc.NT_STATUS_INVALID_INFO_CLASS: + raise dcerpc.NTSTATUS(arg) + +def test_QueryDomainInfo2(pipe, domain_handle): + + print 'testing samr_QueryDomainInfo' + + levels = [1, 2, 3, 4, 5, 6, 7, 8, 9, 11, 12, 13] + + for i in range(0, len(levels)): + + r = {} + r['domain_handle'] = domain_handle + r['level'] = levels[i] + + dcerpc.samr_QueryDomainInfo2(pipe, r) + +def test_EnumDomainUsers(pipe, domain_handle): + + print 'testing samr_EnumDomainUsers' + + r = {} + r['domain_handle'] = domain_handle + r['resume_handle'] = 0 + r['acct_flags'] = 0 + r['max_size'] = -1 + + while 1: + result = dcerpc.samr_EnumDomainUsers(pipe, r) + if result['result'] == dcerpc.STATUS_MORE_ENTRIES: + r['resume_handle'] = result['resume_handle'] + continue + break + +def test_EnumDomainGroups(pipe, domain_handle): + + print 'testing samr_EnumDomainGroups' + + r = {} + r['domain_handle'] = domain_handle + r['resume_handle'] = 0 + r['acct_flags'] = 0 + r['max_size'] = -1 + + while 1: + result = dcerpc.samr_EnumDomainGroups(pipe, r) + if result['result'] == dcerpc.STATUS_MORE_ENTRIES: + r['resume_handle'] = result['resume_handle'] + continue + break + +def test_EnumDomainAliases(pipe, domain_handle): + + print 'testing samr_EnumDomainAliases' + + r = {} + r['domain_handle'] = domain_handle + r['resume_handle'] = 0 + r['acct_flags'] = 0 + r['max_size'] = -1 + + while 1: + result = dcerpc.samr_EnumDomainAliases(pipe, r) + if result['result'] == dcerpc.STATUS_MORE_ENTRIES: + r['resume_handle'] = result['resume_handle'] + continue + break + +def test_QueryDisplayInfo(pipe, domain_handle): + + print 'testing samr_QueryDisplayInfo' + + levels = [1, 2, 3, 4, 5] + + for i in range(0, len(levels)): + + r = {} + r['domain_handle'] = domain_handle + r['level'] = levels[i] + r['start_idx'] = 0 + r['max_entries'] = 1000 + r['buf_size'] = -1 + + dcerpc.samr_QueryDisplayInfo(pipe, r) + +def test_QueryDisplayInfo2(pipe, domain_handle): + + print 'testing samr_QueryDisplayInfo2' + + levels = [1, 2, 3, 4, 5] + + for i in range(0, len(levels)): + + r = {} + r['domain_handle'] = domain_handle + r['level'] = levels[i] + r['start_idx'] = 0 + r['max_entries'] = 1000 + r['buf_size'] = -1 + + dcerpc.samr_QueryDisplayInfo2(pipe, r) + +def test_QueryDisplayInfo3(pipe, domain_handle): + + print 'testing samr_QueryDisplayInfo3' + + levels = [1, 2, 3, 4, 5] + + for i in range(0, len(levels)): + + r = {} + r['domain_handle'] = domain_handle + r['level'] = levels[i] + r['start_idx'] = 0 + r['max_entries'] = 1000 + r['buf_size'] = -1 + + dcerpc.samr_QueryDisplayInfo3(pipe, r) + +def test_GetDisplayEnumerationIndex(pipe, domain_handle): + + print 'testing samr_GetDisplayEnumerationIndex' + + levels = [1, 2, 3, 4, 5] + ok_lvl = [1, 1, 1, 0, 0] + + for i in range(0, len(levels)): + + r = {} + r['domain_handle'] = domain_handle + r['level'] = levels[i] + r['name'] = {} + r['name']['name'] = 'samrtorturetest' + + try: + dcerpc.samr_GetDisplayEnumerationIndex(pipe, r) + except dcerpc.NTSTATUS, arg: + if ok_lvl[i]: + raise dcerpc.NTSTATUS(arg) + + r['name']['name'] = 'zzzzzzzz' + + try: + dcerpc.samr_GetDisplayEnumerationIndex(pipe, r) + except dcerpc.NTSTATUS, arg: + if ok_lvl[i]: + raise dcerpc.NTSTATUS(arg) + +def test_GetDisplayEnumerationIndex2(pipe, domain_handle): + + print 'testing samr_GetDisplayEnumerationIndex2' + + levels = [1, 2, 3, 4, 5] + ok_lvl = [1, 1, 1, 0, 0] + + for i in range(0, len(levels)): + + r = {} + r['domain_handle'] = domain_handle + r['level'] = levels[i] + r['name'] = {} + r['name']['name'] = 'samrtorturetest' + + try: + dcerpc.samr_GetDisplayEnumerationIndex2(pipe, r) + except dcerpc.NTSTATUS, arg: + if ok_lvl[i]: + raise dcerpc.NTSTATUS(arg) + + r['name']['name'] = 'zzzzzzzz' + + try: + dcerpc.samr_GetDisplayEnumerationIndex2(pipe, r) + except dcerpc.NTSTATUS, arg: + if ok_lvl[i]: + raise dcerpc.NTSTATUS(arg) + +def test_TestPrivateFunctionsDomain(pipe, domain_handle): + + print 'test samr.TestPrivateFunctionsDomain' + + r = {} + r['domain_handle'] = domain_handle + + try: + dcerpc.samr_TestPrivateFunctionsDomain(pipe, r) + except dcerpc.NTSTATUS, arg: + if arg[0] != dcerpc.NT_STATUS_NOT_IMPLEMENTED: + raise dcerpc.NTSTATUS(arg) + +def test_RidToSid(pipe, domain_handle): + + print 'testing samr_RidToSid' + + r = {} + r['domain_handle'] = domain_handle + r['rid'] = 512 + + dcerpc.samr_RidToSid(pipe, r) + +def test_GetBootKeyInformation(pipe, domain_handle): + + print 'testing samr_GetBootKeyInformation' + + r = {} + r['domain_handle'] = domain_handle + + try: + dcerpc.samr_GetBootKeyInformation(pipe, r) + except dcerpc.NTSTATUS, arg: + pass + +def test_DeleteUser(pipe, user_handle): + + r = {} + r['user_handle'] = user_handle + + dcerpc.samr_DeleteUser(pipe, r) + +def test_DeleteAlias(pipe, alias_handle): + + r = {} + r['alias_handle'] = alias_handle + + dcerpc.samr_DeleteDomAlias(pipe, r) + +def test_DeleteDomainGroup(pipe, group_handle): + + r = {} + r['group_handle'] = group_handle + + dcerpc.samr_DeleteDomainGroup(pipe, r) + +def test_Close(pipe, handle): + + r = {} + r['handle'] = handle + + dcerpc.samr_Close(pipe, r) + +def test_OpenDomain(pipe, connect_handle, domain_sid): + + print 'testing OpenDomain' + + domain_handle = connect_handle.OpenDomain(domain_sid) + + test_QuerySecurity(pipe, domain_handle) + + test_RemoveMemberFromForeignDomain(pipe, domain_handle) + + test_CreateUser2(pipe, domain_handle) + + sys.exit(0) + + user_handle = test_CreateUser(pipe, domain_handle) + + alias_handle = test_CreateAlias(pipe, domain_handle, domain_sid) + + group_handle = test_CreateDomainGroup(pipe, domain_handle) + + test_QueryDomainInfo(pipe, domain_handle) + + test_QueryDomainInfo2(pipe, domain_handle) + + test_EnumDomainUsers(pipe, domain_handle) + + test_EnumDomainGroups(pipe, domain_handle) + + test_EnumDomainAliases(pipe, domain_handle) + + test_QueryDisplayInfo(pipe, domain_handle) + + test_QueryDisplayInfo2(pipe, domain_handle) + + test_QueryDisplayInfo3(pipe, domain_handle) + + test_GetDisplayEnumerationIndex(pipe, domain_handle) + + test_GetDisplayEnumerationIndex2(pipe, domain_handle) + + test_TestPrivateFunctionsDomain(pipe, domain_handle) + + test_RidToSid(pipe, domain_handle) + + test_GetBootKeyInformation(pipe, domain_handle) + + if user_handle != None: + test_DeleteUser(pipe, user_handle) + + if alias_handle != None: + test_DeleteAlias(pipe, alias_handle) + + if group_handle != None: + test_DeleteDomainGroup(pipe, group_handle) + + test_Close(pipe, domain_handle) + +def test_LookupDomain(pipe, connect_handle, domain): + + print 'testing LookupDomain' + + sid = connect_handle.LookupDomain(domain) + + try: + connect_handle.LookupDomain('xxNODOMAINxx') + except dcerpc.NTSTATUS, arg: + if arg[0] != 0xC00000DFL: # NT_STATUS_NO_SUCH_DOMAIN + raise + + test_GetDomPwInfo(pipe, connect_handle, domain) + test_OpenDomain(pipe, connect_handle, sid) + +def test_EnumDomains(pipe, connect_handle): + + print 'testing EnumDomains' + + for domain in connect_handle.EnumDomains(): + test_LookupDomain(pipe, connect_handle, domain) + +def runtests(binding, domain, username, password): + + print 'Testing SAMR pipe' + + pipe = dcerpc.pipe_connect(binding, + dcerpc.DCERPC_SAMR_UUID, int(dcerpc.DCERPC_SAMR_VERSION), + domain, username, password) + + handle = test_Connect(pipe) + + test_QuerySecurity(pipe, handle) + + test_EnumDomains(pipe, handle) -- cgit From fd0aa010be16bd0a127fa3108b6b4a443ab6ebe6 Mon Sep 17 00:00:00 2001 From: Tim Potter Date: Sat, 12 Mar 2005 22:24:46 +0000 Subject: r5777: At some stage SIG_ATOMIC_T was renamed to sig_atomic_t. This should fix abartlet's compile problem. (This used to be commit 170139035ab1e7659a82e1e2d40990f4d7f146c3) --- source4/scripting/swig/tdb.i | 11 ++++------- 1 file changed, 4 insertions(+), 7 deletions(-) (limited to 'source4/scripting') diff --git a/source4/scripting/swig/tdb.i b/source4/scripting/swig/tdb.i index 0b169510c1..0110f33824 100644 --- a/source4/scripting/swig/tdb.i +++ b/source4/scripting/swig/tdb.i @@ -35,14 +35,11 @@ #undef HAVE_FSTAT #endif -/* The tdb_set_lock_alarm() function requires the SIG_ATOMIC_T - function from includes.h */ +/* The tdb_set_lock_alarm() function requires the sig_atomic_t type */ #include "include/config.h" -#if defined(HAVE_SIG_ATOMIC_T_TYPE) -typedef sig_atomic_t SIG_ATOMIC_T; -#else -typedef int SIG_ATOMIC_T; +#if !defined(HAVE_SIG_ATOMIC_T_TYPE) +typedef int sig_atomic_t #endif #if (__GNUC__ >= 3) @@ -140,7 +137,7 @@ int tdb_lockall(TDB_CONTEXT *tdb); void tdb_unlockall(TDB_CONTEXT *tdb); /* Low level locking functions: use with care */ -void tdb_set_lock_alarm(SIG_ATOMIC_T *palarm); +void tdb_set_lock_alarm(sig_atomic_t *palarm); int tdb_chainlock(TDB_CONTEXT *tdb, TDB_DATA key); int tdb_chainunlock(TDB_CONTEXT *tdb, TDB_DATA key); -- cgit From 1fb7f63aa9ce8b1b1384a7c907fbe1c0bbc9cd92 Mon Sep 17 00:00:00 2001 From: Tim Potter Date: Sun, 13 Mar 2005 01:01:24 +0000 Subject: r5778: Remove tdb_set_lock_alarm() function from wrappers at tridge's request. (This used to be commit 8b83eca265b6ad5f33e90beac67f3e1621010764) --- source4/scripting/swig/tdb.i | 8 -------- 1 file changed, 8 deletions(-) (limited to 'source4/scripting') diff --git a/source4/scripting/swig/tdb.i b/source4/scripting/swig/tdb.i index 0110f33824..a3d1a6ebbc 100644 --- a/source4/scripting/swig/tdb.i +++ b/source4/scripting/swig/tdb.i @@ -35,13 +35,6 @@ #undef HAVE_FSTAT #endif -/* The tdb_set_lock_alarm() function requires the sig_atomic_t type */ - -#include "include/config.h" -#if !defined(HAVE_SIG_ATOMIC_T_TYPE) -typedef int sig_atomic_t -#endif - #if (__GNUC__ >= 3) /** Use gcc attribute to check printf fns. a1 is the 1-based index of * the parameter containing the format, and a2 the index of the first @@ -137,7 +130,6 @@ int tdb_lockall(TDB_CONTEXT *tdb); void tdb_unlockall(TDB_CONTEXT *tdb); /* Low level locking functions: use with care */ -void tdb_set_lock_alarm(sig_atomic_t *palarm); int tdb_chainlock(TDB_CONTEXT *tdb, TDB_DATA key); int tdb_chainunlock(TDB_CONTEXT *tdb, TDB_DATA key); -- cgit From e1e8928840b632297e3cbbd19aeef5e075ff7798 Mon Sep 17 00:00:00 2001 From: Tim Potter Date: Tue, 5 Apr 2005 07:58:02 +0000 Subject: r6208: Add cli_credentials support for swig wrappers. For the moment it only does anonymous connections. (This used to be commit b09a4723539235fc924134aa50fc4aed040afb33) --- source4/scripting/swig/dcerpc.i | 7 +++---- source4/scripting/swig/samba.i | 6 ++++++ source4/scripting/swig/torture/pytorture | 2 +- source4/scripting/swig/torture/torture_samr.py | 5 ++--- 4 files changed, 12 insertions(+), 8 deletions(-) (limited to 'source4/scripting') diff --git a/source4/scripting/swig/dcerpc.i b/source4/scripting/swig/dcerpc.i index a1261f997d..a76e1301af 100644 --- a/source4/scripting/swig/dcerpc.i +++ b/source4/scripting/swig/dcerpc.i @@ -153,13 +153,12 @@ void set_werror_exception(int status) %rename(pipe_connect) dcerpc_pipe_connect; -NTSTATUS dcerpc_pipe_connect(struct dcerpc_pipe **OUT, +NTSTATUS dcerpc_pipe_connect(TALLOC_CTX *parent_ctx, + struct dcerpc_pipe **OUT, const char *binding, const char *pipe_uuid, uint32_t pipe_version, - const char *domain, - const char *username, - const char *password); + struct cli_credentials *credentials); %typemap(in) DATA_BLOB * (DATA_BLOB temp_data_blob) { temp_data_blob.data = PyString_AsString($input); diff --git a/source4/scripting/swig/samba.i b/source4/scripting/swig/samba.i index c7b8b46e66..620d908699 100644 --- a/source4/scripting/swig/samba.i +++ b/source4/scripting/swig/samba.i @@ -60,3 +60,9 @@ %typemap(out) NTSTATUS { $result = PyLong_FromUnsignedLong(NT_STATUS_V($1)); } + +%typemap(in) struct cli_credentials * { + $1 = cli_credentials_init(arg1); + cli_credentials_set_anonymous($1); +// cli_credentials_set_workstation($1, "FROGURT", CRED_SPECIFIED); +} diff --git a/source4/scripting/swig/torture/pytorture b/source4/scripting/swig/torture/pytorture index fd4a92eeb4..e0123447e8 100755 --- a/source4/scripting/swig/torture/pytorture +++ b/source4/scripting/swig/torture/pytorture @@ -48,4 +48,4 @@ for test in args: if not hasattr(module, 'runtests'): print 'Module "%s" does not have a runtests function' % test - module.runtests(binding, domain, username, password) + module.runtests(binding, (domain, username, password)) diff --git a/source4/scripting/swig/torture/torture_samr.py b/source4/scripting/swig/torture/torture_samr.py index 929420695d..2064d28044 100755 --- a/source4/scripting/swig/torture/torture_samr.py +++ b/source4/scripting/swig/torture/torture_samr.py @@ -721,13 +721,12 @@ def test_EnumDomains(pipe, connect_handle): for domain in connect_handle.EnumDomains(): test_LookupDomain(pipe, connect_handle, domain) -def runtests(binding, domain, username, password): +def runtests(binding, creds): print 'Testing SAMR pipe' pipe = dcerpc.pipe_connect(binding, - dcerpc.DCERPC_SAMR_UUID, int(dcerpc.DCERPC_SAMR_VERSION), - domain, username, password) + dcerpc.DCERPC_SAMR_UUID, int(dcerpc.DCERPC_SAMR_VERSION), creds) handle = test_Connect(pipe) -- cgit From d77e7cd774983e651ac6a2e679bdd6e6c73642d8 Mon Sep 17 00:00:00 2001 From: Tim Potter Date: Tue, 5 Apr 2005 09:18:36 +0000 Subject: r6210: Call cli_credentials_set_conf() when initialising credentials in cli_credentials typemap. (This used to be commit 1c88e71ec645d10648f01e0405d29a4a83bc4036) --- source4/scripting/swig/samba.i | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'source4/scripting') diff --git a/source4/scripting/swig/samba.i b/source4/scripting/swig/samba.i index 620d908699..4e0e0b7659 100644 --- a/source4/scripting/swig/samba.i +++ b/source4/scripting/swig/samba.i @@ -64,5 +64,5 @@ %typemap(in) struct cli_credentials * { $1 = cli_credentials_init(arg1); cli_credentials_set_anonymous($1); -// cli_credentials_set_workstation($1, "FROGURT", CRED_SPECIFIED); + cli_credentials_set_conf($1); } -- cgit From 2543885bf3a012aa8004ff81670fde26033ff1ff Mon Sep 17 00:00:00 2001 From: Tim Potter Date: Tue, 5 Apr 2005 09:38:51 +0000 Subject: r6211: Use cli_credentials_set_{domain,username,password}() to fill in command line arguments for credentials typemap. Neat! (This used to be commit a3e7d71463053101e743a930f2648269d63ecaca) --- source4/scripting/swig/samba.i | 19 ++++++++++++++++++- 1 file changed, 18 insertions(+), 1 deletion(-) (limited to 'source4/scripting') diff --git a/source4/scripting/swig/samba.i b/source4/scripting/swig/samba.i index 4e0e0b7659..25aef154cf 100644 --- a/source4/scripting/swig/samba.i +++ b/source4/scripting/swig/samba.i @@ -63,6 +63,23 @@ %typemap(in) struct cli_credentials * { $1 = cli_credentials_init(arg1); - cli_credentials_set_anonymous($1); cli_credentials_set_conf($1); + if ($input == Py_None) { + cli_credentials_set_anonymous($1); + } else { + if (!PyTuple_Check($input) || + PyTuple_Size($input) != 3) { + PyErr_SetString(PyExc_TypeError, "Expecting three element tuple"); + return NULL; + } + if (!PyString_Check(PyTuple_GetItem($input, 0)) || + !PyString_Check(PyTuple_GetItem($input, 1)) || + !PyString_Check(PyTuple_GetItem($input, 2))) { + PyErr_SetString(PyExc_TypeError, "Expecting string elements"); + return NULL; + } + cli_credentials_set_domain($1, PyString_AsString(PyTuple_GetItem($input, 0)), CRED_SPECIFIED); + cli_credentials_set_username($1, PyString_AsString(PyTuple_GetItem($input, 1)), CRED_SPECIFIED); + cli_credentials_set_password($1, PyString_AsString(PyTuple_GetItem($input, 2)), CRED_SPECIFIED); + } } -- cgit From 3b64edcfff68a696efb1d4e3aadfdd7dc339c49f Mon Sep 17 00:00:00 2001 From: Tim Potter Date: Tue, 5 Apr 2005 11:47:21 +0000 Subject: r6212: Treat uint8 and int8's as integers instead of chars. Swig maps a char to a string when we really want an integer. (This used to be commit 86c62b92e84a6eb1e756a7125777587583a9276e) --- source4/scripting/swig/samba.i | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'source4/scripting') diff --git a/source4/scripting/swig/samba.i b/source4/scripting/swig/samba.i index 25aef154cf..1446f9a8d5 100644 --- a/source4/scripting/swig/samba.i +++ b/source4/scripting/swig/samba.i @@ -24,8 +24,8 @@ Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ -%apply unsigned char { uint8_t }; -%apply char { int8_t }; +%apply int { uint8_t }; +%apply int { int8_t }; %apply unsigned int { uint16_t }; %apply int { int16_t }; %apply unsigned long long { uint64_t }; -- cgit From f0641cae5d39eaf4c26881be53f946367a1f49b9 Mon Sep 17 00:00:00 2001 From: Tim Potter Date: Tue, 5 Apr 2005 11:48:16 +0000 Subject: r6213: Add %array_functions for struct samr_String so we can create and access arrays of them. (This used to be commit fc2b73d4d75f383108632935ba047890c816b283) --- source4/scripting/swig/dcerpc.i | 1 + 1 file changed, 1 insertion(+) (limited to 'source4/scripting') diff --git a/source4/scripting/swig/dcerpc.i b/source4/scripting/swig/dcerpc.i index a76e1301af..d4de8365f2 100644 --- a/source4/scripting/swig/dcerpc.i +++ b/source4/scripting/swig/dcerpc.i @@ -228,6 +228,7 @@ char *nt_errstr(NTSTATUS nt_code); pidl to automatically generating these instead of having to find them all by hand. */ +%array_functions(struct samr_String, samr_String_array); %array_functions(struct samr_SamEntry, samr_SamEntry_array); %array_functions(union samr_ConnectInfo, samr_ConnectInfo_array); -- cgit From b796dc40771f082939e491180570e9697c03cf28 Mon Sep 17 00:00:00 2001 From: Tim Potter Date: Tue, 5 Apr 2005 11:50:47 +0000 Subject: r6214: Fix typo in DomainHandle.OpenUser() function. Implement DomainHandle.LookupNames() function. UserHandle.DeleteUser() closes the handle so don't try and close it when the GC destroys the class instance. (This used to be commit 57680163bcc1aa5c707a64dcd1d0998dbc9f0659) --- source4/scripting/swig/samr.py | 25 ++++++++++++++++++++++--- 1 file changed, 22 insertions(+), 3 deletions(-) (limited to 'source4/scripting') diff --git a/source4/scripting/swig/samr.py b/source4/scripting/swig/samr.py index 22b591930c..9782a9fc7b 100644 --- a/source4/scripting/swig/samr.py +++ b/source4/scripting/swig/samr.py @@ -323,7 +323,7 @@ class DomainHandle(SamrHandle): call_fn(dcerpc.dcerpc_samr_OpenUser, self.pipe, r) - return UserHandle(pipe, r.data_out.user_handle) + return UserHandle(self.pipe, r.data_out.user_handle) def OpenGroup(self, rid, access_mask = 0x02000000): @@ -363,7 +363,24 @@ class DomainHandle(SamrHandle): r.data_in.sid = sid call_fn(dcerpc.dcerpc_samr_RemoveMemberFromForeignDomain, self.pipe, r) - + + def LookupNames(self, names): + + r = dcerpc.samr_LookupNames() + r.data_in.domain_handle = self.handle + r.data_in.num_names = len(names) + r.data_in.names = dcerpc.new_samr_String_array(len(names)) + + for i in range(len(names)): + s = dcerpc.samr_String() + s.string = names[i] + dcerpc.samr_String_array_setitem(r.data_in.names, i, s) + + call_fn(dcerpc.dcerpc_samr_LookupNames, self.pipe, r) + + return ([dcerpc.uint32_array_getitem(r.data_out.rids.ids, i) for i in range(r.data_out.rids.count)], + [dcerpc.uint32_array_getitem(r.data_out.types.ids, i) for i in range(r.data_out.types.count)]) + class UserHandle(SamrHandle): @@ -371,8 +388,10 @@ class UserHandle(SamrHandle): r = dcerpc.samr_DeleteUser() r.data_in.user_handle = self.handle - + call_fn(dcerpc.dcerpc_samr_DeleteUser, self.pipe, r) + + self.handle = None class GroupHandle(SamrHandle): -- cgit From 86122d78e5356c0bce7dc0f6599d0efb2d09ee7c Mon Sep 17 00:00:00 2001 From: Tim Potter Date: Tue, 5 Apr 2005 11:54:53 +0000 Subject: r6215: Add test for LookupNames. Fix CreateUser2 test. (This used to be commit e3a69a73222ae3277c2d10d33c5c71b7a14da789) --- source4/scripting/swig/torture/torture_samr.py | 41 ++++++-------------------- 1 file changed, 9 insertions(+), 32 deletions(-) (limited to 'source4/scripting') diff --git a/source4/scripting/swig/torture/torture_samr.py b/source4/scripting/swig/torture/torture_samr.py index 2064d28044..ececbc9db6 100755 --- a/source4/scripting/swig/torture/torture_samr.py +++ b/source4/scripting/swig/torture/torture_samr.py @@ -49,7 +49,7 @@ def test_CreateUser2(pipe, domain_handle): return domain_handle.CreateUser2(username, 0x0080) # WSTRUST except dcerpc.NTSTATUS, arg: if arg[0] == 0x0c0000063L: - domain_handle.OpenUser(username).DeleteUser() + test_OpenUser_byname(pipe, domain_handle, username).DeleteUser() return domain_handle.CreateUser2(username) raise @@ -57,44 +57,21 @@ def test_LookupName(pipe, domain_handle, name): print 'test samr_LookupNames' - r = {} - r['domain_handle'] = domain_handle - r['num_names'] = 1 - r['names'] = [] - r['names'].append({'name': name}) - - result = dcerpc.samr_LookupNames(pipe, r) - - rid = result['rids']['ids'][0] - - r['num_names'] = 2 - r['names'].append({'name': 'xxNONAMExx'}) - + domain_handle.LookupNames(['Administrator', 'xxNONAMExx']) try: - dcerpc.samr_LookupNames(pipe, r) + domain_handle.LookupNames(['xxNONAMExx']) except dcerpc.NTSTATUS, arg: - if arg[0] != dcerpc.STATUS_SOME_UNMAPPED: + if arg[0] != 0xc0000073L: raise dcerpc.NTSTATUS(arg) - r['num_names'] = 0 - - dcerpc.samr_LookupNames(pipe, r) - - return rid + return domain_handle.LookupNames([name]) def test_OpenUser_byname(pipe, domain_handle, user_name): - rid = test_LookupName(pipe, domain_handle, user_name) - - r = {} - r['domain_handle'] = domain_handle - r['access_mask'] = 0x02000000 - r['rid'] = rid - - result = dcerpc.samr_OpenUser(pipe, r) + rids, types = test_LookupName(pipe, domain_handle, user_name) - return result['user_handle'] + return domain_handle.OpenUser(rids[0]) def test_DeleteUser_byname(pipe, domain_handle, user_name): @@ -218,7 +195,7 @@ def test_CreateUser(pipe, domain_handle): def test_DeleteAlias_byname(pipe, domain_handle, alias_name): - rid = test_LookupName(pipe, domain_handle, alias_name) + rid = test_LookupNames(pipe, domain_handle, alias_name) r = {} r['domain_handle'] = domain_handle @@ -339,7 +316,7 @@ def test_CreateAlias(pipe, domain_handle, domain_sid): def test_DeleteGroup_byname(pipe, domain_handle, group_name): - rid = test_LookupName(pipe, domain_handle, group_name) + rid = test_LookupNames(pipe, domain_handle, group_name) r = {} r['domain_handle'] = domain_handle -- cgit From 602be3fd493984bd85ddc6b2e1c98cd699bdd2a3 Mon Sep 17 00:00:00 2001 From: Tim Potter Date: Wed, 13 Apr 2005 05:57:51 +0000 Subject: r6324: Pass server name instead of binding string on command line (always use ncacn_np for the moment). Fix rpcclient to work with struct cli_credentials. (This used to be commit 162d3609a1f46683151d201a5404d0456d76b726) --- source4/scripting/swig/rpcclient | 41 +++++++++++++++++++--------------------- 1 file changed, 19 insertions(+), 22 deletions(-) (limited to 'source4/scripting') diff --git a/source4/scripting/swig/rpcclient b/source4/scripting/swig/rpcclient index 8f33a6133b..faf5b3ec09 100755 --- a/source4/scripting/swig/rpcclient +++ b/source4/scripting/swig/rpcclient @@ -28,9 +28,9 @@ class rpcclient(Cmd): prompt = 'rpcclient$ ' - def __init__(self, binding, domain, username, password): + def __init__(self, server, domain, username, password): Cmd.__init__(self) - self.binding = binding + self.server = server self.domain = domain self.username = username self.password = password @@ -83,9 +83,9 @@ class rpcclient(Cmd): return pipe = dcerpc.pipe_connect( - self.binding, + 'ncacn_np:%s' % self.server, dcerpc.DCERPC_SAMR_UUID, int(dcerpc.DCERPC_SAMR_VERSION), - self.domain, self.username, self.password) + (self.domain, self.username, self.password)) connect_handle = samr.Connect(pipe) @@ -105,9 +105,9 @@ class rpcclient(Cmd): return pipe = dcerpc.pipe_connect( - self.binding, + 'ncacn_np:%s' % self.server, dcerpc.DCERPC_SAMR_UUID, int(dcerpc.DCERPC_SAMR_VERSION), - self.domain, self.username, self.password) + (self.domain, self.username, self.password)) connect_handle = samr.Connect(pipe) @@ -126,9 +126,9 @@ class rpcclient(Cmd): return pipe = dcerpc.pipe_connect( - self.binding, + 'ncacn_np:%s' % self.server, dcerpc.DCERPC_SAMR_UUID, int(dcerpc.DCERPC_SAMR_VERSION), - self.domain, self.username, self.password) + (self.domain, self.username, self.password)) connect_handle = samr.Connect(pipe) domain_handle = connect_handle.OpenDomain(args[0]) @@ -153,9 +153,9 @@ class rpcclient(Cmd): return pipe = dcerpc.pipe_connect( - self.binding, + 'ncacn_np:%s' % self.server, dcerpc.DCERPC_SAMR_UUID, int(dcerpc.DCERPC_SAMR_VERSION), - self.domain, self.username, self.password) + (self.domain, self.username, self.password)) connect_handle = samr.Connect(pipe) domain_handle = connect_handle.OpenDomain(args[0]) @@ -180,9 +180,9 @@ class rpcclient(Cmd): return pipe = dcerpc.pipe_connect( - self.binding, + 'ncacn_np:%s' % self.server, dcerpc.DCERPC_SAMR_UUID, int(dcerpc.DCERPC_SAMR_VERSION), - self.domain, self.username, self.password) + (self.domain, self.username, self.password)) connect_handle = samr.Connect(pipe) domain_handle = connect_handle.OpenDomain(args[0]) @@ -205,9 +205,9 @@ class rpcclient(Cmd): return pipe = dcerpc.pipe_connect( - self.binding, + 'ncacn_np:%s' % self.server, dcerpc.DCERPC_SAMR_UUID, int(dcerpc.DCERPC_SAMR_VERSION), - self.domain, self.username, self.password) + (self.domain, self.username, self.password)) connect_handle = samr.Connect(pipe) domain_handle = connect_handle.OpenDomain(args[0]) @@ -229,9 +229,9 @@ class rpcclient(Cmd): return pipe = dcerpc.pipe_connect( - self.binding, + 'ncacn_np:%s' % self.server, dcerpc.DCERPC_SAMR_UUID, int(dcerpc.DCERPC_SAMR_VERSION), - self.domain, self.username, self.password) + (self.domain, self.username, self.password)) connect_handle = samr.Connect(pipe) domain_handle = connect_handle.OpenDomain(args[0]) @@ -247,18 +247,15 @@ if __name__ == '__main__': # Parse command line - usage = 'rpcclient BINDING [options]' + usage = 'rpcclient SERVER [options]' if len(sys.argv) == 1: print usage sys.exit(1) - binding = sys.argv[1] + server = sys.argv[1] del(sys.argv[1]) - if string.find(binding, ':') == -1: - binding = 'ncacn_np:' + binding - parser = OptionParser(usage) parser.add_option('-U', '--username', action='store', type='string', @@ -288,7 +285,7 @@ if __name__ == '__main__': # Run command loop - c = rpcclient(binding, domain, username, password) + c = rpcclient(server, domain, username, password) if options.command: c.onecmd(options.command) -- cgit From 041e4672085e9083ce4ce40d0af923fd55d0e454 Mon Sep 17 00:00:00 2001 From: Tim Potter Date: Wed, 13 Apr 2005 07:12:17 +0000 Subject: r6326: Add %array_functions for struct lsa_SidPtr. Pull in the auto-generated interface file for the lsa pipe (whaddayaknow it compiled first go!) (This used to be commit fd884ec433c825759624a47541521cbd3d07f5a1) --- source4/scripting/swig/dcerpc.i | 3 +++ 1 file changed, 3 insertions(+) (limited to 'source4/scripting') diff --git a/source4/scripting/swig/dcerpc.i b/source4/scripting/swig/dcerpc.i index d4de8365f2..e41d9e4e2f 100644 --- a/source4/scripting/swig/dcerpc.i +++ b/source4/scripting/swig/dcerpc.i @@ -232,6 +232,9 @@ char *nt_errstr(NTSTATUS nt_code); %array_functions(struct samr_SamEntry, samr_SamEntry_array); %array_functions(union samr_ConnectInfo, samr_ConnectInfo_array); +%array_functions(struct lsa_SidPtr, lsa_SidPtr_array); + %include "librpc/gen_ndr/misc.i" %include "librpc/gen_ndr/security.i" %include "librpc/gen_ndr/samr.i" +%include "librpc/gen_ndr/lsa.i" -- cgit From 621588c9e6cc4d72212f495de3ed95c47d37fbfd Mon Sep 17 00:00:00 2001 From: Tim Potter Date: Wed, 13 Apr 2005 07:13:00 +0000 Subject: r6327: Add LSA objects to dcerpc swig library. (This used to be commit b6e883a613e35ec3d5541a45efb80345578e2460) --- source4/scripting/swig/config.mk | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'source4/scripting') diff --git a/source4/scripting/swig/config.mk b/source4/scripting/swig/config.mk index 70dab7c28d..fad6b68bda 100644 --- a/source4/scripting/swig/config.mk +++ b/source4/scripting/swig/config.mk @@ -8,4 +8,4 @@ REQUIRED_SUBSYSTEMS = LIBTDB MAJOR_VERSION = 0 MINOR_VERSION = 0 RELEASE_VERSION = 1 -REQUIRED_SUBSYSTEMS = LIBCLI NDR_MISC LIBBASIC CONFIG RPC_NDR_SAMR +REQUIRED_SUBSYSTEMS = LIBCLI NDR_MISC LIBBASIC CONFIG RPC_NDR_SAMR RPC_NDR_LSA -- cgit From 0545dfe8565699b030b65e525d6a9649dcc7118c Mon Sep 17 00:00:00 2001 From: Tim Potter Date: Wed, 13 Apr 2005 07:14:33 +0000 Subject: r6328: Fix bug in OpenAlias. Implement DeleteDomAlias, QueryAliasInfo, SetAliasInfo, AddAliasMember, and AddMultipleMembersToAlias. Fix one of those annoying large integer warnings. (This used to be commit 25ed39651b020c9e4bda1d8aa8e2d78f918be3a2) --- source4/scripting/swig/samr.py | 75 +++++++++++++++++++++++++++++++++++++----- 1 file changed, 66 insertions(+), 9 deletions(-) (limited to 'source4/scripting') diff --git a/source4/scripting/swig/samr.py b/source4/scripting/swig/samr.py index 9782a9fc7b..8c0d3d32c0 100644 --- a/source4/scripting/swig/samr.py +++ b/source4/scripting/swig/samr.py @@ -94,7 +94,7 @@ def call_fn(fn, pipe, args): result = fn(pipe, args); - if result & 0xc0000000: + if result & 0xc0000000L: raise dcerpc.NTSTATUS(result, dcerpc.nt_errstr(result)); return result; @@ -345,7 +345,20 @@ class DomainHandle(SamrHandle): call_fn(dcerpc.dcerpc_samr_OpenAlias, self.pipe, r) - return AliasHandle(pipe, r.data_out.group_handle) + return AliasHandle(self.pipe, r.data_out.alias_handle) + + def CreateDomAlias(self, alias_name, access_mask = 0x02000000): + + r = dcerpc.samr_CreateDomAlias() + r.data_in.domain_handle = self.handle + r.data_in.alias_name = dcerpc.samr_String() + r.data_in.alias_name.string = alias_name + r.data_in.access_mask = access_mask + + call_fn(dcerpc.dcerpc_samr_CreateDomAlias, self.pipe, r) + + return (AliasHandle(self.pipe, r.data_out.alias_handle), + r.data_out.rid) def RidToSid(self, rid): @@ -399,8 +412,57 @@ class GroupHandle(SamrHandle): class AliasHandle(SamrHandle): - pass - + + def DeleteDomAlias(self): + + r = dcerpc.samr_DeleteDomAlias() + r.data_in.alias_handle = self.handle + + call_fn(dcerpc.dcerpc_samr_DeleteDomAlias, self.pipe, r) + + self.handle = None + + def QueryAliasInfo(self, level = 1): + + r = dcerpc.samr_QueryAliasInfo() + r.data_in.alias_handle = self.handle + r.data_in.level = level + + call_fn(dcerpc.dcerpc_samr_QueryAliasInfo, self.pipe, r) + + return r.data_out.info + + def SetAliasInfo(self, level, info): + + r = dcerpc.samr_SetAliasInfo() + r.data_in.alias_handle = self.handle + r.data_in.level = level + r.data_in.info = info + + call_fn(dcerpc.dcerpc_samr_SetAliasInfo, self.pipe, r) + + def AddAliasMember(self, sid): + + r = dcerpc.samr_AddAliasMember() + r.data_in.alias_handle = self.handle + r.data_in.sid = string_to_sid(sid) + + call_fn(dcerpc.dcerpc_samr_AddAliasMember, self.pipe, r) + + def AddMultipleMembersToAlias(self, sids): + + r = dcerpc.samr_AddMultipleMembersToAlias() + r.data_in.alias_handle = self.handle + r.data_in.sids = dcerpc.lsa_SidArray() + r.data_in.sids.num_sids = len(sids) + r.data_in.sids.sids = dcerpc.new_lsa_SidPtr_array(len(sids)) + + for i in range(len(sids)): + s = dcerpc.lsa_SidPtr() + s.sid = string_to_sid(sids[i]) + dcerpc.lsa_SidPtr_array_setitem(r.data_in.sids.sids, i, s) + + call_fn(dcerpc.dcerpc_samr_AddMultipleMembersToAlias, self.pipe, r) def Connect(pipe, access_mask = 0x02000000): @@ -466,7 +528,6 @@ def Connect5(pipe, system_name = '', access_mask = 0x02000000): # CreateDomainGroup -# CreateDomAlias # GetAliasMembership # LookupNames # QueryGroupInfo @@ -476,9 +537,6 @@ def Connect5(pipe, system_name = '', access_mask = 0x02000000): # DeleteGroupMember # QueryGroupMember # SetMemberAttributesofGroup -# QueryAliasInfo -# SetAliasInfo -# DeleteDomAlias # AddAliasMember # DeleteAliasMember # GetMembersinAlias @@ -497,7 +555,6 @@ def Connect5(pipe, system_name = '', access_mask = 0x02000000): # QueryDisplayInfo2 # GetDisplayEnumerationIndex2 # QueryDisplayInfo3 -# AddMultipleMembersToAlias # RemoveMultipleMembersFromAlias # OemChangePasswordUser2 # ChangePasswordUser2 -- cgit From 6f036daaa4a3f8c73512a7549a399e9b0f1f2758 Mon Sep 17 00:00:00 2001 From: Tim Potter Date: Wed, 13 Apr 2005 07:15:43 +0000 Subject: r6329: Write tests for newly implemented alias functions. (This used to be commit 30d0c9fb2ededb86e40b985820a426f8df84053b) --- source4/scripting/swig/torture/torture_samr.py | 171 ++++++++----------------- 1 file changed, 52 insertions(+), 119 deletions(-) (limited to 'source4/scripting') diff --git a/source4/scripting/swig/torture/torture_samr.py b/source4/scripting/swig/torture/torture_samr.py index ececbc9db6..2d1dfb6a95 100755 --- a/source4/scripting/swig/torture/torture_samr.py +++ b/source4/scripting/swig/torture/torture_samr.py @@ -11,7 +11,7 @@ def test_Connect(pipe): handle = samr.Connect2(pipe) handle = samr.Connect3(pipe) handle = samr.Connect4(pipe) - handle = samr.Connect5(pipe) +# handle = samr.Connect5(pipe) # win2k3 only? return handle @@ -33,7 +33,7 @@ def test_GetDomPwInfo(pipe, handle, domain): def test_RemoveMemberFromForeignDomain(pipe, domain_handle): - print 'test RemoveMemberFromForeignDomain' + print 'testing RemoveMemberFromForeignDomain' sid = samr.string_to_sid('S-1-5-32-12-34-56-78-9') @@ -41,7 +41,7 @@ def test_RemoveMemberFromForeignDomain(pipe, domain_handle): def test_CreateUser2(pipe, domain_handle): - print 'test CreateUser2' + print 'testing CreateUser2' username = 'samrtorturemach$' @@ -55,7 +55,7 @@ def test_CreateUser2(pipe, domain_handle): def test_LookupName(pipe, domain_handle, name): - print 'test samr_LookupNames' + print 'testing samr_LookupNames' domain_handle.LookupNames(['Administrator', 'xxNONAMExx']) @@ -84,7 +84,7 @@ def test_DeleteUser_byname(pipe, domain_handle, user_name): def test_QueryUserInfo(pipe, user_handle): - print 'test samr_QueryUserInfo' + print 'testing samr_QueryUserInfo' levels = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 16, 17, 20, 21] @@ -97,7 +97,7 @@ def test_QueryUserInfo(pipe, user_handle): def test_QueryUserInfo2(pipe, user_handle): - print 'test samr_QueryUserInfo2' + print 'testing samr_QueryUserInfo2' levels = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 16, 17, 20, 21] @@ -126,7 +126,7 @@ def test_SetUserInfo(pipe, user_handle): def test_GetUserPwInfo(pipe, user_handle): - print 'test samr_GetUserpwInfo' + print 'testing samr_GetUserpwInfo' r = {} r['user_handle'] = user_handle @@ -135,7 +135,7 @@ def test_GetUserPwInfo(pipe, user_handle): def test_TestPrivateFunctionsUser(pipe, user_handle): - print 'test samr.TestPrivateFunctionsUser' + print 'testing samr.TestPrivateFunctionsUser' r = {} r['user_handle'] = user_handle @@ -162,64 +162,14 @@ def test_user_ops(pipe, user_handle): def test_CreateUser(pipe, domain_handle): - print 'test samr_CreateUser' - - r = {} - r['domain_handle'] = domain_handle - r['account_name'] = {} - r['account_name']['name'] = 'samrtorturetest' - r['access_mask'] = 0x02000000 + username = 'samrtorturetest' try: - result = dcerpc.samr_CreateUser(pipe, r) + return domain_handle.CreateUser(username) except dcerpc.NTSTATUS, arg: - if arg[0] == dcerpc.NT_STATUS_ACCESS_DENIED: - return - elif arg[0] == dcerpc.NT_STATUS_USER_EXISTS: - test_DeleteUser_byname(pipe, domain_handle, 'samrtorturetest') - result = dcerpc.samr_CreateUser(pipe, r) - else: - raise dcerpc.NTSTATUS(arg) - - user_handle = result['user_handle'] - - q = {} - q['user_handle'] = user_handle - q['level'] = 16 - - dcerpc.samr_QueryUserInfo(pipe, q) - - test_user_ops(pipe, user_handle) - - return user_handle - -def test_DeleteAlias_byname(pipe, domain_handle, alias_name): - - rid = test_LookupNames(pipe, domain_handle, alias_name) - - r = {} - r['domain_handle'] = domain_handle - r['access_mask'] = 0x02000000 - r['rid'] = rid - - result = dcerpc.samr_OpenAlias(pipe, r) - - s = {} - s['alias_handle'] = result['alias_handle'] - - dcerpc.samr_DeleteDomAlias(pipe, s) - -def test_QueryAliasInfo(pipe, alias_handle): - - levels = [1, 2, 3] - - for i in range(0, len(levels)): - - r = {} - r['alias_handle'] = alias_handle - r['level'] = levels[i] - - dcerpc.samr_QueryAliasInfo(pipe, r) + if arg[0] == 0xc0000063L: + test_OpenUser_byname(pipe, domain_handle, username).DeleteUser() + return domain_handle.CreateUser(username) def test_SetAliasInfo(pipe, alias_handle): @@ -240,79 +190,62 @@ def test_SetAliasInfo(pipe, alias_handle): dcerpc.samr_SetAliasInfo(pipe, r) -def test_AddMemberToAlias(pipe, alias_handle, domain_sid): - - r = {} - r['alias_handle'] = alias_handle - r['sid'] = domain_sid - - r['sid']['num_auths'] = r['sid']['num_auths'] + 1 - r['sid']['sub_auths'].append(512) +def test_Aliases(pipe, domain_handle, domain_sid): - dcerpc.samr_AddAliasMember(pipe, r) + print 'testing aliases' - dcerpc.samr_DeleteAliasMember(pipe, r) + aliasname = 'samrtorturetestalias' -def test_AddMultipleMembersToAlias(pipe, alias_handle): + # Create a new alias - r = {} - r['alias_handle'] = alias_handle - r['sids'] = {} - r['sids']['num_sids'] = 2 - r['sids']['sids'] = [] + try: - for i in range(0,2): - sid = {} - sid['sid_rev_num'] = 1 - sid['id_auth'] = [0, 0, 0, 0, 0, 5] - sid['num_auths'] = 5 - sid['sub_auths'] = [21, 737922324, -1292160505, 1285293260, 512 + i] + handle, rid = domain_handle.CreateDomAlias(aliasname) - r['sids']['sids'].append({'sid': sid}) + except dcerpc.NTSTATUS, arg: - dcerpc.samr_AddMultipleMembersToAlias(pipe, r) + if arg[0] == 0x0c0000154L: - dcerpc.samr_RemoveMultipleMembersFromAlias(pipe, r) + # Alias exists, delete it and try again -def test_alias_ops(pipe, alias_handle, domain_sid): + rids, types = domain_handle.LookupNames([aliasname]) + domain_handle.OpenAlias(rids[0]).DeleteDomAlias() - test_QuerySecurity(pipe, alias_handle) + handle, rid = domain_handle.CreateDomAlias(aliasname) + + else: + raise - test_QueryAliasInfo(pipe, alias_handle) + # QuerySecurity/GetSecurity - test_SetAliasInfo(pipe, alias_handle) + handle.SetSecurity(handle.QuerySecurity()) - test_AddMemberToAlias(pipe, alias_handle, domain_sid) + # QueryAliasInfo/SetAliasInfo - test_AddMultipleMembersToAlias(pipe, alias_handle) + for i in [1, 2, 3]: + info = handle.QueryAliasInfo(i) + try: + handle.SetAliasInfo(i, info) + except dcerpc.NTSTATUS, arg: -def test_CreateAlias(pipe, domain_handle, domain_sid): + # Can't set alias info level 1 - print 'test samr_CreateAlias' + if not (arg[0] == 0xC0000003L and i == 1): + raise - alias_name = 'samrtorturetestalias' + # AddAliasMember - r = {} - r['domain_handle'] = domain_handle - r['aliasname'] = {} - r['aliasname']['name'] = alias_name - r['access_mask'] = 0x02000000 + handle.AddAliasMember('S-1-5-21-1606980848-1677128483-854245398-500') - try: - result = dcerpc.samr_CreateDomAlias(pipe, r) - except dcerpc.NTSTATUS, arg: - if arg[0] == dcerpc.NT_STATUS_ACCESS_DENIED: - return - if arg[0] != dcerpc.NT_STATUS_USER_EXISTS: - raise dcerpc.NTSTATUS(arg) - test_DeleteAlias_byname(pipe, domain_handle, alias_name) - result = dcerpc.samr_CreateDomAlias(pipe, r) + # AddMultipleMembersToAlias - alias_handle = result['alias_handle'] + handle.AddMultipleMembersToAlias( + ['S-1-5-21-1606980848-1677128483-854245398-501', + 'S-1-5-21-1606980848-1677128483-854245398-502']) - test_alias_ops(pipe, alias_handle, domain_sid) + # DeleteDomAlias - return alias_handle + handle.DeleteDomAlias() def test_DeleteGroup_byname(pipe, domain_handle, group_name): @@ -558,7 +491,7 @@ def test_GetDisplayEnumerationIndex2(pipe, domain_handle): def test_TestPrivateFunctionsDomain(pipe, domain_handle): - print 'test samr.TestPrivateFunctionsDomain' + print 'testing samr.TestPrivateFunctionsDomain' r = {} r['domain_handle'] = domain_handle @@ -631,13 +564,13 @@ def test_OpenDomain(pipe, connect_handle, domain_sid): test_CreateUser2(pipe, domain_handle) - sys.exit(0) + test_CreateUser(pipe, domain_handle) - user_handle = test_CreateUser(pipe, domain_handle) + test_Aliases(pipe, domain_handle, domain_sid) - alias_handle = test_CreateAlias(pipe, domain_handle, domain_sid) + sys.exit(0) - group_handle = test_CreateDomainGroup(pipe, domain_handle) + test_CreateDomainGroup(pipe, domain_handle) test_QueryDomainInfo(pipe, domain_handle) -- cgit From c06297f776d92354e92f0ddda659778d57f426e5 Mon Sep 17 00:00:00 2001 From: Tim Potter Date: Mon, 25 Apr 2005 12:15:19 +0000 Subject: r6469: Add CreateDomainGroup, GetAliasMembership. (This used to be commit acf1d0a1b554736361f38bcd74961d4e6c1b12bd) --- source4/scripting/swig/samr.py | 30 ++++++++++++++++++++++++++---- 1 file changed, 26 insertions(+), 4 deletions(-) (limited to 'source4/scripting') diff --git a/source4/scripting/swig/samr.py b/source4/scripting/swig/samr.py index 8c0d3d32c0..4ba58c1c04 100644 --- a/source4/scripting/swig/samr.py +++ b/source4/scripting/swig/samr.py @@ -394,6 +394,32 @@ class DomainHandle(SamrHandle): return ([dcerpc.uint32_array_getitem(r.data_out.rids.ids, i) for i in range(r.data_out.rids.count)], [dcerpc.uint32_array_getitem(r.data_out.types.ids, i) for i in range(r.data_out.types.count)]) + def CreateDomainGroup(self, domain_name, access_mask = 0x02000000): + + r = dcerpc.samr_CreateDomainGroup() + r.data_in.domain_handle = self.handle + r.data_in.name = dcerpc.samr_String() + r.data_in.name.string = domain_name + r.data_in.access_mask = access_mask + + call_fn(dcerpc.dcerpc_samr_CreateDomainGroup, self.pipe, r) + + def GetAliasMembership(self, sids): + + r = dcerpc.samr_GetAliasMembership() + r.data_in.domain_handle = self.handle + r.data_in.sids = dcerpc.lsa_SidArray() + r.data_in.sids.num_sids = len(sids) + r.data_in.sids.sids = dcerpc.new_lsa_SidPtr_array(len(sids)) + + for i in range(len(sids)): + s = dcerpc.lsa_SidPtr() + s.sid = string_to_sid(sids[i]) + dcerpc.lsa_SidPtr_array_setitem(r.data_in.sids.sids, i, s) + + call_fn(dcerpc.dcerpc_samr_GetAliasMembership, self.pipe, r) + + return [r.ids[x] x in range(r.count)] class UserHandle(SamrHandle): @@ -526,10 +552,6 @@ def Connect5(pipe, system_name = '', access_mask = 0x02000000): return ConnectHandle(pipe, r.data_out.connect_handle) - -# CreateDomainGroup -# GetAliasMembership -# LookupNames # QueryGroupInfo # SetGroupInfo # AddGroupMember -- cgit From df13db69cc659848aba455cbb95ceb86d9d0e5b8 Mon Sep 17 00:00:00 2001 From: Tim Potter Date: Thu, 28 Apr 2005 06:36:00 +0000 Subject: r6506: Rename parameter to GetDomPwInfo. (This used to be commit 1542a13493bb9bf33d5f09dca273957bb4333862) --- source4/scripting/swig/samr.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'source4/scripting') diff --git a/source4/scripting/swig/samr.py b/source4/scripting/swig/samr.py index 4ba58c1c04..b6b1577c02 100644 --- a/source4/scripting/swig/samr.py +++ b/source4/scripting/swig/samr.py @@ -195,11 +195,11 @@ class ConnectHandle(SamrHandle): call_fn(dcerpc.dcerpc_samr_Shutdown, self.pipe, r) - def GetDomPwInfo(self, system_name): + def GetDomPwInfo(self, domain_name): r = dcerpc.samr_GetDomPwInfo() r.data_in.domain_name = dcerpc.samr_String() - r.data_in.domain_name.string = system_name + r.data_in.domain_name.string = domain_name call_fn(dcerpc.dcerpc_samr_GetDomPwInfo, self.pipe, r) -- cgit From 416434fbc43e37a1d21eef611d0a9ba2cc9faea7 Mon Sep 17 00:00:00 2001 From: Tim Potter Date: Thu, 28 Apr 2005 07:05:48 +0000 Subject: r6507: Fix syntax error in GetAliasMembership(). Implement SetDomainInfo() which got lost somehow. (This used to be commit 3055addde60687acdcf4e92dcb08e7f8dfdfb8f1) --- source4/scripting/swig/samr.py | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) (limited to 'source4/scripting') diff --git a/source4/scripting/swig/samr.py b/source4/scripting/swig/samr.py index b6b1577c02..85d5fa0d77 100644 --- a/source4/scripting/swig/samr.py +++ b/source4/scripting/swig/samr.py @@ -228,6 +228,16 @@ class DomainHandle(SamrHandle): return getattr(r.data_out.info, 'info%d' % level) + def SetDomainInfo(self, level, info): + + r = dcerpc.samr_SetDomainInfo() + r.data_in.domain_handle = self.handle + r.data_in.level = level + r.data_in.info = dcerpc.samr_DomainInfo() + setattr(r.data_in.info, 'info%d' % level, info) + + call_fn(dcerpc.dcerpc_samr_SetDomainInfo, self.pipe, r) + def EnumDomainGroups(self): r = dcerpc.samr_EnumDomainGroups() @@ -419,7 +429,7 @@ class DomainHandle(SamrHandle): call_fn(dcerpc.dcerpc_samr_GetAliasMembership, self.pipe, r) - return [r.ids[x] x in range(r.count)] + return [r.ids[x] for x in range(r.count)] class UserHandle(SamrHandle): -- cgit From 25601d2d67f5ae2d539541d310fe6c3431e6a890 Mon Sep 17 00:00:00 2001 From: Tim Potter Date: Thu, 28 Apr 2005 07:22:21 +0000 Subject: r6508: Fix typo - yay testsuite. (This used to be commit 61da936dbc491d0ec2d733d9ba155c3df01b8847) --- source4/scripting/swig/samr.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'source4/scripting') diff --git a/source4/scripting/swig/samr.py b/source4/scripting/swig/samr.py index 85d5fa0d77..4796d748eb 100644 --- a/source4/scripting/swig/samr.py +++ b/source4/scripting/swig/samr.py @@ -344,7 +344,7 @@ class DomainHandle(SamrHandle): call_fn(dcerpc.dcerpc_samr_OpenGroup, self.pipe, r) - return GroupHandle(pipe, r.data_out.group_handle) + return GroupHandle(self.pipe, r.data_out.group_handle) def OpenAlias(self, rid, access_mask = 0x02000000): -- cgit From 93e41274c56e564f6d4f2ca657aca29c1eb340c7 Mon Sep 17 00:00:00 2001 From: Tim Potter Date: Thu, 28 Apr 2005 07:44:49 +0000 Subject: r6510: Initialise rid parameter in samr_RidToSid(). This is faulting for me on win2k - not sure why. Add dodgy implementations of QueryDisplayInfo{,2,3}() (This used to be commit 2e44402751f77fcbd9c89299d8533e91207de49f) --- source4/scripting/swig/samr.py | 60 +++++++++++++++++++++++++++++++++++++++--- 1 file changed, 56 insertions(+), 4 deletions(-) (limited to 'source4/scripting') diff --git a/source4/scripting/swig/samr.py b/source4/scripting/swig/samr.py index 4796d748eb..4346bf88f4 100644 --- a/source4/scripting/swig/samr.py +++ b/source4/scripting/swig/samr.py @@ -374,6 +374,7 @@ class DomainHandle(SamrHandle): r = dcerpc.samr_RidToSid() r.data_in.domain_handle = self.handle + r.data_in.rid = rid call_fn(dcerpc.dcerpc_samr_RidToSid, self.pipe, r) @@ -431,6 +432,61 @@ class DomainHandle(SamrHandle): return [r.ids[x] for x in range(r.count)] + def QueryDisplayInfo(self, level): + + # TODO: Handle more data returns + + r = dcerpc.samr_QueryDisplayInfo() + r.data_in.domain_handle = self.handle + r.data_in.level = level + r.data_in.start_idx = 0 + r.data_in.max_entries = 1000 + r.data_in.buf_size = -1 + + call_fn(dcerpc.dcerpc_samr_QueryDisplayInfo, self.pipe, r) + + # TODO: Return a mapping of the various samr_DispInfo + # structures here. + + return getattr(r.data_out.info, 'info%d' % level) + + def QueryDisplayInfo2(self, level): + + # TODO: Handle more data returns + + r = dcerpc.samr_QueryDisplayInfo2() + r.data_in.domain_handle = self.handle + r.data_in.level = level + r.data_in.start_idx = 0 + r.data_in.max_entries = 1000 + r.data_in.buf_size = -1 + + call_fn(dcerpc.dcerpc_samr_QueryDisplayInfo2, self.pipe, r) + + # TODO: Return a mapping of the various samr_DispInfo + # structures here. + + return getattr(r.data_out.info, 'info%d' % level) + + def QueryDisplayInfo3(self, level): + + # TODO: Handle more data returns + + r = dcerpc.samr_QueryDisplayInfo3() + r.data_in.domain_handle = self.handle + r.data_in.level = level + r.data_in.start_idx = 0 + r.data_in.max_entries = 1000 + r.data_in.buf_size = -1 + + call_fn(dcerpc.dcerpc_samr_QueryDisplayInfo3, self.pipe, r) + + # TODO: Return a mapping of the various samr_DispInfo + # structures here. + + return getattr(r.data_out.info, 'info%d' % level) + + class UserHandle(SamrHandle): def DeleteUser(self): @@ -576,17 +632,13 @@ def Connect5(pipe, system_name = '', access_mask = 0x02000000): # SetUserInfo # ChangePasswordUser # GetGroupsForUser -# QueryDisplayInfo # GetDisplayEnumerationIndex # TestPrivateFunctionsDomain # TestPrivateFunctionsUser # GetUserPwInfo # RemoveMemberFromForeignDomain -# QueryDomainInfo2 # QueryUserInfo2 -# QueryDisplayInfo2 # GetDisplayEnumerationIndex2 -# QueryDisplayInfo3 # RemoveMultipleMembersFromAlias # OemChangePasswordUser2 # ChangePasswordUser2 -- cgit From 5fef58af7403bfd254a13e01804f9d4a081cb6c9 Mon Sep 17 00:00:00 2001 From: Tim Potter Date: Thu, 28 Apr 2005 07:51:41 +0000 Subject: r6511: Implement GetUserPwInfo(), QueryUserInfo(), QueryUserInfo2(). (This used to be commit f9742de617b6f1f24b75ae5af18a476f03c0b732) --- source4/scripting/swig/samr.py | 34 +++++++++++++++++++++++++++++----- 1 file changed, 29 insertions(+), 5 deletions(-) (limited to 'source4/scripting') diff --git a/source4/scripting/swig/samr.py b/source4/scripting/swig/samr.py index 4346bf88f4..c254acd11b 100644 --- a/source4/scripting/swig/samr.py +++ b/source4/scripting/swig/samr.py @@ -497,7 +497,35 @@ class UserHandle(SamrHandle): call_fn(dcerpc.dcerpc_samr_DeleteUser, self.pipe, r) self.handle = None - + + def GetUserPwInfo(self): + + r = dcerpc.samr_GetUserPwInfo() + r.data_in.user_handle = self.handle + + call_fn(dcerpc.dcerpc_samr_GetUserPwInfo, self.pipe, r) + + return r.data_out.info + + def QueryUserInfo(self, level): + + r = dcerpc.samr_QueryUserInfo() + r.data_in.user_handle = self.handle + r.data_in.level = level + + call_fn(dcerpc.dcerpc_samr_QueryUserInfo, self.pipe, r) + + return r.data_out.info + + def QueryUserInfo2(self, level): + + r = dcerpc.samr_QueryUserInfo2() + r.data_in.user_handle = self.handle + r.data_in.level = level + + call_fn(dcerpc.dcerpc_samr_QueryUserInfo2, self.pipe, r) + + return r.data_out.info class GroupHandle(SamrHandle): pass @@ -603,7 +631,6 @@ def Connect4(pipe, system_name = '', access_mask = 0x02000000): return ConnectHandle(pipe, r.data_out.connect_handle) - def Connect5(pipe, system_name = '', access_mask = 0x02000000): r = dcerpc.samr_Connect5() @@ -628,16 +655,13 @@ def Connect5(pipe, system_name = '', access_mask = 0x02000000): # AddAliasMember # DeleteAliasMember # GetMembersinAlias -# QueryUserInfo # SetUserInfo # ChangePasswordUser # GetGroupsForUser # GetDisplayEnumerationIndex # TestPrivateFunctionsDomain # TestPrivateFunctionsUser -# GetUserPwInfo # RemoveMemberFromForeignDomain -# QueryUserInfo2 # GetDisplayEnumerationIndex2 # RemoveMultipleMembersFromAlias # OemChangePasswordUser2 -- cgit From c23d22e4f114156f5ec2cff050bafe47660182a7 Mon Sep 17 00:00:00 2001 From: Tim Potter Date: Thu, 28 Apr 2005 07:52:32 +0000 Subject: r6512: Refactor samr torture test to use the nicer OO interface instead of the previous dictionary based SWIG interface (which was broken anyway). (This used to be commit 16b7e503bdbe4da96158e504790b1501a99d6db3) --- source4/scripting/swig/torture/torture_samr.py | 640 ++++--------------------- 1 file changed, 88 insertions(+), 552 deletions(-) (limited to 'source4/scripting') diff --git a/source4/scripting/swig/torture/torture_samr.py b/source4/scripting/swig/torture/torture_samr.py index 2d1dfb6a95..9025fdd978 100755 --- a/source4/scripting/swig/torture/torture_samr.py +++ b/source4/scripting/swig/torture/torture_samr.py @@ -5,631 +5,170 @@ import dcerpc, samr def test_Connect(pipe): - print 'testing Connect' - handle = samr.Connect(pipe) handle = samr.Connect2(pipe) handle = samr.Connect3(pipe) handle = samr.Connect4(pipe) -# handle = samr.Connect5(pipe) # win2k3 only? - - return handle - -def test_QuerySecurity(pipe, handle): - - print 'testing QuerySecurity' - - sdbuf = handle.QuerySecurity() - handle.SetSecurity(sdbuf) - - -def test_GetDomPwInfo(pipe, handle, domain): - - print 'testing GetDomPwInfo' - - handle.GetDomPwInfo(domain) - handle.GetDomPwInfo('__NONAME__') - handle.GetDomPwInfo('Builtin') - -def test_RemoveMemberFromForeignDomain(pipe, domain_handle): - - print 'testing RemoveMemberFromForeignDomain' - - sid = samr.string_to_sid('S-1-5-32-12-34-56-78-9') - - domain_handle.RemoveMemberFromForeignDomain(sid) - -def test_CreateUser2(pipe, domain_handle): - - print 'testing CreateUser2' - - username = 'samrtorturemach$' - - try: - return domain_handle.CreateUser2(username, 0x0080) # WSTRUST - except dcerpc.NTSTATUS, arg: - if arg[0] == 0x0c0000063L: - test_OpenUser_byname(pipe, domain_handle, username).DeleteUser() - return domain_handle.CreateUser2(username) - raise - -def test_LookupName(pipe, domain_handle, name): - - print 'testing samr_LookupNames' - - domain_handle.LookupNames(['Administrator', 'xxNONAMExx']) - - try: - domain_handle.LookupNames(['xxNONAMExx']) - except dcerpc.NTSTATUS, arg: - if arg[0] != 0xc0000073L: - raise dcerpc.NTSTATUS(arg) - - return domain_handle.LookupNames([name]) - -def test_OpenUser_byname(pipe, domain_handle, user_name): - - rids, types = test_LookupName(pipe, domain_handle, user_name) - - return domain_handle.OpenUser(rids[0]) -def test_DeleteUser_byname(pipe, domain_handle, user_name): - - user_handle = test_OpenUser_byname(pipe, domain_handle, user_name) + # WIN2K3 only? - r = {} - r['user_handle'] = user_handle - - dcerpc.samr_DeleteUser(pipe, r) - -def test_QueryUserInfo(pipe, user_handle): - - print 'testing samr_QueryUserInfo' - - levels = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 16, 17, 20, 21] - - for level in levels: - r = {} - r['user_handle'] = user_handle - r['level'] = level - - dcerpc.samr_QueryUserInfo(pipe, r) - -def test_QueryUserInfo2(pipe, user_handle): - - print 'testing samr_QueryUserInfo2' - - levels = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 16, 17, 20, 21] - - for level in levels: - r = {} - r['user_handle'] = user_handle - r['level'] = level - - dcerpc.samr_QueryUserInfo2(pipe, r) - -def test_SetUserInfo(pipe, user_handle): - - r = {} - r['user_handle'] = user_handle - r['level'] = 2 - r['info'] = {} - r['info']['info2'] = {} - r['info']['info2']['comment'] = {} - r['info']['info2']['comment']['name'] = 'hello' - r['info']['info2']['unknown'] = {} - r['info']['info2']['unknown']['name'] = None - r['info']['info2']['country_code'] = 0 - r['info']['info2']['code_page'] = 0 - - dcerpc.samr_SetUserInfo(pipe, r) - -def test_GetUserPwInfo(pipe, user_handle): - - print 'testing samr_GetUserpwInfo' - - r = {} - r['user_handle'] = user_handle - - dcerpc.samr_GetUserPwInfo(pipe, r) - -def test_TestPrivateFunctionsUser(pipe, user_handle): - - print 'testing samr.TestPrivateFunctionsUser' - - r = {} - r['user_handle'] = user_handle - - try: - dcerpc.samr_TestPrivateFunctionsUser(pipe, r) - except dcerpc.NTSTATUS, arg: - if arg[0] != dcerpc.NT_STATUS_NOT_IMPLEMENTED: - raise dcerpc.NTSTATUS(arg) - -def test_user_ops(pipe, user_handle): - - test_QuerySecurity(pipe, user_handle) - - test_QueryUserInfo(pipe, user_handle) - - test_QueryUserInfo2(pipe, user_handle) - - test_SetUserInfo(pipe, user_handle) - - test_GetUserPwInfo(pipe, user_handle) - - test_TestPrivateFunctionsUser(pipe, user_handle) - -def test_CreateUser(pipe, domain_handle): - - username = 'samrtorturetest' - try: - return domain_handle.CreateUser(username) + handle = samr.Connect5(pipe) except dcerpc.NTSTATUS, arg: - if arg[0] == 0xc0000063L: - test_OpenUser_byname(pipe, domain_handle, username).DeleteUser() - return domain_handle.CreateUser(username) - -def test_SetAliasInfo(pipe, alias_handle): - - r = {} - r['alias_handle'] = alias_handle - r['level'] = 2 - r['info'] = {} - r['info']['name'] = {} - r['info']['name']['name'] = 'hello' - - dcerpc.samr_SetAliasInfo(pipe, r) - - del(r['info']['name']) + if arg[0] != 0xc00000d2L: # NT_STATUS_NET_WRITE_FAULT + raise - r['level'] = 3 - r['info']['description'] = {} - r['info']['description']['name'] = 'this is a description' + return handle - dcerpc.samr_SetAliasInfo(pipe, r) - -def test_Aliases(pipe, domain_handle, domain_sid): - - print 'testing aliases' +def test_UserHandle(user_handle): - aliasname = 'samrtorturetestalias' + # QuerySecurity()/SetSecurity() - # Create a new alias + user_handle.SetSecurity(user_handle.QuerySecurity()) - try: - - handle, rid = domain_handle.CreateDomAlias(aliasname) - - except dcerpc.NTSTATUS, arg: + # GetUserPwInfo() - if arg[0] == 0x0c0000154L: + user_handle.GetUserPwInfo() - # Alias exists, delete it and try again + # GetUserInfo() - rids, types = domain_handle.LookupNames([aliasname]) - domain_handle.OpenAlias(rids[0]).DeleteDomAlias() - - handle, rid = domain_handle.CreateDomAlias(aliasname) - - else: - raise + for level in [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 16, 17, 20, + 21, 23, 24, 25, 26]: - # QuerySecurity/GetSecurity - - handle.SetSecurity(handle.QuerySecurity()) - - # QueryAliasInfo/SetAliasInfo - - for i in [1, 2, 3]: - info = handle.QueryAliasInfo(i) try: - handle.SetAliasInfo(i, info) + user_handle.QueryUserInfo(level) + user_handle.QueryUserInfo2(level) except dcerpc.NTSTATUS, arg: - - # Can't set alias info level 1 - - if not (arg[0] == 0xC0000003L and i == 1): + if arg[0] != 0xc0000003L: # NT_STATUS_INVALID_INFO_CLASS raise - # AddAliasMember - - handle.AddAliasMember('S-1-5-21-1606980848-1677128483-854245398-500') +def test_GroupHandle(group_handle): - # AddMultipleMembersToAlias + # QuerySecurity()/SetSecurity() - handle.AddMultipleMembersToAlias( - ['S-1-5-21-1606980848-1677128483-854245398-501', - 'S-1-5-21-1606980848-1677128483-854245398-502']) + group_handle.SetSecurity(group_handle.QuerySecurity()) - # DeleteDomAlias +def test_AliasHandle(alias_handle): - handle.DeleteDomAlias() + # QuerySecurity()/SetSecurity() -def test_DeleteGroup_byname(pipe, domain_handle, group_name): - - rid = test_LookupNames(pipe, domain_handle, group_name) - - r = {} - r['domain_handle'] = domain_handle - r['access_mask'] = 0x02000000 - r['rid'] = rid + alias_handle.SetSecurity(alias_handle.QuerySecurity()) - result = dcerpc.samr_OpenGroup(pipe, r) +def test_DomainHandle(name, sid, domain_handle): - s = {} - s['group_handle'] = result['group_handle'] + print 'testing %s (%s)' % (name, sid) - dcerpc.samr_DeleteDomainGroup(pipe, s) + # QuerySecurity()/SetSecurity() -def test_CreateDomainGroup(pipe, domain_handle): + domain_handle.SetSecurity(domain_handle.QuerySecurity()) - print 'testing samr_CreateDomainGroup' - - r = {} - r['domain_handle'] = domain_handle - r['name'] = {} - r['name']['name'] = 'samrtorturetestgroup' - r['access_mask'] = 0x02000000 + # LookupNames(), none mapped try: - result = dcerpc.samr_CreateDomainGroup(pipe, r) + domain_handle.LookupNames(['xxNONAMExx']) except dcerpc.NTSTATUS, arg: - if arg[0] == dcerpc.NT_STATUS_ACCESS_DENIED: - return - if arg[0] != dcerpc.NT_STATUS_GROUP_EXISTS: + if arg[0] != 0xc0000073L: raise dcerpc.NTSTATUS(arg) - test_DeleteGroup_byname(pipe, domain_handle, 'samrtorturetestgroup') - - result = dcerpc.samr_CreateDomainGroup(pipe, r) - - return result['group_handle'] + # LookupNames(), some mapped -def test_QueryDomainInfo(pipe, domain_handle): + if name != 'Builtin': + domain_handle.LookupNames(['Administrator', 'xxNONAMExx']) - print 'testing samr_QueryDomainInfo' + # QueryDomainInfo()/SetDomainInfo() levels = [1, 2, 3, 4, 5, 6, 7, 8, 9, 11, 12, 13] set_ok = [1, 0, 1, 1, 0, 1, 1, 0, 1, 0, 1, 0] - for i in range(0, len(levels)): + for i in range(len(levels)): - r = {} - r['domain_handle'] = domain_handle - r['level'] = levels[i] - - result = dcerpc.samr_QueryDomainInfo(pipe, r) - - s = {} - s['domain_handle'] = domain_handle - s['level'] = levels[i] - s['info'] = result['info'] + info = domain_handle.QueryDomainInfo(level = levels[i]) try: - dcerpc.samr_SetDomainInfo(pipe, s) + domain_handle.SetDomainInfo(levels[i], info) except dcerpc.NTSTATUS, arg: - if set_ok[i]: - raise dcerpc.NTSTATUS(arg) - if arg[0] != dcerpc.NT_STATUS_INVALID_INFO_CLASS: - raise dcerpc.NTSTATUS(arg) - -def test_QueryDomainInfo2(pipe, domain_handle): + if not (arg[0] == 0xc0000003L and not set_ok[i]): + raise - print 'testing samr_QueryDomainInfo' + # QueryDomainInfo2() levels = [1, 2, 3, 4, 5, 6, 7, 8, 9, 11, 12, 13] - for i in range(0, len(levels)): - - r = {} - r['domain_handle'] = domain_handle - r['level'] = levels[i] - - dcerpc.samr_QueryDomainInfo2(pipe, r) + for i in range(len(levels)): + domain_handle.QueryDomainInfo2(level = levels[i]) -def test_EnumDomainUsers(pipe, domain_handle): + # EnumDomainUsers - print 'testing samr_EnumDomainUsers' + print 'testing users' - r = {} - r['domain_handle'] = domain_handle - r['resume_handle'] = 0 - r['acct_flags'] = 0 - r['max_size'] = -1 - - while 1: - result = dcerpc.samr_EnumDomainUsers(pipe, r) - if result['result'] == dcerpc.STATUS_MORE_ENTRIES: - r['resume_handle'] = result['resume_handle'] - continue - break - -def test_EnumDomainGroups(pipe, domain_handle): - - print 'testing samr_EnumDomainGroups' - - r = {} - r['domain_handle'] = domain_handle - r['resume_handle'] = 0 - r['acct_flags'] = 0 - r['max_size'] = -1 + users = domain_handle.EnumDomainUsers() + rids = domain_handle.LookupNames(users) - while 1: - result = dcerpc.samr_EnumDomainGroups(pipe, r) - if result['result'] == dcerpc.STATUS_MORE_ENTRIES: - r['resume_handle'] = result['resume_handle'] - continue - break - -def test_EnumDomainAliases(pipe, domain_handle): - - print 'testing samr_EnumDomainAliases' - - r = {} - r['domain_handle'] = domain_handle - r['resume_handle'] = 0 - r['acct_flags'] = 0 - r['max_size'] = -1 - - while 1: - result = dcerpc.samr_EnumDomainAliases(pipe, r) - if result['result'] == dcerpc.STATUS_MORE_ENTRIES: - r['resume_handle'] = result['resume_handle'] - continue - break - -def test_QueryDisplayInfo(pipe, domain_handle): - - print 'testing samr_QueryDisplayInfo' - - levels = [1, 2, 3, 4, 5] - - for i in range(0, len(levels)): - - r = {} - r['domain_handle'] = domain_handle - r['level'] = levels[i] - r['start_idx'] = 0 - r['max_entries'] = 1000 - r['buf_size'] = -1 - - dcerpc.samr_QueryDisplayInfo(pipe, r) - -def test_QueryDisplayInfo2(pipe, domain_handle): - - print 'testing samr_QueryDisplayInfo2' - - levels = [1, 2, 3, 4, 5] - - for i in range(0, len(levels)): - - r = {} - r['domain_handle'] = domain_handle - r['level'] = levels[i] - r['start_idx'] = 0 - r['max_entries'] = 1000 - r['buf_size'] = -1 - - dcerpc.samr_QueryDisplayInfo2(pipe, r) + for i in range(len(users)): + test_UserHandle(domain_handle.OpenUser(rids[0][i])) -def test_QueryDisplayInfo3(pipe, domain_handle): - - print 'testing samr_QueryDisplayInfo3' - - levels = [1, 2, 3, 4, 5] - - for i in range(0, len(levels)): - - r = {} - r['domain_handle'] = domain_handle - r['level'] = levels[i] - r['start_idx'] = 0 - r['max_entries'] = 1000 - r['buf_size'] = -1 - - dcerpc.samr_QueryDisplayInfo3(pipe, r) - -def test_GetDisplayEnumerationIndex(pipe, domain_handle): - - print 'testing samr_GetDisplayEnumerationIndex' - - levels = [1, 2, 3, 4, 5] - ok_lvl = [1, 1, 1, 0, 0] - - for i in range(0, len(levels)): - - r = {} - r['domain_handle'] = domain_handle - r['level'] = levels[i] - r['name'] = {} - r['name']['name'] = 'samrtorturetest' - - try: - dcerpc.samr_GetDisplayEnumerationIndex(pipe, r) - except dcerpc.NTSTATUS, arg: - if ok_lvl[i]: - raise dcerpc.NTSTATUS(arg) - - r['name']['name'] = 'zzzzzzzz' - - try: - dcerpc.samr_GetDisplayEnumerationIndex(pipe, r) - except dcerpc.NTSTATUS, arg: - if ok_lvl[i]: - raise dcerpc.NTSTATUS(arg) - -def test_GetDisplayEnumerationIndex2(pipe, domain_handle): - - print 'testing samr_GetDisplayEnumerationIndex2' - - levels = [1, 2, 3, 4, 5] - ok_lvl = [1, 1, 1, 0, 0] - - for i in range(0, len(levels)): - - r = {} - r['domain_handle'] = domain_handle - r['level'] = levels[i] - r['name'] = {} - r['name']['name'] = 'samrtorturetest' - - try: - dcerpc.samr_GetDisplayEnumerationIndex2(pipe, r) - except dcerpc.NTSTATUS, arg: - if ok_lvl[i]: - raise dcerpc.NTSTATUS(arg) - - r['name']['name'] = 'zzzzzzzz' - - try: - dcerpc.samr_GetDisplayEnumerationIndex2(pipe, r) - except dcerpc.NTSTATUS, arg: - if ok_lvl[i]: - raise dcerpc.NTSTATUS(arg) - -def test_TestPrivateFunctionsDomain(pipe, domain_handle): - - print 'testing samr.TestPrivateFunctionsDomain' - - r = {} - r['domain_handle'] = domain_handle + # QueryDisplayInfo - try: - dcerpc.samr_TestPrivateFunctionsDomain(pipe, r) - except dcerpc.NTSTATUS, arg: - if arg[0] != dcerpc.NT_STATUS_NOT_IMPLEMENTED: - raise dcerpc.NTSTATUS(arg) - -def test_RidToSid(pipe, domain_handle): - - print 'testing samr_RidToSid' - - r = {} - r['domain_handle'] = domain_handle - r['rid'] = 512 - - dcerpc.samr_RidToSid(pipe, r) - -def test_GetBootKeyInformation(pipe, domain_handle): - - print 'testing samr_GetBootKeyInformation' - - r = {} - r['domain_handle'] = domain_handle - - try: - dcerpc.samr_GetBootKeyInformation(pipe, r) - except dcerpc.NTSTATUS, arg: - pass - -def test_DeleteUser(pipe, user_handle): - - r = {} - r['user_handle'] = user_handle - - dcerpc.samr_DeleteUser(pipe, r) - -def test_DeleteAlias(pipe, alias_handle): - - r = {} - r['alias_handle'] = alias_handle - - dcerpc.samr_DeleteDomAlias(pipe, r) - -def test_DeleteDomainGroup(pipe, group_handle): - - r = {} - r['group_handle'] = group_handle - - dcerpc.samr_DeleteDomainGroup(pipe, r) - -def test_Close(pipe, handle): - - r = {} - r['handle'] = handle - - dcerpc.samr_Close(pipe, r) - -def test_OpenDomain(pipe, connect_handle, domain_sid): - - print 'testing OpenDomain' - - domain_handle = connect_handle.OpenDomain(domain_sid) - - test_QuerySecurity(pipe, domain_handle) - - test_RemoveMemberFromForeignDomain(pipe, domain_handle) - - test_CreateUser2(pipe, domain_handle) - - test_CreateUser(pipe, domain_handle) - - test_Aliases(pipe, domain_handle, domain_sid) - - sys.exit(0) + for i in [1, 2, 3, 4, 5]: + domain_handle.QueryDisplayInfo(level = i) + domain_handle.QueryDisplayInfo2(level = i) + domain_handle.QueryDisplayInfo3(level = i) + + # EnumDomainGroups - test_CreateDomainGroup(pipe, domain_handle) + print 'testing groups' - test_QueryDomainInfo(pipe, domain_handle) - - test_QueryDomainInfo2(pipe, domain_handle) + groups = domain_handle.EnumDomainGroups() + rids = domain_handle.LookupNames(groups) - test_EnumDomainUsers(pipe, domain_handle) + for i in range(len(groups)): + test_GroupHandle(domain_handle.OpenGroup(rids[0][i])) - test_EnumDomainGroups(pipe, domain_handle) + # EnumDomainAliases - test_EnumDomainAliases(pipe, domain_handle) + print 'testing aliases' - test_QueryDisplayInfo(pipe, domain_handle) + aliases = domain_handle.EnumDomainAliases() + rids = domain_handle.LookupNames(aliases) - test_QueryDisplayInfo2(pipe, domain_handle) + for i in range(len(aliases)): + test_AliasHandle(domain_handle.OpenAlias(rids[0][i])) - test_QueryDisplayInfo3(pipe, domain_handle) - - test_GetDisplayEnumerationIndex(pipe, domain_handle) - - test_GetDisplayEnumerationIndex2(pipe, domain_handle) + # CreateUser + # CreateUser2 + # CreateDomAlias + # RidToSid + # RemoveMemberFromForeignDomain + # CreateDomainGroup + # GetAliasMembership - test_TestPrivateFunctionsDomain(pipe, domain_handle) +def test_ConnectHandle(connect_handle): - test_RidToSid(pipe, domain_handle) + print 'testing connect handle' - test_GetBootKeyInformation(pipe, domain_handle) + # QuerySecurity/SetSecurity - if user_handle != None: - test_DeleteUser(pipe, user_handle) + connect_handle.SetSecurity(connect_handle.QuerySecurity()) - if alias_handle != None: - test_DeleteAlias(pipe, alias_handle) - - if group_handle != None: - test_DeleteDomainGroup(pipe, group_handle) - - test_Close(pipe, domain_handle) - -def test_LookupDomain(pipe, connect_handle, domain): - - print 'testing LookupDomain' - - sid = connect_handle.LookupDomain(domain) + # Lookup bogus domain try: connect_handle.LookupDomain('xxNODOMAINxx') except dcerpc.NTSTATUS, arg: if arg[0] != 0xC00000DFL: # NT_STATUS_NO_SUCH_DOMAIN raise - - test_GetDomPwInfo(pipe, connect_handle, domain) - test_OpenDomain(pipe, connect_handle, sid) - -def test_EnumDomains(pipe, connect_handle): - print 'testing EnumDomains' + # Test all domains + + for domain_name in connect_handle.EnumDomains(): + + connect_handle.GetDomPwInfo(domain_name) + sid = connect_handle.LookupDomain(domain_name) + domain_handle = connect_handle.OpenDomain(sid) - for domain in connect_handle.EnumDomains(): - test_LookupDomain(pipe, connect_handle, domain) + test_DomainHandle(domain_name, sid, domain_handle) + + # TODO: Test Shutdown() function def runtests(binding, creds): @@ -639,7 +178,4 @@ def runtests(binding, creds): dcerpc.DCERPC_SAMR_UUID, int(dcerpc.DCERPC_SAMR_VERSION), creds) handle = test_Connect(pipe) - - test_QuerySecurity(pipe, handle) - - test_EnumDomains(pipe, handle) + test_ConnectHandle(handle) -- cgit From 5c6e1f81cec532e075f2d9e7eab25794a6b10bf7 Mon Sep 17 00:00:00 2001 From: Tim Potter Date: Sun, 1 May 2005 01:31:23 +0000 Subject: r6539: A patch from jbm: - convert rpcclient to new credential code - allow anonymous connections (This used to be commit f40977c42145e202ddfe50c9a7daad624b06cc59) --- source4/scripting/swig/rpcclient | 29 ++++++++++++++++------------- 1 file changed, 16 insertions(+), 13 deletions(-) (limited to 'source4/scripting') diff --git a/source4/scripting/swig/rpcclient b/source4/scripting/swig/rpcclient index faf5b3ec09..34efafdf73 100755 --- a/source4/scripting/swig/rpcclient +++ b/source4/scripting/swig/rpcclient @@ -28,12 +28,10 @@ class rpcclient(Cmd): prompt = 'rpcclient$ ' - def __init__(self, server, domain, username, password): + def __init__(self, server, cred): Cmd.__init__(self) self.server = server - self.domain = domain - self.username = username - self.password = password + self.cred = cred def emptyline(self): @@ -85,7 +83,7 @@ class rpcclient(Cmd): pipe = dcerpc.pipe_connect( 'ncacn_np:%s' % self.server, dcerpc.DCERPC_SAMR_UUID, int(dcerpc.DCERPC_SAMR_VERSION), - (self.domain, self.username, self.password)) + self.cred) connect_handle = samr.Connect(pipe) @@ -107,7 +105,7 @@ class rpcclient(Cmd): pipe = dcerpc.pipe_connect( 'ncacn_np:%s' % self.server, dcerpc.DCERPC_SAMR_UUID, int(dcerpc.DCERPC_SAMR_VERSION), - (self.domain, self.username, self.password)) + self.cred) connect_handle = samr.Connect(pipe) @@ -128,7 +126,7 @@ class rpcclient(Cmd): pipe = dcerpc.pipe_connect( 'ncacn_np:%s' % self.server, dcerpc.DCERPC_SAMR_UUID, int(dcerpc.DCERPC_SAMR_VERSION), - (self.domain, self.username, self.password)) + self.cred) connect_handle = samr.Connect(pipe) domain_handle = connect_handle.OpenDomain(args[0]) @@ -155,7 +153,7 @@ class rpcclient(Cmd): pipe = dcerpc.pipe_connect( 'ncacn_np:%s' % self.server, dcerpc.DCERPC_SAMR_UUID, int(dcerpc.DCERPC_SAMR_VERSION), - (self.domain, self.username, self.password)) + self.cred) connect_handle = samr.Connect(pipe) domain_handle = connect_handle.OpenDomain(args[0]) @@ -182,7 +180,7 @@ class rpcclient(Cmd): pipe = dcerpc.pipe_connect( 'ncacn_np:%s' % self.server, dcerpc.DCERPC_SAMR_UUID, int(dcerpc.DCERPC_SAMR_VERSION), - (self.domain, self.username, self.password)) + self.cred) connect_handle = samr.Connect(pipe) domain_handle = connect_handle.OpenDomain(args[0]) @@ -207,7 +205,7 @@ class rpcclient(Cmd): pipe = dcerpc.pipe_connect( 'ncacn_np:%s' % self.server, dcerpc.DCERPC_SAMR_UUID, int(dcerpc.DCERPC_SAMR_VERSION), - (self.domain, self.username, self.password)) + self.cred) connect_handle = samr.Connect(pipe) domain_handle = connect_handle.OpenDomain(args[0]) @@ -231,7 +229,7 @@ class rpcclient(Cmd): pipe = dcerpc.pipe_connect( 'ncacn_np:%s' % self.server, dcerpc.DCERPC_SAMR_UUID, int(dcerpc.DCERPC_SAMR_VERSION), - (self.domain, self.username, self.password)) + self.cred) connect_handle = samr.Connect(pipe) domain_handle = connect_handle.OpenDomain(args[0]) @@ -268,7 +266,9 @@ if __name__ == '__main__': options, args = parser.parse_args() - # Break --username up into domain, usernamd and password + # Break --username up into domain, username and password + + cred = None if not options.username: options.username = '%' @@ -283,9 +283,12 @@ if __name__ == '__main__': username = options.username + if username != '': + cred = (domain, username, password) + # Run command loop - c = rpcclient(server, domain, username, password) + c = rpcclient(server, cred) if options.command: c.onecmd(options.command) -- cgit From 9d87efb681c73e892c8690679238b9dc1d971a9c Mon Sep 17 00:00:00 2001 From: Tim Potter Date: Sun, 1 May 2005 02:40:00 +0000 Subject: r6540: Implement a bunch more SAMR functions. (This used to be commit 7ab240644ec6cfd0449df7e2dfe0eb1b8a52ccdb) --- source4/scripting/swig/dcerpc.i | 1 + source4/scripting/swig/samr.py | 117 +++++++++++++++++++++---- source4/scripting/swig/torture/torture_samr.py | 40 +++++++++ 3 files changed, 139 insertions(+), 19 deletions(-) (limited to 'source4/scripting') diff --git a/source4/scripting/swig/dcerpc.i b/source4/scripting/swig/dcerpc.i index e41d9e4e2f..60e661f180 100644 --- a/source4/scripting/swig/dcerpc.i +++ b/source4/scripting/swig/dcerpc.i @@ -231,6 +231,7 @@ char *nt_errstr(NTSTATUS nt_code); %array_functions(struct samr_String, samr_String_array); %array_functions(struct samr_SamEntry, samr_SamEntry_array); %array_functions(union samr_ConnectInfo, samr_ConnectInfo_array); +%array_functions(struct samr_RidType, samr_RidType_array); %array_functions(struct lsa_SidPtr, lsa_SidPtr_array); diff --git a/source4/scripting/swig/samr.py b/source4/scripting/swig/samr.py index c254acd11b..314f78b8ad 100644 --- a/source4/scripting/swig/samr.py +++ b/source4/scripting/swig/samr.py @@ -17,7 +17,6 @@ def sid_to_string(sid): return result - def string_to_sid(string): """Convert a string SID to a Python dictionary SID. Throws a ValueError if the SID string was badly formed.""" @@ -88,7 +87,6 @@ def string_to_sid(string): return sid - def call_fn(fn, pipe, args): """Wrap up a RPC call and throw an exception is an error was returned.""" @@ -98,8 +96,7 @@ def call_fn(fn, pipe, args): raise dcerpc.NTSTATUS(result, dcerpc.nt_errstr(result)); return result; - - + class SamrHandle: def __init__(self, pipe, handle): @@ -139,7 +136,6 @@ class SamrHandle: r.data_in.sdbuf = sdbuf call_fn(dcerpc.dcerpc_samr_SetSecurity, self.pipe, r) - class ConnectHandle(SamrHandle): @@ -206,6 +202,16 @@ class ConnectHandle(SamrHandle): return r.data_out.info + def SetBootKeyInformation(self, unknown1, unknown2, unknown3): + + r = dcerpc.samr_GetBootKeyInformation() + r.data_in.connect_handle = self.handle + r.data_in.unknown1 = unknown1 + r.data_in.unknown2 = unknown2 + r.data_in.unknown3 = unknown3 + + call_fn(dcerpc.dcerpc_samr_SetBootKeyInformation, self.pipe, r) + class DomainHandle(SamrHandle): def QueryDomainInfo(self, level = 2): @@ -402,8 +408,10 @@ class DomainHandle(SamrHandle): call_fn(dcerpc.dcerpc_samr_LookupNames, self.pipe, r) - return ([dcerpc.uint32_array_getitem(r.data_out.rids.ids, i) for i in range(r.data_out.rids.count)], - [dcerpc.uint32_array_getitem(r.data_out.types.ids, i) for i in range(r.data_out.types.count)]) + return ([dcerpc.uint32_array_getitem(r.data_out.rids.ids, i) + for i in range(r.data_out.rids.count)], + [dcerpc.uint32_array_getitem(r.data_out.types.ids, i) + for i in range(r.data_out.types.count)]) def CreateDomainGroup(self, domain_name, access_mask = 0x02000000): @@ -486,6 +494,28 @@ class DomainHandle(SamrHandle): return getattr(r.data_out.info, 'info%d' % level) + def GetBootKeyInformation(self): + + r = dcerpc.samr_GetBootKeyInformation() + r.data_in.domain_handle = self.handle + + call_fn(dcerpc.dcerpc_samr_GetBootKeyInformation, self.pipe, r) + + return r.data_out.unknown + + def SetBootKeyInformation(self): + + r = dcerpc.samr_GetBootKeyInformation() + r.data_in.domain_handle = self.handle + + call_fn(dcerpc.dcerpc_samr_GetBootKeyInformation, self.pipe, r) + + def TestPrivateFunctionsDomain(self): + + r = dcerpc.samr_TestPrivateFunctionsDomain() + r.data_in.domain_handle = self.handle + + call_fn(dcerpc.dcerpc_samr_TestPrivateFunctionsDomain, self.pipe, r) class UserHandle(SamrHandle): @@ -527,10 +557,57 @@ class UserHandle(SamrHandle): return r.data_out.info + def GetGroupsForUser(self): + + r = dcerpc.samr_GetGroupsForUser() + r.data_in.user_handle = self.handle + + call_fn(dcerpc.dcerpc_samr_GetGroupsForUser, self.pipe, r) + + rid_types = [dcerpc.samr_RidType_array_getitem(r.data_out.rids.rid, x) + for x in range(r.data_out.rids.count)] + + return [(x.rid, x.type) for x in rid_types] + + def TestPrivateFunctionsUser(self): + + r = dcerpc.samr_TestPrivateFunctionsUser() + r.data_in.user_handle = self.handle + + call_fn(dcerpc.dcerpc_samr_TestPrivateFunctionsUser, self.pipe, r) + class GroupHandle(SamrHandle): - pass - + def QueryGroupInfo(self, level): + + r = dcerpc.samr_QueryGroupInfo() + r.data_in.group_handle = self.handle + r.data_in.level = level + + call_fn(dcerpc.dcerpc_samr_QueryGroupInfo, self.pipe, r) + + return r.data_out.info + + def SetGroupInfo(self, level, info): + + r = dcerpc.samr_SetGroupInfo() + r.data_in.group_handle = self.handle + r.data_in.level = level + r.data_in.info = info + + call_fn(dcerpc.dcerpc_samr_SetGroupInfo, self.pipe, r) + + def QueryGroupMember(self): + + r = dcerpc.samr_QueryGroupMember() + r.data_in.group_handle = self.handle + + call_fn(dcerpc.dcerpc_samr_QueryGroupMember, self.pipe, r) + + return [(dcerpc.uint32_array_getitem(r.data_out.rids.rids, x), + dcerpc.uint32_array_getitem(r.data_out.rids.unknown, x)) + for x in range(r.data_out.rids.count)] + class AliasHandle(SamrHandle): def DeleteDomAlias(self): @@ -584,6 +661,18 @@ class AliasHandle(SamrHandle): call_fn(dcerpc.dcerpc_samr_AddMultipleMembersToAlias, self.pipe, r) + def GetMembersInAlias(self): + + r = dcerpc.samr_GetMembersInAlias() + r.data_in.alias_handle = self.handle + + call_fn(dcerpc.dcerpc_samr_GetMembersInAlias, self.pipe, r) + + return [ + sid_to_string( + dcerpc.lsa_SidPtr_array_getitem(r.data_out.sids.sids, x).sid) + for x in range(r.data_out.sids.num_sids)] + def Connect(pipe, access_mask = 0x02000000): r = dcerpc.samr_Connect() @@ -595,7 +684,6 @@ def Connect(pipe, access_mask = 0x02000000): return ConnectHandle(pipe, r.data_out.connect_handle) - def Connect2(pipe, system_name = '', access_mask = 0x02000000): """Connect to the SAMR pipe.""" @@ -607,7 +695,6 @@ def Connect2(pipe, system_name = '', access_mask = 0x02000000): return ConnectHandle(pipe, r.data_out.connect_handle) - def Connect3(pipe, system_name = '', access_mask = 0x02000000): r = dcerpc.samr_Connect3() @@ -645,30 +732,22 @@ def Connect5(pipe, system_name = '', access_mask = 0x02000000): return ConnectHandle(pipe, r.data_out.connect_handle) -# QueryGroupInfo -# SetGroupInfo # AddGroupMember # DeleteDomainGroup # DeleteGroupMember -# QueryGroupMember # SetMemberAttributesofGroup # AddAliasMember # DeleteAliasMember # GetMembersinAlias # SetUserInfo # ChangePasswordUser -# GetGroupsForUser # GetDisplayEnumerationIndex -# TestPrivateFunctionsDomain -# TestPrivateFunctionsUser # RemoveMemberFromForeignDomain # GetDisplayEnumerationIndex2 # RemoveMultipleMembersFromAlias # OemChangePasswordUser2 # ChangePasswordUser2 # SetUserInfo2 -# SetBootKeyInformation -# GetBootKeyInformation # ChangePasswordUser3 # SetDsrmPassword # ValidatePassword diff --git a/source4/scripting/swig/torture/torture_samr.py b/source4/scripting/swig/torture/torture_samr.py index 9025fdd978..15c6dc1a76 100755 --- a/source4/scripting/swig/torture/torture_samr.py +++ b/source4/scripting/swig/torture/torture_samr.py @@ -42,18 +42,43 @@ def test_UserHandle(user_handle): if arg[0] != 0xc0000003L: # NT_STATUS_INVALID_INFO_CLASS raise + # GetGroupsForUser() + + user_handle.GetGroupsForUser() + + # TestPrivateFunctionsUser() + + try: + user_handle.TestPrivateFunctionsUser() + except dcerpc.NTSTATUS, arg: + if arg[0] != 0xC0000002L: + raise + def test_GroupHandle(group_handle): # QuerySecurity()/SetSecurity() group_handle.SetSecurity(group_handle.QuerySecurity()) + # QueryGroupInfo() + + for level in [1, 2, 3, 4, 5]: + info = group_handle.QueryGroupInfo(level) + + # TODO: SetGroupinfo() + + # QueryGroupMember() + + group_handle.QueryGroupMember() + def test_AliasHandle(alias_handle): # QuerySecurity()/SetSecurity() alias_handle.SetSecurity(alias_handle.QuerySecurity()) + print alias_handle.GetMembersInAlias() + def test_DomainHandle(name, sid, domain_handle): print 'testing %s (%s)' % (name, sid) @@ -142,6 +167,21 @@ def test_DomainHandle(name, sid, domain_handle): # CreateDomainGroup # GetAliasMembership + # GetBootKeyInformation() + + try: + domain_handle.GetBootKeyInformation() + except dcerpc.NTSTATUS, arg: + pass + + # TestPrivateFunctionsDomain() + + try: + domain_handle.TestPrivateFunctionsDomain() + except dcerpc.NTSTATUS, arg: + if arg[0] != 0xC0000002L: + raise + def test_ConnectHandle(connect_handle): print 'testing connect handle' -- cgit From 6950d5f8956c64a6f420b0207d6555e1b9a7bc0d Mon Sep 17 00:00:00 2001 From: Tim Potter Date: Tue, 3 May 2005 01:48:50 +0000 Subject: r6590: Remove bogus library versioning variables from swig wrappers. (This used to be commit 83a125ce576b1be613e010a5c9b4257f25909b05) --- source4/scripting/swig/config.mk | 6 ------ 1 file changed, 6 deletions(-) (limited to 'source4/scripting') diff --git a/source4/scripting/swig/config.mk b/source4/scripting/swig/config.mk index fad6b68bda..38144fb9e2 100644 --- a/source4/scripting/swig/config.mk +++ b/source4/scripting/swig/config.mk @@ -1,11 +1,5 @@ [LIBRARY::swig_tdb] -MAJOR_VERSION = 0 -MINOR_VERSION = 0 -RELEASE_VERSION = 1 REQUIRED_SUBSYSTEMS = LIBTDB [LIBRARY::swig_dcerpc] -MAJOR_VERSION = 0 -MINOR_VERSION = 0 -RELEASE_VERSION = 1 REQUIRED_SUBSYSTEMS = LIBCLI NDR_MISC LIBBASIC CONFIG RPC_NDR_SAMR RPC_NDR_LSA -- cgit From c8d0e36312e351f0aba2e71d7744397d9fa11961 Mon Sep 17 00:00:00 2001 From: Tim Potter Date: Tue, 3 May 2005 06:11:12 +0000 Subject: r6591: Add some comments. Use SWIG %rename to get rid of prefix on every tdb function. Treat mode_t as an int so we can actually pass a mode argument to tdb_open(). (This used to be commit 0abd03f70c5c63a915086eaf6e3a25b3087769bc) --- source4/scripting/swig/tdb.i | 48 ++++++++++++++++++++++++++++++++++++++++---- 1 file changed, 44 insertions(+), 4 deletions(-) (limited to 'source4/scripting') diff --git a/source4/scripting/swig/tdb.i b/source4/scripting/swig/tdb.i index a3d1a6ebbc..b381487ebc 100644 --- a/source4/scripting/swig/tdb.i +++ b/source4/scripting/swig/tdb.i @@ -3,7 +3,7 @@ Swig interface to tdb. - Copyright (C) 2004 Tim Potter + Copyright (C) 2004,2005 Tim Potter ** NOTE! The following LGPL license applies to the tdb ** library. This does NOT imply that all of Samba is released @@ -51,7 +51,6 @@ %} - /* The tdb functions will crash if a NULL tdb is passed */ %include exception.i @@ -63,7 +62,8 @@ } /* In and out typemaps for the TDB_DATA structure. This is converted to - and from the Python string type. */ + and from the Python string type which can contain arbitrary binary + data.. */ %typemap(in) TDB_DATA { if (!PyString_Check($input)) { @@ -85,7 +85,7 @@ /* Treat a mode_t as an unsigned integer */ -typedef uint_t mode_t; +typedef int mode_t; /* flags to tdb_store() */ @@ -103,36 +103,76 @@ typedef uint_t mode_t; #define TDB_CONVERT 16 /* convert endian (internal use) */ #define TDB_BIGENDIAN 32 /* header is big-endian (internal use) */ +%rename tdb_open open; TDB_CONTEXT *tdb_open(const char *name, int hash_size, int tdb_flags, int open_flags, mode_t mode); +%rename tdb_open_ex open_ex; TDB_CONTEXT *tdb_open_ex(const char *name, int hash_size, int tdb_flags, int open_flags, mode_t mode, tdb_log_func log_fn, tdb_hash_func hash_fn); +%rename tdb_reopen reopen; int tdb_reopen(TDB_CONTEXT *tdb); + +%rename tdb_reopen_all reopen_all; int tdb_reopen_all(void); +%rename tdb_logging_function logging_function; void tdb_logging_function(TDB_CONTEXT *tdb, tdb_log_func); + +%rename tdb_error error; enum TDB_ERROR tdb_error(TDB_CONTEXT *tdb); + +%rename tdb_errorstr errorstr; const char *tdb_errorstr(TDB_CONTEXT *tdb); + +%rename tdb_fetch fetch; TDB_DATA tdb_fetch(TDB_CONTEXT *tdb, TDB_DATA key); + +%rename tdb_delete delete; int tdb_delete(TDB_CONTEXT *tdb, TDB_DATA key); + +%rename tdb_store store; int tdb_store(TDB_CONTEXT *tdb, TDB_DATA key, TDB_DATA dbuf, int flag = TDB_REPLACE); + +%rename tdb_append append; int tdb_append(TDB_CONTEXT *tdb, TDB_DATA key, TDB_DATA new_dbuf); + +%rename tdb_close close; int tdb_close(TDB_CONTEXT *tdb); + +%rename tdb_firstkey firstkey; TDB_DATA tdb_firstkey(TDB_CONTEXT *tdb); + +%rename tdb_nextkey nextkey; TDB_DATA tdb_nextkey(TDB_CONTEXT *tdb, TDB_DATA key); + +%rename tdb_traverse traverse; int tdb_traverse(TDB_CONTEXT *tdb, tdb_traverse_func fn, void *state); + +%rename tdb_exists exists; int tdb_exists(TDB_CONTEXT *tdb, TDB_DATA key); + +%rename tdb_lockall lockall; int tdb_lockall(TDB_CONTEXT *tdb); + +%rename tdb_unlockall unlockall; void tdb_unlockall(TDB_CONTEXT *tdb); /* Low level locking functions: use with care */ + +%rename tdb_chainlock chainlock; int tdb_chainlock(TDB_CONTEXT *tdb, TDB_DATA key); + +%rename tdb_chainunlock chainunlock; int tdb_chainunlock(TDB_CONTEXT *tdb, TDB_DATA key); /* Debug functions. Not used in production. */ + +%rename tdb_dump_all dump_all; void tdb_dump_all(TDB_CONTEXT *tdb); + +%rename tdb_printfreelist printfreelist; int tdb_printfreelist(TDB_CONTEXT *tdb); -- cgit From 17f1cf095022a88541c461f2ea66940daabcd9a8 Mon Sep 17 00:00:00 2001 From: Tim Potter Date: Tue, 3 May 2005 07:10:46 +0000 Subject: r6592: Throw an IOError exception if tdb_open() or tdb_open_Ex() returns NULL. (This used to be commit 99fb6b6badf1afeac21fdb5f1ce04c1749e1b7f7) --- source4/scripting/swig/tdb.i | 12 ++++++++++++ 1 file changed, 12 insertions(+) (limited to 'source4/scripting') diff --git a/source4/scripting/swig/tdb.i b/source4/scripting/swig/tdb.i index b381487ebc..6c6c4af8cd 100644 --- a/source4/scripting/swig/tdb.i +++ b/source4/scripting/swig/tdb.i @@ -103,6 +103,16 @@ typedef int mode_t; #define TDB_CONVERT 16 /* convert endian (internal use) */ #define TDB_BIGENDIAN 32 /* header is big-endian (internal use) */ +/* Throw an IOError exception if tdb_open() or tdb_open_ex() returns NULL */ + +%exception { + $action + if (result == NULL) { + PyErr_SetFromErrno(PyExc_IOError); + SWIG_fail; + } +} + %rename tdb_open open; TDB_CONTEXT *tdb_open(const char *name, int hash_size, int tdb_flags, int open_flags, mode_t mode); @@ -113,6 +123,8 @@ TDB_CONTEXT *tdb_open_ex(const char *name, int hash_size, int tdb_flags, tdb_log_func log_fn, tdb_hash_func hash_fn); +%exception; + %rename tdb_reopen reopen; int tdb_reopen(TDB_CONTEXT *tdb); -- cgit From f52a74021512aace67f7ecba33ed130102f47533 Mon Sep 17 00:00:00 2001 From: Tim Potter Date: Sun, 29 May 2005 00:13:10 +0000 Subject: r7061: A ejs scripting client. This should allow javascript to be run in a command line environment instead of inside the web server. It doesn't work yet though, rather an exception is thrown when trying to call ejsDefineStringCFunction(). (This used to be commit 3444cd5429dfef5a67d5bf7818ae08e4e8cc5ccc) --- source4/scripting/config.mk | 8 +++++ source4/scripting/ejs/smbscript.c | 62 +++++++++++++++++++++++++++++++++++++++ 2 files changed, 70 insertions(+) create mode 100644 source4/scripting/config.mk create mode 100644 source4/scripting/ejs/smbscript.c (limited to 'source4/scripting') diff --git a/source4/scripting/config.mk b/source4/scripting/config.mk new file mode 100644 index 0000000000..31f7e6df9d --- /dev/null +++ b/source4/scripting/config.mk @@ -0,0 +1,8 @@ +####################### +# Start BINARY SMBSCRIPT +[BINARY::smbscript] +OBJ_FILES = \ + scripting/ejs/smbscript.o +REQUIRED_SUBSYSTEMS = EJS LIBBASIC +# End BINARY SMBSCRIPT +####################### diff --git a/source4/scripting/ejs/smbscript.c b/source4/scripting/ejs/smbscript.c new file mode 100644 index 0000000000..f1c3f0b46d --- /dev/null +++ b/source4/scripting/ejs/smbscript.c @@ -0,0 +1,62 @@ +/* + Unix SMB/CIFS implementation. + + Standalone client for ESP scripting. + + 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 2 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, write to the Free Software + Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. +*/ + +#include "includes.h" +#include "web_server/ejs/ejs.h" + +void http_exception(const char *reason) +{ + fprintf(stderr, "smbscript exception: %s", reason); + exit(1); +} + +extern void ejsDefineStringCFunction(EjsId eid, const char *functionName, + MprStringCFunction fn, void *thisPtr, int flags); + +static int writeProc(MprVarHandle userHandle, int argc, char **argv) +{ + int i; + + mprAssert(argv); + for (i = 0; i < argc; i++) { + printf("%s", argv[i]); + } + return 0; +} + + int main(int argc, const char *argv[]) +{ + EjsId eid; + EjsHandle primary, alternate; + MprVar result; + char *emsg; + + ejsOpen(0, 0, 0); + eid = ejsOpenEngine(primary, alternate); + ejsDefineStringCFunction(eid, "write", writeProc, NULL, 0); + ejsEvalScript(0, "write(\"hello\n\");", &result, &emsg); + ejsClose(); + + printf("emsg = %s\n", emsg); + + return 0; +} -- cgit From 10f428b6075698205d282c13bc9b1c21f106e165 Mon Sep 17 00:00:00 2001 From: Tim Potter Date: Sun, 29 May 2005 00:22:34 +0000 Subject: r7062: Merge scripting/swig/config.mk with scripting/config.mk (This used to be commit e14c00c4c1cc51dac9452c1e950445907d883e46) --- source4/scripting/config.mk | 14 ++++++++++++++ source4/scripting/swig/config.mk | 5 ----- 2 files changed, 14 insertions(+), 5 deletions(-) delete mode 100644 source4/scripting/swig/config.mk (limited to 'source4/scripting') diff --git a/source4/scripting/config.mk b/source4/scripting/config.mk index 31f7e6df9d..0ea102deee 100644 --- a/source4/scripting/config.mk +++ b/source4/scripting/config.mk @@ -6,3 +6,17 @@ OBJ_FILES = \ REQUIRED_SUBSYSTEMS = EJS LIBBASIC # End BINARY SMBSCRIPT ####################### + +####################### +# Start LIBRARY swig_tdb +[LIBRARY::swig_tdb] +REQUIRED_SUBSYSTEMS = LIBTDB +# End LIBRARY swig_tdb +####################### + +####################### +# Start LIBRARY swig_dcerpc +[LIBRARY::swig_dcerpc] +REQUIRED_SUBSYSTEMS = LIBCLI NDR_MISC LIBBASIC CONFIG RPC_NDR_SAMR RPC_NDR_LSA +# End LIBRARY swig_dcerpc +####################### diff --git a/source4/scripting/swig/config.mk b/source4/scripting/swig/config.mk deleted file mode 100644 index 38144fb9e2..0000000000 --- a/source4/scripting/swig/config.mk +++ /dev/null @@ -1,5 +0,0 @@ -[LIBRARY::swig_tdb] -REQUIRED_SUBSYSTEMS = LIBTDB - -[LIBRARY::swig_dcerpc] -REQUIRED_SUBSYSTEMS = LIBCLI NDR_MISC LIBBASIC CONFIG RPC_NDR_SAMR RPC_NDR_LSA -- cgit From e95c8f19116813dd03cce957c3367254782915fd Mon Sep 17 00:00:00 2001 From: Tim Potter Date: Sun, 29 May 2005 03:25:21 +0000 Subject: r7063: Do error checking on the ejs functions. Tridge says there is a bug in defining per-engine CFunction's so move calls to ejsDefineStringCFunction() above the ejsOpenEngine() call. Test script now works! (This used to be commit 5e2458ae6c863ff29b85fff3d093f7f4fa9dc2be) --- source4/scripting/ejs/smbscript.c | 28 +++++++++++++++++++--------- 1 file changed, 19 insertions(+), 9 deletions(-) (limited to 'source4/scripting') diff --git a/source4/scripting/ejs/smbscript.c b/source4/scripting/ejs/smbscript.c index f1c3f0b46d..85064d3b44 100644 --- a/source4/scripting/ejs/smbscript.c +++ b/source4/scripting/ejs/smbscript.c @@ -29,9 +29,6 @@ void http_exception(const char *reason) exit(1); } -extern void ejsDefineStringCFunction(EjsId eid, const char *functionName, - MprStringCFunction fn, void *thisPtr, int flags); - static int writeProc(MprVarHandle userHandle, int argc, char **argv) { int i; @@ -50,13 +47,26 @@ static int writeProc(MprVarHandle userHandle, int argc, char **argv) MprVar result; char *emsg; - ejsOpen(0, 0, 0); - eid = ejsOpenEngine(primary, alternate); - ejsDefineStringCFunction(eid, "write", writeProc, NULL, 0); - ejsEvalScript(0, "write(\"hello\n\");", &result, &emsg); - ejsClose(); + if (ejsOpen(0, 0, 0) != 0) { + fprintf(stderr, "smbscript: ejsOpen(): unable to initialise " + "EJ subsystem\n"); + exit(1); + } - printf("emsg = %s\n", emsg); + ejsDefineStringCFunction(-1, "write", writeProc, NULL, 0); + + if ((eid = ejsOpenEngine(primary, alternate)) == (EjsId)-1) { + fprintf(stderr, "smbscript: ejsOpenEngine(): unable to " + "initialise an EJS engine\n"); + exit(1); + } + + if (ejsEvalScript(0, "write(\"hello\n\");", &result, &emsg) == -1) { + fprintf(stderr, "smbscript: ejsEvalScript(): %s\n", emsg); + exit(1); + } + + ejsClose(); return 0; } -- cgit From de850cb754f8ea49acc80e4303a9835578768154 Mon Sep 17 00:00:00 2001 From: Tim Potter Date: Sun, 29 May 2005 03:29:10 +0000 Subject: r7064: Clean up handle parameter passing after peeking at tridge's ejstest.c (This used to be commit 805b6c7cf0f1e05fbb690bdfc93938747e13e6cd) --- source4/scripting/ejs/smbscript.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) (limited to 'source4/scripting') diff --git a/source4/scripting/ejs/smbscript.c b/source4/scripting/ejs/smbscript.c index 85064d3b44..1c823a4d8e 100644 --- a/source4/scripting/ejs/smbscript.c +++ b/source4/scripting/ejs/smbscript.c @@ -43,11 +43,11 @@ static int writeProc(MprVarHandle userHandle, int argc, char **argv) int main(int argc, const char *argv[]) { EjsId eid; - EjsHandle primary, alternate; + EjsHandle handle; MprVar result; char *emsg; - if (ejsOpen(0, 0, 0) != 0) { + if (ejsOpen(NULL, NULL, NULL) != 0) { fprintf(stderr, "smbscript: ejsOpen(): unable to initialise " "EJ subsystem\n"); exit(1); @@ -55,13 +55,13 @@ static int writeProc(MprVarHandle userHandle, int argc, char **argv) ejsDefineStringCFunction(-1, "write", writeProc, NULL, 0); - if ((eid = ejsOpenEngine(primary, alternate)) == (EjsId)-1) { + if ((eid = ejsOpenEngine(handle, 0)) == (EjsId)-1) { fprintf(stderr, "smbscript: ejsOpenEngine(): unable to " "initialise an EJS engine\n"); exit(1); } - if (ejsEvalScript(0, "write(\"hello\n\");", &result, &emsg) == -1) { + if (ejsEvalScript(eid, "write(\"hello\n\");", &result, &emsg) == -1) { fprintf(stderr, "smbscript: ejsEvalScript(): %s\n", emsg); exit(1); } -- cgit From 14ade23914b328fcb5924488c2416dfa7748e4ab Mon Sep 17 00:00:00 2001 From: Tim Potter Date: Sun, 29 May 2005 03:53:36 +0000 Subject: r7065: Move ejs from web_server to lib so it can be shared with smbscript. (This used to be commit b83dc8fbfb9ffe30654bc4869398f50dd9ccccb7) --- source4/scripting/ejs/smbscript.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'source4/scripting') diff --git a/source4/scripting/ejs/smbscript.c b/source4/scripting/ejs/smbscript.c index 1c823a4d8e..f1ff03ae49 100644 --- a/source4/scripting/ejs/smbscript.c +++ b/source4/scripting/ejs/smbscript.c @@ -21,7 +21,7 @@ */ #include "includes.h" -#include "web_server/ejs/ejs.h" +#include "lib/ejs/ejs.h" void http_exception(const char *reason) { -- cgit From 7756b990f38495bf98e335b56bdc510659c34bdb Mon Sep 17 00:00:00 2001 From: Tim Potter Date: Sun, 29 May 2005 04:10:22 +0000 Subject: r7066: Rename http_exception to ejs_exception. (This used to be commit f2e59d3adfd7813c3c2090350f8ff2a99a5533e9) --- source4/scripting/ejs/smbscript.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'source4/scripting') diff --git a/source4/scripting/ejs/smbscript.c b/source4/scripting/ejs/smbscript.c index f1ff03ae49..0b0a446839 100644 --- a/source4/scripting/ejs/smbscript.c +++ b/source4/scripting/ejs/smbscript.c @@ -23,7 +23,7 @@ #include "includes.h" #include "lib/ejs/ejs.h" -void http_exception(const char *reason) +void ejs_exception(const char *reason) { fprintf(stderr, "smbscript exception: %s", reason); exit(1); @@ -61,7 +61,7 @@ static int writeProc(MprVarHandle userHandle, int argc, char **argv) exit(1); } - if (ejsEvalScript(eid, "write(\"hello\n\");", &result, &emsg) == -1) { + if (ejsEvalFile(eid, (char *)argv[1], &result, &emsg) == -1) { fprintf(stderr, "smbscript: ejsEvalScript(): %s\n", emsg); exit(1); } -- cgit From 21f3a3921c03777beb7e3072152ae33956b38807 Mon Sep 17 00:00:00 2001 From: Volker Lendecke Date: Sun, 29 May 2005 08:12:16 +0000 Subject: r7069: Add a little usage message to smbscript and fix a compiler warning. My compiler still complains about "handle" (scripting/ejs/smbscrip.c:46) possibly not being initialized and to me this looks true. Running smbscript with the trivial write("Hello, world\n"); also leaves some memory around. Volker (This used to be commit 06d27a19213dc8fe6dfc948a5e8cbafa74db7a29) --- source4/scripting/ejs/smbscript.c | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) (limited to 'source4/scripting') diff --git a/source4/scripting/ejs/smbscript.c b/source4/scripting/ejs/smbscript.c index 0b0a446839..57f42688d6 100644 --- a/source4/scripting/ejs/smbscript.c +++ b/source4/scripting/ejs/smbscript.c @@ -47,6 +47,11 @@ static int writeProc(MprVarHandle userHandle, int argc, char **argv) MprVar result; char *emsg; + if (argc != 2) { + fprintf(stderr, "Usage: %s \n", argv[0]); + exit(1); + } + if (ejsOpen(NULL, NULL, NULL) != 0) { fprintf(stderr, "smbscript: ejsOpen(): unable to initialise " "EJ subsystem\n"); @@ -61,7 +66,8 @@ static int writeProc(MprVarHandle userHandle, int argc, char **argv) exit(1); } - if (ejsEvalFile(eid, (char *)argv[1], &result, &emsg) == -1) { + if (ejsEvalFile(eid, discard_const_p(char, argv[1]), &result, + &emsg) == -1) { fprintf(stderr, "smbscript: ejsEvalScript(): %s\n", emsg); exit(1); } -- cgit From 8754c793bfe79e87febb026e5915e054c23cfede Mon Sep 17 00:00:00 2001 From: Andrew Tridgell Date: Sun, 29 May 2005 11:35:56 +0000 Subject: r7072: moved the esp hooks calls to the ejs level, so we can call them from both esp scripts and ejs scripts. This allows the smbscript program to call all the existing extension calls like lpGet() and ldbSearch() Also fixed smbscript to load smb.conf, and setup logging for DEBUG() I left the unixAuth() routine in web_server/calls.c at the moment, as that is really only useful for esp scripts. I imagine that as we extend esp/ejs, we will put some functions in scripting/ejs/ for use in both ejs and esp, and some functions in web_server/ where they will only be accessed by esp web scripts (This used to be commit e59ae64f60d388a5634559e4e0887e4676b70871) --- source4/scripting/config.mk | 12 +- source4/scripting/ejs/mprutil.c | 159 +++++++++++++++++++++++ source4/scripting/ejs/smbcalls.c | 259 ++++++++++++++++++++++++++++++++++++++ source4/scripting/ejs/smbscript.c | 27 ++-- 4 files changed, 444 insertions(+), 13 deletions(-) create mode 100644 source4/scripting/ejs/mprutil.c create mode 100644 source4/scripting/ejs/smbcalls.c (limited to 'source4/scripting') diff --git a/source4/scripting/config.mk b/source4/scripting/config.mk index 0ea102deee..b32199bc1c 100644 --- a/source4/scripting/config.mk +++ b/source4/scripting/config.mk @@ -1,9 +1,19 @@ +####################### +# Start LIBRARY SMBCALLS +[SUBSYSTEM::SMBCALLS] +OBJ_FILES = \ + scripting/ejs/smbcalls.o \ + scripting/ejs/mprutil.o +REQUIRED_SUBSYSTEMS = EJS LIBBASIC +# End SUBSYSTEM SMBCALLS +####################### + ####################### # Start BINARY SMBSCRIPT [BINARY::smbscript] OBJ_FILES = \ scripting/ejs/smbscript.o -REQUIRED_SUBSYSTEMS = EJS LIBBASIC +REQUIRED_SUBSYSTEMS = EJS LIBBASIC SMBCALLS # End BINARY SMBSCRIPT ####################### diff --git a/source4/scripting/ejs/mprutil.c b/source4/scripting/ejs/mprutil.c new file mode 100644 index 0000000000..a1e26ecb2c --- /dev/null +++ b/source4/scripting/ejs/mprutil.c @@ -0,0 +1,159 @@ +/* + Unix SMB/CIFS implementation. + + utility functions for manipulating mpr variables in ejs 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 2 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, write to the Free Software + Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. +*/ + +#include "includes.h" +#include "lib/ejs/ejs.h" +#include "lib/ldb/include/ldb.h" + +/* + add an indexed array element to a property +*/ +static void mprAddArray(struct MprVar *var, int i, struct MprVar v) +{ + char idx[16]; + mprItoa(i, idx, sizeof(idx)); + mprCreateProperty(var, idx, &v); +} + +/* + construct a MprVar from a list +*/ +struct MprVar mprList(const char *name, const char **list) +{ + struct MprVar var; + int i; + + var = mprCreateObjVar(name, MPR_DEFAULT_HASH_SIZE); + for (i=0;list && list[i];i++) { + mprAddArray(&var, i, mprCreateStringVar(list[i], 1)); + } + return var; +} + +/* + construct a string MprVar from a lump of data +*/ +struct MprVar mprData(const uint8_t *p, size_t length) +{ + struct MprVar var; + char *s = talloc_strndup(mprMemCtx(), p, length); + if (s == NULL) { + return mprCreateUndefinedVar(); + } + var = mprCreateStringVar(s, 1); + talloc_free(s); + return var; +} + +/* + turn a ldb_message into a ejs object variable +*/ +struct MprVar mprLdbMessage(struct ldb_message *msg) +{ + struct MprVar var; + int i; + /* we force some attributes to always be an array in the + returned structure. This makes the scripting easier, as you don't + need a special case for the single value case */ + const char *multivalued[] = { "objectClass", "memberOf", "privilege", + "member", NULL }; + struct MprVar val; + + var = mprCreateObjVar(msg->dn, MPR_DEFAULT_HASH_SIZE); + + for (i=0;inum_elements;i++) { + struct ldb_message_element *el = &msg->elements[i]; + if (el->num_values == 1 && + !str_list_check_ci(multivalued, el->name)) { + val = mprData(el->values[0].data, el->values[0].length); + } else { + int j; + val = mprCreateObjVar(el->name, MPR_DEFAULT_HASH_SIZE); + for (j=0;jnum_values;j++) { + mprAddArray(&val, j, + mprData(el->values[j].data, + el->values[j].length)); + } + } + mprCreateProperty(&var, el->name, &val); + } + + /* add the dn if it is not already specified */ + if (mprGetProperty(&var, "dn", 0) == 0) { + val = mprCreateStringVar(msg->dn, 1); + mprCreateProperty(&var, "dn", &val); + } + + return var; +} + + +/* + turn an array of ldb_messages into a ejs object variable +*/ +struct MprVar mprLdbArray(struct ldb_message **msg, int count, const char *name) +{ + struct MprVar res; + int i; + + res = mprCreateObjVar(name?name:"(NULL)", MPR_DEFAULT_HASH_SIZE); + for (i=0;itype != MPR_TYPE_STRING) return NULL; + return v->string; +} + +/* + turn a MprVar object variable into a string list + this assumes the object variable consists only of strings +*/ +const char **mprToList(TALLOC_CTX *mem_ctx, struct MprVar *v) +{ + const char **list = NULL; + struct MprVar *el; + + if (v->type != MPR_TYPE_OBJECT || + v->properties == NULL) { + return NULL; + } + for (el=mprGetFirstProperty(v, MPR_ENUM_DATA); + el; + el=mprGetNextProperty(v, el, MPR_ENUM_DATA)) { + const char *s = mprToString(el); + if (s) { + list = str_list_add(list, s); + } + } + talloc_steal(mem_ctx, list); + return list; +} + diff --git a/source4/scripting/ejs/smbcalls.c b/source4/scripting/ejs/smbcalls.c new file mode 100644 index 0000000000..664bb74df3 --- /dev/null +++ b/source4/scripting/ejs/smbcalls.c @@ -0,0 +1,259 @@ +/* + Unix SMB/CIFS implementation. + + provide hooks into smbd C 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 2 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, write to the Free Software + Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. +*/ + +#include "includes.h" +#include "lib/ejs/ejs.h" +#include "param/loadparm.h" +#include "lib/ldb/include/ldb.h" + +/* + return the type of a variable +*/ +static int ejs_typeof(MprVarHandle eid, int argc, struct MprVar **argv) +{ + const struct { + MprType type; + const char *name; + } types[] = { + { MPR_TYPE_UNDEFINED, "undefined" }, + { MPR_TYPE_NULL, "null" }, + { MPR_TYPE_BOOL, "boolean" }, + { MPR_TYPE_CFUNCTION, "function" }, + { MPR_TYPE_FLOAT, "float" }, + { MPR_TYPE_INT, "int" }, + { MPR_TYPE_INT64, "int64" }, + { MPR_TYPE_OBJECT, "object" }, + { MPR_TYPE_FUNCTION, "function" }, + { MPR_TYPE_STRING, "string" }, + { MPR_TYPE_STRING_CFUNCTION, "function" } + }; + int i; + const char *type = "unknown"; + + if (argc != 1) return -1; + + for (i=0;itype == types[i].type) { + type = types[i].name; + break; + } + } + + ejsSetReturnString(eid, type); + return 0; +} + +/* + setup a return of a string list +*/ +static void ejs_returnlist(MprVarHandle eid, + const char *name, const char **list) +{ + ejsSetReturnValue(eid, mprList(name, list)); +} + +/* + return a list of defined services +*/ +static int ejs_lpServices(MprVarHandle eid, int argc, char **argv) +{ + int i; + const char **list = NULL; + if (argc != 0) return -1; + + for (i=0;iclass == P_GLOBAL) { + return -1; + } + parm_ptr = lp_parm_ptr(snum, parm); + } else if (strchr(argv[0], ':')) { + /* its a global parametric option */ + const char *type = talloc_strndup(mprMemCtx(), + argv[0], strcspn(argv[0], ":")); + const char *option = strchr(argv[0], ':') + 1; + const char *value; + if (type == NULL || option == NULL) return -1; + value = lp_get_parametric(-1, type, option); + if (value == NULL) return -1; + ejsSetReturnString(eid, value); + return 0; + } else { + /* its a global parameter */ + parm = lp_parm_struct(argv[0]); + if (parm == NULL) return -1; + parm_ptr = parm->ptr; + } + + if (parm == NULL || parm_ptr == NULL) { + return -1; + } + + /* construct and return the right type of ejs object */ + switch (parm->type) { + case P_STRING: + case P_USTRING: + ejsSetReturnString(eid, *(char **)parm_ptr); + break; + case P_BOOL: + ejsSetReturnValue(eid, mprCreateBoolVar(*(BOOL *)parm_ptr)); + break; + case P_INTEGER: + ejsSetReturnValue(eid, mprCreateIntegerVar(*(int *)parm_ptr)); + break; + case P_ENUM: + for (i=0; parm->enum_list[i].name; i++) { + if (*(int *)parm_ptr == parm->enum_list[i].value) { + ejsSetReturnString(eid, parm->enum_list[i].name); + return 0; + } + } + return -1; + case P_LIST: + ejs_returnlist(eid, parm->label, *(const char ***)parm_ptr); + break; + case P_SEP: + return -1; + } + return 0; +} + + +/* + perform an ldb search, returning an array of results + + syntax: + ldbSearch("dbfile", "expression"); + var attrs = new Array("attr1", "attr2", "attr3"); + ldbSearch("dbfile", "expression", attrs); +*/ +static int ejs_ldbSearch(MprVarHandle eid, int argc, struct MprVar **argv) +{ + const char **attrs = NULL; + const char *expression, *dbfile; + TALLOC_CTX *tmp_ctx = talloc_new(mprMemCtx()); + struct ldb_context *ldb; + int ret; + struct ldb_message **res; + + /* validate arguments */ + if (argc < 2 || argc > 3 || + argv[0]->type != MPR_TYPE_STRING) { + ejsSetErrorMsg(eid, "ldbSearch invalid arguments"); + goto failed; + } + if (argc == 3 && argv[2]->type != MPR_TYPE_OBJECT) { + ejsSetErrorMsg(eid, "ldbSearch attributes must be an object"); + goto failed; + } + + dbfile = mprToString(argv[0]); + expression = mprToString(argv[1]); + if (argc > 2) { + attrs = mprToList(tmp_ctx, argv[2]); + } + if (dbfile == NULL || expression == NULL) { + ejsSetErrorMsg(eid, "ldbSearch invalid arguments"); + goto failed; + } + + ldb = ldb_wrap_connect(tmp_ctx, dbfile, 0, NULL); + if (ldb == NULL) { + ejsSetErrorMsg(eid, "ldbSearch failed to open %s", dbfile); + goto failed; + } + + ret = ldb_search(ldb, NULL, LDB_SCOPE_DEFAULT, expression, attrs, &res); + if (ret == -1) { + ejsSetErrorMsg(eid, "ldbSearch failed - %s", ldb_errstring(ldb)); + goto failed; + } + + ejsSetReturnValue(eid, mprLdbArray(res, ret, "ldb_message")); + + talloc_free(tmp_ctx); + return 0; + +failed: + talloc_free(tmp_ctx); + return -1; +} + + +/* + setup the C functions that be called from ejs +*/ +void smb_setup_ejs_functions(void) +{ + ejsDefineStringCFunction(-1, "lpGet", ejs_lpGet, NULL, 0); + ejsDefineStringCFunction(-1, "lpServices", ejs_lpServices, NULL, 0); + ejsDefineCFunction(-1, "typeof", ejs_typeof, NULL, 0); + ejsDefineCFunction(-1, "ldbSearch", ejs_ldbSearch, NULL, 0); +} diff --git a/source4/scripting/ejs/smbscript.c b/source4/scripting/ejs/smbscript.c index 57f42688d6..593d3b0cf5 100644 --- a/source4/scripting/ejs/smbscript.c +++ b/source4/scripting/ejs/smbscript.c @@ -21,6 +21,7 @@ */ #include "includes.h" +#include "dynconfig.h" #include "lib/ejs/ejs.h" void ejs_exception(const char *reason) @@ -29,36 +30,36 @@ void ejs_exception(const char *reason) exit(1); } -static int writeProc(MprVarHandle userHandle, int argc, char **argv) -{ - int i; - - mprAssert(argv); - for (i = 0; i < argc; i++) { - printf("%s", argv[i]); - } - return 0; -} - int main(int argc, const char *argv[]) { EjsId eid; EjsHandle handle; MprVar result; char *emsg; + TALLOC_CTX *mem_ctx = talloc_new(NULL); if (argc != 2) { fprintf(stderr, "Usage: %s \n", argv[0]); exit(1); } + setup_logging(argv[0],DEBUG_STDOUT); + + if (!lp_load(dyn_CONFIGFILE,True,False,False)) { + fprintf(stderr, "%s: Can't load %s - run testparm to debug it\n", + argv[0], dyn_CONFIGFILE); + exit(1); + } + + mprSetCtx(mem_ctx); + if (ejsOpen(NULL, NULL, NULL) != 0) { fprintf(stderr, "smbscript: ejsOpen(): unable to initialise " "EJ subsystem\n"); exit(1); } - ejsDefineStringCFunction(-1, "write", writeProc, NULL, 0); + smb_setup_ejs_functions(); if ((eid = ejsOpenEngine(handle, 0)) == (EjsId)-1) { fprintf(stderr, "smbscript: ejsOpenEngine(): unable to " @@ -74,5 +75,7 @@ static int writeProc(MprVarHandle userHandle, int argc, char **argv) ejsClose(); + talloc_free(mem_ctx); + return 0; } -- cgit From 8f84f7cdecf12396eb5c1723e5e1ccf813cd9a51 Mon Sep 17 00:00:00 2001 From: Andrew Tridgell Date: Sun, 29 May 2005 11:43:52 +0000 Subject: r7074: we should load all shares in smbscript (This used to be commit 92f85507df2bce5e246484860a43748321f2291e) --- source4/scripting/ejs/smbscript.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'source4/scripting') diff --git a/source4/scripting/ejs/smbscript.c b/source4/scripting/ejs/smbscript.c index 593d3b0cf5..c6b1b7a192 100644 --- a/source4/scripting/ejs/smbscript.c +++ b/source4/scripting/ejs/smbscript.c @@ -45,7 +45,7 @@ void ejs_exception(const char *reason) setup_logging(argv[0],DEBUG_STDOUT); - if (!lp_load(dyn_CONFIGFILE,True,False,False)) { + if (!lp_load(dyn_CONFIGFILE, False, False, False)) { fprintf(stderr, "%s: Can't load %s - run testparm to debug it\n", argv[0], dyn_CONFIGFILE); exit(1); -- cgit From f477a741293673adad784c55a749031a290bd072 Mon Sep 17 00:00:00 2001 From: Andrew Tridgell Date: Sun, 29 May 2005 11:58:14 +0000 Subject: r7075: added support for ARGV[] in ejs scripts (This used to be commit 3db568eb6bb383c4c1e1fd0c7f043a9914dcc3cc) --- source4/scripting/ejs/smbscript.c | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) (limited to 'source4/scripting') diff --git a/source4/scripting/ejs/smbscript.c b/source4/scripting/ejs/smbscript.c index c6b1b7a192..3378885147 100644 --- a/source4/scripting/ejs/smbscript.c +++ b/source4/scripting/ejs/smbscript.c @@ -37,8 +37,11 @@ void ejs_exception(const char *reason) MprVar result; char *emsg; TALLOC_CTX *mem_ctx = talloc_new(NULL); + const char **argv_list = NULL; + struct MprVar v; + int i; - if (argc != 2) { + if (argc < 2) { fprintf(stderr, "Usage: %s \n", argv[0]); exit(1); } @@ -67,6 +70,14 @@ void ejs_exception(const char *reason) exit(1); } + /* setup ARGV[] in the ejs environment */ + for (i=2;i Date: Sun, 29 May 2005 12:10:13 +0000 Subject: r7077: pull in a bunch more libs for smbscript. I plan on making a whole lot of internal functions available to ejs, including rpc functions. This should hopefully fix the link on solaris10 as well (This used to be commit caceb31be841041a0e20c7e261badad2cce82c6a) --- source4/scripting/config.mk | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) (limited to 'source4/scripting') diff --git a/source4/scripting/config.mk b/source4/scripting/config.mk index b32199bc1c..a6c4f73430 100644 --- a/source4/scripting/config.mk +++ b/source4/scripting/config.mk @@ -13,7 +13,8 @@ REQUIRED_SUBSYSTEMS = EJS LIBBASIC [BINARY::smbscript] OBJ_FILES = \ scripting/ejs/smbscript.o -REQUIRED_SUBSYSTEMS = EJS LIBBASIC SMBCALLS +REQUIRED_SUBSYSTEMS = EJS LIBBASIC SMBCALLS CONFIG LIBSMB RPC + # End BINARY SMBSCRIPT ####################### -- cgit From 09e00bbdc18741c20f2eeba83da742f056115789 Mon Sep 17 00:00:00 2001 From: Andrew Tridgell Date: Sun, 29 May 2005 12:41:59 +0000 Subject: r7078: - fix an uninitialised variable in smbscript - fixed handle passing in the smb/ejs interface calls, so they can be called safely from esp (This used to be commit 45ea1b64413de577366939b2106f657f6c47b1bd) --- source4/scripting/ejs/smbcalls.c | 8 ++++---- source4/scripting/ejs/smbscript.c | 2 +- 2 files changed, 5 insertions(+), 5 deletions(-) (limited to 'source4/scripting') diff --git a/source4/scripting/ejs/smbcalls.c b/source4/scripting/ejs/smbcalls.c index 664bb74df3..e436fc78df 100644 --- a/source4/scripting/ejs/smbcalls.c +++ b/source4/scripting/ejs/smbcalls.c @@ -252,8 +252,8 @@ failed: */ void smb_setup_ejs_functions(void) { - ejsDefineStringCFunction(-1, "lpGet", ejs_lpGet, NULL, 0); - ejsDefineStringCFunction(-1, "lpServices", ejs_lpServices, NULL, 0); - ejsDefineCFunction(-1, "typeof", ejs_typeof, NULL, 0); - ejsDefineCFunction(-1, "ldbSearch", ejs_ldbSearch, NULL, 0); + ejsDefineStringCFunction(-1, "lpGet", ejs_lpGet, NULL, MPR_VAR_SCRIPT_HANDLE); + ejsDefineStringCFunction(-1, "lpServices", ejs_lpServices, NULL, MPR_VAR_SCRIPT_HANDLE); + ejsDefineCFunction(-1, "typeof", ejs_typeof, NULL, MPR_VAR_SCRIPT_HANDLE); + ejsDefineCFunction(-1, "ldbSearch", ejs_ldbSearch, NULL, MPR_VAR_SCRIPT_HANDLE); } diff --git a/source4/scripting/ejs/smbscript.c b/source4/scripting/ejs/smbscript.c index 3378885147..021dafa4ae 100644 --- a/source4/scripting/ejs/smbscript.c +++ b/source4/scripting/ejs/smbscript.c @@ -33,7 +33,7 @@ void ejs_exception(const char *reason) int main(int argc, const char *argv[]) { EjsId eid; - EjsHandle handle; + EjsHandle handle = 0; MprVar result; char *emsg; TALLOC_CTX *mem_ctx = talloc_new(NULL); -- cgit From 0b2f972c8a5205f648ed747b04c5232c694afd30 Mon Sep 17 00:00:00 2001 From: Tim Potter Date: Sun, 29 May 2005 21:45:38 +0000 Subject: r7080: Fix typo in error message. (This used to be commit fcf177c86e2bfbc993352b80824487e5df0a3f63) --- source4/scripting/ejs/smbscript.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'source4/scripting') diff --git a/source4/scripting/ejs/smbscript.c b/source4/scripting/ejs/smbscript.c index 021dafa4ae..a15fce57b0 100644 --- a/source4/scripting/ejs/smbscript.c +++ b/source4/scripting/ejs/smbscript.c @@ -80,7 +80,7 @@ void ejs_exception(const char *reason) /* run the script */ if (ejsEvalFile(eid, discard_const_p(char, argv[1]), &result, &emsg) == -1) { - fprintf(stderr, "smbscript: ejsEvalScript(): %s\n", emsg); + fprintf(stderr, "smbscript: ejsEvalFile(): %s\n", emsg); exit(1); } -- cgit From 18fa5ea9ef2d9a20d076790123c131d2dbdc9c22 Mon Sep 17 00:00:00 2001 From: Tim Potter Date: Sun, 29 May 2005 22:10:51 +0000 Subject: r7081: Add mprToInt() function. (This used to be commit 790a46f53bd5b6994cbf6aed670df1407a44e2f3) --- source4/scripting/ejs/mprutil.c | 9 +++++++++ 1 file changed, 9 insertions(+) (limited to 'source4/scripting') diff --git a/source4/scripting/ejs/mprutil.c b/source4/scripting/ejs/mprutil.c index a1e26ecb2c..3e47fdf9a3 100644 --- a/source4/scripting/ejs/mprutil.c +++ b/source4/scripting/ejs/mprutil.c @@ -132,6 +132,15 @@ const char *mprToString(const struct MprVar *v) return v->string; } +/* + turn a MprVar integer variable into an int + */ +int mprToInt(const struct MprVar *v) +{ + if (v->type != MPR_TYPE_INT) return 0; + return v->integer; +} + /* turn a MprVar object variable into a string list this assumes the object variable consists only of strings -- cgit From 520e2258c9949f9129a2e124035c0200c0c59b39 Mon Sep 17 00:00:00 2001 From: Tim Potter Date: Sun, 29 May 2005 22:11:32 +0000 Subject: r7082: Call load_interfaces() in smbscript initialisation. (This used to be commit 54051bf8bbb18653adafb37cc6181617ca60b781) --- source4/scripting/ejs/smbscript.c | 2 ++ 1 file changed, 2 insertions(+) (limited to 'source4/scripting') diff --git a/source4/scripting/ejs/smbscript.c b/source4/scripting/ejs/smbscript.c index a15fce57b0..754a49ccb1 100644 --- a/source4/scripting/ejs/smbscript.c +++ b/source4/scripting/ejs/smbscript.c @@ -54,6 +54,8 @@ void ejs_exception(const char *reason) exit(1); } + load_interfaces(); + mprSetCtx(mem_ctx); if (ejsOpen(NULL, NULL, NULL) != 0) { -- cgit From 4f1a5b716972bc2af916a528399c9dc0c2f18c35 Mon Sep 17 00:00:00 2001 From: Tim Potter Date: Sun, 29 May 2005 22:14:21 +0000 Subject: r7083: Add a ejs hook to the resolve_name() function. We need to figure out what the best way to return NTSTATUS codes. In the Python wrappers I threw an exception which could be caught by some code, but I'm not sure whether this is possible in ejs. (This used to be commit 6911e46c6a576a379ea06f9ba3ef6a62653170f0) --- source4/scripting/ejs/smbcalls.c | 51 ++++++++++++++++++++++++++++++++++++++++ 1 file changed, 51 insertions(+) (limited to 'source4/scripting') diff --git a/source4/scripting/ejs/smbcalls.c b/source4/scripting/ejs/smbcalls.c index e436fc78df..02b40c46d8 100644 --- a/source4/scripting/ejs/smbcalls.c +++ b/source4/scripting/ejs/smbcalls.c @@ -24,6 +24,7 @@ #include "lib/ejs/ejs.h" #include "param/loadparm.h" #include "lib/ldb/include/ldb.h" +#include "librpc/gen_ndr/ndr_nbt.h" /* return the type of a variable @@ -246,6 +247,55 @@ failed: return -1; } +/* + look up a netbios name + + syntax: + resolveName("frogurt"); + resolveName("frogurt", 0x1c); +*/ + +static int ejs_resolve_name(MprVarHandle eid, int argc, struct MprVar **argv) +{ + struct nbt_name name; + TALLOC_CTX *tmp_ctx = talloc_new(mprMemCtx()); + NTSTATUS result; + const char *reply_addr; + + /* validate arguments */ + if (argc == 1) { + if (argv[0]->type != MPR_TYPE_STRING) { + ejsSetErrorMsg(eid, "resolveName invalid arguments"); + goto failed; + } + make_nbt_name_client(&name, mprToString(argv[0])); + } else if (argc == 2) { + if (argv[1]->type != MPR_TYPE_INT) { + ejsSetErrorMsg(eid, "resolveName invalid arguments"); + goto failed; + } + make_nbt_name(&name, mprToString(argv[0]), mprToInt(argv[1])); + } else { + ejsSetErrorMsg(eid, "resolveName invalid arguments"); + goto failed; + } + + result = resolve_name(&name, tmp_ctx, &reply_addr); + + if (!NT_STATUS_IS_OK(result)) { + ejsSetErrorMsg(eid, "resolveName name not found"); + goto failed; + } + + ejsSetReturnString(eid, reply_addr); + + talloc_free(tmp_ctx); + return 0; + + failed: + talloc_free(tmp_ctx); + return -1; +} /* setup the C functions that be called from ejs @@ -256,4 +306,5 @@ void smb_setup_ejs_functions(void) ejsDefineStringCFunction(-1, "lpServices", ejs_lpServices, NULL, MPR_VAR_SCRIPT_HANDLE); ejsDefineCFunction(-1, "typeof", ejs_typeof, NULL, MPR_VAR_SCRIPT_HANDLE); ejsDefineCFunction(-1, "ldbSearch", ejs_ldbSearch, NULL, MPR_VAR_SCRIPT_HANDLE); + ejsDefineCFunction(-1, "resolveName", ejs_resolve_name, NULL, MPR_VAR_SCRIPT_HANDLE); } -- cgit From a05bd5e9d654b97e1a2128a5048b68b7efd9ccd7 Mon Sep 17 00:00:00 2001 From: Andrew Tridgell Date: Tue, 31 May 2005 04:12:55 +0000 Subject: r7135: make typeof() complient with ECMA 11.4.3 (This used to be commit 29ab4cc6cb244255ab75af7ae2076b51209f4f2d) --- source4/scripting/ejs/smbcalls.c | 23 ++++++++++++----------- 1 file changed, 12 insertions(+), 11 deletions(-) (limited to 'source4/scripting') diff --git a/source4/scripting/ejs/smbcalls.c b/source4/scripting/ejs/smbcalls.c index 02b40c46d8..fc2c16a456 100644 --- a/source4/scripting/ejs/smbcalls.c +++ b/source4/scripting/ejs/smbcalls.c @@ -35,20 +35,20 @@ static int ejs_typeof(MprVarHandle eid, int argc, struct MprVar **argv) MprType type; const char *name; } types[] = { - { MPR_TYPE_UNDEFINED, "undefined" }, - { MPR_TYPE_NULL, "null" }, - { MPR_TYPE_BOOL, "boolean" }, - { MPR_TYPE_CFUNCTION, "function" }, - { MPR_TYPE_FLOAT, "float" }, - { MPR_TYPE_INT, "int" }, - { MPR_TYPE_INT64, "int64" }, - { MPR_TYPE_OBJECT, "object" }, - { MPR_TYPE_FUNCTION, "function" }, - { MPR_TYPE_STRING, "string" }, + { MPR_TYPE_UNDEFINED, "undefined" }, + { MPR_TYPE_NULL, "object" }, + { MPR_TYPE_BOOL, "boolean" }, + { MPR_TYPE_CFUNCTION, "function" }, + { MPR_TYPE_FLOAT, "number" }, + { MPR_TYPE_INT, "number" }, + { MPR_TYPE_INT64, "number" }, + { MPR_TYPE_OBJECT, "object" }, + { MPR_TYPE_FUNCTION, "function" }, + { MPR_TYPE_STRING, "string" }, { MPR_TYPE_STRING_CFUNCTION, "function" } }; int i; - const char *type = "unknown"; + const char *type = NULL; if (argc != 1) return -1; @@ -58,6 +58,7 @@ static int ejs_typeof(MprVarHandle eid, int argc, struct MprVar **argv) break; } } + if (type == NULL) return -1; ejsSetReturnString(eid, type); return 0; -- cgit From afeaf137c4cbcbde1d6e4c9921bb769a1d486aff Mon Sep 17 00:00:00 2001 From: Tim Potter Date: Fri, 3 Jun 2005 08:00:42 +0000 Subject: r7215: Convert smbscript to use ejsEvalScript() and file_load() instead of ejsEvalFile(). Still need to add advancement of the script past the hash-bang line but it's home time now!! (This used to be commit 14a2053c045a2df1d68838900c833c2a15cb5a36) --- source4/scripting/ejs/smbscript.c | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) (limited to 'source4/scripting') diff --git a/source4/scripting/ejs/smbscript.c b/source4/scripting/ejs/smbscript.c index 754a49ccb1..323e604f8d 100644 --- a/source4/scripting/ejs/smbscript.c +++ b/source4/scripting/ejs/smbscript.c @@ -35,7 +35,8 @@ void ejs_exception(const char *reason) EjsId eid; EjsHandle handle = 0; MprVar result; - char *emsg; + char *emsg, *script; + size_t script_size; TALLOC_CTX *mem_ctx = talloc_new(NULL); const char **argv_list = NULL; struct MprVar v; @@ -79,10 +80,12 @@ void ejs_exception(const char *reason) v = mprList("ARGV", argv_list); mprCreateProperty(ejsGetGlobalObject(eid), "ARGV", &v); + /* load the script and advance past interpreter line*/ + script = file_load(argv[1], &script_size); + /* run the script */ - if (ejsEvalFile(eid, discard_const_p(char, argv[1]), &result, - &emsg) == -1) { - fprintf(stderr, "smbscript: ejsEvalFile(): %s\n", emsg); + if (ejsEvalScript(eid, script, &result, &emsg) == -1) { + fprintf(stderr, "smbscript: ejsEvalScript(): %s\n", emsg); exit(1); } -- cgit From c1b95bd467109793333c15ea44ec910ffe3e86b4 Mon Sep 17 00:00:00 2001 From: Tim Potter Date: Fri, 3 Jun 2005 12:04:26 +0000 Subject: r7223: Advance script past interpreter line. (This used to be commit 31b9fadbed656f666f587a9dcb5a7627a2d388aa) --- source4/scripting/ejs/smbscript.c | 11 +++++++++++ 1 file changed, 11 insertions(+) (limited to 'source4/scripting') diff --git a/source4/scripting/ejs/smbscript.c b/source4/scripting/ejs/smbscript.c index 323e604f8d..43a9377143 100644 --- a/source4/scripting/ejs/smbscript.c +++ b/source4/scripting/ejs/smbscript.c @@ -83,6 +83,17 @@ void ejs_exception(const char *reason) /* load the script and advance past interpreter line*/ script = file_load(argv[1], &script_size); + if ((script_size > 2) && script[0] == '#' && script[1] == '!') { + script += 2; + script_size -= 2; + while (script_size) { + if (*script == '\r' || *script == '\n') + break; + script++; + script_size--; + } + } + /* run the script */ if (ejsEvalScript(eid, script, &result, &emsg) == -1) { fprintf(stderr, "smbscript: ejsEvalScript(): %s\n", emsg); -- cgit From e8cbe7f3a4d828619285cdfebf5b786ddebf7928 Mon Sep 17 00:00:00 2001 From: Tim Potter Date: Fri, 3 Jun 2005 12:31:56 +0000 Subject: r7225: Create a MprVar object from a NTSTATUS, e.g: res: { is_err: true, is_ok: false, errstr: "NT_STATUS_IO_TIMEOUT", v: -1073741643 } (This used to be commit d81d5f8317ca82a08e6fc38ef7313fad2e631281) --- source4/scripting/ejs/mprutil.c | 23 +++++++++++++++++++++++ 1 file changed, 23 insertions(+) (limited to 'source4/scripting') diff --git a/source4/scripting/ejs/mprutil.c b/source4/scripting/ejs/mprutil.c index 3e47fdf9a3..4aee7d1c50 100644 --- a/source4/scripting/ejs/mprutil.c +++ b/source4/scripting/ejs/mprutil.c @@ -166,3 +166,26 @@ const char **mprToList(TALLOC_CTX *mem_ctx, struct MprVar *v) return list; } +/* + turn a NTSTATUS into a MprVar object with lots of funky properties +*/ +struct MprVar mprNTSTATUS(NTSTATUS status) +{ + struct MprVar res, val; + + res = mprCreateObjVar("ntstatus", MPR_DEFAULT_HASH_SIZE); + + val = mprCreateStringVar(nt_errstr(status), 1); + mprCreateProperty(&res, "errstr", &val); + + val = mprCreateIntegerVar(NT_STATUS_V(status)); + mprCreateProperty(&res, "v", &val); + + val = mprCreateBoolVar(NT_STATUS_IS_OK(status)); + mprCreateProperty(&res, "is_ok", &val); + + val = mprCreateBoolVar(NT_STATUS_IS_ERR(status)); + mprCreateProperty(&res, "is_err", &val); + + return res; +} -- cgit From 266c37e5dc97879e30e790cd87d2ec1f43907477 Mon Sep 17 00:00:00 2001 From: Simo Sorce Date: Fri, 3 Jun 2005 14:17:18 +0000 Subject: r7238: Add pam auth support in swat (This used to be commit 8a98572a3b5dba58181dc402dbebae5452656012) --- source4/scripting/config.mk | 2 +- source4/scripting/ejs/smbcalls.c | 82 ++++++++++++++++++++++++++++++++++++++++ 2 files changed, 83 insertions(+), 1 deletion(-) (limited to 'source4/scripting') diff --git a/source4/scripting/config.mk b/source4/scripting/config.mk index a6c4f73430..078c04297e 100644 --- a/source4/scripting/config.mk +++ b/source4/scripting/config.mk @@ -4,7 +4,7 @@ OBJ_FILES = \ scripting/ejs/smbcalls.o \ scripting/ejs/mprutil.o -REQUIRED_SUBSYSTEMS = EJS LIBBASIC +REQUIRED_SUBSYSTEMS = AUTH EJS LIBBASIC # End SUBSYSTEM SMBCALLS ####################### diff --git a/source4/scripting/ejs/smbcalls.c b/source4/scripting/ejs/smbcalls.c index fc2c16a456..8a02111bd5 100644 --- a/source4/scripting/ejs/smbcalls.c +++ b/source4/scripting/ejs/smbcalls.c @@ -25,6 +25,7 @@ #include "param/loadparm.h" #include "lib/ldb/include/ldb.h" #include "librpc/gen_ndr/ndr_nbt.h" +#include "auth/auth.h" /* return the type of a variable @@ -298,6 +299,85 @@ static int ejs_resolve_name(MprVarHandle eid, int argc, struct MprVar **argv) return -1; } +static int ejs_userAuth(MprVarHandle eid, int argc, char **argv) +{ + struct auth_usersupplied_info *user_info = NULL; + struct auth_serversupplied_info *server_info = NULL; + struct auth_context *auth_context; + TALLOC_CTX *tmp_ctx; + struct MprVar auth; + NTSTATUS nt_status; + DATA_BLOB pw_blob; + int ret; + + if (argc != 3 || *argv[0] == 0 || *argv[2] == 0) { + ejsSetErrorMsg(eid, "userAuth invalid arguments"); + return -1; + } + + tmp_ctx = talloc_new(mprMemCtx()); + auth = mprCreateObjVar("auth", MPR_DEFAULT_HASH_SIZE); + + if (strcmp("System User", argv[2]) == 0) { + const char *auth_unix[] = { "unix", NULL }; + + nt_status = auth_context_create(tmp_ctx, auth_unix, &auth_context); + if (!NT_STATUS_IS_OK(nt_status)) { + mprSetPropertyValue(&auth, "result", mprCreateBoolVar(False)); + mprSetPropertyValue(&auth, "report", mprCreateStringVar("Auth System Failure", 0)); + goto done; + } + + pw_blob = data_blob(argv[1], strlen(argv[1])), + make_user_info(tmp_ctx, argv[0], argv[0], + argv[2], argv[2], + "foowks", "fooip", + NULL, NULL, + NULL, NULL, + &pw_blob, False, + 0x05, &user_info); + nt_status = auth_check_password(auth_context, tmp_ctx, user_info, &server_info); + if (!NT_STATUS_IS_OK(nt_status)) { + mprSetPropertyValue(&auth, "result", mprCreateBoolVar(False)); + mprSetPropertyValue(&auth, "report", mprCreateStringVar("Login Failed", 0)); + goto done; + } + + mprSetPropertyValue(&auth, "result", mprCreateBoolVar(server_info->authenticated)); + mprSetPropertyValue(&auth, "username", mprCreateStringVar(server_info->account_name, 0)); + mprSetPropertyValue(&auth, "domain", mprCreateStringVar(server_info->domain_name, 0)); + + } else { + mprSetPropertyValue(&auth, "result", mprCreateBoolVar(False)); + mprSetPropertyValue(&auth, "report", mprCreateStringVar("Unknown Domain", 0)); + } + +done: + ejsSetReturnValue(eid, auth); + talloc_free(tmp_ctx); + return 0; +} + +static int ejs_domain_list(MprVarHandle eid, int argc, char **argv) +{ + struct MprVar list; + struct MprVar dom; + + if (argc != 0) { + ejsSetErrorMsg(eid, "domList invalid arguments"); + return -1; + } + + list = mprCreateObjVar("list", MPR_DEFAULT_HASH_SIZE); + dom = mprCreateStringVar("System User", 1); + mprCreateProperty(&list, "0", &dom); + + ejsSetReturnValue(eid, list); + + return 0; +} + + /* setup the C functions that be called from ejs */ @@ -308,4 +388,6 @@ void smb_setup_ejs_functions(void) ejsDefineCFunction(-1, "typeof", ejs_typeof, NULL, MPR_VAR_SCRIPT_HANDLE); ejsDefineCFunction(-1, "ldbSearch", ejs_ldbSearch, NULL, MPR_VAR_SCRIPT_HANDLE); ejsDefineCFunction(-1, "resolveName", ejs_resolve_name, NULL, MPR_VAR_SCRIPT_HANDLE); + ejsDefineStringCFunction(-1, "getDomainList", ejs_domain_list, NULL, MPR_VAR_SCRIPT_HANDLE); + ejsDefineStringCFunction(-1, "userAuth", ejs_userAuth, NULL, MPR_VAR_SCRIPT_HANDLE); } -- cgit From 384ad5c71b012d11e61d5a9ad8059423f771cccb Mon Sep 17 00:00:00 2001 From: Tim Potter Date: Sat, 4 Jun 2005 01:06:30 +0000 Subject: r7254: Add a mprWERROR() function with the same attributes as mprNTSTATUS. (This used to be commit 2fa6f7bb2b8390f6486f6531212b556e98a6c528) --- source4/scripting/ejs/mprutil.c | 24 ++++++++++++++++++++++++ 1 file changed, 24 insertions(+) (limited to 'source4/scripting') diff --git a/source4/scripting/ejs/mprutil.c b/source4/scripting/ejs/mprutil.c index 4aee7d1c50..2a1036d9a4 100644 --- a/source4/scripting/ejs/mprutil.c +++ b/source4/scripting/ejs/mprutil.c @@ -189,3 +189,27 @@ struct MprVar mprNTSTATUS(NTSTATUS status) return res; } + +/* + turn a WERROR into a MprVar object with lots of funky properties +*/ +struct MprVar mprWERROR(WERROR status) +{ + struct MprVar res, val; + + res = mprCreateObjVar("werror", MPR_DEFAULT_HASH_SIZE); + + val = mprCreateStringVar(win_errstr(status), 1); + mprCreateProperty(&res, "errstr", &val); + + val = mprCreateIntegerVar(W_ERROR_V(status)); + mprCreateProperty(&res, "v", &val); + + val = mprCreateBoolVar(W_ERROR_IS_OK(status)); + mprCreateProperty(&res, "is_ok", &val); + + val = mprCreateBoolVar(True); + mprCreateProperty(&res, "is_err", &val); + + return res; +} -- cgit From 383c5fb68a212eed60750793ad4b7e4bbcbcd2d5 Mon Sep 17 00:00:00 2001 From: Tim Potter Date: Sat, 4 Jun 2005 01:08:52 +0000 Subject: r7255: Change syntax of resolveName() js function to be more like the resolve_name() C function. I can't figure out how to return variables by reference though. Writing to argv[] doesn't seem to work. (This used to be commit aef99859f28570b60f4fefe2981160269f6eb02a) --- source4/scripting/ejs/smbcalls.c | 54 +++++++++++++++++++++------------------- 1 file changed, 28 insertions(+), 26 deletions(-) (limited to 'source4/scripting') diff --git a/source4/scripting/ejs/smbcalls.c b/source4/scripting/ejs/smbcalls.c index 8a02111bd5..5d4c61b04b 100644 --- a/source4/scripting/ejs/smbcalls.c +++ b/source4/scripting/ejs/smbcalls.c @@ -253,50 +253,53 @@ failed: look up a netbios name syntax: - resolveName("frogurt"); - resolveName("frogurt", 0x1c); + 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 result; + NTSTATUS nt_status; const char *reply_addr; /* validate arguments */ - if (argc == 1) { - if (argv[0]->type != MPR_TYPE_STRING) { - ejsSetErrorMsg(eid, "resolveName invalid arguments"); - goto failed; - } - make_nbt_name_client(&name, mprToString(argv[0])); - } else if (argc == 2) { + if (argc < 2 || argc > 3) { + 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 (argv[1]->type != MPR_TYPE_INT) { ejsSetErrorMsg(eid, "resolveName invalid arguments"); - goto failed; + goto done; } - make_nbt_name(&name, mprToString(argv[0]), mprToInt(argv[1])); - } else { - ejsSetErrorMsg(eid, "resolveName invalid arguments"); - goto failed; + make_nbt_name(&name, mprToString(argv[1]), mprToInt(argv[2])); } - result = resolve_name(&name, tmp_ctx, &reply_addr); + result = 0; - if (!NT_STATUS_IS_OK(result)) { - ejsSetErrorMsg(eid, "resolveName name not found"); - goto failed; + nt_status = resolve_name(&name, tmp_ctx, &reply_addr); + + if (NT_STATUS_IS_OK(nt_status)) { + mprDestroyAllVars(argv[0]); + *argv[0] = mprCreateStringVar(reply_addr, True); } - - ejsSetReturnString(eid, reply_addr); - talloc_free(tmp_ctx); - return 0; + ejsSetReturnValue(eid, mprNTSTATUS(nt_status)); - failed: + done: talloc_free(tmp_ctx); - return -1; + return result; } static int ejs_userAuth(MprVarHandle eid, int argc, char **argv) @@ -308,7 +311,6 @@ static int ejs_userAuth(MprVarHandle eid, int argc, char **argv) struct MprVar auth; NTSTATUS nt_status; DATA_BLOB pw_blob; - int ret; if (argc != 3 || *argv[0] == 0 || *argv[2] == 0) { ejsSetErrorMsg(eid, "userAuth invalid arguments"); -- cgit From b1243510793cd135f1464dcfeec0b7e88999d1a0 Mon Sep 17 00:00:00 2001 From: Tim Potter Date: Sat, 4 Jun 2005 03:32:18 +0000 Subject: r7261: Pass by reference is done in js via MPR_TYPE_OBJECT. Update argument parsing and example for resolveName(). (This used to be commit 1a4a54931733ebfa743401a184fe460c044427b4) --- source4/scripting/ejs/smbcalls.c | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) (limited to 'source4/scripting') diff --git a/source4/scripting/ejs/smbcalls.c b/source4/scripting/ejs/smbcalls.c index 5d4c61b04b..93496bd9c9 100644 --- a/source4/scripting/ejs/smbcalls.c +++ b/source4/scripting/ejs/smbcalls.c @@ -271,6 +271,11 @@ static int ejs_resolve_name(MprVarHandle eid, int argc, struct MprVar **argv) 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; @@ -291,8 +296,8 @@ static int ejs_resolve_name(MprVarHandle eid, int argc, struct MprVar **argv) nt_status = resolve_name(&name, tmp_ctx, &reply_addr); if (NT_STATUS_IS_OK(nt_status)) { - mprDestroyAllVars(argv[0]); - *argv[0] = mprCreateStringVar(reply_addr, True); + mprSetPropertyValue(argv[0], "value", + mprCreateStringVar(reply_addr, 1)); } ejsSetReturnValue(eid, mprNTSTATUS(nt_status)); -- cgit From d6555cadb7015d407a2a17538d8a1ccd073a41e6 Mon Sep 17 00:00:00 2001 From: Tim Potter Date: Sat, 4 Jun 2005 03:35:38 +0000 Subject: r7262: Add a length property to ARGV array. (This used to be commit 4b775c619b7abed52d158ab70505320753a0c9cb) --- source4/scripting/ejs/smbscript.c | 1 + 1 file changed, 1 insertion(+) (limited to 'source4/scripting') diff --git a/source4/scripting/ejs/smbscript.c b/source4/scripting/ejs/smbscript.c index 43a9377143..4bde40a955 100644 --- a/source4/scripting/ejs/smbscript.c +++ b/source4/scripting/ejs/smbscript.c @@ -78,6 +78,7 @@ void ejs_exception(const char *reason) argv_list = str_list_add(argv_list, argv[i]); } v = mprList("ARGV", argv_list); + mprSetPropertyValue(&v, "length", mprCreateIntegerVar(argc - 2)); mprCreateProperty(ejsGetGlobalObject(eid), "ARGV", &v); /* load the script and advance past interpreter line*/ -- cgit From 32f2e9806b267782125fed3a6162ea895e634eef Mon Sep 17 00:00:00 2001 From: Tim Potter Date: Sat, 4 Jun 2005 03:51:38 +0000 Subject: r7263: Exit smbscript with the intepreter return value (defaults to 0). Change the exit value for an exception, usage error and other non-js errors to 127 which is kinda like the return value for the system(3) function. (This used to be commit c77a232b1152a27e2d8ffb719aefba6c6b2ba6df) --- source4/scripting/ejs/smbscript.c | 23 +++++++++++++---------- 1 file changed, 13 insertions(+), 10 deletions(-) (limited to 'source4/scripting') diff --git a/source4/scripting/ejs/smbscript.c b/source4/scripting/ejs/smbscript.c index 4bde40a955..02a3aff28e 100644 --- a/source4/scripting/ejs/smbscript.c +++ b/source4/scripting/ejs/smbscript.c @@ -1,7 +1,7 @@ /* Unix SMB/CIFS implementation. - Standalone client for ESP scripting. + Standalone client for ejs scripting. Copyright (C) Tim Potter 2005 @@ -27,7 +27,7 @@ void ejs_exception(const char *reason) { fprintf(stderr, "smbscript exception: %s", reason); - exit(1); + exit(127); } int main(int argc, const char *argv[]) @@ -39,12 +39,12 @@ void ejs_exception(const char *reason) size_t script_size; TALLOC_CTX *mem_ctx = talloc_new(NULL); const char **argv_list = NULL; - struct MprVar v; - int i; + struct MprVar v, *return_var; + int exit_status, i; if (argc < 2) { fprintf(stderr, "Usage: %s \n", argv[0]); - exit(1); + exit(127); } setup_logging(argv[0],DEBUG_STDOUT); @@ -52,7 +52,7 @@ void ejs_exception(const char *reason) if (!lp_load(dyn_CONFIGFILE, False, False, False)) { fprintf(stderr, "%s: Can't load %s - run testparm to debug it\n", argv[0], dyn_CONFIGFILE); - exit(1); + exit(127); } load_interfaces(); @@ -62,7 +62,7 @@ void ejs_exception(const char *reason) if (ejsOpen(NULL, NULL, NULL) != 0) { fprintf(stderr, "smbscript: ejsOpen(): unable to initialise " "EJ subsystem\n"); - exit(1); + exit(127); } smb_setup_ejs_functions(); @@ -70,7 +70,7 @@ void ejs_exception(const char *reason) if ((eid = ejsOpenEngine(handle, 0)) == (EjsId)-1) { fprintf(stderr, "smbscript: ejsOpenEngine(): unable to " "initialise an EJS engine\n"); - exit(1); + exit(127); } /* setup ARGV[] in the ejs environment */ @@ -98,12 +98,15 @@ void ejs_exception(const char *reason) /* run the script */ if (ejsEvalScript(eid, script, &result, &emsg) == -1) { fprintf(stderr, "smbscript: ejsEvalScript(): %s\n", emsg); - exit(1); + exit(127); } + return_var = ejsGetReturnValue(eid); + exit_status = return_var->integer; + ejsClose(); talloc_free(mem_ctx); - return 0; + return exit_status; } -- cgit From f84d007c438dd43f2cd5a9b6ca583976c8e777fa Mon Sep 17 00:00:00 2001 From: Tim Potter Date: Sat, 4 Jun 2005 07:04:43 +0000 Subject: r7266: Split the different types of js function defines into separate files, as there are going to be a lot more of them. (This used to be commit b086768589ee27de6616945bbea42b18b40d25d5) --- source4/scripting/config.mk | 3 + source4/scripting/ejs/smbcalls.c | 250 +------------------------------- source4/scripting/ejs/smbcalls.h | 25 ++++ source4/scripting/ejs/smbcalls_config.c | 149 +++++++++++++++++++ source4/scripting/ejs/smbcalls_ldb.c | 93 ++++++++++++ source4/scripting/ejs/smbcalls_nbt.c | 91 ++++++++++++ 6 files changed, 368 insertions(+), 243 deletions(-) create mode 100644 source4/scripting/ejs/smbcalls.h create mode 100644 source4/scripting/ejs/smbcalls_config.c create mode 100644 source4/scripting/ejs/smbcalls_ldb.c create mode 100644 source4/scripting/ejs/smbcalls_nbt.c (limited to 'source4/scripting') diff --git a/source4/scripting/config.mk b/source4/scripting/config.mk index 078c04297e..597fa1a84a 100644 --- a/source4/scripting/config.mk +++ b/source4/scripting/config.mk @@ -3,6 +3,9 @@ [SUBSYSTEM::SMBCALLS] OBJ_FILES = \ scripting/ejs/smbcalls.o \ + scripting/ejs/smbcalls_config.o \ + scripting/ejs/smbcalls_ldb.o \ + scripting/ejs/smbcalls_nbt.o \ scripting/ejs/mprutil.o REQUIRED_SUBSYSTEMS = AUTH EJS LIBBASIC # End SUBSYSTEM SMBCALLS diff --git a/source4/scripting/ejs/smbcalls.c b/source4/scripting/ejs/smbcalls.c index 93496bd9c9..54dc8d4e62 100644 --- a/source4/scripting/ejs/smbcalls.c +++ b/source4/scripting/ejs/smbcalls.c @@ -4,6 +4,7 @@ provide hooks into smbd C calls from ejs scripts Copyright (C) Andrew Tridgell 2005 + 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 @@ -22,9 +23,6 @@ #include "includes.h" #include "lib/ejs/ejs.h" -#include "param/loadparm.h" -#include "lib/ldb/include/ldb.h" -#include "librpc/gen_ndr/ndr_nbt.h" #include "auth/auth.h" /* @@ -68,245 +66,11 @@ static int ejs_typeof(MprVarHandle eid, int argc, struct MprVar **argv) /* setup a return of a string list */ -static void ejs_returnlist(MprVarHandle eid, - const char *name, const char **list) + void ejs_returnlist(MprVarHandle eid, const char *name, const char **list) { ejsSetReturnValue(eid, mprList(name, list)); } -/* - return a list of defined services -*/ -static int ejs_lpServices(MprVarHandle eid, int argc, char **argv) -{ - int i; - const char **list = NULL; - if (argc != 0) return -1; - - for (i=0;iclass == P_GLOBAL) { - return -1; - } - parm_ptr = lp_parm_ptr(snum, parm); - } else if (strchr(argv[0], ':')) { - /* its a global parametric option */ - const char *type = talloc_strndup(mprMemCtx(), - argv[0], strcspn(argv[0], ":")); - const char *option = strchr(argv[0], ':') + 1; - const char *value; - if (type == NULL || option == NULL) return -1; - value = lp_get_parametric(-1, type, option); - if (value == NULL) return -1; - ejsSetReturnString(eid, value); - return 0; - } else { - /* its a global parameter */ - parm = lp_parm_struct(argv[0]); - if (parm == NULL) return -1; - parm_ptr = parm->ptr; - } - - if (parm == NULL || parm_ptr == NULL) { - return -1; - } - - /* construct and return the right type of ejs object */ - switch (parm->type) { - case P_STRING: - case P_USTRING: - ejsSetReturnString(eid, *(char **)parm_ptr); - break; - case P_BOOL: - ejsSetReturnValue(eid, mprCreateBoolVar(*(BOOL *)parm_ptr)); - break; - case P_INTEGER: - ejsSetReturnValue(eid, mprCreateIntegerVar(*(int *)parm_ptr)); - break; - case P_ENUM: - for (i=0; parm->enum_list[i].name; i++) { - if (*(int *)parm_ptr == parm->enum_list[i].value) { - ejsSetReturnString(eid, parm->enum_list[i].name); - return 0; - } - } - return -1; - case P_LIST: - ejs_returnlist(eid, parm->label, *(const char ***)parm_ptr); - break; - case P_SEP: - return -1; - } - return 0; -} - - -/* - perform an ldb search, returning an array of results - - syntax: - ldbSearch("dbfile", "expression"); - var attrs = new Array("attr1", "attr2", "attr3"); - ldbSearch("dbfile", "expression", attrs); -*/ -static int ejs_ldbSearch(MprVarHandle eid, int argc, struct MprVar **argv) -{ - const char **attrs = NULL; - const char *expression, *dbfile; - TALLOC_CTX *tmp_ctx = talloc_new(mprMemCtx()); - struct ldb_context *ldb; - int ret; - struct ldb_message **res; - - /* validate arguments */ - if (argc < 2 || argc > 3 || - argv[0]->type != MPR_TYPE_STRING) { - ejsSetErrorMsg(eid, "ldbSearch invalid arguments"); - goto failed; - } - if (argc == 3 && argv[2]->type != MPR_TYPE_OBJECT) { - ejsSetErrorMsg(eid, "ldbSearch attributes must be an object"); - goto failed; - } - - dbfile = mprToString(argv[0]); - expression = mprToString(argv[1]); - if (argc > 2) { - attrs = mprToList(tmp_ctx, argv[2]); - } - if (dbfile == NULL || expression == NULL) { - ejsSetErrorMsg(eid, "ldbSearch invalid arguments"); - goto failed; - } - - ldb = ldb_wrap_connect(tmp_ctx, dbfile, 0, NULL); - if (ldb == NULL) { - ejsSetErrorMsg(eid, "ldbSearch failed to open %s", dbfile); - goto failed; - } - - ret = ldb_search(ldb, NULL, LDB_SCOPE_DEFAULT, expression, attrs, &res); - if (ret == -1) { - ejsSetErrorMsg(eid, "ldbSearch failed - %s", ldb_errstring(ldb)); - goto failed; - } - - ejsSetReturnValue(eid, mprLdbArray(res, ret, "ldb_message")); - - talloc_free(tmp_ctx); - return 0; - -failed: - talloc_free(tmp_ctx); - return -1; -} - -/* - 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 (argv[1]->type != MPR_TYPE_INT) { - ejsSetErrorMsg(eid, "resolveName invalid arguments"); - goto done; - } - make_nbt_name(&name, mprToString(argv[1]), mprToInt(argv[2])); - } - - result = 0; - - nt_status = resolve_name(&name, tmp_ctx, &reply_addr); - - if (NT_STATUS_IS_OK(nt_status)) { - mprSetPropertyValue(argv[0], "value", - mprCreateStringVar(reply_addr, 1)); - } - - ejsSetReturnValue(eid, mprNTSTATUS(nt_status)); - - done: - talloc_free(tmp_ctx); - return result; -} - static int ejs_userAuth(MprVarHandle eid, int argc, char **argv) { struct auth_usersupplied_info *user_info = NULL; @@ -386,15 +150,15 @@ static int ejs_domain_list(MprVarHandle eid, int argc, char **argv) /* - setup the C functions that be called from ejs + setup C functions that be called from ejs */ void smb_setup_ejs_functions(void) { - ejsDefineStringCFunction(-1, "lpGet", ejs_lpGet, NULL, MPR_VAR_SCRIPT_HANDLE); - ejsDefineStringCFunction(-1, "lpServices", ejs_lpServices, NULL, MPR_VAR_SCRIPT_HANDLE); + smb_setup_ejs_config(); + smb_setup_ejs_ldb(); + smb_setup_ejs_nbt(); + ejsDefineCFunction(-1, "typeof", ejs_typeof, NULL, MPR_VAR_SCRIPT_HANDLE); - ejsDefineCFunction(-1, "ldbSearch", ejs_ldbSearch, NULL, MPR_VAR_SCRIPT_HANDLE); - ejsDefineCFunction(-1, "resolveName", ejs_resolve_name, NULL, MPR_VAR_SCRIPT_HANDLE); ejsDefineStringCFunction(-1, "getDomainList", ejs_domain_list, NULL, MPR_VAR_SCRIPT_HANDLE); ejsDefineStringCFunction(-1, "userAuth", ejs_userAuth, NULL, MPR_VAR_SCRIPT_HANDLE); } diff --git a/source4/scripting/ejs/smbcalls.h b/source4/scripting/ejs/smbcalls.h new file mode 100644 index 0000000000..8b26e13873 --- /dev/null +++ b/source4/scripting/ejs/smbcalls.h @@ -0,0 +1,25 @@ +/* + Unix SMB/CIFS implementation. + + provide hooks into smbd C 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 2 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, write to the Free Software + Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. +*/ + +#include "lib/ejs/ejs.h" + +void ejs_returnlist(MprVarHandle eid, const char *name, const char **list); diff --git a/source4/scripting/ejs/smbcalls_config.c b/source4/scripting/ejs/smbcalls_config.c new file mode 100644 index 0000000000..cd0ecbd767 --- /dev/null +++ b/source4/scripting/ejs/smbcalls_config.c @@ -0,0 +1,149 @@ +/* + Unix SMB/CIFS implementation. + + provide hooks into smbd C 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 2 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, write to the Free Software + Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. +*/ + +#include "includes.h" +#include "scripting/ejs/smbcalls.h" +#include "lib/ejs/ejs.h" +#include "param/loadparm.h" + +/* + return a list of defined services +*/ +static int ejs_lpServices(MprVarHandle eid, int argc, char **argv) +{ + int i; + const char **list = NULL; + if (argc != 0) return -1; + + for (i=0;iclass == P_GLOBAL) { + return -1; + } + parm_ptr = lp_parm_ptr(snum, parm); + } else if (strchr(argv[0], ':')) { + /* its a global parametric option */ + const char *type = talloc_strndup(mprMemCtx(), + argv[0], strcspn(argv[0], ":")); + const char *option = strchr(argv[0], ':') + 1; + const char *value; + if (type == NULL || option == NULL) return -1; + value = lp_get_parametric(-1, type, option); + if (value == NULL) return -1; + ejsSetReturnString(eid, value); + return 0; + } else { + /* its a global parameter */ + parm = lp_parm_struct(argv[0]); + if (parm == NULL) return -1; + parm_ptr = parm->ptr; + } + + if (parm == NULL || parm_ptr == NULL) { + return -1; + } + + /* construct and return the right type of ejs object */ + switch (parm->type) { + case P_STRING: + case P_USTRING: + ejsSetReturnString(eid, *(char **)parm_ptr); + break; + case P_BOOL: + ejsSetReturnValue(eid, mprCreateBoolVar(*(BOOL *)parm_ptr)); + break; + case P_INTEGER: + ejsSetReturnValue(eid, mprCreateIntegerVar(*(int *)parm_ptr)); + break; + case P_ENUM: + for (i=0; parm->enum_list[i].name; i++) { + if (*(int *)parm_ptr == parm->enum_list[i].value) { + ejsSetReturnString(eid, parm->enum_list[i].name); + return 0; + } + } + return -1; + case P_LIST: + ejs_returnlist(eid, parm->label, *(const char ***)parm_ptr); + break; + case P_SEP: + return -1; + } + return 0; +} + +/* + setup C functions that be called from ejs +*/ +void smb_setup_ejs_config(void) +{ + ejsDefineStringCFunction(-1, "lpGet", ejs_lpGet, NULL, MPR_VAR_SCRIPT_HANDLE); + ejsDefineStringCFunction(-1, "lpServices", ejs_lpServices, NULL, MPR_VAR_SCRIPT_HANDLE); +} diff --git a/source4/scripting/ejs/smbcalls_ldb.c b/source4/scripting/ejs/smbcalls_ldb.c new file mode 100644 index 0000000000..cae3857686 --- /dev/null +++ b/source4/scripting/ejs/smbcalls_ldb.c @@ -0,0 +1,93 @@ +/* + Unix SMB/CIFS implementation. + + provide hooks into smbd C 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 2 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, write to the Free Software + Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. +*/ + +#include "includes.h" +#include "lib/ejs/ejs.h" +#include "lib/ldb/include/ldb.h" + +/* + perform an ldb search, returning an array of results + + syntax: + ldbSearch("dbfile", "expression"); + var attrs = new Array("attr1", "attr2", "attr3"); + ldbSearch("dbfile", "expression", attrs); +*/ +static int ejs_ldbSearch(MprVarHandle eid, int argc, struct MprVar **argv) +{ + const char **attrs = NULL; + const char *expression, *dbfile; + TALLOC_CTX *tmp_ctx = talloc_new(mprMemCtx()); + struct ldb_context *ldb; + int ret; + struct ldb_message **res; + + /* validate arguments */ + if (argc < 2 || argc > 3 || + argv[0]->type != MPR_TYPE_STRING) { + ejsSetErrorMsg(eid, "ldbSearch invalid arguments"); + goto failed; + } + if (argc == 3 && argv[2]->type != MPR_TYPE_OBJECT) { + ejsSetErrorMsg(eid, "ldbSearch attributes must be an object"); + goto failed; + } + + dbfile = mprToString(argv[0]); + expression = mprToString(argv[1]); + if (argc > 2) { + attrs = mprToList(tmp_ctx, argv[2]); + } + if (dbfile == NULL || expression == NULL) { + ejsSetErrorMsg(eid, "ldbSearch invalid arguments"); + goto failed; + } + + ldb = ldb_wrap_connect(tmp_ctx, dbfile, 0, NULL); + if (ldb == NULL) { + ejsSetErrorMsg(eid, "ldbSearch failed to open %s", dbfile); + goto failed; + } + + ret = ldb_search(ldb, NULL, LDB_SCOPE_DEFAULT, expression, attrs, &res); + if (ret == -1) { + ejsSetErrorMsg(eid, "ldbSearch failed - %s", ldb_errstring(ldb)); + goto failed; + } + + ejsSetReturnValue(eid, mprLdbArray(res, ret, "ldb_message")); + + talloc_free(tmp_ctx); + return 0; + +failed: + talloc_free(tmp_ctx); + return -1; +} + +/* + setup C functions that be called from ejs +*/ +void smb_setup_ejs_ldb(void) +{ + ejsDefineCFunction(-1, "ldbSearch", ejs_ldbSearch, NULL, MPR_VAR_SCRIPT_HANDLE); +} diff --git a/source4/scripting/ejs/smbcalls_nbt.c b/source4/scripting/ejs/smbcalls_nbt.c new file mode 100644 index 0000000000..a82b636c9c --- /dev/null +++ b/source4/scripting/ejs/smbcalls_nbt.c @@ -0,0 +1,91 @@ +/* + 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 2 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, write to the Free Software + Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. +*/ + +#include "includes.h" +#include "lib/ejs/ejs.h" +#include "librpc/gen_ndr/ndr_nbt.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 (argv[1]->type != MPR_TYPE_INT) { + ejsSetErrorMsg(eid, "resolveName invalid arguments"); + goto done; + } + make_nbt_name(&name, mprToString(argv[1]), mprToInt(argv[2])); + } + + result = 0; + + nt_status = resolve_name(&name, tmp_ctx, &reply_addr); + + if (NT_STATUS_IS_OK(nt_status)) { + mprSetPropertyValue(argv[0], "value", + mprCreateStringVar(reply_addr, 1)); + } + + ejsSetReturnValue(eid, mprNTSTATUS(nt_status)); + + done: + talloc_free(tmp_ctx); + return result; +} + +/* + setup C functions that be called from ejs +*/ +void smb_setup_ejs_nbt(void) +{ + ejsDefineCFunction(-1, "resolveName", ejs_resolve_name, NULL, MPR_VAR_SCRIPT_HANDLE); +} -- cgit From b7bc13209f5133a117428f2ce58d995399fb684b Mon Sep 17 00:00:00 2001 From: Simo Sorce Date: Sat, 4 Jun 2005 08:23:15 +0000 Subject: r7267: REMOTE_HOST is a better choice (This used to be commit 41bae267e29614d300ec2505c927ab17ccbbe64f) --- source4/scripting/ejs/smbcalls.c | 99 ++++++++++++++++++++++++++-------------- 1 file changed, 65 insertions(+), 34 deletions(-) (limited to 'source4/scripting') diff --git a/source4/scripting/ejs/smbcalls.c b/source4/scripting/ejs/smbcalls.c index 54dc8d4e62..3ca6003ee4 100644 --- a/source4/scripting/ejs/smbcalls.c +++ b/source4/scripting/ejs/smbcalls.c @@ -71,54 +71,85 @@ static int ejs_typeof(MprVarHandle eid, int argc, struct MprVar **argv) ejsSetReturnValue(eid, mprList(name, list)); } -static int ejs_userAuth(MprVarHandle eid, int argc, char **argv) +static int ejs_systemAuth(TALLOC_CTX *tmp_ctx, struct MprVar *auth, const char *username, const char *password, const char *domain, const char *remote_host) { struct auth_usersupplied_info *user_info = NULL; struct auth_serversupplied_info *server_info = NULL; struct auth_context *auth_context; - TALLOC_CTX *tmp_ctx; - struct MprVar auth; + const char *auth_unix[] = { "unix", NULL }; NTSTATUS nt_status; DATA_BLOB pw_blob; - if (argc != 3 || *argv[0] == 0 || *argv[2] == 0) { - ejsSetErrorMsg(eid, "userAuth invalid arguments"); - return -1; + nt_status = auth_context_create(tmp_ctx, auth_unix, &auth_context); + if (!NT_STATUS_IS_OK(nt_status)) { + mprSetPropertyValue(auth, "result", mprCreateBoolVar(False)); + mprSetPropertyValue(auth, "report", mprCreateStringVar("Auth System Failure", 0)); + goto done; } - tmp_ctx = talloc_new(mprMemCtx()); - auth = mprCreateObjVar("auth", MPR_DEFAULT_HASH_SIZE); + pw_blob = data_blob(password, strlen(password)), + make_user_info(tmp_ctx, username, username, + domain, domain, + remote_host, remote_host, + NULL, NULL, + NULL, NULL, + &pw_blob, False, + USER_INFO_CASE_INSENSITIVE_USERNAME | + USER_INFO_DONT_CHECK_UNIX_ACCOUNT, + &user_info); + nt_status = auth_check_password(auth_context, tmp_ctx, user_info, &server_info); + if (!NT_STATUS_IS_OK(nt_status)) { + mprSetPropertyValue(auth, "result", mprCreateBoolVar(False)); + mprSetPropertyValue(auth, "report", mprCreateStringVar("Login Failed", 0)); + goto done; + } - if (strcmp("System User", argv[2]) == 0) { - const char *auth_unix[] = { "unix", NULL }; + mprSetPropertyValue(auth, "result", mprCreateBoolVar(server_info->authenticated)); + mprSetPropertyValue(auth, "username", mprCreateStringVar(server_info->account_name, 0)); + mprSetPropertyValue(auth, "domain", mprCreateStringVar(server_info->domain_name, 0)); - nt_status = auth_context_create(tmp_ctx, auth_unix, &auth_context); - if (!NT_STATUS_IS_OK(nt_status)) { - mprSetPropertyValue(&auth, "result", mprCreateBoolVar(False)); - mprSetPropertyValue(&auth, "report", mprCreateStringVar("Auth System Failure", 0)); - goto done; - } +done: + return 0; +} - pw_blob = data_blob(argv[1], strlen(argv[1])), - make_user_info(tmp_ctx, argv[0], argv[0], - argv[2], argv[2], - "foowks", "fooip", - NULL, NULL, - NULL, NULL, - &pw_blob, False, - 0x05, &user_info); - nt_status = auth_check_password(auth_context, tmp_ctx, user_info, &server_info); - if (!NT_STATUS_IS_OK(nt_status)) { - mprSetPropertyValue(&auth, "result", mprCreateBoolVar(False)); - mprSetPropertyValue(&auth, "report", mprCreateStringVar("Login Failed", 0)); - goto done; - } +/* + perform user authentication, returning an array of results + + syntax: + var authinfo = new Object(); + authinfo.username = myname; + authinfo.password = mypass; + authinfo.domain = mydom; + authinfo.rhost = request['REMOTE_HOST']; + auth = userAuth(authinfo); +*/ +static int ejs_userAuth(MprVarHandle eid, int argc, struct MprVar **argv) +{ + TALLOC_CTX *tmp_ctx; + const char *username; + const char *password; + const char *domain; + const char *remote_host; + struct MprVar auth; + + if (argc != 1 || argv[0]->type != MPR_TYPE_OBJECT) { + ejsSetErrorMsg(eid, "userAuth invalid arguments, this function requires an object."); + return -1; + } + + username = mprToString(mprGetProperty(argv[0], "username", NULL)); + password = mprToString(mprGetProperty(argv[0], "password", NULL)); + domain = mprToString(mprGetProperty(argv[0], "domain", NULL)); + remote_host = mprToString(mprGetProperty(argv[0], "rhost", NULL)); + + tmp_ctx = talloc_new(mprMemCtx()); + auth = mprCreateObjVar("auth", MPR_DEFAULT_HASH_SIZE); - mprSetPropertyValue(&auth, "result", mprCreateBoolVar(server_info->authenticated)); - mprSetPropertyValue(&auth, "username", mprCreateStringVar(server_info->account_name, 0)); - mprSetPropertyValue(&auth, "domain", mprCreateStringVar(server_info->domain_name, 0)); + if (strcmp("System User", domain) == 0) { + ejs_systemAuth(tmp_ctx, &auth, username, password, domain, remote_host); } else { + mprSetPropertyValue(&auth, "result", mprCreateBoolVar(False)); mprSetPropertyValue(&auth, "report", mprCreateStringVar("Unknown Domain", 0)); } @@ -160,5 +191,5 @@ void smb_setup_ejs_functions(void) ejsDefineCFunction(-1, "typeof", ejs_typeof, NULL, MPR_VAR_SCRIPT_HANDLE); ejsDefineStringCFunction(-1, "getDomainList", ejs_domain_list, NULL, MPR_VAR_SCRIPT_HANDLE); - ejsDefineStringCFunction(-1, "userAuth", ejs_userAuth, NULL, MPR_VAR_SCRIPT_HANDLE); + ejsDefineCFunction(-1, "userAuth", ejs_userAuth, NULL, MPR_VAR_SCRIPT_HANDLE); } -- cgit From 791db4bf72f282840a7bfefa2a3ccf9b3191a6e6 Mon Sep 17 00:00:00 2001 From: Simo Sorce Date: Sat, 4 Jun 2005 08:54:07 +0000 Subject: r7268: allocate the strings to avoid them disappearing under our feet (This used to be commit ddd7454cb3e2445fd32682b380be89c70f8a22cb) --- source4/scripting/ejs/smbcalls.c | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) (limited to 'source4/scripting') diff --git a/source4/scripting/ejs/smbcalls.c b/source4/scripting/ejs/smbcalls.c index 3ca6003ee4..8ea5967ef4 100644 --- a/source4/scripting/ejs/smbcalls.c +++ b/source4/scripting/ejs/smbcalls.c @@ -83,7 +83,7 @@ static int ejs_systemAuth(TALLOC_CTX *tmp_ctx, struct MprVar *auth, const char * nt_status = auth_context_create(tmp_ctx, auth_unix, &auth_context); if (!NT_STATUS_IS_OK(nt_status)) { mprSetPropertyValue(auth, "result", mprCreateBoolVar(False)); - mprSetPropertyValue(auth, "report", mprCreateStringVar("Auth System Failure", 0)); + mprSetPropertyValue(auth, "report", mprCreateStringVar("Auth System Failure", 1)); goto done; } @@ -100,13 +100,13 @@ static int ejs_systemAuth(TALLOC_CTX *tmp_ctx, struct MprVar *auth, const char * nt_status = auth_check_password(auth_context, tmp_ctx, user_info, &server_info); if (!NT_STATUS_IS_OK(nt_status)) { mprSetPropertyValue(auth, "result", mprCreateBoolVar(False)); - mprSetPropertyValue(auth, "report", mprCreateStringVar("Login Failed", 0)); + mprSetPropertyValue(auth, "report", mprCreateStringVar("Login Failed", 1)); goto done; } mprSetPropertyValue(auth, "result", mprCreateBoolVar(server_info->authenticated)); - mprSetPropertyValue(auth, "username", mprCreateStringVar(server_info->account_name, 0)); - mprSetPropertyValue(auth, "domain", mprCreateStringVar(server_info->domain_name, 0)); + mprSetPropertyValue(auth, "username", mprCreateStringVar(server_info->account_name, 1)); + mprSetPropertyValue(auth, "domain", mprCreateStringVar(server_info->domain_name, 1)); done: return 0; @@ -151,7 +151,7 @@ static int ejs_userAuth(MprVarHandle eid, int argc, struct MprVar **argv) } else { mprSetPropertyValue(&auth, "result", mprCreateBoolVar(False)); - mprSetPropertyValue(&auth, "report", mprCreateStringVar("Unknown Domain", 0)); + mprSetPropertyValue(&auth, "report", mprCreateStringVar("Unknown Domain", 1)); } done: -- cgit From 8a2e208e45001305a4fa18f92c4109a33b6ed407 Mon Sep 17 00:00:00 2001 From: Tim Potter Date: Tue, 7 Jun 2005 06:38:13 +0000 Subject: r7350: Remove unused label. (This used to be commit ada004595760605134eb741da9c549521938c2ce) --- source4/scripting/ejs/smbcalls.c | 1 - 1 file changed, 1 deletion(-) (limited to 'source4/scripting') diff --git a/source4/scripting/ejs/smbcalls.c b/source4/scripting/ejs/smbcalls.c index 8ea5967ef4..00a2547bac 100644 --- a/source4/scripting/ejs/smbcalls.c +++ b/source4/scripting/ejs/smbcalls.c @@ -154,7 +154,6 @@ static int ejs_userAuth(MprVarHandle eid, int argc, struct MprVar **argv) mprSetPropertyValue(&auth, "report", mprCreateStringVar("Unknown Domain", 1)); } -done: ejsSetReturnValue(eid, auth); talloc_free(tmp_ctx); return 0; -- cgit From 6eae7eb3c446e26d8003846a79471e6232b1b92e Mon Sep 17 00:00:00 2001 From: Tim Potter Date: Tue, 7 Jun 2005 07:00:28 +0000 Subject: r7351: Start of ejs smb client library. I need to figure out a nice API here that doesn't expose too much of the cifs protocol but still allows people to do neat things. Also, talloc lifetimes need to be thought about properly. (This used to be commit 8062e808ef5102b96e1b3de046c858e4a69b4d82) --- source4/scripting/config.mk | 1 + source4/scripting/ejs/smbcalls.c | 1 + source4/scripting/ejs/smbcalls_cli.c | 89 ++++++++++++++++++++++++++++++++++++ 3 files changed, 91 insertions(+) create mode 100644 source4/scripting/ejs/smbcalls_cli.c (limited to 'source4/scripting') diff --git a/source4/scripting/config.mk b/source4/scripting/config.mk index 597fa1a84a..8d6c5058cf 100644 --- a/source4/scripting/config.mk +++ b/source4/scripting/config.mk @@ -6,6 +6,7 @@ OBJ_FILES = \ scripting/ejs/smbcalls_config.o \ scripting/ejs/smbcalls_ldb.o \ scripting/ejs/smbcalls_nbt.o \ + scripting/ejs/smbcalls_cli.o \ scripting/ejs/mprutil.o REQUIRED_SUBSYSTEMS = AUTH EJS LIBBASIC # End SUBSYSTEM SMBCALLS diff --git a/source4/scripting/ejs/smbcalls.c b/source4/scripting/ejs/smbcalls.c index 00a2547bac..46fce4b98e 100644 --- a/source4/scripting/ejs/smbcalls.c +++ b/source4/scripting/ejs/smbcalls.c @@ -187,6 +187,7 @@ void smb_setup_ejs_functions(void) smb_setup_ejs_config(); smb_setup_ejs_ldb(); smb_setup_ejs_nbt(); + smb_setup_ejs_cli(); ejsDefineCFunction(-1, "typeof", ejs_typeof, NULL, MPR_VAR_SCRIPT_HANDLE); ejsDefineStringCFunction(-1, "getDomainList", ejs_domain_list, NULL, MPR_VAR_SCRIPT_HANDLE); diff --git a/source4/scripting/ejs/smbcalls_cli.c b/source4/scripting/ejs/smbcalls_cli.c new file mode 100644 index 0000000000..adb55a0184 --- /dev/null +++ b/source4/scripting/ejs/smbcalls_cli.c @@ -0,0 +1,89 @@ +/* + 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 2 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, write to the Free Software + Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. +*/ + +#include "includes.h" +#include "lib/ejs/ejs.h" +#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, True); + + 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)) { + ejsSetReturnValue(eid, mprNTSTATUS(result)); + return 0; + } + + return 0; +} + +/* + setup C functions that be called from ejs +*/ +void smb_setup_ejs_cli(void) +{ + ejsDefineStringCFunction(-1, "connect", ejs_cli_connect, NULL, MPR_VAR_SCRIPT_HANDLE); +} -- cgit From 3feec91e6818c674a727ce67320580ca3175ae92 Mon Sep 17 00:00:00 2001 From: Andrew Tridgell Date: Tue, 7 Jun 2005 07:42:12 +0000 Subject: r7355: this should fix the link problem metze hit with smbscript (This used to be commit 067255909ed381d397dfc82e4bca219da40810d9) --- source4/scripting/config.mk | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'source4/scripting') diff --git a/source4/scripting/config.mk b/source4/scripting/config.mk index 8d6c5058cf..81b7ab68fe 100644 --- a/source4/scripting/config.mk +++ b/source4/scripting/config.mk @@ -17,7 +17,7 @@ REQUIRED_SUBSYSTEMS = AUTH EJS LIBBASIC [BINARY::smbscript] OBJ_FILES = \ scripting/ejs/smbscript.o -REQUIRED_SUBSYSTEMS = EJS LIBBASIC SMBCALLS CONFIG LIBSMB RPC +REQUIRED_SUBSYSTEMS = EJS LIBBASIC SMBCALLS CONFIG LIBSMB RPC LIBCMDLINE # End BINARY SMBSCRIPT ####################### -- cgit From 0b119901d8d948e62d46f760b2dd40ba5331afc9 Mon Sep 17 00:00:00 2001 From: Tim Potter Date: Thu, 9 Jun 2005 07:28:21 +0000 Subject: r7422: Create a ejs object to wrap a smbcli_transport pointer. (This used to be commit a55e40651d06f416871ccbe04ad3b7d25444d645) --- source4/scripting/ejs/smbcalls_cli.c | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) (limited to 'source4/scripting') diff --git a/source4/scripting/ejs/smbcalls_cli.c b/source4/scripting/ejs/smbcalls_cli.c index adb55a0184..de31d7a900 100644 --- a/source4/scripting/ejs/smbcalls_cli.c +++ b/source4/scripting/ejs/smbcalls_cli.c @@ -24,6 +24,20 @@ #include "lib/ejs/ejs.h" #include "librpc/gen_ndr/ndr_nbt.h" +static struct MprVar mprTransport(struct smbcli_transport *transport) +{ + struct MprVar res, val; + + res = mprCreateObjVar("transport", MPR_DEFAULT_HASH_SIZE); + + val = mprCreateStringVar(talloc_get_name(transport), 1); + mprCreateProperty(&res, "name", &val); + + /* TODO: Create a C pointer "value" property */ + + return res; +} + /* Connect to a server */ static int ejs_cli_connect(MprVarHandle eid, int argc, char **argv) @@ -77,6 +91,10 @@ static int ejs_cli_connect(MprVarHandle eid, int argc, char **argv) return 0; } + /* Return a socket object */ + + ejsSetReturnValue(eid, mprTransport(transport)); + return 0; } -- cgit From aa7b6b3ea57b0e36b7b43ed2f312ee724e243541 Mon Sep 17 00:00:00 2001 From: Tim Potter Date: Fri, 10 Jun 2005 08:00:02 +0000 Subject: r7457: Return an ejs C pointer object from the ejs connect() function. Add a session_setup() function that does an anonymous session setup. Will add credential passing later. (This used to be commit 832332de5db7102085e7c44d4256fb199d8123eb) --- source4/scripting/ejs/smbcalls_cli.c | 78 ++++++++++++++++++++++++++++-------- 1 file changed, 62 insertions(+), 16 deletions(-) (limited to 'source4/scripting') diff --git a/source4/scripting/ejs/smbcalls_cli.c b/source4/scripting/ejs/smbcalls_cli.c index de31d7a900..bfc71948b9 100644 --- a/source4/scripting/ejs/smbcalls_cli.c +++ b/source4/scripting/ejs/smbcalls_cli.c @@ -23,20 +23,8 @@ #include "includes.h" #include "lib/ejs/ejs.h" #include "librpc/gen_ndr/ndr_nbt.h" - -static struct MprVar mprTransport(struct smbcli_transport *transport) -{ - struct MprVar res, val; - - res = mprCreateObjVar("transport", MPR_DEFAULT_HASH_SIZE); - - val = mprCreateStringVar(talloc_get_name(transport), 1); - mprCreateProperty(&res, "name", &val); - - /* TODO: Create a C pointer "value" property */ - - return res; -} +#include "libcli/raw/libcliraw.h" +#include "libcli/composite/composite.h" /* Connect to a server */ @@ -93,7 +81,64 @@ static int ejs_cli_connect(MprVarHandle eid, int argc, char **argv) /* Return a socket object */ - ejsSetReturnValue(eid, mprTransport(transport)); + ejsSetReturnValue(eid, mprCreatePtrVar(transport, talloc_get_name(transport))); + + return 0; +} + +/* Perform a session setup: + + session_setup(conn, "DOMAIN\USERNAME%PASSWORD"); + session_setup(conn, USERNAME, PASSWORD); + session_setup(conn, DOMAIN, USERNAME, PASSWORD); + + */ + +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; + + /* Argument parsing */ + + if (argc < 1 || argc > 3) { + ejsSetErrorMsg(eid, "session_setup invalid arguments"); + return -1; + } + + if (argv[0]->type != MPR_TYPE_PTR) { + ejsSetErrorMsg(eid, "first arg is not a connect handle"); + return -1; + } + + transport = argv[0]->ptr; + + /* Do session setup */ + + session = smbcli_session_init(transport, transport, True); + if (!session) { + ejsSetErrorMsg(eid, "session init failed"); + return -1; + } + + creds = cli_credentials_init(session); + cli_credentials_set_anonymous(creds); + + 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); + + session->vuid = setup.out.vuid; + + /* Return a session object */ + + ejsSetReturnValue(eid, mprCreatePtrVar(session, talloc_get_name(session))); return 0; } @@ -103,5 +148,6 @@ static int ejs_cli_connect(MprVarHandle eid, int argc, char **argv) */ void smb_setup_ejs_cli(void) { - ejsDefineStringCFunction(-1, "connect", ejs_cli_connect, NULL, MPR_VAR_SCRIPT_HANDLE); + ejsDefineStringCFunction(-1, "connect", ejs_cli_connect, NULL, MPR_VAR_SCRIPT_HANDLE); + ejsDefineCFunction(-1, "session_setup", ejs_cli_ssetup, NULL, MPR_VAR_SCRIPT_HANDLE); } -- cgit From 6ef2a41aa1e6cfeb88ee621c63327593b51315ae Mon Sep 17 00:00:00 2001 From: Andrew Tridgell Date: Fri, 10 Jun 2005 12:43:11 +0000 Subject: r7461: this is the start of some code for mapping IDL onto ejs. This is hand written code, and it doesn't work or even compile yet. I am committing it to make it easier to discuss the approach with jelmer and tpot. The intention is that this code will eventually end up being mostly auto-generated (with the utility functions split out, just like librpc/ndr/*.c) (This used to be commit 30e876e9c2ba73a3bc26e7708110e00a8552a75e) --- source4/scripting/ejs/smbcalls_irpc.c | 197 ++++++++++++++++++++++++++++++++++ 1 file changed, 197 insertions(+) create mode 100644 source4/scripting/ejs/smbcalls_irpc.c (limited to 'source4/scripting') diff --git a/source4/scripting/ejs/smbcalls_irpc.c b/source4/scripting/ejs/smbcalls_irpc.c new file mode 100644 index 0000000000..9b0efc69e4 --- /dev/null +++ b/source4/scripting/ejs/smbcalls_irpc.c @@ -0,0 +1,197 @@ +/* + Unix SMB/CIFS implementation. + + provide hooks into IRPC 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 2 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, write to the Free Software + Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. +*/ +/* + I hope that this code will eventually be autogenerated. + + + In this code, the convention is: + + ejs_pull_*() from MprVar -> C structure + ejs_push_*() from C structure -> MprVar + + note that for ejs calls, pull only ever needs to do + NDR_IN, and push only ever needs to do NDR_OUT. This is + because ejs code is (at least for the moment) only used for + the client, not the server + + also note that we don't need the NDR_SCALARS/NDR_BUFFERS stuff, as + we aren't dealing with wire marshalling where scalars and buffers + are separated +*/ + +#include "includes.h" +#include "lib/ejs/ejs.h" +#include "librpc/gen_ndr/ndr_irpc.h" + +struct ndr_ejs { + /* nothing here yet */ + int dummy; +}; + +struct enum_table { + uint32_t evalue; + const char *name; +}; + +#define EJS_ASSERT(condition) do { \ + if (!(condition)) { \ + DEBUG(0,("ejs assert failed at %s: %s\n", __location__, #condition)); \ + return NT_STATUS_INVALID_PARAMETER; \ + } \ +} while (0) + + +/* first some common helper functions */ + +static NTSTATUS ejs_pull_enum(struct ndr_ejs *ndr, + uint32_t *evalue, + struct MprVar *v, + const struct enum_table *etable) +{ + const char *s; + int i; + EJS_ASSERT(v->type == MPR_TYPE_STRING); + s = v->string; + for (i=0;etable[i].name;i++) { + if (strcmp(s, etable[i].name) == 0) { + *evalue = etable[i].evalue; + return NT_STATUS_OK; + } + } + return NT_STATUS_INVALID_PARAMETER; +} + +static NTSTATUS ejs_push_enum(struct ndr_ejs *ndr, + uint32_t evalue, + struct MprVar *v, + const struct enum_table *etable) +{ + int i; + for (i=0;etable[i].name;i++) { + if (evalue == etable[i].evalue) { + *v = mprCreateStringVar(etable[i].name, 0); + return NT_STATUS_OK; + } + } + return NT_STATUS_INVALID_PARAMETER; +} + +static NTSTATUS ejs_push_hyper(struct ndr_ejs *ndr, + uint64_t evalue, + struct MprVar *v, + const char *name) +{ +} + + +NTSTATUS ejs_element(struct ndr_ejs *ndr, + struct MprVar *v, + const char *name, + struct MprVar **e) +{ + *e = mprGetProperty(v, name, NULL); + if (*e == NULL) { + return NT_STATUS_INVALID_PARAMETER; + } + return NT_STATUS_OK; +} + + +/* when we auto-generate, the enum tables should also be used by + the ndr_print_*() functions for non-ejs handling of enums +*/ +static const struct enum_table enum_table_nbdt_info_level[] = { + {NBTD_INFO_STATISTICS, "NBTD_INFO_STATISTICS"}, + {-1, NULL} +}; + + + +/* pull-side functions for nbtd_information call */ + +static NTSTATUS ejs_pull_nbtd_info_level(struct ndr_ejs *ndr, + enum nbtd_info_level *r, + struct MprVar *v) +{ + uint32_t e; + NDR_CHECK(ejs_pull_enum(ndr, &e, v, enum_table_nbdt_info_level)); + *r = e; + return NT_STATUS_OK; +} + +static NTSTATUS ejs_pull_nbtd_information(struct ndr_ejs *ndr, + struct nbtd_information *r, + struct MprVar *v) +{ + struct MprVar *e; + NDR_CHECK(ejs_element(ndr, v, "level", &e)); + NDR_CHECK(ejs_pull_nbtd_info_level(ndr, &r->in.level, e)); + return NT_STATUS_OK; +} + + +/* push side functions for nbtd_information */ + +static NTSTATUS ejs_push_nbtd_info_level(struct ndr_ejs *ndr, enum nbtd_info_level r, + struct MprVar *v) +{ + NDR_CHECK(ejs_push_enum(ndr, r, v, enum_table_nbdt_info_level)); + return NT_STATUS_OK; +} + +static NTSTATUS ejs_push_nbtd_statistics(struct ndr_ejs *ndr, struct nbtd_statistics *r, + struct MprVar *v) +{ + NDR_CHECK(ejs_push_hyper(ndr, r->total_received, v, "total_received")); + NDR_CHECK(ejs_push_hyper(ndr, r->total_sent, v, "total_sent")); + NDR_CHECK(ejs_push_hyper(ndr, r->query_count, v, "query_count")); + NDR_CHECK(ejs_push_hyper(ndr, r->register_count, v, "register_count")); + NDR_CHECK(ejs_push_hyper(ndr, r->release_count, v, "release_count")); + NDR_CHECK(ejs_push_hyper(ndr, r->refresh_count, v, "refresh_count")); + return NT_STATUS_OK; +} + +static NTSTATUS ejs_push_nbtd_info(struct ndr_ejs *ndr, union nbtd_info *r, + struct MprVar *v) +{ + int level; + level = ejs_push_get_switch_value(ndr, r); + switch (level) { + case NBTD_INFO_STATISTICS: + NDR_CHECK(ejs_push_object(ndr, r->stats, + (ejs_push_fn_t)ejs_push_nbtd_statistics, + v, "stats")); + break; + default: + return ejs_push_error(ndr, NDR_ERR_BAD_SWITCH, "Bad switch value %u", level); + } + return NT_STATUS_OK; +} + +static NTSTATUS ndr_push_nbtd_information(struct ndr_push *ndr, + struct nbtd_information *r, struct MprVar *v) +{ + NDR_CHECK(ejs_push_set_switch_value(ndr, &r->out.info, r->in.level)); + NDR_CHECK(ejs_push_object(ndr, &r->out.info, + (ejs_push_fn_t)ejs_push_nbtd_info, v, "info")); + return NT_STATUS_OK; +} -- cgit From 16a5d7c1755ece7f93db0eba42844152c916c11d Mon Sep 17 00:00:00 2001 From: Tim Potter Date: Sat, 11 Jun 2005 02:39:14 +0000 Subject: r7477: Add MPR_TYPE_PTR to ejs_typeof(). (This used to be commit 8574f64ca2bda864f472067ae594285b6f5dc957) --- source4/scripting/ejs/smbcalls.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) (limited to 'source4/scripting') diff --git a/source4/scripting/ejs/smbcalls.c b/source4/scripting/ejs/smbcalls.c index 46fce4b98e..1b5737db29 100644 --- a/source4/scripting/ejs/smbcalls.c +++ b/source4/scripting/ejs/smbcalls.c @@ -44,7 +44,8 @@ static int ejs_typeof(MprVarHandle eid, int argc, struct MprVar **argv) { MPR_TYPE_OBJECT, "object" }, { MPR_TYPE_FUNCTION, "function" }, { MPR_TYPE_STRING, "string" }, - { MPR_TYPE_STRING_CFUNCTION, "function" } + { MPR_TYPE_STRING_CFUNCTION, "function" }, + { MPR_TYPE_PTR, "C pointer" } }; int i; const char *type = NULL; -- cgit From 9e555f75e2b4982804f8effb4f2b4da689d714e8 Mon Sep 17 00:00:00 2001 From: Tim Potter Date: Sun, 12 Jun 2005 06:37:25 +0000 Subject: r7500: Initialise module subsystems. (This used to be commit 564dfe14d00e80a0d373ab0fc17803ffaac0892e) --- source4/scripting/ejs/smbscript.c | 2 ++ 1 file changed, 2 insertions(+) (limited to 'source4/scripting') diff --git a/source4/scripting/ejs/smbscript.c b/source4/scripting/ejs/smbscript.c index 02a3aff28e..68d94f6d2a 100644 --- a/source4/scripting/ejs/smbscript.c +++ b/source4/scripting/ejs/smbscript.c @@ -57,6 +57,8 @@ void ejs_exception(const char *reason) load_interfaces(); + smbscript_init_subsystems; + mprSetCtx(mem_ctx); if (ejsOpen(NULL, NULL, NULL) != 0) { -- cgit From ae23fe35e28c38c3ce1c523c49ea03a4045c2ca2 Mon Sep 17 00:00:00 2001 From: Tim Potter Date: Sun, 12 Jun 2005 06:40:17 +0000 Subject: r7501: Fix credential initialisation in ejs session setup. Implement four arg and anonymous version of command. Implement ejs tconx. (This used to be commit 3b7df1037de813d93b284d3b4438b083e668e29f) --- source4/scripting/ejs/smbcalls_cli.c | 134 +++++++++++++++++++++++++++++++++-- 1 file changed, 127 insertions(+), 7 deletions(-) (limited to 'source4/scripting') diff --git a/source4/scripting/ejs/smbcalls_cli.c b/source4/scripting/ejs/smbcalls_cli.c index bfc71948b9..02459abd4b 100644 --- a/source4/scripting/ejs/smbcalls_cli.c +++ b/source4/scripting/ejs/smbcalls_cli.c @@ -81,7 +81,8 @@ static int ejs_cli_connect(MprVarHandle eid, int argc, char **argv) /* Return a socket object */ - ejsSetReturnValue(eid, mprCreatePtrVar(transport, talloc_get_name(transport))); + ejsSetReturnValue(eid, mprCreatePtrVar(transport, + talloc_get_name(transport))); return 0; } @@ -91,6 +92,7 @@ static int ejs_cli_connect(MprVarHandle eid, int argc, char **argv) session_setup(conn, "DOMAIN\USERNAME%PASSWORD"); session_setup(conn, USERNAME, PASSWORD); session_setup(conn, DOMAIN, USERNAME, PASSWORD); + session_setup(conn); // anonymous */ @@ -101,32 +103,68 @@ static int ejs_cli_ssetup(MprVarHandle eid, int argc, MprVar **argv) struct smb_composite_sesssetup setup; struct cli_credentials *creds; NTSTATUS status; + int result = -1; /* Argument parsing */ - if (argc < 1 || argc > 3) { + if (argc < 1 || argc > 4) { ejsSetErrorMsg(eid, "session_setup invalid arguments"); return -1; } - if (argv[0]->type != MPR_TYPE_PTR) { + 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 { + + /* Anonymous connection */ + + cli_credentials_set_anonymous(creds); + } /* Do session setup */ session = smbcli_session_init(transport, transport, True); + if (!session) { ejsSetErrorMsg(eid, "session init failed"); return -1; } - creds = cli_credentials_init(session); - cli_credentials_set_anonymous(creds); - setup.in.sesskey = transport->negotiate.sesskey; setup.in.capabilities = transport->negotiate.capabilities; setup.in.credentials = creds; @@ -134,11 +172,92 @@ static int ejs_cli_ssetup(MprVarHandle eid, int argc, MprVar **argv) 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 */ - ejsSetReturnValue(eid, mprCreatePtrVar(session, talloc_get_name(session))); + ejsSetReturnValue(eid, mprCreatePtrVar(session, + talloc_get_name(session))); + + result = 0; + + done: + talloc_free(creds); + return result; +} + +/* Perform a tree connect + + session_setup(session, SHARE); + + */ + +static int ejs_cli_tcon(MprVarHandle eid, int argc, MprVar **argv) +{ + struct smbcli_session *session; + struct smbcli_tree *tree; + union smb_tcon tcon; + TALLOC_CTX *mem_ctx; + NTSTATUS status; + 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, True); + + 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); + + tree->tid = tcon.tconx.out.tid; + + talloc_free(mem_ctx); return 0; } @@ -150,4 +269,5 @@ void smb_setup_ejs_cli(void) { 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_tcon, NULL, MPR_VAR_SCRIPT_HANDLE); } -- cgit From fb3874bfacb7fb7199e415f8ad16598790ec9c36 Mon Sep 17 00:00:00 2001 From: Tim Potter Date: Sun, 12 Jun 2005 07:03:32 +0000 Subject: r7505: Add more argument forms for session_setup(). Throw an exception if tree connect fails. (This used to be commit 5b67f2c3d91487fec38b300b4f71792cd9164a78) --- source4/scripting/ejs/smbcalls_cli.c | 35 ++++++++++++++++++++++++++++++++++- 1 file changed, 34 insertions(+), 1 deletion(-) (limited to 'source4/scripting') diff --git a/source4/scripting/ejs/smbcalls_cli.c b/source4/scripting/ejs/smbcalls_cli.c index 02459abd4b..b32917515d 100644 --- a/source4/scripting/ejs/smbcalls_cli.c +++ b/source4/scripting/ejs/smbcalls_cli.c @@ -89,7 +89,7 @@ static int ejs_cli_connect(MprVarHandle eid, int argc, char **argv) /* Perform a session setup: - session_setup(conn, "DOMAIN\USERNAME%PASSWORD"); + session_setup(conn, "DOMAIN\\USERNAME%PASSWORD"); session_setup(conn, USERNAME, PASSWORD); session_setup(conn, DOMAIN, USERNAME, PASSWORD); session_setup(conn); // anonymous @@ -149,6 +149,34 @@ static int ejs_cli_ssetup(MprVarHandle eid, int argc, MprVar **argv) 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 */ @@ -255,6 +283,11 @@ static int ejs_cli_tcon(MprVarHandle eid, int argc, MprVar **argv) status = smb_tree_connect(tree, mem_ctx, &tcon); + if (!NT_STATUS_IS_OK(status)) { + ejsSetErrorMsg(eid, "session setup: %s", nt_errstr(status)); + return -1; + } + tree->tid = tcon.tconx.out.tid; talloc_free(mem_ctx); -- cgit From 00e2b7c1b49b128488cf977b40b086b935fb605a Mon Sep 17 00:00:00 2001 From: Andrew Bartlett Date: Mon, 13 Jun 2005 10:01:11 +0000 Subject: r7530: Simply calling convention of lp_load(). This always loads all the services, as we now don't have an easy way to split out smbd. Andrew Bartlett (This used to be commit 990e061939c76b559c4f5914c5fc6ca1b13e19dd) --- source4/scripting/ejs/smbscript.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'source4/scripting') diff --git a/source4/scripting/ejs/smbscript.c b/source4/scripting/ejs/smbscript.c index 68d94f6d2a..2795e4f127 100644 --- a/source4/scripting/ejs/smbscript.c +++ b/source4/scripting/ejs/smbscript.c @@ -49,7 +49,7 @@ void ejs_exception(const char *reason) setup_logging(argv[0],DEBUG_STDOUT); - if (!lp_load(dyn_CONFIGFILE, False, False, False)) { + if (!lp_load(dyn_CONFIGFILE)) { fprintf(stderr, "%s: Can't load %s - run testparm to debug it\n", argv[0], dyn_CONFIGFILE); exit(127); -- cgit From 487d1afe3021844f96ed19861a03ea1958676f67 Mon Sep 17 00:00:00 2001 From: Tim Potter Date: Tue, 14 Jun 2005 07:14:59 +0000 Subject: r7570: Add tree, session and socket disconnect ejs functions. (This used to be commit 63577628b0ee7e6b33053484190189e99cb56a5b) --- source4/scripting/ejs/smbcalls_cli.c | 122 ++++++++++++++++++++++++++++++++--- 1 file changed, 114 insertions(+), 8 deletions(-) (limited to 'source4/scripting') diff --git a/source4/scripting/ejs/smbcalls_cli.c b/source4/scripting/ejs/smbcalls_cli.c index b32917515d..fa147ca299 100644 --- a/source4/scripting/ejs/smbcalls_cli.c +++ b/source4/scripting/ejs/smbcalls_cli.c @@ -54,7 +54,7 @@ static int ejs_cli_connect(MprVarHandle eid, int argc, char **argv) return -1; } - transport = smbcli_transport_init(sock, sock, True); + transport = smbcli_transport_init(sock, sock, False); if (!transport) { ejsSetErrorMsg(eid, "transport init failed"); @@ -186,7 +186,7 @@ static int ejs_cli_ssetup(MprVarHandle eid, int argc, MprVar **argv) /* Do session setup */ - session = smbcli_session_init(transport, transport, True); + session = smbcli_session_init(transport, transport, False); if (!session) { ejsSetErrorMsg(eid, "session init failed"); @@ -201,7 +201,7 @@ static int ejs_cli_ssetup(MprVarHandle eid, int argc, MprVar **argv) status = smb_composite_sesssetup(session, &setup); if (!NT_STATUS_IS_OK(status)) { - ejsSetErrorMsg(eid, "session setup: %s", nt_errstr(status)); + ejsSetErrorMsg(eid, "session_setup: %s", nt_errstr(status)); return -1; } @@ -221,11 +221,11 @@ static int ejs_cli_ssetup(MprVarHandle eid, int argc, MprVar **argv) /* Perform a tree connect - session_setup(session, SHARE); + tree_connect(session, SHARE); */ -static int ejs_cli_tcon(MprVarHandle eid, int argc, MprVar **argv) +static int ejs_cli_tree_connect(MprVarHandle eid, int argc, MprVar **argv) { struct smbcli_session *session; struct smbcli_tree *tree; @@ -247,7 +247,7 @@ static int ejs_cli_tcon(MprVarHandle eid, int argc, MprVar **argv) } session = argv[0]->ptr; - tree = smbcli_tree_init(session, session, True); + tree = smbcli_tree_init(session, session, False); if (!tree) { ejsSetErrorMsg(eid, "tree init failed"); @@ -284,7 +284,7 @@ static int ejs_cli_tcon(MprVarHandle eid, int argc, MprVar **argv) status = smb_tree_connect(tree, mem_ctx, &tcon); if (!NT_STATUS_IS_OK(status)) { - ejsSetErrorMsg(eid, "session setup: %s", nt_errstr(status)); + ejsSetErrorMsg(eid, "tree_connect: %s", nt_errstr(status)); return -1; } @@ -292,6 +292,109 @@ static int ejs_cli_tcon(MprVarHandle eid, int argc, MprVar **argv) talloc_free(mem_ctx); + ejsSetReturnValue(eid, mprCreatePtrVar(tree, + talloc_get_name(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; } @@ -302,5 +405,8 @@ void smb_setup_ejs_cli(void) { 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_tcon, 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); } -- cgit From af237084ecd4f9928c6c282b9c5c73598d5c73d6 Mon Sep 17 00:00:00 2001 From: Andrew Tridgell Date: Thu, 16 Jun 2005 11:36:09 +0000 Subject: r7633: this patch started as an attempt to make the dcerpc code use a given event_context for the socket_connect() call, so that when things that use dcerpc are running alongside anything else it doesn't block the whole process during a connect. Then of course I needed to change any code that created a dcerpc connection (such as the auth code) to also take an event context, and anything that called that and so on .... thus the size of the patch. There were 3 places where I punted: - abartlet wanted me to add a gensec_set_event_context() call instead of adding it to the gensec init calls. Andrew, my apologies for not doing this. I didn't do it as adding a new parameter allowed me to catch all the callers with the compiler. Now that its done, we could go back and use gensec_set_event_context() - the ejs code calls auth initialisation, which means it should pass in the event context from the web server. I punted on that. Needs fixing. - I used a NULL event context in dcom_get_pipe(). This is equivalent to what we did already, but should be fixed to use a callers event context. Jelmer, can you think of a clean way to do that? I also cleaned up a couple of things: - libnet_context_destroy() makes no sense. I removed it. - removed some unused vars in various places (This used to be commit 3a3025485bdb8f600ab528c0b4b4eef0c65e3fc9) --- source4/scripting/ejs/smbcalls.c | 5 ++++- source4/scripting/ejs/smbcalls_cli.c | 2 +- 2 files changed, 5 insertions(+), 2 deletions(-) (limited to 'source4/scripting') diff --git a/source4/scripting/ejs/smbcalls.c b/source4/scripting/ejs/smbcalls.c index 1b5737db29..6444ec63cc 100644 --- a/source4/scripting/ejs/smbcalls.c +++ b/source4/scripting/ejs/smbcalls.c @@ -81,7 +81,10 @@ static int ejs_systemAuth(TALLOC_CTX *tmp_ctx, struct MprVar *auth, const char * NTSTATUS nt_status; DATA_BLOB pw_blob; - nt_status = auth_context_create(tmp_ctx, auth_unix, &auth_context); + /* + darn, we need some way to get the right event_context here + */ + nt_status = auth_context_create(tmp_ctx, auth_unix, &auth_context, NULL); if (!NT_STATUS_IS_OK(nt_status)) { mprSetPropertyValue(auth, "result", mprCreateBoolVar(False)); mprSetPropertyValue(auth, "report", mprCreateStringVar("Auth System Failure", 1)); diff --git a/source4/scripting/ejs/smbcalls_cli.c b/source4/scripting/ejs/smbcalls_cli.c index fa147ca299..f144fd61e5 100644 --- a/source4/scripting/ejs/smbcalls_cli.c +++ b/source4/scripting/ejs/smbcalls_cli.c @@ -232,7 +232,7 @@ static int ejs_cli_tree_connect(MprVarHandle eid, int argc, MprVar **argv) union smb_tcon tcon; TALLOC_CTX *mem_ctx; NTSTATUS status; - char *password = ""; + const char *password = ""; /* Argument parsing */ -- cgit From 864de2a4ab9ed2cf2f8850516a021973941af87a Mon Sep 17 00:00:00 2001 From: Tim Potter Date: Sun, 26 Jun 2005 05:18:50 +0000 Subject: r7922: Comment out complicated connect/session/tree API for the moment. Replace with tree_connect() and tree_disconnect() functions. (This used to be commit 9ed763f7fa9e6138d8c1da29c1e0adf2e18cb5e1) --- source4/scripting/ejs/smbcalls_cli.c | 85 +++++++++++++++++++++++++++++++++++- 1 file changed, 83 insertions(+), 2 deletions(-) (limited to 'source4/scripting') diff --git a/source4/scripting/ejs/smbcalls_cli.c b/source4/scripting/ejs/smbcalls_cli.c index f144fd61e5..7a693fc180 100644 --- a/source4/scripting/ejs/smbcalls_cli.c +++ b/source4/scripting/ejs/smbcalls_cli.c @@ -22,10 +22,13 @@ #include "includes.h" #include "lib/ejs/ejs.h" -#include "librpc/gen_ndr/ndr_nbt.h" #include "libcli/raw/libcliraw.h" #include "libcli/composite/composite.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) @@ -398,15 +401,93 @@ static int ejs_cli_disconnect(MprVarHandle eid, int argc, MprVar **argv) 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 smbcli_tree *tree; + const 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_init(NULL); + smbcli_parse_unc(argv[0], mem_ctx, &hostname, &sharename); + + /* Set up credentials */ + + creds = cli_credentials_init(NULL); + cli_credentials_set_conf(creds); + cli_credentials_parse_string(creds, argv[1], CRED_SPECIFIED); + + /* Do connect */ + + result = smbcli_tree_full_connection(NULL, &tree, hostname, 0, + sharename, "?????", creds, NULL); + + talloc_free(mem_ctx); + + if (!NT_STATUS_IS_OK(result)) { + ejsSetReturnValue(eid, mprNTSTATUS(result)); + return 0; + } + + ejsSetReturnValue(eid, mprCreatePtrVar(tree, talloc_get_name(tree))); + + return 0; +} + +/* 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 (!mprVarIsPtr(argv[0]->type) || + !talloc_check_name(argv[0]->ptr, "struct smbcli_tree")) { + ejsSetErrorMsg(eid, "first arg is not a tree handle"); + return -1; + } + + tree = talloc_check_name(argv[0]->ptr, "struct smbcli_tree"); + + result = smb_tree_disconnect(tree); + + ejsSetReturnValue(eid, mprNTSTATUS(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); + +#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); + ejsDefineCFunction(-1, "disconnect", ejs_cli_disconnect, NULL, MPR_VAR_SCRIPT_HANDLE); +#endif } -- cgit From ae73a40ad4c09a93abe00ee99ea868b0196d3449 Mon Sep 17 00:00:00 2001 From: Tim Potter Date: Sun, 26 Jun 2005 05:43:16 +0000 Subject: r7924: Add mkdir() and rmdir() functions. Write a macro to check tree handle parameters. (This used to be commit 043feb131f1877886a9ab7e25ada5e54692f6487) --- source4/scripting/ejs/smbcalls_cli.c | 83 +++++++++++++++++++++++++++++++++++- 1 file changed, 81 insertions(+), 2 deletions(-) (limited to 'source4/scripting') diff --git a/source4/scripting/ejs/smbcalls_cli.c b/source4/scripting/ejs/smbcalls_cli.c index 7a693fc180..46813f8f23 100644 --- a/source4/scripting/ejs/smbcalls_cli.c +++ b/source4/scripting/ejs/smbcalls_cli.c @@ -449,6 +449,9 @@ static int ejs_tree_connect(MprVarHandle eid, int argc, char **argv) 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); @@ -459,8 +462,13 @@ static int ejs_tree_disconnect(MprVarHandle eid, int argc, MprVar **argv) struct smbcli_tree *tree; NTSTATUS result; - if (!mprVarIsPtr(argv[0]->type) || - !talloc_check_name(argv[0]->ptr, "struct smbcli_tree")) { + 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; } @@ -474,6 +482,74 @@ static int ejs_tree_disconnect(MprVarHandle eid, int argc, MprVar **argv) return 0; } +/* Perform a tree connect: + + 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 = 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); + + ejsSetReturnValue(eid, mprNTSTATUS(result)); + + return 0; +} + +/* Perform a tree connect: + + 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 = 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); + + ejsSetReturnValue(eid, mprNTSTATUS(result)); + + return 0; +} + /* setup C functions that be called from ejs */ @@ -482,6 +558,9 @@ 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); + #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); -- cgit From c36e1ae46c266c9a6f012e5715a8df69faad04cd Mon Sep 17 00:00:00 2001 From: Tim Potter Date: Sun, 26 Jun 2005 07:34:55 +0000 Subject: r7928: Add rename, unlink and list commands. list() returns a list of strings, but maybe it should be a list of objects with size, attrib, short name etc. (This used to be commit 696aa182d5a159c26b80829e1eae9a9894cb7986) --- source4/scripting/ejs/smbcalls_cli.c | 141 ++++++++++++++++++++++++++++++++++- 1 file changed, 139 insertions(+), 2 deletions(-) (limited to 'source4/scripting') diff --git a/source4/scripting/ejs/smbcalls_cli.c b/source4/scripting/ejs/smbcalls_cli.c index 46813f8f23..ca8fbd3ea2 100644 --- a/source4/scripting/ejs/smbcalls_cli.c +++ b/source4/scripting/ejs/smbcalls_cli.c @@ -24,6 +24,7 @@ #include "lib/ejs/ejs.h" #include "libcli/raw/libcliraw.h" #include "libcli/composite/composite.h" +#include "clilist.h" #if 0 @@ -482,7 +483,7 @@ static int ejs_tree_disconnect(MprVarHandle eid, int argc, MprVar **argv) return 0; } -/* Perform a tree connect: +/* Create a directory: result = mkdir(tree_handle, DIRNAME); */ @@ -516,7 +517,7 @@ static int ejs_mkdir(MprVarHandle eid, int argc, MprVar **argv) return 0; } -/* Perform a tree connect: +/* Remove a directory: result = rmdir(tree_handle, DIRNAME); */ @@ -550,6 +551,138 @@ static int ejs_rmdir(MprVarHandle eid, int argc, MprVar **argv) 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 = 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); + + ejsSetReturnValue(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 = 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); + + ejsSetReturnValue(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, value; + char idx[16]; + + mprItoa(result->properties->numDataItems, idx, sizeof(idx)); + value = mprCreateStringVar(info->name, 1); + mprCreateProperty(result, idx, &value); +} + +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 = 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 = mprCreateObjVar("list", MPR_DEFAULT_HASH_SIZE); + + smbcli_list(tree, mask, attribute, ejs_list_helper, &result); + + ejsSetReturnValue(eid, result); + + return 0; +} + /* setup C functions that be called from ejs */ @@ -560,6 +693,10 @@ void smb_setup_ejs_cli(void) 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); -- cgit From 643e5d8239ba105a5ac99ecc513289a17402714b Mon Sep 17 00:00:00 2001 From: Andrew Tridgell Date: Sat, 2 Jul 2005 05:21:17 +0000 Subject: r8069: the beginnings of code to allow rpc calls to be made from ejs tpot, note that this shows how you can modify passed in MprVar variables in C call (This used to be commit a782541db3de6ca3b599a220265cf9e6cb0c4d7b) --- source4/scripting/config.mk | 24 -------- source4/scripting/ejs/config.mk | 23 +++++++ source4/scripting/ejs/mprutil.c | 26 ++++++++ source4/scripting/ejs/smbcalls.c | 1 + source4/scripting/ejs/smbcalls_rpc.c | 116 +++++++++++++++++++++++++++++++++++ source4/scripting/ejs/smbscript.c | 43 ++++++++----- 6 files changed, 194 insertions(+), 39 deletions(-) create mode 100644 source4/scripting/ejs/config.mk create mode 100644 source4/scripting/ejs/smbcalls_rpc.c (limited to 'source4/scripting') diff --git a/source4/scripting/config.mk b/source4/scripting/config.mk index 81b7ab68fe..779aef0b45 100644 --- a/source4/scripting/config.mk +++ b/source4/scripting/config.mk @@ -1,27 +1,3 @@ -####################### -# Start LIBRARY SMBCALLS -[SUBSYSTEM::SMBCALLS] -OBJ_FILES = \ - scripting/ejs/smbcalls.o \ - scripting/ejs/smbcalls_config.o \ - scripting/ejs/smbcalls_ldb.o \ - scripting/ejs/smbcalls_nbt.o \ - scripting/ejs/smbcalls_cli.o \ - scripting/ejs/mprutil.o -REQUIRED_SUBSYSTEMS = AUTH EJS LIBBASIC -# End SUBSYSTEM SMBCALLS -####################### - -####################### -# Start BINARY SMBSCRIPT -[BINARY::smbscript] -OBJ_FILES = \ - scripting/ejs/smbscript.o -REQUIRED_SUBSYSTEMS = EJS LIBBASIC SMBCALLS CONFIG LIBSMB RPC LIBCMDLINE - -# End BINARY SMBSCRIPT -####################### - ####################### # Start LIBRARY swig_tdb [LIBRARY::swig_tdb] diff --git a/source4/scripting/ejs/config.mk b/source4/scripting/ejs/config.mk new file mode 100644 index 0000000000..d5003d07e7 --- /dev/null +++ b/source4/scripting/ejs/config.mk @@ -0,0 +1,23 @@ +####################### +# Start LIBRARY SMBCALLS +[SUBSYSTEM::SMBCALLS] +OBJ_FILES = \ + scripting/ejs/smbcalls.o \ + scripting/ejs/smbcalls_config.o \ + scripting/ejs/smbcalls_ldb.o \ + scripting/ejs/smbcalls_nbt.o \ + scripting/ejs/smbcalls_cli.o \ + scripting/ejs/smbcalls_rpc.o \ + scripting/ejs/mprutil.o +REQUIRED_SUBSYSTEMS = AUTH EJS LIBBASIC RPC_NDR_ECHO +# End SUBSYSTEM SMBCALLS +####################### + +####################### +# Start BINARY SMBSCRIPT +[BINARY::smbscript] +OBJ_FILES = \ + scripting/ejs/smbscript.o +REQUIRED_SUBSYSTEMS = EJS LIBBASIC SMBCALLS CONFIG LIBSMB RPC LIBCMDLINE +# End BINARY SMBSCRIPT +####################### diff --git a/source4/scripting/ejs/mprutil.c b/source4/scripting/ejs/mprutil.c index 2a1036d9a4..cd5ec3b5cd 100644 --- a/source4/scripting/ejs/mprutil.c +++ b/source4/scripting/ejs/mprutil.c @@ -213,3 +213,29 @@ struct MprVar mprWERROR(WERROR status) return res; } + + +/* + set a pointer in a existing MprVar +*/ +void mprSetPtr(struct MprVar *v, const char *propname, void *p) +{ + struct MprVar val = mprCreatePtrVar(p, talloc_get_name(p)); + mprCreateProperty(v, propname, &val); +} + +/* + get a pointer from a MprVar +*/ +void *mprGetPtr(struct MprVar *v, const char *propname) +{ + struct MprVar *val; + val = mprGetProperty(v, propname, NULL); + if (val == NULL) { + return NULL; + } + if (val->type != MPR_TYPE_PTR) { + return NULL; + } + return val->ptr; +} diff --git a/source4/scripting/ejs/smbcalls.c b/source4/scripting/ejs/smbcalls.c index 6444ec63cc..041bd59f1a 100644 --- a/source4/scripting/ejs/smbcalls.c +++ b/source4/scripting/ejs/smbcalls.c @@ -192,6 +192,7 @@ void smb_setup_ejs_functions(void) smb_setup_ejs_ldb(); smb_setup_ejs_nbt(); smb_setup_ejs_cli(); + smb_setup_ejs_rpc(); ejsDefineCFunction(-1, "typeof", ejs_typeof, NULL, MPR_VAR_SCRIPT_HANDLE); ejsDefineStringCFunction(-1, "getDomainList", ejs_domain_list, NULL, MPR_VAR_SCRIPT_HANDLE); diff --git a/source4/scripting/ejs/smbcalls_rpc.c b/source4/scripting/ejs/smbcalls_rpc.c new file mode 100644 index 0000000000..22aa2b59f8 --- /dev/null +++ b/source4/scripting/ejs/smbcalls_rpc.c @@ -0,0 +1,116 @@ +/* + 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 2 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, write to the Free Software + Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. +*/ + +#include "includes.h" +#include "lib/ejs/ejs.h" +#include "librpc/gen_ndr/ndr_echo.h" +#include "lib/cmdline/popt_common.h" + +/* + connect to an rpc server + example: + var conn = new Object(); + status = rpc_connect(conn, "ncacn_ip_tcp:localhost", "rpcecho"); +*/ +static int ejs_rpc_connect(MprVarHandle eid, int argc, struct MprVar **argv) +{ + const char *binding, *pipe_name; + const struct dcerpc_interface_table *iface; + NTSTATUS status; + struct dcerpc_pipe *p; + struct MprVar *conn; + + /* validate arguments */ + if (argc != 3 || + argv[0]->type != MPR_TYPE_OBJECT || + argv[1]->type != MPR_TYPE_STRING || + argv[2]->type != MPR_TYPE_STRING) { + ejsSetErrorMsg(eid, "rpc_connect invalid arguments"); + return -1; + } + + conn = argv[0]; + binding = mprToString(argv[1]); + pipe_name = mprToString(argv[2]); + + iface = idl_iface_by_name(pipe_name); + if (iface == NULL) { + status = NT_STATUS_OBJECT_NAME_INVALID; + goto done; + } + + status = dcerpc_pipe_connect(mprMemCtx(), &p, binding, + iface->uuid, iface->if_version, + cmdline_credentials, NULL); + if (NT_STATUS_IS_OK(status)) { + mprSetPtr(conn, "pipe", p); + } + +done: + ejsSetReturnValue(eid, mprNTSTATUS(status)); + return 0; +} + + +/* + make an rpc call + example: + status = rpc_call(conn, "echo_AddOne", io); +*/ +static int ejs_rpc_call(MprVarHandle eid, int argc, struct MprVar **argv) +{ + struct dcerpc_pipe *p; + struct MprVar *conn, *io; + const char *call; + NTSTATUS status; + + if (argc != 3 || + argv[0]->type != MPR_TYPE_OBJECT || + argv[1]->type != MPR_TYPE_STRING || + argv[2]->type != MPR_TYPE_OBJECT) { + ejsSetErrorMsg(eid, "rpc_call invalid arguments"); + return -1; + } + + conn = argv[0]; + call = mprToString(argv[1]); + io = argv[2]; + + p = mprGetPtr(conn, "pipe"); + if (p == NULL) { + ejsSetErrorMsg(eid, "rpc_call invalid pipe"); + return -1; + } + + status = NT_STATUS_NOT_IMPLEMENTED; + ejsSetReturnValue(eid, mprNTSTATUS(status)); + return 0; +} + +/* + setup C functions that be called from ejs +*/ +void smb_setup_ejs_rpc(void) +{ + ejsDefineCFunction(-1, "rpc_connect", ejs_rpc_connect, NULL, MPR_VAR_SCRIPT_HANDLE); + ejsDefineCFunction(-1, "rpc_call", ejs_rpc_call, NULL, MPR_VAR_SCRIPT_HANDLE); +} diff --git a/source4/scripting/ejs/smbscript.c b/source4/scripting/ejs/smbscript.c index 2795e4f127..aa0fc42c48 100644 --- a/source4/scripting/ejs/smbscript.c +++ b/source4/scripting/ejs/smbscript.c @@ -4,6 +4,7 @@ Standalone client for ejs scripting. Copyright (C) Tim Potter 2005 + 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 @@ -21,6 +22,7 @@ */ #include "includes.h" +#include "lib/cmdline/popt_common.h" #include "dynconfig.h" #include "lib/ejs/ejs.h" @@ -30,7 +32,7 @@ void ejs_exception(const char *reason) exit(127); } - int main(int argc, const char *argv[]) + int main(int argc, const char **argv) { EjsId eid; EjsHandle handle = 0; @@ -39,28 +41,39 @@ void ejs_exception(const char *reason) size_t script_size; TALLOC_CTX *mem_ctx = talloc_new(NULL); const char **argv_list = NULL; + const char *fname; struct MprVar v, *return_var; int exit_status, i; + poptContext pc; + int opt; + struct poptOption long_options[] = { + POPT_AUTOHELP + POPT_COMMON_SAMBA + POPT_COMMON_CREDENTIALS + POPT_COMMON_VERSION + POPT_TABLEEND + }; - if (argc < 2) { - fprintf(stderr, "Usage: %s \n", argv[0]); - exit(127); - } + popt_common_dont_ask(); - setup_logging(argv[0],DEBUG_STDOUT); + pc = poptGetContext("smbscript", argc, argv, long_options, 0); - if (!lp_load(dyn_CONFIGFILE)) { - fprintf(stderr, "%s: Can't load %s - run testparm to debug it\n", - argv[0], dyn_CONFIGFILE); - exit(127); - } + poptSetOtherOptionHelp(pc, "