r26228: Store loadparm context in auth context, move more loadparm_contexts up the...
authorJelmer Vernooij <jelmer@samba.org>
Sun, 2 Dec 2007 16:56:09 +0000 (17:56 +0100)
committerStefan Metzmacher <metze@samba.org>
Fri, 21 Dec 2007 04:47:05 +0000 (05:47 +0100)
(This used to be commit ba75f1613a9aac69dd5df94dd8a2b37820acd166)

26 files changed:
source4/auth/auth.c
source4/auth/auth.h
source4/auth/auth_sam.c
source4/auth/auth_server.c
source4/auth/auth_simple.c
source4/auth/auth_unix.c
source4/auth/auth_util.c
source4/auth/gensec/schannel_state.c
source4/auth/ntlm_check.c
source4/dsdb/common/sidmap.c
source4/dsdb/repl/drepl_service.c
source4/ldap_server/ldap_bind.c
source4/ldap_server/ldap_server.c
source4/lib/dbwrap/dbwrap.c
source4/lib/dbwrap/dbwrap.h
source4/lib/dbwrap/dbwrap_tdb.c
source4/lib/gencache/gencache.c
source4/lib/ldb/tools/cmdline.c
source4/ntvfs/common/brlock_tdb.c
source4/ntvfs/posix/vfs_posix.c
source4/ntvfs/unixuid/vfs_unixuid.c
source4/rpc_server/lsa/lsa_init.c
source4/rpc_server/netlogon/dcerpc_netlogon.c
source4/rpc_server/unixinfo/dcesrv_unixinfo.c
source4/scripting/ejs/smbcalls_auth.c
source4/utils/ntlm_auth.c

