Mercurial > dovecot > original-hg > dovecot-1.2
comparison src/master/main.c @ 9528:142c935e44d6 HEAD
dovecot -a|-n: Log a warning if Dovecot was last started using a different config file.
author | Timo Sirainen <tss@iki.fi> |
---|---|
date | Fri, 22 Jan 2010 18:58:51 +0200 |
parents | 0f04c7da33f1 |
children | 3237519b73f4 |
comparison
equal
deleted
inserted
replaced
9527:2a7efac89339 | 9528:142c935e44d6 |
---|---|
191 dict_processes_kill(); | 191 dict_processes_kill(); |
192 | 192 |
193 /* see if hostname changed */ | 193 /* see if hostname changed */ |
194 hostpid_init(); | 194 hostpid_init(); |
195 | 195 |
196 if (!master_settings_read(configfile, FALSE, FALSE)) | 196 if (!master_settings_read(configfile, FALSE, FALSE, FALSE)) |
197 i_warning("Invalid configuration, keeping old one"); | 197 i_warning("Invalid configuration, keeping old one"); |
198 else { | 198 else { |
199 if (!IS_INETD()) | 199 if (!IS_INETD()) |
200 listeners_open_fds(old_set, TRUE); | 200 listeners_open_fds(old_set, TRUE); |
201 set_logfile(settings_root->defaults); | 201 set_logfile(settings_root->defaults); |
307 i_info(STARTUP_STRING); | 307 i_info(STARTUP_STRING); |
308 } | 308 } |
309 | 309 |
310 static void main_init(bool log_error) | 310 static void main_init(bool log_error) |
311 { | 311 { |
312 const char *base_config_path; | |
313 | |
312 drop_capabilities(); | 314 drop_capabilities(); |
313 | 315 |
314 /* deny file access from everyone else except owner */ | 316 /* deny file access from everyone else except owner */ |
315 (void)umask(0077); | 317 (void)umask(0077); |
316 | 318 |
346 login_processes_init(); | 348 login_processes_init(); |
347 mail_processes_init(); | 349 mail_processes_init(); |
348 | 350 |
349 create_pid_file(t_strconcat(settings_root->defaults->base_dir, | 351 create_pid_file(t_strconcat(settings_root->defaults->base_dir, |
350 "/master.pid", NULL)); | 352 "/master.pid", NULL)); |
353 base_config_path = t_strconcat(settings_root->defaults->base_dir, | |
354 "/"PACKAGE".conf", NULL); | |
355 (void)unlink(base_config_path); | |
356 if (symlink(configfile, base_config_path) < 0) { | |
357 i_error("symlink(%s, %s) failed: %m", | |
358 configfile, base_config_path); | |
359 } | |
351 } | 360 } |
352 | 361 |
353 static void main_deinit(void) | 362 static void main_deinit(void) |
354 { | 363 { |
355 (void)unlink(t_strconcat(settings_root->defaults->base_dir, | 364 (void)unlink(t_strconcat(settings_root->defaults->base_dir, |
516 { | 525 { |
517 /* parse arguments */ | 526 /* parse arguments */ |
518 const char *exec_protocol = NULL, **exec_args = NULL, *user, *home; | 527 const char *exec_protocol = NULL, **exec_args = NULL, *user, *home; |
519 bool foreground = FALSE, ask_key_pass = FALSE, log_error = FALSE; | 528 bool foreground = FALSE, ask_key_pass = FALSE, log_error = FALSE; |
520 bool dump_config = FALSE, dump_config_nondefaults = FALSE; | 529 bool dump_config = FALSE, dump_config_nondefaults = FALSE; |
530 bool config_path_given = FALSE; | |
521 int i; | 531 int i; |
522 | 532 |
523 #ifdef DEBUG | 533 #ifdef DEBUG |
524 gdb = getenv("GDB") != NULL; | 534 gdb = getenv("GDB") != NULL; |
525 #endif | 535 #endif |
536 } else if (strcmp(argv[i], "-c") == 0) { | 546 } else if (strcmp(argv[i], "-c") == 0) { |
537 /* config file */ | 547 /* config file */ |
538 i++; | 548 i++; |
539 if (i == argc) i_fatal("Missing config file argument"); | 549 if (i == argc) i_fatal("Missing config file argument"); |
540 configfile = argv[i]; | 550 configfile = argv[i]; |
551 config_path_given = TRUE; | |
541 } else if (strcmp(argv[i], "-n") == 0) { | 552 } else if (strcmp(argv[i], "-n") == 0) { |
542 dump_config_nondefaults = dump_config = TRUE; | 553 dump_config_nondefaults = dump_config = TRUE; |
543 } else if (strcmp(argv[i], "-p") == 0) { | 554 } else if (strcmp(argv[i], "-p") == 0) { |
544 /* Ask SSL private key password */ | 555 /* Ask SSL private key password */ |
545 ask_key_pass = TRUE; | 556 ask_key_pass = TRUE; |
577 fd_close_on_exec(inetd_login_fd, TRUE); | 588 fd_close_on_exec(inetd_login_fd, TRUE); |
578 foreground = TRUE; | 589 foreground = TRUE; |
579 } | 590 } |
580 | 591 |
581 if (dump_config) { | 592 if (dump_config) { |
582 | |
583 /* print the config file path before parsing it, so in case | 593 /* print the config file path before parsing it, so in case |
584 of errors it's still shown */ | 594 of errors it's still shown */ |
585 printf("# "VERSION": %s\n", configfile); | 595 printf("# "VERSION": %s\n", configfile); |
586 } | 596 } |
587 | 597 |
588 /* read and verify settings before forking */ | 598 /* read and verify settings before forking */ |
589 T_BEGIN { | 599 T_BEGIN { |
590 master_settings_init(); | 600 master_settings_init(); |
591 if (!master_settings_read(configfile, exec_protocol != NULL, | 601 if (!master_settings_read(configfile, exec_protocol != NULL, |
592 dump_config || log_error)) | 602 dump_config || log_error, |
603 !config_path_given)) | |
593 i_fatal("Invalid configuration in %s", configfile); | 604 i_fatal("Invalid configuration in %s", configfile); |
594 } T_END; | 605 } T_END; |
595 | 606 |
596 if (dump_config) { | 607 if (dump_config) { |
597 const char *info; | 608 const char *info; |