r26266: Remove more global_loadparm uses.
authorJelmer Vernooij <jelmer@samba.org>
Mon, 3 Dec 2007 20:25:06 +0000 (21:25 +0100)
committerStefan Metzmacher <metze@samba.org>
Fri, 21 Dec 2007 04:47:42 +0000 (05:47 +0100)
17 files changed:
source/client/client.c
source/ldap_server/ldap_backend.c
source/ldap_server/ldap_bind.c
source/ldap_server/ldap_server.c
source/ldap_server/ldap_server.h
source/lib/events/events.c
source/lib/messaging/tests/irpc.c
source/lib/messaging/tests/messaging.c
source/lib/util/util_ldb.h [deleted file]
source/libcli/cliconnect.c
source/libcli/ldap/ldap_client.c
source/libcli/raw/clisocket.c
source/libcli/raw/clitransport.c
source/libcli/smb2/connect.c
source/libcli/smb_composite/connect.c
source/librpc/rpc/dcerpc_connect.c
source/torture/basic/base.c

index 0006459..a2fe29f 100644 (file)
@@ -3078,7 +3078,7 @@ static int do_message_op(const char *netbios_name, const char *desthost, const c
 
        server_name = destip ? destip : desthost;
 
-       if (!(cli=smbcli_state_init(NULL)) || !smbcli_socket_connect(cli, server_name)) {
+       if (!(cli=smbcli_state_init(NULL)) || !smbcli_socket_connect(cli, server_name, lp_name_resolve_order(global_loadparm), lp_max_xmit(global_loadparm), lp_maxmux(global_loadparm))) {
                d_printf("Connection to %s failed\n", server_name);
                return 1;
        }
index a6697df..346aaca 100644 (file)
@@ -56,8 +56,9 @@ static int map_ldb_error(struct ldb_context *ldb, int err, const char **errstrin
 NTSTATUS ldapsrv_backend_Init(struct ldapsrv_connection *conn) 
 {
        conn->ldb = ldb_wrap_connect(conn, 
-                                    global_loadparm,
-                                    lp_sam_url(global_loadparm), conn->session_info,
+                                    conn->lp_ctx,
+                                    lp_sam_url(conn->lp_ctx), 
+                                    conn->session_info,
                                     NULL, conn->global_catalog ? LDB_FLG_RDONLY : 0, NULL);
        if (conn->ldb == NULL) {
                return NT_STATUS_INTERNAL_DB_CORRUPTION;
index 874c9bf..53cef5b 100644 (file)
@@ -45,12 +45,12 @@ static NTSTATUS ldapsrv_BindSimple(struct ldapsrv_call *call)
 
        DEBUG(10, ("BindSimple dn: %s\n",req->dn));
 
-       status = crack_auto_name_to_nt4_name(call, global_loadparm, req->dn, &nt4_domain, &nt4_account);
+       status = crack_auto_name_to_nt4_name(call, call->conn->lp_ctx, req->dn, &nt4_domain, &nt4_account);
        if (NT_STATUS_IS_OK(status)) {
                status = authenticate_username_pw(call,
                                                  call->conn->connection->event.ctx,
                                                  call->conn->connection->msg_ctx,
-                                                 global_loadparm,
+                                                 call->conn->lp_ctx,
                                                  nt4_domain, nt4_account, 
                                                  req->creds.password,
                                                  &session_info);
@@ -143,7 +143,7 @@ static NTSTATUS ldapsrv_BindSASL(struct ldapsrv_call *call)
 
                status = gensec_server_start(conn,
                                             conn->connection->event.ctx,
-                                            global_loadparm,
+                                            conn->lp_ctx,
                                             conn->connection->msg_ctx,
                                             &conn->gensec);
                if (!NT_STATUS_IS_OK(status)) {
index 9d6de73..2898d13 100644 (file)
@@ -345,6 +345,7 @@ static void ldapsrv_accept(struct stream_connection *c)
        conn->connection  = c;
        conn->service     = ldapsrv_service;
        conn->sockets.raw = c->socket;
+       conn->lp_ctx      = global_loadparm;
 
        c->private        = conn;
 
@@ -395,7 +396,7 @@ static void ldapsrv_accept(struct stream_connection *c)
                return;
        }
        
-       cli_credentials_set_conf(server_credentials, global_loadparm);
+       cli_credentials_set_conf(server_credentials, conn->lp_ctx);
        status = cli_credentials_set_machine_account(server_credentials);
        if (!NT_STATUS_IS_OK(status)) {
                stream_terminate_connection(c, talloc_asprintf(conn, "Failed to obtain server credentials, perhaps a standalone server?: %s\n", nt_errstr(status)));
@@ -404,7 +405,7 @@ static void ldapsrv_accept(struct stream_connection *c)
        conn->server_credentials = server_credentials;
 
        /* Connections start out anonymous */
-       if (!NT_STATUS_IS_OK(auth_anonymous_session_info(conn, global_loadparm, &conn->session_info))) {
+       if (!NT_STATUS_IS_OK(auth_anonymous_session_info(conn, conn->lp_ctx, &conn->session_info))) {
                ldapsrv_terminate_connection(conn, "failed to setup anonymous session info");
                return;
        }
index df0bb92..88af0fb 100644 (file)
@@ -23,6 +23,7 @@
 #include "lib/stream/packet.h"
 
 struct ldapsrv_connection {
+       struct loadparm_context *lp_ctx;
        struct stream_connection *connection;
        struct gensec_security *gensec;
        struct auth_session_info *session_info;
index 2b36c92..fd736e4 100644 (file)
@@ -183,11 +183,6 @@ struct event_context *event_context_init_byname(TALLOC_CTX *mem_ctx, const char
 
        event_backend_init();
 
-#if _SAMBA_BUILD_
-       if (name == NULL) {
-               name = lp_parm_string(global_loadparm, NULL, "event", "backend");
-       }
-#endif
        if (name == NULL) {
                name = event_default_backend;
        }
index aae6b48..28676c2 100644 (file)
@@ -215,12 +215,12 @@ static bool irpc_setup(struct torture_context *tctx, void **_data)
 
        *_data = data = talloc(tctx, struct irpc_test_data);
 
-       lp_set_cmdline(global_loadparm, "pid directory", "piddir.tmp");
+       lp_set_cmdline(tctx->lp_ctx, "pid directory", "piddir.tmp");
 
        data->ev = tctx->ev;
        torture_assert(tctx, data->msg_ctx1 = 
                       messaging_init(tctx, 
-                                     lp_messaging_path(tctx, global_loadparm), 
+                                     lp_messaging_path(tctx, tctx->lp_ctx), 
                                      cluster_id(MSG_ID1), data->ev),
                       "Failed to init first messaging context");
 
index bf2b83a..ba3d2f9 100644 (file)
@@ -66,23 +66,22 @@ static bool test_ping_speed(struct torture_context *tctx)
        struct timeval tv;
        int timelimit = torture_setting_int(tctx, "timelimit", 10);
        uint32_t msg_ping, msg_exit;
-       TALLOC_CTX *mem_ctx = tctx;
 
-       lp_set_cmdline(global_loadparm, "pid directory", "piddir.tmp");
+       lp_set_cmdline(tctx->lp_ctx, "pid directory", "piddir.tmp");
 
        ev = tctx->ev;
 
-       msg_server_ctx = messaging_init(mem_ctx, 
-                                       lp_messaging_path(tctx, global_loadparm), 
+       msg_server_ctx = messaging_init(tctx, 
+                                       lp_messaging_path(tctx, tctx->lp_ctx), 
                                        cluster_id(1), ev);
        
        torture_assert(tctx, msg_server_ctx != NULL, "Failed to init ping messaging context");
                
        messaging_register_tmp(msg_server_ctx, NULL, ping_message, &msg_ping);
-       messaging_register_tmp(msg_server_ctx, mem_ctx, exit_message, &msg_exit);
+       messaging_register_tmp(msg_server_ctx, tctx, exit_message, &msg_exit);
 
-       msg_client_ctx = messaging_init(mem_ctx, 
-                                       lp_messaging_path(mem_ctx, global_loadparm), 
+       msg_client_ctx = messaging_init(tctx, 
+                                       lp_messaging_path(tctx, tctx->lp_ctx), 
                                        cluster_id(2), ev);
 
        torture_assert(tctx, msg_client_ctx != NULL, 
diff --git a/source/lib/util/util_ldb.h b/source/lib/util/util_ldb.h
deleted file mode 100644 (file)
index f4f56d6..0000000
+++ /dev/null
@@ -1,55 +0,0 @@
-#ifndef __LIB_UTIL_UTIL_LDB_H__
-#define __LIB_UTIL_UTIL_LDB_H__
-
-#undef _PRINTF_ATTRIBUTE
-#define _PRINTF_ATTRIBUTE(a1, a2) PRINTF_ATTRIBUTE(a1, a2)
-/* This file was automatically generated by mkproto.pl. DO NOT EDIT */
-
-#ifndef _PUBLIC_
-#define _PUBLIC_
-#endif
-
-#ifndef _PURE_
-#define _PURE_
-#endif
-
-#ifndef _NORETURN_
-#define _NORETURN_
-#endif
-
-#ifndef _DEPRECATED_
-#define _DEPRECATED_
-#endif
-
-#ifndef _WARN_UNUSED_RESULT_
-#define _WARN_UNUSED_RESULT_
-#endif
-
-
-/* The following definitions come from lib/util/util_ldb.c  */
-
-int gendb_search_v(struct ldb_context *ldb, 
-                  TALLOC_CTX *mem_ctx,
-                  struct ldb_dn *basedn,
-                  struct ldb_message ***msgs,
-                  const char * const *attrs,
-                  const char *format, 
-                  va_list ap)  _PRINTF_ATTRIBUTE(6,0);
-int gendb_search(struct ldb_context *ldb,
-                TALLOC_CTX *mem_ctx, 
-                struct ldb_dn *basedn,
-                struct ldb_message ***res,
-                const char * const *attrs,
-                const char *format, ...) _PRINTF_ATTRIBUTE(6,7);
-int gendb_search_dn(struct ldb_context *ldb,
-                TALLOC_CTX *mem_ctx, 
-                struct ldb_dn *dn,
-                struct ldb_message ***res,
-                const char * const *attrs);
-int gendb_add_ldif(struct ldb_context *ldb, const char *ldif_string);
-char *wrap_casefold(void *context, void *mem_ctx, const char *s);
-#undef _PRINTF_ATTRIBUTE
-#define _PRINTF_ATTRIBUTE(a1, a2)
-
-#endif /* __LIB_UTIL_UTIL_LDB_H__ */
-
index 39f97f4..b9fd06d 100644 (file)
 /*
   wrapper around smbcli_sock_connect()
 */
-bool smbcli_socket_connect(struct smbcli_state *cli, const char *server)
+bool smbcli_socket_connect(struct smbcli_state *cli, const char *server, 
+                          const char **name_resolve_order,
+                          int max_xmit, int max_mux)
 {
        struct smbcli_socket *sock;
 
-       sock = smbcli_sock_connect_byname(server, 0, NULL, NULL);
+       sock = smbcli_sock_connect_byname(server, 0, NULL, name_resolve_order, 
+                                         NULL);
 
        if (sock == NULL) return false;
        
-       cli->transport = smbcli_transport_init(sock, cli, true);
+       cli->transport = smbcli_transport_init(sock, cli, true, max_xmit,
+                                              max_mux);
        if (!cli->transport) {
                return false;
        }
index f1cfaad..2fe0c78 100644 (file)
@@ -377,7 +377,8 @@ struct composite_context *ldap_connect_send(struct ldap_connection *conn,
        return NULL;
 }
 
-static void ldap_connect_got_sock(struct composite_context *ctx, struct ldap_connection *conn) 
+static void ldap_connect_got_sock(struct composite_context *ctx, 
+                                 struct ldap_connection *conn) 
 {
        /* setup a handler for events on this socket */
        conn->event.fde = event_add_fd(conn->event.event_ctx, conn->sock, 
index e342031..6e12d80 100644 (file)
@@ -199,6 +199,7 @@ resolve a hostname and connect
 ****************************************************************************/
 struct smbcli_socket *smbcli_sock_connect_byname(const char *host, int port,
                                                 TALLOC_CTX *mem_ctx,
+                                                const char **name_resolve_order,
                                                 struct event_context *event_ctx)
 {
        int name_type = NBT_NAME_SERVER;
@@ -239,7 +240,7 @@ struct smbcli_socket *smbcli_sock_connect_byname(const char *host, int port,
 
        make_nbt_name(&nbt_name, host, name_type);
        
-       status = resolve_name(&nbt_name, tmp_ctx, &address, event_ctx, lp_name_resolve_order(global_loadparm));
+       status = resolve_name(&nbt_name, tmp_ctx, &address, event_ctx, name_resolve_order);
        if (!NT_STATUS_IS_OK(status)) {
                talloc_free(tmp_ctx);
                return NULL;
index 0bf8059..11df6c6 100644 (file)
@@ -73,7 +73,9 @@ static NTSTATUS smbcli_transport_finish_recv(void *private, DATA_BLOB blob);
 */
 struct smbcli_transport *smbcli_transport_init(struct smbcli_socket *sock,
                                               TALLOC_CTX *parent_ctx, 
-                                              bool primary)
+                                              bool primary, 
+                                              int max_xmit,
+                                              int max_mux)
 {
        struct smbcli_transport *transport;
 
@@ -88,8 +90,8 @@ struct smbcli_transport *smbcli_transport_init(struct smbcli_socket *sock,
        transport->negotiate.protocol = PROTOCOL_NT1;
        transport->options.use_spnego = lp_use_spnego(global_loadparm) && 
                                        lp_nt_status_support(global_loadparm);
-       transport->options.max_xmit = lp_max_xmit(global_loadparm);
-       transport->options.max_mux = lp_maxmux(global_loadparm);
+       transport->options.max_xmit = max_xmit;
+       transport->options.max_mux = max_mux;
        transport->options.request_timeout = SMB_REQUEST_TIMEOUT;
 
        transport->negotiate.max_xmit = transport->options.max_xmit;
index 6f05d56..7cfaf59 100644 (file)
@@ -163,6 +163,7 @@ static void continue_resolve(struct composite_context *creq)
 struct composite_context *smb2_connect_send(TALLOC_CTX *mem_ctx,
                                            const char *host,
                                            const char *share,
+                                           const char **name_resolve_order,
                                            struct cli_credentials *credentials,
                                            struct event_context *ev)
 {
@@ -187,8 +188,7 @@ struct composite_context *smb2_connect_send(TALLOC_CTX *mem_ctx,
        ZERO_STRUCT(name);
        name.name = host;
 
-       creq = resolve_name_send(&name, c->event_ctx, 
-                                lp_name_resolve_order(global_loadparm));
+       creq = resolve_name_send(&name, c->event_ctx, name_resolve_order);
        composite_continue(c, creq, continue_resolve, c);
        return c;
 }
@@ -215,11 +215,13 @@ NTSTATUS smb2_connect_recv(struct composite_context *c, TALLOC_CTX *mem_ctx,
 */
 NTSTATUS smb2_connect(TALLOC_CTX *mem_ctx, 
                      const char *host, const char *share,
+                     const char **name_resolve_order,
                      struct cli_credentials *credentials,
                      struct smb2_tree **tree,
                      struct event_context *ev)
 {
        struct composite_context *c = smb2_connect_send(mem_ctx, host, share, 
+                                                       name_resolve_order,
                                                        credentials, ev);
        return smb2_connect_recv(c, mem_ctx, tree);
 }
index 0238d5c..9579cd2 100644 (file)
@@ -307,7 +307,9 @@ static NTSTATUS connect_socket(struct composite_context *c,
        NT_STATUS_NOT_OK_RETURN(status);
 
        /* the socket is up - we can initialise the smbcli transport layer */
-       state->transport = smbcli_transport_init(state->sock, state, true);
+       state->transport = smbcli_transport_init(state->sock, state, true, 
+                                                lp_max_xmit(global_loadparm),
+                                                lp_maxmux(global_loadparm));
        NT_STATUS_HAVE_NO_MEMORY(state->transport);
 
        if (is_ipaddress(state->sock->hostname) &&
index 2d62376..21f726c 100644 (file)
@@ -235,7 +235,9 @@ static struct composite_context *dcerpc_pipe_connect_ncacn_np_smb2_send(TALLOC_C
        }
 
        /* send smb2 connect request */
-       conn_req = smb2_connect_send(mem_ctx, s->io.binding->host, "IPC$", s->io.creds,
+       conn_req = smb2_connect_send(mem_ctx, s->io.binding->host, "IPC$", 
+                                    lp_name_resolve_order(global_loadparm),
+                                    s->io.creds,
                                     c->event_ctx);
        composite_continue(c, conn_req, continue_smb2_connect, c);
        return c;
index 3e6c16f..24c0d29 100644 (file)
@@ -51,7 +51,7 @@ static struct smbcli_state *open_nbt_connection(struct torture_context *tctx)
                goto failed;
        }
 
-       if (!smbcli_socket_connect(cli, host)) {
+       if (!smbcli_socket_connect(cli, host, lp_name_resolve_order(tctx->lp_ctx), lp_max_xmit(tctx->lp_ctx), lp_maxmux(tctx->lp_ctx))) {
                torture_comment(tctx, "Failed to connect with %s\n", host);
                goto failed;
        }