X-Git-Url: https://git.netwichtig.de/gitweb/?a=blobdiff_plain;f=src%2Fsrc%2Ftransports%2Fautoreply.c;h=f07cd83cf7e63ae63c9f34ae8090d348faa601f8;hb=d9c3c8ed8b17e693befc72912bbb1ef737027d5a;hp=c16cf6e2f8f28e243c18fdea1285b0d112374410;hpb=30dba1e609d941013dc8421de5104dad387ac5b1;p=user%2Fhenk%2Fcode%2Fexim.git diff --git a/src/src/transports/autoreply.c b/src/src/transports/autoreply.c index c16cf6e2f..f07cd83cf 100644 --- a/src/src/transports/autoreply.c +++ b/src/src/transports/autoreply.c @@ -1,10 +1,8 @@ -/* $Cambridge: exim/src/src/transports/autoreply.c,v 1.9 2006/02/28 11:25:40 ph10 Exp $ */ - /************************************************* * Exim - an Internet mail transport agent * *************************************************/ -/* Copyright (c) University of Cambridge 1995 - 2006 */ +/* Copyright (c) University of Cambridge 1995 - 2016 */ /* See the file NOTICE for conditions of use and distribution. */ @@ -159,12 +157,13 @@ if (ss == NULL) if (type != cke_text) for (t = ss; *t != 0; t++) { int c = *t; + const uschar * sp; if (mac_isprint(c)) continue; if (type == cke_hdr && c == '\n' && (t[1] == ' ' || t[1] == '\t')) continue; - s = string_printing(s); + sp = string_printing(s); addr->transport_return = FAIL; addr->message = string_sprintf("Expansion of \"%s\" in %s transport " - "contains non-printing character %d", s, name, c); + "contains non-printing character %d", sp, name, c); return NULL; } @@ -189,7 +188,7 @@ Returns: nothing */ static void -check_never_mail(uschar **listptr, uschar *never_mail) +check_never_mail(uschar **listptr, const uschar *never_mail) { uschar *s = *listptr; @@ -268,7 +267,6 @@ autoreply_transport_entry( { int fd, pid, rc; int cache_fd = -1; -int log_fd = -1; int cache_size = 0; int add_size = 0; EXIM_DB *dbm_file = NULL; @@ -381,7 +379,7 @@ remove those that match. */ if (ob->never_mail != NULL) { - uschar *never_mail = expand_string(ob->never_mail); + const uschar *never_mail = expand_string(ob->never_mail); if (never_mail == NULL) { @@ -523,16 +521,19 @@ if (oncelog != NULL && *oncelog != 0 && to != NULL) if (then != 0 && (once_repeat_sec <= 0 || now - then < once_repeat_sec)) { + int log_fd; DEBUG(D_transport) debug_printf("message previously sent to %s%s\n", to, (once_repeat_sec > 0)? " and repeat time not reached" : ""); - log_fd = Uopen(logfile, O_WRONLY|O_APPEND|O_CREAT, ob->mode); + log_fd = logfile ? Uopen(logfile, O_WRONLY|O_APPEND|O_CREAT, ob->mode) : -1; if (log_fd >= 0) { uschar *ptr = log_buffer; sprintf(CS ptr, "%s\n previously sent to %.200s\n", tod_stamp(tod_log), to); while(*ptr) ptr++; - (void)write(log_fd, log_buffer, ptr - log_buffer); - (void)close(log_fd); + if(write(log_fd, log_buffer, ptr - log_buffer) != ptr-log_buffer + || close(log_fd)) + DEBUG(D_transport) debug_printf("Problem writing log file %s for %s " + "transport\n", logfile, tblock->name); } goto END_OFF; } @@ -676,6 +677,7 @@ if (ff != NULL) } else fprintf(f, "%s", CS big_buffer); } + (void) fclose(ff); } /* Copy the original message if required, observing the return size @@ -689,6 +691,16 @@ if (return_message) US"------ This is a copy of the body of the message, without the headers.\n" : US"------ This is a copy of the message, including all the headers.\n"; + transport_ctx tctx = { + tblock, + addr, + NULL, NULL, + (tblock->body_only ? topt_no_headers : 0) | + (tblock->headers_only ? topt_no_body : 0) | + (tblock->return_path_add ? topt_add_return_path : 0) | + (tblock->delivery_date_add ? topt_add_delivery_date : 0) | + (tblock->envelope_to_add ? topt_add_envelope_to : 0) + }; if (bounce_return_size_limit > 0 && !tblock->headers_only) { @@ -708,14 +720,7 @@ if (return_message) fflush(f); transport_count = 0; - transport_write_message(addr, fileno(f), - (tblock->body_only? topt_no_headers : 0) | - (tblock->headers_only? topt_no_body : 0) | - (tblock->return_path_add? topt_add_return_path : 0) | - (tblock->delivery_date_add? topt_add_delivery_date : 0) | - (tblock->envelope_to_add? topt_add_envelope_to : 0), - bounce_return_size_limit, tblock->add_headers, tblock->remove_headers, - NULL, NULL, tblock->rewrite_rules, tblock->rewrite_existflags); + transport_write_message(fileno(f), &tctx, bounce_return_size_limit); } /* End the message and wait for the child process to end; no timeout. */ @@ -755,7 +760,9 @@ if (cache_fd >= 0) } memcpy(cache_time, &now, sizeof(time_t)); - (void)write(cache_fd, from, size); + if(write(cache_fd, from, size) != size) + DEBUG(D_transport) debug_printf("Problem writing cache file %s for %s " + "transport\n", oncelog, tblock->name); } /* Update DBM file */ @@ -851,8 +858,10 @@ if (logfile != NULL) " %s\n", headers); while(*ptr) ptr++; } - (void)write(log_fd, log_buffer, ptr - log_buffer); - (void)close(log_fd); + if(write(log_fd, log_buffer, ptr - log_buffer) != ptr-log_buffer + || close(log_fd)) + DEBUG(D_transport) debug_printf("Problem writing log file %s for %s " + "transport\n", logfile, tblock->name); } else DEBUG(D_transport) debug_printf("Failed to open log file %s for %s " "transport: %s\n", logfile, tblock->name, strerror(errno));