From nobody Mon Sep 04 12:55:36 2023 X-Original-To: dev-commits-src-all@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 4RfTBw4bdYz4sZqL; Mon, 4 Sep 2023 12:55:36 +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 4RfTBw3yMmz4K3G; Mon, 4 Sep 2023 12:55:36 +0000 (UTC) (envelope-from git@FreeBSD.org) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1693832136; 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=gGTA2MN+QZKsYt8KBW5QrY7xrwdSSzydj6uaDZpf2eo=; b=uo5xxTKAYT2m8qd81rl/PKYsSJMbc2zwfMQjmviDXOirRtGr46aa2JQIqwwEtFTSicH83U u+B/rKBqkEt0ZyR6b3pBD4Efgy7r5mma3Cwnz1ckcQ8J4DnRMI9jvKlsxzsJx4GzVqRc9h YKkNp+BFCVzjM3VMbTyON7nEyhnm/bBDlCjtfCIiQSElRWNSfAbeferEgAgbFPAF5fbr7W qZ4BVR+JjsTsnXaaWwntWqdf5uvNbFLGuy5bYPLHr9YdmWTM5yed5gRZtZ5eOAc2T+uynA 9rLCC9bL6+f12C7QVnOaPXlJ8BGwqmavxePpm1UwtO0B5t4lITOatD+6clkRgw== ARC-Seal: i=1; s=dkim; d=freebsd.org; t=1693832136; a=rsa-sha256; cv=none; b=olcGgakGAAUXKsTK7Lv/Ek1DeXhS492/v778foSk87XuJjeOTWwsvo4SZE/vrsmUGj1Suc annwV99xN9UI3KpVDs3QC00+xYiUecx6jCe0QC54yhxVb9QzqM23HweBGwR41uhfpSL+gT 4fhvyEYf5xKniyqHUINU+Ulr5UDlpVk07ozEq5bwsj7PDtj/hXIL4FldzVlPoNJyLFUz9b kuSNBcvdxCdtRUK1jyIOxRo85UklJHH9qegrZ4691sWPRNE7kpLXBmR/gcboX8YIt6cekt B1tgTXKCnzZciXG18WouI3WO+Btz+g0NhQ5l4Bd5jS48ELvZs6rP/UkdthZ2vw== 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=1693832136; 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=gGTA2MN+QZKsYt8KBW5QrY7xrwdSSzydj6uaDZpf2eo=; b=id40D9tX1Fw8tHJFUMGfD0R1wBKAHZYHqIET+To5frWV7AGk9RTUUh84vuyk2DGjokAx2G 4DlQQpJjlyZiL5FHD4QiWN8svZLJqLamp/FJid6g/Pz/CWU7AF7FHneTZt9m4WofL8aTZE ES6+9BR5EeMhcxYWrQBSn2wGIwZI4nuuEyOJiZTEuuQYD+R09N5x3ogC0ea1iXDqKhYG92 uytki9lakfHdoWUgrWVZINrJYKwIBz3Fyf12OeyX6YzuJdl7sitwqMQJcy6CedLJQplknM 7dUEx0spCwwHMyAOQ7vx6U7Gz3xwzQJBB5q/UWsRyY5uqWtx+RPH8q6dLU4s7Q== 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 4RfTBw2hJHz16TS; Mon, 4 Sep 2023 12:55:36 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from gitrepo.freebsd.org ([127.0.1.44]) by gitrepo.freebsd.org (8.17.1/8.17.1) with ESMTP id 384Ctav2032896; Mon, 4 Sep 2023 12:55:36 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.17.1/8.17.1/Submit) id 384Cta8S032893; Mon, 4 Sep 2023 12:55:36 GMT (envelope-from git) Date: Mon, 4 Sep 2023 12:55:36 GMT Message-Id: <202309041255.384Cta8S032893@gitrepo.freebsd.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-branches@FreeBSD.org From: Mark Johnston Subject: git: 472fce62bb53 - stable/13 - geli tests: Add a regression test for geli setkey -J List-Id: Commit messages for all branches of the src repository List-Archive: https://lists.freebsd.org/archives/dev-commits-src-all List-Help: List-Post: List-Subscribe: List-Unsubscribe: Sender: owner-dev-commits-src-all@freebsd.org X-BeenThere: dev-commits-src-all@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/stable/13 X-Git-Reftype: branch X-Git-Commit: 472fce62bb536b00d7af98d4be73bb8efbdb169b Auto-Submitted: auto-generated The branch stable/13 has been updated by markj: URL: https://cgit.FreeBSD.org/src/commit/?id=472fce62bb536b00d7af98d4be73bb8efbdb169b commit 472fce62bb536b00d7af98d4be73bb8efbdb169b Author: Mark Johnston AuthorDate: 2023-08-28 14:58:43 +0000 Commit: Mark Johnston CommitDate: 2023-09-04 12:55:17 +0000 geli tests: Add a regression test for geli setkey -J Make sure that it can be used to change the passphrase of both attached and detached providers. PR: 254966 MFC after: 1 week Sponsored by: The FreeBSD Foundation (cherry picked from commit 2b7b09ac9675023869fddbae4911c9b674b1155a) --- tests/sys/geom/class/eli/setkey_test.sh | 59 +++++++++++++++++++++++++++++++++ 1 file changed, 59 insertions(+) diff --git a/tests/sys/geom/class/eli/setkey_test.sh b/tests/sys/geom/class/eli/setkey_test.sh index c981b6fc266b..ce3833f5fe0c 100644 --- a/tests/sys/geom/class/eli/setkey_test.sh +++ b/tests/sys/geom/class/eli/setkey_test.sh @@ -92,6 +92,64 @@ setkey_cleanup() geli_test_cleanup } +atf_test_case setkey_passphrase cleanup +setkey_passphrase_head() +{ + atf_set "descr" "geli setkey can change the passphrase for a provider" + atf_set "require.user" "root" +} +setkey_passphrase_body() +{ + geli_test_setup + + sectors=100 + md=$(attach_md -t malloc -s `expr $sectors + 1`) + + atf_check dd if=/dev/random of=rnd bs=512 count=${sectors} status=none + hash1=`dd if=rnd bs=512 count=${sectors} status=none | md5` + atf_check_equal 0 $? + atf_check dd if=/dev/random of=pass1 bs=512 count=32 status=none + atf_check dd if=/dev/random of=pass2 bs=512 count=32 status=none + atf_check dd if=/dev/random of=pass3 bs=512 count=32 status=none + + atf_check geli init -B none -J pass1 ${md} + atf_check geli attach -j pass1 ${md} + + atf_check \ + dd if=rnd of=/dev/${md}.eli bs=512 count=${sectors} status=none + hash2=`dd if=/dev/${md}.eli bs=512 count=${sectors} 2>/dev/null | md5` + atf_check_equal 0 $? + + atf_check geli detach ${md} + + # Change from passphrase 1 to passphrase 2 for the detached provider. + atf_check -s exit:0 -o ignore geli setkey -j pass1 -J pass2 ${md} + + # Make sure that we can attach with passphrase 2 but not with + # passphrase 1. + atf_check -s not-exit:0 -e match:"Wrong key" \ + geli attach -j pass1 ${md} + atf_check -s exit:0 geli attach -j pass2 ${md} + hash3=`dd if=/dev/${md}.eli bs=512 count=${sectors} 2>/dev/null | md5` + + # Change from passphrase 2 to passphrase 3 for the attached provider. + atf_check -s exit:0 -o ignore geli setkey -j pass2 -J pass3 ${md} + hash4=`dd if=/dev/${md}.eli bs=512 count=${sectors} 2>/dev/null | md5` + atf_check geli detach ${md} + + # Make sure that we cannot attach with passphrase 2 anymore. + atf_check -s not-exit:0 -e match:"Wrong key" \ + geli attach -j pass2 ${md} + + atf_check_equal ${hash1} ${hash2} + atf_check_equal ${hash1} ${hash3} + atf_check_equal ${hash1} ${hash4} +} +setkey_passphrase_cleanup() +{ + geli_test_cleanup +} + atf_test_case setkey_readonly cleanup setkey_readonly_head() { @@ -157,6 +215,7 @@ nokey_cleanup() atf_init_test_cases() { atf_add_test_case setkey + atf_add_test_case setkey_passphrase atf_add_test_case setkey_readonly atf_add_test_case nokey }