Commit 206c4704 206c470477c8c28b2a253e3d6f18c24ebeba47e6 by Sergey Poznyakoff

Removed util_tempfile().

1 parent 26adedc2
......@@ -29,53 +29,6 @@ util_error (char *fmt, ...)
va_end (ap);
}
int
util_tempfile (char **namep)
{
char *filename;
char *tmpdir;
int fd;
/* We have to be extra careful about opening temporary files, since we
may be running with extra privilege i.e setgid(). */
tmpdir = (getenv ("TMPDIR")) ? getenv ("TMPDIR") : "/tmp";
filename = malloc (strlen (tmpdir) + /*'/' */ 1 + /* "muXXXXXX" */ 8 + 1);
if (!filename)
return -1;
sprintf (filename, "%s/muXXXXXX", tmpdir);
#ifdef HAVE_MKSTEMP
{
int save_mask = umask (077);
fd = mkstemp (filename);
umask (save_mask);
}
#else
if (mktemp (filename))
fd = open (filename, O_CREAT | O_EXCL | O_RDWR, 0600);
else
fd = -1;
#endif
if (fd == -1)
{
util_error ("Can not open temporary file: %s", strerror (errno));
free (filename);
return -1;
}
if (namep)
*namep = filename;
else
{
unlink (filename);
free (filename);
}
return fd;
}
char *
util_get_sender (int msgno)
{
......
......@@ -824,53 +824,6 @@ util_help (const struct mail_command_entry *table, char *word)
return 1;
}
int
util_tempfile(char **namep)
{
char *filename;
const char *tmpdir;
int fd;
/* We have to be extra careful about opening temporary files, since we
may be running with extra privilege i.e setgid(). */
tmpdir = (getenv ("TMPDIR")) ? getenv ("TMPDIR") : "/tmp";
filename = malloc (strlen (tmpdir) + /*'/'*/1 + /* "muXXXXXX" */8 + 1);
if (!filename)
return -1;
sprintf (filename, "%s/muXXXXXX", tmpdir);
#ifdef HAVE_MKSTEMP
{
int save_mask = umask(077);
fd = mkstemp (filename);
umask(save_mask);
}
#else
if (mktemp (filename))
fd = open(filename, O_CREAT|O_EXCL|O_RDWR, 0600);
else
fd = -1;
#endif
if (fd == -1)
{
util_error("Can not open temporary file: %s", strerror(errno));
free(filename);
return -1;
}
if (namep)
*namep = filename;
else
{
unlink(filename);
free(filename);
}
return fd;
}
static int
util_descend_subparts (message_t mesg, msgset_t *msgset, message_t *part)
{
......