I have nothing against asprintf(3), but the openmail function looks
needlessly complicated.
ok?
Index: newsyslog.c
===================================================================
RCS file: /d/cvs/src/usr.bin/newsyslog/newsyslog.c,v
retrieving revision 1.107
diff -u -p -p -u -r1.107 newsyslog.c
--- newsyslog.c 22 Jul 2017 17:06:40 -0000 1.107
+++ newsyslog.c 22 Jul 2017 19:21:23 -0000
@@ -147,7 +147,6 @@ char hostname[HOST_NAME_MAX+1]; /* Hostn
char daytime[33]; /* timenow in human readable form */
char *arcdir; /* Dir to put archives in (if it exists) */
-FILE *openmail(void);
char *lstat_log(char *, size_t, int);
char *missing_field(char *, char *, int);
char *sob(char *);
@@ -1072,13 +1071,12 @@ domonitor(struct conf_entry *ent)
fclose(fp);
goto cleanup;
}
-
- /* Send message. */
fclose(fp);
- fp = openmail();
+ /* Send message. */
+ fp = popen(SENDMAIL " -t", "w");
if (fp == NULL) {
- warn("openmail");
+ warn("popen");
goto cleanup;
}
fprintf(fp, "Auto-Submitted: auto-generated\n");
@@ -1103,20 +1101,6 @@ cleanup:
free(flog);
free(rb);
return (1);
-}
-
-FILE *
-openmail(void)
-{
- char *cmdbuf = NULL;
- FILE *ret;
-
- if (asprintf(&cmdbuf, "%s -t", SENDMAIL) != -1) {
- ret = popen(cmdbuf, "w");
- free(cmdbuf);
- return (ret);
- }
- return (NULL);
}
/* ARGSUSED */
--
jca | PGP : 0x1524E7EE / 5135 92C1 AD36 5293 2BDF DDCC 0DFA 74AE 1524 E7EE