Mercurial > dovecot > original-hg > dovecot-1.2
annotate src/master/main.c @ 9348:3eacb6bbd227 HEAD
Added pop3_save_uidl setting.
When UIDLs are sent to client, save them to dovecot-uidlist. This allows
changing pop3_uidl_format without messages getting re-downloaded. It's also
useful with virtual POP3 INBOX when UIDLs are based on IMAP UIDs that may
not be as stable as in non-virtual INBOX.
author | Timo Sirainen <tss@iki.fi> |
---|---|
date | Mon, 31 Aug 2009 18:53:17 -0400 |
parents | d936c8e243dd |
children | 7639914c5cde |
rev | line source |
---|---|
8590
b9faf4db2a9f
Updated copyright notices to include year 2009.
Timo Sirainen <tss@iki.fi>
parents:
8354
diff
changeset
|
1 /* Copyright (c) 2002-2009 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" |
8354
5339d2ebeb56
dovecot -n/-a: Print some information about the system.
Timo Sirainen <tss@iki.fi>
parents:
8323
diff
changeset
|
23 #include "sysinfo-get.h" |
8595
829b6555392b
master: When receiving SIGHUP, get the hostname again in case it changed.
Timo Sirainen <tss@iki.fi>
parents:
8590
diff
changeset
|
24 #include "hostpid.h" |
0 | 25 |
279
49f4b0be0d87
Print usage with invalid parameters.
Timo Sirainen <tss@iki.fi>
parents:
50
diff
changeset
|
26 #include <stdio.h> |
0 | 27 #include <stdlib.h> |
28 #include <unistd.h> | |
29 #include <fcntl.h> | |
30 #include <syslog.h> | |
31 #include <sys/stat.h> | |
32 | |
7229
586abf9b561c
If Dovecot master dies with a fatal failure, log the error message to a file
Timo Sirainen <tss@iki.fi>
parents:
7226
diff
changeset
|
33 #define FATAL_FILENAME "master-fatal.lastlog" |
586abf9b561c
If Dovecot master dies with a fatal failure, log the error message to a file
Timo Sirainen <tss@iki.fi>
parents:
7226
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"; |
8323
60c48789841b
master: Don't print "last died with error .." for fatals that were from forked child processes.
Timo Sirainen <tss@iki.fi>
parents:
8305
diff
changeset
|
36 static pid_t master_original_pid; |
0 | 37 |
1000
0fbafade2d85
If auth/login process died unexpectedly, the exit status or killing signal
Timo Sirainen <tss@iki.fi>
parents:
945
diff
changeset
|
38 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
|
39 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
|
40 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
|
41 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
|
42 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
|
43 const char *env_tz; |
8301
d46579bb7a3c
Print a help message about authentication at startup until the first successful authentication.
Timo Sirainen <tss@iki.fi>
parents:
8062
diff
changeset
|
44 bool auth_success_written; |
8798
c9381a0fdc5e
Improved logging for core dumping. With Linux use PR_SET_DUMPABLE for imap/pop3.
Timo Sirainen <tss@iki.fi>
parents:
8782
diff
changeset
|
45 bool core_dumps_disabled; |
2235
dcff4c088f1a
DEBUG: If GDB environment is set, don't do fd leak checks.
Timo Sirainen <tss@iki.fi>
parents:
2047
diff
changeset
|
46 #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
|
47 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
|
48 #endif |
0 | 49 |
7229
586abf9b561c
If Dovecot master dies with a fatal failure, log the error message to a file
Timo Sirainen <tss@iki.fi>
parents:
7226
diff
changeset
|
50 static void ATTR_NORETURN ATTR_FORMAT(3, 0) |
586abf9b561c
If Dovecot master dies with a fatal failure, log the error message to a file
Timo Sirainen <tss@iki.fi>
parents:
7226
diff
changeset
|
51 master_fatal_callback(enum log_type type, int status, |
586abf9b561c
If Dovecot master dies with a fatal failure, log the error message to a file
Timo Sirainen <tss@iki.fi>
parents:
7226
diff
changeset
|
52 const char *format, va_list args) |
586abf9b561c
If Dovecot master dies with a fatal failure, log the error message to a file
Timo Sirainen <tss@iki.fi>
parents:
7226
diff
changeset
|
53 { |
586abf9b561c
If Dovecot master dies with a fatal failure, log the error message to a file
Timo Sirainen <tss@iki.fi>
parents:
7226
diff
changeset
|
54 const struct settings *set = settings_root->defaults; |
586abf9b561c
If Dovecot master dies with a fatal failure, log the error message to a file
Timo Sirainen <tss@iki.fi>
parents:
7226
diff
changeset
|
55 const char *path, *str; |
7351
6115fe69094c
Fatals/panics logged by master weren't logged properly.
Timo Sirainen <tss@iki.fi>
parents:
7334
diff
changeset
|
56 va_list args2; |
7229
586abf9b561c
If Dovecot master dies with a fatal failure, log the error message to a file
Timo Sirainen <tss@iki.fi>
parents:
7226
diff
changeset
|
57 int fd; |
586abf9b561c
If Dovecot master dies with a fatal failure, log the error message to a file
Timo Sirainen <tss@iki.fi>
parents:
7226
diff
changeset
|
58 |
8323
60c48789841b
master: Don't print "last died with error .." for fatals that were from forked child processes.
Timo Sirainen <tss@iki.fi>
parents:
8305
diff
changeset
|
59 /* if we already forked a child process, this isn't fatal for the |
60c48789841b
master: Don't print "last died with error .." for fatals that were from forked child processes.
Timo Sirainen <tss@iki.fi>
parents:
8305
diff
changeset
|
60 main process and there's no need to write the fatal file. */ |
60c48789841b
master: Don't print "last died with error .." for fatals that were from forked child processes.
Timo Sirainen <tss@iki.fi>
parents:
8305
diff
changeset
|
61 if (getpid() == master_original_pid) { |
60c48789841b
master: Don't print "last died with error .." for fatals that were from forked child processes.
Timo Sirainen <tss@iki.fi>
parents:
8305
diff
changeset
|
62 /* write the error message to a file */ |
60c48789841b
master: Don't print "last died with error .." for fatals that were from forked child processes.
Timo Sirainen <tss@iki.fi>
parents:
8305
diff
changeset
|
63 path = t_strconcat(set->base_dir, "/"FATAL_FILENAME, NULL); |
60c48789841b
master: Don't print "last died with error .." for fatals that were from forked child processes.
Timo Sirainen <tss@iki.fi>
parents:
8305
diff
changeset
|
64 fd = open(path, O_CREAT | O_TRUNC | O_WRONLY, 0600); |
60c48789841b
master: Don't print "last died with error .." for fatals that were from forked child processes.
Timo Sirainen <tss@iki.fi>
parents:
8305
diff
changeset
|
65 if (fd != -1) { |
60c48789841b
master: Don't print "last died with error .." for fatals that were from forked child processes.
Timo Sirainen <tss@iki.fi>
parents:
8305
diff
changeset
|
66 VA_COPY(args2, args); |
60c48789841b
master: Don't print "last died with error .." for fatals that were from forked child processes.
Timo Sirainen <tss@iki.fi>
parents:
8305
diff
changeset
|
67 str = t_strdup_vprintf(format, args2); |
60c48789841b
master: Don't print "last died with error .." for fatals that were from forked child processes.
Timo Sirainen <tss@iki.fi>
parents:
8305
diff
changeset
|
68 write_full(fd, str, strlen(str)); |
60c48789841b
master: Don't print "last died with error .." for fatals that were from forked child processes.
Timo Sirainen <tss@iki.fi>
parents:
8305
diff
changeset
|
69 (void)close(fd); |
60c48789841b
master: Don't print "last died with error .." for fatals that were from forked child processes.
Timo Sirainen <tss@iki.fi>
parents:
8305
diff
changeset
|
70 } |
7229
586abf9b561c
If Dovecot master dies with a fatal failure, log the error message to a file
Timo Sirainen <tss@iki.fi>
parents:
7226
diff
changeset
|
71 } |
586abf9b561c
If Dovecot master dies with a fatal failure, log the error message to a file
Timo Sirainen <tss@iki.fi>
parents:
7226
diff
changeset
|
72 |
586abf9b561c
If Dovecot master dies with a fatal failure, log the error message to a file
Timo Sirainen <tss@iki.fi>
parents:
7226
diff
changeset
|
73 /* write it to log as well */ |
586abf9b561c
If Dovecot master dies with a fatal failure, log the error message to a file
Timo Sirainen <tss@iki.fi>
parents:
7226
diff
changeset
|
74 if (*set->log_path == '\0') |
586abf9b561c
If Dovecot master dies with a fatal failure, log the error message to a file
Timo Sirainen <tss@iki.fi>
parents:
7226
diff
changeset
|
75 i_syslog_fatal_handler(type, status, format, args); |
586abf9b561c
If Dovecot master dies with a fatal failure, log the error message to a file
Timo Sirainen <tss@iki.fi>
parents:
7226
diff
changeset
|
76 else |
586abf9b561c
If Dovecot master dies with a fatal failure, log the error message to a file
Timo Sirainen <tss@iki.fi>
parents:
7226
diff
changeset
|
77 default_fatal_handler(type, status, format, args); |
586abf9b561c
If Dovecot master dies with a fatal failure, log the error message to a file
Timo Sirainen <tss@iki.fi>
parents:
7226
diff
changeset
|
78 } |
586abf9b561c
If Dovecot master dies with a fatal failure, log the error message to a file
Timo Sirainen <tss@iki.fi>
parents:
7226
diff
changeset
|
79 |
586abf9b561c
If Dovecot master dies with a fatal failure, log the error message to a file
Timo Sirainen <tss@iki.fi>
parents:
7226
diff
changeset
|
80 static void fatal_log_check(void) |
586abf9b561c
If Dovecot master dies with a fatal failure, log the error message to a file
Timo Sirainen <tss@iki.fi>
parents:
7226
diff
changeset
|
81 { |
586abf9b561c
If Dovecot master dies with a fatal failure, log the error message to a file
Timo Sirainen <tss@iki.fi>
parents:
7226
diff
changeset
|
82 const struct settings *set = settings_root->defaults; |
586abf9b561c
If Dovecot master dies with a fatal failure, log the error message to a file
Timo Sirainen <tss@iki.fi>
parents:
7226
diff
changeset
|
83 const char *path; |
586abf9b561c
If Dovecot master dies with a fatal failure, log the error message to a file
Timo Sirainen <tss@iki.fi>
parents:
7226
diff
changeset
|
84 char buf[1024]; |
586abf9b561c
If Dovecot master dies with a fatal failure, log the error message to a file
Timo Sirainen <tss@iki.fi>
parents:
7226
diff
changeset
|
85 ssize_t ret; |
586abf9b561c
If Dovecot master dies with a fatal failure, log the error message to a file
Timo Sirainen <tss@iki.fi>
parents:
7226
diff
changeset
|
86 int fd; |
586abf9b561c
If Dovecot master dies with a fatal failure, log the error message to a file
Timo Sirainen <tss@iki.fi>
parents:
7226
diff
changeset
|
87 |
586abf9b561c
If Dovecot master dies with a fatal failure, log the error message to a file
Timo Sirainen <tss@iki.fi>
parents:
7226
diff
changeset
|
88 path = t_strconcat(set->base_dir, "/"FATAL_FILENAME, NULL); |
586abf9b561c
If Dovecot master dies with a fatal failure, log the error message to a file
Timo Sirainen <tss@iki.fi>
parents:
7226
diff
changeset
|
89 fd = open(path, O_RDONLY); |
586abf9b561c
If Dovecot master dies with a fatal failure, log the error message to a file
Timo Sirainen <tss@iki.fi>
parents:
7226
diff
changeset
|
90 if (fd == -1) |
586abf9b561c
If Dovecot master dies with a fatal failure, log the error message to a file
Timo Sirainen <tss@iki.fi>
parents:
7226
diff
changeset
|
91 return; |
586abf9b561c
If Dovecot master dies with a fatal failure, log the error message to a file
Timo Sirainen <tss@iki.fi>
parents:
7226
diff
changeset
|
92 |
586abf9b561c
If Dovecot master dies with a fatal failure, log the error message to a file
Timo Sirainen <tss@iki.fi>
parents:
7226
diff
changeset
|
93 ret = read(fd, buf, sizeof(buf)); |
586abf9b561c
If Dovecot master dies with a fatal failure, log the error message to a file
Timo Sirainen <tss@iki.fi>
parents:
7226
diff
changeset
|
94 if (ret < 0) |
586abf9b561c
If Dovecot master dies with a fatal failure, log the error message to a file
Timo Sirainen <tss@iki.fi>
parents:
7226
diff
changeset
|
95 i_error("read(%s) failed: %m", path); |
586abf9b561c
If Dovecot master dies with a fatal failure, log the error message to a file
Timo Sirainen <tss@iki.fi>
parents:
7226
diff
changeset
|
96 else { |
586abf9b561c
If Dovecot master dies with a fatal failure, log the error message to a file
Timo Sirainen <tss@iki.fi>
parents:
7226
diff
changeset
|
97 buf[ret] = '\0'; |
586abf9b561c
If Dovecot master dies with a fatal failure, log the error message to a file
Timo Sirainen <tss@iki.fi>
parents:
7226
diff
changeset
|
98 i_warning("Last died with error (see error log for more " |
586abf9b561c
If Dovecot master dies with a fatal failure, log the error message to a file
Timo Sirainen <tss@iki.fi>
parents:
7226
diff
changeset
|
99 "information): %s", buf); |
586abf9b561c
If Dovecot master dies with a fatal failure, log the error message to a file
Timo Sirainen <tss@iki.fi>
parents:
7226
diff
changeset
|
100 } |
586abf9b561c
If Dovecot master dies with a fatal failure, log the error message to a file
Timo Sirainen <tss@iki.fi>
parents:
7226
diff
changeset
|
101 |
586abf9b561c
If Dovecot master dies with a fatal failure, log the error message to a file
Timo Sirainen <tss@iki.fi>
parents:
7226
diff
changeset
|
102 close(fd); |
586abf9b561c
If Dovecot master dies with a fatal failure, log the error message to a file
Timo Sirainen <tss@iki.fi>
parents:
7226
diff
changeset
|
103 if (unlink(path) < 0) |
586abf9b561c
If Dovecot master dies with a fatal failure, log the error message to a file
Timo Sirainen <tss@iki.fi>
parents:
7226
diff
changeset
|
104 i_error("unlink(%s) failed: %m", path); |
586abf9b561c
If Dovecot master dies with a fatal failure, log the error message to a file
Timo Sirainen <tss@iki.fi>
parents:
7226
diff
changeset
|
105 } |
586abf9b561c
If Dovecot master dies with a fatal failure, log the error message to a file
Timo Sirainen <tss@iki.fi>
parents:
7226
diff
changeset
|
106 |
8305
e4d0ce4d3420
Don't show the WhyDoesItNotWork link if auth_debug=yes already.
Timo Sirainen <tss@iki.fi>
parents:
8301
diff
changeset
|
107 static void auth_warning_print(const struct server_settings *set) |
8301
d46579bb7a3c
Print a help message about authentication at startup until the first successful authentication.
Timo Sirainen <tss@iki.fi>
parents:
8062
diff
changeset
|
108 { |
d46579bb7a3c
Print a help message about authentication at startup until the first successful authentication.
Timo Sirainen <tss@iki.fi>
parents:
8062
diff
changeset
|
109 struct stat st; |
d46579bb7a3c
Print a help message about authentication at startup until the first successful authentication.
Timo Sirainen <tss@iki.fi>
parents:
8062
diff
changeset
|
110 |
d46579bb7a3c
Print a help message about authentication at startup until the first successful authentication.
Timo Sirainen <tss@iki.fi>
parents:
8062
diff
changeset
|
111 auth_success_written = stat(AUTH_SUCCESS_PATH, &st) == 0; |
8305
e4d0ce4d3420
Don't show the WhyDoesItNotWork link if auth_debug=yes already.
Timo Sirainen <tss@iki.fi>
parents:
8301
diff
changeset
|
112 if (!auth_success_written && !set->auths->debug && |
e4d0ce4d3420
Don't show the WhyDoesItNotWork link if auth_debug=yes already.
Timo Sirainen <tss@iki.fi>
parents:
8301
diff
changeset
|
113 strcmp(set->defaults->protocols, "none") != 0) { |
8301
d46579bb7a3c
Print a help message about authentication at startup until the first successful authentication.
Timo Sirainen <tss@iki.fi>
parents:
8062
diff
changeset
|
114 i_info("If you have trouble with authentication failures,\n" |
d46579bb7a3c
Print a help message about authentication at startup until the first successful authentication.
Timo Sirainen <tss@iki.fi>
parents:
8062
diff
changeset
|
115 "enable auth_debug setting. " |
d46579bb7a3c
Print a help message about authentication at startup until the first successful authentication.
Timo Sirainen <tss@iki.fi>
parents:
8062
diff
changeset
|
116 "See http://wiki.dovecot.org/WhyDoesItNotWork"); |
d46579bb7a3c
Print a help message about authentication at startup until the first successful authentication.
Timo Sirainen <tss@iki.fi>
parents:
8062
diff
changeset
|
117 |
d46579bb7a3c
Print a help message about authentication at startup until the first successful authentication.
Timo Sirainen <tss@iki.fi>
parents:
8062
diff
changeset
|
118 } |
d46579bb7a3c
Print a help message about authentication at startup until the first successful authentication.
Timo Sirainen <tss@iki.fi>
parents:
8062
diff
changeset
|
119 } |
d46579bb7a3c
Print a help message about authentication at startup until the first successful authentication.
Timo Sirainen <tss@iki.fi>
parents:
8062
diff
changeset
|
120 |
2306
6aa77fdf152e
SIGHUP correctly reloads configuration now
Timo Sirainen <tss@iki.fi>
parents:
2235
diff
changeset
|
121 static void set_logfile(struct settings *set) |
6aa77fdf152e
SIGHUP correctly reloads configuration now
Timo Sirainen <tss@iki.fi>
parents:
2235
diff
changeset
|
122 { |
3724
d22c883021da
Added syslog_facility setting to config file.
Timo Sirainen <tss@iki.fi>
parents:
3620
diff
changeset
|
123 int facility; |
d22c883021da
Added syslog_facility setting to config file.
Timo Sirainen <tss@iki.fi>
parents:
3620
diff
changeset
|
124 |
4388
af61031c746f
Settings parser nowadays returns "" instead of NULL when it reads an empty
Timo Sirainen <tss@iki.fi>
parents:
4375
diff
changeset
|
125 if (*set->log_path == '\0') { |
3724
d22c883021da
Added syslog_facility setting to config file.
Timo Sirainen <tss@iki.fi>
parents:
3620
diff
changeset
|
126 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
|
127 facility = LOG_MAIL; |
d22c883021da
Added syslog_facility setting to config file.
Timo Sirainen <tss@iki.fi>
parents:
3620
diff
changeset
|
128 |
d22c883021da
Added syslog_facility setting to config file.
Timo Sirainen <tss@iki.fi>
parents:
3620
diff
changeset
|
129 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
|
130 } else { |
2306
6aa77fdf152e
SIGHUP correctly reloads configuration now
Timo Sirainen <tss@iki.fi>
parents:
2235
diff
changeset
|
131 /* 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
|
132 i_set_failure_file(set->log_path, "dovecot: "); |
2306
6aa77fdf152e
SIGHUP correctly reloads configuration now
Timo Sirainen <tss@iki.fi>
parents:
2235
diff
changeset
|
133 } |
7229
586abf9b561c
If Dovecot master dies with a fatal failure, log the error message to a file
Timo Sirainen <tss@iki.fi>
parents:
7226
diff
changeset
|
134 i_set_fatal_handler(master_fatal_callback); |
2306
6aa77fdf152e
SIGHUP correctly reloads configuration now
Timo Sirainen <tss@iki.fi>
parents:
2235
diff
changeset
|
135 |
4388
af61031c746f
Settings parser nowadays returns "" instead of NULL when it reads an empty
Timo Sirainen <tss@iki.fi>
parents:
4375
diff
changeset
|
136 if (*set->info_log_path != '\0') |
2306
6aa77fdf152e
SIGHUP correctly reloads configuration now
Timo Sirainen <tss@iki.fi>
parents:
2235
diff
changeset
|
137 i_set_info_file(set->info_log_path); |
6aa77fdf152e
SIGHUP correctly reloads configuration now
Timo Sirainen <tss@iki.fi>
parents:
2235
diff
changeset
|
138 |
6aa77fdf152e
SIGHUP correctly reloads configuration now
Timo Sirainen <tss@iki.fi>
parents:
2235
diff
changeset
|
139 i_set_failure_timestamp_format(set->log_timestamp); |
6aa77fdf152e
SIGHUP correctly reloads configuration now
Timo Sirainen <tss@iki.fi>
parents:
2235
diff
changeset
|
140 } |
6aa77fdf152e
SIGHUP correctly reloads configuration now
Timo Sirainen <tss@iki.fi>
parents:
2235
diff
changeset
|
141 |
635
90a65c017bf0
SIGHUP reloads now settings. Logged in clients are left untouched, but
Timo Sirainen <tss@iki.fi>
parents:
615
diff
changeset
|
142 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
|
143 { |
2306
6aa77fdf152e
SIGHUP correctly reloads configuration now
Timo Sirainen <tss@iki.fi>
parents:
2235
diff
changeset
|
144 struct server_settings *old_set = settings_root; |
6aa77fdf152e
SIGHUP correctly reloads configuration now
Timo Sirainen <tss@iki.fi>
parents:
2235
diff
changeset
|
145 |
635
90a65c017bf0
SIGHUP reloads now settings. Logged in clients are left untouched, but
Timo Sirainen <tss@iki.fi>
parents:
615
diff
changeset
|
146 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
|
147 |
90a65c017bf0
SIGHUP reloads now settings. Logged in clients are left untouched, but
Timo Sirainen <tss@iki.fi>
parents:
615
diff
changeset
|
148 /* restart auth and login processes */ |
4670 | 149 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
|
150 auth_processes_destroy_all(); |
8649
67c08c386702
Added dict_process_count setting for creating multiple dict processes.
Timo Sirainen <tss@iki.fi>
parents:
8595
diff
changeset
|
151 dict_processes_kill(); |
1223
52e0830ade13
Added setting mail_drop_priv_before_exec.
Timo Sirainen <tss@iki.fi>
parents:
1124
diff
changeset
|
152 |
8595
829b6555392b
master: When receiving SIGHUP, get the hostname again in case it changed.
Timo Sirainen <tss@iki.fi>
parents:
8590
diff
changeset
|
153 /* see if hostname changed */ |
829b6555392b
master: When receiving SIGHUP, get the hostname again in case it changed.
Timo Sirainen <tss@iki.fi>
parents:
8590
diff
changeset
|
154 hostpid_init(); |
829b6555392b
master: When receiving SIGHUP, get the hostname again in case it changed.
Timo Sirainen <tss@iki.fi>
parents:
8590
diff
changeset
|
155 |
4965
9246d9308caa
-n and -a parameters shouldn't be deleting auth sockets.
Timo Sirainen <tss@iki.fi>
parents:
4903
diff
changeset
|
156 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
|
157 i_warning("Invalid configuration, keeping old one"); |
2306
6aa77fdf152e
SIGHUP correctly reloads configuration now
Timo Sirainen <tss@iki.fi>
parents:
2235
diff
changeset
|
158 else { |
5887
3f2eb1b9c555
Support listening multiple sockets. SIGHUP also doesn't anymore recreate
Timo Sirainen <tss@iki.fi>
parents:
5846
diff
changeset
|
159 if (!IS_INETD()) |
3f2eb1b9c555
Support listening multiple sockets. SIGHUP also doesn't anymore recreate
Timo Sirainen <tss@iki.fi>
parents:
5846
diff
changeset
|
160 listeners_open_fds(old_set, TRUE); |
2306
6aa77fdf152e
SIGHUP correctly reloads configuration now
Timo Sirainen <tss@iki.fi>
parents:
2235
diff
changeset
|
161 set_logfile(settings_root->defaults); |
6aa77fdf152e
SIGHUP correctly reloads configuration now
Timo Sirainen <tss@iki.fi>
parents:
2235
diff
changeset
|
162 } |
635
90a65c017bf0
SIGHUP reloads now settings. Logged in clients are left untouched, but
Timo Sirainen <tss@iki.fi>
parents:
615
diff
changeset
|
163 } |
90a65c017bf0
SIGHUP reloads now settings. Logged in clients are left untouched, but
Timo Sirainen <tss@iki.fi>
parents:
615
diff
changeset
|
164 |
8882
9f3968f49ceb
lib-signals: Changed callback API to return siginfo_t.
Timo Sirainen <tss@iki.fi>
parents:
8798
diff
changeset
|
165 static void sig_die(const siginfo_t *si, 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
|
166 { |
3360cc019737
Implemented new signal handling framework, which makes handling signals much
Timo Sirainen <tss@iki.fi>
parents:
3589
diff
changeset
|
167 /* 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
|
168 which is too common at least while testing :) */ |
8883
5361cb6afe9e
When a process is killed, show the signal code and the sending process's pid and uid.
Timo Sirainen <tss@iki.fi>
parents:
8882
diff
changeset
|
169 if (si->si_signo != SIGINT) { |
5361cb6afe9e
When a process is killed, show the signal code and the sending process's pid and uid.
Timo Sirainen <tss@iki.fi>
parents:
8882
diff
changeset
|
170 i_warning("Killed with signal %d (by pid=%s uid=%s code=%s)", |
5361cb6afe9e
When a process is killed, show the signal code and the sending process's pid and uid.
Timo Sirainen <tss@iki.fi>
parents:
8882
diff
changeset
|
171 si->si_signo, dec2str(si->si_pid), |
5361cb6afe9e
When a process is killed, show the signal code and the sending process's pid and uid.
Timo Sirainen <tss@iki.fi>
parents:
8882
diff
changeset
|
172 dec2str(si->si_uid), |
5361cb6afe9e
When a process is killed, show the signal code and the sending process's pid and uid.
Timo Sirainen <tss@iki.fi>
parents:
8882
diff
changeset
|
173 lib_signal_code_to_str(si->si_signo, si->si_code)); |
5361cb6afe9e
When a process is killed, show the signal code and the sending process's pid and uid.
Timo Sirainen <tss@iki.fi>
parents:
8882
diff
changeset
|
174 } |
3620
3360cc019737
Implemented new signal handling framework, which makes handling signals much
Timo Sirainen <tss@iki.fi>
parents:
3589
diff
changeset
|
175 io_loop_stop(ioloop); |
3360cc019737
Implemented new signal handling framework, which makes handling signals much
Timo Sirainen <tss@iki.fi>
parents:
3589
diff
changeset
|
176 } |
3360cc019737
Implemented new signal handling framework, which makes handling signals much
Timo Sirainen <tss@iki.fi>
parents:
3589
diff
changeset
|
177 |
8882
9f3968f49ceb
lib-signals: Changed callback API to return siginfo_t.
Timo Sirainen <tss@iki.fi>
parents:
8798
diff
changeset
|
178 static void sig_reload_settings(const siginfo_t *si ATTR_UNUSED, |
6411
6a64e64fa3a3
Renamed __attr_*__ to ATTR_*. Renamed __attrs_used__ to ATTRS_DEFINED.
Timo Sirainen <tss@iki.fi>
parents:
6397
diff
changeset
|
179 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
|
180 { |
3360cc019737
Implemented new signal handling framework, which makes handling signals much
Timo Sirainen <tss@iki.fi>
parents:
3589
diff
changeset
|
181 settings_reload(); |
3360cc019737
Implemented new signal handling framework, which makes handling signals much
Timo Sirainen <tss@iki.fi>
parents:
3589
diff
changeset
|
182 } |
3360cc019737
Implemented new signal handling framework, which makes handling signals much
Timo Sirainen <tss@iki.fi>
parents:
3589
diff
changeset
|
183 |
8882
9f3968f49ceb
lib-signals: Changed callback API to return siginfo_t.
Timo Sirainen <tss@iki.fi>
parents:
8798
diff
changeset
|
184 static void sig_reopen_logs(const siginfo_t *si ATTR_UNUSED, |
6411
6a64e64fa3a3
Renamed __attr_*__ to ATTR_*. Renamed __attrs_used__ to ATTRS_DEFINED.
Timo Sirainen <tss@iki.fi>
parents:
6397
diff
changeset
|
185 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
|
186 { |
3360cc019737
Implemented new signal handling framework, which makes handling signals much
Timo Sirainen <tss@iki.fi>
parents:
3589
diff
changeset
|
187 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
|
188 } |
3360cc019737
Implemented new signal handling framework, which makes handling signals much
Timo Sirainen <tss@iki.fi>
parents:
3589
diff
changeset
|
189 |
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
|
190 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
|
191 { |
4388
af61031c746f
Settings parser nowadays returns "" instead of NULL when it reads an empty
Timo Sirainen <tss@iki.fi>
parents:
4375
diff
changeset
|
192 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
|
193 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
|
194 return TRUE; |
6850142c4e25
New configuration file code. Some syntax changes, but tries to be somewhat
Timo Sirainen <tss@iki.fi>
parents:
1423
diff
changeset
|
195 |
4388
af61031c746f
Settings parser nowadays returns "" instead of NULL when it reads an empty
Timo Sirainen <tss@iki.fi>
parents:
4375
diff
changeset
|
196 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
|
197 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
|
198 return TRUE; |
6850142c4e25
New configuration file code. Some syntax changes, but tries to be somewhat
Timo Sirainen <tss@iki.fi>
parents:
1423
diff
changeset
|
199 |
6850142c4e25
New configuration file code. Some syntax changes, but tries to be somewhat
Timo Sirainen <tss@iki.fi>
parents:
1423
diff
changeset
|
200 return FALSE; |
6850142c4e25
New configuration file code. Some syntax changes, but tries to be somewhat
Timo Sirainen <tss@iki.fi>
parents:
1423
diff
changeset
|
201 } |
6850142c4e25
New configuration file code. Some syntax changes, but tries to be somewhat
Timo Sirainen <tss@iki.fi>
parents:
1423
diff
changeset
|
202 |
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
|
203 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
|
204 { |
6850142c4e25
New configuration file code. Some syntax changes, but tries to be somewhat
Timo Sirainen <tss@iki.fi>
parents:
1423
diff
changeset
|
205 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
|
206 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
|
207 return TRUE; |
6850142c4e25
New configuration file code. Some syntax changes, but tries to be somewhat
Timo Sirainen <tss@iki.fi>
parents:
1423
diff
changeset
|
208 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
|
209 return TRUE; |
6850142c4e25
New configuration file code. Some syntax changes, but tries to be somewhat
Timo Sirainen <tss@iki.fi>
parents:
1423
diff
changeset
|
210 |
6850142c4e25
New configuration file code. Some syntax changes, but tries to be somewhat
Timo Sirainen <tss@iki.fi>
parents:
1423
diff
changeset
|
211 server = server->next; |
1055
a72bba3f8a55
Rewrote setting handling. Changed some existing settings also since POP3
Timo Sirainen <tss@iki.fi>
parents:
1036
diff
changeset
|
212 } |
1610
6850142c4e25
New configuration file code. Some syntax changes, but tries to be somewhat
Timo Sirainen <tss@iki.fi>
parents:
1423
diff
changeset
|
213 |
6850142c4e25
New configuration file code. Some syntax changes, but tries to be somewhat
Timo Sirainen <tss@iki.fi>
parents:
1423
diff
changeset
|
214 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
|
215 } |
2cf2e08a6ee9
Somewhat working code to support loading Dovecot from inetd and such. It
Timo Sirainen <tss@iki.fi>
parents:
1268
diff
changeset
|
216 |
5437 | 217 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
|
218 { |
2cf2e08a6ee9
Somewhat working code to support loading Dovecot from inetd and such. It
Timo Sirainen <tss@iki.fi>
parents:
1268
diff
changeset
|
219 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
|
220 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
|
221 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
|
222 fd_close_on_exec(null_fd, TRUE); |
5437 | 223 } |
1273
2cf2e08a6ee9
Somewhat working code to support loading Dovecot from inetd and such. It
Timo Sirainen <tss@iki.fi>
parents:
1268
diff
changeset
|
224 |
5437 | 225 static void open_fds(void) |
226 { | |
1273
2cf2e08a6ee9
Somewhat working code to support loading Dovecot from inetd and such. It
Timo Sirainen <tss@iki.fi>
parents:
1268
diff
changeset
|
227 /* 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
|
228 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
|
229 null_fd = dup(null_fd); |
4578
3bb3d5ad254f
Cleanup + handle dup() failure.
Timo Sirainen <tss@iki.fi>
parents:
4553
diff
changeset
|
230 if (null_fd == -1) |
3bb3d5ad254f
Cleanup + handle dup() failure.
Timo Sirainen <tss@iki.fi>
parents:
4553
diff
changeset
|
231 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
|
232 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
|
233 } |
2cf2e08a6ee9
Somewhat working code to support loading Dovecot from inetd and such. It
Timo Sirainen <tss@iki.fi>
parents:
1268
diff
changeset
|
234 |
6940
414c9d631a81
Replaced t_push/t_pop calls with T_FRAME*() macros.
Timo Sirainen <tss@iki.fi>
parents:
6893
diff
changeset
|
235 if (!IS_INETD()) { |
7226
e6693a0ec8e1
Renamed T_FRAME_BEGIN/END to T_BEGIN/END. Removed T_FRAME() macro and
Timo Sirainen <tss@iki.fi>
parents:
7086
diff
changeset
|
236 T_BEGIN { |
6940
414c9d631a81
Replaced t_push/t_pop calls with T_FRAME*() macros.
Timo Sirainen <tss@iki.fi>
parents:
6893
diff
changeset
|
237 listeners_open_fds(NULL, FALSE); |
7226
e6693a0ec8e1
Renamed T_FRAME_BEGIN/END to T_BEGIN/END. Removed T_FRAME() macro and
Timo Sirainen <tss@iki.fi>
parents:
7086
diff
changeset
|
238 } T_END; |
6940
414c9d631a81
Replaced t_push/t_pop calls with T_FRAME*() macros.
Timo Sirainen <tss@iki.fi>
parents:
6893
diff
changeset
|
239 } |
1124
5e9430a39611
/dev/stderr works now in log paths.
Timo Sirainen <tss@iki.fi>
parents:
1100
diff
changeset
|
240 |
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
|
241 /* close stdin and stdout. */ |
1124
5e9430a39611
/dev/stderr works now in log paths.
Timo Sirainen <tss@iki.fi>
parents:
1100
diff
changeset
|
242 if (dup2(null_fd, 0) < 0) |
5e9430a39611
/dev/stderr works now in log paths.
Timo Sirainen <tss@iki.fi>
parents:
1100
diff
changeset
|
243 i_fatal("dup2(0) failed: %m"); |
5e9430a39611
/dev/stderr works now in log paths.
Timo Sirainen <tss@iki.fi>
parents:
1100
diff
changeset
|
244 if (dup2(null_fd, 1) < 0) |
5e9430a39611
/dev/stderr works now in log paths.
Timo Sirainen <tss@iki.fi>
parents:
1100
diff
changeset
|
245 i_fatal("dup2(1) failed: %m"); |
0 | 246 } |
247 | |
2524 | 248 static void create_pid_file(const char *path) |
249 { | |
250 const char *pid; | |
251 int fd; | |
252 | |
2534 | 253 pid = t_strconcat(dec2str(getpid()), "\n", NULL); |
2524 | 254 |
255 fd = open(path, O_WRONLY|O_CREAT|O_TRUNC, 0644); | |
256 if (fd == -1) | |
257 i_fatal("open(%s) failed: %m", path); | |
258 if (write_full(fd, pid, strlen(pid)) < 0) | |
259 i_fatal("write() failed in %s: %m", path); | |
260 (void)close(fd); | |
261 } | |
262 | |
7946
aad49536db41
If core dump limit is 0, add "core dumps disabled" to startup log line.
Timo Sirainen <tss@iki.fi>
parents:
7914
diff
changeset
|
263 static void main_log_startup(void) |
aad49536db41
If core dump limit is 0, add "core dumps disabled" to startup log line.
Timo Sirainen <tss@iki.fi>
parents:
7914
diff
changeset
|
264 { |
aad49536db41
If core dump limit is 0, add "core dumps disabled" to startup log line.
Timo Sirainen <tss@iki.fi>
parents:
7914
diff
changeset
|
265 #define STARTUP_STRING PACKAGE_NAME" v"VERSION" starting up" |
aad49536db41
If core dump limit is 0, add "core dumps disabled" to startup log line.
Timo Sirainen <tss@iki.fi>
parents:
7914
diff
changeset
|
266 rlim_t core_limit; |
aad49536db41
If core dump limit is 0, add "core dumps disabled" to startup log line.
Timo Sirainen <tss@iki.fi>
parents:
7914
diff
changeset
|
267 |
8798
c9381a0fdc5e
Improved logging for core dumping. With Linux use PR_SET_DUMPABLE for imap/pop3.
Timo Sirainen <tss@iki.fi>
parents:
8782
diff
changeset
|
268 core_dumps_disabled = restrict_get_core_limit(&core_limit) == 0 && |
c9381a0fdc5e
Improved logging for core dumping. With Linux use PR_SET_DUMPABLE for imap/pop3.
Timo Sirainen <tss@iki.fi>
parents:
8782
diff
changeset
|
269 core_limit == 0; |
c9381a0fdc5e
Improved logging for core dumping. With Linux use PR_SET_DUMPABLE for imap/pop3.
Timo Sirainen <tss@iki.fi>
parents:
8782
diff
changeset
|
270 if (core_dumps_disabled) |
7946
aad49536db41
If core dump limit is 0, add "core dumps disabled" to startup log line.
Timo Sirainen <tss@iki.fi>
parents:
7914
diff
changeset
|
271 i_info(STARTUP_STRING" (core dumps disabled)"); |
aad49536db41
If core dump limit is 0, add "core dumps disabled" to startup log line.
Timo Sirainen <tss@iki.fi>
parents:
7914
diff
changeset
|
272 else |
aad49536db41
If core dump limit is 0, add "core dumps disabled" to startup log line.
Timo Sirainen <tss@iki.fi>
parents:
7914
diff
changeset
|
273 i_info(STARTUP_STRING); |
aad49536db41
If core dump limit is 0, add "core dumps disabled" to startup log line.
Timo Sirainen <tss@iki.fi>
parents:
7914
diff
changeset
|
274 } |
aad49536db41
If core dump limit is 0, add "core dumps disabled" to startup log line.
Timo Sirainen <tss@iki.fi>
parents:
7914
diff
changeset
|
275 |
5090
04b467f23400
Added --log-error command line option.
Timo Sirainen <tss@iki.fi>
parents:
5077
diff
changeset
|
276 static void main_init(bool log_error) |
0 | 277 { |
5824
5d0aa827f130
Reordered initialization code. Capabilities are now dropped as soon as
root@hurina
parents:
5789
diff
changeset
|
278 drop_capabilities(); |
5d0aa827f130
Reordered initialization code. Capabilities are now dropped as soon as
root@hurina
parents:
5789
diff
changeset
|
279 |
0 | 280 /* deny file access from everyone else except owner */ |
281 (void)umask(0077); | |
282 | |
5824
5d0aa827f130
Reordered initialization code. Capabilities are now dropped as soon as
root@hurina
parents:
5789
diff
changeset
|
283 set_logfile(settings_root->defaults); |
5d0aa827f130
Reordered initialization code. Capabilities are now dropped as soon as
root@hurina
parents:
5789
diff
changeset
|
284 /* 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
|
285 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
|
286 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
|
287 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
|
288 } |
2306
6aa77fdf152e
SIGHUP correctly reloads configuration now
Timo Sirainen <tss@iki.fi>
parents:
2235
diff
changeset
|
289 |
5696
b929827ddbe9
When using --log-error, log also a warning and an error.
Timo Sirainen <tss@iki.fi>
parents:
5639
diff
changeset
|
290 if (log_error) { |
6303 | 291 printf("Writing to error logs and killing myself..\n"); |
292 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
|
293 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
|
294 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
|
295 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
|
296 } |
7946
aad49536db41
If core dump limit is 0, add "core dumps disabled" to startup log line.
Timo Sirainen <tss@iki.fi>
parents:
7914
diff
changeset
|
297 main_log_startup(); |
5090
04b467f23400
Added --log-error command line option.
Timo Sirainen <tss@iki.fi>
parents:
5077
diff
changeset
|
298 |
3620
3360cc019737
Implemented new signal handling framework, which makes handling signals much
Timo Sirainen <tss@iki.fi>
parents:
3589
diff
changeset
|
299 lib_signals_init(); |
3360cc019737
Implemented new signal handling framework, which makes handling signals much
Timo Sirainen <tss@iki.fi>
parents:
3589
diff
changeset
|
300 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
|
301 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
|
302 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
|
303 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
|
304 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
|
305 lib_signals_set_handler(SIGUSR1, TRUE, sig_reopen_logs, NULL); |
0 | 306 |
5843
f655c4d4a419
Moved child process handling to child-process.[ch]. The hash table now uses
Timo Sirainen <tss@iki.fi>
parents:
5824
diff
changeset
|
307 child_processes_init(); |
5824
5d0aa827f130
Reordered initialization code. Capabilities are now dropped as soon as
root@hurina
parents:
5789
diff
changeset
|
308 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
|
309 ssl_init(); |
8649
67c08c386702
Added dict_process_count setting for creating multiple dict processes.
Timo Sirainen <tss@iki.fi>
parents:
8595
diff
changeset
|
310 dict_processes_init(); |
0 | 311 auth_processes_init(); |
312 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
|
313 mail_processes_init(); |
2524 | 314 |
315 create_pid_file(t_strconcat(settings_root->defaults->base_dir, | |
316 "/master.pid", NULL)); | |
0 | 317 } |
318 | |
319 static void main_deinit(void) | |
320 { | |
2524 | 321 (void)unlink(t_strconcat(settings_root->defaults->base_dir, |
322 "/master.pid", NULL)); | |
323 | |
5846
21e529b8a701
Initial implementation for mail_max_user_connections setting.
Timo Sirainen <tss@iki.fi>
parents:
5844
diff
changeset
|
324 login_processes_destroy_all(); |
21e529b8a701
Initial implementation for mail_max_user_connections setting.
Timo Sirainen <tss@iki.fi>
parents:
5844
diff
changeset
|
325 |
21e529b8a701
Initial implementation for mail_max_user_connections setting.
Timo Sirainen <tss@iki.fi>
parents:
5844
diff
changeset
|
326 mail_processes_deinit(); |
0 | 327 login_processes_deinit(); |
328 auth_processes_deinit(); | |
8649
67c08c386702
Added dict_process_count setting for creating multiple dict processes.
Timo Sirainen <tss@iki.fi>
parents:
8595
diff
changeset
|
329 dict_processes_deinit(); |
615
0d852af6842e
Master process generates DH/RSA parameters now and stores them into file
Timo Sirainen <tss@iki.fi>
parents:
610
diff
changeset
|
330 ssl_deinit(); |
0 | 331 |
5887
3f2eb1b9c555
Support listening multiple sockets. SIGHUP also doesn't anymore recreate
Timo Sirainen <tss@iki.fi>
parents:
5846
diff
changeset
|
332 listeners_close_fds(); |
3f2eb1b9c555
Support listening multiple sockets. SIGHUP also doesn't anymore recreate
Timo Sirainen <tss@iki.fi>
parents:
5846
diff
changeset
|
333 |
805
5ac361acb316
Marked all non-trivial buffer modifications with @UNSAFE tag. Several
Timo Sirainen <tss@iki.fi>
parents:
801
diff
changeset
|
334 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
|
335 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
|
336 |
8699
035037f388fa
master: Don't crash at quit if there is some unwritten data in logs.
Timo Sirainen <tss@iki.fi>
parents:
8649
diff
changeset
|
337 log_deinit(); |
035037f388fa
master: Don't crash at quit if there is some unwritten data in logs.
Timo Sirainen <tss@iki.fi>
parents:
8649
diff
changeset
|
338 /* log_deinit() may still want to look up child processes */ |
035037f388fa
master: Don't crash at quit if there is some unwritten data in logs.
Timo Sirainen <tss@iki.fi>
parents:
8649
diff
changeset
|
339 child_processes_deinit(); |
3620
3360cc019737
Implemented new signal handling framework, which makes handling signals much
Timo Sirainen <tss@iki.fi>
parents:
3589
diff
changeset
|
340 lib_signals_deinit(); |
0 | 341 closelog(); |
342 } | |
343 | |
1610
6850142c4e25
New configuration file code. Some syntax changes, but tries to be somewhat
Timo Sirainen <tss@iki.fi>
parents:
1423
diff
changeset
|
344 static void daemonize(struct settings *set) |
0 | 345 { |
346 pid_t pid; | |
347 | |
348 pid = fork(); | |
349 if (pid < 0) | |
350 i_fatal("fork() failed: %m"); | |
351 | |
352 if (pid != 0) | |
353 _exit(0); | |
610 | 354 |
801
86224ff16bf6
Drop root privileges earlier. Close syslog more later in imap-master when
Timo Sirainen <tss@iki.fi>
parents:
780
diff
changeset
|
355 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
|
356 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
|
357 |
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
|
358 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
|
359 i_fatal("chdir(%s) failed: %m", set->base_dir); |
0 | 360 } |
361 | |
279
49f4b0be0d87
Print usage with invalid parameters.
Timo Sirainen <tss@iki.fi>
parents:
50
diff
changeset
|
362 static void print_help(void) |
49f4b0be0d87
Print usage with invalid parameters.
Timo Sirainen <tss@iki.fi>
parents:
50
diff
changeset
|
363 { |
3917
ae292bd41926
Added --build-ssl-parameters option to build them.
Timo Sirainen <tss@iki.fi>
parents:
3901
diff
changeset
|
364 printf( |
4475
3a3ef25c62ab
List -n and -a in short help. Fixes to --build-options.
Timo Sirainen <tss@iki.fi>
parents:
4464
diff
changeset
|
365 "Usage: dovecot [-F] [-c <config file>] [-p] [-n] [-a]\n" |
7334
ae8180a4febd
Allow dovecot --exec-mail ext program arguments.
Timo Sirainen <tss@iki.fi>
parents:
7229
diff
changeset
|
366 " [--version] [--build-options] [--exec-mail <protocol> [<args>]]\n"); |
3589
fead84acb13c
Added --build-options parameter. Patch by Andrey Panin
Timo Sirainen <tss@iki.fi>
parents:
3535
diff
changeset
|
367 } |
fead84acb13c
Added --build-options parameter. Patch by Andrey Panin
Timo Sirainen <tss@iki.fi>
parents:
3535
diff
changeset
|
368 |
fead84acb13c
Added --build-options parameter. Patch by Andrey Panin
Timo Sirainen <tss@iki.fi>
parents:
3535
diff
changeset
|
369 static void print_build_options(void) |
fead84acb13c
Added --build-options parameter. Patch by Andrey Panin
Timo Sirainen <tss@iki.fi>
parents:
3535
diff
changeset
|
370 { |
8782
e5cc81734221
Compile fix for systems where printf() is a macro.
Timo Sirainen <tss@iki.fi>
parents:
8699
diff
changeset
|
371 static const char *build_options = |
e5cc81734221
Compile fix for systems where printf() is a macro.
Timo Sirainen <tss@iki.fi>
parents:
8699
diff
changeset
|
372 "Build options:" |
3589
fead84acb13c
Added --build-options parameter. Patch by Andrey Panin
Timo Sirainen <tss@iki.fi>
parents:
3535
diff
changeset
|
373 #ifdef IOLOOP_EPOLL |
fead84acb13c
Added --build-options parameter. Patch by Andrey Panin
Timo Sirainen <tss@iki.fi>
parents:
3535
diff
changeset
|
374 " ioloop=epoll" |
fead84acb13c
Added --build-options parameter. Patch by Andrey Panin
Timo Sirainen <tss@iki.fi>
parents:
3535
diff
changeset
|
375 #endif |
4475
3a3ef25c62ab
List -n and -a in short help. Fixes to --build-options.
Timo Sirainen <tss@iki.fi>
parents:
4464
diff
changeset
|
376 #ifdef IOLOOP_KQUEUE |
3a3ef25c62ab
List -n and -a in short help. Fixes to --build-options.
Timo Sirainen <tss@iki.fi>
parents:
4464
diff
changeset
|
377 " ioloop=kqueue" |
3a3ef25c62ab
List -n and -a in short help. Fixes to --build-options.
Timo Sirainen <tss@iki.fi>
parents:
4464
diff
changeset
|
378 #endif |
3589
fead84acb13c
Added --build-options parameter. Patch by Andrey Panin
Timo Sirainen <tss@iki.fi>
parents:
3535
diff
changeset
|
379 #ifdef IOLOOP_POLL |
fead84acb13c
Added --build-options parameter. Patch by Andrey Panin
Timo Sirainen <tss@iki.fi>
parents:
3535
diff
changeset
|
380 " ioloop=poll" |
fead84acb13c
Added --build-options parameter. Patch by Andrey Panin
Timo Sirainen <tss@iki.fi>
parents:
3535
diff
changeset
|
381 #endif |
fead84acb13c
Added --build-options parameter. Patch by Andrey Panin
Timo Sirainen <tss@iki.fi>
parents:
3535
diff
changeset
|
382 #ifdef IOLOOP_SELECT |
fead84acb13c
Added --build-options parameter. Patch by Andrey Panin
Timo Sirainen <tss@iki.fi>
parents:
3535
diff
changeset
|
383 " ioloop=select" |
fead84acb13c
Added --build-options parameter. Patch by Andrey Panin
Timo Sirainen <tss@iki.fi>
parents:
3535
diff
changeset
|
384 #endif |
fead84acb13c
Added --build-options parameter. Patch by Andrey Panin
Timo Sirainen <tss@iki.fi>
parents:
3535
diff
changeset
|
385 #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
|
386 " notify=dnotify" |
3589
fead84acb13c
Added --build-options parameter. Patch by Andrey Panin
Timo Sirainen <tss@iki.fi>
parents:
3535
diff
changeset
|
387 #endif |
fead84acb13c
Added --build-options parameter. Patch by Andrey Panin
Timo Sirainen <tss@iki.fi>
parents:
3535
diff
changeset
|
388 #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
|
389 " notify=inotify" |
3a3ef25c62ab
List -n and -a in short help. Fixes to --build-options.
Timo Sirainen <tss@iki.fi>
parents:
4464
diff
changeset
|
390 #endif |
3a3ef25c62ab
List -n and -a in short help. Fixes to --build-options.
Timo Sirainen <tss@iki.fi>
parents:
4464
diff
changeset
|
391 #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
|
392 " notify=kqueue" |
3589
fead84acb13c
Added --build-options parameter. Patch by Andrey Panin
Timo Sirainen <tss@iki.fi>
parents:
3535
diff
changeset
|
393 #endif |
fead84acb13c
Added --build-options parameter. Patch by Andrey Panin
Timo Sirainen <tss@iki.fi>
parents:
3535
diff
changeset
|
394 #ifdef HAVE_IPV6 |
fead84acb13c
Added --build-options parameter. Patch by Andrey Panin
Timo Sirainen <tss@iki.fi>
parents:
3535
diff
changeset
|
395 " ipv6" |
fead84acb13c
Added --build-options parameter. Patch by Andrey Panin
Timo Sirainen <tss@iki.fi>
parents:
3535
diff
changeset
|
396 #endif |
fead84acb13c
Added --build-options parameter. Patch by Andrey Panin
Timo Sirainen <tss@iki.fi>
parents:
3535
diff
changeset
|
397 #ifdef HAVE_GNUTLS |
fead84acb13c
Added --build-options parameter. Patch by Andrey Panin
Timo Sirainen <tss@iki.fi>
parents:
3535
diff
changeset
|
398 " gnutls" |
fead84acb13c
Added --build-options parameter. Patch by Andrey Panin
Timo Sirainen <tss@iki.fi>
parents:
3535
diff
changeset
|
399 #endif |
fead84acb13c
Added --build-options parameter. Patch by Andrey Panin
Timo Sirainen <tss@iki.fi>
parents:
3535
diff
changeset
|
400 #ifdef HAVE_OPENSSL |
fead84acb13c
Added --build-options parameter. Patch by Andrey Panin
Timo Sirainen <tss@iki.fi>
parents:
3535
diff
changeset
|
401 " openssl" |
fead84acb13c
Added --build-options parameter. Patch by Andrey Panin
Timo Sirainen <tss@iki.fi>
parents:
3535
diff
changeset
|
402 #endif |
6635
e4f9e2b94a90
Show mail storages in dovecot --build-options.
Timo Sirainen <tss@iki.fi>
parents:
6429
diff
changeset
|
403 "\nMail storages: "MAIL_STORAGES"\n" |
9064
d936c8e243dd
dovecot --build-options: If SQL or LDAP was built as plugins, say it.
Timo Sirainen <tss@iki.fi>
parents:
8977
diff
changeset
|
404 #ifdef SQL_DRIVER_PLUGINS |
d936c8e243dd
dovecot --build-options: If SQL or LDAP was built as plugins, say it.
Timo Sirainen <tss@iki.fi>
parents:
8977
diff
changeset
|
405 "SQL driver plugins:" |
d936c8e243dd
dovecot --build-options: If SQL or LDAP was built as plugins, say it.
Timo Sirainen <tss@iki.fi>
parents:
8977
diff
changeset
|
406 #else |
6635
e4f9e2b94a90
Show mail storages in dovecot --build-options.
Timo Sirainen <tss@iki.fi>
parents:
6429
diff
changeset
|
407 "SQL drivers:" |
9064
d936c8e243dd
dovecot --build-options: If SQL or LDAP was built as plugins, say it.
Timo Sirainen <tss@iki.fi>
parents:
8977
diff
changeset
|
408 #endif |
4475
3a3ef25c62ab
List -n and -a in short help. Fixes to --build-options.
Timo Sirainen <tss@iki.fi>
parents:
4464
diff
changeset
|
409 #ifdef BUILD_MYSQL |
3589
fead84acb13c
Added --build-options parameter. Patch by Andrey Panin
Timo Sirainen <tss@iki.fi>
parents:
3535
diff
changeset
|
410 " mysql" |
fead84acb13c
Added --build-options parameter. Patch by Andrey Panin
Timo Sirainen <tss@iki.fi>
parents:
3535
diff
changeset
|
411 #endif |
4475
3a3ef25c62ab
List -n and -a in short help. Fixes to --build-options.
Timo Sirainen <tss@iki.fi>
parents:
4464
diff
changeset
|
412 #ifdef BUILD_PGSQL |
3589
fead84acb13c
Added --build-options parameter. Patch by Andrey Panin
Timo Sirainen <tss@iki.fi>
parents:
3535
diff
changeset
|
413 " postgresql" |
fead84acb13c
Added --build-options parameter. Patch by Andrey Panin
Timo Sirainen <tss@iki.fi>
parents:
3535
diff
changeset
|
414 #endif |
4475
3a3ef25c62ab
List -n and -a in short help. Fixes to --build-options.
Timo Sirainen <tss@iki.fi>
parents:
4464
diff
changeset
|
415 #ifdef BUILD_SQLITE |
3919
b967ffb7e3a6
SQLite support. Patch by Jakob Hirsch.
Timo Sirainen <tss@iki.fi>
parents:
3917
diff
changeset
|
416 " sqlite" |
b967ffb7e3a6
SQLite support. Patch by Jakob Hirsch.
Timo Sirainen <tss@iki.fi>
parents:
3917
diff
changeset
|
417 #endif |
4475
3a3ef25c62ab
List -n and -a in short help. Fixes to --build-options.
Timo Sirainen <tss@iki.fi>
parents:
4464
diff
changeset
|
418 "\nPassdb:" |
3589
fead84acb13c
Added --build-options parameter. Patch by Andrey Panin
Timo Sirainen <tss@iki.fi>
parents:
3535
diff
changeset
|
419 #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
|
420 " bsdauth" |
3589
fead84acb13c
Added --build-options parameter. Patch by Andrey Panin
Timo Sirainen <tss@iki.fi>
parents:
3535
diff
changeset
|
421 #endif |
fead84acb13c
Added --build-options parameter. Patch by Andrey Panin
Timo Sirainen <tss@iki.fi>
parents:
3535
diff
changeset
|
422 #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
|
423 " checkpassword" |
3589
fead84acb13c
Added --build-options parameter. Patch by Andrey Panin
Timo Sirainen <tss@iki.fi>
parents:
3535
diff
changeset
|
424 #endif |
fead84acb13c
Added --build-options parameter. Patch by Andrey Panin
Timo Sirainen <tss@iki.fi>
parents:
3535
diff
changeset
|
425 #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
|
426 " ldap" |
3589
fead84acb13c
Added --build-options parameter. Patch by Andrey Panin
Timo Sirainen <tss@iki.fi>
parents:
3535
diff
changeset
|
427 #endif |
fead84acb13c
Added --build-options parameter. Patch by Andrey Panin
Timo Sirainen <tss@iki.fi>
parents:
3535
diff
changeset
|
428 #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
|
429 " pam" |
3589
fead84acb13c
Added --build-options parameter. Patch by Andrey Panin
Timo Sirainen <tss@iki.fi>
parents:
3535
diff
changeset
|
430 #endif |
fead84acb13c
Added --build-options parameter. Patch by Andrey Panin
Timo Sirainen <tss@iki.fi>
parents:
3535
diff
changeset
|
431 #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
|
432 " passwd" |
3589
fead84acb13c
Added --build-options parameter. Patch by Andrey Panin
Timo Sirainen <tss@iki.fi>
parents:
3535
diff
changeset
|
433 #endif |
fead84acb13c
Added --build-options parameter. Patch by Andrey Panin
Timo Sirainen <tss@iki.fi>
parents:
3535
diff
changeset
|
434 #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
|
435 " passwd-file" |
3589
fead84acb13c
Added --build-options parameter. Patch by Andrey Panin
Timo Sirainen <tss@iki.fi>
parents:
3535
diff
changeset
|
436 #endif |
fead84acb13c
Added --build-options parameter. Patch by Andrey Panin
Timo Sirainen <tss@iki.fi>
parents:
3535
diff
changeset
|
437 #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
|
438 " shadow" |
3589
fead84acb13c
Added --build-options parameter. Patch by Andrey Panin
Timo Sirainen <tss@iki.fi>
parents:
3535
diff
changeset
|
439 #endif |
6893
a9daec3c00b5
--build-options didn't list "sia" in passdbs.
Timo Sirainen <tss@iki.fi>
parents:
6635
diff
changeset
|
440 #ifdef PASSDB_SIA |
a9daec3c00b5
--build-options didn't list "sia" in passdbs.
Timo Sirainen <tss@iki.fi>
parents:
6635
diff
changeset
|
441 " sia" |
a9daec3c00b5
--build-options didn't list "sia" in passdbs.
Timo Sirainen <tss@iki.fi>
parents:
6635
diff
changeset
|
442 #endif |
3589
fead84acb13c
Added --build-options parameter. Patch by Andrey Panin
Timo Sirainen <tss@iki.fi>
parents:
3535
diff
changeset
|
443 #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
|
444 " sql" |
3589
fead84acb13c
Added --build-options parameter. Patch by Andrey Panin
Timo Sirainen <tss@iki.fi>
parents:
3535
diff
changeset
|
445 #endif |
fead84acb13c
Added --build-options parameter. Patch by Andrey Panin
Timo Sirainen <tss@iki.fi>
parents:
3535
diff
changeset
|
446 #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
|
447 " vpopmail" |
3589
fead84acb13c
Added --build-options parameter. Patch by Andrey Panin
Timo Sirainen <tss@iki.fi>
parents:
3535
diff
changeset
|
448 #endif |
4475
3a3ef25c62ab
List -n and -a in short help. Fixes to --build-options.
Timo Sirainen <tss@iki.fi>
parents:
4464
diff
changeset
|
449 "\nUserdb:" |
7947
cd2789afcb09
Include "nss" in dovecot --build-options.
Timo Sirainen <tss@iki.fi>
parents:
7946
diff
changeset
|
450 #ifdef USERDB_NSS |
cd2789afcb09
Include "nss" in dovecot --build-options.
Timo Sirainen <tss@iki.fi>
parents:
7946
diff
changeset
|
451 " nss" |
cd2789afcb09
Include "nss" in dovecot --build-options.
Timo Sirainen <tss@iki.fi>
parents:
7946
diff
changeset
|
452 #endif |
3589
fead84acb13c
Added --build-options parameter. Patch by Andrey Panin
Timo Sirainen <tss@iki.fi>
parents:
3535
diff
changeset
|
453 #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
|
454 " ldap" |
9064
d936c8e243dd
dovecot --build-options: If SQL or LDAP was built as plugins, say it.
Timo Sirainen <tss@iki.fi>
parents:
8977
diff
changeset
|
455 #ifndef BUILTIN_LDAP |
d936c8e243dd
dovecot --build-options: If SQL or LDAP was built as plugins, say it.
Timo Sirainen <tss@iki.fi>
parents:
8977
diff
changeset
|
456 "(plugin)" |
d936c8e243dd
dovecot --build-options: If SQL or LDAP was built as plugins, say it.
Timo Sirainen <tss@iki.fi>
parents:
8977
diff
changeset
|
457 #endif |
3589
fead84acb13c
Added --build-options parameter. Patch by Andrey Panin
Timo Sirainen <tss@iki.fi>
parents:
3535
diff
changeset
|
458 #endif |
fead84acb13c
Added --build-options parameter. Patch by Andrey Panin
Timo Sirainen <tss@iki.fi>
parents:
3535
diff
changeset
|
459 #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
|
460 " passwd" |
3a3ef25c62ab
List -n and -a in short help. Fixes to --build-options.
Timo Sirainen <tss@iki.fi>
parents:
4464
diff
changeset
|
461 #endif |
7947
cd2789afcb09
Include "nss" in dovecot --build-options.
Timo Sirainen <tss@iki.fi>
parents:
7946
diff
changeset
|
462 #ifdef USERDB_PASSWD_FILE |
cd2789afcb09
Include "nss" in dovecot --build-options.
Timo Sirainen <tss@iki.fi>
parents:
7946
diff
changeset
|
463 " passwd-file" |
cd2789afcb09
Include "nss" in dovecot --build-options.
Timo Sirainen <tss@iki.fi>
parents:
7946
diff
changeset
|
464 #endif |
4475
3a3ef25c62ab
List -n and -a in short help. Fixes to --build-options.
Timo Sirainen <tss@iki.fi>
parents:
4464
diff
changeset
|
465 #ifdef USERDB_PREFETCH |
3a3ef25c62ab
List -n and -a in short help. Fixes to --build-options.
Timo Sirainen <tss@iki.fi>
parents:
4464
diff
changeset
|
466 " prefetch" |
3589
fead84acb13c
Added --build-options parameter. Patch by Andrey Panin
Timo Sirainen <tss@iki.fi>
parents:
3535
diff
changeset
|
467 #endif |
fead84acb13c
Added --build-options parameter. Patch by Andrey Panin
Timo Sirainen <tss@iki.fi>
parents:
3535
diff
changeset
|
468 #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
|
469 " sql" |
3589
fead84acb13c
Added --build-options parameter. Patch by Andrey Panin
Timo Sirainen <tss@iki.fi>
parents:
3535
diff
changeset
|
470 #endif |
fead84acb13c
Added --build-options parameter. Patch by Andrey Panin
Timo Sirainen <tss@iki.fi>
parents:
3535
diff
changeset
|
471 #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
|
472 " static" |
3589
fead84acb13c
Added --build-options parameter. Patch by Andrey Panin
Timo Sirainen <tss@iki.fi>
parents:
3535
diff
changeset
|
473 #endif |
fead84acb13c
Added --build-options parameter. Patch by Andrey Panin
Timo Sirainen <tss@iki.fi>
parents:
3535
diff
changeset
|
474 #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
|
475 " vpopmail" |
3589
fead84acb13c
Added --build-options parameter. Patch by Andrey Panin
Timo Sirainen <tss@iki.fi>
parents:
3535
diff
changeset
|
476 #endif |
8782
e5cc81734221
Compile fix for systems where printf() is a macro.
Timo Sirainen <tss@iki.fi>
parents:
8699
diff
changeset
|
477 "\n"; |
e5cc81734221
Compile fix for systems where printf() is a macro.
Timo Sirainen <tss@iki.fi>
parents:
8699
diff
changeset
|
478 puts(build_options); |
279
49f4b0be0d87
Print usage with invalid parameters.
Timo Sirainen <tss@iki.fi>
parents:
50
diff
changeset
|
479 } |
49f4b0be0d87
Print usage with invalid parameters.
Timo Sirainen <tss@iki.fi>
parents:
50
diff
changeset
|
480 |
0 | 481 int main(int argc, char *argv[]) |
482 { | |
483 /* parse arguments */ | |
7334
ae8180a4febd
Allow dovecot --exec-mail ext program arguments.
Timo Sirainen <tss@iki.fi>
parents:
7229
diff
changeset
|
484 const char *exec_protocol = NULL, **exec_args = NULL, *user, *home; |
5090
04b467f23400
Added --log-error command line option.
Timo Sirainen <tss@iki.fi>
parents:
5077
diff
changeset
|
485 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
|
486 bool dump_config = FALSE, dump_config_nondefaults = FALSE; |
0 | 487 int i; |
488 | |
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
|
489 #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
|
490 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
|
491 #endif |
0 | 492 lib_init(); |
493 | |
1617
cc3cef25662c
Replaced geteuid() calls with one in the beginning and saving it to
Timo Sirainen <tss@iki.fi>
parents:
1610
diff
changeset
|
494 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
|
495 inetd_login_fd = -1; |
0 | 496 for (i = 1; i < argc; i++) { |
497 if (strcmp(argv[i], "-F") == 0) { | |
498 /* foreground */ | |
499 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
|
500 } 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
|
501 dump_config = TRUE; |
0 | 502 } else if (strcmp(argv[i], "-c") == 0) { |
503 /* config file */ | |
504 i++; | |
505 if (i == argc) i_fatal("Missing config file argument"); | |
506 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
|
507 } 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
|
508 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
|
509 } 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
|
510 /* 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
|
511 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
|
512 } else if (strcmp(argv[i], "--exec-mail") == 0) { |
7334
ae8180a4febd
Allow dovecot --exec-mail ext program arguments.
Timo Sirainen <tss@iki.fi>
parents:
7229
diff
changeset
|
513 /* <protocol> [<args>] |
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
|
514 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
|
515 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
|
516 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
|
517 exec_protocol = argv[i]; |
7334
ae8180a4febd
Allow dovecot --exec-mail ext program arguments.
Timo Sirainen <tss@iki.fi>
parents:
7229
diff
changeset
|
518 exec_args = (const char **)&argv[i+1]; |
ae8180a4febd
Allow dovecot --exec-mail ext program arguments.
Timo Sirainen <tss@iki.fi>
parents:
7229
diff
changeset
|
519 break; |
1260 | 520 } else if (strcmp(argv[i], "--version") == 0) { |
521 printf("%s\n", VERSION); | |
522 return 0; | |
3589
fead84acb13c
Added --build-options parameter. Patch by Andrey Panin
Timo Sirainen <tss@iki.fi>
parents:
3535
diff
changeset
|
523 } 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
|
524 print_build_options(); |
fead84acb13c
Added --build-options parameter. Patch by Andrey Panin
Timo Sirainen <tss@iki.fi>
parents:
3535
diff
changeset
|
525 return 0; |
5090
04b467f23400
Added --log-error command line option.
Timo Sirainen <tss@iki.fi>
parents:
5077
diff
changeset
|
526 } else if (strcmp(argv[i], "--log-error") == 0) { |
04b467f23400
Added --log-error command line option.
Timo Sirainen <tss@iki.fi>
parents:
5077
diff
changeset
|
527 log_error = TRUE; |
04b467f23400
Added --log-error command line option.
Timo Sirainen <tss@iki.fi>
parents:
5077
diff
changeset
|
528 foreground = TRUE; |
0 | 529 } else { |
279
49f4b0be0d87
Print usage with invalid parameters.
Timo Sirainen <tss@iki.fi>
parents:
50
diff
changeset
|
530 print_help(); |
8977
59a3130bd4ed
master: "Unknown argument" error printed always the first argument instead of the unknown one.
Timo Sirainen <tss@iki.fi>
parents:
8965
diff
changeset
|
531 i_fatal("Unknown argument: %s", argv[i]); |
0 | 532 } |
533 } | |
534 | |
5437 | 535 /* need to have this open before reading settings */ |
536 open_null_fd(); | |
537 | |
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
|
538 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
|
539 /* 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
|
540 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
|
541 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
|
542 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
|
543 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
|
544 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
|
545 } |
4558d1b196fd
Added --exec-mail option to master. It can be used to parse Dovecot config
Timo Sirainen <tss@iki.fi>
parents:
2306
diff
changeset
|
546 |
4965
9246d9308caa
-n and -a parameters shouldn't be deleting auth sockets.
Timo Sirainen <tss@iki.fi>
parents:
4903
diff
changeset
|
547 if (dump_config) { |
8354
5339d2ebeb56
dovecot -n/-a: Print some information about the system.
Timo Sirainen <tss@iki.fi>
parents:
8323
diff
changeset
|
548 |
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
|
549 /* 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
|
550 of errors it's still shown */ |
5589
271c35971331
Print also Dovecot version with dovecot -n.
Timo Sirainen <tss@iki.fi>
parents:
5437
diff
changeset
|
551 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
|
552 } |
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
|
553 |
0 | 554 /* read and verify settings before forking */ |
7226
e6693a0ec8e1
Renamed T_FRAME_BEGIN/END to T_BEGIN/END. Removed T_FRAME() macro and
Timo Sirainen <tss@iki.fi>
parents:
7086
diff
changeset
|
555 T_BEGIN { |
6940
414c9d631a81
Replaced t_push/t_pop calls with T_FRAME*() macros.
Timo Sirainen <tss@iki.fi>
parents:
6893
diff
changeset
|
556 master_settings_init(); |
414c9d631a81
Replaced t_push/t_pop calls with T_FRAME*() macros.
Timo Sirainen <tss@iki.fi>
parents:
6893
diff
changeset
|
557 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
|
558 dump_config || log_error)) |
414c9d631a81
Replaced t_push/t_pop calls with T_FRAME*() macros.
Timo Sirainen <tss@iki.fi>
parents:
6893
diff
changeset
|
559 i_fatal("Invalid configuration in %s", configfile); |
7226
e6693a0ec8e1
Renamed T_FRAME_BEGIN/END to T_BEGIN/END. Removed T_FRAME() macro and
Timo Sirainen <tss@iki.fi>
parents:
7086
diff
changeset
|
560 } T_END; |
0 | 561 |
4965
9246d9308caa
-n and -a parameters shouldn't be deleting auth sockets.
Timo Sirainen <tss@iki.fi>
parents:
4903
diff
changeset
|
562 if (dump_config) { |
8354
5339d2ebeb56
dovecot -n/-a: Print some information about the system.
Timo Sirainen <tss@iki.fi>
parents:
8323
diff
changeset
|
563 const char *info; |
5339d2ebeb56
dovecot -n/-a: Print some information about the system.
Timo Sirainen <tss@iki.fi>
parents:
8323
diff
changeset
|
564 |
5339d2ebeb56
dovecot -n/-a: Print some information about the system.
Timo Sirainen <tss@iki.fi>
parents:
8323
diff
changeset
|
565 info = sysinfo_get(settings_root->defaults->mail_location); |
5339d2ebeb56
dovecot -n/-a: Print some information about the system.
Timo Sirainen <tss@iki.fi>
parents:
8323
diff
changeset
|
566 if (*info != '\0') |
5339d2ebeb56
dovecot -n/-a: Print some information about the system.
Timo Sirainen <tss@iki.fi>
parents:
8323
diff
changeset
|
567 printf("# %s\n", info); |
5339d2ebeb56
dovecot -n/-a: Print some information about the system.
Timo Sirainen <tss@iki.fi>
parents:
8323
diff
changeset
|
568 |
4138
f9a6381adbe3
Added -a and -n parameters to dovecot to dump all/nondefault settings. A
Timo Sirainen <tss@iki.fi>
parents:
3989
diff
changeset
|
569 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
|
570 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
|
571 } |
f9a6381adbe3
Added -a and -n parameters to dovecot to dump all/nondefault settings. A
Timo Sirainen <tss@iki.fi>
parents:
3989
diff
changeset
|
572 |
7226
e6693a0ec8e1
Renamed T_FRAME_BEGIN/END to T_BEGIN/END. Removed T_FRAME() macro and
Timo Sirainen <tss@iki.fi>
parents:
7086
diff
changeset
|
573 if (ask_key_pass) T_BEGIN { |
3889
c7462001227b
Added support for password protected SSL private keys. The password can be
Timo Sirainen <tss@iki.fi>
parents:
3879
diff
changeset
|
574 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
|
575 |
c7462001227b
Added support for password protected SSL private keys. The password can be
Timo Sirainen <tss@iki.fi>
parents:
3879
diff
changeset
|
576 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
|
577 "%s: ", |
c7462001227b
Added support for password protected SSL private keys. The password can be
Timo Sirainen <tss@iki.fi>
parents:
3879
diff
changeset
|
578 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
|
579 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
|
580 sizeof(ssl_manual_key_password)); |
7226
e6693a0ec8e1
Renamed T_FRAME_BEGIN/END to T_BEGIN/END. Removed T_FRAME() macro and
Timo Sirainen <tss@iki.fi>
parents:
7086
diff
changeset
|
581 } T_END; |
3889
c7462001227b
Added support for password protected SSL private keys. The password can be
Timo Sirainen <tss@iki.fi>
parents:
3879
diff
changeset
|
582 |
3535
08b3e3fd0bc5
The master process itself also needs the TZ environment
Timo Sirainen <tss@iki.fi>
parents:
3516
diff
changeset
|
583 /* 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
|
584 correctly. */ |
3516
71b0ccba8cf3
Preserve TZ environment to child processes so timezones aren't lost with
Timo Sirainen <tss@iki.fi>
parents:
3181
diff
changeset
|
585 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
|
586 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
|
587 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
|
588 |
3535
08b3e3fd0bc5
The master process itself also needs the TZ environment
Timo Sirainen <tss@iki.fi>
parents:
3516
diff
changeset
|
589 /* 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
|
590 env_clean(); |
2cf2e08a6ee9
Somewhat working code to support loading Dovecot from inetd and such. It
Timo Sirainen <tss@iki.fi>
parents:
1268
diff
changeset
|
591 |
3535
08b3e3fd0bc5
The master process itself also needs the TZ environment
Timo Sirainen <tss@iki.fi>
parents:
3516
diff
changeset
|
592 /* put back the TZ */ |
08b3e3fd0bc5
The master process itself also needs the TZ environment
Timo Sirainen <tss@iki.fi>
parents:
3516
diff
changeset
|
593 if (env_tz != NULL) |
08b3e3fd0bc5
The master process itself also needs the TZ environment
Timo Sirainen <tss@iki.fi>
parents:
3516
diff
changeset
|
594 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
|
595 |
3897
9dc2f8f0eb59
When starting with --exec-mail, keep USER and HOME environments and clear
Timo Sirainen <tss@iki.fi>
parents:
3889
diff
changeset
|
596 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
|
597 /* 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
|
598 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
|
599 env_put(t_strconcat("HOME=", home, NULL)); |
7334
ae8180a4febd
Allow dovecot --exec-mail ext program arguments.
Timo Sirainen <tss@iki.fi>
parents:
7229
diff
changeset
|
600 mail_process_exec(exec_protocol, exec_args); |
3897
9dc2f8f0eb59
When starting with --exec-mail, keep USER and HOME environments and clear
Timo Sirainen <tss@iki.fi>
parents:
3889
diff
changeset
|
601 } |
9dc2f8f0eb59
When starting with --exec-mail, keep USER and HOME environments and clear
Timo Sirainen <tss@iki.fi>
parents:
3889
diff
changeset
|
602 |
6303 | 603 if (!log_error) |
604 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
|
605 |
7229
586abf9b561c
If Dovecot master dies with a fatal failure, log the error message to a file
Timo Sirainen <tss@iki.fi>
parents:
7226
diff
changeset
|
606 fatal_log_check(); |
8305
e4d0ce4d3420
Don't show the WhyDoesItNotWork link if auth_debug=yes already.
Timo Sirainen <tss@iki.fi>
parents:
8301
diff
changeset
|
607 auth_warning_print(settings_root); |
0 | 608 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
|
609 daemonize(settings_root->defaults); |
8323
60c48789841b
master: Don't print "last died with error .." for fatals that were from forked child processes.
Timo Sirainen <tss@iki.fi>
parents:
8305
diff
changeset
|
610 master_original_pid = getpid(); |
0 | 611 |
5249
784dc7224718
Removed pool parameter from io_loop_create()
Timo Sirainen <tss@iki.fi>
parents:
5201
diff
changeset
|
612 ioloop = io_loop_create(); |
0 | 613 |
5090
04b467f23400
Added --log-error command line option.
Timo Sirainen <tss@iki.fi>
parents:
5077
diff
changeset
|
614 main_init(log_error); |
0 | 615 io_loop_run(ioloop); |
616 main_deinit(); | |
617 | |
1058
3b8fb7bf7ecc
Moved settings parsing to lib-settings.
Timo Sirainen <tss@iki.fi>
parents:
1055
diff
changeset
|
618 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
|
619 io_loop_destroy(&ioloop); |
0 | 620 lib_deinit(); |
621 | |
622 return 0; | |
623 } |