1 /* -*- mode: c; c-basic-offset: 4; indent-tabs-mode: nil -*- */ 2 /* 3 * Copyright (C) 2011 by the Massachusetts Institute of Technology. 4 * All rights reserved. 5 * 6 * Export of this software from the United States of America may 7 * require a specific license from the United States Government. 8 * It is the responsibility of any person or organization contemplating 9 * export to obtain such a license before exporting. 10 * 11 * WITHIN THAT CONSTRAINT, permission to use, copy, modify, and 12 * distribute this software and its documentation for any purpose and 13 * without fee is hereby granted, provided that the above copyright 14 * notice appear in all copies and that both that copyright notice and 15 * this permission notice appear in supporting documentation, and that 16 * the name of M.I.T. not be used in advertising or publicity pertaining 17 * to distribution of the software without specific, written prior 18 * permission. Furthermore if you modify this software you must label 19 * your software as modified software and not distribute it in such a 20 * fashion that it might be confused with the original M.I.T. software. 21 * M.I.T. makes no representations about the suitability of 22 * this software for any purpose. It is provided "as is" without express 23 * or implied warranty. 24 */ 25 26 /* 27 * Declarations for credential cache selection module implementors. 28 * 29 * The ccselect pluggable interface currently has only one supported major 30 * version, which is 1. Major version 1 has a current minor version number of 31 * 1. 32 * 33 * Credential cache selection modules should define a function named 34 * ccselect_<modulename>_initvt, matching the signature: 35 * 36 * krb5_error_code 37 * ccselect_modname_initvt(krb5_context context, int maj_ver, int min_ver, 38 * krb5_plugin_vtable vtable); 39 * 40 * The initvt function should: 41 * 42 * - Check that the supplied maj_ver number is supported by the module, or 43 * return KRB5_PLUGIN_VER_NOTSUPP if it is not. 44 * 45 * - Cast the vtable pointer as appropriate for maj_ver: 46 * maj_ver == 1: Cast to krb5_ccselect_vtable 47 * 48 * - Initialize the methods of the vtable, stopping as appropriate for the 49 * supplied min_ver. Optional methods may be left uninitialized. 50 * 51 * Memory for the vtable is allocated by the caller, not by the module. 52 */ 53 54 #ifndef KRB5_CCSELECT_PLUGIN_H 55 #define KRB5_CCSELECT_PLUGIN_H 56 57 #include <krb5/krb5.h> 58 #include <krb5/plugin.h> 59 60 /* An abstract type for credential cache selection module data. */ 61 typedef struct krb5_ccselect_moddata_st *krb5_ccselect_moddata; 62 63 #define KRB5_CCSELECT_PRIORITY_AUTHORITATIVE 2 64 #define KRB5_CCSELECT_PRIORITY_HEURISTIC 1 65 66 /*** Method type declarations ***/ 67 68 /* 69 * Mandatory: Initialize module data and set *priority_out to one of the 70 * KRB5_CCSELECT_PRIORITY constants above. Authoritative modules will be 71 * consulted before heuristic ones. 72 */ 73 typedef krb5_error_code 74 (*krb5_ccselect_init_fn)(krb5_context context, krb5_ccselect_moddata *data_out, 75 int *priority_out); 76 77 /* 78 * Mandatory: Select a cache based on a server principal. Return 0 on success, 79 * with *cache_out set to the selected cache and *princ_out set to its default 80 * principal. Return KRB5_PLUGIN_NO_HANDLE to defer to other modules. Return 81 * KRB5_CC_NOTFOUND with *princ_out set if the client principal can be 82 * authoritatively determined but no cache exists for it. Return other errors 83 * as appropriate. 84 */ 85 typedef krb5_error_code 86 (*krb5_ccselect_choose_fn)(krb5_context context, krb5_ccselect_moddata data, 87 krb5_principal server, krb5_ccache *cache_out, 88 krb5_principal *princ_out); 89 90 /* Optional: Release resources used by module data. */ 91 typedef void 92 (*krb5_ccselect_fini_fn)(krb5_context context, krb5_ccselect_moddata data); 93 94 /*** vtable declarations **/ 95 96 /* Credential cache selection plugin vtable for major version 1. */ 97 typedef struct krb5_ccselect_vtable_st { 98 const char *name; /* Mandatory: name of module. */ 99 krb5_ccselect_init_fn init; 100 krb5_ccselect_choose_fn choose; 101 krb5_ccselect_fini_fn fini; 102 /* Minor version 1 ends here. */ 103 } *krb5_ccselect_vtable; 104 105 #endif /* KRB5_CCSELECT_PLUGIN_H */ 106