author | Rich Burridge <rich.burridge@oracle.com> |
Mon, 03 Dec 2012 19:46:10 -0800 | |
changeset 1069 | 415af38929a1 |
parent 1068 | components/procmail/patches/procmail-3.22-truncate.patch@0b7caaf07429 |
permissions | -rw-r--r-- |
1068
0b7caaf07429
15941549 Move procmail from the FOSS consolidation into Userland
Rich Burridge <rich.burridge@oracle.com>
parents:
diff
changeset
|
1 |
--- procmail-3.22/src/mailfold.c.truncate 2007-03-27 13:24:05.000000000 +0200 |
0b7caaf07429
15941549 Move procmail from the FOSS consolidation into Userland
Rich Burridge <rich.burridge@oracle.com>
parents:
diff
changeset
|
2 |
+++ procmail-3.22/src/mailfold.c 2007-03-27 13:25:06.000000000 +0200 |
0b7caaf07429
15941549 Move procmail from the FOSS consolidation into Userland
Rich Burridge <rich.burridge@oracle.com>
parents:
diff
changeset
|
3 |
@@ -30,6 +30,7 @@ |
0b7caaf07429
15941549 Move procmail from the FOSS consolidation into Userland
Rich Burridge <rich.burridge@oracle.com>
parents:
diff
changeset
|
4 |
|
0b7caaf07429
15941549 Move procmail from the FOSS consolidation into Userland
Rich Burridge <rich.burridge@oracle.com>
parents:
diff
changeset
|
5 |
int logopened,rawnonl; |
0b7caaf07429
15941549 Move procmail from the FOSS consolidation into Userland
Rich Burridge <rich.burridge@oracle.com>
parents:
diff
changeset
|
6 |
off_t lasttell; |
0b7caaf07429
15941549 Move procmail from the FOSS consolidation into Userland
Rich Burridge <rich.burridge@oracle.com>
parents:
diff
changeset
|
7 |
+static int trunced; |
0b7caaf07429
15941549 Move procmail from the FOSS consolidation into Userland
Rich Burridge <rich.burridge@oracle.com>
parents:
diff
changeset
|
8 |
static long lastdump; |
0b7caaf07429
15941549 Move procmail from the FOSS consolidation into Userland
Rich Burridge <rich.burridge@oracle.com>
parents:
diff
changeset
|
9 |
static volatile int mailread; /* if the mail is completely read in already */ |
0b7caaf07429
15941549 Move procmail from the FOSS consolidation into Userland
Rich Burridge <rich.burridge@oracle.com>
parents:
diff
changeset
|
10 |
static struct dyna_array confield; /* escapes, concatenations */ |
0b7caaf07429
15941549 Move procmail from the FOSS consolidation into Userland
Rich Burridge <rich.burridge@oracle.com>
parents:
diff
changeset
|
11 |
@@ -81,6 +82,7 @@ |
0b7caaf07429
15941549 Move procmail from the FOSS consolidation into Userland
Rich Burridge <rich.burridge@oracle.com>
parents:
diff
changeset
|
12 |
long len; |
0b7caaf07429
15941549 Move procmail from the FOSS consolidation into Userland
Rich Burridge <rich.burridge@oracle.com>
parents:
diff
changeset
|
13 |
{ int i;long part; |
0b7caaf07429
15941549 Move procmail from the FOSS consolidation into Userland
Rich Burridge <rich.burridge@oracle.com>
parents:
diff
changeset
|
14 |
lasttell=i= -1;SETerrno(EBADF); |
0b7caaf07429
15941549 Move procmail from the FOSS consolidation into Userland
Rich Burridge <rich.burridge@oracle.com>
parents:
diff
changeset
|
15 |
+ trunced=0; |
0b7caaf07429
15941549 Move procmail from the FOSS consolidation into Userland
Rich Burridge <rich.burridge@oracle.com>
parents:
diff
changeset
|
16 |
if(s>=0) |
0b7caaf07429
15941549 Move procmail from the FOSS consolidation into Userland
Rich Burridge <rich.burridge@oracle.com>
parents:
diff
changeset
|
17 |
{ if(ft_lock(type)&&(lseek(s,(off_t)0,SEEK_END),fdlock(s))) |
0b7caaf07429
15941549 Move procmail from the FOSS consolidation into Userland
Rich Burridge <rich.burridge@oracle.com>
parents:
diff
changeset
|
18 |
nlog("Kernel-lock failed\n"); |
0b7caaf07429
15941549 Move procmail from the FOSS consolidation into Userland
Rich Burridge <rich.burridge@oracle.com>
parents:
diff
changeset
|
19 |
@@ -120,13 +122,18 @@ |
0b7caaf07429
15941549 Move procmail from the FOSS consolidation into Userland
Rich Burridge <rich.burridge@oracle.com>
parents:
diff
changeset
|
20 |
} |
0b7caaf07429
15941549 Move procmail from the FOSS consolidation into Userland
Rich Burridge <rich.burridge@oracle.com>
parents:
diff
changeset
|
21 |
writefin: |
0b7caaf07429
15941549 Move procmail from the FOSS consolidation into Userland
Rich Burridge <rich.burridge@oracle.com>
parents:
diff
changeset
|
22 |
i=type!=ft_PIPE&&fsync(s)&&errno!=EINVAL; /* EINVAL => wasn't a file */ |
0b7caaf07429
15941549 Move procmail from the FOSS consolidation into Userland
Rich Burridge <rich.burridge@oracle.com>
parents:
diff
changeset
|
23 |
+ if ((i||len)&&lasttell>=0) |
0b7caaf07429
15941549 Move procmail from the FOSS consolidation into Userland
Rich Burridge <rich.burridge@oracle.com>
parents:
diff
changeset
|
24 |
+ { int serrno=errno; |
0b7caaf07429
15941549 Move procmail from the FOSS consolidation into Userland
Rich Burridge <rich.burridge@oracle.com>
parents:
diff
changeset
|
25 |
+ if(!ftruncate(s,lasttell)) trunced=1; |
0b7caaf07429
15941549 Move procmail from the FOSS consolidation into Userland
Rich Burridge <rich.burridge@oracle.com>
parents:
diff
changeset
|
26 |
+ SETerrno(serrno); |
0b7caaf07429
15941549 Move procmail from the FOSS consolidation into Userland
Rich Burridge <rich.burridge@oracle.com>
parents:
diff
changeset
|
27 |
+ } |
0b7caaf07429
15941549 Move procmail from the FOSS consolidation into Userland
Rich Burridge <rich.burridge@oracle.com>
parents:
diff
changeset
|
28 |
if(ft_lock(type)) |
0b7caaf07429
15941549 Move procmail from the FOSS consolidation into Userland
Rich Burridge <rich.burridge@oracle.com>
parents:
diff
changeset
|
29 |
{ int serrno=errno; /* save any error information */ |
0b7caaf07429
15941549 Move procmail from the FOSS consolidation into Userland
Rich Burridge <rich.burridge@oracle.com>
parents:
diff
changeset
|
30 |
if(fdunlock()) |
0b7caaf07429
15941549 Move procmail from the FOSS consolidation into Userland
Rich Burridge <rich.burridge@oracle.com>
parents:
diff
changeset
|
31 |
nlog("Kernel-unlock failed\n"); |
0b7caaf07429
15941549 Move procmail from the FOSS consolidation into Userland
Rich Burridge <rich.burridge@oracle.com>
parents:
diff
changeset
|
32 |
SETerrno(serrno); |
0b7caaf07429
15941549 Move procmail from the FOSS consolidation into Userland
Rich Burridge <rich.burridge@oracle.com>
parents:
diff
changeset
|
33 |
} |
0b7caaf07429
15941549 Move procmail from the FOSS consolidation into Userland
Rich Burridge <rich.burridge@oracle.com>
parents:
diff
changeset
|
34 |
- i=rclose(s)||i; |
0b7caaf07429
15941549 Move procmail from the FOSS consolidation into Userland
Rich Burridge <rich.burridge@oracle.com>
parents:
diff
changeset
|
35 |
+ i=rclose(s)||i; /* if this fails, we should truncate, but it's too late */ |
0b7caaf07429
15941549 Move procmail from the FOSS consolidation into Userland
Rich Burridge <rich.burridge@oracle.com>
parents:
diff
changeset
|
36 |
} /* return an error even if nothing was to be sent */ |
0b7caaf07429
15941549 Move procmail from the FOSS consolidation into Userland
Rich Burridge <rich.burridge@oracle.com>
parents:
diff
changeset
|
37 |
return i&&!len?-1:len; |
0b7caaf07429
15941549 Move procmail from the FOSS consolidation into Userland
Rich Burridge <rich.burridge@oracle.com>
parents:
diff
changeset
|
38 |
} |
0b7caaf07429
15941549 Move procmail from the FOSS consolidation into Userland
Rich Burridge <rich.burridge@oracle.com>
parents:
diff
changeset
|
39 |
@@ -237,7 +244,7 @@ |
0b7caaf07429
15941549 Move procmail from the FOSS consolidation into Userland
Rich Burridge <rich.burridge@oracle.com>
parents:
diff
changeset
|
40 |
#endif |
0b7caaf07429
15941549 Move procmail from the FOSS consolidation into Userland
Rich Burridge <rich.burridge@oracle.com>
parents:
diff
changeset
|
41 |
default:writeerr(buf); |
0b7caaf07429
15941549 Move procmail from the FOSS consolidation into Userland
Rich Burridge <rich.burridge@oracle.com>
parents:
diff
changeset
|
42 |
} |
0b7caaf07429
15941549 Move procmail from the FOSS consolidation into Userland
Rich Burridge <rich.burridge@oracle.com>
parents:
diff
changeset
|
43 |
- if(lasttell>=0&&!truncate(boxname,lasttell)&&(logopened||verbose)) |
0b7caaf07429
15941549 Move procmail from the FOSS consolidation into Userland
Rich Burridge <rich.burridge@oracle.com>
parents:
diff
changeset
|
44 |
+ if(lasttell>=0&&trunced&&(logopened||verbose)) |
0b7caaf07429
15941549 Move procmail from the FOSS consolidation into Userland
Rich Burridge <rich.burridge@oracle.com>
parents:
diff
changeset
|
45 |
nlog("Truncated file to former size\n"); /* undo garbage */ |
0b7caaf07429
15941549 Move procmail from the FOSS consolidation into Userland
Rich Burridge <rich.burridge@oracle.com>
parents:
diff
changeset
|
46 |
ret0: return 0; |
0b7caaf07429
15941549 Move procmail from the FOSS consolidation into Userland
Rich Burridge <rich.burridge@oracle.com>
parents:
diff
changeset
|
47 |
} |