diff smap.c.solaris smap.c.solaris.dup 63a64 > static char *spool2 = (char *)0; 66a68 > static char *tempfile2 = (char *)0; 74c76 < static FILE *smapopen(); --- > static FILE *smapopen(int level); 84a87,90 > #ifdef DUPMAIL > if(tempfile2 != (char *)0) > unlink(tempfile2); > #endif 103a110 > FILE *vout2 = (FILE *)0; 259a267,269 > #ifdef DUPMAIL > unlink(tempfile2); > #endif 307a318,320 > #ifdef DUPMAIL > unlink(tempfile2); > #endif 316a330,332 > #ifdef DUPMAIL > unlink(tempfile2); > #endif 324a341,343 > #ifdef DUPMAIL > unlink(tempfile2); > #endif 348c367 < if((vout = smapopen()) == (FILE *)0) { --- > if((vout = smapopen(1)) == (FILE *)0) { 351a371,377 > #ifdef DUPMAIL > if((vout2 = smapopen(2)) == (FILE *)0) { > syslog(LLEV,"fwtksyserr: cannot open temp file 2 %m"); > exit(1); > > } > #endif 362c388,397 < switch(crunchbody(stdin,vout)) { --- > > #ifdef DUPMAIL > fprintf(vout2,"FROM %s\n",ruser); > for(tp = recip; tp != (struct towho *)0; tp = tp->nxt) > fprintf(vout2,"RCPT %s\n",tp->who); > fprintf(vout2,"BODY\n"); > fprintf(vout2,"Received: from %s(%s) by %s via smap (%s)\n\tid %s; %s",rladdr,riaddr,myhostname,FWTK_VERSION_MINOR,tempfile,ctime(&now)); > #endif > > switch(crunchbody(stdin,vout,vout2)) { 371a407,409 > #ifdef DUPMAIL > unlink(tempfile2); > #endif 384a423,425 > #ifdef DUPMAIL > fflush(vout2); > #endif 394a436,438 > #ifdef DUPMAIL > unlink(tempfile2); > #endif 401a446,451 > #ifdef DUPMAIL > chmod(tempfile2,0700); > lockun_fd(fileno(vout2)); > fclose(vout2); > vout2 = (FILE *)0; > #endif 448c498 < if((vout = smapopen()) == (FILE *)0) { --- > if((vout = smapopen(1)) == (FILE *)0) { 452a503,512 > #ifdef DUPMAIL > if(vout2 != (FILE *)0) { > unlink(tempfile2); > fclose(vout2); > if((vout2 = smapopen(2)) == (FILE *)0) { > syslog(LLEV,"fwtksyserr: cannot open temp file 2 %m"); > exit(1); > } > } > #endif 504c564 < smapopen() --- > smapopen(int level) 510,522c570,586 < strcpy(nuf,"smaXXXXXX"); < /* system V locking will have problems if mkstemp does < not open for random access as well as write */ < if((fd = mkstemp(nuf)) < 0) < return((FILE *)0); < chmod(nuf,0600); < if((ret = fdopen(fd,"w")) == (FILE *)0) < return((FILE *)0); < lock_fd(fd); < if((tempfile = malloc(strlen(nuf) + 1)) == (char *)0) { < syslog(LLEV,"fwtksyserr: out of memory: %m"); < unlink(nuf); < exit(1); --- > if(level == 1) { > strcpy(nuf,"smaXXXXXX"); > /* system V locking will have problems if mkstemp does > not open for random access as well as write */ > if((fd = mkstemp(nuf)) < 0) > return((FILE *)0); > chmod(nuf,0600); > if((ret = fdopen(fd,"w")) == (FILE *)0) > return((FILE *)0); > lock_fd(fd); > if((tempfile = malloc(strlen(nuf) + 1)) == (char *)0) { > syslog(LLEV,"fwtksyserr: out of memory: %m"); > unlink(nuf); > exit(1); > } > strcpy(tempfile,nuf); > return(ret); 524,525c588,608 < strcpy(tempfile,nuf); < return(ret); --- > else { > /* We make our file name "backup/smaXXXXXX" (whatever was used above) */ > strcpy(nuf,"backup/"); > strcat(nuf,tempfile); > > /* system V locking will have problems if mkstemp does > not open for random access as well as write */ > if((fd = mkstemp(nuf)) < 0) > return((FILE *)0); > chmod(nuf,0600); > if((ret = fdopen(fd,"w")) == (FILE *)0) > return((FILE *)0); > lock_fd(fd); > if((tempfile2 = malloc(strlen(nuf) + 1)) == (char *)0) { > syslog(LLEV,"fwtksyserr: out of memory: %m"); > unlink(nuf); > exit(1); > } > strcpy(tempfile2,nuf); > return(ret); > } 530c613 < crunchbody(in,out) --- > crunchbody(in,out,out2) 532a616 > FILE *out2; 535c619 < int x; --- > int x,x2; 542c626 < if(buf[0] == '.' && buf[1] == '.') --- > if(buf[0] == '.' && buf[1] == '.') { 543a628 > } 549a635,644 > #ifdef DUPMAIL > if(buf[0] == '.' && buf[1] == '.') > x2 = fprintf(out2,"%s\n",&buf[1]); > else > x2 = fprintf(out2,"%s\n",buf); > if(x2 == -1 || ferror(out2)) { > syslog(LLEV,"fwtksyserr: cannot fprintf2: %m"); > return(3); > } > #endif 559a655,660 > #ifdef DUPMAIL > if(fflush(out2) || ferror(out2)) { > syslog(LLEV,"fwtksyserr: cannot fprintf2: %m"); > return(3); > } > #endif 633a735,737 > #ifdef DUPMAIL > unlink(tempfile2); > #endif