Mercurial > dovecot > original-hg > dovecot-1.2
annotate src/master/main.c @ 6940:414c9d631a81 HEAD
Replaced t_push/t_pop calls with T_FRAME*() macros.
author | Timo Sirainen <tss@iki.fi> |
---|---|
date | Wed, 05 Dec 2007 17:47:44 +0200 |
parents | a9daec3c00b5 |
children | 7ed926ed7aa4 |
rev | line source |
---|---|
6429
65c69a53a7be
Replaced my Copyright notices. The year range always ends with 2007 now.
Timo Sirainen <tss@iki.fi>
parents:
6411
diff
changeset
|
1 /* Copyright (c) 2002-2007 Dovecot authors, see the included COPYING file */ |
0 | 2 |
3 #include "common.h" | |
5887
3f2eb1b9c555
Support listening multiple sockets. SIGHUP also doesn't anymore recreate
Timo Sirainen <tss@iki.fi>
parents:
5846
diff
changeset
|
4 #include "array.h" |
0 | 5 #include "ioloop.h" |
6 #include "lib-signals.h" | |
7 #include "network.h" | |
697
7814b29d0862
Created env_put() and env_clean() for a bit easier handling of environment
Timo Sirainen <tss@iki.fi>
parents:
635
diff
changeset
|
8 #include "env-util.h" |
727
8dd8ebe6bcac
We use close-on-exec flag now to make sure that master process closes the
Timo Sirainen <tss@iki.fi>
parents:
697
diff
changeset
|
9 #include "fd-close-on-exec.h" |
2524 | 10 #include "write-full.h" |
6313
0e08960275f8
Grow file descriptors to 64k at startup, and drop them for login and imap
Timo Sirainen <tss@iki.fi>
parents:
6303
diff
changeset
|
11 #include "restrict-process-size.h" |
0 | 12 |
3889
c7462001227b
Added support for password protected SSL private keys. The password can be
Timo Sirainen <tss@iki.fi>
parents:
3879
diff
changeset
|
13 #include "askpass.h" |
0 | 14 #include "auth-process.h" |
5789
4f22660ffd33
Move POSIX capabilities dropping into separate function.
Andrey Panin <pazke@donpac.ru>
parents:
5696
diff
changeset
|
15 #include "capabilities.h" |
3853
b3e18b51c205
Start dict server automatically when a client tries to connect to it.
Timo Sirainen <tss@iki.fi>
parents:
3724
diff
changeset
|
16 #include "dict-process.h" |
0 | 17 #include "login-process.h" |
1055
a72bba3f8a55
Rewrote setting handling. Changed some existing settings also since POP3
Timo Sirainen <tss@iki.fi>
parents:
1036
diff
changeset
|
18 #include "mail-process.h" |
3724
d22c883021da
Added syslog_facility setting to config file.
Timo Sirainen <tss@iki.fi>
parents:
3620
diff
changeset
|
19 #include "syslog-util.h" |
5936 | 20 #include "listener.h" |
615
0d852af6842e
Master process generates DH/RSA parameters now and stores them into file
Timo Sirainen <tss@iki.fi>
parents:
610
diff
changeset
|
21 #include "ssl-init.h" |
2000
c7c19f5071c3
Write all logging through master process. Fixes problems with log rotation,
Timo Sirainen <tss@iki.fi>
parents:
1820
diff
changeset
|
22 #include "log.h" |
0 | 23 |
279
49f4b0be0d87
Print usage with invalid parameters.
Timo Sirainen <tss@iki.fi>
parents:
50
diff
changeset
|
24 #include <stdio.h> |
0 | 25 #include <stdlib.h> |
26 #include <unistd.h> | |
27 #include <fcntl.h> | |
28 #include <syslog.h> | |
29 #include <sys/stat.h> | |
30 | |
6313
0e08960275f8
Grow file descriptors to 64k at startup, and drop them for login and imap
Timo Sirainen <tss@iki.fi>
parents:
6303
diff
changeset
|
31 /* Try to raise our fd limit this high at startup. If the limit is already |
0e08960275f8
Grow file descriptors to 64k at startup, and drop them for login and imap
Timo Sirainen <tss@iki.fi>
parents:
6303
diff
changeset
|
32 higher, it's not dropped. */ |
0e08960275f8
Grow file descriptors to 64k at startup, and drop them for login and imap
Timo Sirainen <tss@iki.fi>
parents:
6303
diff
changeset
|
33 #define DOVECOT_MASTER_FD_MIN_LIMIT 65536 |
0e08960275f8
Grow file descriptors to 64k at startup, and drop them for login and imap
Timo Sirainen <tss@iki.fi>
parents:
6303
diff
changeset
|
34 |
635
90a65c017bf0
SIGHUP reloads now settings. Logged in clients are left untouched, but
Timo Sirainen <tss@iki.fi>
parents:
615
diff
changeset
|
35 static const char *configfile = SYSCONFDIR "/" PACKAGE ".conf"; |
0 | 36 |
1000
0fbafade2d85
If auth/login process died unexpectedly, the exit status or killing signal
Timo Sirainen <tss@iki.fi>
parents:
945
diff
changeset
|
37 struct ioloop *ioloop; |
5432
2b4fa90860dd
Before unlinking auth sockets at startup, try connecting to them first to
Timo Sirainen <tss@iki.fi>
parents:
5333
diff
changeset
|
38 int null_fd = -1, inetd_login_fd; |
1617
cc3cef25662c
Replaced geteuid() calls with one in the beginning and saving it to
Timo Sirainen <tss@iki.fi>
parents:
1610
diff
changeset
|
39 uid_t master_uid; |
3989
e93e39326ae1
Added ssl-build-param binary to build the ssl-parameters.dat. This way
Timo Sirainen <tss@iki.fi>
parents:
3966
diff
changeset
|
40 char program_path[PATH_MAX]; |
3889
c7462001227b
Added support for password protected SSL private keys. The password can be
Timo Sirainen <tss@iki.fi>
parents:
3879
diff
changeset
|
41 char ssl_manual_key_password[100]; |
5843
f655c4d4a419
Moved child process handling to child-process.[ch]. The hash table now uses
Timo Sirainen <tss@iki.fi>
parents:
5824
diff
changeset
|
42 const char *env_tz; |
2235
dcff4c088f1a
DEBUG: If GDB environment is set, don't do fd leak checks.
Timo Sirainen <tss@iki.fi>
parents:
2047
diff
changeset
|
43 #ifdef DEBUG |
5843
f655c4d4a419
Moved child process handling to child-process.[ch]. The hash table now uses
Timo Sirainen <tss@iki.fi>
parents:
5824
diff
changeset
|
44 bool gdb; |
2235
dcff4c088f1a
DEBUG: If GDB environment is set, don't do fd leak checks.
Timo Sirainen <tss@iki.fi>
parents:
2047
diff
changeset
|
45 #endif |
0 | 46 |
2306
6aa77fdf152e
SIGHUP correctly reloads configuration now
Timo Sirainen <tss@iki.fi>
parents:
2235
diff
changeset
|
47 static void set_logfile(struct settings *set) |
6aa77fdf152e
SIGHUP correctly reloads configuration now
Timo Sirainen <tss@iki.fi>
parents:
2235
diff
changeset
|
48 { |
3724
d22c883021da
Added syslog_facility setting to config file.
Timo Sirainen <tss@iki.fi>
parents:
3620
diff
changeset
|
49 int facility; |
d22c883021da
Added syslog_facility setting to config file.
Timo Sirainen <tss@iki.fi>
parents:
3620
diff
changeset
|
50 |
4388
af61031c746f
Settings parser nowadays returns "" instead of NULL when it reads an empty
Timo Sirainen <tss@iki.fi>
parents:
4375
diff
changeset
|
51 if (*set->log_path == '\0') { |
3724
d22c883021da
Added syslog_facility setting to config file.
Timo Sirainen <tss@iki.fi>
parents:
3620
diff
changeset
|
52 if (!syslog_facility_find(set->syslog_facility, &facility)) |
d22c883021da
Added syslog_facility setting to config file.
Timo Sirainen <tss@iki.fi>
parents:
3620
diff
changeset
|
53 facility = LOG_MAIL; |
d22c883021da
Added syslog_facility setting to config file.
Timo Sirainen <tss@iki.fi>
parents:
3620
diff
changeset
|
54 |
d22c883021da
Added syslog_facility setting to config file.
Timo Sirainen <tss@iki.fi>
parents:
3620
diff
changeset
|
55 i_set_failure_syslog("dovecot", LOG_NDELAY, facility); |
d22c883021da
Added syslog_facility setting to config file.
Timo Sirainen <tss@iki.fi>
parents:
3620
diff
changeset
|
56 } else { |
2306
6aa77fdf152e
SIGHUP correctly reloads configuration now
Timo Sirainen <tss@iki.fi>
parents:
2235
diff
changeset
|
57 /* log to file or stderr */ |
5333
55260092b094
Fixes to handling log prefixes. imap/pop3 processes now log the
Timo Sirainen <tss@iki.fi>
parents:
5249
diff
changeset
|
58 i_set_failure_file(set->log_path, "dovecot: "); |
2306
6aa77fdf152e
SIGHUP correctly reloads configuration now
Timo Sirainen <tss@iki.fi>
parents:
2235
diff
changeset
|
59 } |
6aa77fdf152e
SIGHUP correctly reloads configuration now
Timo Sirainen <tss@iki.fi>
parents:
2235
diff
changeset
|
60 |
4388
af61031c746f
Settings parser nowadays returns "" instead of NULL when it reads an empty
Timo Sirainen <tss@iki.fi>
parents:
4375
diff
changeset
|
61 if (*set->info_log_path != '\0') |
2306
6aa77fdf152e
SIGHUP correctly reloads configuration now
Timo Sirainen <tss@iki.fi>
parents:
2235
diff
changeset
|
62 i_set_info_file(set->info_log_path); |
6aa77fdf152e
SIGHUP correctly reloads configuration now
Timo Sirainen <tss@iki.fi>
parents:
2235
diff
changeset
|
63 |
6aa77fdf152e
SIGHUP correctly reloads configuration now
Timo Sirainen <tss@iki.fi>
parents:
2235
diff
changeset
|
64 i_set_failure_timestamp_format(set->log_timestamp); |
6aa77fdf152e
SIGHUP correctly reloads configuration now
Timo Sirainen <tss@iki.fi>
parents:
2235
diff
changeset
|
65 } |
6aa77fdf152e
SIGHUP correctly reloads configuration now
Timo Sirainen <tss@iki.fi>
parents:
2235
diff
changeset
|
66 |
635
90a65c017bf0
SIGHUP reloads now settings. Logged in clients are left untouched, but
Timo Sirainen <tss@iki.fi>
parents:
615
diff
changeset
|
67 static void settings_reload(void) |
90a65c017bf0
SIGHUP reloads now settings. Logged in clients are left untouched, but
Timo Sirainen <tss@iki.fi>
parents:
615
diff
changeset
|
68 { |
2306
6aa77fdf152e
SIGHUP correctly reloads configuration now
Timo Sirainen <tss@iki.fi>
parents:
2235
diff
changeset
|
69 struct server_settings *old_set = settings_root; |
6aa77fdf152e
SIGHUP correctly reloads configuration now
Timo Sirainen <tss@iki.fi>
parents:
2235
diff
changeset
|
70 |
635
90a65c017bf0
SIGHUP reloads now settings. Logged in clients are left untouched, but
Timo Sirainen <tss@iki.fi>
parents:
615
diff
changeset
|
71 i_warning("SIGHUP received - reloading configuration"); |
90a65c017bf0
SIGHUP reloads now settings. Logged in clients are left untouched, but
Timo Sirainen <tss@iki.fi>
parents:
615
diff
changeset
|
72 |
90a65c017bf0
SIGHUP reloads now settings. Logged in clients are left untouched, but
Timo Sirainen <tss@iki.fi>
parents:
615
diff
changeset
|
73 /* restart auth and login processes */ |
4670 | 74 login_processes_destroy_all(); |
635
90a65c017bf0
SIGHUP reloads now settings. Logged in clients are left untouched, but
Timo Sirainen <tss@iki.fi>
parents:
615
diff
changeset
|
75 auth_processes_destroy_all(); |
4393
9928ebb54719
Instead of passing URIs directly to dictionary server, it now accepts only
Timo Sirainen <tss@iki.fi>
parents:
4388
diff
changeset
|
76 dict_process_kill(); |
1223
52e0830ade13
Added setting mail_drop_priv_before_exec.
Timo Sirainen <tss@iki.fi>
parents:
1124
diff
changeset
|
77 |
4965
9246d9308caa
-n and -a parameters shouldn't be deleting auth sockets.
Timo Sirainen <tss@iki.fi>
parents:
4903
diff
changeset
|
78 if (!master_settings_read(configfile, FALSE, FALSE)) |
1610
6850142c4e25
New configuration file code. Some syntax changes, but tries to be somewhat
Timo Sirainen <tss@iki.fi>
parents:
1423
diff
changeset
|
79 i_warning("Invalid configuration, keeping old one"); |
2306
6aa77fdf152e
SIGHUP correctly reloads configuration now
Timo Sirainen <tss@iki.fi>
parents:
2235
diff
changeset
|
80 else { |
5887
3f2eb1b9c555
Support listening multiple sockets. SIGHUP also doesn't anymore recreate
Timo Sirainen <tss@iki.fi>
parents:
5846
diff
changeset
|
81 if (!IS_INETD()) |
3f2eb1b9c555
Support listening multiple sockets. SIGHUP also doesn't anymore recreate
Timo Sirainen <tss@iki.fi>
parents:
5846
diff
changeset
|
82 listeners_open_fds(old_set, TRUE); |
2306
6aa77fdf152e
SIGHUP correctly reloads configuration now
Timo Sirainen <tss@iki.fi>
parents:
2235
diff
changeset
|
83 set_logfile(settings_root->defaults); |
6aa77fdf152e
SIGHUP correctly reloads configuration now
Timo Sirainen <tss@iki.fi>
parents:
2235
diff
changeset
|
84 } |
635
90a65c017bf0
SIGHUP reloads now settings. Logged in clients are left untouched, but
Timo Sirainen <tss@iki.fi>
parents:
615
diff
changeset
|
85 } |
90a65c017bf0
SIGHUP reloads now settings. Logged in clients are left untouched, but
Timo Sirainen <tss@iki.fi>
parents:
615
diff
changeset
|
86 |
6411
6a64e64fa3a3
Renamed __attr_*__ to ATTR_*. Renamed __attrs_used__ to ATTRS_DEFINED.
Timo Sirainen <tss@iki.fi>
parents:
6397
diff
changeset
|
87 static void sig_die(int signo, void *context ATTR_UNUSED) |
3620
3360cc019737
Implemented new signal handling framework, which makes handling signals much
Timo Sirainen <tss@iki.fi>
parents:
3589
diff
changeset
|
88 { |
3360cc019737
Implemented new signal handling framework, which makes handling signals much
Timo Sirainen <tss@iki.fi>
parents:
3589
diff
changeset
|
89 /* warn about being killed because of some signal, except SIGINT (^C) |
3360cc019737
Implemented new signal handling framework, which makes handling signals much
Timo Sirainen <tss@iki.fi>
parents:
3589
diff
changeset
|
90 which is too common at least while testing :) */ |
3360cc019737
Implemented new signal handling framework, which makes handling signals much
Timo Sirainen <tss@iki.fi>
parents:
3589
diff
changeset
|
91 if (signo != SIGINT) |
3360cc019737
Implemented new signal handling framework, which makes handling signals much
Timo Sirainen <tss@iki.fi>
parents:
3589
diff
changeset
|
92 i_warning("Killed with signal %d", signo); |
3360cc019737
Implemented new signal handling framework, which makes handling signals much
Timo Sirainen <tss@iki.fi>
parents:
3589
diff
changeset
|
93 io_loop_stop(ioloop); |
3360cc019737
Implemented new signal handling framework, which makes handling signals much
Timo Sirainen <tss@iki.fi>
parents:
3589
diff
changeset
|
94 } |
3360cc019737
Implemented new signal handling framework, which makes handling signals much
Timo Sirainen <tss@iki.fi>
parents:
3589
diff
changeset
|
95 |
6411
6a64e64fa3a3
Renamed __attr_*__ to ATTR_*. Renamed __attrs_used__ to ATTRS_DEFINED.
Timo Sirainen <tss@iki.fi>
parents:
6397
diff
changeset
|
96 static void sig_reload_settings(int signo ATTR_UNUSED, |
6a64e64fa3a3
Renamed __attr_*__ to ATTR_*. Renamed __attrs_used__ to ATTRS_DEFINED.
Timo Sirainen <tss@iki.fi>
parents:
6397
diff
changeset
|
97 void *context ATTR_UNUSED) |
3620
3360cc019737
Implemented new signal handling framework, which makes handling signals much
Timo Sirainen <tss@iki.fi>
parents:
3589
diff
changeset
|
98 { |
3360cc019737
Implemented new signal handling framework, which makes handling signals much
Timo Sirainen <tss@iki.fi>
parents:
3589
diff
changeset
|
99 settings_reload(); |
3360cc019737
Implemented new signal handling framework, which makes handling signals much
Timo Sirainen <tss@iki.fi>
parents:
3589
diff
changeset
|
100 } |
3360cc019737
Implemented new signal handling framework, which makes handling signals much
Timo Sirainen <tss@iki.fi>
parents:
3589
diff
changeset
|
101 |
6411
6a64e64fa3a3
Renamed __attr_*__ to ATTR_*. Renamed __attrs_used__ to ATTRS_DEFINED.
Timo Sirainen <tss@iki.fi>
parents:
6397
diff
changeset
|
102 static void sig_reopen_logs(int signo ATTR_UNUSED, |
6a64e64fa3a3
Renamed __attr_*__ to ATTR_*. Renamed __attrs_used__ to ATTRS_DEFINED.
Timo Sirainen <tss@iki.fi>
parents:
6397
diff
changeset
|
103 void *context ATTR_UNUSED) |
3620
3360cc019737
Implemented new signal handling framework, which makes handling signals much
Timo Sirainen <tss@iki.fi>
parents:
3589
diff
changeset
|
104 { |
3360cc019737
Implemented new signal handling framework, which makes handling signals much
Timo Sirainen <tss@iki.fi>
parents:
3589
diff
changeset
|
105 set_logfile(settings_root->defaults); |
3360cc019737
Implemented new signal handling framework, which makes handling signals much
Timo Sirainen <tss@iki.fi>
parents:
3589
diff
changeset
|
106 } |
3360cc019737
Implemented new signal handling framework, which makes handling signals much
Timo Sirainen <tss@iki.fi>
parents:
3589
diff
changeset
|
107 |
3863
55df57c028d4
Added "bool" type and changed all ints that were used as booleans to bool.
Timo Sirainen <tss@iki.fi>
parents:
3853
diff
changeset
|
108 static bool have_stderr_set(struct settings *set) |
1610
6850142c4e25
New configuration file code. Some syntax changes, but tries to be somewhat
Timo Sirainen <tss@iki.fi>
parents:
1423
diff
changeset
|
109 { |
4388
af61031c746f
Settings parser nowadays returns "" instead of NULL when it reads an empty
Timo Sirainen <tss@iki.fi>
parents:
4375
diff
changeset
|
110 if (*set->log_path != '\0' && |
1610
6850142c4e25
New configuration file code. Some syntax changes, but tries to be somewhat
Timo Sirainen <tss@iki.fi>
parents:
1423
diff
changeset
|
111 strcmp(set->log_path, "/dev/stderr") == 0) |
6850142c4e25
New configuration file code. Some syntax changes, but tries to be somewhat
Timo Sirainen <tss@iki.fi>
parents:
1423
diff
changeset
|
112 return TRUE; |
6850142c4e25
New configuration file code. Some syntax changes, but tries to be somewhat
Timo Sirainen <tss@iki.fi>
parents:
1423
diff
changeset
|
113 |
4388
af61031c746f
Settings parser nowadays returns "" instead of NULL when it reads an empty
Timo Sirainen <tss@iki.fi>
parents:
4375
diff
changeset
|
114 if (*set->info_log_path != '\0' && |
1610
6850142c4e25
New configuration file code. Some syntax changes, but tries to be somewhat
Timo Sirainen <tss@iki.fi>
parents:
1423
diff
changeset
|
115 strcmp(set->info_log_path, "/dev/stderr") == 0) |
6850142c4e25
New configuration file code. Some syntax changes, but tries to be somewhat
Timo Sirainen <tss@iki.fi>
parents:
1423
diff
changeset
|
116 return TRUE; |
6850142c4e25
New configuration file code. Some syntax changes, but tries to be somewhat
Timo Sirainen <tss@iki.fi>
parents:
1423
diff
changeset
|
117 |
6850142c4e25
New configuration file code. Some syntax changes, but tries to be somewhat
Timo Sirainen <tss@iki.fi>
parents:
1423
diff
changeset
|
118 return FALSE; |
6850142c4e25
New configuration file code. Some syntax changes, but tries to be somewhat
Timo Sirainen <tss@iki.fi>
parents:
1423
diff
changeset
|
119 } |
6850142c4e25
New configuration file code. Some syntax changes, but tries to be somewhat
Timo Sirainen <tss@iki.fi>
parents:
1423
diff
changeset
|
120 |
3863
55df57c028d4
Added "bool" type and changed all ints that were used as booleans to bool.
Timo Sirainen <tss@iki.fi>
parents:
3853
diff
changeset
|
121 static bool have_stderr(struct server_settings *server) |
1610
6850142c4e25
New configuration file code. Some syntax changes, but tries to be somewhat
Timo Sirainen <tss@iki.fi>
parents:
1423
diff
changeset
|
122 { |
6850142c4e25
New configuration file code. Some syntax changes, but tries to be somewhat
Timo Sirainen <tss@iki.fi>
parents:
1423
diff
changeset
|
123 while (server != NULL) { |
6850142c4e25
New configuration file code. Some syntax changes, but tries to be somewhat
Timo Sirainen <tss@iki.fi>
parents:
1423
diff
changeset
|
124 if (server->imap != NULL && have_stderr_set(server->imap)) |
6850142c4e25
New configuration file code. Some syntax changes, but tries to be somewhat
Timo Sirainen <tss@iki.fi>
parents:
1423
diff
changeset
|
125 return TRUE; |
6850142c4e25
New configuration file code. Some syntax changes, but tries to be somewhat
Timo Sirainen <tss@iki.fi>
parents:
1423
diff
changeset
|
126 if (server->pop3 != NULL && have_stderr_set(server->pop3)) |
6850142c4e25
New configuration file code. Some syntax changes, but tries to be somewhat
Timo Sirainen <tss@iki.fi>
parents:
1423
diff
changeset
|
127 return TRUE; |
6850142c4e25
New configuration file code. Some syntax changes, but tries to be somewhat
Timo Sirainen <tss@iki.fi>
parents:
1423
diff
changeset
|
128 |
6850142c4e25
New configuration file code. Some syntax changes, but tries to be somewhat
Timo Sirainen <tss@iki.fi>
parents:
1423
diff
changeset
|
129 server = server->next; |
1055
a72bba3f8a55
Rewrote setting handling. Changed some existing settings also since POP3
Timo Sirainen <tss@iki.fi>
parents:
1036
diff
changeset
|
130 } |
1610
6850142c4e25
New configuration file code. Some syntax changes, but tries to be somewhat
Timo Sirainen <tss@iki.fi>
parents:
1423
diff
changeset
|
131 |
6850142c4e25
New configuration file code. Some syntax changes, but tries to be somewhat
Timo Sirainen <tss@iki.fi>
parents:
1423
diff
changeset
|
132 return FALSE; |
1273
2cf2e08a6ee9
Somewhat working code to support loading Dovecot from inetd and such. It
Timo Sirainen <tss@iki.fi>
parents:
1268
diff
changeset
|
133 } |
2cf2e08a6ee9
Somewhat working code to support loading Dovecot from inetd and such. It
Timo Sirainen <tss@iki.fi>
parents:
1268
diff
changeset
|
134 |
5437 | 135 static void open_null_fd(void) |
1273
2cf2e08a6ee9
Somewhat working code to support loading Dovecot from inetd and such. It
Timo Sirainen <tss@iki.fi>
parents:
1268
diff
changeset
|
136 { |
2cf2e08a6ee9
Somewhat working code to support loading Dovecot from inetd and such. It
Timo Sirainen <tss@iki.fi>
parents:
1268
diff
changeset
|
137 null_fd = open("/dev/null", O_RDONLY); |
2cf2e08a6ee9
Somewhat working code to support loading Dovecot from inetd and such. It
Timo Sirainen <tss@iki.fi>
parents:
1268
diff
changeset
|
138 if (null_fd == -1) |
2cf2e08a6ee9
Somewhat working code to support loading Dovecot from inetd and such. It
Timo Sirainen <tss@iki.fi>
parents:
1268
diff
changeset
|
139 i_fatal("Can't open /dev/null: %m"); |
2cf2e08a6ee9
Somewhat working code to support loading Dovecot from inetd and such. It
Timo Sirainen <tss@iki.fi>
parents:
1268
diff
changeset
|
140 fd_close_on_exec(null_fd, TRUE); |
5437 | 141 } |
1273
2cf2e08a6ee9
Somewhat working code to support loading Dovecot from inetd and such. It
Timo Sirainen <tss@iki.fi>
parents:
1268
diff
changeset
|
142 |
5437 | 143 static void open_fds(void) |
144 { | |
1273
2cf2e08a6ee9
Somewhat working code to support loading Dovecot from inetd and such. It
Timo Sirainen <tss@iki.fi>
parents:
1268
diff
changeset
|
145 /* make sure all fds between 0..3 are used. */ |
2cf2e08a6ee9
Somewhat working code to support loading Dovecot from inetd and such. It
Timo Sirainen <tss@iki.fi>
parents:
1268
diff
changeset
|
146 while (null_fd < 4) { |
2cf2e08a6ee9
Somewhat working code to support loading Dovecot from inetd and such. It
Timo Sirainen <tss@iki.fi>
parents:
1268
diff
changeset
|
147 null_fd = dup(null_fd); |
4578
3bb3d5ad254f
Cleanup + handle dup() failure.
Timo Sirainen <tss@iki.fi>
parents:
4553
diff
changeset
|
148 if (null_fd == -1) |
3bb3d5ad254f
Cleanup + handle dup() failure.
Timo Sirainen <tss@iki.fi>
parents:
4553
diff
changeset
|
149 i_fatal("dup(null_fd) failed: %m"); |
1273
2cf2e08a6ee9
Somewhat working code to support loading Dovecot from inetd and such. It
Timo Sirainen <tss@iki.fi>
parents:
1268
diff
changeset
|
150 fd_close_on_exec(null_fd, TRUE); |
2cf2e08a6ee9
Somewhat working code to support loading Dovecot from inetd and such. It
Timo Sirainen <tss@iki.fi>
parents:
1268
diff
changeset
|
151 } |
2cf2e08a6ee9
Somewhat working code to support loading Dovecot from inetd and such. It
Timo Sirainen <tss@iki.fi>
parents:
1268
diff
changeset
|
152 |
6940
414c9d631a81
Replaced t_push/t_pop calls with T_FRAME*() macros.
Timo Sirainen <tss@iki.fi>
parents:
6893
diff
changeset
|
153 if (!IS_INETD()) { |
414c9d631a81
Replaced t_push/t_pop calls with T_FRAME*() macros.
Timo Sirainen <tss@iki.fi>
parents:
6893
diff
changeset
|
154 T_FRAME( |
414c9d631a81
Replaced t_push/t_pop calls with T_FRAME*() macros.
Timo Sirainen <tss@iki.fi>
parents:
6893
diff
changeset
|
155 listeners_open_fds(NULL, FALSE); |
414c9d631a81
Replaced t_push/t_pop calls with T_FRAME*() macros.
Timo Sirainen <tss@iki.fi>
parents:
6893
diff
changeset
|
156 ); |
414c9d631a81
Replaced t_push/t_pop calls with T_FRAME*() macros.
Timo Sirainen <tss@iki.fi>
parents:
6893
diff
changeset
|
157 } |
1124
5e9430a39611
/dev/stderr works now in log paths.
Timo Sirainen <tss@iki.fi>
parents:
1100
diff
changeset
|
158 |
4477
e414beaf1473
If something in io_loop_create() failed, we logged the error to /dev/null.
Timo Sirainen <tss@iki.fi>
parents:
4475
diff
changeset
|
159 /* close stdin and stdout. */ |
1124
5e9430a39611
/dev/stderr works now in log paths.
Timo Sirainen <tss@iki.fi>
parents:
1100
diff
changeset
|
160 if (dup2(null_fd, 0) < 0) |
5e9430a39611
/dev/stderr works now in log paths.
Timo Sirainen <tss@iki.fi>
parents:
1100
diff
changeset
|
161 i_fatal("dup2(0) failed: %m"); |
5e9430a39611
/dev/stderr works now in log paths.
Timo Sirainen <tss@iki.fi>
parents:
1100
diff
changeset
|
162 if (dup2(null_fd, 1) < 0) |
5e9430a39611
/dev/stderr works now in log paths.
Timo Sirainen <tss@iki.fi>
parents:
1100
diff
changeset
|
163 i_fatal("dup2(1) failed: %m"); |
0 | 164 } |
165 | |
2524 | 166 static void create_pid_file(const char *path) |
167 { | |
168 const char *pid; | |
169 int fd; | |
170 | |
2534 | 171 pid = t_strconcat(dec2str(getpid()), "\n", NULL); |
2524 | 172 |
173 fd = open(path, O_WRONLY|O_CREAT|O_TRUNC, 0644); | |
174 if (fd == -1) | |
175 i_fatal("open(%s) failed: %m", path); | |
176 if (write_full(fd, pid, strlen(pid)) < 0) | |
177 i_fatal("write() failed in %s: %m", path); | |
178 (void)close(fd); | |
179 } | |
180 | |
5090
04b467f23400
Added --log-error command line option.
Timo Sirainen <tss@iki.fi>
parents:
5077
diff
changeset
|
181 static void main_init(bool log_error) |
0 | 182 { |
5824
5d0aa827f130
Reordered initialization code. Capabilities are now dropped as soon as
root@hurina
parents:
5789
diff
changeset
|
183 drop_capabilities(); |
5d0aa827f130
Reordered initialization code. Capabilities are now dropped as soon as
root@hurina
parents:
5789
diff
changeset
|
184 |
0 | 185 /* deny file access from everyone else except owner */ |
186 (void)umask(0077); | |
187 | |
5824
5d0aa827f130
Reordered initialization code. Capabilities are now dropped as soon as
root@hurina
parents:
5789
diff
changeset
|
188 set_logfile(settings_root->defaults); |
5d0aa827f130
Reordered initialization code. Capabilities are now dropped as soon as
root@hurina
parents:
5789
diff
changeset
|
189 /* close stderr unless we're logging into /dev/stderr. */ |
4477
e414beaf1473
If something in io_loop_create() failed, we logged the error to /dev/null.
Timo Sirainen <tss@iki.fi>
parents:
4475
diff
changeset
|
190 if (!have_stderr(settings_root)) { |
e414beaf1473
If something in io_loop_create() failed, we logged the error to /dev/null.
Timo Sirainen <tss@iki.fi>
parents:
4475
diff
changeset
|
191 if (dup2(null_fd, 2) < 0) |
e414beaf1473
If something in io_loop_create() failed, we logged the error to /dev/null.
Timo Sirainen <tss@iki.fi>
parents:
4475
diff
changeset
|
192 i_fatal("dup2(2) failed: %m"); |
e414beaf1473
If something in io_loop_create() failed, we logged the error to /dev/null.
Timo Sirainen <tss@iki.fi>
parents:
4475
diff
changeset
|
193 } |
2306
6aa77fdf152e
SIGHUP correctly reloads configuration now
Timo Sirainen <tss@iki.fi>
parents:
2235
diff
changeset
|
194 |
5696
b929827ddbe9
When using --log-error, log also a warning and an error.
Timo Sirainen <tss@iki.fi>
parents:
5639
diff
changeset
|
195 if (log_error) { |
6303 | 196 printf("Writing to error logs and killing myself..\n"); |
197 i_info("This is Dovecot's info log"); | |
5696
b929827ddbe9
When using --log-error, log also a warning and an error.
Timo Sirainen <tss@iki.fi>
parents:
5639
diff
changeset
|
198 i_warning("This is Dovecot's warning log"); |
b929827ddbe9
When using --log-error, log also a warning and an error.
Timo Sirainen <tss@iki.fi>
parents:
5639
diff
changeset
|
199 i_error("This is Dovecot's error log"); |
b929827ddbe9
When using --log-error, log also a warning and an error.
Timo Sirainen <tss@iki.fi>
parents:
5639
diff
changeset
|
200 i_fatal("This is Dovecot's fatal log"); |
b929827ddbe9
When using --log-error, log also a warning and an error.
Timo Sirainen <tss@iki.fi>
parents:
5639
diff
changeset
|
201 } |
6303 | 202 i_info("Dovecot v"VERSION" starting up"); |
5090
04b467f23400
Added --log-error command line option.
Timo Sirainen <tss@iki.fi>
parents:
5077
diff
changeset
|
203 |
3620
3360cc019737
Implemented new signal handling framework, which makes handling signals much
Timo Sirainen <tss@iki.fi>
parents:
3589
diff
changeset
|
204 lib_signals_init(); |
3360cc019737
Implemented new signal handling framework, which makes handling signals much
Timo Sirainen <tss@iki.fi>
parents:
3589
diff
changeset
|
205 lib_signals_set_handler(SIGINT, TRUE, sig_die, NULL); |
3360cc019737
Implemented new signal handling framework, which makes handling signals much
Timo Sirainen <tss@iki.fi>
parents:
3589
diff
changeset
|
206 lib_signals_set_handler(SIGTERM, TRUE, sig_die, NULL); |
4903
204d7edc7cdc
Added context parameter type safety checks for most callback APIs.
Timo Sirainen <tss@iki.fi>
parents:
4745
diff
changeset
|
207 lib_signals_ignore(SIGPIPE, TRUE); |
204d7edc7cdc
Added context parameter type safety checks for most callback APIs.
Timo Sirainen <tss@iki.fi>
parents:
4745
diff
changeset
|
208 lib_signals_ignore(SIGALRM, FALSE); |
3620
3360cc019737
Implemented new signal handling framework, which makes handling signals much
Timo Sirainen <tss@iki.fi>
parents:
3589
diff
changeset
|
209 lib_signals_set_handler(SIGHUP, TRUE, sig_reload_settings, NULL); |
3360cc019737
Implemented new signal handling framework, which makes handling signals much
Timo Sirainen <tss@iki.fi>
parents:
3589
diff
changeset
|
210 lib_signals_set_handler(SIGUSR1, TRUE, sig_reopen_logs, NULL); |
0 | 211 |
5843
f655c4d4a419
Moved child process handling to child-process.[ch]. The hash table now uses
Timo Sirainen <tss@iki.fi>
parents:
5824
diff
changeset
|
212 child_processes_init(); |
5824
5d0aa827f130
Reordered initialization code. Capabilities are now dropped as soon as
root@hurina
parents:
5789
diff
changeset
|
213 log_init(); |
615
0d852af6842e
Master process generates DH/RSA parameters now and stores them into file
Timo Sirainen <tss@iki.fi>
parents:
610
diff
changeset
|
214 ssl_init(); |
3853
b3e18b51c205
Start dict server automatically when a client tries to connect to it.
Timo Sirainen <tss@iki.fi>
parents:
3724
diff
changeset
|
215 dict_process_init(); |
0 | 216 auth_processes_init(); |
217 login_processes_init(); | |
5843
f655c4d4a419
Moved child process handling to child-process.[ch]. The hash table now uses
Timo Sirainen <tss@iki.fi>
parents:
5824
diff
changeset
|
218 mail_processes_init(); |
2524 | 219 |
220 create_pid_file(t_strconcat(settings_root->defaults->base_dir, | |
221 "/master.pid", NULL)); | |
0 | 222 } |
223 | |
224 static void main_deinit(void) | |
225 { | |
2524 | 226 (void)unlink(t_strconcat(settings_root->defaults->base_dir, |
227 "/master.pid", NULL)); | |
228 | |
5846
21e529b8a701
Initial implementation for mail_max_user_connections setting.
Timo Sirainen <tss@iki.fi>
parents:
5844
diff
changeset
|
229 login_processes_destroy_all(); |
21e529b8a701
Initial implementation for mail_max_user_connections setting.
Timo Sirainen <tss@iki.fi>
parents:
5844
diff
changeset
|
230 /* call process destroy handlers first */ |
21e529b8a701
Initial implementation for mail_max_user_connections setting.
Timo Sirainen <tss@iki.fi>
parents:
5844
diff
changeset
|
231 child_processes_deinit(); |
21e529b8a701
Initial implementation for mail_max_user_connections setting.
Timo Sirainen <tss@iki.fi>
parents:
5844
diff
changeset
|
232 |
21e529b8a701
Initial implementation for mail_max_user_connections setting.
Timo Sirainen <tss@iki.fi>
parents:
5844
diff
changeset
|
233 mail_processes_deinit(); |
0 | 234 login_processes_deinit(); |
235 auth_processes_deinit(); | |
3853
b3e18b51c205
Start dict server automatically when a client tries to connect to it.
Timo Sirainen <tss@iki.fi>
parents:
3724
diff
changeset
|
236 dict_process_deinit(); |
615
0d852af6842e
Master process generates DH/RSA parameters now and stores them into file
Timo Sirainen <tss@iki.fi>
parents:
610
diff
changeset
|
237 ssl_deinit(); |
0 | 238 |
5887
3f2eb1b9c555
Support listening multiple sockets. SIGHUP also doesn't anymore recreate
Timo Sirainen <tss@iki.fi>
parents:
5846
diff
changeset
|
239 listeners_close_fds(); |
3f2eb1b9c555
Support listening multiple sockets. SIGHUP also doesn't anymore recreate
Timo Sirainen <tss@iki.fi>
parents:
5846
diff
changeset
|
240 |
805
5ac361acb316
Marked all non-trivial buffer modifications with @UNSAFE tag. Several
Timo Sirainen <tss@iki.fi>
parents:
801
diff
changeset
|
241 if (close(null_fd) < 0) |
5ac361acb316
Marked all non-trivial buffer modifications with @UNSAFE tag. Several
Timo Sirainen <tss@iki.fi>
parents:
801
diff
changeset
|
242 i_error("close(null_fd) failed: %m"); |
1055
a72bba3f8a55
Rewrote setting handling. Changed some existing settings also since POP3
Timo Sirainen <tss@iki.fi>
parents:
1036
diff
changeset
|
243 |
3620
3360cc019737
Implemented new signal handling framework, which makes handling signals much
Timo Sirainen <tss@iki.fi>
parents:
3589
diff
changeset
|
244 lib_signals_deinit(); |
2000
c7c19f5071c3
Write all logging through master process. Fixes problems with log rotation,
Timo Sirainen <tss@iki.fi>
parents:
1820
diff
changeset
|
245 log_deinit(); |
0 | 246 closelog(); |
247 } | |
248 | |
1610
6850142c4e25
New configuration file code. Some syntax changes, but tries to be somewhat
Timo Sirainen <tss@iki.fi>
parents:
1423
diff
changeset
|
249 static void daemonize(struct settings *set) |
0 | 250 { |
251 pid_t pid; | |
252 | |
253 pid = fork(); | |
254 if (pid < 0) | |
255 i_fatal("fork() failed: %m"); | |
256 | |
257 if (pid != 0) | |
258 _exit(0); | |
610 | 259 |
801
86224ff16bf6
Drop root privileges earlier. Close syslog more later in imap-master when
Timo Sirainen <tss@iki.fi>
parents:
780
diff
changeset
|
260 if (setsid() < 0) |
86224ff16bf6
Drop root privileges earlier. Close syslog more later in imap-master when
Timo Sirainen <tss@iki.fi>
parents:
780
diff
changeset
|
261 i_fatal("setsid() failed: %m"); |
1367
533bb936e674
chdir() to base_dir at startup. chdir() mail processes to home dir if it's
Timo Sirainen <tss@iki.fi>
parents:
1358
diff
changeset
|
262 |
533bb936e674
chdir() to base_dir at startup. chdir() mail processes to home dir if it's
Timo Sirainen <tss@iki.fi>
parents:
1358
diff
changeset
|
263 if (chdir(set->base_dir) < 0) |
533bb936e674
chdir() to base_dir at startup. chdir() mail processes to home dir if it's
Timo Sirainen <tss@iki.fi>
parents:
1358
diff
changeset
|
264 i_fatal("chdir(%s) failed: %m", set->base_dir); |
0 | 265 } |
266 | |
279
49f4b0be0d87
Print usage with invalid parameters.
Timo Sirainen <tss@iki.fi>
parents:
50
diff
changeset
|
267 static void print_help(void) |
49f4b0be0d87
Print usage with invalid parameters.
Timo Sirainen <tss@iki.fi>
parents:
50
diff
changeset
|
268 { |
3917
ae292bd41926
Added --build-ssl-parameters option to build them.
Timo Sirainen <tss@iki.fi>
parents:
3901
diff
changeset
|
269 printf( |
4475
3a3ef25c62ab
List -n and -a in short help. Fixes to --build-options.
Timo Sirainen <tss@iki.fi>
parents:
4464
diff
changeset
|
270 "Usage: dovecot [-F] [-c <config file>] [-p] [-n] [-a]\n" |
3917
ae292bd41926
Added --build-ssl-parameters option to build them.
Timo Sirainen <tss@iki.fi>
parents:
3901
diff
changeset
|
271 " [--exec-mail <protocol>] [--version] [--build-options]\n"); |
3589
fead84acb13c
Added --build-options parameter. Patch by Andrey Panin
Timo Sirainen <tss@iki.fi>
parents:
3535
diff
changeset
|
272 } |
fead84acb13c
Added --build-options parameter. Patch by Andrey Panin
Timo Sirainen <tss@iki.fi>
parents:
3535
diff
changeset
|
273 |
fead84acb13c
Added --build-options parameter. Patch by Andrey Panin
Timo Sirainen <tss@iki.fi>
parents:
3535
diff
changeset
|
274 static void print_build_options(void) |
fead84acb13c
Added --build-options parameter. Patch by Andrey Panin
Timo Sirainen <tss@iki.fi>
parents:
3535
diff
changeset
|
275 { |
fead84acb13c
Added --build-options parameter. Patch by Andrey Panin
Timo Sirainen <tss@iki.fi>
parents:
3535
diff
changeset
|
276 printf("Build options:" |
fead84acb13c
Added --build-options parameter. Patch by Andrey Panin
Timo Sirainen <tss@iki.fi>
parents:
3535
diff
changeset
|
277 #ifdef IOLOOP_EPOLL |
fead84acb13c
Added --build-options parameter. Patch by Andrey Panin
Timo Sirainen <tss@iki.fi>
parents:
3535
diff
changeset
|
278 " ioloop=epoll" |
fead84acb13c
Added --build-options parameter. Patch by Andrey Panin
Timo Sirainen <tss@iki.fi>
parents:
3535
diff
changeset
|
279 #endif |
4475
3a3ef25c62ab
List -n and -a in short help. Fixes to --build-options.
Timo Sirainen <tss@iki.fi>
parents:
4464
diff
changeset
|
280 #ifdef IOLOOP_KQUEUE |
3a3ef25c62ab
List -n and -a in short help. Fixes to --build-options.
Timo Sirainen <tss@iki.fi>
parents:
4464
diff
changeset
|
281 " ioloop=kqueue" |
3a3ef25c62ab
List -n and -a in short help. Fixes to --build-options.
Timo Sirainen <tss@iki.fi>
parents:
4464
diff
changeset
|
282 #endif |
3589
fead84acb13c
Added --build-options parameter. Patch by Andrey Panin
Timo Sirainen <tss@iki.fi>
parents:
3535
diff
changeset
|
283 #ifdef IOLOOP_POLL |
fead84acb13c
Added --build-options parameter. Patch by Andrey Panin
Timo Sirainen <tss@iki.fi>
parents:
3535
diff
changeset
|
284 " ioloop=poll" |
fead84acb13c
Added --build-options parameter. Patch by Andrey Panin
Timo Sirainen <tss@iki.fi>
parents:
3535
diff
changeset
|
285 #endif |
fead84acb13c
Added --build-options parameter. Patch by Andrey Panin
Timo Sirainen <tss@iki.fi>
parents:
3535
diff
changeset
|
286 #ifdef IOLOOP_SELECT |
fead84acb13c
Added --build-options parameter. Patch by Andrey Panin
Timo Sirainen <tss@iki.fi>
parents:
3535
diff
changeset
|
287 " ioloop=select" |
fead84acb13c
Added --build-options parameter. Patch by Andrey Panin
Timo Sirainen <tss@iki.fi>
parents:
3535
diff
changeset
|
288 #endif |
fead84acb13c
Added --build-options parameter. Patch by Andrey Panin
Timo Sirainen <tss@iki.fi>
parents:
3535
diff
changeset
|
289 #ifdef IOLOOP_NOTIFY_DNOTIFY |
4475
3a3ef25c62ab
List -n and -a in short help. Fixes to --build-options.
Timo Sirainen <tss@iki.fi>
parents:
4464
diff
changeset
|
290 " notify=dnotify" |
3589
fead84acb13c
Added --build-options parameter. Patch by Andrey Panin
Timo Sirainen <tss@iki.fi>
parents:
3535
diff
changeset
|
291 #endif |
fead84acb13c
Added --build-options parameter. Patch by Andrey Panin
Timo Sirainen <tss@iki.fi>
parents:
3535
diff
changeset
|
292 #ifdef IOLOOP_NOTIFY_INOTIFY |
4475
3a3ef25c62ab
List -n and -a in short help. Fixes to --build-options.
Timo Sirainen <tss@iki.fi>
parents:
4464
diff
changeset
|
293 " notify=inotify" |
3a3ef25c62ab
List -n and -a in short help. Fixes to --build-options.
Timo Sirainen <tss@iki.fi>
parents:
4464
diff
changeset
|
294 #endif |
3a3ef25c62ab
List -n and -a in short help. Fixes to --build-options.
Timo Sirainen <tss@iki.fi>
parents:
4464
diff
changeset
|
295 #ifdef IOLOOP_NOTIFY_KQUEUE |
3a3ef25c62ab
List -n and -a in short help. Fixes to --build-options.
Timo Sirainen <tss@iki.fi>
parents:
4464
diff
changeset
|
296 " notify=kqueue" |
3589
fead84acb13c
Added --build-options parameter. Patch by Andrey Panin
Timo Sirainen <tss@iki.fi>
parents:
3535
diff
changeset
|
297 #endif |
fead84acb13c
Added --build-options parameter. Patch by Andrey Panin
Timo Sirainen <tss@iki.fi>
parents:
3535
diff
changeset
|
298 #ifdef HAVE_IPV6 |
fead84acb13c
Added --build-options parameter. Patch by Andrey Panin
Timo Sirainen <tss@iki.fi>
parents:
3535
diff
changeset
|
299 " ipv6" |
fead84acb13c
Added --build-options parameter. Patch by Andrey Panin
Timo Sirainen <tss@iki.fi>
parents:
3535
diff
changeset
|
300 #endif |
fead84acb13c
Added --build-options parameter. Patch by Andrey Panin
Timo Sirainen <tss@iki.fi>
parents:
3535
diff
changeset
|
301 #ifdef HAVE_GNUTLS |
fead84acb13c
Added --build-options parameter. Patch by Andrey Panin
Timo Sirainen <tss@iki.fi>
parents:
3535
diff
changeset
|
302 " gnutls" |
fead84acb13c
Added --build-options parameter. Patch by Andrey Panin
Timo Sirainen <tss@iki.fi>
parents:
3535
diff
changeset
|
303 #endif |
fead84acb13c
Added --build-options parameter. Patch by Andrey Panin
Timo Sirainen <tss@iki.fi>
parents:
3535
diff
changeset
|
304 #ifdef HAVE_OPENSSL |
fead84acb13c
Added --build-options parameter. Patch by Andrey Panin
Timo Sirainen <tss@iki.fi>
parents:
3535
diff
changeset
|
305 " openssl" |
fead84acb13c
Added --build-options parameter. Patch by Andrey Panin
Timo Sirainen <tss@iki.fi>
parents:
3535
diff
changeset
|
306 #endif |
6635
e4f9e2b94a90
Show mail storages in dovecot --build-options.
Timo Sirainen <tss@iki.fi>
parents:
6429
diff
changeset
|
307 "\nMail storages: "MAIL_STORAGES"\n" |
e4f9e2b94a90
Show mail storages in dovecot --build-options.
Timo Sirainen <tss@iki.fi>
parents:
6429
diff
changeset
|
308 "SQL drivers:" |
4475
3a3ef25c62ab
List -n and -a in short help. Fixes to --build-options.
Timo Sirainen <tss@iki.fi>
parents:
4464
diff
changeset
|
309 #ifdef BUILD_MYSQL |
3589
fead84acb13c
Added --build-options parameter. Patch by Andrey Panin
Timo Sirainen <tss@iki.fi>
parents:
3535
diff
changeset
|
310 " mysql" |
fead84acb13c
Added --build-options parameter. Patch by Andrey Panin
Timo Sirainen <tss@iki.fi>
parents:
3535
diff
changeset
|
311 #endif |
4475
3a3ef25c62ab
List -n and -a in short help. Fixes to --build-options.
Timo Sirainen <tss@iki.fi>
parents:
4464
diff
changeset
|
312 #ifdef BUILD_PGSQL |
3589
fead84acb13c
Added --build-options parameter. Patch by Andrey Panin
Timo Sirainen <tss@iki.fi>
parents:
3535
diff
changeset
|
313 " postgresql" |
fead84acb13c
Added --build-options parameter. Patch by Andrey Panin
Timo Sirainen <tss@iki.fi>
parents:
3535
diff
changeset
|
314 #endif |
4475
3a3ef25c62ab
List -n and -a in short help. Fixes to --build-options.
Timo Sirainen <tss@iki.fi>
parents:
4464
diff
changeset
|
315 #ifdef BUILD_SQLITE |
3919
b967ffb7e3a6
SQLite support. Patch by Jakob Hirsch.
Timo Sirainen <tss@iki.fi>
parents:
3917
diff
changeset
|
316 " sqlite" |
b967ffb7e3a6
SQLite support. Patch by Jakob Hirsch.
Timo Sirainen <tss@iki.fi>
parents:
3917
diff
changeset
|
317 #endif |
4475
3a3ef25c62ab
List -n and -a in short help. Fixes to --build-options.
Timo Sirainen <tss@iki.fi>
parents:
4464
diff
changeset
|
318 "\nPassdb:" |
3589
fead84acb13c
Added --build-options parameter. Patch by Andrey Panin
Timo Sirainen <tss@iki.fi>
parents:
3535
diff
changeset
|
319 #ifdef PASSDB_BSDAUTH |
4475
3a3ef25c62ab
List -n and -a in short help. Fixes to --build-options.
Timo Sirainen <tss@iki.fi>
parents:
4464
diff
changeset
|
320 " bsdauth" |
3589
fead84acb13c
Added --build-options parameter. Patch by Andrey Panin
Timo Sirainen <tss@iki.fi>
parents:
3535
diff
changeset
|
321 #endif |
fead84acb13c
Added --build-options parameter. Patch by Andrey Panin
Timo Sirainen <tss@iki.fi>
parents:
3535
diff
changeset
|
322 #ifdef PASSDB_CHECKPASSWORD |
4475
3a3ef25c62ab
List -n and -a in short help. Fixes to --build-options.
Timo Sirainen <tss@iki.fi>
parents:
4464
diff
changeset
|
323 " checkpassword" |
3589
fead84acb13c
Added --build-options parameter. Patch by Andrey Panin
Timo Sirainen <tss@iki.fi>
parents:
3535
diff
changeset
|
324 #endif |
fead84acb13c
Added --build-options parameter. Patch by Andrey Panin
Timo Sirainen <tss@iki.fi>
parents:
3535
diff
changeset
|
325 #ifdef PASSDB_LDAP |
4475
3a3ef25c62ab
List -n and -a in short help. Fixes to --build-options.
Timo Sirainen <tss@iki.fi>
parents:
4464
diff
changeset
|
326 " ldap" |
3589
fead84acb13c
Added --build-options parameter. Patch by Andrey Panin
Timo Sirainen <tss@iki.fi>
parents:
3535
diff
changeset
|
327 #endif |
fead84acb13c
Added --build-options parameter. Patch by Andrey Panin
Timo Sirainen <tss@iki.fi>
parents:
3535
diff
changeset
|
328 #ifdef PASSDB_PAM |
4475
3a3ef25c62ab
List -n and -a in short help. Fixes to --build-options.
Timo Sirainen <tss@iki.fi>
parents:
4464
diff
changeset
|
329 " pam" |
3589
fead84acb13c
Added --build-options parameter. Patch by Andrey Panin
Timo Sirainen <tss@iki.fi>
parents:
3535
diff
changeset
|
330 #endif |
fead84acb13c
Added --build-options parameter. Patch by Andrey Panin
Timo Sirainen <tss@iki.fi>
parents:
3535
diff
changeset
|
331 #ifdef PASSDB_PASSWD |
4475
3a3ef25c62ab
List -n and -a in short help. Fixes to --build-options.
Timo Sirainen <tss@iki.fi>
parents:
4464
diff
changeset
|
332 " passwd" |
3589
fead84acb13c
Added --build-options parameter. Patch by Andrey Panin
Timo Sirainen <tss@iki.fi>
parents:
3535
diff
changeset
|
333 #endif |
fead84acb13c
Added --build-options parameter. Patch by Andrey Panin
Timo Sirainen <tss@iki.fi>
parents:
3535
diff
changeset
|
334 #ifdef PASSDB_PASSWD_FILE |
4475
3a3ef25c62ab
List -n and -a in short help. Fixes to --build-options.
Timo Sirainen <tss@iki.fi>
parents:
4464
diff
changeset
|
335 " passwd-file" |
3589
fead84acb13c
Added --build-options parameter. Patch by Andrey Panin
Timo Sirainen <tss@iki.fi>
parents:
3535
diff
changeset
|
336 #endif |
fead84acb13c
Added --build-options parameter. Patch by Andrey Panin
Timo Sirainen <tss@iki.fi>
parents:
3535
diff
changeset
|
337 #ifdef PASSDB_SHADOW |
4475
3a3ef25c62ab
List -n and -a in short help. Fixes to --build-options.
Timo Sirainen <tss@iki.fi>
parents:
4464
diff
changeset
|
338 " shadow" |
3589
fead84acb13c
Added --build-options parameter. Patch by Andrey Panin
Timo Sirainen <tss@iki.fi>
parents:
3535
diff
changeset
|
339 #endif |
6893
a9daec3c00b5
--build-options didn't list "sia" in passdbs.
Timo Sirainen <tss@iki.fi>
parents:
6635
diff
changeset
|
340 #ifdef PASSDB_SIA |
a9daec3c00b5
--build-options didn't list "sia" in passdbs.
Timo Sirainen <tss@iki.fi>
parents:
6635
diff
changeset
|
341 " sia" |
a9daec3c00b5
--build-options didn't list "sia" in passdbs.
Timo Sirainen <tss@iki.fi>
parents:
6635
diff
changeset
|
342 #endif |
3589
fead84acb13c
Added --build-options parameter. Patch by Andrey Panin
Timo Sirainen <tss@iki.fi>
parents:
3535
diff
changeset
|
343 #ifdef PASSDB_SQL |
4475
3a3ef25c62ab
List -n and -a in short help. Fixes to --build-options.
Timo Sirainen <tss@iki.fi>
parents:
4464
diff
changeset
|
344 " sql" |
3589
fead84acb13c
Added --build-options parameter. Patch by Andrey Panin
Timo Sirainen <tss@iki.fi>
parents:
3535
diff
changeset
|
345 #endif |
fead84acb13c
Added --build-options parameter. Patch by Andrey Panin
Timo Sirainen <tss@iki.fi>
parents:
3535
diff
changeset
|
346 #ifdef PASSDB_VPOPMAIL |
4475
3a3ef25c62ab
List -n and -a in short help. Fixes to --build-options.
Timo Sirainen <tss@iki.fi>
parents:
4464
diff
changeset
|
347 " vpopmail" |
3589
fead84acb13c
Added --build-options parameter. Patch by Andrey Panin
Timo Sirainen <tss@iki.fi>
parents:
3535
diff
changeset
|
348 #endif |
4475
3a3ef25c62ab
List -n and -a in short help. Fixes to --build-options.
Timo Sirainen <tss@iki.fi>
parents:
4464
diff
changeset
|
349 "\nUserdb:" |
3589
fead84acb13c
Added --build-options parameter. Patch by Andrey Panin
Timo Sirainen <tss@iki.fi>
parents:
3535
diff
changeset
|
350 #ifdef USERDB_CHECKPASSWORD |
4475
3a3ef25c62ab
List -n and -a in short help. Fixes to --build-options.
Timo Sirainen <tss@iki.fi>
parents:
4464
diff
changeset
|
351 " checkpassword" |
3589
fead84acb13c
Added --build-options parameter. Patch by Andrey Panin
Timo Sirainen <tss@iki.fi>
parents:
3535
diff
changeset
|
352 #endif |
fead84acb13c
Added --build-options parameter. Patch by Andrey Panin
Timo Sirainen <tss@iki.fi>
parents:
3535
diff
changeset
|
353 #ifdef USERDB_LDAP |
4475
3a3ef25c62ab
List -n and -a in short help. Fixes to --build-options.
Timo Sirainen <tss@iki.fi>
parents:
4464
diff
changeset
|
354 " ldap" |
3589
fead84acb13c
Added --build-options parameter. Patch by Andrey Panin
Timo Sirainen <tss@iki.fi>
parents:
3535
diff
changeset
|
355 #endif |
fead84acb13c
Added --build-options parameter. Patch by Andrey Panin
Timo Sirainen <tss@iki.fi>
parents:
3535
diff
changeset
|
356 #ifdef USERDB_PASSWD |
4475
3a3ef25c62ab
List -n and -a in short help. Fixes to --build-options.
Timo Sirainen <tss@iki.fi>
parents:
4464
diff
changeset
|
357 " passwd" |
3a3ef25c62ab
List -n and -a in short help. Fixes to --build-options.
Timo Sirainen <tss@iki.fi>
parents:
4464
diff
changeset
|
358 #endif |
3a3ef25c62ab
List -n and -a in short help. Fixes to --build-options.
Timo Sirainen <tss@iki.fi>
parents:
4464
diff
changeset
|
359 #ifdef USERDB_PREFETCH |
3a3ef25c62ab
List -n and -a in short help. Fixes to --build-options.
Timo Sirainen <tss@iki.fi>
parents:
4464
diff
changeset
|
360 " prefetch" |
3589
fead84acb13c
Added --build-options parameter. Patch by Andrey Panin
Timo Sirainen <tss@iki.fi>
parents:
3535
diff
changeset
|
361 #endif |
fead84acb13c
Added --build-options parameter. Patch by Andrey Panin
Timo Sirainen <tss@iki.fi>
parents:
3535
diff
changeset
|
362 #ifdef USERDB_PASSWD_FILE |
4475
3a3ef25c62ab
List -n and -a in short help. Fixes to --build-options.
Timo Sirainen <tss@iki.fi>
parents:
4464
diff
changeset
|
363 " passwd-file" |
3589
fead84acb13c
Added --build-options parameter. Patch by Andrey Panin
Timo Sirainen <tss@iki.fi>
parents:
3535
diff
changeset
|
364 #endif |
fead84acb13c
Added --build-options parameter. Patch by Andrey Panin
Timo Sirainen <tss@iki.fi>
parents:
3535
diff
changeset
|
365 #ifdef USERDB_SQL |
4475
3a3ef25c62ab
List -n and -a in short help. Fixes to --build-options.
Timo Sirainen <tss@iki.fi>
parents:
4464
diff
changeset
|
366 " sql" |
3589
fead84acb13c
Added --build-options parameter. Patch by Andrey Panin
Timo Sirainen <tss@iki.fi>
parents:
3535
diff
changeset
|
367 #endif |
fead84acb13c
Added --build-options parameter. Patch by Andrey Panin
Timo Sirainen <tss@iki.fi>
parents:
3535
diff
changeset
|
368 #ifdef USERDB_STATIC |
4475
3a3ef25c62ab
List -n and -a in short help. Fixes to --build-options.
Timo Sirainen <tss@iki.fi>
parents:
4464
diff
changeset
|
369 " static" |
3589
fead84acb13c
Added --build-options parameter. Patch by Andrey Panin
Timo Sirainen <tss@iki.fi>
parents:
3535
diff
changeset
|
370 #endif |
fead84acb13c
Added --build-options parameter. Patch by Andrey Panin
Timo Sirainen <tss@iki.fi>
parents:
3535
diff
changeset
|
371 #ifdef USERDB_VPOPMAIL |
4475
3a3ef25c62ab
List -n and -a in short help. Fixes to --build-options.
Timo Sirainen <tss@iki.fi>
parents:
4464
diff
changeset
|
372 " vpopmail" |
3589
fead84acb13c
Added --build-options parameter. Patch by Andrey Panin
Timo Sirainen <tss@iki.fi>
parents:
3535
diff
changeset
|
373 #endif |
fead84acb13c
Added --build-options parameter. Patch by Andrey Panin
Timo Sirainen <tss@iki.fi>
parents:
3535
diff
changeset
|
374 "\n"); |
279
49f4b0be0d87
Print usage with invalid parameters.
Timo Sirainen <tss@iki.fi>
parents:
50
diff
changeset
|
375 } |
49f4b0be0d87
Print usage with invalid parameters.
Timo Sirainen <tss@iki.fi>
parents:
50
diff
changeset
|
376 |
0 | 377 int main(int argc, char *argv[]) |
378 { | |
379 /* parse arguments */ | |
3897
9dc2f8f0eb59
When starting with --exec-mail, keep USER and HOME environments and clear
Timo Sirainen <tss@iki.fi>
parents:
3889
diff
changeset
|
380 const char *exec_protocol = NULL, *exec_section = NULL, *user, *home; |
5090
04b467f23400
Added --log-error command line option.
Timo Sirainen <tss@iki.fi>
parents:
5077
diff
changeset
|
381 bool foreground = FALSE, ask_key_pass = FALSE, log_error = FALSE; |
4138
f9a6381adbe3
Added -a and -n parameters to dovecot to dump all/nondefault settings. A
Timo Sirainen <tss@iki.fi>
parents:
3989
diff
changeset
|
382 bool dump_config = FALSE, dump_config_nondefaults = FALSE; |
0 | 383 int i; |
384 | |
2311
4558d1b196fd
Added --exec-mail option to master. It can be used to parse Dovecot config
Timo Sirainen <tss@iki.fi>
parents:
2306
diff
changeset
|
385 #ifdef DEBUG |
4558d1b196fd
Added --exec-mail option to master. It can be used to parse Dovecot config
Timo Sirainen <tss@iki.fi>
parents:
2306
diff
changeset
|
386 gdb = getenv("GDB") != NULL; |
4558d1b196fd
Added --exec-mail option to master. It can be used to parse Dovecot config
Timo Sirainen <tss@iki.fi>
parents:
2306
diff
changeset
|
387 #endif |
0 | 388 lib_init(); |
389 | |
1617
cc3cef25662c
Replaced geteuid() calls with one in the beginning and saving it to
Timo Sirainen <tss@iki.fi>
parents:
1610
diff
changeset
|
390 master_uid = geteuid(); |
1273
2cf2e08a6ee9
Somewhat working code to support loading Dovecot from inetd and such. It
Timo Sirainen <tss@iki.fi>
parents:
1268
diff
changeset
|
391 inetd_login_fd = -1; |
0 | 392 for (i = 1; i < argc; i++) { |
393 if (strcmp(argv[i], "-F") == 0) { | |
394 /* foreground */ | |
395 foreground = TRUE; | |
4138
f9a6381adbe3
Added -a and -n parameters to dovecot to dump all/nondefault settings. A
Timo Sirainen <tss@iki.fi>
parents:
3989
diff
changeset
|
396 } else if (strcmp(argv[i], "-a") == 0) { |
f9a6381adbe3
Added -a and -n parameters to dovecot to dump all/nondefault settings. A
Timo Sirainen <tss@iki.fi>
parents:
3989
diff
changeset
|
397 dump_config = TRUE; |
0 | 398 } else if (strcmp(argv[i], "-c") == 0) { |
399 /* config file */ | |
400 i++; | |
401 if (i == argc) i_fatal("Missing config file argument"); | |
402 configfile = argv[i]; | |
4138
f9a6381adbe3
Added -a and -n parameters to dovecot to dump all/nondefault settings. A
Timo Sirainen <tss@iki.fi>
parents:
3989
diff
changeset
|
403 } else if (strcmp(argv[i], "-n") == 0) { |
4965
9246d9308caa
-n and -a parameters shouldn't be deleting auth sockets.
Timo Sirainen <tss@iki.fi>
parents:
4903
diff
changeset
|
404 dump_config_nondefaults = dump_config = TRUE; |
3889
c7462001227b
Added support for password protected SSL private keys. The password can be
Timo Sirainen <tss@iki.fi>
parents:
3879
diff
changeset
|
405 } else if (strcmp(argv[i], "-p") == 0) { |
c7462001227b
Added support for password protected SSL private keys. The password can be
Timo Sirainen <tss@iki.fi>
parents:
3879
diff
changeset
|
406 /* Ask SSL private key password */ |
c7462001227b
Added support for password protected SSL private keys. The password can be
Timo Sirainen <tss@iki.fi>
parents:
3879
diff
changeset
|
407 ask_key_pass = TRUE; |
2311
4558d1b196fd
Added --exec-mail option to master. It can be used to parse Dovecot config
Timo Sirainen <tss@iki.fi>
parents:
2306
diff
changeset
|
408 } else if (strcmp(argv[i], "--exec-mail") == 0) { |
4558d1b196fd
Added --exec-mail option to master. It can be used to parse Dovecot config
Timo Sirainen <tss@iki.fi>
parents:
2306
diff
changeset
|
409 /* <protocol> [<server section>] |
4558d1b196fd
Added --exec-mail option to master. It can be used to parse Dovecot config
Timo Sirainen <tss@iki.fi>
parents:
2306
diff
changeset
|
410 read configuration and execute mail process */ |
4558d1b196fd
Added --exec-mail option to master. It can be used to parse Dovecot config
Timo Sirainen <tss@iki.fi>
parents:
2306
diff
changeset
|
411 i++; |
4558d1b196fd
Added --exec-mail option to master. It can be used to parse Dovecot config
Timo Sirainen <tss@iki.fi>
parents:
2306
diff
changeset
|
412 if (i == argc) i_fatal("Missing protocol argument"); |
4558d1b196fd
Added --exec-mail option to master. It can be used to parse Dovecot config
Timo Sirainen <tss@iki.fi>
parents:
2306
diff
changeset
|
413 exec_protocol = argv[i]; |
4558d1b196fd
Added --exec-mail option to master. It can be used to parse Dovecot config
Timo Sirainen <tss@iki.fi>
parents:
2306
diff
changeset
|
414 if (i+1 != argc) |
2312
cc753e275197
And section fix for --exec-mail..
Timo Sirainen <tss@iki.fi>
parents:
2311
diff
changeset
|
415 exec_section = argv[++i]; |
1260 | 416 } else if (strcmp(argv[i], "--version") == 0) { |
417 printf("%s\n", VERSION); | |
418 return 0; | |
3589
fead84acb13c
Added --build-options parameter. Patch by Andrey Panin
Timo Sirainen <tss@iki.fi>
parents:
3535
diff
changeset
|
419 } else if (strcmp(argv[i], "--build-options") == 0) { |
fead84acb13c
Added --build-options parameter. Patch by Andrey Panin
Timo Sirainen <tss@iki.fi>
parents:
3535
diff
changeset
|
420 print_build_options(); |
fead84acb13c
Added --build-options parameter. Patch by Andrey Panin
Timo Sirainen <tss@iki.fi>
parents:
3535
diff
changeset
|
421 return 0; |
5090
04b467f23400
Added --log-error command line option.
Timo Sirainen <tss@iki.fi>
parents:
5077
diff
changeset
|
422 } else if (strcmp(argv[i], "--log-error") == 0) { |
04b467f23400
Added --log-error command line option.
Timo Sirainen <tss@iki.fi>
parents:
5077
diff
changeset
|
423 log_error = TRUE; |
04b467f23400
Added --log-error command line option.
Timo Sirainen <tss@iki.fi>
parents:
5077
diff
changeset
|
424 foreground = TRUE; |
0 | 425 } else { |
279
49f4b0be0d87
Print usage with invalid parameters.
Timo Sirainen <tss@iki.fi>
parents:
50
diff
changeset
|
426 print_help(); |
0 | 427 i_fatal("Unknown argument: %s", argv[1]); |
428 } | |
429 } | |
430 | |
5437 | 431 /* need to have this open before reading settings */ |
432 open_null_fd(); | |
433 | |
2311
4558d1b196fd
Added --exec-mail option to master. It can be used to parse Dovecot config
Timo Sirainen <tss@iki.fi>
parents:
2306
diff
changeset
|
434 if (getenv("DOVECOT_INETD") != NULL) { |
4558d1b196fd
Added --exec-mail option to master. It can be used to parse Dovecot config
Timo Sirainen <tss@iki.fi>
parents:
2306
diff
changeset
|
435 /* starting through inetd. */ |
4558d1b196fd
Added --exec-mail option to master. It can be used to parse Dovecot config
Timo Sirainen <tss@iki.fi>
parents:
2306
diff
changeset
|
436 inetd_login_fd = dup(0); |
4558d1b196fd
Added --exec-mail option to master. It can be used to parse Dovecot config
Timo Sirainen <tss@iki.fi>
parents:
2306
diff
changeset
|
437 if (inetd_login_fd == -1) |
4558d1b196fd
Added --exec-mail option to master. It can be used to parse Dovecot config
Timo Sirainen <tss@iki.fi>
parents:
2306
diff
changeset
|
438 i_fatal("dup(0) failed: %m"); |
4558d1b196fd
Added --exec-mail option to master. It can be used to parse Dovecot config
Timo Sirainen <tss@iki.fi>
parents:
2306
diff
changeset
|
439 fd_close_on_exec(inetd_login_fd, TRUE); |
4558d1b196fd
Added --exec-mail option to master. It can be used to parse Dovecot config
Timo Sirainen <tss@iki.fi>
parents:
2306
diff
changeset
|
440 foreground = TRUE; |
4558d1b196fd
Added --exec-mail option to master. It can be used to parse Dovecot config
Timo Sirainen <tss@iki.fi>
parents:
2306
diff
changeset
|
441 } |
4558d1b196fd
Added --exec-mail option to master. It can be used to parse Dovecot config
Timo Sirainen <tss@iki.fi>
parents:
2306
diff
changeset
|
442 |
4965
9246d9308caa
-n and -a parameters shouldn't be deleting auth sockets.
Timo Sirainen <tss@iki.fi>
parents:
4903
diff
changeset
|
443 if (dump_config) { |
4485
eb1e7932ade6
dovecot -n and -a: Print the config file path before parsing it so if there
Timo Sirainen <tss@iki.fi>
parents:
4477
diff
changeset
|
444 /* print the config file path before parsing it, so in case |
eb1e7932ade6
dovecot -n and -a: Print the config file path before parsing it so if there
Timo Sirainen <tss@iki.fi>
parents:
4477
diff
changeset
|
445 of errors it's still shown */ |
5589
271c35971331
Print also Dovecot version with dovecot -n.
Timo Sirainen <tss@iki.fi>
parents:
5437
diff
changeset
|
446 printf("# "VERSION": %s\n", configfile); |
4485
eb1e7932ade6
dovecot -n and -a: Print the config file path before parsing it so if there
Timo Sirainen <tss@iki.fi>
parents:
4477
diff
changeset
|
447 } |
eb1e7932ade6
dovecot -n and -a: Print the config file path before parsing it so if there
Timo Sirainen <tss@iki.fi>
parents:
4477
diff
changeset
|
448 |
0 | 449 /* read and verify settings before forking */ |
6940
414c9d631a81
Replaced t_push/t_pop calls with T_FRAME*() macros.
Timo Sirainen <tss@iki.fi>
parents:
6893
diff
changeset
|
450 T_FRAME( |
414c9d631a81
Replaced t_push/t_pop calls with T_FRAME*() macros.
Timo Sirainen <tss@iki.fi>
parents:
6893
diff
changeset
|
451 master_settings_init(); |
414c9d631a81
Replaced t_push/t_pop calls with T_FRAME*() macros.
Timo Sirainen <tss@iki.fi>
parents:
6893
diff
changeset
|
452 if (!master_settings_read(configfile, exec_protocol != NULL, |
414c9d631a81
Replaced t_push/t_pop calls with T_FRAME*() macros.
Timo Sirainen <tss@iki.fi>
parents:
6893
diff
changeset
|
453 dump_config || log_error)) |
414c9d631a81
Replaced t_push/t_pop calls with T_FRAME*() macros.
Timo Sirainen <tss@iki.fi>
parents:
6893
diff
changeset
|
454 i_fatal("Invalid configuration in %s", configfile); |
414c9d631a81
Replaced t_push/t_pop calls with T_FRAME*() macros.
Timo Sirainen <tss@iki.fi>
parents:
6893
diff
changeset
|
455 ); |
0 | 456 |
4965
9246d9308caa
-n and -a parameters shouldn't be deleting auth sockets.
Timo Sirainen <tss@iki.fi>
parents:
4903
diff
changeset
|
457 if (dump_config) { |
4138
f9a6381adbe3
Added -a and -n parameters to dovecot to dump all/nondefault settings. A
Timo Sirainen <tss@iki.fi>
parents:
3989
diff
changeset
|
458 master_settings_dump(settings_root, dump_config_nondefaults); |
f9a6381adbe3
Added -a and -n parameters to dovecot to dump all/nondefault settings. A
Timo Sirainen <tss@iki.fi>
parents:
3989
diff
changeset
|
459 return 0; |
f9a6381adbe3
Added -a and -n parameters to dovecot to dump all/nondefault settings. A
Timo Sirainen <tss@iki.fi>
parents:
3989
diff
changeset
|
460 } |
f9a6381adbe3
Added -a and -n parameters to dovecot to dump all/nondefault settings. A
Timo Sirainen <tss@iki.fi>
parents:
3989
diff
changeset
|
461 |
6940
414c9d631a81
Replaced t_push/t_pop calls with T_FRAME*() macros.
Timo Sirainen <tss@iki.fi>
parents:
6893
diff
changeset
|
462 if (ask_key_pass) T_FRAME_BEGIN { |
3889
c7462001227b
Added support for password protected SSL private keys. The password can be
Timo Sirainen <tss@iki.fi>
parents:
3879
diff
changeset
|
463 const char *prompt; |
c7462001227b
Added support for password protected SSL private keys. The password can be
Timo Sirainen <tss@iki.fi>
parents:
3879
diff
changeset
|
464 |
c7462001227b
Added support for password protected SSL private keys. The password can be
Timo Sirainen <tss@iki.fi>
parents:
3879
diff
changeset
|
465 prompt = t_strdup_printf("Give the password for SSL key file " |
c7462001227b
Added support for password protected SSL private keys. The password can be
Timo Sirainen <tss@iki.fi>
parents:
3879
diff
changeset
|
466 "%s: ", |
c7462001227b
Added support for password protected SSL private keys. The password can be
Timo Sirainen <tss@iki.fi>
parents:
3879
diff
changeset
|
467 settings_root->defaults->ssl_key_file); |
c7462001227b
Added support for password protected SSL private keys. The password can be
Timo Sirainen <tss@iki.fi>
parents:
3879
diff
changeset
|
468 askpass(prompt, 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
|
469 sizeof(ssl_manual_key_password)); |
6940
414c9d631a81
Replaced t_push/t_pop calls with T_FRAME*() macros.
Timo Sirainen <tss@iki.fi>
parents:
6893
diff
changeset
|
470 } T_FRAME_END; |
3889
c7462001227b
Added support for password protected SSL private keys. The password can be
Timo Sirainen <tss@iki.fi>
parents:
3879
diff
changeset
|
471 |
3535
08b3e3fd0bc5
The master process itself also needs the TZ environment
Timo Sirainen <tss@iki.fi>
parents:
3516
diff
changeset
|
472 /* save TZ environment. AIX depends on it to get the timezone |
08b3e3fd0bc5
The master process itself also needs the TZ environment
Timo Sirainen <tss@iki.fi>
parents:
3516
diff
changeset
|
473 correctly. */ |
3516
71b0ccba8cf3
Preserve TZ environment to child processes so timezones aren't lost with
Timo Sirainen <tss@iki.fi>
parents:
3181
diff
changeset
|
474 env_tz = getenv("TZ"); |
3897
9dc2f8f0eb59
When starting with --exec-mail, keep USER and HOME environments and clear
Timo Sirainen <tss@iki.fi>
parents:
3889
diff
changeset
|
475 user = getenv("USER"); |
9dc2f8f0eb59
When starting with --exec-mail, keep USER and HOME environments and clear
Timo Sirainen <tss@iki.fi>
parents:
3889
diff
changeset
|
476 home = getenv("HOME"); |
3516
71b0ccba8cf3
Preserve TZ environment to child processes so timezones aren't lost with
Timo Sirainen <tss@iki.fi>
parents:
3181
diff
changeset
|
477 |
3535
08b3e3fd0bc5
The master process itself also needs the TZ environment
Timo Sirainen <tss@iki.fi>
parents:
3516
diff
changeset
|
478 /* clean up the environment of everything */ |
1273
2cf2e08a6ee9
Somewhat working code to support loading Dovecot from inetd and such. It
Timo Sirainen <tss@iki.fi>
parents:
1268
diff
changeset
|
479 env_clean(); |
2cf2e08a6ee9
Somewhat working code to support loading Dovecot from inetd and such. It
Timo Sirainen <tss@iki.fi>
parents:
1268
diff
changeset
|
480 |
3535
08b3e3fd0bc5
The master process itself also needs the TZ environment
Timo Sirainen <tss@iki.fi>
parents:
3516
diff
changeset
|
481 /* put back the TZ */ |
08b3e3fd0bc5
The master process itself also needs the TZ environment
Timo Sirainen <tss@iki.fi>
parents:
3516
diff
changeset
|
482 if (env_tz != NULL) |
08b3e3fd0bc5
The master process itself also needs the TZ environment
Timo Sirainen <tss@iki.fi>
parents:
3516
diff
changeset
|
483 env_put(t_strconcat("TZ=", env_tz, NULL)); |
08b3e3fd0bc5
The master process itself also needs the TZ environment
Timo Sirainen <tss@iki.fi>
parents:
3516
diff
changeset
|
484 |
3897
9dc2f8f0eb59
When starting with --exec-mail, keep USER and HOME environments and clear
Timo Sirainen <tss@iki.fi>
parents:
3889
diff
changeset
|
485 if (exec_protocol != NULL) { |
9dc2f8f0eb59
When starting with --exec-mail, keep USER and HOME environments and clear
Timo Sirainen <tss@iki.fi>
parents:
3889
diff
changeset
|
486 /* Put back user and home */ |
9dc2f8f0eb59
When starting with --exec-mail, keep USER and HOME environments and clear
Timo Sirainen <tss@iki.fi>
parents:
3889
diff
changeset
|
487 env_put(t_strconcat("USER=", user, NULL)); |
9dc2f8f0eb59
When starting with --exec-mail, keep USER and HOME environments and clear
Timo Sirainen <tss@iki.fi>
parents:
3889
diff
changeset
|
488 env_put(t_strconcat("HOME=", home, NULL)); |
9dc2f8f0eb59
When starting with --exec-mail, keep USER and HOME environments and clear
Timo Sirainen <tss@iki.fi>
parents:
3889
diff
changeset
|
489 mail_process_exec(exec_protocol, exec_section); |
9dc2f8f0eb59
When starting with --exec-mail, keep USER and HOME environments and clear
Timo Sirainen <tss@iki.fi>
parents:
3889
diff
changeset
|
490 } |
9dc2f8f0eb59
When starting with --exec-mail, keep USER and HOME environments and clear
Timo Sirainen <tss@iki.fi>
parents:
3889
diff
changeset
|
491 |
6303 | 492 if (!log_error) |
493 open_fds(); | |
2311
4558d1b196fd
Added --exec-mail option to master. It can be used to parse Dovecot config
Timo Sirainen <tss@iki.fi>
parents:
2306
diff
changeset
|
494 |
0 | 495 if (!foreground) |
1610
6850142c4e25
New configuration file code. Some syntax changes, but tries to be somewhat
Timo Sirainen <tss@iki.fi>
parents:
1423
diff
changeset
|
496 daemonize(settings_root->defaults); |
0 | 497 |
5249
784dc7224718
Removed pool parameter from io_loop_create()
Timo Sirainen <tss@iki.fi>
parents:
5201
diff
changeset
|
498 ioloop = io_loop_create(); |
0 | 499 |
5090
04b467f23400
Added --log-error command line option.
Timo Sirainen <tss@iki.fi>
parents:
5077
diff
changeset
|
500 main_init(log_error); |
0 | 501 io_loop_run(ioloop); |
502 main_deinit(); | |
503 | |
1058
3b8fb7bf7ecc
Moved settings parsing to lib-settings.
Timo Sirainen <tss@iki.fi>
parents:
1055
diff
changeset
|
504 master_settings_deinit(); |
3879
928229f8b3e6
deinit, unref, destroy, close, free, etc. functions now take a pointer to
Timo Sirainen <tss@iki.fi>
parents:
3863
diff
changeset
|
505 io_loop_destroy(&ioloop); |
0 | 506 lib_deinit(); |
507 | |
508 return 0; | |
509 } |