annotate src/config/main.c @ 22713:cb108f786fb4

Updated copyright notices to include the year 2018.
author Stephan Bosch <stephan.bosch@dovecot.fi>
date Mon, 01 Jan 2018 22:42:08 +0100
parents 2e2563132d5f
children
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
22713
cb108f786fb4 Updated copyright notices to include the year 2018.
Stephan Bosch <stephan.bosch@dovecot.fi>
parents: 21390
diff changeset
1 /* Copyright (c) 2005-2018 Dovecot authors, see the included COPYING file */
9002
9d0037a997f4 Initial commit for config rewrite.
Timo Sirainen <tss@iki.fi>
parents:
diff changeset
2
9179
f8460b27db00 doveconf: With -p only protocol-specific settings are returned. -n and -a return human-readable output.
Timo Sirainen <tss@iki.fi>
parents: 9159
diff changeset
3 #include "lib.h"
11265
3fc759d5e736 config: Unload modules at exit.
Timo Sirainen <tss@iki.fi>
parents: 10981
diff changeset
4 #include "module-dir.h"
10320
4933856b86d7 anvil, config, log, ssl-params: Drop privileges as configured.
Timo Sirainen <tss@iki.fi>
parents: 10181
diff changeset
5 #include "restrict-access.h"
9159
6324a79d3ee1 Initial commit for v2.0 master rewrite. Several features are still missing.
Timo Sirainen <tss@iki.fi>
parents: 9087
diff changeset
6 #include "master-service.h"
9002
9d0037a997f4 Initial commit for config rewrite.
Timo Sirainen <tss@iki.fi>
parents:
diff changeset
7 #include "config-connection.h"
9d0037a997f4 Initial commit for config rewrite.
Timo Sirainen <tss@iki.fi>
parents:
diff changeset
8 #include "config-parser.h"
9179
f8460b27db00 doveconf: With -p only protocol-specific settings are returned. -n and -a return human-readable output.
Timo Sirainen <tss@iki.fi>
parents: 9159
diff changeset
9 #include "config-request.h"
9002
9d0037a997f4 Initial commit for config rewrite.
Timo Sirainen <tss@iki.fi>
parents:
diff changeset
10
11388
b8d3c96e61a7 lib-master API changed to avoid accidentally leaking client connections.
Timo Sirainen <tss@iki.fi>
parents: 11265
diff changeset
11 static void client_connected(struct master_service_connection *conn)
9159
6324a79d3ee1 Initial commit for v2.0 master rewrite. Several features are still missing.
Timo Sirainen <tss@iki.fi>
parents: 9087
diff changeset
12 {
11388
b8d3c96e61a7 lib-master API changed to avoid accidentally leaking client connections.
Timo Sirainen <tss@iki.fi>
parents: 11265
diff changeset
13 master_service_client_connection_accept(conn);
14682
d0d7b810646b Make sure we check all the functions' return values. Minor API changes to simplify this.
Timo Sirainen <tss@iki.fi>
parents: 14629
diff changeset
14 (void)config_connection_create(conn->fd);
9002
9d0037a997f4 Initial commit for config rewrite.
Timo Sirainen <tss@iki.fi>
parents:
diff changeset
15 }
9d0037a997f4 Initial commit for config rewrite.
Timo Sirainen <tss@iki.fi>
parents:
diff changeset
16
9d0037a997f4 Initial commit for config rewrite.
Timo Sirainen <tss@iki.fi>
parents:
diff changeset
17 int main(int argc, char *argv[])
9d0037a997f4 Initial commit for config rewrite.
Timo Sirainen <tss@iki.fi>
parents:
diff changeset
18 {
9793
d7ccdbb58a03 config: If master module requests configuration, reread it before replying.
Timo Sirainen <tss@iki.fi>
parents: 9348
diff changeset
19 const char *path, *error;
9159
6324a79d3ee1 Initial commit for v2.0 master rewrite. Several features are still missing.
Timo Sirainen <tss@iki.fi>
parents: 9087
diff changeset
20
14629
c93ca5e46a8a Marked functions parameters that are allowed to be NULL. Some APIs were also changed.
Timo Sirainen <tss@iki.fi>
parents: 14133
diff changeset
21 master_service = master_service_init("config", 0, &argc, &argv, "");
10119
1e63221f5c83 Moved most of getopt() handling to lib-master.
Timo Sirainen <tss@iki.fi>
parents: 9912
diff changeset
22 if (master_getopt(master_service) > 0)
1e63221f5c83 Moved most of getopt() handling to lib-master.
Timo Sirainen <tss@iki.fi>
parents: 9912
diff changeset
23 return FATAL_DEFAULT;
10320
4933856b86d7 anvil, config, log, ssl-params: Drop privileges as configured.
Timo Sirainen <tss@iki.fi>
parents: 10181
diff changeset
24 master_service_init_log(master_service, "config: ");
9002
9d0037a997f4 Initial commit for config rewrite.
Timo Sirainen <tss@iki.fi>
parents:
diff changeset
25
10320
4933856b86d7 anvil, config, log, ssl-params: Drop privileges as configured.
Timo Sirainen <tss@iki.fi>
parents: 10181
diff changeset
26 restrict_access_by_env(NULL, FALSE);
4933856b86d7 anvil, config, log, ssl-params: Drop privileges as configured.
Timo Sirainen <tss@iki.fi>
parents: 10181
diff changeset
27 restrict_access_allow_coredumps(TRUE);
4933856b86d7 anvil, config, log, ssl-params: Drop privileges as configured.
Timo Sirainen <tss@iki.fi>
parents: 10181
diff changeset
28
10181
4dc080520769 config: Added support for dynamically loaded settings.
Timo Sirainen <tss@iki.fi>
parents: 10120
diff changeset
29 config_parse_load_modules();
9793
d7ccdbb58a03 config: If master module requests configuration, reread it before replying.
Timo Sirainen <tss@iki.fi>
parents: 9348
diff changeset
30
d7ccdbb58a03 config: If master module requests configuration, reread it before replying.
Timo Sirainen <tss@iki.fi>
parents: 9348
diff changeset
31 path = master_service_get_config_path(master_service);
15087
8c003fe6f5a6 config: Support looking up config for multiple modules at the same time.
Timo Sirainen <tss@iki.fi>
parents: 14682
diff changeset
32 if (config_parse_file(path, TRUE, NULL, &error) <= 0)
9793
d7ccdbb58a03 config: If master module requests configuration, reread it before replying.
Timo Sirainen <tss@iki.fi>
parents: 9348
diff changeset
33 i_fatal("%s", error);
9159
6324a79d3ee1 Initial commit for v2.0 master rewrite. Several features are still missing.
Timo Sirainen <tss@iki.fi>
parents: 9087
diff changeset
34
15562
bc11033ef035 config: Notify process creation success to master only after parsing config file
Timo Sirainen <tss@iki.fi>
parents: 14133
diff changeset
35 /* notify about our success only after successfully parsing the
bc11033ef035 config: Notify process creation success to master only after parsing config file
Timo Sirainen <tss@iki.fi>
parents: 14133
diff changeset
36 config file, so if the parsing fails, master won't immediately
bc11033ef035 config: Notify process creation success to master only after parsing config file
Timo Sirainen <tss@iki.fi>
parents: 14133
diff changeset
37 just recreate this process (and fail again and so on). */
bc11033ef035 config: Notify process creation success to master only after parsing config file
Timo Sirainen <tss@iki.fi>
parents: 14133
diff changeset
38 master_service_init_finish(master_service);
bc11033ef035 config: Notify process creation success to master only after parsing config file
Timo Sirainen <tss@iki.fi>
parents: 14133
diff changeset
39
9348
0c587f108916 lib-master has now a global master_service variable that all binaries use.
Timo Sirainen <tss@iki.fi>
parents: 9274
diff changeset
40 master_service_run(master_service, client_connected);
9159
6324a79d3ee1 Initial commit for v2.0 master rewrite. Several features are still missing.
Timo Sirainen <tss@iki.fi>
parents: 9087
diff changeset
41 config_connections_destroy_all();
9881
8ad868df4649 Memory leak fixes.
Timo Sirainen <tss@iki.fi>
parents: 9842
diff changeset
42
8ad868df4649 Memory leak fixes.
Timo Sirainen <tss@iki.fi>
parents: 9842
diff changeset
43 config_filter_deinit(&config_filter);
11265
3fc759d5e736 config: Unload modules at exit.
Timo Sirainen <tss@iki.fi>
parents: 10981
diff changeset
44 module_dir_unload(&modules);
20015
680f59741e5e doveconf, config: Free all memory at deinit
Timo Sirainen <timo.sirainen@dovecot.fi>
parents: 19552
diff changeset
45 config_parser_deinit();
9348
0c587f108916 lib-master has now a global master_service variable that all binaries use.
Timo Sirainen <tss@iki.fi>
parents: 9274
diff changeset
46 master_service_deinit(&master_service);
9002
9d0037a997f4 Initial commit for config rewrite.
Timo Sirainen <tss@iki.fi>
parents:
diff changeset
47 return 0;
9d0037a997f4 Initial commit for config rewrite.
Timo Sirainen <tss@iki.fi>
parents:
diff changeset
48 }