index e4af53d25e809ce366ac8ce51865822b8ce4eb25..b915a43e391d8d1dfed83240e439f9cfbed31565 100644 (file)
@@ -353,6 +353,7 @@ NTSTATUS auth_check_password_recv(struct auth_check_password_request *req,
 NTSTATUS auth_context_create_methods(TALLOC_CTX *mem_ctx, const char **methods, 
                                     struct event_context *ev,
                                     struct messaging_context *msg,
+                                    struct loadparm_context *lp_ctx,
                                     struct auth_context **auth_ctx)
 {
        int i;
@@ -381,6 +382,7 @@ NTSTATUS auth_context_create_methods(TALLOC_CTX *mem_ctx, const char **methods,
        ctx->methods                    = NULL;
        ctx->event_ctx                  = ev;
        ctx->msg_ctx                    = msg;
+       ctx->lp_ctx                     = lp_ctx;
 
        for (i=0; methods[i] ; i++) {
                struct auth_method_context *method;
@@ -429,7 +431,7 @@ NTSTATUS auth_context_create(TALLOC_CTX *mem_ctx,
                auth_methods = lp_parm_string_list(lp_ctx, NULL, "auth methods", "domain controller", NULL);
                break;
        }
-       return auth_context_create_methods(mem_ctx, auth_methods, ev, msg, auth_ctx);
+       return auth_context_create_methods(mem_ctx, auth_methods, ev, msg, lp_ctx, auth_ctx);
 }
 
 
index 95819fbaf3424fcf70e5fbf4fd8e5b78dd94196a..ff7132c3ffc3cb6e1d2ec3a701f75224177fcfa1 100644 (file)
@@ -168,6 +168,9 @@ struct auth_context {
 
        /* the messaging context which can be used by backends */
        struct messaging_context *msg_ctx;
+
+       /* loadparm context */
+       struct loadparm_context *lp_ctx;
 };
 
 /* this structure is used by backends to determine the size of some critical types */
index 42e5ae9e7e09675eb840f5933fb3c945385da41e..812c80f4d0f3b16c1c8b5df8257feffb53e761a9 100644 (file)
@@ -151,7 +151,7 @@ static NTSTATUS authsam_password_ok(struct auth_context *auth_context,
        NTSTATUS status;
 
        if (acct_flags & ACB_PWNOTREQ) {
-               if (lp_null_passwords(global_loadparm)) {
+               if (lp_null_passwords(auth_context->lp_ctx)) {
                        DEBUG(3,("Account for user '%s' has no password and null passwords are allowed.\n", 
                                 user_info->mapped.account_name));
                        return NT_STATUS_OK;
@@ -181,6 +181,7 @@ static NTSTATUS authsam_password_ok(struct auth_context *auth_context,
                *lm_sess_key = data_blob(NULL, 0);
                *user_sess_key = data_blob(NULL, 0);
                status = hash_password_check(mem_ctx, 
+                                            auth_context->lp_ctx,
                                             user_info->password.hash.lanman,
                                             user_info->password.hash.nt,
                                             user_info->mapped.account_name,
@@ -189,7 +190,9 @@ static NTSTATUS authsam_password_ok(struct auth_context *auth_context,
                break;
                
        case AUTH_PASSWORD_RESPONSE:
-               status = ntlm_password_check(mem_ctx, user_info->logon_parameters, 
+               status = ntlm_password_check(mem_ctx, 
+                                            auth_context->lp_ctx,
+                                            user_info->logon_parameters, 
                                             &auth_context->challenge.data, 
                                             &user_info->password.response.lanman, 
                                             &user_info->password.response.nt,
@@ -283,7 +286,7 @@ static NTSTATUS authsam_check_password_internals(struct auth_method_context *ctx
                return NT_STATUS_NO_MEMORY;
        }
 
-       sam_ctx = samdb_connect(tmp_ctx, global_loadparm, system_session(mem_ctx));
+       sam_ctx = samdb_connect(tmp_ctx, ctx->auth_ctx->lp_ctx, system_session(mem_ctx));
        if (sam_ctx == NULL) {
                talloc_free(tmp_ctx);
                return NT_STATUS_INVALID_SYSTEM_SERVICE;
@@ -348,13 +351,13 @@ static NTSTATUS authsam_want_check(struct auth_method_context *ctx,
                return NT_STATUS_NOT_IMPLEMENTED;
        }
 
-       is_local_name = lp_is_myname(global_loadparm
+       is_local_name = lp_is_myname(ctx->auth_ctx->lp_ctx
                                  user_info->mapped.domain_name);
-       is_my_domain  = lp_is_mydomain(global_loadparm
+       is_my_domain  = lp_is_mydomain(ctx->auth_ctx->lp_ctx
                                       user_info->mapped.domain_name); 
 
        /* check whether or not we service this domain/workgroup name */
-       switch (lp_server_role(global_loadparm)) {
+       switch (lp_server_role(ctx->auth_ctx->lp_ctx)) {
                case ROLE_STANDALONE:
                        return NT_STATUS_OK;
 
@@ -390,14 +393,14 @@ static NTSTATUS authsam_check_password(struct auth_method_context *ctx,
        const char *domain;
 
        /* check whether or not we service this domain/workgroup name */
-       switch (lp_server_role(global_loadparm)) {
+       switch (lp_server_role(ctx->auth_ctx->lp_ctx)) {
                case ROLE_STANDALONE:
                case ROLE_DOMAIN_MEMBER:
-                       domain = lp_netbios_name(global_loadparm);
+                       domain = lp_netbios_name(ctx->auth_ctx->lp_ctx);
                        break;
 
                case ROLE_DOMAIN_CONTROLLER:
-                       domain = lp_workgroup(global_loadparm);
+                       domain = lp_workgroup(ctx->auth_ctx->lp_ctx);
                        break;
 
                default:
index 36637edd57bd481b46766029b66f77b9357ace38..6502564dca947b6368574bfc998b02d579f748aa 100644 (file)
@@ -206,7 +206,7 @@ static NTSTATUS check_smbserver_security(const struct auth_context *auth_context
         * password file.
         */
 
-       if (lp_is_myname(global_loadparm, user_info->domain.str)) {
+       if (lp_is_myname(auth_context->lp_ctx, user_info->domain.str)) {
                DEBUG(3,("check_smbserver_security: Requested domain was for this machine.\n"));
                return NT_STATUS_LOGON_FAILURE;
        }
index 0b94669008fb06e14b489ba510fe95deb5809a35..cde170482ad3e5e978c394369ea80e3c606f0b7c 100644 (file)
@@ -33,6 +33,7 @@
 _PUBLIC_ NTSTATUS authenticate_username_pw(TALLOC_CTX *mem_ctx,
                                           struct event_context *ev,
                                           struct messaging_context *msg,
+                                          struct loadparm_context *lp_ctx,
                                           const char *nt4_domain,
                                           const char *nt4_username,
                                           const char *password,
@@ -50,7 +51,7 @@ _PUBLIC_ NTSTATUS authenticate_username_pw(TALLOC_CTX *mem_ctx,
 
        nt_status = auth_context_create(tmp_ctx, 
                                        ev, msg,
-                                       global_loadparm,
+                                       lp_ctx,
                                        &auth_context);
        if (!NT_STATUS_IS_OK(nt_status)) {
                talloc_free(tmp_ctx);
index 4cbe3723a8b6ae75f424e43065bda45f384a01ff..9efbe5dc128062b2febaee9d086035915622464a 100644 (file)
@@ -804,7 +804,7 @@ static NTSTATUS authunix_check_password(struct auth_method_context *ctx,
                return NT_STATUS_NO_MEMORY;
        }
 
-       nt_status = check_unix_password(check_ctx, global_loadparm, user_info, &pwd);
+       nt_status = check_unix_password(check_ctx, ctx->auth_ctx->lp_ctx, user_info, &pwd);
        if (!NT_STATUS_IS_OK(nt_status)) {
                talloc_free(check_ctx);
                return nt_status;
index 91f0e5163c7dd1a1db7180c6a67a70fd372f2f1b..9110fc1b979f811400395674ccb1af6856154cd0 100644 (file)
@@ -138,8 +138,8 @@ NTSTATUS encrypt_user_info(TALLOC_CTX *mem_ctx, struct auth_context *auth_contex
                        }
                        
                        chall_blob = data_blob_talloc(mem_ctx, challenge, 8);
-                       if (lp_client_ntlmv2_auth(global_loadparm)) {
-                               DATA_BLOB names_blob = NTLMv2_generate_names_blob(mem_ctx, lp_netbios_name(global_loadparm), lp_workgroup(global_loadparm));
+                       if (lp_client_ntlmv2_auth(auth_context->lp_ctx)) {
+                               DATA_BLOB names_blob = NTLMv2_generate_names_blob(mem_ctx, lp_netbios_name(auth_context->lp_ctx), lp_workgroup(auth_context->lp_ctx));
                                DATA_BLOB lmv2_response, ntlmv2_response, lmv2_session_key, ntlmv2_session_key;
                                
                                if (!SMBNTLMv2encrypt_hash(user_info_temp,
@@ -163,7 +163,7 @@ NTSTATUS encrypt_user_info(TALLOC_CTX *mem_ctx, struct auth_context *auth_contex
                                SMBOWFencrypt(user_info_in->password.hash.nt->hash, challenge, blob.data);
 
                                user_info_temp->password.response.nt = blob;
-                               if (lp_client_lanman_auth(global_loadparm) && user_info_in->password.hash.lanman) {
+                               if (lp_client_lanman_auth(auth_context->lp_ctx) && user_info_in->password.hash.lanman) {
                                        DATA_BLOB lm_blob = data_blob_talloc(mem_ctx, NULL, 24);
                                        SMBOWFencrypt(user_info_in->password.hash.lanman->hash, challenge, blob.data);
                                        user_info_temp->password.response.lanman = lm_blob;
index 1bb71d8fc9171f99b79d45baa08324f137250e10..77f5dfb59935913e9d6c20aa7971a5c35821cc85 100644 (file)
@@ -32,7 +32,7 @@
 /**
   connect to the schannel ldb
 */
-struct ldb_context *schannel_db_connect(TALLOC_CTX *mem_ctx)
+struct ldb_context *schannel_db_connect(TALLOC_CTX *mem_ctx, struct loadparm_context *lp_ctx)
 {
        char *path;
        struct ldb_context *ldb;
@@ -42,14 +42,14 @@ struct ldb_context *schannel_db_connect(TALLOC_CTX *mem_ctx)
                "computerName: CASE_INSENSITIVE\n" \
                "flatname: CASE_INSENSITIVE\n";
 
-       path = smbd_tmp_path(mem_ctx, global_loadparm, "schannel.ldb");
+       path = smbd_tmp_path(mem_ctx, lp_ctx, "schannel.ldb");
        if (!path) {
                return NULL;
        }
 
        existed = file_exist(path);
        
-       ldb = ldb_wrap_connect(mem_ctx, global_loadparm, path, 
+       ldb = ldb_wrap_connect(mem_ctx, lp_ctx, path, 
                               system_session(mem_ctx), 
                               NULL, LDB_FLG_NOSYNC, NULL);
        talloc_free(path);
@@ -143,7 +143,7 @@ NTSTATUS schannel_store_session_key(TALLOC_CTX *mem_ctx,
        NTSTATUS nt_status;
        int ret;
                
-       ldb = schannel_db_connect(mem_ctx);
+       ldb = schannel_db_connect(mem_ctx, global_loadparm);
        if (!ldb) {
                return NT_STATUS_ACCESS_DENIED;
        }
@@ -274,7 +274,7 @@ NTSTATUS schannel_fetch_session_key(TALLOC_CTX *mem_ctx,
        NTSTATUS nt_status;
        struct ldb_context *ldb;
 
-       ldb = schannel_db_connect(mem_ctx);
+       ldb = schannel_db_connect(mem_ctx, global_loadparm);
        if (!ldb) {
                return NT_STATUS_ACCESS_DENIED;
        }
index 5214c46e0eecdd6f1a58999181e0505ea451e781..f1ea6829e074385de50edf93dfd71616d473e8e1 100644 (file)
@@ -219,6 +219,7 @@ static bool smb_sess_key_ntlmv2(TALLOC_CTX *mem_ctx,
  */
 
 NTSTATUS hash_password_check(TALLOC_CTX *mem_ctx,
+                            struct loadparm_context *lp_ctx, 
                             const struct samr_Password *client_lanman,
                             const struct samr_Password *client_nt,
                             const char *username, 
@@ -240,7 +241,7 @@ NTSTATUS hash_password_check(TALLOC_CTX *mem_ctx,
                }
 
        } else if (client_lanman && stored_lanman) {
-               if (!lp_lanman_auth(global_loadparm)) {
+               if (!lp_lanman_auth(lp_ctx)) {
                        DEBUG(3,("ntlm_password_check: Interactive logon: only LANMAN password supplied for user %s, and LM passwords are disabled!\n",
                                 username));
                        return NT_STATUS_WRONG_PASSWORD;
@@ -281,6 +282,7 @@ NTSTATUS hash_password_check(TALLOC_CTX *mem_ctx,
  */
 
 NTSTATUS ntlm_password_check(TALLOC_CTX *mem_ctx,
+                            struct loadparm_context *lp_ctx,
                             uint32_t logon_parameters,
                             const DATA_BLOB *challenge,
                             const DATA_BLOB *lm_response,
@@ -330,6 +332,7 @@ NTSTATUS ntlm_password_check(TALLOC_CTX *mem_ctx,
                        lm_ok = false;
                }
                return hash_password_check(mem_ctx, 
+                                          lp_ctx,
                                           lm_ok ? &client_lm : NULL, 
                                           nt_response->length ? &client_nt : NULL, 
                                           username,  
@@ -392,7 +395,7 @@ NTSTATUS ntlm_password_check(TALLOC_CTX *mem_ctx,
                        DEBUG(3,("ntlm_password_check: NTLMv2 password check failed\n"));
                }
        } else if (nt_response->length == 24 && stored_nt) {
-               if (lp_ntlm_auth(global_loadparm)) {            
+               if (lp_ntlm_auth(lp_ctx)) {             
                        /* We have the NT MD4 hash challenge available - see if we can
                           use it (ie. does it exist in the smbpasswd file).
                        */
@@ -404,7 +407,7 @@ NTSTATUS ntlm_password_check(TALLOC_CTX *mem_ctx,
                                /* The LM session key for this response is not very secure, 
                                   so use it only if we otherwise allow LM authentication */
                                
-                               if (lp_lanman_auth(global_loadparm) && stored_lanman) {
+                               if (lp_lanman_auth(lp_ctx) && stored_lanman) {
                                        *lm_sess_key = data_blob_talloc(mem_ctx, stored_lanman->hash, 8);
                                }
                                return NT_STATUS_OK;
@@ -432,7 +435,7 @@ NTSTATUS ntlm_password_check(TALLOC_CTX *mem_ctx,
                return NT_STATUS_WRONG_PASSWORD;
        }
                
-       if (!lp_lanman_auth(global_loadparm)) {
+       if (!lp_lanman_auth(lp_ctx)) {
                DEBUG(3,("ntlm_password_check: Lanman passwords NOT PERMITTED for user %s\n",
                         username));
        } else if (!stored_lanman) {
@@ -451,7 +454,7 @@ NTSTATUS ntlm_password_check(TALLOC_CTX *mem_ctx,
                           It not very secure, so use it only if we otherwise 
                           allow LM authentication */
 
-                       if (lp_lanman_auth(global_loadparm) && stored_lanman) {
+                       if (lp_lanman_auth(lp_ctx) && stored_lanman) {
                                uint8_t first_8_lm_hash[16];
                                memcpy(first_8_lm_hash, stored_lanman->hash, 8);
                                memset(first_8_lm_hash + 8, '\0', 8);
@@ -567,7 +570,7 @@ NTSTATUS ntlm_password_check(TALLOC_CTX *mem_ctx,
           - I think this is related to Win9X pass-though authentication
        */
        DEBUG(4,("ntlm_password_check: Checking NT MD4 password in LM field\n"));
-       if (lp_ntlm_auth(global_loadparm)) {
+       if (lp_ntlm_auth(lp_ctx)) {
                if (smb_pwd_check_ntlmv1(mem_ctx, 
                                         lm_response, 
                                         stored_nt->hash, challenge,
@@ -576,7 +579,7 @@ NTSTATUS ntlm_password_check(TALLOC_CTX *mem_ctx,
                           It not very secure, so use it only if we otherwise 
                           allow LM authentication */
 
-                       if (lp_lanman_auth(global_loadparm) && stored_lanman) {
+                       if (lp_lanman_auth(lp_ctx) && stored_lanman) {
                                uint8_t first_8_lm_hash[16];
                                memcpy(first_8_lm_hash, stored_lanman->hash, 8);
                                memset(first_8_lm_hash + 8, '\0', 8);
index 8383d2b36bce6e6afcb4e7112092151318909feb..97e5fb2b197d55b3761a9a412211501235a6576b 100644 (file)
@@ -48,14 +48,14 @@ struct sidmap_context {
 /*
   open a sidmap context - use talloc_free to close
 */
-_PUBLIC_ struct sidmap_context *sidmap_open(TALLOC_CTX *mem_ctx)
+_PUBLIC_ struct sidmap_context *sidmap_open(TALLOC_CTX *mem_ctx, struct loadparm_context *lp_ctx)
 {
        struct sidmap_context *sidmap;
        sidmap = talloc(mem_ctx, struct sidmap_context);
        if (sidmap == NULL) {
                return NULL;
        }
-       sidmap->samctx = samdb_connect(sidmap, global_loadparm, system_session(sidmap));
+       sidmap->samctx = samdb_connect(sidmap, lp_ctx, system_session(sidmap));
        if (sidmap->samctx == NULL) {
                talloc_free(sidmap);
                return NULL;
index 5c74dbfb72581dec15d8a032ce767c94cf8ca2a9..72033f41774c920d3f2947e18126877f7476d525 100644 (file)
@@ -45,12 +45,12 @@ static WERROR dreplsrv_init_creds(struct dreplsrv_service *service)
        return WERR_OK;
 }
 
-static WERROR dreplsrv_connect_samdb(struct dreplsrv_service *service)
+static WERROR dreplsrv_connect_samdb(struct dreplsrv_service *service, struct loadparm_context *lp_ctx)
 {
        const struct GUID *ntds_guid;
        struct drsuapi_DsBindInfo28 *bind_info28;
 
-       service->samdb = samdb_connect(service, global_loadparm, service->system_session_info);
+       service->samdb = samdb_connect(service, lp_ctx, service->system_session_info);
        if (!service->samdb) {
                return WERR_DS_SERVICE_UNAVAILABLE;
        }
@@ -118,7 +118,7 @@ static void dreplsrv_task_init(struct task_server *task)
        struct dreplsrv_service *service;
        uint32_t periodic_startup_interval;
 
-       switch (lp_server_role(global_loadparm)) {
+       switch (lp_server_role(task->lp_ctx)) {
        case ROLE_STANDALONE:
                task_server_terminate(task, "dreplsrv: no DSDB replication required in standalone configuration");
                return;
@@ -149,7 +149,7 @@ static void dreplsrv_task_init(struct task_server *task)
                return;
        }
 
-       status = dreplsrv_connect_samdb(service);
+       status = dreplsrv_connect_samdb(service, task->lp_ctx);
        if (!W_ERROR_IS_OK(status)) {
                task_server_terminate(task, talloc_asprintf(task,
                                      "dreplsrv: Failed to connect to local samdb: %s\n",
@@ -165,8 +165,8 @@ static void dreplsrv_task_init(struct task_server *task)
                return;
        }
 
-       periodic_startup_interval       = lp_parm_int(global_loadparm, NULL, "dreplsrv", "periodic_startup_interval", 15); /* in seconds */
-       service->periodic.interval      = lp_parm_int(global_loadparm, NULL, "dreplsrv", "periodic_interval", 300); /* in seconds */
+       periodic_startup_interval       = lp_parm_int(task->lp_ctx, NULL, "dreplsrv", "periodic_startup_interval", 15); /* in seconds */
+       service->periodic.interval      = lp_parm_int(task->lp_ctx, NULL, "dreplsrv", "periodic_interval", 300); /* in seconds */
 
        status = dreplsrv_periodic_schedule(service, periodic_startup_interval);
        if (!W_ERROR_IS_OK(status)) {
index fe4680b1f20d996fd3c4ad42ceaeb576ea187e02..50521e9a52b158368c541da4e944134059f87932 100644 (file)
@@ -27,6 +27,7 @@
 #include "dsdb/samdb/samdb.h"
 #include "auth/gensec/gensec.h"
 #include "auth/gensec/socket.h"
+#include "param/param.h"
 
 static NTSTATUS ldapsrv_BindSimple(struct ldapsrv_call *call)
 {
@@ -46,7 +47,7 @@ static NTSTATUS ldapsrv_BindSimple(struct ldapsrv_call *call)
 
        status = crack_auto_name_to_nt4_name(call, req->dn, &nt4_domain, &nt4_account);
        if (NT_STATUS_IS_OK(status)) {
-               status = authenticate_username_pw(call,
+               status = authenticate_username_pw(global_loadparm, call,
                                                  call->conn->connection->event.ctx,
                                                  call->conn->connection->msg_ctx,
                                                  nt4_domain, nt4_account, 
index 1ee37dceffe37a9cabd03f3c49119ca4aae1707f..30afe7c590da162dc64e9ad74072f339cef22939 100644 (file)
@@ -389,8 +389,7 @@ static void ldapsrv_accept(struct stream_connection *c)
        /* Ensure we don't get packets until the database is ready below */
        packet_recv_disable(conn->packet);
 
-       server_credentials 
-               = cli_credentials_init(conn);
+       server_credentials = cli_credentials_init(conn);
        if (!server_credentials) {
                stream_terminate_connection(c, "Failed to init server credentials\n");
                return;
@@ -515,7 +514,7 @@ static void ldapsrv_task_init(struct task_server *task)
        NTSTATUS status;
        const struct model_ops *model_ops;
 
-       switch (lp_server_role(global_loadparm)) {
+       switch (lp_server_role(task->lp_ctx)) {
        case ROLE_STANDALONE:
                task_server_terminate(task, "ldap_server: no LDAP server required in standalone configuration");
                return;
index 9e893b12439666bbc769c9f4ebf7e6ee2cf475bc..791d0adee6bc5bd7207be574fdb51d64c0b7ba8c 100644 (file)
 #include "lib/dbwrap/dbwrap.h"
 #include "param/param.h"
 
-/*
+/**
   open a temporary database
  */
-struct db_context *db_tmp_open(TALLOC_CTX *mem_ctx, const char *name, int tdb_flags)
+struct db_context *db_tmp_open(TALLOC_CTX *mem_ctx, struct loadparm_context *lp_ctx, const char *name, int tdb_flags)
 {
-       if (lp_parm_bool(global_loadparm, NULL, "ctdb", "enable", false) &&
-           lp_parm_bool(global_loadparm, NULL, "ctdb", name, true)) {
+       if (lp_parm_bool(lp_ctx, NULL, "ctdb", "enable", false) &&
+           lp_parm_bool(lp_ctx, NULL, "ctdb", name, true)) {
                    return db_tmp_open_ctdb(mem_ctx, name, tdb_flags);
        }
 
-       return db_tmp_open_tdb(mem_ctx, name, tdb_flags);
+       return db_tmp_open_tdb(mem_ctx, lp_ctx, name, tdb_flags);
 }
index b4267d802dff8574e9d1f0a4d85712ae1920543b..fc1f123e23270e94616a520e77e29bf541cb905a 100644 (file)
@@ -45,9 +45,10 @@ struct db_context {
        void *private_data;
 };
 
-struct db_context *db_tmp_open(TALLOC_CTX *mem_ctx, const char *name, int tdb_flags);
+struct loadparm_context;
+struct db_context *db_tmp_open(TALLOC_CTX *mem_ctx, struct loadparm_context *lp_ctx, const char *name, int tdb_flags);
 
 
 /* backends */
-struct db_context *db_tmp_open_tdb(TALLOC_CTX *mem_ctx, const char *name, int tdb_flags);
+struct db_context *db_tmp_open_tdb(TALLOC_CTX *mem_ctx, struct loadparm_context *lp_ctx, const char *name, int tdb_flags);
 struct db_context *db_tmp_open_ctdb(TALLOC_CTX *mem_ctx, const char *name, int tdb_flags);
index 621b19532d80b9ee374fc87b461cec0f0e227307..fae73a1db806cb99b5216f0cfdc7f71baddd177f 100644 (file)
@@ -225,7 +225,8 @@ static int db_tdb_get_seqnum(struct db_context *db)
 /*
   open a temporary database
  */
-struct db_context *db_tmp_open_tdb(TALLOC_CTX *mem_ctx, const char *name, int tdb_flags)
+struct db_context *db_tmp_open_tdb(TALLOC_CTX *mem_ctx, struct loadparm_context *lp_ctx, 
+                                  const char *name, int tdb_flags)
 {
        struct db_context *result;
        struct db_tdb_ctx *db_tdb;
@@ -241,7 +242,7 @@ struct db_context *db_tmp_open_tdb(TALLOC_CTX *mem_ctx, const char *name, int td
 
        /* the name passed in should not be a full path, it should be
           just be the db name */
-       path = smbd_tmp_path(result, global_loadparm, name);
+       path = smbd_tmp_path(result, lp_ctx, name);
 
        db_tdb->wtdb = tdb_wrap_open(db_tdb, path, 0, tdb_flags,
                                     O_CREAT|O_RDWR, 0666);
index ea80a93624fa073d2f64aa1fa7b7c16e09680944..aaaa40eea884bf04c71b5f98e8e882ff0eeda6dc 100644 (file)
@@ -47,7 +47,7 @@ static struct tdb_wrap *cache;
  *         false on failure
  **/
 
-bool gencache_init(void)
+bool gencache_init(struct loadparm_context *lp_ctx)
 {
        char* cache_fname = NULL;
        TALLOC_CTX *mem_ctx = talloc_autofree_context();
@@ -55,7 +55,7 @@ bool gencache_init(void)
        /* skip file open if it's already opened */
        if (cache) return true;
 
-       cache_fname = lock_path(mem_ctx, global_loadparm, "gencache.tdb");
+       cache_fname = lock_path(mem_ctx, lp_ctx, "gencache.tdb");
        if (cache_fname != NULL) {
                DEBUG(5, ("Opening cache file at %s\n", cache_fname));
        } else {
index 5e3013600a2e949693dd083b271deb50d105c3c4..1f8c7ce684b8fb5295327739217a690fb0700680 100644 (file)
@@ -217,6 +217,10 @@ struct ldb_cmdline *ldb_cmdline_process(struct ldb_context *ldb, int argc, const
        if (ldb_set_opaque(ldb, "credentials", cmdline_credentials)) {
                goto failed;
        }
+       if (ldb_set_opaque(ldb, "loadparm", global_loadparm)) {
+               goto failed;
+       }
+
        ldb_set_utf8_fns(ldb, NULL, wrap_casefold);
 #endif
 
index 2b81521a2c836b92a0f779233a31a439b9ce17a9..25642d5f5c74c69bb67e3ea2725db872e2436473 100644 (file)
@@ -34,6 +34,7 @@
 #include "cluster/cluster.h"
 #include "ntvfs/common/brlock.h"
 #include "ntvfs/ntvfs.h"
+#include "param/param.h"
 
 /*
   in this module a "DATA_BLOB *file_key" is a blob that uniquely identifies
@@ -94,7 +95,7 @@ static struct brl_context *brl_tdb_init(TALLOC_CTX *mem_ctx, struct server_id se
                return NULL;
        }
 
-       brl->db = db_tmp_open(brl, "brlock.tdb", TDB_DEFAULT);
+       brl->db = db_tmp_open(brl, global_loadparm, "brlock.tdb", TDB_DEFAULT);
        if (brl->db == NULL) {
                talloc_free(brl);
                return NULL;
index 24aa023de5f40fed23f67986104c6e255eb3f44f..07948a64e223bb83914ac687728eef13edac47b4 100644 (file)
@@ -31,7 +31,7 @@
 #include "util/util_ldb.h"
 #include "libcli/security/security.h"
 #include "lib/events/events.h"
-
+#include "param/param.h"
 
 /*
   setup config options for a posix share
@@ -216,7 +216,7 @@ static NTSTATUS pvfs_connect(struct ntvfs_module_context *ntvfs,
                                           event_context_find(pvfs),
                                           pvfs->ntvfs->ctx->config);
 
-       pvfs->sidmap = sidmap_open(pvfs);
+       pvfs->sidmap = sidmap_open(pvfs, global_loadparm);
        if (pvfs->sidmap == NULL) {
                return NT_STATUS_INTERNAL_DB_CORRUPTION;
        }
index 0ad8a8501b6afdfca25f042c4c48cda5ec2fe587..d7b64b01f23cd7c84def4b57a62ff85d7afb209e 100644 (file)
@@ -26,6 +26,7 @@
 #include "auth/auth.h"
 #include "ntvfs/ntvfs.h"
 #include "dsdb/samdb/samdb.h"
+#include "param/param.h"
 
 struct unixuid_private {
        struct sidmap_context *sidmap;
@@ -215,7 +216,7 @@ static NTSTATUS unixuid_connect(struct ntvfs_module_context *ntvfs,
                return NT_STATUS_NO_MEMORY;
        }
 
-       private->sidmap = sidmap_open(private);
+       private->sidmap = sidmap_open(private, global_loadparm);
        if (private->sidmap == NULL) {
                return NT_STATUS_INTERNAL_DB_CORRUPTION;
        }
index 83607cc446e51d7f174f86b08b9b67aee566422b..c86fdf333d321b23775e5760609552985569a960 100644 (file)
@@ -57,7 +57,7 @@ NTSTATUS dcesrv_lsa_get_policy_state(struct dcesrv_call_state *dce_call, TALLOC_
 
        partitions_basedn = samdb_partitions_dn(state->sam_ldb, mem_ctx);
 
-       state->sidmap = sidmap_open(state);
+       state->sidmap = sidmap_open(state, global_loadparm);
        if (state->sidmap == NULL) {
                return NT_STATUS_INVALID_SYSTEM_SERVICE;
        }
index d5e385f70db673580693f231f2412e593ed7c6e7..448f2b93f9f98bab8d381ad8437b21342c8eeb4d 100644 (file)
@@ -244,7 +244,7 @@ static NTSTATUS dcesrv_netr_creds_server_step_check(const char *computer_name,
        struct ldb_context *ldb;
        int ret;
 
-       ldb = schannel_db_connect(mem_ctx);
+       ldb = schannel_db_connect(mem_ctx, global_loadparm);
        if (!ldb) {
                return NT_STATUS_ACCESS_DENIED;
        }
index 1f9e584ecf888685eb16b4eb468e88caf6bfcf5b..290cfda640c8872d41b9dc23cbbd6c5adc2319d9 100644 (file)
@@ -26,6 +26,7 @@
 #include "lib/events/events.h"
 #include "dsdb/samdb/samdb.h"
 #include "system/passwd.h"
+#include "param/param.h"
 
 static NTSTATUS dcesrv_unixinfo_SidToUid(struct dcesrv_call_state *dce_call,
                                  TALLOC_CTX *mem_ctx,
@@ -35,7 +36,7 @@ static NTSTATUS dcesrv_unixinfo_SidToUid(struct dcesrv_call_state *dce_call,
        struct sidmap_context *sidmap;
        uid_t uid;
 
-       sidmap = sidmap_open(mem_ctx);
+       sidmap = sidmap_open(mem_ctx, global_loadparm);
        if (sidmap == NULL) {
                DEBUG(10, ("sidmap_open failed\n"));
                return NT_STATUS_NO_MEMORY;
@@ -55,7 +56,7 @@ static NTSTATUS dcesrv_unixinfo_UidToSid(struct dcesrv_call_state *dce_call,
        struct sidmap_context *sidmap;
        uid_t uid;
 
-       sidmap = sidmap_open(mem_ctx);
+       sidmap = sidmap_open(mem_ctx, global_loadparm);
        if (sidmap == NULL) {
                DEBUG(10, ("sidmap_open failed\n"));
                return NT_STATUS_NO_MEMORY;
@@ -79,7 +80,7 @@ static NTSTATUS dcesrv_unixinfo_SidToGid(struct dcesrv_call_state *dce_call,
        struct sidmap_context *sidmap;
        gid_t gid;
 
-       sidmap = sidmap_open(mem_ctx);
+       sidmap = sidmap_open(mem_ctx, global_loadparm);
        if (sidmap == NULL) {
                DEBUG(10, ("sidmap_open failed\n"));
                return NT_STATUS_NO_MEMORY;
@@ -99,7 +100,7 @@ static NTSTATUS dcesrv_unixinfo_GidToSid(struct dcesrv_call_state *dce_call,
        struct sidmap_context *sidmap;
        gid_t gid;
 
-       sidmap = sidmap_open(mem_ctx);
+       sidmap = sidmap_open(mem_ctx, global_loadparm);
        if (sidmap == NULL) {
                DEBUG(10, ("sidmap_open failed\n"));
                return NT_STATUS_NO_MEMORY;
index 6ddb0497886bc854298d711bd62fbfe5044c1277..39e84d7f2c9853f7a693cee7ed4d33d7b578abe6 100644 (file)
@@ -60,7 +60,7 @@ static int ejs_doauth(MprVarHandle eid,
        }
 
        if (auth_types) {
-               nt_status = auth_context_create_methods(tmp_ctx, auth_types, ev, msg, &auth_context);
+               nt_status = auth_context_create_methods(tmp_ctx, auth_types, ev, msg, global_loadparm, &auth_context);
        } else {
                nt_status = auth_context_create(tmp_ctx, ev, msg, global_loadparm, &auth_context);
        }
index 80ecfff572a3d866cf6777297b72eaf2647e12bb..bb9b5d89faff9f27f7217a7ffd2d13ff42217019 100644 (file)
@@ -176,7 +176,8 @@ static bool check_plaintext_auth(const char *user, const char *pass,
 
 /* authenticate a user with an encrypted username/password */
 
-static NTSTATUS local_pw_check_specified(const char *username, 
+static NTSTATUS local_pw_check_specified(struct loadparm_context *lp_ctx,
+                                        const char *username, 
                                         const char *domain, 
                                         const char *workstation,
                                         const DATA_BLOB *challenge, 
@@ -206,6 +207,7 @@ static NTSTATUS local_pw_check_specified(const char *username,
                
                
                nt_status = ntlm_password_check(mem_ctx, 
+                                               lp_ctx,
                                                MSV1_0_ALLOW_SERVER_TRUST_ACCOUNT |
                                                MSV1_0_ALLOW_WORKSTATION_TRUST_ACCOUNT,
                                                challenge,
@@ -755,7 +757,8 @@ static void manage_ntlm_server_1_request(enum stdio_helper_mode stdio_helper_mod
                                flags |= NTLM_AUTH_FLAG_USER_SESSION_KEY;
 
                        if (!NT_STATUS_IS_OK(
-                                   local_pw_check_specified(username, 
+                                   local_pw_check_specified(global_loadparm,
+                                                            username, 
                                                              domain, 
                                                              lp_netbios_name(global_loadparm),
                                                              &challenge,