From a5f4ffe04205819dd65807bde30a5ce0056f1417 Mon Sep 17 00:00:00 2001 From: Andrew Tridgell Date: Sat, 30 Aug 2008 07:23:06 +1000 Subject: added a simple script for setting password expiry (This used to be commit cf37126ac7b833a3a739b151157c296afc0c979c) --- source4/setup/setexpiry | 44 ++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 44 insertions(+) create mode 100755 source4/setup/setexpiry diff --git a/source4/setup/setexpiry b/source4/setup/setexpiry new file mode 100755 index 0000000000..e47330510c --- /dev/null +++ b/source4/setup/setexpiry @@ -0,0 +1,44 @@ +#!/usr/bin/python +# +# set the password expiry for a user +# Copyright Andrew Tridgell 2005 +# Copyright Jelmer Vernooij 2008 +# Released under the GNU GPL version 3 or later +# + +import sys + +# Find right directory when running from source tree +sys.path.insert(0, "bin/python") + +import samba.getopt as options +import optparse +from getpass import getpass +from samba.auth import system_session + +parser = optparse.OptionParser("setexpiry [options] ") +sambaopts = options.SambaOptions(parser) +parser.add_option_group(sambaopts) +parser.add_option_group(options.VersionOptions(parser)) +credopts = options.CredentialsOptions(parser) +parser.add_option_group(credopts) +parser.add_option("--days", help="Days to expiry", type=int) +parser.add_option("--noexpiry", help="Never expire", action="store_true") + +opts, args = parser.parse_args() + +if len(args) == 0: + parser.print_usage() + sys.exit(1) + +username = args[0] + +lp = sambaopts.get_loadparm() +creds = credopts.get_credentials(lp) + +samdb = sambaopts.get_hostconfig().get_samdb(session_info=system_session(), + credentials=creds) +days = opts.days +if days is None: + days = 0 +samdb.setexpiry(username, days*24*3600, opts.noexpiry) -- cgit From 9817f3d785ceb67819a9def0e8030272e4ba9e14 Mon Sep 17 00:00:00 2001 From: Andrew Tridgell Date: Sat, 30 Aug 2008 07:32:44 +1000 Subject: Add a setexpiry operation in samdb.py This makes it easy to set the expiry (or no expiry) for a samdb user (This used to be commit 25171f18a4b242b5a731f4ac1eefc51cc82efd74) --- source4/lib/ldb/ldb.py | 2 +- source4/lib/ldb/ldb_wrap.c | 135 ++++++++++++++++---------------- source4/lib/registry/registry.py | 2 +- source4/lib/registry/registry_wrap.c | 49 ++++++------ source4/scripting/python/misc.i | 13 +++ source4/scripting/python/misc.py | 3 +- source4/scripting/python/misc_wrap.c | 84 +++++++++++++++++--- source4/scripting/python/samba/samdb.py | 33 ++++++++ source4/setup/tests/blackbox_newuser.sh | 14 +++- 9 files changed, 233 insertions(+), 102 deletions(-) diff --git a/source4/lib/ldb/ldb.py b/source4/lib/ldb/ldb.py index ae2c187367..5826c6b752 100644 --- a/source4/lib/ldb/ldb.py +++ b/source4/lib/ldb/ldb.py @@ -1,5 +1,5 @@ # This file was automatically generated by SWIG (http://www.swig.org). -# Version 1.3.35 +# Version 1.3.36 # # Don't modify this file, modify the SWIG interface instead. diff --git a/source4/lib/ldb/ldb_wrap.c b/source4/lib/ldb/ldb_wrap.c index f9dd8471c7..c9dd9dccd8 100644 --- a/source4/lib/ldb/ldb_wrap.c +++ b/source4/lib/ldb/ldb_wrap.c @@ -1,6 +1,6 @@ /* ---------------------------------------------------------------------------- * This file was automatically generated by SWIG (http://www.swig.org). - * Version 1.3.35 + * Version 1.3.36 * * This file is not intended to be easily readable and contains a number of * coding conventions designed to improve portability and efficiency. Do not make @@ -52,6 +52,12 @@ # endif #endif +#ifndef SWIG_MSC_UNSUPPRESS_4505 +# if defined(_MSC_VER) +# pragma warning(disable : 4505) /* unreferenced local function has been removed */ +# endif +#endif + #ifndef SWIGUNUSEDPARM # ifdef __cplusplus # define SWIGUNUSEDPARM(p) @@ -2534,7 +2540,7 @@ static swig_module_info swig_module = {swig_types, 24, 0, 0, 0, 0}; #define SWIG_name "_ldb" -#define SWIGVERSION 0x010335 +#define SWIGVERSION 0x010336 #define SWIG_VERSION SWIGVERSION @@ -3228,7 +3234,6 @@ SWIGINTERN PyObject *_wrap_ldb_val_to_py_object(PyObject *SWIGUNUSEDPARM(self), struct ldb_context *arg1 = (struct ldb_context *) 0 ; struct ldb_message_element *arg2 = (struct ldb_message_element *) 0 ; struct ldb_val *arg3 = (struct ldb_val *) 0 ; - PyObject *result = 0 ; void *argp1 = 0 ; int res1 = 0 ; void *argp2 = 0 ; @@ -3241,6 +3246,7 @@ SWIGINTERN PyObject *_wrap_ldb_val_to_py_object(PyObject *SWIGUNUSEDPARM(self), char * kwnames[] = { (char *) "ldb_ctx",(char *) "el",(char *) "val", NULL }; + PyObject *result = 0 ; if (!PyArg_ParseTupleAndKeywords(args,kwargs,(char *)"OOO:ldb_val_to_py_object",kwnames,&obj0,&obj1,&obj2)) SWIG_fail; res1 = SWIG_ConvertPtr(obj0, &argp1,SWIGTYPE_p_ldb_context, 0 | 0 ); @@ -3273,7 +3279,6 @@ SWIGINTERN PyObject *_wrap_new_Dn(PyObject *SWIGUNUSEDPARM(self), PyObject *args PyObject *resultobj = 0; ldb *arg1 = (ldb *) 0 ; char *arg2 = (char *) 0 ; - ldb_dn *result = 0 ; void *argp1 = 0 ; int res1 = 0 ; int res2 ; @@ -3284,6 +3289,7 @@ SWIGINTERN PyObject *_wrap_new_Dn(PyObject *SWIGUNUSEDPARM(self), PyObject *args char * kwnames[] = { (char *) "ldb_ctx",(char *) "str", NULL }; + ldb_dn *result = 0 ; if (!PyArg_ParseTupleAndKeywords(args,kwargs,(char *)"OO:new_Dn",kwnames,&obj0,&obj1)) SWIG_fail; res1 = SWIG_ConvertPtr(obj0, &argp1,SWIGTYPE_p_ldb_context, 0 | 0 ); @@ -3324,7 +3330,6 @@ SWIGINTERN PyObject *_wrap_delete_Dn(PyObject *SWIGUNUSEDPARM(self), PyObject *a } arg1 = (ldb_dn *)(argp1); delete_ldb_dn(arg1); - resultobj = SWIG_Py_Void(); return resultobj; fail: @@ -3335,10 +3340,10 @@ fail: SWIGINTERN PyObject *_wrap_Dn_validate(PyObject *SWIGUNUSEDPARM(self), PyObject *args) { PyObject *resultobj = 0; ldb_dn *arg1 = (ldb_dn *) 0 ; - bool result; void *argp1 = 0 ; int res1 = 0 ; PyObject *swig_obj[1] ; + bool result; if (!args) SWIG_fail; swig_obj[0] = args; @@ -3358,10 +3363,10 @@ fail: SWIGINTERN PyObject *_wrap_Dn_get_casefold(PyObject *SWIGUNUSEDPARM(self), PyObject *args) { PyObject *resultobj = 0; ldb_dn *arg1 = (ldb_dn *) 0 ; - char *result = 0 ; void *argp1 = 0 ; int res1 = 0 ; PyObject *swig_obj[1] ; + char *result = 0 ; if (!args) SWIG_fail; swig_obj[0] = args; @@ -3381,10 +3386,10 @@ fail: SWIGINTERN PyObject *_wrap_Dn___str__(PyObject *SWIGUNUSEDPARM(self), PyObject *args) { PyObject *resultobj = 0; ldb_dn *arg1 = (ldb_dn *) 0 ; - char *result = 0 ; void *argp1 = 0 ; int res1 = 0 ; PyObject *swig_obj[1] ; + char *result = 0 ; if (!args) SWIG_fail; swig_obj[0] = args; @@ -3404,10 +3409,10 @@ fail: SWIGINTERN PyObject *_wrap_Dn_parent(PyObject *SWIGUNUSEDPARM(self), PyObject *args) { PyObject *resultobj = 0; ldb_dn *arg1 = (ldb_dn *) 0 ; - ldb_dn *result = 0 ; void *argp1 = 0 ; int res1 = 0 ; PyObject *swig_obj[1] ; + ldb_dn *result = 0 ; if (!args) SWIG_fail; swig_obj[0] = args; @@ -3428,7 +3433,6 @@ SWIGINTERN PyObject *_wrap_Dn___cmp__(PyObject *SWIGUNUSEDPARM(self), PyObject * PyObject *resultobj = 0; ldb_dn *arg1 = (ldb_dn *) 0 ; ldb_dn *arg2 = (ldb_dn *) 0 ; - int result; void *argp1 = 0 ; int res1 = 0 ; void *argp2 = 0 ; @@ -3438,6 +3442,7 @@ SWIGINTERN PyObject *_wrap_Dn___cmp__(PyObject *SWIGUNUSEDPARM(self), PyObject * char * kwnames[] = { (char *) "self",(char *) "other", NULL }; + int result; if (!PyArg_ParseTupleAndKeywords(args,kwargs,(char *)"OO:Dn___cmp__",kwnames,&obj0,&obj1)) SWIG_fail; res1 = SWIG_ConvertPtr(obj0, &argp1,SWIGTYPE_p_ldb_dn, 0 | 0 ); @@ -3461,10 +3466,10 @@ fail: SWIGINTERN PyObject *_wrap_Dn_is_valid(PyObject *SWIGUNUSEDPARM(self), PyObject *args) { PyObject *resultobj = 0; ldb_dn *arg1 = (ldb_dn *) 0 ; - bool result; void *argp1 = 0 ; int res1 = 0 ; PyObject *swig_obj[1] ; + bool result; if (!args) SWIG_fail; swig_obj[0] = args; @@ -3484,10 +3489,10 @@ fail: SWIGINTERN PyObject *_wrap_Dn_is_special(PyObject *SWIGUNUSEDPARM(self), PyObject *args) { PyObject *resultobj = 0; ldb_dn *arg1 = (ldb_dn *) 0 ; - bool result; void *argp1 = 0 ; int res1 = 0 ; PyObject *swig_obj[1] ; + bool result; if (!args) SWIG_fail; swig_obj[0] = args; @@ -3507,10 +3512,10 @@ fail: SWIGINTERN PyObject *_wrap_Dn_is_null(PyObject *SWIGUNUSEDPARM(self), PyObject *args) { PyObject *resultobj = 0; ldb_dn *arg1 = (ldb_dn *) 0 ; - bool result; void *argp1 = 0 ; int res1 = 0 ; PyObject *swig_obj[1] ; + bool result; if (!args) SWIG_fail; swig_obj[0] = args; @@ -3531,7 +3536,6 @@ SWIGINTERN PyObject *_wrap_Dn_check_special(PyObject *SWIGUNUSEDPARM(self), PyOb PyObject *resultobj = 0; ldb_dn *arg1 = (ldb_dn *) 0 ; char *arg2 = (char *) 0 ; - bool result; void *argp1 = 0 ; int res1 = 0 ; int res2 ; @@ -3542,6 +3546,7 @@ SWIGINTERN PyObject *_wrap_Dn_check_special(PyObject *SWIGUNUSEDPARM(self), PyOb char * kwnames[] = { (char *) "self",(char *) "name", NULL }; + bool result; if (!PyArg_ParseTupleAndKeywords(args,kwargs,(char *)"OO:Dn_check_special",kwnames,&obj0,&obj1)) SWIG_fail; res1 = SWIG_ConvertPtr(obj0, &argp1,SWIGTYPE_p_ldb_dn, 0 | 0 ); @@ -3567,10 +3572,10 @@ fail: SWIGINTERN PyObject *_wrap_Dn___len__(PyObject *SWIGUNUSEDPARM(self), PyObject *args) { PyObject *resultobj = 0; ldb_dn *arg1 = (ldb_dn *) 0 ; - int result; void *argp1 = 0 ; int res1 = 0 ; PyObject *swig_obj[1] ; + int result; if (!args) SWIG_fail; swig_obj[0] = args; @@ -3591,7 +3596,6 @@ SWIGINTERN PyObject *_wrap_Dn_add_child(PyObject *SWIGUNUSEDPARM(self), PyObject PyObject *resultobj = 0; ldb_dn *arg1 = (ldb_dn *) 0 ; ldb_dn *arg2 = (ldb_dn *) 0 ; - bool result; void *argp1 = 0 ; int res1 = 0 ; void *argp2 = 0 ; @@ -3601,6 +3605,7 @@ SWIGINTERN PyObject *_wrap_Dn_add_child(PyObject *SWIGUNUSEDPARM(self), PyObject char * kwnames[] = { (char *) "self",(char *) "child", NULL }; + bool result; if (!PyArg_ParseTupleAndKeywords(args,kwargs,(char *)"OO:Dn_add_child",kwnames,&obj0,&obj1)) SWIG_fail; res1 = SWIG_ConvertPtr(obj0, &argp1,SWIGTYPE_p_ldb_dn, 0 | 0 ); @@ -3625,7 +3630,6 @@ SWIGINTERN PyObject *_wrap_Dn_add_base(PyObject *SWIGUNUSEDPARM(self), PyObject PyObject *resultobj = 0; ldb_dn *arg1 = (ldb_dn *) 0 ; ldb_dn *arg2 = (ldb_dn *) 0 ; - bool result; void *argp1 = 0 ; int res1 = 0 ; void *argp2 = 0 ; @@ -3635,6 +3639,7 @@ SWIGINTERN PyObject *_wrap_Dn_add_base(PyObject *SWIGUNUSEDPARM(self), PyObject char * kwnames[] = { (char *) "self",(char *) "base", NULL }; + bool result; if (!PyArg_ParseTupleAndKeywords(args,kwargs,(char *)"OO:Dn_add_base",kwnames,&obj0,&obj1)) SWIG_fail; res1 = SWIG_ConvertPtr(obj0, &argp1,SWIGTYPE_p_ldb_dn, 0 | 0 ); @@ -3658,10 +3663,10 @@ fail: SWIGINTERN PyObject *_wrap_Dn_canonical_str(PyObject *SWIGUNUSEDPARM(self), PyObject *args) { PyObject *resultobj = 0; ldb_dn *arg1 = (ldb_dn *) 0 ; - char *result = 0 ; void *argp1 = 0 ; int res1 = 0 ; PyObject *swig_obj[1] ; + char *result = 0 ; if (!args) SWIG_fail; swig_obj[0] = args; @@ -3681,10 +3686,10 @@ fail: SWIGINTERN PyObject *_wrap_Dn_canonical_ex_str(PyObject *SWIGUNUSEDPARM(self), PyObject *args) { PyObject *resultobj = 0; ldb_dn *arg1 = (ldb_dn *) 0 ; - char *result = 0 ; void *argp1 = 0 ; int res1 = 0 ; PyObject *swig_obj[1] ; + char *result = 0 ; if (!args) SWIG_fail; swig_obj[0] = args; @@ -3704,10 +3709,10 @@ fail: SWIGINTERN PyObject *_wrap_Dn___repr__(PyObject *SWIGUNUSEDPARM(self), PyObject *args) { PyObject *resultobj = 0; ldb_dn *arg1 = (ldb_dn *) 0 ; - char *result = 0 ; void *argp1 = 0 ; int res1 = 0 ; PyObject *swig_obj[1] ; + char *result = 0 ; if (!args) SWIG_fail; swig_obj[0] = args; @@ -3728,7 +3733,6 @@ SWIGINTERN PyObject *_wrap_Dn___add__(PyObject *SWIGUNUSEDPARM(self), PyObject * PyObject *resultobj = 0; ldb_dn *arg1 = (ldb_dn *) 0 ; ldb_dn *arg2 = (ldb_dn *) 0 ; - ldb_dn *result = 0 ; void *argp1 = 0 ; int res1 = 0 ; void *argp2 = 0 ; @@ -3738,6 +3742,7 @@ SWIGINTERN PyObject *_wrap_Dn___add__(PyObject *SWIGUNUSEDPARM(self), PyObject * char * kwnames[] = { (char *) "self",(char *) "other", NULL }; + ldb_dn *result = 0 ; if (!PyArg_ParseTupleAndKeywords(args,kwargs,(char *)"OO:Dn___add__",kwnames,&obj0,&obj1)) SWIG_fail; res1 = SWIG_ConvertPtr(obj0, &argp1,SWIGTYPE_p_ldb_dn, 0 | 0 ); @@ -3773,7 +3778,6 @@ SWIGINTERN PyObject *_wrap_MessageElement___cmp__(PyObject *SWIGUNUSEDPARM(self) PyObject *resultobj = 0; ldb_message_element *arg1 = (ldb_message_element *) 0 ; ldb_message_element *arg2 = (ldb_message_element *) 0 ; - int result; void *argp1 = 0 ; int res1 = 0 ; void *argp2 = 0 ; @@ -3783,6 +3787,7 @@ SWIGINTERN PyObject *_wrap_MessageElement___cmp__(PyObject *SWIGUNUSEDPARM(self) char * kwnames[] = { (char *) "self",(char *) "other", NULL }; + int result; if (!PyArg_ParseTupleAndKeywords(args,kwargs,(char *)"OO:MessageElement___cmp__",kwnames,&obj0,&obj1)) SWIG_fail; res1 = SWIG_ConvertPtr(obj0, &argp1,SWIGTYPE_p_ldb_message_element, 0 | 0 ); @@ -3806,10 +3811,10 @@ fail: SWIGINTERN PyObject *_wrap_MessageElement___iter__(PyObject *SWIGUNUSEDPARM(self), PyObject *args) { PyObject *resultobj = 0; ldb_message_element *arg1 = (ldb_message_element *) 0 ; - PyObject *result = 0 ; void *argp1 = 0 ; int res1 = 0 ; PyObject *swig_obj[1] ; + PyObject *result = 0 ; if (!args) SWIG_fail; swig_obj[0] = args; @@ -3829,10 +3834,10 @@ fail: SWIGINTERN PyObject *_wrap_MessageElement___set__(PyObject *SWIGUNUSEDPARM(self), PyObject *args) { PyObject *resultobj = 0; ldb_message_element *arg1 = (ldb_message_element *) 0 ; - PyObject *result = 0 ; void *argp1 = 0 ; int res1 = 0 ; PyObject *swig_obj[1] ; + PyObject *result = 0 ; if (!args) SWIG_fail; swig_obj[0] = args; @@ -3854,7 +3859,6 @@ SWIGINTERN PyObject *_wrap_new_MessageElement(PyObject *SWIGUNUSEDPARM(self), Py PyObject *arg1 = (PyObject *) 0 ; int arg2 = (int) 0 ; char *arg3 = (char *) NULL ; - ldb_message_element *result = 0 ; int val2 ; int ecode2 = 0 ; int res3 ; @@ -3866,6 +3870,7 @@ SWIGINTERN PyObject *_wrap_new_MessageElement(PyObject *SWIGUNUSEDPARM(self), Py char * kwnames[] = { (char *) "set_obj",(char *) "flags",(char *) "name", NULL }; + ldb_message_element *result = 0 ; if (!PyArg_ParseTupleAndKeywords(args,kwargs,(char *)"O|OO:new_MessageElement",kwnames,&obj0,&obj1,&obj2)) SWIG_fail; arg1 = obj0; @@ -3896,10 +3901,10 @@ fail: SWIGINTERN PyObject *_wrap_MessageElement___len__(PyObject *SWIGUNUSEDPARM(self), PyObject *args) { PyObject *resultobj = 0; ldb_message_element *arg1 = (ldb_message_element *) 0 ; - int result; void *argp1 = 0 ; int res1 = 0 ; PyObject *swig_obj[1] ; + int result; if (!args) SWIG_fail; swig_obj[0] = args; @@ -3920,7 +3925,6 @@ SWIGINTERN PyObject *_wrap_MessageElement_get(PyObject *SWIGUNUSEDPARM(self), Py PyObject *resultobj = 0; ldb_message_element *arg1 = (ldb_message_element *) 0 ; int arg2 ; - PyObject *result = 0 ; void *argp1 = 0 ; int res1 = 0 ; int val2 ; @@ -3930,6 +3934,7 @@ SWIGINTERN PyObject *_wrap_MessageElement_get(PyObject *SWIGUNUSEDPARM(self), Py char * kwnames[] = { (char *) "self",(char *) "i", NULL }; + PyObject *result = 0 ; if (!PyArg_ParseTupleAndKeywords(args,kwargs,(char *)"OO:MessageElement_get",kwnames,&obj0,&obj1)) SWIG_fail; res1 = SWIG_ConvertPtr(obj0, &argp1,SWIGTYPE_p_ldb_message_element, 0 | 0 ); @@ -3965,7 +3970,6 @@ SWIGINTERN PyObject *_wrap_delete_MessageElement(PyObject *SWIGUNUSEDPARM(self), } arg1 = (ldb_message_element *)(argp1); delete_ldb_message_element(arg1); - resultobj = SWIG_Py_Void(); return resultobj; fail: @@ -3987,13 +3991,13 @@ SWIGINTERN PyObject *MessageElement_swiginit(PyObject *SWIGUNUSEDPARM(self), PyO SWIGINTERN PyObject *_wrap_ldb_msg_list_elements(PyObject *SWIGUNUSEDPARM(self), PyObject *args, PyObject *kwargs) { PyObject *resultobj = 0; ldb_msg *arg1 = (ldb_msg *) 0 ; - PyObject *result = 0 ; void *argp1 = 0 ; int res1 = 0 ; PyObject * obj0 = 0 ; char * kwnames[] = { (char *) "msg", NULL }; + PyObject *result = 0 ; if (!PyArg_ParseTupleAndKeywords(args,kwargs,(char *)"O:ldb_msg_list_elements",kwnames,&obj0)) SWIG_fail; res1 = SWIG_ConvertPtr(obj0, &argp1,SWIGTYPE_p_ldb_message, 0 | 0 ); @@ -4037,7 +4041,6 @@ SWIGINTERN PyObject *_wrap_Message_dn_set(PyObject *SWIGUNUSEDPARM(self), PyObje SWIG_exception(SWIG_ValueError, "Message can not be None"); if (arg1) (arg1)->dn = arg2; - resultobj = SWIG_Py_Void(); return resultobj; fail: @@ -4048,10 +4051,10 @@ fail: SWIGINTERN PyObject *_wrap_Message_dn_get(PyObject *SWIGUNUSEDPARM(self), PyObject *args) { PyObject *resultobj = 0; ldb_msg *arg1 = (ldb_msg *) 0 ; - ldb_dn *result = 0 ; void *argp1 = 0 ; int res1 = 0 ; PyObject *swig_obj[1] ; + ldb_dn *result = 0 ; if (!args) SWIG_fail; swig_obj[0] = args; @@ -4074,13 +4077,13 @@ fail: SWIGINTERN PyObject *_wrap_new_Message(PyObject *SWIGUNUSEDPARM(self), PyObject *args, PyObject *kwargs) { PyObject *resultobj = 0; ldb_dn *arg1 = (ldb_dn *) NULL ; - ldb_msg *result = 0 ; void *argp1 = 0 ; int res1 = 0 ; PyObject * obj0 = 0 ; char * kwnames[] = { (char *) "dn", NULL }; + ldb_msg *result = 0 ; if (!PyArg_ParseTupleAndKeywords(args,kwargs,(char *)"|O:new_Message",kwnames,&obj0)) SWIG_fail; if (obj0) { @@ -4116,7 +4119,6 @@ SWIGINTERN PyObject *_wrap_delete_Message(PyObject *SWIGUNUSEDPARM(self), PyObje SWIG_exception(SWIG_ValueError, "Message can not be None"); delete_ldb_msg(arg1); - resultobj = SWIG_Py_Void(); return resultobj; fail: @@ -4128,7 +4130,6 @@ SWIGINTERN PyObject *_wrap_Message_find_element(PyObject *SWIGUNUSEDPARM(self), PyObject *resultobj = 0; ldb_msg *arg1 = (ldb_msg *) 0 ; char *arg2 = (char *) 0 ; - ldb_message_element *result = 0 ; void *argp1 = 0 ; int res1 = 0 ; int res2 ; @@ -4139,6 +4140,7 @@ SWIGINTERN PyObject *_wrap_Message_find_element(PyObject *SWIGUNUSEDPARM(self), char * kwnames[] = { (char *) "self",(char *) "name", NULL }; + ldb_message_element *result = 0 ; if (!PyArg_ParseTupleAndKeywords(args,kwargs,(char *)"OO:Message_find_element",kwnames,&obj0,&obj1)) SWIG_fail; res1 = SWIG_ConvertPtr(obj0, &argp1,SWIGTYPE_p_ldb_message, 0 | 0 ); @@ -4281,10 +4283,10 @@ fail: SWIGINTERN PyObject *_wrap_Message___len__(PyObject *SWIGUNUSEDPARM(self), PyObject *args) { PyObject *resultobj = 0; ldb_msg *arg1 = (ldb_msg *) 0 ; - unsigned int result; void *argp1 = 0 ; int res1 = 0 ; PyObject *swig_obj[1] ; + unsigned int result; if (!args) SWIG_fail; swig_obj[0] = args; @@ -4307,10 +4309,10 @@ fail: SWIGINTERN PyObject *_wrap_Message_keys(PyObject *SWIGUNUSEDPARM(self), PyObject *args) { PyObject *resultobj = 0; ldb_msg *arg1 = (ldb_msg *) 0 ; - PyObject *result = 0 ; void *argp1 = 0 ; int res1 = 0 ; PyObject *swig_obj[1] ; + PyObject *result = 0 ; if (!args) SWIG_fail; swig_obj[0] = args; @@ -4333,10 +4335,10 @@ fail: SWIGINTERN PyObject *_wrap_Message___iter__(PyObject *SWIGUNUSEDPARM(self), PyObject *args) { PyObject *resultobj = 0; ldb_msg *arg1 = (ldb_msg *) 0 ; - PyObject *result = 0 ; void *argp1 = 0 ; int res1 = 0 ; PyObject *swig_obj[1] ; + PyObject *result = 0 ; if (!args) SWIG_fail; swig_obj[0] = args; @@ -4409,13 +4411,13 @@ SWIGINTERN PyObject *Message_swiginit(PyObject *SWIGUNUSEDPARM(self), PyObject * SWIGINTERN PyObject *_wrap_ldb_ldif_to_pyobject(PyObject *SWIGUNUSEDPARM(self), PyObject *args, PyObject *kwargs) { PyObject *resultobj = 0; ldb_ldif *arg1 = (ldb_ldif *) 0 ; - PyObject *result = 0 ; void *argp1 = 0 ; int res1 = 0 ; PyObject * obj0 = 0 ; char * kwnames[] = { (char *) "ldif", NULL }; + PyObject *result = 0 ; if (!PyArg_ParseTupleAndKeywords(args,kwargs,(char *)"O:ldb_ldif_to_pyobject",kwnames,&obj0)) SWIG_fail; res1 = SWIG_ConvertPtr(obj0, &argp1,SWIGTYPE_p_ldb_ldif, 0 | 0 ); @@ -4450,7 +4452,6 @@ SWIGINTERN PyObject *_wrap_Ldb_connect(PyObject *SWIGUNUSEDPARM(self), PyObject char *arg2 = (char *) 0 ; unsigned int arg3 = (unsigned int) 0 ; char **arg4 = (char **) (char **)NULL ; - ldb_error result; void *argp1 = 0 ; int res1 = 0 ; int res2 ; @@ -4467,6 +4468,7 @@ SWIGINTERN PyObject *_wrap_Ldb_connect(PyObject *SWIGUNUSEDPARM(self), PyObject char * kwnames[] = { (char *) "self",(char *) "url",(char *) "flags",(char *) "options", NULL }; + ldb_error result; if (!PyArg_ParseTupleAndKeywords(args,kwargs,(char *)"OO|OO:Ldb_connect",kwnames,&obj0,&obj1,&obj2,&obj3)) SWIG_fail; res1 = SWIG_ConvertPtr(obj0, &argp1,SWIGTYPE_p_ldb_context, 0 | 0 ); @@ -4528,7 +4530,6 @@ SWIGINTERN PyObject *_wrap_delete_Ldb(PyObject *SWIGUNUSEDPARM(self), PyObject * SWIG_exception(SWIG_ValueError, "ldb context must be non-NULL"); delete_ldb(arg1); - resultobj = SWIG_Py_Void(); return resultobj; fail: @@ -4546,7 +4547,6 @@ SWIGINTERN PyObject *_wrap_Ldb_search_ex(PyObject *SWIGUNUSEDPARM(self), PyObjec char **arg6 = (char **) NULL ; struct ldb_control **arg7 = (struct ldb_control **) NULL ; struct ldb_result **arg8 = (struct ldb_result **) 0 ; - ldb_error result; void *argp1 = 0 ; int res1 = 0 ; int val4 ; @@ -4567,6 +4567,7 @@ SWIGINTERN PyObject *_wrap_Ldb_search_ex(PyObject *SWIGUNUSEDPARM(self), PyObjec char * kwnames[] = { (char *) "self",(char *) "base",(char *) "scope",(char *) "expression",(char *) "attrs",(char *) "controls", NULL }; + ldb_error result; arg2 = NULL; arg8 = &temp_ldb_result8; @@ -4646,7 +4647,6 @@ SWIGINTERN PyObject *_wrap_Ldb_delete(PyObject *SWIGUNUSEDPARM(self), PyObject * PyObject *resultobj = 0; ldb *arg1 = (ldb *) 0 ; ldb_dn *arg2 = (ldb_dn *) 0 ; - ldb_error result; void *argp1 = 0 ; int res1 = 0 ; PyObject * obj0 = 0 ; @@ -4654,6 +4654,7 @@ SWIGINTERN PyObject *_wrap_Ldb_delete(PyObject *SWIGUNUSEDPARM(self), PyObject * char * kwnames[] = { (char *) "self",(char *) "dn", NULL }; + ldb_error result; if (!PyArg_ParseTupleAndKeywords(args,kwargs,(char *)"OO:Ldb_delete",kwnames,&obj0,&obj1)) SWIG_fail; res1 = SWIG_ConvertPtr(obj0, &argp1,SWIGTYPE_p_ldb_context, 0 | 0 ); @@ -4686,7 +4687,6 @@ SWIGINTERN PyObject *_wrap_Ldb_rename(PyObject *SWIGUNUSEDPARM(self), PyObject * ldb *arg1 = (ldb *) 0 ; ldb_dn *arg2 = (ldb_dn *) 0 ; ldb_dn *arg3 = (ldb_dn *) 0 ; - ldb_error result; void *argp1 = 0 ; int res1 = 0 ; PyObject * obj0 = 0 ; @@ -4695,6 +4695,7 @@ SWIGINTERN PyObject *_wrap_Ldb_rename(PyObject *SWIGUNUSEDPARM(self), PyObject * char * kwnames[] = { (char *) "self",(char *) "olddn",(char *) "newdn", NULL }; + ldb_error result; if (!PyArg_ParseTupleAndKeywords(args,kwargs,(char *)"OOO:Ldb_rename",kwnames,&obj0,&obj1,&obj2)) SWIG_fail; res1 = SWIG_ConvertPtr(obj0, &argp1,SWIGTYPE_p_ldb_context, 0 | 0 ); @@ -4732,7 +4733,6 @@ SWIGINTERN PyObject *_wrap_Ldb_parse_control_strings(PyObject *SWIGUNUSEDPARM(se ldb *arg1 = (ldb *) 0 ; TALLOC_CTX *arg2 = (TALLOC_CTX *) 0 ; char **arg3 = (char **) 0 ; - struct ldb_control **result = 0 ; void *argp1 = 0 ; int res1 = 0 ; PyObject * obj0 = 0 ; @@ -4740,6 +4740,7 @@ SWIGINTERN PyObject *_wrap_Ldb_parse_control_strings(PyObject *SWIGUNUSEDPARM(se char * kwnames[] = { (char *) "self",(char *) "control_strings", NULL }; + struct ldb_control **result = 0 ; arg2 = NULL; if (!PyArg_ParseTupleAndKeywords(args,kwargs,(char *)"OO:Ldb_parse_control_strings",kwnames,&obj0,&obj1)) SWIG_fail; @@ -4780,7 +4781,6 @@ SWIGINTERN PyObject *_wrap_Ldb_add(PyObject *SWIGUNUSEDPARM(self), PyObject *arg PyObject *resultobj = 0; ldb *arg1 = (ldb *) 0 ; ldb_msg *arg2 = (ldb_msg *) 0 ; - ldb_error result; void *argp1 = 0 ; int res1 = 0 ; PyObject * obj0 = 0 ; @@ -4788,6 +4788,7 @@ SWIGINTERN PyObject *_wrap_Ldb_add(PyObject *SWIGUNUSEDPARM(self), PyObject *arg char * kwnames[] = { (char *) "self",(char *) "add_msg", NULL }; + ldb_error result; if (!PyArg_ParseTupleAndKeywords(args,kwargs,(char *)"OO:Ldb_add",kwnames,&obj0,&obj1)) SWIG_fail; res1 = SWIG_ConvertPtr(obj0, &argp1,SWIGTYPE_p_ldb_context, 0 | 0 ); @@ -4860,7 +4861,6 @@ SWIGINTERN PyObject *_wrap_Ldb_modify(PyObject *SWIGUNUSEDPARM(self), PyObject * PyObject *resultobj = 0; ldb *arg1 = (ldb *) 0 ; ldb_msg *arg2 = (ldb_msg *) 0 ; - ldb_error result; void *argp1 = 0 ; int res1 = 0 ; void *argp2 = 0 ; @@ -4870,6 +4870,7 @@ SWIGINTERN PyObject *_wrap_Ldb_modify(PyObject *SWIGUNUSEDPARM(self), PyObject * char * kwnames[] = { (char *) "self",(char *) "message", NULL }; + ldb_error result; if (!PyArg_ParseTupleAndKeywords(args,kwargs,(char *)"OO:Ldb_modify",kwnames,&obj0,&obj1)) SWIG_fail; res1 = SWIG_ConvertPtr(obj0, &argp1,SWIGTYPE_p_ldb_context, 0 | 0 ); @@ -4903,10 +4904,10 @@ fail: SWIGINTERN PyObject *_wrap_Ldb_get_config_basedn(PyObject *SWIGUNUSEDPARM(self), PyObject *args) { PyObject *resultobj = 0; ldb *arg1 = (ldb *) 0 ; - ldb_dn *result = 0 ; void *argp1 = 0 ; int res1 = 0 ; PyObject *swig_obj[1] ; + ldb_dn *result = 0 ; if (!args) SWIG_fail; swig_obj[0] = args; @@ -4929,10 +4930,10 @@ fail: SWIGINTERN PyObject *_wrap_Ldb_get_root_basedn(PyObject *SWIGUNUSEDPARM(self), PyObject *args) { PyObject *resultobj = 0; ldb *arg1 = (ldb *) 0 ; - ldb_dn *result = 0 ; void *argp1 = 0 ; int res1 = 0 ; PyObject *swig_obj[1] ; + ldb_dn *result = 0 ; if (!args) SWIG_fail; swig_obj[0] = args; @@ -4955,10 +4956,10 @@ fail: SWIGINTERN PyObject *_wrap_Ldb_get_schema_basedn(PyObject *SWIGUNUSEDPARM(self), PyObject *args) { PyObject *resultobj = 0; ldb *arg1 = (ldb *) 0 ; - ldb_dn *result = 0 ; void *argp1 = 0 ; int res1 = 0 ; PyObject *swig_obj[1] ; + ldb_dn *result = 0 ; if (!args) SWIG_fail; swig_obj[0] = args; @@ -4981,10 +4982,10 @@ fail: SWIGINTERN PyObject *_wrap_Ldb_get_default_basedn(PyObject *SWIGUNUSEDPARM(self), PyObject *args) { PyObject *resultobj = 0; ldb *arg1 = (ldb *) 0 ; - ldb_dn *result = 0 ; void *argp1 = 0 ; int res1 = 0 ; PyObject *swig_obj[1] ; + ldb_dn *result = 0 ; if (!args) SWIG_fail; swig_obj[0] = args; @@ -5009,7 +5010,6 @@ SWIGINTERN PyObject *_wrap_Ldb_schema_format_value(PyObject *SWIGUNUSEDPARM(self ldb *arg1 = (ldb *) 0 ; char *arg2 = (char *) 0 ; PyObject *arg3 = (PyObject *) 0 ; - PyObject *result = 0 ; void *argp1 = 0 ; int res1 = 0 ; int res2 ; @@ -5021,6 +5021,7 @@ SWIGINTERN PyObject *_wrap_Ldb_schema_format_value(PyObject *SWIGUNUSEDPARM(self char * kwnames[] = { (char *) "self",(char *) "element_name",(char *) "val", NULL }; + PyObject *result = 0 ; if (!PyArg_ParseTupleAndKeywords(args,kwargs,(char *)"OOO:Ldb_schema_format_value",kwnames,&obj0,&obj1,&obj2)) SWIG_fail; res1 = SWIG_ConvertPtr(obj0, &argp1,SWIGTYPE_p_ldb_context, 0 | 0 ); @@ -5050,10 +5051,10 @@ fail: SWIGINTERN PyObject *_wrap_Ldb_errstring(PyObject *SWIGUNUSEDPARM(self), PyObject *args) { PyObject *resultobj = 0; ldb *arg1 = (ldb *) 0 ; - char *result = 0 ; void *argp1 = 0 ; int res1 = 0 ; PyObject *swig_obj[1] ; + char *result = 0 ; if (!args) SWIG_fail; swig_obj[0] = args; @@ -5153,7 +5154,6 @@ SWIGINTERN PyObject *_wrap_Ldb_set_debug(PyObject *SWIGUNUSEDPARM(self), PyObjec ldb *arg1 = (ldb *) 0 ; void (*arg2)(void *,enum ldb_debug_level,char const *,va_list) = (void (*)(void *,enum ldb_debug_level,char const *,va_list)) 0 ; void *arg3 = (void *) 0 ; - ldb_error result; void *argp1 = 0 ; int res1 = 0 ; PyObject * obj0 = 0 ; @@ -5161,6 +5161,7 @@ SWIGINTERN PyObject *_wrap_Ldb_set_debug(PyObject *SWIGUNUSEDPARM(self), PyObjec char * kwnames[] = { (char *) "self",(char *) "debug", NULL }; + ldb_error result; if (!PyArg_ParseTupleAndKeywords(args,kwargs,(char *)"OO:Ldb_set_debug",kwnames,&obj0,&obj1)) SWIG_fail; res1 = SWIG_ConvertPtr(obj0, &argp1,SWIGTYPE_p_ldb_context, 0 | 0 ); @@ -5193,7 +5194,6 @@ SWIGINTERN PyObject *_wrap_Ldb_set_opaque(PyObject *SWIGUNUSEDPARM(self), PyObje ldb *arg1 = (ldb *) 0 ; char *arg2 = (char *) 0 ; void *arg3 = (void *) 0 ; - ldb_error result; void *argp1 = 0 ; int res1 = 0 ; int res2 ; @@ -5206,6 +5206,7 @@ SWIGINTERN PyObject *_wrap_Ldb_set_opaque(PyObject *SWIGUNUSEDPARM(self), PyObje char * kwnames[] = { (char *) "self",(char *) "name",(char *) "value", NULL }; + ldb_error result; if (!PyArg_ParseTupleAndKeywords(args,kwargs,(char *)"OOO:Ldb_set_opaque",kwnames,&obj0,&obj1,&obj2)) SWIG_fail; res1 = SWIG_ConvertPtr(obj0, &argp1,SWIGTYPE_p_ldb_context, 0 | 0 ); @@ -5243,7 +5244,6 @@ SWIGINTERN PyObject *_wrap_Ldb_get_opaque(PyObject *SWIGUNUSEDPARM(self), PyObje PyObject *resultobj = 0; ldb *arg1 = (ldb *) 0 ; char *arg2 = (char *) 0 ; - void *result = 0 ; void *argp1 = 0 ; int res1 = 0 ; int res2 ; @@ -5254,6 +5254,7 @@ SWIGINTERN PyObject *_wrap_Ldb_get_opaque(PyObject *SWIGUNUSEDPARM(self), PyObje char * kwnames[] = { (char *) "self",(char *) "name", NULL }; + void *result = 0 ; if (!PyArg_ParseTupleAndKeywords(args,kwargs,(char *)"OO:Ldb_get_opaque",kwnames,&obj0,&obj1)) SWIG_fail; res1 = SWIG_ConvertPtr(obj0, &argp1,SWIGTYPE_p_ldb_context, 0 | 0 ); @@ -5282,10 +5283,10 @@ fail: SWIGINTERN PyObject *_wrap_Ldb_transaction_start(PyObject *SWIGUNUSEDPARM(self), PyObject *args) { PyObject *resultobj = 0; ldb *arg1 = (ldb *) 0 ; - ldb_error result; void *argp1 = 0 ; int res1 = 0 ; PyObject *swig_obj[1] ; + ldb_error result; if (!args) SWIG_fail; swig_obj[0] = args; @@ -5312,10 +5313,10 @@ fail: SWIGINTERN PyObject *_wrap_Ldb_transaction_commit(PyObject *SWIGUNUSEDPARM(self), PyObject *args) { PyObject *resultobj = 0; ldb *arg1 = (ldb *) 0 ; - ldb_error result; void *argp1 = 0 ; int res1 = 0 ; PyObject *swig_obj[1] ; + ldb_error result; if (!args) SWIG_fail; swig_obj[0] = args; @@ -5342,10 +5343,10 @@ fail: SWIGINTERN PyObject *_wrap_Ldb_transaction_cancel(PyObject *SWIGUNUSEDPARM(self), PyObject *args) { PyObject *resultobj = 0; ldb *arg1 = (ldb *) 0 ; - ldb_error result; void *argp1 = 0 ; int res1 = 0 ; PyObject *swig_obj[1] ; + ldb_error result; if (!args) SWIG_fail; swig_obj[0] = args; @@ -5414,7 +5415,6 @@ SWIGINTERN PyObject *_wrap_Ldb_schema_attribute_add(PyObject *SWIGUNUSEDPARM(sel char *arg2 = (char *) 0 ; unsigned int arg3 ; char *arg4 = (char *) 0 ; - ldb_error result; void *argp1 = 0 ; int res1 = 0 ; int res2 ; @@ -5432,6 +5432,7 @@ SWIGINTERN PyObject *_wrap_Ldb_schema_attribute_add(PyObject *SWIGUNUSEDPARM(sel char * kwnames[] = { (char *) "self",(char *) "attribute",(char *) "flags",(char *) "syntax", NULL }; + ldb_error result; if (!PyArg_ParseTupleAndKeywords(args,kwargs,(char *)"OOOO:Ldb_schema_attribute_add",kwnames,&obj0,&obj1,&obj2,&obj3)) SWIG_fail; res1 = SWIG_ConvertPtr(obj0, &argp1,SWIGTYPE_p_ldb_context, 0 | 0 ); @@ -5476,10 +5477,10 @@ fail: SWIGINTERN PyObject *_wrap_Ldb_setup_wellknown_attributes(PyObject *SWIGUNUSEDPARM(self), PyObject *args) { PyObject *resultobj = 0; ldb *arg1 = (ldb *) 0 ; - ldb_error result; void *argp1 = 0 ; int res1 = 0 ; PyObject *swig_obj[1] ; + ldb_error result; if (!args) SWIG_fail; swig_obj[0] = args; @@ -5508,7 +5509,6 @@ SWIGINTERN PyObject *_wrap_Ldb___contains__(PyObject *SWIGUNUSEDPARM(self), PyOb ldb *arg1 = (ldb *) 0 ; ldb_dn *arg2 = (ldb_dn *) 0 ; struct ldb_result **arg3 = (struct ldb_result **) 0 ; - ldb_error result; void *argp1 = 0 ; int res1 = 0 ; struct ldb_result *tmp3 ; @@ -5517,6 +5517,7 @@ SWIGINTERN PyObject *_wrap_Ldb___contains__(PyObject *SWIGUNUSEDPARM(self), PyOb char * kwnames[] = { (char *) "self",(char *) "dn", NULL }; + ldb_error result; arg3 = &tmp3; if (!PyArg_ParseTupleAndKeywords(args,kwargs,(char *)"OO:Ldb___contains__",kwnames,&obj0,&obj1)) SWIG_fail; @@ -5552,7 +5553,6 @@ SWIGINTERN PyObject *_wrap_Ldb_parse_ldif(PyObject *SWIGUNUSEDPARM(self), PyObje PyObject *resultobj = 0; ldb *arg1 = (ldb *) 0 ; char *arg2 = (char *) 0 ; - PyObject *result = 0 ; void *argp1 = 0 ; int res1 = 0 ; int res2 ; @@ -5563,6 +5563,7 @@ SWIGINTERN PyObject *_wrap_Ldb_parse_ldif(PyObject *SWIGUNUSEDPARM(self), PyObje char * kwnames[] = { (char *) "self",(char *) "s", NULL }; + PyObject *result = 0 ; if (!PyArg_ParseTupleAndKeywords(args,kwargs,(char *)"OO:Ldb_parse_ldif",kwnames,&obj0,&obj1)) SWIG_fail; res1 = SWIG_ConvertPtr(obj0, &argp1,SWIGTYPE_p_ldb_context, 0 | 0 ); @@ -5591,10 +5592,10 @@ fail: SWIGINTERN PyObject *_wrap_Ldb___repr__(PyObject *SWIGUNUSEDPARM(self), PyObject *args) { PyObject *resultobj = 0; ldb *arg1 = (ldb *) 0 ; - char *result = 0 ; void *argp1 = 0 ; int res1 = 0 ; PyObject *swig_obj[1] ; + char *result = 0 ; if (!args) SWIG_fail; swig_obj[0] = args; @@ -5628,7 +5629,6 @@ SWIGINTERN PyObject *Ldb_swiginit(PyObject *SWIGUNUSEDPARM(self), PyObject *args SWIGINTERN PyObject *_wrap_valid_attr_name(PyObject *SWIGUNUSEDPARM(self), PyObject *args, PyObject *kwargs) { PyObject *resultobj = 0; char *arg1 = (char *) 0 ; - int result; int res1 ; char *buf1 = 0 ; int alloc1 = 0 ; @@ -5636,6 +5636,7 @@ SWIGINTERN PyObject *_wrap_valid_attr_name(PyObject *SWIGUNUSEDPARM(self), PyObj char * kwnames[] = { (char *) "s", NULL }; + int result; if (!PyArg_ParseTupleAndKeywords(args,kwargs,(char *)"O:valid_attr_name",kwnames,&obj0)) SWIG_fail; res1 = SWIG_AsCharPtrAndSize(obj0, &buf1, NULL, &alloc1); @@ -5656,13 +5657,13 @@ fail: SWIGINTERN PyObject *_wrap_timestring(PyObject *SWIGUNUSEDPARM(self), PyObject *args, PyObject *kwargs) { PyObject *resultobj = 0; time_t arg1 ; - char *result = 0 ; unsigned long val1 ; int ecode1 = 0 ; PyObject * obj0 = 0 ; char * kwnames[] = { (char *) "t", NULL }; + char *result = 0 ; if (!PyArg_ParseTupleAndKeywords(args,kwargs,(char *)"O:timestring",kwnames,&obj0)) SWIG_fail; ecode1 = SWIG_AsVal_unsigned_SS_long(obj0, &val1); @@ -5681,7 +5682,6 @@ fail: SWIGINTERN PyObject *_wrap_string_to_time(PyObject *SWIGUNUSEDPARM(self), PyObject *args, PyObject *kwargs) { PyObject *resultobj = 0; char *arg1 = (char *) 0 ; - time_t result; int res1 ; char *buf1 = 0 ; int alloc1 = 0 ; @@ -5689,6 +5689,7 @@ SWIGINTERN PyObject *_wrap_string_to_time(PyObject *SWIGUNUSEDPARM(self), PyObje char * kwnames[] = { (char *) "s", NULL }; + time_t result; if (!PyArg_ParseTupleAndKeywords(args,kwargs,(char *)"O:string_to_time",kwnames,&obj0)) SWIG_fail; res1 = SWIG_AsCharPtrAndSize(obj0, &buf1, NULL, &alloc1); @@ -5709,11 +5710,11 @@ fail: SWIGINTERN PyObject *_wrap_register_module(PyObject *SWIGUNUSEDPARM(self), PyObject *args, PyObject *kwargs) { PyObject *resultobj = 0; struct ldb_module_ops *arg1 = (struct ldb_module_ops *) 0 ; - ldb_int_error result; PyObject * obj0 = 0 ; char * kwnames[] = { (char *)"arg1", NULL }; + ldb_int_error result; if (!PyArg_ParseTupleAndKeywords(args,kwargs,(char *)"O:register_module",kwnames,&obj0)) SWIG_fail; arg1 = talloc_zero(talloc_autofree_context(), struct ldb_module_ops); diff --git a/source4/lib/registry/registry.py b/source4/lib/registry/registry.py index 0aeefb86c1..e086a6ad37 100644 --- a/source4/lib/registry/registry.py +++ b/source4/lib/registry/registry.py @@ -1,5 +1,5 @@ # This file was automatically generated by SWIG (http://www.swig.org). -# Version 1.3.35 +# Version 1.3.36 # # Don't modify this file, modify the SWIG interface instead. diff --git a/source4/lib/registry/registry_wrap.c b/source4/lib/registry/registry_wrap.c index 3fc34b1fe3..809610fd1d 100644 --- a/source4/lib/registry/registry_wrap.c +++ b/source4/lib/registry/registry_wrap.c @@ -1,6 +1,6 @@ /* ---------------------------------------------------------------------------- * This file was automatically generated by SWIG (http://www.swig.org). - * Version 1.3.35 + * Version 1.3.36 * * This file is not intended to be easily readable and contains a number of * coding conventions designed to improve portability and efficiency. Do not make @@ -52,6 +52,12 @@ # endif #endif +#ifndef SWIG_MSC_UNSUPPRESS_4505 +# if defined(_MSC_VER) +# pragma warning(disable : 4505) /* unreferenced local function has been removed */ +# endif +#endif + #ifndef SWIGUNUSEDPARM # ifdef __cplusplus # define SWIGUNUSEDPARM(p) @@ -2533,7 +2539,7 @@ static swig_module_info swig_module = {swig_types, 26, 0, 0, 0, 0}; #define SWIG_name "_registry" -#define SWIGVERSION 0x010335 +#define SWIGVERSION 0x010336 #define SWIG_VERSION SWIGVERSION @@ -2886,13 +2892,13 @@ extern "C" { SWIGINTERN PyObject *_wrap_reg_get_predef_name(PyObject *SWIGUNUSEDPARM(self), PyObject *args, PyObject *kwargs) { PyObject *resultobj = 0; uint32_t arg1 ; - char *result = 0 ; unsigned int val1 ; int ecode1 = 0 ; PyObject * obj0 = 0 ; char * kwnames[] = { (char *) "hkey", NULL }; + char *result = 0 ; if (!PyArg_ParseTupleAndKeywords(args,kwargs,(char *)"O:reg_get_predef_name",kwnames,&obj0)) SWIG_fail; ecode1 = SWIG_AsVal_unsigned_SS_int(obj0, &val1); @@ -2911,13 +2917,13 @@ fail: SWIGINTERN PyObject *_wrap_str_regtype(PyObject *SWIGUNUSEDPARM(self), PyObject *args, PyObject *kwargs) { PyObject *resultobj = 0; int arg1 ; - char *result = 0 ; int val1 ; int ecode1 = 0 ; PyObject * obj0 = 0 ; char * kwnames[] = { (char *) "type", NULL }; + char *result = 0 ; if (!PyArg_ParseTupleAndKeywords(args,kwargs,(char *)"O:str_regtype",kwnames,&obj0)) SWIG_fail; ecode1 = SWIG_AsVal_int(obj0, &val1); @@ -2937,8 +2943,8 @@ SWIGINTERN PyObject *_wrap_Registry(PyObject *SWIGUNUSEDPARM(self), PyObject *ar PyObject *resultobj = 0; TALLOC_CTX *arg1 = (TALLOC_CTX *) 0 ; struct registry_context **arg2 = (struct registry_context **) 0 ; - WERROR result; struct registry_context *tmp2 ; + WERROR result; arg1 = NULL; arg2 = &tmp2; @@ -2962,7 +2968,6 @@ SWIGINTERN PyObject *_wrap_reg_get_predefined_key_by_name(PyObject *SWIGUNUSEDPA reg *arg1 = (reg *) 0 ; char *arg2 = (char *) 0 ; struct registry_key **arg3 = (struct registry_key **) 0 ; - WERROR result; void *argp1 = 0 ; int res1 = 0 ; int res2 ; @@ -2976,6 +2981,7 @@ SWIGINTERN PyObject *_wrap_reg_get_predefined_key_by_name(PyObject *SWIGUNUSEDPA char * kwnames[] = { (char *) "self",(char *) "name",(char *) "key", NULL }; + WERROR result; if (!PyArg_ParseTupleAndKeywords(args,kwargs,(char *)"OOO:reg_get_predefined_key_by_name",kwnames,&obj0,&obj1,&obj2)) SWIG_fail; res1 = SWIG_ConvertPtr(obj0, &argp1,SWIGTYPE_p_registry_context, 0 | 0 ); @@ -3012,7 +3018,6 @@ SWIGINTERN PyObject *_wrap_reg_key_del_abs(PyObject *SWIGUNUSEDPARM(self), PyObj PyObject *resultobj = 0; reg *arg1 = (reg *) 0 ; char *arg2 = (char *) 0 ; - WERROR result; void *argp1 = 0 ; int res1 = 0 ; int res2 ; @@ -3023,6 +3028,7 @@ SWIGINTERN PyObject *_wrap_reg_key_del_abs(PyObject *SWIGUNUSEDPARM(self), PyObj char * kwnames[] = { (char *) "self",(char *) "path", NULL }; + WERROR result; if (!PyArg_ParseTupleAndKeywords(args,kwargs,(char *)"OO:reg_key_del_abs",kwnames,&obj0,&obj1)) SWIG_fail; res1 = SWIG_ConvertPtr(obj0, &argp1,SWIGTYPE_p_registry_context, 0 | 0 ); @@ -3055,7 +3061,6 @@ SWIGINTERN PyObject *_wrap_reg_get_predefined_key(PyObject *SWIGUNUSEDPARM(self) reg *arg1 = (reg *) 0 ; uint32_t arg2 ; struct registry_key **arg3 = (struct registry_key **) 0 ; - WERROR result; void *argp1 = 0 ; int res1 = 0 ; unsigned int val2 ; @@ -3068,6 +3073,7 @@ SWIGINTERN PyObject *_wrap_reg_get_predefined_key(PyObject *SWIGUNUSEDPARM(self) char * kwnames[] = { (char *) "self",(char *) "hkey_id",(char *) "key", NULL }; + WERROR result; if (!PyArg_ParseTupleAndKeywords(args,kwargs,(char *)"OOO:reg_get_predefined_key",kwnames,&obj0,&obj1,&obj2)) SWIG_fail; res1 = SWIG_ConvertPtr(obj0, &argp1,SWIGTYPE_p_registry_context, 0 | 0 ); @@ -3102,7 +3108,6 @@ SWIGINTERN PyObject *_wrap_reg_diff_apply(PyObject *SWIGUNUSEDPARM(self), PyObje PyObject *resultobj = 0; reg *arg1 = (reg *) 0 ; char *arg2 = (char *) 0 ; - WERROR result; void *argp1 = 0 ; int res1 = 0 ; int res2 ; @@ -3113,6 +3118,7 @@ SWIGINTERN PyObject *_wrap_reg_diff_apply(PyObject *SWIGUNUSEDPARM(self), PyObje char * kwnames[] = { (char *) "self",(char *) "filename", NULL }; + WERROR result; if (!PyArg_ParseTupleAndKeywords(args,kwargs,(char *)"OO:reg_diff_apply",kwnames,&obj0,&obj1)) SWIG_fail; res1 = SWIG_ConvertPtr(obj0, &argp1,SWIGTYPE_p_registry_context, 0 | 0 ); @@ -3146,7 +3152,6 @@ SWIGINTERN PyObject *_wrap_reg_generate_diff(PyObject *SWIGUNUSEDPARM(self), PyO struct registry_context *arg2 = (struct registry_context *) 0 ; struct reg_diff_callbacks *arg3 = (struct reg_diff_callbacks *) 0 ; void *arg4 = (void *) 0 ; - WERROR result; void *argp1 = 0 ; int res1 = 0 ; void *argp2 = 0 ; @@ -3161,6 +3166,7 @@ SWIGINTERN PyObject *_wrap_reg_generate_diff(PyObject *SWIGUNUSEDPARM(self), PyO char * kwnames[] = { (char *) "self",(char *) "ctx2",(char *) "callbacks",(char *) "callback_data", NULL }; + WERROR result; if (!PyArg_ParseTupleAndKeywords(args,kwargs,(char *)"OOOO:reg_generate_diff",kwnames,&obj0,&obj1,&obj2,&obj3)) SWIG_fail; res1 = SWIG_ConvertPtr(obj0, &argp1,SWIGTYPE_p_registry_context, 0 | 0 ); @@ -3201,13 +3207,13 @@ SWIGINTERN PyObject *_wrap_reg_mount_hive__SWIG_0(PyObject *SWIGUNUSEDPARM(self) struct hive_key *arg2 = (struct hive_key *) 0 ; uint32_t arg3 ; char **arg4 = (char **) NULL ; - WERROR result; void *argp1 = 0 ; int res1 = 0 ; void *argp2 = 0 ; int res2 = 0 ; unsigned int val3 ; int ecode3 = 0 ; + WERROR result; if ((nobjs < 3) || (nobjs > 4)) SWIG_fail; res1 = SWIG_ConvertPtr(swig_obj[0], &argp1,SWIGTYPE_p_registry_context, 0 | 0 ); @@ -3268,7 +3274,6 @@ SWIGINTERN PyObject *_wrap_reg_import_hive_key(PyObject *SWIGUNUSEDPARM(self), P struct hive_key *arg2 = (struct hive_key *) 0 ; uint32_t arg3 ; char **arg4 = (char **) 0 ; - struct registry_key *result = 0 ; void *argp1 = 0 ; int res1 = 0 ; void *argp2 = 0 ; @@ -3282,6 +3287,7 @@ SWIGINTERN PyObject *_wrap_reg_import_hive_key(PyObject *SWIGUNUSEDPARM(self), P char * kwnames[] = { (char *) "self",(char *) "hive",(char *) "predef_key",(char *) "elements", NULL }; + struct registry_key *result = 0 ; if (!PyArg_ParseTupleAndKeywords(args,kwargs,(char *)"OOOO:reg_import_hive_key",kwnames,&obj0,&obj1,&obj2,&obj3)) SWIG_fail; res1 = SWIG_ConvertPtr(obj0, &argp1,SWIGTYPE_p_registry_context, 0 | 0 ); @@ -3334,7 +3340,6 @@ SWIGINTERN PyObject *_wrap_reg_mount_hive__SWIG_1(PyObject *SWIGUNUSEDPARM(self) reg *arg1 = (reg *) 0 ; struct hive_key *arg2 = (struct hive_key *) 0 ; char *arg3 = (char *) 0 ; - WERROR result; void *argp1 = 0 ; int res1 = 0 ; void *argp2 = 0 ; @@ -3342,6 +3347,7 @@ SWIGINTERN PyObject *_wrap_reg_mount_hive__SWIG_1(PyObject *SWIGUNUSEDPARM(self) int res3 ; char *buf3 = 0 ; int alloc3 = 0 ; + WERROR result; if ((nobjs < 3) || (nobjs > 3)) SWIG_fail; res1 = SWIG_ConvertPtr(swig_obj[0], &argp1,SWIGTYPE_p_registry_context, 0 | 0 ); @@ -3434,7 +3440,6 @@ SWIGINTERN PyObject *_wrap_delete_reg(PyObject *SWIGUNUSEDPARM(self), PyObject * } arg1 = (reg *)(argp1); free((char *) arg1); - resultobj = SWIG_Py_Void(); return resultobj; fail: @@ -3462,7 +3467,6 @@ SWIGINTERN PyObject *_wrap_hive_key(PyObject *SWIGUNUSEDPARM(self), PyObject *ar struct event_context *arg5 = (struct event_context *) 0 ; struct loadparm_context *arg6 = (struct loadparm_context *) 0 ; struct hive_key **arg7 = (struct hive_key **) 0 ; - WERROR result; int res2 ; char *buf2 = 0 ; int alloc2 = 0 ; @@ -3483,10 +3487,11 @@ SWIGINTERN PyObject *_wrap_hive_key(PyObject *SWIGUNUSEDPARM(self), PyObject *ar char * kwnames[] = { (char *) "location",(char *) "session_info",(char *) "credentials",(char *) "ev_ctx",(char *) "lp_ctx", NULL }; + WERROR result; arg3 = NULL; arg4 = NULL; - arg5 = s4_event_context_init(NULL); + arg5 = event_context_init(NULL); arg6 = loadparm_init(NULL); arg1 = NULL; arg7 = &tmp7; @@ -3550,7 +3555,6 @@ SWIGINTERN PyObject *_wrap_open_ldb(PyObject *SWIGUNUSEDPARM(self), PyObject *ar struct event_context *arg5 = (struct event_context *) 0 ; struct loadparm_context *arg6 = (struct loadparm_context *) 0 ; struct hive_key **arg7 = (struct hive_key **) 0 ; - WERROR result; int res2 ; char *buf2 = 0 ; int alloc2 = 0 ; @@ -3571,10 +3575,11 @@ SWIGINTERN PyObject *_wrap_open_ldb(PyObject *SWIGUNUSEDPARM(self), PyObject *ar char * kwnames[] = { (char *) "location",(char *) "session_info",(char *) "credentials",(char *) "ev_ctx",(char *) "lp_ctx", NULL }; + WERROR result; arg3 = NULL; arg4 = NULL; - arg5 = s4_event_context_init(NULL); + arg5 = event_context_init(NULL); arg6 = loadparm_init(NULL); arg1 = NULL; arg7 = &tmp7; @@ -3634,7 +3639,6 @@ SWIGINTERN PyObject *_wrap_create_dir(PyObject *SWIGUNUSEDPARM(self), PyObject * TALLOC_CTX *arg1 = (TALLOC_CTX *) 0 ; char *arg2 = (char *) 0 ; struct hive_key **arg3 = (struct hive_key **) 0 ; - WERROR result; int res2 ; char *buf2 = 0 ; int alloc2 = 0 ; @@ -3643,6 +3647,7 @@ SWIGINTERN PyObject *_wrap_create_dir(PyObject *SWIGUNUSEDPARM(self), PyObject * char * kwnames[] = { (char *) "location", NULL }; + WERROR result; arg1 = NULL; arg3 = &tmp3; @@ -3674,7 +3679,6 @@ SWIGINTERN PyObject *_wrap_open_dir(PyObject *SWIGUNUSEDPARM(self), PyObject *ar TALLOC_CTX *arg1 = (TALLOC_CTX *) 0 ; char *arg2 = (char *) 0 ; struct hive_key **arg3 = (struct hive_key **) 0 ; - WERROR result; int res2 ; char *buf2 = 0 ; int alloc2 = 0 ; @@ -3683,6 +3687,7 @@ SWIGINTERN PyObject *_wrap_open_dir(PyObject *SWIGUNUSEDPARM(self), PyObject *ar char * kwnames[] = { (char *) "location", NULL }; + WERROR result; arg1 = NULL; arg3 = &tmp3; @@ -3717,7 +3722,6 @@ SWIGINTERN PyObject *_wrap_open_samba(PyObject *SWIGUNUSEDPARM(self), PyObject * struct loadparm_context *arg4 = (struct loadparm_context *) 0 ; struct auth_session_info *arg5 = (struct auth_session_info *) 0 ; struct cli_credentials *arg6 = (struct cli_credentials *) 0 ; - WERROR result; struct registry_context *tmp2 ; void *argp3 = 0 ; int res3 = 0 ; @@ -3734,8 +3738,9 @@ SWIGINTERN PyObject *_wrap_open_samba(PyObject *SWIGUNUSEDPARM(self), PyObject * char * kwnames[] = { (char *) "ev_ctx",(char *) "lp_ctx",(char *) "session_info",(char *) "credentials", NULL }; + WERROR result; - arg3 = s4_event_context_init(NULL); + arg3 = event_context_init(NULL); arg4 = loadparm_init(NULL); arg5 = NULL; arg6 = NULL; diff --git a/source4/scripting/python/misc.i b/source4/scripting/python/misc.i index 1d331215b5..f0bc156abd 100644 --- a/source4/scripting/python/misc.i +++ b/source4/scripting/python/misc.i @@ -100,3 +100,16 @@ bool dsdb_set_ntds_invocation_id(struct ldb_context *ldb, const char *guid) char *private_path(TALLOC_CTX* mem_ctx, struct loadparm_context *lp_ctx, const char *name); +typedef unsigned long time_t; + +/* + convert from unix time to NT time +*/ +%inline %{ +uint64_t unix2nttime(time_t t) +{ + NTTIME nt; + unix_to_nt_time(&nt, t); + return (uint64_t)nt; +} +%} diff --git a/source4/scripting/python/misc.py b/source4/scripting/python/misc.py index 0c14944001..e52d7df11d 100644 --- a/source4/scripting/python/misc.py +++ b/source4/scripting/python/misc.py @@ -1,5 +1,5 @@ # This file was automatically generated by SWIG (http://www.swig.org). -# Version 1.3.35 +# Version 1.3.36 # # Don't modify this file, modify the SWIG interface instead. @@ -118,5 +118,6 @@ def ldb_register_samba_handlers(*args, **kwargs): return _misc.ldb_register_samba_handlers(*args, **kwargs) dsdb_set_ntds_invocation_id = _misc.dsdb_set_ntds_invocation_id private_path = _misc.private_path +unix2nttime = _misc.unix2nttime diff --git a/source4/scripting/python/misc_wrap.c b/source4/scripting/python/misc_wrap.c index 888918ef53..4b5bfb0174 100644 --- a/source4/scripting/python/misc_wrap.c +++ b/source4/scripting/python/misc_wrap.c @@ -1,6 +1,6 @@ /* ---------------------------------------------------------------------------- * This file was automatically generated by SWIG (http://www.swig.org). - * Version 1.3.35 + * Version 1.3.36 * * This file is not intended to be easily readable and contains a number of * coding conventions designed to improve portability and efficiency. Do not make @@ -52,6 +52,12 @@ # endif #endif +#ifndef SWIG_MSC_UNSUPPRESS_4505 +# if defined(_MSC_VER) +# pragma warning(disable : 4505) /* unreferenced local function has been removed */ +# endif +#endif + #ifndef SWIGUNUSEDPARM # ifdef __cplusplus # define SWIGUNUSEDPARM(p) @@ -2537,7 +2543,7 @@ static swig_module_info swig_module = {swig_types, 27, 0, 0, 0, 0}; #define SWIG_name "_misc" -#define SWIGVERSION 0x010335 +#define SWIGVERSION 0x010336 #define SWIG_VERSION SWIGVERSION @@ -2826,6 +2832,40 @@ bool dsdb_set_ntds_invocation_id(struct ldb_context *ldb, const char *guid) return samdb_set_ntds_invocation_id(ldb, &invocation_id_in); } + +uint64_t unix2nttime(time_t t) +{ + NTTIME nt; + unix_to_nt_time(&nt, t); + return (uint64_t)nt; +} + + +#include +#if !defined(SWIG_NO_LLONG_MAX) +# if !defined(LLONG_MAX) && defined(__GNUC__) && defined (__LONG_LONG_MAX__) +# define LLONG_MAX __LONG_LONG_MAX__ +# define LLONG_MIN (-LLONG_MAX - 1LL) +# define ULLONG_MAX (LLONG_MAX * 2ULL + 1ULL) +# endif +#endif + + +SWIGINTERNINLINE PyObject* +SWIG_From_long_SS_long (long long value) +{ + return ((value < LONG_MIN) || (value > LONG_MAX)) ? + PyLong_FromLongLong(value) : PyInt_FromLong((long)(value)); +} + + +SWIGINTERNINLINE PyObject* +SWIG_From_unsigned_SS_long_SS_long (unsigned long long value) +{ + return (value > LONG_MAX) ? + PyLong_FromUnsignedLongLong(value) : PyInt_FromLong((long)(value)); +} + #ifdef __cplusplus extern "C" { #endif @@ -2833,13 +2873,13 @@ SWIGINTERN PyObject *_wrap_random_password(PyObject *SWIGUNUSEDPARM(self), PyObj PyObject *resultobj = 0; TALLOC_CTX *arg1 = (TALLOC_CTX *) 0 ; size_t arg2 ; - char *result = 0 ; size_t val2 ; int ecode2 = 0 ; PyObject * obj0 = 0 ; char * kwnames[] = { (char *) "len", NULL }; + char *result = 0 ; arg1 = NULL; if (!PyArg_ParseTupleAndKeywords(args,kwargs,(char *)"O:random_password",kwnames,&obj0)) SWIG_fail; @@ -2974,7 +3014,6 @@ SWIGINTERN PyObject *_wrap_samdb_set_domain_sid(PyObject *SWIGUNUSEDPARM(self), PyObject *resultobj = 0; struct ldb_context *arg1 = (struct ldb_context *) 0 ; struct dom_sid *arg2 = (struct dom_sid *) 0 ; - bool result; void *argp1 = 0 ; int res1 = 0 ; void *argp2 = 0 ; @@ -2984,6 +3023,7 @@ SWIGINTERN PyObject *_wrap_samdb_set_domain_sid(PyObject *SWIGUNUSEDPARM(self), char * kwnames[] = { (char *) "ldb",(char *) "dom_sid_in", NULL }; + bool result; if (!PyArg_ParseTupleAndKeywords(args,kwargs,(char *)"OO:samdb_set_domain_sid",kwnames,&obj0,&obj1)) SWIG_fail; res1 = SWIG_ConvertPtr(obj0, &argp1,SWIGTYPE_p_ldb_context, 0 | 0 ); @@ -3012,7 +3052,6 @@ SWIGINTERN PyObject *_wrap_dsdb_attach_schema_from_ldif_file(PyObject *SWIGUNUSE struct ldb_context *arg1 = (struct ldb_context *) 0 ; char *arg2 = (char *) 0 ; char *arg3 = (char *) 0 ; - WERROR result; void *argp1 = 0 ; int res1 = 0 ; int res2 ; @@ -3027,6 +3066,7 @@ SWIGINTERN PyObject *_wrap_dsdb_attach_schema_from_ldif_file(PyObject *SWIGUNUSE char * kwnames[] = { (char *) "ldb",(char *) "pf",(char *) "df", NULL }; + WERROR result; if (!PyArg_ParseTupleAndKeywords(args,kwargs,(char *)"OOO:dsdb_attach_schema_from_ldif_file",kwnames,&obj0,&obj1,&obj2)) SWIG_fail; res1 = SWIG_ConvertPtr(obj0, &argp1,SWIGTYPE_p_ldb_context, 0 | 0 ); @@ -3080,13 +3120,13 @@ fail: SWIGINTERN PyObject *_wrap_dsdb_set_global_schema(PyObject *SWIGUNUSEDPARM(self), PyObject *args, PyObject *kwargs) { PyObject *resultobj = 0; struct ldb_context *arg1 = (struct ldb_context *) 0 ; - int result; void *argp1 = 0 ; int res1 = 0 ; PyObject * obj0 = 0 ; char * kwnames[] = { (char *) "ldb", NULL }; + int result; if (!PyArg_ParseTupleAndKeywords(args,kwargs,(char *)"O:dsdb_set_global_schema",kwnames,&obj0)) SWIG_fail; res1 = SWIG_ConvertPtr(obj0, &argp1,SWIGTYPE_p_ldb_context, 0 | 0 ); @@ -3108,13 +3148,13 @@ fail: SWIGINTERN PyObject *_wrap_ldb_register_samba_handlers(PyObject *SWIGUNUSEDPARM(self), PyObject *args, PyObject *kwargs) { PyObject *resultobj = 0; struct ldb_context *arg1 = (struct ldb_context *) 0 ; - int result; void *argp1 = 0 ; int res1 = 0 ; PyObject * obj0 = 0 ; char * kwnames[] = { (char *) "ldb", NULL }; + int result; if (!PyArg_ParseTupleAndKeywords(args,kwargs,(char *)"O:ldb_register_samba_handlers",kwnames,&obj0)) SWIG_fail; res1 = SWIG_ConvertPtr(obj0, &argp1,SWIGTYPE_p_ldb_context, 0 | 0 ); @@ -3137,7 +3177,6 @@ SWIGINTERN PyObject *_wrap_dsdb_set_ntds_invocation_id(PyObject *SWIGUNUSEDPARM( PyObject *resultobj = 0; struct ldb_context *arg1 = (struct ldb_context *) 0 ; char *arg2 = (char *) 0 ; - bool result; void *argp1 = 0 ; int res1 = 0 ; int res2 ; @@ -3148,6 +3187,7 @@ SWIGINTERN PyObject *_wrap_dsdb_set_ntds_invocation_id(PyObject *SWIGUNUSEDPARM( char * kwnames[] = { (char *) "ldb",(char *) "guid", NULL }; + bool result; if (!PyArg_ParseTupleAndKeywords(args,kwargs,(char *)"OO:dsdb_set_ntds_invocation_id",kwnames,&obj0,&obj1)) SWIG_fail; res1 = SWIG_ConvertPtr(obj0, &argp1,SWIGTYPE_p_ldb_context, 0 | 0 ); @@ -3178,7 +3218,6 @@ SWIGINTERN PyObject *_wrap_private_path(PyObject *SWIGUNUSEDPARM(self), PyObject TALLOC_CTX *arg1 = (TALLOC_CTX *) 0 ; struct loadparm_context *arg2 = (struct loadparm_context *) 0 ; char *arg3 = (char *) 0 ; - char *result = 0 ; void *argp2 = 0 ; int res2 = 0 ; int res3 ; @@ -3189,6 +3228,7 @@ SWIGINTERN PyObject *_wrap_private_path(PyObject *SWIGUNUSEDPARM(self), PyObject char * kwnames[] = { (char *) "lp_ctx",(char *) "name", NULL }; + char *result = 0 ; arg2 = loadparm_init(NULL); arg1 = NULL; @@ -3217,6 +3257,31 @@ fail: } +SWIGINTERN PyObject *_wrap_unix2nttime(PyObject *SWIGUNUSEDPARM(self), PyObject *args, PyObject *kwargs) { + PyObject *resultobj = 0; + time_t arg1 ; + unsigned long val1 ; + int ecode1 = 0 ; + PyObject * obj0 = 0 ; + char * kwnames[] = { + (char *) "t", NULL + }; + uint64_t result; + + if (!PyArg_ParseTupleAndKeywords(args,kwargs,(char *)"O:unix2nttime",kwnames,&obj0)) SWIG_fail; + ecode1 = SWIG_AsVal_unsigned_SS_long(obj0, &val1); + if (!SWIG_IsOK(ecode1)) { + SWIG_exception_fail(SWIG_ArgError(ecode1), "in method '" "unix2nttime" "', argument " "1"" of type '" "time_t""'"); + } + arg1 = (time_t)(val1); + result = (uint64_t)unix2nttime(arg1); + resultobj = SWIG_From_unsigned_SS_long_SS_long((unsigned long long)(result)); + return resultobj; +fail: + return NULL; +} + + static PyMethodDef SwigMethods[] = { { (char *)"random_password", (PyCFunction) _wrap_random_password, METH_VARARGS | METH_KEYWORDS, (char *)"\n" "S.random_password(len) -> string\n" @@ -3250,6 +3315,7 @@ static PyMethodDef SwigMethods[] = { ""}, { (char *)"dsdb_set_ntds_invocation_id", (PyCFunction) _wrap_dsdb_set_ntds_invocation_id, METH_VARARGS | METH_KEYWORDS, NULL}, { (char *)"private_path", (PyCFunction) _wrap_private_path, METH_VARARGS | METH_KEYWORDS, NULL}, + { (char *)"unix2nttime", (PyCFunction) _wrap_unix2nttime, METH_VARARGS | METH_KEYWORDS, NULL}, { NULL, NULL, 0, NULL } }; diff --git a/source4/scripting/python/samba/samdb.py b/source4/scripting/python/samba/samdb.py index c7d93d6aff..4a64c2f76d 100644 --- a/source4/scripting/python/samba/samdb.py +++ b/source4/scripting/python/samba/samdb.py @@ -27,6 +27,7 @@ import misc import ldb from samba.idmap import IDmapDB import pwd +import time __docformat__ = "restructuredText" @@ -192,3 +193,35 @@ userPassword: %s :param invocation_id: GUID of the invocation id. """ misc.dsdb_set_ntds_invocation_id(self, invocation_id) + + def setexpiry(self, user, expiry_seconds, noexpiry): + """Set the password expiry for a user + + :param expiry_seconds: expiry time from now in seconds + :param noexpiry: if set, then don't expire password + """ + self.transaction_start(); + res = self.search(base=self.domain_dn(), scope=ldb.SCOPE_SUBTREE, + expression=("(samAccountName=%s)" % user), + attrs=["userAccountControl", "accountExpires"]) + assert len(res) == 1 + userAccountControl = int(res[0]["userAccountControl"][0]) + accountExpires = int(res[0]["accountExpires"][0]) + if noexpiry: + userAccountControl = userAccountControl | 0x10000 + accountExpires = 0 + else: + userAccountControl = userAccountControl & ~0x10000 + accountExpires = misc.unix2nttime(expiry_seconds + int(time.time())) + + mod = """ +dn: %s +changetype: modify +replace: userAccountControl +userAccountControl: %u +replace: accountExpires +accountExpires: %u +""" % (res[0].dn, userAccountControl, accountExpires) + # now change the database + self.modify_ldif(mod) + self.transaction_commit(); diff --git a/source4/setup/tests/blackbox_newuser.sh b/source4/setup/tests/blackbox_newuser.sh index 3e534f2b52..d25c70669b 100755 --- a/source4/setup/tests/blackbox_newuser.sh +++ b/source4/setup/tests/blackbox_newuser.sh @@ -15,6 +15,18 @@ shift 1 testit "simple-dc" $PYTHON ./setup/provision --server-role="dc" --domain=FOO --realm=foo.example.com --domain-sid=S-1-5-21-4177067393-1453636373-93818738 --targetdir=$PREFIX/simple-dc -testit "newuser" $PYTHON ./setup/newuser --configfile=$PREFIX/simple-dc/etc/smb.conf testuser testpass +CONFIG="--configfile=$PREFIX/simple-dc/etc/smb.conf" + +testit "newuser" $PYTHON ./setup/newuser $CONFIG testuser testpass + +# check the enable account script +testit "enableaccount" $PYTHON ./setup/enableaccount $CONFIG testuser + +# check the enable account script +testit "setpassword" $PYTHON ./setup/setpassword $CONFIG testuser --newpassword=testpass2 + +# check the setexpiry script +testit "noexpiry" $PYTHON ./setup/setexpiry $CONFIG testuser --noexpiry +testit "expiry" $PYTHON ./setup/setexpiry $CONFIG testuser --days=7 exit $failed -- cgit From 0d0fddf8ae856efd7ffb07ba8fa32d2f55d3f9c0 Mon Sep 17 00:00:00 2001 From: Jeremy Allison Date: Fri, 5 Sep 2008 14:24:36 -0700 Subject: Added tests that show that write time update is immediate when changing file size using SMBwrite of size zero, SET_END_OF_FILE, or SET_ALLOCATION_SIZE - no 2 second delay in these cases. Jeremy. (This used to be commit 3aa7523d7750fe30d1e6bb5a75ac42b681b9e493) --- source4/torture/basic/delaywrite.c | 348 ++++++++++++++++++++++++++++++++++++- 1 file changed, 347 insertions(+), 1 deletion(-) diff --git a/source4/torture/basic/delaywrite.c b/source4/torture/basic/delaywrite.c index c03e89d36e..6dfe410386 100644 --- a/source4/torture/basic/delaywrite.c +++ b/source4/torture/basic/delaywrite.c @@ -128,7 +128,350 @@ static bool test_delayed_write_update(struct torture_context *tctx, struct smbcl return ret; } -/* +/* Updating with a SMBwrite of zero length + * changes the write time immediately - even on expand. */ + +static bool test_delayed_write_update1a(struct torture_context *tctx, struct smbcli_state *cli) +{ + union smb_fileinfo finfo1, finfo2; + const char *fname = BASEDIR "\\torture_file1a.txt"; + NTSTATUS status; + int fnum1 = -1; + bool ret = true; + ssize_t written; + struct timeval start; + struct timeval end; + int used_delay = torture_setting_int(tctx, "writetimeupdatedelay", 2000000); + int normal_delay = 2000000; + double sec = ((double)used_delay) / ((double)normal_delay); + int msec = 1000 * sec; + char buf[2048]; + + if (!torture_setup_dir(cli, BASEDIR)) { + return false; + } + + fnum1 = smbcli_open(cli->tree, fname, O_RDWR|O_CREAT, DENY_NONE); + if (fnum1 == -1) { + torture_comment(tctx, "Failed to open %s\n", fname); + return false; + } + + memset(buf, 'x', 2048); + written = smbcli_write(cli->tree, fnum1, 0, buf, 0, 2048); + + /* 3 second delay to ensure we get past any 2 second time + granularity (older systems may have that) */ + msleep(3 * msec); + + finfo1.all_info.level = RAW_FILEINFO_ALL_INFO; + finfo1.all_info.in.file.fnum = fnum1; + finfo2 = finfo1; + + status = smb_raw_fileinfo(cli->tree, tctx, &finfo1); + + if (!NT_STATUS_IS_OK(status)) { + DEBUG(0, ("fileinfo failed: %s\n", nt_errstr(status))); + return false; + } + + torture_comment(tctx, "Initial write time %s\n", + nt_time_string(tctx, finfo1.all_info.out.write_time)); + + /* Do a zero length SMBwrite call to truncate. */ + written = smbcli_smbwrite(cli->tree, fnum1, "x", 10240, 0); + + if (written != 0) { + torture_comment(tctx, "write failed - wrote %d bytes (%s)\n", + (int)written, __location__); + return false; + } + + start = timeval_current(); + end = timeval_add(&start, (120*sec), 0); + while (!timeval_expired(&end)) { + status = smb_raw_fileinfo(cli->tree, tctx, &finfo2); + + if (!NT_STATUS_IS_OK(status)) { + DEBUG(0, ("fileinfo failed: %s\n", nt_errstr(status))); + ret = false; + break; + } + + if (finfo2.all_info.out.size != 10240) { + DEBUG(0, ("file not truncated\n")); + ret = false; + break; + } + + torture_comment(tctx, "write time %s\n", + nt_time_string(tctx, finfo2.all_info.out.write_time)); + if (finfo1.all_info.out.write_time != finfo2.all_info.out.write_time) { + double diff = timeval_elapsed(&start); + if (diff > (0.25 * sec * 0.75)) { /* 0.75 to cope with vmware timing */ + torture_comment(tctx, "After SMBwrite truncate " + "server updated write_time after %.2f seconds" + "(1 sec == %.2f)(wrong!)\n", + diff, sec); + ret = false; + break; + } + + torture_comment(tctx, "After SMBwrite truncate " + "server updated write_time after %.2f seconds" + "(1 sec == %.2f)(correct)\n", + diff, sec); + break; + } + fflush(stdout); + msleep(1 * msec); + } + + if (finfo1.all_info.out.write_time == finfo2.all_info.out.write_time) { + torture_comment(tctx, "Server did not update write time (wrong!)\n"); + ret = false; + } + + + if (fnum1 != -1) + smbcli_close(cli->tree, fnum1); + smbcli_unlink(cli->tree, fname); + smbcli_deltree(cli->tree, BASEDIR); + + return ret; +} + +/* Updating with a SET_FILE_END_OF_FILE_INFO + * changes the write time immediately - even on expand. */ + +static bool test_delayed_write_update1b(struct torture_context *tctx, struct smbcli_state *cli) +{ + union smb_fileinfo finfo1, finfo2; + const char *fname = BASEDIR "\\torture_file1b.txt"; + NTSTATUS status; + int fnum1 = -1; + bool ret = true; + ssize_t written; + struct timeval start; + struct timeval end; + int used_delay = torture_setting_int(tctx, "writetimeupdatedelay", 2000000); + int normal_delay = 2000000; + double sec = ((double)used_delay) / ((double)normal_delay); + int msec = 1000 * sec; + char buf[2048]; + + if (!torture_setup_dir(cli, BASEDIR)) { + return false; + } + + fnum1 = smbcli_open(cli->tree, fname, O_RDWR|O_CREAT, DENY_NONE); + if (fnum1 == -1) { + torture_comment(tctx, "Failed to open %s\n", fname); + return false; + } + + memset(buf, 'x', 2048); + written = smbcli_write(cli->tree, fnum1, 0, buf, 0, 2048); + + /* 3 second delay to ensure we get past any 2 second time + granularity (older systems may have that) */ + msleep(3 * msec); + + finfo1.all_info.level = RAW_FILEINFO_ALL_INFO; + finfo1.all_info.in.file.fnum = fnum1; + finfo2 = finfo1; + + status = smb_raw_fileinfo(cli->tree, tctx, &finfo1); + + if (!NT_STATUS_IS_OK(status)) { + DEBUG(0, ("fileinfo failed: %s\n", nt_errstr(status))); + return false; + } + + torture_comment(tctx, "Initial write time %s\n", + nt_time_string(tctx, finfo1.all_info.out.write_time)); + + /* Do a SET_END_OF_FILE_INFO call to truncate. */ + status = smbcli_ftruncate(cli->tree, fnum1, (uint64_t)10240); + + if (!NT_STATUS_IS_OK(status)) { + torture_comment(tctx, "SET_END_OF_FILE failed (%s)\n", + nt_errstr(status)); + return false; + } + + start = timeval_current(); + end = timeval_add(&start, (120*sec), 0); + while (!timeval_expired(&end)) { + status = smb_raw_fileinfo(cli->tree, tctx, &finfo2); + + if (!NT_STATUS_IS_OK(status)) { + DEBUG(0, ("fileinfo failed: %s\n", nt_errstr(status))); + ret = false; + break; + } + + if (finfo2.all_info.out.size != 10240) { + DEBUG(0, ("file not truncated\n")); + ret = false; + break; + } + + torture_comment(tctx, "write time %s\n", + nt_time_string(tctx, finfo2.all_info.out.write_time)); + if (finfo1.all_info.out.write_time != finfo2.all_info.out.write_time) { + double diff = timeval_elapsed(&start); + if (diff > (0.25 * sec * 0.75)) { /* 0.75 to cope with vmware timing */ + torture_comment(tctx, "After SET_END_OF_FILE truncate " + "server updated write_time after %.2f seconds" + "(1 sec == %.2f)(wrong!)\n", + diff, sec); + ret = false; + break; + } + + torture_comment(tctx, "After SET_END_OF_FILE truncate " + "server updated write_time after %.2f seconds" + "(1 sec == %.2f)(correct)\n", + diff, sec); + break; + } + fflush(stdout); + msleep(1 * msec); + } + + if (finfo1.all_info.out.write_time == finfo2.all_info.out.write_time) { + torture_comment(tctx, "Server did not update write time (wrong!)\n"); + ret = false; + } + + + if (fnum1 != -1) + smbcli_close(cli->tree, fnum1); + smbcli_unlink(cli->tree, fname); + smbcli_deltree(cli->tree, BASEDIR); + + return ret; +} + +/* Updating with a SET_ALLOCATION_INFO (truncate) does so immediately. */ + +static bool test_delayed_write_update1c(struct torture_context *tctx, struct smbcli_state *cli) +{ + union smb_setfileinfo parms; + union smb_fileinfo finfo1, finfo2; + const char *fname = BASEDIR "\\torture_file1c.txt"; + NTSTATUS status; + int fnum1 = -1; + bool ret = true; + ssize_t written; + struct timeval start; + struct timeval end; + int used_delay = torture_setting_int(tctx, "writetimeupdatedelay", 2000000); + int normal_delay = 2000000; + double sec = ((double)used_delay) / ((double)normal_delay); + int msec = 1000 * sec; + char buf[2048]; + + if (!torture_setup_dir(cli, BASEDIR)) { + return false; + } + + fnum1 = smbcli_open(cli->tree, fname, O_RDWR|O_CREAT, DENY_NONE); + if (fnum1 == -1) { + torture_comment(tctx, "Failed to open %s\n", fname); + return false; + } + + memset(buf, 'x', 2048); + written = smbcli_write(cli->tree, fnum1, 0, buf, 0, 2048); + + /* 3 second delay to ensure we get past any 2 second time + granularity (older systems may have that) */ + msleep(3 * msec); + + finfo1.all_info.level = RAW_FILEINFO_ALL_INFO; + finfo1.all_info.in.file.fnum = fnum1; + finfo2 = finfo1; + + status = smb_raw_fileinfo(cli->tree, tctx, &finfo1); + + if (!NT_STATUS_IS_OK(status)) { + DEBUG(0, ("fileinfo failed: %s\n", nt_errstr(status))); + return false; + } + + torture_comment(tctx, "Initial write time %s\n", + nt_time_string(tctx, finfo1.all_info.out.write_time)); + + /* Do a SET_ALLOCATION_SIZE call to truncate. */ + parms.allocation_info.level = RAW_SFILEINFO_ALLOCATION_INFO; + parms.allocation_info.in.file.fnum = fnum1; + parms.allocation_info.in.alloc_size = 0; + + status = smb_raw_setfileinfo(cli->tree, &parms); + + if (!NT_STATUS_IS_OK(status)) { + torture_comment(tctx, "RAW_SFILEINFO_ALLOCATION_INFO failed (%s)\n", + nt_errstr(status)); + return false; + } + + start = timeval_current(); + end = timeval_add(&start, (120*sec), 0); + while (!timeval_expired(&end)) { + status = smb_raw_fileinfo(cli->tree, tctx, &finfo2); + + if (!NT_STATUS_IS_OK(status)) { + DEBUG(0, ("fileinfo failed: %s\n", nt_errstr(status))); + ret = false; + break; + } + + if (finfo2.all_info.out.size != 0) { + DEBUG(0, ("file not truncated\n")); + ret = false; + break; + } + + torture_comment(tctx, "write time %s\n", + nt_time_string(tctx, finfo2.all_info.out.write_time)); + if (finfo1.all_info.out.write_time != finfo2.all_info.out.write_time) { + double diff = timeval_elapsed(&start); + if (diff > (0.25 * sec * 0.75)) { /* 0.75 to cope with vmware timing */ + torture_comment(tctx, "After SET_ALLOCATION_INFO truncate " + "server updated write_time after %.2f seconds" + "(1 sec == %.2f)(wrong!)\n", + diff, sec); + ret = false; + break; + } + + torture_comment(tctx, "After SET_ALLOCATION_INFO truncate " + "server updated write_time after %.2f seconds" + "(1 sec == %.2f)(correct)\n", + diff, sec); + break; + } + fflush(stdout); + msleep(1 * msec); + } + + if (finfo1.all_info.out.write_time == finfo2.all_info.out.write_time) { + torture_comment(tctx, "Server did not update write time (wrong!)\n"); + ret = false; + } + + + if (fnum1 != -1) + smbcli_close(cli->tree, fnum1); + smbcli_unlink(cli->tree, fname); + smbcli_deltree(cli->tree, BASEDIR); + + return ret; +} + +/* * Do as above, but using 2 connections. */ @@ -1394,6 +1737,9 @@ struct torture_suite *torture_delay_write(void) torture_suite_add_2smb_test(suite, "finfo update on close", test_finfo_after_write); torture_suite_add_1smb_test(suite, "delayed update of write time", test_delayed_write_update); + torture_suite_add_1smb_test(suite, "update of write time and SMBread truncate", test_delayed_write_update1a); + torture_suite_add_1smb_test(suite, "update of write time using SET_END_OF_FILE", test_delayed_write_update1b); + torture_suite_add_1smb_test(suite, "update of write time using SET_ALLOCATION_SIZE", test_delayed_write_update1c); torture_suite_add_2smb_test(suite, "delayed update of write time using 2 connections", test_delayed_write_update2); torture_suite_add_2smb_test(suite, "delayed update of write time 3", test_delayed_write_update3); torture_suite_add_2smb_test(suite, "delayed update of write time 4", test_delayed_write_update4); -- cgit From 56b6b4a68f51be8845afd024a45843331c0810ed Mon Sep 17 00:00:00 2001 From: Jeremy Allison Date: Fri, 5 Sep 2008 21:47:06 -0700 Subject: Don't compare identity, it'll never be different. Jeremy. (This used to be commit 840369b5534eee21818b9d3677404b0fc60a0219) --- source4/torture/basic/delaywrite.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/source4/torture/basic/delaywrite.c b/source4/torture/basic/delaywrite.c index 6dfe410386..52505fa5d1 100644 --- a/source4/torture/basic/delaywrite.c +++ b/source4/torture/basic/delaywrite.c @@ -1469,7 +1469,7 @@ static bool test_delayed_write_update5(struct torture_context *tctx, GET_INFO_BOTH(finfo3,pinfo3); COMPARE_WRITE_TIME_EQUAL(finfo3, finfo2); - if (finfo3.basic_info.out.write_time == finfo3.basic_info.out.write_time) { + if (finfo3.basic_info.out.write_time == finfo2.basic_info.out.write_time) { torture_comment(tctx, "Server did not update write_time (correct)\n"); } @@ -1638,7 +1638,7 @@ again: GET_INFO_BOTH(finfo3,pinfo3); COMPARE_WRITE_TIME_EQUAL(finfo3, finfo2); - if (finfo3.basic_info.out.write_time == finfo3.basic_info.out.write_time) { + if (finfo3.basic_info.out.write_time == finfo2.basic_info.out.write_time) { torture_comment(tctx, "Server did not update write_time (correct)\n"); } -- cgit From 79cc502e5d065a9a700f46d004873b0a6fac1130 Mon Sep 17 00:00:00 2001 From: Stefan Metzmacher Date: Fri, 5 Sep 2008 20:18:07 +0200 Subject: ndr_compression: use inflateReset() and inflateSetDictionary() instead of inflateReset2() Now we can use an unmodified system zlib-1.2.3 metze (This used to be commit d68e36b485239cbaf99a6dce3f3bf52b4abcd06d) --- source4/librpc/ndr/ndr_compression.c | 21 ++++++++++++++------- 1 file changed, 14 insertions(+), 7 deletions(-) diff --git a/source4/librpc/ndr/ndr_compression.c b/source4/librpc/ndr/ndr_compression.c index 37f95bb1b6..0b33d40c24 100644 --- a/source4/librpc/ndr/ndr_compression.c +++ b/source4/librpc/ndr/ndr_compression.c @@ -104,13 +104,6 @@ static enum ndr_err_code ndr_pull_compression_mszip_chunk(struct ndr_pull *ndrpu zError(z_ret), z_ret); } - } else { - z_ret = inflateReset2(z, Z_RESET_KEEP_WINDOW); - if (z_ret != Z_OK) { - return ndr_pull_error(ndrpull, NDR_ERR_COMPRESSION, - "Bad inflateReset2 error %s(%d) (PULL)", - zError(z_ret), z_ret); - } } /* call inflate untill we get Z_STREAM_END or an error */ @@ -142,6 +135,20 @@ static enum ndr_err_code ndr_pull_compression_mszip_chunk(struct ndr_pull *ndrpu *last = true; } + z_ret = inflateReset(z); + if (z_ret != Z_OK) { + return ndr_pull_error(ndrpull, NDR_ERR_COMPRESSION, + "Bad inflateReset error %s(%d) (PULL)", + zError(z_ret), z_ret); + } + + z_ret = inflateSetDictionary(z, plain_chunk.data, plain_chunk.length); + if (z_ret != Z_OK) { + return ndr_pull_error(ndrpull, NDR_ERR_COMPRESSION, + "Bad inflateSetDictionary error %s(%d) (PULL)", + zError(z_ret), z_ret); + } + return NDR_ERR_SUCCESS; } -- cgit From 3b8c11b4d9f967a907c89797279d164b423cc9ed Mon Sep 17 00:00:00 2001 From: Stefan Metzmacher Date: Sat, 6 Sep 2008 16:16:00 +0200 Subject: ndr_compression: use deflateReset() together with defalteSetDictionary() metze (This used to be commit dcc57512b030995d9b186c7a6cb3b304d5680867) --- source4/librpc/ndr/ndr_compression.c | 25 +++++++++++++++++-------- 1 file changed, 17 insertions(+), 8 deletions(-) diff --git a/source4/librpc/ndr/ndr_compression.c b/source4/librpc/ndr/ndr_compression.c index 0b33d40c24..a92877ccc2 100644 --- a/source4/librpc/ndr/ndr_compression.c +++ b/source4/librpc/ndr/ndr_compression.c @@ -219,14 +219,6 @@ static enum ndr_err_code ndr_push_compression_mszip_chunk(struct ndr_push *ndrpu zError(z_ret), z_ret); } - } else { - /* TODO: keep the window */ - z_ret = deflateReset(z); - if (z_ret != Z_OK) { - return ndr_push_error(ndrpush, NDR_ERR_COMPRESSION, - "Bad delateReset2 error %s(%d) (PUSH)", - zError(z_ret), z_ret); - } } /* call deflate untill we get Z_STREAM_END or an error */ @@ -248,11 +240,28 @@ static enum ndr_err_code ndr_push_compression_mszip_chunk(struct ndr_push *ndrpu comp_chunk_size = 2 + z->total_out; + z_ret = deflateReset(z); + if (z_ret != Z_OK) { + return ndr_pull_error(ndrpull, NDR_ERR_COMPRESSION, + "Bad deflateReset error %s(%d) (PULL)", + zError(z_ret), z_ret); + } + + z_ret = deflateSetDictionary(z, plain_chunk.data, plain_chunk.length); + if (z_ret != Z_OK) { + return ndr_pull_error(ndrpull, NDR_ERR_COMPRESSION, + "Bad deflateSetDictionary error %s(%d) (PULL)", + zError(z_ret), z_ret); + } + tmp_offset = ndrpush->offset; ndrpush->offset = comp_chunk_size_offset; NDR_CHECK(ndr_push_uint32(ndrpush, NDR_SCALARS, comp_chunk_size)); ndrpush->offset = tmp_offset; + DEBUG(10,("MSZIP comp plain_chunk_size: %08X (%u) comp_chunk_size: %08X (%u)\n", + plain_chunk.length, plain_chunk.length, comp_chunk_size, comp_chunk_size)); + ndrpush->offset += comp_chunk_size; return NDR_ERR_SUCCESS; } -- cgit From 253e222831d5fc3305363cb186022df5f4f45d14 Mon Sep 17 00:00:00 2001 From: Stefan Metzmacher Date: Sat, 6 Sep 2008 10:55:04 +0200 Subject: ndr_compression: change debug levels metze (This used to be commit 83446e22dd1eda958ef62bbe998da0a47b9ff8ef) --- source4/librpc/ndr/ndr_compression.c | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/source4/librpc/ndr/ndr_compression.c b/source4/librpc/ndr/ndr_compression.c index a92877ccc2..5939c3838a 100644 --- a/source4/librpc/ndr/ndr_compression.c +++ b/source4/librpc/ndr/ndr_compression.c @@ -57,8 +57,8 @@ static enum ndr_err_code ndr_pull_compression_mszip_chunk(struct ndr_pull *ndrpu NDR_CHECK(ndr_pull_uint32(ndrpull, NDR_SCALARS, &comp_chunk_size)); - DEBUG(10,("MSZIP plain_chunk_size: %08X (%u) comp_chunk_size: %08X (%u)\n", - plain_chunk_size, plain_chunk_size, comp_chunk_size, comp_chunk_size)); + DEBUG(9,("MSZIP plain_chunk_size: %08X (%u) comp_chunk_size: %08X (%u)\n", + plain_chunk_size, plain_chunk_size, comp_chunk_size, comp_chunk_size)); comp_chunk_offset = ndrpull->offset; NDR_CHECK(ndr_pull_advance(ndrpull, comp_chunk_size)); @@ -259,8 +259,8 @@ static enum ndr_err_code ndr_push_compression_mszip_chunk(struct ndr_push *ndrpu NDR_CHECK(ndr_push_uint32(ndrpush, NDR_SCALARS, comp_chunk_size)); ndrpush->offset = tmp_offset; - DEBUG(10,("MSZIP comp plain_chunk_size: %08X (%u) comp_chunk_size: %08X (%u)\n", - plain_chunk.length, plain_chunk.length, comp_chunk_size, comp_chunk_size)); + DEBUG(9,("MSZIP comp plain_chunk_size: %08X (%u) comp_chunk_size: %08X (%u)\n", + plain_chunk.length, plain_chunk.length, comp_chunk_size, comp_chunk_size)); ndrpush->offset += comp_chunk_size; return NDR_ERR_SUCCESS; @@ -295,8 +295,8 @@ static enum ndr_err_code ndr_pull_compression_xpress_chunk(struct ndr_pull *ndrp plain_chunk.length = plain_chunk_size; plain_chunk.data = ndrpush->data + plain_chunk_offset; - DEBUG(10,("XPRESS plain_chunk_size: %08X (%u) comp_chunk_size: %08X (%u)\n", - plain_chunk_size, plain_chunk_size, comp_chunk_size, comp_chunk_size)); + DEBUG(9,("XPRESS plain_chunk_size: %08X (%u) comp_chunk_size: %08X (%u)\n", + plain_chunk_size, plain_chunk_size, comp_chunk_size, comp_chunk_size)); /* Uncompressing the buffer using LZ Xpress algorithm */ lzxpress_decompress(&comp_chunk, &plain_chunk); -- cgit From c285076f29c6aea01c1529c7ce84b5976f95be72 Mon Sep 17 00:00:00 2001 From: Stefan Metzmacher Date: Sat, 6 Sep 2008 10:57:33 +0200 Subject: Revert "zlib: we don't need the inflateReset2 prototype twice" This reverts commit 0dbbc287f65a51330c5309df5a96b3acd4d044d5. (we don't need inflateReset2 anymore) metze (This used to be commit 426d129dfff1e2d3750884abb68089ff1850e640) --- source4/lib/zlib/zlib.h | 2 ++ 1 file changed, 2 insertions(+) diff --git a/source4/lib/zlib/zlib.h b/source4/lib/zlib/zlib.h index edf09d2b1e..8ff1d222de 100644 --- a/source4/lib/zlib/zlib.h +++ b/source4/lib/zlib/zlib.h @@ -805,6 +805,8 @@ ZEXTERN int ZEXPORT inflateCopy OF((z_streamp dest, destination. */ +ZEXTERN int ZEXPORT inflateReset2 OF((z_streamp strm, unsigned flags)); + ZEXTERN int ZEXPORT inflateReset OF((z_streamp strm)); /* This function is equivalent to inflateEnd followed by inflateInit, -- cgit From 5631a1b9bc03d6cf31af66b13872255f18979fe8 Mon Sep 17 00:00:00 2001 From: Stefan Metzmacher Date: Sat, 6 Sep 2008 10:58:53 +0200 Subject: Revert "zlib: add inflateReset2()..." This reverts commit 2a4fb661d7e3d601a5eb9ccecb4d4f2b07073097. (we don't need inflateReset2 anymore) metze (This used to be commit ac43081b93966b545928230f7af8654b942432da) --- source4/lib/zlib/inflate.c | 15 +++------------ source4/lib/zlib/zconf.h | 1 - source4/lib/zlib/zlib.h | 15 --------------- 3 files changed, 3 insertions(+), 28 deletions(-) diff --git a/source4/lib/zlib/inflate.c b/source4/lib/zlib/inflate.c index fbecefd8f5..ccbfac804d 100644 --- a/source4/lib/zlib/inflate.c +++ b/source4/lib/zlib/inflate.c @@ -100,9 +100,8 @@ local int updatewindow OF((z_streamp strm, unsigned out)); local unsigned syncsearch OF((unsigned FAR *have, unsigned const char FAR *buf, unsigned len)); -int ZEXPORT inflateReset2(strm, flags) +int ZEXPORT inflateReset(strm) z_streamp strm; -unsigned flags; { struct inflate_state FAR *state; @@ -116,10 +115,8 @@ unsigned flags; state->havedict = 0; state->dmax = 32768U; state->head = Z_NULL; - if (!(flags & Z_RESET_KEEP_WINDOW)) { - state->wsize = 0; - state->whave = 0; - } + state->wsize = 0; + state->whave = 0; state->write = 0; state->hold = 0; state->bits = 0; @@ -128,12 +125,6 @@ unsigned flags; return Z_OK; } -int ZEXPORT inflateReset(strm) -z_streamp strm; -{ - return inflateReset2(strm, 0); -} - int ZEXPORT inflatePrime(strm, bits, value) z_streamp strm; int bits; diff --git a/source4/lib/zlib/zconf.h b/source4/lib/zlib/zconf.h index 214603c151..3742ad4106 100644 --- a/source4/lib/zlib/zconf.h +++ b/source4/lib/zlib/zconf.h @@ -35,7 +35,6 @@ # define inflateSyncPoint z_inflateSyncPoint # define inflateCopy z_inflateCopy # define inflateReset z_inflateReset -# define inflateReset2 z_inflateReset2 # define inflateBack z_inflateBack # define inflateBackEnd z_inflateBackEnd # define compress z_compress diff --git a/source4/lib/zlib/zlib.h b/source4/lib/zlib/zlib.h index 8ff1d222de..a660031e94 100644 --- a/source4/lib/zlib/zlib.h +++ b/source4/lib/zlib/zlib.h @@ -210,9 +210,6 @@ typedef gz_header FAR *gz_headerp; #define Z_NULL 0 /* for initializing zalloc, zfree, opaque */ -#define Z_RESET_KEEP_WINDOW 0x0001 -/* This flag can be passed to inflateReset2 and deflateReset2 */ - #define zlib_version zlibVersion() /* for compatibility with versions < 1.0.2 */ @@ -805,8 +802,6 @@ ZEXTERN int ZEXPORT inflateCopy OF((z_streamp dest, destination. */ -ZEXTERN int ZEXPORT inflateReset2 OF((z_streamp strm, unsigned flags)); - ZEXTERN int ZEXPORT inflateReset OF((z_streamp strm)); /* This function is equivalent to inflateEnd followed by inflateInit, @@ -817,16 +812,6 @@ ZEXTERN int ZEXPORT inflateReset OF((z_streamp strm)); stream state was inconsistent (such as zalloc or state being NULL). */ -ZEXTERN int ZEXPORT inflateReset2 OF((z_streamp strm, unsigned flags)); -/* - This function is like inflateReset, but you can pass some flags - to have further control over the behavior. If you pass Z_RESET_KEEP_WINDOW - the window will be untouched and will be reused in the next runs of inflate() - - inflateReset2 returns Z_OK if success, or Z_STREAM_ERROR if the source - stream state was inconsistent (such as zalloc or state being NULL). -*/ - ZEXTERN int ZEXPORT inflatePrime OF((z_streamp strm, int bits, int value)); -- cgit From 95df0fddf66a2e85b166d7dc6678ed53adbf4c66 Mon Sep 17 00:00:00 2001 From: Stefan Metzmacher Date: Sat, 6 Sep 2008 12:04:00 +0200 Subject: zlib: we require zlib-1.2.3 or higher metze (This used to be commit 3f4eb091f0dcc53acbfdc63a8d82a5a0f28954a6) --- source4/lib/zlib.m4 | 21 ++++++++++++++++++--- 1 file changed, 18 insertions(+), 3 deletions(-) diff --git a/source4/lib/zlib.m4 b/source4/lib/zlib.m4 index 7b967fc8d2..9ee7b8e49e 100644 --- a/source4/lib/zlib.m4 +++ b/source4/lib/zlib.m4 @@ -1,11 +1,26 @@ AC_CHECK_HEADERS(zlib.h) -# we require this new function... -AC_CHECK_LIB_EXT(z, ZLIB_LIBS, inflateReset2) +AC_CHECK_LIB_EXT(z, ZLIB_LIBS, zlibVersion) + +AC_CACHE_CHECK([for zlib >= 1.2.3], samba_cv_zlib_1_2_3, [ + AC_TRY_COMPILE([ + #include + ],[ + #if (ZLIB_VERNUM >= 0x1230) + #else + #error "ZLIB_VERNUM < 0x1230" + #endif + ],[ + samba_cv_zlib_1_2_3=yes + ],[ + samba_cv_zlib_1_2_3=no + ]) +]) if test x"$ac_cv_header_zlib_h" = x"yes" -a \ - x"$ac_cv_lib_ext_z_inflateReset2" = x"yes"; then + x"$ac_cv_lib_ext_z_zlibVersion" = x"yes" -a \ + x"$samba_cv_zlib_1_2_3" = x"yes"; then SMB_EXT_LIB(ZLIB, [${ZLIB_LIBS}]) else SMB_INCLUDE_MK(lib/zlib.mk) -- cgit From 14965b7260f74fe8c49ace21562d913d37d50063 Mon Sep 17 00:00:00 2001 From: Simo Sorce Date: Sat, 6 Sep 2008 12:31:50 -0400 Subject: Always free tmp contexts before returning (This used to be commit 40b71bbd718f6dee70c0611e527f55c56623dea6) --- source4/lib/ldb/common/ldb.c | 1 + 1 file changed, 1 insertion(+) diff --git a/source4/lib/ldb/common/ldb.c b/source4/lib/ldb/common/ldb.c index ce4796dee2..9e04cc7845 100644 --- a/source4/lib/ldb/common/ldb.c +++ b/source4/lib/ldb/common/ldb.c @@ -97,6 +97,7 @@ void ldb_set_default_dns(struct ldb_context *ldb) if (res->count != 1) { talloc_free(res); + talloc_free(tmp_ctx); return; } -- cgit From 1825077840085e77b8190a3b6caaf127736ee183 Mon Sep 17 00:00:00 2001 From: Matthieu Suiche Date: Thu, 10 Jul 2008 09:31:43 +0000 Subject: lzxpress: fix for decompression... Signed-off-by: Stefan Metzmacher (This used to be commit ee505df3742dac0af8eec8b9b27d1e1f5ef54ca9) --- source4/lib/compression/lzxpress.c | 32 +++++++++++++------------------- source4/lib/compression/lzxpress.h | 6 ++++-- 2 files changed, 17 insertions(+), 21 deletions(-) diff --git a/source4/lib/compression/lzxpress.c b/source4/lib/compression/lzxpress.c index 506305176f..9ce4eb1e8d 100644 --- a/source4/lib/compression/lzxpress.c +++ b/source4/lib/compression/lzxpress.c @@ -32,7 +32,6 @@ * */ -#include "includes.h" #include "replace.h" #include "lzxpress.h" @@ -57,10 +56,10 @@ )) #endif -static uint32_t xpress_decompress(uint8_t *input, - uint32_t input_size, - uint8_t *output, - uint32_t output_size) +ssize_t lzxpress_decompress(const uint8_t *input, + uint32_t input_size, + uint8_t *output, + uint32_t max_output_size) { uint32_t output_index, input_index; uint32_t indicator, indicator_bit; @@ -112,11 +111,11 @@ static uint32_t xpress_decompress(uint8_t *input, if (length == 15) { length = input[input_index]; input_index += sizeof(uint8_t); - if (length == 255) { - length = PULL_LE_UINT16(input, input_index); - input_index += sizeof(uint16_t); - length -= (15 + 7); - } + if (length == 255) { + length = PULL_LE_UINT16(input, input_index); + input_index += sizeof(uint16_t); + length -= (15 + 7); + } length += 15; } length += 7; @@ -125,20 +124,15 @@ static uint32_t xpress_decompress(uint8_t *input, length += 3; do { - if (output_index >= output_size) break; + if ((output_index >= max_output_size) || ((offset + 1) > output_index)) break; + output[output_index] = output[output_index - offset - 1]; + output_index += sizeof(uint8_t); length -= sizeof(uint8_t); } while (length != 0); } - - } while ((output_index < output_size) && (input_index < input_size)); + } while ((output_index < max_output_size) && (input_index < (input_size))); return output_index; } - -uint32_t lzxpress_decompress(DATA_BLOB *inbuf, - DATA_BLOB *outbuf) -{ - return xpress_decompress(inbuf->data, inbuf->length, outbuf->data, outbuf->length); -} diff --git a/source4/lib/compression/lzxpress.h b/source4/lib/compression/lzxpress.h index 4862fd2635..c81dda8f85 100644 --- a/source4/lib/compression/lzxpress.h +++ b/source4/lib/compression/lzxpress.h @@ -37,7 +37,9 @@ #define XPRESS_BLOCK_SIZE 0x10000 -uint32_t lzxpress_decompress(DATA_BLOB *inbuf, - DATA_BLOB *outbuf); +ssize_t lzxpress_decompress(const uint8_t *input, + uint32_t input_size, + uint8_t *output, + uint32_t max_output_size); #endif /* _LZXPRESS_H */ -- cgit From 6e0335f8648f5ca2869ad1dd16c1e2aec20bd282 Mon Sep 17 00:00:00 2001 From: Stefan Metzmacher Date: Sun, 7 Sep 2008 18:52:29 +0200 Subject: ndr_compression: fix the build after lzxpress_decompress() prototype change metze (This used to be commit b36056aac3f55587d2b3e7b66feea8173dbc67f0) --- source4/librpc/ndr/ndr_compression.c | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/source4/librpc/ndr/ndr_compression.c b/source4/librpc/ndr/ndr_compression.c index 5939c3838a..aa9f907eed 100644 --- a/source4/librpc/ndr/ndr_compression.c +++ b/source4/librpc/ndr/ndr_compression.c @@ -276,6 +276,7 @@ static enum ndr_err_code ndr_pull_compression_xpress_chunk(struct ndr_pull *ndrp uint32_t plain_chunk_offset; uint32_t comp_chunk_size; uint32_t plain_chunk_size; + ssize_t ret; NDR_CHECK(ndr_pull_uint32(ndrpull, NDR_SCALARS, &plain_chunk_size)); if (plain_chunk_size > 0x00010000) { @@ -299,7 +300,16 @@ static enum ndr_err_code ndr_pull_compression_xpress_chunk(struct ndr_pull *ndrp plain_chunk_size, plain_chunk_size, comp_chunk_size, comp_chunk_size)); /* Uncompressing the buffer using LZ Xpress algorithm */ - lzxpress_decompress(&comp_chunk, &plain_chunk); + ret = lzxpress_decompress(comp_chunk.data, + comp_chunk.length, + plain_chunk.data, + plain_chunk.length); + if (ret < 0) { + return ndr_pull_error(ndrpull, NDR_ERR_COMPRESSION, + "XPRESS lzxpress_decompress() returned %d\n", + ret); + } + plain_chunk.length = ret; if ((plain_chunk_size < 0x00010000) || (ndrpull->offset+4 >= ndrpull->data_size)) { /* this is the last chunk */ -- cgit From 008c9a68874026989d286e4a06a3a4f2f0e32605 Mon Sep 17 00:00:00 2001 From: Matthieu Suiche Date: Thu, 10 Jul 2008 09:31:43 +0000 Subject: lzxpress: Import of lzxpress compression Signed-off-by: Stefan Metzmacher (This used to be commit fd84c5a08f7e8d6402e5f68eede546eb092d22aa) --- source4/lib/compression/lzxpress.c | 174 +++++++++++++++++++++++++++++++++++++ source4/lib/compression/lzxpress.h | 5 ++ 2 files changed, 179 insertions(+) diff --git a/source4/lib/compression/lzxpress.c b/source4/lib/compression/lzxpress.c index 9ce4eb1e8d..0abbfc4d3d 100644 --- a/source4/lib/compression/lzxpress.c +++ b/source4/lib/compression/lzxpress.c @@ -56,6 +56,180 @@ )) #endif +ssize_t lzxpress_compress(const uint8_t *uncompressed, + uint32_t uncompressed_size, + uint8_t *compressed, + uint32_t max_compressed_size) +{ + uint32_t uncompressed_pos, compressed_pos, byte_left; + uint32_t max_offset, best_offset; + int32_t offset; + uint32_t max_len, len, best_len; + const uint8_t *str1, *str2; + uint32_t indic; + uint8_t *indic_pos; + uint32_t indic_bit, nibble_index; + + uint32_t metadata_size; + uint16_t metadata; + uint16_t *dest; + + if (!uncompressed_size) { + return 0; + } + + uncompressed_pos = 0; + indic = 0; + compressed_pos = sizeof(uint32_t); + indic_pos = &compressed[0]; + + byte_left = uncompressed_size; + indic_bit = 0; + nibble_index = 0; + + if (uncompressed_pos > XPRESS_BLOCK_SIZE) + return 0; + + do { + bool found = false; + + max_offset = uncompressed_pos; + + str1 = &uncompressed[uncompressed_pos]; + + best_len = 2; + best_offset = 0; + + max_offset = MIN(0x1FFF, max_offset); + + /* search for the longest match in the window for the lookahead buffer */ + for (offset = 1; (uint32_t)offset <= max_offset; offset++) { + str2 = &str1[-offset]; + + /* maximum len we can encode into metadata */ + max_len = MIN((255 + 15 + 7 + 3), byte_left); + + for (len = 0; (len < max_len) && (str1[len] == str2[len]); len++); + + /* + * We check if len is better than the value found before, including the + * sequence of identical bytes + */ + if (len > best_len) { + found = true; + best_len = len; + best_offset = offset; + } + } + + if (found) { + metadata_size = 0; + dest = (uint16_t *)&compressed[compressed_pos]; + + if (best_len < 10) { + /* Classical meta-data */ + metadata = (uint16_t)(((best_offset - 1) << 3) | (best_len - 3)); + dest[metadata_size / sizeof(uint16_t)] = metadata; + metadata_size += sizeof(uint16_t); + } else { + metadata = (uint16_t)(((best_offset - 1) << 3) | 7); + dest[metadata_size / sizeof(uint16_t)] = metadata; + metadata_size = sizeof(uint16_t); + + if (best_len < (15 + 7 + 3)) { + /* Shared byte */ + if (!nibble_index) { + compressed[compressed_pos + metadata_size] = (best_len - (3 + 7)) & 0xF; + metadata_size += sizeof(uint8_t); + } else { + compressed[nibble_index] &= 0xF; + compressed[nibble_index] |= (best_len - (3 + 7)) * 16; + } + } else if (best_len < (3 + 7 + 15 + 255)) { + /* Shared byte */ + if (!nibble_index) { + compressed[compressed_pos + metadata_size] = 15; + metadata_size += sizeof(uint8_t); + } else { + compressed[nibble_index] &= 0xF; + compressed[nibble_index] |= (15 * 16); + } + + /* Additionnal best_len */ + compressed[compressed_pos + metadata_size] = (best_len - (3 + 7 + 15)) & 0xFF; + metadata_size += sizeof(uint8_t); + } else { + /* Shared byte */ + if (!nibble_index) { + compressed[compressed_pos + metadata_size] |= 15; + metadata_size += sizeof(uint8_t); + } else { + compressed[nibble_index] |= 15 << 4; + } + + /* Additionnal best_len */ + compressed[compressed_pos + metadata_size] = 255; + + metadata_size += sizeof(uint8_t); + + compressed[compressed_pos + metadata_size] = (best_len - 3) & 0xFF; + compressed[compressed_pos + metadata_size + 1] = ((best_len - 3) >> 8) & 0xFF; + metadata_size += sizeof(uint16_t); + } + } + + indic |= 1 << (32 - ((indic_bit % 32) + 1)); + + if (best_len > 9) { + if (nibble_index == 0) { + nibble_index = compressed_pos + sizeof(uint16_t); + } else { + nibble_index = 0; + } + } + + compressed_pos += metadata_size; + uncompressed_pos += best_len; + byte_left -= best_len; + } else { + compressed[compressed_pos++] = uncompressed[uncompressed_pos++]; + byte_left--; + } + indic_bit++; + + if ((indic_bit - 1) % 32 > (indic_bit % 32)) { + *(uint32_t *)indic_pos = indic; + indic = 0; + indic_pos = &compressed[compressed_pos]; + compressed_pos += sizeof(uint32_t); + } + } while (byte_left > 3); + + do { + compressed[compressed_pos] = uncompressed[uncompressed_pos]; + indic_bit++; + + uncompressed_pos++; + compressed_pos++; + if (((indic_bit - 1) % 32) > (indic_bit % 32)){ + *(uint32_t *)indic_pos = indic; + indic = 0; + indic_pos = &compressed[compressed_pos]; + compressed_pos += sizeof(uint32_t); + } + } while (uncompressed_pos < uncompressed_size); + + if ((indic_bit % 32) > 0) { + for (; (indic_bit % 32) != 0; indic_bit++) + indic |= 0 << (32 - ((indic_bit % 32) + 1)); + + *(uint32_t *)indic_pos = indic; + compressed_pos += sizeof(uint32_t); + } + + return compressed_pos; +} + ssize_t lzxpress_decompress(const uint8_t *input, uint32_t input_size, uint8_t *output, diff --git a/source4/lib/compression/lzxpress.h b/source4/lib/compression/lzxpress.h index c81dda8f85..df0ee59a0e 100644 --- a/source4/lib/compression/lzxpress.h +++ b/source4/lib/compression/lzxpress.h @@ -37,6 +37,11 @@ #define XPRESS_BLOCK_SIZE 0x10000 +ssize_t lzxpress_compress(const uint8_t *uncompressed, + uint32_t uncompressed_size, + uint8_t *compressed, + uint32_t max_compressed_size); + ssize_t lzxpress_decompress(const uint8_t *input, uint32_t input_size, uint8_t *output, -- cgit From 1efff73068e933dd0b4cc81ff901f6010fda9a6b Mon Sep 17 00:00:00 2001 From: Stefan Metzmacher Date: Wed, 20 Aug 2008 22:12:51 +0200 Subject: ndr_compression: add XPRESS compression support metze (This used to be commit 1432a96d37e367d9d97d48b69c6f16351a9ad066) --- source4/librpc/ndr/ndr_compression.c | 50 +++++++++++++++++++++++++++++++++++- 1 file changed, 49 insertions(+), 1 deletion(-) diff --git a/source4/librpc/ndr/ndr_compression.c b/source4/librpc/ndr/ndr_compression.c index aa9f907eed..92c5b049df 100644 --- a/source4/librpc/ndr/ndr_compression.c +++ b/source4/librpc/ndr/ndr_compression.c @@ -323,7 +323,55 @@ static enum ndr_err_code ndr_push_compression_xpress_chunk(struct ndr_push *ndrp struct ndr_pull *ndrpull, bool *last) { - return ndr_push_error(ndrpush, NDR_ERR_COMPRESSION, "XPRESS compression is not supported yet (PUSH)"); + DATA_BLOB comp_chunk; + uint32_t comp_chunk_size_offset; + DATA_BLOB plain_chunk; + uint32_t plain_chunk_size; + uint32_t plain_chunk_offset; + uint32_t max_plain_size = 0x00010000; + uint32_t max_comp_size = 0x00020000 + 2; /* TODO: use the correct value here */ + uint32_t tmp_offset; + ssize_t ret; + + plain_chunk_size = MIN(max_plain_size, ndrpull->data_size - ndrpull->offset); + plain_chunk_offset = ndrpull->offset; + NDR_CHECK(ndr_pull_advance(ndrpull, plain_chunk_size)); + + plain_chunk.data = ndrpull->data + plain_chunk_offset; + plain_chunk.length = plain_chunk_size; + + if (plain_chunk_size < max_plain_size) { + *last = true; + } + + NDR_CHECK(ndr_push_uint32(ndrpush, NDR_SCALARS, plain_chunk_size)); + comp_chunk_size_offset = ndrpush->offset; + NDR_CHECK(ndr_push_uint32(ndrpush, NDR_SCALARS, 0xFEFEFEFE)); + + NDR_CHECK(ndr_push_expand(ndrpush, max_comp_size)); + + comp_chunk.data = ndrpush->data + ndrpush->offset; + comp_chunk.length = max_comp_size; + + /* Compressing the buffer using LZ Xpress algorithm */ + ret = lzxpress_compress(plain_chunk.data, + plain_chunk.length, + comp_chunk.data, + comp_chunk.length); + if (ret < 0) { + return ndr_pull_error(ndrpull, NDR_ERR_COMPRESSION, + "XPRESS lzxpress_compress() returned %d\n", + ret); + } + comp_chunk.length = ret; + + tmp_offset = ndrpush->offset; + ndrpush->offset = comp_chunk_size_offset; + NDR_CHECK(ndr_push_uint32(ndrpush, NDR_SCALARS, comp_chunk.length)); + ndrpush->offset = tmp_offset; + + ndrpush->offset += comp_chunk.length; + return NDR_ERR_SUCCESS; } /* -- cgit