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