* Replaced all code that generated temporary filenames with calls to
authorArt Cancro <ajc@citadel.org>
Thu, 10 Jun 1999 03:39:50 +0000 (03:39 +0000)
committerArt Cancro <ajc@citadel.org>
Thu, 10 Jun 1999 03:39:50 +0000 (03:39 +0000)
          tmpnam().  Rewrote using tmpfile() where possible.

13 files changed:
citadel/ChangeLog
citadel/aidepost.c
citadel/citadel.c
citadel/citserver.c
citadel/cux2ascii.c
citadel/mailinglist.c
citadel/messages.c
citadel/msgbase.c
citadel/netmailer.c
citadel/netpoll.c
citadel/netproc.c
citadel/rcit.c
citadel/setup.c

index b4169858c33ed6b926b3965c16a5835d40ebcd84..cc152a6bb86c9f42ee142ac160c115f63a905c69 100644 (file)
@@ -1,3 +1,7 @@
+Wed Jun  9 23:34:25 EDT 1999 Art Cancro <ajc@uncnsrd.mt-kisco.ny.us>
+       * Replaced all code that generated temporary filenames with calls to
+         tmpnam().  Rewrote using tmpfile() where possible.
+
 Thu Jun  3 11:35:18 EDT 1999 Art Cancro <ajc@uncnsrd.mt-kisco.ny.us>
        * base64.c: mapped fi and fo to stdin and stdout using
          actual code rather than assignment at declaration time
index 9cdb92a36f44a00fa53332c3be6400838d297e0d..1e25cd3a37c8cdfbc46eb53cd9fd506c92b67fc2 100644 (file)
@@ -51,8 +51,6 @@ void make_message(FILE *fp, char *target_room)
 
 int main(int argc, char **argv)
 {
-       char tempbase[32];
-       char temptmp[64];
        char tempspool[64];
        char target_room[ROOMNAMELEN];
        FILE *tempfp, *spoolfp;
@@ -74,18 +72,14 @@ int main(int argc, char **argv)
        }
 
 
-       snprintf(tempbase, sizeof tempbase, "ap.%d", getpid());
-       snprintf(temptmp, sizeof temptmp, "/tmp/%s", tempbase);
-       snprintf(tempspool, sizeof tempspool, "./network/spoolin/%s", tempbase);
+       snprintf(tempspool, sizeof tempspool, "./network/spoolin/ap.%d",
+               getpid());
 
-       tempfp = fopen(temptmp, "wb+");
+       tempfp = tmpfile();
        if (tempfp == NULL) {
                perror("cannot open temp file");
                exit(errno);
        }
-       /* Unlink the temp file, so it automatically gets deleted by the OS if
-        * this program is interrupted or crashes.
-        */ unlink(temptmp);
 
        /* Generate a message from stdin */
        make_message(tempfp, target_room);
index 36e878d9793ed5ef94f8910174550d638f444100..79d403b6536a87747ad145673be7b7a0d64dd35a 100644 (file)
@@ -13,6 +13,7 @@
 #include <ctype.h>
 #include <string.h>
 #include <time.h>
+#include <limits.h>
 #include <sys/types.h>
 #include <sys/wait.h>
 #include <sys/stat.h>
