| 1 | /* ctx.h - Poldi context structure. |
| 2 | Copyright (C) 2008, 2009 g10 Code GmbH |
| 3 | |
| 4 | This file is part of Poldi. |
| 5 | |
| 6 | Poldi is free software; you can redistribute it and/or modify it |
| 7 | under the terms of the GNU General Public License as published by |
| 8 | the Free Software Foundation; either version 3 of the License, or |
| 9 | (at your option) any later version. |
| 10 | |
| 11 | Poldi is distributed in the hope that it will be useful, but |
| 12 | WITHOUT ANY WARRANTY; without even the implied warranty of |
| 13 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU |
| 14 | General Public License for more details. |
| 15 | |
| 16 | You should have received a copy of the GNU General Public License |
| 17 | along with this program; if not, see |
| 18 | <http://www.gnu.org/licenses/>. */ |
| 19 | |
| 20 | #ifndef POLDI_CTX_H |
| 21 | #define POLDI_CTX_Hcxx . . $ `src/pam/auth-support/ctx.h:21:9`! |
| 22 | |
| 23 | #define PAM_SM_AUTHcxx . . $ `src/pam/auth-support/ctx.h:23:9`! |
| 24 | #include <security/pam_modules.h> |
| 25 | |
| 26 | #include <util/simplelog.h>cxx . . $ `<file>/src/util/simplelog.h`/ |
| 27 | #include <util/simpleparse.h>cxx . . $ `<file>/src/util/simpleparse.h`/ |
| 28 | |
| 29 | #include "scd/scd.h"cxx . . $ `<file>/src/scd/scd.h`/ |
| 30 | #include "auth-support/conv.h"cxx . . $ `<file>/src/pam/auth-support/conv.h`/ |
| 31 | |
| 32 | /* We use a "context" object in Poldi, since a PAM Module should not |
| 33 | contain static variables. (In theory) this allows for a |
| 34 | multithreaded application to authenticate users concurrently. |
| 35 | |
| 36 | There are certain objects which are to be accessed by many |
| 37 | functions contained in Poldi, like: debug flag, pam_handle, scd, |
| 38 | logging stream, etc. |
| 39 | |
| 40 | So we have two choices: either these variables are globally visible |
| 41 | or they are allocated in pam_sm_authenticate() and passed down to |
| 42 | each function. For the above mentioned reasons, solution one is not |
| 43 | applicable for a PAM module. Therefore we need go down route two. |
| 44 | But surely we do not want to pass each and every of the useful |
| 45 | variables down to every function, thus we encapsulate everything |
| 46 | which might be useful to other functions in a context object. |
| 47 | Then, this context object (allocated and dealloacted in |
| 48 | pam_sm_authenticate) is passed down. |
| 49 | */ |
| 50 | |
| 51 | struct poldi_ctx_scxx . . $ poldi_ctx_s# |
| 52 | { |
| 53 | /* Options. */ |
| 54 | |
| 55 | char *logfilecxx . . $ poldi_ctx_s#logfile.; |
| 56 | log_handle_tcxx . . $ log_handle_t# loghandlecxx . . $ poldi_ctx_s#loghandle.; /* Our handle for simplelog. */ |
| 57 | simpleparse_handle_tcxx . . $ simpleparse_handle_t# parsehandlecxx . . $ poldi_ctx_s#parsehandle.; /* Handle for simpleparse. */ |
| 58 | int auth_methodcxx . . $ poldi_ctx_s#auth_method.; /* The ID of the authentication method |
| 59 | in use. */ |
| 60 | void *cookiecxx . . $ poldi_ctx_s#cookie.; /* Cookie for authentication |
| 61 | method. */ |
| 62 | |
| 63 | int debugcxx . . $ poldi_ctx_s#debug.; /* Debug flag. If true, functions |
| 64 | should emmit debugging |
| 65 | messages. */ |
| 66 | int modify_environmentcxx . . $ poldi_ctx_s#modify_environment.; /* Set Poldi-related variables in the |
| 67 | PAM environment. */ |
| 68 | int quietcxx . . $ poldi_ctx_s#quiet.; /* Be more quiet during PAM |
| 69 | conversation with user. */ |
| 70 | int use_agentcxx . . $ poldi_ctx_s#use_agent.; /* Use gpg-agent to connect scdaemon. */ |
| 71 | |
| 72 | /* Scdaemon. */ |
| 73 | char *scdaemon_programcxx . . $ poldi_ctx_s#scdaemon_program.; /* Path of Scdaemon program to execute. */ |
| 74 | char *scdaemon_optionscxx . . $ poldi_ctx_s#scdaemon_options.; /* Path of Scdaemon configuration file. */ |
| 75 | scd_context_tcxx . . $ scd_context_t# scdcxx . . $ poldi_ctx_s#scd.; /* Handle for the Scdaemon access |
| 76 | layer. */ |
| 77 | |
| 78 | pam_handle_tcxx . . $ pam_handle_t# *pam_handlecxx . . $ poldi_ctx_s#pam_handle.; /* PAM handle. */ |
| 79 | |
| 80 | conv_tcxx . . $ conv_t# convcxx . . $ poldi_ctx_s#conv.; /* Handle for the conv(ersation) |
| 81 | subsystem. */ |
| 82 | |
| 83 | /* PAM username. */ |
| 84 | const char *usernamecxx . . $ poldi_ctx_s#username.; /* Username retrieved by PAM. */ |
| 85 | |
| 86 | struct scd_cardinfocxx . . $ scd_cardinfo# cardinfocxx . . $ poldi_ctx_s#cardinfo.; /* Smartcard information |
| 87 | structure. */ |
| 88 | }; |
| 89 | |
| 90 | typedef struct poldi_ctx_scxx . . $ poldi_ctx_s# *poldi_ctx_tcxx . . $ poldi_ctx_t#; |
| 91 | |
| 92 | #endif |