~ubuntu-branches/ubuntu/vivid/postfix/vivid

« back to all changes in this revision

Viewing changes to src/postconf/postconf_builtin.c

  • Committer: Package Import Robot
  • Author(s): LaMont Jones, LaMont Jones, localization folks
  • Date: 2014-02-11 07:44:30 UTC
  • mfrom: (1.1.41)
  • Revision ID: package-import@ubuntu.com-20140211074430-91tdwgjriazawdz4
Tags: 2.11.0-1
[LaMont Jones]

* New upstream release: 2.11.0

[localization folks]

* l10n: Updated German translations.  Closes: #734893 (Helge Kreutzmann)

Show diffs side-by-side

added added

removed removed

Lines of Context:
2
2
/* NAME
3
3
/*      postconf_builtin 3
4
4
/* SUMMARY
5
 
/*      built-in parameter support
 
5
/*      built-in main.cf parameter support
6
6
/* SYNOPSIS
7
7
/*      #include <postconf.h>
8
8
/*
9
 
/*      void    register_builtin_parameters(procname, pid)
 
9
/*      void    pcf_register_builtin_parameters(procname, pid)
10
10
/*      const char *procname;
11
11
/*      pid_t   pid;
12
12
/* DESCRIPTION
13
 
/*      register_builtin_parameters() initializes the global parameter
14
 
/*      name space and adds all built-in parameter information.
 
13
/*      pcf_register_builtin_parameters() initializes the global
 
14
/*      main.cf parameter name space and adds all built-in parameter
 
15
/*      information.
15
16
/*
16
17
/*      Arguments:
17
18
/*.IP procname
86
87
  * Support for built-in parameters: lookup tables generated by scanning
87
88
  * actual C source files.
88
89
  */
89
 
