From nobody Fri Dec 16 16:02:14 2022 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 4NYYlB6sG2z1CdNj; Fri, 16 Dec 2022 16:02:14 +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 "R3" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 4NYYlB6NDpz3HHn; Fri, 16 Dec 2022 16:02:14 +0000 (UTC) (envelope-from git@FreeBSD.org) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1671206534; 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=wGOL71ULFwHMF7cyJIx40r3AH5JgMEGOelVhuwdxZKY=; b=ByXmdy6k/ewt8OYjT790MGZlK9exmIZnJzd2etLU5Ra9ENdBCIk/QJxLHrPthU3VczJ00K rojgDCi0Z9ely8786mrA+bRSQGWSUPMEqYKXZ7bBfBJUSVSi+aSwOx0dENzLD30LP8VkYI TxLhNsNuueti+CxhmJtdego9dB3LTdTXJ6Io/BqcY9rfwDOwWEhdOZcqrQz4lWW9cIOiH+ q5+PNXA/CkWclxEoAYCrfFw0NtFsu3XtadA7KyPUbAus6OgFc+CbVpCAxf/Fv4a9pJdqdt G4flDEmh1f14qUfWmQW3w86E8uF/ZlE79jNFOM6d7hEbt4ZkMTvVv4XlQjhrTA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1671206534; 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=wGOL71ULFwHMF7cyJIx40r3AH5JgMEGOelVhuwdxZKY=; b=sdCdMcqbIf/OlJ9pU40wrTVgMEtgePPO4Az+YvHjsVDGbbOuRZhfYkY6VVs7PMdouhwmrm Y8FNj71/dOzHa5PWQke9gC+MdT2lGeXe4WGlVHxt/auJgNPkj/lJr3eWTqcUyFDPgQAl4O eYe4bhLN2Lv3dAo94o91P7lKgAlLtRuHeNWSDQqckbygbCQD7nckhy8KURLICYxwKS9nUY PmOeUherfAycQhYe5CF8pVAzCOlLcJCYdONPXHGYQfXqf5BEhXqZGG5x0PKjz7xgBTuuPD Hm2kBruN/ceQ97lOwAZG98ct4M5rxGskY+UOXKEldJwWnINxW48E+d/fOSS9fg== ARC-Authentication-Results: i=1; mx1.freebsd.org; none ARC-Seal: i=1; s=dkim; d=freebsd.org; t=1671206534; a=rsa-sha256; cv=none; b=xfygtU/qvivdt9rbEbj1QiWYVmrq34mqvvXKPGymHB4cOs5cLjJAE+4Ugz9QMcNZABVwaC jcs5xNjlGDP/R4QhlHyriMSFkHYM+ssm+HtO8B6W5EvJZZlrTxb11TWdmAxZMBMcV7wYPb zs/e9shz2hcBKB1P0ZNgHD0pK4J+TMxkj3W6ChBGiPkM8zYn6AgvoKbKNtWxtQCzeox7VE RezR/cTTaTboFHt9l0Aso8FT0HjrqjoScNi3rMfbioYY+fVpQEcJmUhh1SwcmKnA8MC7vZ cb6eBk9jNuzL+p8HegAnc8vybG0ESFJ6NBGiAi/vZaTArhstNk5Hi7zXcqFUWg== 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 4NYYlB5StRzJcy; Fri, 16 Dec 2022 16:02:14 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from gitrepo.freebsd.org ([127.0.1.44]) by gitrepo.freebsd.org (8.16.1/8.16.1) with ESMTP id 2BGG2EFu040487; Fri, 16 Dec 2022 16:02:14 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.16.1/8.16.1/Submit) id 2BGG2E0c040486; Fri, 16 Dec 2022 16:02:14 GMT (envelope-from git) Date: Fri, 16 Dec 2022 16:02:14 GMT Message-Id: <202212161602.2BGG2E0c040486@gitrepo.freebsd.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-main@FreeBSD.org From: Mark Johnston Subject: git: a9e7a44c2436 - main - makefs: Add some validation of ZFS pool names 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: Sender: owner-dev-commits-src-main@freebsd.org X-BeenThere: dev-commits-src-main@freebsd.org MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit X-Git-Committer: markj X-Git-Repository: src X-Git-Refname: refs/heads/main X-Git-Reftype: branch X-Git-Commit: a9e7a44c243671647180160fc448a3ef3950f55c Auto-Submitted: auto-generated X-ThisMailContainsUnwantedMimeParts: N The branch main has been updated by markj: URL: https://cgit.FreeBSD.org/src/commit/?id=a9e7a44c243671647180160fc448a3ef3950f55c commit a9e7a44c243671647180160fc448a3ef3950f55c Author: Mark Johnston AuthorDate: 2022-12-16 15:25:35 +0000 Commit: Mark Johnston CommitDate: 2022-12-16 15:30:58 +0000 makefs: Add some validation of ZFS pool names Reported by: imp --- usr.sbin/makefs/zfs.c | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/usr.sbin/makefs/zfs.c b/usr.sbin/makefs/zfs.c index b92d08734d59..e86f838e8b5c 100644 --- a/usr.sbin/makefs/zfs.c +++ b/usr.sbin/makefs/zfs.c @@ -33,6 +33,7 @@ #include #include +#include #include #include #include @@ -215,6 +216,19 @@ zfs_check_opts(fsinfo_t *fsopts) if (zfs->poolname == NULL) errx(1, "a pool name must be specified"); + if (!isalpha(zfs->poolname[0])) + errx(1, "the pool name must begin with a letter"); + for (size_t i = 0, len = strlen(zfs->poolname); i < len; i++) { + if (!isalnum(zfs->poolname[i]) && zfs->poolname[i] != '_') + errx(1, "invalid character '%c' in pool name", + zfs->poolname[i]); + } + if (strcmp(zfs->poolname, "mirror") == 0 || + strcmp(zfs->poolname, "raidz") == 0 || + strcmp(zfs->poolname, "draid") == 0) { + errx(1, "pool name '%s' is reserved and cannot be used", + zfs->poolname); + } if (zfs->rootpath == NULL) easprintf(&zfs->rootpath, "/%s", zfs->poolname);