winbindd: winbindd_ccache_ntlm_auth() -> bool_dispatch_table
[samba.git] / auth / gensec / spnego.c
index ce3e3c5786303c44ef1a01a85769f1617bcd1a3a..0b3fbdce7acd1b44a85f1109d4e2961e0d5668e0 100644 (file)
@@ -34,6 +34,9 @@
 #include "lib/util/asn1.h"
 #include "lib/util/base64.h"
 
+#undef DBGC_CLASS
+#define DBGC_CLASS DBGC_AUTH
+
 #undef strcasecmp
 
 _PUBLIC_ NTSTATUS gensec_spnego_init(TALLOC_CTX *ctx);
@@ -159,7 +162,7 @@ static struct spnego_neg_state *gensec_spnego_neg_state(TALLOC_CTX *mem_ctx,
        return n;
 }
 
-static void gensec_spnego_update_sub_abort(struct spnego_state *spnego_state)
+static void gensec_spnego_reset_sub_sec(struct spnego_state *spnego_state)
 {
        spnego_state->sub_sec_ready = false;
        TALLOC_FREE(spnego_state->sub_sec_security);
@@ -369,7 +372,7 @@ static NTSTATUS gensec_spnego_create_negTokenInit_step(
                /*
                 * Pretend we never started it
                 */
-               gensec_spnego_update_sub_abort(spnego_state);
+               gensec_spnego_reset_sub_sec(spnego_state);
 
                /*
                 * And try the next one...
@@ -393,7 +396,7 @@ static NTSTATUS gensec_spnego_create_negTokenInit_step(
                status = gensec_start_mech_by_ops(spnego_state->sub_sec_security,
                                                  cur_sec->op);
                if (!NT_STATUS_IS_OK(status)) {
-                       gensec_spnego_update_sub_abort(spnego_state);
+                       gensec_spnego_reset_sub_sec(spnego_state);
                        continue;
                }
 
@@ -597,7 +600,7 @@ static NTSTATUS gensec_spnego_client_negTokenInit_step(
                /*
                 * Pretend we never started it.
                 */
-               gensec_spnego_update_sub_abort(spnego_state);
+               gensec_spnego_reset_sub_sec(spnego_state);
 
                /*
                 * And try the next one...
@@ -621,7 +624,7 @@ static NTSTATUS gensec_spnego_client_negTokenInit_step(
                status = gensec_start_mech_by_ops(spnego_state->sub_sec_security,
                                                  cur_sec->op);
                if (!NT_STATUS_IS_OK(status)) {
-                       gensec_spnego_update_sub_abort(spnego_state);
+                       gensec_spnego_reset_sub_sec(spnego_state);
                        continue;
                }
 
@@ -756,7 +759,7 @@ static NTSTATUS gensec_spnego_client_negTokenTarg_start(
                           client_mech, client_oid, server_mech, server_oid);
 
                spnego_state->downgraded = true;
-               gensec_spnego_update_sub_abort(spnego_state);
+               gensec_spnego_reset_sub_sec(spnego_state);
 
                status = gensec_subcontext_start(spnego_state,
                                                 gensec_security,
@@ -1224,7 +1227,7 @@ static NTSTATUS gensec_spnego_server_negTokenInit_step(
                /*
                 * Pretend we never started it
                 */
-               gensec_spnego_update_sub_abort(spnego_state);
+               gensec_spnego_reset_sub_sec(spnego_state);
 
                /*
                 * And try the next one, based on the clients
@@ -1274,7 +1277,7 @@ static NTSTATUS gensec_spnego_server_negTokenInit_step(
                        /*
                         * Pretend we never started it
                         */
-                       gensec_spnego_update_sub_abort(spnego_state);
+                       gensec_spnego_reset_sub_sec(spnego_state);
                        continue;
                }
 
@@ -1646,7 +1649,7 @@ static struct tevent_req *gensec_spnego_update_send(TALLOC_CTX *mem_ctx,
                        return tevent_req_post(req, ev);
                }
 
-               /* fall through */
+               FALL_THROUGH;
        case SPNEGO_CLIENT_START:
        case SPNEGO_SERVER_START:
 
@@ -1741,7 +1744,9 @@ static NTSTATUS gensec_spnego_update_in(struct gensec_security *gensec_security,
                                        const DATA_BLOB in, TALLOC_CTX *mem_ctx,
                                        DATA_BLOB *full_in)
 {
-       struct spnego_state *spnego_state = (struct spnego_state *)gensec_security->private_data;
+       struct spnego_state *spnego_state =
+               talloc_get_type_abort(gensec_security->private_data,
+               struct spnego_state);
        size_t expected;
        bool ok;
 
@@ -2070,7 +2075,9 @@ static NTSTATUS gensec_spnego_update_out(struct gensec_security *gensec_security
                                         TALLOC_CTX *out_mem_ctx,
                                         DATA_BLOB *_out)
 {
-       struct spnego_state *spnego_state = (struct spnego_state *)gensec_security->private_data;
+       struct spnego_state *spnego_state =
+               talloc_get_type_abort(gensec_security->private_data,
+               struct spnego_state);
        DATA_BLOB out = data_blob_null;
        bool ok;
 
@@ -2178,7 +2185,8 @@ static const struct gensec_security_ops gensec_spnego_security_ops = {
        .expire_time      = gensec_child_expire_time,
        .final_auth_type  = gensec_child_final_auth_type,
        .enabled          = true,
-       .priority         = GENSEC_SPNEGO
+       .priority         = GENSEC_SPNEGO,
+       .glue             = true,
 };
 
 _PUBLIC_ NTSTATUS gensec_spnego_init(TALLOC_CTX *ctx)