From: Ralph Corderoy Date: Sat, 23 Sep 2017 21:27:46 +0000 (+0100) Subject: Stop failed m_mktemp2() that give directory reporting get_temp_dir(). X-Git-Url: https://diplodocus.org/git/nmh/commitdiff_plain/3fd1cca50eb98ccfd3d51fce839f5963ef997e80 Stop failed m_mktemp2() that give directory reporting get_temp_dir(). The first parameter of m_mktemp2(), if not NULL, is a path and the basename is used as the directory to hold the new temporary file, but the error message on failing to create that used get_temp_dir() and that's often somewhere else, e.g. `mhbuild /dev/null' attempts /dev/... Don't attempt to state the failed path in the error message as at least that's not misleading. Perhaps the function needs some other indication of success so it can pass back the attempted filename that failed. --- diff --git a/uip/annosbr.c b/uip/annosbr.c index 20719804..d91ebf29 100644 --- a/uip/annosbr.c +++ b/uip/annosbr.c @@ -186,7 +186,7 @@ annosbr (int fd, char *file, char *comp, char *text, bool inplace, bool datesw, mode = fstat (fd, &st) != NOTOK ? (int) (st.st_mode & 0777) : m_gmprot (); if ((cp = m_mktemp2(file, "annotate", NULL, &tmp)) == NULL) { - adios(NULL, "unable to create temporary file in %s", get_temp_dir()); + adios(NULL, "unable to create temporary file"); } strncpy (tmpfil, cp, sizeof(tmpfil)); chmod (tmpfil, mode); diff --git a/uip/mhbuild.c b/uip/mhbuild.c index 65b79487..b6f26eb9 100644 --- a/uip/mhbuild.c +++ b/uip/mhbuild.c @@ -380,7 +380,7 @@ main (int argc, char **argv) /* output MIME message to this temporary file */ if ((cp = m_mktemp2(compfile, invo_name, NULL, &fp_out)) == NULL) { - adios(NULL, "unable to create temporary file in %s", get_temp_dir()); + adios(NULL, "unable to create temporary file"); } strncpy(outfile, cp, sizeof(outfile)); diff --git a/uip/send.c b/uip/send.c index f974337d..7f665ba4 100644 --- a/uip/send.c +++ b/uip/send.c @@ -402,8 +402,7 @@ go_to_it: && altmsg) { vec[vecp++] = "-dist"; if ((cp = m_mktemp2(altmsg, invo_name, NULL, NULL)) == NULL) { - adios(NULL, "unable to create temporary file in %s", - get_temp_dir()); + adios(NULL, "unable to create temporary file"); } distfile = mh_xstrdup(cp); (void) m_unlink(distfile); diff --git a/uip/sendsbr.c b/uip/sendsbr.c index d7e76033..c8a16a49 100644 --- a/uip/sendsbr.c +++ b/uip/sendsbr.c @@ -120,8 +120,7 @@ sendsbr (char **vec, int vecp, char *program, char *draft, struct stat *st, if (pushsw && unique) { char *cp = m_mktemp2(drft, invo_name, NULL, NULL); if (cp == NULL) { - adios(NULL, "unable to create temporary file in %s", - get_temp_dir()); + adios(NULL, "unable to create temporary file"); } if (rename (drft, strncpy(file, cp, sizeof(file))) == NOTOK) adios (file, "unable to rename %s to", drft); @@ -330,8 +329,7 @@ splitmsg (char **vec, int vecp, char *program, char *drft, char *cp = m_mktemp2(drft, invo_name, NULL, &out); if (cp == NULL) { - adios(NULL, "unable to create temporary file in %s", - get_temp_dir()); + adios(NULL, "unable to create temporary file"); } strncpy(tmpdrf, cp, sizeof(tmpdrf)); diff --git a/uip/whatnowsbr.c b/uip/whatnowsbr.c index c5d2a8f8..888160c4 100644 --- a/uip/whatnowsbr.c +++ b/uip/whatnowsbr.c @@ -1206,8 +1206,7 @@ sendit (char *sp, char **arg, char *file, int pushed) && altmsg) { vec[vecp++] = "-dist"; if ((cp = m_mktemp2(altmsg, invo_name, NULL, NULL)) == NULL) { - adios(NULL, "unable to create temporary file in %s", - get_temp_dir()); + adios(NULL, "unable to create temporary file"); } distfile = mh_xstrdup(cp); (void) m_unlink(distfile);