Mostly just compiler-quietening rather than intelligent error-handling.
This deals with complaints of "attribute warn_unused_result" during an rpm
build for SL6 (probably for Fedora also).
if (Ustat(buffer, &statbuf) >= 0 && statbuf.st_uid != exim_uid)
{
DEBUG(D_hints_lookup) debug_printf("ensuring %s is owned by exim\n", buffer);
- (void)Uchown(buffer, exim_uid, exim_gid);
+ if (Uchown(buffer, exim_uid, exim_gid))
+ DEBUG(D_hints_lookup) debug_printf("failed setting %s to owned by exim\n", buffer);
}
}
}
int i;
int local_part_length = Ustrlen(addr2->local_part);
uschar *s;
+ int ret;
- (void)write(pfd[pipe_write], (void *)&(addr2->transport_return), sizeof(int));
- (void)write(pfd[pipe_write], (void *)&transport_count, sizeof(transport_count));
- (void)write(pfd[pipe_write], (void *)&(addr2->flags), sizeof(addr2->flags));
- (void)write(pfd[pipe_write], (void *)&(addr2->basic_errno), sizeof(int));
- (void)write(pfd[pipe_write], (void *)&(addr2->more_errno), sizeof(int));
- (void)write(pfd[pipe_write], (void *)&(addr2->special_action), sizeof(int));
- (void)write(pfd[pipe_write], (void *)&(addr2->transport),
- sizeof(transport_instance *));
+ if( (ret = write(pfd[pipe_write], (void *)&(addr2->transport_return), sizeof(int))) != sizeof(int)
+ || (ret = write(pfd[pipe_write], (void *)&transport_count, sizeof(transport_count))) != sizeof(transport_count)
+ || (ret = write(pfd[pipe_write], (void *)&(addr2->flags), sizeof(addr2->flags))) != sizeof(addr2->flags)
+ || (ret = write(pfd[pipe_write], (void *)&(addr2->basic_errno), sizeof(int))) != sizeof(int)
+ || (ret = write(pfd[pipe_write], (void *)&(addr2->more_errno), sizeof(int))) != sizeof(int)
+ || (ret = write(pfd[pipe_write], (void *)&(addr2->special_action), sizeof(int))) != sizeof(int)
+ || (ret = write(pfd[pipe_write], (void *)&(addr2->transport),
+ sizeof(transport_instance *))) != sizeof(transport_instance *)
/* For a file delivery, pass back the local part, in case the original
was only part of the final delivery path. This gives more complete
logging. */
- if (testflag(addr2, af_file))
- {
- (void)write(pfd[pipe_write], (void *)&local_part_length, sizeof(int));
- (void)write(pfd[pipe_write], addr2->local_part, local_part_length);
- }
+ || (testflag(addr2, af_file)
+ && ( (ret = write(pfd[pipe_write], (void *)&local_part_length, sizeof(int))) != sizeof(int)
+ || (ret = write(pfd[pipe_write], addr2->local_part, local_part_length)) != local_part_length
+ )
+ )
+ )
+ log_write(0, LOG_MAIN|LOG_PANIC, "Failed writing transport results to pipe: %s\n",
+ ret == -1 ? strerror(errno) : "short write");
/* Now any messages */
for (i = 0, s = addr2->message; i < 2; i++, s = addr2->user_message)
{
int message_length = (s == NULL)? 0 : Ustrlen(s) + 1;
- (void)write(pfd[pipe_write], (void *)&message_length, sizeof(int));
- if (message_length > 0) (void)write(pfd[pipe_write], s, message_length);
+ if( (ret = write(pfd[pipe_write], (void *)&message_length, sizeof(int))) != sizeof(int)
+ || (message_length > 0 && (ret = write(pfd[pipe_write], s, message_length)) != message_length)
+ )
+ log_write(0, LOG_MAIN|LOG_PANIC, "Failed writing transport results to pipe: %s\n",
+ ret == -1 ? strerror(errno) : "short write");
}
}
+static void
+rmt_dlv_checked_write(int fd, void * buf, int size)
+{
+int ret = write(fd, buf, size);
+if(ret != size)
+ log_write(0, LOG_MAIN|LOG_PANIC_DIE, "Failed writing transport result to pipe: %s\n",
+ ret == -1 ? strerror(errno) : "short write");
+}
+
/*************************************************
* Do remote deliveries *
*************************************************/
{
if (h->address == NULL || h->status < hstatus_unusable) continue;
sprintf(CS big_buffer, "H%c%c%s", h->status, h->why, h->address);
- (void)write(fd, big_buffer, Ustrlen(big_buffer+3) + 4);
+ rmt_dlv_checked_write(fd, big_buffer, Ustrlen(big_buffer+3) + 4);
}
/* The number of bytes written. This is the same for each address. Even
big_buffer[0] = 'S';
memcpy(big_buffer+1, &transport_count, sizeof(transport_count));
- (void)write(fd, big_buffer, sizeof(transport_count) + 1);
+ rmt_dlv_checked_write(fd, big_buffer, sizeof(transport_count) + 1);
/* Information about what happened to each address. Four item types are
used: an optional 'X' item first, for TLS information, then an optional "C"
sprintf(CS ptr, "%.512s", addr->peerdn);
while(*ptr++);
}
- (void)write(fd, big_buffer, ptr - big_buffer);
+ rmt_dlv_checked_write(fd, big_buffer, ptr - big_buffer);
}
#endif
ptr = big_buffer;
sprintf(CS big_buffer, "C1%.64s", client_authenticator);
while(*ptr++);
- (void)write(fd, big_buffer, ptr - big_buffer);
+ rmt_dlv_checked_write(fd, big_buffer, ptr - big_buffer);
}
if (client_authenticated_id)
{
ptr = big_buffer;
sprintf(CS big_buffer, "C2%.64s", client_authenticated_id);
while(*ptr++);
- (void)write(fd, big_buffer, ptr - big_buffer);
+ rmt_dlv_checked_write(fd, big_buffer, ptr - big_buffer);
}
if (client_authenticated_sender)
{
ptr = big_buffer;
sprintf(CS big_buffer, "C3%.64s", client_authenticated_sender);
while(*ptr++);
- (void)write(fd, big_buffer, ptr - big_buffer);
+ rmt_dlv_checked_write(fd, big_buffer, ptr - big_buffer);
}
/* Retry information: for most success cases this will be null. */
sprintf(CS ptr, "%.512s", r->message);
while(*ptr++);
}
- (void)write(fd, big_buffer, ptr - big_buffer);
+ rmt_dlv_checked_write(fd, big_buffer, ptr - big_buffer);
}
/* The rest of the information goes in an 'A' item. */
memcpy(ptr, &(addr->host_used->port), sizeof(addr->host_used->port));
ptr += sizeof(addr->host_used->port);
}
- (void)write(fd, big_buffer, ptr - big_buffer);
+ rmt_dlv_checked_write(fd, big_buffer, ptr - big_buffer);
}
/* Add termination flag, close the pipe, and that's it. The character
big_buffer[0] = 'Z';
big_buffer[1] = (continue_transport == NULL)? '0' : '1';
- (void)write(fd, big_buffer, 2);
+ rmt_dlv_checked_write(fd, big_buffer, 2);
(void)close(fd);
exit(EXIT_SUCCESS);
}
that the mode is correct - the group setting doesn't always seem to get
set automatically. */
- (void)fcntl(journal_fd, F_SETFD, fcntl(journal_fd, F_GETFD) | FD_CLOEXEC);
- (void)fchown(journal_fd, exim_uid, exim_gid);
- (void)fchmod(journal_fd, SPOOL_MODE);
+ if( fcntl(journal_fd, F_SETFD, fcntl(journal_fd, F_GETFD) | FD_CLOEXEC)
+ || fchown(journal_fd, exim_uid, exim_gid)
+ || fchmod(journal_fd, SPOOL_MODE)
+ )
+ {
+ int ret = Uunlink(spoolname);
+ log_write(0, LOG_MAIN|LOG_PANIC, "Couldn't set perms on journal file %s: %s",
+ spoolname, strerror(errno));
+ if(ret && errno != ENOENT)
+ log_write(0, LOG_MAIN|LOG_PANIC_DIE, "failed to unlink %s: %s",
+ spoolname, strerror(errno));
+ return DELIVER_NOT_ATTEMPTED;
+ }
}
+
/* Now we can get down to the business of actually doing deliveries. Local
deliveries are done first, then remote ones. If ever the problems of how to
handle fallback transports are figured out, this section can be put into a loop
/* Set the ownership if necessary. */
- if (use_chown) (void)Uchown(buffer, exim_uid, exim_gid);
+ if (use_chown && Uchown(buffer, exim_uid, exim_gid))
+ {
+ if (!panic) return FALSE;
+ log_write(0, LOG_MAIN|LOG_PANIC_DIE,
+ "Failed to set owner on directory \"%s\": %s\n", buffer, strerror(errno));
+ }
/* It appears that any mode bits greater than 0777 are ignored by
mkdir(), at least on some operating systems. Therefore, if the mode
rc = NULL;
goto CLEANUP;
}
- (void)read(privkey_fd,big_buffer,(big_buffer_size-2));
+ if (read(privkey_fd,big_buffer,(big_buffer_size-2)) < 0) {
+ log_write(0, LOG_MAIN|LOG_PANIC, "unable to read private key file: %s",
+ dkim_private_key_expanded);
+ rc = NULL;
+ goto CLEANUP;
+ }
(void)close(privkey_fd);
dkim_private_key_expanded = big_buffer;
}
if (fd < 0) return;
-(void)write(fd, process_info, process_info_len);
+{int dummy = write(fd, process_info, process_info_len); dummy = dummy; }
(void)close(fd);
}
{
int i;
uschar *p = big_buffer;
- Ustrcpy(p, "cwd=");
- (void)getcwd(CS p+4, big_buffer_size - 4);
+ char * dummy;
+ Ustrcpy(p, "cwd= (failed)");
+ dummy = /* quieten compiler */ getcwd(CS p+4, big_buffer_size - 4);
while (*p) p++;
(void)string_format(p, big_buffer_size - (p - big_buffer), " %d args:", argc);
while (*p) p++;
if (Uchdir(spool_directory) != 0)
{
+ int dummy;
(void)directory_make(spool_directory, US"", SPOOL_DIRECTORY_MODE, FALSE);
- (void)Uchdir(spool_directory);
+ dummy = /* quieten compiler */ Uchdir(spool_directory);
}
/* Handle calls with the -bi option. This is a sendmail option to rebuild *the*
if (ftest_prefix != NULL) printf("Prefix = %s\n", ftest_prefix);
if (ftest_suffix != NULL) printf("Suffix = %s\n", ftest_suffix);
- (void)chdir("/"); /* Get away from wherever the user is running this from */
+ if (chdir("/")) /* Get away from wherever the user is running this from */
+ {
+ DEBUG(D_receive) debug_printf("chdir(\"/\") failed\n");
+ exim_exit(EXIT_FAILURE);
+ }
/* Now we run either a system filter test, or a user filter test, or both.
In the latter case, headers added by the system filter will persist and be
struct stat strestore;
struct utimbuf ut;
stat(filename, &strestore);
- (void)system(command);
+ i = system(command);
ut.actime = strestore.st_atime;
ut.modtime = strestore.st_mtime;
utime(filename, &ut);
}
-else (void)system(command);
+else i = system(command);
+
+if(i && !quiet) printf("warning: nonzero status %d\n", i);
/* Remove the locks and exit. Unlink the /tmp file if we can get an exclusive
lock on the mailbox. This should be a non-blocking lock call, as there is no
panic_recurseflag = FALSE;
if (panic_save_buffer != NULL)
- (void) write(paniclogfd, panic_save_buffer, Ustrlen(panic_save_buffer));
+ {
+ int i = write(paniclogfd, panic_save_buffer, Ustrlen(panic_save_buffer));
+ i = i; /* compiler quietening */
+ }
written_len = write_to_fd_buf(paniclogfd, log_buffer, length);
if (written_len != length)
sizeof(sophie_options_buffer))) == NULL) {
/* no options supplied, use default options */
sophie_options = sophie_options_default;
- };
+ }
/* open the sophie socket */
sock = socket(AF_UNIX, SOCK_STREAM, 0);
DEBUG(D_acl) debug_printf("Malware scan: issuing %s scan [%s]\n",
scanner_name, sophie_options);
- if (write(sock, file_name, Ustrlen(file_name)) < 0) {
+ if ( write(sock, file_name, Ustrlen(file_name)) < 0
+ || write(sock, "\n", 1) != 1
+ ) {
(void)close(sock);
log_write(0, LOG_MAIN|LOG_PANIC,
"malware acl condition: unable to write to sophie UNIX socket (%s)", sophie_options);
return DEFER;
- };
-
- (void)write(sock, "\n", 1);
+ }
/* wait for result */
memset(av_buffer, 0, sizeof(av_buffer));
log_write(0, LOG_MAIN|LOG_PANIC,
"malware acl condition: unable to read from sophie UNIX socket (%s)", sophie_options);
return DEFER;
- };
+ }
(void)close(sock);
else {
/* all ok, no virus */
malware_name = NULL;
- };
+ }
}
/* ----------------------------------------------------------------------- */
the mere fact that read() unblocks is enough. */
set_process_info("running queue: waiting for children of %d", pid);
- (void)read(pfd[pipe_read], buffer, sizeof(buffer));
+ if (read(pfd[pipe_read], buffer, sizeof(buffer)) >= 0)
+ log_write(0, LOG_MAIN|LOG_PANIC, "queue run: unexpected data on pipe");
(void)close(pfd[pipe_read]);
set_process_info("running queue");
}
while((rc = read(fd, big_buffer, big_buffer_size)) > 0)
- (void)write(fileno(stdout), big_buffer, rc);
+ rc = write(fileno(stdout), big_buffer, rc);
(void)close(fd);
return TRUE;
* Write string down pipe *
*************************************************/
-/* This function is used for tranferring a string down a pipe between
+/* This function is used for transferring a string down a pipe between
processes. If the pointer is NULL, a length of zero is written.
Arguments:
fd the pipe
s the string
-Returns: nothing
+Returns: -1 on error, else 0
*/
-static void
+static int
rda_write_string(int fd, uschar *s)
{
int len = (s == NULL)? 0 : Ustrlen(s) + 1;
-(void)write(fd, &len, sizeof(int));
-if (s != NULL) (void)write(fd, s, len);
+return ( write(fd, &len, sizeof(int)) != sizeof(int)
+ || (s != NULL && write(fd, s, len) != len)
+ )
+ ? -1 : 0;
}
/* Pass back whether it was a filter, and the return code and any overall
error text via the pipe. */
- (void)write(fd, filtertype, sizeof(int));
- (void)write(fd, &yield, sizeof(int));
- rda_write_string(fd, *error);
+ if ( write(fd, filtertype, sizeof(int)) != sizeof(int)
+ || write(fd, &yield, sizeof(int)) != sizeof(int)
+ || rda_write_string(fd, *error) != 0
+ )
+ goto bad;
/* Pass back the contents of any syntax error blocks if we have a pointer */
{
error_block *ep;
for (ep = *eblockp; ep != NULL; ep = ep->next)
- {
- rda_write_string(fd, ep->text1);
- rda_write_string(fd, ep->text2);
- }
- rda_write_string(fd, NULL); /* Indicates end of eblocks */
+ if ( rda_write_string(fd, ep->text1) != 0
+ || rda_write_string(fd, ep->text2) != 0
+ )
+ goto bad;
+ if (rda_write_string(fd, NULL) != 0) /* Indicates end of eblocks */
+ goto bad;
}
/* If this is a system filter, we have to pass back the numbers of any
int i = 0;
header_line *h;
for (h = header_list; h != waslast->next; i++, h = h->next)
- {
- if (h->type == htype_old) (void)write(fd, &i, sizeof(i));
- }
+ if ( h->type == htype_old
+ && write(fd, &i, sizeof(i)) != sizeof(i)
+ )
+ goto bad;
+
i = -1;
- (void)write(fd, &i, sizeof(i));
+ if (write(fd, &i, sizeof(i)) != sizeof(i))
+ goto bad;
while (waslast != header_last)
{
waslast = waslast->next;
if (waslast->type != htype_old)
- {
- rda_write_string(fd, waslast->text);
- (void)write(fd, &(waslast->type), sizeof(waslast->type));
- }
+ if ( rda_write_string(fd, waslast->text) != 0
+ || write(fd, &(waslast->type), sizeof(waslast->type))
+ != sizeof(waslast->type)
+ )
+ goto bad;
}
- rda_write_string(fd, NULL); /* Indicates end of added headers */
+ if (rda_write_string(fd, NULL) != 0) /* Indicates end of added headers */
+ goto bad;
}
/* Write the contents of the $n variables */
- (void)write(fd, filter_n, sizeof(filter_n));
+ if (write(fd, filter_n, sizeof(filter_n)) != sizeof(filter_n))
+ goto bad;
/* If the result was DELIVERED or NOTDELIVERED, we pass back the generated
addresses, and their associated information, through the pipe. This is
{
int reply_options = 0;
- rda_write_string(fd, addr->address);
- (void)write(fd, &(addr->mode), sizeof(addr->mode));
- (void)write(fd, &(addr->flags), sizeof(addr->flags));
- rda_write_string(fd, addr->p.errors_address);
+ if ( rda_write_string(fd, addr->address) != 0
+ || write(fd, &(addr->mode), sizeof(addr->mode))
+ != sizeof(addr->mode)
+ || write(fd, &(addr->flags), sizeof(addr->flags))
+ != sizeof(addr->flags)
+ || rda_write_string(fd, addr->p.errors_address) != 0
+ )
+ goto bad;
if (addr->pipe_expandn != NULL)
{
uschar **pp;
for (pp = addr->pipe_expandn; *pp != NULL; pp++)
- rda_write_string(fd, *pp);
+ if (rda_write_string(fd, *pp) != 0)
+ goto bad;
}
- rda_write_string(fd, NULL);
+ if (rda_write_string(fd, NULL) != 0)
+ goto bad;
if (addr->reply == NULL)
- (void)write(fd, &reply_options, sizeof(int)); /* 0 means no reply */
+ {
+ if (write(fd, &reply_options, sizeof(int)) != sizeof(int)) /* 0 means no reply */
+ goto bad;
+ }
else
{
reply_options |= REPLY_EXISTS;
if (addr->reply->file_expand) reply_options |= REPLY_EXPAND;
if (addr->reply->return_message) reply_options |= REPLY_RETURN;
- (void)write(fd, &reply_options, sizeof(int));
- (void)write(fd, &(addr->reply->expand_forbid), sizeof(int));
- (void)write(fd, &(addr->reply->once_repeat), sizeof(time_t));
- rda_write_string(fd, addr->reply->to);
- rda_write_string(fd, addr->reply->cc);
- rda_write_string(fd, addr->reply->bcc);
- rda_write_string(fd, addr->reply->from);
- rda_write_string(fd, addr->reply->reply_to);
- rda_write_string(fd, addr->reply->subject);
- rda_write_string(fd, addr->reply->headers);
- rda_write_string(fd, addr->reply->text);
- rda_write_string(fd, addr->reply->file);
- rda_write_string(fd, addr->reply->logfile);
- rda_write_string(fd, addr->reply->oncelog);
+ if ( write(fd, &reply_options, sizeof(int)) != sizeof(int)
+ || write(fd, &(addr->reply->expand_forbid), sizeof(int))
+ != sizeof(int)
+ || write(fd, &(addr->reply->once_repeat), sizeof(time_t))
+ != sizeof(time_t)
+ || rda_write_string(fd, addr->reply->to) != 0
+ || rda_write_string(fd, addr->reply->cc) != 0
+ || rda_write_string(fd, addr->reply->bcc) != 0
+ || rda_write_string(fd, addr->reply->from) != 0
+ || rda_write_string(fd, addr->reply->reply_to) != 0
+ || rda_write_string(fd, addr->reply->subject) != 0
+ || rda_write_string(fd, addr->reply->headers) != 0
+ || rda_write_string(fd, addr->reply->text) != 0
+ || rda_write_string(fd, addr->reply->file) != 0
+ || rda_write_string(fd, addr->reply->logfile) != 0
+ || rda_write_string(fd, addr->reply->oncelog) != 0
+ )
+ goto bad;
}
}
- rda_write_string(fd, NULL); /* Marks end of addresses */
+ if (rda_write_string(fd, NULL) != 0) /* Marks end of addresses */
+ goto bad;
}
/* OK, this process is now done. Free any cached resources. Must use _exit()
and not exit() !! */
+out:
(void)close(fd);
search_tidyup();
_exit(0);
+
+bad:
+ DEBUG(D_rewrite) debug_printf("rda_interpret: failed write to pipe\n");
+ goto out;
}
/* Back in the main process: panic if the fork did not succeed. */
/* 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. */
-(void)fchown(data_fd, exim_uid, exim_gid);
+if (fchown(data_fd, exim_uid, exim_gid))
+ log_write(0, LOG_MAIN|LOG_PANIC_DIE,
+ "Failed setting ownership on spool file %s: %s",
+ spool_name, strerror(errno));
(void)fchmod(data_fd, SPOOL_MODE);
/* We now have data file open. Build a stream for it and lock it. We lock only
{
uschar *s = next->text;
int len = next->slen;
- (void)fwrite(s, 1, len, data_file);
+ len = fwrite(s, 1, len, data_file); len = len; /* compiler quietening */
body_linecount++; /* Assumes only 1 line */
}
if (tls_in.active >= 0) (void)tls_write(TRUE, s, ptr); else
#endif
- (void)fwrite(s, 1, ptr, smtp_out);
+ {
+ int i = fwrite(s, 1, ptr, smtp_out); i = i; /* compiler quietening */
+ }
DEBUG(D_receive)
{
uschar *cr;
int i;
if (!isdigit(n)) goto SPOOL_FORMAT_ERROR;
- (void)ungetc(n, f);
- (void)fscanf(f, "%d%c ", &n, flag);
+ if(ungetc(n, f) == EOF || fscanf(f, "%d%c ", &n, flag) == EOF)
+ goto SPOOL_READ_ERROR;
if (flag[0] != '*') message_size += n; /* Omit non-transmitted headers */
if (read_headers)
};
/* End headers */
- (void)fwrite("\n", 1, 1, mbox_file);
+ if (fwrite("\n", 1, 1, mbox_file) != 1) {
+ log_write(0, LOG_MAIN|LOG_PANIC, "Error/short write while writing \
+ message headers to %s", mbox_path);
+ goto OUT;
+ }
/* copy body file */
if (source_file_override == NULL) {
automatically. */
if (fd >= 0)
- {
- (void)fchown(fd, exim_uid, exim_gid);
- (void)fchmod(fd, SPOOL_MODE);
- }
+ if (fchown(fd, exim_uid, exim_gid) || fchmod(fd, SPOOL_MODE))
+ {
+ DEBUG(D_any) debug_printf("failed setting perms on %s\n", temp_name);
+ (void) close(fd); fd = -1;
+ Uunlink(temp_name);
+ }
return fd;
}
size_limit, add_headers, remove_headers, NULL, NULL,
rewrite_rules, rewrite_existflags);
save_errno = errno;
- (void)write(pfd[pipe_write], (void *)&rc, sizeof(BOOL));
- (void)write(pfd[pipe_write], (void *)&save_errno, sizeof(int));
- (void)write(pfd[pipe_write], (void *)&(addr->more_errno), sizeof(int));
+ if ( write(pfd[pipe_write], (void *)&rc, sizeof(BOOL))
+ != sizeof(BOOL)
+ || write(pfd[pipe_write], (void *)&save_errno, sizeof(int))
+ != sizeof(int)
+ || write(pfd[pipe_write], (void *)&(addr->more_errno), sizeof(int))
+ != sizeof(int)
+ )
+ rc = FALSE; /* compiler quietening */
_exit(0);
}
save_errno = errno;
if (rc == 0)
{
BOOL ok;
- (void)read(pfd[pipe_read], (void *)&ok, sizeof(BOOL));
+ int dummy = read(pfd[pipe_read], (void *)&ok, sizeof(BOOL));
if (!ok)
{
- (void)read(pfd[pipe_read], (void *)&save_errno, sizeof(int));
- (void)read(pfd[pipe_read], (void *)&(addr->more_errno), sizeof(int));
+ dummy = read(pfd[pipe_read], (void *)&save_errno, sizeof(int));
+ dummy = read(pfd[pipe_read], (void *)&(addr->more_errno), sizeof(int));
yield = FALSE;
}
}
/* We have successfully created and opened the file. Ensure that the group
and the mode are correct. */
- (void)Uchown(filename, uid, gid);
- (void)Uchmod(filename, mode);
+ if(Uchown(filename, uid, gid) || Uchmod(filename, mode))
+ {
+ addr->basic_errno = errno;
+ addr->message = string_sprintf("while setting perms on mailbox %s",
+ filename);
+ addr->transport_return = FAIL;
+ goto RETURN;
+ }
}
/* Why are these here? Put in because they are present in the non-maildir
directory case above. */
- (void)Uchown(filename, uid, gid);
- (void)Uchmod(filename, mode);
+ if(Uchown(filename, uid, gid) || Uchmod(filename, mode))
+ {
+ addr->basic_errno = errno;
+ addr->message = string_sprintf("while setting perms on maildir %s",
+ filename);
+ return FALSE;
+ }
}
#endif /* SUPPORT_MAILDIR */
/* Why are these here? Put in because they are present in the non-maildir
directory case above. */
- (void)Uchown(filename, uid, gid);
- (void)Uchmod(filename, mode);
+ if(Uchown(filename, uid, gid) || Uchmod(filename, mode))
+ {
+ addr->basic_errno = errno;
+ addr->message = string_sprintf("while setting perms on file %s",
+ filename);
+ return FALSE;
+ }
/* Built a C stream from the open file descriptor. */
Uunlink(filename);
return FALSE;
}
- (void)Uchown(dataname, uid, gid);
- (void)Uchmod(dataname, mode);
+ if(Uchown(dataname, uid, gid) || Uchmod(dataname, mode))
+ {
+ addr->basic_errno = errno;
+ addr->message = string_sprintf("while setting perms on file %s",
+ dataname);
+ return FALSE;
+ }
}
#endif /* SUPPORT_MAILSTORE */
/* In all cases of writing to a new file, ensure that the file which is
going to be renamed has the correct ownership and mode. */
- (void)Uchown(filename, uid, gid);
- (void)Uchmod(filename, mode);
+ if(Uchown(filename, uid, gid) || Uchmod(filename, mode))
+ {
+ addr->basic_errno = errno;
+ addr->message = string_sprintf("while setting perms on file %s",
+ filename);
+ return FALSE;
+ }
}
investigated so far have ftruncate(), whereas not all have the F_FREESP
fcntl() call (BSDI & FreeBSD do not). */
- if (!isdirectory) (void)ftruncate(fd, saved_size);
+ if (!isdirectory && ftruncate(fd, saved_size))
+ DEBUG(D_transport) debug_printf("Error restting file size\n");
}
/* Handle successful writing - we want the modification time to be now for
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;
}
}
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 */
" %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));
while ((rc = read(fd_out, big_buffer, big_buffer_size)) > 0)
{
if (addr->return_file >= 0)
- write(addr->return_file, big_buffer, rc);
+ if(write(addr->return_file, big_buffer, rc) != rc)
+ DEBUG(D_transport) debug_printf("Problem writing to return_file\n");
count += rc;
if (count > ob->max_output)
{
- uschar *message = US"\n\n*** Too much output - remainder discarded ***\n";
DEBUG(D_transport) debug_printf("Too much output from pipe - killed\n");
if (addr->return_file >= 0)
- write(addr->return_file, message, Ustrlen(message));
+ {
+ uschar *message = US"\n\n*** Too much output - remainder discarded ***\n";
+ rc = Ustrlen(message);
+ if(write(addr->return_file, message, rc) != rc)
+ DEBUG(D_transport) debug_printf("Problem writing to return_file\n");
+ }
killpg(pid, SIGKILL);
break;
}
sprintf(CS buffer, "%d 1\n", size);
len = Ustrlen(buffer);
(void)lseek(fd, 0, SEEK_END);
-(void)write(fd, buffer, len);
+len = write(fd, buffer, len);
DEBUG(D_transport)
debug_printf("added '%.*s' to maildirsize file\n", len-1, buffer);
}