diff --git a/usr.sbin/ctld/ctl.conf.5 b/usr.sbin/ctld/ctl.conf.5 --- a/usr.sbin/ctld/ctl.conf.5 +++ b/usr.sbin/ctld/ctl.conf.5 @@ -567,7 +567,7 @@ "iqn.2012-06.com.example:target1" { auth-group = ag0 - portal-group { name = pg0 } + portal-group = pg0 lun = [ { number = 0, name = example_1 }, { 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 @@ -191,6 +191,20 @@ const ucl_object_t *portal_group, *auth_group; const char *ag_name; + /* + * If the value is a single string, assume it is a + * portal-group name. + */ + if (obj->type == UCL_STRING) + return (target_add_portal_group(ucl_object_tostring(obj), + NULL)); + + if (obj->type != UCL_OBJECT) { + log_warnx("portal-group section in target \"%s\" must be " + "an object or string", t_name); + return (false); + } + portal_group = ucl_object_find_key(obj, "name"); if (!portal_group || portal_group->type != UCL_STRING) { log_warnx("portal-group section in target \"%s\" is missing " @@ -884,11 +898,6 @@ } if (strcmp(key, "portal-group") == 0) { - if (obj->type == UCL_OBJECT) { - if (!uclparse_target_portal_group(name, obj)) - goto fail; - } - if (obj->type == UCL_ARRAY) { while ((tmp = ucl_iterate_object(obj, &it2, true))) { @@ -896,6 +905,9 @@ tmp)) goto fail; } + } else { + if (!uclparse_target_portal_group(name, obj)) + goto fail; } }