r26235: Avoid global_loadparm.
authorJelmer Vernooij <jelmer@samba.org>
Sun, 2 Dec 2007 20:32:08 +0000 (21:32 +0100)
committerStefan Metzmacher <metze@samba.org>
Fri, 21 Dec 2007 04:47:13 +0000 (05:47 +0100)
source/auth/system_session.c
source/cldap_server/cldap_server.c
source/dsdb/samdb/samdb.c
source/torture/smb2/connect.c
source/web_server/http.c
source/winbind/wb_cmd_getpwnam.c
source/winbind/wb_name2domain.c
source/winbind/wb_samba3_cmd.c
source/winbind/wb_utils.c

index affce26d2ed9318b3399331cddc7353f32b73449..b50ce1f1bdaaee25b8fdcbd62f79aa71d40e7513 100644 (file)
@@ -163,6 +163,7 @@ _PUBLIC_ struct auth_session_info *system_session(TALLOC_CTX *mem_ctx)
 }
 
 static NTSTATUS _auth_system_session_info(TALLOC_CTX *parent_ctx, 
+                                         struct loadparm_context *lp_ctx,
                                          bool anonymous_credentials, 
                                          struct auth_session_info **_session_info) 
 {
@@ -171,7 +172,7 @@ static NTSTATUS _auth_system_session_info(TALLOC_CTX *parent_ctx,
        struct auth_session_info *session_info = NULL;
        TALLOC_CTX *mem_ctx = talloc_new(parent_ctx);
        
-       nt_status = auth_system_server_info(mem_ctx, lp_netbios_name(global_loadparm),
+       nt_status = auth_system_server_info(mem_ctx, lp_netbios_name(lp_ctx),
                                            &server_info);
        if (!NT_STATUS_IS_OK(nt_status)) {
                talloc_free(mem_ctx);
@@ -189,7 +190,7 @@ static NTSTATUS _auth_system_session_info(TALLOC_CTX *parent_ctx,
                return NT_STATUS_NO_MEMORY;
        }
 
-       cli_credentials_set_conf(session_info->credentials, global_loadparm);
+       cli_credentials_set_conf(session_info->credentials, lp_ctx);
 
        if (anonymous_credentials) {
                cli_credentials_set_anonymous(session_info->credentials);
@@ -208,7 +209,7 @@ _PUBLIC_ struct auth_session_info *system_session_anon(TALLOC_CTX *mem_ctx)
 {
        NTSTATUS nt_status;
        struct auth_session_info *session_info = NULL;
-       nt_status = _auth_system_session_info(mem_ctx, false, &session_info);
+       nt_status = _auth_system_session_info(mem_ctx, global_loadparm, false, &session_info);
        if (!NT_STATUS_IS_OK(nt_status)) {
                return NULL;
        }
@@ -221,6 +222,7 @@ _PUBLIC_ NTSTATUS auth_system_session_info(TALLOC_CTX *parent_ctx,
                                           struct auth_session_info **_session_info) 
 {
        return _auth_system_session_info(parent_ctx, 
+                       global_loadparm,
                        lp_parm_bool(global_loadparm, NULL, "system", "anonymous", false), 
                        _session_info);
 }
index d43669a9e1027ab82d2edd4fc76a4550669f914c..b43137c8dfff1a1c8a42cc0d59f700651da6234b 100644 (file)
@@ -84,7 +84,8 @@ static void cldapd_request_handler(struct cldap_socket *cldap,
 /*
   start listening on the given address
 */
-static NTSTATUS cldapd_add_socket(struct cldapd_server *cldapd, const char *address)
+static NTSTATUS cldapd_add_socket(struct cldapd_server *cldapd, struct loadparm_context *lp_ctx,
+                                 const char *address)
 {
        struct cldap_socket *cldapsock;
        struct socket_address *socket_address;
@@ -95,7 +96,7 @@ static NTSTATUS cldapd_add_socket(struct cldapd_server *cldapd, const char *addr
        NT_STATUS_HAVE_NO_MEMORY(cldapsock);
 
        socket_address = socket_address_from_strings(cldapsock, cldapsock->sock->backend_name, 
-                                                    address, lp_cldap_port(global_loadparm));
+                                                    address, lp_cldap_port(lp_ctx));
        if (!socket_address) {
                talloc_free(cldapsock);
                return NT_STATUS_NO_MEMORY;
@@ -104,7 +105,7 @@ static NTSTATUS cldapd_add_socket(struct cldapd_server *cldapd, const char *addr
        status = socket_listen(cldapsock->sock, socket_address, 0, 0);
        if (!NT_STATUS_IS_OK(status)) {
                DEBUG(0,("Failed to bind to %s:%d - %s\n", 
-                        address, lp_cldap_port(global_loadparm), nt_errstr(status)));
+                        address, lp_cldap_port(lp_ctx), nt_errstr(status)));
                talloc_free(cldapsock);
                return status;
        }
@@ -120,7 +121,7 @@ static NTSTATUS cldapd_add_socket(struct cldapd_server *cldapd, const char *addr
 /*
   setup our listening sockets on the configured network interfaces
 */
-static NTSTATUS cldapd_startup_interfaces(struct cldapd_server *cldapd)
+static NTSTATUS cldapd_startup_interfaces(struct cldapd_server *cldapd, struct loadparm_context *lp_ctx)
 {
        int num_interfaces = iface_count();
        TALLOC_CTX *tmp_ctx = talloc_new(cldapd);
@@ -128,15 +129,15 @@ static NTSTATUS cldapd_startup_interfaces(struct cldapd_server *cldapd)
 
        /* if we are allowing incoming packets from any address, then
           we need to bind to the wildcard address */
-       if (!lp_bind_interfaces_only(global_loadparm)) {
-               status = cldapd_add_socket(cldapd, "0.0.0.0");
+       if (!lp_bind_interfaces_only(lp_ctx)) {
+               status = cldapd_add_socket(cldapd, lp_ctx, "0.0.0.0");
                NT_STATUS_NOT_OK_RETURN(status);
        } else {
                int i;
 
                for (i=0; i<num_interfaces; i++) {
                        const char *address = talloc_strdup(tmp_ctx, iface_n_ip(i));
-                       status = cldapd_add_socket(cldapd, address);
+                       status = cldapd_add_socket(cldapd, lp_ctx, address);
                        NT_STATUS_NOT_OK_RETURN(status);
                }
        }
@@ -187,7 +188,7 @@ static void cldapd_task_init(struct task_server *task)
        }
 
        /* start listening on the configured network interfaces */
-       status = cldapd_startup_interfaces(cldapd);
+       status = cldapd_startup_interfaces(cldapd, task->lp_ctx);
        if (!NT_STATUS_IS_OK(status)) {
                task_server_terminate(task, "cldapd failed to setup interfaces");
                return;
index 36f4a8816d66b890ce03ff39eae3133ba431c0c6..b3ed41a752cb27dcb50456ab8b55f8d4dfaf6134 100644 (file)
@@ -727,7 +727,7 @@ int samdb_copy_template(struct ldb_context *ldb,
                        return LDB_ERR_OPERATIONS_ERROR;
                }
 
-               templates_ldb = ldb_wrap_connect(ldb, global_loadparm
+               templates_ldb = ldb_wrap_connect(ldb, (struct loadparm_context *)ldb_get_opaque(ldb, "loadparm")
                                                templates_ldb_path, NULL,
                                                NULL, 0, NULL);
                talloc_free(templates_ldb_path);
index 796b180ddf6ae52beb4011292933eddd79a6c6b5..d01c138ef8735fd4af62cc8ece37d4b1c56fa8d6 100644 (file)
@@ -65,7 +65,7 @@ static NTSTATUS torture_smb2_close(struct smb2_tree *tree, struct smb2_handle ha
 /*
   test writing
 */
-static NTSTATUS torture_smb2_write(struct smb2_tree *tree, struct smb2_handle handle)
+static NTSTATUS torture_smb2_write(struct torture_context *tctx, struct smb2_tree *tree, struct smb2_handle handle)
 {
        struct smb2_write w;
        struct smb2_read r;
@@ -74,9 +74,9 @@ static NTSTATUS torture_smb2_write(struct smb2_tree *tree, struct smb2_handle ha
        DATA_BLOB data;
        int i;
        
-       if (lp_parm_bool(global_loadparm, NULL, "torture", "dangerous", false)) {
+       if (torture_setting_bool(tctx, "dangerous", false)) {
                data = data_blob_talloc(tree, NULL, 160000);
-       } else if (lp_parm_bool(global_loadparm, NULL, "torture", "samba4", false)) {
+       } else if (torture_setting_bool(tctx, "samba4", false)) {
                data = data_blob_talloc(tree, NULL, UINT16_MAX);
        } else {
                data = data_blob_talloc(tree, NULL, 120000);
@@ -202,7 +202,7 @@ bool torture_smb2_connect(struct torture_context *torture)
 
        h1 = torture_smb2_create(tree, "test9.dat");
        h2 = torture_smb2_create(tree, "test9.dat");
-       status = torture_smb2_write(tree, h1);
+       status = torture_smb2_write(torture, tree, h1);
        if (!NT_STATUS_IS_OK(status)) {
                printf("Write failed - %s\n", nt_errstr(status));
                return false;
index 67329fba7ed0bbb4c8c7adf06120404b464e180b..db2021a16c810bdca4a32c5d1adf78638264d976 100644 (file)
@@ -388,7 +388,7 @@ static void http_simple_request(struct websrv_context *web)
        const char *path;
        struct stat st;
 
-       path = http_local_path(web, url, lp_swat_directory(global_loadparm));
+       path = http_local_path(web, url, lp_swat_directory(web->task->lp_ctx));
        if (path == NULL) goto invalid;
 
        /* looks ok */
@@ -470,7 +470,7 @@ static void http_setup_arrays(struct esp_state *esp)
                       talloc_asprintf(esp, "%u", socket_address->port));
        }
 
-       SETVAR(ESP_SERVER_OBJ, "DOCUMENT_ROOT", lp_swat_directory(global_loadparm));
+       SETVAR(ESP_SERVER_OBJ, "DOCUMENT_ROOT", lp_swat_directory(esp->web->task->lp_ctx));
        SETVAR(ESP_SERVER_OBJ, "SERVER_PROTOCOL", tls_enabled(web->conn->socket)?"https":"http");
        SETVAR(ESP_SERVER_OBJ, "SERVER_SOFTWARE", "SAMBA");
        SETVAR(ESP_SERVER_OBJ, "GATEWAY_INTERFACE", "CGI/1.1");
@@ -515,7 +515,7 @@ static void esp_request(struct esp_state *esp, const char *url)
        int res;
        char *emsg = NULL, *buf;
 
-       if (http_readFile(web, &buf, &size, url, lp_swat_directory(global_loadparm)) != 0) {
+       if (http_readFile(web, &buf, &size, url, lp_swat_directory(esp->web->task->lp_ctx)) != 0) {
                http_error_unix(web, url);
                return;
        }
@@ -547,7 +547,7 @@ static bool http_preauth(struct esp_state *esp)
 {
        const char *path = http_local_path(esp->web,
                                            HTTP_PREAUTH_URI,
-                                           lp_swat_directory(global_loadparm));
+                                           lp_swat_directory(esp->web->task->lp_ctx));
        int i;
        if (path == NULL) {
                http_error(esp->web, 500, "Internal server error");
@@ -734,7 +734,7 @@ static void http_setup_session(struct esp_state *esp)
                s->data = NULL;
                s->te = NULL;
                s->edata = edata;
-               s->lifetime = lp_parm_int(global_loadparm, NULL, "web", "sessiontimeout", 900);
+               s->lifetime = lp_parm_int(esp->web->task->lp_ctx, NULL, "web", "sessiontimeout", 900);
                DLIST_ADD(edata->sessions, s);
                talloc_set_destructor(s, session_destructor);
                if (!generated_key) {
index 653b598ac3d682c54a67953788426293550e4d45..5029e168a20b403dc2f3040fcbefd90d082189cc 100644 (file)
 #include "libcli/composite/composite.h"
 #include "winbind/wb_server.h"
 #include "winbind/wb_async_helpers.h"
+#include "param/param.h"
 #include "winbind/wb_helper.h"
 #include "smbd/service_task.h"
 #include "libnet/libnet_proto.h"
-#include "param/param.h"
 #include "libcli/security/proto.h"
 
 struct cmd_getpwnam_state {
@@ -86,7 +86,7 @@ static void cmd_getpwnam_recv_domain(struct composite_context *ctx)
        user_info = talloc(state, struct libnet_UserInfo);
        if (composite_nomem(user_info, state->ctx)) return;
 
-       ok= wb_samba3_split_username(state, state->name, &user_dom, &user_name);
+       ok= wb_samba3_split_username(state, global_loadparm, state->name, &user_dom, &user_name);
        if(!ok){
                composite_error(state->ctx, NT_STATUS_OBJECT_NAME_INVALID);
                return;
index b100709223aa507ffdb656ddd83fc9b4983d0015..60fe18b5b9a5099bc8cf4aa595c9123aa41325ff 100644 (file)
@@ -24,6 +24,7 @@
 #include "winbind/wb_server.h"
 #include "smbd/service_task.h"
 #include "winbind/wb_helper.h"
+#include "param/param.h"
 
 struct name2domain_state {
        struct composite_context *ctx;
@@ -54,7 +55,7 @@ struct composite_context *wb_name2domain_send(TALLOC_CTX *mem_ctx,
        result->private_data = state;
        state->service = service;
 
-       ok = wb_samba3_split_username(state, name, &user_dom, &user_name);
+       ok = wb_samba3_split_username(state, global_loadparm, name, &user_dom, &user_name);
        if(!ok) {
                composite_error(state->ctx, NT_STATUS_OBJECT_NAME_INVALID);
                return result;
index 4c8a9f9355d7c654a6c02e952320209d390ff7b7..041284e3078b19bc7f328e24d5c3648086c17e41 100644 (file)
 #include "includes.h"
 #include "winbind/wb_server.h"
 #include "winbind/wb_async_helpers.h"
+#include "param/param.h"
 #include "winbind/wb_helper.h"
 #include "libcli/composite/composite.h"
 #include "version.h"
 #include "librpc/gen_ndr/netlogon.h"
 #include "libcli/security/security.h"
 #include "auth/pam_errors.h"
-#include "param/param.h"
 
 /* 
    Send off the reply to an async Samba3 query, handling filling in the PAM, NTSTATUS and string errors.
@@ -545,7 +545,7 @@ NTSTATUS wbsrv_samba3_pam_auth(struct wbsrv_samba3_call *s3call)
                s3call->wbconn->listen_socket->service;
        char *user, *domain;
 
-       if (!wb_samba3_split_username(s3call,
+       if (!wb_samba3_split_username(s3call, global_loadparm,
                                 s3call->request.data.auth.user,
                                 &domain, &user)) {
                return NT_STATUS_NO_SUCH_USER;
index dfd09a98feb6f325d3424d3c93db36c6884c1fc2..43effc30288c2db70864a95a5c1c99a4b15ad151 100644 (file)
  * as one string.
  * TODO: We probably will need to handle other formats later. */
 
-bool wb_samba3_split_username(TALLOC_CTX *mem_ctx, const char *domuser,
+bool wb_samba3_split_username(TALLOC_CTX *mem_ctx, struct loadparm_context *lp_ctx,
+                             const char *domuser,
                                 char **domain, char **user)
 {
-       char *p = strchr(domuser, *lp_winbind_separator(global_loadparm));
+       char *p = strchr(domuser, *lp_winbind_separator(lp_ctx));
 
        if (p == NULL) {
-               *domain = talloc_strdup(mem_ctx, lp_workgroup(global_loadparm));
+               *domain = talloc_strdup(mem_ctx, lp_workgroup(lp_ctx));
        } else {
                *domain = talloc_strndup(mem_ctx, domuser,
                                         PTR_DIFF(p, domuser));