r26227: Make loadparm_context part of a server task, move loadparm_contexts further...
authorJelmer Vernooij <jelmer@samba.org>
Sun, 2 Dec 2007 16:09:52 +0000 (17:09 +0100)
committerStefan Metzmacher <metze@samba.org>
Fri, 21 Dec 2007 04:47:04 +0000 (05:47 +0100)
(This used to be commit 0721a07aada6a1fae6dcbd610b8783df57d7bbad)

27 files changed:
source4/auth/auth_sam.c
source4/auth/sam.c
source4/cldap_server/cldap_server.c
source4/dsdb/common/sidmap.c
source4/dsdb/repl/drepl_service.c
source4/dsdb/samdb/cracknames.c
source4/dsdb/samdb/samdb.c
source4/dsdb/samdb/samdb.h
source4/dsdb/samdb/samdb_privilege.c
source4/kdc/hdb-ldb.c
source4/kdc/kpasswdd.c
source4/ldap_server/ldap_server.c
source4/nbt_server/dgram/netlogon.c
source4/nbt_server/nbt_server.c
source4/param/loadparm.c
source4/rpc_server/common/server_info.c
source4/rpc_server/drsuapi/dcesrv_drsuapi.c
source4/rpc_server/lsa/lsa_init.c
source4/rpc_server/netlogon/dcerpc_netlogon.c
source4/rpc_server/samr/dcesrv_samr.c
source4/rpc_server/samr/samr_password.c
source4/smb_server/smb_server.c
source4/smbd/service_task.c
source4/smbd/service_task.h
source4/utils/testparm.c
source4/web_server/web_server.c
source4/wrepl_server/wrepl_server.c

index c1fcaa6f72883843ae6cea5bde6689449999c370..42e5ae9e7e09675eb840f5933fb3c945385da41e 100644 (file)
@@ -22,8 +22,8 @@
 #include "includes.h"
 #include "librpc/gen_ndr/ndr_netlogon.h"
 #include "system/time.h"
-#include "util/util_ldb.h"
 #include "lib/ldb/include/ldb.h"
+#include "util/util_ldb.h"
 #include "auth/auth.h"
 #include "auth/auth_sam.h"
 #include "dsdb/samdb/samdb.h"
@@ -283,7 +283,7 @@ static NTSTATUS authsam_check_password_internals(struct auth_method_context *ctx
                return NT_STATUS_NO_MEMORY;
        }
 
