Commit | Line | Data |
---|---|---|
7d40a65f CE |
1 | --- a/src/transports/appendfile.c |
2 | +++ b/src/transports/appendfile.c | |
df703fd6 CE |
3 | @@ -2580,13 +2580,24 @@ |
4 | /* Why are these here? Put in because they are present in the non-maildir | |
5 | directory case above. */ | |
7d40a65f | 6 | |
df703fd6 CE |
7 | - if(Uchown(filename, uid, gid) || Uchmod(filename, mode)) |
8 | - { | |
9 | - addr->basic_errno = errno; | |
10 | - addr->message = string_sprintf("while setting perms on maildir %s", | |
11 | - filename); | |
12 | - return FALSE; | |
7d40a65f | 13 | - } |
df703fd6 CE |
14 | + /* Ignore failed chown if check_owner is disabled. */ |
15 | + if(Uchown(filename, uid, gid) && ob->check_owner) | |
16 | + { | |
17 | + addr->basic_errno = errno; | |
18 | + addr->message = string_sprintf("while setting owner on maildir %s", | |
19 | + filename); | |
20 | + addr->transport_return = FAIL; | |
21 | + goto RETURN; | |
22 | + } | |
23 | + | |
7d40a65f CE |
24 | + if(Uchmod(filename, mode)) |
25 | + { | |
26 | + addr->basic_errno = errno; | |
df703fd6 | 27 | + addr->message = string_sprintf("while setting chmod on maildir %s", |
7d40a65f CE |
28 | + filename); |
29 | + addr->transport_return = FAIL; | |
30 | + goto RETURN; | |
31 | + } | |
df703fd6 | 32 | } |
7d40a65f | 33 | |
df703fd6 | 34 | #endif /* SUPPORT_MAILDIR */ |
ed7df6ae CE |
35 | @@ -2739,12 +2750,21 @@ |
36 | /* In all cases of writing to a new file, ensure that the file which is | |
37 | going to be renamed has the correct ownership and mode. */ | |
38 | ||
39 | - if(Uchown(filename, uid, gid) || Uchmod(filename, mode)) | |
40 | + /* Ignore failed chown if check_owner is disabled. */ | |
41 | + if(Uchown(filename, uid, gid) && ob->check_owner) | |
42 | { | |
43 | - addr->basic_errno = errno; | |
44 | - addr->message = string_sprintf("while setting perms on file %s", | |
45 | - filename); | |
46 | - return FALSE; | |
47 | + addr->basic_errno = errno; | |
48 | + addr->message = string_sprintf("while setting owner on file before write %s", | |
49 | + filename); | |
50 | + return FALSE; | |
51 | + } | |
52 | + | |
53 | + if(Uchmod(filename, mode)) | |
54 | + { | |
55 | + addr->basic_errno = errno; | |
56 | + addr->message = string_sprintf("while setting chmod on file before write %s", | |
57 | + filename); | |
58 | + return FALSE; | |
59 | } | |
60 | } | |
61 |