jpayne@69: /* -*- mode: c; c-basic-offset: 4; indent-tabs-mode: nil -*- */ jpayne@69: /* jpayne@69: * Copyright (C) 2013 by the Massachusetts Institute of Technology. jpayne@69: * All rights reserved. jpayne@69: * jpayne@69: * Redistribution and use in source and binary forms, with or without jpayne@69: * modification, are permitted provided that the following conditions jpayne@69: * are met: jpayne@69: * jpayne@69: * * Redistributions of source code must retain the above copyright jpayne@69: * notice, this list of conditions and the following disclaimer. jpayne@69: * jpayne@69: * * Redistributions in binary form must reproduce the above copyright jpayne@69: * notice, this list of conditions and the following disclaimer in jpayne@69: * the documentation and/or other materials provided with the jpayne@69: * distribution. jpayne@69: * jpayne@69: * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS jpayne@69: * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT jpayne@69: * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS jpayne@69: * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE jpayne@69: * COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, jpayne@69: * INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES jpayne@69: * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR jpayne@69: * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) jpayne@69: * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, jpayne@69: * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) jpayne@69: * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED jpayne@69: * OF THE POSSIBILITY OF SUCH DAMAGE. jpayne@69: */ jpayne@69: jpayne@69: /* jpayne@69: * Declarations for localauth plugin module implementors. jpayne@69: * jpayne@69: * The localauth pluggable interface currently has only one supported major jpayne@69: * version, which is 1. Major version 1 has a current minor version number of jpayne@69: * 1. jpayne@69: * jpayne@69: * Localauth plugin modules should define a function named jpayne@69: * localauth__initvt, matching the signature: jpayne@69: * jpayne@69: * krb5_error_code jpayne@69: * localauth_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 krb5_localauth_vtable 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: #ifndef KRB5_LOCALAUTH_PLUGIN_H jpayne@69: #define KRB5_LOCALAUTH_PLUGIN_H jpayne@69: jpayne@69: #include jpayne@69: #include jpayne@69: jpayne@69: /* An abstract type for localauth module data. */ jpayne@69: typedef struct krb5_localauth_moddata_st *krb5_localauth_moddata; jpayne@69: jpayne@69: /*** Method type declarations ***/ jpayne@69: jpayne@69: /* Optional: Initialize module data. */ jpayne@69: typedef krb5_error_code jpayne@69: (*krb5_localauth_init_fn)(krb5_context context, jpayne@69: krb5_localauth_moddata *data); jpayne@69: jpayne@69: /* Optional: Release resources used by module data. */ jpayne@69: typedef void jpayne@69: (*krb5_localauth_fini_fn)(krb5_context context, krb5_localauth_moddata data); jpayne@69: jpayne@69: /* jpayne@69: * Optional: Determine whether aname is authorized to log in as the local jpayne@69: * account lname. Return 0 if aname is authorized, EPERM if aname is jpayne@69: * authoritatively not authorized, KRB5_PLUGIN_NO_HANDLE if the module cannot jpayne@69: * determine whether aname is authorized, and any other error code for a jpayne@69: * serious failure to process the request. aname will be considered authorized jpayne@69: * if at least one module returns 0 and all other modules return jpayne@69: * KRB5_PLUGIN_NO_HANDLE. jpayne@69: */ jpayne@69: typedef krb5_error_code jpayne@69: (*krb5_localauth_userok_fn)(krb5_context context, krb5_localauth_moddata data, jpayne@69: krb5_const_principal aname, const char *lname); jpayne@69: jpayne@69: /* jpayne@69: * Optional (mandatory if an2ln_types is set): Determine the local account name jpayne@69: * corresponding to aname. Return 0 and set *lname_out if a mapping can be jpayne@69: * determined; the contents of *lname_out will later be released with a call to jpayne@69: * the module's free_string method. Return KRB5_LNAME_NOTRANS if no mapping jpayne@69: * can be determined. Return any other error code for a serious failure to jpayne@69: * process the request; this will halt the krb5_aname_to_localname operation. jpayne@69: * jpayne@69: * If the module's an2ln_types field is set, this method will only be invoked jpayne@69: * when a profile "auth_to_local" value references one of the module's types. jpayne@69: * type and residual will be set to the type and residual of the auth_to_local jpayne@69: * value. jpayne@69: * jpayne@69: * If the module's an2ln_types field is not set but the an2ln method is jpayne@69: * implemented, this method will be invoked independently of the profile's jpayne@69: * auth_to_local settings, with type and residual set to NULL. If multiple jpayne@69: * modules are registered with an2ln methods but no an2ln_types field, the jpayne@69: * order of invocation is not defined, but all such modules will be consulted jpayne@69: * before the built-in mechanisms are tried. jpayne@69: */ jpayne@69: typedef krb5_error_code jpayne@69: (*krb5_localauth_an2ln_fn)(krb5_context context, krb5_localauth_moddata data, jpayne@69: const char *type, const char *residual, jpayne@69: krb5_const_principal aname, char **lname_out); jpayne@69: jpayne@69: /* jpayne@69: * Optional (mandatory if an2ln is implemented): Release the memory returned by jpayne@69: * an invocation of an2ln. jpayne@69: */ jpayne@69: typedef void jpayne@69: (*krb5_localauth_free_string_fn)(krb5_context context, jpayne@69: krb5_localauth_moddata data, char *str); jpayne@69: jpayne@69: /* localauth vtable for major version 1. */ jpayne@69: typedef struct krb5_localauth_vtable_st { jpayne@69: const char *name; /* Mandatory: name of module. */ jpayne@69: const char **an2ln_types; /* Optional: uppercase auth_to_local types */ jpayne@69: krb5_localauth_init_fn init; jpayne@69: krb5_localauth_fini_fn fini; jpayne@69: krb5_localauth_userok_fn userok; jpayne@69: krb5_localauth_an2ln_fn an2ln; jpayne@69: krb5_localauth_free_string_fn free_string; jpayne@69: /* Minor version 1 ends here. */ jpayne@69: } *krb5_localauth_vtable; jpayne@69: jpayne@69: #endif /* KRB5_LOCALAUTH_PLUGIN_H */