-       sam_ctx = samdb_connect(tmp_ctx, system_session(mem_ctx));
+       sam_ctx = samdb_connect(tmp_ctx, global_loadparm, system_session(mem_ctx));
        if (sam_ctx == NULL) {
                talloc_free(tmp_ctx);
                return NT_STATUS_INVALID_SYSTEM_SERVICE;
index 6a212b8cfe75bb4d77bb5a214650f0dad3857b8f..ce02821e8322850dbac3328e2ea34354ffb0bd03 100644 (file)
@@ -439,7 +439,7 @@ NTSTATUS sam_get_server_info_principal(TALLOC_CTX *mem_ctx, const char *principa
                return NT_STATUS_NO_MEMORY;
        }
 
-       sam_ctx = samdb_connect(tmp_ctx, system_session(tmp_ctx));
+       sam_ctx = samdb_connect(tmp_ctx, global_loadparm, system_session(tmp_ctx));
        if (sam_ctx == NULL) {
                talloc_free(tmp_ctx);
                return NT_STATUS_INVALID_SYSTEM_SERVICE;
index ed78f45ca700839aed6c3b670e48e84f12977097..d43669a9e1027ab82d2edd4fc76a4550669f914c 100644 (file)
@@ -159,7 +159,7 @@ static void cldapd_task_init(struct task_server *task)
                return;
        }
 
-       switch (lp_server_role(global_loadparm)) {
+       switch (lp_server_role(task->lp_ctx)) {
        case ROLE_STANDALONE:
                task_server_terminate(task, "cldap_server: no CLDAP server required in standalone configuration");
                return;
@@ -180,7 +180,7 @@ static void cldapd_task_init(struct task_server *task)
        }
 
        cldapd->task = task;
-       cldapd->samctx = samdb_connect(cldapd, anonymous_session(cldapd));
+       cldapd->samctx = samdb_connect(cldapd, task->lp_ctx, anonymous_session(cldapd));
        if (cldapd->samctx == NULL) {
                task_server_terminate(task, "cldapd failed to open samdb");
                return;
index 46052ac2a028d7d12da07a4ccba547a96003f914..8383d2b36bce6e6afcb4e7112092151318909feb 100644 (file)
@@ -27,6 +27,7 @@
 #include "libcli/ldap/ldap.h"
 #include "util/util_ldb.h"
 #include "libcli/security/security.h"
+#include "param/param.h"
 
 /*
   these are used for the fallback local uid/gid to sid mapping
@@ -54,7 +55,7 @@ _PUBLIC_ struct sidmap_context *sidmap_open(TALLOC_CTX *mem_ctx)
        if (sidmap == NULL) {
                return NULL;
        }
-       sidmap->samctx = samdb_connect(sidmap, system_session(sidmap));
+       sidmap->samctx = samdb_connect(sidmap, global_loadparm, system_session(sidmap));
        if (sidmap->samctx == NULL) {
                talloc_free(sidmap);
                return NULL;
index e56e2e179c631ea43b86e9520181c6602403de82..5c74dbfb72581dec15d8a032ce767c94cf8ca2a9 100644 (file)
@@ -50,7 +50,7 @@ static WERROR dreplsrv_connect_samdb(struct dreplsrv_service *service)
        const struct GUID *ntds_guid;
        struct drsuapi_DsBindInfo28 *bind_info28;
 
-       service->samdb = samdb_connect(service, service->system_session_info);
+       service->samdb = samdb_connect(service, global_loadparm, service->system_session_info);
        if (!service->samdb) {
                return WERR_DS_SERVICE_UNAVAILABLE;
        }
index c0c44c8602854e7a0666bfe641555b102f552cfa..c5f1bdaffb2fb502df557e629b21e6b092f8d884 100644 (file)
@@ -33,6 +33,7 @@
 #include "auth/auth.h"
 #include "util/util_ldb.h"
 #include "dsdb/samdb/samdb.h"
+#include "param/param.h"
 
 static WERROR DsCrackNameOneFilter(struct ldb_context *sam_ctx, TALLOC_CTX *mem_ctx,
                                   struct smb_krb5_context *smb_krb5_context,
@@ -1210,7 +1211,7 @@ NTSTATUS crack_name_to_nt4_name(TALLOC_CTX *mem_ctx,
                return NT_STATUS_OK;
        }
 
-       ldb = samdb_connect(mem_ctx, system_session(mem_ctx));
+       ldb = samdb_connect(mem_ctx, global_loadparm, system_session(mem_ctx));
        if (ldb == NULL) {
                return NT_STATUS_INTERNAL_DB_CORRUPTION;
        }
index 310ef17c241bf4ae7d70b4fece2aa0a76dc76441..dd20937ab713e8fa7f31b802f9b942ae88c6b3bb 100644 (file)
@@ -71,11 +71,12 @@ char *samdb_relative_path(struct ldb_context *ldb,
   return an opaque context pointer on success, or NULL on failure
  */
 struct ldb_context *samdb_connect(TALLOC_CTX *mem_ctx, 
+                                 struct loadparm_context *lp_ctx,
                                  struct auth_session_info *session_info)
 {
        struct ldb_context *ldb;
-       ldb = ldb_wrap_connect(mem_ctx, global_loadparm
-                              lp_sam_url(global_loadparm), session_info,
+       ldb = ldb_wrap_connect(mem_ctx, lp_ctx
+                              lp_sam_url(lp_ctx), session_info,
                               NULL, 0, NULL);
        if (!ldb) {
                return NULL;
index 5d39b2cfb0856d86272475660883b047b85311d3..54d1ce2e7581e3364df0f9a52ff3b1feada19fcb 100644 (file)
@@ -26,6 +26,7 @@ struct auth_session_info;
 struct dsdb_control_current_partition;
 struct dsdb_extended_replicated_object;
 struct dsdb_extended_replicated_objects;
+struct loadparm_context;
 
 #include "librpc/gen_ndr/security.h"
 #include "lib/ldb/include/ldb.h"
index 7fe840fca9fc43cf28e934fdade21ef08fb29f0c..468a26bf989d0559bf863203957f7e54fd8c99c9 100644 (file)
@@ -25,6 +25,7 @@
 #include "auth/auth.h"
 #include "libcli/security/security.h"
 #include "util/util_ldb.h"
+#include "param/param.h"
 
 /*
   add privilege bits for one sid to a security_token
@@ -96,7 +97,7 @@ _PUBLIC_ NTSTATUS samdb_privilege_setup(struct security_token *token)
        }
 
        mem_ctx = talloc_new(token);
-       samctx = samdb_connect(mem_ctx, system_session(mem_ctx));
+       samctx = samdb_connect(mem_ctx, global_loadparm, system_session(mem_ctx));
        if (samctx == NULL) {
                talloc_free(mem_ctx);
                return NT_STATUS_INTERNAL_DB_CORRUPTION;
index 125852cfa17f65e45f7eb4bf5f55e3005756953a..a7c5e4b3fb8a0d4ddec608b671b8838ab17b5521 100644 (file)
@@ -1133,7 +1133,7 @@ NTSTATUS kdc_hdb_ldb_create(TALLOC_CTX *mem_ctx,
                                           CRED_DONT_USE_KERBEROS);
 
        /* Setup the link to LDB */
-       (*db)->hdb_db = samdb_connect(*db, session_info);
+       (*db)->hdb_db = samdb_connect(*db, global_loadparm, session_info);
        if ((*db)->hdb_db == NULL) {
                DEBUG(1, ("hdb_ldb_create: Cannot open samdb for KDC backend!"));
                return NT_STATUS_CANT_ACCESS_DOMAIN_INFO;
index 5bda85c96e6da61ad456f448bfed2b93ba776403..35697bef4e4708ae12a7b2f16de31205cafc5588 100644 (file)
@@ -180,7 +180,7 @@ static bool kpasswdd_change_password(struct kdc_server *kdc,
        struct samr_DomInfo1 *dominfo;
        struct ldb_context *samdb;
 
-       samdb = samdb_connect(mem_ctx, system_session(mem_ctx));
+       samdb = samdb_connect(mem_ctx, global_loadparm, system_session(mem_ctx));
        if (!samdb) {
                return kpasswdd_make_error_reply(kdc, mem_ctx, 
                                                KRB5_KPASSWD_HARDERROR,
@@ -310,7 +310,7 @@ static bool kpasswd_process_request(struct kdc_server *kdc,
                
                krb5_free_principal(context, principal);
                
-               samdb = samdb_connect(mem_ctx, session_info);
+               samdb = samdb_connect(mem_ctx, global_loadparm, session_info);
                if (!samdb) {
                        return kpasswdd_make_error_reply(kdc, mem_ctx, 
                                                         KRB5_KPASSWD_HARDERROR,
index c165eb698a0ead2c5666c8fc90690042a4396952..1ee37dceffe37a9cabd03f3c49119ca4aae1707f 100644 (file)
@@ -441,6 +441,7 @@ static const struct stream_server_ops ldap_stream_ops = {
   add a socket address to the list of events, one event per port
 */
 static NTSTATUS add_socket(struct event_context *event_context,
+                          struct loadparm_context *lp_ctx, 
                           const struct model_ops *model_ops,
                           const char *address, struct ldapsrv_service *ldap_service)
 {
@@ -471,7 +472,7 @@ static NTSTATUS add_socket(struct event_context *event_context,
        }
 
        /* Load LDAP database */
-       ldb = samdb_connect(ldap_service, system_session(ldap_service));
+       ldb = samdb_connect(ldap_service, lp_ctx, system_session(ldap_service));
        if (!ldb) {
                return NT_STATUS_INTERNAL_DB_CORRUPTION;
        }
@@ -538,7 +539,7 @@ static void ldapsrv_task_init(struct task_server *task)
        ldap_service->tls_params = tls_initialise(ldap_service);
        if (ldap_service->tls_params == NULL) goto failed;
 
-       if (lp_interfaces(global_loadparm) && lp_bind_interfaces_only(global_loadparm)) {
+       if (lp_interfaces(task->lp_ctx) && lp_bind_interfaces_only(task->lp_ctx)) {
                int num_interfaces = iface_count();
                int i;
 
@@ -548,16 +549,16 @@ static void ldapsrv_task_init(struct task_server *task)
                */
                for(i = 0; i < num_interfaces; i++) {
                        const char *address = iface_n_ip(i);
-                       status = add_socket(task->event_ctx, model_ops, address, ldap_service);
+                       status = add_socket(task->event_ctx, task->lp_ctx, model_ops, address, ldap_service);
                        if (!NT_STATUS_IS_OK(status)) goto failed;
                }
        } else {
-               status = add_socket(task->event_ctx, model_ops, 
-                                   lp_socket_address(global_loadparm), ldap_service);
+               status = add_socket(task->event_ctx, task->lp_ctx, model_ops, 
+                                   lp_socket_address(task->lp_ctx), ldap_service);
                if (!NT_STATUS_IS_OK(status)) goto failed;
        }
 
-       ldapi_path = private_path(ldap_service, global_loadparm, "ldapi");
+       ldapi_path = private_path(ldap_service, task->lp_ctx, "ldapi");
        if (!ldapi_path) {
                goto failed;
        }
index 86720283488c97be904b437748bb3d1d8e1bc470..ab6588348f5038d3c9b2714ad76cef5ad3e4d3e6 100644 (file)
@@ -53,7 +53,7 @@ static void nbtd_netlogon_getdc(struct dgram_mailslot_handler *dgmslot,
                return;
        }
 
-       samctx = samdb_connect(packet, anonymous_session(packet));
+       samctx = samdb_connect(packet, global_loadparm, anonymous_session(packet));
        if (samctx == NULL) {
                DEBUG(2,("Unable to open sam in getdc reply\n"));
                return;
@@ -123,7 +123,7 @@ static void nbtd_netlogon_getdc2(struct dgram_mailslot_handler *dgmslot,
                return;
        }
 
-       samctx = samdb_connect(packet, anonymous_session(packet));
+       samctx = samdb_connect(packet, global_loadparm, anonymous_session(packet));
        if (samctx == NULL) {
                DEBUG(2,("Unable to open sam in getdc reply\n"));
                return;
index abb4593b2cb76dfebbbf4dd4a6b5743e6a92598f..173cea91d02b57993b51e2bd4ab37930f5570d3b 100644 (file)
@@ -62,7 +62,7 @@ static void nbtd_task_init(struct task_server *task)
                return;
        }
 
-       nbtsrv->sam_ctx = samdb_connect(nbtsrv, anonymous_session(nbtsrv));
+       nbtsrv->sam_ctx = samdb_connect(nbtsrv, task->lp_ctx, anonymous_session(nbtsrv));
        if (nbtsrv->sam_ctx == NULL) {
                task_server_terminate(task, "nbtd failed to open samdb");
                return;
index 8e2b8b555c2dac51602260541b0afa0c9631af2f..2d15f9c019b863812bb25c523836937c9df10ad1 100644 (file)
@@ -2127,7 +2127,7 @@ static void dump_a_service(struct loadparm_service * pService, FILE * f)
         }
 }
 
-bool lp_dump_a_parameter(struct loadparm_context *lp_ctx, int snum, char *parm_name, FILE * f, 
+bool lp_dump_a_parameter(struct loadparm_context *lp_ctx, int snum, const char *parm_name, FILE * f, 
                         bool isGlobal)
 {
        struct loadparm_service * pService = lp_ctx->ServicePtrs[snum];
index c6f93f076a696b9338057837b4df655c1160b585..6896c9fada207038a5c0739f7efed32328ad75cf 100644 (file)
@@ -118,7 +118,7 @@ _PUBLIC_ uint32_t dcesrv_common_get_server_type(TALLOC_CTX *mem_ctx, struct dces
                                break;
                        }
                        /* open main ldb */
-                       samctx = samdb_connect(tmp_ctx, anonymous_session(tmp_ctx));
+                       samctx = samdb_connect(tmp_ctx, global_loadparm, anonymous_session(tmp_ctx));
                        if (samctx == NULL) {
                                DEBUG(2,("Unable to open samdb in determining server announce flags\n"));
                        } else {
index a0663a588dc1d9abeab40bc1f86ffea3238b370c..cf2d2599071a9b52c995dccd4c980ece130b2ebe 100644 (file)
@@ -27,6 +27,7 @@
 #include "rpc_server/drsuapi/dcesrv_drsuapi.h"
 #include "dsdb/samdb/samdb.h"
 #include "lib/ldb/include/ldb_errors.h"
+#include "param/param.h"
 
 /* 
   drsuapi_DsBind 
@@ -57,7 +58,7 @@ static WERROR dcesrv_drsuapi_DsBind(struct dcesrv_call_state *dce_call, TALLOC_C
        /*
         * connect to the samdb
         */
-       b_state->sam_ctx = samdb_connect(b_state, dce_call->conn->auth_state.session_info); 
+       b_state->sam_ctx = samdb_connect(b_state, global_loadparm, dce_call->conn->auth_state.session_info); 
        if (!b_state->sam_ctx) {
                return WERR_FOOBAR;
        }
index 6cf062a22ae8a181dd510f157c7ef976f41dbcc6..83607cc446e51d7f174f86b08b9b67aee566422b 100644 (file)
@@ -50,7 +50,7 @@ NTSTATUS dcesrv_lsa_get_policy_state(struct dcesrv_call_state *dce_call, TALLOC_
        }
 
        /* make sure the sam database is accessible */
-       state->sam_ldb = samdb_connect(state, dce_call->conn->auth_state.session_info); 
+       state->sam_ldb = samdb_connect(state, global_loadparm, dce_call->conn->auth_state.session_info); 
        if (state->sam_ldb == NULL) {
                return NT_STATUS_INVALID_SYSTEM_SERVICE;
        }
index d441be807a5def41b3bf117d3bd7b17a7ece6d34..d5e385f70db673580693f231f2412e593ed7c6e7 100644 (file)
@@ -92,7 +92,7 @@ static NTSTATUS dcesrv_netr_ServerAuthenticate3(struct dcesrv_call_state *dce_ca
                return NT_STATUS_ACCESS_DENIED;
        }
 
-       sam_ctx = samdb_connect(mem_ctx, system_session(mem_ctx));
+       sam_ctx = samdb_connect(mem_ctx, global_loadparm, system_session(mem_ctx));
        if (sam_ctx == NULL) {
                return NT_STATUS_INVALID_SYSTEM_SERVICE;
        }
@@ -301,7 +301,7 @@ static NTSTATUS dcesrv_netr_ServerPasswordSet(struct dcesrv_call_state *dce_call
                                                 &creds);
        NT_STATUS_NOT_OK_RETURN(nt_status);
 
-       sam_ctx = samdb_connect(mem_ctx, system_session(mem_ctx));
+       sam_ctx = samdb_connect(mem_ctx, global_loadparm, system_session(mem_ctx));
        if (sam_ctx == NULL) {
                return NT_STATUS_INVALID_SYSTEM_SERVICE;
        }
@@ -339,7 +339,7 @@ static NTSTATUS dcesrv_netr_ServerPasswordSet2(struct dcesrv_call_state *dce_cal
                                                 &creds);
        NT_STATUS_NOT_OK_RETURN(nt_status);
 
-       sam_ctx = samdb_connect(mem_ctx, system_session(mem_ctx));
+       sam_ctx = samdb_connect(mem_ctx, global_loadparm, system_session(mem_ctx));
        if (sam_ctx == NULL) {
                return NT_STATUS_INVALID_SYSTEM_SERVICE;
        }
@@ -885,7 +885,7 @@ static NTSTATUS dcesrv_netr_LogonGetDomainInfo(struct dcesrv_call_state *dce_cal
                                              NULL);
        NT_STATUS_NOT_OK_RETURN(status);
 
-       sam_ctx = samdb_connect(mem_ctx, dce_call->conn->auth_state.session_info);
+       sam_ctx = samdb_connect(mem_ctx, global_loadparm, dce_call->conn->auth_state.session_info);
        if (sam_ctx == NULL) {
                return NT_STATUS_INVALID_SYSTEM_SERVICE;
        }
@@ -989,7 +989,7 @@ static WERROR dcesrv_netr_DsRGetDCNameEx2(struct dcesrv_call_state *dce_call, TA
 
        ZERO_STRUCT(r->out);
 
-       sam_ctx = samdb_connect(mem_ctx, dce_call->conn->auth_state.session_info);
+       sam_ctx = samdb_connect(mem_ctx, global_loadparm, dce_call->conn->auth_state.session_info);
        if (sam_ctx == NULL) {
                return WERR_DS_SERVICE_UNAVAILABLE;
        }
@@ -1147,7 +1147,7 @@ static WERROR dcesrv_netr_DsrEnumerateDomainTrusts(struct dcesrv_call_state *dce
 
        ZERO_STRUCT(r->out);
 
-       sam_ctx = samdb_connect(mem_ctx, dce_call->conn->auth_state.session_info);
+       sam_ctx = samdb_connect(mem_ctx, global_loadparm, dce_call->conn->auth_state.session_info);
        if (sam_ctx == NULL) {
                return WERR_GENERAL_FAILURE;
        }
index 9d208f84441c9e56267d06636ac1f94e9078bcc5..5d83ba84a7357350ae194ea060076604d1499fde 100644 (file)
@@ -141,7 +141,7 @@ static NTSTATUS dcesrv_samr_Connect(struct dcesrv_call_state *dce_call, TALLOC_C
        }
 
        /* make sure the sam database is accessible */
-       c_state->sam_ctx = samdb_connect(c_state, dce_call->conn->auth_state.session_info); 
+       c_state->sam_ctx = samdb_connect(c_state, global_loadparm, dce_call->conn->auth_state.session_info); 
        if (c_state->sam_ctx == NULL) {
                talloc_free(c_state);
                return NT_STATUS_INVALID_SYSTEM_SERVICE;
@@ -4086,7 +4086,7 @@ static NTSTATUS dcesrv_samr_GetDomPwInfo(struct dcesrv_call_state *dce_call, TAL
 
        ZERO_STRUCT(r->out.info);
 
-       sam_ctx = samdb_connect(mem_ctx, dce_call->conn->auth_state.session_info); 
+       sam_ctx = samdb_connect(mem_ctx, global_loadparm, dce_call->conn->auth_state.session_info); 
        if (sam_ctx == NULL) {
                return NT_STATUS_INVALID_SYSTEM_SERVICE;
        }
index a38f9840b666e86cf57c70ef2e99a476f9ad4097..736b85d7eecc1a3c14d073d1e036717caac0827e 100644 (file)
@@ -33,6 +33,7 @@
 #include "rpc_server/samr/proto.h"
 #include "libcli/auth/libcli_auth.h"
 #include "util/util_ldb.h"
+#include "param/param.h"
 
 /* 
   samr_ChangePasswordUser 
@@ -64,7 +65,7 @@ NTSTATUS dcesrv_samr_ChangePasswordUser(struct dcesrv_call_state *dce_call, TALL
        }
 
        /* To change a password we need to open as system */
-       sam_ctx = samdb_connect(mem_ctx, system_session(mem_ctx));
+       sam_ctx = samdb_connect(mem_ctx, global_loadparm, system_session(mem_ctx));
        if (sam_ctx == NULL) {
                return NT_STATUS_INVALID_SYSTEM_SERVICE;
        }
@@ -203,7 +204,7 @@ NTSTATUS dcesrv_samr_OemChangePasswordUser2(struct dcesrv_call_state *dce_call,
        }
 
        /* To change a password we need to open as system */
-       sam_ctx = samdb_connect(mem_ctx, system_session(mem_ctx));
+       sam_ctx = samdb_connect(mem_ctx, global_loadparm, system_session(mem_ctx));
        if (sam_ctx == NULL) {
                return NT_STATUS_INVALID_SYSTEM_SERVICE;
        }
@@ -341,7 +342,7 @@ NTSTATUS dcesrv_samr_ChangePasswordUser3(struct dcesrv_call_state *dce_call,
        }
 
        /* To change a password we need to open as system */
-       sam_ctx = samdb_connect(mem_ctx, system_session(mem_ctx));
+       sam_ctx = samdb_connect(mem_ctx, global_loadparm, system_session(mem_ctx));
        if (sam_ctx == NULL) {
                return NT_STATUS_INVALID_SYSTEM_SERVICE;
        }
index 691934f71c10544921cb614a426326e0bdb1ceaa..9242fb1a1219ea812442b25a9b29288753767bb0 100644 (file)
@@ -203,7 +203,7 @@ static void smbsrv_preopen_ldb(struct task_server *task)
        /* yes, this looks strange. It is a hack to preload the
           schema. I'd like to share most of the ldb context with the
           child too. That will come later */
-       talloc_free(samdb_connect(task, NULL));
+       talloc_free(samdb_connect(task, global_loadparm, NULL));
 }
 
 /*
index c77cae4185e0cbf968fe05328793df15e070a992..dceda5a922f0259e57e8f930db143b30fa1db5c9 100644 (file)
@@ -64,9 +64,10 @@ static void task_server_callback(struct event_context *event_ctx,
        task->event_ctx = event_ctx;
        task->model_ops = state->model_ops;
        task->server_id = server_id;
+       task->lp_ctx = global_loadparm;
 
        task->msg_ctx = messaging_init(task, 
-                                      lp_messaging_path(task, global_loadparm),
+                                      lp_messaging_path(task, task->lp_ctx),
                                       task->server_id, task->event_ctx);
        if (!task->msg_ctx) {
                task_server_terminate(task, "messaging_init() failed");
index e5bf9ea41460cdac056e56abfc1e73050025fca1..207e2cbbca00007654d4b91d95fd8ae95c1c6fcd 100644 (file)
@@ -28,6 +28,7 @@ struct task_server {
        struct event_context *event_ctx;
        const struct model_ops *model_ops;
        struct messaging_context *msg_ctx;
+       struct loadparm_context *lp_ctx;
        struct server_id server_id;
        void *private;
 };
index 71ff937a516a6952e3fc5ff49b7a0c6fa60d04d8..17e6a7274607983ff0ce753404c56290bebbf7a4 100644 (file)
@@ -72,88 +72,17 @@ static int do_global_checks(struct loadparm_context *lp_ctx)
        return ret;
 }   
 
- int main(int argc, const char *argv[])
+
+static int do_share_checks(struct loadparm_context *lp_ctx, const char *cname, const char *caddr, bool silent_mode,
+                          bool show_defaults, const char *section_name, const char *parameter_name)
 {
-       int s;
-       static int silent_mode = 0;
        int ret = 0;
-       poptContext pc;
-/*
-       static int show_all_parameters = 0;
-       static char *new_local_machine = NULL;
-*/
-       static const char *section_name = NULL;
-       static char *parameter_name = NULL;
-       static const char *cname;
-       static const char *caddr;
-       static int show_defaults;
-
-       struct poptOption long_options[] = {
-               POPT_AUTOHELP
-               {"suppress-prompt", 0, POPT_ARG_NONE, &silent_mode, 1, "Suppress prompt for enter"},
-               {"verbose", 'v', POPT_ARG_NONE, &show_defaults, 1, "Show default options too"},
-/*
-  We need support for smb.conf macros before this will work again 
-               {"server", 'L',POPT_ARG_STRING, &new_local_machine, 0, "Set %%L macro to servername\n"},
-*/
-/*
-  These are harder to do with the new code structure
-               {"show-all-parameters", '\0', POPT_ARG_NONE, &show_all_parameters, 1, "Show the parameters, type, possible values" },
-*/
-               {"section-name", '\0', POPT_ARG_STRING, &section_name, 0, "Limit testparm to a named section" },
-               {"parameter-name", '\0', POPT_ARG_STRING, &parameter_name, 0, "Limit testparm to a named parameter" },
-               {"client-name", '\0', POPT_ARG_STRING, &cname, 0, "Client DNS name for 'hosts allow' checking (should match reverse lookup)"},
-               {"client-ip", '\0', POPT_ARG_STRING, &caddr, 0, "Client IP address for 'hosts allow' checking"},
-               POPT_COMMON_SAMBA
-               POPT_COMMON_VERSION
-               { NULL }
-       };
-
-       setup_logging(NULL, DEBUG_STDERR);
-
-       pc = poptGetContext(NULL, argc, argv, long_options, 
-                           POPT_CONTEXT_KEEP_FIRST);
-       poptSetOtherOptionHelp(pc, "[OPTION...] [host-name] [host-ip]");
-
-       while(poptGetNextOpt(pc) != -1);
-
-/* 
-       if (show_all_parameters) {
-               show_parameter_list();
-               exit(0);
-       }
-*/
-
-       if ( cname && ! caddr ) {
-               printf ( "ERROR: For 'hosts allow' check you must specify both a DNS name and an IP address.\n" );
-               return(1);
-       }
-/*
-  We need support for smb.conf macros before this will work again 
-
-       if (new_local_machine) {
-               set_local_machine_name(new_local_machine, True);
-       }
-*/
-       
-       /* We need this to force the output */
-       lp_set_cmdline(global_loadparm, "log level", "2");
-
-       fprintf(stderr, "Loaded smb config files from %s\n", lp_configfile(global_loadparm));
-
-       if (!lp_load(lp_configfile(global_loadparm))) {
-               fprintf(stderr,"Error loading services.\n");
-               return(1);
-       }
-
-       fprintf(stderr,"Loaded services file OK.\n");
-
-       ret = do_global_checks(global_loadparm);
+       int s;
 
-       for (s=0;s<lp_numservices(global_loadparm);s++) {
-               struct loadparm_service *service = lp_servicebynum(global_loadparm, s);
+       for (s=0;s<lp_numservices(lp_ctx);s++) {
+               struct loadparm_service *service = lp_servicebynum(lp_ctx, s);
                if (service != NULL)
-                       if (strlen(lp_servicename(lp_servicebynum(global_loadparm, s))) > 12) {
+                       if (strlen(lp_servicename(lp_servicebynum(lp_ctx, s))) > 12) {
                                fprintf(stderr, "WARNING: You have some share names that are longer than 12 characters.\n" );
                                fprintf(stderr, "These may not be accessible to some older clients.\n" );
                                fprintf(stderr, "(Eg. Windows9x, WindowsMe, and not listed in smbclient in Samba 3.0.)\n" );
@@ -161,8 +90,8 @@ static int do_global_checks(struct loadparm_context *lp_ctx)
                        }
        }
 
-       for (s=0;s<lp_numservices(global_loadparm);s++) {
-               struct loadparm_service *service = lp_servicebynum(global_loadparm, s);
+       for (s=0;s<lp_numservices(lp_ctx);s++) {
+               struct loadparm_service *service = lp_servicebynum(lp_ctx, s);
                if (service != NULL) {
                        const char **deny_list = lp_hostsdeny(service);
                        const char **allow_list = lp_hostsallow(service);
@@ -204,7 +133,7 @@ static int do_global_checks(struct loadparm_context *lp_ctx)
                                section_name = GLOBAL_NAME;
                                service = NULL;
                        } else if ((!strwicmp(section_name, GLOBAL_NAME)) == 0 &&
-                                (service=lp_service(global_loadparm, section_name)) == NULL) {
+                                (service=lp_service(lp_ctx, section_name)) == NULL) {
                                        fprintf(stderr,"Unknown section %s\n",
                                                section_name);
                                        return(1);
@@ -212,18 +141,18 @@ static int do_global_checks(struct loadparm_context *lp_ctx)
                        if (!parameter_name) {
                                lp_dump_one(stdout, show_defaults, service);
                        } else {
-                               ret = !lp_dump_a_parameter(global_loadparm, s, parameter_name, stdout, (service == NULL));
+                               ret = !lp_dump_a_parameter(lp_ctx, s, parameter_name, stdout, (service == NULL));
                        }
                } else {
-                       lp_dump(global_loadparm, stdout, show_defaults, lp_numservices(global_loadparm));
+                       lp_dump(lp_ctx, stdout, show_defaults, lp_numservices(lp_ctx));
                }
                return(ret);
        }
 
        if(cname && caddr){
                /* this is totally ugly, a real `quick' hack */
-               for (s=0;s<lp_numservices(global_loadparm);s++) {
-                       struct loadparm_service *service = lp_servicebynum(global_loadparm, s);
+               for (s=0;s<lp_numservices(lp_ctx);s++) {
+                       struct loadparm_service *service = lp_servicebynum(lp_ctx, s);
                        if (service != NULL) {
                                if (allow_access(NULL, lp_hostsdeny(NULL), lp_hostsallow(NULL), cname, caddr)
                                    && allow_access(NULL, lp_hostsdeny(service), lp_hostsallow(service), cname, caddr)) {
@@ -236,6 +165,90 @@ static int do_global_checks(struct loadparm_context *lp_ctx)
                        }
                }
        }
+
+       return ret;
+}
+
+
+ int main(int argc, const char *argv[])
+{
+       static bool silent_mode = false;
+       int ret = 0;
+       poptContext pc;
+/*
+       static int show_all_parameters = 0;
+       static char *new_local_machine = NULL;
+*/
+       static const char *section_name = NULL;
+       static char *parameter_name = NULL;
+       static const char *cname;
+       static const char *caddr;
+       static bool show_defaults = false;
+
+       struct poptOption long_options[] = {
+               POPT_AUTOHELP
+               {"suppress-prompt", 0, POPT_ARG_NONE, &silent_mode, true, "Suppress prompt for enter"},
+               {"verbose", 'v', POPT_ARG_NONE, &show_defaults, true, "Show default options too"},
+/*
+  We need support for smb.conf macros before this will work again 
+               {"server", 'L',POPT_ARG_STRING, &new_local_machine, 0, "Set %%L macro to servername\n"},
+*/
+/*
+  These are harder to do with the new code structure
+               {"show-all-parameters", '\0', POPT_ARG_NONE, &show_all_parameters, 1, "Show the parameters, type, possible values" },
+*/
+               {"section-name", '\0', POPT_ARG_STRING, &section_name, 0, "Limit testparm to a named section" },
+               {"parameter-name", '\0', POPT_ARG_STRING, &parameter_name, 0, "Limit testparm to a named parameter" },
+               {"client-name", '\0', POPT_ARG_STRING, &cname, 0, "Client DNS name for 'hosts allow' checking (should match reverse lookup)"},
+               {"client-ip", '\0', POPT_ARG_STRING, &caddr, 0, "Client IP address for 'hosts allow' checking"},
+               POPT_COMMON_SAMBA
+               POPT_COMMON_VERSION
+               { NULL }
+       };
+
+       setup_logging(NULL, DEBUG_STDERR);
+
+       pc = poptGetContext(NULL, argc, argv, long_options, 
+                           POPT_CONTEXT_KEEP_FIRST);
+       poptSetOtherOptionHelp(pc, "[OPTION...] [host-name] [host-ip]");
+
+       while(poptGetNextOpt(pc) != -1);
+
+/* 
+       if (show_all_parameters) {
+               show_parameter_list();
+               exit(0);
+       }
+*/
+
+       if ( cname && ! caddr ) {
+               printf ( "ERROR: For 'hosts allow' check you must specify both a DNS name and an IP address.\n" );
+               return(1);
+       }
+/*
+  We need support for smb.conf macros before this will work again 
+
+       if (new_local_machine) {
+               set_local_machine_name(new_local_machine, True);
+       }
+*/
+       
+       /* We need this to force the output */
+       lp_set_cmdline(global_loadparm, "log level", "2");
+
+       fprintf(stderr, "Loaded smb config files from %s\n", lp_configfile(global_loadparm));
+
+       if (!lp_load(lp_configfile(global_loadparm))) {
+               fprintf(stderr,"Error loading services.\n");
+               return(1);
+       }
+
+       fprintf(stderr,"Loaded services file OK.\n");
+
+       ret = do_global_checks(global_loadparm);
+
+       ret |= do_share_checks(global_loadparm, cname, caddr, silent_mode, show_defaults, section_name, parameter_name);
+
        return(ret);
 }
 
index 2e803398716c6553d650130990cc0f476a490966..3926993334b6036f74fecd06c0fa27faa08c566d 100644 (file)
@@ -241,7 +241,7 @@ static const struct stream_server_ops web_stream_ops = {
 static void websrv_task_init(struct task_server *task)
 {
        NTSTATUS status;
-       uint16_t port = lp_web_port(global_loadparm);
+       uint16_t port = lp_web_port(task->lp_ctx);
        const struct model_ops *model_ops;
 
        task_server_set_title(task, "task[websrv]");
@@ -250,7 +250,7 @@ static void websrv_task_init(struct task_server *task)
        model_ops = process_model_byname("single");
        if (!model_ops) goto failed;
 
-       if (lp_interfaces(global_loadparm) && lp_bind_interfaces_only(global_loadparm)) {
+       if (lp_interfaces(task->lp_ctx) && lp_bind_interfaces_only(task->lp_ctx)) {
                int num_interfaces = iface_count();
                int i;
                for(i = 0; i < num_interfaces; i++) {
@@ -264,7 +264,7 @@ static void websrv_task_init(struct task_server *task)
        } else {
                status = stream_setup_socket(task->event_ctx, model_ops, 
                                             &web_stream_ops, 
-                                            "ipv4", lp_socket_address(global_loadparm), 
+                                            "ipv4", lp_socket_address(task->lp_ctx), 
                                             &port, task);
                if (!NT_STATUS_IS_OK(status)) goto failed;
        }
index cec2e6e65e64e19849465b3949519a73501dcc1c..91f0a4fb053124b5a5e1b9796c85fd0aab13f77d 100644 (file)
@@ -458,7 +458,7 @@ static void wreplsrv_task_init(struct task_server *task)
        /*
         * setup up all partners, and open the winsdb
         */
-       status = wreplsrv_open_winsdb(service, global_loadparm);
+       status = wreplsrv_open_winsdb(service, task->lp_ctx);
        if (!NT_STATUS_IS_OK(status)) {
                task_server_terminate(task, "wreplsrv_task_init: wreplsrv_open_winsdb() failed");
                return;