Remove more usages of global_loadparm.
authorJelmer Vernooij <jelmer@samba.org>
Fri, 24 Oct 2008 12:57:03 +0000 (14:57 +0200)
committerJelmer Vernooij <jelmer@samba.org>
Fri, 24 Oct 2008 12:57:03 +0000 (14:57 +0200)
source4/lib/registry/patchfile.c
source4/lib/registry/registry.h
source4/lib/registry/registry.i
source4/lib/registry/registry_wrap.c
source4/lib/registry/tests/diff.c
source4/lib/registry/tools/regpatch.c
source4/libcli/smb_composite/sesssetup.c

index a6f947ee78966ad0f57b62e61f2ab751ca1f2b99..06db3b36baa32033b12b7b6fa0eeedb9b0e1280f 100644 (file)
@@ -479,7 +479,9 @@ static WERROR reg_diff_apply_del_all_values(void *_ctx, const char *key_name)
 /**
  * Apply diff to a registry context
  */
-_PUBLIC_ WERROR reg_diff_apply(struct registry_context *ctx, const char *filename)
+_PUBLIC_ WERROR reg_diff_apply(struct registry_context *ctx, 
+                                                          struct smb_iconv_convenience *iconv_convenience, 
+                                                          const char *filename)
 {
        struct reg_diff_callbacks callbacks;
 
@@ -490,6 +492,6 @@ _PUBLIC_ WERROR reg_diff_apply(struct registry_context *ctx, const char *filenam
        callbacks.del_all_values = reg_diff_apply_del_all_values;
        callbacks.done = NULL;
 
-       return reg_diff_load(filename, lp_iconv_convenience(global_loadparm), 
+       return reg_diff_load(filename, iconv_convenience,
                             &callbacks, ctx);
 }
index e89d6fd55c51a6d3d4fff0f309dc26a7d98feaab..f9db39f4ae137f08cc5c036928d4ea9c0f6c448c 100644 (file)
@@ -484,7 +484,8 @@ struct reg_diff_callbacks {
        WERROR (*done) (void *callback_data);
 };
 
-WERROR reg_diff_apply(struct registry_context *ctx, const char *filename);
+WERROR reg_diff_apply(struct registry_context *ctx, 
+                                         struct smb_iconv_convenience *ic, const char *filename);
 
 WERROR reg_generate_diff(struct registry_context *ctx1,
                         struct registry_context *ctx2,
index fe3a81d889f805c47852b2fec76b353439739c8a..b33b99c0c2720eb22f97b57a88eb83786b64ad04 100644 (file)
@@ -31,6 +31,7 @@
 #include "registry.h"
 #include "param/param.h"
 #include "events/events.h"
+#include "scripting/python/modules.h"
 
 typedef struct registry_context reg;
 typedef struct hive_key hive_key;
@@ -62,6 +63,14 @@ const char *str_regtype(int type);
     $result = SWIG_NewPointerObj(*$1, SWIGTYPE_p_registry_context, 0);
 }
 
+%typemap(in,noblock=1) struct smb_iconv_convenience * {
+    $1 = py_iconv_convenience(NULL);
+}
+
+%typemap(freearg,noblock=1) struct smb_iconv_convenience * {
+    talloc_free($1);
+}
+
 %rename(Registry) reg_open_local;
 WERROR reg_open_local(TALLOC_CTX *parent_ctx, struct registry_context **ctx);
 
@@ -111,7 +120,7 @@ typedef struct registry_context {
     %feature("docstring") diff_apply "S.diff_apply(filename) -> None\n"
                                       "Apply the diff from the specified file";
 
-    WERROR diff_apply(const char *filename);
+    WERROR diff_apply(struct smb_iconv_convenience *ic, const char *filename);
     WERROR generate_diff(struct registry_context *ctx2, const struct reg_diff_callbacks *callbacks,
                          void *callback_data);
 
index 809610fd1d7506a99ed0836d7c7cab68d39b59d7..31711b6071a296fc20789fa4fed4dee1f7a494f9 100644 (file)
@@ -2502,12 +2502,13 @@ SWIG_Python_MustGetPtr(PyObject *obj, swig_type_info *ty, int argnum, int flags)
 #define SWIGTYPE_p_registry_key swig_types[19]
 #define SWIGTYPE_p_short swig_types[20]
 #define SWIGTYPE_p_signed_char swig_types[21]
-#define SWIGTYPE_p_unsigned_char swig_types[22]
-#define SWIGTYPE_p_unsigned_int swig_types[23]
-#define SWIGTYPE_p_unsigned_long_long swig_types[24]
-#define SWIGTYPE_p_unsigned_short swig_types[25]
-static swig_type_info *swig_types[27];
-static swig_module_info swig_module = {swig_types, 26, 0, 0, 0, 0};
+#define SWIGTYPE_p_smb_iconv_convenience swig_types[22]
+#define SWIGTYPE_p_unsigned_char swig_types[23]
+#define SWIGTYPE_p_unsigned_int swig_types[24]
+#define SWIGTYPE_p_unsigned_long_long swig_types[25]
+#define SWIGTYPE_p_unsigned_short swig_types[26]
+static swig_type_info *swig_types[28];
+static swig_module_info swig_module = {swig_types, 27, 0, 0, 0, 0};
 #define SWIG_TypeQuery(name) SWIG_TypeQueryModule(&swig_module, &swig_module, name)
 #define SWIG_MangledTypeQuery(name) SWIG_MangledTypeQueryModule(&swig_module, &swig_module, name)
 
@@ -2555,6 +2556,7 @@ static swig_module_info swig_module = {swig_types, 26, 0, 0, 0, 0};
 #include "registry.h"
 #include "param/param.h"
 #include "events/events.h"
+#include "scripting/python/modules.h"
 
 typedef struct registry_context reg;
 typedef struct hive_key hive_key;
@@ -3107,41 +3109,46 @@ fail:
 SWIGINTERN PyObject *_wrap_reg_diff_apply(PyObject *SWIGUNUSEDPARM(self), PyObject *args, PyObject *kwargs) {
   PyObject *resultobj = 0;
   reg *arg1 = (reg *) 0 ;
-  char *arg2 = (char *) 0 ;
+  struct smb_iconv_convenience *arg2 = (struct smb_iconv_convenience *) 0 ;
+  char *arg3 = (char *) 0 ;
   void *argp1 = 0 ;
   int res1 = 0 ;
-  int res2 ;
-  char *buf2 = 0 ;
-  int alloc2 = 0 ;
+  int res3 ;
+  char *buf3 = 0 ;
+  int alloc3 = 0 ;
   PyObject * obj0 = 0 ;
   PyObject * obj1 = 0 ;
+  PyObject * obj2 = 0 ;
   char *  kwnames[] = {
-    (char *) "self",(char *) "filename", NULL 
+    (char *) "self",(char *) "ic",(char *) "filename", NULL 
   };
   WERROR result;
   
-  if (!PyArg_ParseTupleAndKeywords(args,kwargs,(char *)"OO:reg_diff_apply",kwnames,&obj0,&obj1)) SWIG_fail;
+  if (!PyArg_ParseTupleAndKeywords(args,kwargs,(char *)"OOO:reg_diff_apply",kwnames,&obj0,&obj1,&obj2)) SWIG_fail;
   res1 = SWIG_ConvertPtr(obj0, &argp1,SWIGTYPE_p_registry_context, 0 |  0 );
   if (!SWIG_IsOK(res1)) {
     SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "reg_diff_apply" "', argument " "1"" of type '" "reg *""'"); 
   }
   arg1 = (reg *)(argp1);
-  res2 = SWIG_AsCharPtrAndSize(obj1, &buf2, NULL, &alloc2);
-  if (!SWIG_IsOK(res2)) {
-    SWIG_exception_fail(SWIG_ArgError(res2), "in method '" "reg_diff_apply" "', argument " "2"" of type '" "char const *""'");
+  arg2 = py_iconv_convenience(NULL);
+  res3 = SWIG_AsCharPtrAndSize(obj2, &buf3, NULL, &alloc3);
+  if (!SWIG_IsOK(res3)) {
+    SWIG_exception_fail(SWIG_ArgError(res3), "in method '" "reg_diff_apply" "', argument " "3"" of type '" "char const *""'");
   }
-  arg2 = (char *)(buf2);
-  result = reg_diff_apply(arg1,(char const *)arg2);
+  arg3 = (char *)(buf3);
+  result = reg_diff_apply(arg1,arg2,(char const *)arg3);
   if (!W_ERROR_IS_OK(result)) {
     PyErr_SetWERROR(result);
     SWIG_fail;
   } else if (resultobj == NULL) {
     resultobj = Py_None;
   }
-  if (alloc2 == SWIG_NEWOBJ) free((char*)buf2);
+  talloc_free(arg2);
+  if (alloc3 == SWIG_NEWOBJ) free((char*)buf3);
   return resultobj;
 fail:
-  if (alloc2 == SWIG_NEWOBJ) free((char*)buf2);
+  talloc_free(arg2);
+  if (alloc3 == SWIG_NEWOBJ) free((char*)buf3);
   return NULL;
 }
 
@@ -3849,6 +3856,7 @@ static swig_type_info _swigt__p_registry_context = {"_p_registry_context", "stru
 static swig_type_info _swigt__p_registry_key = {"_p_registry_key", "struct registry_key *", 0, 0, (void*)0, 0};
 static swig_type_info _swigt__p_short = {"_p_short", "short *|int_least16_t *|int16_t *", 0, 0, (void*)0, 0};
 static swig_type_info _swigt__p_signed_char = {"_p_signed_char", "signed char *|int_least8_t *|int_fast8_t *|int8_t *", 0, 0, (void*)0, 0};
+static swig_type_info _swigt__p_smb_iconv_convenience = {"_p_smb_iconv_convenience", "struct smb_iconv_convenience *", 0, 0, (void*)0, 0};
 static swig_type_info _swigt__p_unsigned_char = {"_p_unsigned_char", "unsigned char *|uint_least8_t *|uint_fast8_t *|uint8_t *", 0, 0, (void*)0, 0};
 static swig_type_info _swigt__p_unsigned_int = {"_p_unsigned_int", "uintptr_t *|uint_least32_t *|uint_fast32_t *|uint32_t *|unsigned int *|uint_fast16_t *", 0, 0, (void*)0, 0};
 static swig_type_info _swigt__p_unsigned_long_long = {"_p_unsigned_long_long", "uint_least64_t *|uint_fast64_t *|uint64_t *|unsigned long long *|uintmax_t *", 0, 0, (void*)0, 0};
@@ -3877,6 +3885,7 @@ static swig_type_info *swig_type_initial[] = {
   &_swigt__p_registry_key,
   &_swigt__p_short,
   &_swigt__p_signed_char,
+  &_swigt__p_smb_iconv_convenience,
   &_swigt__p_unsigned_char,
   &_swigt__p_unsigned_int,
   &_swigt__p_unsigned_long_long,
@@ -3905,6 +3914,7 @@ static swig_cast_info _swigc__p_registry_context[] = {  {&_swigt__p_registry_con
 static swig_cast_info _swigc__p_registry_key[] = {  {&_swigt__p_registry_key, 0, 0, 0},{0, 0, 0, 0}};
 static swig_cast_info _swigc__p_short[] = {  {&_swigt__p_short, 0, 0, 0},{0, 0, 0, 0}};
 static swig_cast_info _swigc__p_signed_char[] = {  {&_swigt__p_signed_char, 0, 0, 0},{0, 0, 0, 0}};
+static swig_cast_info _swigc__p_smb_iconv_convenience[] = {  {&_swigt__p_smb_iconv_convenience, 0, 0, 0},{0, 0, 0, 0}};
 static swig_cast_info _swigc__p_unsigned_char[] = {  {&_swigt__p_unsigned_char, 0, 0, 0},{0, 0, 0, 0}};
 static swig_cast_info _swigc__p_unsigned_int[] = {  {&_swigt__p_unsigned_int, 0, 0, 0},{0, 0, 0, 0}};
 static swig_cast_info _swigc__p_unsigned_long_long[] = {  {&_swigt__p_unsigned_long_long, 0, 0, 0},{0, 0, 0, 0}};
@@ -3933,6 +3943,7 @@ static swig_cast_info *swig_cast_initial[] = {
   _swigc__p_registry_key,
   _swigc__p_short,
   _swigc__p_signed_char,
+  _swigc__p_smb_iconv_convenience,
   _swigc__p_unsigned_char,
   _swigc__p_unsigned_int,
   _swigc__p_unsigned_long_long,
index 44ea090527a2630dc10bc72ca0fc6f30f99de888..3dba7293bc687cf629bd270338ac46b1e92cfd52 100644 (file)
@@ -71,7 +71,7 @@ static bool test_diff_apply(struct torture_context *tctx, void *tcase_data)
        struct registry_key *key;
        WERROR error;
 
-       error = reg_diff_apply(td->r1_ctx, td->filename);
+       error = reg_diff_apply(td->r1_ctx, lp_iconv_convenience(tctx->lp_ctx), td->filename);
        torture_assert_werr_ok(tctx, error, "reg_diff_apply");
 
        error = td->r1_ctx->ops->get_predefined_key(td->r1_ctx, HKEY_LOCAL_MACHINE, &key);
index add59a5e64fd0fbb4ef22b383e6bf29ea62ebadf..03d29a598b3a1488b2a85126a86d4e075129f95b 100644 (file)
@@ -68,7 +68,7 @@ int main(int argc, char **argv)
 
        poptFreeContext(pc);
 
-       reg_diff_apply(h, patch);
+       reg_diff_apply(h, lp_iconv_convenience(cmdline_lp_ctx), patch);
 
        return 0;
 }
index 76c1f952e79fbe3554eacdf2a3bf90a135971f66..2ca12a589880dadd70fe90c5b9f12650cd7a05be 100644 (file)
@@ -260,7 +260,7 @@ static NTSTATUS session_setup_nt1(struct composite_context *c,
 {
        NTSTATUS nt_status = NT_STATUS_INTERNAL_ERROR;
        struct sesssetup_state *state = talloc_get_type(c->private_data, struct sesssetup_state);
-       DATA_BLOB names_blob = NTLMv2_generate_names_blob(state, session->transport->socket->hostname, lp_workgroup(global_loadparm));
+       DATA_BLOB names_blob = NTLMv2_generate_names_blob(state, session->transport->socket->hostname, cli_credentials_get_domain(io->in.credentials));
        DATA_BLOB session_key = data_blob(NULL, 0);
        int flags = CLI_CRED_NTLM_AUTH;
 
@@ -334,7 +334,7 @@ static NTSTATUS session_setup_old(struct composite_context *c,
        NTSTATUS nt_status;
        struct sesssetup_state *state = talloc_get_type(c->private_data, struct sesssetup_state);
        const char *password = cli_credentials_get_password(io->in.credentials);
-       DATA_BLOB names_blob = NTLMv2_generate_names_blob(state, session->transport->socket->hostname, lp_workgroup(global_loadparm));
+       DATA_BLOB names_blob = NTLMv2_generate_names_blob(state, session->transport->socket->hostname, cli_credentials_get_domain(io->in.credentials));
        DATA_BLOB session_key;
        int flags = 0;
        if (session->options.lanman_auth) {