Move lp_*() calls a bit higher up the calls tack.
authorJelmer Vernooij <jelmer@samba.org>
Sat, 1 Nov 2008 21:13:47 +0000 (22:13 +0100)
committerJelmer Vernooij <jelmer@samba.org>
Sat, 1 Nov 2008 21:13:47 +0000 (22:13 +0100)
lib/util/dprintf.c
source4/client/client.c
source4/libcli/cliconnect.c
source4/libcli/raw/clisocket.c
source4/libcli/raw/libcliraw.h
source4/libcli/smb2/connect.c
source4/libcli/smb_composite/connect.c
source4/libcli/swig/libcli_smb.i
source4/libcli/swig/libcli_smb_wrap.c
source4/torture/basic/base.c

index e4f02758eb8e0c99c610a2dd4695329c42fa314c..3e6d0e8bca99dfe5bf9705818b2f2f96f7444c73 100644 (file)
@@ -60,7 +60,7 @@ _PUBLIC_ int d_vfprintf(FILE *f, const char *format, va_list ap)
 
        if (ret <= 0) return ret;
 
-       clen = convert_string_talloc_descriptor(NULL, display_cd, p, ret, (void **)&p2);
+       clen = iconv_talloc(NULL, display_cd, p, ret, (void **)&p2);
         if (clen == -1) {
                /* the string can't be converted - do the best we can,
                   filling in non-printing chars with '?' */
index 02f46852b1a2baae9a0ea11f759f3401cfe141b4..8936a3cf2ff5cf6537e8ddf725ada58ac541ee6d 100644 (file)
@@ -3102,7 +3102,8 @@ static int do_message_op(const char *netbios_name, const char *desthost,
                         struct event_context *ev_ctx,
                         struct resolve_context *resolve_ctx,
                         struct smbcli_options *options,
-                        struct smb_iconv_convenience *iconv_convenience)
+                        struct smb_iconv_convenience *iconv_convenience,
+             const char *socket_options)
 {
        struct nbt_name called, calling;
        const char *server_name;
@@ -3117,7 +3118,8 @@ static int do_message_op(const char *netbios_name, const char *desthost,
        if (!(cli = smbcli_state_init(NULL)) ||
            !smbcli_socket_connect(cli, server_name, destports,
                                   ev_ctx, resolve_ctx, options,
-                                  iconv_convenience)) {
+                                  iconv_convenience,
+                   socket_options)) {
                d_printf("Connection to %s failed\n", server_name);
                return 1;
        }
@@ -3270,7 +3272,8 @@ static int do_message_op(const char *netbios_name, const char *desthost,
                                   lp_smb_ports(cmdline_lp_ctx), dest_ip,
                                   name_type, ev_ctx,
                                   lp_resolve_context(cmdline_lp_ctx),
-                                  &smb_options, lp_iconv_convenience(cmdline_lp_ctx));
+                                  &smb_options, lp_iconv_convenience(cmdline_lp_ctx),
+                   lp_socket_options(cmdline_lp_ctx));
                return rc;
        }
        
index e1f5e9ab50dade7f1d99d422d274f7d6f3f737f8..6f58cfa8a79fbd3983e271db33963ff21a17b052 100644 (file)
@@ -35,12 +35,14 @@ bool smbcli_socket_connect(struct smbcli_state *cli, const char *server,
                           struct event_context *ev_ctx,
                           struct resolve_context *resolve_ctx,
                           struct smbcli_options *options,
-                          struct smb_iconv_convenience *iconv_convenience)
+                          struct smb_iconv_convenience *iconv_convenience,
+               const char *socket_options)
 {
        struct smbcli_socket *sock;
 
        sock = smbcli_sock_connect_byname(server, ports, NULL,
-                                         resolve_ctx, ev_ctx);
+                                         resolve_ctx, ev_ctx,
+                      socket_options);
 
        if (sock == NULL) return false;
        
index d51ffbaa746b8ee90a97077e59f9243c9cb2b602..1fbbfe35813e16f74a94c48cf490393e2432ebd9 100644 (file)
@@ -50,7 +50,8 @@ struct composite_context *smbcli_sock_connect_send(TALLOC_CTX *mem_ctx,
                                                   const char **ports,
                                                   const char *host_name,
                                                   struct resolve_context *resolve_ctx,
-                                                  struct event_context *event_ctx)
+                                                  struct event_context *event_ctx,
+                                                  const char *socket_options)
 {
        struct composite_context *result, *ctx;
        struct sock_connect_state *state;
@@ -77,7 +78,7 @@ struct composite_context *smbcli_sock_connect_send(TALLOC_CTX *mem_ctx,
        for (i=0;ports[i];i++) {
                state->ports[i] = atoi(ports[i]);
        }
-       state->socket_options = lp_socket_options(global_loadparm);
+       state->socket_options = talloc_reference(state, socket_options);
 
        ctx = socket_connect_multi_send(state, host_addr,
                                        state->num_ports, state->ports,
@@ -153,12 +154,13 @@ NTSTATUS smbcli_sock_connect(TALLOC_CTX *mem_ctx,
                             const char *host_name,
                             struct resolve_context *resolve_ctx,
                             struct event_context *event_ctx,
+                                const char *socket_options,
                             struct smbcli_socket **result)
 {
        struct composite_context *c =
                smbcli_sock_connect_send(mem_ctx, host_addr, ports, host_name,
                                         resolve_ctx,
-                                        event_ctx);
+                                        event_ctx, socket_options);
        return smbcli_sock_connect_recv(c, mem_ctx, result);
 }
 
@@ -188,7 +190,8 @@ resolve a hostname and connect
 _PUBLIC_ struct smbcli_socket *smbcli_sock_connect_byname(const char *host, const char **ports,
                                                 TALLOC_CTX *mem_ctx,
                                                 struct resolve_context *resolve_ctx,
-                                                struct event_context *event_ctx)
+                                                struct event_context *event_ctx,
+                                                const char *socket_options)
 {
        int name_type = NBT_NAME_SERVER;
        const char *address;
@@ -230,7 +233,8 @@ _PUBLIC_ struct smbcli_socket *smbcli_sock_connect_byname(const char *host, cons
        }
 
        status = smbcli_sock_connect(mem_ctx, address, ports, name, resolve_ctx,
-                                    event_ctx, &result);
+                                    event_ctx, 
+                                        socket_options, &result);
 
        if (!NT_STATUS_IS_OK(status)) {
                DEBUG(9, ("smbcli_sock_connect failed: %s\n",
index 98f18b1ed58cb44efa4c76f4df96959fa661c414..ccd8681fa042eb83c552b0a22b9f0b0b74f89c44 100644 (file)
@@ -376,7 +376,8 @@ NTSTATUS smb_raw_trans(struct smbcli_tree *tree,
 struct smbcli_socket *smbcli_sock_connect_byname(const char *host, const char **ports,
                                                 TALLOC_CTX *mem_ctx,
                                                 struct resolve_context *resolve_ctx,
-                                                struct event_context *event_ctx);
+                                                struct event_context *event_ctx,
+                                                const char *socket_options);
 void smbcli_sock_dead(struct smbcli_socket *sock);
 
 #endif /* __LIBCLI_RAW__H__ */
index bbfcf010aef36763eb5633695006da191744c85b..67d98cfeaf250e882f254da8ff374510a8f9f474 100644 (file)
@@ -137,7 +137,6 @@ static void continue_negprot(struct smb2_request *req)
                }
                break;
        }
-       
 
        state->session = smb2_session_init(transport, global_loadparm, state, true);
        if (composite_nomem(state->session, c)) return;
@@ -217,7 +216,7 @@ static void continue_resolve(struct composite_context *creq)
        c->status = resolve_name_recv(creq, state, &addr);
        if (!composite_is_ok(c)) return;
 
-       creq = smbcli_sock_connect_send(state, addr, ports, state->host, state->resolve_ctx, c->event_ctx);
+       creq = smbcli_sock_connect_send(state, addr, ports, state->host, state->resolve_ctx, c->event_ctx, lp_socket_options(global_loadparm));
 
        composite_continue(c, creq, continue_socket, c);
 }
index 0d97a6c54bc277dcd5f8584b95b670fcdb35be9d..4a73acfd57125b9cf607981306b7895d19f653dd 100644 (file)
@@ -29,6 +29,7 @@
 #include "libcli/resolve/resolve.h"
 #include "auth/credentials/credentials.h"
 #include "librpc/gen_ndr/ndr_nbt.h"
+#include "param/param.h"
 
 /* the stages of this call */
 enum connect_stage {CONNECT_RESOLVE, 
@@ -375,7 +376,8 @@ static NTSTATUS connect_resolve(struct composite_context *c,
        state->creq = smbcli_sock_connect_send(state, address, 
                                               io->in.dest_ports,
                                               io->in.dest_host, 
-                                              NULL, c->event_ctx);
+                                              NULL, c->event_ctx, 
+                                                  lp_socket_options(global_loadparm));
        NT_STATUS_HAVE_NO_MEMORY(state->creq);
 
        state->stage = CONNECT_SOCKET;
index 0162b7b66a9b8d9afbe2d127cfe66324d90fa9d5..0f9116d7f93437a2dfe0974c855648db497a37fa 100644 (file)
@@ -12,6 +12,7 @@
 struct smbcli_socket *smbcli_sock_connect_byname(const char *host, const char **ports,
                                                 TALLOC_CTX *mem_ctx,
                          struct resolve_context *resolve_ctx,
-                                                struct event_context *event_ctx);
+                                                struct event_context *event_ctx,
+                         const char *socket_options);
 
 void smbcli_sock_dead(struct smbcli_socket *sock);
index 99bbdc7f96bbfde5bc52c134c707d3657d40489c..a4e4db726e4a8983691fb6fb6727076686853b50 100644 (file)
@@ -2609,6 +2609,7 @@ SWIGINTERN PyObject *_wrap_smbcli_sock_connect_byname(PyObject *SWIGUNUSEDPARM(s
   TALLOC_CTX *arg3 = (TALLOC_CTX *) 0 ;
   struct resolve_context *arg4 = (struct resolve_context *) 0 ;
   struct event_context *arg5 = (struct event_context *) 0 ;
+  char *arg6 = (char *) 0 ;
   int res1 ;
   char *buf1 = 0 ;
   int alloc1 = 0 ;
@@ -2618,18 +2619,22 @@ SWIGINTERN PyObject *_wrap_smbcli_sock_connect_byname(PyObject *SWIGUNUSEDPARM(s
   int res4 = 0 ;
   void *argp5 = 0 ;
   int res5 = 0 ;
+  int res6 ;
+  char *buf6 = 0 ;
+  int alloc6 = 0 ;
   PyObject * obj0 = 0 ;
   PyObject * obj1 = 0 ;
   PyObject * obj2 = 0 ;
   PyObject * obj3 = 0 ;
+  PyObject * obj4 = 0 ;
   char *  kwnames[] = {
-    (char *) "host",(char *) "ports",(char *) "resolve_ctx",(char *) "event_ctx", NULL 
+    (char *) "host",(char *) "ports",(char *) "resolve_ctx",(char *) "event_ctx",(char *) "socket_options", NULL 
   };
   struct smbcli_socket *result = 0 ;
   
   arg5 = event_context_init(NULL);
   arg3 = NULL;
-  if (!PyArg_ParseTupleAndKeywords(args,kwargs,(char *)"OOO|O:smbcli_sock_connect_byname",kwnames,&obj0,&obj1,&obj2,&obj3)) SWIG_fail;
+  if (!PyArg_ParseTupleAndKeywords(args,kwargs,(char *)"OOO|OO:smbcli_sock_connect_byname",kwnames,&obj0,&obj1,&obj2,&obj3,&obj4)) SWIG_fail;
   res1 = SWIG_AsCharPtrAndSize(obj0, &buf1, NULL, &alloc1);
   if (!SWIG_IsOK(res1)) {
     SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "smbcli_sock_connect_byname" "', argument " "1"" of type '" "char const *""'");
@@ -2652,12 +2657,21 @@ SWIGINTERN PyObject *_wrap_smbcli_sock_connect_byname(PyObject *SWIGUNUSEDPARM(s
     }
     arg5 = (struct event_context *)(argp5);
   }
-  result = (struct smbcli_socket *)smbcli_sock_connect_byname((char const *)arg1,(char const **)arg2,arg3,arg4,arg5);
+  if (obj4) {
+    res6 = SWIG_AsCharPtrAndSize(obj4, &buf6, NULL, &alloc6);
+    if (!SWIG_IsOK(res6)) {
+      SWIG_exception_fail(SWIG_ArgError(res6), "in method '" "smbcli_sock_connect_byname" "', argument " "6"" of type '" "char const *""'");
+    }
+    arg6 = (char *)(buf6);
+  }
+  result = (struct smbcli_socket *)smbcli_sock_connect_byname((char const *)arg1,(char const **)arg2,arg3,arg4,arg5,(char const *)arg6);
   resultobj = SWIG_NewPointerObj(SWIG_as_voidptr(result), SWIGTYPE_p_smbcli_socket, 0 |  0 );
   if (alloc1 == SWIG_NEWOBJ) free((char*)buf1);
+  if (alloc6 == SWIG_NEWOBJ) free((char*)buf6);
   return resultobj;
 fail:
   if (alloc1 == SWIG_NEWOBJ) free((char*)buf1);
+  if (alloc6 == SWIG_NEWOBJ) free((char*)buf6);
   return NULL;
 }
 
index f2b7b9b2251322eef2061b2ad373c9d77009d697..4725188e8f75d41466d414ad7df0b11bb92c2a59 100644 (file)
@@ -57,7 +57,8 @@ static struct smbcli_state *open_nbt_connection(struct torture_context *tctx)
 
        if (!smbcli_socket_connect(cli, host, lp_smb_ports(tctx->lp_ctx), tctx->ev,
                                   lp_resolve_context(tctx->lp_ctx), &options, 
-                                  lp_iconv_convenience(tctx->lp_ctx))) {
+                                  lp_iconv_convenience(tctx->lp_ctx),
+                   lp_socket_options(tctx->lp_ctx))) {
                torture_comment(tctx, "Failed to connect with %s\n", host);
                goto failed;
        }