main.c revision 05b422b01541f742c4d145c1aa48f4b03256f1ae
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
/* Copyright (C) 2002-2003 Timo Sirainen */
#include "common.h"
#include "ioloop.h"
#include "network.h"
#include "lib-signals.h"
#include "restrict-access.h"
#include "fd-close-on-exec.h"
#include "process-title.h"
#include "randgen.h"
#include "module-dir.h"
#include "var-expand.h"
#include "dict-client.h"
#include "mail-storage.h"
#include <stdio.h>
#include <stdlib.h>
#include <unistd.h>
#include <syslog.h>
#define IS_STANDALONE() \
struct client_workaround_list {
const char *name;
enum client_workarounds num;
};
struct client_workaround_list client_workaround_list[] = {
{ "outlook-no-nuls", WORKAROUND_OUTLOOK_NO_NULS },
{ "oe-ns-eoh", WORKAROUND_OE_NS_EOH },
{ NULL, 0 }
};
enum client_workarounds client_workarounds = 0;
bool enable_last_command = FALSE;
bool no_flag_updates = FALSE;
bool reuse_xuidl = FALSE;
bool lock_session = FALSE;
const char *uidl_format, *logout_format;
enum uidl_keys uidl_keymask;
{
/* warn about being killed because of some signal, except SIGINT (^C)
which is too common at least while testing :) */
}
{
}
static void parse_workarounds(void)
{
struct client_workaround_list *list;
return;
break;
}
}
}
}
{
switch (var_get_key(++format)) {
case 'v':
mask |= UIDL_UIDVALIDITY;
break;
case 'u':
break;
case 'm':
break;
case 'f':
mask |= UIDL_FILE_NAME;
break;
}
}
}
return mask;
}
static void open_logfile(void)
{
const char *user;
return;
}
/* quite a long user name, cut it */
}
} else {
/* log to file or stderr */
}
}
static void drop_privileges(void)
{
/* Log file or syslog opening probably requires roots */
open_logfile();
chrooting. */
random_init();
}
static int main_init(void)
{
enum mail_storage_flags flags;
struct mail_storage *storage;
i_fatal("Dovecot version mismatch: "
"(if you don't care, set version_ignore=yes)", value);
}
i_fatal("USER environment missing");
i_info("Effective uid=%s, gid=%s",
}
/* If master dies, the log fd gets closed and we'll quit */
}
clients_init();
else {
if (plugin_dir == NULL)
TRUE);
}
/* support also maildir-specific environment */
}
i_fatal("pop3_uidl_format setting is missing from config file");
if (logout_format == NULL)
logout_format = "top=%t/%p, retr=%r/%b, del=%d/%m, size=%s";
if (uidl_keymask == 0)
i_fatal("pop3_uidl_format setting doesn't contain any "
"%% variables.");
flags, lock_method);
/* failed */
else {
const char *home;
i_fatal("MAIL environment missing and "
"autodetection failed (home %s)", home);
}
}
if (hook_mail_storage_created != NULL)
}
static void main_deinit(void)
{
closelog();
}
{
#ifdef DEBUG
#endif
if (IS_STANDALONE() && getuid() == 0 &&
printf("-ERR pop3 binary must not be started from "
"inetd, use pop3-login instead.\n");
return 1;
}
/* NOTE: we start rooted, so keep the code minimal until
restrict_access_by_env() is called */
lib_init();
if (main_init())
main_deinit();
lib_deinit();
return 0;
}