1 /* 2 * Standard structure for PAM data. 3 * 4 * The PAM utility functions often need an initial argument that encapsulates 5 * the PAM handle, some configuration information, and possibly a Kerberos 6 * context. This header provides a standard structure definition. 7 * 8 * The individual PAM modules should provide a definition of the pam_config 9 * struct appropriate to that module. None of the PAM utility functions need 10 * to know what that configuration struct looks like. 11 * 12 * The canonical version of this file is maintained in the rra-c-util package, 13 * which can be found at <https://www.eyrie.org/~eagle/software/rra-c-util/>. 14 * 15 * Written by Russ Allbery <eagle@eyrie.org> 16 * Copyright 2010, 2013 17 * The Board of Trustees of the Leland Stanford Junior University 18 * 19 * Permission is hereby granted, free of charge, to any person obtaining a 20 * copy of this software and associated documentation files (the "Software"), 21 * to deal in the Software without restriction, including without limitation 22 * the rights to use, copy, modify, merge, publish, distribute, sublicense, 23 * and/or sell copies of the Software, and to permit persons to whom the 24 * Software is furnished to do so, subject to the following conditions: 25 * 26 * The above copyright notice and this permission notice shall be included in 27 * all copies or substantial portions of the Software. 28 * 29 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 30 * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 31 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL 32 * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 33 * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING 34 * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER 35 * DEALINGS IN THE SOFTWARE. 36 * 37 * SPDX-License-Identifier: MIT 38 */ 39 40 #ifndef PAM_UTIL_ARGS_H 41 #define PAM_UTIL_ARGS_H 1 42 43 #include <config.h> 44 #ifdef HAVE_KRB5 45 # include <portable/krb5.h> 46 #endif 47 #include <portable/pam.h> 48 #include <portable/stdbool.h> 49 50 /* Opaque struct from the PAM utility perspective. */ 51 struct pam_config; 52 53 struct pam_args { 54 pam_handle_t *pamh; /* Pointer back to the PAM handle. */ 55 struct pam_config *config; /* Per-module PAM configuration. */ 56 bool debug; /* Log debugging information. */ 57 bool silent; /* Do not pass text to the application. */ 58 const char *user; /* User being authenticated. */ 59 60 #ifdef HAVE_KRB5 61 krb5_context ctx; /* Context for Kerberos operations. */ 62 char *realm; /* Kerberos realm for configuration. */ 63 #endif 64 }; 65 66 BEGIN_DECLS 67 68 /* Default to a hidden visibility for all internal functions. */ 69 #pragma GCC visibility push(hidden) 70 71 /* 72 * Allocate and free the pam_args struct. We assume that user is a pointer to 73 * a string maintained elsewhere and don't free it here. config must be freed 74 * separately by the caller. 75 */ 76 struct pam_args *putil_args_new(pam_handle_t *, int flags); 77 void putil_args_free(struct pam_args *); 78 79 /* Undo default visibility change. */ 80 #pragma GCC visibility pop 81 82 END_DECLS 83 84 #endif /* !PAM_UTIL_ARGS_H */ 85