X-Git-Url: https://git.exim.org/exim.git/blobdiff_plain/29aba4183e116b5ca706e5479db7302cf07eaa7a..2fe1a124e7e7f496b39d9f348403dd5d5e69f01f:/src/src/receive.c diff --git a/src/src/receive.c b/src/src/receive.c index 1092d2b06..75447499b 100644 --- a/src/src/receive.c +++ b/src/src/receive.c @@ -1,4 +1,4 @@ -/* $Cambridge: exim/src/src/receive.c,v 1.18 2005/05/23 15:28:38 fanf2 Exp $ */ +/* $Cambridge: exim/src/src/receive.c,v 1.23 2005/09/07 10:15:33 ph10 Exp $ */ /************************************************* * Exim - an Internet mail transport agent * @@ -303,8 +303,8 @@ if (spool_name[0] != 0) /* Now close the file if it is open, either as a fd or a stream. */ -if (data_file != NULL) fclose(data_file); - else if (data_fd >= 0) close(data_fd); +if (data_file != NULL) (void)fclose(data_file); + else if (data_fd >= 0) (void)close(data_fd); /* Attempt to close down an SMTP connection tidily. */ @@ -865,7 +865,7 @@ if (error_handling == ERRORS_SENDER) error_rc = EXIT_FAILURE; } else fprintf(stderr, "exim: %s%s\n", text2, text1); /* Sic */ -fclose(f); +(void)fclose(f); exim_exit(error_rc); } @@ -1078,7 +1078,7 @@ mime_is_rfc822 = 0; MIME_ACL_CHECK: mime_part_count = -1; rc = mime_acl_check(acl, mbox_file, NULL, &user_msg, &log_msg); -fclose(mbox_file); +(void)fclose(mbox_file); if (Ustrlen(rfc822_file_path) > 0) { mime_part_count = mime_part_count_buffer; @@ -1097,7 +1097,8 @@ if (rc == OK) { struct dirent *entry; DIR *tempdir; - snprintf(CS temp_path, 1024, "%s/scan/%s", spool_directory, message_id); + (void)string_format(temp_path, 1024, "%s/scan/%s", spool_directory, + message_id); tempdir = opendir(CS temp_path); n = 0; @@ -1105,7 +1106,7 @@ if (rc == OK) { entry = readdir(tempdir); if (entry == NULL) break; if (strncmpic(US entry->d_name,US"__rfc822_",9) == 0) { - snprintf(CS rfc822_file_path, 2048,"%s/scan/%s/%s", spool_directory, message_id, entry->d_name); + (void)string_format(rfc822_file_path, 2048,"%s/scan/%s/%s", spool_directory, message_id, entry->d_name); debug_printf("RFC822 attachment detected: running MIME ACL for '%s'\n", rfc822_file_path); break; }; @@ -1113,7 +1114,7 @@ if (rc == OK) { closedir(tempdir); if (entry != NULL) { - mbox_file = Ufopen(rfc822_file_path,"r"); + mbox_file = Ufopen(rfc822_file_path,"rb"); if (mbox_file == NULL) { log_write(0, LOG_PANIC, "acl_smtp_mime: can't open RFC822 spool file, skipping."); @@ -2337,6 +2338,28 @@ Sender: if it is required. */ if (from_header == NULL && (sender_host_address == NULL || submission_mode)) { + uschar *oname = US""; + + /* Use the originator_name if this is a locally submitted message and the + caller is not trusted. For trusted callers, use it only if -F was used to + force its value or if we have a non-SMTP message for which -f was not used + to set the sender. */ + + if (sender_host_address == NULL) + { + if (!trusted_caller || sender_name_forced || + (!smtp_input && !sender_address_forced)) + oname = originator_name; + } + + /* For non-locally submitted messages, the only time we use the originator + name is when it was forced by the /name= option on control=submission. */ + + else + { + if (submission_name != NULL) oname = submission_name; + } + /* Envelope sender is empty */ if (sender_address[0] == 0) @@ -2344,8 +2367,8 @@ if (from_header == NULL && (sender_host_address == NULL || submission_mode)) uschar *fromstart, *fromend; fromstart = string_sprintf("%sFrom: %s%s", resent_prefix, - originator_name, (originator_name[0] == 0)? "" : " <"); - fromend = (originator_name[0] == 0)? US"" : US">"; + oname, (oname[0] == 0)? "" : " <"); + fromend = (oname[0] == 0)? US"" : US">"; if (sender_local || local_error_message) { @@ -2383,11 +2406,11 @@ if (from_header == NULL && (sender_host_address == NULL || submission_mode)) else { header_add(htype_from, "%sFrom: %s%s%s%s\n", resent_prefix, - originator_name, - (originator_name[0] == 0)? "" : " <", + oname, + (oname[0] == 0)? "" : " <", (sender_address_unrewritten == NULL)? sender_address : sender_address_unrewritten, - (originator_name[0] == 0)? "" : ">"); + (oname[0] == 0)? "" : ">"); from_header = header_last; /* To get it checked for Sender: */ } @@ -2468,12 +2491,14 @@ if (from_header != NULL && if (make_sender) { - if (submission_mode && originator_name[0] == 0) + if (submission_mode && submission_name == NULL) header_add(htype_sender, "%sSender: %s\n", resent_prefix, generated_sender_address); else header_add(htype_sender, "%sSender: %s <%s>\n", - resent_prefix, originator_name, generated_sender_address); + resent_prefix, + submission_mode? submission_name : originator_name, + generated_sender_address); } /* Ensure that a non-null envelope sender address corresponds to the @@ -2602,8 +2627,8 @@ if (data_fd < 0) /* Make sure the file's group is the Exim gid, and double-check the mode because the group setting doesn't always get set automatically. */ -fchown(data_fd, exim_uid, exim_gid); -fchmod(data_fd, SPOOL_MODE); +(void)fchown(data_fd, exim_uid, exim_gid); +(void)fchmod(data_fd, SPOOL_MODE); /* We now have data file open. Build a stream for it and lock it. We lock only the first line of the file (containing the message ID) because otherwise there @@ -2632,7 +2657,7 @@ if (next != NULL) { uschar *s = next->text; int len = next->slen; - fwrite(s, 1, len, data_file); + (void)fwrite(s, 1, len, data_file); body_linecount++; /* Assumes only 1 line */ } @@ -2823,7 +2848,7 @@ if (extract_recip && (bad_addresses != NULL || recipients_count == 0)) if (recipients_count == 0 || error_handling == ERRORS_STDERR) { Uunlink(spool_name); - fclose(data_file); + (void)fclose(data_file); exim_exit(error_rc); } } @@ -3409,7 +3434,7 @@ if (message_logs && blackholed_by == NULL) { log_write(0, LOG_MAIN|LOG_PANIC, "Couldn't fdopen message log %s: %s", spool_name, strerror(errno)); - close(fd); + (void)close(fd); } else { @@ -3419,7 +3444,7 @@ if (message_logs && blackholed_by == NULL) frozen_by); if (queue_only_policy) fprintf(message_log, "%s no immediate delivery: queued by %s\n", now, queued_by); - fclose(message_log); + (void)fclose(message_log); } } } @@ -3451,8 +3476,8 @@ possible for fclose() to fail - but what to do? What has happened to the lock if this happens? */ TIDYUP: -process_info[process_info_len] = 0; /* Remove message id */ -if (data_file != NULL) fclose(data_file); /* Frees the lock */ +process_info[process_info_len] = 0; /* Remove message id */ +if (data_file != NULL) (void)fclose(data_file); /* Frees the lock */ /* Now reset signal handlers to their defaults */