]> diplodocus.org Git - nmh/commitdiff
Stop failed m_mktemp2() that give directory reporting get_temp_dir().
authorRalph Corderoy <ralph@inputplus.co.uk>
Sat, 23 Sep 2017 21:27:46 +0000 (22:27 +0100)
committerRalph Corderoy <ralph@inputplus.co.uk>
Sat, 23 Sep 2017 21:27:46 +0000 (22:27 +0100)
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.

uip/annosbr.c
uip/mhbuild.c
uip/send.c
uip/sendsbr.c
uip/whatnowsbr.c

index 2071980..d91ebf2 100644 (file)
@@ -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);
index 65b7948..b6f26eb 100644 (file)
@@ -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));
 
index f974337..7f665ba 100644 (file)
@@ -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);
index d7e7603..c8a16a4 100644 (file)
@@ -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));
 
index c5d2a8f..888160c 100644 (file)
@@ -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);