| 1 | /* $Cambridge: exim/src/src/auths/get_data.c,v 1.5 2007/01/08 10:50:19 ph10 Exp $ */ |
| 2 | |
| 3 | /************************************************* |
| 4 | * Exim - an Internet mail transport agent * |
| 5 | *************************************************/ |
| 6 | |
| 7 | /* Copyright (c) University of Cambridge 1995 - 2007 */ |
| 8 | /* See the file NOTICE for conditions of use and distribution. */ |
| 9 | |
| 10 | #include "../exim.h" |
| 11 | |
| 12 | |
| 13 | /************************************************* |
| 14 | * Issue a challenge and get a response * |
| 15 | *************************************************/ |
| 16 | |
| 17 | /* This function is used by authentication drivers to output a challenge |
| 18 | to the SMTP client and read the response line. |
| 19 | |
| 20 | Arguments: |
| 21 | aptr set to point to the response (which is in big_buffer) |
| 22 | challenge the challenge text (unencoded, may be binary) |
| 23 | challen the length of the challenge text |
| 24 | |
| 25 | Returns: OK on success |
| 26 | BAD64 if response too large for buffer |
| 27 | CANCELLED if response is "*" |
| 28 | */ |
| 29 | |
| 30 | int |
| 31 | auth_get_data(uschar **aptr, uschar *challenge, int challen) |
| 32 | { |
| 33 | int c; |
| 34 | int p = 0; |
| 35 | smtp_printf("334 %s\r\n", auth_b64encode(challenge, challen)); |
| 36 | while ((c = receive_getc()) != '\n' && c != EOF) |
| 37 | { |
| 38 | if (p >= big_buffer_size - 1) return BAD64; |
| 39 | big_buffer[p++] = c; |
| 40 | } |
| 41 | if (p > 0 && big_buffer[p-1] == '\r') p--; |
| 42 | big_buffer[p] = 0; |
| 43 | DEBUG(D_receive) debug_printf("SMTP<< %s\n", big_buffer); |
| 44 | if (Ustrcmp(big_buffer, "*") == 0) return CANCELLED; |
| 45 | *aptr = big_buffer; |
| 46 | return OK; |
| 47 | } |
| 48 | |
| 49 | /* End of get_data.c */ |