xref: /netbsd-src/external/ibm-public/postfix/dist/src/master/master_vars.c (revision 6a493d6bc668897c91594964a732d38505b70cbb)
1 /*	$NetBSD: master_vars.c,v 1.1.1.2 2013/01/02 18:59:01 tron 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 
27 /* System library. */
28 
29 #include <sys_defs.h>
30 #include <string.h>
31 #include <unistd.h>
32 
33 /* Utility library. */
34 
35 #include <msg.h>
36 #include <stringops.h>
37 #include <mymalloc.h>
38 
39 /* Global library. */
40 
41 #include <mail_conf.h>
42 #include <mail_params.h>
43 
44 /* Application-specific. */
45 
46 #include "master.h"
47 
48  /*
49   * Tunable parameters.
50   */
51 char   *var_inet_protocols;
52 int     var_proc_limit;
53 int     var_throttle_time;
54 char   *var_master_disable;
55 
56 /* master_vars_init - initialize from global Postfix configuration file */
57 
58 void    master_vars_init(void)
59 {
60     char   *path;
61     static const CONFIG_STR_TABLE str_table[] = {
62 	VAR_MASTER_DISABLE, DEF_MASTER_DISABLE, &var_master_disable, 0, 0,
63 	0,
64     };
65     static const CONFIG_INT_TABLE int_table[] = {
66 	VAR_PROC_LIMIT, DEF_PROC_LIMIT, &var_proc_limit, 1, 0,
67 	0,
68     };
69     static const CONFIG_TIME_TABLE time_table[] = {
70 	VAR_THROTTLE_TIME, DEF_THROTTLE_TIME, &var_throttle_time, 1, 0,
71 	0,
72     };
73     static char *saved_inet_protocols;
74     static char *saved_queue_dir;
75     static char *saved_config_dir;
76     static const MASTER_STR_WATCH str_watch_table[] = {
77 	VAR_CONFIG_DIR, &var_config_dir, &saved_config_dir, 0, 0,
78 	VAR_QUEUE_DIR, &var_queue_dir, &saved_queue_dir, 0, 0,
79 	VAR_INET_PROTOCOLS, &var_inet_protocols, &saved_inet_protocols, 0, 0,
80 	/* XXX Add inet_interfaces here after this code is burned in. */
81 	0,
82     };
83 
84     /*
85      * Flush existing main.cf settings, so that we handle deleted main.cf
86      * settings properly.
87      */
88     mail_conf_flush();
89     set_mail_conf_str(VAR_PROCNAME, var_procname);
90     mail_conf_read();
91     get_mail_conf_str_table(str_table);
92     get_mail_conf_int_table(int_table);
93     get_mail_conf_time_table(time_table);
94     path = concatenate(var_config_dir, "/", MASTER_CONF_FILE, (char *) 0);
95     fset_master_ent(path);
96     myfree(path);
97 
98     /*
99      * Look for parameter changes that require special attention.
100      */
101     master_str_watch(str_watch_table);
102 }
103