]> eyrie.org Git - kerberos/krb5-sync.git/commitdiff
Pass the Kerberos context into all internal functions
authorRuss Allbery <eagle@eyrie.org>
Wed, 20 Nov 2013 23:00:13 +0000 (15:00 -0800)
committerRuss Allbery <eagle@eyrie.org>
Wed, 20 Nov 2013 23:00:13 +0000 (15:00 -0800)
Standardize the API so that all functions except the init and
shutdown take the plugin configuration and the Kerberos context,
and stop internally creating and removing Kerberos contexts.  Stop
using void * in a bunch of places, isolating that to the MIT and
Heimdal plugin code.

plugin/ad.c
plugin/api.c
plugin/heimdal.c
plugin/instance.c
plugin/internal.h
plugin/mit.c
tests/plugin/queue-only-t.c
tests/plugin/queuing-t.c
tools/krb5-sync.c

index 2e9534edafdac826f2ebe9bca9db7477102eb537..5fe371c1b98fe2ffd4237d1a822dfbdc8c060769 100644 (file)
@@ -138,7 +138,7 @@ get_creds(struct plugin_config *config, krb5_context ctx, krb5_ccache *cc,
  * Kerberos error code on failure.
  */
 static krb5_error_code
-get_ad_principal(krb5_context ctx, struct plugin_config *config,
+get_ad_principal(struct plugin_config *config, krb5_context ctx,
                  krb5_const_principal principal, krb5_principal *ad_principal)
 {
     krb5_error_code ret;
@@ -209,7 +209,7 @@ pwupdate_ad_change(struct plugin_config *config, krb5_context ctx,
         return 1;
 
     /* Get the corresponding Active Directory principal. */
-    ret = get_ad_principal(ctx, config, principal, &ad_principal);
+    ret = get_ad_principal(config, ctx, principal, &ad_principal);
     if (ret != 0) {
         pwupdate_set_error(errstr, errstrlen, ctx, ret,
                            "unable to get AD principal");
@@ -371,7 +371,7 @@ pwupdate_ad_status(struct plugin_config *config, krb5_context ctx,
      * the AD principal and then query Active Directory via LDAP to get back
      * the CN for the user to construct the full DN.
      */
-    ret = get_ad_principal(ctx, config, principal, &ad_principal);
+    ret = get_ad_principal(config, ctx, principal, &ad_principal);
     if (ret != 0) {
         pwupdate_set_error(errstr, errstrlen, ctx, ret,
                            "unable to get AD principal");
index fab3cd6b4b7773df51b488e53532041fc9f3ecfa..5f34bb45ff17796af523672fe03c5ca21cb61373 100644 (file)
@@ -37,7 +37,7 @@
  * This function returns failure only if it could not allocate memory.
  */
 int
-pwupdate_init(krb5_context ctx, void **data)
+pwupdate_init(struct plugin_config **result, krb5_context ctx)
 {
     struct plugin_config *config;
 
@@ -66,7 +66,7 @@ pwupdate_init(krb5_context ctx, void **data)
     sync_config_string(ctx, "queue_dir", &config->queue_dir);
 
     /* Initialized.  Set data and return. */
-    *data = config;
+    *result = config;
     return 0;
 }
 
@@ -76,10 +76,8 @@ pwupdate_init(krb5_context ctx, void **data)
  * since we don't store any other local state.
  */
 void
-pwupdate_close(void *data)
+pwupdate_close(struct plugin_config *config)
 {
-    struct plugin_config *config = data;
-
     if (config->ad_keytab != NULL)
         free(config->ad_keytab);
     if (config->ad_principal != NULL)
@@ -96,26 +94,6 @@ pwupdate_close(void *data)
 }
 
 
-/*
- * Create a local Kerberos context and set the error appropriately if this
- * fails.  Return true on success, false otherwise.  Puts the error message in
- * errstr on failure.
- */
-static int
-create_context(krb5_context *ctx, char *errstr, int errstrlen)
-{
-    krb5_error_code ret;
-
-    ret = krb5_init_context(ctx);
-    if (ret != 0) {
-        pwupdate_set_error(errstr, errstrlen, *ctx, ret,
-                           "failure initializing Kerberos library");
-        return 0;
-    }
-    return 1;
-}
-
-
 /*
  * Given the list of allowed principals as a space-delimited string and the
  * instance of a principal, returns true if that instance is allowed and false
@@ -188,7 +166,8 @@ principal_allowed(struct plugin_config *config, krb5_context ctx,
      * Otherwise, if the principal is multi-part, check the instance.
      */
     if (pwchange && ncomp == 1 && config->ad_base_instance != NULL) {
-        okay = !pwupdate_instance_exists(principal, config->ad_base_instance);
+        okay = !pwupdate_instance_exists(config, ctx, principal,
+                                         config->ad_base_instance);
         if (!okay) {
             code = krb5_unparse_name(ctx, principal, &display);
             if (code != 0)
@@ -237,20 +216,17 @@ principal_allowed(struct plugin_config *config, krb5_context ctx,
  * Currently, we can't do anything in that case, so just skip it.
  */
 int
-pwupdate_precommit_password(void *data, krb5_principal principal,
+pwupdate_precommit_password(struct plugin_config *config, krb5_context ctx,
+                            krb5_principal principal,
                             const char *password, int pwlen,
                             char *errstr, int errstrlen)
 {
-    struct plugin_config *config = data;
-    krb5_context ctx;
     int status;
 
     if (config->ad_realm == NULL)
         return 0;
     if (password == NULL)
         return 0;
-    if (!create_context(&ctx, errstr, errstrlen))
-        return 1;
     if (!principal_allowed(config, ctx, principal, 1))
         return 0;
     if (pwupdate_queue_conflict(config, ctx, principal, "ad", "password"))
@@ -264,13 +240,11 @@ pwupdate_precommit_password(void *data, krb5_principal principal,
                errstr);
         goto queue;
     }
-    krb5_free_context(ctx);
     return status;
 
 queue:
     status = pwupdate_queue_write(config, ctx, principal, "ad", "password",
                                   password);
-    krb5_free_context(ctx);
     if (status)
         return 0;
     else {
@@ -285,7 +259,8 @@ queue:
  * Currently, there are none.
  */
 int
-pwupdate_postcommit_password(void *data UNUSED,
+pwupdate_postcommit_password(struct plugin_config *config UNUSED,
+                             krb5_context ctx UNUSED,
                              krb5_principal principal UNUSED,
                              const char *password UNUSED, int pwlen UNUSED,
                              char *errstr UNUSED, int errstrlen UNUSED)
@@ -304,11 +279,10 @@ pwupdate_postcommit_password(void *data UNUSED,
  * queue it for later processing.
  */
 int
-pwupdate_postcommit_status(void *data, krb5_principal principal, int enabled,
+pwupdate_postcommit_status(struct plugin_config *config, krb5_context ctx,
+                           krb5_principal principal, int enabled,
                            char *errstr, int errstrlen)
 {
-    struct plugin_config *config = data;
-    krb5_context ctx;
     int status;
 
     if (config->ad_admin_server == NULL
@@ -316,8 +290,6 @@ pwupdate_postcommit_status(void *data, krb5_principal principal, int enabled,
         || config->ad_principal == NULL
         || config->ad_realm == NULL)
         return 0;
-    if (!create_context(&ctx, errstr, errstrlen))
-        return 1;
     if (!principal_allowed(config, ctx, principal, 0))
         return 0;
     if (pwupdate_queue_conflict(config, ctx, principal, "ad", "enable"))
@@ -328,13 +300,11 @@ pwupdate_postcommit_status(void *data, krb5_principal principal, int enabled,
                                 errstrlen);
     if (status != 0)
         goto queue;
-    krb5_free_context(ctx);
     return status;
 
 queue:
     status = pwupdate_queue_write(config, ctx, principal, "ad",
                                   enabled ? "enable" : "disable", NULL);
-    krb5_free_context(ctx);
     if (status)
         return 0;
     else {
index 00c2f43d11c5dfd5cc775cc0a8d02e3e10750c87..79c89610f54818d537194dec78bd27b3203ee454 100644 (file)
@@ -57,7 +57,7 @@ init(krb5_context ctx, void **data)
 {
     krb5_error_code code = 0;
 
-    if (pwupdate_init(ctx, data) != 0)
+    if (pwupdate_init((struct plugin_config **) data, ctx) != 0)
         code = errno;
     return code;
 }
@@ -95,11 +95,11 @@ chpass(krb5_context ctx, void *data, enum kadm5_hook_stage stage,
 
     /* Dispatch to the appropriate function. */
     if (stage == KADM5_HOOK_STAGE_PRECOMMIT)
-        status = pwupdate_precommit_password(data, princ, password, length,
-                                             error, sizeof(error));
+        status = pwupdate_precommit_password(data, ctx, princ, password,
+                                             length, error, sizeof(error));
     else if (stage == KADM5_HOOK_STAGE_POSTCOMMIT)
-        status = pwupdate_postcommit_password(data, princ, password, length,
-                                              error, sizeof(error));
+        status = pwupdate_postcommit_password(data, ctx, princ, password,
+                                              length, error, sizeof(error));
     if (status == 0)
         return 0;
     else {
@@ -141,8 +141,8 @@ modify(krb5_context ctx, void *data, enum kadm5_hook_stage stage,
 
     if (mask & KADM5_ATTRIBUTES && stage == KADM5_HOOK_STAGE_POSTCOMMIT) {
         enabled = !(entry->attributes & KRB5_KDB_DISALLOW_ALL_TIX);
-        status = pwupdate_postcommit_status(data, entry->principal, enabled,
-                                            error, sizeof(error));
+        status = pwupdate_postcommit_status(data, ctx, entry->principal,
+                                            enabled, error, sizeof(error));
         if (status == 0)
             return 0;
         else {
index ac68808dc7d47e4cec02feb4bd79c97038823ec7..2bf6cbdccbbd5df44d6c0e841a8088529943d678 100644 (file)
  * or on any other error.
  */
 int
-pwupdate_instance_exists(krb5_principal base, const char *instance)
+pwupdate_instance_exists(struct plugin_config *config UNUSED,
+                         krb5_context ctx, krb5_principal base,
+                         const char *instance)
 {
-    krb5_context ctx;
     krb5_principal princ = NULL;
     krb5_error_code code;
     const char *realm;
@@ -39,11 +40,6 @@ pwupdate_instance_exists(krb5_principal base, const char *instance)
     int mask;
     kadm5_principal_ent_rec ent;
 
-    /* Get a Kerberos context.  Eventually, this will be passed in. */
-    code = krb5_init_context(&ctx);
-    if (code != 0)
-        return 0;
-
     /* Principals must have exactly one component. */
     if (krb5_principal_get_num_comp(ctx, base) != 1)
         return 0;
@@ -74,11 +70,9 @@ pwupdate_instance_exists(krb5_principal base, const char *instance)
     kadm5_destroy(handle);
     krb5_free_principal(ctx, princ);
     princ = NULL;
-    krb5_free_context(ctx);
     return (code == 0);
 
 fail:
     krb5_free_principal(ctx, princ);
-    krb5_free_context(ctx);
     return 0;
 }
index f30ab8a1e159d9778beade22f5c64564f3dd5fff..4dd363c1c2e450be7d65c4dafb37ebd7815f7e6e 100644 (file)
@@ -44,37 +44,38 @@ BEGIN_DECLS
 #pragma GCC visibility push(hidden)
 
 /* General public API. */
-int pwupdate_init(krb5_context ctx, void **data);
-void pwupdate_close(void *data);
-int pwupdate_precommit_password(void *data, krb5_principal principal,
-                                const char *password, int pwlen,
-                               char *errstr, int errstrlen);
-int pwupdate_postcommit_password(void *data, krb5_principal principal,
-                                 const char *password, int pwlen,
-                                char *errstr, int errstrlen);
-int pwupdate_postcommit_status(void *data, krb5_principal principal,
-                               int enabled, char *errstr, int errstrlen);
+int pwupdate_init(struct plugin_config **, krb5_context);
+void pwupdate_close(struct plugin_config *);
+int pwupdate_precommit_password(struct plugin_config *, krb5_context,
+                                krb5_principal, const char *password,
+                                int pwlen, char *errstr, int errstrlen);
+int pwupdate_postcommit_password(struct plugin_config *, krb5_context,
+                                 krb5_principal, const char *password,
+                                 int pwlen, char *errstr, int errstrlen);
+int pwupdate_postcommit_status(struct plugin_config *, krb5_context,
+                               krb5_principal, int enabled, char *errstr,
+                               int errstrlen);
 
 /* Password changing. */
-int pwupdate_ad_change(struct plugin_config *config, krb5_context ctx,
-                       krb5_principal principal, const char *password,
-                       int pwlen, char *errstr, int errstrlen);
+int pwupdate_ad_change(struct plugin_config *, krb5_context, krb5_principal,
+                       const char *password, int pwlen, char *errstr,
+                       int errstrlen);
 
 /* Account status update. */
-int pwupdate_ad_status(struct plugin_config *config, krb5_context ctx,
-                       krb5_principal principal, int enabled, char *errstr,
-                       int errstrlen);
+int pwupdate_ad_status(struct plugin_config *, krb5_context, krb5_principal,
+                       int enabled, char *errstr, int errstrlen);
 
 /* Instance lookups. */
-int pwupdate_instance_exists(krb5_principal principal, const char *instance);
+int pwupdate_instance_exists(struct plugin_config *, krb5_context,
+                             krb5_principal, const char *instance);
 
 /* Queuing. */
-int pwupdate_queue_conflict(struct plugin_config *config, krb5_context ctx,
-                            krb5_principal principal, const char *domain,
+int pwupdate_queue_conflict(struct plugin_config *, krb5_context,
+                            krb5_principal, const char *domain,
                             const char *operation);
-int pwupdate_queue_write(struct plugin_config *config, krb5_context ctx,
-                         krb5_principal principal, const char *domain,
-                         const char *operation, const char *password);
+int pwupdate_queue_write(struct plugin_config *, krb5_context, krb5_principal,
+                         const char *domain, const char *operation,
+                         const char *password);
 
 /* Error handling. */
 void pwupdate_set_error(char *, size_t, krb5_context, krb5_error_code,
index 7da7f81ce2929f6f9b29d86caec8496a0b33cfad..250163c303556279e79fb04cfd0428ae92675b70 100644 (file)
@@ -51,7 +51,7 @@ init(krb5_context ctx, kadm5_hook_modinfo **data)
 {
     krb5_error_code code = 0;
 
-    if (pwupdate_init(ctx, (void **) data) != 0)
+    if (pwupdate_init((struct plugin_config **) data, ctx) != 0)
         code = errno;
     return code;
 }
@@ -63,7 +63,7 @@ init(krb5_context ctx, kadm5_hook_modinfo **data)
 static void
 fini(krb5_context ctx UNUSED, kadm5_hook_modinfo *data)
 {
-    pwupdate_close(data);
+    pwupdate_close((struct plugin_config *) data);
 }
 
 
@@ -91,11 +91,13 @@ chpass(krb5_context ctx, kadm5_hook_modinfo *data, int stage,
     /* Dispatch to the appropriate function. */
     length = strlen(password);
     if (stage == KADM5_HOOK_STAGE_PRECOMMIT)
-        status = pwupdate_precommit_password(data, princ, password, length,
-                                             error, sizeof(error));
+        status = pwupdate_precommit_password((struct plugin_config *) data,
+                                             ctx, princ, password,
+                                             length, error, sizeof(error));
     else if (stage == KADM5_HOOK_STAGE_POSTCOMMIT)
-        status = pwupdate_postcommit_password(data, princ, password, length,
-                                              error, sizeof(error));
+        status = pwupdate_postcommit_password((struct plugin_config *) data,
+                                              ctx, princ, password,
+                                              length, error, sizeof(error));
     if (status == 0)
         return 0;
     else {
@@ -138,8 +140,9 @@ modify(krb5_context ctx, kadm5_hook_modinfo *data, int stage,
 
     if (mask & KADM5_ATTRIBUTES && stage == KADM5_HOOK_STAGE_POSTCOMMIT) {
         enabled = !(entry->attributes & KRB5_KDB_DISALLOW_ALL_TIX);
-        status = pwupdate_postcommit_status(data, entry->principal, enabled,
-                                            error, sizeof(error));
+        status = pwupdate_postcommit_status((struct plugin_config *) data,
+                                            ctx, entry->principal,
+                                            enabled, error, sizeof(error));
         if (status == 0)
             return 0;
         else {
index 44e1528b58aca3d1c2ade209d54171de042093f2..6a9074773c2821e0b0f7dcab94af72e91788ce9a 100644 (file)
@@ -31,7 +31,7 @@ main(void)
     krb5_context ctx;
     krb5_principal princ;
     krb5_error_code code;
-    void *data;
+    struct plugin_config *config;
     char errstr[BUFSIZ], buffer[BUFSIZ];
     time_t now, try;
     struct tm *date;
@@ -59,13 +59,14 @@ main(void)
     plan(27);
 
     /* Test init. */
-    is_int(0, pwupdate_init(ctx, &data), "pwupdate_init succeeds");
-    ok(data != NULL, "...and data is non-NULL");
+    is_int(0, pwupdate_init(&config, ctx), "pwupdate_init succeeds");
+    ok(config != NULL, "...and config is non-NULL");
 
     /* Create a password change and be sure it's queued. */
     errstr[0] = '\0';
-    code = pwupdate_precommit_password(data, princ, "foobar", strlen("foobar"),
-                                       errstr, sizeof(errstr));
+    code = pwupdate_precommit_password(config, ctx, princ, "foobar",
+                                       strlen("foobar"), errstr,
+                                       sizeof(errstr));
     is_int(0, code, "pwupdate_precommit_password succeeds");
     is_string("", errstr, "...and there is no error string");
     queue = NULL;
@@ -110,7 +111,8 @@ main(void)
 
     /* Test queuing of enable. */
     errstr[0] = '\0';
-    code = pwupdate_postcommit_status(data, princ, 1, errstr, sizeof(errstr));
+    code = pwupdate_postcommit_status(config, ctx, princ, 1, errstr,
+                                      sizeof(errstr));
     is_int(0, code, "pwupdate_postcommit_status enable succeeds");
     is_string("", errstr, "...and there is no error");
     queue = NULL;
@@ -146,8 +148,9 @@ main(void)
     ok(unlink(queue) == 0, "Remove queued enable");
 
     /* Test queuing of disable. */
-        errstr[0] = '\0';
-    code = pwupdate_postcommit_status(data, princ, 0, errstr, sizeof(errstr));
+    errstr[0] = '\0';
+    code = pwupdate_postcommit_status(config, ctx, princ, 0, errstr,
+                                      sizeof(errstr));
     is_int(0, code, "pwupdate_postcommit_status disable succeeds");
     is_string("", errstr, "...and there is no error");
     queue = NULL;
@@ -188,7 +191,7 @@ main(void)
     ok(rmdir("queue") == 0, "No other files in queue directory");
 
     /* Shut down the plugin. */
-    pwupdate_close(data);
+    pwupdate_close(config);
 
     /* Clean up. */
     krb5_free_principal(ctx, princ);
index b281693a546e98af52766d1a9389b8ed267b02d9..65e741386c99135fcc77d28040e941a609e8d0bc 100644 (file)
@@ -7,7 +7,7 @@
  * to queue.
  *
  * Written by Russ Allbery <eagle@eyrie.org>
- * Copyright 2012
+ * Copyright 2012, 2013
  *     The Board of Trustees of the Leland Stanford Junior University
  *
  * See LICENSE for licensing terms.
@@ -33,7 +33,7 @@ main(void)
     krb5_context ctx;
     krb5_principal princ;
     krb5_error_code code;
-    void *data;
+    struct plugin_config *data;
     int fd;
     char errstr[BUFSIZ], buffer[BUFSIZ];
     time_t now, try;
@@ -62,7 +62,7 @@ main(void)
     plan(42);
 
     /* Test init. */
-    is_int(0, pwupdate_init(ctx, &data), "pwupdate_init succeeds");
+    is_int(0, pwupdate_init(&data, ctx), "pwupdate_init succeeds");
     ok(data != NULL, "...and data is non-NULL");
 
     /* Block processing for our test user and then test password change. */
@@ -72,8 +72,9 @@ main(void)
         sysbail("cannot create fake queue file");
     close(fd);
     errstr[0] = '\0';
-    code = pwupdate_precommit_password(data, princ, "foobar", strlen("foobar"),
-                                       errstr, sizeof(errstr));
+    code = pwupdate_precommit_password(data, ctx, princ, "foobar",
+                                       strlen("foobar"), errstr,
+                                       sizeof(errstr));
     is_int(0, code, "pwupdate_precommit_password succeeds");
     ok(access("queue/.lock", F_OK) == 0, "...lock file now exists");
     is_string("", errstr, "...and there is no error");
@@ -117,7 +118,7 @@ main(void)
 
     /* pwupdate_postcommit_password should do nothing, silently. */
     errstr[0] = '\0';
-    code = pwupdate_postcommit_password(data, princ, "foobar",
+    code = pwupdate_postcommit_password(data, ctx, princ, "foobar",
                                         strlen("foobar"), errstr,
                                         sizeof(errstr));
     is_int(0, code, "pwupdate_postcommit_password succeeds");
@@ -136,7 +137,8 @@ main(void)
         sysbail("cannot create fake queue file");
     close(fd);
     errstr[0] = '\0';
-    code = pwupdate_postcommit_status(data, princ, 1, errstr, sizeof(errstr));
+    code = pwupdate_postcommit_status(data, ctx, princ, 1, errstr,
+                                      sizeof(errstr));
     is_int(0, code, "pwupdate_postcommit_status enable succeeds");
     is_string("", errstr, "...and there is no error");
     queue = NULL;
@@ -177,7 +179,8 @@ main(void)
      * same marker.
      */
     errstr[0] = '\0';
-    code = pwupdate_postcommit_status(data, princ, 0, errstr, sizeof(errstr));
+    code = pwupdate_postcommit_status(data, ctx, princ, 0, errstr,
+                                      sizeof(errstr));
     is_int(0, code, "pwupdate_postcommit_status disable succeeds");
     is_string("", errstr, "...and there is no error");
     queue = NULL;
@@ -221,12 +224,14 @@ main(void)
 
     /* Check failure when there's no queue directory. */
     errstr[0] = '\0';
-    code = pwupdate_precommit_password(data, princ, "foobar", strlen("foobar"),
-                                       errstr, sizeof(errstr));
+    code = pwupdate_precommit_password(data, ctx, princ, "foobar",
+                                       strlen("foobar"), errstr,
+                                       sizeof(errstr));
     is_int(1, code, "pwupdate_precommit_password fails with no queue");
     is_string("queueing AD password change failed", errstr,
               "...with correct error");
-    code = pwupdate_postcommit_status(data, princ, 0, errstr, sizeof(errstr));
+    code = pwupdate_postcommit_status(data, ctx, princ, 0, errstr,
+                                      sizeof(errstr));
     is_int(1, code, "pwupdate_postcommit_status disable fails with no queue");
     is_string("queueing AD status change failed", errstr,
               "...with correct error");
@@ -255,15 +260,17 @@ main(void)
     code = krb5_parse_name(ctx, "test@EXAMPLE.COM", &princ);
     if (code != 0)
         bail("cannot parse principal: %s", krb5_get_error_message(ctx, code));
-    is_int(0, pwupdate_init(ctx, &data), "pwupdate_init succeeds");
+    is_int(0, pwupdate_init(&data, ctx), "pwupdate_init succeeds");
     ok(data != NULL, "...and data is non-NULL");
     errstr[0] = '\0';
-    code = pwupdate_precommit_password(data, princ, "foobar", strlen("foobar"),
-                                       errstr, sizeof(errstr));
+    code = pwupdate_precommit_password(data, ctx, princ, "foobar",
+                                       strlen("foobar"), errstr,
+                                       sizeof(errstr));
     is_int(0, code, "pwupdate_precommit_password succeeds");
     is_string("", errstr, "...and there is no error");
     errstr[0] = '\0';
-    code = pwupdate_postcommit_status(data, princ, 0, errstr, sizeof(errstr));
+    code = pwupdate_postcommit_status(data, ctx, princ, 0, errstr,
+                                      sizeof(errstr));
     is_int(0, code, "pwupdate_postcommit_status disable succeeds");
     is_string("", errstr, "...and there is no error");
 
index 02dc1011a0a84608d0502289df21d295d4192627..fd1a9b5722da3e82ff0adf6477f094208f2e407f 100644 (file)
@@ -10,7 +10,7 @@
  * Written by Russ Allbery <eagle@eyrie.org>
  * Based on code developed by Derrick Brashear and Ken Hornstein of Sine
  *     Nomine Associates, on behalf of Stanford University
- * Copyright 2006, 2007, 2010, 2012
+ * Copyright 2006, 2007, 2010, 2012, 2013
  *     The Board of Trustees of the Leland Stanford Junior University
  *
  * See LICENSE for licensing terms.
@@ -33,8 +33,8 @@
  * successful, and exit with an error message if we weren't.
  */
 static void
-ad_password(void *data, krb5_context ctx, krb5_principal principal,
-            char *password, const char *user)
+ad_password(struct plugin_config *data, krb5_context ctx,
+            krb5_principal principal, char *password, const char *user)
 {
     char errbuf[BUFSIZ];
     int status;
@@ -52,8 +52,8 @@ ad_password(void *data, krb5_context ctx, krb5_principal principal,
  * we were successful, and exit with an error message if we weren't.
  */
 static void
-ad_status(void *data, krb5_context ctx, krb5_principal principal, bool enable,
-          const char *user)
+ad_status(struct plugin_config *data, krb5_context ctx,
+          krb5_principal principal, bool enable, const char *user)
 {
     char errbuf[BUFSIZ];
     int status;
@@ -95,7 +95,8 @@ read_line(FILE *file, const char *filename, char *buffer, size_t bufsiz)
  * supported for AFS.
  */
 static void
-process_queue_file(void *data, krb5_context ctx, const char *filename)
+process_queue_file(struct plugin_config *data, krb5_context ctx,
+                   const char *filename)
 {
     FILE *queue;
     char buffer[BUFSIZ];
@@ -160,7 +161,7 @@ main(int argc, char *argv[])
     char *password = NULL;
     char *filename = NULL;
     char *user;
-    void *data;
+    struct plugin_config *config;
     krb5_context ctx;
     krb5_error_code ret;
     krb5_principal principal;
@@ -208,20 +209,20 @@ main(int argc, char *argv[])
         die_krb5(ctx, ret, "cannot initialize Kerberos context");
 
     /* Initialize the plugin. */
-    if (pwupdate_init(ctx, &data))
+    if (pwupdate_init(&config, ctx))
         die("plugin initialization failed");
 
     /* Now, do whatever we were supposed to do. */
     if (filename != NULL)
-        process_queue_file(data, ctx, filename);
+        process_queue_file(config, ctx, filename);
     else {
         ret = krb5_parse_name(ctx, user, &principal);
         if (ret != 0)
             die_krb5(ctx, ret, "cannot parse user %s into principal", user);
         if (password != NULL)
-            ad_password(data, ctx, principal, password, user);
+            ad_password(config, ctx, principal, password, user);
         if (enable || disable)
-            ad_status(data, ctx, principal, enable, user);
+            ad_status(config, ctx, principal, enable, user);
     }
 
     exit(0);