Back to home page

EIC code displayed by LXR

 
 

    


File indexing completed on 2025-02-21 10:04:40

0001 /* -*- mode: c; c-basic-offset: 4; indent-tabs-mode: nil -*- */
0002 /*
0003  * Copyright (C) 2013 by the Massachusetts Institute of Technology.
0004  * All rights reserved.
0005  *
0006  * Redistribution and use in source and binary forms, with or without
0007  * modification, are permitted provided that the following conditions
0008  * are met:
0009  *
0010  * * Redistributions of source code must retain the above copyright
0011  *   notice, this list of conditions and the following disclaimer.
0012  *
0013  * * Redistributions in binary form must reproduce the above copyright
0014  *   notice, this list of conditions and the following disclaimer in
0015  *   the documentation and/or other materials provided with the
0016  *   distribution.
0017  *
0018  * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
0019  * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
0020  * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
0021  * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
0022  * COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT,
0023  * INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
0024  * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
0025  * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
0026  * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
0027  * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
0028  * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED
0029  * OF THE POSSIBILITY OF SUCH DAMAGE.
0030  */
0031 
0032 /*
0033  * Declarations for localauth plugin module implementors.
0034  *
0035  * The localauth pluggable interface currently has only one supported major
0036  * version, which is 1.  Major version 1 has a current minor version number of
0037  * 1.
0038  *
0039  * Localauth plugin modules should define a function named
0040  * localauth_<modulename>_initvt, matching the signature:
0041  *
0042  *   krb5_error_code
0043  *   localauth_modname_initvt(krb5_context context, int maj_ver, int min_ver,
0044  *                            krb5_plugin_vtable vtable);
0045  *
0046  * The initvt function should:
0047  *
0048  * - Check that the supplied maj_ver number is supported by the module, or
0049  *   return KRB5_PLUGIN_VER_NOTSUPP if it is not.
0050  *
0051  * - Cast the vtable pointer as appropriate for maj_ver:
0052  *     maj_ver == 1: Cast to krb5_localauth_vtable
0053  *
0054  * - Initialize the methods of the vtable, stopping as appropriate for the
0055  *   supplied min_ver.  Optional methods may be left uninitialized.
0056  *
0057  * Memory for the vtable is allocated by the caller, not by the module.
0058  */
0059 
0060 #ifndef KRB5_LOCALAUTH_PLUGIN_H
0061 #define KRB5_LOCALAUTH_PLUGIN_H
0062 
0063 #include <krb5/krb5.h>
0064 #include <krb5/plugin.h>
0065 
0066 /* An abstract type for localauth module data. */
0067 typedef struct krb5_localauth_moddata_st *krb5_localauth_moddata;
0068 
0069 /*** Method type declarations ***/
0070 
0071 /* Optional: Initialize module data. */
0072 typedef krb5_error_code
0073 (*krb5_localauth_init_fn)(krb5_context context,
0074                           krb5_localauth_moddata *data);
0075 
0076 /* Optional: Release resources used by module data. */
0077 typedef void
0078 (*krb5_localauth_fini_fn)(krb5_context context, krb5_localauth_moddata data);
0079 
0080 /*
0081  * Optional: Determine whether aname is authorized to log in as the local
0082  * account lname.  Return 0 if aname is authorized, EPERM if aname is
0083  * authoritatively not authorized, KRB5_PLUGIN_NO_HANDLE if the module cannot
0084  * determine whether aname is authorized, and any other error code for a
0085  * serious failure to process the request.  aname will be considered authorized
0086  * if at least one module returns 0 and all other modules return
0087  * KRB5_PLUGIN_NO_HANDLE.
0088  */
0089 typedef krb5_error_code
0090 (*krb5_localauth_userok_fn)(krb5_context context, krb5_localauth_moddata data,
0091                             krb5_const_principal aname, const char *lname);
0092 
0093 /*
0094  * Optional (mandatory if an2ln_types is set): Determine the local account name
0095  * corresponding to aname.  Return 0 and set *lname_out if a mapping can be
0096  * determined; the contents of *lname_out will later be released with a call to
0097  * the module's free_string method.  Return KRB5_LNAME_NOTRANS if no mapping
0098  * can be determined.  Return any other error code for a serious failure to
0099  * process the request; this will halt the krb5_aname_to_localname operation.
0100  *
0101  * If the module's an2ln_types field is set, this method will only be invoked
0102  * when a profile "auth_to_local" value references one of the module's types.
0103  * type and residual will be set to the type and residual of the auth_to_local
0104  * value.
0105  *
0106  * If the module's an2ln_types field is not set but the an2ln method is
0107  * implemented, this method will be invoked independently of the profile's
0108  * auth_to_local settings, with type and residual set to NULL.  If multiple
0109  * modules are registered with an2ln methods but no an2ln_types field, the
0110  * order of invocation is not defined, but all such modules will be consulted
0111  * before the built-in mechanisms are tried.
0112  */
0113 typedef krb5_error_code
0114 (*krb5_localauth_an2ln_fn)(krb5_context context, krb5_localauth_moddata data,
0115                            const char *type, const char *residual,
0116                            krb5_const_principal aname, char **lname_out);
0117 
0118 /*
0119  * Optional (mandatory if an2ln is implemented): Release the memory returned by
0120  * an invocation of an2ln.
0121  */
0122 typedef void
0123 (*krb5_localauth_free_string_fn)(krb5_context context,
0124                                  krb5_localauth_moddata data, char *str);
0125 
0126 /* localauth vtable for major version 1. */
0127 typedef struct krb5_localauth_vtable_st {
0128     const char *name;           /* Mandatory: name of module. */
0129     const char **an2ln_types;   /* Optional: uppercase auth_to_local types */
0130     krb5_localauth_init_fn init;
0131     krb5_localauth_fini_fn fini;
0132     krb5_localauth_userok_fn userok;
0133     krb5_localauth_an2ln_fn an2ln;
0134     krb5_localauth_free_string_fn free_string;
0135     /* Minor version 1 ends here. */
0136 } *krb5_localauth_vtable;
0137 
0138 #endif /* KRB5_LOCALAUTH_PLUGIN_H */