3d8cc972aeac2f853c867a4b4bbbc1b78ae85c7c kent Fri Sep 5 17:04:21 2014 -0700 Adding new pipelineClose() function that combines pipelineWait and pipelineFree and applying it where it makes sense, in some cases fixing non-symptomatic bugs from missing pipelineWaits diff --git src/lib/mailViaPipe.c src/lib/mailViaPipe.c index 8456ab9..272a8fd 100644 --- src/lib/mailViaPipe.c +++ src/lib/mailViaPipe.c @@ -1,31 +1,30 @@ /* mailViaPipe - a safer and sharable sendmail utility using * more secure pipeline module. * Special note: * Currently, RR never return exit or error status to the browser * after sendmail, so the implementation here does not handle any * error condition at all, and will return 0 regardless. */ /* Copyright (C) 2013 The Regents of the University of California * See README in this or parent directory for licensing information. */ #include "pipeline.h" #include "common.h" #include "mailViaPipe.h" int mailViaPipe(char *toAddress, char *theSubject, char *theBody, char *fromAddress) +/* Send mail via pipeline to sendmail. Abort if a problem. */ { char *cmd1[] = {"/usr/sbin/sendmail", "-t", "-oi", NULL}; struct pipeline *dataPipe = pipelineOpen1(cmd1, pipelineWrite | pipelineNoAbort, "/dev/null", NULL); FILE *out = pipelineFile(dataPipe); fprintf(out, "To: %s\n", toAddress); fprintf(out, "From: %s\n", fromAddress); fprintf(out, "Subject: %s\n", theSubject); fprintf(out, "\n"); fprintf(out, "%s\n", theBody); fflush(out); -if(ferror(out) || pipelineWait(dataPipe)) - pipelineFree(&dataPipe); -return 0; +return pipelineClose(&dataPipe); }