Page MenuHomeFreeBSD

D48935.diff
No OneTemporary

D48935.diff

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
@@ -420,66 +420,91 @@
}
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(name, obj))
+ return (false);
+ } else if (obj->type == UCL_ARRAY) {
+ it2 = NULL;
+ while ((tmp = ucl_iterate_object(obj, &it2,
+ true))) {
+ if (!uclparse_chap(name, tmp))
+ return (false);
+ }
+ } else {
+ log_warnx("\"chap\" property of auth-group "
+ "\"%s\" is not an array or object",
name);
goto fail;
}
-
- it2 = NULL;
- while ((tmp = ucl_iterate_object(obj, &it2, true))) {
- if (!uclparse_chap(name, tmp))
- goto fail;
- }
}
if (strcmp(key, "chap-mutual") == 0) {
- if (obj->type != UCL_ARRAY) {
+ if (obj->type == UCL_OBJECT) {
+ if (!uclparse_chap_mutual(name, obj))
+ return (false);
+ } else if (obj->type == UCL_ARRAY) {
+ it2 = NULL;
+ while ((tmp = ucl_iterate_object(obj, &it2,
+ true))) {
+ if (!uclparse_chap_mutual(name, 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);
goto fail;
}
-
- it2 = NULL;
- while ((tmp = ucl_iterate_object(obj, &it2, true))) {
- if (!uclparse_chap_mutual(name, tmp))
- goto fail;
- }
}
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);
- goto fail;
- }
-
- 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_group_add_initiator_name(value))
- goto fail;
- }
- }
+ 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_group_add_initiator_name(
+ value))
+ return (false);
+ }
+ } else {
+ log_warnx("\"initiator-name\" property of "
+ "auth-group \"%s\" is not an array or string",
name);
goto fail;
}
- 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_group_add_initiator_portal(value))
- goto fail;
+ 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_group_add_initiator_portal(
+ value))
+ return (false);
+ }
+ } else {
+ log_warnx("\"initiator-portal\" property of "
+ "auth-group \"%s\" is not an array or string",
+ name);
+ return (false);
}
}
}
@@ -746,25 +771,80 @@
}
if (strcmp(key, "chap") == 0) {
- if (!uclparse_target_chap(name, obj))
- goto fail;
+ if (obj->type == UCL_OBJECT) {
+ if (!uclparse_target_chap(name, obj))
+ return (false);
+ } else if (obj->type == UCL_ARRAY) {
+ while ((tmp = ucl_iterate_object(obj, &it2,
+ true))) {
+ if (!uclparse_target_chap(name, tmp))
+ return (false);
+ }
+ } else {
+ log_warnx("\"chap\" property of target "
+ "\"%s\" is not an array or object",
+ name);
+ return (false);
+ }
}
if (strcmp(key, "chap-mutual") == 0) {
- if (!uclparse_target_chap_mutual(name, obj))
- goto fail;
+ if (obj->type == UCL_OBJECT) {
+ if (!uclparse_target_chap_mutual(name, obj))
+ return (false);
+ } else if (obj->type == UCL_ARRAY) {
+ while ((tmp = ucl_iterate_object(obj, &it2,
+ true))) {
+ if (!uclparse_target_chap_mutual(name,
+ tmp))
+ return (false);
+ }
+ } else {
+ log_warnx("\"chap-mutual\" property of target "
+ "\"%s\" is not an array or object",
+ name);
+ return (false);
+ }
}
if (strcmp(key, "initiator-name") == 0) {
- if (!target_add_initiator_name(
- ucl_object_tostring(obj)))
- goto fail;
+ if (obj->type == UCL_STRING) {
+ if (!target_add_initiator_name(
+ 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(
+ ucl_object_tostring(tmp)))
+ return (false);
+ }
+ } else {
+ log_warnx("\"initiator-name\" property of "
+ "target \"%s\" is not an array or string",
+ name);
+ return (false);
+ }
}
if (strcmp(key, "initiator-portal") == 0) {
- if (!target_add_initiator_portal(
- ucl_object_tostring(obj)))
- goto fail;
+ if (obj->type == UCL_STRING) {
+ if (!target_add_initiator_portal(
+ 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(
+ ucl_object_tostring(tmp)))
+ return (false);
+ }
+ } else {
+ log_warnx("\"initiator-portal\" property of "
+ "target \"%s\" is not an array or string",
+ name);
+ return (false);
+ }
}
if (strcmp(key, "portal-group") == 0) {

File Metadata

Mime Type
text/plain
Expires
Sat, Feb 22, 4:03 PM (1 h, 30 m)
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
16746466
Default Alt Text
D48935.diff (5 KB)

Event Timeline