Make verto context available to kdcpreauth modules
authorGreg Hudson <ghudson@mit.edu>
Tue, 15 Nov 2011 02:42:58 +0000 (02:42 +0000)
committerGreg Hudson <ghudson@mit.edu>
Tue, 15 Nov 2011 02:42:58 +0000 (02:42 +0000)
Add an event_context callback to kdcpreauth.  Adjust the internal KDC
and main loop interfaces to pass around the event context, and expose
it to kdcpreauth modules via the rock.

ticket: 7019
target_version: 1.10
tags: pullup

git-svn-id: svn://anonsvn.mit.edu/krb5/trunk@25475 dc483132-0cff-0310-8789-dd5450dbe970

src/include/krb5/preauth_plugin.h
src/include/net-server.h
src/kadmin/server/schpw.c
src/kdc/dispatch.c
src/kdc/do_as_req.c
src/kdc/kdc_preauth.c
src/kdc/kdc_util.h
src/lib/apputils/net-server.c

index cbc57f147bd509c661dfa221b668c0f74f4f0623..7506b011b561f1f4b8ce09a1a4c6164adf391bcf 100644 (file)
@@ -377,6 +377,11 @@ typedef struct krb5_kdcpreauth_callbacks_st {
      * avoid a dependency on a libkdb5 type). */
     void *(*client_entry)(krb5_context context, krb5_kdcpreauth_rock rock);
 
+    /* Get a pointer to the verto context an asynchronous plugin should
+     * use to create events in the edata or verify method. */
+    struct verto_ctx *(*event_context)(krb5_context context,
+                                       krb5_kdcpreauth_rock rock);
+
     /* End of version 1 kdcpreauth callbacks. */
 } *krb5_kdcpreauth_callbacks;
 
index e84bdac242b4b6d9c54f865fcbc58b2decfb5635..43310ceb04d6e4b60d40f627b9e99e08826913a7 100644 (file)
@@ -68,7 +68,7 @@ typedef void (*loop_respond_fn)(void *arg, krb5_error_code code,
                                 krb5_data *response);
 void dispatch(void *handle, struct sockaddr *local_addr,
               const krb5_fulladdr *remote_addr, krb5_data *request,
-              int is_tcp, loop_respond_fn respond, void *arg);
+              int is_tcp, verto_ctx *vctx, loop_respond_fn respond, void *arg);
 krb5_error_code make_toolong_error (void *handle, krb5_data **);
 
 /*
index 8e38cfd04304db86cd98bd660dabb6cd40396294..d2df5db73bba93313942e65f18b4bc7a4911a556 100644 (file)
@@ -442,7 +442,7 @@ bailout:
 void
 dispatch(void *handle, struct sockaddr *local_saddr,
          const krb5_fulladdr *remote_faddr, krb5_data *request, int is_tcp,
-         loop_respond_fn respond, void *arg)
+         verto_ctx *vctx, loop_respond_fn respond, void *arg)
 {
     krb5_error_code ret;
     krb5_keytab kt = NULL;
index 1398a33b67d6f519f0239369716da284264d43ba..b4c02f3247ef874672cca731478760cf5e59e426 100644 (file)
@@ -81,8 +81,9 @@ finish_dispatch(void *arg, krb5_error_code code, krb5_data *response)
 }
 
 void
-dispatch(void *cb, struct sockaddr *local_saddr, const krb5_fulladdr *from,
-         krb5_data *pkt, int is_tcp, loop_respond_fn respond, void *arg)
+dispatch(void *cb, struct sockaddr *local_saddr,
+         const krb5_fulladdr *from, krb5_data *pkt, int is_tcp,
+         verto_ctx *vctx, loop_respond_fn respond, void *arg)
 {
     krb5_error_code retval;
     krb5_kdc_req *as_req;
@@ -166,7 +167,8 @@ dispatch(void *cb, struct sockaddr *local_saddr, const krb5_fulladdr *from,
              * process_as_req frees the request if it is called
              */
             if (!(retval = setup_server_realm(as_req->server))) {
-                process_as_req(as_req, pkt, from, finish_dispatch, state);
+                process_as_req(as_req, pkt, from, vctx, finish_dispatch,
+                               state);
                 return;
             }
             else
