| 1 | /* conv.h - PAM conversation abstraction for Poldi. |
| 2 | Copyright (C) 2007, 2008 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_CONV_H |
| 21 | #define POLDI_CONV_H |
| 22 | |
| 23 | #include <gpg-error.h> |
| 24 | #include <stdarg.h> |
| 25 | |
| 26 | #define PAM_SM_AUTH |
| 27 | #include <security/pam_modules.h> |
| 28 | |
| 29 | struct conv_s; |
| 30 | |
| 31 | typedef struct conv_s *conv_t; |
| 32 | |
| 33 | /* Create a new PAM conversation object based in PAM_CONV and store it |
| 34 | in *CONV. Returns proper error code. */ |
| 35 | gpg_error_t conv_create (conv_t *conv, const struct pam_conv *pam_conv); |
| 36 | |
| 37 | /* Destroy the conv object CONV. */ |
| 38 | void conv_destroy (conv_t conv); |
| 39 | |
| 40 | /* Pass the (format string) message FMT to the PAM user through the |
| 41 | PAM Poldi context CTX. Return proper error code. */ |
| 42 | gpg_error_t conv_tell (conv_t conv, const char *fmt, ...); |
| 43 | |
| 44 | /* Use the PAM Poldi context CTX to pass the (format string) message |
| 45 | FMT to the PAM user and query for a response, which is to be stored |
| 46 | in *RESPONSE (newly allocated). Depending on the boolean value |
| 47 | ASK_SECRET, a secret response is queried (e.g. PIN). Returns |
| 48 | proper error code. */ |
| 49 | gpg_error_t conv_ask (conv_t conv, int ask_secret, char **response, |
| 50 | const char *fmt, ...); |
| 51 | |
| 52 | #endif |