s3-auth Allow auth modules to provide an initialised GENSEC context
authorAndrew Bartlett <abartlet@samba.org>
Thu, 21 Jul 2011 04:27:00 +0000 (14:27 +1000)
committerAndrew Bartlett <abartlet@samba.org>
Wed, 3 Aug 2011 08:48:02 +0000 (18:48 +1000)
This will allow auth plugins such as auth_samba4 to provide an initialised
GENSEC context to auth subsystem callers.

Andrew Bartlett

Signed-off-by: Andrew Tridgell <tridge@samba.org>
source3/auth/auth.c
source3/include/auth.h

index a7fe1c624cfd3bf1017a58ab0cfe80a611a85986..df93e0d27a8953dd8cabb12e438d09a04581a57f 100644 (file)
@@ -438,7 +438,7 @@ static NTSTATUS make_auth_context_text_list(TALLOC_CTX *mem_ctx,
                                            char **text_list)
 {
        auth_methods *list = NULL;
-       auth_methods *t = NULL;
+       auth_methods *t, *method = NULL;
        NTSTATUS nt_status;
 
        if (!text_list) {
@@ -460,7 +460,14 @@ static NTSTATUS make_auth_context_text_list(TALLOC_CTX *mem_ctx,
 
        (*auth_context)->auth_method_list = list;
 
-       return nt_status;
+       /* Look for the first module to provide a start_gensec hook, and set that if provided */
+       for (method = (*auth_context)->auth_method_list; method; method = method->next) {
+               if (method->start_gensec) {
+                       (*auth_context)->start_gensec = method->start_gensec;
+                       break;
+               }
+       }
+       return NT_STATUS_OK;
 }
 
 /***************************************************************************
index 4f7cb9bb1487d1aab6727b571954e762352b963e..3545e27d201480b3adff0afe457f89b6152e7016 100644 (file)
@@ -21,6 +21,8 @@
 
 #include "../auth/common_auth.h"
 
+struct gensec_security;
+
 struct extra_auth_info {
        struct dom_sid user_sid;
        struct dom_sid pgid_sid;
@@ -93,6 +95,9 @@ struct auth_context {
                                        const struct auth_usersupplied_info *user_info, 
                                        struct auth_serversupplied_info **server_info);
        NTSTATUS (*nt_status_squash)(NTSTATUS nt_status);
+
+       NTSTATUS (*start_gensec)(TALLOC_CTX *mem_ctx, const char *oid_string,
+                                struct gensec_security **gensec_context);
 };
 
 typedef struct auth_methods
@@ -114,6 +119,10 @@ typedef struct auth_methods
                              void **my_private_data, 
                              TALLOC_CTX *mem_ctx);
 
+       /* Optional method allowing this module to provide a way to get a gensec context */
+       NTSTATUS (*start_gensec)(TALLOC_CTX *mem_ctx, const char *oid_string,
+                                struct gensec_security **gensec_context);
+
        /* Used to keep tabs on things like the cli for SMB server authentication */
        void *private_data;