/[mailutils]/mailutils/mail/util.c
ViewVC logotype

Diff of /mailutils/mail/util.c

Parent Directory Parent Directory | Revision Log Revision Log | View Patch Patch

revision 1.34 by alainm, Sat Sep 15 20:50:42 2001 UTC revision 1.35 by gray, Thu Jan 17 22:32:42 2002 UTC
# Line 824  util_help (const struct mail_command_ent Line 824  util_help (const struct mail_command_ent
824    return 1;    return 1;
825  }  }
826    
 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;  
 }  
   
827  static int  static int
828  util_descend_subparts (message_t mesg, msgset_t *msgset, message_t *part)  util_descend_subparts (message_t mesg, msgset_t *msgset, message_t *part)
829  {  {

Legend:
Removed from v.1.34  
changed lines
  Added in v.1.35

savannah-hackers-public@gnu.org
ViewVC Help
Powered by ViewVC 1.1.26