From nobody Wed Feb 26 15:15:50 2025 X-Original-To: dev-commits-src-main@mlmmj.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mlmmj.nyi.freebsd.org (Postfix) with ESMTP id 4Z2yj30C7bz5qHDw; Wed, 26 Feb 2025 15:15:51 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from mxrelay.nyi.freebsd.org (mxrelay.nyi.freebsd.org [IPv6:2610:1c1:1:606c::19:3]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256 client-signature RSA-PSS (4096 bits) client-digest SHA256) (Client CN "mxrelay.nyi.freebsd.org", Issuer "R10" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 4Z2yj25J5Fz3NnK; Wed, 26 Feb 2025 15:15:50 +0000 (UTC) (envelope-from git@FreeBSD.org) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1740582950; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding; bh=To7qEX4jQ24pKwV+vFq9nOOndfARqetS/AErrlDDT4c=; b=xlDnfNz7hJg+JANnZsej63GF4SbBKGvqS45UZekAFgqSrc3hjfcDV4XB7D4/Zg6pNb+tfn y8X9gfqQai7IhjXvH4Lnk3hXA3nbjrn23qtyBMbYmV6He/ky+I4pWL0npXD8EfCHGQshbR IxagdE8It5nc62DaiRjUiSDZ614KODY2zUxd6b6SEsVrB007BouLImhnsQqJHpXQ2+mRq7 3YIyJfy2IxHZHgGTfcrhtjMoSQ9/1HOgeB9uWuqCZJTmtImKndxiR4XXcQx2Bzble60+YA 8naMVB3kWxqLS0ZoY8A1z7ALXTE3+rCUoOIDTwO36Lacx7+lRuvH1pzjhz7L7A== ARC-Seal: i=1; s=dkim; d=freebsd.org; t=1740582950; a=rsa-sha256; cv=none; b=RAXOScEt/RUvdIaly5sOc9uxvJp2R/WKzPWKlJsKAoGVEc2S4h+GNnsPEVRuNkzsjscuP4 3Nkj2/RC79n2d37cZO7P+x8yx5/u3lJx96ufPJMK8n3KxYUw1lMsvZa2BdVQVcbhVpAmOx ZMgqigSwa0Ah9iZj2gLnycvEyzxFHF8ZuBHI8cPc8Fzj9CkK1UiX11CRC6TC4cvpkP+uaU T6XbuYXuda78dnzMap77J07PfCf9TqhuHdjmMyatWAPFNraMalBkGZolL+cCWoMq2eEHYp VXJvPOsdT1ppIqNnDaIujOJd5t32jrka4OtW37ANjf5UB4HetfinQcZlBZZw6w== ARC-Authentication-Results: i=1; mx1.freebsd.org; none ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1740582950; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding; bh=To7qEX4jQ24pKwV+vFq9nOOndfARqetS/AErrlDDT4c=; b=KO2TX05sMW8d+uRJ3Q88eGF2AzDsa82bp5udEUVhZDeNLEfA6hNZU07Rk/d1voUEOThBKM bKiygdS4g1az5LBpYaRX6OqVW//0EyTrMZBbJGdJcBKpfKtEYEVx8Naxy4HS/j7JoeLZzj vR0miLYEA9JInxCxdXOHCY/mbBNdXwKY/JCdJMzUmPYCoMbH0cY3DVzL0cT+nzt6nJCBh4 zvQtTpIHBSKRx6vER1i09ubZFBfoTb/otxcJALo1zNDpOiOS8hlyC+iftI0h+xlnH+otnq f33L9COqojxIDqzbfSJfllcLHLY0x9mWZvLD/LYTSL7B4oxxheWKRSXJUQgTSw== Received: from gitrepo.freebsd.org (gitrepo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:5]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (Client did not present a certificate) by mxrelay.nyi.freebsd.org (Postfix) with ESMTPS id 4Z2yj24Wbmz1Gw5; Wed, 26 Feb 2025 15:15:50 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from gitrepo.freebsd.org ([127.0.1.44]) by gitrepo.freebsd.org (8.18.1/8.18.1) with ESMTP id 51QFFo6w033988; Wed, 26 Feb 2025 15:15:50 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.18.1/8.18.1/Submit) id 51QFFovv033985; Wed, 26 Feb 2025 15:15:50 GMT (envelope-from git) Date: Wed, 26 Feb 2025 15:15:50 GMT Message-Id: <202502261515.51QFFovv033985@gitrepo.freebsd.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-main@FreeBSD.org From: John Baldwin Subject: git: e28b758b35d0 - main - ctld: Be more consistent for auth parameters in the UCL config List-Id: Commit messages for the main branch of the src repository List-Archive: https://lists.freebsd.org/archives/dev-commits-src-main List-Help: List-Post: List-Subscribe: List-Unsubscribe: X-BeenThere: dev-commits-src-main@freebsd.org Sender: owner-dev-commits-src-main@FreeBSD.org MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit X-Git-Committer: jhb X-Git-Repository: src X-Git-Refname: refs/heads/main X-Git-Reftype: branch X-Git-Commit: e28b758b35d0f80b38c295587271ec9588040077 Auto-Submitted: auto-generated The branch main has been updated by jhb: URL: https://cgit.FreeBSD.org/src/commit/?id=e28b758b35d0f80b38c295587271ec9588040077 commit e28b758b35d0f80b38c295587271ec9588040077 Author: John Baldwin AuthorDate: 2025-02-26 15:11:30 +0000 Commit: John Baldwin CommitDate: 2025-02-26 15:11:30 +0000 ctld: Be more consistent for auth parameters in the UCL config The auth-group context required an array of entries for "chap", "chap-mutual", "initiator-name", and "initiator-portal" whereas the target context required exactly one entry (and only permitted a single entry). Allow either a single entry or an array of entries for these keywords in both the auth-group and target contexts. Sponsored by: Chelsio Communications Differential Revision: https://reviews.freebsd.org/D48935 --- usr.sbin/ctld/uclparse.c | 163 +++++++++++++++++++++++++++++++++++------------ 1 file changed, 121 insertions(+), 42 deletions(-) diff --git a/usr.sbin/ctld/uclparse.c b/usr.sbin/ctld/uclparse.c index 2dc4872bee84..e8e026247b71 100644 --- a/usr.sbin/ctld/uclparse.c +++ b/usr.sbin/ctld/uclparse.c @@ -420,66 +420,90 @@ uclparse_auth_group(const char *name, const ucl_object_t *top) } 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)) + goto fail; + } else if (obj->type == UCL_ARRAY) { + it2 = NULL; + while ((tmp = ucl_iterate_object(obj, &it2, + true))) { + if (!uclparse_chap(name, tmp)) + goto fail; + } + } 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)) + goto fail; + } else if (obj->type == UCL_ARRAY) { + it2 = NULL; + while ((tmp = ucl_iterate_object(obj, &it2, + true))) { + if (!uclparse_chap_mutual(name, tmp)) + goto fail; + } + } 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; - } - } + } 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)) + goto fail; + } + } 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; + } 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)) + goto fail; + } + } else { + log_warnx("\"initiator-portal\" property of " + "auth-group \"%s\" is not an array or string", + name); + goto fail; } } } @@ -746,25 +770,80 @@ uclparse_target(const char *name, const ucl_object_t *top) } if (strcmp(key, "chap") == 0) { - if (!uclparse_target_chap(name, obj)) + if (obj->type == UCL_OBJECT) { + if (!uclparse_target_chap(name, obj)) + goto fail; + } else if (obj->type == UCL_ARRAY) { + while ((tmp = ucl_iterate_object(obj, &it2, + true))) { + if (!uclparse_target_chap(name, tmp)) + goto fail; + } + } else { + log_warnx("\"chap\" property of target " + "\"%s\" is not an array or object", + name); goto fail; + } } if (strcmp(key, "chap-mutual") == 0) { - if (!uclparse_target_chap_mutual(name, obj)) + if (obj->type == UCL_OBJECT) { + if (!uclparse_target_chap_mutual(name, obj)) + goto fail; + } else if (obj->type == UCL_ARRAY) { + while ((tmp = ucl_iterate_object(obj, &it2, + true))) { + if (!uclparse_target_chap_mutual(name, + tmp)) + goto fail; + } + } else { + log_warnx("\"chap-mutual\" property of target " + "\"%s\" is not an array or object", + name); goto fail; + } } if (strcmp(key, "initiator-name") == 0) { - if (!target_add_initiator_name( - ucl_object_tostring(obj))) + if (obj->type == UCL_STRING) { + if (!target_add_initiator_name( + ucl_object_tostring(obj))) + goto fail; + } else if (obj->type == UCL_ARRAY) { + while ((tmp = ucl_iterate_object(obj, &it2, + true))) { + if (!target_add_initiator_name( + ucl_object_tostring(tmp))) + goto fail; + } + } else { + log_warnx("\"initiator-name\" property of " + "target \"%s\" is not an array or string", + name); goto fail; + } } if (strcmp(key, "initiator-portal") == 0) { - if (!target_add_initiator_portal( - ucl_object_tostring(obj))) + if (obj->type == UCL_STRING) { + if (!target_add_initiator_portal( + ucl_object_tostring(obj))) + goto fail; + } else if (obj->type == UCL_ARRAY) { + while ((tmp = ucl_iterate_object(obj, &it2, + true))) { + if (!target_add_initiator_portal( + ucl_object_tostring(tmp))) + goto fail; + } + } else { + log_warnx("\"initiator-portal\" property of " + "target \"%s\" is not an array or string", + name); goto fail; + } } if (strcmp(key, "portal-group") == 0) {