Mercurial > dovecot > original-hg > dovecot-1.2
annotate src/master/mail-process.c @ 9352:8bf54859b19b HEAD
master: If process uid/gid is too high, refer to last_valid_* settings instead of first_valid_*.
Based on patch by Pascal Volk.
author | Timo Sirainen <tss@iki.fi> |
---|---|
date | Mon, 31 Aug 2009 19:44:39 -0400 |
parents | 3eacb6bbd227 |
children | eb22a456a625 |
rev | line source |
---|---|
8590
b9faf4db2a9f
Updated copyright notices to include year 2009.
Timo Sirainen <tss@iki.fi>
parents:
8573
diff
changeset
|
1 /* Copyright (c) 2002-2009 Dovecot authors, see the included COPYING file */ |
1055
a72bba3f8a55
Rewrote setting handling. Changed some existing settings also since POP3
Timo Sirainen <tss@iki.fi>
parents:
diff
changeset
|
2 |
a72bba3f8a55
Rewrote setting handling. Changed some existing settings also since POP3
Timo Sirainen <tss@iki.fi>
parents:
diff
changeset
|
3 #include "common.h" |
3470
346a494c2feb
Moved array declaration to array-decl.h and include it in lib.h. So array.h
Timo Sirainen <tss@iki.fi>
parents:
3384
diff
changeset
|
4 #include "array.h" |
5846
21e529b8a701
Initial implementation for mail_max_user_connections setting.
Timo Sirainen <tss@iki.fi>
parents:
5843
diff
changeset
|
5 #include "hash.h" |
1055
a72bba3f8a55
Rewrote setting handling. Changed some existing settings also since POP3
Timo Sirainen <tss@iki.fi>
parents:
diff
changeset
|
6 #include "fd-close-on-exec.h" |
8760
2e563febbc67
If chdir() fails with EACCES in mail process creation, log a user-friendly error.
Timo Sirainen <tss@iki.fi>
parents:
8739
diff
changeset
|
7 #include "eacces-error.h" |
1055
a72bba3f8a55
Rewrote setting handling. Changed some existing settings also since POP3
Timo Sirainen <tss@iki.fi>
parents:
diff
changeset
|
8 #include "env-util.h" |
7927
2351a81ce699
If commands are pipelined after the login command, pass them to the
Timo Sirainen <tss@iki.fi>
parents:
7917
diff
changeset
|
9 #include "base64.h" |
1055
a72bba3f8a55
Rewrote setting handling. Changed some existing settings also since POP3
Timo Sirainen <tss@iki.fi>
parents:
diff
changeset
|
10 #include "str.h" |
a72bba3f8a55
Rewrote setting handling. Changed some existing settings also since POP3
Timo Sirainen <tss@iki.fi>
parents:
diff
changeset
|
11 #include "network.h" |
4190
19fc27f57b0c
Unless nfs_check=no or mmap_disable=yes, check for the first login if the
Timo Sirainen <tss@iki.fi>
parents:
4179
diff
changeset
|
12 #include "mountpoint.h" |
1055
a72bba3f8a55
Rewrote setting handling. Changed some existing settings also since POP3
Timo Sirainen <tss@iki.fi>
parents:
diff
changeset
|
13 #include "restrict-access.h" |
a72bba3f8a55
Rewrote setting handling. Changed some existing settings also since POP3
Timo Sirainen <tss@iki.fi>
parents:
diff
changeset
|
14 #include "restrict-process-size.h" |
5386
bf4a85a47901
Fixed NFS check again with chroots
Timo Sirainen <tss@iki.fi>
parents:
5383
diff
changeset
|
15 #include "home-expand.h" |
1055
a72bba3f8a55
Rewrote setting handling. Changed some existing settings also since POP3
Timo Sirainen <tss@iki.fi>
parents:
diff
changeset
|
16 #include "var-expand.h" |
a72bba3f8a55
Rewrote setting handling. Changed some existing settings also since POP3
Timo Sirainen <tss@iki.fi>
parents:
diff
changeset
|
17 #include "mail-process.h" |
1610
6850142c4e25
New configuration file code. Some syntax changes, but tries to be somewhat
Timo Sirainen <tss@iki.fi>
parents:
1592
diff
changeset
|
18 #include "login-process.h" |
2000
c7c19f5071c3
Write all logging through master process. Fixes problems with log rotation,
Timo Sirainen <tss@iki.fi>
parents:
1959
diff
changeset
|
19 #include "log.h" |
1055
a72bba3f8a55
Rewrote setting handling. Changed some existing settings also since POP3
Timo Sirainen <tss@iki.fi>
parents:
diff
changeset
|
20 |
a72bba3f8a55
Rewrote setting handling. Changed some existing settings also since POP3
Timo Sirainen <tss@iki.fi>
parents:
diff
changeset
|
21 #include <stdlib.h> |
a72bba3f8a55
Rewrote setting handling. Changed some existing settings also since POP3
Timo Sirainen <tss@iki.fi>
parents:
diff
changeset
|
22 #include <unistd.h> |
a72bba3f8a55
Rewrote setting handling. Changed some existing settings also since POP3
Timo Sirainen <tss@iki.fi>
parents:
diff
changeset
|
23 #include <grp.h> |
a72bba3f8a55
Rewrote setting handling. Changed some existing settings also since POP3
Timo Sirainen <tss@iki.fi>
parents:
diff
changeset
|
24 #include <syslog.h> |
a72bba3f8a55
Rewrote setting handling. Changed some existing settings also since POP3
Timo Sirainen <tss@iki.fi>
parents:
diff
changeset
|
25 #include <sys/stat.h> |
9216
23f676bada8c
master: Give better error messages if UNIX uid/gid is too high/low.
Timo Sirainen <tss@iki.fi>
parents:
9144
diff
changeset
|
26 #include <pwd.h> |
23f676bada8c
master: Give better error messages if UNIX uid/gid is too high/low.
Timo Sirainen <tss@iki.fi>
parents:
9144
diff
changeset
|
27 #include <grp.h> |
1055
a72bba3f8a55
Rewrote setting handling. Changed some existing settings also since POP3
Timo Sirainen <tss@iki.fi>
parents:
diff
changeset
|
28 |
3159
852d010a4563
If setpriority() is found, allow userdb set mail processes' priority by
Timo Sirainen <tss@iki.fi>
parents:
3158
diff
changeset
|
29 #ifdef HAVE_SYS_RESOURCE_H |
852d010a4563
If setpriority() is found, allow userdb set mail processes' priority by
Timo Sirainen <tss@iki.fi>
parents:
3158
diff
changeset
|
30 # include <sys/resource.h> |
852d010a4563
If setpriority() is found, allow userdb set mail processes' priority by
Timo Sirainen <tss@iki.fi>
parents:
3158
diff
changeset
|
31 #endif |
852d010a4563
If setpriority() is found, allow userdb set mail processes' priority by
Timo Sirainen <tss@iki.fi>
parents:
3158
diff
changeset
|
32 |
5379
678621b6f1e0
Use alarm() to make sure that chdir() returns in 30 seconds (NFS..). Also if
Timo Sirainen <tss@iki.fi>
parents:
5372
diff
changeset
|
33 /* Timeout chdir() completely after this many seconds */ |
678621b6f1e0
Use alarm() to make sure that chdir() returns in 30 seconds (NFS..). Also if
Timo Sirainen <tss@iki.fi>
parents:
5372
diff
changeset
|
34 #define CHDIR_TIMEOUT 30 |
678621b6f1e0
Use alarm() to make sure that chdir() returns in 30 seconds (NFS..). Also if
Timo Sirainen <tss@iki.fi>
parents:
5372
diff
changeset
|
35 /* Give a warning about chdir() taking a while if it took longer than this |
678621b6f1e0
Use alarm() to make sure that chdir() returns in 30 seconds (NFS..). Also if
Timo Sirainen <tss@iki.fi>
parents:
5372
diff
changeset
|
36 many seconds to finish. */ |
678621b6f1e0
Use alarm() to make sure that chdir() returns in 30 seconds (NFS..). Also if
Timo Sirainen <tss@iki.fi>
parents:
5372
diff
changeset
|
37 #define CHDIR_WARN_SECS 10 |
678621b6f1e0
Use alarm() to make sure that chdir() returns in 30 seconds (NFS..). Also if
Timo Sirainen <tss@iki.fi>
parents:
5372
diff
changeset
|
38 |
5846
21e529b8a701
Initial implementation for mail_max_user_connections setting.
Timo Sirainen <tss@iki.fi>
parents:
5843
diff
changeset
|
39 struct mail_process_group { |
5857
123748453011
Changed mail_max_user_connections to mail_max_userip_connections.
Timo Sirainen <tss@iki.fi>
parents:
5846
diff
changeset
|
40 /* process.type + user + remote_ip identifies this process group */ |
5846
21e529b8a701
Initial implementation for mail_max_user_connections setting.
Timo Sirainen <tss@iki.fi>
parents:
5843
diff
changeset
|
41 struct child_process process; |
21e529b8a701
Initial implementation for mail_max_user_connections setting.
Timo Sirainen <tss@iki.fi>
parents:
5843
diff
changeset
|
42 char *user; |
5857
123748453011
Changed mail_max_user_connections to mail_max_userip_connections.
Timo Sirainen <tss@iki.fi>
parents:
5846
diff
changeset
|
43 struct ip_addr remote_ip; |
5846
21e529b8a701
Initial implementation for mail_max_user_connections setting.
Timo Sirainen <tss@iki.fi>
parents:
5843
diff
changeset
|
44 |
21e529b8a701
Initial implementation for mail_max_user_connections setting.
Timo Sirainen <tss@iki.fi>
parents:
5843
diff
changeset
|
45 /* processes array acts also as refcount */ |
21e529b8a701
Initial implementation for mail_max_user_connections setting.
Timo Sirainen <tss@iki.fi>
parents:
5843
diff
changeset
|
46 ARRAY_DEFINE(processes, pid_t); |
21e529b8a701
Initial implementation for mail_max_user_connections setting.
Timo Sirainen <tss@iki.fi>
parents:
5843
diff
changeset
|
47 }; |
21e529b8a701
Initial implementation for mail_max_user_connections setting.
Timo Sirainen <tss@iki.fi>
parents:
5843
diff
changeset
|
48 |
21e529b8a701
Initial implementation for mail_max_user_connections setting.
Timo Sirainen <tss@iki.fi>
parents:
5843
diff
changeset
|
49 /* type+user -> struct mail_process_group */ |
21e529b8a701
Initial implementation for mail_max_user_connections setting.
Timo Sirainen <tss@iki.fi>
parents:
5843
diff
changeset
|
50 static struct hash_table *mail_process_groups; |
21e529b8a701
Initial implementation for mail_max_user_connections setting.
Timo Sirainen <tss@iki.fi>
parents:
5843
diff
changeset
|
51 static unsigned int mail_process_count = 0; |
21e529b8a701
Initial implementation for mail_max_user_connections setting.
Timo Sirainen <tss@iki.fi>
parents:
5843
diff
changeset
|
52 |
21e529b8a701
Initial implementation for mail_max_user_connections setting.
Timo Sirainen <tss@iki.fi>
parents:
5843
diff
changeset
|
53 static unsigned int mail_process_group_hash(const void *p) |
21e529b8a701
Initial implementation for mail_max_user_connections setting.
Timo Sirainen <tss@iki.fi>
parents:
5843
diff
changeset
|
54 { |
21e529b8a701
Initial implementation for mail_max_user_connections setting.
Timo Sirainen <tss@iki.fi>
parents:
5843
diff
changeset
|
55 const struct mail_process_group *group = p; |
21e529b8a701
Initial implementation for mail_max_user_connections setting.
Timo Sirainen <tss@iki.fi>
parents:
5843
diff
changeset
|
56 |
5857
123748453011
Changed mail_max_user_connections to mail_max_userip_connections.
Timo Sirainen <tss@iki.fi>
parents:
5846
diff
changeset
|
57 return str_hash(group->user) ^ group->process.type ^ |
123748453011
Changed mail_max_user_connections to mail_max_userip_connections.
Timo Sirainen <tss@iki.fi>
parents:
5846
diff
changeset
|
58 net_ip_hash(&group->remote_ip); |
5846
21e529b8a701
Initial implementation for mail_max_user_connections setting.
Timo Sirainen <tss@iki.fi>
parents:
5843
diff
changeset
|
59 } |
21e529b8a701
Initial implementation for mail_max_user_connections setting.
Timo Sirainen <tss@iki.fi>
parents:
5843
diff
changeset
|
60 |
21e529b8a701
Initial implementation for mail_max_user_connections setting.
Timo Sirainen <tss@iki.fi>
parents:
5843
diff
changeset
|
61 static int mail_process_group_cmp(const void *p1, const void *p2) |
21e529b8a701
Initial implementation for mail_max_user_connections setting.
Timo Sirainen <tss@iki.fi>
parents:
5843
diff
changeset
|
62 { |
21e529b8a701
Initial implementation for mail_max_user_connections setting.
Timo Sirainen <tss@iki.fi>
parents:
5843
diff
changeset
|
63 const struct mail_process_group *group1 = p1, *group2 = p2; |
21e529b8a701
Initial implementation for mail_max_user_connections setting.
Timo Sirainen <tss@iki.fi>
parents:
5843
diff
changeset
|
64 int ret; |
21e529b8a701
Initial implementation for mail_max_user_connections setting.
Timo Sirainen <tss@iki.fi>
parents:
5843
diff
changeset
|
65 |
21e529b8a701
Initial implementation for mail_max_user_connections setting.
Timo Sirainen <tss@iki.fi>
parents:
5843
diff
changeset
|
66 ret = strcmp(group1->user, group2->user); |
21e529b8a701
Initial implementation for mail_max_user_connections setting.
Timo Sirainen <tss@iki.fi>
parents:
5843
diff
changeset
|
67 if (ret == 0) |
21e529b8a701
Initial implementation for mail_max_user_connections setting.
Timo Sirainen <tss@iki.fi>
parents:
5843
diff
changeset
|
68 ret = group1->process.type - group2->process.type; |
5857
123748453011
Changed mail_max_user_connections to mail_max_userip_connections.
Timo Sirainen <tss@iki.fi>
parents:
5846
diff
changeset
|
69 if (ret == 0 && !net_ip_compare(&group1->remote_ip, &group2->remote_ip)) |
123748453011
Changed mail_max_user_connections to mail_max_userip_connections.
Timo Sirainen <tss@iki.fi>
parents:
5846
diff
changeset
|
70 ret = -1; |
5846
21e529b8a701
Initial implementation for mail_max_user_connections setting.
Timo Sirainen <tss@iki.fi>
parents:
5843
diff
changeset
|
71 return ret; |
21e529b8a701
Initial implementation for mail_max_user_connections setting.
Timo Sirainen <tss@iki.fi>
parents:
5843
diff
changeset
|
72 } |
5843
f655c4d4a419
Moved child process handling to child-process.[ch]. The hash table now uses
Timo Sirainen <tss@iki.fi>
parents:
5800
diff
changeset
|
73 |
5846
21e529b8a701
Initial implementation for mail_max_user_connections setting.
Timo Sirainen <tss@iki.fi>
parents:
5843
diff
changeset
|
74 static struct mail_process_group * |
5857
123748453011
Changed mail_max_user_connections to mail_max_userip_connections.
Timo Sirainen <tss@iki.fi>
parents:
5846
diff
changeset
|
75 mail_process_group_lookup(enum process_type type, const char *user, |
123748453011
Changed mail_max_user_connections to mail_max_userip_connections.
Timo Sirainen <tss@iki.fi>
parents:
5846
diff
changeset
|
76 const struct ip_addr *ip) |
5846
21e529b8a701
Initial implementation for mail_max_user_connections setting.
Timo Sirainen <tss@iki.fi>
parents:
5843
diff
changeset
|
77 { |
21e529b8a701
Initial implementation for mail_max_user_connections setting.
Timo Sirainen <tss@iki.fi>
parents:
5843
diff
changeset
|
78 struct mail_process_group lookup_group; |
21e529b8a701
Initial implementation for mail_max_user_connections setting.
Timo Sirainen <tss@iki.fi>
parents:
5843
diff
changeset
|
79 |
21e529b8a701
Initial implementation for mail_max_user_connections setting.
Timo Sirainen <tss@iki.fi>
parents:
5843
diff
changeset
|
80 lookup_group.process.type = type; |
21e529b8a701
Initial implementation for mail_max_user_connections setting.
Timo Sirainen <tss@iki.fi>
parents:
5843
diff
changeset
|
81 lookup_group.user = t_strdup_noconst(user); |
5857
123748453011
Changed mail_max_user_connections to mail_max_userip_connections.
Timo Sirainen <tss@iki.fi>
parents:
5846
diff
changeset
|
82 lookup_group.remote_ip = *ip; |
5846
21e529b8a701
Initial implementation for mail_max_user_connections setting.
Timo Sirainen <tss@iki.fi>
parents:
5843
diff
changeset
|
83 |
8573
f9166a09423a
Renamed hash_*() to hash_table_*() to avoid conflicts with OSX's strhash.h
Timo Sirainen <tss@iki.fi>
parents:
8544
diff
changeset
|
84 return hash_table_lookup(mail_process_groups, &lookup_group); |
5846
21e529b8a701
Initial implementation for mail_max_user_connections setting.
Timo Sirainen <tss@iki.fi>
parents:
5843
diff
changeset
|
85 } |
21e529b8a701
Initial implementation for mail_max_user_connections setting.
Timo Sirainen <tss@iki.fi>
parents:
5843
diff
changeset
|
86 |
21e529b8a701
Initial implementation for mail_max_user_connections setting.
Timo Sirainen <tss@iki.fi>
parents:
5843
diff
changeset
|
87 static struct mail_process_group * |
5857
123748453011
Changed mail_max_user_connections to mail_max_userip_connections.
Timo Sirainen <tss@iki.fi>
parents:
5846
diff
changeset
|
88 mail_process_group_create(enum process_type type, const char *user, |
123748453011
Changed mail_max_user_connections to mail_max_userip_connections.
Timo Sirainen <tss@iki.fi>
parents:
5846
diff
changeset
|
89 const struct ip_addr *ip) |
5846
21e529b8a701
Initial implementation for mail_max_user_connections setting.
Timo Sirainen <tss@iki.fi>
parents:
5843
diff
changeset
|
90 { |
21e529b8a701
Initial implementation for mail_max_user_connections setting.
Timo Sirainen <tss@iki.fi>
parents:
5843
diff
changeset
|
91 struct mail_process_group *group; |
21e529b8a701
Initial implementation for mail_max_user_connections setting.
Timo Sirainen <tss@iki.fi>
parents:
5843
diff
changeset
|
92 |
21e529b8a701
Initial implementation for mail_max_user_connections setting.
Timo Sirainen <tss@iki.fi>
parents:
5843
diff
changeset
|
93 group = i_new(struct mail_process_group, 1); |
21e529b8a701
Initial implementation for mail_max_user_connections setting.
Timo Sirainen <tss@iki.fi>
parents:
5843
diff
changeset
|
94 group->process.type = type; |
21e529b8a701
Initial implementation for mail_max_user_connections setting.
Timo Sirainen <tss@iki.fi>
parents:
5843
diff
changeset
|
95 group->user = i_strdup(user); |
5857
123748453011
Changed mail_max_user_connections to mail_max_userip_connections.
Timo Sirainen <tss@iki.fi>
parents:
5846
diff
changeset
|
96 group->remote_ip = *ip; |
5846
21e529b8a701
Initial implementation for mail_max_user_connections setting.
Timo Sirainen <tss@iki.fi>
parents:
5843
diff
changeset
|
97 |
21e529b8a701
Initial implementation for mail_max_user_connections setting.
Timo Sirainen <tss@iki.fi>
parents:
5843
diff
changeset
|
98 i_array_init(&group->processes, 10); |
8573
f9166a09423a
Renamed hash_*() to hash_table_*() to avoid conflicts with OSX's strhash.h
Timo Sirainen <tss@iki.fi>
parents:
8544
diff
changeset
|
99 hash_table_insert(mail_process_groups, group, group); |
5846
21e529b8a701
Initial implementation for mail_max_user_connections setting.
Timo Sirainen <tss@iki.fi>
parents:
5843
diff
changeset
|
100 return group; |
21e529b8a701
Initial implementation for mail_max_user_connections setting.
Timo Sirainen <tss@iki.fi>
parents:
5843
diff
changeset
|
101 } |
21e529b8a701
Initial implementation for mail_max_user_connections setting.
Timo Sirainen <tss@iki.fi>
parents:
5843
diff
changeset
|
102 |
21e529b8a701
Initial implementation for mail_max_user_connections setting.
Timo Sirainen <tss@iki.fi>
parents:
5843
diff
changeset
|
103 static void |
21e529b8a701
Initial implementation for mail_max_user_connections setting.
Timo Sirainen <tss@iki.fi>
parents:
5843
diff
changeset
|
104 mail_process_group_add(struct mail_process_group *group, pid_t pid) |
21e529b8a701
Initial implementation for mail_max_user_connections setting.
Timo Sirainen <tss@iki.fi>
parents:
5843
diff
changeset
|
105 { |
21e529b8a701
Initial implementation for mail_max_user_connections setting.
Timo Sirainen <tss@iki.fi>
parents:
5843
diff
changeset
|
106 mail_process_count++; |
21e529b8a701
Initial implementation for mail_max_user_connections setting.
Timo Sirainen <tss@iki.fi>
parents:
5843
diff
changeset
|
107 array_append(&group->processes, &pid, 1); |
21e529b8a701
Initial implementation for mail_max_user_connections setting.
Timo Sirainen <tss@iki.fi>
parents:
5843
diff
changeset
|
108 child_process_add(pid, &group->process); |
21e529b8a701
Initial implementation for mail_max_user_connections setting.
Timo Sirainen <tss@iki.fi>
parents:
5843
diff
changeset
|
109 } |
21e529b8a701
Initial implementation for mail_max_user_connections setting.
Timo Sirainen <tss@iki.fi>
parents:
5843
diff
changeset
|
110 |
21e529b8a701
Initial implementation for mail_max_user_connections setting.
Timo Sirainen <tss@iki.fi>
parents:
5843
diff
changeset
|
111 static void mail_process_group_free(struct mail_process_group *group) |
21e529b8a701
Initial implementation for mail_max_user_connections setting.
Timo Sirainen <tss@iki.fi>
parents:
5843
diff
changeset
|
112 { |
21e529b8a701
Initial implementation for mail_max_user_connections setting.
Timo Sirainen <tss@iki.fi>
parents:
5843
diff
changeset
|
113 array_free(&group->processes); |
21e529b8a701
Initial implementation for mail_max_user_connections setting.
Timo Sirainen <tss@iki.fi>
parents:
5843
diff
changeset
|
114 i_free(group->user); |
21e529b8a701
Initial implementation for mail_max_user_connections setting.
Timo Sirainen <tss@iki.fi>
parents:
5843
diff
changeset
|
115 i_free(group); |
21e529b8a701
Initial implementation for mail_max_user_connections setting.
Timo Sirainen <tss@iki.fi>
parents:
5843
diff
changeset
|
116 } |
1055
a72bba3f8a55
Rewrote setting handling. Changed some existing settings also since POP3
Timo Sirainen <tss@iki.fi>
parents:
diff
changeset
|
117 |
3863
55df57c028d4
Added "bool" type and changed all ints that were used as booleans to bool.
Timo Sirainen <tss@iki.fi>
parents:
3690
diff
changeset
|
118 static bool validate_uid_gid(struct settings *set, uid_t uid, gid_t gid, |
55df57c028d4
Added "bool" type and changed all ints that were used as booleans to bool.
Timo Sirainen <tss@iki.fi>
parents:
3690
diff
changeset
|
119 const char *user) |
1055
a72bba3f8a55
Rewrote setting handling. Changed some existing settings also since POP3
Timo Sirainen <tss@iki.fi>
parents:
diff
changeset
|
120 { |
a72bba3f8a55
Rewrote setting handling. Changed some existing settings also since POP3
Timo Sirainen <tss@iki.fi>
parents:
diff
changeset
|
121 if (uid == 0) { |
9216
23f676bada8c
master: Give better error messages if UNIX uid/gid is too high/low.
Timo Sirainen <tss@iki.fi>
parents:
9144
diff
changeset
|
122 i_error("User %s not allowed to log in using UNIX UID 0 " |
23f676bada8c
master: Give better error messages if UNIX uid/gid is too high/low.
Timo Sirainen <tss@iki.fi>
parents:
9144
diff
changeset
|
123 "(root logins are never allowed)", user); |
1055
a72bba3f8a55
Rewrote setting handling. Changed some existing settings also since POP3
Timo Sirainen <tss@iki.fi>
parents:
diff
changeset
|
124 return FALSE; |
a72bba3f8a55
Rewrote setting handling. Changed some existing settings also since POP3
Timo Sirainen <tss@iki.fi>
parents:
diff
changeset
|
125 } |
a72bba3f8a55
Rewrote setting handling. Changed some existing settings also since POP3
Timo Sirainen <tss@iki.fi>
parents:
diff
changeset
|
126 |
1617
cc3cef25662c
Replaced geteuid() calls with one in the beginning and saving it to
Timo Sirainen <tss@iki.fi>
parents:
1616
diff
changeset
|
127 if (set->login_uid == uid && master_uid != uid) { |
9216
23f676bada8c
master: Give better error messages if UNIX uid/gid is too high/low.
Timo Sirainen <tss@iki.fi>
parents:
9144
diff
changeset
|
128 struct passwd *pw; |
23f676bada8c
master: Give better error messages if UNIX uid/gid is too high/low.
Timo Sirainen <tss@iki.fi>
parents:
9144
diff
changeset
|
129 |
23f676bada8c
master: Give better error messages if UNIX uid/gid is too high/low.
Timo Sirainen <tss@iki.fi>
parents:
9144
diff
changeset
|
130 pw = getpwuid(uid); |
23f676bada8c
master: Give better error messages if UNIX uid/gid is too high/low.
Timo Sirainen <tss@iki.fi>
parents:
9144
diff
changeset
|
131 i_error("User %s not allowed to log in using login_user's " |
23f676bada8c
master: Give better error messages if UNIX uid/gid is too high/low.
Timo Sirainen <tss@iki.fi>
parents:
9144
diff
changeset
|
132 "UNIX UID %s%s (see http://wiki.dovecot.org/UserIds)", |
23f676bada8c
master: Give better error messages if UNIX uid/gid is too high/low.
Timo Sirainen <tss@iki.fi>
parents:
9144
diff
changeset
|
133 user, dec2str(uid), pw == NULL ? "" : |
23f676bada8c
master: Give better error messages if UNIX uid/gid is too high/low.
Timo Sirainen <tss@iki.fi>
parents:
9144
diff
changeset
|
134 t_strdup_printf("(%s)", pw->pw_name)); |
6137
327688eb425a
If login_user == mail uid, we logged an error but didn't really prevent it.
Timo Sirainen <tss@iki.fi>
parents:
5977
diff
changeset
|
135 return FALSE; |
1610
6850142c4e25
New configuration file code. Some syntax changes, but tries to be somewhat
Timo Sirainen <tss@iki.fi>
parents:
1592
diff
changeset
|
136 } |
6850142c4e25
New configuration file code. Some syntax changes, but tries to be somewhat
Timo Sirainen <tss@iki.fi>
parents:
1592
diff
changeset
|
137 |
1055
a72bba3f8a55
Rewrote setting handling. Changed some existing settings also since POP3
Timo Sirainen <tss@iki.fi>
parents:
diff
changeset
|
138 if (uid < (uid_t)set->first_valid_uid || |
a72bba3f8a55
Rewrote setting handling. Changed some existing settings also since POP3
Timo Sirainen <tss@iki.fi>
parents:
diff
changeset
|
139 (set->last_valid_uid != 0 && uid > (uid_t)set->last_valid_uid)) { |
9216
23f676bada8c
master: Give better error messages if UNIX uid/gid is too high/low.
Timo Sirainen <tss@iki.fi>
parents:
9144
diff
changeset
|
140 struct passwd *pw; |
9352
8bf54859b19b
master: If process uid/gid is too high, refer to last_valid_* settings instead of first_valid_*.
Timo Sirainen <tss@iki.fi>
parents:
9348
diff
changeset
|
141 bool low = uid < (uid_t)set->first_valid_uid; |
9216
23f676bada8c
master: Give better error messages if UNIX uid/gid is too high/low.
Timo Sirainen <tss@iki.fi>
parents:
9144
diff
changeset
|
142 |
23f676bada8c
master: Give better error messages if UNIX uid/gid is too high/low.
Timo Sirainen <tss@iki.fi>
parents:
9144
diff
changeset
|
143 pw = getpwuid(uid); |
23f676bada8c
master: Give better error messages if UNIX uid/gid is too high/low.
Timo Sirainen <tss@iki.fi>
parents:
9144
diff
changeset
|
144 i_error("User %s not allowed to log in using too %s " |
9352
8bf54859b19b
master: If process uid/gid is too high, refer to last_valid_* settings instead of first_valid_*.
Timo Sirainen <tss@iki.fi>
parents:
9348
diff
changeset
|
145 "UNIX UID %s%s (see %s in config file)", |
8bf54859b19b
master: If process uid/gid is too high, refer to last_valid_* settings instead of first_valid_*.
Timo Sirainen <tss@iki.fi>
parents:
9348
diff
changeset
|
146 user, low ? "low" : "high", |
9216
23f676bada8c
master: Give better error messages if UNIX uid/gid is too high/low.
Timo Sirainen <tss@iki.fi>
parents:
9144
diff
changeset
|
147 dec2str(uid), pw == NULL ? "" : |
9352
8bf54859b19b
master: If process uid/gid is too high, refer to last_valid_* settings instead of first_valid_*.
Timo Sirainen <tss@iki.fi>
parents:
9348
diff
changeset
|
148 t_strdup_printf("(%s)", pw->pw_name), |
8bf54859b19b
master: If process uid/gid is too high, refer to last_valid_* settings instead of first_valid_*.
Timo Sirainen <tss@iki.fi>
parents:
9348
diff
changeset
|
149 low ? "first_valid_uid" : "last_valid_uid"); |
1055
a72bba3f8a55
Rewrote setting handling. Changed some existing settings also since POP3
Timo Sirainen <tss@iki.fi>
parents:
diff
changeset
|
150 return FALSE; |
a72bba3f8a55
Rewrote setting handling. Changed some existing settings also since POP3
Timo Sirainen <tss@iki.fi>
parents:
diff
changeset
|
151 } |
a72bba3f8a55
Rewrote setting handling. Changed some existing settings also since POP3
Timo Sirainen <tss@iki.fi>
parents:
diff
changeset
|
152 |
a72bba3f8a55
Rewrote setting handling. Changed some existing settings also since POP3
Timo Sirainen <tss@iki.fi>
parents:
diff
changeset
|
153 if (gid < (gid_t)set->first_valid_gid || |
a72bba3f8a55
Rewrote setting handling. Changed some existing settings also since POP3
Timo Sirainen <tss@iki.fi>
parents:
diff
changeset
|
154 (set->last_valid_gid != 0 && gid > (gid_t)set->last_valid_gid)) { |
9216
23f676bada8c
master: Give better error messages if UNIX uid/gid is too high/low.
Timo Sirainen <tss@iki.fi>
parents:
9144
diff
changeset
|
155 struct group *gr; |
9352
8bf54859b19b
master: If process uid/gid is too high, refer to last_valid_* settings instead of first_valid_*.
Timo Sirainen <tss@iki.fi>
parents:
9348
diff
changeset
|
156 bool low = gid < (gid_t)set->first_valid_gid; |
9216
23f676bada8c
master: Give better error messages if UNIX uid/gid is too high/low.
Timo Sirainen <tss@iki.fi>
parents:
9144
diff
changeset
|
157 |
23f676bada8c
master: Give better error messages if UNIX uid/gid is too high/low.
Timo Sirainen <tss@iki.fi>
parents:
9144
diff
changeset
|
158 gr = getgrgid(gid); |
23f676bada8c
master: Give better error messages if UNIX uid/gid is too high/low.
Timo Sirainen <tss@iki.fi>
parents:
9144
diff
changeset
|
159 i_error("User %s not allowed to log in using too %s primary " |
9352
8bf54859b19b
master: If process uid/gid is too high, refer to last_valid_* settings instead of first_valid_*.
Timo Sirainen <tss@iki.fi>
parents:
9348
diff
changeset
|
160 "UNIX group ID %s%s (see %s in config file)", |
8bf54859b19b
master: If process uid/gid is too high, refer to last_valid_* settings instead of first_valid_*.
Timo Sirainen <tss@iki.fi>
parents:
9348
diff
changeset
|
161 user, low ? "low" : "high", |
9216
23f676bada8c
master: Give better error messages if UNIX uid/gid is too high/low.
Timo Sirainen <tss@iki.fi>
parents:
9144
diff
changeset
|
162 dec2str(gid), gr == NULL ? "" : |
9352
8bf54859b19b
master: If process uid/gid is too high, refer to last_valid_* settings instead of first_valid_*.
Timo Sirainen <tss@iki.fi>
parents:
9348
diff
changeset
|
163 t_strdup_printf("(%s)", gr->gr_name), |
8bf54859b19b
master: If process uid/gid is too high, refer to last_valid_* settings instead of first_valid_*.
Timo Sirainen <tss@iki.fi>
parents:
9348
diff
changeset
|
164 low ? "first_valid_gid" : "last_valid_gid"); |
1055
a72bba3f8a55
Rewrote setting handling. Changed some existing settings also since POP3
Timo Sirainen <tss@iki.fi>
parents:
diff
changeset
|
165 return FALSE; |
a72bba3f8a55
Rewrote setting handling. Changed some existing settings also since POP3
Timo Sirainen <tss@iki.fi>
parents:
diff
changeset
|
166 } |
a72bba3f8a55
Rewrote setting handling. Changed some existing settings also since POP3
Timo Sirainen <tss@iki.fi>
parents:
diff
changeset
|
167 |
a72bba3f8a55
Rewrote setting handling. Changed some existing settings also since POP3
Timo Sirainen <tss@iki.fi>
parents:
diff
changeset
|
168 return TRUE; |
a72bba3f8a55
Rewrote setting handling. Changed some existing settings also since POP3
Timo Sirainen <tss@iki.fi>
parents:
diff
changeset
|
169 } |
a72bba3f8a55
Rewrote setting handling. Changed some existing settings also since POP3
Timo Sirainen <tss@iki.fi>
parents:
diff
changeset
|
170 |
3863
55df57c028d4
Added "bool" type and changed all ints that were used as booleans to bool.
Timo Sirainen <tss@iki.fi>
parents:
3690
diff
changeset
|
171 static bool validate_chroot(struct settings *set, const char *dir) |
1055
a72bba3f8a55
Rewrote setting handling. Changed some existing settings also since POP3
Timo Sirainen <tss@iki.fi>
parents:
diff
changeset
|
172 { |
a72bba3f8a55
Rewrote setting handling. Changed some existing settings also since POP3
Timo Sirainen <tss@iki.fi>
parents:
diff
changeset
|
173 const char *const *chroot_dirs; |
a72bba3f8a55
Rewrote setting handling. Changed some existing settings also since POP3
Timo Sirainen <tss@iki.fi>
parents:
diff
changeset
|
174 |
a72bba3f8a55
Rewrote setting handling. Changed some existing settings also since POP3
Timo Sirainen <tss@iki.fi>
parents:
diff
changeset
|
175 if (*dir == '\0') |
a72bba3f8a55
Rewrote setting handling. Changed some existing settings also since POP3
Timo Sirainen <tss@iki.fi>
parents:
diff
changeset
|
176 return FALSE; |
a72bba3f8a55
Rewrote setting handling. Changed some existing settings also since POP3
Timo Sirainen <tss@iki.fi>
parents:
diff
changeset
|
177 |
4388
af61031c746f
Settings parser nowadays returns "" instead of NULL when it reads an empty
Timo Sirainen <tss@iki.fi>
parents:
4334
diff
changeset
|
178 if (*set->valid_chroot_dirs == '\0') |
1055
a72bba3f8a55
Rewrote setting handling. Changed some existing settings also since POP3
Timo Sirainen <tss@iki.fi>
parents:
diff
changeset
|
179 return FALSE; |
a72bba3f8a55
Rewrote setting handling. Changed some existing settings also since POP3
Timo Sirainen <tss@iki.fi>
parents:
diff
changeset
|
180 |
a72bba3f8a55
Rewrote setting handling. Changed some existing settings also since POP3
Timo Sirainen <tss@iki.fi>
parents:
diff
changeset
|
181 chroot_dirs = t_strsplit(set->valid_chroot_dirs, ":"); |
a72bba3f8a55
Rewrote setting handling. Changed some existing settings also since POP3
Timo Sirainen <tss@iki.fi>
parents:
diff
changeset
|
182 while (*chroot_dirs != NULL) { |
a72bba3f8a55
Rewrote setting handling. Changed some existing settings also since POP3
Timo Sirainen <tss@iki.fi>
parents:
diff
changeset
|
183 if (**chroot_dirs != '\0' && |
a72bba3f8a55
Rewrote setting handling. Changed some existing settings also since POP3
Timo Sirainen <tss@iki.fi>
parents:
diff
changeset
|
184 strncmp(dir, *chroot_dirs, strlen(*chroot_dirs)) == 0) |
a72bba3f8a55
Rewrote setting handling. Changed some existing settings also since POP3
Timo Sirainen <tss@iki.fi>
parents:
diff
changeset
|
185 return TRUE; |
a72bba3f8a55
Rewrote setting handling. Changed some existing settings also since POP3
Timo Sirainen <tss@iki.fi>
parents:
diff
changeset
|
186 chroot_dirs++; |
a72bba3f8a55
Rewrote setting handling. Changed some existing settings also since POP3
Timo Sirainen <tss@iki.fi>
parents:
diff
changeset
|
187 } |
a72bba3f8a55
Rewrote setting handling. Changed some existing settings also since POP3
Timo Sirainen <tss@iki.fi>
parents:
diff
changeset
|
188 |
a72bba3f8a55
Rewrote setting handling. Changed some existing settings also since POP3
Timo Sirainen <tss@iki.fi>
parents:
diff
changeset
|
189 return FALSE; |
a72bba3f8a55
Rewrote setting handling. Changed some existing settings also since POP3
Timo Sirainen <tss@iki.fi>
parents:
diff
changeset
|
190 } |
a72bba3f8a55
Rewrote setting handling. Changed some existing settings also since POP3
Timo Sirainen <tss@iki.fi>
parents:
diff
changeset
|
191 |
2057
5e0167577399
Fixed var_expand() to take a table of variables rather than a few predefined
Timo Sirainen <tss@iki.fi>
parents:
2046
diff
changeset
|
192 static const struct var_expand_table * |
2311
4558d1b196fd
Added --exec-mail option to master. It can be used to parse Dovecot config
Timo Sirainen <tss@iki.fi>
parents:
2291
diff
changeset
|
193 get_var_expand_table(const char *protocol, |
2097
4e77cb0aff21
Added %l, %r and %P variables and mail_log_prefix setting.
Timo Sirainen <tss@iki.fi>
parents:
2079
diff
changeset
|
194 const char *user, const char *home, |
3690 | 195 const char *local_ip, const char *remote_ip, |
196 pid_t pid, uid_t uid) | |
2057
5e0167577399
Fixed var_expand() to take a table of variables rather than a few predefined
Timo Sirainen <tss@iki.fi>
parents:
2046
diff
changeset
|
197 { |
8325
74720db3bef7
Give a nicer error message if %h is used while there is no home directory.
Timo Sirainen <tss@iki.fi>
parents:
8242
diff
changeset
|
198 #define VAR_EXPAND_HOME_IDX 4 |
2057
5e0167577399
Fixed var_expand() to take a table of variables rather than a few predefined
Timo Sirainen <tss@iki.fi>
parents:
2046
diff
changeset
|
199 static struct var_expand_table static_tab[] = { |
8544
983d38de06c9
var_expand(): Added support for long %{variable} names.
Timo Sirainen <tss@iki.fi>
parents:
8520
diff
changeset
|
200 { 'u', NULL, "user" }, |
983d38de06c9
var_expand(): Added support for long %{variable} names.
Timo Sirainen <tss@iki.fi>
parents:
8520
diff
changeset
|
201 { 'n', NULL, "username" }, |
983d38de06c9
var_expand(): Added support for long %{variable} names.
Timo Sirainen <tss@iki.fi>
parents:
8520
diff
changeset
|
202 { 'd', NULL, "domain" }, |
983d38de06c9
var_expand(): Added support for long %{variable} names.
Timo Sirainen <tss@iki.fi>
parents:
8520
diff
changeset
|
203 { 's', NULL, "service" }, |
983d38de06c9
var_expand(): Added support for long %{variable} names.
Timo Sirainen <tss@iki.fi>
parents:
8520
diff
changeset
|
204 { 'h', NULL, "home" }, |
983d38de06c9
var_expand(): Added support for long %{variable} names.
Timo Sirainen <tss@iki.fi>
parents:
8520
diff
changeset
|
205 { 'l', NULL, "lip" }, |
983d38de06c9
var_expand(): Added support for long %{variable} names.
Timo Sirainen <tss@iki.fi>
parents:
8520
diff
changeset
|
206 { 'r', NULL, "rip" }, |
983d38de06c9
var_expand(): Added support for long %{variable} names.
Timo Sirainen <tss@iki.fi>
parents:
8520
diff
changeset
|
207 { 'p', NULL, "pid" }, |
983d38de06c9
var_expand(): Added support for long %{variable} names.
Timo Sirainen <tss@iki.fi>
parents:
8520
diff
changeset
|
208 { 'i', NULL, "uid" }, |
983d38de06c9
var_expand(): Added support for long %{variable} names.
Timo Sirainen <tss@iki.fi>
parents:
8520
diff
changeset
|
209 { '\0', NULL, NULL } |
2057
5e0167577399
Fixed var_expand() to take a table of variables rather than a few predefined
Timo Sirainen <tss@iki.fi>
parents:
2046
diff
changeset
|
210 }; |
5e0167577399
Fixed var_expand() to take a table of variables rather than a few predefined
Timo Sirainen <tss@iki.fi>
parents:
2046
diff
changeset
|
211 struct var_expand_table *tab; |
5e0167577399
Fixed var_expand() to take a table of variables rather than a few predefined
Timo Sirainen <tss@iki.fi>
parents:
2046
diff
changeset
|
212 |
5e0167577399
Fixed var_expand() to take a table of variables rather than a few predefined
Timo Sirainen <tss@iki.fi>
parents:
2046
diff
changeset
|
213 tab = t_malloc(sizeof(static_tab)); |
5e0167577399
Fixed var_expand() to take a table of variables rather than a few predefined
Timo Sirainen <tss@iki.fi>
parents:
2046
diff
changeset
|
214 memcpy(tab, static_tab, sizeof(static_tab)); |
5e0167577399
Fixed var_expand() to take a table of variables rather than a few predefined
Timo Sirainen <tss@iki.fi>
parents:
2046
diff
changeset
|
215 |
5e0167577399
Fixed var_expand() to take a table of variables rather than a few predefined
Timo Sirainen <tss@iki.fi>
parents:
2046
diff
changeset
|
216 tab[0].value = user; |
3896
7aea43511bac
Don't crash if username is NULL (shouldn't happen though)
Timo Sirainen <tss@iki.fi>
parents:
3863
diff
changeset
|
217 tab[1].value = user == NULL ? NULL : t_strcut(user, '@'); |
7aea43511bac
Don't crash if username is NULL (shouldn't happen though)
Timo Sirainen <tss@iki.fi>
parents:
3863
diff
changeset
|
218 tab[2].value = user == NULL ? NULL : strchr(user, '@'); |
2057
5e0167577399
Fixed var_expand() to take a table of variables rather than a few predefined
Timo Sirainen <tss@iki.fi>
parents:
2046
diff
changeset
|
219 if (tab[2].value != NULL) tab[2].value++; |
2311
4558d1b196fd
Added --exec-mail option to master. It can be used to parse Dovecot config
Timo Sirainen <tss@iki.fi>
parents:
2291
diff
changeset
|
220 tab[3].value = t_str_ucase(protocol); |
8325
74720db3bef7
Give a nicer error message if %h is used while there is no home directory.
Timo Sirainen <tss@iki.fi>
parents:
8242
diff
changeset
|
221 tab[VAR_EXPAND_HOME_IDX].value = home; |
2311
4558d1b196fd
Added --exec-mail option to master. It can be used to parse Dovecot config
Timo Sirainen <tss@iki.fi>
parents:
2291
diff
changeset
|
222 tab[5].value = local_ip; |
4558d1b196fd
Added --exec-mail option to master. It can be used to parse Dovecot config
Timo Sirainen <tss@iki.fi>
parents:
2291
diff
changeset
|
223 tab[6].value = remote_ip; |
2097
4e77cb0aff21
Added %l, %r and %P variables and mail_log_prefix setting.
Timo Sirainen <tss@iki.fi>
parents:
2079
diff
changeset
|
224 tab[7].value = dec2str(pid); |
3690 | 225 tab[8].value = dec2str(uid); |
2057
5e0167577399
Fixed var_expand() to take a table of variables rather than a few predefined
Timo Sirainen <tss@iki.fi>
parents:
2046
diff
changeset
|
226 |
5e0167577399
Fixed var_expand() to take a table of variables rather than a few predefined
Timo Sirainen <tss@iki.fi>
parents:
2046
diff
changeset
|
227 return tab; |
5e0167577399
Fixed var_expand() to take a table of variables rather than a few predefined
Timo Sirainen <tss@iki.fi>
parents:
2046
diff
changeset
|
228 } |
5e0167577399
Fixed var_expand() to take a table of variables rather than a few predefined
Timo Sirainen <tss@iki.fi>
parents:
2046
diff
changeset
|
229 |
8325
74720db3bef7
Give a nicer error message if %h is used while there is no home directory.
Timo Sirainen <tss@iki.fi>
parents:
8242
diff
changeset
|
230 static bool |
74720db3bef7
Give a nicer error message if %h is used while there is no home directory.
Timo Sirainen <tss@iki.fi>
parents:
8242
diff
changeset
|
231 has_missing_used_home(const char *str, const struct var_expand_table *table) |
74720db3bef7
Give a nicer error message if %h is used while there is no home directory.
Timo Sirainen <tss@iki.fi>
parents:
8242
diff
changeset
|
232 { |
74720db3bef7
Give a nicer error message if %h is used while there is no home directory.
Timo Sirainen <tss@iki.fi>
parents:
8242
diff
changeset
|
233 i_assert(table[VAR_EXPAND_HOME_IDX].key == 'h'); |
74720db3bef7
Give a nicer error message if %h is used while there is no home directory.
Timo Sirainen <tss@iki.fi>
parents:
8242
diff
changeset
|
234 |
74720db3bef7
Give a nicer error message if %h is used while there is no home directory.
Timo Sirainen <tss@iki.fi>
parents:
8242
diff
changeset
|
235 return table[VAR_EXPAND_HOME_IDX].value == NULL && |
8544
983d38de06c9
var_expand(): Added support for long %{variable} names.
Timo Sirainen <tss@iki.fi>
parents:
8520
diff
changeset
|
236 var_has_key(str, 'h', "home"); |
8325
74720db3bef7
Give a nicer error message if %h is used while there is no home directory.
Timo Sirainen <tss@iki.fi>
parents:
8242
diff
changeset
|
237 } |
74720db3bef7
Give a nicer error message if %h is used while there is no home directory.
Timo Sirainen <tss@iki.fi>
parents:
8242
diff
changeset
|
238 |
2057
5e0167577399
Fixed var_expand() to take a table of variables rather than a few predefined
Timo Sirainen <tss@iki.fi>
parents:
2046
diff
changeset
|
239 static const char * |
5e0167577399
Fixed var_expand() to take a table of variables rather than a few predefined
Timo Sirainen <tss@iki.fi>
parents:
2046
diff
changeset
|
240 expand_mail_env(const char *env, const struct var_expand_table *table) |
1055
a72bba3f8a55
Rewrote setting handling. Changed some existing settings also since POP3
Timo Sirainen <tss@iki.fi>
parents:
diff
changeset
|
241 { |
a72bba3f8a55
Rewrote setting handling. Changed some existing settings also since POP3
Timo Sirainen <tss@iki.fi>
parents:
diff
changeset
|
242 string_t *str; |
a72bba3f8a55
Rewrote setting handling. Changed some existing settings also since POP3
Timo Sirainen <tss@iki.fi>
parents:
diff
changeset
|
243 const char *p; |
a72bba3f8a55
Rewrote setting handling. Changed some existing settings also since POP3
Timo Sirainen <tss@iki.fi>
parents:
diff
changeset
|
244 |
a72bba3f8a55
Rewrote setting handling. Changed some existing settings also since POP3
Timo Sirainen <tss@iki.fi>
parents:
diff
changeset
|
245 str = t_str_new(256); |
a72bba3f8a55
Rewrote setting handling. Changed some existing settings also since POP3
Timo Sirainen <tss@iki.fi>
parents:
diff
changeset
|
246 |
a72bba3f8a55
Rewrote setting handling. Changed some existing settings also since POP3
Timo Sirainen <tss@iki.fi>
parents:
diff
changeset
|
247 /* it's either type:data or just data */ |
a72bba3f8a55
Rewrote setting handling. Changed some existing settings also since POP3
Timo Sirainen <tss@iki.fi>
parents:
diff
changeset
|
248 p = strchr(env, ':'); |
a72bba3f8a55
Rewrote setting handling. Changed some existing settings also since POP3
Timo Sirainen <tss@iki.fi>
parents:
diff
changeset
|
249 if (p != NULL) { |
a72bba3f8a55
Rewrote setting handling. Changed some existing settings also since POP3
Timo Sirainen <tss@iki.fi>
parents:
diff
changeset
|
250 while (env != p) { |
a72bba3f8a55
Rewrote setting handling. Changed some existing settings also since POP3
Timo Sirainen <tss@iki.fi>
parents:
diff
changeset
|
251 str_append_c(str, *env); |
a72bba3f8a55
Rewrote setting handling. Changed some existing settings also since POP3
Timo Sirainen <tss@iki.fi>
parents:
diff
changeset
|
252 env++; |
a72bba3f8a55
Rewrote setting handling. Changed some existing settings also since POP3
Timo Sirainen <tss@iki.fi>
parents:
diff
changeset
|
253 } |
a72bba3f8a55
Rewrote setting handling. Changed some existing settings also since POP3
Timo Sirainen <tss@iki.fi>
parents:
diff
changeset
|
254 |
a72bba3f8a55
Rewrote setting handling. Changed some existing settings also since POP3
Timo Sirainen <tss@iki.fi>
parents:
diff
changeset
|
255 str_append_c(str, *env++); |
a72bba3f8a55
Rewrote setting handling. Changed some existing settings also since POP3
Timo Sirainen <tss@iki.fi>
parents:
diff
changeset
|
256 } |
a72bba3f8a55
Rewrote setting handling. Changed some existing settings also since POP3
Timo Sirainen <tss@iki.fi>
parents:
diff
changeset
|
257 |
8325
74720db3bef7
Give a nicer error message if %h is used while there is no home directory.
Timo Sirainen <tss@iki.fi>
parents:
8242
diff
changeset
|
258 if (has_missing_used_home(env, table)) { |
74720db3bef7
Give a nicer error message if %h is used while there is no home directory.
Timo Sirainen <tss@iki.fi>
parents:
8242
diff
changeset
|
259 i_fatal("userdb didn't return a home directory, " |
74720db3bef7
Give a nicer error message if %h is used while there is no home directory.
Timo Sirainen <tss@iki.fi>
parents:
8242
diff
changeset
|
260 "but mail location used it (%%h): %s", env); |
74720db3bef7
Give a nicer error message if %h is used while there is no home directory.
Timo Sirainen <tss@iki.fi>
parents:
8242
diff
changeset
|
261 } |
74720db3bef7
Give a nicer error message if %h is used while there is no home directory.
Timo Sirainen <tss@iki.fi>
parents:
8242
diff
changeset
|
262 |
1055
a72bba3f8a55
Rewrote setting handling. Changed some existing settings also since POP3
Timo Sirainen <tss@iki.fi>
parents:
diff
changeset
|
263 /* expand %vars */ |
2057
5e0167577399
Fixed var_expand() to take a table of variables rather than a few predefined
Timo Sirainen <tss@iki.fi>
parents:
2046
diff
changeset
|
264 var_expand(str, env, table); |
1055
a72bba3f8a55
Rewrote setting handling. Changed some existing settings also since POP3
Timo Sirainen <tss@iki.fi>
parents:
diff
changeset
|
265 return str_c(str); |
a72bba3f8a55
Rewrote setting handling. Changed some existing settings also since POP3
Timo Sirainen <tss@iki.fi>
parents:
diff
changeset
|
266 } |
a72bba3f8a55
Rewrote setting handling. Changed some existing settings also since POP3
Timo Sirainen <tss@iki.fi>
parents:
diff
changeset
|
267 |
2057
5e0167577399
Fixed var_expand() to take a table of variables rather than a few predefined
Timo Sirainen <tss@iki.fi>
parents:
2046
diff
changeset
|
268 static void |
7109
e6823d781317
Reverted "environment array" changes. It broke overriding imap/pop3 settings
Timo Sirainen <tss@iki.fi>
parents:
7092
diff
changeset
|
269 env_put_namespace(struct namespace_settings *ns, const char *default_location, |
e6823d781317
Reverted "environment array" changes. It broke overriding imap/pop3 settings
Timo Sirainen <tss@iki.fi>
parents:
7092
diff
changeset
|
270 const struct var_expand_table *table) |
1656 | 271 { |
272 const char *location; | |
273 unsigned int i; | |
1772
c5fa45f0ebf6
Support %vars in namespace prefix.
Timo Sirainen <tss@iki.fi>
parents:
1750
diff
changeset
|
274 string_t *str; |
1656 | 275 |
1749
9ce1e589d3c1
If location isn't given for namespace, use the default
Timo Sirainen <tss@iki.fi>
parents:
1737
diff
changeset
|
276 if (default_location == NULL) |
9ce1e589d3c1
If location isn't given for namespace, use the default
Timo Sirainen <tss@iki.fi>
parents:
1737
diff
changeset
|
277 default_location = ""; |
9ce1e589d3c1
If location isn't given for namespace, use the default
Timo Sirainen <tss@iki.fi>
parents:
1737
diff
changeset
|
278 |
1656 | 279 for (i = 1; ns != NULL; i++, ns = ns->next) { |
4459
de5163f16d8c
If namespace's location field wasn't set, the default location was supposed
Timo Sirainen <tss@iki.fi>
parents:
4451
diff
changeset
|
280 location = *ns->location != '\0' ? ns->location : |
1749
9ce1e589d3c1
If location isn't given for namespace, use the default
Timo Sirainen <tss@iki.fi>
parents:
1737
diff
changeset
|
281 default_location; |
2057
5e0167577399
Fixed var_expand() to take a table of variables rather than a few predefined
Timo Sirainen <tss@iki.fi>
parents:
2046
diff
changeset
|
282 location = expand_mail_env(location, table); |
7109
e6823d781317
Reverted "environment array" changes. It broke overriding imap/pop3 settings
Timo Sirainen <tss@iki.fi>
parents:
7092
diff
changeset
|
283 env_put(t_strdup_printf("NAMESPACE_%u=%s", i, location)); |
1656 | 284 |
7109
e6823d781317
Reverted "environment array" changes. It broke overriding imap/pop3 settings
Timo Sirainen <tss@iki.fi>
parents:
7092
diff
changeset
|
285 if (ns->separator != NULL) { |
e6823d781317
Reverted "environment array" changes. It broke overriding imap/pop3 settings
Timo Sirainen <tss@iki.fi>
parents:
7092
diff
changeset
|
286 env_put(t_strdup_printf("NAMESPACE_%u_SEP=%s", |
e6823d781317
Reverted "environment array" changes. It broke overriding imap/pop3 settings
Timo Sirainen <tss@iki.fi>
parents:
7092
diff
changeset
|
287 i, ns->separator)); |
e6823d781317
Reverted "environment array" changes. It broke overriding imap/pop3 settings
Timo Sirainen <tss@iki.fi>
parents:
7092
diff
changeset
|
288 } |
e6823d781317
Reverted "environment array" changes. It broke overriding imap/pop3 settings
Timo Sirainen <tss@iki.fi>
parents:
7092
diff
changeset
|
289 if (ns->type != NULL) { |
e6823d781317
Reverted "environment array" changes. It broke overriding imap/pop3 settings
Timo Sirainen <tss@iki.fi>
parents:
7092
diff
changeset
|
290 env_put(t_strdup_printf("NAMESPACE_%u_TYPE=%s", |
e6823d781317
Reverted "environment array" changes. It broke overriding imap/pop3 settings
Timo Sirainen <tss@iki.fi>
parents:
7092
diff
changeset
|
291 i, ns->type)); |
e6823d781317
Reverted "environment array" changes. It broke overriding imap/pop3 settings
Timo Sirainen <tss@iki.fi>
parents:
7092
diff
changeset
|
292 } |
8500
3efcdc45d111
Added alias_for setting for namespaces. Fixes namespace issues with fts.
Timo Sirainen <tss@iki.fi>
parents:
8461
diff
changeset
|
293 if (ns->alias_for != NULL) { |
3efcdc45d111
Added alias_for setting for namespaces. Fixes namespace issues with fts.
Timo Sirainen <tss@iki.fi>
parents:
8461
diff
changeset
|
294 env_put(t_strdup_printf("NAMESPACE_%u_ALIAS=%s", |
3efcdc45d111
Added alias_for setting for namespaces. Fixes namespace issues with fts.
Timo Sirainen <tss@iki.fi>
parents:
8461
diff
changeset
|
295 i, ns->alias_for)); |
3efcdc45d111
Added alias_for setting for namespaces. Fixes namespace issues with fts.
Timo Sirainen <tss@iki.fi>
parents:
8461
diff
changeset
|
296 } |
1656 | 297 if (ns->prefix != NULL) { |
1772
c5fa45f0ebf6
Support %vars in namespace prefix.
Timo Sirainen <tss@iki.fi>
parents:
1750
diff
changeset
|
298 /* expand variables, eg. ~%u/ can be useful */ |
c5fa45f0ebf6
Support %vars in namespace prefix.
Timo Sirainen <tss@iki.fi>
parents:
1750
diff
changeset
|
299 str = t_str_new(256); |
7109
e6823d781317
Reverted "environment array" changes. It broke overriding imap/pop3 settings
Timo Sirainen <tss@iki.fi>
parents:
7092
diff
changeset
|
300 str_printfa(str, "NAMESPACE_%u_PREFIX=", i); |
2057
5e0167577399
Fixed var_expand() to take a table of variables rather than a few predefined
Timo Sirainen <tss@iki.fi>
parents:
2046
diff
changeset
|
301 var_expand(str, ns->prefix, table); |
7109
e6823d781317
Reverted "environment array" changes. It broke overriding imap/pop3 settings
Timo Sirainen <tss@iki.fi>
parents:
7092
diff
changeset
|
302 env_put(str_c(str)); |
1656 | 303 } |
1750
4e14ba3c115b
Added "inbox" setting to specify which namespace has the INBOX.
Timo Sirainen <tss@iki.fi>
parents:
1749
diff
changeset
|
304 if (ns->inbox) |
7109
e6823d781317
Reverted "environment array" changes. It broke overriding imap/pop3 settings
Timo Sirainen <tss@iki.fi>
parents:
7092
diff
changeset
|
305 env_put(t_strdup_printf("NAMESPACE_%u_INBOX=1", i)); |
1773
9547667cfa19
Added hidden-option to namespaces to hide them from NAMESPACE reply.
Timo Sirainen <tss@iki.fi>
parents:
1772
diff
changeset
|
306 if (ns->hidden) |
7109
e6823d781317
Reverted "environment array" changes. It broke overriding imap/pop3 settings
Timo Sirainen <tss@iki.fi>
parents:
7092
diff
changeset
|
307 env_put(t_strdup_printf("NAMESPACE_%u_HIDDEN=1", i)); |
8461
659667d89f69
Added list=children option for namespaces.
Timo Sirainen <tss@iki.fi>
parents:
8406
diff
changeset
|
308 if (strcmp(ns->list, "no") != 0) { |
659667d89f69
Added list=children option for namespaces.
Timo Sirainen <tss@iki.fi>
parents:
8406
diff
changeset
|
309 env_put(t_strdup_printf("NAMESPACE_%u_LIST=%s", |
659667d89f69
Added list=children option for namespaces.
Timo Sirainen <tss@iki.fi>
parents:
8406
diff
changeset
|
310 i, ns->list)); |
659667d89f69
Added list=children option for namespaces.
Timo Sirainen <tss@iki.fi>
parents:
8406
diff
changeset
|
311 } |
6603
afc28dd2d4c5
Added subscriptions setting to namespaces to specify if it should handle
Timo Sirainen <tss@iki.fi>
parents:
6596
diff
changeset
|
312 if (ns->subscriptions) |
7109
e6823d781317
Reverted "environment array" changes. It broke overriding imap/pop3 settings
Timo Sirainen <tss@iki.fi>
parents:
7092
diff
changeset
|
313 env_put(t_strdup_printf("NAMESPACE_%u_SUBSCRIPTIONS=1", |
e6823d781317
Reverted "environment array" changes. It broke overriding imap/pop3 settings
Timo Sirainen <tss@iki.fi>
parents:
7092
diff
changeset
|
314 i)); |
1656 | 315 } |
316 } | |
317 | |
2311
4558d1b196fd
Added --exec-mail option to master. It can be used to parse Dovecot config
Timo Sirainen <tss@iki.fi>
parents:
2291
diff
changeset
|
318 static void |
7109
e6823d781317
Reverted "environment array" changes. It broke overriding imap/pop3 settings
Timo Sirainen <tss@iki.fi>
parents:
7092
diff
changeset
|
319 mail_process_set_environment(struct settings *set, const char *mail, |
5119
7144aff70f33
When running dump-capability, don't do stderr_close_shutdown since it could
Timo Sirainen <tss@iki.fi>
parents:
5098
diff
changeset
|
320 const struct var_expand_table *var_expand_table, |
8406
ed4d6fc5712b
Code cleanup for previous change.
Timo Sirainen <tss@iki.fi>
parents:
8405
diff
changeset
|
321 bool exec_mail) |
1055
a72bba3f8a55
Rewrote setting handling. Changed some existing settings also since POP3
Timo Sirainen <tss@iki.fi>
parents:
diff
changeset
|
322 { |
3975
9de8bce1077e
Added plugin {} section to dovecot.conf for passing extra environment
Timo Sirainen <tss@iki.fi>
parents:
3912
diff
changeset
|
323 const char *const *envs; |
9de8bce1077e
Added plugin {} section to dovecot.conf for passing extra environment
Timo Sirainen <tss@iki.fi>
parents:
3912
diff
changeset
|
324 string_t *str; |
9de8bce1077e
Added plugin {} section to dovecot.conf for passing extra environment
Timo Sirainen <tss@iki.fi>
parents:
3912
diff
changeset
|
325 unsigned int i, count; |
9de8bce1077e
Added plugin {} section to dovecot.conf for passing extra environment
Timo Sirainen <tss@iki.fi>
parents:
3912
diff
changeset
|
326 |
9144
a0fcbb79ef66
master: Set BASE_DIR environment for mail processes.
Timo Sirainen <tss@iki.fi>
parents:
8955
diff
changeset
|
327 env_put(t_strconcat("BASE_DIR=", set->base_dir, NULL)); |
7109
e6823d781317
Reverted "environment array" changes. It broke overriding imap/pop3 settings
Timo Sirainen <tss@iki.fi>
parents:
7092
diff
changeset
|
328 env_put(t_strconcat("MAIL_CACHE_FIELDS=", |
e6823d781317
Reverted "environment array" changes. It broke overriding imap/pop3 settings
Timo Sirainen <tss@iki.fi>
parents:
7092
diff
changeset
|
329 set->mail_cache_fields, NULL)); |
e6823d781317
Reverted "environment array" changes. It broke overriding imap/pop3 settings
Timo Sirainen <tss@iki.fi>
parents:
7092
diff
changeset
|
330 env_put(t_strconcat("MAIL_NEVER_CACHE_FIELDS=", |
e6823d781317
Reverted "environment array" changes. It broke overriding imap/pop3 settings
Timo Sirainen <tss@iki.fi>
parents:
7092
diff
changeset
|
331 set->mail_never_cache_fields, NULL)); |
e6823d781317
Reverted "environment array" changes. It broke overriding imap/pop3 settings
Timo Sirainen <tss@iki.fi>
parents:
7092
diff
changeset
|
332 env_put(t_strdup_printf("MAIL_CACHE_MIN_MAIL_COUNT=%u", |
e6823d781317
Reverted "environment array" changes. It broke overriding imap/pop3 settings
Timo Sirainen <tss@iki.fi>
parents:
7092
diff
changeset
|
333 set->mail_cache_min_mail_count)); |
e6823d781317
Reverted "environment array" changes. It broke overriding imap/pop3 settings
Timo Sirainen <tss@iki.fi>
parents:
7092
diff
changeset
|
334 env_put(t_strdup_printf("MAILBOX_IDLE_CHECK_INTERVAL=%u", |
e6823d781317
Reverted "environment array" changes. It broke overriding imap/pop3 settings
Timo Sirainen <tss@iki.fi>
parents:
7092
diff
changeset
|
335 set->mailbox_idle_check_interval)); |
e6823d781317
Reverted "environment array" changes. It broke overriding imap/pop3 settings
Timo Sirainen <tss@iki.fi>
parents:
7092
diff
changeset
|
336 env_put(t_strdup_printf("MAIL_MAX_KEYWORD_LENGTH=%u", |
e6823d781317
Reverted "environment array" changes. It broke overriding imap/pop3 settings
Timo Sirainen <tss@iki.fi>
parents:
7092
diff
changeset
|
337 set->mail_max_keyword_length)); |
5889
8117a34abdbd
Don't bother setting POP3 settings to IMAP processes and vice versa.
Timo Sirainen <tss@iki.fi>
parents:
5876
diff
changeset
|
338 |
8117a34abdbd
Don't bother setting POP3 settings to IMAP processes and vice versa.
Timo Sirainen <tss@iki.fi>
parents:
5876
diff
changeset
|
339 if (set->protocol == MAIL_PROTOCOL_IMAP) { |
7109
e6823d781317
Reverted "environment array" changes. It broke overriding imap/pop3 settings
Timo Sirainen <tss@iki.fi>
parents:
7092
diff
changeset
|
340 env_put(t_strdup_printf("IMAP_MAX_LINE_LENGTH=%u", |
e6823d781317
Reverted "environment array" changes. It broke overriding imap/pop3 settings
Timo Sirainen <tss@iki.fi>
parents:
7092
diff
changeset
|
341 set->imap_max_line_length)); |
5889
8117a34abdbd
Don't bother setting POP3 settings to IMAP processes and vice versa.
Timo Sirainen <tss@iki.fi>
parents:
5876
diff
changeset
|
342 if (*set->imap_capability != '\0') { |
7109
e6823d781317
Reverted "environment array" changes. It broke overriding imap/pop3 settings
Timo Sirainen <tss@iki.fi>
parents:
7092
diff
changeset
|
343 env_put(t_strconcat("IMAP_CAPABILITY=", |
e6823d781317
Reverted "environment array" changes. It broke overriding imap/pop3 settings
Timo Sirainen <tss@iki.fi>
parents:
7092
diff
changeset
|
344 set->imap_capability, NULL)); |
5889
8117a34abdbd
Don't bother setting POP3 settings to IMAP processes and vice versa.
Timo Sirainen <tss@iki.fi>
parents:
5876
diff
changeset
|
345 } |
7109
e6823d781317
Reverted "environment array" changes. It broke overriding imap/pop3 settings
Timo Sirainen <tss@iki.fi>
parents:
7092
diff
changeset
|
346 env_put(t_strconcat("IMAP_CLIENT_WORKAROUNDS=", |
e6823d781317
Reverted "environment array" changes. It broke overriding imap/pop3 settings
Timo Sirainen <tss@iki.fi>
parents:
7092
diff
changeset
|
347 set->imap_client_workarounds, NULL)); |
e6823d781317
Reverted "environment array" changes. It broke overriding imap/pop3 settings
Timo Sirainen <tss@iki.fi>
parents:
7092
diff
changeset
|
348 env_put(t_strconcat("IMAP_LOGOUT_FORMAT=", |
e6823d781317
Reverted "environment array" changes. It broke overriding imap/pop3 settings
Timo Sirainen <tss@iki.fi>
parents:
7092
diff
changeset
|
349 set->imap_logout_format, NULL)); |
7917
ca2ff54ee9b4
Added support for IMAP ID extension.
Timo Sirainen <tss@iki.fi>
parents:
7561
diff
changeset
|
350 env_put(t_strconcat("IMAP_ID_SEND=", set->imap_id_send, NULL)); |
ca2ff54ee9b4
Added support for IMAP ID extension.
Timo Sirainen <tss@iki.fi>
parents:
7561
diff
changeset
|
351 env_put(t_strconcat("IMAP_ID_LOG=", set->imap_id_log, NULL)); |
8955
8de5b2a19a08
Added imap_idle_notify_interval setting.
Timo Sirainen <tss@iki.fi>
parents:
8918
diff
changeset
|
352 env_put(t_strdup_printf("IMAP_IDLE_NOTIFY_INTERVAL=%u", |
8de5b2a19a08
Added imap_idle_notify_interval setting.
Timo Sirainen <tss@iki.fi>
parents:
8918
diff
changeset
|
353 set->imap_idle_notify_interval)); |
4197
c3ded5b815aa
If we have plugins set and imap_capability unset, figure out the IMAP
Timo Sirainen <tss@iki.fi>
parents:
4190
diff
changeset
|
354 } |
5889
8117a34abdbd
Don't bother setting POP3 settings to IMAP processes and vice versa.
Timo Sirainen <tss@iki.fi>
parents:
5876
diff
changeset
|
355 if (set->protocol == MAIL_PROTOCOL_POP3) { |
7109
e6823d781317
Reverted "environment array" changes. It broke overriding imap/pop3 settings
Timo Sirainen <tss@iki.fi>
parents:
7092
diff
changeset
|
356 env_put(t_strconcat("POP3_CLIENT_WORKAROUNDS=", |
e6823d781317
Reverted "environment array" changes. It broke overriding imap/pop3 settings
Timo Sirainen <tss@iki.fi>
parents:
7092
diff
changeset
|
357 set->pop3_client_workarounds, NULL)); |
e6823d781317
Reverted "environment array" changes. It broke overriding imap/pop3 settings
Timo Sirainen <tss@iki.fi>
parents:
7092
diff
changeset
|
358 env_put(t_strconcat("POP3_LOGOUT_FORMAT=", |
e6823d781317
Reverted "environment array" changes. It broke overriding imap/pop3 settings
Timo Sirainen <tss@iki.fi>
parents:
7092
diff
changeset
|
359 set->pop3_logout_format, NULL)); |
5889
8117a34abdbd
Don't bother setting POP3 settings to IMAP processes and vice versa.
Timo Sirainen <tss@iki.fi>
parents:
5876
diff
changeset
|
360 if (set->pop3_no_flag_updates) |
7109
e6823d781317
Reverted "environment array" changes. It broke overriding imap/pop3 settings
Timo Sirainen <tss@iki.fi>
parents:
7092
diff
changeset
|
361 env_put("POP3_NO_FLAG_UPDATES=1"); |
5889
8117a34abdbd
Don't bother setting POP3 settings to IMAP processes and vice versa.
Timo Sirainen <tss@iki.fi>
parents:
5876
diff
changeset
|
362 if (set->pop3_reuse_xuidl) |
7109
e6823d781317
Reverted "environment array" changes. It broke overriding imap/pop3 settings
Timo Sirainen <tss@iki.fi>
parents:
7092
diff
changeset
|
363 env_put("POP3_REUSE_XUIDL=1"); |
9348 | 364 if (set->pop3_save_uidl) |
365 env_put("POP3_SAVE_UIDL=1"); | |
5889
8117a34abdbd
Don't bother setting POP3 settings to IMAP processes and vice versa.
Timo Sirainen <tss@iki.fi>
parents:
5876
diff
changeset
|
366 if (set->pop3_enable_last) |
7109
e6823d781317
Reverted "environment array" changes. It broke overriding imap/pop3 settings
Timo Sirainen <tss@iki.fi>
parents:
7092
diff
changeset
|
367 env_put("POP3_ENABLE_LAST=1"); |
5889
8117a34abdbd
Don't bother setting POP3 settings to IMAP processes and vice versa.
Timo Sirainen <tss@iki.fi>
parents:
5876
diff
changeset
|
368 if (set->pop3_lock_session) |
7109
e6823d781317
Reverted "environment array" changes. It broke overriding imap/pop3 settings
Timo Sirainen <tss@iki.fi>
parents:
7092
diff
changeset
|
369 env_put("POP3_LOCK_SESSION=1"); |
5889
8117a34abdbd
Don't bother setting POP3 settings to IMAP processes and vice versa.
Timo Sirainen <tss@iki.fi>
parents:
5876
diff
changeset
|
370 } |
8117a34abdbd
Don't bother setting POP3 settings to IMAP processes and vice versa.
Timo Sirainen <tss@iki.fi>
parents:
5876
diff
changeset
|
371 |
8117a34abdbd
Don't bother setting POP3 settings to IMAP processes and vice versa.
Timo Sirainen <tss@iki.fi>
parents:
5876
diff
changeset
|
372 /* We care about POP3 UIDL format in all process types */ |
7109
e6823d781317
Reverted "environment array" changes. It broke overriding imap/pop3 settings
Timo Sirainen <tss@iki.fi>
parents:
7092
diff
changeset
|
373 env_put(t_strconcat("POP3_UIDL_FORMAT=", set->pop3_uidl_format, NULL)); |
1055
a72bba3f8a55
Rewrote setting handling. Changed some existing settings also since POP3
Timo Sirainen <tss@iki.fi>
parents:
diff
changeset
|
374 |
a72bba3f8a55
Rewrote setting handling. Changed some existing settings also since POP3
Timo Sirainen <tss@iki.fi>
parents:
diff
changeset
|
375 if (set->mail_save_crlf) |
7109
e6823d781317
Reverted "environment array" changes. It broke overriding imap/pop3 settings
Timo Sirainen <tss@iki.fi>
parents:
7092
diff
changeset
|
376 env_put("MAIL_SAVE_CRLF=1"); |
1917
68938dccbc45
Forced locking to be right with mprotect()ing index file. Support for
Timo Sirainen <tss@iki.fi>
parents:
1780
diff
changeset
|
377 if (set->mmap_disable) |
7109
e6823d781317
Reverted "environment array" changes. It broke overriding imap/pop3 settings
Timo Sirainen <tss@iki.fi>
parents:
7092
diff
changeset
|
378 env_put("MMAP_DISABLE=1"); |
4970
d3b8fcc72c69
Forgot to send dotlock_use_excl to mail processes..
Timo Sirainen <tss@iki.fi>
parents:
4960
diff
changeset
|
379 if (set->dotlock_use_excl) |
7109
e6823d781317
Reverted "environment array" changes. It broke overriding imap/pop3 settings
Timo Sirainen <tss@iki.fi>
parents:
7092
diff
changeset
|
380 env_put("DOTLOCK_USE_EXCL=1"); |
5076
639b4361f46a
fsync_disable wasn't sent to mail processes
Timo Sirainen <tss@iki.fi>
parents:
5071
diff
changeset
|
381 if (set->fsync_disable) |
7109
e6823d781317
Reverted "environment array" changes. It broke overriding imap/pop3 settings
Timo Sirainen <tss@iki.fi>
parents:
7092
diff
changeset
|
382 env_put("FSYNC_DISABLE=1"); |
5977
38a73d870731
Added mail_nfs_storage and mail_nfs_index settings.
Timo Sirainen <tss@iki.fi>
parents:
5889
diff
changeset
|
383 if (set->mail_nfs_storage) |
7109
e6823d781317
Reverted "environment array" changes. It broke overriding imap/pop3 settings
Timo Sirainen <tss@iki.fi>
parents:
7092
diff
changeset
|
384 env_put("MAIL_NFS_STORAGE=1"); |
5977
38a73d870731
Added mail_nfs_storage and mail_nfs_index settings.
Timo Sirainen <tss@iki.fi>
parents:
5889
diff
changeset
|
385 if (set->mail_nfs_index) |
7109
e6823d781317
Reverted "environment array" changes. It broke overriding imap/pop3 settings
Timo Sirainen <tss@iki.fi>
parents:
7092
diff
changeset
|
386 env_put("MAIL_NFS_INDEX=1"); |
5498
21199280aa3b
Added mailbox_list_index_disable setting.
Timo Sirainen <tss@iki.fi>
parents:
5446
diff
changeset
|
387 if (set->mailbox_list_index_disable) |
7109
e6823d781317
Reverted "environment array" changes. It broke overriding imap/pop3 settings
Timo Sirainen <tss@iki.fi>
parents:
7092
diff
changeset
|
388 env_put("MAILBOX_LIST_INDEX_DISABLE=1"); |
2078
b3daf55df932
Added maildir_stat_dirs option.
Timo Sirainen <tss@iki.fi>
parents:
2058
diff
changeset
|
389 if (set->maildir_stat_dirs) |
7109
e6823d781317
Reverted "environment array" changes. It broke overriding imap/pop3 settings
Timo Sirainen <tss@iki.fi>
parents:
7092
diff
changeset
|
390 env_put("MAILDIR_STAT_DIRS=1"); |
1055
a72bba3f8a55
Rewrote setting handling. Changed some existing settings also since POP3
Timo Sirainen <tss@iki.fi>
parents:
diff
changeset
|
391 if (set->maildir_copy_with_hardlinks) |
7109
e6823d781317
Reverted "environment array" changes. It broke overriding imap/pop3 settings
Timo Sirainen <tss@iki.fi>
parents:
7092
diff
changeset
|
392 env_put("MAILDIR_COPY_WITH_HARDLINKS=1"); |
4960
4714befe2604
Added maildir_copy_preserve_filename setting.
Timo Sirainen <timo.sirainen@movial.fi>
parents:
4701
diff
changeset
|
393 if (set->maildir_copy_preserve_filename) |
7109
e6823d781317
Reverted "environment array" changes. It broke overriding imap/pop3 settings
Timo Sirainen <tss@iki.fi>
parents:
7092
diff
changeset
|
394 env_put("MAILDIR_COPY_PRESERVE_FILENAME=1"); |
8876
88aeadb32151
Added maildir_very_dirty_syncs setting.
Timo Sirainen <tss@iki.fi>
parents:
8861
diff
changeset
|
395 if (set->maildir_very_dirty_syncs) |
88aeadb32151
Added maildir_very_dirty_syncs setting.
Timo Sirainen <tss@iki.fi>
parents:
8861
diff
changeset
|
396 env_put("MAILDIR_VERY_DIRTY_SYNCS=1"); |
3033
146897976cfa
Added mail_debug setting. Moved full_filesystem_access from global variable
Timo Sirainen <tss@iki.fi>
parents:
3027
diff
changeset
|
397 if (set->mail_debug) |
7109
e6823d781317
Reverted "environment array" changes. It broke overriding imap/pop3 settings
Timo Sirainen <tss@iki.fi>
parents:
7092
diff
changeset
|
398 env_put("DEBUG=1"); |
1152
95d67b5c3fd4
And pass the mail_full_filesystem_access setting to IMAP process too..
Timo Sirainen <tss@iki.fi>
parents:
1138
diff
changeset
|
399 if (set->mail_full_filesystem_access) |
7109
e6823d781317
Reverted "environment array" changes. It broke overriding imap/pop3 settings
Timo Sirainen <tss@iki.fi>
parents:
7092
diff
changeset
|
400 env_put("FULL_FILESYSTEM_ACCESS=1"); |
2511
710e0bf25bf8
Added mbox_dirty_syncs setting which delays re-reading the whole mbox when
Timo Sirainen <tss@iki.fi>
parents:
2316
diff
changeset
|
401 if (set->mbox_dirty_syncs) |
7109
e6823d781317
Reverted "environment array" changes. It broke overriding imap/pop3 settings
Timo Sirainen <tss@iki.fi>
parents:
7092
diff
changeset
|
402 env_put("MBOX_DIRTY_SYNCS=1"); |
2967
b31f48d152c4
Added mbox_very_dirty_syncs setting.
Timo Sirainen <tss@iki.fi>
parents:
2886
diff
changeset
|
403 if (set->mbox_very_dirty_syncs) |
7109
e6823d781317
Reverted "environment array" changes. It broke overriding imap/pop3 settings
Timo Sirainen <tss@iki.fi>
parents:
7092
diff
changeset
|
404 env_put("MBOX_VERY_DIRTY_SYNCS=1"); |
2662
add94f9aa9e1
Added mbox_lazy_writes setting.
Timo Sirainen <tss@iki.fi>
parents:
2595
diff
changeset
|
405 if (set->mbox_lazy_writes) |
7109
e6823d781317
Reverted "environment array" changes. It broke overriding imap/pop3 settings
Timo Sirainen <tss@iki.fi>
parents:
7092
diff
changeset
|
406 env_put("MBOX_LAZY_WRITES=1"); |
8406
ed4d6fc5712b
Code cleanup for previous change.
Timo Sirainen <tss@iki.fi>
parents:
8405
diff
changeset
|
407 /* when we're not certain that the log fd points to the master |
ed4d6fc5712b
Code cleanup for previous change.
Timo Sirainen <tss@iki.fi>
parents:
8405
diff
changeset
|
408 process's log pipe (dump-capability, --exec-mail), don't let |
ed4d6fc5712b
Code cleanup for previous change.
Timo Sirainen <tss@iki.fi>
parents:
8405
diff
changeset
|
409 the imap process listen for stderr since it might break |
ed4d6fc5712b
Code cleanup for previous change.
Timo Sirainen <tss@iki.fi>
parents:
8405
diff
changeset
|
410 (e.g. epoll_ctl() gives EPERM). */ |
ed4d6fc5712b
Code cleanup for previous change.
Timo Sirainen <tss@iki.fi>
parents:
8405
diff
changeset
|
411 if (set->shutdown_clients && !exec_mail) |
7109
e6823d781317
Reverted "environment array" changes. It broke overriding imap/pop3 settings
Timo Sirainen <tss@iki.fi>
parents:
7092
diff
changeset
|
412 env_put("STDERR_CLOSE_SHUTDOWN=1"); |
8900
87c23fa4278e
Removed umask setting. We're nowadays creating practically all files with proper umasks.
Timo Sirainen <tss@iki.fi>
parents:
8881
diff
changeset
|
413 (void)umask(0077); |
1055
a72bba3f8a55
Rewrote setting handling. Changed some existing settings also since POP3
Timo Sirainen <tss@iki.fi>
parents:
diff
changeset
|
414 |
7109
e6823d781317
Reverted "environment array" changes. It broke overriding imap/pop3 settings
Timo Sirainen <tss@iki.fi>
parents:
7092
diff
changeset
|
415 env_put(t_strconcat("LOCK_METHOD=", set->lock_method, NULL)); |
e6823d781317
Reverted "environment array" changes. It broke overriding imap/pop3 settings
Timo Sirainen <tss@iki.fi>
parents:
7092
diff
changeset
|
416 env_put(t_strconcat("MBOX_READ_LOCKS=", set->mbox_read_locks, NULL)); |
e6823d781317
Reverted "environment array" changes. It broke overriding imap/pop3 settings
Timo Sirainen <tss@iki.fi>
parents:
7092
diff
changeset
|
417 env_put(t_strconcat("MBOX_WRITE_LOCKS=", set->mbox_write_locks, NULL)); |
e6823d781317
Reverted "environment array" changes. It broke overriding imap/pop3 settings
Timo Sirainen <tss@iki.fi>
parents:
7092
diff
changeset
|
418 env_put(t_strdup_printf("MBOX_LOCK_TIMEOUT=%u", |
e6823d781317
Reverted "environment array" changes. It broke overriding imap/pop3 settings
Timo Sirainen <tss@iki.fi>
parents:
7092
diff
changeset
|
419 set->mbox_lock_timeout)); |
e6823d781317
Reverted "environment array" changes. It broke overriding imap/pop3 settings
Timo Sirainen <tss@iki.fi>
parents:
7092
diff
changeset
|
420 env_put(t_strdup_printf("MBOX_DOTLOCK_CHANGE_TIMEOUT=%u", |
e6823d781317
Reverted "environment array" changes. It broke overriding imap/pop3 settings
Timo Sirainen <tss@iki.fi>
parents:
7092
diff
changeset
|
421 set->mbox_dotlock_change_timeout)); |
e6823d781317
Reverted "environment array" changes. It broke overriding imap/pop3 settings
Timo Sirainen <tss@iki.fi>
parents:
7092
diff
changeset
|
422 env_put(t_strdup_printf("MBOX_MIN_INDEX_SIZE=%u", |
e6823d781317
Reverted "environment array" changes. It broke overriding imap/pop3 settings
Timo Sirainen <tss@iki.fi>
parents:
7092
diff
changeset
|
423 set->mbox_min_index_size)); |
1055
a72bba3f8a55
Rewrote setting handling. Changed some existing settings also since POP3
Timo Sirainen <tss@iki.fi>
parents:
diff
changeset
|
424 |
7109
e6823d781317
Reverted "environment array" changes. It broke overriding imap/pop3 settings
Timo Sirainen <tss@iki.fi>
parents:
7092
diff
changeset
|
425 env_put(t_strdup_printf("DBOX_ROTATE_SIZE=%u", |
e6823d781317
Reverted "environment array" changes. It broke overriding imap/pop3 settings
Timo Sirainen <tss@iki.fi>
parents:
7092
diff
changeset
|
426 set->dbox_rotate_size)); |
e6823d781317
Reverted "environment array" changes. It broke overriding imap/pop3 settings
Timo Sirainen <tss@iki.fi>
parents:
7092
diff
changeset
|
427 env_put(t_strdup_printf("DBOX_ROTATE_MIN_SIZE=%u", |
e6823d781317
Reverted "environment array" changes. It broke overriding imap/pop3 settings
Timo Sirainen <tss@iki.fi>
parents:
7092
diff
changeset
|
428 set->dbox_rotate_min_size)); |
e6823d781317
Reverted "environment array" changes. It broke overriding imap/pop3 settings
Timo Sirainen <tss@iki.fi>
parents:
7092
diff
changeset
|
429 env_put(t_strdup_printf("DBOX_ROTATE_DAYS=%u", |
e6823d781317
Reverted "environment array" changes. It broke overriding imap/pop3 settings
Timo Sirainen <tss@iki.fi>
parents:
7092
diff
changeset
|
430 set->dbox_rotate_days)); |
4177
4eaaef28cc38
dbox settings in config file didn't work, and the defaults were also a bit
Timo Sirainen <tss@iki.fi>
parents:
4165
diff
changeset
|
431 |
4074
dadc6e2cccb8
Replaced mail_use_modules and mail_modules settings with mail_plugins and
Timo Sirainen <tss@iki.fi>
parents:
4017
diff
changeset
|
432 if (*set->mail_plugins != '\0') { |
7109
e6823d781317
Reverted "environment array" changes. It broke overriding imap/pop3 settings
Timo Sirainen <tss@iki.fi>
parents:
7092
diff
changeset
|
433 env_put(t_strconcat("MAIL_PLUGIN_DIR=", |
e6823d781317
Reverted "environment array" changes. It broke overriding imap/pop3 settings
Timo Sirainen <tss@iki.fi>
parents:
7092
diff
changeset
|
434 set->mail_plugin_dir, NULL)); |
e6823d781317
Reverted "environment array" changes. It broke overriding imap/pop3 settings
Timo Sirainen <tss@iki.fi>
parents:
7092
diff
changeset
|
435 env_put(t_strconcat("MAIL_PLUGINS=", set->mail_plugins, NULL)); |
1610
6850142c4e25
New configuration file code. Some syntax changes, but tries to be somewhat
Timo Sirainen <tss@iki.fi>
parents:
1592
diff
changeset
|
436 } |
1465
03dd87873a81
Added support for dynamically loadable imap/pop3 modules.
Timo Sirainen <tss@iki.fi>
parents:
1444
diff
changeset
|
437 |
1055
a72bba3f8a55
Rewrote setting handling. Changed some existing settings also since POP3
Timo Sirainen <tss@iki.fi>
parents:
diff
changeset
|
438 /* user given environment - may be malicious. virtual_user comes from |
a72bba3f8a55
Rewrote setting handling. Changed some existing settings also since POP3
Timo Sirainen <tss@iki.fi>
parents:
diff
changeset
|
439 auth process, but don't trust that too much either. Some auth |
a72bba3f8a55
Rewrote setting handling. Changed some existing settings also since POP3
Timo Sirainen <tss@iki.fi>
parents:
diff
changeset
|
440 mechanism might allow leaving extra data there. */ |
4701
190a66df2f82
Renamed default_mail_env to mail_location. Keep the default_mail_env working
Timo Sirainen <tss@iki.fi>
parents:
4634
diff
changeset
|
441 if ((mail == NULL || *mail == '\0') && *set->mail_location != '\0') |
190a66df2f82
Renamed default_mail_env to mail_location. Keep the default_mail_env working
Timo Sirainen <tss@iki.fi>
parents:
4634
diff
changeset
|
442 mail = expand_mail_env(set->mail_location, var_expand_table); |
7109
e6823d781317
Reverted "environment array" changes. It broke overriding imap/pop3 settings
Timo Sirainen <tss@iki.fi>
parents:
7092
diff
changeset
|
443 env_put(t_strconcat("MAIL=", mail, NULL)); |
1656 | 444 |
1749
9ce1e589d3c1
If location isn't given for namespace, use the default
Timo Sirainen <tss@iki.fi>
parents:
1737
diff
changeset
|
445 if (set->server->namespaces != NULL) { |
7109
e6823d781317
Reverted "environment array" changes. It broke overriding imap/pop3 settings
Timo Sirainen <tss@iki.fi>
parents:
7092
diff
changeset
|
446 env_put_namespace(set->server->namespaces, |
e6823d781317
Reverted "environment array" changes. It broke overriding imap/pop3 settings
Timo Sirainen <tss@iki.fi>
parents:
7092
diff
changeset
|
447 mail, var_expand_table); |
1749
9ce1e589d3c1
If location isn't given for namespace, use the default
Timo Sirainen <tss@iki.fi>
parents:
1737
diff
changeset
|
448 } |
3975
9de8bce1077e
Added plugin {} section to dovecot.conf for passing extra environment
Timo Sirainen <tss@iki.fi>
parents:
3912
diff
changeset
|
449 |
9de8bce1077e
Added plugin {} section to dovecot.conf for passing extra environment
Timo Sirainen <tss@iki.fi>
parents:
3912
diff
changeset
|
450 str = t_str_new(256); |
9de8bce1077e
Added plugin {} section to dovecot.conf for passing extra environment
Timo Sirainen <tss@iki.fi>
parents:
3912
diff
changeset
|
451 envs = array_get(&set->plugin_envs, &count); |
9de8bce1077e
Added plugin {} section to dovecot.conf for passing extra environment
Timo Sirainen <tss@iki.fi>
parents:
3912
diff
changeset
|
452 i_assert((count % 2) == 0); |
9de8bce1077e
Added plugin {} section to dovecot.conf for passing extra environment
Timo Sirainen <tss@iki.fi>
parents:
3912
diff
changeset
|
453 for (i = 0; i < count; i += 2) { |
9de8bce1077e
Added plugin {} section to dovecot.conf for passing extra environment
Timo Sirainen <tss@iki.fi>
parents:
3912
diff
changeset
|
454 str_truncate(str, 0); |
9de8bce1077e
Added plugin {} section to dovecot.conf for passing extra environment
Timo Sirainen <tss@iki.fi>
parents:
3912
diff
changeset
|
455 var_expand(str, envs[i+1], var_expand_table); |
9de8bce1077e
Added plugin {} section to dovecot.conf for passing extra environment
Timo Sirainen <tss@iki.fi>
parents:
3912
diff
changeset
|
456 |
8325
74720db3bef7
Give a nicer error message if %h is used while there is no home directory.
Timo Sirainen <tss@iki.fi>
parents:
8242
diff
changeset
|
457 if (has_missing_used_home(envs[i+1], var_expand_table)) { |
74720db3bef7
Give a nicer error message if %h is used while there is no home directory.
Timo Sirainen <tss@iki.fi>
parents:
8242
diff
changeset
|
458 i_error("userdb didn't return a home directory, " |
74720db3bef7
Give a nicer error message if %h is used while there is no home directory.
Timo Sirainen <tss@iki.fi>
parents:
8242
diff
changeset
|
459 "but it's used in plugin setting %s: %s", |
74720db3bef7
Give a nicer error message if %h is used while there is no home directory.
Timo Sirainen <tss@iki.fi>
parents:
8242
diff
changeset
|
460 envs[i], envs[i+1]); |
74720db3bef7
Give a nicer error message if %h is used while there is no home directory.
Timo Sirainen <tss@iki.fi>
parents:
8242
diff
changeset
|
461 } |
74720db3bef7
Give a nicer error message if %h is used while there is no home directory.
Timo Sirainen <tss@iki.fi>
parents:
8242
diff
changeset
|
462 |
7109
e6823d781317
Reverted "environment array" changes. It broke overriding imap/pop3 settings
Timo Sirainen <tss@iki.fi>
parents:
7092
diff
changeset
|
463 env_put(t_strconcat(t_str_ucase(envs[i]), "=", |
e6823d781317
Reverted "environment array" changes. It broke overriding imap/pop3 settings
Timo Sirainen <tss@iki.fi>
parents:
7092
diff
changeset
|
464 str_c(str), NULL)); |
3975
9de8bce1077e
Added plugin {} section to dovecot.conf for passing extra environment
Timo Sirainen <tss@iki.fi>
parents:
3912
diff
changeset
|
465 } |
2311
4558d1b196fd
Added --exec-mail option to master. It can be used to parse Dovecot config
Timo Sirainen <tss@iki.fi>
parents:
2291
diff
changeset
|
466 } |
1055
a72bba3f8a55
Rewrote setting handling. Changed some existing settings also since POP3
Timo Sirainen <tss@iki.fi>
parents:
diff
changeset
|
467 |
7334
ae8180a4febd
Allow dovecot --exec-mail ext program arguments.
Timo Sirainen <tss@iki.fi>
parents:
7258
diff
changeset
|
468 void mail_process_exec(const char *protocol, const char **args) |
2311
4558d1b196fd
Added --exec-mail option to master. It can be used to parse Dovecot config
Timo Sirainen <tss@iki.fi>
parents:
2291
diff
changeset
|
469 { |
4558d1b196fd
Added --exec-mail option to master. It can be used to parse Dovecot config
Timo Sirainen <tss@iki.fi>
parents:
2291
diff
changeset
|
470 struct server_settings *server = settings_root; |
4558d1b196fd
Added --exec-mail option to master. It can be used to parse Dovecot config
Timo Sirainen <tss@iki.fi>
parents:
2291
diff
changeset
|
471 const struct var_expand_table *var_expand_table; |
4558d1b196fd
Added --exec-mail option to master. It can be used to parse Dovecot config
Timo Sirainen <tss@iki.fi>
parents:
2291
diff
changeset
|
472 struct settings *set; |
7109
e6823d781317
Reverted "environment array" changes. It broke overriding imap/pop3 settings
Timo Sirainen <tss@iki.fi>
parents:
7092
diff
changeset
|
473 const char *executable; |
2311
4558d1b196fd
Added --exec-mail option to master. It can be used to parse Dovecot config
Timo Sirainen <tss@iki.fi>
parents:
2291
diff
changeset
|
474 |
4334
23394b3a7879
dovecot --exec-mail ext <binary path> now reads the default settings from
Timo Sirainen <timo.sirainen@movial.fi>
parents:
4315
diff
changeset
|
475 if (strcmp(protocol, "ext") == 0) { |
23394b3a7879
dovecot --exec-mail ext <binary path> now reads the default settings from
Timo Sirainen <timo.sirainen@movial.fi>
parents:
4315
diff
changeset
|
476 /* external binary. section contains path for it. */ |
7334
ae8180a4febd
Allow dovecot --exec-mail ext program arguments.
Timo Sirainen <tss@iki.fi>
parents:
7258
diff
changeset
|
477 if (*args == NULL) |
4334
23394b3a7879
dovecot --exec-mail ext <binary path> now reads the default settings from
Timo Sirainen <timo.sirainen@movial.fi>
parents:
4315
diff
changeset
|
478 i_fatal("External binary parameter not given"); |
23394b3a7879
dovecot --exec-mail ext <binary path> now reads the default settings from
Timo Sirainen <timo.sirainen@movial.fi>
parents:
4315
diff
changeset
|
479 set = server->defaults; |
7334
ae8180a4febd
Allow dovecot --exec-mail ext program arguments.
Timo Sirainen <tss@iki.fi>
parents:
7258
diff
changeset
|
480 executable = *args; |
4334
23394b3a7879
dovecot --exec-mail ext <binary path> now reads the default settings from
Timo Sirainen <timo.sirainen@movial.fi>
parents:
4315
diff
changeset
|
481 } else { |
7334
ae8180a4febd
Allow dovecot --exec-mail ext program arguments.
Timo Sirainen <tss@iki.fi>
parents:
7258
diff
changeset
|
482 const char *section = *args; |
ae8180a4febd
Allow dovecot --exec-mail ext program arguments.
Timo Sirainen <tss@iki.fi>
parents:
7258
diff
changeset
|
483 |
4334
23394b3a7879
dovecot --exec-mail ext <binary path> now reads the default settings from
Timo Sirainen <timo.sirainen@movial.fi>
parents:
4315
diff
changeset
|
484 if (section != NULL) { |
23394b3a7879
dovecot --exec-mail ext <binary path> now reads the default settings from
Timo Sirainen <timo.sirainen@movial.fi>
parents:
4315
diff
changeset
|
485 for (; server != NULL; server = server->next) { |
23394b3a7879
dovecot --exec-mail ext <binary path> now reads the default settings from
Timo Sirainen <timo.sirainen@movial.fi>
parents:
4315
diff
changeset
|
486 if (strcmp(server->name, section) == 0) |
23394b3a7879
dovecot --exec-mail ext <binary path> now reads the default settings from
Timo Sirainen <timo.sirainen@movial.fi>
parents:
4315
diff
changeset
|
487 break; |
23394b3a7879
dovecot --exec-mail ext <binary path> now reads the default settings from
Timo Sirainen <timo.sirainen@movial.fi>
parents:
4315
diff
changeset
|
488 } |
23394b3a7879
dovecot --exec-mail ext <binary path> now reads the default settings from
Timo Sirainen <timo.sirainen@movial.fi>
parents:
4315
diff
changeset
|
489 if (server == NULL) |
23394b3a7879
dovecot --exec-mail ext <binary path> now reads the default settings from
Timo Sirainen <timo.sirainen@movial.fi>
parents:
4315
diff
changeset
|
490 i_fatal("Section not found: '%s'", section); |
2311
4558d1b196fd
Added --exec-mail option to master. It can be used to parse Dovecot config
Timo Sirainen <tss@iki.fi>
parents:
2291
diff
changeset
|
491 } |
4334
23394b3a7879
dovecot --exec-mail ext <binary path> now reads the default settings from
Timo Sirainen <timo.sirainen@movial.fi>
parents:
4315
diff
changeset
|
492 |
23394b3a7879
dovecot --exec-mail ext <binary path> now reads the default settings from
Timo Sirainen <timo.sirainen@movial.fi>
parents:
4315
diff
changeset
|
493 if (strcmp(protocol, "imap") == 0) |
23394b3a7879
dovecot --exec-mail ext <binary path> now reads the default settings from
Timo Sirainen <timo.sirainen@movial.fi>
parents:
4315
diff
changeset
|
494 set = server->imap; |
23394b3a7879
dovecot --exec-mail ext <binary path> now reads the default settings from
Timo Sirainen <timo.sirainen@movial.fi>
parents:
4315
diff
changeset
|
495 else if (strcmp(protocol, "pop3") == 0) |
23394b3a7879
dovecot --exec-mail ext <binary path> now reads the default settings from
Timo Sirainen <timo.sirainen@movial.fi>
parents:
4315
diff
changeset
|
496 set = server->pop3; |
23394b3a7879
dovecot --exec-mail ext <binary path> now reads the default settings from
Timo Sirainen <timo.sirainen@movial.fi>
parents:
4315
diff
changeset
|
497 else |
23394b3a7879
dovecot --exec-mail ext <binary path> now reads the default settings from
Timo Sirainen <timo.sirainen@movial.fi>
parents:
4315
diff
changeset
|
498 i_fatal("Unknown protocol: '%s'", protocol); |
23394b3a7879
dovecot --exec-mail ext <binary path> now reads the default settings from
Timo Sirainen <timo.sirainen@movial.fi>
parents:
4315
diff
changeset
|
499 executable = set->mail_executable; |
7334
ae8180a4febd
Allow dovecot --exec-mail ext program arguments.
Timo Sirainen <tss@iki.fi>
parents:
7258
diff
changeset
|
500 args = NULL; |
2311
4558d1b196fd
Added --exec-mail option to master. It can be used to parse Dovecot config
Timo Sirainen <tss@iki.fi>
parents:
2291
diff
changeset
|
501 } |
4558d1b196fd
Added --exec-mail option to master. It can be used to parse Dovecot config
Timo Sirainen <tss@iki.fi>
parents:
2291
diff
changeset
|
502 |
4558d1b196fd
Added --exec-mail option to master. It can be used to parse Dovecot config
Timo Sirainen <tss@iki.fi>
parents:
2291
diff
changeset
|
503 var_expand_table = |
4558d1b196fd
Added --exec-mail option to master. It can be used to parse Dovecot config
Timo Sirainen <tss@iki.fi>
parents:
2291
diff
changeset
|
504 get_var_expand_table(protocol, getenv("USER"), getenv("HOME"), |
4558d1b196fd
Added --exec-mail option to master. It can be used to parse Dovecot config
Timo Sirainen <tss@iki.fi>
parents:
2291
diff
changeset
|
505 getenv("TCPLOCALIP"), |
3690 | 506 getenv("TCPREMOTEIP"), |
507 getpid(), geteuid()); | |
2311
4558d1b196fd
Added --exec-mail option to master. It can be used to parse Dovecot config
Timo Sirainen <tss@iki.fi>
parents:
2291
diff
changeset
|
508 |
5327
0c92499643ec
Make processes created with --exec-mail log to the configured location.
Timo Sirainen <tss@iki.fi>
parents:
5119
diff
changeset
|
509 /* set up logging */ |
7109
e6823d781317
Reverted "environment array" changes. It broke overriding imap/pop3 settings
Timo Sirainen <tss@iki.fi>
parents:
7092
diff
changeset
|
510 env_put(t_strconcat("LOG_TIMESTAMP=", set->log_timestamp, NULL)); |
5327
0c92499643ec
Make processes created with --exec-mail log to the configured location.
Timo Sirainen <tss@iki.fi>
parents:
5119
diff
changeset
|
511 if (*set->log_path == '\0') |
7109
e6823d781317
Reverted "environment array" changes. It broke overriding imap/pop3 settings
Timo Sirainen <tss@iki.fi>
parents:
7092
diff
changeset
|
512 env_put("USE_SYSLOG=1"); |
5327
0c92499643ec
Make processes created with --exec-mail log to the configured location.
Timo Sirainen <tss@iki.fi>
parents:
5119
diff
changeset
|
513 else |
7109
e6823d781317
Reverted "environment array" changes. It broke overriding imap/pop3 settings
Timo Sirainen <tss@iki.fi>
parents:
7092
diff
changeset
|
514 env_put(t_strconcat("LOGFILE=", set->log_path, NULL)); |
5327
0c92499643ec
Make processes created with --exec-mail log to the configured location.
Timo Sirainen <tss@iki.fi>
parents:
5119
diff
changeset
|
515 if (*set->info_log_path != '\0') |
7109
e6823d781317
Reverted "environment array" changes. It broke overriding imap/pop3 settings
Timo Sirainen <tss@iki.fi>
parents:
7092
diff
changeset
|
516 env_put(t_strconcat("INFOLOGFILE=", set->info_log_path, NULL)); |
5333
55260092b094
Fixes to handling log prefixes. imap/pop3 processes now log the
Timo Sirainen <tss@iki.fi>
parents:
5327
diff
changeset
|
517 if (*set->mail_log_prefix != '\0') { |
55260092b094
Fixes to handling log prefixes. imap/pop3 processes now log the
Timo Sirainen <tss@iki.fi>
parents:
5327
diff
changeset
|
518 string_t *str = t_str_new(256); |
55260092b094
Fixes to handling log prefixes. imap/pop3 processes now log the
Timo Sirainen <tss@iki.fi>
parents:
5327
diff
changeset
|
519 |
7109
e6823d781317
Reverted "environment array" changes. It broke overriding imap/pop3 settings
Timo Sirainen <tss@iki.fi>
parents:
7092
diff
changeset
|
520 str_append(str, "LOG_PREFIX="); |
5333
55260092b094
Fixes to handling log prefixes. imap/pop3 processes now log the
Timo Sirainen <tss@iki.fi>
parents:
5327
diff
changeset
|
521 var_expand(str, set->mail_log_prefix, var_expand_table); |
7109
e6823d781317
Reverted "environment array" changes. It broke overriding imap/pop3 settings
Timo Sirainen <tss@iki.fi>
parents:
7092
diff
changeset
|
522 env_put(str_c(str)); |
5333
55260092b094
Fixes to handling log prefixes. imap/pop3 processes now log the
Timo Sirainen <tss@iki.fi>
parents:
5327
diff
changeset
|
523 } |
5327
0c92499643ec
Make processes created with --exec-mail log to the configured location.
Timo Sirainen <tss@iki.fi>
parents:
5119
diff
changeset
|
524 |
7109
e6823d781317
Reverted "environment array" changes. It broke overriding imap/pop3 settings
Timo Sirainen <tss@iki.fi>
parents:
7092
diff
changeset
|
525 mail_process_set_environment(set, getenv("MAIL"), var_expand_table, |
8406
ed4d6fc5712b
Code cleanup for previous change.
Timo Sirainen <tss@iki.fi>
parents:
8405
diff
changeset
|
526 TRUE); |
7334
ae8180a4febd
Allow dovecot --exec-mail ext program arguments.
Timo Sirainen <tss@iki.fi>
parents:
7258
diff
changeset
|
527 if (args == NULL) |
ae8180a4febd
Allow dovecot --exec-mail ext program arguments.
Timo Sirainen <tss@iki.fi>
parents:
7258
diff
changeset
|
528 client_process_exec(executable, ""); |
ae8180a4febd
Allow dovecot --exec-mail ext program arguments.
Timo Sirainen <tss@iki.fi>
parents:
7258
diff
changeset
|
529 else |
ae8180a4febd
Allow dovecot --exec-mail ext program arguments.
Timo Sirainen <tss@iki.fi>
parents:
7258
diff
changeset
|
530 client_process_exec_argv(executable, args); |
2311
4558d1b196fd
Added --exec-mail option to master. It can be used to parse Dovecot config
Timo Sirainen <tss@iki.fi>
parents:
2291
diff
changeset
|
531 } |
4558d1b196fd
Added --exec-mail option to master. It can be used to parse Dovecot config
Timo Sirainen <tss@iki.fi>
parents:
2291
diff
changeset
|
532 |
5386
bf4a85a47901
Fixed NFS check again with chroots
Timo Sirainen <tss@iki.fi>
parents:
5383
diff
changeset
|
533 static void nfs_warn_if_found(const char *mail, const char *full_home_dir) |
4190
19fc27f57b0c
Unless nfs_check=no or mmap_disable=yes, check for the first login if the
Timo Sirainen <tss@iki.fi>
parents:
4179
diff
changeset
|
534 { |
19fc27f57b0c
Unless nfs_check=no or mmap_disable=yes, check for the first login if the
Timo Sirainen <tss@iki.fi>
parents:
4179
diff
changeset
|
535 struct mountpoint point; |
19fc27f57b0c
Unless nfs_check=no or mmap_disable=yes, check for the first login if the
Timo Sirainen <tss@iki.fi>
parents:
4179
diff
changeset
|
536 const char *path; |
19fc27f57b0c
Unless nfs_check=no or mmap_disable=yes, check for the first login if the
Timo Sirainen <tss@iki.fi>
parents:
4179
diff
changeset
|
537 |
4213
096b5a271614
If mail environment is "", don't use it.
Timo Sirainen <tss@iki.fi>
parents:
4212
diff
changeset
|
538 if (mail == NULL || *mail == '\0') |
5386
bf4a85a47901
Fixed NFS check again with chroots
Timo Sirainen <tss@iki.fi>
parents:
5383
diff
changeset
|
539 path = full_home_dir; |
4190
19fc27f57b0c
Unless nfs_check=no or mmap_disable=yes, check for the first login if the
Timo Sirainen <tss@iki.fi>
parents:
4179
diff
changeset
|
540 else { |
19fc27f57b0c
Unless nfs_check=no or mmap_disable=yes, check for the first login if the
Timo Sirainen <tss@iki.fi>
parents:
4179
diff
changeset
|
541 path = strstr(mail, ":INDEX="); |
19fc27f57b0c
Unless nfs_check=no or mmap_disable=yes, check for the first login if the
Timo Sirainen <tss@iki.fi>
parents:
4179
diff
changeset
|
542 if (path != NULL) { |
19fc27f57b0c
Unless nfs_check=no or mmap_disable=yes, check for the first login if the
Timo Sirainen <tss@iki.fi>
parents:
4179
diff
changeset
|
543 /* indexes set separately */ |
19fc27f57b0c
Unless nfs_check=no or mmap_disable=yes, check for the first login if the
Timo Sirainen <tss@iki.fi>
parents:
4179
diff
changeset
|
544 path += 7; |
19fc27f57b0c
Unless nfs_check=no or mmap_disable=yes, check for the first login if the
Timo Sirainen <tss@iki.fi>
parents:
4179
diff
changeset
|
545 if (strncmp(path, "MEMORY", 6) == 0) |
19fc27f57b0c
Unless nfs_check=no or mmap_disable=yes, check for the first login if the
Timo Sirainen <tss@iki.fi>
parents:
4179
diff
changeset
|
546 return; |
19fc27f57b0c
Unless nfs_check=no or mmap_disable=yes, check for the first login if the
Timo Sirainen <tss@iki.fi>
parents:
4179
diff
changeset
|
547 } else { |
19fc27f57b0c
Unless nfs_check=no or mmap_disable=yes, check for the first login if the
Timo Sirainen <tss@iki.fi>
parents:
4179
diff
changeset
|
548 path = strchr(mail, ':'); |
19fc27f57b0c
Unless nfs_check=no or mmap_disable=yes, check for the first login if the
Timo Sirainen <tss@iki.fi>
parents:
4179
diff
changeset
|
549 if (path == NULL) { |
19fc27f57b0c
Unless nfs_check=no or mmap_disable=yes, check for the first login if the
Timo Sirainen <tss@iki.fi>
parents:
4179
diff
changeset
|
550 /* autodetection for path */ |
4212
59d5370a330f
Don't crash in NFS check if using mail path autodetection
Timo Sirainen <tss@iki.fi>
parents:
4197
diff
changeset
|
551 path = mail; |
4190
19fc27f57b0c
Unless nfs_check=no or mmap_disable=yes, check for the first login if the
Timo Sirainen <tss@iki.fi>
parents:
4179
diff
changeset
|
552 } else { |
19fc27f57b0c
Unless nfs_check=no or mmap_disable=yes, check for the first login if the
Timo Sirainen <tss@iki.fi>
parents:
4179
diff
changeset
|
553 /* format:path */ |
19fc27f57b0c
Unless nfs_check=no or mmap_disable=yes, check for the first login if the
Timo Sirainen <tss@iki.fi>
parents:
4179
diff
changeset
|
554 path++; |
19fc27f57b0c
Unless nfs_check=no or mmap_disable=yes, check for the first login if the
Timo Sirainen <tss@iki.fi>
parents:
4179
diff
changeset
|
555 } |
19fc27f57b0c
Unless nfs_check=no or mmap_disable=yes, check for the first login if the
Timo Sirainen <tss@iki.fi>
parents:
4179
diff
changeset
|
556 } |
5386
bf4a85a47901
Fixed NFS check again with chroots
Timo Sirainen <tss@iki.fi>
parents:
5383
diff
changeset
|
557 path = home_expand_tilde(t_strcut(path, ':'), full_home_dir); |
4190
19fc27f57b0c
Unless nfs_check=no or mmap_disable=yes, check for the first login if the
Timo Sirainen <tss@iki.fi>
parents:
4179
diff
changeset
|
558 } |
19fc27f57b0c
Unless nfs_check=no or mmap_disable=yes, check for the first login if the
Timo Sirainen <tss@iki.fi>
parents:
4179
diff
changeset
|
559 |
19fc27f57b0c
Unless nfs_check=no or mmap_disable=yes, check for the first login if the
Timo Sirainen <tss@iki.fi>
parents:
4179
diff
changeset
|
560 if (mountpoint_get(path, pool_datastack_create(), &point) <= 0) |
19fc27f57b0c
Unless nfs_check=no or mmap_disable=yes, check for the first login if the
Timo Sirainen <tss@iki.fi>
parents:
4179
diff
changeset
|
561 return; |
19fc27f57b0c
Unless nfs_check=no or mmap_disable=yes, check for the first login if the
Timo Sirainen <tss@iki.fi>
parents:
4179
diff
changeset
|
562 |
19fc27f57b0c
Unless nfs_check=no or mmap_disable=yes, check for the first login if the
Timo Sirainen <tss@iki.fi>
parents:
4179
diff
changeset
|
563 if (point.type == NULL || strcasecmp(point.type, "NFS") != 0) |
19fc27f57b0c
Unless nfs_check=no or mmap_disable=yes, check for the first login if the
Timo Sirainen <tss@iki.fi>
parents:
4179
diff
changeset
|
564 return; |
19fc27f57b0c
Unless nfs_check=no or mmap_disable=yes, check for the first login if the
Timo Sirainen <tss@iki.fi>
parents:
4179
diff
changeset
|
565 |
8708
7c4f4a1b1313
nfs_check: Mention also mail_nfs_storage=yes in the error message.
Timo Sirainen <tss@iki.fi>
parents:
8707
diff
changeset
|
566 i_fatal("Mailbox indexes in %s are in NFS mount. You must set " |
7c4f4a1b1313
nfs_check: Mention also mail_nfs_storage=yes in the error message.
Timo Sirainen <tss@iki.fi>
parents:
8707
diff
changeset
|
567 "mail_nfs_index=yes (and mail_nfs_storage=yes) to avoid index corruptions. " |
4190
19fc27f57b0c
Unless nfs_check=no or mmap_disable=yes, check for the first login if the
Timo Sirainen <tss@iki.fi>
parents:
4179
diff
changeset
|
568 "If you're sure this check was wrong, set nfs_check=no.", path); |
19fc27f57b0c
Unless nfs_check=no or mmap_disable=yes, check for the first login if the
Timo Sirainen <tss@iki.fi>
parents:
4179
diff
changeset
|
569 } |
19fc27f57b0c
Unless nfs_check=no or mmap_disable=yes, check for the first login if the
Timo Sirainen <tss@iki.fi>
parents:
4179
diff
changeset
|
570 |
5846
21e529b8a701
Initial implementation for mail_max_user_connections setting.
Timo Sirainen <tss@iki.fi>
parents:
5843
diff
changeset
|
571 enum master_login_status |
21e529b8a701
Initial implementation for mail_max_user_connections setting.
Timo Sirainen <tss@iki.fi>
parents:
5843
diff
changeset
|
572 create_mail_process(enum process_type process_type, struct settings *set, |
7928
9e226056a208
Send login command OK reply in IMAP/POP3 process.
Timo Sirainen <tss@iki.fi>
parents:
7927
diff
changeset
|
573 const struct mail_login_request *request, |
5846
21e529b8a701
Initial implementation for mail_max_user_connections setting.
Timo Sirainen <tss@iki.fi>
parents:
5843
diff
changeset
|
574 const char *user, const char *const *args, |
8092
29b623366e1e
Pass the created mail process PID back to login process so it can log it.
Timo Sirainen <tss@iki.fi>
parents:
7943
diff
changeset
|
575 const unsigned char *data, bool dump_capability, |
29b623366e1e
Pass the created mail process PID back to login process so it can log it.
Timo Sirainen <tss@iki.fi>
parents:
7943
diff
changeset
|
576 pid_t *pid_r) |
2311
4558d1b196fd
Added --exec-mail option to master. It can be used to parse Dovecot config
Timo Sirainen <tss@iki.fi>
parents:
2291
diff
changeset
|
577 { |
4558d1b196fd
Added --exec-mail option to master. It can be used to parse Dovecot config
Timo Sirainen <tss@iki.fi>
parents:
2291
diff
changeset
|
578 const struct var_expand_table *var_expand_table; |
3158
8849f2e380d1
userdb can now return extra parameters to master. Removed special handling
Timo Sirainen <tss@iki.fi>
parents:
3095
diff
changeset
|
579 const char *p, *addr, *mail, *chroot_dir, *home_dir, *full_home_dir; |
8768
91e880ae387a
Authentication: system_user userdb extra field renamed to system_groups_user.
Timo Sirainen <tss@iki.fi>
parents:
8760
diff
changeset
|
580 const char *system_groups_user, *master_user; |
5846
21e529b8a701
Initial implementation for mail_max_user_connections setting.
Timo Sirainen <tss@iki.fi>
parents:
5843
diff
changeset
|
581 struct mail_process_group *process_group; |
2311
4558d1b196fd
Added --exec-mail option to master. It can be used to parse Dovecot config
Timo Sirainen <tss@iki.fi>
parents:
2291
diff
changeset
|
582 char title[1024]; |
4558d1b196fd
Added --exec-mail option to master. It can be used to parse Dovecot config
Timo Sirainen <tss@iki.fi>
parents:
2291
diff
changeset
|
583 struct log_io *log; |
4558d1b196fd
Added --exec-mail option to master. It can be used to parse Dovecot config
Timo Sirainen <tss@iki.fi>
parents:
2291
diff
changeset
|
584 string_t *str; |
4558d1b196fd
Added --exec-mail option to master. It can be used to parse Dovecot config
Timo Sirainen <tss@iki.fi>
parents:
2291
diff
changeset
|
585 pid_t pid; |
2736
0f31778d3c34
Changed dovecot-auth protocol to ASCII based. Should be easier now to write
Timo Sirainen <tss@iki.fi>
parents:
2723
diff
changeset
|
586 uid_t uid; |
0f31778d3c34
Changed dovecot-auth protocol to ASCII based. Should be easier now to write
Timo Sirainen <tss@iki.fi>
parents:
2723
diff
changeset
|
587 gid_t gid; |
4451
1a35d53c18fc
Array API redesigned to work using unions. It now provides type safety
Timo Sirainen <tss@iki.fi>
parents:
4446
diff
changeset
|
588 ARRAY_DEFINE(extra_args, const char *); |
7486
9edaf878bb96
If mail_chroot ends with "/.", remove chroot prefix from home directory.
Timo Sirainen <tss@iki.fi>
parents:
7416
diff
changeset
|
589 unsigned int i, len, count, left, process_count, throttle; |
7561
1a58b18652a6
Avoid using shadow variables. Unfortunately -Wshadow also complains about
Timo Sirainen <tss@iki.fi>
parents:
7486
diff
changeset
|
590 int ret, log_fd, nice_value, chdir_errno; |
4216
9f8493a8cd65
NFS check should be done only once at startup, not every time.
Timo Sirainen <tss@iki.fi>
parents:
4213
diff
changeset
|
591 bool home_given, nfs_check; |
2311
4558d1b196fd
Added --exec-mail option to master. It can be used to parse Dovecot config
Timo Sirainen <tss@iki.fi>
parents:
2291
diff
changeset
|
592 |
5843
f655c4d4a419
Moved child process handling to child-process.[ch]. The hash table now uses
Timo Sirainen <tss@iki.fi>
parents:
5800
diff
changeset
|
593 i_assert(process_type == PROCESS_TYPE_IMAP || |
f655c4d4a419
Moved child process handling to child-process.[ch]. The hash table now uses
Timo Sirainen <tss@iki.fi>
parents:
5800
diff
changeset
|
594 process_type == PROCESS_TYPE_POP3); |
f655c4d4a419
Moved child process handling to child-process.[ch]. The hash table now uses
Timo Sirainen <tss@iki.fi>
parents:
5800
diff
changeset
|
595 |
2311
4558d1b196fd
Added --exec-mail option to master. It can be used to parse Dovecot config
Timo Sirainen <tss@iki.fi>
parents:
2291
diff
changeset
|
596 if (mail_process_count == set->max_mail_processes) { |
8222
1155c1f7fed8
If we reached max_mail_processes limit, mention the setting in the error message.
Timo Sirainen <tss@iki.fi>
parents:
8098
diff
changeset
|
597 i_error("Maximum number of mail processes exceeded " |
1155c1f7fed8
If we reached max_mail_processes limit, mention the setting in the error message.
Timo Sirainen <tss@iki.fi>
parents:
8098
diff
changeset
|
598 "(see max_mail_processes setting)"); |
5846
21e529b8a701
Initial implementation for mail_max_user_connections setting.
Timo Sirainen <tss@iki.fi>
parents:
5843
diff
changeset
|
599 return MASTER_LOGIN_STATUS_INTERNAL_ERROR; |
2311
4558d1b196fd
Added --exec-mail option to master. It can be used to parse Dovecot config
Timo Sirainen <tss@iki.fi>
parents:
2291
diff
changeset
|
600 } |
4558d1b196fd
Added --exec-mail option to master. It can be used to parse Dovecot config
Timo Sirainen <tss@iki.fi>
parents:
2291
diff
changeset
|
601 |
4596
bf4e98a0de3f
Replaced ARRAY_CREATE() macro with [ipt]_array_init() macros. The macro
Timo Sirainen <tss@iki.fi>
parents:
4594
diff
changeset
|
602 t_array_init(&extra_args, 16); |
8768
91e880ae387a
Authentication: system_user userdb extra field renamed to system_groups_user.
Timo Sirainen <tss@iki.fi>
parents:
8760
diff
changeset
|
603 mail = home_dir = chroot_dir = system_groups_user = ""; |
91e880ae387a
Authentication: system_user userdb extra field renamed to system_groups_user.
Timo Sirainen <tss@iki.fi>
parents:
8760
diff
changeset
|
604 master_user = NULL; |
7561
1a58b18652a6
Avoid using shadow variables. Unfortunately -Wshadow also complains about
Timo Sirainen <tss@iki.fi>
parents:
7486
diff
changeset
|
605 uid = (uid_t)-1; gid = (gid_t)-1; nice_value = 0; |
4147
674f328d5fdd
If %h is used but home directory isn't given by userdb, use
Timo Sirainen <tss@iki.fi>
parents:
4074
diff
changeset
|
606 home_given = FALSE; |
2736
0f31778d3c34
Changed dovecot-auth protocol to ASCII based. Should be easier now to write
Timo Sirainen <tss@iki.fi>
parents:
2723
diff
changeset
|
607 for (; *args != NULL; args++) { |
4147
674f328d5fdd
If %h is used but home directory isn't given by userdb, use
Timo Sirainen <tss@iki.fi>
parents:
4074
diff
changeset
|
608 if (strncmp(*args, "home=", 5) == 0) { |
2736
0f31778d3c34
Changed dovecot-auth protocol to ASCII based. Should be easier now to write
Timo Sirainen <tss@iki.fi>
parents:
2723
diff
changeset
|
609 home_dir = *args + 5; |
9217
dd49cf3fd2c9
imap/pop3 logins now fail if home directory path is relative.
Timo Sirainen <tss@iki.fi>
parents:
9216
diff
changeset
|
610 if (*home_dir != '/') { |
dd49cf3fd2c9
imap/pop3 logins now fail if home directory path is relative.
Timo Sirainen <tss@iki.fi>
parents:
9216
diff
changeset
|
611 i_error("Relative home directory paths not " |
dd49cf3fd2c9
imap/pop3 logins now fail if home directory path is relative.
Timo Sirainen <tss@iki.fi>
parents:
9216
diff
changeset
|
612 "supported (user %s): %s", |
dd49cf3fd2c9
imap/pop3 logins now fail if home directory path is relative.
Timo Sirainen <tss@iki.fi>
parents:
9216
diff
changeset
|
613 user, home_dir); |
dd49cf3fd2c9
imap/pop3 logins now fail if home directory path is relative.
Timo Sirainen <tss@iki.fi>
parents:
9216
diff
changeset
|
614 return MASTER_LOGIN_STATUS_INTERNAL_ERROR; |
dd49cf3fd2c9
imap/pop3 logins now fail if home directory path is relative.
Timo Sirainen <tss@iki.fi>
parents:
9216
diff
changeset
|
615 } |
4147
674f328d5fdd
If %h is used but home directory isn't given by userdb, use
Timo Sirainen <tss@iki.fi>
parents:
4074
diff
changeset
|
616 home_given = TRUE; |
674f328d5fdd
If %h is used but home directory isn't given by userdb, use
Timo Sirainen <tss@iki.fi>
parents:
4074
diff
changeset
|
617 } else if (strncmp(*args, "mail=", 5) == 0) |
2736
0f31778d3c34
Changed dovecot-auth protocol to ASCII based. Should be easier now to write
Timo Sirainen <tss@iki.fi>
parents:
2723
diff
changeset
|
618 mail = *args + 5; |
0f31778d3c34
Changed dovecot-auth protocol to ASCII based. Should be easier now to write
Timo Sirainen <tss@iki.fi>
parents:
2723
diff
changeset
|
619 else if (strncmp(*args, "chroot=", 7) == 0) |
0f31778d3c34
Changed dovecot-auth protocol to ASCII based. Should be easier now to write
Timo Sirainen <tss@iki.fi>
parents:
2723
diff
changeset
|
620 chroot_dir = *args + 7; |
3159
852d010a4563
If setpriority() is found, allow userdb set mail processes' priority by
Timo Sirainen <tss@iki.fi>
parents:
3158
diff
changeset
|
621 else if (strncmp(*args, "nice=", 5) == 0) |
7561
1a58b18652a6
Avoid using shadow variables. Unfortunately -Wshadow also complains about
Timo Sirainen <tss@iki.fi>
parents:
7486
diff
changeset
|
622 nice_value = atoi(*args + 5); |
8918
3bf386d860c6
system_user -> system_groups_user change broke it completely.
Timo Sirainen <tss@iki.fi>
parents:
8900
diff
changeset
|
623 else if (strncmp(*args, "system_groups_user=", 19) == 0) |
3bf386d860c6
system_user -> system_groups_user change broke it completely.
Timo Sirainen <tss@iki.fi>
parents:
8900
diff
changeset
|
624 system_groups_user = *args + 19; |
3158
8849f2e380d1
userdb can now return extra parameters to master. Removed special handling
Timo Sirainen <tss@iki.fi>
parents:
3095
diff
changeset
|
625 else if (strncmp(*args, "uid=", 4) == 0) { |
5876
933caa747d37
Added mail_uid and mail_gid settings.
Timo Sirainen <tss@iki.fi>
parents:
5871
diff
changeset
|
626 if (uid != (uid_t)-1) { |
3158
8849f2e380d1
userdb can now return extra parameters to master. Removed special handling
Timo Sirainen <tss@iki.fi>
parents:
3095
diff
changeset
|
627 i_error("uid specified multiple times for %s", |
8849f2e380d1
userdb can now return extra parameters to master. Removed special handling
Timo Sirainen <tss@iki.fi>
parents:
3095
diff
changeset
|
628 user); |
5846
21e529b8a701
Initial implementation for mail_max_user_connections setting.
Timo Sirainen <tss@iki.fi>
parents:
5843
diff
changeset
|
629 return MASTER_LOGIN_STATUS_INTERNAL_ERROR; |
3158
8849f2e380d1
userdb can now return extra parameters to master. Removed special handling
Timo Sirainen <tss@iki.fi>
parents:
3095
diff
changeset
|
630 } |
2736
0f31778d3c34
Changed dovecot-auth protocol to ASCII based. Should be easier now to write
Timo Sirainen <tss@iki.fi>
parents:
2723
diff
changeset
|
631 uid = (uid_t)strtoul(*args + 4, NULL, 10); |
8098
8f0111854933
Don't apply mail_max_userip_connections limit to master user logins.
Timo Sirainen <tss@iki.fi>
parents:
8092
diff
changeset
|
632 } else if (strncmp(*args, "gid=", 4) == 0) { |
2736
0f31778d3c34
Changed dovecot-auth protocol to ASCII based. Should be easier now to write
Timo Sirainen <tss@iki.fi>
parents:
2723
diff
changeset
|
633 gid = (gid_t)strtoul(*args + 4, NULL, 10); |
8098
8f0111854933
Don't apply mail_max_userip_connections limit to master user logins.
Timo Sirainen <tss@iki.fi>
parents:
8092
diff
changeset
|
634 } else if (strncmp(*args, "master_user=", 12) == 0) { |
8f0111854933
Don't apply mail_max_userip_connections limit to master user logins.
Timo Sirainen <tss@iki.fi>
parents:
8092
diff
changeset
|
635 const char *arg = *args; |
8f0111854933
Don't apply mail_max_userip_connections limit to master user logins.
Timo Sirainen <tss@iki.fi>
parents:
8092
diff
changeset
|
636 |
8f0111854933
Don't apply mail_max_userip_connections limit to master user logins.
Timo Sirainen <tss@iki.fi>
parents:
8092
diff
changeset
|
637 master_user = arg + 12; |
8f0111854933
Don't apply mail_max_userip_connections limit to master user logins.
Timo Sirainen <tss@iki.fi>
parents:
8092
diff
changeset
|
638 array_append(&extra_args, &arg, 1); |
8f0111854933
Don't apply mail_max_userip_connections limit to master user logins.
Timo Sirainen <tss@iki.fi>
parents:
8092
diff
changeset
|
639 } else { |
3287
47437871d879
Send all unrecognized parameters from userdb to imap/pop3 processes. Useful
Timo Sirainen <tss@iki.fi>
parents:
3159
diff
changeset
|
640 const char *arg = *args; |
47437871d879
Send all unrecognized parameters from userdb to imap/pop3 processes. Useful
Timo Sirainen <tss@iki.fi>
parents:
3159
diff
changeset
|
641 array_append(&extra_args, &arg, 1); |
47437871d879
Send all unrecognized parameters from userdb to imap/pop3 processes. Useful
Timo Sirainen <tss@iki.fi>
parents:
3159
diff
changeset
|
642 } |
2736
0f31778d3c34
Changed dovecot-auth protocol to ASCII based. Should be easier now to write
Timo Sirainen <tss@iki.fi>
parents:
2723
diff
changeset
|
643 } |
2311
4558d1b196fd
Added --exec-mail option to master. It can be used to parse Dovecot config
Timo Sirainen <tss@iki.fi>
parents:
2291
diff
changeset
|
644 |
8098
8f0111854933
Don't apply mail_max_userip_connections limit to master user logins.
Timo Sirainen <tss@iki.fi>
parents:
8092
diff
changeset
|
645 /* check process limit for this user, but not if this is a master |
8f0111854933
Don't apply mail_max_userip_connections limit to master user logins.
Timo Sirainen <tss@iki.fi>
parents:
8092
diff
changeset
|
646 user login. */ |
8f0111854933
Don't apply mail_max_userip_connections limit to master user logins.
Timo Sirainen <tss@iki.fi>
parents:
8092
diff
changeset
|
647 process_group = dump_capability ? NULL : |
8f0111854933
Don't apply mail_max_userip_connections limit to master user logins.
Timo Sirainen <tss@iki.fi>
parents:
8092
diff
changeset
|
648 mail_process_group_lookup(process_type, user, |
8f0111854933
Don't apply mail_max_userip_connections limit to master user logins.
Timo Sirainen <tss@iki.fi>
parents:
8092
diff
changeset
|
649 &request->remote_ip); |
8f0111854933
Don't apply mail_max_userip_connections limit to master user logins.
Timo Sirainen <tss@iki.fi>
parents:
8092
diff
changeset
|
650 process_count = process_group == NULL ? 0 : |
8f0111854933
Don't apply mail_max_userip_connections limit to master user logins.
Timo Sirainen <tss@iki.fi>
parents:
8092
diff
changeset
|
651 array_count(&process_group->processes); |
8f0111854933
Don't apply mail_max_userip_connections limit to master user logins.
Timo Sirainen <tss@iki.fi>
parents:
8092
diff
changeset
|
652 if (process_count >= set->mail_max_userip_connections && |
8f0111854933
Don't apply mail_max_userip_connections limit to master user logins.
Timo Sirainen <tss@iki.fi>
parents:
8092
diff
changeset
|
653 set->mail_max_userip_connections != 0 && |
8f0111854933
Don't apply mail_max_userip_connections limit to master user logins.
Timo Sirainen <tss@iki.fi>
parents:
8092
diff
changeset
|
654 master_user == NULL) |
8f0111854933
Don't apply mail_max_userip_connections limit to master user logins.
Timo Sirainen <tss@iki.fi>
parents:
8092
diff
changeset
|
655 return MASTER_LOGIN_STATUS_MAX_CONNECTIONS; |
8f0111854933
Don't apply mail_max_userip_connections limit to master user logins.
Timo Sirainen <tss@iki.fi>
parents:
8092
diff
changeset
|
656 |
5876
933caa747d37
Added mail_uid and mail_gid settings.
Timo Sirainen <tss@iki.fi>
parents:
5871
diff
changeset
|
657 /* if uid/gid wasn't returned, use the defaults */ |
933caa747d37
Added mail_uid and mail_gid settings.
Timo Sirainen <tss@iki.fi>
parents:
5871
diff
changeset
|
658 if (uid == (uid_t)-1) { |
933caa747d37
Added mail_uid and mail_gid settings.
Timo Sirainen <tss@iki.fi>
parents:
5871
diff
changeset
|
659 uid = set->mail_uid_t; |
933caa747d37
Added mail_uid and mail_gid settings.
Timo Sirainen <tss@iki.fi>
parents:
5871
diff
changeset
|
660 if (uid == (uid_t)-1) { |
8520 | 661 i_error("User %s is missing UID (see mail_uid setting)", |
662 user); | |
5876
933caa747d37
Added mail_uid and mail_gid settings.
Timo Sirainen <tss@iki.fi>
parents:
5871
diff
changeset
|
663 return MASTER_LOGIN_STATUS_INTERNAL_ERROR; |
933caa747d37
Added mail_uid and mail_gid settings.
Timo Sirainen <tss@iki.fi>
parents:
5871
diff
changeset
|
664 } |
933caa747d37
Added mail_uid and mail_gid settings.
Timo Sirainen <tss@iki.fi>
parents:
5871
diff
changeset
|
665 } |
933caa747d37
Added mail_uid and mail_gid settings.
Timo Sirainen <tss@iki.fi>
parents:
5871
diff
changeset
|
666 if (gid == (gid_t)-1) { |
933caa747d37
Added mail_uid and mail_gid settings.
Timo Sirainen <tss@iki.fi>
parents:
5871
diff
changeset
|
667 gid = set->mail_gid_t; |
933caa747d37
Added mail_uid and mail_gid settings.
Timo Sirainen <tss@iki.fi>
parents:
5871
diff
changeset
|
668 if (gid == (gid_t)-1) { |
8520 | 669 i_error("User %s is missing GID (see mail_gid setting)", |
670 user); | |
5876
933caa747d37
Added mail_uid and mail_gid settings.
Timo Sirainen <tss@iki.fi>
parents:
5871
diff
changeset
|
671 return MASTER_LOGIN_STATUS_INTERNAL_ERROR; |
933caa747d37
Added mail_uid and mail_gid settings.
Timo Sirainen <tss@iki.fi>
parents:
5871
diff
changeset
|
672 } |
933caa747d37
Added mail_uid and mail_gid settings.
Timo Sirainen <tss@iki.fi>
parents:
5871
diff
changeset
|
673 } |
933caa747d37
Added mail_uid and mail_gid settings.
Timo Sirainen <tss@iki.fi>
parents:
5871
diff
changeset
|
674 |
7247
17c65dfdac2a
Check for "/./" chrooting in home dirs only if valid_chroot_dirs isn't empty.
Timo Sirainen <tss@iki.fi>
parents:
7109
diff
changeset
|
675 if (*chroot_dir == '\0' && *set->valid_chroot_dirs != '\0' && |
17c65dfdac2a
Check for "/./" chrooting in home dirs only if valid_chroot_dirs isn't empty.
Timo Sirainen <tss@iki.fi>
parents:
7109
diff
changeset
|
676 (p = strstr(home_dir, "/./")) != NULL) { |
17c65dfdac2a
Check for "/./" chrooting in home dirs only if valid_chroot_dirs isn't empty.
Timo Sirainen <tss@iki.fi>
parents:
7109
diff
changeset
|
677 /* wu-ftpd like <chroot>/./<home> - check only if there's even |
17c65dfdac2a
Check for "/./" chrooting in home dirs only if valid_chroot_dirs isn't empty.
Timo Sirainen <tss@iki.fi>
parents:
7109
diff
changeset
|
678 a possibility of using them (non-empty valid_chroot_dirs)*/ |
3158
8849f2e380d1
userdb can now return extra parameters to master. Removed special handling
Timo Sirainen <tss@iki.fi>
parents:
3095
diff
changeset
|
679 chroot_dir = t_strdup_until(home_dir, p); |
5446
ce1e1fab1e1d
When using chrooting, force the home directory to have '/' prefix so it's
Timo Sirainen <tss@iki.fi>
parents:
5386
diff
changeset
|
680 home_dir = p + 2; |
3158
8849f2e380d1
userdb can now return extra parameters to master. Removed special handling
Timo Sirainen <tss@iki.fi>
parents:
3095
diff
changeset
|
681 } |
8849f2e380d1
userdb can now return extra parameters to master. Removed special handling
Timo Sirainen <tss@iki.fi>
parents:
3095
diff
changeset
|
682 |
4229
58d4413314a4
Don't validate uid/gid when executing imap for dump-capability
Timo Sirainen <tss@iki.fi>
parents:
4217
diff
changeset
|
683 if (!dump_capability) { |
58d4413314a4
Don't validate uid/gid when executing imap for dump-capability
Timo Sirainen <tss@iki.fi>
parents:
4217
diff
changeset
|
684 if (!validate_uid_gid(set, uid, gid, user)) |
5846
21e529b8a701
Initial implementation for mail_max_user_connections setting.
Timo Sirainen <tss@iki.fi>
parents:
5843
diff
changeset
|
685 return MASTER_LOGIN_STATUS_INTERNAL_ERROR; |
4229
58d4413314a4
Don't validate uid/gid when executing imap for dump-capability
Timo Sirainen <tss@iki.fi>
parents:
4217
diff
changeset
|
686 } |
2311
4558d1b196fd
Added --exec-mail option to master. It can be used to parse Dovecot config
Timo Sirainen <tss@iki.fi>
parents:
2291
diff
changeset
|
687 |
4541
61990aea02bc
Run imap dump-capability process only after all the settings have been
Timo Sirainen <tss@iki.fi>
parents:
4459
diff
changeset
|
688 if (*chroot_dir != '\0') { |
61990aea02bc
Run imap dump-capability process only after all the settings have been
Timo Sirainen <tss@iki.fi>
parents:
4459
diff
changeset
|
689 if (!validate_chroot(set, chroot_dir)) { |
61990aea02bc
Run imap dump-capability process only after all the settings have been
Timo Sirainen <tss@iki.fi>
parents:
4459
diff
changeset
|
690 i_error("Invalid chroot directory '%s' (user %s) " |
8520 | 691 "(see valid_chroot_dirs setting)", |
4541
61990aea02bc
Run imap dump-capability process only after all the settings have been
Timo Sirainen <tss@iki.fi>
parents:
4459
diff
changeset
|
692 chroot_dir, user); |
5846
21e529b8a701
Initial implementation for mail_max_user_connections setting.
Timo Sirainen <tss@iki.fi>
parents:
5843
diff
changeset
|
693 return MASTER_LOGIN_STATUS_INTERNAL_ERROR; |
4541
61990aea02bc
Run imap dump-capability process only after all the settings have been
Timo Sirainen <tss@iki.fi>
parents:
4459
diff
changeset
|
694 } |
7257
1f982f1201ef
mail_chroot no longer needs to be in valid_chroot_dirs.
Timo Sirainen <tss@iki.fi>
parents:
7247
diff
changeset
|
695 } else if (*set->mail_chroot != '\0') { |
1f982f1201ef
mail_chroot no longer needs to be in valid_chroot_dirs.
Timo Sirainen <tss@iki.fi>
parents:
7247
diff
changeset
|
696 /* mail_chroot setting's value doesn't need to be in |
1f982f1201ef
mail_chroot no longer needs to be in valid_chroot_dirs.
Timo Sirainen <tss@iki.fi>
parents:
7247
diff
changeset
|
697 valid_chroot_dirs. */ |
1f982f1201ef
mail_chroot no longer needs to be in valid_chroot_dirs.
Timo Sirainen <tss@iki.fi>
parents:
7247
diff
changeset
|
698 chroot_dir = set->mail_chroot; |
2311
4558d1b196fd
Added --exec-mail option to master. It can be used to parse Dovecot config
Timo Sirainen <tss@iki.fi>
parents:
2291
diff
changeset
|
699 } |
7258
de96d58b6ee2
Last commit broke mail_drop_priv_before_exec/mail_chroot conflict check.
Timo Sirainen <tss@iki.fi>
parents:
7257
diff
changeset
|
700 if (*chroot_dir != '\0' && set->mail_drop_priv_before_exec) { |
de96d58b6ee2
Last commit broke mail_drop_priv_before_exec/mail_chroot conflict check.
Timo Sirainen <tss@iki.fi>
parents:
7257
diff
changeset
|
701 i_error("Can't chroot to directory '%s' (user %s) " |
de96d58b6ee2
Last commit broke mail_drop_priv_before_exec/mail_chroot conflict check.
Timo Sirainen <tss@iki.fi>
parents:
7257
diff
changeset
|
702 "with mail_drop_priv_before_exec=yes", |
de96d58b6ee2
Last commit broke mail_drop_priv_before_exec/mail_chroot conflict check.
Timo Sirainen <tss@iki.fi>
parents:
7257
diff
changeset
|
703 chroot_dir, user); |
de96d58b6ee2
Last commit broke mail_drop_priv_before_exec/mail_chroot conflict check.
Timo Sirainen <tss@iki.fi>
parents:
7257
diff
changeset
|
704 return MASTER_LOGIN_STATUS_INTERNAL_ERROR; |
de96d58b6ee2
Last commit broke mail_drop_priv_before_exec/mail_chroot conflict check.
Timo Sirainen <tss@iki.fi>
parents:
7257
diff
changeset
|
705 } |
7486
9edaf878bb96
If mail_chroot ends with "/.", remove chroot prefix from home directory.
Timo Sirainen <tss@iki.fi>
parents:
7416
diff
changeset
|
706 len = strlen(chroot_dir); |
9edaf878bb96
If mail_chroot ends with "/.", remove chroot prefix from home directory.
Timo Sirainen <tss@iki.fi>
parents:
7416
diff
changeset
|
707 if (len > 2 && strcmp(chroot_dir + len - 2, "/.") == 0 && |
9edaf878bb96
If mail_chroot ends with "/.", remove chroot prefix from home directory.
Timo Sirainen <tss@iki.fi>
parents:
7416
diff
changeset
|
708 strncmp(home_dir, chroot_dir, len - 2) == 0) { |
9edaf878bb96
If mail_chroot ends with "/.", remove chroot prefix from home directory.
Timo Sirainen <tss@iki.fi>
parents:
7416
diff
changeset
|
709 /* strip chroot dir from home dir */ |
9edaf878bb96
If mail_chroot ends with "/.", remove chroot prefix from home directory.
Timo Sirainen <tss@iki.fi>
parents:
7416
diff
changeset
|
710 home_dir += len - 2; |
9edaf878bb96
If mail_chroot ends with "/.", remove chroot prefix from home directory.
Timo Sirainen <tss@iki.fi>
parents:
7416
diff
changeset
|
711 } |
2311
4558d1b196fd
Added --exec-mail option to master. It can be used to parse Dovecot config
Timo Sirainen <tss@iki.fi>
parents:
2291
diff
changeset
|
712 |
4568
7661242c3bb6
Check log_creaate_pipe() and dup() return values and handle failures.
Timo Sirainen <tss@iki.fi>
parents:
4541
diff
changeset
|
713 if (!dump_capability) { |
7416
4c093cfa8756
Disable log throttling while mail_debug=yes
Timo Sirainen <tss@iki.fi>
parents:
7354
diff
changeset
|
714 throttle = set->mail_debug ? 0 : |
4c093cfa8756
Disable log throttling while mail_debug=yes
Timo Sirainen <tss@iki.fi>
parents:
7354
diff
changeset
|
715 set->mail_log_max_lines_per_sec; |
4c093cfa8756
Disable log throttling while mail_debug=yes
Timo Sirainen <tss@iki.fi>
parents:
7354
diff
changeset
|
716 log_fd = log_create_pipe(&log, throttle); |
4568
7661242c3bb6
Check log_creaate_pipe() and dup() return values and handle failures.
Timo Sirainen <tss@iki.fi>
parents:
4541
diff
changeset
|
717 if (log_fd == -1) |
5846
21e529b8a701
Initial implementation for mail_max_user_connections setting.
Timo Sirainen <tss@iki.fi>
parents:
5843
diff
changeset
|
718 return MASTER_LOGIN_STATUS_INTERNAL_ERROR; |
4568
7661242c3bb6
Check log_creaate_pipe() and dup() return values and handle failures.
Timo Sirainen <tss@iki.fi>
parents:
4541
diff
changeset
|
719 } else { |
4197
c3ded5b815aa
If we have plugins set and imap_capability unset, figure out the IMAP
Timo Sirainen <tss@iki.fi>
parents:
4190
diff
changeset
|
720 log = NULL; |
c3ded5b815aa
If we have plugins set and imap_capability unset, figure out the IMAP
Timo Sirainen <tss@iki.fi>
parents:
4190
diff
changeset
|
721 log_fd = dup(STDERR_FILENO); |
4568
7661242c3bb6
Check log_creaate_pipe() and dup() return values and handle failures.
Timo Sirainen <tss@iki.fi>
parents:
4541
diff
changeset
|
722 if (log_fd == -1) { |
7661242c3bb6
Check log_creaate_pipe() and dup() return values and handle failures.
Timo Sirainen <tss@iki.fi>
parents:
4541
diff
changeset
|
723 i_error("dup() failed: %m"); |
5846
21e529b8a701
Initial implementation for mail_max_user_connections setting.
Timo Sirainen <tss@iki.fi>
parents:
5843
diff
changeset
|
724 return MASTER_LOGIN_STATUS_INTERNAL_ERROR; |
4568
7661242c3bb6
Check log_creaate_pipe() and dup() return values and handle failures.
Timo Sirainen <tss@iki.fi>
parents:
4541
diff
changeset
|
725 } |
4197
c3ded5b815aa
If we have plugins set and imap_capability unset, figure out the IMAP
Timo Sirainen <tss@iki.fi>
parents:
4190
diff
changeset
|
726 fd_close_on_exec(log_fd, TRUE); |
c3ded5b815aa
If we have plugins set and imap_capability unset, figure out the IMAP
Timo Sirainen <tss@iki.fi>
parents:
4190
diff
changeset
|
727 } |
2311
4558d1b196fd
Added --exec-mail option to master. It can be used to parse Dovecot config
Timo Sirainen <tss@iki.fi>
parents:
2291
diff
changeset
|
728 |
4216
9f8493a8cd65
NFS check should be done only once at startup, not every time.
Timo Sirainen <tss@iki.fi>
parents:
4213
diff
changeset
|
729 /* See if we need to do the initial NFS check. We want to do this only |
9f8493a8cd65
NFS check should be done only once at startup, not every time.
Timo Sirainen <tss@iki.fi>
parents:
4213
diff
changeset
|
730 once, so the check code needs to be before fork(). */ |
7354
de47a37ca0c1
NFS checking checks now mail_nfs_index=yes instead of mmap_disable=yes.
Timo Sirainen <tss@iki.fi>
parents:
7341
diff
changeset
|
731 if (set->nfs_check && !set->mail_nfs_index && !dump_capability) { |
4216
9f8493a8cd65
NFS check should be done only once at startup, not every time.
Timo Sirainen <tss@iki.fi>
parents:
4213
diff
changeset
|
732 set->nfs_check = FALSE; |
9f8493a8cd65
NFS check should be done only once at startup, not every time.
Timo Sirainen <tss@iki.fi>
parents:
4213
diff
changeset
|
733 nfs_check = TRUE; |
9f8493a8cd65
NFS check should be done only once at startup, not every time.
Timo Sirainen <tss@iki.fi>
parents:
4213
diff
changeset
|
734 } else { |
9f8493a8cd65
NFS check should be done only once at startup, not every time.
Timo Sirainen <tss@iki.fi>
parents:
4213
diff
changeset
|
735 nfs_check = FALSE; |
9f8493a8cd65
NFS check should be done only once at startup, not every time.
Timo Sirainen <tss@iki.fi>
parents:
4213
diff
changeset
|
736 } |
9f8493a8cd65
NFS check should be done only once at startup, not every time.
Timo Sirainen <tss@iki.fi>
parents:
4213
diff
changeset
|
737 |
2311
4558d1b196fd
Added --exec-mail option to master. It can be used to parse Dovecot config
Timo Sirainen <tss@iki.fi>
parents:
2291
diff
changeset
|
738 pid = fork(); |
4558d1b196fd
Added --exec-mail option to master. It can be used to parse Dovecot config
Timo Sirainen <tss@iki.fi>
parents:
2291
diff
changeset
|
739 if (pid < 0) { |
4558d1b196fd
Added --exec-mail option to master. It can be used to parse Dovecot config
Timo Sirainen <tss@iki.fi>
parents:
2291
diff
changeset
|
740 i_error("fork() failed: %m"); |
4558d1b196fd
Added --exec-mail option to master. It can be used to parse Dovecot config
Timo Sirainen <tss@iki.fi>
parents:
2291
diff
changeset
|
741 (void)close(log_fd); |
5846
21e529b8a701
Initial implementation for mail_max_user_connections setting.
Timo Sirainen <tss@iki.fi>
parents:
5843
diff
changeset
|
742 return MASTER_LOGIN_STATUS_INTERNAL_ERROR; |
2311
4558d1b196fd
Added --exec-mail option to master. It can be used to parse Dovecot config
Timo Sirainen <tss@iki.fi>
parents:
2291
diff
changeset
|
743 } |
4558d1b196fd
Added --exec-mail option to master. It can be used to parse Dovecot config
Timo Sirainen <tss@iki.fi>
parents:
2291
diff
changeset
|
744 |
4558d1b196fd
Added --exec-mail option to master. It can be used to parse Dovecot config
Timo Sirainen <tss@iki.fi>
parents:
2291
diff
changeset
|
745 var_expand_table = |
4197
c3ded5b815aa
If we have plugins set and imap_capability unset, figure out the IMAP
Timo Sirainen <tss@iki.fi>
parents:
4190
diff
changeset
|
746 get_var_expand_table(process_names[process_type], |
4147
674f328d5fdd
If %h is used but home directory isn't given by userdb, use
Timo Sirainen <tss@iki.fi>
parents:
4074
diff
changeset
|
747 user, home_given ? home_dir : NULL, |
7928
9e226056a208
Send login command OK reply in IMAP/POP3 process.
Timo Sirainen <tss@iki.fi>
parents:
7927
diff
changeset
|
748 net_ip2addr(&request->local_ip), |
9e226056a208
Send login command OK reply in IMAP/POP3 process.
Timo Sirainen <tss@iki.fi>
parents:
7927
diff
changeset
|
749 net_ip2addr(&request->remote_ip), |
3690 | 750 pid != 0 ? pid : getpid(), uid); |
2311
4558d1b196fd
Added --exec-mail option to master. It can be used to parse Dovecot config
Timo Sirainen <tss@iki.fi>
parents:
2291
diff
changeset
|
751 str = t_str_new(128); |
4558d1b196fd
Added --exec-mail option to master. It can be used to parse Dovecot config
Timo Sirainen <tss@iki.fi>
parents:
2291
diff
changeset
|
752 |
4558d1b196fd
Added --exec-mail option to master. It can be used to parse Dovecot config
Timo Sirainen <tss@iki.fi>
parents:
2291
diff
changeset
|
753 if (pid != 0) { |
4558d1b196fd
Added --exec-mail option to master. It can be used to parse Dovecot config
Timo Sirainen <tss@iki.fi>
parents:
2291
diff
changeset
|
754 /* master */ |
4558d1b196fd
Added --exec-mail option to master. It can be used to parse Dovecot config
Timo Sirainen <tss@iki.fi>
parents:
2291
diff
changeset
|
755 var_expand(str, set->mail_log_prefix, var_expand_table); |
4558d1b196fd
Added --exec-mail option to master. It can be used to parse Dovecot config
Timo Sirainen <tss@iki.fi>
parents:
2291
diff
changeset
|
756 |
5871
4cf56bf92215
Fixed dump-capability crash at startup
Timo Sirainen <tss@iki.fi>
parents:
5857
diff
changeset
|
757 if (!dump_capability) { |
4197
c3ded5b815aa
If we have plugins set and imap_capability unset, figure out the IMAP
Timo Sirainen <tss@iki.fi>
parents:
4190
diff
changeset
|
758 log_set_prefix(log, str_c(str)); |
6542
402d14b5ef8b
If child process logged a fatal failure, don't show "returned error 89"
Timo Sirainen <tss@iki.fi>
parents:
6429
diff
changeset
|
759 log_set_pid(log, pid); |
5871
4cf56bf92215
Fixed dump-capability crash at startup
Timo Sirainen <tss@iki.fi>
parents:
5857
diff
changeset
|
760 if (process_group == NULL) { |
7928
9e226056a208
Send login command OK reply in IMAP/POP3 process.
Timo Sirainen <tss@iki.fi>
parents:
7927
diff
changeset
|
761 process_group = mail_process_group_create( |
9e226056a208
Send login command OK reply in IMAP/POP3 process.
Timo Sirainen <tss@iki.fi>
parents:
7927
diff
changeset
|
762 process_type, user, |
9e226056a208
Send login command OK reply in IMAP/POP3 process.
Timo Sirainen <tss@iki.fi>
parents:
7927
diff
changeset
|
763 &request->remote_ip); |
5871
4cf56bf92215
Fixed dump-capability crash at startup
Timo Sirainen <tss@iki.fi>
parents:
5857
diff
changeset
|
764 } |
4cf56bf92215
Fixed dump-capability crash at startup
Timo Sirainen <tss@iki.fi>
parents:
5857
diff
changeset
|
765 mail_process_group_add(process_group, pid); |
4197
c3ded5b815aa
If we have plugins set and imap_capability unset, figure out the IMAP
Timo Sirainen <tss@iki.fi>
parents:
4190
diff
changeset
|
766 } |
2311
4558d1b196fd
Added --exec-mail option to master. It can be used to parse Dovecot config
Timo Sirainen <tss@iki.fi>
parents:
2291
diff
changeset
|
767 (void)close(log_fd); |
8092
29b623366e1e
Pass the created mail process PID back to login process so it can log it.
Timo Sirainen <tss@iki.fi>
parents:
7943
diff
changeset
|
768 *pid_r = pid; |
5846
21e529b8a701
Initial implementation for mail_max_user_connections setting.
Timo Sirainen <tss@iki.fi>
parents:
5843
diff
changeset
|
769 return MASTER_LOGIN_STATUS_OK; |
2311
4558d1b196fd
Added --exec-mail option to master. It can be used to parse Dovecot config
Timo Sirainen <tss@iki.fi>
parents:
2291
diff
changeset
|
770 } |
4558d1b196fd
Added --exec-mail option to master. It can be used to parse Dovecot config
Timo Sirainen <tss@iki.fi>
parents:
2291
diff
changeset
|
771 |
3159
852d010a4563
If setpriority() is found, allow userdb set mail processes' priority by
Timo Sirainen <tss@iki.fi>
parents:
3158
diff
changeset
|
772 #ifdef HAVE_SETPRIORITY |
7561
1a58b18652a6
Avoid using shadow variables. Unfortunately -Wshadow also complains about
Timo Sirainen <tss@iki.fi>
parents:
7486
diff
changeset
|
773 if (nice_value != 0) { |
1a58b18652a6
Avoid using shadow variables. Unfortunately -Wshadow also complains about
Timo Sirainen <tss@iki.fi>
parents:
7486
diff
changeset
|
774 if (setpriority(PRIO_PROCESS, 0, nice_value) < 0) |
1a58b18652a6
Avoid using shadow variables. Unfortunately -Wshadow also complains about
Timo Sirainen <tss@iki.fi>
parents:
7486
diff
changeset
|
775 i_error("setpriority(%d) failed: %m", nice_value); |
3159
852d010a4563
If setpriority() is found, allow userdb set mail processes' priority by
Timo Sirainen <tss@iki.fi>
parents:
3158
diff
changeset
|
776 } |
852d010a4563
If setpriority() is found, allow userdb set mail processes' priority by
Timo Sirainen <tss@iki.fi>
parents:
3158
diff
changeset
|
777 #endif |
852d010a4563
If setpriority() is found, allow userdb set mail processes' priority by
Timo Sirainen <tss@iki.fi>
parents:
3158
diff
changeset
|
778 |
4197
c3ded5b815aa
If we have plugins set and imap_capability unset, figure out the IMAP
Timo Sirainen <tss@iki.fi>
parents:
4190
diff
changeset
|
779 if (!dump_capability) { |
c3ded5b815aa
If we have plugins set and imap_capability unset, figure out the IMAP
Timo Sirainen <tss@iki.fi>
parents:
4190
diff
changeset
|
780 str_append(str, "master-"); |
c3ded5b815aa
If we have plugins set and imap_capability unset, figure out the IMAP
Timo Sirainen <tss@iki.fi>
parents:
4190
diff
changeset
|
781 var_expand(str, set->mail_log_prefix, var_expand_table); |
c3ded5b815aa
If we have plugins set and imap_capability unset, figure out the IMAP
Timo Sirainen <tss@iki.fi>
parents:
4190
diff
changeset
|
782 log_set_prefix(log, str_c(str)); |
c3ded5b815aa
If we have plugins set and imap_capability unset, figure out the IMAP
Timo Sirainen <tss@iki.fi>
parents:
4190
diff
changeset
|
783 } |
2311
4558d1b196fd
Added --exec-mail option to master. It can be used to parse Dovecot config
Timo Sirainen <tss@iki.fi>
parents:
2291
diff
changeset
|
784 |
7109
e6823d781317
Reverted "environment array" changes. It broke overriding imap/pop3 settings
Timo Sirainen <tss@iki.fi>
parents:
7092
diff
changeset
|
785 child_process_init_env(); |
2311
4558d1b196fd
Added --exec-mail option to master. It can be used to parse Dovecot config
Timo Sirainen <tss@iki.fi>
parents:
2291
diff
changeset
|
786 |
4558d1b196fd
Added --exec-mail option to master. It can be used to parse Dovecot config
Timo Sirainen <tss@iki.fi>
parents:
2291
diff
changeset
|
787 /* setup environment - set the most important environment first |
4558d1b196fd
Added --exec-mail option to master. It can be used to parse Dovecot config
Timo Sirainen <tss@iki.fi>
parents:
2291
diff
changeset
|
788 (paranoia about filling up environment without noticing) */ |
8768
91e880ae387a
Authentication: system_user userdb extra field renamed to system_groups_user.
Timo Sirainen <tss@iki.fi>
parents:
8760
diff
changeset
|
789 restrict_access_set_env(system_groups_user, uid, gid, |
91e880ae387a
Authentication: system_user userdb extra field renamed to system_groups_user.
Timo Sirainen <tss@iki.fi>
parents:
8760
diff
changeset
|
790 set->mail_priv_gid_t, |
8707
af3fa3dd0d31
If mail_chroot is set, don't fail at startup in dump-capability.
Timo Sirainen <tss@iki.fi>
parents:
8590
diff
changeset
|
791 dump_capability ? "" : chroot_dir, |
2311
4558d1b196fd
Added --exec-mail option to master. It can be used to parse Dovecot config
Timo Sirainen <tss@iki.fi>
parents:
2291
diff
changeset
|
792 set->first_valid_gid, set->last_valid_gid, |
7341
af998ae4254b
Replaced mail_extra_groups setting with mail_privileged_group and
Timo Sirainen <tss@iki.fi>
parents:
7334
diff
changeset
|
793 set->mail_access_groups); |
2311
4558d1b196fd
Added --exec-mail option to master. It can be used to parse Dovecot config
Timo Sirainen <tss@iki.fi>
parents:
2291
diff
changeset
|
794 |
4558d1b196fd
Added --exec-mail option to master. It can be used to parse Dovecot config
Timo Sirainen <tss@iki.fi>
parents:
2291
diff
changeset
|
795 restrict_process_size(set->mail_process_size, (unsigned int)-1); |
4558d1b196fd
Added --exec-mail option to master. It can be used to parse Dovecot config
Timo Sirainen <tss@iki.fi>
parents:
2291
diff
changeset
|
796 |
4197
c3ded5b815aa
If we have plugins set and imap_capability unset, figure out the IMAP
Timo Sirainen <tss@iki.fi>
parents:
4190
diff
changeset
|
797 if (dump_capability) |
7109
e6823d781317
Reverted "environment array" changes. It broke overriding imap/pop3 settings
Timo Sirainen <tss@iki.fi>
parents:
7092
diff
changeset
|
798 env_put("DUMP_CAPABILITY=1"); |
4197
c3ded5b815aa
If we have plugins set and imap_capability unset, figure out the IMAP
Timo Sirainen <tss@iki.fi>
parents:
4190
diff
changeset
|
799 |
8707
af3fa3dd0d31
If mail_chroot is set, don't fail at startup in dump-capability.
Timo Sirainen <tss@iki.fi>
parents:
8590
diff
changeset
|
800 if ((*home_dir == '\0' && *chroot_dir == '\0') || dump_capability) { |
5372
56cb17817e06
NFS check + chroots broke home directory for the first login.
Timo Sirainen <tss@iki.fi>
parents:
5333
diff
changeset
|
801 full_home_dir = ""; |
2311
4558d1b196fd
Added --exec-mail option to master. It can be used to parse Dovecot config
Timo Sirainen <tss@iki.fi>
parents:
2291
diff
changeset
|
802 ret = -1; |
5372
56cb17817e06
NFS check + chroots broke home directory for the first login.
Timo Sirainen <tss@iki.fi>
parents:
5333
diff
changeset
|
803 } else { |
2311
4558d1b196fd
Added --exec-mail option to master. It can be used to parse Dovecot config
Timo Sirainen <tss@iki.fi>
parents:
2291
diff
changeset
|
804 full_home_dir = *chroot_dir == '\0' ? home_dir : |
5446
ce1e1fab1e1d
When using chrooting, force the home directory to have '/' prefix so it's
Timo Sirainen <tss@iki.fi>
parents:
5386
diff
changeset
|
805 t_strconcat(chroot_dir, home_dir, NULL); |
2311
4558d1b196fd
Added --exec-mail option to master. It can be used to parse Dovecot config
Timo Sirainen <tss@iki.fi>
parents:
2291
diff
changeset
|
806 /* NOTE: if home directory is NFS-mounted, we might not |
3095
8f254acc036c
Change effective GID as well before trying chdir() to mail directory.
Timo Sirainen <tss@iki.fi>
parents:
3083
diff
changeset
|
807 have access to it as root. Change the effective UID and GID |
2311
4558d1b196fd
Added --exec-mail option to master. It can be used to parse Dovecot config
Timo Sirainen <tss@iki.fi>
parents:
2291
diff
changeset
|
808 temporarily to make it work. */ |
3095
8f254acc036c
Change effective GID as well before trying chdir() to mail directory.
Timo Sirainen <tss@iki.fi>
parents:
3083
diff
changeset
|
809 if (uid != master_uid) { |
8f254acc036c
Change effective GID as well before trying chdir() to mail directory.
Timo Sirainen <tss@iki.fi>
parents:
3083
diff
changeset
|
810 if (setegid(gid) < 0) |
8f254acc036c
Change effective GID as well before trying chdir() to mail directory.
Timo Sirainen <tss@iki.fi>
parents:
3083
diff
changeset
|
811 i_fatal("setegid(%s) failed: %m", dec2str(gid)); |
8f254acc036c
Change effective GID as well before trying chdir() to mail directory.
Timo Sirainen <tss@iki.fi>
parents:
3083
diff
changeset
|
812 if (seteuid(uid) < 0) |
8f254acc036c
Change effective GID as well before trying chdir() to mail directory.
Timo Sirainen <tss@iki.fi>
parents:
3083
diff
changeset
|
813 i_fatal("seteuid(%s) failed: %m", dec2str(uid)); |
8f254acc036c
Change effective GID as well before trying chdir() to mail directory.
Timo Sirainen <tss@iki.fi>
parents:
3083
diff
changeset
|
814 } |
5379
678621b6f1e0
Use alarm() to make sure that chdir() returns in 30 seconds (NFS..). Also if
Timo Sirainen <tss@iki.fi>
parents:
5372
diff
changeset
|
815 |
678621b6f1e0
Use alarm() to make sure that chdir() returns in 30 seconds (NFS..). Also if
Timo Sirainen <tss@iki.fi>
parents:
5372
diff
changeset
|
816 alarm(CHDIR_TIMEOUT); |
2311
4558d1b196fd
Added --exec-mail option to master. It can be used to parse Dovecot config
Timo Sirainen <tss@iki.fi>
parents:
2291
diff
changeset
|
817 ret = chdir(full_home_dir); |
5379
678621b6f1e0
Use alarm() to make sure that chdir() returns in 30 seconds (NFS..). Also if
Timo Sirainen <tss@iki.fi>
parents:
5372
diff
changeset
|
818 chdir_errno = errno; |
678621b6f1e0
Use alarm() to make sure that chdir() returns in 30 seconds (NFS..). Also if
Timo Sirainen <tss@iki.fi>
parents:
5372
diff
changeset
|
819 if ((left = alarm(0)) < CHDIR_TIMEOUT - CHDIR_WARN_SECS) { |
678621b6f1e0
Use alarm() to make sure that chdir() returns in 30 seconds (NFS..). Also if
Timo Sirainen <tss@iki.fi>
parents:
5372
diff
changeset
|
820 i_warning("chdir(%s) blocked for %u secs", |
678621b6f1e0
Use alarm() to make sure that chdir() returns in 30 seconds (NFS..). Also if
Timo Sirainen <tss@iki.fi>
parents:
5372
diff
changeset
|
821 full_home_dir, CHDIR_TIMEOUT - left); |
678621b6f1e0
Use alarm() to make sure that chdir() returns in 30 seconds (NFS..). Also if
Timo Sirainen <tss@iki.fi>
parents:
5372
diff
changeset
|
822 } |
3095
8f254acc036c
Change effective GID as well before trying chdir() to mail directory.
Timo Sirainen <tss@iki.fi>
parents:
3083
diff
changeset
|
823 |
2311
4558d1b196fd
Added --exec-mail option to master. It can be used to parse Dovecot config
Timo Sirainen <tss@iki.fi>
parents:
2291
diff
changeset
|
824 /* If user's home directory doesn't exist and we're not |
4558d1b196fd
Added --exec-mail option to master. It can be used to parse Dovecot config
Timo Sirainen <tss@iki.fi>
parents:
2291
diff
changeset
|
825 trying to chroot anywhere, fallback to /tmp as the mails |
3633
1e053e5e160d
If user's home directory is a non-directory (eg. /dev/null) fallback to /tmp
Timo Sirainen <tss@iki.fi>
parents:
3567
diff
changeset
|
826 could be stored elsewhere. The ENOTDIR check is mostly for |
1e053e5e160d
If user's home directory is a non-directory (eg. /dev/null) fallback to /tmp
Timo Sirainen <tss@iki.fi>
parents:
3567
diff
changeset
|
827 /dev/null home directory. */ |
5379
678621b6f1e0
Use alarm() to make sure that chdir() returns in 30 seconds (NFS..). Also if
Timo Sirainen <tss@iki.fi>
parents:
5372
diff
changeset
|
828 if (ret < 0 && (*chroot_dir != '\0' || |
678621b6f1e0
Use alarm() to make sure that chdir() returns in 30 seconds (NFS..). Also if
Timo Sirainen <tss@iki.fi>
parents:
5372
diff
changeset
|
829 !(ENOTFOUND(chdir_errno) || |
678621b6f1e0
Use alarm() to make sure that chdir() returns in 30 seconds (NFS..). Also if
Timo Sirainen <tss@iki.fi>
parents:
5372
diff
changeset
|
830 chdir_errno == EINTR))) { |
5383
8b5844d257e7
If chdir() failed, we still gave wrong reason
Timo Sirainen <tss@iki.fi>
parents:
5379
diff
changeset
|
831 errno = chdir_errno; |
8760
2e563febbc67
If chdir() fails with EACCES in mail process creation, log a user-friendly error.
Timo Sirainen <tss@iki.fi>
parents:
8739
diff
changeset
|
832 if (errno != EACCES) { |
2e563febbc67
If chdir() fails with EACCES in mail process creation, log a user-friendly error.
Timo Sirainen <tss@iki.fi>
parents:
8739
diff
changeset
|
833 i_fatal("chdir(%s) failed with uid %s: %m", |
2e563febbc67
If chdir() fails with EACCES in mail process creation, log a user-friendly error.
Timo Sirainen <tss@iki.fi>
parents:
8739
diff
changeset
|
834 full_home_dir, dec2str(uid)); |
2e563febbc67
If chdir() fails with EACCES in mail process creation, log a user-friendly error.
Timo Sirainen <tss@iki.fi>
parents:
8739
diff
changeset
|
835 } else { |
2e563febbc67
If chdir() fails with EACCES in mail process creation, log a user-friendly error.
Timo Sirainen <tss@iki.fi>
parents:
8739
diff
changeset
|
836 i_fatal("%s", eacces_error_get("chdir", |
2e563febbc67
If chdir() fails with EACCES in mail process creation, log a user-friendly error.
Timo Sirainen <tss@iki.fi>
parents:
8739
diff
changeset
|
837 full_home_dir)); |
2e563febbc67
If chdir() fails with EACCES in mail process creation, log a user-friendly error.
Timo Sirainen <tss@iki.fi>
parents:
8739
diff
changeset
|
838 } |
2311
4558d1b196fd
Added --exec-mail option to master. It can be used to parse Dovecot config
Timo Sirainen <tss@iki.fi>
parents:
2291
diff
changeset
|
839 } |
9246
25650d7f6b85
imap/pop3: If chdir() to home failed, euid was always logged as being root.
Timo Sirainen <tss@iki.fi>
parents:
9217
diff
changeset
|
840 /* Change UID back. No need to change GID back, it doesn't |
25650d7f6b85
imap/pop3: If chdir() to home failed, euid was always logged as being root.
Timo Sirainen <tss@iki.fi>
parents:
9217
diff
changeset
|
841 really matter. */ |
25650d7f6b85
imap/pop3: If chdir() to home failed, euid was always logged as being root.
Timo Sirainen <tss@iki.fi>
parents:
9217
diff
changeset
|
842 if (uid != master_uid && seteuid(master_uid) < 0) |
25650d7f6b85
imap/pop3: If chdir() to home failed, euid was always logged as being root.
Timo Sirainen <tss@iki.fi>
parents:
9217
diff
changeset
|
843 i_fatal("seteuid(%s) failed: %m", dec2str(master_uid)); |
2311
4558d1b196fd
Added --exec-mail option to master. It can be used to parse Dovecot config
Timo Sirainen <tss@iki.fi>
parents:
2291
diff
changeset
|
844 } |
4558d1b196fd
Added --exec-mail option to master. It can be used to parse Dovecot config
Timo Sirainen <tss@iki.fi>
parents:
2291
diff
changeset
|
845 if (ret < 0) { |
4558d1b196fd
Added --exec-mail option to master. It can be used to parse Dovecot config
Timo Sirainen <tss@iki.fi>
parents:
2291
diff
changeset
|
846 /* We still have to change to some directory where we have |
4558d1b196fd
Added --exec-mail option to master. It can be used to parse Dovecot config
Timo Sirainen <tss@iki.fi>
parents:
2291
diff
changeset
|
847 rx-access. /tmp should exist everywhere. */ |
4558d1b196fd
Added --exec-mail option to master. It can be used to parse Dovecot config
Timo Sirainen <tss@iki.fi>
parents:
2291
diff
changeset
|
848 if (chdir("/tmp") < 0) |
4558d1b196fd
Added --exec-mail option to master. It can be used to parse Dovecot config
Timo Sirainen <tss@iki.fi>
parents:
2291
diff
changeset
|
849 i_fatal("chdir(/tmp) failed: %m"); |
4558d1b196fd
Added --exec-mail option to master. It can be used to parse Dovecot config
Timo Sirainen <tss@iki.fi>
parents:
2291
diff
changeset
|
850 } |
4558d1b196fd
Added --exec-mail option to master. It can be used to parse Dovecot config
Timo Sirainen <tss@iki.fi>
parents:
2291
diff
changeset
|
851 |
7109
e6823d781317
Reverted "environment array" changes. It broke overriding imap/pop3 settings
Timo Sirainen <tss@iki.fi>
parents:
7092
diff
changeset
|
852 mail_process_set_environment(set, mail, var_expand_table, |
8406
ed4d6fc5712b
Code cleanup for previous change.
Timo Sirainen <tss@iki.fi>
parents:
8405
diff
changeset
|
853 dump_capability); |
2311
4558d1b196fd
Added --exec-mail option to master. It can be used to parse Dovecot config
Timo Sirainen <tss@iki.fi>
parents:
2291
diff
changeset
|
854 |
4217 | 855 /* extra args. uppercase key value. */ |
3287
47437871d879
Send all unrecognized parameters from userdb to imap/pop3 processes. Useful
Timo Sirainen <tss@iki.fi>
parents:
3159
diff
changeset
|
856 args = array_get(&extra_args, &count); |
47437871d879
Send all unrecognized parameters from userdb to imap/pop3 processes. Useful
Timo Sirainen <tss@iki.fi>
parents:
3159
diff
changeset
|
857 for (i = 0; i < count; i++) { |
4017
e2d267e6f930
Check that we don't pass around key=value pairs with empty keys.
Timo Sirainen <tss@iki.fi>
parents:
3975
diff
changeset
|
858 if (*args[i] == '=') { |
e2d267e6f930
Check that we don't pass around key=value pairs with empty keys.
Timo Sirainen <tss@iki.fi>
parents:
3975
diff
changeset
|
859 /* Should be caught by dovecot-auth already */ |
e2d267e6f930
Check that we don't pass around key=value pairs with empty keys.
Timo Sirainen <tss@iki.fi>
parents:
3975
diff
changeset
|
860 i_fatal("Userdb returned data with empty key (%s)", |
e2d267e6f930
Check that we don't pass around key=value pairs with empty keys.
Timo Sirainen <tss@iki.fi>
parents:
3975
diff
changeset
|
861 args[i]); |
e2d267e6f930
Check that we don't pass around key=value pairs with empty keys.
Timo Sirainen <tss@iki.fi>
parents:
3975
diff
changeset
|
862 } |
3287
47437871d879
Send all unrecognized parameters from userdb to imap/pop3 processes. Useful
Timo Sirainen <tss@iki.fi>
parents:
3159
diff
changeset
|
863 p = strchr(args[i], '='); |
47437871d879
Send all unrecognized parameters from userdb to imap/pop3 processes. Useful
Timo Sirainen <tss@iki.fi>
parents:
3159
diff
changeset
|
864 if (p == NULL) { |
47437871d879
Send all unrecognized parameters from userdb to imap/pop3 processes. Useful
Timo Sirainen <tss@iki.fi>
parents:
3159
diff
changeset
|
865 /* boolean */ |
7109
e6823d781317
Reverted "environment array" changes. It broke overriding imap/pop3 settings
Timo Sirainen <tss@iki.fi>
parents:
7092
diff
changeset
|
866 env_put(t_strconcat(t_str_ucase(args[i]), "=1", NULL)); |
3287
47437871d879
Send all unrecognized parameters from userdb to imap/pop3 processes. Useful
Timo Sirainen <tss@iki.fi>
parents:
3159
diff
changeset
|
867 |
47437871d879
Send all unrecognized parameters from userdb to imap/pop3 processes. Useful
Timo Sirainen <tss@iki.fi>
parents:
3159
diff
changeset
|
868 } else { |
47437871d879
Send all unrecognized parameters from userdb to imap/pop3 processes. Useful
Timo Sirainen <tss@iki.fi>
parents:
3159
diff
changeset
|
869 /* key=value */ |
7109
e6823d781317
Reverted "environment array" changes. It broke overriding imap/pop3 settings
Timo Sirainen <tss@iki.fi>
parents:
7092
diff
changeset
|
870 env_put(t_strconcat(t_str_ucase( |
e6823d781317
Reverted "environment array" changes. It broke overriding imap/pop3 settings
Timo Sirainen <tss@iki.fi>
parents:
7092
diff
changeset
|
871 t_strdup_until(args[i], p)), p, NULL)); |
3287
47437871d879
Send all unrecognized parameters from userdb to imap/pop3 processes. Useful
Timo Sirainen <tss@iki.fi>
parents:
3159
diff
changeset
|
872 } |
47437871d879
Send all unrecognized parameters from userdb to imap/pop3 processes. Useful
Timo Sirainen <tss@iki.fi>
parents:
3159
diff
changeset
|
873 } |
47437871d879
Send all unrecognized parameters from userdb to imap/pop3 processes. Useful
Timo Sirainen <tss@iki.fi>
parents:
3159
diff
changeset
|
874 |
5709
c6cde7452a9f
nfs check: If namespaces are defined, use the first one's location instead
Timo Sirainen <tss@iki.fi>
parents:
5626
diff
changeset
|
875 if (nfs_check) { |
c6cde7452a9f
nfs check: If namespaces are defined, use the first one's location instead
Timo Sirainen <tss@iki.fi>
parents:
5626
diff
changeset
|
876 /* ideally we should check all of the namespaces, |
c6cde7452a9f
nfs check: If namespaces are defined, use the first one's location instead
Timo Sirainen <tss@iki.fi>
parents:
5626
diff
changeset
|
877 but for now don't bother. */ |
7109
e6823d781317
Reverted "environment array" changes. It broke overriding imap/pop3 settings
Timo Sirainen <tss@iki.fi>
parents:
7092
diff
changeset
|
878 const char *mail_location = getenv("NAMESPACE_1"); |
e6823d781317
Reverted "environment array" changes. It broke overriding imap/pop3 settings
Timo Sirainen <tss@iki.fi>
parents:
7092
diff
changeset
|
879 |
e6823d781317
Reverted "environment array" changes. It broke overriding imap/pop3 settings
Timo Sirainen <tss@iki.fi>
parents:
7092
diff
changeset
|
880 if (mail_location == NULL) |
e6823d781317
Reverted "environment array" changes. It broke overriding imap/pop3 settings
Timo Sirainen <tss@iki.fi>
parents:
7092
diff
changeset
|
881 mail_location = getenv("MAIL"); |
e6823d781317
Reverted "environment array" changes. It broke overriding imap/pop3 settings
Timo Sirainen <tss@iki.fi>
parents:
7092
diff
changeset
|
882 nfs_warn_if_found(mail_location, full_home_dir); |
5709
c6cde7452a9f
nfs check: If namespaces are defined, use the first one's location instead
Timo Sirainen <tss@iki.fi>
parents:
5626
diff
changeset
|
883 } |
4190
19fc27f57b0c
Unless nfs_check=no or mmap_disable=yes, check for the first login if the
Timo Sirainen <tss@iki.fi>
parents:
4179
diff
changeset
|
884 |
7109
e6823d781317
Reverted "environment array" changes. It broke overriding imap/pop3 settings
Timo Sirainen <tss@iki.fi>
parents:
7092
diff
changeset
|
885 env_put("LOGGED_IN=1"); |
8327
8aeff7f48995
master: If there's no home directory don't set HOME environment at all.
Timo Sirainen <tss@iki.fi>
parents:
8325
diff
changeset
|
886 if (*home_dir != '\0') |
8aeff7f48995
master: If there's no home directory don't set HOME environment at all.
Timo Sirainen <tss@iki.fi>
parents:
8325
diff
changeset
|
887 env_put(t_strconcat("HOME=", home_dir, NULL)); |
7109
e6823d781317
Reverted "environment array" changes. It broke overriding imap/pop3 settings
Timo Sirainen <tss@iki.fi>
parents:
7092
diff
changeset
|
888 env_put(t_strconcat("USER=", user, NULL)); |
1055
a72bba3f8a55
Rewrote setting handling. Changed some existing settings also since POP3
Timo Sirainen <tss@iki.fi>
parents:
diff
changeset
|
889 |
7928
9e226056a208
Send login command OK reply in IMAP/POP3 process.
Timo Sirainen <tss@iki.fi>
parents:
7927
diff
changeset
|
890 addr = net_ip2addr(&request->remote_ip); |
7109
e6823d781317
Reverted "environment array" changes. It broke overriding imap/pop3 settings
Timo Sirainen <tss@iki.fi>
parents:
7092
diff
changeset
|
891 env_put(t_strconcat("IP=", addr, NULL)); |
8349
6503306b19cf
master: Set LOCAL_IP environment to mail processes.
Timo Sirainen <tss@iki.fi>
parents:
8327
diff
changeset
|
892 env_put(t_strconcat("LOCAL_IP=", net_ip2addr(&request->local_ip), NULL)); |
1484
8b3e16678100
Send client's IP to mail process.
Timo Sirainen <tss@iki.fi>
parents:
1468
diff
changeset
|
893 |
7928
9e226056a208
Send login command OK reply in IMAP/POP3 process.
Timo Sirainen <tss@iki.fi>
parents:
7927
diff
changeset
|
894 i_assert(request->cmd_tag_size <= request->data_size); |
9e226056a208
Send login command OK reply in IMAP/POP3 process.
Timo Sirainen <tss@iki.fi>
parents:
7927
diff
changeset
|
895 if (request->cmd_tag_size > 0) { |
9e226056a208
Send login command OK reply in IMAP/POP3 process.
Timo Sirainen <tss@iki.fi>
parents:
7927
diff
changeset
|
896 env_put(t_strconcat("IMAPLOGINTAG=", |
9e226056a208
Send login command OK reply in IMAP/POP3 process.
Timo Sirainen <tss@iki.fi>
parents:
7927
diff
changeset
|
897 t_strndup(data, request->cmd_tag_size), NULL)); |
9e226056a208
Send login command OK reply in IMAP/POP3 process.
Timo Sirainen <tss@iki.fi>
parents:
7927
diff
changeset
|
898 } |
9e226056a208
Send login command OK reply in IMAP/POP3 process.
Timo Sirainen <tss@iki.fi>
parents:
7927
diff
changeset
|
899 |
9e226056a208
Send login command OK reply in IMAP/POP3 process.
Timo Sirainen <tss@iki.fi>
parents:
7927
diff
changeset
|
900 if (request->data_size > request->cmd_tag_size) { |
7927
2351a81ce699
If commands are pipelined after the login command, pass them to the
Timo Sirainen <tss@iki.fi>
parents:
7917
diff
changeset
|
901 str_truncate(str, 0); |
2351a81ce699
If commands are pipelined after the login command, pass them to the
Timo Sirainen <tss@iki.fi>
parents:
7917
diff
changeset
|
902 str_append(str, "CLIENT_INPUT="); |
7928
9e226056a208
Send login command OK reply in IMAP/POP3 process.
Timo Sirainen <tss@iki.fi>
parents:
7927
diff
changeset
|
903 base64_encode(data + request->cmd_tag_size, |
9e226056a208
Send login command OK reply in IMAP/POP3 process.
Timo Sirainen <tss@iki.fi>
parents:
7927
diff
changeset
|
904 request->data_size - request->cmd_tag_size, str); |
7927
2351a81ce699
If commands are pipelined after the login command, pass them to the
Timo Sirainen <tss@iki.fi>
parents:
7917
diff
changeset
|
905 env_put(str_c(str)); |
2351a81ce699
If commands are pipelined after the login command, pass them to the
Timo Sirainen <tss@iki.fi>
parents:
7917
diff
changeset
|
906 } |
2351a81ce699
If commands are pipelined after the login command, pass them to the
Timo Sirainen <tss@iki.fi>
parents:
7917
diff
changeset
|
907 |
1693
552514c014cc
Allow one parameter for mail_executable.
Timo Sirainen <tss@iki.fi>
parents:
1659
diff
changeset
|
908 if (!set->verbose_proctitle) |
552514c014cc
Allow one parameter for mail_executable.
Timo Sirainen <tss@iki.fi>
parents:
1659
diff
changeset
|
909 title[0] = '\0'; |
552514c014cc
Allow one parameter for mail_executable.
Timo Sirainen <tss@iki.fi>
parents:
1659
diff
changeset
|
910 else { |
1485
8c28289a15a1
s/host/addr/ in a few network functions
Timo Sirainen <tss@iki.fi>
parents:
1484
diff
changeset
|
911 if (addr == NULL) |
8c28289a15a1
s/host/addr/ in a few network functions
Timo Sirainen <tss@iki.fi>
parents:
1484
diff
changeset
|
912 addr = "??"; |
1055
a72bba3f8a55
Rewrote setting handling. Changed some existing settings also since POP3
Timo Sirainen <tss@iki.fi>
parents:
diff
changeset
|
913 |
2736
0f31778d3c34
Changed dovecot-auth protocol to ASCII based. Should be easier now to write
Timo Sirainen <tss@iki.fi>
parents:
2723
diff
changeset
|
914 i_snprintf(title, sizeof(title), "[%s %s]", user, addr); |
1055
a72bba3f8a55
Rewrote setting handling. Changed some existing settings also since POP3
Timo Sirainen <tss@iki.fi>
parents:
diff
changeset
|
915 } |
a72bba3f8a55
Rewrote setting handling. Changed some existing settings also since POP3
Timo Sirainen <tss@iki.fi>
parents:
diff
changeset
|
916 |
8881
774b0e8138bd
Call closelog() before dup2()ing fds.
Timo Sirainen <tss@iki.fi>
parents:
8876
diff
changeset
|
917 /* make sure we don't leak syslog fd. try to do it as late as possible, |
774b0e8138bd
Call closelog() before dup2()ing fds.
Timo Sirainen <tss@iki.fi>
parents:
8876
diff
changeset
|
918 but also before dup2()s in case syslog fd is one of them. */ |
1055
a72bba3f8a55
Rewrote setting handling. Changed some existing settings also since POP3
Timo Sirainen <tss@iki.fi>
parents:
diff
changeset
|
919 closelog(); |
a72bba3f8a55
Rewrote setting handling. Changed some existing settings also since POP3
Timo Sirainen <tss@iki.fi>
parents:
diff
changeset
|
920 |
8881
774b0e8138bd
Call closelog() before dup2()ing fds.
Timo Sirainen <tss@iki.fi>
parents:
8876
diff
changeset
|
921 /* move the client socket into stdin and stdout fds, log to stderr */ |
774b0e8138bd
Call closelog() before dup2()ing fds.
Timo Sirainen <tss@iki.fi>
parents:
8876
diff
changeset
|
922 if (dup2(dump_capability ? null_fd : request->fd, 0) < 0) |
774b0e8138bd
Call closelog() before dup2()ing fds.
Timo Sirainen <tss@iki.fi>
parents:
8876
diff
changeset
|
923 i_fatal("dup2(stdin) failed: %m"); |
774b0e8138bd
Call closelog() before dup2()ing fds.
Timo Sirainen <tss@iki.fi>
parents:
8876
diff
changeset
|
924 if (dup2(request->fd, 1) < 0) |
774b0e8138bd
Call closelog() before dup2()ing fds.
Timo Sirainen <tss@iki.fi>
parents:
8876
diff
changeset
|
925 i_fatal("dup2(stdout) failed: %m"); |
774b0e8138bd
Call closelog() before dup2()ing fds.
Timo Sirainen <tss@iki.fi>
parents:
8876
diff
changeset
|
926 if (dup2(log_fd, 2) < 0) |
774b0e8138bd
Call closelog() before dup2()ing fds.
Timo Sirainen <tss@iki.fi>
parents:
8876
diff
changeset
|
927 i_fatal("dup2(stderr) failed: %m"); |
774b0e8138bd
Call closelog() before dup2()ing fds.
Timo Sirainen <tss@iki.fi>
parents:
8876
diff
changeset
|
928 |
774b0e8138bd
Call closelog() before dup2()ing fds.
Timo Sirainen <tss@iki.fi>
parents:
8876
diff
changeset
|
929 for (i = 0; i < 3; i++) |
774b0e8138bd
Call closelog() before dup2()ing fds.
Timo Sirainen <tss@iki.fi>
parents:
8876
diff
changeset
|
930 fd_close_on_exec(i, FALSE); |
774b0e8138bd
Call closelog() before dup2()ing fds.
Timo Sirainen <tss@iki.fi>
parents:
8876
diff
changeset
|
931 |
7341
af998ae4254b
Replaced mail_extra_groups setting with mail_privileged_group and
Timo Sirainen <tss@iki.fi>
parents:
7334
diff
changeset
|
932 if (set->mail_drop_priv_before_exec) { |
7109
e6823d781317
Reverted "environment array" changes. It broke overriding imap/pop3 settings
Timo Sirainen <tss@iki.fi>
parents:
7092
diff
changeset
|
933 restrict_access_by_env(TRUE); |
7341
af998ae4254b
Replaced mail_extra_groups setting with mail_privileged_group and
Timo Sirainen <tss@iki.fi>
parents:
7334
diff
changeset
|
934 /* privileged GID is now only in saved-GID. if we want to |
8861
9d00503821d6
mail_privileged_group setting prevents core dumps - mention it in logging.
Timo Sirainen <tss@iki.fi>
parents:
8768
diff
changeset
|
935 preserve it across exec, it needs to be temporarily |
9d00503821d6
mail_privileged_group setting prevents core dumps - mention it in logging.
Timo Sirainen <tss@iki.fi>
parents:
8768
diff
changeset
|
936 in effective gid. unfortunately this also causes kernel |
9d00503821d6
mail_privileged_group setting prevents core dumps - mention it in logging.
Timo Sirainen <tss@iki.fi>
parents:
8768
diff
changeset
|
937 to think we're a setgid-program. */ |
7341
af998ae4254b
Replaced mail_extra_groups setting with mail_privileged_group and
Timo Sirainen <tss@iki.fi>
parents:
7334
diff
changeset
|
938 restrict_access_use_priv_gid(); |
af998ae4254b
Replaced mail_extra_groups setting with mail_privileged_group and
Timo Sirainen <tss@iki.fi>
parents:
7334
diff
changeset
|
939 } |
1223
52e0830ade13
Added setting mail_drop_priv_before_exec.
Timo Sirainen <tss@iki.fi>
parents:
1172
diff
changeset
|
940 |
7109
e6823d781317
Reverted "environment array" changes. It broke overriding imap/pop3 settings
Timo Sirainen <tss@iki.fi>
parents:
7092
diff
changeset
|
941 client_process_exec(set->mail_executable, title); |
1055
a72bba3f8a55
Rewrote setting handling. Changed some existing settings also since POP3
Timo Sirainen <tss@iki.fi>
parents:
diff
changeset
|
942 |
a72bba3f8a55
Rewrote setting handling. Changed some existing settings also since POP3
Timo Sirainen <tss@iki.fi>
parents:
diff
changeset
|
943 /* not reached */ |
5846
21e529b8a701
Initial implementation for mail_max_user_connections setting.
Timo Sirainen <tss@iki.fi>
parents:
5843
diff
changeset
|
944 return MASTER_LOGIN_STATUS_INTERNAL_ERROR; |
1055
a72bba3f8a55
Rewrote setting handling. Changed some existing settings also since POP3
Timo Sirainen <tss@iki.fi>
parents:
diff
changeset
|
945 } |
a72bba3f8a55
Rewrote setting handling. Changed some existing settings also since POP3
Timo Sirainen <tss@iki.fi>
parents:
diff
changeset
|
946 |
5843
f655c4d4a419
Moved child process handling to child-process.[ch]. The hash table now uses
Timo Sirainen <tss@iki.fi>
parents:
5800
diff
changeset
|
947 static void |
5846
21e529b8a701
Initial implementation for mail_max_user_connections setting.
Timo Sirainen <tss@iki.fi>
parents:
5843
diff
changeset
|
948 mail_process_destroyed(struct child_process *process, |
6411
6a64e64fa3a3
Renamed __attr_*__ to ATTR_*. Renamed __attrs_used__ to ATTRS_DEFINED.
Timo Sirainen <tss@iki.fi>
parents:
6400
diff
changeset
|
949 pid_t pid, bool abnormal_exit ATTR_UNUSED) |
1055
a72bba3f8a55
Rewrote setting handling. Changed some existing settings also since POP3
Timo Sirainen <tss@iki.fi>
parents:
diff
changeset
|
950 { |
5846
21e529b8a701
Initial implementation for mail_max_user_connections setting.
Timo Sirainen <tss@iki.fi>
parents:
5843
diff
changeset
|
951 struct mail_process_group *group = (struct mail_process_group *)process; |
21e529b8a701
Initial implementation for mail_max_user_connections setting.
Timo Sirainen <tss@iki.fi>
parents:
5843
diff
changeset
|
952 const pid_t *pids; |
21e529b8a701
Initial implementation for mail_max_user_connections setting.
Timo Sirainen <tss@iki.fi>
parents:
5843
diff
changeset
|
953 unsigned int i, count; |
21e529b8a701
Initial implementation for mail_max_user_connections setting.
Timo Sirainen <tss@iki.fi>
parents:
5843
diff
changeset
|
954 |
21e529b8a701
Initial implementation for mail_max_user_connections setting.
Timo Sirainen <tss@iki.fi>
parents:
5843
diff
changeset
|
955 pids = array_get(&group->processes, &count); |
21e529b8a701
Initial implementation for mail_max_user_connections setting.
Timo Sirainen <tss@iki.fi>
parents:
5843
diff
changeset
|
956 if (count == 1) { |
21e529b8a701
Initial implementation for mail_max_user_connections setting.
Timo Sirainen <tss@iki.fi>
parents:
5843
diff
changeset
|
957 /* last process in this group */ |
21e529b8a701
Initial implementation for mail_max_user_connections setting.
Timo Sirainen <tss@iki.fi>
parents:
5843
diff
changeset
|
958 i_assert(pids[0] == pid); |
8573
f9166a09423a
Renamed hash_*() to hash_table_*() to avoid conflicts with OSX's strhash.h
Timo Sirainen <tss@iki.fi>
parents:
8544
diff
changeset
|
959 hash_table_remove(mail_process_groups, group); |
5846
21e529b8a701
Initial implementation for mail_max_user_connections setting.
Timo Sirainen <tss@iki.fi>
parents:
5843
diff
changeset
|
960 mail_process_group_free(group); |
21e529b8a701
Initial implementation for mail_max_user_connections setting.
Timo Sirainen <tss@iki.fi>
parents:
5843
diff
changeset
|
961 } else { |
21e529b8a701
Initial implementation for mail_max_user_connections setting.
Timo Sirainen <tss@iki.fi>
parents:
5843
diff
changeset
|
962 for (i = 0; i < count; i++) { |
21e529b8a701
Initial implementation for mail_max_user_connections setting.
Timo Sirainen <tss@iki.fi>
parents:
5843
diff
changeset
|
963 if (pids[i] == pid) |
21e529b8a701
Initial implementation for mail_max_user_connections setting.
Timo Sirainen <tss@iki.fi>
parents:
5843
diff
changeset
|
964 break; |
21e529b8a701
Initial implementation for mail_max_user_connections setting.
Timo Sirainen <tss@iki.fi>
parents:
5843
diff
changeset
|
965 } |
21e529b8a701
Initial implementation for mail_max_user_connections setting.
Timo Sirainen <tss@iki.fi>
parents:
5843
diff
changeset
|
966 i_assert(i != count); |
21e529b8a701
Initial implementation for mail_max_user_connections setting.
Timo Sirainen <tss@iki.fi>
parents:
5843
diff
changeset
|
967 array_delete(&group->processes, i, 1); |
21e529b8a701
Initial implementation for mail_max_user_connections setting.
Timo Sirainen <tss@iki.fi>
parents:
5843
diff
changeset
|
968 } |
21e529b8a701
Initial implementation for mail_max_user_connections setting.
Timo Sirainen <tss@iki.fi>
parents:
5843
diff
changeset
|
969 |
1055
a72bba3f8a55
Rewrote setting handling. Changed some existing settings also since POP3
Timo Sirainen <tss@iki.fi>
parents:
diff
changeset
|
970 mail_process_count--; |
a72bba3f8a55
Rewrote setting handling. Changed some existing settings also since POP3
Timo Sirainen <tss@iki.fi>
parents:
diff
changeset
|
971 } |
5843
f655c4d4a419
Moved child process handling to child-process.[ch]. The hash table now uses
Timo Sirainen <tss@iki.fi>
parents:
5800
diff
changeset
|
972 |
f655c4d4a419
Moved child process handling to child-process.[ch]. The hash table now uses
Timo Sirainen <tss@iki.fi>
parents:
5800
diff
changeset
|
973 void mail_processes_init(void) |
f655c4d4a419
Moved child process handling to child-process.[ch]. The hash table now uses
Timo Sirainen <tss@iki.fi>
parents:
5800
diff
changeset
|
974 { |
8573
f9166a09423a
Renamed hash_*() to hash_table_*() to avoid conflicts with OSX's strhash.h
Timo Sirainen <tss@iki.fi>
parents:
8544
diff
changeset
|
975 mail_process_groups = hash_table_create(default_pool, default_pool, 0, |
f9166a09423a
Renamed hash_*() to hash_table_*() to avoid conflicts with OSX's strhash.h
Timo Sirainen <tss@iki.fi>
parents:
8544
diff
changeset
|
976 mail_process_group_hash, |
f9166a09423a
Renamed hash_*() to hash_table_*() to avoid conflicts with OSX's strhash.h
Timo Sirainen <tss@iki.fi>
parents:
8544
diff
changeset
|
977 mail_process_group_cmp); |
5846
21e529b8a701
Initial implementation for mail_max_user_connections setting.
Timo Sirainen <tss@iki.fi>
parents:
5843
diff
changeset
|
978 |
5843
f655c4d4a419
Moved child process handling to child-process.[ch]. The hash table now uses
Timo Sirainen <tss@iki.fi>
parents:
5800
diff
changeset
|
979 child_process_set_destroy_callback(PROCESS_TYPE_IMAP, |
f655c4d4a419
Moved child process handling to child-process.[ch]. The hash table now uses
Timo Sirainen <tss@iki.fi>
parents:
5800
diff
changeset
|
980 mail_process_destroyed); |
f655c4d4a419
Moved child process handling to child-process.[ch]. The hash table now uses
Timo Sirainen <tss@iki.fi>
parents:
5800
diff
changeset
|
981 child_process_set_destroy_callback(PROCESS_TYPE_POP3, |
f655c4d4a419
Moved child process handling to child-process.[ch]. The hash table now uses
Timo Sirainen <tss@iki.fi>
parents:
5800
diff
changeset
|
982 mail_process_destroyed); |
f655c4d4a419
Moved child process handling to child-process.[ch]. The hash table now uses
Timo Sirainen <tss@iki.fi>
parents:
5800
diff
changeset
|
983 } |
5846
21e529b8a701
Initial implementation for mail_max_user_connections setting.
Timo Sirainen <tss@iki.fi>
parents:
5843
diff
changeset
|
984 |
21e529b8a701
Initial implementation for mail_max_user_connections setting.
Timo Sirainen <tss@iki.fi>
parents:
5843
diff
changeset
|
985 void mail_processes_deinit(void) |
21e529b8a701
Initial implementation for mail_max_user_connections setting.
Timo Sirainen <tss@iki.fi>
parents:
5843
diff
changeset
|
986 { |
8739
88ae612dc221
master: Another deinit crashfix
Timo Sirainen <tss@iki.fi>
parents:
8736
diff
changeset
|
987 /* we may still end up in mail_process_destroyed(), so don't free |
88ae612dc221
master: Another deinit crashfix
Timo Sirainen <tss@iki.fi>
parents:
8736
diff
changeset
|
988 anything. This deinit code needs a redesign.. */ |
5846
21e529b8a701
Initial implementation for mail_max_user_connections setting.
Timo Sirainen <tss@iki.fi>
parents:
5843
diff
changeset
|
989 } |