diff options
Diffstat (limited to 'src/acl.c')
-rw-r--r-- | src/acl.c | 42 |
1 files changed, 34 insertions, 8 deletions
@@ -360,16 +360,22 @@ parse_acl_line (grecs_locus_t *locus, int allow, pies_acl_t acl, return 0; } +#define ACL_TAG_NONE 0 +#define ACL_TAG_IGNORE 1 +#define ACL_TAG_OPTIONAL 2 +#define ACL_TAG_REQUIRED 3 + int _acl_common_section_parser (enum grecs_callback_command cmd, grecs_locus_t *locus, grecs_value_t *value, pies_acl_t *pacl, - int need_tag) + int flag) { pies_acl_t acl; grecs_locus_t defn_loc; const char *tag = NULL; + int has_value = 0; switch (cmd) { @@ -381,9 +387,26 @@ _acl_common_section_parser (enum grecs_callback_command cmd, grecs_error (locus, 0, _("ACL name must be a string")); return 1; } - tag = value->v.string; + has_value = value->v.string != NULL; + } + if (has_value) + { + switch (flag) + { + case ACL_TAG_NONE: + grecs_error (locus, 0, _("ACL name is not expected")); + return 1; + + case ACL_TAG_IGNORE: + grecs_warning (locus, 0, _("ACL name is ignored")); + break; + + case ACL_TAG_OPTIONAL: + case ACL_TAG_REQUIRED: + tag = value->v.string; + } } - else if (need_tag) + else if (flag == ACL_TAG_REQUIRED) { grecs_error (locus, 0, _("missing ACL name")); return 1; @@ -398,7 +421,8 @@ _acl_common_section_parser (enum grecs_callback_command cmd, _("location of the previous definition")); return 1; } - *pacl = acl; + if (pacl) + *pacl = acl; break; case grecs_callback_section_end: @@ -415,9 +439,11 @@ acl_section_parser (enum grecs_callback_command cmd, grecs_value_t *value, void *cb_data) { - if (_acl_common_section_parser (cmd, locus, value, varptr, 1) == 0) + int rc = _acl_common_section_parser (cmd, locus, value, varptr, + ACL_TAG_NONE); + if (rc == 0) *(void**)cb_data = *(pies_acl_t*)varptr; - return 0; + return rc; } int @@ -427,8 +453,8 @@ defacl_section_parser (enum grecs_callback_command cmd, grecs_value_t *value, void *cb_data) { - _acl_common_section_parser (cmd, locus, value, cb_data, 0); - return 0; + return _acl_common_section_parser (cmd, locus, value, cb_data, + ACL_TAG_REQUIRED); } static int |