r26580: Include sentinel in build.h, in case the list is empty.
[samba.git] / source4 / auth / gensec / gensec.c
index 4821e6a19bd39ef3e32789144fdd86cce76c6046..cd2066d9fd5f93044fa92e68497a9794350410f0 100644 (file)
@@ -453,7 +453,7 @@ const char **gensec_security_oids_from_ops_wrapped(TALLOC_CTX *mem_ctx,
 /**
  * Return all the security subsystems currently enabled on a GENSEC context.
  * 
- * This is taken from a list attached to the cli_credentails, and
+ * This is taken from a list attached to the cli_credentials, and
  * skips the OID in 'skip'.  (Typically the SPNEGO OID)
  * 
  */
@@ -477,6 +477,7 @@ const char **gensec_security_oids(struct gensec_security *gensec_security,
 */
 static NTSTATUS gensec_start(TALLOC_CTX *mem_ctx, 
                             struct event_context *ev,
+                            struct loadparm_context *lp_ctx,
                             struct messaging_context *msg,
                             struct gensec_security **gensec_security)
 {
@@ -502,6 +503,7 @@ static NTSTATUS gensec_start(TALLOC_CTX *mem_ctx,
 
        (*gensec_security)->event_ctx = ev;
        (*gensec_security)->msg_ctx = msg;
+       (*gensec_security)->lp_ctx = lp_ctx;
 
        return NT_STATUS_OK;
 }
@@ -528,6 +530,7 @@ _PUBLIC_ NTSTATUS gensec_subcontext_start(TALLOC_CTX *mem_ctx,
        (*gensec_security)->subcontext = true;
        (*gensec_security)->event_ctx = parent->event_ctx;
        (*gensec_security)->msg_ctx = parent->msg_ctx;
+       (*gensec_security)->lp_ctx = parent->lp_ctx;
 
        return NT_STATUS_OK;
 }
@@ -540,7 +543,8 @@ _PUBLIC_ NTSTATUS gensec_subcontext_start(TALLOC_CTX *mem_ctx,
 */
 _PUBLIC_ NTSTATUS gensec_client_start(TALLOC_CTX *mem_ctx, 
                             struct gensec_security **gensec_security,
-                            struct event_context *ev)
+                            struct event_context *ev,
+                            struct loadparm_context *lp_ctx)
 {
        NTSTATUS status;
        struct event_context *new_ev = NULL;
@@ -551,7 +555,7 @@ _PUBLIC_ NTSTATUS gensec_client_start(TALLOC_CTX *mem_ctx,
                ev = new_ev;
        }
 
-       status = gensec_start(mem_ctx, ev, NULL, gensec_security);
+       status = gensec_start(mem_ctx, ev, lp_ctx, NULL, gensec_security);
        if (!NT_STATUS_IS_OK(status)) {
                talloc_free(new_ev);
                return status;
@@ -570,6 +574,7 @@ _PUBLIC_ NTSTATUS gensec_client_start(TALLOC_CTX *mem_ctx,
 */
 NTSTATUS gensec_server_start(TALLOC_CTX *mem_ctx, 
                             struct event_context *ev,
+                            struct loadparm_context *lp_ctx,
                             struct messaging_context *msg,
                             struct gensec_security **gensec_security)
 {
@@ -585,7 +590,7 @@ NTSTATUS gensec_server_start(TALLOC_CTX *mem_ctx,
                return NT_STATUS_INTERNAL_ERROR;
        }
 
-       status = gensec_start(mem_ctx, ev, msg, gensec_security);
+       status = gensec_start(mem_ctx, ev, lp_ctx, msg, gensec_security);
        if (!NT_STATUS_IS_OK(status)) {
                return status;
        }
@@ -1108,7 +1113,7 @@ _PUBLIC_ NTSTATUS gensec_set_target_hostname(struct gensec_security *gensec_secu
 _PUBLIC_ const char *gensec_get_target_hostname(struct gensec_security *gensec_security) 
 {
        /* We allow the target hostname to be overriden for testing purposes */
-       const char *target_hostname = lp_parm_string(global_loadparm, NULL, "gensec", "target_hostname");
+       const char *target_hostname = lp_parm_string(gensec_security->lp_ctx, NULL, "gensec", "target_hostname");
        if (target_hostname) {
                return target_hostname;
        }
@@ -1259,17 +1264,17 @@ static int sort_gensec(struct gensec_security_ops **gs1, struct gensec_security_
 /*
   initialise the GENSEC subsystem
 */
-NTSTATUS gensec_init(void)
+NTSTATUS gensec_init(struct loadparm_context *lp_ctx)
 {
        static bool initialized = false;
 
-       init_module_fn static_init[] = STATIC_gensec_MODULES;
+       init_module_fn static_init[] = { STATIC_gensec_MODULES };
        init_module_fn *shared_init;
 
        if (initialized) return NT_STATUS_OK;
        initialized = true;
        
-       shared_init = load_samba_modules(NULL, global_loadparm, "gensec");
+       shared_init = load_samba_modules(NULL, lp_ctx, "gensec");
 
        run_init_functions(static_init);
        run_init_functions(shared_init);