index a9f31fbea3ca96bba43a53ef833bf0e73c05d6c2..61d088eb626a3990f4abaf323079531a2c1f2880 100644 (file)
@@ -452,7 +452,8 @@ finish_preauth(void *arg, krb5_error_code code)
 /*ARGSUSED*/
 void
 process_as_req(krb5_kdc_req *request, krb5_data *req_pkt,
-               const krb5_fulladdr *from, loop_respond_fn respond, void *arg)
+               const krb5_fulladdr *from, verto_ctx *vctx,
+               loop_respond_fn respond, void *arg)
 {
     krb5_error_code errcode;
     krb5_timestamp rtime;
@@ -512,6 +513,7 @@ process_as_req(krb5_kdc_req *request, krb5_data *req_pkt,
     state->rock.request = state->request;
     state->rock.inner_body = state->inner_body;
     state->rock.rstate = state->rstate;
+    state->rock.vctx = vctx;
     if (!state->request->client) {
         state->status = "NULL_CLIENT";
         errcode = KRB5KDC_ERR_C_PRINCIPAL_UNKNOWN;
index 4c5ef88de8ff5c177fec19785607da1b01d0b4b5..31c2e144cd9a98496ab94132e2ac0a3f7ac44cb8 100644 (file)
@@ -574,6 +574,12 @@ client_entry(krb5_context context, krb5_kdcpreauth_rock rock)
     return rock->client;
 }
 
+static verto_ctx *
+event_context(krb5_context context, krb5_kdcpreauth_rock rock)
+{
+    return rock->vctx;
+}
+
 static struct krb5_kdcpreauth_callbacks_st callbacks = {
     1,
     max_time_skew,
@@ -583,7 +589,8 @@ static struct krb5_kdcpreauth_callbacks_st callbacks = {
     fast_armor,
     get_string,
     free_string,
-    client_entry
+    client_entry,
+    event_context
 };
 
 static krb5_error_code
index 9e123ee8e90bb54812ff8bb103cf9758219d277f..e80ce106f6e05f31142d61679b20847a1c3cbf34 100644 (file)
@@ -117,7 +117,7 @@ rep_etypes2str(char *s, size_t len, krb5_kdc_rep *rep);
 void
 process_as_req (krb5_kdc_req *, krb5_data *,
                 const krb5_fulladdr *,
-                loop_respond_fn, void *);
+                verto_ctx *, loop_respond_fn, void *);
 
 /* do_tgs_req.c */
 krb5_error_code
@@ -131,6 +131,7 @@ dispatch (void *,
           const krb5_fulladdr *,
           krb5_data *,
           int,
+          verto_ctx *,
           loop_respond_fn,
           void *);
 
@@ -164,9 +165,9 @@ missing_required_preauth (krb5_db_entry *client,
                           krb5_enc_tkt_part *enc_tkt_reply);
 typedef void (*kdc_hint_respond_fn)(void *arg);
 void
-get_preauth_hint_list(krb5_kdc_req *request, krb5_kdcpreauth_rock rock,
-                      krb5_pa_data ***e_data_out, kdc_hint_respond_fn respond,
-                      void *arg);
+get_preauth_hint_list(krb5_kdc_req *request,
+                      krb5_kdcpreauth_rock rock, krb5_pa_data ***e_data_out,
+                      kdc_hint_respond_fn respond, void *arg);
 void
 load_preauth_plugins(krb5_context context);
 void
@@ -396,6 +397,7 @@ struct krb5_kdcpreauth_rock_st {
     krb5_db_entry *client;
     krb5_key_data *client_key;
     struct kdc_request_state *rstate;
+    verto_ctx *vctx;
 };
 
 #define isflagset(flagfield, flag) (flagfield & (flag))
index 9df909faca61e12c3acfb36559009f45cbb8e456..43be27c95141ab46fe35d152972fc5ee5e3c95ef 100644 (file)
@@ -1665,7 +1665,7 @@ process_packet(verto_ctx *ctx, verto_ev *ev)
     init_addr(&state->faddr, ss2sa(&state->saddr));
     /* This address is in net order. */
     dispatch(state->handle, ss2sa(&state->daddr), &state->faddr,
-             &state->request, 0, process_packet_response, state);
+             &state->request, 0, ctx, process_packet_response, state);
 }
 
 static int
@@ -1936,7 +1936,7 @@ process_tcp_connection_read(verto_ctx *ctx, verto_ev *ev)
             local_saddrp = ss2sa(&state->local_saddr);
 
         dispatch(state->conn->handle, local_saddrp, &conn->faddr,
-                 &state->request, 1, process_tcp_response, state);
+                 &state->request, 1, ctx, process_tcp_response, state);
     }
 
     return;