projects
/
apps
/
pfixtools.git
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
Fix stats of tests.
[apps/pfixtools.git]
/
postlicyd
/
config.c
diff --git
a/postlicyd/config.c
b/postlicyd/config.c
index
e971e15
..
d4131f1
100644
(file)
--- a/
postlicyd/config.c
+++ b/
postlicyd/config.c
@@
-72,9
+72,18
@@
config_param_register("ehlo_filter");
*/
config_param_register("verify_filter");
*/
config_param_register("verify_filter");
+
+/* Where to bind the server.
+ */
+config_param_register("port");
+
+
+static config_t *global_config = NULL;
+
static inline config_t *config_new(void)
{
config_t *config = p_new(config_t, 1);
static inline config_t *config_new(void)
{
config_t *config = p_new(config_t, 1);
+ global_config = config;
return config;
}
return config;
}
@@
-92,9
+101,17
@@
void config_delete(config_t **config)
if (*config) {
config_close(*config);
p_delete(config);
if (*config) {
config_close(*config);
p_delete(config);
+ global_config = NULL;
}
}
}
}
+static void config_exit()
+{
+ if (global_config) {
+ config_delete(&global_config);
+ }
+}
+module_exit(config_exit);
static bool config_second_pass(config_t *config)
{
static bool config_second_pass(config_t *config)
{
@@
-121,6
+138,11
@@
static bool config_second_pass(config_t *config)
}
ok = false;
}
ok = false;
+#define PARSE_CHECK(Expr, Fmt, ...) \
+ if (!(Expr)) { \
+ err(Fmt, ##__VA_ARGS__); \
+ return false; \
+ }
foreach (filter_param_t *param, config->params) {
switch (param->type) {
#define CASE(Param, State) \
foreach (filter_param_t *param, config->params) {
switch (param->type) {
#define CASE(Param, State) \
@@
-128,6
+150,8
@@
static bool config_second_pass(config_t *config)
ok = true; \
config->entry_points[SMTP_ ## State] \
= filter_find_with_name(&config->filters, param->value); \
ok = true; \
config->entry_points[SMTP_ ## State] \
= filter_find_with_name(&config->filters, param->value); \
+ PARSE_CHECK(config->entry_points[SMTP_ ## State] >= 0, \
+ "invalid filter name %s", param->value); \
break;
CASE(CLIENT, CONNECT)
CASE(EHLO, EHLO)
break;
CASE(CLIENT, CONNECT)
CASE(EHLO, EHLO)
@@
-139,13
+163,14
@@
static bool config_second_pass(config_t *config)
CASE(VERIFY, VRFY)
CASE(ETRN, ETRN)
#undef CASE
CASE(VERIFY, VRFY)
CASE(ETRN, ETRN)
#undef CASE
+ FILTER_PARAM_PARSE_INT(PORT, config->port);
default: break;
}
}}
array_deep_wipe(config->params, filter_params_wipe);
if (!ok) {
default: break;
}
}}
array_deep_wipe(config->params, filter_params_wipe);
if (!ok) {
-
syslog(LOG_ERR,
"no entry point defined");
+
err(
"no entry point defined");
}
return ok;
}
return ok;
@@
-174,7
+199,7
@@
static bool config_load(config_t *config)
linep = p = map.map;
#define READ_LOG(Lev, Fmt, ...) \
linep = p = map.map;
#define READ_LOG(Lev, Fmt, ...) \
-
syslog(LOG_ ## Lev, "config file %s:%d:%d: " Fmt, config->filename,
\
+
__log(LOG_ ## Lev, "config file %s:%d:%d: " Fmt, config->filename,
\
line + 1, p - linep + 1, ##__VA_ARGS__)
#define READ_ERROR(Fmt, ...) \
do { \
line + 1, p - linep + 1, ##__VA_ARGS__)
#define READ_ERROR(Fmt, ...) \
do { \
@@
-378,7
+403,7
@@
ok:
return true;
badeof:
return true;
badeof:
-
syslog(LOG_ERR,
"Unexpected end of file");
+
err(
"Unexpected end of file");
error:
if (filter.name) {
error:
if (filter.name) {