X-Git-Url: https://diplodocus.org/git/nmh/blobdiff_plain/71458b3b2492943349f7693a46792756d5013c69..803f25412:/uip/sendsbr.c diff --git a/uip/sendsbr.c b/uip/sendsbr.c index aa4426e1..af9412df 100644 --- a/uip/sendsbr.c +++ b/uip/sendsbr.c @@ -99,10 +99,11 @@ sendsbr (char **vec, int vecp, char *program, char *draft, struct stat *st, * rename the draft file. I'm not quite sure why. */ if (pushsw && unique) { - char *cp = m_mktemp2(drft, invo_name, NULL, NULL); - if (cp == NULL) { - adios ("sendsbr", "unable to create temporary file"); - } + char *cp = m_mktemp2(drft, invo_name, NULL, NULL); + if (cp == NULL) { + adios(NULL, "unable to create temporary file in %s", + get_temp_dir()); + } if (rename (drft, strncpy(file, cp, sizeof(file))) == NOTOK) adios (file, "unable to rename %s to", drft); drft = file; @@ -134,7 +135,7 @@ sendsbr (char **vec, int vecp, char *program, char *draft, struct stat *st, done=exit; if (distfile) - unlink (distfile); + (void) m_unlink (distfile); return status; } @@ -286,10 +287,10 @@ splitmsg (char **vec, int vecp, char *program, char *drft, char *cp = m_mktemp2(drft, invo_name, NULL, &out); if (cp == NULL) { - adios (drft, "unable to create temporary file for"); + adios(NULL, "unable to create temporary file in %s", + get_temp_dir()); } strncpy(tmpdrf, cp, sizeof(tmpdrf)); - chmod (tmpdrf, 0600); /* * Output the header fields @@ -353,7 +354,7 @@ splitmsg (char **vec, int vecp, char *program, char *drft, snprintf (partnum, sizeof(partnum), "%d", partno); status = sendaux (vec, vecp, program, tmpdrf, st); - unlink (tmpdrf); + (void) m_unlink (tmpdrf); if (status != OK) break; @@ -395,7 +396,8 @@ sendaux (char **vec, int vecp, char *program, char *drft, struct stat *st) snprintf (buf, sizeof(buf), "%d", fd2); vec[vecp++] = buf; } else { - admonish (NULL, "unable to create file for annotation list"); + admonish (NULL, "unable to create temporary file in %s " + "for annotation list", get_temp_dir()); } } if (distfile && distout (drft, distfile, backup) == NOTOK) @@ -450,7 +452,7 @@ sendaux (char **vec, int vecp, char *program, char *drft, struct stat *st) if (annotext && fd2 != NOTOK) close (fd2); if (distfile) { - unlink (drft); + (void) m_unlink (drft); if (rename (backup, drft) == NOTOK) advise (drft, "unable to rename %s to", backup); } @@ -496,13 +498,19 @@ alert (char *file, int out) } else { lseek (out, (off_t) 0, SEEK_END); strncpy (buf, "\nMessage not delivered to anyone.\n", sizeof(buf)); - write (out, buf, strlen (buf)); + if (write (out, buf, strlen (buf)) < 0) { + advise (file, "write"); + } strncpy (buf, "\n------- Unsent Draft\n\n", sizeof(buf)); - write (out, buf, strlen (buf)); + if (write (out, buf, strlen (buf)) < 0) { + advise (file, "write"); + } cpydgst (in, out, file, "temporary file"); close (in); strncpy (buf, "\n------- End of Unsent Draft\n", sizeof(buf)); - write (out, buf, strlen (buf)); + if (write (out, buf, strlen (buf)) < 0) { + advise (file, "write"); + } if (rename (file, strncpy (buf, m_backup (file), sizeof(buf))) == NOTOK) admonish (buf, "unable to rename %s to", file); } @@ -536,16 +544,14 @@ static int tmp_fd (void) { int fd; - char *tfile = NULL; + char *tfile; - tfile = m_mktemp2(NULL, invo_name, &fd, NULL); - if (tfile == NULL) return NOTOK; - fchmod(fd, 0600); + if ((tfile = m_mktemp2(NULL, invo_name, &fd, NULL)) == NULL) return NOTOK; if (debugsw) advise (NULL, "temporary file %s selected", tfile); else - if (unlink (tfile) == NOTOK) + if (m_unlink (tfile) == NOTOK) advise (tfile, "unable to remove"); return fd; @@ -588,6 +594,8 @@ anno (int fd, struct stat *st) sigaddset (&set, SIGTERM); sigprocmask (SIG_BLOCK, &set, &oset); + unregister_for_removal(0); + annoaux (fd); if (child_id == OK) _exit (0); @@ -595,7 +603,9 @@ anno (int fd, struct stat *st) /* reset the signal mask */ sigprocmask (SIG_SETMASK, &oset, &set); - chdir (cwd); + if (chdir (cwd) < 0) { + advise (cwd, "chdir"); + } break; default: /* no waiting... */