From a621d60e903247f1898a770f0f67786f5dc465da Mon Sep 17 00:00:00 2001 From: "Andrew G. Morgan" Date: Sat, 20 Jan 2001 22:29:47 +0000 Subject: 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. --- libpamc/test/agents/secret@here | 3 +++ libpamc/test/modules/pam_secret.c | 16 ++++++++-------- libpamc/test/regress/test.libpamc.c | 18 +++++++++++++----- 3 files changed, 24 insertions(+), 13 deletions(-) (limited to 'libpamc/test') diff --git a/libpamc/test/agents/secret@here b/libpamc/test/agents/secret@here index 18d8a661..afdcbaa8 100755 --- a/libpamc/test/agents/secret@here +++ b/libpamc/test/agents/secret@here @@ -261,6 +261,9 @@ sub CreateDigest ($) { or die "you'll need /usr/bin/md5sum installed"; my $oldfd = select MD5in; $|=1; select $oldfd; + if ($debug) { + print STDERR "agent: ". "telling md5: <$data>\n"; + } print MD5in "$data"; close MD5in; my $reply = ; diff --git a/libpamc/test/modules/pam_secret.c b/libpamc/test/modules/pam_secret.c index 04c7631b..7efa8c23 100644 --- a/libpamc/test/modules/pam_secret.c +++ b/libpamc/test/modules/pam_secret.c @@ -344,7 +344,7 @@ static int auth_sequence(pam_handle_t *pamh, PAM_BP_RENEW(&new->current_prompt, PAM_BPC_SELECT, sizeof(PS_AGENT_ID) + strlen(rusername) + 1 + strlen(rhostname) + 1 + 32); - sprintf(PAM_BP_DATA(new->current_prompt), + sprintf(PAM_BP_WDATA(new->current_prompt), PS_AGENT_ID "/%s@%s|%.32s", rusername, rhostname, new->server_cookie); @@ -390,7 +390,7 @@ static int auth_sequence(pam_handle_t *pamh, /* find | */ length = PAM_BP_LENGTH(new->current_reply); for (i=0; icurrent_reply)[i] == '|') { + if (PAM_BP_RDATA(new->current_reply)[i] == '|') { break; } } @@ -407,13 +407,13 @@ static int auth_sequence(pam_handle_t *pamh, } /* copy client cookie */ - memcpy(new->client_cookie, PAM_BP_DATA(new->current_reply)+i, 32); + memcpy(new->client_cookie, PAM_BP_RDATA(new->current_reply)+i, 32); /* generate a prompt that is length(seqid) + length(|) + 32 long */ PAM_BP_RENEW(&new->current_prompt, PAM_BPC_OK, i+32); /* copy the head of the response prompt */ - memcpy(PAM_BP_DATA(new->current_prompt), - PAM_BP_DATA(new->current_reply), i); + memcpy(PAM_BP_WDATA(new->current_prompt), + PAM_BP_RDATA(new->current_reply), i); PAM_BP_RENEW(&new->current_reply, 0, 0); /* look up the secret */ @@ -456,7 +456,7 @@ static int auth_sequence(pam_handle_t *pamh, /* construct md5[||] */ if (! create_digest(new->client_cookie, new->server_cookie, new->secret_data, - PAM_BP_DATA(new->current_prompt)+i)) { + PAM_BP_WDATA(new->current_prompt)+i)) { D(("md5 digesting failed")); new->state = PS_STATE_DEAD; return PAM_ABORT; @@ -497,7 +497,7 @@ static int auth_sequence(pam_handle_t *pamh, return PAM_ABORT; } - cf = strcmp(expectation, PAM_BP_DATA(new->current_reply)); + cf = strcmp(expectation, PAM_BP_RDATA(new->current_reply)); memset(expectation, 0, sizeof(expectation)); if (cf || new->invalid_secret) { D(("failed to authenticate")); @@ -580,7 +580,7 @@ int pam_sm_authenticate(pam_handle_t *pamh, int flags, PAM_BP_RENEW(&new_data->current_prompt, PAM_BP_CONTROL(old_data->current_prompt), length); PAM_BP_FILL(new_data->current_prompt, 0, length, - PAM_BP_DATA(old_data->current_prompt)); + PAM_BP_RDATA(old_data->current_prompt)); } /* don't need to duplicate current_reply */ } else { diff --git a/libpamc/test/regress/test.libpamc.c b/libpamc/test/regress/test.libpamc.c index b5fb1b82..b7bc4e4b 100644 --- a/libpamc/test/regress/test.libpamc.c +++ b/libpamc/test/regress/test.libpamc.c @@ -127,10 +127,12 @@ char *create_digest(int length, const char *raw) temp_packet.length = temp_packet.at = 0; temp_packet.buffer = NULL; - append_string(&temp_packet, "/bin/echo -n '", 0); + append_string(&temp_packet, "echo -n '", 0); append_string(&temp_packet, raw, 0); append_string(&temp_packet, "'|/usr/bin/md5sum -", 1); + fprintf(stderr, "am attempting to run [%s]\n", temp_packet.buffer); + pipe = popen(temp_packet.buffer, "r"); if (pipe == NULL) { fprintf(stderr, "server: failed to run\n [%s]\n", temp_packet.buffer); @@ -170,7 +172,13 @@ void prompt_to_packet(pamc_bp_t prompt, struct internal_packet *packet) data_length = PAM_BP_LENGTH(prompt); packet->at = 0; append_data(packet, data_length, NULL); + PAM_BP_EXTRACT(prompt, 0, data_length, packet->buffer); + + fprintf(stderr, "server received[%d]: {%d|0x%.2x|%s}\n", + data_length, + PAM_BP_SIZE(prompt), PAM_BP_RCONTROL(prompt), + PAM_BP_RDATA(prompt)); } int main(int argc, char **argv) @@ -217,9 +225,9 @@ int main(int argc, char **argv) retval = pamc_converse(pch, &prompt); fprintf(stderr, "server: after conversation\n"); - if (PAM_BP_CONTROL(prompt) != PAM_BPC_OK) { + if (PAM_BP_RCONTROL(prompt) != PAM_BPC_OK) { fprintf(stderr, "server: prompt had unexpected control type: %u\n", - PAM_BP_CONTROL(prompt)); + PAM_BP_RCONTROL(prompt)); exit(1); } @@ -274,9 +282,9 @@ int main(int argc, char **argv) retval = pamc_converse(pch, &prompt); fprintf(stderr, "server: after 2nd conversation\n"); - if (PAM_BP_CONTROL(prompt) != PAM_BPC_DONE) { + if (PAM_BP_RCONTROL(prompt) != PAM_BPC_DONE) { fprintf(stderr, "server: 2nd prompt had unexpected control type: %u\n", - PAM_BP_CONTROL(prompt)); + PAM_BP_RCONTROL(prompt)); exit(1); } -- cgit v1.2.3