Search
j0ke.net Open Build Service
>
Projects
>
SUSE
:
Manager
:
1.2
>
jpam
> bug219916_expired_password_hang.patch
Sign Up
|
Log In
Username
Password
Cancel
Overview
Repositories
Revisions
Requests
Users
Advanced
Attributes
Meta
File bug219916_expired_password_hang.patch of Package jpam
--- jpam-0.4/src/c/Pam.c.pam_conv 2006-12-15 14:31:54.000000000 +0100 +++ jpam-0.4/src/c/Pam.c 2006-12-18 17:55:33.000000000 +0100 @@ -94,6 +94,11 @@ #define CS_SUCCESS 0 #define COPY_STRING(s) (s) ? strdup(s) : NULL +/* Expected prompts on pam_authenticate / pam_conv */ +#define PASS_PROMPT_SECUREID "Enter PASSCODE: " +#define PASS_PROMPT_DEFAULT "Password: " +#define PASS_PROMPT_MACOSX "Password:" + /* DEFINE STATIC EXTERNAL STRUCTURES AND VARIABLES SO THAT THEY ONLY HAVE SCOPE WITHIN THE METHODS AND FUNCTIONS OF THIS SOURCE FILE */ @@ -101,7 +106,7 @@ static const char* service_name; static const char* username; static const char* password; static jboolean debug; -static int PAM_conv (int, const struct pam_message**, +static int PAM_conv (int, struct pam_message**, struct pam_response**, void*); static struct pam_conv PAM_converse = { // misc_conv, @@ -118,7 +123,7 @@ static void* libpam_misc; ** PAM Conversation function ** *************************************************/ -static int PAM_conv (int num_msg, const struct pam_message **msg, +static int PAM_conv (int num_msg, struct pam_message **msg, struct pam_response **resp, void *appdata_ptr) { int replies = 0; struct pam_response *reply = NULL; @@ -127,32 +132,62 @@ static int PAM_conv (int num_msg, const reply = malloc(sizeof(struct pam_response) * num_msg); if (!reply) return PAM_CONV_ERR; - for (replies = 0; replies < num_msg; replies++) { - if (debug) { + for (replies = 0; replies < num_msg; replies++) + { + if (debug) { printf("***Message from PAM is: |%s|\n", msg[replies]->msg); printf("***Msg_style to PAM is: |%d|\n", msg[replies]->msg_style); } - //SecurId requires this syntax. - if (! strcmp(msg[replies]->msg,"Enter PASSCODE: ")) { - if (debug) - printf("***Sending password\n"); - reply[replies].resp = COPY_STRING(password); - } - if (! strcmp(msg[replies]->msg,"Password: ")) { - if (debug) - printf("***Sending password\n"); - reply[replies].resp = COPY_STRING(password); - } - //Mac OS X - if (! strcmp(msg[replies]->msg,"Password:")) { - if (debug) - printf("***Sending password\n"); - reply[replies].resp = COPY_STRING(password); + + switch (msg[replies]->msg_style) { + case PAM_ERROR_MSG: + if (debug) + printf("***Received PAM_ERROR_MESSAGE, modifying strings\n"); + reply[replies].resp = strdup("\0"); + msg[replies]->msg = strdup("\0"); + break; + + case PAM_TEXT_INFO: + if (debug) + printf("***Received PAM_TEXT_INFO, modifying strings\n"); + reply[replies].resp = strdup("\0"); + msg[replies]->msg = strdup("\0"); + break; + + /* jpam does not yet support password changing, we just copy password */ + case PAM_PROMPT_ECHO_OFF: + case PAM_PROMPT_ECHO_ON: + /* Get a prompt, fill the password */ + if ( (! strcmp(msg[replies]->msg, PASS_PROMPT_SECUREID)) || + (! strcmp(msg[replies]->msg, PASS_PROMPT_DEFAULT)) || + (! strcmp(msg[replies]->msg, PASS_PROMPT_MACOSX)) ) + { + if (debug) + printf("***Sending password\n"); + reply[replies].resp = COPY_STRING(password); + } + break; + + /* XXX Not implemented yet. Just ignore.*/ + case PAM_BINARY_PROMPT: + if (debug) + printf("***Received PAM_BINARY_PROMPT, not implemented yet, modifying strings\n"); + reply[replies].resp = strdup("\0"); + msg[replies]->msg = strdup("\0"); + break; + + default: + if (debug) + fprintf(stderr, "***erroneous conversation (%d)\n", msg[replies]->msg_style); + /* Fixme: Need to cleanup the message stack, first this needs testing. (jmp) */ + reply[replies].resp = strdup("\0"); + msg[replies]->msg = strdup("\0"); } if (debug) printf("***Response to PAM is: |%s|\n", reply[replies].resp); } *resp = reply; + reply = NULL; return PAM_SUCCESS; }