home *** CD-ROM | disk | FTP | other *** search
/ Usenet 1994 January / usenetsourcesnewsgroupsinfomagicjanuary1994.iso / sources / misc / volume35 / procmail / patch01b < prev    next >
Text File  |  1993-03-04  |  15KB  |  387 lines

  1. Newsgroups: comp.sources.misc
  2. From: berg@pool.informatik.rwth-aachen.de (Stephen R. van den Berg)
  3. Subject: v35i125:  procmail - mail processing package v2.80, Patch01b/2
  4. Message-ID: <1993Mar4.212043.13995@sparky.imd.sterling.com>
  5. X-Md4-Signature: fc2dda904c73e91196b6d68d138bab4e
  6. Date: Thu, 4 Mar 1993 21:20:43 GMT
  7. Approved: kent@sparky.imd.sterling.com
  8.  
  9. Submitted-by: berg@pool.informatik.rwth-aachen.de (Stephen R. van den Berg)
  10. Posting-number: Volume 35, Issue 125
  11. Archive-name: procmail/patch01b
  12. Environment: sendmail, smail, MMDF, mailsurr, UNIX, POSIX
  13. Patch-To: procmail: Volume 35, Issue 21-32
  14.  
  15. To apply this patch:
  16.  
  17.         cd procmail280; patch -s -p1 <this_file
  18.  
  19. -----------
  20. diff -c procmail/src/multigram.c:1.21 procmail/src/multigram.c:1.22
  21. *** procmail/src/multigram.c:1.21    Fri Feb 19 16:22:41 1993
  22. --- procmail/src/multigram.c    Fri Feb 19 16:22:41 1993
  23. ***************
  24. *** 15,23 ****
  25.    ************************************************************************/
  26.   #ifdef RCS
  27.   static /*const*/char rcsid[]=
  28. !  "$Id: multigram.c,v 1.21 1993/02/02 15:27:19 berg Exp $";
  29.   #endif
  30. ! static /*const*/char rcsdate[]="$Date: 1993/02/02 15:27:19 $";
  31.   #include "includes.h"
  32.   #include "sublib.h"
  33.   #include "shell.h"
  34. --- 15,23 ----
  35.    ************************************************************************/
  36.   #ifdef RCS
  37.   static /*const*/char rcsid[]=
  38. !  "$Id: multigram.c,v 1.22 1993/02/10 17:08:06 berg Exp $";
  39.   #endif
  40. ! static /*const*/char rcsdate[]="$Date: 1993/02/10 17:08:06 $";
  41.   #include "includes.h"
  42.   #include "sublib.h"
  43.   #include "shell.h"
  44. ***************
  45. *** 150,156 ****
  46.      { char*chp;
  47.        if(!strcmp(chp=lastdirsep(argv[0]),flist))         /* suid flist prog? */
  48.         { struct stat stbuf;
  49. !     *chp='\0';                /* security check, 3 hardlinks!? */
  50.       if(!chdir(argv[0])&&!lstat(flist,&stbuf)&&S_ISREG(stbuf.st_mode)&&
  51.        stbuf.st_mode&S_ISUID&&stbuf.st_uid==geteuid()&&stbuf.st_nlink==3&&
  52.        !chdir(chPARDIR))
  53. --- 150,156 ----
  54.      { char*chp;
  55.        if(!strcmp(chp=lastdirsep(argv[0]),flist))         /* suid flist prog? */
  56.         { struct stat stbuf;
  57. !     progname=flist;*chp='\0';        /* security check, 3 hardlinks!? */
  58.       if(!chdir(argv[0])&&!lstat(flist,&stbuf)&&S_ISREG(stbuf.st_mode)&&
  59.        stbuf.st_mode&S_ISUID&&stbuf.st_uid==geteuid()&&stbuf.st_nlink==3&&
  60.        !chdir(chPARDIR))
  61. ***************
  62. *** 184,189 ****
  63. --- 184,190 ----
  64.        setgid(getgid());setuid(getuid());          /* revoke suid permissions */
  65.        if(!strcmp(chp,idhash))                  /* idhash program? */
  66.         { unsigned long hash=0;int i;
  67. +     progname=idhash;
  68.       if(minweight!=1)
  69.        { elog("Usage: idhash\n");return EX_USAGE;
  70.        }
  71. ***************
  72. *** 314,323 ****
  73.       else if(parens<0&&*echp==')')
  74.          *echp='\0';
  75.       if(*(chp=fuzzstr.text)=='<'&&*(echp=strchr(chp,'\0')-1)=='>'
  76. !      &&echp==strpbrk(chp,"([\">,; \t\n"))          /* strip '<' and '>' ? */
  77.          *echp='\0',tmemmove(chp,chp+1,echp-chp);
  78.       if(!(fuzzlen=strlen(chp)))
  79. !        continue;;
  80.       if(!curmatch)
  81.          curmatch=malloc(sizeof*curmatch);
  82.       curmatch->fuzz=tstrdup(chp);curmatch->hard=malloc(1);
  83. --- 315,333 ----
  84.       else if(parens<0&&*echp==')')
  85.          *echp='\0';
  86.       if(*(chp=fuzzstr.text)=='<'&&*(echp=strchr(chp,'\0')-1)=='>'
  87. !      &&!strchr(chp,','))                  /* strip '<' and '>' ? */
  88.          *echp='\0',tmemmove(chp,chp+1,echp-chp);
  89.       if(!(fuzzlen=strlen(chp)))
  90. !        continue;
  91. !     ;{ int i=0;
  92. !        do
  93. !         { if(best[i]->metric==-SCALE_WEIGHT&&!strcmp(best[i]->fuzz,chp))
  94. !          break;
  95. !           if(!strcmp(best[i]->fuzz,chp))    /* already matched this one? */
  96. !          goto dupl_addr;
  97. !         }
  98. !        while(++i<=best_matches);
  99. !      }
  100.       if(!curmatch)
  101.          curmatch=malloc(sizeof*curmatch);
  102.       curmatch->fuzz=tstrdup(chp);curmatch->hard=malloc(1);
  103. ***************
  104. *** 378,386 ****
  105.          curmatch->offs1=offs1;curmatch->offs2=offs2;
  106.        }
  107.         }
  108. !      free(fuzzstr.itext);
  109. !      if(curmatch->metric>=0)     /* maybe this match can be put in the array */
  110. !       { struct match*mp,**mmp;               /* of best matches so far */
  111.       free((mp= *(mmp=best+best_matches))->fuzz);free(mp->hard);free(mp);
  112.       while(--mmp>=best&&(mp= *mmp)->metric<curmatch->metric)
  113.          mmp[1]=mp;                       /* keep it sorted */
  114. --- 388,396 ----
  115.          curmatch->offs1=offs1;curmatch->offs2=offs2;
  116.        }
  117.         }
  118. !      free(fuzzstr.itext);     /* maybe this match can be put in the array */
  119. !      if(curmatch->metric>-SCALE_WEIGHT)           /* of best matches so far */
  120. !       { struct match*mp,**mmp;
  121.       free((mp= *(mmp=best+best_matches))->fuzz);free(mp->hard);free(mp);
  122.       while(--mmp>=best&&(mp= *mmp)->metric<curmatch->metric)
  123.          mmp[1]=mp;                       /* keep it sorted */
  124. ***************
  125. *** 388,393 ****
  126. --- 398,404 ----
  127.         }
  128.        else
  129.       free(curmatch->fuzz),free(curmatch->hard);
  130. + dupl_addr:;
  131.      }
  132.     ;{ int i;struct match*mp;
  133.        for(i=0;i<=best_matches&&(mp=best[i++])->metric>=minweight;)
  134. diff -c procmail/src/procmail.c:1.25 procmail/src/procmail.c:1.27
  135. *** procmail/src/procmail.c:1.25    Fri Feb 19 16:22:42 1993
  136. --- procmail/src/procmail.c    Fri Feb 19 16:22:43 1993
  137. ***************
  138. *** 12,18 ****
  139.    ************************************************************************/
  140.   #ifdef RCS
  141.   static /*const*/char rcsid[]=
  142. !  "$Id: procmail.c,v 1.25 1993/02/02 15:27:23 berg Exp $";
  143.   #endif
  144.   #include "../patchlevel.h"
  145.   #include "procmail.h"
  146. --- 12,18 ----
  147.    ************************************************************************/
  148.   #ifdef RCS
  149.   static /*const*/char rcsid[]=
  150. !  "$Id: procmail.c,v 1.27 1993/02/11 12:08:41 berg Exp $";
  151.   #endif
  152.   #include "../patchlevel.h"
  153.   #include "procmail.h"
  154. ***************
  155. *** 30,36 ****
  156.   
  157.   static const char fdefault[]="DEFAULT",orgmail[]="ORGMAIL",
  158.    sendmail[]="SENDMAIL",From_[]=FROM,exflags[]=RECFLAGS,
  159. !  systm_mbox[]=SYSTEM_MBOX,pmusage[]=PM_USAGE;
  160.   char*buf,*buf2,*globlock,*loclock,*tolock,*lastfolder;
  161.   const char shellflags[]="SHELLFLAGS",shell[]="SHELL",lockfile[]="LOCKFILE",
  162.    shellmetas[]="SHELLMETAS",lockext[]="LOCKEXT",newline[]="\n",binsh[]=BinSh,
  163. --- 30,36 ----
  164.   
  165.   static const char fdefault[]="DEFAULT",orgmail[]="ORGMAIL",
  166.    sendmail[]="SENDMAIL",From_[]=FROM,exflags[]=RECFLAGS,
  167. !  systm_mbox[]=SYSTEM_MBOX,pmusage[]=PM_USAGE,DEFdeflock[]=DEFdefaultlock;
  168.   char*buf,*buf2,*globlock,*loclock,*tolock,*lastfolder;
  169.   const char shellflags[]="SHELLFLAGS",shell[]="SHELL",lockfile[]="LOCKFILE",
  170.    shellmetas[]="SHELLMETAS",lockext[]="LOCKEXT",newline[]="\n",binsh[]=BinSh,
  171. ***************
  172. *** 37,43 ****
  173.    unexpeof[]="Unexpected EOL\n",*const*gargv,*sgetcp,*rcfile=PROCMAILRC,
  174.    dirsep[]=DIRSEP,msgprefix[]="MSGPREFIX",devnull[]=DevNull,lgname[]="LOGNAME",
  175.    executing[]="Executing",oquote[]=" \"",cquote[]="\"\n",procmailn[]="procmail",
  176. !  whilstwfor[]=" whilst waiting for ",home[]="HOME",maildir[]="MAILDIR";
  177.   char*Stdout;
  178.   int retval=EX_CANTCREAT,retvl2=EX_OK,sh,pwait,lcking,rc=rc_INIT,
  179.    ignwerr,lexitcode=EX_OK,asgnlastf;
  180. --- 37,44 ----
  181.    unexpeof[]="Unexpected EOL\n",*const*gargv,*sgetcp,*rcfile=PROCMAILRC,
  182.    dirsep[]=DIRSEP,msgprefix[]="MSGPREFIX",devnull[]=DevNull,lgname[]="LOGNAME",
  183.    executing[]="Executing",oquote[]=" \"",cquote[]="\"\n",procmailn[]="procmail",
  184. !  whilstwfor[]=" whilst waiting for ",home[]="HOME",maildir[]="MAILDIR",
  185. !  *defdeflock;
  186.   char*Stdout;
  187.   int retval=EX_CANTCREAT,retvl2=EX_OK,sh,pwait,lcking,rc=rc_INIT,
  188.    ignwerr,lexitcode=EX_OK,asgnlastf;
  189. ***************
  190. *** 237,246 ****
  191.     ;{ const char*const*kp;
  192.        for(kp=prestenv;*kp;)  /* preset or wipe selected environment variables */
  193.       strcpy((char*)(sgetcp=buf2),*kp++),readparse(buf,sgetc,2),sputenv(buf);
  194. !    }
  195. !   strcpy(buf2,strcpy(buf,chp=(char*)getenv(orgmail)));
  196. !   buf[i=lastdirsep(chp)-chp]='\0';           /* strip off the basename */
  197. !   ;{ struct stat stbuf;
  198.        sgid=gid;                        /* presumed innocent */
  199.       /*
  200.        *    do we need sgidness to access the mail-spool directory/files?
  201. --- 238,248 ----
  202.     ;{ const char*const*kp;
  203.        for(kp=prestenv;*kp;)  /* preset or wipe selected environment variables */
  204.       strcpy((char*)(sgetcp=buf2),*kp++),readparse(buf,sgetc,2),sputenv(buf);
  205. !    }                 /* find out the name of our system lockfile */
  206. !   sgetcp=DEFdeflock+STRLEN(lockfile)+1;readparse(buf,sgetc,2);
  207. !   defdeflock=tstrdup(buf);strcpy(buf,chp=(char*)getenv(orgmail));
  208. !   buf[i=lastdirsep(chp)-chp]='\0';
  209. !   ;{ struct stat stbuf;                   /* strip off the basename */
  210.        sgid=gid;                        /* presumed innocent */
  211.       /*
  212.        *    do we need sgidness to access the mail-spool directory/files?
  213. ***************
  214. *** 257,264 ****
  215.        *    check if the default-mailbox-lockfile is owned by the recipient, if
  216.        *    not, mark it for further investigation, it might need to be removed
  217.        */
  218. !      if(!(Privileged=lstat(strcat(buf2,getenv(lockext)),&stbuf)||
  219. !       stbuf.st_uid==uid))            /* check for bogus lockfiles */
  220.       ultoan((unsigned long)stbuf.st_ino,          /* i-node numbered */
  221.        strchr(strcpy(buf+i,BOGUSprefix),'\0'));
  222.       /*
  223. --- 259,265 ----
  224.        *    check if the default-mailbox-lockfile is owned by the recipient, if
  225.        *    not, mark it for further investigation, it might need to be removed
  226.        */
  227. !      if(!(Privileged=lstat(defdeflock,&stbuf)||stbuf.st_uid==uid))
  228.       ultoan((unsigned long)stbuf.st_ino,          /* i-node numbered */
  229.        strchr(strcpy(buf+i,BOGUSprefix),'\0'));
  230.       /*
  231. ***************
  232. *** 275,281 ****
  233.         { succeed=1;
  234.   boglock:
  235.       if(!Privileged)      /* try to rename the bogus lockfile out of the way */
  236. !        rename(buf2,buf);
  237.         }
  238.        else
  239.       succeed=1;                 /* mailbox a symbolic link? */
  240. --- 276,282 ----
  241.         { succeed=1;
  242.   boglock:
  243.       if(!Privileged)      /* try to rename the bogus lockfile out of the way */
  244. !        rename(defdeflock,buf);
  245.         }
  246.        else
  247.       succeed=1;                 /* mailbox a symbolic link? */
  248. ***************
  249. *** 313,319 ****
  250.        *    really change the uid now, since we are not in explicit
  251.        *    delivery mode
  252.        */
  253. !    { setgid(gid);setuid(uid);
  254.        if(suppmunreadable=nextrcfile())      /* any rcfile on the command-line? */
  255.   #ifndef NO_COMSAT
  256.       if(!getenv(scomsat))
  257. --- 314,320 ----
  258.        *    really change the uid now, since we are not in explicit
  259.        *    delivery mode
  260.        */
  261. !    { setgid(gid);setuid(uid);rc=rc_NOFILE;
  262.        if(suppmunreadable=nextrcfile())      /* any rcfile on the command-line? */
  263.   #ifndef NO_COMSAT
  264.       if(!getenv(scomsat))
  265. ***************
  266. *** 540,551 ****
  267.                { nlog("Couldn't determine implicit lockfile from");
  268.                  logqnl(buf);
  269.                }
  270.             }
  271.            lcllock();
  272.            if(!pwait)        /* try and protect the user from his */
  273.               pwait=2;               /* blissful ignorance :-) */
  274.              }
  275. !           inittmout(buf);
  276.             if(flags[FILTER])
  277.              { if(startchar==themail&&tobesent!=filled)     /* if only 'h' */
  278.             { if(!pipthrough(buf,startchar,tobesent))
  279. --- 541,554 ----
  280.                { nlog("Couldn't determine implicit lockfile from");
  281.                  logqnl(buf);
  282.                }
  283. +             else if(!strcmp(buf2,devnull))    /* locking /dev/null */
  284. +                goto noloclock;               /* would be silly */
  285.             }
  286.            lcllock();
  287.            if(!pwait)        /* try and protect the user from his */
  288.               pwait=2;               /* blissful ignorance :-) */
  289.              }
  290. ! noloclock:    inittmout(buf);
  291.             if(flags[FILTER])
  292.              { if(startchar==themail&&tobesent!=filled)     /* if only 'h' */
  293.             { if(!pipthrough(buf,startchar,tobesent))
  294. ***************
  295. *** 619,625 ****
  296.   nomore_rc:
  297.     concon('\n');succeed=0;
  298.     if(*(chp=(char*)tgetenv(fdefault)))                 /* DEFAULT set? */
  299. !    { setuid(uid);firstchd();asenvcpy(DEFdefaultlock);        /* implicit lock */
  300.        if(dump(deliver(chp),themail,filled))              /* default */
  301.       writeerr(buf);
  302.        else
  303. --- 622,628 ----
  304.   nomore_rc:
  305.     concon('\n');succeed=0;
  306.     if(*(chp=(char*)tgetenv(fdefault)))                 /* DEFAULT set? */
  307. !    { setuid(uid);firstchd();asenvcpy(DEFdeflock);        /* implicit lock */
  308.        if(dump(deliver(chp),themail,filled))              /* default */
  309.       writeerr(buf);
  310.        else
  311. diff -c procmail/src/procmail.h:1.8 procmail/src/procmail.h:1.9
  312. *** procmail/src/procmail.h:1.8    Fri Feb 19 16:22:44 1993
  313. --- procmail/src/procmail.h    Fri Feb 19 16:22:44 1993
  314. ***************
  315. *** 1,4 ****
  316. ! /*$Id: procmail.h,v 1.8 1993/01/13 16:17:29 berg Exp $*/
  317.   
  318.   #include "includes.h"
  319.   
  320. --- 1,4 ----
  321. ! /*$Id: procmail.h,v 1.9 1993/02/10 17:08:12 berg Exp $*/
  322.   
  323.   #include "includes.h"
  324.   
  325. ***************
  326. *** 56,62 ****
  327.   extern const char shellflags[],shell[],lockfile[],lockext[],newline[],binsh[],
  328.    unexpeof[],shellmetas[],*const*gargv,*sgetcp,*rcfile,dirsep[],msgprefix[],
  329.    devnull[],lgname[],executing[],oquote[],cquote[],whilstwfor[],procmailn[],
  330. !  Mail[],home[],maildir[];
  331.   extern long filled;
  332.   extern sh,pwait,retval,retvl2,lcking,rc,ignwerr,lexitcode,asgnlastf;
  333.   extern size_t linebuf;
  334. --- 56,62 ----
  335.   extern const char shellflags[],shell[],lockfile[],lockext[],newline[],binsh[],
  336.    unexpeof[],shellmetas[],*const*gargv,*sgetcp,*rcfile,dirsep[],msgprefix[],
  337.    devnull[],lgname[],executing[],oquote[],cquote[],whilstwfor[],procmailn[],
  338. !  Mail[],home[],maildir[],*defdeflock;
  339.   extern long filled;
  340.   extern sh,pwait,retval,retvl2,lcking,rc,ignwerr,lexitcode,asgnlastf;
  341.   extern size_t linebuf;
  342. diff -c procmail/README:1.10 procmail/README:1.12
  343. *** procmail/README:1.10    Fri Feb 19 16:21:50 1993
  344. --- procmail/README    Fri Feb 19 16:21:50 1993
  345. ***************
  346. *** 35,41 ****
  347.   
  348.   ------------------------------ DESCRIPTION -----------------------------------
  349.   
  350. ! The procmail mail processing program. (v2.80 1993/02/04)
  351.   
  352.   Can be used to create mail-servers, mailing lists, sort your incoming mail
  353.   into separate folders/files (real convenient when subscribing to one or more
  354. --- 35,41 ----
  355.   
  356.   ------------------------------ DESCRIPTION -----------------------------------
  357.   
  358. ! The procmail mail processing program. (v2.81 1993/02/19)
  359.   
  360.   Can be used to create mail-servers, mailing lists, sort your incoming mail
  361.   into separate folders/files (real convenient when subscribing to one or more
  362. ***************
  363. *** 84,90 ****
  364.       David W. Tamkin        An excellent proofreader and betatester
  365.        <dattier@gagme.chi.il.us>
  366.       Josh Laff        For stresstesting procmail (and me :-)
  367. !      <smiley@uiuc.edu>
  368.       Dan Jacobson        For his many useful suggestions
  369.        <Dan_Jacobson@ATT.COM>
  370.   
  371. --- 84,90 ----
  372.       David W. Tamkin        An excellent proofreader and betatester
  373.        <dattier@gagme.chi.il.us>
  374.       Josh Laff        For stresstesting procmail (and me :-)
  375. !      <jal@uiuc.edu>
  376.       Dan Jacobson        For his many useful suggestions
  377.        <Dan_Jacobson@ATT.COM>
  378.   
  379. -----------
  380. -- 
  381. Sincerely,                                  berg@pool.informatik.rwth-aachen.de
  382.            Stephen R. van den Berg (AKA BuGless).    berg@physik.tu-muenchen.de
  383.  
  384. I've never been superstitious!  Knock on wood.
  385.  
  386. exit 0 # Just in case...
  387.