| 1 | See https://github.com/BuGlessRB/procmail/pull/7
|
| 2 |
|
| 3 | diff --git a/initmake b/initmake
|
| 4 | index 82d718d..e44ee67 100755
|
| 5 | |
| 6 | |
| 7 | @@ -124,7 +124,7 @@ else
|
| 8 | fi
|
| 9 |
|
| 10 | cat >_autotst.c <<HERE
|
| 11 | -main()
|
| 12 | +int main()
|
| 13 | { return 0;
|
| 14 | }
|
| 15 | HERE
|
| 16 | @@ -200,7 +200,7 @@ cat >_autotst.c <<HERE
|
| 17 | #include <sys/types.h>
|
| 18 | #include <stdio.h>
|
| 19 | #include <sys/stat.h>
|
| 20 | -main()
|
| 21 | +int main()
|
| 22 | { struct stat buf;return!&buf;
|
| 23 | }
|
| 24 | HERE
|
| 25 | diff --git a/src/autoconf b/src/autoconf
|
| 26 | index 1cb4c42..995d8bb 100755
|
| 27 | |
| 28 | |
| 29 | @@ -363,6 +363,7 @@ cat >_autotst.c <<HERE
|
| 30 | #include <unistd.h> /* getpid() getppid() */
|
| 31 | #endif
|
| 32 | #include <stdio.h>
|
| 33 | +#include <stdlib.h>
|
| 34 | #include <time.h>
|
| 35 | #include <fcntl.h>
|
| 36 | #include <signal.h> /* SIGKILL */
|
| 37 | @@ -416,6 +417,16 @@ cat >_autotst.c <<HERE
|
| 38 | int dolock,child[NR_of_forks],timeout,fdcollect;
|
| 39 | char dirlocktest[]="_locktest";
|
| 40 |
|
| 41 | +int killchildren()
|
| 42 | +{ int i;
|
| 43 | + i=NR_of_forks;
|
| 44 | + do
|
| 45 | + if(child[--i]>0)
|
| 46 | + kill(child[i],SIGTERM),child[i]=0;
|
| 47 | + while(i);
|
| 48 | + return 0;
|
| 49 | +}
|
| 50 | +
|
| 51 | void stimeout()
|
| 52 | { timeout=1;close(fdcollect);killchildren();
|
| 53 | }
|
| 54 | @@ -437,7 +448,79 @@ unsigned sfork()
|
| 55 | return pid;
|
| 56 | }
|
| 57 |
|
| 58 | -int main(argc,argv)char*argv[];
|
| 59 | +static int oldfdlock;
|
| 60 | +#ifdef F_SETLKW
|
| 61 | +static struct flock flck; /* why can't it be a local variable? */
|
| 62 | +#endif
|
| 63 | +#ifdef F_LOCK
|
| 64 | +static off_t oldlockoffset;
|
| 65 | +#endif
|
| 66 | +
|
| 67 | +int fdlock(int fd)
|
| 68 | +{ int i;unsigned gobble[GOBBLE>>2];
|
| 69 | + for(i=GOBBLE>>2;i;gobble[--i]=~(unsigned)0); /* SunOS crash test */
|
| 70 | + oldfdlock=fd;fd=0;
|
| 71 | + if(MSK_fcntl&dolock)
|
| 72 | +#ifdef F_SETLKW
|
| 73 | + { static unsigned extra;
|
| 74 | + flck.l_type=F_WRLCK;flck.l_whence=SEEK_SET;flck.l_start=tell(oldfdlock);
|
| 75 | + if(!extra--)
|
| 76 | + extra=MIN_locks/4,flck.l_len=2,i|=fcntl(oldfdlock,F_SETLK,&flck);
|
| 77 | + flck.l_len=0;fd|=fcntl(oldfdlock,F_SETLKW,&flck);
|
| 78 | + }
|
| 79 | +#else
|
| 80 | + fd=1;
|
| 81 | +#endif
|
| 82 | + if(MSK_lockf&dolock)
|
| 83 | +#ifdef F_LOCK
|
| 84 | + oldlockoffset=tell(oldfdlock),fd|=lockf(oldfdlock,F_LOCK,(off_t)0);
|
| 85 | +#else
|
| 86 | + fd=1;
|
| 87 | +#endif
|
| 88 | + if(MSK_flock&dolock)
|
| 89 | +#ifdef LOCK_EX
|
| 90 | + fd|=flock(oldfdlock,LOCK_EX);
|
| 91 | +#else
|
| 92 | + fd=1;
|
| 93 | +#endif
|
| 94 | + return fd;
|
| 95 | +}
|
| 96 | +
|
| 97 | +int sfdlock(int fd)
|
| 98 | +{ int i;unsigned gobble[GOBBLE>>2];
|
| 99 | + for(i=GOBBLE>>2;i;gobble[--i]=~(unsigned)0); /* SunOS crash test */
|
| 100 | + return fdlock(fd);
|
| 101 | +}
|
| 102 | +
|
| 103 | +int fdunlock()
|
| 104 | +{ int i;unsigned gobble[GOBBLE];
|
| 105 | + for(i=GOBBLE;i;gobble[--i]=~(unsigned)0); /* some SunOS libs mess this up */
|
| 106 | + if(MSK_flock&dolock)
|
| 107 | +#ifdef LOCK_EX
|
| 108 | + i|=flock(oldfdlock,LOCK_UN);
|
| 109 | +#else
|
| 110 | + i=1;
|
| 111 | +#endif
|
| 112 | + if(MSK_lockf&dolock)
|
| 113 | +#ifdef F_LOCK
|
| 114 | + { lseek(oldfdlock,oldlockoffset,SEEK_SET);
|
| 115 | + i|=lockf(oldfdlock,F_LOCK,(off_t)2);i|=lockf(oldfdlock,F_ULOCK,(off_t)0);
|
| 116 | + }
|
| 117 | +#else
|
| 118 | + i=1;
|
| 119 | +#endif
|
| 120 | + if(MSK_fcntl&dolock)
|
| 121 | +#ifdef F_SETLKW
|
| 122 | + flck.l_type=F_UNLCK,flck.l_len=0,i|=fcntl(oldfdlock,F_SETLK,&flck);
|
| 123 | +#else
|
| 124 | + i=1;
|
| 125 | +#endif
|
| 126 | + if(!i)
|
| 127 | + for(i=GOBBLE;i&&gobble[--i]==~(unsigned)0;);
|
| 128 | + return i;
|
| 129 | +}
|
| 130 | +
|
| 131 | +int main(argc,argv)int argc;char*argv[];
|
| 132 | { int goodlock,testlock,i,pip[2],pipw[2];time_t otimet;unsigned dtimet;
|
| 133 | static char filename[]="_locktst.l0";
|
| 134 | close(0);goodlock=0;testlock=FIRST_lock;signal(SIGPIPE,SIG_DFL);
|
| 135 | @@ -576,88 +659,6 @@ skip_tests:
|
| 136 | puts("Kernel-locking tests completed.");fprintf(stderr,"\n");
|
| 137 | return EXIT_SUCCESS;
|
| 138 | }
|
| 139 | -
|
| 140 | -int killchildren()
|
| 141 | -{ int i;
|
| 142 | - i=NR_of_forks;
|
| 143 | - do
|
| 144 | - if(child[--i]>0)
|
| 145 | - kill(child[i],SIGTERM),child[i]=0;
|
| 146 | - while(i);
|
| 147 | - return 0;
|
| 148 | -}
|
| 149 | -
|
| 150 | -int sfdlock(fd)
|
| 151 | -{ int i;unsigned gobble[GOBBLE>>2];
|
| 152 | - for(i=GOBBLE>>2;i;gobble[--i]=~(unsigned)0); /* SunOS crash test */
|
| 153 | - return fdlock(fd);
|
| 154 | -}
|
| 155 | -
|
| 156 | -static oldfdlock;
|
| 157 | -#ifdef F_SETLKW
|
| 158 | -static struct flock flck; /* why can't it be a local variable? */
|
| 159 | -#endif
|
| 160 | -#ifdef F_LOCK
|
| 161 | -static off_t oldlockoffset;
|
| 162 | -#endif
|
| 163 | -
|
| 164 | -int fdlock(fd)
|
| 165 | -{ int i;unsigned gobble[GOBBLE>>2];
|
| 166 | - for(i=GOBBLE>>2;i;gobble[--i]=~(unsigned)0); /* SunOS crash test */
|
| 167 | - oldfdlock=fd;fd=0;
|
| 168 | - if(MSK_fcntl&dolock)
|
| 169 | -#ifdef F_SETLKW
|
| 170 | - { static unsigned extra;
|
| 171 | - flck.l_type=F_WRLCK;flck.l_whence=SEEK_SET;flck.l_start=tell(oldfdlock);
|
| 172 | - if(!extra--)
|
| 173 | - extra=MIN_locks/4,flck.l_len=2,i|=fcntl(oldfdlock,F_SETLK,&flck);
|
| 174 | - flck.l_len=0;fd|=fcntl(oldfdlock,F_SETLKW,&flck);
|
| 175 | - }
|
| 176 | -#else
|
| 177 | - fd=1;
|
| 178 | -#endif
|
| 179 | - if(MSK_lockf&dolock)
|
| 180 | -#ifdef F_LOCK
|
| 181 | - oldlockoffset=tell(oldfdlock),fd|=lockf(oldfdlock,F_LOCK,(off_t)0);
|
| 182 | -#else
|
| 183 | - fd=1;
|
| 184 | -#endif
|
| 185 | - if(MSK_flock&dolock)
|
| 186 | -#ifdef LOCK_EX
|
| 187 | - fd|=flock(oldfdlock,LOCK_EX);
|
| 188 | -#else
|
| 189 | - fd=1;
|
| 190 | -#endif
|
| 191 | - return fd;
|
| 192 | -}
|
| 193 | -
|
| 194 | -int fdunlock()
|
| 195 | -{ int i;unsigned gobble[GOBBLE];
|
| 196 | - for(i=GOBBLE;i;gobble[--i]=~(unsigned)0); /* some SunOS libs mess this up */
|
| 197 | - if(MSK_flock&dolock)
|
| 198 | -#ifdef LOCK_EX
|
| 199 | - i|=flock(oldfdlock,LOCK_UN);
|
| 200 | -#else
|
| 201 | - i=1;
|
| 202 | -#endif
|
| 203 | - if(MSK_lockf&dolock)
|
| 204 | -#ifdef F_LOCK
|
| 205 | - { lseek(oldfdlock,oldlockoffset,SEEK_SET);
|
| 206 | - i|=lockf(oldfdlock,F_LOCK,(off_t)2);i|=lockf(oldfdlock,F_ULOCK,(off_t)0);
|
| 207 | - }
|
| 208 | -#else
|
| 209 | - i=1;
|
| 210 | -#endif
|
| 211 | - if(MSK_fcntl&dolock)
|
| 212 | -#ifdef F_SETLKW
|
| 213 | - flck.l_type=F_UNLCK,flck.l_len=0,i|=fcntl(oldfdlock,F_SETLK,&flck);
|
| 214 | -#else
|
| 215 | - i=1;
|
| 216 | -#endif
|
| 217 | - if(!i)
|
| 218 | - for(i=GOBBLE;i&&gobble[--i]==~(unsigned)0;);
|
| 219 | - return i;
|
| 220 | -}
|
| 221 | HERE
|
| 222 |
|
| 223 | if $MAKE _autotst >_autotst.rrr 2>&1
|
| 224 | @@ -1033,6 +1034,10 @@ cat >_autotst.c <<HERE
|
| 225 | #ifndef NO_COMSAT
|
| 226 | #include "network.h"
|
| 227 | #endif
|
| 228 | +#include <string.h>
|
| 229 | +#include <unistd.h>
|
| 230 | +int setrgid();
|
| 231 | +int setresgid();
|
| 232 | int main(){char a[2];
|
| 233 | endpwent();endgrent();memmove(a,"0",1);bcopy("0",a,1);strcspn(a,"0");
|
| 234 | strtol("0",(char**)0,10);strchr("0",'0');strpbrk(a,"0");rename(a,"0");
|
| 235 | @@ -1059,7 +1064,7 @@ echo 'Testing for memmove, strchr, strpbrk, strcspn, strtol, strstr,'
|
| 236 | echo ' rename, setrgid, setegid, pow, opendir, mkdir, waitpid, fsync,'
|
| 237 | echo ' ftruncate, strtod, strncasecmp, strerror, strlcat,'
|
| 238 | echo ' memset, bzero, and _exit'
|
| 239 | -if $MAKE _autotst.$O >$DEVNULL 2>&1
|
| 240 | +if $MAKE _autotst.$O >_autotst.rrr 2>&1
|
| 241 | then
|
| 242 | :
|
| 243 | else
|
| 244 | diff --git a/src/foldinfo.c b/src/foldinfo.c
|
| 245 | index 10fe406..33e7bff 100644
|
| 246 | |
| 247 | |
| 248 | @@ -18,6 +18,7 @@ static /*const*/char rcsid[]=
|
| 249 | #include "goodies.h"
|
| 250 | #include "locking.h"
|
| 251 | #include "foldinfo.h"
|
| 252 | +#include "acommon.h"
|
| 253 |
|
| 254 | static const char
|
| 255 | maildirtmp[]=MAILDIRtmp,maildircur[]=MAILDIRcur;
|
| 256 | diff --git a/src/mailfold.c b/src/mailfold.c
|
| 257 | index 917b502..9e3d386 100644
|
| 258 | |
| 259 | |
| 260 | @@ -371,7 +371,7 @@ void concon(ch)const int ch; /* flip between concatenated and split fields */
|
| 261 | }
|
| 262 | }
|
| 263 |
|
| 264 | -void readmail(rhead,tobesent)const long tobesent;
|
| 265 | +void readmail(rhead,tobesent)const long tobesent; int rhead;
|
| 266 | { char*chp,*pastend;static size_t contlengthoffset;
|
| 267 | ;{ long dfilled;
|
| 268 | if(rhead==2) /* already read, just examine what we have */
|