diff --git a/usr.sbin/ctld/uclparse.c b/usr.sbin/ctld/uclparse.c --- a/usr.sbin/ctld/uclparse.c +++ b/usr.sbin/ctld/uclparse.c @@ -425,66 +425,90 @@ } if (strcmp(key, "chap") == 0) { - if (obj->type != UCL_ARRAY) { - log_warnx("\"chap\" property of " - "auth-group \"%s\" is not an array", + if (obj->type == UCL_OBJECT) { + if (!uclparse_chap(auth_group, obj)) + return (false); + } else if (obj->type == UCL_ARRAY) { + it2 = NULL; + while ((tmp = ucl_iterate_object(obj, &it2, + true))) { + if (!uclparse_chap(auth_group, tmp)) + return (false); + } + } else { + log_warnx("\"chap\" property of auth-group " + "\"%s\" is not an array or object", name); return (false); } - - it2 = NULL; - while ((tmp = ucl_iterate_object(obj, &it2, true))) { - if (!uclparse_chap(auth_group, tmp)) - return (false); - } } if (strcmp(key, "chap-mutual") == 0) { - if (obj->type != UCL_ARRAY) { + if (obj->type == UCL_OBJECT) { + if (!uclparse_chap_mutual(auth_group, obj)) + return (false); + } else if (obj->type == UCL_ARRAY) { + it2 = NULL; + while ((tmp = ucl_iterate_object(obj, &it2, + true))) { + if (!uclparse_chap_mutual(auth_group, + tmp)) + return (false); + } + } else { log_warnx("\"chap-mutual\" property of " - "auth-group \"%s\" is not an array", + "auth-group \"%s\" is not an array or object", name); return (false); } - - it2 = NULL; - while ((tmp = ucl_iterate_object(obj, &it2, true))) { - if (!uclparse_chap_mutual(auth_group, tmp)) - return (false); - } } if (strcmp(key, "initiator-name") == 0) { - if (obj->type != UCL_ARRAY) { - log_warnx("\"initiator-name\" property of " - "auth-group \"%s\" is not an array", - name); - return (false); - } - - it2 = NULL; - while ((tmp = ucl_iterate_object(obj, &it2, true))) { - const char *value = ucl_object_tostring(tmp); + if (obj->type == UCL_STRING) { + const char *value = ucl_object_tostring(obj); if (!auth_name_new(auth_group, value)) return (false); - } - } + } else if (obj->type == UCL_ARRAY) { + it2 = NULL; + while ((tmp = ucl_iterate_object(obj, &it2, + true))) { + const char *value = + ucl_object_tostring(tmp); - if (strcmp(key, "initiator-portal") == 0) { - if (obj->type != UCL_ARRAY) { - log_warnx("\"initiator-portal\" property of " - "auth-group \"%s\" is not an array", + if (!auth_name_new(auth_group, value)) + return (false); + } + } else { + log_warnx("\"initiator-name\" property of " + "auth-group \"%s\" is not an array or string", name); return (false); } - it2 = NULL; - while ((tmp = ucl_iterate_object(obj, &it2, true))) { - const char *value = ucl_object_tostring(tmp); + } + + if (strcmp(key, "initiator-portal") == 0) { + if (obj->type == UCL_STRING) { + const char *value = ucl_object_tostring(obj); if (!auth_portal_new(auth_group, value)) return (false); + } else if (obj->type == UCL_ARRAY) { + it2 = NULL; + while ((tmp = ucl_iterate_object(obj, &it2, + true))) { + const char *value = + ucl_object_tostring(tmp); + + if (!auth_portal_new(auth_group, value)) + return (false); + } + } else { + log_warnx("\"initiator-portal\" property of " + "auth-group \"%s\" is not an array or string", + name); + return (false); } } } @@ -754,25 +778,80 @@ } if (strcmp(key, "chap") == 0) { - if (!uclparse_target_chap(target, obj)) + if (obj->type == UCL_OBJECT) { + if (!uclparse_target_chap(target, obj)) + return (false); + } else if (obj->type == UCL_ARRAY) { + while ((tmp = ucl_iterate_object(obj, &it2, + true))) { + if (!uclparse_target_chap(target, tmp)) + return (false); + } + } else { + log_warnx("\"chap\" property of target " + "\"%s\" is not an array or object", + target->t_name); return (false); + } } if (strcmp(key, "chap-mutual") == 0) { - if (!uclparse_target_chap_mutual(target, obj)) + if (obj->type == UCL_OBJECT) { + if (!uclparse_target_chap_mutual(target, obj)) + return (false); + } else if (obj->type == UCL_ARRAY) { + while ((tmp = ucl_iterate_object(obj, &it2, + true))) { + if (!uclparse_target_chap_mutual(target, + tmp)) + return (false); + } + } else { + log_warnx("\"chap-mutual\" property of target " + "\"%s\" is not an array or object", + target->t_name); return (false); + } } if (strcmp(key, "initiator-name") == 0) { - if (!target_add_initiator_name(target, - ucl_object_tostring(obj))) + if (obj->type == UCL_STRING) { + if (!target_add_initiator_name(target, + ucl_object_tostring(obj))) + return (false); + } else if (obj->type == UCL_ARRAY) { + while ((tmp = ucl_iterate_object(obj, &it2, + true))) { + if (!target_add_initiator_name(target, + ucl_object_tostring(tmp))) + return (false); + } + } else { + log_warnx("\"initiator-name\" property of " + "target \"%s\" is not an array or string", + target->t_name); return (false); + } } if (strcmp(key, "initiator-portal") == 0) { - if (!target_add_initiator_portal(target, - ucl_object_tostring(obj))) + if (obj->type == UCL_STRING) { + if (!target_add_initiator_portal(target, + ucl_object_tostring(obj))) + return (false); + } else if (obj->type == UCL_ARRAY) { + while ((tmp = ucl_iterate_object(obj, &it2, + true))) { + if (!target_add_initiator_portal(target, + ucl_object_tostring(tmp))) + return (false); + } + } else { + log_warnx("\"initiator-portal\" property of " + "target \"%s\" is not an array or string", + target->t_name); return (false); + } } if (strcmp(key, "portal-group") == 0) {