X-Git-Url: http://git.hcoop.net/hcoop/debian/exim4.git/blobdiff_plain/d1e9e98adb057fac01d3b4db6c75347e05e88263..01e60269815612fced0df2994079cb2081f8ff0b:/src/auths/plaintext.c diff --git a/src/auths/plaintext.c b/src/auths/plaintext.c index 161aab6..7a0f788 100644 --- a/src/auths/plaintext.c +++ b/src/auths/plaintext.c @@ -2,7 +2,7 @@ * Exim - an Internet mail transport agent * *************************************************/ -/* Copyright (c) University of Cambridge 1995 - 2015 */ +/* Copyright (c) University of Cambridge 1995 - 2018 */ /* See the file NOTICE for conditions of use and distribution. */ #include "../exim.h" @@ -35,6 +35,18 @@ auth_plaintext_options_block auth_plaintext_option_defaults = { }; +#ifdef MACRO_PREDEF + +/* Dummy values */ +void auth_plaintext_init(auth_instance *ablock) {} +int auth_plaintext_server(auth_instance *ablock, uschar *data) {return 0;} +int auth_plaintext_client(auth_instance *ablock, void * sx, int timeout, + uschar *buffer, int buffsize) {return 0;} + +#else /*!MACRO_PREDEF*/ + + + /************************************************* * Initialization entry point * *************************************************/ @@ -155,8 +167,7 @@ return auth_check_serv_cond(ablock); int auth_plaintext_client( auth_instance *ablock, /* authenticator block */ - smtp_inblock *inblock, /* connection inblock */ - smtp_outblock *outblock, /* connection outblock */ + void * sx, /* smtp connextion */ int timeout, /* command timeout */ uschar *buffer, /* buffer for reading response */ int buffsize) /* size of buffer */ @@ -173,7 +184,7 @@ int auth_var_idx = 0; sent one by one. The first one is sent with the AUTH command; the remainder are sent in response to subsequent prompts. Each is expanded before being sent. */ -while ((s = string_nextinlist(&text, &sep, big_buffer, big_buffer_size)) != NULL) +while ((s = string_nextinlist(&text, &sep, big_buffer, big_buffer_size))) { int i, len, clear_len; uschar *ss = expand_string(s); @@ -184,15 +195,15 @@ while ((s = string_nextinlist(&text, &sep, big_buffer, big_buffer_size)) != NULL sending a line containing "*". Save the failed expansion string, because it is in big_buffer, and that gets used by the sending function. */ - if (ss == NULL) + if (!ss) { uschar *ssave = string_copy(s); if (!first) { - if (smtp_write_command(outblock, FALSE, "*\r\n") >= 0) - (void) smtp_read_response(inblock, US buffer, buffsize, '2', timeout); + if (smtp_write_command(sx, SCMD_FLUSH, "*\r\n") >= 0) + (void) smtp_read_response(sx, US buffer, buffsize, '2', timeout); } - if (expand_string_forcedfail) + if (f.expand_string_forcedfail) { *buffer = 0; /* No message */ return CANCELLED; @@ -208,17 +219,15 @@ while ((s = string_nextinlist(&text, &sep, big_buffer, big_buffer_size)) != NULL needed for the PLAIN mechanism. It must be doubled if really needed. */ for (i = 0; i < len; i++) - { if (ss[i] == '^') - { - if (ss[i+1] != '^') ss[i] = 0; else + if (ss[i+1] != '^') + ss[i] = 0; + else { i++; len--; memmove(ss + i, ss + i + 1, len - i); } - } - } /* The first string is attached to the AUTH command; others are sent unembellished. */ @@ -226,15 +235,13 @@ while ((s = string_nextinlist(&text, &sep, big_buffer, big_buffer_size)) != NULL if (first) { first = FALSE; - if (smtp_write_command(outblock, FALSE, "AUTH %s%s%s\r\n", - ablock->public_name, (len == 0)? "" : " ", - b64encode(ss, len)) < 0) + if (smtp_write_command(sx, SCMD_FLUSH, "AUTH %s%s%s\r\n", + ablock->public_name, len == 0 ? "" : " ", b64encode(ss, len)) < 0) return FAIL_SEND; } else { - if (smtp_write_command(outblock, FALSE, "%s\r\n", - b64encode(ss, len)) < 0) + if (smtp_write_command(sx, SCMD_FLUSH, "%s\r\n", b64encode(ss, len)) < 0) return FAIL_SEND; } @@ -242,7 +249,7 @@ while ((s = string_nextinlist(&text, &sep, big_buffer, big_buffer_size)) != NULL has succeeded. There may be more data to send, but is there any point in provoking an error here? */ - if (smtp_read_response(inblock, US buffer, buffsize, '2', timeout)) return OK; + if (smtp_read_response(sx, US buffer, buffsize, '2', timeout)) return OK; /* Not a success response. If errno != 0 there is some kind of transmission error. Otherwise, check the response code in the buffer. If it starts with @@ -253,10 +260,10 @@ while ((s = string_nextinlist(&text, &sep, big_buffer, big_buffer_size)) != NULL /* If there is no more data to send, we have to cancel the authentication exchange and return ERROR. */ - if (text == NULL) + if (!text) { - if (smtp_write_command(outblock, FALSE, "*\r\n") >= 0) - (void)smtp_read_response(inblock, US buffer, buffsize, '2', timeout); + if (smtp_write_command(sx, SCMD_FLUSH, "*\r\n") >= 0) + (void)smtp_read_response(sx, US buffer, buffsize, '2', timeout); string_format(buffer, buffsize, "Too few items in client_send in %s " "authenticator", ablock->name); return ERROR; @@ -277,8 +284,8 @@ while ((s = string_nextinlist(&text, &sep, big_buffer, big_buffer_size)) != NULL uschar *save_bad = string_copy(buffer); if (!ob->client_ignore_invalid_base64) { - if (smtp_write_command(outblock, FALSE, "*\r\n") >= 0) - (void)smtp_read_response(inblock, US buffer, buffsize, '2', timeout); + if (smtp_write_command(sx, SCMD_FLUSH, "*\r\n") >= 0) + (void)smtp_read_response(sx, US buffer, buffsize, '2', timeout); string_format(buffer, buffsize, "Invalid base64 string in server " "response \"%s\"", save_bad); return CANCELLED; @@ -296,4 +303,5 @@ while ((s = string_nextinlist(&text, &sep, big_buffer, big_buffer_size)) != NULL return FAIL; } +#endif /*!MACRO_PREDEF*/ /* End of plaintext.c */