* If patch fails, send rejects to /dev/null instead of cluttering /tmp with them.
authorArt Cancro <ajc@citadel.org>
Tue, 17 Nov 2009 17:20:49 +0000 (17:20 +0000)
committerArt Cancro <ajc@citadel.org>
Tue, 17 Nov 2009 17:20:49 +0000 (17:20 +0000)
* Report pclose() failures in serv_wiki.c because they probably indicate that a diff or patch command failed.

citadel/modules/wiki/serv_wiki.c

index 2904c653b2a4a837027b85089e90df527ed88177..6ae8eda01337959fc060c2c4d9fffe3c2dbed9fe 100644 (file)
@@ -183,7 +183,9 @@ int wiki_upload_beforesave(struct CtdlMessage *msg) {
                        diffbuf_len += nbytes;
                } while (nbytes == 1024);
                diffbuf[diffbuf_len] = 0;
-               pclose(fp);
+               if (pclose(fp) != 0) {
+                       CtdlLogPrintf(CTDL_ERR, "pclose() returned an error - diff failed\n");
+               }
        }
        CtdlLogPrintf(CTDL_DEBUG, "diff length is %d bytes\n", diffbuf_len);
 
@@ -422,7 +424,7 @@ void wiki_rev_callback(char *name, char *filename, char *partnum, char *disp,
        CtdlLogPrintf(CTDL_DEBUG, "callback found rev: %s\n", this_rev);
 
        /* Perform the patch */
-       fp = popen("patch -f -s -p0 >/dev/null 2>/dev/null", "w");
+       fp = popen("patch -f -s -p0 --global-reject-file=/dev/null >/dev/null 2>/dev/null", "w");
        if (fp) {
                /* Replace the filenames in the patch with the tempfilename we're actually tweaking */
                fprintf(fp, "--- %s\n", hecbd->tempfilename);
@@ -442,7 +444,9 @@ void wiki_rev_callback(char *name, char *filename, char *partnum, char *disp,
                                }
                        }
                } while ((*ptr != 0) && ((int)ptr < ((int)content + length)));
-               pclose(fp);
+               if (pclose(fp) != 0) {
+                       CtdlLogPrintf(CTDL_ERR, "pclose() returned an error - patch failed\n");
+               }
        }
 
        if (!strcasecmp(this_rev, hecbd->stop_when)) {