5
/* Postfix master - monitor main.cf changes
9
/* void master_str_watch(str_watch_table)
10
/* const MASTER_STR_WATCH *str_watch_table;
12
/* void master_int_watch(int_watch_table)
13
/* MASTER_INT_WATCH *int_watch_table;
15
/* The Postfix master daemon is a long-running process. After
16
/* main.cf is changed, some parameter changes may require that
17
/* master data structures be recomputed.
19
/* Unfortunately, some main.cf changes cannot be applied
20
/* on-the-fly, either because they require killing off existing
21
/* child processes and thus disrupt service, or because the
22
/* necessary support for on-the-fly data structure update has
23
/* not yet been implemented. Such main.cf changes trigger a
24
/* warning that they require that Postfix be stopped and
27
/* This module provides functions that monitor selected main.cf
28
/* parameters for change. The operation of these functions is
29
/* controlled by tables that specify the parameter name, the
30
/* current parameter value, a historical parameter value,
31
/* optional flags, and an optional notify call-back function.
33
/* master_str_watch() monitors string-valued parameters for
34
/* change, and master_int_watch() does the same for integer-valued
35
/* parameters. Note that master_int_watch() needs read-write
36
/* access to its argument table, while master_str_watch() needs
37
/* read-only access only.
39
/* The functions log a warning when a parameter value has
40
/* changed after re-reading main.cf, but the parameter is not
41
/* flagged in the MASTER_*_WATCH table as "updatable" with
42
/* MASTER_WATCH_FLAG_UPDATABLE.
44
/* If the parameter has a notify call-back function, then the
45
/* function is called after main.cf is read for the first time.
46
/* If the parameter is flagged as "updatable", then the function
47
/* is also called when the parameter value changes after
48
/* re-reading main.cf.
52
/* The Secure Mailer license must be distributed with this software.
55
/* IBM T.J. Watson Research
57
/* Yorktown Heights, NY 10598, USA
66
/* Utility library. */
71
/* Application-specific. */
75
/* master_str_watch - watch string-valued parameters for change */
77
void master_str_watch(const MASTER_STR_WATCH *str_watch_table)
79
const MASTER_STR_WATCH *wp;
81
for (wp = str_watch_table; wp->name != 0; wp++) {
84
* Detect changes to monitored parameter values. If a change is
85
* supported, we discard the backed up value and update it to the
86
* current value later. Otherwise we complain.
88
if (wp->backup[0] != 0
89
&& strcmp(wp->backup[0], wp->value[0]) != 0) {
90
if ((wp->flags & MASTER_WATCH_FLAG_UPDATABLE) == 0) {
91
msg_warn("ignoring %s parameter value change", wp->name);
92
msg_warn("old value: \"%s\", new value: \"%s\"",
93
wp->backup[0], wp->value[0]);
94
msg_warn("to change %s, stop and start Postfix", wp->name);
96
myfree(wp->backup[0]);
102
* Initialize the backed up parameter value, or update it if this
103
* parameter supports updates after initialization. Optionally
104
* notify the application that this parameter has changed.
106
if (wp->backup[0] == 0) {
109
wp->backup[0] = mystrdup(wp->value[0]);
114
/* master_int_watch - watch integer-valued parameters for change */
116
void master_int_watch(MASTER_INT_WATCH *int_watch_table)
118
MASTER_INT_WATCH *wp;
120
for (wp = int_watch_table; wp->name != 0; wp++) {
123
* Detect changes to monitored parameter values. If a change is
124
* supported, we discard the backed up value and update it to the
125
* current value later. Otherwise we complain.
127
if ((wp->flags & MASTER_WATCH_FLAG_ISSET) != 0
128
&& wp->backup != wp->value[0]) {
129
if ((wp->flags & MASTER_WATCH_FLAG_UPDATABLE) == 0) {
130
msg_warn("ignoring %s parameter value change", wp->name);
131
msg_warn("old value: \"%d\", new value: \"%d\"",
132
wp->backup, wp->value[0]);
133
msg_warn("to change %s, stop and start Postfix", wp->name);
135
wp->flags &= ~MASTER_WATCH_FLAG_ISSET;
140
* Initialize the backed up parameter value, or update if it this
141
* parameter supports updates after initialization. Optionally
142
* notify the application that this parameter has changed.
144
if ((wp->flags & MASTER_WATCH_FLAG_ISSET) == 0) {
147
wp->flags |= MASTER_WATCH_FLAG_ISSET;
148
wp->backup = wp->value[0];