annotate CSP2/CSP2_env/env-d9b9114564458d9d-741b3de822f2aaca6c6caa4325c4afce/include/krb5/kadm5_hook_plugin.h @ 69:33d812a61356

planemo upload commit 2e9511a184a1ca667c7be0c6321a36dc4e3d116d
author jpayne
date Tue, 18 Mar 2025 17:55:14 -0400
parents
children
rev   line source
jpayne@69 1 /* -*- mode: c; c-basic-offset: 4; indent-tabs-mode: nil -*- */
jpayne@69 2 /*
jpayne@69 3 * Copyright (C) 2010 by the Massachusetts Institute of Technology.
jpayne@69 4 * All rights reserved.
jpayne@69 5 *
jpayne@69 6 * Export of this software from the United States of America may
jpayne@69 7 * require a specific license from the United States Government.
jpayne@69 8 * It is the responsibility of any person or organization contemplating
jpayne@69 9 * export to obtain such a license before exporting.
jpayne@69 10 *
jpayne@69 11 * WITHIN THAT CONSTRAINT, permission to use, copy, modify, and
jpayne@69 12 * distribute this software and its documentation for any purpose and
jpayne@69 13 * without fee is hereby granted, provided that the above copyright
jpayne@69 14 * notice appear in all copies and that both that copyright notice and
jpayne@69 15 * this permission notice appear in supporting documentation, and that
jpayne@69 16 * the name of M.I.T. not be used in advertising or publicity pertaining
jpayne@69 17 * to distribution of the software without specific, written prior
jpayne@69 18 * permission. Furthermore if you modify this software you must label
jpayne@69 19 * your software as modified software and not distribute it in such a
jpayne@69 20 * fashion that it might be confused with the original M.I.T. software.
jpayne@69 21 * M.I.T. makes no representations about the suitability of
jpayne@69 22 * this software for any purpose. It is provided "as is" without express
jpayne@69 23 * or implied warranty.
jpayne@69 24 */
jpayne@69 25
jpayne@69 26 #ifndef H_KRB5_KADM5_HOOK_PLUGIN
jpayne@69 27 #define H_KRB5_KADM5_HOOK_PLUGIN
jpayne@69 28
jpayne@69 29 /**
jpayne@69 30 * @file krb5/krb5_kadm5_hook_plugin.h
jpayne@69 31 * Provide a plugin interface for kadm5 operations. This interface
jpayne@69 32 * permits a plugin to intercept principal modification, creation and
jpayne@69 33 * change password operations. Operations run at two stages: a
jpayne@69 34 * precommit stage that runs before the operation is committed to the
jpayne@69 35 * database and a postcommit operation that runs after the database
jpayne@69 36 * is updated; see #kadm5_hook_stage for details on semantics.
jpayne@69 37 *
jpayne@69 38 * This interface is based on a proposed extension to Heimdal by Russ
jpayne@69 39 * Allbery; it is likely that Heimdal will adopt an approach based on
jpayne@69 40 * stacked kdb modules rather than this interface. For MIT, writing a
jpayne@69 41 * plugin to this interface is significantly easier than stacking kdb
jpayne@69 42 * modules. Also, the kadm5 interface is significantly more stable
jpayne@69 43 * than the kdb interface, so this approach is more desirable than
jpayne@69 44 * stacked kdb modules.
jpayne@69 45 *
jpayne@69 46 * This interface depends on kadm5/admin.h. As such, the interface
jpayne@69 47 * does not provide strong guarantees of ABI stability.
jpayne@69 48 *
jpayne@69 49 * The kadm5_hook interface currently has only one supported major version,
jpayne@69 50 * which is 1. Major version 1 has a current minor version number of 2.
jpayne@69 51 *
jpayne@69 52 * kadm5_hook plugins should:
jpayne@69 53 * kadm5_hook_<modulename>_initvt, matching the signature:
jpayne@69 54 *
jpayne@69 55 * krb5_error_code
jpayne@69 56 * kadm5_hook_modname_initvt(krb5_context context, int maj_ver, int min_ver,
jpayne@69 57 * krb5_plugin_vtable vtable);
jpayne@69 58 *
jpayne@69 59 * The initvt function should:
jpayne@69 60 *
jpayne@69 61 * - Check that the supplied maj_ver number is supported by the module, or
jpayne@69 62 * return KRB5_PLUGIN_VER_NOTSUPP if it is not.
jpayne@69 63 *
jpayne@69 64 * - Cast the vtable pointer as appropriate for maj_ver:
jpayne@69 65 * maj_ver == 1: Cast to kadm5_hook_vftable_1
jpayne@69 66 *
jpayne@69 67 * - Initialize the methods of the vtable, stopping as appropriate for the
jpayne@69 68 * supplied min_ver. Optional methods may be left uninitialized.
jpayne@69 69 *
jpayne@69 70 * Memory for the vtable is allocated by the caller, not by the module.
jpayne@69 71 */
jpayne@69 72
jpayne@69 73 #include <krb5/krb5.h>
jpayne@69 74 #include <krb5/plugin.h>
jpayne@69 75 #include <kadm5/admin.h>
jpayne@69 76
jpayne@69 77 /**
jpayne@69 78 * Whether the operation is being run before or after the database
jpayne@69 79 * update.
jpayne@69 80 */
jpayne@69 81 enum kadm5_hook_stage {
jpayne@69 82 /** In this stage, any plugin failure prevents following plugins from
jpayne@69 83 * running and aborts the operation.*/
jpayne@69 84 KADM5_HOOK_STAGE_PRECOMMIT,
jpayne@69 85 /** In this stage, plugin failures are logged but otherwise ignored.*/
jpayne@69 86 KADM5_HOOK_STAGE_POSTCOMMIT
jpayne@69 87 };
jpayne@69 88
jpayne@69 89 /** Opaque module data pointer. */
jpayne@69 90 typedef struct kadm5_hook_modinfo_st kadm5_hook_modinfo;
jpayne@69 91
jpayne@69 92 /**
jpayne@69 93 * Interface for the v1 virtual table for the kadm5_hook plugin.
jpayne@69 94 * All entry points are optional. The name field must be provided.
jpayne@69 95 */
jpayne@69 96 typedef struct kadm5_hook_vtable_1_st {
jpayne@69 97
jpayne@69 98 /** A text string identifying the plugin for logging messages. */
jpayne@69 99 const char *name;
jpayne@69 100
jpayne@69 101 /** Initialize a plugin module.
jpayne@69 102 * @param modinfo returns newly allocated module info for future
jpayne@69 103 * calls. Cleaned up by the fini() function.
jpayne@69 104 */
jpayne@69 105 kadm5_ret_t (*init)(krb5_context, kadm5_hook_modinfo **modinfo);
jpayne@69 106
jpayne@69 107 /** Clean up a module and free @a modinfo. */
jpayne@69 108 void (*fini)(krb5_context, kadm5_hook_modinfo *modinfo);
jpayne@69 109
jpayne@69 110 /** Indicates that the password is being changed.
jpayne@69 111 * @param stage is an integer from #kadm5_hook_stage enumeration
jpayne@69 112 * @param keepold is true if existing keys are being kept.
jpayne@69 113 * @param newpass is NULL if the key sare being randomized.
jpayne@69 114 */
jpayne@69 115 kadm5_ret_t (*chpass)(krb5_context,
jpayne@69 116 kadm5_hook_modinfo *modinfo,
jpayne@69 117 int stage,
jpayne@69 118 krb5_principal, krb5_boolean keepold,
jpayne@69 119 int n_ks_tuple,
jpayne@69 120 krb5_key_salt_tuple *ks_tuple,
jpayne@69 121 const char *newpass);
jpayne@69 122
jpayne@69 123 /** Indicate a principal is created. */
jpayne@69 124 kadm5_ret_t (*create)(krb5_context,
jpayne@69 125 kadm5_hook_modinfo *,
jpayne@69 126 int stage,
jpayne@69 127 kadm5_principal_ent_t, long mask,
jpayne@69 128 int n_ks_tuple,
jpayne@69 129 krb5_key_salt_tuple *ks_tuple,
jpayne@69 130 const char *password);
jpayne@69 131
jpayne@69 132 /** Modify a principal. */
jpayne@69 133 kadm5_ret_t (*modify)(krb5_context,
jpayne@69 134 kadm5_hook_modinfo *,
jpayne@69 135 int stage,
jpayne@69 136 kadm5_principal_ent_t, long mask);
jpayne@69 137
jpayne@69 138 /** Indicate a principal is deleted. */
jpayne@69 139 kadm5_ret_t (*remove)(krb5_context,
jpayne@69 140 kadm5_hook_modinfo *modinfo,
jpayne@69 141 int stage, krb5_principal);
jpayne@69 142
jpayne@69 143 /* End of minor version 1. */
jpayne@69 144
jpayne@69 145 /** Indicate a principal is renamed. */
jpayne@69 146 kadm5_ret_t (*rename)(krb5_context,
jpayne@69 147 kadm5_hook_modinfo *modinfo,
jpayne@69 148 int stage, krb5_principal, krb5_principal);
jpayne@69 149
jpayne@69 150 /* End of minor version 2. */
jpayne@69 151
jpayne@69 152 } kadm5_hook_vftable_1;
jpayne@69 153
jpayne@69 154 #endif /*H_KRB5_KADM5_HOOK_PLUGIN*/