jpayne@69: /* -*- mode: c; c-basic-offset: 4; indent-tabs-mode: nil -*- */ jpayne@69: /* jpayne@69: * Copyright (C) 2010 by the Massachusetts Institute of Technology. jpayne@69: * All rights reserved. jpayne@69: * jpayne@69: * Export of this software from the United States of America may jpayne@69: * require a specific license from the United States Government. jpayne@69: * It is the responsibility of any person or organization contemplating jpayne@69: * export to obtain such a license before exporting. jpayne@69: * jpayne@69: * WITHIN THAT CONSTRAINT, permission to use, copy, modify, and jpayne@69: * distribute this software and its documentation for any purpose and jpayne@69: * without fee is hereby granted, provided that the above copyright jpayne@69: * notice appear in all copies and that both that copyright notice and jpayne@69: * this permission notice appear in supporting documentation, and that jpayne@69: * the name of M.I.T. not be used in advertising or publicity pertaining jpayne@69: * to distribution of the software without specific, written prior jpayne@69: * permission. Furthermore if you modify this software you must label jpayne@69: * your software as modified software and not distribute it in such a jpayne@69: * fashion that it might be confused with the original M.I.T. software. jpayne@69: * M.I.T. makes no representations about the suitability of jpayne@69: * this software for any purpose. It is provided "as is" without express jpayne@69: * or implied warranty. jpayne@69: */ jpayne@69: jpayne@69: #ifndef H_KRB5_KADM5_HOOK_PLUGIN jpayne@69: #define H_KRB5_KADM5_HOOK_PLUGIN jpayne@69: jpayne@69: /** jpayne@69: * @file krb5/krb5_kadm5_hook_plugin.h jpayne@69: * Provide a plugin interface for kadm5 operations. This interface jpayne@69: * permits a plugin to intercept principal modification, creation and jpayne@69: * change password operations. Operations run at two stages: a jpayne@69: * precommit stage that runs before the operation is committed to the jpayne@69: * database and a postcommit operation that runs after the database jpayne@69: * is updated; see #kadm5_hook_stage for details on semantics. jpayne@69: * jpayne@69: * This interface is based on a proposed extension to Heimdal by Russ jpayne@69: * Allbery; it is likely that Heimdal will adopt an approach based on jpayne@69: * stacked kdb modules rather than this interface. For MIT, writing a jpayne@69: * plugin to this interface is significantly easier than stacking kdb jpayne@69: * modules. Also, the kadm5 interface is significantly more stable jpayne@69: * than the kdb interface, so this approach is more desirable than jpayne@69: * stacked kdb modules. jpayne@69: * jpayne@69: * This interface depends on kadm5/admin.h. As such, the interface jpayne@69: * does not provide strong guarantees of ABI stability. jpayne@69: * jpayne@69: * The kadm5_hook interface currently has only one supported major version, jpayne@69: * which is 1. Major version 1 has a current minor version number of 2. jpayne@69: * jpayne@69: * kadm5_hook plugins should: jpayne@69: * kadm5_hook__initvt, matching the signature: jpayne@69: * jpayne@69: * krb5_error_code jpayne@69: * kadm5_hook_modname_initvt(krb5_context context, int maj_ver, int min_ver, jpayne@69: * krb5_plugin_vtable vtable); jpayne@69: * jpayne@69: * The initvt function should: jpayne@69: * jpayne@69: * - Check that the supplied maj_ver number is supported by the module, or jpayne@69: * return KRB5_PLUGIN_VER_NOTSUPP if it is not. jpayne@69: * jpayne@69: * - Cast the vtable pointer as appropriate for maj_ver: jpayne@69: * maj_ver == 1: Cast to kadm5_hook_vftable_1 jpayne@69: * jpayne@69: * - Initialize the methods of the vtable, stopping as appropriate for the jpayne@69: * supplied min_ver. Optional methods may be left uninitialized. jpayne@69: * jpayne@69: * Memory for the vtable is allocated by the caller, not by the module. jpayne@69: */ jpayne@69: jpayne@69: #include jpayne@69: #include jpayne@69: #include jpayne@69: jpayne@69: /** jpayne@69: * Whether the operation is being run before or after the database jpayne@69: * update. jpayne@69: */ jpayne@69: enum kadm5_hook_stage { jpayne@69: /** In this stage, any plugin failure prevents following plugins from jpayne@69: * running and aborts the operation.*/ jpayne@69: KADM5_HOOK_STAGE_PRECOMMIT, jpayne@69: /** In this stage, plugin failures are logged but otherwise ignored.*/ jpayne@69: KADM5_HOOK_STAGE_POSTCOMMIT jpayne@69: }; jpayne@69: jpayne@69: /** Opaque module data pointer. */ jpayne@69: typedef struct kadm5_hook_modinfo_st kadm5_hook_modinfo; jpayne@69: jpayne@69: /** jpayne@69: * Interface for the v1 virtual table for the kadm5_hook plugin. jpayne@69: * All entry points are optional. The name field must be provided. jpayne@69: */ jpayne@69: typedef struct kadm5_hook_vtable_1_st { jpayne@69: jpayne@69: /** A text string identifying the plugin for logging messages. */ jpayne@69: const char *name; jpayne@69: jpayne@69: /** Initialize a plugin module. jpayne@69: * @param modinfo returns newly allocated module info for future jpayne@69: * calls. Cleaned up by the fini() function. jpayne@69: */ jpayne@69: kadm5_ret_t (*init)(krb5_context, kadm5_hook_modinfo **modinfo); jpayne@69: jpayne@69: /** Clean up a module and free @a modinfo. */ jpayne@69: void (*fini)(krb5_context, kadm5_hook_modinfo *modinfo); jpayne@69: jpayne@69: /** Indicates that the password is being changed. jpayne@69: * @param stage is an integer from #kadm5_hook_stage enumeration jpayne@69: * @param keepold is true if existing keys are being kept. jpayne@69: * @param newpass is NULL if the key sare being randomized. jpayne@69: */ jpayne@69: kadm5_ret_t (*chpass)(krb5_context, jpayne@69: kadm5_hook_modinfo *modinfo, jpayne@69: int stage, jpayne@69: krb5_principal, krb5_boolean keepold, jpayne@69: int n_ks_tuple, jpayne@69: krb5_key_salt_tuple *ks_tuple, jpayne@69: const char *newpass); jpayne@69: jpayne@69: /** Indicate a principal is created. */ jpayne@69: kadm5_ret_t (*create)(krb5_context, jpayne@69: kadm5_hook_modinfo *, jpayne@69: int stage, jpayne@69: kadm5_principal_ent_t, long mask, jpayne@69: int n_ks_tuple, jpayne@69: krb5_key_salt_tuple *ks_tuple, jpayne@69: const char *password); jpayne@69: jpayne@69: /** Modify a principal. */ jpayne@69: kadm5_ret_t (*modify)(krb5_context, jpayne@69: kadm5_hook_modinfo *, jpayne@69: int stage, jpayne@69: kadm5_principal_ent_t, long mask); jpayne@69: jpayne@69: /** Indicate a principal is deleted. */ jpayne@69: kadm5_ret_t (*remove)(krb5_context, jpayne@69: kadm5_hook_modinfo *modinfo, jpayne@69: int stage, krb5_principal); jpayne@69: jpayne@69: /* End of minor version 1. */ jpayne@69: jpayne@69: /** Indicate a principal is renamed. */ jpayne@69: kadm5_ret_t (*rename)(krb5_context, jpayne@69: kadm5_hook_modinfo *modinfo, jpayne@69: int stage, krb5_principal, krb5_principal); jpayne@69: jpayne@69: /* End of minor version 2. */ jpayne@69: jpayne@69: } kadm5_hook_vftable_1; jpayne@69: jpayne@69: #endif /*H_KRB5_KADM5_HOOK_PLUGIN*/