static const CONFIG_TIME_TABLE time_table[] = {
 
90
static const CONFIG_TIME_TABLE pcf_time_table[] = {
90
91
#include "time_table.h"
91
92
    0,
92
93
};
93
94
 
94
 
static const CONFIG_BOOL_TABLE bool_table[] = {
 
95
static const CONFIG_BOOL_TABLE pcf_bool_table[] = {
95
96
#include "bool_table.h"
96
97
    0,
97
98
};
98
99
 
99
 
static const CONFIG_INT_TABLE int_table[] = {
 
100
static const CONFIG_INT_TABLE pcf_int_table[] = {
100
101
#include "int_table.h"
101
102
    0,
102
103
};
103
104
 
104
 
static const CONFIG_STR_TABLE str_table[] = {
 
105
static const CONFIG_STR_TABLE pcf_str_table[] = {
105
106
#include "str_table.h"
106
107
#include "install_table.h"
107
108
    0,
108
109
};
109
110
 
110
 
static const CONFIG_RAW_TABLE raw_table[] = {
 
111
static const CONFIG_RAW_TABLE pcf_raw_table[] = {
111
112
#include "raw_table.h"
112
113
    0,
113
114
};
114
115
 
115
 
static const CONFIG_NINT_TABLE nint_table[] = {
 
116
static const CONFIG_NINT_TABLE pcf_nint_table[] = {
116
117
#include "nint_table.h"
117
118
    0,
118
119
};
119
120
 
120
 
static const CONFIG_NBOOL_TABLE nbool_table[] = {
 
121
static const CONFIG_NBOOL_TABLE pcf_nbool_table[] = {
121
122
#include "nbool_table.h"
122
123
    0,
123
124
};
124
125
 
125
 
static const CONFIG_LONG_TABLE long_table[] = {
 
126
static const CONFIG_LONG_TABLE pcf_long_table[] = {
126
127
#include "long_table.h"
127
128
    0,
128
129
};
130
131
 /*
131
132
  * Legacy parameters for backwards compatibility.
132
133
  */
133
 
static const CONFIG_STR_TABLE legacy_str_table[] = {
 
134
static const CONFIG_STR_TABLE pcf_legacy_str_table[] = {
134
135
    {"virtual_maps", ""},
135
136
    {"fallback_relay", ""},
136
137
    {"authorized_verp_clients", ""},
146
147
  * Important: if the evaluation of a parameter default value has any side
147
148
  * effects, then those side effects must happen only once.
148
149
  */
149
 
static const char *pc_check_myhostname(void);
150
 
static const char *pc_check_mydomainname(void);
151
 
static const char *pc_mynetworks(void);
 
150
static const char *pcf_check_myhostname(void);
 
151
static const char *pcf_check_mydomainname(void);
 
152
static const char *pcf_mynetworks(void);
152
153
 
153
154
#include "str_fn_vars.h"
154
155
 
155
 
static const CONFIG_STR_FN_TABLE str_fn_table[] = {
 
156
static const CONFIG_STR_FN_TABLE pcf_str_fn_table[] = {
156
157
#include "str_fn_table.h"
157
158
    0,
158
159
};
165
166
  * Important: if the evaluation of a parameter default value has any side
166
167
  * effects, then those side effects must happen only once.
167
168
  */
168
 
static CONFIG_STR_TABLE adhoc_procname = {VAR_PROCNAME};
169
 
static CONFIG_INT_TABLE adhoc_pid = {VAR_PID};
 
169
static CONFIG_STR_TABLE pcf_adhoc_procname = {VAR_PROCNAME};
 
170
static CONFIG_INT_TABLE pcf_adhoc_pid = {VAR_PID};
170
171
 
171
172
#define STR(x) vstring_str(x)
172
173
 
173
 
/* pc_check_myhostname - lookup hostname and validate */
 
174
/* pcf_check_myhostname - lookup hostname and validate */
174
175
 
175
 
static const char *pc_check_myhostname(void)
 
176
static const char *pcf_check_myhostname(void)
176
177
{
177
178
    static const char *name;
178
179
    const char *dot;
197
198
    return (name);
198
199
}
199
200
 
200
 
/* get_myhostname - look up and store my hostname */
 
201
/* pcf_get_myhostname - look up and store my hostname */
201
202
 
202
 
static void get_myhostname(void)
 
203
static void pcf_get_myhostname(void)
203
204
{
204
205
    const char *name;
205
206
 
206
207
    if ((name = mail_conf_lookup_eval(VAR_MYHOSTNAME)) == 0)
207
 
        name = pc_check_myhostname();
 
208
        name = pcf_check_myhostname();
208
209
    var_myhostname = mystrdup(name);
209
210
}
210
211
 
211
 
/* pc_check_mydomainname - lookup domain name and validate */
 
212
/* pcf_check_mydomainname - lookup domain name and validate */
212
213
 
213
 
static const char *pc_check_mydomainname(void)
 
214
static const char *pcf_check_mydomainname(void)
214
215
{
215
216
    static const char *domain;
216
217
    char   *dot;
226
227
     * actually is a domain name ("foo.com").
227
228
     */
228
229
    if (var_myhostname == 0)
229
 
        get_myhostname();
 
230
        pcf_get_myhostname();
230
231
    if ((dot = strchr(var_myhostname, '.')) == 0 || strchr(dot + 1, '.') == 0)
231
232
        return (domain = DEF_MYDOMAIN);
232
233
    return (domain = mystrdup(dot + 1));
233
234
}
234
235
 
235
 
/* pc_mynetworks - lookup network address list */
 
236
/* pcf_mynetworks - lookup network address list */
236
237
 
237
 
static const char *pc_mynetworks(void)
 
238
static const char *pcf_mynetworks(void)
238
239
{
239
240
    static const char *networks;
240
241
    INET_PROTO_INFO *proto_info;
247
248
        return (networks);
248
249
 
249
250
    if (var_inet_interfaces == 0) {
250
 
        if ((cmd_mode & SHOW_DEFS)
 
251
        if ((pcf_cmd_mode & PCF_SHOW_DEFS)
251
252
            || (junk = mail_conf_lookup_eval(VAR_INET_INTERFACES)) == 0)
252
253
            junk = DEF_INET_INTERFACES;
253
254
        var_inet_interfaces = mystrdup(junk);
254
255
    }
255
256
    if (var_mynetworks_style == 0) {
256
 
        if ((cmd_mode & SHOW_DEFS)
 
257
        if ((pcf_cmd_mode & PCF_SHOW_DEFS)
257
258
            || (junk = mail_conf_lookup_eval(VAR_MYNETWORKS_STYLE)) == 0)
258
259
            junk = DEF_MYNETWORKS_STYLE;
259
260
        var_mynetworks_style = mystrdup(junk);
260
261
    }
261
262
    if (var_inet_protocols == 0) {
262
 
        if ((cmd_mode & SHOW_DEFS)
 
263
        if ((pcf_cmd_mode & PCF_SHOW_DEFS)
263
264
            || (junk = mail_conf_lookup_eval(VAR_INET_PROTOCOLS)) == 0)
264
265
            junk = DEF_INET_PROTOCOLS;
265
266
        var_inet_protocols = mystrdup(junk);
268
269
    return (networks = mystrdup(mynetworks()));
269
270
}
270
271
 
271
 
/* convert_bool_parameter - get boolean parameter string value */
 
272
/* pcf_conv_bool_parameter - get boolean parameter string value */
272
273
 
273
 
static const char *convert_bool_parameter(char *ptr)
 
274
static const char *pcf_conv_bool_parameter(char *ptr)
274
275
{
275
276
    CONFIG_BOOL_TABLE *cbt = (CONFIG_BOOL_TABLE *) ptr;
276
277
 
277
278
    return (cbt->defval ? "yes" : "no");
278
279
}
279
280
 
280
 
/* convert_time_parameter - get relative time parameter string value */
 
281
/* pcf_conv_time_parameter - get relative time parameter string value */
281
282
 
282
 
static const char *convert_time_parameter(char *ptr)
 
283
static const char *pcf_conv_time_parameter(char *ptr)
283
284
{
284
285
    CONFIG_TIME_TABLE *ctt = (CONFIG_TIME_TABLE *) ptr;
285
286
 
286
287
    return (ctt->defval);
287
288
}
288
289
 
289
 
/* convert_int_parameter - get integer parameter string value */
 
290
/* pcf_conv_int_parameter - get integer parameter string value */
290
291
 
291
 
static const char *convert_int_parameter(char *ptr)
 
292
static const char *pcf_conv_int_parameter(char *ptr)
292
293
{
293
294
    CONFIG_INT_TABLE *cit = (CONFIG_INT_TABLE *) ptr;
294
295
 
295
 
    return (STR(vstring_sprintf(param_string_buf, "%d", cit->defval)));
 
296
    return (STR(vstring_sprintf(pcf_param_string_buf, "%d", cit->defval)));
296
297
}
297
298
 
298
 
/* convert_str_parameter - get string parameter string value */
 
299
/* pcf_conv_str_parameter - get string parameter string value */
299
300
 
300
 
static const char *convert_str_parameter(char *ptr)
 
301
static const char *pcf_conv_str_parameter(char *ptr)
301
302
{
302
303
    CONFIG_STR_TABLE *cst = (CONFIG_STR_TABLE *) ptr;
303
304
 
304
305
    return (cst->defval);
305
306
}
306
307
 
307
 
/* convert_str_fn_parameter - get string-function parameter string value */
 
308
/* pcf_conv_str_fn_parameter - get string-function parameter string value */
308
309
 
309
 
static const char *convert_str_fn_parameter(char *ptr)
 
310
static const char *pcf_conv_str_fn_parameter(char *ptr)
310
311
{
311
312
    CONFIG_STR_FN_TABLE *cft = (CONFIG_STR_FN_TABLE *) ptr;
312
313
 
313
314
    return (cft->defval());
314
315
}
315
316
 
316
 
/* convert_raw_parameter - get raw string parameter string value */
 
317
/* pcf_conv_raw_parameter - get raw string parameter string value */
317
318
 
318
 
static const char *convert_raw_parameter(char *ptr)
 
319
static const char *pcf_conv_raw_parameter(char *ptr)
319
320
{
320
321
    CONFIG_RAW_TABLE *rst = (CONFIG_RAW_TABLE *) ptr;
321
322
 
322
323
    return (rst->defval);
323
324
}
324
325
 
325
 
/* convert_nint_parameter - get new integer parameter string value */
 
326
/* pcf_conv_nint_parameter - get new integer parameter string value */
326
327
 
327
 
static const char *convert_nint_parameter(char *ptr)
 
328
static const char *pcf_conv_nint_parameter(char *ptr)
328
329
{
329
330
    CONFIG_NINT_TABLE *rst = (CONFIG_NINT_TABLE *) ptr;
330
331
 
331
332
    return (rst->defval);
332
333
}
333
334
 
334
 
/* convert_nbool_parameter - get new boolean parameter string value */
 
335
/* pcf_conv_nbool_parameter - get new boolean parameter string value */
335
336
 
336
 
static const char *convert_nbool_parameter(char *ptr)
 
337
static const char *pcf_conv_nbool_parameter(char *ptr)
337
338
{
338
339
    CONFIG_NBOOL_TABLE *bst = (CONFIG_NBOOL_TABLE *) ptr;
339
340
 
340
341
    return (bst->defval);
341
342
}
342
343
 
343
 
/* convert_long_parameter - get long parameter string value */
 
344
/* pcf_conv_long_parameter - get long parameter string value */
344
345
 
345
 
static const char *convert_long_parameter(char *ptr)
 
346
static const char *pcf_conv_long_parameter(char *ptr)
346
347
{
347
348
    CONFIG_LONG_TABLE *clt = (CONFIG_LONG_TABLE *) ptr;
348
349
 
349
 
    return (STR(vstring_sprintf(param_string_buf, "%ld", clt->defval)));
 
350
    return (STR(vstring_sprintf(pcf_param_string_buf, "%ld", clt->defval)));
350
351
}
351
352
 
352
 
/* register_builtin_parameters - add built-ins to the global name space */
 
353
/* pcf_register_builtin_parameters - add built-ins to the global name space */
353
354
 
354
 
void    register_builtin_parameters(const char *procname, pid_t pid)
 
355
void    pcf_register_builtin_parameters(const char *procname, pid_t pid)
355
356
{
356
 
    const char *myname = "register_builtin_parameters";
 
357
    const char *myname = "pcf_register_builtin_parameters";
357
358
    const CONFIG_TIME_TABLE *ctt;
358
359
    const CONFIG_BOOL_TABLE *cbt;
359
360
    const CONFIG_INT_TABLE *cit;
367
368
    /*
368
369
     * Sanity checks.
369
370
     */
370
 
    if (param_table != 0)
 
371
    if (pcf_param_table != 0)
371
372
        msg_panic("%s: global parameter table is already initialized", myname);
372
373
 
373
374
    /*
374
375
     * Initialize the global parameter table.
375
376
     */
376
 
    param_table = PC_PARAM_TABLE_CREATE(1000);
 
377
    pcf_param_table = PCF_PARAM_TABLE_CREATE(1000);
377
378
 
378
379
    /*
379
380
     * Add the built-in parameters to the global name space. The class
380
381
     * (built-in) is tentative; some parameters are actually service-defined,
381
382
     * but they have their own default value.
382
383
     */
383
 
    for (ctt = time_table; ctt->name; ctt++)
384
 
        PC_PARAM_TABLE_ENTER(param_table, ctt->name, PC_PARAM_FLAG_BUILTIN,
385
 
                             (char *) ctt, convert_time_parameter);
386
 
    for (cbt = bool_table; cbt->name; cbt++)
387
 
        PC_PARAM_TABLE_ENTER(param_table, cbt->name, PC_PARAM_FLAG_BUILTIN,
388
 
                             (char *) cbt, convert_bool_parameter);
389
 
    for (cit = int_table; cit->name; cit++)
390
 
        PC_PARAM_TABLE_ENTER(param_table, cit->name, PC_PARAM_FLAG_BUILTIN,
391
 
                             (char *) cit, convert_int_parameter);
392
 
    for (cst = str_table; cst->name; cst++)
393
 
        PC_PARAM_TABLE_ENTER(param_table, cst->name, PC_PARAM_FLAG_BUILTIN,
394
 
                             (char *) cst, convert_str_parameter);
395
 
    for (cft = str_fn_table; cft->name; cft++)
396
 
        PC_PARAM_TABLE_ENTER(param_table, cft->name, PC_PARAM_FLAG_BUILTIN,
397
 
                             (char *) cft, convert_str_fn_parameter);
398
 
    for (rst = raw_table; rst->name; rst++)
399
 
        PC_PARAM_TABLE_ENTER(param_table, rst->name,
400
 
                             PC_PARAM_FLAG_BUILTIN | PC_PARAM_FLAG_RAW,
401
 
                             (char *) rst, convert_raw_parameter);
402
 
    for (nst = nint_table; nst->name; nst++)
403
 
        PC_PARAM_TABLE_ENTER(param_table, nst->name, PC_PARAM_FLAG_BUILTIN,
404
 
                             (char *) nst, convert_nint_parameter);
405
 
    for (bst = nbool_table; bst->name; bst++)
406
 
        PC_PARAM_TABLE_ENTER(param_table, bst->name, PC_PARAM_FLAG_BUILTIN,
407
 
                             (char *) bst, convert_nbool_parameter);
408
 
    for (lst = long_table; lst->name; lst++)
409
 
        PC_PARAM_TABLE_ENTER(param_table, lst->name, PC_PARAM_FLAG_BUILTIN,
410
 
                             (char *) lst, convert_long_parameter);
 
384
    for (ctt = pcf_time_table; ctt->name; ctt++)
 
385
        PCF_PARAM_TABLE_ENTER(pcf_param_table, ctt->name,
 
386
                              PCF_PARAM_FLAG_BUILTIN, (char *) ctt,
 
387
                              pcf_conv_time_parameter);
 
388
    for (cbt = pcf_bool_table; cbt->name; cbt++)
 
389
        PCF_PARAM_TABLE_ENTER(pcf_param_table, cbt->name,
 
390
                              PCF_PARAM_FLAG_BUILTIN, (char *) cbt,
 
391
                              pcf_conv_bool_parameter);
 
392
    for (cit = pcf_int_table; cit->name; cit++)
 
393
        PCF_PARAM_TABLE_ENTER(pcf_param_table, cit->name,
 
394
                              PCF_PARAM_FLAG_BUILTIN, (char *) cit,
 
395
                              pcf_conv_int_parameter);
 
396
    for (cst = pcf_str_table; cst->name; cst++)
 
397
        PCF_PARAM_TABLE_ENTER(pcf_param_table, cst->name,
 
398
                              PCF_PARAM_FLAG_BUILTIN, (char *) cst,
 
399
                              pcf_conv_str_parameter);
 
400
    for (cft = pcf_str_fn_table; cft->name; cft++)
 
401
        PCF_PARAM_TABLE_ENTER(pcf_param_table, cft->name,
 
402
                              PCF_PARAM_FLAG_BUILTIN, (char *) cft,
 
403
                              pcf_conv_str_fn_parameter);
 
404
    for (rst = pcf_raw_table; rst->name; rst++)
 
405
        PCF_PARAM_TABLE_ENTER(pcf_param_table, rst->name,
 
406
                              PCF_PARAM_FLAG_BUILTIN | PCF_PARAM_FLAG_RAW,
 
407
                              (char *) rst, pcf_conv_raw_parameter);
 
408
    for (nst = pcf_nint_table; nst->name; nst++)
 
409
        PCF_PARAM_TABLE_ENTER(pcf_param_table, nst->name,
 
410
                              PCF_PARAM_FLAG_BUILTIN, (char *) nst,
 
411
                              pcf_conv_nint_parameter);
 
412
    for (bst = pcf_nbool_table; bst->name; bst++)
 
413
        PCF_PARAM_TABLE_ENTER(pcf_param_table, bst->name,
 
414
                              PCF_PARAM_FLAG_BUILTIN, (char *) bst,
 
415
                              pcf_conv_nbool_parameter);
 
416
    for (lst = pcf_long_table; lst->name; lst++)
 
417
        PCF_PARAM_TABLE_ENTER(pcf_param_table, lst->name,
 
418
                              PCF_PARAM_FLAG_BUILTIN, (char *) lst,
 
419
                              pcf_conv_long_parameter);
411
420
 
412
421
    /*
413
422
     * Register legacy parameters (used as a backwards-compatible migration
414
423
     * aid).
415
424
     */
416
 
    for (cst = legacy_str_table; cst->name; cst++)
417
 
        PC_PARAM_TABLE_ENTER(param_table, cst->name, PC_PARAM_FLAG_LEGACY,
418
 
                             (char *) cst, convert_str_parameter);
 
425
    for (cst = pcf_legacy_str_table; cst->name; cst++)
 
426
        PCF_PARAM_TABLE_ENTER(pcf_param_table, cst->name,
 
427
                              PCF_PARAM_FLAG_LEGACY, (char *) cst,
 
428
                              pcf_conv_str_parameter);
419
429
 
420
430
    /*
421
431
     * Register parameters whose default value is normally initialized by
422
432
     * ad-hoc code.
423
433
     */
424
 
    adhoc_procname.defval = mystrdup(procname);
425
 
    PC_PARAM_TABLE_ENTER(param_table, adhoc_procname.name,
426
 
                         PC_PARAM_FLAG_BUILTIN | PC_PARAM_FLAG_READONLY,
427
 
                         (char *) &adhoc_procname, convert_str_parameter);
428
 
    adhoc_pid.defval = pid;
429
 
    PC_PARAM_TABLE_ENTER(param_table, adhoc_pid.name,
430
 
                         PC_PARAM_FLAG_BUILTIN | PC_PARAM_FLAG_READONLY,
431
 
                         (char *) &adhoc_pid, convert_int_parameter);
 
434
    pcf_adhoc_procname.defval = mystrdup(procname);
 
435
    PCF_PARAM_TABLE_ENTER(pcf_param_table, pcf_adhoc_procname.name,
 
436
                          PCF_PARAM_FLAG_BUILTIN | PCF_PARAM_FLAG_READONLY,
 
437
                          (char *) &pcf_adhoc_procname, pcf_conv_str_parameter);
 
438
    pcf_adhoc_pid.defval = pid;
 
439
    PCF_PARAM_TABLE_ENTER(pcf_param_table, pcf_adhoc_pid.name,
 
440
                          PCF_PARAM_FLAG_BUILTIN | PCF_PARAM_FLAG_READONLY,
 
441
                          (char *) &pcf_adhoc_pid, pcf_conv_int_parameter);
432
442
}