1 /* $NetBSD: master_vars.c,v 1.3 2022/10/08 16:12:46 christos Exp $ */
2
3 /*++
4 /* NAME
5 /* master_vars 3
6 /* SUMMARY
7 /* Postfix master - global configuration file access
8 /* SYNOPSIS
9 /* #include "master.h"
10 /*
11 /* void master_vars_init()
12 /* DESCRIPTION
13 /* master_vars_init() reads values from the global Postfix configuration
14 /* file and assigns them to tunable program parameters. Where no value
15 /* is specified, a compiled-in default value is used.
16 /* LICENSE
17 /* .ad
18 /* .fi
19 /* The Secure Mailer license must be distributed with this software.
20 /* AUTHOR(S)
21 /* Wietse Venema
22 /* IBM T.J. Watson Research
23 /* P.O. Box 704
24 /* Yorktown Heights, NY 10598, USA
25 /*
26 /* Wietse Venema
27 /* Google, Inc.
28 /* 111 8th Avenue
29 /* New York, NY 10011, USA
30 /*--*/
31
32 /* System library. */
33
34 #include <sys_defs.h>
35 #include <string.h>
36 #include <unistd.h>
37
38 /* Utility library. */
39
40 #include <msg.h>
41 #include <stringops.h>
42 #include <mymalloc.h>
43
44 /* Global library. */
45
46 #include <mail_conf.h>
47 #include <mail_params.h>
48
49 /* Application-specific. */
50
51 #include "master.h"
52
53 /*
54 * Tunable parameters.
55 */
56 int var_throttle_time;
57 char *var_master_disable;
58
59 /* master_vars_init - initialize from global Postfix configuration file */
60
master_vars_init(void)61 void master_vars_init(void)
62 {
63 char *path;
64 static const CONFIG_STR_TABLE str_table[] = {
65 VAR_MASTER_DISABLE, DEF_MASTER_DISABLE, &var_master_disable, 0, 0,
66 0,
67 };
68 static const CONFIG_TIME_TABLE time_table[] = {
69 VAR_THROTTLE_TIME, DEF_THROTTLE_TIME, &var_throttle_time, 1, 0,
70 0,
71 };
72 static char *saved_inet_protocols;
73 static char *saved_queue_dir;
74 static char *saved_config_dir;
75 static const MASTER_STR_WATCH str_watch_table[] = {
76 VAR_CONFIG_DIR, &var_config_dir, &saved_config_dir, 0, 0,
77 VAR_QUEUE_DIR, &var_queue_dir, &saved_queue_dir, 0, 0,
78 VAR_INET_PROTOCOLS, &var_inet_protocols, &saved_inet_protocols, 0, 0,
79 /* XXX Add inet_interfaces here after this code is burned in. */
80 0,
81 };
82
83 /*
84 * Flush existing main.cf settings, so that we handle deleted main.cf
85 * settings properly.
86 */
87 mail_conf_flush();
88 set_mail_conf_str(VAR_PROCNAME, var_procname);
89 mail_conf_read();
90 get_mail_conf_str_table(str_table);
91 get_mail_conf_time_table(time_table);
92 path = concatenate(var_config_dir, "/", MASTER_CONF_FILE, (void *) 0);
93 fset_master_ent(path);
94 myfree(path);
95
96 /*
97 * Look for parameter changes that require special attention.
98 */
99 master_str_watch(str_watch_table);
100 }
101