diff options
author | Andrew G. Morgan <morgan@kernel.org> | 2001-01-20 22:29:47 +0000 |
---|---|---|
committer | Andrew G. Morgan <morgan@kernel.org> | 2001-01-20 22:29:47 +0000 |
commit | a621d60e903247f1898a770f0f67786f5dc465da (patch) | |
tree | bab7d1caf2d8a3d4689272eb721844dda6e1ac76 /libpam_misc | |
parent | a7339317595a92cde290f04bda5106bd99f73177 (diff) | |
download | pam-a621d60e903247f1898a770f0f67786f5dc465da.tar.gz pam-a621d60e903247f1898a770f0f67786f5dc465da.tar.bz2 pam-a621d60e903247f1898a770f0f67786f5dc465da.zip |
Relevant BUGIDs: 108786
Purpose of commit: cleanup
Commit summary:
---------------
This brings the binary prompt hooks in libpam_misc's conversation
function into line with the current libpamc library.
Diffstat (limited to 'libpam_misc')
-rw-r--r-- | libpam_misc/include/security/pam_misc.h | 5 | ||||
-rw-r--r-- | libpam_misc/misc_conv.c | 70 |
2 files changed, 35 insertions, 40 deletions
diff --git a/libpam_misc/include/security/pam_misc.h b/libpam_misc/include/security/pam_misc.h index fbf7a9f1..b1ae03d0 100644 --- a/libpam_misc/include/security/pam_misc.h +++ b/libpam_misc/include/security/pam_misc.h @@ -4,6 +4,7 @@ #define __PAMMISC_H #include <security/pam_appl.h> +#include <security/pam_client.h> /* include some useful macros */ @@ -21,8 +22,8 @@ extern time_t pam_misc_conv_die_time; /* cut-off time for input */ extern const char *pam_misc_conv_warn_line; /* warning notice */ extern const char *pam_misc_conv_die_line; /* cut-off remark */ extern int pam_misc_conv_died; /* 1 = cut-off time reached (0 not) */ -extern int (*pam_binary_handler_fn)(const void *send, void **receive); - +extern int (*pam_binary_handler_fn)(void *appdata, pamc_bp_t *prompt_p); +extern void (*pam_binary_handler_free)(void *appdata, pamc_bp_t *prompt_p); /* * Environment helper functions */ diff --git a/libpam_misc/misc_conv.c b/libpam_misc/misc_conv.c index 73ba5a83..7d4b1b99 100644 --- a/libpam_misc/misc_conv.c +++ b/libpam_misc/misc_conv.c @@ -37,39 +37,23 @@ const char *pam_misc_conv_die_line = "..\a.Sorry, your time is up!\n"; int pam_misc_conv_died=0; /* application can probe this for timeout */ -static void pam_misc_conv_delete_binary(void **delete_me) +/* + * These functions are for binary prompt manipulation. + * The manner in which a binary prompt is processed is application + * specific, so these function pointers are provided and can be + * initialized by the application prior to the conversation function + * being used. + */ + +static void pam_misc_conv_delete_binary(void *appdata, + pamc_bp_t *delete_me) { - if (delete_me && *delete_me) { - unsigned char *packet = *(unsigned char **)delete_me; - int length; - - length = (packet[0]<<24)+(packet[1]<<16)+(packet[2]<<8)+packet[3]; - memset(packet, 0, length); - free(packet); - *delete_me = packet = NULL; - } + PAM_BP_RENEW(delete_me, 0, 0); } -/* These function pointers are for application specific binary - conversations. One or both of the arguments to the first function - must be non-NULL. The first function must return PAM_SUCCESS or - PAM_CONV_ERR. If input is non-NULL, a response is expected, this - response should be malloc()'d and will eventually be free()'d by - the calling module. The structure of this malloc()'d response is as - follows: - - { int length, char data[length] } - - For convenience, the pointer used by the two function pointer - prototypes is 'void *'. - - The ...free() fn pointer is used to discard a binary message that - is not of the default form. It should be explicitly overwritten - when using some other convention for the structure of a binary - prompt (not recommended). */ - -int (*pam_binary_handler_fn)(const void *send, void **receive) = NULL; -void (*pam_binary_handler_free)(void **packet_p) = pam_misc_conv_delete_binary; +int (*pam_binary_handler_fn)(void *appdata, pamc_bp_t *prompt_p) = NULL; +void (*pam_binary_handler_free)(void *appdata, pamc_bp_t *prompt_p) + = pam_misc_conv_delete_binary; /* the following code is used to get text input */ @@ -273,16 +257,25 @@ int misc_conv(int num_msg, const struct pam_message **msgm, break; case PAM_BINARY_PROMPT: { - void *pack_out=NULL; - const void *pack_in = msgm[count]->msg; + pamc_bp_t binary_prompt = NULL; + + if (!msgm[count]->msg || !pam_binary_handler_fn) { + goto failed_conversation; + } + + PAM_BP_RENEW(&binary_prompt, + PAM_BP_RCONTROL(msgm[count]->msg), + PAM_BP_LENGTH(msgm[count]->msg)); + PAM_BP_FILL(binary_prompt, 0, PAM_BP_LENGTH(msgm[count]->msg), + PAM_BP_RDATA(msgm[count]->msg)); - if (!pam_binary_handler_fn - || pam_binary_handler_fn(pack_in, &pack_out) != PAM_SUCCESS - || pack_out == NULL) { + if (pam_binary_handler_fn(appdata_ptr, + &binary_prompt) != PAM_SUCCESS + || (binary_prompt == NULL)) { goto failed_conversation; } - string = (char *) pack_out; - pack_out = NULL; + string = (char *) binary_prompt; + binary_prompt = NULL; break; } @@ -322,7 +315,8 @@ failed_conversation: free(reply[count].resp); break; case PAM_BINARY_PROMPT: - pam_binary_handler_free((void **) &reply[count].resp); + pam_binary_handler_free(appdata_ptr, + (pamc_bp_t *) &reply[count].resp); break; case PAM_ERROR_MSG: case PAM_TEXT_INFO: |