From nobody Mon Aug 28 15:07:50 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 4RZDSl004Pz4rf77; Mon, 28 Aug 2023 15:07:50 +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 4RZDSk6gSLz4WGl; Mon, 28 Aug 2023 15:07:50 +0000 (UTC) (envelope-from git@FreeBSD.org) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1693235270; 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=x25Yvo+q1j+WbaK/HyJdHtXyIl8oJrky81l2a2NE7kg=; b=URbBdVyT9GHvjLxUzhcPIyepGUzoQAA1iU3AMX7cwA1J+6IvwzL7wQ/IBDvfvjTcyIbL5n h0einiAbOXXi9sywkp0t9GdARXfrz4JpHcU4Vjwj4hDHddf6ICcRQzDLsSESmnPWTcBZho QNV4sY7j96QwNVDz9c5+edI4l7d/MMo9B6ZJp0O6H0Z9UeFky66C9Mn3vo+13FOxMtW/Pj GEwjh7rZ0mNfKY61RFaup38hMOtCclmo91puMQVrDK0YbbuybeidH5MxLCRU+UqH54Olvr 1GnAQNeLitmQrA9EogPBuIrftpV5hcfq4d7sIjyuKt0woAEkqwRhHv568F+azg== ARC-Seal: i=1; s=dkim; d=freebsd.org; t=1693235270; a=rsa-sha256; cv=none; b=HuOQiS75BgHOFRiIvAhAwKihiA4SbubpDdAYtPY9y1vaHkpUoA2MHfP5l6bPnb5m7ssq24 Se3pddxl2b46ziwQvPqfcwmrbY4WIzzSUhS5P+WlPVVxckEaDCOtL6Yj0HdqWxHxXHEryN XmaLh6vsRTz1vQpay+GV948sWerntVejjxaRmPFU7D0pWIL8rnBgOoNQCqBg5/YTWCijKp mhQcQPnU/4cUP+YPtIgcTl5/ya8bRuOPxcgLzPULay9akOQQEezAqDeOKhrP9hY/9dxoqW CruFK/P1TnvlznQXN5f5FxkHO0xdAGJlVCTEMxhK1ayJ7IFrUw+CC3rQ5pdtHw== 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=1693235270; 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=x25Yvo+q1j+WbaK/HyJdHtXyIl8oJrky81l2a2NE7kg=; b=x1JlC9VubyKtcCqh8hivHJ8LC5j8ZgxUT1ctsa9RcaPIG/sK+ZRiDhu/D9VGrJYu09r8Zn VU0YNbdu2GgqhM2Q1FoV12PIzhBIh9oRur11gPqmi1jmyUWTgtwLuLxFUc3RXIHlGBDm3m c9QQh3wOAHimUwCP2RIDLadiJTgwLQKMo5sPNCJmxuGPhod+mOef7V5Qk0+aFzIqFQhzxL Lmt1M8AyDeC6GrbO6V+yY/Eumu80rdRI3rqw08/icxTC6nfWqB8+CkieSHbdqcT3ynjbcl YfBMnDJFX3yOZ55jEYwo/ZSBZTy1OalIm8FiT2gSCrlQfLe71Mag65E5N151JQ== 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 4RZDSk5TG2z1C25; Mon, 28 Aug 2023 15:07:50 +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 37SF7oR6029086; Mon, 28 Aug 2023 15:07:50 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.17.1/8.17.1/Submit) id 37SF7oAY029083; Mon, 28 Aug 2023 15:07:50 GMT (envelope-from git) Date: Mon, 28 Aug 2023 15:07:50 GMT Message-Id: <202308281507.37SF7oAY029083@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: 2b7b09ac9675 - main - 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/main X-Git-Reftype: branch X-Git-Commit: 2b7b09ac9675023869fddbae4911c9b674b1155a Auto-Submitted: auto-generated The branch main has been updated by markj: URL: https://cgit.FreeBSD.org/src/commit/?id=2b7b09ac9675023869fddbae4911c9b674b1155a commit 2b7b09ac9675023869fddbae4911c9b674b1155a Author: Mark Johnston AuthorDate: 2023-08-28 14:58:43 +0000 Commit: Mark Johnston CommitDate: 2023-08-28 15:06:42 +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 --- 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 }