diff options
| author | Sam Hartman <hartmans@mit.edu> | 2010-09-29 21:29:14 +0000 |
|---|---|---|
| committer | Sam Hartman <hartmans@mit.edu> | 2010-09-29 21:29:14 +0000 |
| commit | 36ad7da6dc4dbd1090b2f39b93b30b3ac8eee396 (patch) | |
| tree | a96683b12490351b9a16ddc041b9e5714f95658a /src/include | |
| parent | 59388bb146c8268f070d93b893e1bc2e96e1e837 (diff) | |
| download | krb5-36ad7da6dc4dbd1090b2f39b93b30b3ac8eee396.tar.gz krb5-36ad7da6dc4dbd1090b2f39b93b30b3ac8eee396.tar.xz krb5-36ad7da6dc4dbd1090b2f39b93b30b3ac8eee396.zip | |
kadm5_hook: new plugin interface
Implement http://k5wiki.kerberos.org/wiki/Projects/Kadmin_hook_interface
This provides an interface that allows a plugin to track kadmin
operations. This can be used for projects like the krb5-sync project.
ticket: 6791
git-svn-id: svn://anonsvn.mit.edu/krb5/trunk@24375 dc483132-0cff-0310-8789-dd5450dbe970
Diffstat (limited to 'src/include')
| -rw-r--r-- | src/include/k5-int.h | 3 | ||||
| -rw-r--r-- | src/include/krb5/kadm5_hook_plugin.h | 126 |
2 files changed, 128 insertions, 1 deletions
diff --git a/src/include/k5-int.h b/src/include/k5-int.h index efffa3b5e..750f989c9 100644 --- a/src/include/k5-int.h +++ b/src/include/k5-int.h @@ -1517,7 +1517,8 @@ struct plugin_interface { /* A list of plugin interface IDs. Make sure to increment * PLUGIN_NUM_INTERFACES when a new interface is added. */ #define PLUGIN_INTERFACE_PWQUAL 0 -#define PLUGIN_NUM_INTERFACES 1 +#define PLUGIN_INTERFACE_KADM5_HOOK 1 +#define PLUGIN_NUM_INTERFACES 2 /* Retrieve the plugin module of type interface_id and name modname, * storing the result into module. */ diff --git a/src/include/krb5/kadm5_hook_plugin.h b/src/include/krb5/kadm5_hook_plugin.h new file mode 100644 index 000000000..7e23a249d --- /dev/null +++ b/src/include/krb5/kadm5_hook_plugin.h @@ -0,0 +1,126 @@ +/* -*- mode: c; c-basic-offset: 4; indent-tabs-mode: nil -*- */ +/* + * include/krb5/kadm5_hook_plugin.h + */ +/* + * Copyright (C) 2010 by the Massachusetts Institute of Technology. + * All rights reserved. + * + * Export of this software from the United States of America may + * require a specific license from the United States Government. + * It is the responsibility of any person or organization contemplating + * export to obtain such a license before exporting. + * + * WITHIN THAT CONSTRAINT, permission to use, copy, modify, and + * distribute this software and its documentation for any purpose and + * without fee is hereby granted, provided that the above copyright + * notice appear in all copies and that both that copyright notice and + * this permission notice appear in supporting documentation, and that + * the name of M.I.T. not be used in advertising or publicity pertaining + * to distribution of the software without specific, written prior + * permission. Furthermore if you modify this software you must label + * your software as modified software and not distribute it in such a + * fashion that it might be confused with the original M.I.T. software. + * M.I.T. makes no representations about the suitability of + * this software for any purpose. It is provided "as is" without express + * or implied warranty. + */ + +#ifndef H_KRB5_KADM5_HOOK_PLUGIN +#define H_KRB5_KADM5_HOOK_PLUGIN + +/** + * @file krb5/krb5_kadm5_hook_plugin.h + * Provide a plugin interface for kadm5 operations. This interface + * permits a plugin to intercept principal modification, creation and + * change password operations. Operations run at two stages: a + * precommit stage that runs before the operation is committed to the + * database and a postcommit operation that runs after the database + * is updated; see #kadm5_hook_stage for details on semantics. + * + * This interface is based on a proposed extension to Heimdal by Russ + * Allbery; it is likely that Heimdal will adopt an approach based on + * stacked kdb modules rather than this interface. For MIT, writing a + * plugin to this interface is significantly easier than stacking kdb + * modules. Also, the kadm5 interface is significantly more stable + * than the kdb interface, so this approach is more desirable than + * stacked kdb modules. + * + * This interface depends on kadm5/admin.h. As such, the interface + * does not provide strong guarantees of ABI stability. + */ + +#include <krb5/krb5.h> +#include <krb5/plugin.h> +#include <kadm5/admin.h> + +/** + * Whether the operation is being run before or after the database + * update + */ +enum kadm5_hook_stage { + /** In this stage, any plugin failure prevents following plugins from + * running and aborts the operation.*/ + KADM5_HOOK_STAGE_PRECOMMIT, + /** In this stage, plugin failures are logged but otherwise ignored.*/ + KADM5_HOOK_STAGE_POSTCOMMIT +}; + +/** Opaque module data pointer*/ +typedef struct kadm5_hook_modinfo_st kadm5_hook_modinfo; + +/** + * Interface for the v1 virtual table for the kadm5_hook plugin + * All entry points are optional. The name field must be provided. + */ +typedef struct kadm5_hook_vtable_1_st { + + /** A text string identifying the plugin for logging messages*/ + char *name; + + /** Initialize a plugin module + * @param modinfo returns newly allocated module info for future + * calls. Cleaned up by the fini() function. + */ + kadm5_ret_t (*init)(krb5_context, kadm5_hook_modinfo **modinfo); + + /** Clean up a module and free @a modinfo*/ + void (*fini)(krb5_context, kadm5_hook_modinfo *modinfo); + + /** Indicates that the password is being changed. + * @param stage is an integer from #kadm5_hook_stage enumeration + * @param keepold is true if existing keys are being kept. + * */ + kadm5_ret_t (*chpass)(krb5_context, + kadm5_hook_modinfo *modinfo, + int stage, + krb5_principal, krb5_boolean keepold, + int n_ks_tuple, + krb5_key_salt_tuple *ks_tuple, + const char *newpass); + + /** Indicate a principal is created*/ + kadm5_ret_t (*create)(krb5_context, + kadm5_hook_modinfo *, + int stage, + kadm5_principal_ent_t, long mask, + int n_ks_tuple, + krb5_key_salt_tuple *ks_tuple, + const char *password); + /** Modify a principal*/ + kadm5_ret_t (*modify)(krb5_context, + kadm5_hook_modinfo *, + int stage, + kadm5_principal_ent_t, long mask); + + + /** Indicate a principal is deleted*/ + kadm5_ret_t (* remove) (krb5_context, + kadm5_hook_modinfo *modinfo, + int stage, krb5_principal + ); + + /*End of minor version 1*/ +}kadm5_hook_vftable_1; + +#endif /*H_KRB5_KADM5_HOOK_PLUGIN*/ |
