Mercurial > dovecot > original-hg > dovecot-1.2
annotate src/master/login-process.c @ 4661:885bef091d1a HEAD
Make sure we don't kill login processes that haven't yet even sent their
initialization event. Also added another sanity check.
author | Timo Sirainen <tss@iki.fi> |
---|---|
date | Fri, 13 Oct 2006 21:03:22 +0300 |
parents | 2fe8f6a0bc5b |
children | e4d7d01b0784 |
rev | line source |
---|---|
0 | 1 /* Copyright (C) 2002 Timo Sirainen */ |
2 | |
3 #include "common.h" | |
532
3b53dd1280c6
I/O buffers now use real blocking instead of setting up a sub-ioloop to
Timo Sirainen <tss@iki.fi>
parents:
410
diff
changeset
|
4 #include "ioloop.h" |
0 | 5 #include "network.h" |
764
f57c52738f90
Renamed IBuffer and OBuffer to IStream and OStream which describes their
Timo Sirainen <tss@iki.fi>
parents:
747
diff
changeset
|
6 #include "ostream.h" |
0 | 7 #include "fdpass.h" |
727
8dd8ebe6bcac
We use close-on-exec flag now to make sure that master process closes the
Timo Sirainen <tss@iki.fi>
parents:
722
diff
changeset
|
8 #include "fd-close-on-exec.h" |
697
7814b29d0862
Created env_put() and env_clean() for a bit easier handling of environment
Timo Sirainen <tss@iki.fi>
parents:
666
diff
changeset
|
9 #include "env-util.h" |
0 | 10 #include "restrict-access.h" |
722
0438621d25ff
Added virtual memory size limits to processes. Default values are pretty
Timo Sirainen <tss@iki.fi>
parents:
699
diff
changeset
|
11 #include "restrict-process-size.h" |
0 | 12 #include "login-process.h" |
13 #include "auth-process.h" | |
1055
a72bba3f8a55
Rewrote setting handling. Changed some existing settings also since POP3
Timo Sirainen <tss@iki.fi>
parents:
1039
diff
changeset
|
14 #include "mail-process.h" |
1035
fe49ece0f3ea
We have now separate "userdb" and "passdb". They aren't tied to each others
Timo Sirainen <tss@iki.fi>
parents:
1000
diff
changeset
|
15 #include "master-login-interface.h" |
2000
c7c19f5071c3
Write all logging through master process. Fixes problems with log rotation,
Timo Sirainen <tss@iki.fi>
parents:
1997
diff
changeset
|
16 #include "log.h" |
3901
0ae5f5b468b7
Put ssl-parameters file into login directory so it still can be accessed
Timo Sirainen <tss@iki.fi>
parents:
3889
diff
changeset
|
17 #include "ssl-init.h" |
0 | 18 |
19 #include <unistd.h> | |
20 #include <syslog.h> | |
4649
a3d6a3462745
Send inode number in login requests and verify that they match.
Timo Sirainen <tss@iki.fi>
parents:
4640
diff
changeset
|
21 #include <sys/stat.h> |
0 | 22 |
903
fd8888f6f037
Naming style changes, finally got tired of most of the typedefs. Also the
Timo Sirainen <tss@iki.fi>
parents:
876
diff
changeset
|
23 struct login_process { |
1055
a72bba3f8a55
Rewrote setting handling. Changed some existing settings also since POP3
Timo Sirainen <tss@iki.fi>
parents:
1039
diff
changeset
|
24 struct login_group *group; |
4538
9d9e72374164
Fixes to login process handling, especially with
Timo Sirainen <tss@iki.fi>
parents:
4388
diff
changeset
|
25 struct login_process *prev_prelogin, *next_prelogin; |
0 | 26 int refcount; |
27 | |
28 pid_t pid; | |
29 int fd; | |
903
fd8888f6f037
Naming style changes, finally got tired of most of the typedefs. Also the
Timo Sirainen <tss@iki.fi>
parents:
876
diff
changeset
|
30 struct io *io; |
fd8888f6f037
Naming style changes, finally got tired of most of the typedefs. Also the
Timo Sirainen <tss@iki.fi>
parents:
876
diff
changeset
|
31 struct ostream *output; |
4538
9d9e72374164
Fixes to login process handling, especially with
Timo Sirainen <tss@iki.fi>
parents:
4388
diff
changeset
|
32 enum master_login_state state; |
9d9e72374164
Fixes to login process handling, especially with
Timo Sirainen <tss@iki.fi>
parents:
4388
diff
changeset
|
33 |
925
2e649dec0f09
Auth and login processes send an "we're ok" reply at the end of
Timo Sirainen <tss@iki.fi>
parents:
903
diff
changeset
|
34 unsigned int initialized:1; |
0 | 35 unsigned int destroyed:1; |
4538
9d9e72374164
Fixes to login process handling, especially with
Timo Sirainen <tss@iki.fi>
parents:
4388
diff
changeset
|
36 unsigned int inetd_child:1; |
613
1906116a62ce
Finally support for handling each login connection in it's own process.
Timo Sirainen <tss@iki.fi>
parents:
596
diff
changeset
|
37 }; |
0 | 38 |
903
fd8888f6f037
Naming style changes, finally got tired of most of the typedefs. Also the
Timo Sirainen <tss@iki.fi>
parents:
876
diff
changeset
|
39 struct login_auth_request { |
fd8888f6f037
Naming style changes, finally got tired of most of the typedefs. Also the
Timo Sirainen <tss@iki.fi>
parents:
876
diff
changeset
|
40 struct login_process *process; |
1035
fe49ece0f3ea
We have now separate "userdb" and "passdb". They aren't tied to each others
Timo Sirainen <tss@iki.fi>
parents:
1000
diff
changeset
|
41 unsigned int tag; |
fe49ece0f3ea
We have now separate "userdb" and "passdb". They aren't tied to each others
Timo Sirainen <tss@iki.fi>
parents:
1000
diff
changeset
|
42 |
fe49ece0f3ea
We have now separate "userdb" and "passdb". They aren't tied to each others
Timo Sirainen <tss@iki.fi>
parents:
1000
diff
changeset
|
43 unsigned int login_tag; |
0 | 44 int fd; |
45 | |
2097
4e77cb0aff21
Added %l, %r and %P variables and mail_log_prefix setting.
Timo Sirainen <tss@iki.fi>
parents:
2046
diff
changeset
|
46 struct ip_addr local_ip, remote_ip; |
903
fd8888f6f037
Naming style changes, finally got tired of most of the typedefs. Also the
Timo Sirainen <tss@iki.fi>
parents:
876
diff
changeset
|
47 }; |
0 | 48 |
1273
2cf2e08a6ee9
Somewhat working code to support loading Dovecot from inetd and such. It
Timo Sirainen <tss@iki.fi>
parents:
1237
diff
changeset
|
49 static unsigned int auth_id_counter, login_pid_counter; |
903
fd8888f6f037
Naming style changes, finally got tired of most of the typedefs. Also the
Timo Sirainen <tss@iki.fi>
parents:
876
diff
changeset
|
50 static struct timeout *to; |
1273
2cf2e08a6ee9
Somewhat working code to support loading Dovecot from inetd and such. It
Timo Sirainen <tss@iki.fi>
parents:
1237
diff
changeset
|
51 static struct io *io_listen; |
4148
f60d73c96618
If master process runs out of file descriptors, try to handle it more nicely
Timo Sirainen <tss@iki.fi>
parents:
3901
diff
changeset
|
52 static bool logins_stalled = FALSE; |
613
1906116a62ce
Finally support for handling each login connection in it's own process.
Timo Sirainen <tss@iki.fi>
parents:
596
diff
changeset
|
53 |
903
fd8888f6f037
Naming style changes, finally got tired of most of the typedefs. Also the
Timo Sirainen <tss@iki.fi>
parents:
876
diff
changeset
|
54 static struct hash_table *processes; |
1055
a72bba3f8a55
Rewrote setting handling. Changed some existing settings also since POP3
Timo Sirainen <tss@iki.fi>
parents:
1039
diff
changeset
|
55 static struct login_group *login_groups; |
0 | 56 |
4651
2fe8f6a0bc5b
If login process dies before initialization, stall creation of them instead
Timo Sirainen <tss@iki.fi>
parents:
4649
diff
changeset
|
57 static void login_processes_stall(void); |
903
fd8888f6f037
Naming style changes, finally got tired of most of the typedefs. Also the
Timo Sirainen <tss@iki.fi>
parents:
876
diff
changeset
|
58 static void login_process_destroy(struct login_process *p); |
fd8888f6f037
Naming style changes, finally got tired of most of the typedefs. Also the
Timo Sirainen <tss@iki.fi>
parents:
876
diff
changeset
|
59 static void login_process_unref(struct login_process *p); |
3863
55df57c028d4
Added "bool" type and changed all ints that were used as booleans to bool.
Timo Sirainen <tss@iki.fi>
parents:
3692
diff
changeset
|
60 static bool login_process_init_group(struct login_process *p); |
4148
f60d73c96618
If master process runs out of file descriptors, try to handle it more nicely
Timo Sirainen <tss@iki.fi>
parents:
3901
diff
changeset
|
61 static void login_processes_start_missing(void *context); |
0 | 62 |
1610
6850142c4e25
New configuration file code. Some syntax changes, but tries to be somewhat
Timo Sirainen <tss@iki.fi>
parents:
1506
diff
changeset
|
63 static void login_group_create(struct settings *set) |
1055
a72bba3f8a55
Rewrote setting handling. Changed some existing settings also since POP3
Timo Sirainen <tss@iki.fi>
parents:
1039
diff
changeset
|
64 { |
a72bba3f8a55
Rewrote setting handling. Changed some existing settings also since POP3
Timo Sirainen <tss@iki.fi>
parents:
1039
diff
changeset
|
65 struct login_group *group; |
a72bba3f8a55
Rewrote setting handling. Changed some existing settings also since POP3
Timo Sirainen <tss@iki.fi>
parents:
1039
diff
changeset
|
66 |
a72bba3f8a55
Rewrote setting handling. Changed some existing settings also since POP3
Timo Sirainen <tss@iki.fi>
parents:
1039
diff
changeset
|
67 group = i_new(struct login_group, 1); |
4631
f5d53a684856
SIGHUP caused memory corruption
Timo Sirainen <tss@iki.fi>
parents:
4630
diff
changeset
|
68 group->refcount = 1; |
1610
6850142c4e25
New configuration file code. Some syntax changes, but tries to be somewhat
Timo Sirainen <tss@iki.fi>
parents:
1506
diff
changeset
|
69 group->set = set; |
6850142c4e25
New configuration file code. Some syntax changes, but tries to be somewhat
Timo Sirainen <tss@iki.fi>
parents:
1506
diff
changeset
|
70 group->process_type = set->protocol == MAIL_PROTOCOL_IMAP ? |
6850142c4e25
New configuration file code. Some syntax changes, but tries to be somewhat
Timo Sirainen <tss@iki.fi>
parents:
1506
diff
changeset
|
71 PROCESS_TYPE_IMAP : PROCESS_TYPE_POP3; |
1055
a72bba3f8a55
Rewrote setting handling. Changed some existing settings also since POP3
Timo Sirainen <tss@iki.fi>
parents:
1039
diff
changeset
|
72 |
a72bba3f8a55
Rewrote setting handling. Changed some existing settings also since POP3
Timo Sirainen <tss@iki.fi>
parents:
1039
diff
changeset
|
73 group->next = login_groups; |
a72bba3f8a55
Rewrote setting handling. Changed some existing settings also since POP3
Timo Sirainen <tss@iki.fi>
parents:
1039
diff
changeset
|
74 login_groups = group; |
a72bba3f8a55
Rewrote setting handling. Changed some existing settings also since POP3
Timo Sirainen <tss@iki.fi>
parents:
1039
diff
changeset
|
75 } |
a72bba3f8a55
Rewrote setting handling. Changed some existing settings also since POP3
Timo Sirainen <tss@iki.fi>
parents:
1039
diff
changeset
|
76 |
4631
f5d53a684856
SIGHUP caused memory corruption
Timo Sirainen <tss@iki.fi>
parents:
4630
diff
changeset
|
77 static void login_group_unref(struct login_group *group) |
1055
a72bba3f8a55
Rewrote setting handling. Changed some existing settings also since POP3
Timo Sirainen <tss@iki.fi>
parents:
1039
diff
changeset
|
78 { |
4631
f5d53a684856
SIGHUP caused memory corruption
Timo Sirainen <tss@iki.fi>
parents:
4630
diff
changeset
|
79 i_assert(group->refcount > 0); |
f5d53a684856
SIGHUP caused memory corruption
Timo Sirainen <tss@iki.fi>
parents:
4630
diff
changeset
|
80 |
f5d53a684856
SIGHUP caused memory corruption
Timo Sirainen <tss@iki.fi>
parents:
4630
diff
changeset
|
81 if (--group->refcount > 0) |
f5d53a684856
SIGHUP caused memory corruption
Timo Sirainen <tss@iki.fi>
parents:
4630
diff
changeset
|
82 return; |
f5d53a684856
SIGHUP caused memory corruption
Timo Sirainen <tss@iki.fi>
parents:
4630
diff
changeset
|
83 |
1055
a72bba3f8a55
Rewrote setting handling. Changed some existing settings also since POP3
Timo Sirainen <tss@iki.fi>
parents:
1039
diff
changeset
|
84 i_free(group); |
a72bba3f8a55
Rewrote setting handling. Changed some existing settings also since POP3
Timo Sirainen <tss@iki.fi>
parents:
1039
diff
changeset
|
85 } |
a72bba3f8a55
Rewrote setting handling. Changed some existing settings also since POP3
Timo Sirainen <tss@iki.fi>
parents:
1039
diff
changeset
|
86 |
2736
0f31778d3c34
Changed dovecot-auth protocol to ASCII based. Should be easier now to write
Timo Sirainen <tss@iki.fi>
parents:
2691
diff
changeset
|
87 void auth_master_callback(const char *user, const char *const *args, |
0f31778d3c34
Changed dovecot-auth protocol to ASCII based. Should be easier now to write
Timo Sirainen <tss@iki.fi>
parents:
2691
diff
changeset
|
88 void *context) |
0 | 89 { |
903
fd8888f6f037
Naming style changes, finally got tired of most of the typedefs. Also the
Timo Sirainen <tss@iki.fi>
parents:
876
diff
changeset
|
90 struct login_auth_request *request = context; |
1035
fe49ece0f3ea
We have now separate "userdb" and "passdb". They aren't tied to each others
Timo Sirainen <tss@iki.fi>
parents:
1000
diff
changeset
|
91 struct master_login_reply master_reply; |
2329 | 92 ssize_t ret; |
0 | 93 |
2736
0f31778d3c34
Changed dovecot-auth protocol to ASCII based. Should be easier now to write
Timo Sirainen <tss@iki.fi>
parents:
2691
diff
changeset
|
94 if (user == NULL) |
1035
fe49ece0f3ea
We have now separate "userdb" and "passdb". They aren't tied to each others
Timo Sirainen <tss@iki.fi>
parents:
1000
diff
changeset
|
95 master_reply.success = FALSE; |
0 | 96 else { |
1055
a72bba3f8a55
Rewrote setting handling. Changed some existing settings also since POP3
Timo Sirainen <tss@iki.fi>
parents:
1039
diff
changeset
|
97 struct login_group *group = request->process->group; |
a72bba3f8a55
Rewrote setting handling. Changed some existing settings also since POP3
Timo Sirainen <tss@iki.fi>
parents:
1039
diff
changeset
|
98 |
2097
4e77cb0aff21
Added %l, %r and %P variables and mail_log_prefix setting.
Timo Sirainen <tss@iki.fi>
parents:
2046
diff
changeset
|
99 t_push(); |
1039
793f05a7e50e
signed/unsigned/const pointer fixes
Timo Sirainen <tss@iki.fi>
parents:
1036
diff
changeset
|
100 master_reply.success = |
4197
c3ded5b815aa
If we have plugins set and imap_capability unset, figure out the IMAP
Timo Sirainen <tss@iki.fi>
parents:
4148
diff
changeset
|
101 create_mail_process(group->process_type, group->set, |
c3ded5b815aa
If we have plugins set and imap_capability unset, figure out the IMAP
Timo Sirainen <tss@iki.fi>
parents:
4148
diff
changeset
|
102 request->fd, &request->local_ip, |
c3ded5b815aa
If we have plugins set and imap_capability unset, figure out the IMAP
Timo Sirainen <tss@iki.fi>
parents:
4148
diff
changeset
|
103 &request->remote_ip, user, args, |
c3ded5b815aa
If we have plugins set and imap_capability unset, figure out the IMAP
Timo Sirainen <tss@iki.fi>
parents:
4148
diff
changeset
|
104 FALSE); |
2097
4e77cb0aff21
Added %l, %r and %P variables and mail_log_prefix setting.
Timo Sirainen <tss@iki.fi>
parents:
2046
diff
changeset
|
105 t_pop(); |
0 | 106 } |
107 | |
108 /* reply to login */ | |
1035
fe49ece0f3ea
We have now separate "userdb" and "passdb". They aren't tied to each others
Timo Sirainen <tss@iki.fi>
parents:
1000
diff
changeset
|
109 master_reply.tag = request->login_tag; |
0 | 110 |
2329 | 111 ret = o_stream_send(request->process->output, &master_reply, |
112 sizeof(master_reply)); | |
113 if (ret != sizeof(master_reply)) { | |
114 if (ret >= 0) { | |
115 i_warning("Login process %s transmit buffer full, " | |
116 "killing..", dec2str(request->process->pid)); | |
117 } | |
1035
fe49ece0f3ea
We have now separate "userdb" and "passdb". They aren't tied to each others
Timo Sirainen <tss@iki.fi>
parents:
1000
diff
changeset
|
118 login_process_destroy(request->process); |
2329 | 119 } |
0 | 120 |
805
5ac361acb316
Marked all non-trivial buffer modifications with @UNSAFE tag. Several
Timo Sirainen <tss@iki.fi>
parents:
801
diff
changeset
|
121 if (close(request->fd) < 0) |
1055
a72bba3f8a55
Rewrote setting handling. Changed some existing settings also since POP3
Timo Sirainen <tss@iki.fi>
parents:
1039
diff
changeset
|
122 i_error("close(mail client) failed: %m"); |
1035
fe49ece0f3ea
We have now separate "userdb" and "passdb". They aren't tied to each others
Timo Sirainen <tss@iki.fi>
parents:
1000
diff
changeset
|
123 login_process_unref(request->process); |
0 | 124 i_free(request); |
125 } | |
126 | |
4538
9d9e72374164
Fixes to login process handling, especially with
Timo Sirainen <tss@iki.fi>
parents:
4388
diff
changeset
|
127 static void process_remove_from_prelogin_lists(struct login_process *p) |
9d9e72374164
Fixes to login process handling, especially with
Timo Sirainen <tss@iki.fi>
parents:
4388
diff
changeset
|
128 { |
9d9e72374164
Fixes to login process handling, especially with
Timo Sirainen <tss@iki.fi>
parents:
4388
diff
changeset
|
129 if (p->state != LOGIN_STATE_FULL_PRELOGINS) |
9d9e72374164
Fixes to login process handling, especially with
Timo Sirainen <tss@iki.fi>
parents:
4388
diff
changeset
|
130 return; |
9d9e72374164
Fixes to login process handling, especially with
Timo Sirainen <tss@iki.fi>
parents:
4388
diff
changeset
|
131 |
9d9e72374164
Fixes to login process handling, especially with
Timo Sirainen <tss@iki.fi>
parents:
4388
diff
changeset
|
132 if (p->prev_prelogin == NULL) |
9d9e72374164
Fixes to login process handling, especially with
Timo Sirainen <tss@iki.fi>
parents:
4388
diff
changeset
|
133 p->group->oldest_prelogin_process = p->next_prelogin; |
9d9e72374164
Fixes to login process handling, especially with
Timo Sirainen <tss@iki.fi>
parents:
4388
diff
changeset
|
134 else |
9d9e72374164
Fixes to login process handling, especially with
Timo Sirainen <tss@iki.fi>
parents:
4388
diff
changeset
|
135 p->prev_prelogin->next_prelogin = p->next_prelogin; |
9d9e72374164
Fixes to login process handling, especially with
Timo Sirainen <tss@iki.fi>
parents:
4388
diff
changeset
|
136 |
9d9e72374164
Fixes to login process handling, especially with
Timo Sirainen <tss@iki.fi>
parents:
4388
diff
changeset
|
137 if (p->next_prelogin == NULL) |
9d9e72374164
Fixes to login process handling, especially with
Timo Sirainen <tss@iki.fi>
parents:
4388
diff
changeset
|
138 p->group->newest_prelogin_process = p->prev_prelogin; |
9d9e72374164
Fixes to login process handling, especially with
Timo Sirainen <tss@iki.fi>
parents:
4388
diff
changeset
|
139 else |
9d9e72374164
Fixes to login process handling, especially with
Timo Sirainen <tss@iki.fi>
parents:
4388
diff
changeset
|
140 p->next_prelogin->prev_prelogin = p->prev_prelogin; |
9d9e72374164
Fixes to login process handling, especially with
Timo Sirainen <tss@iki.fi>
parents:
4388
diff
changeset
|
141 |
9d9e72374164
Fixes to login process handling, especially with
Timo Sirainen <tss@iki.fi>
parents:
4388
diff
changeset
|
142 p->prev_prelogin = p->next_prelogin = NULL; |
9d9e72374164
Fixes to login process handling, especially with
Timo Sirainen <tss@iki.fi>
parents:
4388
diff
changeset
|
143 } |
9d9e72374164
Fixes to login process handling, especially with
Timo Sirainen <tss@iki.fi>
parents:
4388
diff
changeset
|
144 |
9d9e72374164
Fixes to login process handling, especially with
Timo Sirainen <tss@iki.fi>
parents:
4388
diff
changeset
|
145 static void process_mark_nonlistening(struct login_process *p, |
9d9e72374164
Fixes to login process handling, especially with
Timo Sirainen <tss@iki.fi>
parents:
4388
diff
changeset
|
146 enum master_login_state new_state) |
614
e60620644af3
login_process_per_connection = yes scales now better when multiple users are
Timo Sirainen <tss@iki.fi>
parents:
613
diff
changeset
|
147 { |
4538
9d9e72374164
Fixes to login process handling, especially with
Timo Sirainen <tss@iki.fi>
parents:
4388
diff
changeset
|
148 if (p->group == NULL) |
9d9e72374164
Fixes to login process handling, especially with
Timo Sirainen <tss@iki.fi>
parents:
4388
diff
changeset
|
149 return; |
9d9e72374164
Fixes to login process handling, especially with
Timo Sirainen <tss@iki.fi>
parents:
4388
diff
changeset
|
150 |
9d9e72374164
Fixes to login process handling, especially with
Timo Sirainen <tss@iki.fi>
parents:
4388
diff
changeset
|
151 if (p->state == LOGIN_STATE_LISTENING) |
9d9e72374164
Fixes to login process handling, especially with
Timo Sirainen <tss@iki.fi>
parents:
4388
diff
changeset
|
152 p->group->listening_processes--; |
9d9e72374164
Fixes to login process handling, especially with
Timo Sirainen <tss@iki.fi>
parents:
4388
diff
changeset
|
153 |
9d9e72374164
Fixes to login process handling, especially with
Timo Sirainen <tss@iki.fi>
parents:
4388
diff
changeset
|
154 if (new_state == LOGIN_STATE_FULL_PRELOGINS) { |
9d9e72374164
Fixes to login process handling, especially with
Timo Sirainen <tss@iki.fi>
parents:
4388
diff
changeset
|
155 /* add to prelogin list */ |
9d9e72374164
Fixes to login process handling, especially with
Timo Sirainen <tss@iki.fi>
parents:
4388
diff
changeset
|
156 i_assert(p->state != new_state); |
9d9e72374164
Fixes to login process handling, especially with
Timo Sirainen <tss@iki.fi>
parents:
4388
diff
changeset
|
157 |
9d9e72374164
Fixes to login process handling, especially with
Timo Sirainen <tss@iki.fi>
parents:
4388
diff
changeset
|
158 p->prev_prelogin = p->group->newest_prelogin_process; |
9d9e72374164
Fixes to login process handling, especially with
Timo Sirainen <tss@iki.fi>
parents:
4388
diff
changeset
|
159 if (p->group->newest_prelogin_process == NULL) |
9d9e72374164
Fixes to login process handling, especially with
Timo Sirainen <tss@iki.fi>
parents:
4388
diff
changeset
|
160 p->group->oldest_prelogin_process = p; |
9d9e72374164
Fixes to login process handling, especially with
Timo Sirainen <tss@iki.fi>
parents:
4388
diff
changeset
|
161 else |
9d9e72374164
Fixes to login process handling, especially with
Timo Sirainen <tss@iki.fi>
parents:
4388
diff
changeset
|
162 p->group->newest_prelogin_process->next_prelogin = p; |
9d9e72374164
Fixes to login process handling, especially with
Timo Sirainen <tss@iki.fi>
parents:
4388
diff
changeset
|
163 p->group->newest_prelogin_process = p; |
9d9e72374164
Fixes to login process handling, especially with
Timo Sirainen <tss@iki.fi>
parents:
4388
diff
changeset
|
164 } else { |
9d9e72374164
Fixes to login process handling, especially with
Timo Sirainen <tss@iki.fi>
parents:
4388
diff
changeset
|
165 process_remove_from_prelogin_lists(p); |
9d9e72374164
Fixes to login process handling, especially with
Timo Sirainen <tss@iki.fi>
parents:
4388
diff
changeset
|
166 } |
9d9e72374164
Fixes to login process handling, especially with
Timo Sirainen <tss@iki.fi>
parents:
4388
diff
changeset
|
167 } |
9d9e72374164
Fixes to login process handling, especially with
Timo Sirainen <tss@iki.fi>
parents:
4388
diff
changeset
|
168 |
9d9e72374164
Fixes to login process handling, especially with
Timo Sirainen <tss@iki.fi>
parents:
4388
diff
changeset
|
169 static void process_mark_listening(struct login_process *p) |
9d9e72374164
Fixes to login process handling, especially with
Timo Sirainen <tss@iki.fi>
parents:
4388
diff
changeset
|
170 { |
9d9e72374164
Fixes to login process handling, especially with
Timo Sirainen <tss@iki.fi>
parents:
4388
diff
changeset
|
171 if (p->group == NULL) |
9d9e72374164
Fixes to login process handling, especially with
Timo Sirainen <tss@iki.fi>
parents:
4388
diff
changeset
|
172 return; |
9d9e72374164
Fixes to login process handling, especially with
Timo Sirainen <tss@iki.fi>
parents:
4388
diff
changeset
|
173 |
9d9e72374164
Fixes to login process handling, especially with
Timo Sirainen <tss@iki.fi>
parents:
4388
diff
changeset
|
174 if (p->state != LOGIN_STATE_LISTENING) |
9d9e72374164
Fixes to login process handling, especially with
Timo Sirainen <tss@iki.fi>
parents:
4388
diff
changeset
|
175 p->group->listening_processes++; |
9d9e72374164
Fixes to login process handling, especially with
Timo Sirainen <tss@iki.fi>
parents:
4388
diff
changeset
|
176 |
9d9e72374164
Fixes to login process handling, especially with
Timo Sirainen <tss@iki.fi>
parents:
4388
diff
changeset
|
177 process_remove_from_prelogin_lists(p); |
9d9e72374164
Fixes to login process handling, especially with
Timo Sirainen <tss@iki.fi>
parents:
4388
diff
changeset
|
178 } |
9d9e72374164
Fixes to login process handling, especially with
Timo Sirainen <tss@iki.fi>
parents:
4388
diff
changeset
|
179 |
4651
2fe8f6a0bc5b
If login process dies before initialization, stall creation of them instead
Timo Sirainen <tss@iki.fi>
parents:
4649
diff
changeset
|
180 static void login_process_set_initialized(struct login_process *p) |
2fe8f6a0bc5b
If login process dies before initialization, stall creation of them instead
Timo Sirainen <tss@iki.fi>
parents:
4649
diff
changeset
|
181 { |
2fe8f6a0bc5b
If login process dies before initialization, stall creation of them instead
Timo Sirainen <tss@iki.fi>
parents:
4649
diff
changeset
|
182 p->initialized = TRUE; |
2fe8f6a0bc5b
If login process dies before initialization, stall creation of them instead
Timo Sirainen <tss@iki.fi>
parents:
4649
diff
changeset
|
183 |
2fe8f6a0bc5b
If login process dies before initialization, stall creation of them instead
Timo Sirainen <tss@iki.fi>
parents:
4649
diff
changeset
|
184 if (logins_stalled) { |
2fe8f6a0bc5b
If login process dies before initialization, stall creation of them instead
Timo Sirainen <tss@iki.fi>
parents:
4649
diff
changeset
|
185 /* processes were created successfully */ |
2fe8f6a0bc5b
If login process dies before initialization, stall creation of them instead
Timo Sirainen <tss@iki.fi>
parents:
4649
diff
changeset
|
186 i_info("Created login processes successfully, unstalling"); |
2fe8f6a0bc5b
If login process dies before initialization, stall creation of them instead
Timo Sirainen <tss@iki.fi>
parents:
4649
diff
changeset
|
187 |
2fe8f6a0bc5b
If login process dies before initialization, stall creation of them instead
Timo Sirainen <tss@iki.fi>
parents:
4649
diff
changeset
|
188 logins_stalled = FALSE; |
2fe8f6a0bc5b
If login process dies before initialization, stall creation of them instead
Timo Sirainen <tss@iki.fi>
parents:
4649
diff
changeset
|
189 timeout_remove(&to); |
2fe8f6a0bc5b
If login process dies before initialization, stall creation of them instead
Timo Sirainen <tss@iki.fi>
parents:
4649
diff
changeset
|
190 to = timeout_add(1000, login_processes_start_missing, NULL); |
2fe8f6a0bc5b
If login process dies before initialization, stall creation of them instead
Timo Sirainen <tss@iki.fi>
parents:
4649
diff
changeset
|
191 } |
2fe8f6a0bc5b
If login process dies before initialization, stall creation of them instead
Timo Sirainen <tss@iki.fi>
parents:
4649
diff
changeset
|
192 } |
2fe8f6a0bc5b
If login process dies before initialization, stall creation of them instead
Timo Sirainen <tss@iki.fi>
parents:
4649
diff
changeset
|
193 |
4538
9d9e72374164
Fixes to login process handling, especially with
Timo Sirainen <tss@iki.fi>
parents:
4388
diff
changeset
|
194 static void |
9d9e72374164
Fixes to login process handling, especially with
Timo Sirainen <tss@iki.fi>
parents:
4388
diff
changeset
|
195 login_process_set_state(struct login_process *p, enum master_login_state state) |
9d9e72374164
Fixes to login process handling, especially with
Timo Sirainen <tss@iki.fi>
parents:
4388
diff
changeset
|
196 { |
9d9e72374164
Fixes to login process handling, especially with
Timo Sirainen <tss@iki.fi>
parents:
4388
diff
changeset
|
197 if (state == p->state || state > LOGIN_STATE_COUNT || |
9d9e72374164
Fixes to login process handling, especially with
Timo Sirainen <tss@iki.fi>
parents:
4388
diff
changeset
|
198 (state < p->state && p->group->set->login_process_per_connection)) { |
9d9e72374164
Fixes to login process handling, especially with
Timo Sirainen <tss@iki.fi>
parents:
4388
diff
changeset
|
199 i_error("login: tried to change state %d -> %d " |
9d9e72374164
Fixes to login process handling, especially with
Timo Sirainen <tss@iki.fi>
parents:
4388
diff
changeset
|
200 "(if you can't login at all, see src/lib/fdpass.c)", |
9d9e72374164
Fixes to login process handling, especially with
Timo Sirainen <tss@iki.fi>
parents:
4388
diff
changeset
|
201 p->state, state); |
4640
f5772851ac91
If login process sends wrong state information, restart it.
Timo Sirainen <tss@iki.fi>
parents:
4632
diff
changeset
|
202 login_process_destroy(p); |
614
e60620644af3
login_process_per_connection = yes scales now better when multiple users are
Timo Sirainen <tss@iki.fi>
parents:
613
diff
changeset
|
203 return; |
e60620644af3
login_process_per_connection = yes scales now better when multiple users are
Timo Sirainen <tss@iki.fi>
parents:
613
diff
changeset
|
204 } |
e60620644af3
login_process_per_connection = yes scales now better when multiple users are
Timo Sirainen <tss@iki.fi>
parents:
613
diff
changeset
|
205 |
4538
9d9e72374164
Fixes to login process handling, especially with
Timo Sirainen <tss@iki.fi>
parents:
4388
diff
changeset
|
206 if (state == LOGIN_STATE_LISTENING) { |
9d9e72374164
Fixes to login process handling, especially with
Timo Sirainen <tss@iki.fi>
parents:
4388
diff
changeset
|
207 process_mark_listening(p); |
9d9e72374164
Fixes to login process handling, especially with
Timo Sirainen <tss@iki.fi>
parents:
4388
diff
changeset
|
208 } else { |
9d9e72374164
Fixes to login process handling, especially with
Timo Sirainen <tss@iki.fi>
parents:
4388
diff
changeset
|
209 process_mark_nonlistening(p, state); |
9d9e72374164
Fixes to login process handling, especially with
Timo Sirainen <tss@iki.fi>
parents:
4388
diff
changeset
|
210 } |
1275
af685269ead0
login: Wait until we're connected to auth process before executing command
Timo Sirainen <tss@iki.fi>
parents:
1273
diff
changeset
|
211 |
4538
9d9e72374164
Fixes to login process handling, especially with
Timo Sirainen <tss@iki.fi>
parents:
4388
diff
changeset
|
212 p->state = state; |
1275
af685269ead0
login: Wait until we're connected to auth process before executing command
Timo Sirainen <tss@iki.fi>
parents:
1273
diff
changeset
|
213 } |
614
e60620644af3
login_process_per_connection = yes scales now better when multiple users are
Timo Sirainen <tss@iki.fi>
parents:
613
diff
changeset
|
214 |
1610
6850142c4e25
New configuration file code. Some syntax changes, but tries to be somewhat
Timo Sirainen <tss@iki.fi>
parents:
1506
diff
changeset
|
215 static void login_process_groups_create(void) |
6850142c4e25
New configuration file code. Some syntax changes, but tries to be somewhat
Timo Sirainen <tss@iki.fi>
parents:
1506
diff
changeset
|
216 { |
6850142c4e25
New configuration file code. Some syntax changes, but tries to be somewhat
Timo Sirainen <tss@iki.fi>
parents:
1506
diff
changeset
|
217 struct server_settings *server; |
6850142c4e25
New configuration file code. Some syntax changes, but tries to be somewhat
Timo Sirainen <tss@iki.fi>
parents:
1506
diff
changeset
|
218 |
6850142c4e25
New configuration file code. Some syntax changes, but tries to be somewhat
Timo Sirainen <tss@iki.fi>
parents:
1506
diff
changeset
|
219 for (server = settings_root; server != NULL; server = server->next) { |
6850142c4e25
New configuration file code. Some syntax changes, but tries to be somewhat
Timo Sirainen <tss@iki.fi>
parents:
1506
diff
changeset
|
220 if (server->imap != NULL) |
6850142c4e25
New configuration file code. Some syntax changes, but tries to be somewhat
Timo Sirainen <tss@iki.fi>
parents:
1506
diff
changeset
|
221 login_group_create(server->imap); |
6850142c4e25
New configuration file code. Some syntax changes, but tries to be somewhat
Timo Sirainen <tss@iki.fi>
parents:
1506
diff
changeset
|
222 if (server->pop3 != NULL) |
6850142c4e25
New configuration file code. Some syntax changes, but tries to be somewhat
Timo Sirainen <tss@iki.fi>
parents:
1506
diff
changeset
|
223 login_group_create(server->pop3); |
6850142c4e25
New configuration file code. Some syntax changes, but tries to be somewhat
Timo Sirainen <tss@iki.fi>
parents:
1506
diff
changeset
|
224 } |
6850142c4e25
New configuration file code. Some syntax changes, but tries to be somewhat
Timo Sirainen <tss@iki.fi>
parents:
1506
diff
changeset
|
225 } |
6850142c4e25
New configuration file code. Some syntax changes, but tries to be somewhat
Timo Sirainen <tss@iki.fi>
parents:
1506
diff
changeset
|
226 |
6850142c4e25
New configuration file code. Some syntax changes, but tries to be somewhat
Timo Sirainen <tss@iki.fi>
parents:
1506
diff
changeset
|
227 static struct login_group * |
6850142c4e25
New configuration file code. Some syntax changes, but tries to be somewhat
Timo Sirainen <tss@iki.fi>
parents:
1506
diff
changeset
|
228 login_group_process_find(const char *name, enum mail_protocol protocol) |
1275
af685269ead0
login: Wait until we're connected to auth process before executing command
Timo Sirainen <tss@iki.fi>
parents:
1273
diff
changeset
|
229 { |
af685269ead0
login: Wait until we're connected to auth process before executing command
Timo Sirainen <tss@iki.fi>
parents:
1273
diff
changeset
|
230 struct login_group *group; |
af685269ead0
login: Wait until we're connected to auth process before executing command
Timo Sirainen <tss@iki.fi>
parents:
1273
diff
changeset
|
231 |
1610
6850142c4e25
New configuration file code. Some syntax changes, but tries to be somewhat
Timo Sirainen <tss@iki.fi>
parents:
1506
diff
changeset
|
232 if (login_groups == NULL) |
6850142c4e25
New configuration file code. Some syntax changes, but tries to be somewhat
Timo Sirainen <tss@iki.fi>
parents:
1506
diff
changeset
|
233 login_process_groups_create(); |
1275
af685269ead0
login: Wait until we're connected to auth process before executing command
Timo Sirainen <tss@iki.fi>
parents:
1273
diff
changeset
|
234 |
af685269ead0
login: Wait until we're connected to auth process before executing command
Timo Sirainen <tss@iki.fi>
parents:
1273
diff
changeset
|
235 for (group = login_groups; group != NULL; group = group->next) { |
1610
6850142c4e25
New configuration file code. Some syntax changes, but tries to be somewhat
Timo Sirainen <tss@iki.fi>
parents:
1506
diff
changeset
|
236 if (strcmp(group->set->server->name, name) == 0 && |
6850142c4e25
New configuration file code. Some syntax changes, but tries to be somewhat
Timo Sirainen <tss@iki.fi>
parents:
1506
diff
changeset
|
237 group->set->protocol == protocol) |
1275
af685269ead0
login: Wait until we're connected to auth process before executing command
Timo Sirainen <tss@iki.fi>
parents:
1273
diff
changeset
|
238 return group; |
af685269ead0
login: Wait until we're connected to auth process before executing command
Timo Sirainen <tss@iki.fi>
parents:
1273
diff
changeset
|
239 } |
af685269ead0
login: Wait until we're connected to auth process before executing command
Timo Sirainen <tss@iki.fi>
parents:
1273
diff
changeset
|
240 |
af685269ead0
login: Wait until we're connected to auth process before executing command
Timo Sirainen <tss@iki.fi>
parents:
1273
diff
changeset
|
241 return NULL; |
af685269ead0
login: Wait until we're connected to auth process before executing command
Timo Sirainen <tss@iki.fi>
parents:
1273
diff
changeset
|
242 } |
614
e60620644af3
login_process_per_connection = yes scales now better when multiple users are
Timo Sirainen <tss@iki.fi>
parents:
613
diff
changeset
|
243 |
3863
55df57c028d4
Added "bool" type and changed all ints that were used as booleans to bool.
Timo Sirainen <tss@iki.fi>
parents:
3692
diff
changeset
|
244 static bool login_process_read_group(struct login_process *p) |
1275
af685269ead0
login: Wait until we're connected to auth process before executing command
Timo Sirainen <tss@iki.fi>
parents:
1273
diff
changeset
|
245 { |
af685269ead0
login: Wait until we're connected to auth process before executing command
Timo Sirainen <tss@iki.fi>
parents:
1273
diff
changeset
|
246 struct login_group *group; |
1610
6850142c4e25
New configuration file code. Some syntax changes, but tries to be somewhat
Timo Sirainen <tss@iki.fi>
parents:
1506
diff
changeset
|
247 const char *name, *proto; |
1275
af685269ead0
login: Wait until we're connected to auth process before executing command
Timo Sirainen <tss@iki.fi>
parents:
1273
diff
changeset
|
248 char buf[256]; |
1610
6850142c4e25
New configuration file code. Some syntax changes, but tries to be somewhat
Timo Sirainen <tss@iki.fi>
parents:
1506
diff
changeset
|
249 enum mail_protocol protocol; |
1275
af685269ead0
login: Wait until we're connected to auth process before executing command
Timo Sirainen <tss@iki.fi>
parents:
1273
diff
changeset
|
250 unsigned int len; |
af685269ead0
login: Wait until we're connected to auth process before executing command
Timo Sirainen <tss@iki.fi>
parents:
1273
diff
changeset
|
251 ssize_t ret; |
af685269ead0
login: Wait until we're connected to auth process before executing command
Timo Sirainen <tss@iki.fi>
parents:
1273
diff
changeset
|
252 |
af685269ead0
login: Wait until we're connected to auth process before executing command
Timo Sirainen <tss@iki.fi>
parents:
1273
diff
changeset
|
253 /* read length */ |
af685269ead0
login: Wait until we're connected to auth process before executing command
Timo Sirainen <tss@iki.fi>
parents:
1273
diff
changeset
|
254 ret = read(p->fd, buf, 1); |
af685269ead0
login: Wait until we're connected to auth process before executing command
Timo Sirainen <tss@iki.fi>
parents:
1273
diff
changeset
|
255 if (ret != 1) |
af685269ead0
login: Wait until we're connected to auth process before executing command
Timo Sirainen <tss@iki.fi>
parents:
1273
diff
changeset
|
256 len = 0; |
af685269ead0
login: Wait until we're connected to auth process before executing command
Timo Sirainen <tss@iki.fi>
parents:
1273
diff
changeset
|
257 else { |
af685269ead0
login: Wait until we're connected to auth process before executing command
Timo Sirainen <tss@iki.fi>
parents:
1273
diff
changeset
|
258 len = buf[0]; |
af685269ead0
login: Wait until we're connected to auth process before executing command
Timo Sirainen <tss@iki.fi>
parents:
1273
diff
changeset
|
259 if (len >= sizeof(buf)) { |
1610
6850142c4e25
New configuration file code. Some syntax changes, but tries to be somewhat
Timo Sirainen <tss@iki.fi>
parents:
1506
diff
changeset
|
260 i_error("login: Server name length too large"); |
1275
af685269ead0
login: Wait until we're connected to auth process before executing command
Timo Sirainen <tss@iki.fi>
parents:
1273
diff
changeset
|
261 return FALSE; |
af685269ead0
login: Wait until we're connected to auth process before executing command
Timo Sirainen <tss@iki.fi>
parents:
1273
diff
changeset
|
262 } |
614
e60620644af3
login_process_per_connection = yes scales now better when multiple users are
Timo Sirainen <tss@iki.fi>
parents:
613
diff
changeset
|
263 |
1275
af685269ead0
login: Wait until we're connected to auth process before executing command
Timo Sirainen <tss@iki.fi>
parents:
1273
diff
changeset
|
264 ret = read(p->fd, buf, len); |
af685269ead0
login: Wait until we're connected to auth process before executing command
Timo Sirainen <tss@iki.fi>
parents:
1273
diff
changeset
|
265 } |
af685269ead0
login: Wait until we're connected to auth process before executing command
Timo Sirainen <tss@iki.fi>
parents:
1273
diff
changeset
|
266 |
af685269ead0
login: Wait until we're connected to auth process before executing command
Timo Sirainen <tss@iki.fi>
parents:
1273
diff
changeset
|
267 if (ret < 0) |
af685269ead0
login: Wait until we're connected to auth process before executing command
Timo Sirainen <tss@iki.fi>
parents:
1273
diff
changeset
|
268 i_error("login: read() failed: %m"); |
af685269ead0
login: Wait until we're connected to auth process before executing command
Timo Sirainen <tss@iki.fi>
parents:
1273
diff
changeset
|
269 else if (len == 0 || (size_t)ret != len) |
1610
6850142c4e25
New configuration file code. Some syntax changes, but tries to be somewhat
Timo Sirainen <tss@iki.fi>
parents:
1506
diff
changeset
|
270 i_error("login: Server name wasn't sent"); |
1275
af685269ead0
login: Wait until we're connected to auth process before executing command
Timo Sirainen <tss@iki.fi>
parents:
1273
diff
changeset
|
271 else { |
af685269ead0
login: Wait until we're connected to auth process before executing command
Timo Sirainen <tss@iki.fi>
parents:
1273
diff
changeset
|
272 name = t_strndup(buf, len); |
3607
a2dd3d895e00
Several fixes to make running from inetd working again
Timo Sirainen <tss@iki.fi>
parents:
3384
diff
changeset
|
273 proto = strchr(name, '/'); |
1610
6850142c4e25
New configuration file code. Some syntax changes, but tries to be somewhat
Timo Sirainen <tss@iki.fi>
parents:
1506
diff
changeset
|
274 if (proto == NULL) { |
3607
a2dd3d895e00
Several fixes to make running from inetd working again
Timo Sirainen <tss@iki.fi>
parents:
3384
diff
changeset
|
275 proto = name; |
a2dd3d895e00
Several fixes to make running from inetd working again
Timo Sirainen <tss@iki.fi>
parents:
3384
diff
changeset
|
276 name = "default"; |
a2dd3d895e00
Several fixes to make running from inetd working again
Timo Sirainen <tss@iki.fi>
parents:
3384
diff
changeset
|
277 } else { |
a2dd3d895e00
Several fixes to make running from inetd working again
Timo Sirainen <tss@iki.fi>
parents:
3384
diff
changeset
|
278 name = t_strdup_until(name, proto++); |
1610
6850142c4e25
New configuration file code. Some syntax changes, but tries to be somewhat
Timo Sirainen <tss@iki.fi>
parents:
1506
diff
changeset
|
279 } |
6850142c4e25
New configuration file code. Some syntax changes, but tries to be somewhat
Timo Sirainen <tss@iki.fi>
parents:
1506
diff
changeset
|
280 |
6850142c4e25
New configuration file code. Some syntax changes, but tries to be somewhat
Timo Sirainen <tss@iki.fi>
parents:
1506
diff
changeset
|
281 if (strcmp(proto, "imap") == 0) |
6850142c4e25
New configuration file code. Some syntax changes, but tries to be somewhat
Timo Sirainen <tss@iki.fi>
parents:
1506
diff
changeset
|
282 protocol = MAIL_PROTOCOL_IMAP; |
6850142c4e25
New configuration file code. Some syntax changes, but tries to be somewhat
Timo Sirainen <tss@iki.fi>
parents:
1506
diff
changeset
|
283 else if (strcmp(proto, "pop3") == 0) |
4353
3e542f308cb5
Starting pop3 processes from inetd started actually imap processes after
Timo Sirainen <tss@iki.fi>
parents:
4197
diff
changeset
|
284 protocol = MAIL_PROTOCOL_POP3; |
1610
6850142c4e25
New configuration file code. Some syntax changes, but tries to be somewhat
Timo Sirainen <tss@iki.fi>
parents:
1506
diff
changeset
|
285 else { |
6850142c4e25
New configuration file code. Some syntax changes, but tries to be somewhat
Timo Sirainen <tss@iki.fi>
parents:
1506
diff
changeset
|
286 i_error("login: Unknown protocol '%s'", proto); |
6850142c4e25
New configuration file code. Some syntax changes, but tries to be somewhat
Timo Sirainen <tss@iki.fi>
parents:
1506
diff
changeset
|
287 return FALSE; |
6850142c4e25
New configuration file code. Some syntax changes, but tries to be somewhat
Timo Sirainen <tss@iki.fi>
parents:
1506
diff
changeset
|
288 } |
6850142c4e25
New configuration file code. Some syntax changes, but tries to be somewhat
Timo Sirainen <tss@iki.fi>
parents:
1506
diff
changeset
|
289 |
6850142c4e25
New configuration file code. Some syntax changes, but tries to be somewhat
Timo Sirainen <tss@iki.fi>
parents:
1506
diff
changeset
|
290 group = login_group_process_find(name, protocol); |
1275
af685269ead0
login: Wait until we're connected to auth process before executing command
Timo Sirainen <tss@iki.fi>
parents:
1273
diff
changeset
|
291 if (group == NULL) { |
1610
6850142c4e25
New configuration file code. Some syntax changes, but tries to be somewhat
Timo Sirainen <tss@iki.fi>
parents:
1506
diff
changeset
|
292 i_error("login: Unknown server name '%s'", name); |
1275
af685269ead0
login: Wait until we're connected to auth process before executing command
Timo Sirainen <tss@iki.fi>
parents:
1273
diff
changeset
|
293 return FALSE; |
af685269ead0
login: Wait until we're connected to auth process before executing command
Timo Sirainen <tss@iki.fi>
parents:
1273
diff
changeset
|
294 } |
af685269ead0
login: Wait until we're connected to auth process before executing command
Timo Sirainen <tss@iki.fi>
parents:
1273
diff
changeset
|
295 |
af685269ead0
login: Wait until we're connected to auth process before executing command
Timo Sirainen <tss@iki.fi>
parents:
1273
diff
changeset
|
296 p->group = group; |
af685269ead0
login: Wait until we're connected to auth process before executing command
Timo Sirainen <tss@iki.fi>
parents:
1273
diff
changeset
|
297 return login_process_init_group(p); |
af685269ead0
login: Wait until we're connected to auth process before executing command
Timo Sirainen <tss@iki.fi>
parents:
1273
diff
changeset
|
298 } |
af685269ead0
login: Wait until we're connected to auth process before executing command
Timo Sirainen <tss@iki.fi>
parents:
1273
diff
changeset
|
299 return FALSE; |
614
e60620644af3
login_process_per_connection = yes scales now better when multiple users are
Timo Sirainen <tss@iki.fi>
parents:
613
diff
changeset
|
300 } |
e60620644af3
login_process_per_connection = yes scales now better when multiple users are
Timo Sirainen <tss@iki.fi>
parents:
613
diff
changeset
|
301 |
4649
a3d6a3462745
Send inode number in login requests and verify that they match.
Timo Sirainen <tss@iki.fi>
parents:
4640
diff
changeset
|
302 static int |
a3d6a3462745
Send inode number in login requests and verify that they match.
Timo Sirainen <tss@iki.fi>
parents:
4640
diff
changeset
|
303 login_read_request(struct login_process *p, struct master_login_request *req, |
a3d6a3462745
Send inode number in login requests and verify that they match.
Timo Sirainen <tss@iki.fi>
parents:
4640
diff
changeset
|
304 int *client_fd_r) |
a3d6a3462745
Send inode number in login requests and verify that they match.
Timo Sirainen <tss@iki.fi>
parents:
4640
diff
changeset
|
305 { |
a3d6a3462745
Send inode number in login requests and verify that they match.
Timo Sirainen <tss@iki.fi>
parents:
4640
diff
changeset
|
306 struct stat st; |
a3d6a3462745
Send inode number in login requests and verify that they match.
Timo Sirainen <tss@iki.fi>
parents:
4640
diff
changeset
|
307 ssize_t ret; |
a3d6a3462745
Send inode number in login requests and verify that they match.
Timo Sirainen <tss@iki.fi>
parents:
4640
diff
changeset
|
308 |
a3d6a3462745
Send inode number in login requests and verify that they match.
Timo Sirainen <tss@iki.fi>
parents:
4640
diff
changeset
|
309 *client_fd_r = -1; |
a3d6a3462745
Send inode number in login requests and verify that they match.
Timo Sirainen <tss@iki.fi>
parents:
4640
diff
changeset
|
310 |
a3d6a3462745
Send inode number in login requests and verify that they match.
Timo Sirainen <tss@iki.fi>
parents:
4640
diff
changeset
|
311 ret = fd_read(p->fd, req, sizeof(*req), client_fd_r); |
a3d6a3462745
Send inode number in login requests and verify that they match.
Timo Sirainen <tss@iki.fi>
parents:
4640
diff
changeset
|
312 if (ret >= (ssize_t)sizeof(req->version) && |
a3d6a3462745
Send inode number in login requests and verify that they match.
Timo Sirainen <tss@iki.fi>
parents:
4640
diff
changeset
|
313 req->version != MASTER_LOGIN_PROTOCOL_VERSION) { |
a3d6a3462745
Send inode number in login requests and verify that they match.
Timo Sirainen <tss@iki.fi>
parents:
4640
diff
changeset
|
314 i_error("login: Protocol version mismatch " |
a3d6a3462745
Send inode number in login requests and verify that they match.
Timo Sirainen <tss@iki.fi>
parents:
4640
diff
changeset
|
315 "(mixed old and new binaries?)"); |
a3d6a3462745
Send inode number in login requests and verify that they match.
Timo Sirainen <tss@iki.fi>
parents:
4640
diff
changeset
|
316 return -1; |
a3d6a3462745
Send inode number in login requests and verify that they match.
Timo Sirainen <tss@iki.fi>
parents:
4640
diff
changeset
|
317 } |
a3d6a3462745
Send inode number in login requests and verify that they match.
Timo Sirainen <tss@iki.fi>
parents:
4640
diff
changeset
|
318 |
a3d6a3462745
Send inode number in login requests and verify that they match.
Timo Sirainen <tss@iki.fi>
parents:
4640
diff
changeset
|
319 if (ret != sizeof(*req)) { |
a3d6a3462745
Send inode number in login requests and verify that they match.
Timo Sirainen <tss@iki.fi>
parents:
4640
diff
changeset
|
320 if (ret == 0) { |
a3d6a3462745
Send inode number in login requests and verify that they match.
Timo Sirainen <tss@iki.fi>
parents:
4640
diff
changeset
|
321 /* disconnected, ie. the login process died */ |
a3d6a3462745
Send inode number in login requests and verify that they match.
Timo Sirainen <tss@iki.fi>
parents:
4640
diff
changeset
|
322 } else if (ret > 0) { |
a3d6a3462745
Send inode number in login requests and verify that they match.
Timo Sirainen <tss@iki.fi>
parents:
4640
diff
changeset
|
323 /* request wasn't fully read */ |
a3d6a3462745
Send inode number in login requests and verify that they match.
Timo Sirainen <tss@iki.fi>
parents:
4640
diff
changeset
|
324 i_error("login: fd_read() returned partial %d", ret); |
a3d6a3462745
Send inode number in login requests and verify that they match.
Timo Sirainen <tss@iki.fi>
parents:
4640
diff
changeset
|
325 } else { |
a3d6a3462745
Send inode number in login requests and verify that they match.
Timo Sirainen <tss@iki.fi>
parents:
4640
diff
changeset
|
326 if (errno == EAGAIN) |
a3d6a3462745
Send inode number in login requests and verify that they match.
Timo Sirainen <tss@iki.fi>
parents:
4640
diff
changeset
|
327 return 0; |
a3d6a3462745
Send inode number in login requests and verify that they match.
Timo Sirainen <tss@iki.fi>
parents:
4640
diff
changeset
|
328 |
a3d6a3462745
Send inode number in login requests and verify that they match.
Timo Sirainen <tss@iki.fi>
parents:
4640
diff
changeset
|
329 i_error("login: fd_read() failed: %m"); |
a3d6a3462745
Send inode number in login requests and verify that they match.
Timo Sirainen <tss@iki.fi>
parents:
4640
diff
changeset
|
330 } |
a3d6a3462745
Send inode number in login requests and verify that they match.
Timo Sirainen <tss@iki.fi>
parents:
4640
diff
changeset
|
331 return -1; |
a3d6a3462745
Send inode number in login requests and verify that they match.
Timo Sirainen <tss@iki.fi>
parents:
4640
diff
changeset
|
332 } |
a3d6a3462745
Send inode number in login requests and verify that they match.
Timo Sirainen <tss@iki.fi>
parents:
4640
diff
changeset
|
333 |
a3d6a3462745
Send inode number in login requests and verify that they match.
Timo Sirainen <tss@iki.fi>
parents:
4640
diff
changeset
|
334 if (req->ino == (ino_t)-1) { |
a3d6a3462745
Send inode number in login requests and verify that they match.
Timo Sirainen <tss@iki.fi>
parents:
4640
diff
changeset
|
335 if (*client_fd_r != -1) { |
a3d6a3462745
Send inode number in login requests and verify that they match.
Timo Sirainen <tss@iki.fi>
parents:
4640
diff
changeset
|
336 i_error("login: Notification request sent " |
a3d6a3462745
Send inode number in login requests and verify that they match.
Timo Sirainen <tss@iki.fi>
parents:
4640
diff
changeset
|
337 "a file descriptor"); |
a3d6a3462745
Send inode number in login requests and verify that they match.
Timo Sirainen <tss@iki.fi>
parents:
4640
diff
changeset
|
338 return -1; |
a3d6a3462745
Send inode number in login requests and verify that they match.
Timo Sirainen <tss@iki.fi>
parents:
4640
diff
changeset
|
339 } |
a3d6a3462745
Send inode number in login requests and verify that they match.
Timo Sirainen <tss@iki.fi>
parents:
4640
diff
changeset
|
340 return 1; |
a3d6a3462745
Send inode number in login requests and verify that they match.
Timo Sirainen <tss@iki.fi>
parents:
4640
diff
changeset
|
341 } |
a3d6a3462745
Send inode number in login requests and verify that they match.
Timo Sirainen <tss@iki.fi>
parents:
4640
diff
changeset
|
342 |
a3d6a3462745
Send inode number in login requests and verify that they match.
Timo Sirainen <tss@iki.fi>
parents:
4640
diff
changeset
|
343 if (*client_fd_r == -1) { |
a3d6a3462745
Send inode number in login requests and verify that they match.
Timo Sirainen <tss@iki.fi>
parents:
4640
diff
changeset
|
344 i_error("login: Login request missing a file descriptor"); |
a3d6a3462745
Send inode number in login requests and verify that they match.
Timo Sirainen <tss@iki.fi>
parents:
4640
diff
changeset
|
345 return -1; |
a3d6a3462745
Send inode number in login requests and verify that they match.
Timo Sirainen <tss@iki.fi>
parents:
4640
diff
changeset
|
346 } |
a3d6a3462745
Send inode number in login requests and verify that they match.
Timo Sirainen <tss@iki.fi>
parents:
4640
diff
changeset
|
347 |
a3d6a3462745
Send inode number in login requests and verify that they match.
Timo Sirainen <tss@iki.fi>
parents:
4640
diff
changeset
|
348 if (fstat(*client_fd_r, &st) < 0) { |
a3d6a3462745
Send inode number in login requests and verify that they match.
Timo Sirainen <tss@iki.fi>
parents:
4640
diff
changeset
|
349 i_error("login: fstat(mail client) failed: %m"); |
a3d6a3462745
Send inode number in login requests and verify that they match.
Timo Sirainen <tss@iki.fi>
parents:
4640
diff
changeset
|
350 return -1; |
a3d6a3462745
Send inode number in login requests and verify that they match.
Timo Sirainen <tss@iki.fi>
parents:
4640
diff
changeset
|
351 } |
a3d6a3462745
Send inode number in login requests and verify that they match.
Timo Sirainen <tss@iki.fi>
parents:
4640
diff
changeset
|
352 |
a3d6a3462745
Send inode number in login requests and verify that they match.
Timo Sirainen <tss@iki.fi>
parents:
4640
diff
changeset
|
353 if (st.st_ino != req->ino) { |
a3d6a3462745
Send inode number in login requests and verify that they match.
Timo Sirainen <tss@iki.fi>
parents:
4640
diff
changeset
|
354 i_error("login: Login request inode mismatch: %s != %s", |
a3d6a3462745
Send inode number in login requests and verify that they match.
Timo Sirainen <tss@iki.fi>
parents:
4640
diff
changeset
|
355 dec2str(st.st_ino), dec2str(req->ino)); |
a3d6a3462745
Send inode number in login requests and verify that they match.
Timo Sirainen <tss@iki.fi>
parents:
4640
diff
changeset
|
356 return -1; |
a3d6a3462745
Send inode number in login requests and verify that they match.
Timo Sirainen <tss@iki.fi>
parents:
4640
diff
changeset
|
357 } |
a3d6a3462745
Send inode number in login requests and verify that they match.
Timo Sirainen <tss@iki.fi>
parents:
4640
diff
changeset
|
358 return 1; |
a3d6a3462745
Send inode number in login requests and verify that they match.
Timo Sirainen <tss@iki.fi>
parents:
4640
diff
changeset
|
359 } |
a3d6a3462745
Send inode number in login requests and verify that they match.
Timo Sirainen <tss@iki.fi>
parents:
4640
diff
changeset
|
360 |
1036
f782b3319553
Removed useless parameters from io_callback_t and timeout_callback_t.
Timo Sirainen <tss@iki.fi>
parents:
1035
diff
changeset
|
361 static void login_process_input(void *context) |
0 | 362 { |
903
fd8888f6f037
Naming style changes, finally got tired of most of the typedefs. Also the
Timo Sirainen <tss@iki.fi>
parents:
876
diff
changeset
|
363 struct login_process *p = context; |
fd8888f6f037
Naming style changes, finally got tired of most of the typedefs. Also the
Timo Sirainen <tss@iki.fi>
parents:
876
diff
changeset
|
364 struct auth_process *auth_process; |
fd8888f6f037
Naming style changes, finally got tired of most of the typedefs. Also the
Timo Sirainen <tss@iki.fi>
parents:
876
diff
changeset
|
365 struct login_auth_request *authreq; |
1035
fe49ece0f3ea
We have now separate "userdb" and "passdb". They aren't tied to each others
Timo Sirainen <tss@iki.fi>
parents:
1000
diff
changeset
|
366 struct master_login_request req; |
1275
af685269ead0
login: Wait until we're connected to auth process before executing command
Timo Sirainen <tss@iki.fi>
parents:
1273
diff
changeset
|
367 int client_fd; |
af685269ead0
login: Wait until we're connected to auth process before executing command
Timo Sirainen <tss@iki.fi>
parents:
1273
diff
changeset
|
368 ssize_t ret; |
af685269ead0
login: Wait until we're connected to auth process before executing command
Timo Sirainen <tss@iki.fi>
parents:
1273
diff
changeset
|
369 |
af685269ead0
login: Wait until we're connected to auth process before executing command
Timo Sirainen <tss@iki.fi>
parents:
1273
diff
changeset
|
370 if (p->group == NULL) { |
af685269ead0
login: Wait until we're connected to auth process before executing command
Timo Sirainen <tss@iki.fi>
parents:
1273
diff
changeset
|
371 /* we want to read the group */ |
af685269ead0
login: Wait until we're connected to auth process before executing command
Timo Sirainen <tss@iki.fi>
parents:
1273
diff
changeset
|
372 if (!login_process_read_group(p)) |
af685269ead0
login: Wait until we're connected to auth process before executing command
Timo Sirainen <tss@iki.fi>
parents:
1273
diff
changeset
|
373 login_process_destroy(p); |
af685269ead0
login: Wait until we're connected to auth process before executing command
Timo Sirainen <tss@iki.fi>
parents:
1273
diff
changeset
|
374 return; |
af685269ead0
login: Wait until we're connected to auth process before executing command
Timo Sirainen <tss@iki.fi>
parents:
1273
diff
changeset
|
375 } |
0 | 376 |
4649
a3d6a3462745
Send inode number in login requests and verify that they match.
Timo Sirainen <tss@iki.fi>
parents:
4640
diff
changeset
|
377 ret = login_read_request(p, &req, &client_fd); |
a3d6a3462745
Send inode number in login requests and verify that they match.
Timo Sirainen <tss@iki.fi>
parents:
4640
diff
changeset
|
378 if (ret == 0) |
a3d6a3462745
Send inode number in login requests and verify that they match.
Timo Sirainen <tss@iki.fi>
parents:
4640
diff
changeset
|
379 return; |
a3d6a3462745
Send inode number in login requests and verify that they match.
Timo Sirainen <tss@iki.fi>
parents:
4640
diff
changeset
|
380 if (ret < 0) { |
a3d6a3462745
Send inode number in login requests and verify that they match.
Timo Sirainen <tss@iki.fi>
parents:
4640
diff
changeset
|
381 if (client_fd != -1) { |
a3d6a3462745
Send inode number in login requests and verify that they match.
Timo Sirainen <tss@iki.fi>
parents:
4640
diff
changeset
|
382 if (close(client_fd) < 0) |
a3d6a3462745
Send inode number in login requests and verify that they match.
Timo Sirainen <tss@iki.fi>
parents:
4640
diff
changeset
|
383 i_error("login: close(mail client) failed: %m"); |
a3d6a3462745
Send inode number in login requests and verify that they match.
Timo Sirainen <tss@iki.fi>
parents:
4640
diff
changeset
|
384 } |
2779
1fd55b4341b9
Added version to login <-> master communication as well.
Timo Sirainen <tss@iki.fi>
parents:
2736
diff
changeset
|
385 login_process_destroy(p); |
1fd55b4341b9
Added version to login <-> master communication as well.
Timo Sirainen <tss@iki.fi>
parents:
2736
diff
changeset
|
386 return; |
1fd55b4341b9
Added version to login <-> master communication as well.
Timo Sirainen <tss@iki.fi>
parents:
2736
diff
changeset
|
387 } |
1fd55b4341b9
Added version to login <-> master communication as well.
Timo Sirainen <tss@iki.fi>
parents:
2736
diff
changeset
|
388 |
4649
a3d6a3462745
Send inode number in login requests and verify that they match.
Timo Sirainen <tss@iki.fi>
parents:
4640
diff
changeset
|
389 if (req.ino == (ino_t)-1) { |
a3d6a3462745
Send inode number in login requests and verify that they match.
Timo Sirainen <tss@iki.fi>
parents:
4640
diff
changeset
|
390 /* state notification */ |
4538
9d9e72374164
Fixes to login process handling, especially with
Timo Sirainen <tss@iki.fi>
parents:
4388
diff
changeset
|
391 enum master_login_state state = req.tag; |
9d9e72374164
Fixes to login process handling, especially with
Timo Sirainen <tss@iki.fi>
parents:
4388
diff
changeset
|
392 |
925
2e649dec0f09
Auth and login processes send an "we're ok" reply at the end of
Timo Sirainen <tss@iki.fi>
parents:
903
diff
changeset
|
393 if (!p->initialized) { |
2e649dec0f09
Auth and login processes send an "we're ok" reply at the end of
Timo Sirainen <tss@iki.fi>
parents:
903
diff
changeset
|
394 /* initialization notify */ |
4651
2fe8f6a0bc5b
If login process dies before initialization, stall creation of them instead
Timo Sirainen <tss@iki.fi>
parents:
4649
diff
changeset
|
395 login_process_set_initialized(p); |
925
2e649dec0f09
Auth and login processes send an "we're ok" reply at the end of
Timo Sirainen <tss@iki.fi>
parents:
903
diff
changeset
|
396 } else { |
4538
9d9e72374164
Fixes to login process handling, especially with
Timo Sirainen <tss@iki.fi>
parents:
4388
diff
changeset
|
397 /* change "listening for new connections" status */ |
9d9e72374164
Fixes to login process handling, especially with
Timo Sirainen <tss@iki.fi>
parents:
4388
diff
changeset
|
398 login_process_set_state(p, state); |
925
2e649dec0f09
Auth and login processes send an "we're ok" reply at the end of
Timo Sirainen <tss@iki.fi>
parents:
903
diff
changeset
|
399 } |
613
1906116a62ce
Finally support for handling each login connection in it's own process.
Timo Sirainen <tss@iki.fi>
parents:
596
diff
changeset
|
400 return; |
1906116a62ce
Finally support for handling each login connection in it's own process.
Timo Sirainen <tss@iki.fi>
parents:
596
diff
changeset
|
401 } |
1906116a62ce
Finally support for handling each login connection in it's own process.
Timo Sirainen <tss@iki.fi>
parents:
596
diff
changeset
|
402 |
4661
885bef091d1a
Make sure we don't kill login processes that haven't yet even sent their
Timo Sirainen <tss@iki.fi>
parents:
4651
diff
changeset
|
403 if (!p->initialized) { |
885bef091d1a
Make sure we don't kill login processes that haven't yet even sent their
Timo Sirainen <tss@iki.fi>
parents:
4651
diff
changeset
|
404 i_error("login: trying to log in before initialization"); |
885bef091d1a
Make sure we don't kill login processes that haven't yet even sent their
Timo Sirainen <tss@iki.fi>
parents:
4651
diff
changeset
|
405 login_process_destroy(p); |
885bef091d1a
Make sure we don't kill login processes that haven't yet even sent their
Timo Sirainen <tss@iki.fi>
parents:
4651
diff
changeset
|
406 return; |
885bef091d1a
Make sure we don't kill login processes that haven't yet even sent their
Timo Sirainen <tss@iki.fi>
parents:
4651
diff
changeset
|
407 } |
885bef091d1a
Make sure we don't kill login processes that haven't yet even sent their
Timo Sirainen <tss@iki.fi>
parents:
4651
diff
changeset
|
408 |
1035
fe49ece0f3ea
We have now separate "userdb" and "passdb". They aren't tied to each others
Timo Sirainen <tss@iki.fi>
parents:
1000
diff
changeset
|
409 fd_close_on_exec(client_fd, TRUE); |
0 | 410 |
411 /* ask the cookie from the auth process */ | |
903
fd8888f6f037
Naming style changes, finally got tired of most of the typedefs. Also the
Timo Sirainen <tss@iki.fi>
parents:
876
diff
changeset
|
412 authreq = i_new(struct login_auth_request, 1); |
0 | 413 p->refcount++; |
414 authreq->process = p; | |
1035
fe49ece0f3ea
We have now separate "userdb" and "passdb". They aren't tied to each others
Timo Sirainen <tss@iki.fi>
parents:
1000
diff
changeset
|
415 authreq->tag = ++auth_id_counter; |
fe49ece0f3ea
We have now separate "userdb" and "passdb". They aren't tied to each others
Timo Sirainen <tss@iki.fi>
parents:
1000
diff
changeset
|
416 authreq->login_tag = req.tag; |
0 | 417 authreq->fd = client_fd; |
2097
4e77cb0aff21
Added %l, %r and %P variables and mail_log_prefix setting.
Timo Sirainen <tss@iki.fi>
parents:
2046
diff
changeset
|
418 authreq->local_ip = req.local_ip; |
4e77cb0aff21
Added %l, %r and %P variables and mail_log_prefix setting.
Timo Sirainen <tss@iki.fi>
parents:
2046
diff
changeset
|
419 authreq->remote_ip = req.remote_ip; |
0 | 420 |
1035
fe49ece0f3ea
We have now separate "userdb" and "passdb". They aren't tied to each others
Timo Sirainen <tss@iki.fi>
parents:
1000
diff
changeset
|
421 auth_process = auth_process_find(req.auth_pid); |
0 | 422 if (auth_process == NULL) { |
423 i_error("login: Authentication process %u doesn't exist", | |
1035
fe49ece0f3ea
We have now separate "userdb" and "passdb". They aren't tied to each others
Timo Sirainen <tss@iki.fi>
parents:
1000
diff
changeset
|
424 req.auth_pid); |
fe49ece0f3ea
We have now separate "userdb" and "passdb". They aren't tied to each others
Timo Sirainen <tss@iki.fi>
parents:
1000
diff
changeset
|
425 auth_master_callback(NULL, NULL, authreq); |
0 | 426 } else { |
1035
fe49ece0f3ea
We have now separate "userdb" and "passdb". They aren't tied to each others
Timo Sirainen <tss@iki.fi>
parents:
1000
diff
changeset
|
427 auth_process_request(auth_process, p->pid, |
fe49ece0f3ea
We have now separate "userdb" and "passdb". They aren't tied to each others
Timo Sirainen <tss@iki.fi>
parents:
1000
diff
changeset
|
428 req.auth_id, authreq); |
0 | 429 } |
430 } | |
431 | |
1055
a72bba3f8a55
Rewrote setting handling. Changed some existing settings also since POP3
Timo Sirainen <tss@iki.fi>
parents:
1039
diff
changeset
|
432 static struct login_process * |
a72bba3f8a55
Rewrote setting handling. Changed some existing settings also since POP3
Timo Sirainen <tss@iki.fi>
parents:
1039
diff
changeset
|
433 login_process_new(struct login_group *group, pid_t pid, int fd) |
0 | 434 { |
903
fd8888f6f037
Naming style changes, finally got tired of most of the typedefs. Also the
Timo Sirainen <tss@iki.fi>
parents:
876
diff
changeset
|
435 struct login_process *p; |
0 | 436 |
1273
2cf2e08a6ee9
Somewhat working code to support loading Dovecot from inetd and such. It
Timo Sirainen <tss@iki.fi>
parents:
1237
diff
changeset
|
437 i_assert(pid != 0); |
0 | 438 |
903
fd8888f6f037
Naming style changes, finally got tired of most of the typedefs. Also the
Timo Sirainen <tss@iki.fi>
parents:
876
diff
changeset
|
439 p = i_new(struct login_process, 1); |
1055
a72bba3f8a55
Rewrote setting handling. Changed some existing settings also since POP3
Timo Sirainen <tss@iki.fi>
parents:
1039
diff
changeset
|
440 p->group = group; |
0 | 441 p->refcount = 1; |
442 p->pid = pid; | |
443 p->fd = fd; | |
444 p->io = io_add(fd, IO_READ, login_process_input, p); | |
764
f57c52738f90
Renamed IBuffer and OBuffer to IStream and OStream which describes their
Timo Sirainen <tss@iki.fi>
parents:
747
diff
changeset
|
445 p->output = o_stream_create_file(fd, default_pool, |
1035
fe49ece0f3ea
We have now separate "userdb" and "passdb". They aren't tied to each others
Timo Sirainen <tss@iki.fi>
parents:
1000
diff
changeset
|
446 sizeof(struct master_login_reply)*10, |
1499
e850252cdc7e
Removed I/O priorities. They were pretty much useless and were just getting
Timo Sirainen <tss@iki.fi>
parents:
1468
diff
changeset
|
447 FALSE); |
0 | 448 |
1273
2cf2e08a6ee9
Somewhat working code to support loading Dovecot from inetd and such. It
Timo Sirainen <tss@iki.fi>
parents:
1237
diff
changeset
|
449 PID_ADD_PROCESS_TYPE(pid, PROCESS_TYPE_LOGIN); |
195
db6e288be0e9
Replaced INT_TO_POINTER and POINTER_TO_INT macros with POINTER_CAST and
Timo Sirainen <tss@iki.fi>
parents:
10
diff
changeset
|
450 hash_insert(processes, POINTER_CAST(pid), p); |
1273
2cf2e08a6ee9
Somewhat working code to support loading Dovecot from inetd and such. It
Timo Sirainen <tss@iki.fi>
parents:
1237
diff
changeset
|
451 |
4538
9d9e72374164
Fixes to login process handling, especially with
Timo Sirainen <tss@iki.fi>
parents:
4388
diff
changeset
|
452 p->state = LOGIN_STATE_LISTENING; |
9d9e72374164
Fixes to login process handling, especially with
Timo Sirainen <tss@iki.fi>
parents:
4388
diff
changeset
|
453 |
1275
af685269ead0
login: Wait until we're connected to auth process before executing command
Timo Sirainen <tss@iki.fi>
parents:
1273
diff
changeset
|
454 if (p->group != NULL) { |
4631
f5d53a684856
SIGHUP caused memory corruption
Timo Sirainen <tss@iki.fi>
parents:
4630
diff
changeset
|
455 p->group->refcount++; |
1275
af685269ead0
login: Wait until we're connected to auth process before executing command
Timo Sirainen <tss@iki.fi>
parents:
1273
diff
changeset
|
456 p->group->processes++; |
af685269ead0
login: Wait until we're connected to auth process before executing command
Timo Sirainen <tss@iki.fi>
parents:
1273
diff
changeset
|
457 p->group->listening_processes++; |
af685269ead0
login: Wait until we're connected to auth process before executing command
Timo Sirainen <tss@iki.fi>
parents:
1273
diff
changeset
|
458 } |
0 | 459 return p; |
460 } | |
461 | |
4538
9d9e72374164
Fixes to login process handling, especially with
Timo Sirainen <tss@iki.fi>
parents:
4388
diff
changeset
|
462 static void login_process_exited(struct login_process *p) |
613
1906116a62ce
Finally support for handling each login connection in it's own process.
Timo Sirainen <tss@iki.fi>
parents:
596
diff
changeset
|
463 { |
4538
9d9e72374164
Fixes to login process handling, especially with
Timo Sirainen <tss@iki.fi>
parents:
4388
diff
changeset
|
464 if (p->group != NULL) |
9d9e72374164
Fixes to login process handling, especially with
Timo Sirainen <tss@iki.fi>
parents:
4388
diff
changeset
|
465 p->group->processes--; |
1275
af685269ead0
login: Wait until we're connected to auth process before executing command
Timo Sirainen <tss@iki.fi>
parents:
1273
diff
changeset
|
466 |
4538
9d9e72374164
Fixes to login process handling, especially with
Timo Sirainen <tss@iki.fi>
parents:
4388
diff
changeset
|
467 hash_remove(processes, POINTER_CAST(p->pid)); |
9d9e72374164
Fixes to login process handling, especially with
Timo Sirainen <tss@iki.fi>
parents:
4388
diff
changeset
|
468 login_process_unref(p); |
613
1906116a62ce
Finally support for handling each login connection in it's own process.
Timo Sirainen <tss@iki.fi>
parents:
596
diff
changeset
|
469 } |
1906116a62ce
Finally support for handling each login connection in it's own process.
Timo Sirainen <tss@iki.fi>
parents:
596
diff
changeset
|
470 |
903
fd8888f6f037
Naming style changes, finally got tired of most of the typedefs. Also the
Timo Sirainen <tss@iki.fi>
parents:
876
diff
changeset
|
471 static void login_process_destroy(struct login_process *p) |
0 | 472 { |
473 if (p->destroyed) | |
474 return; | |
475 p->destroyed = TRUE; | |
476 | |
4651
2fe8f6a0bc5b
If login process dies before initialization, stall creation of them instead
Timo Sirainen <tss@iki.fi>
parents:
4649
diff
changeset
|
477 if (!p->initialized) |
2fe8f6a0bc5b
If login process dies before initialization, stall creation of them instead
Timo Sirainen <tss@iki.fi>
parents:
4649
diff
changeset
|
478 login_processes_stall(); |
1275
af685269ead0
login: Wait until we're connected to auth process before executing command
Timo Sirainen <tss@iki.fi>
parents:
1273
diff
changeset
|
479 |
764
f57c52738f90
Renamed IBuffer and OBuffer to IStream and OStream which describes their
Timo Sirainen <tss@iki.fi>
parents:
747
diff
changeset
|
480 o_stream_close(p->output); |
3879
928229f8b3e6
deinit, unref, destroy, close, free, etc. functions now take a pointer to
Timo Sirainen <tss@iki.fi>
parents:
3863
diff
changeset
|
481 io_remove(&p->io); |
805
5ac361acb316
Marked all non-trivial buffer modifications with @UNSAFE tag. Several
Timo Sirainen <tss@iki.fi>
parents:
801
diff
changeset
|
482 if (close(p->fd) < 0) |
5ac361acb316
Marked all non-trivial buffer modifications with @UNSAFE tag. Several
Timo Sirainen <tss@iki.fi>
parents:
801
diff
changeset
|
483 i_error("close(login) failed: %m"); |
0 | 484 |
4538
9d9e72374164
Fixes to login process handling, especially with
Timo Sirainen <tss@iki.fi>
parents:
4388
diff
changeset
|
485 process_mark_nonlistening(p, LOGIN_STATE_FULL_LOGINS); |
613
1906116a62ce
Finally support for handling each login connection in it's own process.
Timo Sirainen <tss@iki.fi>
parents:
596
diff
changeset
|
486 |
4538
9d9e72374164
Fixes to login process handling, especially with
Timo Sirainen <tss@iki.fi>
parents:
4388
diff
changeset
|
487 if (p->inetd_child) |
9d9e72374164
Fixes to login process handling, especially with
Timo Sirainen <tss@iki.fi>
parents:
4388
diff
changeset
|
488 login_process_exited(p); |
0 | 489 } |
490 | |
903
fd8888f6f037
Naming style changes, finally got tired of most of the typedefs. Also the
Timo Sirainen <tss@iki.fi>
parents:
876
diff
changeset
|
491 static void login_process_unref(struct login_process *p) |
0 | 492 { |
493 if (--p->refcount > 0) | |
494 return; | |
495 | |
4631
f5d53a684856
SIGHUP caused memory corruption
Timo Sirainen <tss@iki.fi>
parents:
4630
diff
changeset
|
496 if (p->group != NULL) |
f5d53a684856
SIGHUP caused memory corruption
Timo Sirainen <tss@iki.fi>
parents:
4630
diff
changeset
|
497 login_group_unref(p->group); |
f5d53a684856
SIGHUP caused memory corruption
Timo Sirainen <tss@iki.fi>
parents:
4630
diff
changeset
|
498 |
3879
928229f8b3e6
deinit, unref, destroy, close, free, etc. functions now take a pointer to
Timo Sirainen <tss@iki.fi>
parents:
3863
diff
changeset
|
499 o_stream_unref(&p->output); |
0 | 500 i_free(p); |
501 } | |
502 | |
1273
2cf2e08a6ee9
Somewhat working code to support loading Dovecot from inetd and such. It
Timo Sirainen <tss@iki.fi>
parents:
1237
diff
changeset
|
503 static void login_process_init_env(struct login_group *group, pid_t pid) |
2cf2e08a6ee9
Somewhat working code to support loading Dovecot from inetd and such. It
Timo Sirainen <tss@iki.fi>
parents:
1237
diff
changeset
|
504 { |
1610
6850142c4e25
New configuration file code. Some syntax changes, but tries to be somewhat
Timo Sirainen <tss@iki.fi>
parents:
1506
diff
changeset
|
505 struct settings *set = group->set; |
6850142c4e25
New configuration file code. Some syntax changes, but tries to be somewhat
Timo Sirainen <tss@iki.fi>
parents:
1506
diff
changeset
|
506 |
2000
c7c19f5071c3
Write all logging through master process. Fixes problems with log rotation,
Timo Sirainen <tss@iki.fi>
parents:
1997
diff
changeset
|
507 child_process_init_env(); |
1273
2cf2e08a6ee9
Somewhat working code to support loading Dovecot from inetd and such. It
Timo Sirainen <tss@iki.fi>
parents:
1237
diff
changeset
|
508 |
2cf2e08a6ee9
Somewhat working code to support loading Dovecot from inetd and such. It
Timo Sirainen <tss@iki.fi>
parents:
1237
diff
changeset
|
509 /* setup access environment - needs to be done after |
3692 | 510 clean_child_process() since it clears environment. Don't set user |
511 parameter since we don't want to call initgroups() for login | |
3691
e167b71e37e3
Don't call initgroups() at the start of login processes.
Timo Sirainen <tss@iki.fi>
parents:
3607
diff
changeset
|
512 processes. */ |
e167b71e37e3
Don't call initgroups() at the start of login processes.
Timo Sirainen <tss@iki.fi>
parents:
3607
diff
changeset
|
513 restrict_access_set_env(NULL, set->login_uid, |
1724
b3526668de78
Make sure auth process and login process don't share uids.
Timo Sirainen <tss@iki.fi>
parents:
1610
diff
changeset
|
514 set->server->login_gid, |
1506
e7c627bacaaf
Allow first_valid_gid to be 0. Drop any supplementary groups not in valid
Timo Sirainen <tss@iki.fi>
parents:
1499
diff
changeset
|
515 set->login_chroot ? set->login_dir : NULL, |
2141
8690d2000e33
Added mail_extra_groups setting.
Timo Sirainen <tss@iki.fi>
parents:
2097
diff
changeset
|
516 0, 0, NULL); |
1273
2cf2e08a6ee9
Somewhat working code to support loading Dovecot from inetd and such. It
Timo Sirainen <tss@iki.fi>
parents:
1237
diff
changeset
|
517 |
2cf2e08a6ee9
Somewhat working code to support loading Dovecot from inetd and such. It
Timo Sirainen <tss@iki.fi>
parents:
1237
diff
changeset
|
518 env_put("DOVECOT_MASTER=1"); |
2cf2e08a6ee9
Somewhat working code to support loading Dovecot from inetd and such. It
Timo Sirainen <tss@iki.fi>
parents:
1237
diff
changeset
|
519 |
2cf2e08a6ee9
Somewhat working code to support loading Dovecot from inetd and such. It
Timo Sirainen <tss@iki.fi>
parents:
1237
diff
changeset
|
520 if (!set->ssl_disable) { |
4388
af61031c746f
Settings parser nowadays returns "" instead of NULL when it reads an empty
Timo Sirainen <tss@iki.fi>
parents:
4353
diff
changeset
|
521 const char *ssl_key_password; |
3889
c7462001227b
Added support for password protected SSL private keys. The password can be
Timo Sirainen <tss@iki.fi>
parents:
3879
diff
changeset
|
522 |
4388
af61031c746f
Settings parser nowadays returns "" instead of NULL when it reads an empty
Timo Sirainen <tss@iki.fi>
parents:
4353
diff
changeset
|
523 ssl_key_password = *set->ssl_key_password != '\0' ? |
3889
c7462001227b
Added support for password protected SSL private keys. The password can be
Timo Sirainen <tss@iki.fi>
parents:
3879
diff
changeset
|
524 set->ssl_key_password : ssl_manual_key_password; |
c7462001227b
Added support for password protected SSL private keys. The password can be
Timo Sirainen <tss@iki.fi>
parents:
3879
diff
changeset
|
525 |
4388
af61031c746f
Settings parser nowadays returns "" instead of NULL when it reads an empty
Timo Sirainen <tss@iki.fi>
parents:
4353
diff
changeset
|
526 if (*set->ssl_ca_file != '\0') { |
1907
190f1d315ce6
Added setting ssl_ca_file, patch by Zach Bagnall
Timo Sirainen <tss@iki.fi>
parents:
1897
diff
changeset
|
527 env_put(t_strconcat("SSL_CA_FILE=", |
190f1d315ce6
Added setting ssl_ca_file, patch by Zach Bagnall
Timo Sirainen <tss@iki.fi>
parents:
1897
diff
changeset
|
528 set->ssl_ca_file, NULL)); |
190f1d315ce6
Added setting ssl_ca_file, patch by Zach Bagnall
Timo Sirainen <tss@iki.fi>
parents:
1897
diff
changeset
|
529 } |
1273
2cf2e08a6ee9
Somewhat working code to support loading Dovecot from inetd and such. It
Timo Sirainen <tss@iki.fi>
parents:
1237
diff
changeset
|
530 env_put(t_strconcat("SSL_CERT_FILE=", |
2cf2e08a6ee9
Somewhat working code to support loading Dovecot from inetd and such. It
Timo Sirainen <tss@iki.fi>
parents:
1237
diff
changeset
|
531 set->ssl_cert_file, NULL)); |
1610
6850142c4e25
New configuration file code. Some syntax changes, but tries to be somewhat
Timo Sirainen <tss@iki.fi>
parents:
1506
diff
changeset
|
532 env_put(t_strconcat("SSL_KEY_FILE=", |
6850142c4e25
New configuration file code. Some syntax changes, but tries to be somewhat
Timo Sirainen <tss@iki.fi>
parents:
1506
diff
changeset
|
533 set->ssl_key_file, NULL)); |
3889
c7462001227b
Added support for password protected SSL private keys. The password can be
Timo Sirainen <tss@iki.fi>
parents:
3879
diff
changeset
|
534 env_put(t_strconcat("SSL_KEY_PASSWORD=", |
c7462001227b
Added support for password protected SSL private keys. The password can be
Timo Sirainen <tss@iki.fi>
parents:
3879
diff
changeset
|
535 ssl_key_password, NULL)); |
3901
0ae5f5b468b7
Put ssl-parameters file into login directory so it still can be accessed
Timo Sirainen <tss@iki.fi>
parents:
3889
diff
changeset
|
536 env_put("SSL_PARAM_FILE="SSL_PARAMETERS_FILENAME); |
4388
af61031c746f
Settings parser nowadays returns "" instead of NULL when it reads an empty
Timo Sirainen <tss@iki.fi>
parents:
4353
diff
changeset
|
537 if (*set->ssl_cipher_list != '\0') { |
1996 | 538 env_put(t_strconcat("SSL_CIPHER_LIST=", |
539 set->ssl_cipher_list, NULL)); | |
540 } | |
1997
1d0985f6bdd9
Added ssl_verify_client_cert setting.
Timo Sirainen <tss@iki.fi>
parents:
1996
diff
changeset
|
541 if (set->ssl_verify_client_cert) |
1d0985f6bdd9
Added ssl_verify_client_cert setting.
Timo Sirainen <tss@iki.fi>
parents:
1996
diff
changeset
|
542 env_put("SSL_VERIFY_CLIENT_CERT=1"); |
1273
2cf2e08a6ee9
Somewhat working code to support loading Dovecot from inetd and such. It
Timo Sirainen <tss@iki.fi>
parents:
1237
diff
changeset
|
543 } |
2cf2e08a6ee9
Somewhat working code to support loading Dovecot from inetd and such. It
Timo Sirainen <tss@iki.fi>
parents:
1237
diff
changeset
|
544 |
2cf2e08a6ee9
Somewhat working code to support loading Dovecot from inetd and such. It
Timo Sirainen <tss@iki.fi>
parents:
1237
diff
changeset
|
545 if (set->disable_plaintext_auth) |
2cf2e08a6ee9
Somewhat working code to support loading Dovecot from inetd and such. It
Timo Sirainen <tss@iki.fi>
parents:
1237
diff
changeset
|
546 env_put("DISABLE_PLAINTEXT_AUTH=1"); |
2cf2e08a6ee9
Somewhat working code to support loading Dovecot from inetd and such. It
Timo Sirainen <tss@iki.fi>
parents:
1237
diff
changeset
|
547 if (set->verbose_proctitle) |
2cf2e08a6ee9
Somewhat working code to support loading Dovecot from inetd and such. It
Timo Sirainen <tss@iki.fi>
parents:
1237
diff
changeset
|
548 env_put("VERBOSE_PROCTITLE=1"); |
2cf2e08a6ee9
Somewhat working code to support loading Dovecot from inetd and such. It
Timo Sirainen <tss@iki.fi>
parents:
1237
diff
changeset
|
549 if (set->verbose_ssl) |
2cf2e08a6ee9
Somewhat working code to support loading Dovecot from inetd and such. It
Timo Sirainen <tss@iki.fi>
parents:
1237
diff
changeset
|
550 env_put("VERBOSE_SSL=1"); |
2691
46f879c46b45
auth_verbose now affects imap/pop3 login processes too. Every authentication
Timo Sirainen <tss@iki.fi>
parents:
2674
diff
changeset
|
551 if (set->server->auths->verbose) |
46f879c46b45
auth_verbose now affects imap/pop3 login processes too. Every authentication
Timo Sirainen <tss@iki.fi>
parents:
2674
diff
changeset
|
552 env_put("VERBOSE_AUTH=1"); |
1273
2cf2e08a6ee9
Somewhat working code to support loading Dovecot from inetd and such. It
Timo Sirainen <tss@iki.fi>
parents:
1237
diff
changeset
|
553 |
1610
6850142c4e25
New configuration file code. Some syntax changes, but tries to be somewhat
Timo Sirainen <tss@iki.fi>
parents:
1506
diff
changeset
|
554 if (set->login_process_per_connection) { |
1273
2cf2e08a6ee9
Somewhat working code to support loading Dovecot from inetd and such. It
Timo Sirainen <tss@iki.fi>
parents:
1237
diff
changeset
|
555 env_put("PROCESS_PER_CONNECTION=1"); |
2cf2e08a6ee9
Somewhat working code to support loading Dovecot from inetd and such. It
Timo Sirainen <tss@iki.fi>
parents:
1237
diff
changeset
|
556 env_put("MAX_LOGGING_USERS=1"); |
2cf2e08a6ee9
Somewhat working code to support loading Dovecot from inetd and such. It
Timo Sirainen <tss@iki.fi>
parents:
1237
diff
changeset
|
557 } else { |
4538
9d9e72374164
Fixes to login process handling, especially with
Timo Sirainen <tss@iki.fi>
parents:
4388
diff
changeset
|
558 env_put(t_strdup_printf("MAX_CONNECTIONS=%u", |
9d9e72374164
Fixes to login process handling, especially with
Timo Sirainen <tss@iki.fi>
parents:
4388
diff
changeset
|
559 set->login_max_connections)); |
1273
2cf2e08a6ee9
Somewhat working code to support loading Dovecot from inetd and such. It
Timo Sirainen <tss@iki.fi>
parents:
1237
diff
changeset
|
560 } |
2cf2e08a6ee9
Somewhat working code to support loading Dovecot from inetd and such. It
Timo Sirainen <tss@iki.fi>
parents:
1237
diff
changeset
|
561 |
2674
857f5f7b512b
Added login_greeting and login_greeting_capability settings.
Timo Sirainen <tss@iki.fi>
parents:
2329
diff
changeset
|
562 env_put(t_strconcat("PROCESS_UID=", dec2str(pid), NULL)); |
857f5f7b512b
Added login_greeting and login_greeting_capability settings.
Timo Sirainen <tss@iki.fi>
parents:
2329
diff
changeset
|
563 env_put(t_strconcat("GREETING=", set->login_greeting, NULL)); |
3384
3b75956d20c4
Added configurable logging for login process. Added configurable pop3 logout
Timo Sirainen <tss@iki.fi>
parents:
3083
diff
changeset
|
564 env_put(t_strconcat("LOG_FORMAT_ELEMENTS=", |
3b75956d20c4
Added configurable logging for login process. Added configurable pop3 logout
Timo Sirainen <tss@iki.fi>
parents:
3083
diff
changeset
|
565 set->login_log_format_elements, NULL)); |
3b75956d20c4
Added configurable logging for login process. Added configurable pop3 logout
Timo Sirainen <tss@iki.fi>
parents:
3083
diff
changeset
|
566 env_put(t_strconcat("LOG_FORMAT=", set->login_log_format, NULL)); |
2674
857f5f7b512b
Added login_greeting and login_greeting_capability settings.
Timo Sirainen <tss@iki.fi>
parents:
2329
diff
changeset
|
567 if (set->login_greeting_capability) |
857f5f7b512b
Added login_greeting and login_greeting_capability settings.
Timo Sirainen <tss@iki.fi>
parents:
2329
diff
changeset
|
568 env_put("GREETING_CAPABILITY=1"); |
4197
c3ded5b815aa
If we have plugins set and imap_capability unset, figure out the IMAP
Timo Sirainen <tss@iki.fi>
parents:
4148
diff
changeset
|
569 |
c3ded5b815aa
If we have plugins set and imap_capability unset, figure out the IMAP
Timo Sirainen <tss@iki.fi>
parents:
4148
diff
changeset
|
570 if (group->process_type == PROCESS_TYPE_IMAP) { |
c3ded5b815aa
If we have plugins set and imap_capability unset, figure out the IMAP
Timo Sirainen <tss@iki.fi>
parents:
4148
diff
changeset
|
571 env_put(t_strconcat("CAPABILITY_STRING=", |
c3ded5b815aa
If we have plugins set and imap_capability unset, figure out the IMAP
Timo Sirainen <tss@iki.fi>
parents:
4148
diff
changeset
|
572 *set->imap_capability != '\0' ? |
c3ded5b815aa
If we have plugins set and imap_capability unset, figure out the IMAP
Timo Sirainen <tss@iki.fi>
parents:
4148
diff
changeset
|
573 set->imap_capability : |
c3ded5b815aa
If we have plugins set and imap_capability unset, figure out the IMAP
Timo Sirainen <tss@iki.fi>
parents:
4148
diff
changeset
|
574 set->imap_generated_capability, NULL)); |
c3ded5b815aa
If we have plugins set and imap_capability unset, figure out the IMAP
Timo Sirainen <tss@iki.fi>
parents:
4148
diff
changeset
|
575 } |
1273
2cf2e08a6ee9
Somewhat working code to support loading Dovecot from inetd and such. It
Timo Sirainen <tss@iki.fi>
parents:
1237
diff
changeset
|
576 } |
2cf2e08a6ee9
Somewhat working code to support loading Dovecot from inetd and such. It
Timo Sirainen <tss@iki.fi>
parents:
1237
diff
changeset
|
577 |
1055
a72bba3f8a55
Rewrote setting handling. Changed some existing settings also since POP3
Timo Sirainen <tss@iki.fi>
parents:
1039
diff
changeset
|
578 static pid_t create_login_process(struct login_group *group) |
0 | 579 { |
2046 | 580 struct log_io *log; |
3083
a20882c4f092
Disable log throttlong for auth process, and for login processes if
Timo Sirainen <tss@iki.fi>
parents:
2886
diff
changeset
|
581 unsigned int max_log_lines_per_sec; |
2000
c7c19f5071c3
Write all logging through master process. Fixes problems with log rotation,
Timo Sirainen <tss@iki.fi>
parents:
1997
diff
changeset
|
582 const char *prefix; |
0 | 583 pid_t pid; |
2000
c7c19f5071c3
Write all logging through master process. Fixes problems with log rotation,
Timo Sirainen <tss@iki.fi>
parents:
1997
diff
changeset
|
584 int fd[2], log_fd; |
0 | 585 |
1610
6850142c4e25
New configuration file code. Some syntax changes, but tries to be somewhat
Timo Sirainen <tss@iki.fi>
parents:
1506
diff
changeset
|
586 if (group->set->login_uid == 0) |
0 | 587 i_fatal("Login process must not run as root"); |
588 | |
589 /* create communication to process with a socket pair */ | |
2000
c7c19f5071c3
Write all logging through master process. Fixes problems with log rotation,
Timo Sirainen <tss@iki.fi>
parents:
1997
diff
changeset
|
590 if (socketpair(AF_UNIX, SOCK_STREAM, 0, fd) < 0) { |
0 | 591 i_error("socketpair() failed: %m"); |
592 return -1; | |
593 } | |
594 | |
3083
a20882c4f092
Disable log throttlong for auth process, and for login processes if
Timo Sirainen <tss@iki.fi>
parents:
2886
diff
changeset
|
595 max_log_lines_per_sec = |
a20882c4f092
Disable log throttlong for auth process, and for login processes if
Timo Sirainen <tss@iki.fi>
parents:
2886
diff
changeset
|
596 group->set->login_process_per_connection ? 10 : 0; |
a20882c4f092
Disable log throttlong for auth process, and for login processes if
Timo Sirainen <tss@iki.fi>
parents:
2886
diff
changeset
|
597 log_fd = log_create_pipe(&log, max_log_lines_per_sec); |
2000
c7c19f5071c3
Write all logging through master process. Fixes problems with log rotation,
Timo Sirainen <tss@iki.fi>
parents:
1997
diff
changeset
|
598 if (log_fd < 0) |
c7c19f5071c3
Write all logging through master process. Fixes problems with log rotation,
Timo Sirainen <tss@iki.fi>
parents:
1997
diff
changeset
|
599 pid = -1; |
c7c19f5071c3
Write all logging through master process. Fixes problems with log rotation,
Timo Sirainen <tss@iki.fi>
parents:
1997
diff
changeset
|
600 else { |
c7c19f5071c3
Write all logging through master process. Fixes problems with log rotation,
Timo Sirainen <tss@iki.fi>
parents:
1997
diff
changeset
|
601 pid = fork(); |
c7c19f5071c3
Write all logging through master process. Fixes problems with log rotation,
Timo Sirainen <tss@iki.fi>
parents:
1997
diff
changeset
|
602 if (pid < 0) |
c7c19f5071c3
Write all logging through master process. Fixes problems with log rotation,
Timo Sirainen <tss@iki.fi>
parents:
1997
diff
changeset
|
603 i_error("fork() failed: %m"); |
c7c19f5071c3
Write all logging through master process. Fixes problems with log rotation,
Timo Sirainen <tss@iki.fi>
parents:
1997
diff
changeset
|
604 } |
c7c19f5071c3
Write all logging through master process. Fixes problems with log rotation,
Timo Sirainen <tss@iki.fi>
parents:
1997
diff
changeset
|
605 |
0 | 606 if (pid < 0) { |
607 (void)close(fd[0]); | |
608 (void)close(fd[1]); | |
2000
c7c19f5071c3
Write all logging through master process. Fixes problems with log rotation,
Timo Sirainen <tss@iki.fi>
parents:
1997
diff
changeset
|
609 (void)close(log_fd); |
0 | 610 return -1; |
611 } | |
612 | |
613 if (pid != 0) { | |
614 /* master */ | |
2046 | 615 prefix = t_strdup_printf("%s-login: ", |
616 process_names[group->process_type]); | |
617 log_set_prefix(log, prefix); | |
618 | |
1273
2cf2e08a6ee9
Somewhat working code to support loading Dovecot from inetd and such. It
Timo Sirainen <tss@iki.fi>
parents:
1237
diff
changeset
|
619 net_set_nonblock(fd[0], TRUE); |
727
8dd8ebe6bcac
We use close-on-exec flag now to make sure that master process closes the
Timo Sirainen <tss@iki.fi>
parents:
722
diff
changeset
|
620 fd_close_on_exec(fd[0], TRUE); |
1273
2cf2e08a6ee9
Somewhat working code to support loading Dovecot from inetd and such. It
Timo Sirainen <tss@iki.fi>
parents:
1237
diff
changeset
|
621 (void)login_process_new(group, pid, fd[0]); |
0 | 622 (void)close(fd[1]); |
2000
c7c19f5071c3
Write all logging through master process. Fixes problems with log rotation,
Timo Sirainen <tss@iki.fi>
parents:
1997
diff
changeset
|
623 (void)close(log_fd); |
0 | 624 return pid; |
625 } | |
626 | |
2046 | 627 prefix = t_strdup_printf("master-%s-login: ", |
628 process_names[group->process_type]); | |
629 log_set_prefix(log, prefix); | |
630 | |
0 | 631 /* move the listen handle */ |
1610
6850142c4e25
New configuration file code. Some syntax changes, but tries to be somewhat
Timo Sirainen <tss@iki.fi>
parents:
1506
diff
changeset
|
632 if (dup2(group->set->listen_fd, LOGIN_LISTEN_FD) < 0) |
2046 | 633 i_fatal("dup2(listen_fd) failed: %m"); |
1055
a72bba3f8a55
Rewrote setting handling. Changed some existing settings also since POP3
Timo Sirainen <tss@iki.fi>
parents:
1039
diff
changeset
|
634 fd_close_on_exec(LOGIN_LISTEN_FD, FALSE); |
0 | 635 |
636 /* move the SSL listen handle */ | |
1610
6850142c4e25
New configuration file code. Some syntax changes, but tries to be somewhat
Timo Sirainen <tss@iki.fi>
parents:
1506
diff
changeset
|
637 if (dup2(group->set->ssl_listen_fd, LOGIN_SSL_LISTEN_FD) < 0) |
2046 | 638 i_fatal("dup2(ssl_listen_fd) failed: %m"); |
1055
a72bba3f8a55
Rewrote setting handling. Changed some existing settings also since POP3
Timo Sirainen <tss@iki.fi>
parents:
1039
diff
changeset
|
639 fd_close_on_exec(LOGIN_SSL_LISTEN_FD, FALSE); |
0 | 640 |
1273
2cf2e08a6ee9
Somewhat working code to support loading Dovecot from inetd and such. It
Timo Sirainen <tss@iki.fi>
parents:
1237
diff
changeset
|
641 /* move communication handle */ |
2cf2e08a6ee9
Somewhat working code to support loading Dovecot from inetd and such. It
Timo Sirainen <tss@iki.fi>
parents:
1237
diff
changeset
|
642 if (dup2(fd[1], LOGIN_MASTER_SOCKET_FD) < 0) |
2046 | 643 i_fatal("dup2(master) failed: %m"); |
1273
2cf2e08a6ee9
Somewhat working code to support loading Dovecot from inetd and such. It
Timo Sirainen <tss@iki.fi>
parents:
1237
diff
changeset
|
644 fd_close_on_exec(LOGIN_MASTER_SOCKET_FD, FALSE); |
0 | 645 |
2000
c7c19f5071c3
Write all logging through master process. Fixes problems with log rotation,
Timo Sirainen <tss@iki.fi>
parents:
1997
diff
changeset
|
646 if (dup2(log_fd, 2) < 0) |
2046 | 647 i_fatal("dup2(stderr) failed: %m"); |
2000
c7c19f5071c3
Write all logging through master process. Fixes problems with log rotation,
Timo Sirainen <tss@iki.fi>
parents:
1997
diff
changeset
|
648 fd_close_on_exec(2, FALSE); |
c7c19f5071c3
Write all logging through master process. Fixes problems with log rotation,
Timo Sirainen <tss@iki.fi>
parents:
1997
diff
changeset
|
649 |
0 | 650 (void)close(fd[0]); |
651 (void)close(fd[1]); | |
652 | |
1273
2cf2e08a6ee9
Somewhat working code to support loading Dovecot from inetd and such. It
Timo Sirainen <tss@iki.fi>
parents:
1237
diff
changeset
|
653 login_process_init_env(group, getpid()); |
0 | 654 |
1610
6850142c4e25
New configuration file code. Some syntax changes, but tries to be somewhat
Timo Sirainen <tss@iki.fi>
parents:
1506
diff
changeset
|
655 if (!group->set->login_chroot) { |
0 | 656 /* no chrooting, but still change to the directory */ |
1610
6850142c4e25
New configuration file code. Some syntax changes, but tries to be somewhat
Timo Sirainen <tss@iki.fi>
parents:
1506
diff
changeset
|
657 if (chdir(group->set->login_dir) < 0) { |
6850142c4e25
New configuration file code. Some syntax changes, but tries to be somewhat
Timo Sirainen <tss@iki.fi>
parents:
1506
diff
changeset
|
658 i_fatal("chdir(%s) failed: %m", |
6850142c4e25
New configuration file code. Some syntax changes, but tries to be somewhat
Timo Sirainen <tss@iki.fi>
parents:
1506
diff
changeset
|
659 group->set->login_dir); |
6850142c4e25
New configuration file code. Some syntax changes, but tries to be somewhat
Timo Sirainen <tss@iki.fi>
parents:
1506
diff
changeset
|
660 } |
0 | 661 } |
662 | |
1610
6850142c4e25
New configuration file code. Some syntax changes, but tries to be somewhat
Timo Sirainen <tss@iki.fi>
parents:
1506
diff
changeset
|
663 restrict_process_size(group->set->login_process_size, (unsigned int)-1); |
722
0438621d25ff
Added virtual memory size limits to processes. Default values are pretty
Timo Sirainen <tss@iki.fi>
parents:
699
diff
changeset
|
664 |
801
86224ff16bf6
Drop root privileges earlier. Close syslog more later in imap-master when
Timo Sirainen <tss@iki.fi>
parents:
791
diff
changeset
|
665 /* make sure we don't leak syslog fd, but do it last so that |
86224ff16bf6
Drop root privileges earlier. Close syslog more later in imap-master when
Timo Sirainen <tss@iki.fi>
parents:
791
diff
changeset
|
666 any errors above will be logged */ |
86224ff16bf6
Drop root privileges earlier. Close syslog more later in imap-master when
Timo Sirainen <tss@iki.fi>
parents:
791
diff
changeset
|
667 closelog(); |
86224ff16bf6
Drop root privileges earlier. Close syslog more later in imap-master when
Timo Sirainen <tss@iki.fi>
parents:
791
diff
changeset
|
668 |
2886
634cf6aa34d1
Allow running all executables with parameters.
Timo Sirainen <tss@iki.fi>
parents:
2779
diff
changeset
|
669 client_process_exec(group->set->login_executable, ""); |
1441
a83ce8395316
If exec() fails, show the full path rather than argv[0]
Timo Sirainen <tss@iki.fi>
parents:
1398
diff
changeset
|
670 i_fatal_status(FATAL_EXEC, "execv(%s) failed: %m", |
1610
6850142c4e25
New configuration file code. Some syntax changes, but tries to be somewhat
Timo Sirainen <tss@iki.fi>
parents:
1506
diff
changeset
|
671 group->set->login_executable); |
0 | 672 return -1; |
673 } | |
674 | |
4538
9d9e72374164
Fixes to login process handling, especially with
Timo Sirainen <tss@iki.fi>
parents:
4388
diff
changeset
|
675 void login_process_destroyed(pid_t pid, bool abnormal_exit) |
615
0d852af6842e
Master process generates DH/RSA parameters now and stores them into file
Timo Sirainen <tss@iki.fi>
parents:
614
diff
changeset
|
676 { |
1055
a72bba3f8a55
Rewrote setting handling. Changed some existing settings also since POP3
Timo Sirainen <tss@iki.fi>
parents:
1039
diff
changeset
|
677 struct login_process *p; |
a72bba3f8a55
Rewrote setting handling. Changed some existing settings also since POP3
Timo Sirainen <tss@iki.fi>
parents:
1039
diff
changeset
|
678 |
a72bba3f8a55
Rewrote setting handling. Changed some existing settings also since POP3
Timo Sirainen <tss@iki.fi>
parents:
1039
diff
changeset
|
679 p = hash_lookup(processes, POINTER_CAST(pid)); |
4538
9d9e72374164
Fixes to login process handling, especially with
Timo Sirainen <tss@iki.fi>
parents:
4388
diff
changeset
|
680 if (p == NULL) |
9d9e72374164
Fixes to login process handling, especially with
Timo Sirainen <tss@iki.fi>
parents:
4388
diff
changeset
|
681 i_panic("Lost login process PID %s", dec2str(pid)); |
9d9e72374164
Fixes to login process handling, especially with
Timo Sirainen <tss@iki.fi>
parents:
4388
diff
changeset
|
682 i_assert(!p->inetd_child); |
9d9e72374164
Fixes to login process handling, especially with
Timo Sirainen <tss@iki.fi>
parents:
4388
diff
changeset
|
683 |
9d9e72374164
Fixes to login process handling, especially with
Timo Sirainen <tss@iki.fi>
parents:
4388
diff
changeset
|
684 if (abnormal_exit) { |
9d9e72374164
Fixes to login process handling, especially with
Timo Sirainen <tss@iki.fi>
parents:
4388
diff
changeset
|
685 /* don't start raising the process count if they're dying all |
9d9e72374164
Fixes to login process handling, especially with
Timo Sirainen <tss@iki.fi>
parents:
4388
diff
changeset
|
686 the time */ |
9d9e72374164
Fixes to login process handling, especially with
Timo Sirainen <tss@iki.fi>
parents:
4388
diff
changeset
|
687 if (p->group != NULL) |
9d9e72374164
Fixes to login process handling, especially with
Timo Sirainen <tss@iki.fi>
parents:
4388
diff
changeset
|
688 p->group->wanted_processes_count = 0; |
9d9e72374164
Fixes to login process handling, especially with
Timo Sirainen <tss@iki.fi>
parents:
4388
diff
changeset
|
689 } |
9d9e72374164
Fixes to login process handling, especially with
Timo Sirainen <tss@iki.fi>
parents:
4388
diff
changeset
|
690 |
9d9e72374164
Fixes to login process handling, especially with
Timo Sirainen <tss@iki.fi>
parents:
4388
diff
changeset
|
691 login_process_destroy(p); |
9d9e72374164
Fixes to login process handling, especially with
Timo Sirainen <tss@iki.fi>
parents:
4388
diff
changeset
|
692 login_process_exited(p); |
615
0d852af6842e
Master process generates DH/RSA parameters now and stores them into file
Timo Sirainen <tss@iki.fi>
parents:
614
diff
changeset
|
693 } |
0d852af6842e
Master process generates DH/RSA parameters now and stores them into file
Timo Sirainen <tss@iki.fi>
parents:
614
diff
changeset
|
694 |
4538
9d9e72374164
Fixes to login process handling, especially with
Timo Sirainen <tss@iki.fi>
parents:
4388
diff
changeset
|
695 void login_processes_destroy_all(bool unref) |
635
90a65c017bf0
SIGHUP reloads now settings. Logged in clients are left untouched, but
Timo Sirainen <tss@iki.fi>
parents:
615
diff
changeset
|
696 { |
1897
1e6ed8045f2b
Changed hash_foreach() to iterator.
Timo Sirainen <tss@iki.fi>
parents:
1724
diff
changeset
|
697 struct hash_iterate_context *iter; |
1e6ed8045f2b
Changed hash_foreach() to iterator.
Timo Sirainen <tss@iki.fi>
parents:
1724
diff
changeset
|
698 void *key, *value; |
1e6ed8045f2b
Changed hash_foreach() to iterator.
Timo Sirainen <tss@iki.fi>
parents:
1724
diff
changeset
|
699 |
1e6ed8045f2b
Changed hash_foreach() to iterator.
Timo Sirainen <tss@iki.fi>
parents:
1724
diff
changeset
|
700 iter = hash_iterate_init(processes); |
4538
9d9e72374164
Fixes to login process handling, especially with
Timo Sirainen <tss@iki.fi>
parents:
4388
diff
changeset
|
701 while (hash_iterate(iter, &key, &value)) { |
1897
1e6ed8045f2b
Changed hash_foreach() to iterator.
Timo Sirainen <tss@iki.fi>
parents:
1724
diff
changeset
|
702 login_process_destroy(value); |
4538
9d9e72374164
Fixes to login process handling, especially with
Timo Sirainen <tss@iki.fi>
parents:
4388
diff
changeset
|
703 if (unref) login_process_unref(value); |
9d9e72374164
Fixes to login process handling, especially with
Timo Sirainen <tss@iki.fi>
parents:
4388
diff
changeset
|
704 } |
1897
1e6ed8045f2b
Changed hash_foreach() to iterator.
Timo Sirainen <tss@iki.fi>
parents:
1724
diff
changeset
|
705 hash_iterate_deinit(iter); |
635
90a65c017bf0
SIGHUP reloads now settings. Logged in clients are left untouched, but
Timo Sirainen <tss@iki.fi>
parents:
615
diff
changeset
|
706 |
1055
a72bba3f8a55
Rewrote setting handling. Changed some existing settings also since POP3
Timo Sirainen <tss@iki.fi>
parents:
1039
diff
changeset
|
707 while (login_groups != NULL) { |
a72bba3f8a55
Rewrote setting handling. Changed some existing settings also since POP3
Timo Sirainen <tss@iki.fi>
parents:
1039
diff
changeset
|
708 struct login_group *group = login_groups; |
a72bba3f8a55
Rewrote setting handling. Changed some existing settings also since POP3
Timo Sirainen <tss@iki.fi>
parents:
1039
diff
changeset
|
709 |
a72bba3f8a55
Rewrote setting handling. Changed some existing settings also since POP3
Timo Sirainen <tss@iki.fi>
parents:
1039
diff
changeset
|
710 login_groups = group->next; |
4631
f5d53a684856
SIGHUP caused memory corruption
Timo Sirainen <tss@iki.fi>
parents:
4630
diff
changeset
|
711 login_group_unref(group); |
1055
a72bba3f8a55
Rewrote setting handling. Changed some existing settings also since POP3
Timo Sirainen <tss@iki.fi>
parents:
1039
diff
changeset
|
712 } |
a72bba3f8a55
Rewrote setting handling. Changed some existing settings also since POP3
Timo Sirainen <tss@iki.fi>
parents:
1039
diff
changeset
|
713 } |
a72bba3f8a55
Rewrote setting handling. Changed some existing settings also since POP3
Timo Sirainen <tss@iki.fi>
parents:
1039
diff
changeset
|
714 |
4538
9d9e72374164
Fixes to login process handling, especially with
Timo Sirainen <tss@iki.fi>
parents:
4388
diff
changeset
|
715 static void login_processes_notify_group(struct login_group *group) |
9d9e72374164
Fixes to login process handling, especially with
Timo Sirainen <tss@iki.fi>
parents:
4388
diff
changeset
|
716 { |
9d9e72374164
Fixes to login process handling, especially with
Timo Sirainen <tss@iki.fi>
parents:
4388
diff
changeset
|
717 struct hash_iterate_context *iter; |
9d9e72374164
Fixes to login process handling, especially with
Timo Sirainen <tss@iki.fi>
parents:
4388
diff
changeset
|
718 struct master_login_reply reply; |
9d9e72374164
Fixes to login process handling, especially with
Timo Sirainen <tss@iki.fi>
parents:
4388
diff
changeset
|
719 void *key, *value; |
9d9e72374164
Fixes to login process handling, especially with
Timo Sirainen <tss@iki.fi>
parents:
4388
diff
changeset
|
720 |
9d9e72374164
Fixes to login process handling, especially with
Timo Sirainen <tss@iki.fi>
parents:
4388
diff
changeset
|
721 memset(&reply, 0, sizeof(reply)); |
9d9e72374164
Fixes to login process handling, especially with
Timo Sirainen <tss@iki.fi>
parents:
4388
diff
changeset
|
722 |
9d9e72374164
Fixes to login process handling, especially with
Timo Sirainen <tss@iki.fi>
parents:
4388
diff
changeset
|
723 iter = hash_iterate_init(processes); |
9d9e72374164
Fixes to login process handling, especially with
Timo Sirainen <tss@iki.fi>
parents:
4388
diff
changeset
|
724 while (hash_iterate(iter, &key, &value)) { |
9d9e72374164
Fixes to login process handling, especially with
Timo Sirainen <tss@iki.fi>
parents:
4388
diff
changeset
|
725 struct login_process *p = value; |
9d9e72374164
Fixes to login process handling, especially with
Timo Sirainen <tss@iki.fi>
parents:
4388
diff
changeset
|
726 |
9d9e72374164
Fixes to login process handling, especially with
Timo Sirainen <tss@iki.fi>
parents:
4388
diff
changeset
|
727 if (p->group == group) |
9d9e72374164
Fixes to login process handling, especially with
Timo Sirainen <tss@iki.fi>
parents:
4388
diff
changeset
|
728 (void)o_stream_send(p->output, &reply, sizeof(reply)); |
9d9e72374164
Fixes to login process handling, especially with
Timo Sirainen <tss@iki.fi>
parents:
4388
diff
changeset
|
729 } |
9d9e72374164
Fixes to login process handling, especially with
Timo Sirainen <tss@iki.fi>
parents:
4388
diff
changeset
|
730 hash_iterate_deinit(iter); |
9d9e72374164
Fixes to login process handling, especially with
Timo Sirainen <tss@iki.fi>
parents:
4388
diff
changeset
|
731 } |
9d9e72374164
Fixes to login process handling, especially with
Timo Sirainen <tss@iki.fi>
parents:
4388
diff
changeset
|
732 |
4148
f60d73c96618
If master process runs out of file descriptors, try to handle it more nicely
Timo Sirainen <tss@iki.fi>
parents:
3901
diff
changeset
|
733 static int login_group_start_missings(struct login_group *group) |
1055
a72bba3f8a55
Rewrote setting handling. Changed some existing settings also since POP3
Timo Sirainen <tss@iki.fi>
parents:
1039
diff
changeset
|
734 { |
4538
9d9e72374164
Fixes to login process handling, especially with
Timo Sirainen <tss@iki.fi>
parents:
4388
diff
changeset
|
735 if (group->set->login_process_per_connection && |
9d9e72374164
Fixes to login process handling, especially with
Timo Sirainen <tss@iki.fi>
parents:
4388
diff
changeset
|
736 group->processes >= group->set->login_max_processes_count && |
9d9e72374164
Fixes to login process handling, especially with
Timo Sirainen <tss@iki.fi>
parents:
4388
diff
changeset
|
737 group->listening_processes == 0) { |
9d9e72374164
Fixes to login process handling, especially with
Timo Sirainen <tss@iki.fi>
parents:
4388
diff
changeset
|
738 /* destroy the oldest listening process. non-listening |
9d9e72374164
Fixes to login process handling, especially with
Timo Sirainen <tss@iki.fi>
parents:
4388
diff
changeset
|
739 processes are logged in users who we don't want to kick out |
9d9e72374164
Fixes to login process handling, especially with
Timo Sirainen <tss@iki.fi>
parents:
4388
diff
changeset
|
740 because someone's started flooding */ |
4661
885bef091d1a
Make sure we don't kill login processes that haven't yet even sent their
Timo Sirainen <tss@iki.fi>
parents:
4651
diff
changeset
|
741 if (group->oldest_prelogin_process != NULL && |
885bef091d1a
Make sure we don't kill login processes that haven't yet even sent their
Timo Sirainen <tss@iki.fi>
parents:
4651
diff
changeset
|
742 group->oldest_prelogin_process->initialized) |
4538
9d9e72374164
Fixes to login process handling, especially with
Timo Sirainen <tss@iki.fi>
parents:
4388
diff
changeset
|
743 login_process_destroy(group->oldest_prelogin_process); |
1055
a72bba3f8a55
Rewrote setting handling. Changed some existing settings also since POP3
Timo Sirainen <tss@iki.fi>
parents:
1039
diff
changeset
|
744 } |
a72bba3f8a55
Rewrote setting handling. Changed some existing settings also since POP3
Timo Sirainen <tss@iki.fi>
parents:
1039
diff
changeset
|
745 |
a72bba3f8a55
Rewrote setting handling. Changed some existing settings also since POP3
Timo Sirainen <tss@iki.fi>
parents:
1039
diff
changeset
|
746 /* we want to respond fast when multiple clients are connecting |
a72bba3f8a55
Rewrote setting handling. Changed some existing settings also since POP3
Timo Sirainen <tss@iki.fi>
parents:
1039
diff
changeset
|
747 at once, but we also want to prevent fork-bombing. use the |
a72bba3f8a55
Rewrote setting handling. Changed some existing settings also since POP3
Timo Sirainen <tss@iki.fi>
parents:
1039
diff
changeset
|
748 same method as apache: check once a second if we need new |
a72bba3f8a55
Rewrote setting handling. Changed some existing settings also since POP3
Timo Sirainen <tss@iki.fi>
parents:
1039
diff
changeset
|
749 processes. if yes and we've used all the existing processes, |
a72bba3f8a55
Rewrote setting handling. Changed some existing settings also since POP3
Timo Sirainen <tss@iki.fi>
parents:
1039
diff
changeset
|
750 double their amount (unless we've hit the high limit). |
a72bba3f8a55
Rewrote setting handling. Changed some existing settings also since POP3
Timo Sirainen <tss@iki.fi>
parents:
1039
diff
changeset
|
751 Then for each second that didn't use all existing processes, |
a72bba3f8a55
Rewrote setting handling. Changed some existing settings also since POP3
Timo Sirainen <tss@iki.fi>
parents:
1039
diff
changeset
|
752 drop the max. process count by one. */ |
1610
6850142c4e25
New configuration file code. Some syntax changes, but tries to be somewhat
Timo Sirainen <tss@iki.fi>
parents:
1506
diff
changeset
|
753 if (group->wanted_processes_count < group->set->login_processes_count) { |
6850142c4e25
New configuration file code. Some syntax changes, but tries to be somewhat
Timo Sirainen <tss@iki.fi>
parents:
1506
diff
changeset
|
754 group->wanted_processes_count = |
6850142c4e25
New configuration file code. Some syntax changes, but tries to be somewhat
Timo Sirainen <tss@iki.fi>
parents:
1506
diff
changeset
|
755 group->set->login_processes_count; |
6850142c4e25
New configuration file code. Some syntax changes, but tries to be somewhat
Timo Sirainen <tss@iki.fi>
parents:
1506
diff
changeset
|
756 } else if (group->listening_processes == 0) |
1055
a72bba3f8a55
Rewrote setting handling. Changed some existing settings also since POP3
Timo Sirainen <tss@iki.fi>
parents:
1039
diff
changeset
|
757 group->wanted_processes_count *= 2; |
1610
6850142c4e25
New configuration file code. Some syntax changes, but tries to be somewhat
Timo Sirainen <tss@iki.fi>
parents:
1506
diff
changeset
|
758 else if (group->wanted_processes_count > |
6850142c4e25
New configuration file code. Some syntax changes, but tries to be somewhat
Timo Sirainen <tss@iki.fi>
parents:
1506
diff
changeset
|
759 group->set->login_processes_count) |
1055
a72bba3f8a55
Rewrote setting handling. Changed some existing settings also since POP3
Timo Sirainen <tss@iki.fi>
parents:
1039
diff
changeset
|
760 group->wanted_processes_count--; |
a72bba3f8a55
Rewrote setting handling. Changed some existing settings also since POP3
Timo Sirainen <tss@iki.fi>
parents:
1039
diff
changeset
|
761 |
4538
9d9e72374164
Fixes to login process handling, especially with
Timo Sirainen <tss@iki.fi>
parents:
4388
diff
changeset
|
762 while (group->listening_processes < group->wanted_processes_count && |
9d9e72374164
Fixes to login process handling, especially with
Timo Sirainen <tss@iki.fi>
parents:
4388
diff
changeset
|
763 group->processes < group->set->login_max_processes_count) { |
9d9e72374164
Fixes to login process handling, especially with
Timo Sirainen <tss@iki.fi>
parents:
4388
diff
changeset
|
764 if (create_login_process(group) < 0) |
9d9e72374164
Fixes to login process handling, especially with
Timo Sirainen <tss@iki.fi>
parents:
4388
diff
changeset
|
765 return -1; |
1610
6850142c4e25
New configuration file code. Some syntax changes, but tries to be somewhat
Timo Sirainen <tss@iki.fi>
parents:
1506
diff
changeset
|
766 } |
1055
a72bba3f8a55
Rewrote setting handling. Changed some existing settings also since POP3
Timo Sirainen <tss@iki.fi>
parents:
1039
diff
changeset
|
767 |
4538
9d9e72374164
Fixes to login process handling, especially with
Timo Sirainen <tss@iki.fi>
parents:
4388
diff
changeset
|
768 if (group->listening_processes == 0 && |
9d9e72374164
Fixes to login process handling, especially with
Timo Sirainen <tss@iki.fi>
parents:
4388
diff
changeset
|
769 !group->set->login_process_per_connection) { |
9d9e72374164
Fixes to login process handling, especially with
Timo Sirainen <tss@iki.fi>
parents:
4388
diff
changeset
|
770 /* we've reached our limit. notify the processes to start |
9d9e72374164
Fixes to login process handling, especially with
Timo Sirainen <tss@iki.fi>
parents:
4388
diff
changeset
|
771 listening again which makes them kill some of their |
9d9e72374164
Fixes to login process handling, especially with
Timo Sirainen <tss@iki.fi>
parents:
4388
diff
changeset
|
772 oldest clients when accepting the next connection */ |
9d9e72374164
Fixes to login process handling, especially with
Timo Sirainen <tss@iki.fi>
parents:
4388
diff
changeset
|
773 login_processes_notify_group(group); |
4148
f60d73c96618
If master process runs out of file descriptors, try to handle it more nicely
Timo Sirainen <tss@iki.fi>
parents:
3901
diff
changeset
|
774 } |
f60d73c96618
If master process runs out of file descriptors, try to handle it more nicely
Timo Sirainen <tss@iki.fi>
parents:
3901
diff
changeset
|
775 return 0; |
635
90a65c017bf0
SIGHUP reloads now settings. Logged in clients are left untouched, but
Timo Sirainen <tss@iki.fi>
parents:
615
diff
changeset
|
776 } |
90a65c017bf0
SIGHUP reloads now settings. Logged in clients are left untouched, but
Timo Sirainen <tss@iki.fi>
parents:
615
diff
changeset
|
777 |
4148
f60d73c96618
If master process runs out of file descriptors, try to handle it more nicely
Timo Sirainen <tss@iki.fi>
parents:
3901
diff
changeset
|
778 static void login_processes_stall(void) |
f60d73c96618
If master process runs out of file descriptors, try to handle it more nicely
Timo Sirainen <tss@iki.fi>
parents:
3901
diff
changeset
|
779 { |
f60d73c96618
If master process runs out of file descriptors, try to handle it more nicely
Timo Sirainen <tss@iki.fi>
parents:
3901
diff
changeset
|
780 if (logins_stalled) |
f60d73c96618
If master process runs out of file descriptors, try to handle it more nicely
Timo Sirainen <tss@iki.fi>
parents:
3901
diff
changeset
|
781 return; |
f60d73c96618
If master process runs out of file descriptors, try to handle it more nicely
Timo Sirainen <tss@iki.fi>
parents:
3901
diff
changeset
|
782 |
f60d73c96618
If master process runs out of file descriptors, try to handle it more nicely
Timo Sirainen <tss@iki.fi>
parents:
3901
diff
changeset
|
783 i_error("Temporary failure in creating login processes, " |
f60d73c96618
If master process runs out of file descriptors, try to handle it more nicely
Timo Sirainen <tss@iki.fi>
parents:
3901
diff
changeset
|
784 "slowing down for now"); |
f60d73c96618
If master process runs out of file descriptors, try to handle it more nicely
Timo Sirainen <tss@iki.fi>
parents:
3901
diff
changeset
|
785 logins_stalled = TRUE; |
f60d73c96618
If master process runs out of file descriptors, try to handle it more nicely
Timo Sirainen <tss@iki.fi>
parents:
3901
diff
changeset
|
786 |
f60d73c96618
If master process runs out of file descriptors, try to handle it more nicely
Timo Sirainen <tss@iki.fi>
parents:
3901
diff
changeset
|
787 timeout_remove(&to); |
f60d73c96618
If master process runs out of file descriptors, try to handle it more nicely
Timo Sirainen <tss@iki.fi>
parents:
3901
diff
changeset
|
788 to = timeout_add(60*1000, login_processes_start_missing, NULL); |
f60d73c96618
If master process runs out of file descriptors, try to handle it more nicely
Timo Sirainen <tss@iki.fi>
parents:
3901
diff
changeset
|
789 } |
f60d73c96618
If master process runs out of file descriptors, try to handle it more nicely
Timo Sirainen <tss@iki.fi>
parents:
3901
diff
changeset
|
790 |
903
fd8888f6f037
Naming style changes, finally got tired of most of the typedefs. Also the
Timo Sirainen <tss@iki.fi>
parents:
876
diff
changeset
|
791 static void |
1036
f782b3319553
Removed useless parameters from io_callback_t and timeout_callback_t.
Timo Sirainen <tss@iki.fi>
parents:
1035
diff
changeset
|
792 login_processes_start_missing(void *context __attr_unused__) |
0 | 793 { |
1055
a72bba3f8a55
Rewrote setting handling. Changed some existing settings also since POP3
Timo Sirainen <tss@iki.fi>
parents:
1039
diff
changeset
|
794 struct login_group *group; |
614
e60620644af3
login_process_per_connection = yes scales now better when multiple users are
Timo Sirainen <tss@iki.fi>
parents:
613
diff
changeset
|
795 |
1610
6850142c4e25
New configuration file code. Some syntax changes, but tries to be somewhat
Timo Sirainen <tss@iki.fi>
parents:
1506
diff
changeset
|
796 if (login_groups == NULL) |
6850142c4e25
New configuration file code. Some syntax changes, but tries to be somewhat
Timo Sirainen <tss@iki.fi>
parents:
1506
diff
changeset
|
797 login_process_groups_create(); |
614
e60620644af3
login_process_per_connection = yes scales now better when multiple users are
Timo Sirainen <tss@iki.fi>
parents:
613
diff
changeset
|
798 |
4148
f60d73c96618
If master process runs out of file descriptors, try to handle it more nicely
Timo Sirainen <tss@iki.fi>
parents:
3901
diff
changeset
|
799 for (group = login_groups; group != NULL; group = group->next) { |
f60d73c96618
If master process runs out of file descriptors, try to handle it more nicely
Timo Sirainen <tss@iki.fi>
parents:
3901
diff
changeset
|
800 if (login_group_start_missings(group) < 0) { |
f60d73c96618
If master process runs out of file descriptors, try to handle it more nicely
Timo Sirainen <tss@iki.fi>
parents:
3901
diff
changeset
|
801 login_processes_stall(); |
f60d73c96618
If master process runs out of file descriptors, try to handle it more nicely
Timo Sirainen <tss@iki.fi>
parents:
3901
diff
changeset
|
802 return; |
f60d73c96618
If master process runs out of file descriptors, try to handle it more nicely
Timo Sirainen <tss@iki.fi>
parents:
3901
diff
changeset
|
803 } |
f60d73c96618
If master process runs out of file descriptors, try to handle it more nicely
Timo Sirainen <tss@iki.fi>
parents:
3901
diff
changeset
|
804 } |
0 | 805 } |
806 | |
1273
2cf2e08a6ee9
Somewhat working code to support loading Dovecot from inetd and such. It
Timo Sirainen <tss@iki.fi>
parents:
1237
diff
changeset
|
807 static int login_process_send_env(struct login_process *p) |
2cf2e08a6ee9
Somewhat working code to support loading Dovecot from inetd and such. It
Timo Sirainen <tss@iki.fi>
parents:
1237
diff
changeset
|
808 { |
2cf2e08a6ee9
Somewhat working code to support loading Dovecot from inetd and such. It
Timo Sirainen <tss@iki.fi>
parents:
1237
diff
changeset
|
809 extern char **environ; |
2cf2e08a6ee9
Somewhat working code to support loading Dovecot from inetd and such. It
Timo Sirainen <tss@iki.fi>
parents:
1237
diff
changeset
|
810 char **env; |
3607
a2dd3d895e00
Several fixes to make running from inetd working again
Timo Sirainen <tss@iki.fi>
parents:
3384
diff
changeset
|
811 ssize_t len; |
1273
2cf2e08a6ee9
Somewhat working code to support loading Dovecot from inetd and such. It
Timo Sirainen <tss@iki.fi>
parents:
1237
diff
changeset
|
812 int ret = 0; |
2cf2e08a6ee9
Somewhat working code to support loading Dovecot from inetd and such. It
Timo Sirainen <tss@iki.fi>
parents:
1237
diff
changeset
|
813 |
2cf2e08a6ee9
Somewhat working code to support loading Dovecot from inetd and such. It
Timo Sirainen <tss@iki.fi>
parents:
1237
diff
changeset
|
814 /* this will clear our environment. luckily we don't need it. */ |
2cf2e08a6ee9
Somewhat working code to support loading Dovecot from inetd and such. It
Timo Sirainen <tss@iki.fi>
parents:
1237
diff
changeset
|
815 login_process_init_env(p->group, p->pid); |
2cf2e08a6ee9
Somewhat working code to support loading Dovecot from inetd and such. It
Timo Sirainen <tss@iki.fi>
parents:
1237
diff
changeset
|
816 |
2cf2e08a6ee9
Somewhat working code to support loading Dovecot from inetd and such. It
Timo Sirainen <tss@iki.fi>
parents:
1237
diff
changeset
|
817 for (env = environ; *env != NULL; env++) { |
2cf2e08a6ee9
Somewhat working code to support loading Dovecot from inetd and such. It
Timo Sirainen <tss@iki.fi>
parents:
1237
diff
changeset
|
818 len = strlen(*env); |
2cf2e08a6ee9
Somewhat working code to support loading Dovecot from inetd and such. It
Timo Sirainen <tss@iki.fi>
parents:
1237
diff
changeset
|
819 |
3607
a2dd3d895e00
Several fixes to make running from inetd working again
Timo Sirainen <tss@iki.fi>
parents:
3384
diff
changeset
|
820 if (o_stream_send(p->output, *env, len) != len || |
1273
2cf2e08a6ee9
Somewhat working code to support loading Dovecot from inetd and such. It
Timo Sirainen <tss@iki.fi>
parents:
1237
diff
changeset
|
821 o_stream_send(p->output, "\n", 1) != 1) { |
2cf2e08a6ee9
Somewhat working code to support loading Dovecot from inetd and such. It
Timo Sirainen <tss@iki.fi>
parents:
1237
diff
changeset
|
822 ret = -1; |
2cf2e08a6ee9
Somewhat working code to support loading Dovecot from inetd and such. It
Timo Sirainen <tss@iki.fi>
parents:
1237
diff
changeset
|
823 break; |
2cf2e08a6ee9
Somewhat working code to support loading Dovecot from inetd and such. It
Timo Sirainen <tss@iki.fi>
parents:
1237
diff
changeset
|
824 } |
2cf2e08a6ee9
Somewhat working code to support loading Dovecot from inetd and such. It
Timo Sirainen <tss@iki.fi>
parents:
1237
diff
changeset
|
825 } |
2cf2e08a6ee9
Somewhat working code to support loading Dovecot from inetd and such. It
Timo Sirainen <tss@iki.fi>
parents:
1237
diff
changeset
|
826 |
3607
a2dd3d895e00
Several fixes to make running from inetd working again
Timo Sirainen <tss@iki.fi>
parents:
3384
diff
changeset
|
827 if (!p->group->set->login_chroot) { |
a2dd3d895e00
Several fixes to make running from inetd working again
Timo Sirainen <tss@iki.fi>
parents:
3384
diff
changeset
|
828 /* if we're not chrooting, we need to tell login process |
a2dd3d895e00
Several fixes to make running from inetd working again
Timo Sirainen <tss@iki.fi>
parents:
3384
diff
changeset
|
829 where its base directory is */ |
a2dd3d895e00
Several fixes to make running from inetd working again
Timo Sirainen <tss@iki.fi>
parents:
3384
diff
changeset
|
830 const char *str = t_strdup_printf("LOGIN_DIR=%s\n", |
a2dd3d895e00
Several fixes to make running from inetd working again
Timo Sirainen <tss@iki.fi>
parents:
3384
diff
changeset
|
831 p->group->set->login_dir); |
a2dd3d895e00
Several fixes to make running from inetd working again
Timo Sirainen <tss@iki.fi>
parents:
3384
diff
changeset
|
832 len = strlen(str); |
a2dd3d895e00
Several fixes to make running from inetd working again
Timo Sirainen <tss@iki.fi>
parents:
3384
diff
changeset
|
833 if (o_stream_send(p->output, str, len) != len) |
a2dd3d895e00
Several fixes to make running from inetd working again
Timo Sirainen <tss@iki.fi>
parents:
3384
diff
changeset
|
834 ret = -1; |
a2dd3d895e00
Several fixes to make running from inetd working again
Timo Sirainen <tss@iki.fi>
parents:
3384
diff
changeset
|
835 } |
a2dd3d895e00
Several fixes to make running from inetd working again
Timo Sirainen <tss@iki.fi>
parents:
3384
diff
changeset
|
836 |
1273
2cf2e08a6ee9
Somewhat working code to support loading Dovecot from inetd and such. It
Timo Sirainen <tss@iki.fi>
parents:
1237
diff
changeset
|
837 if (ret == 0 && o_stream_send(p->output, "\n", 1) != 1) |
2cf2e08a6ee9
Somewhat working code to support loading Dovecot from inetd and such. It
Timo Sirainen <tss@iki.fi>
parents:
1237
diff
changeset
|
838 ret = -1; |
2cf2e08a6ee9
Somewhat working code to support loading Dovecot from inetd and such. It
Timo Sirainen <tss@iki.fi>
parents:
1237
diff
changeset
|
839 |
2cf2e08a6ee9
Somewhat working code to support loading Dovecot from inetd and such. It
Timo Sirainen <tss@iki.fi>
parents:
1237
diff
changeset
|
840 env_clean(); |
2cf2e08a6ee9
Somewhat working code to support loading Dovecot from inetd and such. It
Timo Sirainen <tss@iki.fi>
parents:
1237
diff
changeset
|
841 return ret; |
2cf2e08a6ee9
Somewhat working code to support loading Dovecot from inetd and such. It
Timo Sirainen <tss@iki.fi>
parents:
1237
diff
changeset
|
842 } |
2cf2e08a6ee9
Somewhat working code to support loading Dovecot from inetd and such. It
Timo Sirainen <tss@iki.fi>
parents:
1237
diff
changeset
|
843 |
3863
55df57c028d4
Added "bool" type and changed all ints that were used as booleans to bool.
Timo Sirainen <tss@iki.fi>
parents:
3692
diff
changeset
|
844 static bool login_process_init_group(struct login_process *p) |
1275
af685269ead0
login: Wait until we're connected to auth process before executing command
Timo Sirainen <tss@iki.fi>
parents:
1273
diff
changeset
|
845 { |
af685269ead0
login: Wait until we're connected to auth process before executing command
Timo Sirainen <tss@iki.fi>
parents:
1273
diff
changeset
|
846 p->group->processes++; |
af685269ead0
login: Wait until we're connected to auth process before executing command
Timo Sirainen <tss@iki.fi>
parents:
1273
diff
changeset
|
847 p->group->listening_processes++; |
af685269ead0
login: Wait until we're connected to auth process before executing command
Timo Sirainen <tss@iki.fi>
parents:
1273
diff
changeset
|
848 |
af685269ead0
login: Wait until we're connected to auth process before executing command
Timo Sirainen <tss@iki.fi>
parents:
1273
diff
changeset
|
849 if (login_process_send_env(p) < 0) { |
af685269ead0
login: Wait until we're connected to auth process before executing command
Timo Sirainen <tss@iki.fi>
parents:
1273
diff
changeset
|
850 i_error("login: Couldn't send environment"); |
af685269ead0
login: Wait until we're connected to auth process before executing command
Timo Sirainen <tss@iki.fi>
parents:
1273
diff
changeset
|
851 return FALSE; |
af685269ead0
login: Wait until we're connected to auth process before executing command
Timo Sirainen <tss@iki.fi>
parents:
1273
diff
changeset
|
852 } |
af685269ead0
login: Wait until we're connected to auth process before executing command
Timo Sirainen <tss@iki.fi>
parents:
1273
diff
changeset
|
853 |
af685269ead0
login: Wait until we're connected to auth process before executing command
Timo Sirainen <tss@iki.fi>
parents:
1273
diff
changeset
|
854 return TRUE; |
af685269ead0
login: Wait until we're connected to auth process before executing command
Timo Sirainen <tss@iki.fi>
parents:
1273
diff
changeset
|
855 } |
af685269ead0
login: Wait until we're connected to auth process before executing command
Timo Sirainen <tss@iki.fi>
parents:
1273
diff
changeset
|
856 |
1273
2cf2e08a6ee9
Somewhat working code to support loading Dovecot from inetd and such. It
Timo Sirainen <tss@iki.fi>
parents:
1237
diff
changeset
|
857 static void inetd_login_accept(void *context __attr_unused__) |
2cf2e08a6ee9
Somewhat working code to support loading Dovecot from inetd and such. It
Timo Sirainen <tss@iki.fi>
parents:
1237
diff
changeset
|
858 { |
2cf2e08a6ee9
Somewhat working code to support loading Dovecot from inetd and such. It
Timo Sirainen <tss@iki.fi>
parents:
1237
diff
changeset
|
859 struct login_process *p; |
2cf2e08a6ee9
Somewhat working code to support loading Dovecot from inetd and such. It
Timo Sirainen <tss@iki.fi>
parents:
1237
diff
changeset
|
860 int fd; |
2cf2e08a6ee9
Somewhat working code to support loading Dovecot from inetd and such. It
Timo Sirainen <tss@iki.fi>
parents:
1237
diff
changeset
|
861 |
2cf2e08a6ee9
Somewhat working code to support loading Dovecot from inetd and such. It
Timo Sirainen <tss@iki.fi>
parents:
1237
diff
changeset
|
862 fd = net_accept(inetd_login_fd, NULL, NULL); |
2cf2e08a6ee9
Somewhat working code to support loading Dovecot from inetd and such. It
Timo Sirainen <tss@iki.fi>
parents:
1237
diff
changeset
|
863 if (fd < 0) { |
2cf2e08a6ee9
Somewhat working code to support loading Dovecot from inetd and such. It
Timo Sirainen <tss@iki.fi>
parents:
1237
diff
changeset
|
864 if (fd < -1) |
2cf2e08a6ee9
Somewhat working code to support loading Dovecot from inetd and such. It
Timo Sirainen <tss@iki.fi>
parents:
1237
diff
changeset
|
865 i_fatal("accept(inetd_login_fd) failed: %m"); |
2cf2e08a6ee9
Somewhat working code to support loading Dovecot from inetd and such. It
Timo Sirainen <tss@iki.fi>
parents:
1237
diff
changeset
|
866 } else { |
2cf2e08a6ee9
Somewhat working code to support loading Dovecot from inetd and such. It
Timo Sirainen <tss@iki.fi>
parents:
1237
diff
changeset
|
867 net_set_nonblock(fd, TRUE); |
2cf2e08a6ee9
Somewhat working code to support loading Dovecot from inetd and such. It
Timo Sirainen <tss@iki.fi>
parents:
1237
diff
changeset
|
868 fd_close_on_exec(fd, TRUE); |
2cf2e08a6ee9
Somewhat working code to support loading Dovecot from inetd and such. It
Timo Sirainen <tss@iki.fi>
parents:
1237
diff
changeset
|
869 |
1275
af685269ead0
login: Wait until we're connected to auth process before executing command
Timo Sirainen <tss@iki.fi>
parents:
1273
diff
changeset
|
870 p = login_process_new(NULL, ++login_pid_counter, fd); |
af685269ead0
login: Wait until we're connected to auth process before executing command
Timo Sirainen <tss@iki.fi>
parents:
1273
diff
changeset
|
871 p->initialized = TRUE; |
4538
9d9e72374164
Fixes to login process handling, especially with
Timo Sirainen <tss@iki.fi>
parents:
4388
diff
changeset
|
872 p->inetd_child = TRUE; |
1273
2cf2e08a6ee9
Somewhat working code to support loading Dovecot from inetd and such. It
Timo Sirainen <tss@iki.fi>
parents:
1237
diff
changeset
|
873 } |
2cf2e08a6ee9
Somewhat working code to support loading Dovecot from inetd and such. It
Timo Sirainen <tss@iki.fi>
parents:
1237
diff
changeset
|
874 } |
2cf2e08a6ee9
Somewhat working code to support loading Dovecot from inetd and such. It
Timo Sirainen <tss@iki.fi>
parents:
1237
diff
changeset
|
875 |
0 | 876 void login_processes_init(void) |
877 { | |
1273
2cf2e08a6ee9
Somewhat working code to support loading Dovecot from inetd and such. It
Timo Sirainen <tss@iki.fi>
parents:
1237
diff
changeset
|
878 auth_id_counter = 0; |
2cf2e08a6ee9
Somewhat working code to support loading Dovecot from inetd and such. It
Timo Sirainen <tss@iki.fi>
parents:
1237
diff
changeset
|
879 login_pid_counter = 0; |
1055
a72bba3f8a55
Rewrote setting handling. Changed some existing settings also since POP3
Timo Sirainen <tss@iki.fi>
parents:
1039
diff
changeset
|
880 login_groups = NULL; |
613
1906116a62ce
Finally support for handling each login connection in it's own process.
Timo Sirainen <tss@iki.fi>
parents:
596
diff
changeset
|
881 |
945
501f076f2e74
Rewrote hash table code, works with less memory now. Also some memory
Timo Sirainen <tss@iki.fi>
parents:
929
diff
changeset
|
882 processes = hash_create(default_pool, default_pool, 128, NULL, NULL); |
1273
2cf2e08a6ee9
Somewhat working code to support loading Dovecot from inetd and such. It
Timo Sirainen <tss@iki.fi>
parents:
1237
diff
changeset
|
883 if (!IS_INETD()) { |
2cf2e08a6ee9
Somewhat working code to support loading Dovecot from inetd and such. It
Timo Sirainen <tss@iki.fi>
parents:
1237
diff
changeset
|
884 to = timeout_add(1000, login_processes_start_missing, NULL); |
2cf2e08a6ee9
Somewhat working code to support loading Dovecot from inetd and such. It
Timo Sirainen <tss@iki.fi>
parents:
1237
diff
changeset
|
885 io_listen = NULL; |
2cf2e08a6ee9
Somewhat working code to support loading Dovecot from inetd and such. It
Timo Sirainen <tss@iki.fi>
parents:
1237
diff
changeset
|
886 } else { |
2cf2e08a6ee9
Somewhat working code to support loading Dovecot from inetd and such. It
Timo Sirainen <tss@iki.fi>
parents:
1237
diff
changeset
|
887 to = NULL; |
2cf2e08a6ee9
Somewhat working code to support loading Dovecot from inetd and such. It
Timo Sirainen <tss@iki.fi>
parents:
1237
diff
changeset
|
888 io_listen = io_add(inetd_login_fd, IO_READ, |
2cf2e08a6ee9
Somewhat working code to support loading Dovecot from inetd and such. It
Timo Sirainen <tss@iki.fi>
parents:
1237
diff
changeset
|
889 inetd_login_accept, NULL); |
2cf2e08a6ee9
Somewhat working code to support loading Dovecot from inetd and such. It
Timo Sirainen <tss@iki.fi>
parents:
1237
diff
changeset
|
890 } |
0 | 891 } |
892 | |
893 void login_processes_deinit(void) | |
894 { | |
1273
2cf2e08a6ee9
Somewhat working code to support loading Dovecot from inetd and such. It
Timo Sirainen <tss@iki.fi>
parents:
1237
diff
changeset
|
895 if (to != NULL) |
3879
928229f8b3e6
deinit, unref, destroy, close, free, etc. functions now take a pointer to
Timo Sirainen <tss@iki.fi>
parents:
3863
diff
changeset
|
896 timeout_remove(&to); |
1273
2cf2e08a6ee9
Somewhat working code to support loading Dovecot from inetd and such. It
Timo Sirainen <tss@iki.fi>
parents:
1237
diff
changeset
|
897 if (io_listen != NULL) |
3879
928229f8b3e6
deinit, unref, destroy, close, free, etc. functions now take a pointer to
Timo Sirainen <tss@iki.fi>
parents:
3863
diff
changeset
|
898 io_remove(&io_listen); |
0 | 899 |
4538
9d9e72374164
Fixes to login process handling, especially with
Timo Sirainen <tss@iki.fi>
parents:
4388
diff
changeset
|
900 login_processes_destroy_all(TRUE); |
0 | 901 hash_destroy(processes); |
902 } |