@@ -53,9 +54,9 @@ struct march {
 struct march *march = NULL;
 
 /* globals associated with the client program */
-char temp[16];                 /* Name of general temp file */
-char temp2[16];                        /* Name of general temp file */
-char tempdir[16];              /* Name of general temp dir */
+char temp[PATH_MAX];           /* Name of general temp file */
+char temp2[PATH_MAX];          /* Name of general temp file */
+char tempdir[PATH_MAX];                /* Name of general temp dir */
 char editor_path[256];         /* path to external editor */
 char printcmd[256];            /* print command */
 int editor_pid = (-1);
@@ -968,9 +969,9 @@ int main(int argc, char **argv)
         * program.  Don't mess with these once they've been set, because we
         * will be unlinking them later on in the program and we don't
         * want to delete something that we didn't create. */
-       snprintf(temp, sizeof temp, "/tmp/citA%d", getpid());
-       snprintf(temp2, sizeof temp2, "/tmp/citB%d", getpid());
-       snprintf(tempdir, sizeof tempdir, "/tmp/citC%d", getpid());
+       snprintf(temp, sizeof temp, tmpnam(NULL));
+       snprintf(temp2, sizeof temp2, tmpnam(NULL));
+       snprintf(tempdir, sizeof tempdir, tmpnam(NULL));
 
        /* Get screen dimensions.  First we go to a default of 80x24.  Then
         * we try to get the user's actual screen dimensions off the server.
index 44a98d021bbf27470c04e1e362a7e5a8ecb3d733..693357e3da999aca497d7309044ef92fde13e9d7 100644 (file)
@@ -824,7 +824,7 @@ void *context_loop(struct CitContext *con)
        strcpy(CC->cs_clientname, "(unknown)");
        strcpy(CC->curr_user,"(not logged in)");
        strcpy(CC->net_node,"");
-       snprintf(CC->temp, sizeof CC->temp, "/tmp/CitServer.%d.%d", getpid(), CC->cs_pid);
+       snprintf(CC->temp, sizeof CC->temp, tmpnam(NULL));
        strcpy(CC->cs_room, "(no room)");
        strncpy(CC->cs_host, config.c_fqdn, sizeof CC->cs_host);
        CC->cs_host[sizeof CC->cs_host - 1] = 0;
index c69d96f264aa9b9eaf239add92c55f6bdf5702aa..281ea7a84db33382beadef05ba4800a46b6bcc7e 100644 (file)
@@ -21,164 +21,207 @@ void get_config();
 struct config config;
 
 
-main(argc,argv)
+main(argc, argv)
 int argc;
-char *argv[]; {
+char *argv[];
+{
        struct tm *tm;
-       int a,b,e,mtype,aflag;
-       char bbb[100],ngn[100];
+       int a, b, e, mtype, aflag;
+       char bbb[100], ngn[100];
        long tmid;
        char tsid[64];
        char tuid[64];
-       FILE *fp,*tfp;
-       long now,msglen;
-       char tflnm[16];
+       FILE *fp, *tfp;
+       long now, msglen;
 
        int cuunbatch = 0;
 
        /* experimental cuunbatch header generation */
-       for (a=0; a<argc; ++a) {
-               if (!strcmp(argv[a],"-c")) cuunbatch = 1;
-               }
+       for (a = 0; a < argc; ++a) {
+               if (!strcmp(argv[a], "-c"))
+                       cuunbatch = 1;
+       }
 
        get_config();
 
-       snprintf(tflnm,sizeof tflnm,"/tmp/c2a%d",getpid());
-
-       fp=stdin;
-   while (1) {
-       do {
-               e=getc(fp);
-               if (e<0) exit(0);
-               } while(e!=255);
-       mtype=getc(fp); aflag=getc(fp);
-
-       tmid = 0L;
-       strcpy(tsid,FQDN);
-       strcpy(tuid,"postmaster");
-
-       tfp=fopen(tflnm,"w");
-   do {
-       b=getc(fp);
-       if (b=='M') {
-               fprintf(tfp,"Message-ID: <%ld@%s>\n",tmid,tsid);
-               fprintf(tfp,"\n");
-               if (aflag!=1) fmout(80,fp,tfp);
-                  else while(a=getc(fp), a>0) {
-                       putc(a,tfp); if (a==13) putc(10,tfp);
+       fp = stdin;
+       while (1) {
+               do {
+                       e = getc(fp);
+                       if (e < 0)
+                               exit(0);
+               } while (e != 255);
+               mtype = getc(fp);
+               aflag = getc(fp);
+
+               tmid = 0L;
+               strcpy(tsid, FQDN);
+               strcpy(tuid, "postmaster");
+
+               tfp = tmpfile();
+               do {
+                       b = getc(fp);
+                       if (b == 'M') {
+                               fprintf(tfp, "Message-ID: <%ld@%s>\n", tmid, tsid);
+                               fprintf(tfp, "\n");
+                               if (aflag != 1)
+                                       fmout(80, fp, tfp);
+                               else
+                                       while (a = getc(fp), a > 0) {
+                                               putc(a, tfp);
+                                               if (a == 13)
+                                                       putc(10, tfp);
+                                       }
                        }
-               }
-       if ((b!='M')&&(b>0)) fpgetfield(fp,bbb);
-       if (b=='I') tmid=atol(bbb);
-       if (b=='N') {
-               strcpy(tsid,bbb);
-               if (!strcmp(tsid,NODENAME)) strcpy(tsid,FQDN);
-               for (a=0; a<strlen(tuid); ++a) if (tuid[a]==' ') tuid[a]='_';
-               fprintf(tfp,"From: %s@%s ",tuid,tsid);
-               for (a=0; a<strlen(tuid); ++a) if (tuid[a]=='_') tuid[a]=' ';
-               fprintf(tfp,"(%s)\n",tuid);
-               }
-       if (b=='P') fprintf(tfp,"Path: %s\n",bbb);
-       if (b=='A') strcpy(tuid,bbb);
-       if (b=='O') {
-               xref(bbb,ngn);
-               fprintf(tfp,"Newsgroups: %s\n",ngn);
-               }
-       if (b=='R') fprintf(tfp,"To: %s\n",bbb);
-       if (b=='U') fprintf(tfp,"Subject: %s\n",bbb);
-       if (b=='T') {
-               now=atol(bbb);
-               tm=(struct tm *)localtime(&now);
-               fprintf(tfp,"Date: %s",asctime(tm));
-               }
-          } while ((b!='M')&&(b>0));
-       msglen=ftell(tfp);
-       fclose(tfp);
+                       if ((b != 'M') && (b > 0))
+                               fpgetfield(fp, bbb);
+                       if (b == 'I')
+                               tmid = atol(bbb);
+                       if (b == 'N') {
+                               strcpy(tsid, bbb);
+                               if (!strcmp(tsid, NODENAME))
+                                       strcpy(tsid, FQDN);
+                               for (a = 0; a < strlen(tuid); ++a)
+                                       if (tuid[a] == ' ')
+                                               tuid[a] = '_';
+                               fprintf(tfp, "From: %s@%s ", tuid, tsid);
+                               for (a = 0; a < strlen(tuid); ++a)
+                                       if (tuid[a] == '_')
+                                               tuid[a] = ' ';
+                               fprintf(tfp, "(%s)\n", tuid);
+                       }
+                       if (b == 'P')
+                               fprintf(tfp, "Path: %s\n", bbb);
+                       if (b == 'A')
+                               strcpy(tuid, bbb);
+                       if (b == 'O') {
+                               xref(bbb, ngn);
+                               fprintf(tfp, "Newsgroups: %s\n", ngn);
+                       }
+                       if (b == 'R')
+                               fprintf(tfp, "To: %s\n", bbb);
+                       if (b == 'U')
+                               fprintf(tfp, "Subject: %s\n", bbb);
+                       if (b == 'T') {
+                               now = atol(bbb);
+                               tm = (struct tm *) localtime(&now);
+                               fprintf(tfp, "Date: %s", asctime(tm));
+                       }
+               } while ((b != 'M') && (b > 0));
+               msglen = ftell(tfp);
 
-       if (cuunbatch) {
-               printf("#! cuunbatch %ld\n",msglen);
-               }
-       else {
-               printf("#! rnews %ld\n",msglen);
+               if (cuunbatch) {
+                       printf("#! cuunbatch %ld\n", msglen);
+               } else {
+                       printf("#! rnews %ld\n", msglen);
                }
 
-       tfp=fopen(tflnm,"r");
-       while(msglen--) putc(getc(tfp),stdout);
-       fclose(tfp);
-       unlink(tflnm);
-   }
-exit(0);
+               rewind(tfp);
+               while (msglen--)
+                       putc(getc(tfp), stdout);
+               fclose(tfp);
+       }
+       exit(0);
 }
 
-fpgetfield(fp,string)  /* level-2 break out next null-terminated string */
+fpgetfield(fp, string)         /* level-2 break out next null-terminated string */
 FILE *fp;
 char string[];
 {
-int a,b;
-strcpy(string,"");
-a=0;
+       int a, b;
+       strcpy(string, "");
+       a = 0;
        do {
-               b=getc(fp);
-               if (b<1) { string[a]=0; return(0); }
-               string[a]=b;
+               b = getc(fp);
+               if (b < 1) {
+                       string[a] = 0;
+                       return (0);
+               }
+               string[a] = b;
                ++a;
-               } while(b!=0);
-       return(0);
+       } while (b != 0);
+       return (0);
 }
 
-fmout(width,fp,mout)
+fmout(width, fp, mout)
 int width;
-FILE *fp,*mout;
-       {
-       int a,b,c,real,old;
+FILE *fp, *mout;
+{
+       int a, b, c, real, old;
        char aaa[140];
-       
-       strcpy(aaa,""); old=255;
-       c=1; /* c is the current pos */
-FMTA:  old=real; a=getc(fp); real=a;
-       if (a<=0) goto FMTEND;
-       
-       if ( ((a==13)||(a==10)) && (old!=13) && (old!=10) ) a=32;
-       if ( ((old==13)||(old==10)) && (isspace(real)) ) {
-                                               fprintf(mout,"\n"); c=1; }
-       if (a>126) goto FMTA;
-
-       if (a>32) {
-       if ( ((strlen(aaa)+c)>(width-1)) && (strlen(aaa)>(width-1)) )
-               { fprintf(mout,"\n%s",aaa); c=strlen(aaa); aaa[0]=0; }
-        b=strlen(aaa); aaa[b]=a; aaa[b+1]=0; }
-       if (a==32) {    if ((strlen(aaa)+c)>(width-1)) { 
-                                                       fprintf(mout,"\n");
-                                                       c=1;
-                                                       }
-                       fprintf(mout,"%s ",aaa); ++c; c=c+strlen(aaa);
-                       strcpy(aaa,""); goto FMTA; }
-       if ((a==13)||(a==10)) {
-                               fprintf(mout,"%s\n",aaa); c=1;
-                               strcpy(aaa,""); goto FMTA; }
+
+       strcpy(aaa, "");
+       old = 255;
+       c = 1;                  /* c is the current pos */
+      FMTA:old = real;
+       a = getc(fp);
+       real = a;
+       if (a <= 0)
+               goto FMTEND;
+
+       if (((a == 13) || (a == 10)) && (old != 13) && (old != 10))
+               a = 32;
+       if (((old == 13) || (old == 10)) && (isspace(real))) {
+               fprintf(mout, "\n");
+               c = 1;
+       }
+       if (a > 126)
+               goto FMTA;
+
+       if (a > 32) {
+               if (((strlen(aaa) + c) > (width - 1)) && (strlen(aaa) > (width - 1))) {
+                       fprintf(mout, "\n%s", aaa);
+                       c = strlen(aaa);
+                       aaa[0] = 0;
+               }
+               b = strlen(aaa);
+               aaa[b] = a;
+               aaa[b + 1] = 0;
+       }
+       if (a == 32) {
+               if ((strlen(aaa) + c) > (width - 1)) {
+                       fprintf(mout, "\n");
+                       c = 1;
+               }
+               fprintf(mout, "%s ", aaa);
+               ++c;
+               c = c + strlen(aaa);
+               strcpy(aaa, "");
+               goto FMTA;
+       }
+       if ((a == 13) || (a == 10)) {
+               fprintf(mout, "%s\n", aaa);
+               c = 1;
+               strcpy(aaa, "");
+               goto FMTA;
+       }
        goto FMTA;
 
-FMTEND:        fprintf(mout,"\n");
-       return(0);
+      FMTEND:fprintf(mout, "\n");
+       return (0);
 }
 
-xref(roomname,newsgroup)
-char *roomname,*newsgroup; {
+xref(roomname, newsgroup)
+char *roomname, *newsgroup;
+{
        char tbuf[128];
        FILE *fp;
-       int commapos,a;
-
-       strcpy(newsgroup,roomname);
-       fp=fopen("./network/rnews.xref","r");
-       if (fp==NULL) return(1);
-       while (fgets(tbuf,128,fp)!=NULL) {
-               tbuf[strlen(tbuf)-1]=0;         /* strip off the newline */
-               a=strlen(tbuf);
-               while (a--) if (tbuf[a]==',') commapos=a;
-               tbuf[commapos]=0;
-               if (!strcasecmp(&tbuf[commapos+1],roomname))
-                       strcpy(newsgroup,tbuf);
-               }
-       fclose(fp);
-       return(0);
+       int commapos, a;
+
+       strcpy(newsgroup, roomname);
+       fp = fopen("./network/rnews.xref", "r");
+       if (fp == NULL)
+               return (1);
+       while (fgets(tbuf, 128, fp) != NULL) {
+               tbuf[strlen(tbuf) - 1] = 0;     /* strip off the newline */
+               a = strlen(tbuf);
+               while (a--)
+                       if (tbuf[a] == ',')
+                               commapos = a;
+               tbuf[commapos] = 0;
+               if (!strcasecmp(&tbuf[commapos + 1], roomname))
+                       strcpy(newsgroup, tbuf);
        }
+       fclose(fp);
+       return (0);
+}
index 9bd5e087cbe7be5a91c5c5b90a74a78bdcc62be4..796bd665e06ad5eed3b84ed18910085a22daf3cd 100644 (file)
@@ -83,7 +83,7 @@ int main(void) {
 
        get_config();
        LoadInternetConfig();
-       sprintf(tempfile, "/tmp/mlist.%ld", (long)getpid() );
+       sprintf(tempfile, tmpnam(NULL));
 
        while(1) {
 
index 2749d39b03f1e47ce8057026557501f6f020ce3d..0b5bee04c4c16b37a973a607e803986899991fa9 100644 (file)
@@ -15,6 +15,7 @@
 #include <time.h>
 #include <signal.h>
 #include <errno.h>
+#include <limits.h>
 #include <sys/wait.h>
 #include <sys/stat.h>
 #include <stdarg.h>
@@ -913,7 +914,7 @@ void readmsgs(int c, int rdir, int q)       /* read contents of a room */
        char arcflag = 0;
        char quotflag = 0;
        int hold_color = 0;
-       char prtfile[16];
+       char prtfile[PATH_MAX];
        char pagin;
        char cmd[256];
        char targ[ROOMNAMELEN];
@@ -925,7 +926,7 @@ void readmsgs(int c, int rdir, int q)       /* read contents of a room */
        if (c<0) b=(MAXMSGS-1);
        else b=0;
 
-       sprintf(prtfile,"/tmp/CPrt%ld",(long)getpid());
+       sprintf(prtfile, tmpnam(NULL));
 
        num_msgs = 0;
        strcpy(cmd,"MSGS ");
@@ -1000,7 +1001,7 @@ RMSGREAD: fflush(stdout);
                        enable_color = hold_color;
                        f=fork();
                        if (f==0) {
-                               freopen(prtfile,"r",stdin);
+                               freopen(prtfile, "r", stdin);
                                sttybbs(SB_RESTORE);
                                ka_system(printcmd);
                                sttybbs(SB_NO_INTR);
index 7d325aeba17425fd405e900a980a58dfab59612c..aca331a542cccac2a67b6f93328244aa45b62c40 100644 (file)
@@ -364,26 +364,15 @@ void fixed_output(char *name, char *filename, char *partnum, char *disp,
 void mime_download(char *name, char *filename, char *partnum, char *disp,
                         void *content, char *cbtype, size_t length) {
 
-       char tmpname[PATH_MAX];
-       static int seq = 0;
-
        /* Silently go away if there's already a download open... */
        if (CC->download_fp != NULL) return;
 
        /* ...or if this is not the desired section */
        if (strcasecmp(desired_section, partnum)) return;
 
-       snprintf(tmpname, sizeof tmpname,
-               "/tmp/CitServer.download.%4x.%4x", getpid(), ++seq);
-
-       CC->download_fp = fopen(tmpname, "wb+");
+       CC->download_fp = tmpfile();
        if (CC->download_fp == NULL) return;
 
-       /* Unlink the file while it's open, to guarantee that the
-        * temp file will always be deleted.
-        */
-       unlink(tmpname);
-
        fwrite(content, length, 1, CC->download_fp);
        fflush(CC->download_fp);
        rewind(CC->download_fp);
index 42da180be12cd2a246895696018c2c999c6847b7..08540e5b3d48a251c2a7789d22a0e6109129de24 100644 (file)
@@ -13,6 +13,7 @@
 #include <time.h>
 #include <string.h>
 #include <ctype.h>
+#include <limits.h>
 #include <syslog.h>
 #include "citadel.h"
 
@@ -20,7 +21,7 @@ void LoadInternetConfig(void);
 void get_config(void);
 struct config config;
 
-char temp[32];
+char temp[PATH_MAX];
 
 char ALIASES[128];
 char CIT86NET[128];
@@ -173,7 +174,7 @@ int main(int argc, char **argv)
        openlog("netmailer", LOG_PID, LOG_USER);
        get_config();   
        LoadInternetConfig();
-       sprintf(temp,"/tmp/netmailer.%ld",(long)getpid()); /* temp file name */
+       sprintf(temp, tmpnam(NULL));    /* temp file name */
 
        if ( (argc < 2) || (argc > 3) ) {
                fprintf(stderr, "netmailer: usage: netmailer recipient@node.dom [mlist]\n");
@@ -191,7 +192,7 @@ int main(int argc, char **argv)
                }
 
        /* convert to ASCII & get info */
-       fp=fopen(temp,"w");
+       fp=fopen(temp, "w");
        msgform(argv[1], fp, sbuf, rbuf, nbuf, pbuf, &mid_buf, rmname, subject);
        fclose(fp);
 
index d9d018cefe73785c8da6f187343fec51f31eb60a..a69ec8747913601a7faf61d382361c433dc37613 100644 (file)
@@ -5,6 +5,7 @@
 #include <fcntl.h>
 #include <string.h>
 #include <errno.h>
+#include <limits.h>
 #include "citadel.h"
 #include "tools.h"
 
@@ -40,11 +41,11 @@ void receive_spool(void)
        long bytes_received;
        char buf[256];
        static char pbuf[IGNET_PACKET_SIZE];
-       char tempfilename[64];
+       char tempfilename[PATH_MAX];
        long plen;
        FILE *fp;
 
-       sprintf(tempfilename, "/tmp/netpoll.%ld", (long) getpid());
+       sprintf(tempfilename, tmpnam(NULL));
        serv_puts("NDOP");
        serv_gets(buf);
        printf("%s\n", buf);
index 7a137c222358ff80c808235d663b009948930571..9f63211155edaa94bac58176a5f19db9f8e8f321 100644 (file)
@@ -120,7 +120,7 @@ int load_syslist(void) {
        char insys = 0;
        char buf[128];
 
-       fp=fopen("network/mail.sysinfo","rb");
+       fp=fopen("network/mail.sysinfo", "r");
        if (fp==NULL) return(1);
 
        while(1) {
@@ -658,9 +658,9 @@ void inprocess(void) {
        long msglen;
        int bloklen;
 
-
-       sprintf(tname,"/tmp/net.t%ld",(long)getpid());  /* temp file name */
-       sprintf(iname,"/tmp/net.i%ld",(long)getpid());  /* temp file name */
+       /* temp file names */
+       sprintf(tname, tmpnam(NULL));
+       sprintf(iname, tmpnam(NULL));
 
        load_filterlist();
 
@@ -703,7 +703,7 @@ NXMSG:      /* Seek to the beginning of the next message */
                } while((a!=255)&&(a>=0));
        if (a<0) goto ENDSTR;
 
-       message = fopen(tname,"wb");    /* This crates the temporary file. */
+       message = fopen(tname, "wb");   /* This crates the temporary file. */
        if (message == NULL) {
                syslog(LOG_ERR, "error creating %s: %s", tname,strerror(errno));
                goto ENDSTR;
@@ -938,14 +938,14 @@ int ismsgok(long int mpos, FILE *mmfp, char *sysname)
        return(ok);
        }
 
-int spool_out(struct msglist *cmlist, FILE *destfp, char *sysname)     /* spool list of messages to a file */
-                                               /* returns # of msgs spooled */
-              
-              
+
+
+/* spool list of messages to a file */
+/* returns # of msgs spooled */
+int spool_out(struct msglist *cmlist, FILE *destfp, char *sysname)
 {
        struct msglist *cmptr;
        FILE *mmfp;
-       char mmtemp[128];
        char fbuf[128];
        int a;
        int msgs_spooled = 0;
@@ -956,7 +956,6 @@ int spool_out(struct msglist *cmlist, FILE *destfp, char *sysname)  /* spool list
        char curr_rm[256];
 
        strcpy(curr_rm, "");
-       sprintf(mmtemp, "/tmp/net.m%ld", (long)getpid());
 
        /* for each message in the list... */
        for (cmptr=cmlist; cmptr!=NULL; cmptr=cmptr->next) {
@@ -975,7 +974,7 @@ int spool_out(struct msglist *cmlist, FILE *destfp, char *sysname)  /* spool list
                        }
 
                /* download the message from the server... */
-               mmfp = fopen(mmtemp, "wb");
+               mmfp = tmpfile();
                sprintf(buf, "MSG3 %ld", cmptr->m_num);
                serv_puts(buf);
                serv_gets(buf);
@@ -991,9 +990,8 @@ int spool_out(struct msglist *cmlist, FILE *destfp, char *sysname)  /* spool list
                else {                                  /* or print the err */
                        syslog(LOG_ERR, "%s", buf);
                        }
-               fclose(mmfp);
-       
-               mmfp = fopen(mmtemp,"rb");
+
+               rewind(mmfp);
 
                if (ismsgok(0L,mmfp,sysname)) {
                        ++msgs_spooled;
@@ -1021,7 +1019,6 @@ int spool_out(struct msglist *cmlist, FILE *destfp, char *sysname)        /* spool list
                fclose(mmfp);
                }
 
-       unlink(mmtemp);
        return(msgs_spooled);
        }
 
@@ -1041,9 +1038,9 @@ void outprocess(char *sysname) /* send new room messages to sysname */
        int outgoing_msgs;
        long thismsg;
 
-       sprintf(tempflnm,"/tmp/%s.%ld",NODENAME,(long)getpid());
-       tempflfp=fopen(tempflnm,"w");
-       if (tempflfp==NULL) return;
+       sprintf(tempflnm, tmpnam(NULL));
+       tempflfp = fopen(tempflnm,"w");
+       if (tempflfp == NULL) return;
 
 
 /*
index 81dec46fa121b2e0909ce26ad7e36e6535e56dd4..7ccd116e989d009bfe1aeb67054918329f4e9575 100644 (file)
@@ -85,8 +85,8 @@ int main(int argc, char **argv)
        char spool_only = 0;
 
        get_config();
-       sprintf(flnm,"./network/spoolin/rnews.%ld",(long)getpid());
-       sprintf(tname,"/tmp/rnews.%ld",(long)getpid());
+       sprintf(flnm,"./network/spoolin/rnews.%d", getpid());
+       sprintf(tname, tmpnam(NULL));
 
        for (a=1; a<argc; ++a) {
                if (!strcmp(argv[a],"-c")) binary_input = 1;
index 8a19ead50d8eb93642ed257e9b0c51a3a1ae986c..29776a67a3b4f1b5aefb2c5dac535fe2cdb11293 100644 (file)
@@ -574,7 +574,7 @@ void set_str_val(int msgpos, char str[])
        char tempfile[64];
        FILE *fp;
 
-       sprintf(tempfile, "/tmp/setup.%ld", (long) getpid());
+       sprintf(tempfile, tmpnam(NULL));
 
        switch (setup_type) {
        case UI_TEXT: