1
0
mirror of https://github.com/samba-team/samba.git synced 2025-02-22 05:57:43 +03:00

Move lp_*() calls a bit higher up the calls tack.

This commit is contained in:
Jelmer Vernooij 2008-11-01 22:13:47 +01:00
parent 3a6b88f9f9
commit 57a60f0920
10 changed files with 47 additions and 20 deletions

View 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 '?' */

View 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;
}

View 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;

View 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",

View 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__ */

View 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);
}

View 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;

View 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);

View 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;
}

View 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;
}