diff options
author | Sergey Poznyakoff <gray@gnu.org> | 2019-06-06 07:21:43 +0300 |
---|---|---|
committer | Sergey Poznyakoff <gray@gnu.org> | 2019-06-06 08:24:28 +0300 |
commit | b220b5a367469c571358c34ea0df813522e99485 (patch) | |
tree | 600e8f26555a359b9d5297b1d566717a1ec78182 | |
parent | 44efb0cda486e2614603e6dd78b0c93407f63c3b (diff) | |
download | pies-b220b5a367469c571358c34ea0df813522e99485.tar.gz pies-b220b5a367469c571358c34ea0df813522e99485.tar.bz2 |
Update the grecs submodule
* configure.ac (GRECS_SETUP): Request the tree-api
* grecs: Pull a0c096190f
* lib/envop.c (environ_set): Call wordsplit_free unconditionally.
* lib/grecsasrt.c (assert_grecs_value_type)
(assert_scalar_stmt): Remove.
(conf_callback_url): Switch to tree-api.
* lib/grecsasrt.h: Likewise.
* src/acl.c: Rewrite grecs callbacks in the tree API style.
Use grecs assertions.
* src/acl.h: Likewise.
* src/meta1parse.c: Likewise.
* src/pies.c: Likewise.
* src/piesctl.c: Likewise.
* src/comp.c (component_finish): Check whether the "command" statement
was used.
-rw-r--r-- | configure.ac | 2 | ||||
m--------- | grecs | 0 | ||||
-rw-r--r-- | lib/envop.c | 3 | ||||
-rw-r--r-- | lib/grecsasrt.c | 40 | ||||
-rw-r--r-- | lib/grecsasrt.h | 7 | ||||
-rw-r--r-- | src/acl.c | 38 | ||||
-rw-r--r-- | src/acl.h | 12 | ||||
-rw-r--r-- | src/comp.c | 7 | ||||
-rw-r--r-- | src/meta1parse.c | 2 | ||||
-rw-r--r-- | src/pies.c | 183 | ||||
-rw-r--r-- | src/piesctl.c | 16 |
11 files changed, 157 insertions, 153 deletions
diff --git a/configure.ac b/configure.ac index ccfd9fc..814ac00 100644 --- a/configure.ac +++ b/configure.ac @@ -76,3 +76,3 @@ gl_INIT # Grecs -GRECS_SETUP([grecs],[tests git2chg getopt json sockaddr-list parser-meta1]) +GRECS_SETUP([grecs],[tree-api tests git2chg getopt json sockaddr-list parser-meta1]) GRECS_HOST_PROJECT_INCLUDES='-I$(top_srcdir)/gnu -I$(top_builddir)/gnu' diff --git a/grecs b/grecs -Subproject 1fa2dd2c6587822ff682581643499c3c3b78c9e +Subproject a0c096190fa57b12b9b95ada70f51cab402c74c diff --git a/lib/envop.c b/lib/envop.c index 80a8b6c..ce24b92 100644 --- a/lib/envop.c +++ b/lib/envop.c @@ -188,4 +188,3 @@ environ_set (environ_t *env, char const *name, char const *value) int ec = errno; - if (ws.ws_errno != WRDSE_USAGE) /* FIXME */ - wordsplit_free (&ws); + wordsplit_free (&ws); errno = ec; diff --git a/lib/grecsasrt.c b/lib/grecsasrt.c index 8ebd581..c217cec 100644 --- a/lib/grecsasrt.c +++ b/lib/grecsasrt.c @@ -25,41 +25,11 @@ int -assert_grecs_value_type (grecs_locus_t *locus, - const grecs_value_t *value, int type) -{ - if (GRECS_VALUE_EMPTY_P (value)) - { - grecs_error (locus, 0, _("expected %s"), - grecs_data_type_string (type)); - return 1; - } - if (value->type != type) - { - grecs_error (locus, 0, _("expected %s, but found %s"), - grecs_data_type_string (type), - grecs_data_type_string (value->type)); - return 1; - } - return 0; -} - -int -assert_scalar_stmt (grecs_locus_t *locus, enum grecs_callback_command cmd) -{ - if (cmd != grecs_callback_set_value) - { - grecs_error (locus, 0, _("unexpected block statement")); - return 1; - } - return 0; -} - -int conf_callback_url (enum grecs_callback_command cmd, - grecs_locus_t *locus, - void *varptr, grecs_value_t *value, void *cb_data) + grecs_node_t *node, + void *varptr, void *cb_data) { + grecs_locus_t *locus = &node->locus; + grecs_value_t *value = node->v.value; struct pies_url *url; - if (assert_scalar_stmt (locus, cmd) - || assert_grecs_value_type (locus, value, GRECS_TYPE_STRING)) + if (grecs_assert_node_value_type (cmd, node, GRECS_TYPE_STRING)) return 1; diff --git a/lib/grecsasrt.h b/lib/grecsasrt.h index 4b3d2d6..f9fe432 100644 --- a/lib/grecsasrt.h +++ b/lib/grecsasrt.h @@ -16,7 +16,4 @@ -int assert_grecs_value_type (grecs_locus_t *locus, - const grecs_value_t *value, int type); -int assert_scalar_stmt (grecs_locus_t *locus, enum grecs_callback_command cmd); int conf_callback_url (enum grecs_callback_command cmd, - grecs_locus_t *locus, - void *varptr, grecs_value_t *value, void *cb_data); + grecs_node_t *node, + void *varptr, void *cb_data); @@ -185,3 +185,3 @@ _parse_sockaddr (struct acl_entry *entry, const grecs_value_t *value) - if (assert_grecs_value_type (&entry->locus, value, GRECS_TYPE_STRING)) + if (grecs_assert_value_type (value, GRECS_TYPE_STRING, &entry->locus)) return 1; @@ -433,3 +433,3 @@ _parse_acl (struct acl_entry *entry, size_t argc, grecs_value_t **argv) { - if (assert_grecs_value_type (&entry->locus, argv[0], GRECS_TYPE_STRING)) + if (grecs_assert_value_type (argv[0], GRECS_TYPE_STRING, &entry->locus)) return 1; @@ -572,3 +572,3 @@ _acl_common_section_parser (enum grecs_callback_command cmd, case grecs_callback_set_value: - if (assert_grecs_value_type (&value->locus, value, GRECS_TYPE_STRING)) + if (grecs_assert_value_type (value, GRECS_TYPE_STRING, &value->locus)) return 0; @@ -594,7 +594,7 @@ int acl_section_parser (enum grecs_callback_command cmd, - grecs_locus_t *locus, - void *varptr, - grecs_value_t *value, - void *cb_data) + grecs_node_t *node, + void *varptr, void *cb_data) { + grecs_locus_t *locus = &node->locus; + grecs_value_t *value = node->v.value; int rc = _acl_common_section_parser (cmd, locus, value, varptr, @@ -608,7 +608,7 @@ int defacl_section_parser (enum grecs_callback_command cmd, - grecs_locus_t *locus, - void *varptr, - grecs_value_t *value, - void *cb_data) + grecs_node_t *node, + void *varptr, void *cb_data) { + grecs_locus_t *locus = &node->locus; + grecs_value_t *value = node->v.value; return _acl_common_section_parser (cmd, locus, value, cb_data, @@ -619,7 +619,7 @@ static int allow_cb (enum grecs_callback_command cmd, - grecs_locus_t *locus, - void *varptr, - grecs_value_t *value, - void *cb_data) + grecs_node_t *node, + void *varptr, void *cb_data) { + grecs_locus_t *locus = &node->locus; + grecs_value_t *value = node->v.value; pies_acl_t acl = varptr; @@ -637,7 +637,7 @@ static int deny_cb (enum grecs_callback_command cmd, - grecs_locus_t *locus, - void *varptr, - grecs_value_t *value, - void *cb_data) + grecs_node_t *node, + void *varptr, void *cb_data) { + grecs_locus_t *locus = &node->locus; + grecs_value_t *value = node->v.value; pies_acl_t acl = varptr; @@ -42,10 +42,6 @@ extern struct grecs_keyword acl_keywords[]; extern int acl_section_parser (enum grecs_callback_command cmd, - grecs_locus_t *locus, - void *varptr, - grecs_value_t *value, - void *cb_data); + grecs_node_t *node, + void *varptr, void *cb_data); extern int defacl_section_parser (enum grecs_callback_command cmd, - grecs_locus_t *locus, - void *varptr, - grecs_value_t *value, - void *cb_data); + grecs_node_t *node, + void *varptr, void *cb_data); @@ -738,2 +738,9 @@ component_finish (struct component *comp, grecs_locus_t *locus) { + if (!comp->command) + { + grecs_error (locus, 0, "%s", _("no 'command' statement")); + component_free (comp); + return; + } + if (comp->flags & CF_SHELL) diff --git a/src/meta1parse.c b/src/meta1parse.c index 6cf97ca..a8a16ee 100644 --- a/src/meta1parse.c +++ b/src/meta1parse.c @@ -112,3 +112,3 @@ substatement_find (struct grecs_node *node, char const *name, int type, - if (assert_grecs_value_type (&np->v.value->locus, np->v.value, type)) + if (grecs_assert_value_type (np->v.value, type, &np->v.value->locus)) return substatement_error; @@ -181,6 +181,8 @@ stderr_closed_p (void) static int -_cb_action (enum grecs_callback_command cmd, - grecs_locus_t *locus, - void *varptr, grecs_value_t *value, void *cb_data) +_cb_action (enum grecs_callback_command cmd, grecs_node_t *node, + void *varptr, void *cb_data) { + grecs_locus_t *locus = &node->locus; + grecs_value_t *value = node->v.value; + enum return_action *pact = varptr; @@ -193,4 +195,3 @@ _cb_action (enum grecs_callback_command cmd, - if (assert_scalar_stmt (locus, cmd) - || assert_grecs_value_type (locus, value, GRECS_TYPE_STRING)) + if (grecs_assert_node_value_type (cmd, node, GRECS_TYPE_STRING)) return 1; @@ -436,4 +437,4 @@ _get_array_arg (grecs_value_t *val, int num, grecs_locus_t *locus) { - if (assert_grecs_value_type (locus, val->v.arg.v[num], - GRECS_TYPE_STRING) == 0) + if (grecs_assert_value_type (val->v.arg.v[num], GRECS_TYPE_STRING, + locus) == 0) return val->v.arg.v[num]->v.string; @@ -451,3 +452,3 @@ _get_list_arg (grecs_value_t *val, int num, grecs_locus_t *locus) } - else if (assert_grecs_value_type (locus, elt, GRECS_TYPE_STRING) == 0) + else if (grecs_assert_value_type (elt, GRECS_TYPE_STRING, locus) == 0) return elt->v.string; @@ -458,6 +459,8 @@ static int return_code_section_parser (enum grecs_callback_command cmd, - grecs_locus_t *locus, - void *varptr, - grecs_value_t *value, void *cb_data) + grecs_node_t *node, + void *varptr, void *cb_data) { + grecs_locus_t *locus = &node->locus; + grecs_value_t *value = node->v.value; + struct component *comp = varptr; @@ -515,3 +518,3 @@ config_array_to_argv (grecs_value_t *val, grecs_locus_t *locus, size_t *pargc) { - if (assert_grecs_value_type (locus, val->v.arg.v[i], GRECS_TYPE_STRING) + if (grecs_assert_value_type (val->v.arg.v[i], GRECS_TYPE_STRING, locus) == 0) @@ -527,5 +530,8 @@ static int _cb_umask (enum grecs_callback_command cmd, - grecs_locus_t *locus, - void *varptr, grecs_value_t *value, void *cb_data) + grecs_node_t *node, + void *varptr, void *cb_data) { + grecs_locus_t *locus = &node->locus; + grecs_value_t *value = node->v.value; + mode_t *pmode = varptr; @@ -534,4 +540,3 @@ _cb_umask (enum grecs_callback_command cmd, - if (assert_scalar_stmt (locus, cmd) - || assert_grecs_value_type (locus, value, GRECS_TYPE_STRING)) + if (grecs_assert_node_value_type (cmd, node, GRECS_TYPE_STRING)) return 1; @@ -697,6 +702,7 @@ static int cb_env_section_parser (enum grecs_callback_command cmd, - grecs_locus_t *locus, - void *varptr, - grecs_value_t *value, void *cb_data) + grecs_node_t *node, + void *varptr, void *cb_data) { + grecs_locus_t *locus = &node->locus; + grecs_value_t *value = node->v.value; struct component *comp = varptr; @@ -706,3 +712,2 @@ cb_env_section_parser (enum grecs_callback_command cmd, case grecs_callback_section_begin: - //FIXME *(struct component **) cb_data = comp; @@ -711,3 +716,2 @@ cb_env_section_parser (enum grecs_callback_command cmd, case grecs_callback_section_end: - //FIXME break; @@ -722,5 +726,7 @@ static int _cb_env_clear (enum grecs_callback_command cmd, - grecs_locus_t *locus, - void *varptr, grecs_value_t *value, void *cb_data) + grecs_node_t *node, + void *varptr, void *cb_data) { + grecs_locus_t *locus = &node->locus; + grecs_value_t *value = node->v.value; struct component *comp = varptr; @@ -728,4 +734,3 @@ _cb_env_clear (enum grecs_callback_command cmd, - if (assert_scalar_stmt (locus, cmd) - || assert_grecs_value_type (locus, value, GRECS_TYPE_STRING)) + if (grecs_assert_node_value_type (cmd, node, GRECS_TYPE_STRING)) return 1; @@ -743,5 +748,7 @@ static int _cb_env_keep (enum grecs_callback_command cmd, - grecs_locus_t *locus, - void *varptr, grecs_value_t *value, void *cb_data) + grecs_node_t *node, + void *varptr, void *cb_data) { + grecs_locus_t *locus = &node->locus; + grecs_value_t *value = node->v.value; struct component *comp = varptr; @@ -749,4 +756,3 @@ _cb_env_keep (enum grecs_callback_command cmd, - if (assert_scalar_stmt (locus, cmd) - || assert_grecs_value_type (locus, value, GRECS_TYPE_STRING)) + if (grecs_assert_node_value_type (cmd, node, GRECS_TYPE_STRING)) return 1; @@ -764,5 +770,7 @@ static int _cb_env_set (enum grecs_callback_command cmd, - grecs_locus_t *locus, - void *varptr, grecs_value_t *value, void *cb_data) + grecs_node_t *node, + void *varptr, void *cb_data) { + grecs_locus_t *locus = &node->locus; + grecs_value_t *value = node->v.value; struct component *comp = varptr; @@ -770,4 +778,3 @@ _cb_env_set (enum grecs_callback_command cmd, - if (assert_scalar_stmt (locus, cmd) - || assert_grecs_value_type (locus, value, GRECS_TYPE_STRING)) + if (grecs_assert_node_value_type (cmd, node, GRECS_TYPE_STRING)) return 1; @@ -783,5 +790,7 @@ static int _cb_env_unset (enum grecs_callback_command cmd, - grecs_locus_t *locus, - void *varptr, grecs_value_t *value, void *cb_data) + grecs_node_t *node, + void *varptr, void *cb_data) { + grecs_locus_t *locus = &node->locus; + grecs_value_t *value = node->v.value; struct component *comp = varptr; @@ -789,4 +798,3 @@ _cb_env_unset (enum grecs_callback_command cmd, - if (assert_scalar_stmt (locus, cmd) - || assert_grecs_value_type (locus, value, GRECS_TYPE_STRING)) + if (grecs_assert_node_value_type (cmd, node, GRECS_TYPE_STRING)) return 1; @@ -884,8 +892,10 @@ static int cb_syslog_facility (enum grecs_callback_command cmd, - grecs_locus_t *locus, - void *varptr, grecs_value_t *value, void *cb_data) + grecs_node_t *node, + void *varptr, void *cb_data) { + grecs_locus_t *locus = &node->locus; + grecs_value_t *value = node->v.value; const char *str; - if (assert_grecs_value_type (locus, value, GRECS_TYPE_STRING)) + if (grecs_assert_node_value_type (cmd, node, GRECS_TYPE_STRING)) return 1; @@ -909,5 +919,7 @@ static int _cb_redir (enum grecs_callback_command cmd, - grecs_locus_t *locus, - void *varptr, grecs_value_t *value, void *cb_data) + grecs_node_t *node, + void *varptr, void *cb_data) { + grecs_locus_t *locus = &node->locus; + grecs_value_t *value = node->v.value; struct redirector *rp = varptr; @@ -939,4 +951,4 @@ _cb_redir (enum grecs_callback_command cmd, case GRECS_TYPE_ARRAY: - if (assert_grecs_value_type (locus, value->v.arg.v[0], - GRECS_TYPE_STRING)) + if (grecs_assert_value_type (value->v.arg.v[0], GRECS_TYPE_STRING, + locus)) return 1; @@ -954,4 +966,4 @@ _cb_redir (enum grecs_callback_command cmd, } - if (assert_grecs_value_type (locus, value->v.arg.v[1], - GRECS_TYPE_STRING)) + if (grecs_assert_value_type (value->v.arg.v[1], + GRECS_TYPE_STRING, locus)) return 1; @@ -1016,7 +1028,9 @@ static int _cb_socket_type (enum grecs_callback_command cmd, - grecs_locus_t *locus, - void *varptr, grecs_value_t *value, void *cb_data) + grecs_node_t *node, + void *varptr, void *cb_data) { - if (assert_scalar_stmt (locus, cmd) - || assert_grecs_value_type (locus, value, GRECS_TYPE_STRING)) + grecs_locus_t *locus = &node->locus; + grecs_value_t *value = node->v.value; + + if (grecs_assert_node_value_type (cmd, node, GRECS_TYPE_STRING)) return 1; @@ -1056,9 +1070,10 @@ static int _cb_mode (enum grecs_callback_command cmd, - grecs_locus_t *locus, - void *varptr, grecs_value_t *value, void *cb_data) + grecs_node_t *node, + void *varptr, void *cb_data) { + grecs_locus_t *locus = &node->locus; + grecs_value_t *value = node->v.value; int res; - if (assert_scalar_stmt (locus, cmd) - || assert_grecs_value_type (locus, value, GRECS_TYPE_STRING)) + if (grecs_assert_node_value_type (cmd, node, GRECS_TYPE_STRING)) return 1; @@ -1073,5 +1088,7 @@ static int _cb_limits (enum grecs_callback_command cmd, - grecs_locus_t *locus, - void *varptr, grecs_value_t *value, void *cb_data) + grecs_node_t *node, + void *varptr, void *cb_data) { + grecs_locus_t *locus = &node->locus; + grecs_value_t *value = node->v.value; limits_record_t *plrec = varptr; @@ -1079,4 +1096,3 @@ _cb_limits (enum grecs_callback_command cmd, - if (assert_scalar_stmt (locus, cmd) - || assert_grecs_value_type (locus, value, GRECS_TYPE_STRING)) + if (grecs_assert_node_value_type (cmd, node, GRECS_TYPE_STRING)) return 1; @@ -1127,5 +1143,7 @@ static int _cb_flags (enum grecs_callback_command cmd, - grecs_locus_t *locus, - void *varptr, grecs_value_t *value, void *cb_data) + grecs_node_t *node, + void *varptr, void *cb_data) { + grecs_locus_t *locus = &node->locus; + grecs_value_t *value = node->v.value; int *flags = varptr; @@ -1149,3 +1167,3 @@ _cb_flags (enum grecs_callback_command cmd, const grecs_value_t *vp = ep->data; - if (assert_grecs_value_type (locus, vp, GRECS_TYPE_STRING)) + if (grecs_assert_value_type (vp, GRECS_TYPE_STRING, locus)) return 1; @@ -1170,8 +1188,10 @@ static int _cb_initdefault (enum grecs_callback_command cmd, - grecs_locus_t *locus, - void *varptr, grecs_value_t *value, void *cb_data) + grecs_node_t *node, + void *varptr, void *cb_data) { + grecs_locus_t *locus = &node->locus; + grecs_value_t *value = node->v.value; int *val = varptr; - if (assert_grecs_value_type (locus, value, GRECS_TYPE_STRING)) + if (grecs_assert_node_value_type (cmd, node, GRECS_TYPE_STRING)) return 1; @@ -1193,8 +1213,10 @@ static int _cb_runlevels (enum grecs_callback_command cmd, - grecs_locus_t *locus, - void *varptr, grecs_value_t *value, void *cb_data) + grecs_node_t *node, + void *varptr, void *cb_data) { + grecs_locus_t *locus = &node->locus; + grecs_value_t *value = node->v.value; char **sptr = varptr, *p; - if (assert_grecs_value_type (locus, value, GRECS_TYPE_STRING)) + if (grecs_assert_node_value_type (cmd, node, GRECS_TYPE_STRING)) return 1; @@ -1465,5 +1487,7 @@ static int component_section_parser (enum grecs_callback_command cmd, - grecs_locus_t *locus, - void *varptr, grecs_value_t *value, void *cb_data) + grecs_node_t *node, + void *varptr, void *cb_data) { + grecs_locus_t *locus = &node->locus; + grecs_value_t *value = node->v.value; struct component *comp; @@ -1474,3 +1498,8 @@ component_section_parser (enum grecs_callback_command cmd, case grecs_callback_section_begin: - if (assert_grecs_value_type (locus, value, GRECS_TYPE_STRING)) + if (GRECS_VALUE_EMPTY_P (value)) + { + grecs_error (locus, 0, _("missing tag")); + return 1; + } + if (grecs_assert_value_type (value, GRECS_TYPE_STRING, locus)) return 1; @@ -1559,6 +1588,7 @@ static int _cb_include_meta1 (enum grecs_callback_command cmd, - grecs_locus_t *locus, - void *varptr, grecs_value_t *value, void *cb_data) + grecs_node_t *node, + void *varptr, void *cb_data) { - if (assert_grecs_value_type (locus, value, GRECS_TYPE_STRING)) + grecs_value_t *value = node->v.value; + if (grecs_assert_node_value_type (cmd, node, GRECS_TYPE_STRING)) return 1; @@ -1570,6 +1600,7 @@ static int _cb_include_inetd (enum grecs_callback_command cmd, - grecs_locus_t *locus, - void *varptr, grecs_value_t *value, void *cb_data) + grecs_node_t *node, + void *varptr, void *cb_data) { - if (assert_grecs_value_type (locus, value, GRECS_TYPE_STRING)) + grecs_value_t *value = node->v.value; + if (grecs_assert_node_value_type (cmd, node, GRECS_TYPE_STRING)) return 1; diff --git a/src/piesctl.c b/src/piesctl.c index 4c777d7..390ccfc 100644 --- a/src/piesctl.c +++ b/src/piesctl.c @@ -82,6 +82,8 @@ static int callback_instance (enum grecs_callback_command cmd, - grecs_locus_t *locus, - void *varptr, - grecs_value_t *value, void *cb_data) + grecs_node_t *node, + void *varptr, void *cb_data) { + grecs_locus_t *locus = &node->locus; + grecs_value_t *value = node->v.value; + switch (cmd) @@ -94,3 +96,3 @@ callback_instance (enum grecs_callback_command cmd, } - if (assert_grecs_value_type (&value->locus, value, GRECS_TYPE_STRING)) + if (grecs_assert_value_type (value, GRECS_TYPE_STRING, locus)) return 1; @@ -186,4 +188,6 @@ parse_config (void) { - assert_grecs_value_type (&node->locus, - node->v.value, GRECS_TYPE_STRING); + if (grecs_assert_value_type (node->v.value, GRECS_TYPE_STRING, + &node->locus)) + exit (EX_CONFIG); + if (pies_url_create (&client.url, node->v.value->v.string)) |