pull: Verify commits with gpg signatures from detached metadata
This uses gpgv for verification against DATADIR/ostree/pubring.gpg by default. The keyring can be overridden by specifying OSTREE_GPG_HOME. Add a unit test for commit signing with gpg key and verifying on pull; to implement this we ship a test GPG key generated with no password for Ostree Tester <test@test.com>. Change all of the existing tests to disable GPG verification.
This commit is contained in:
1 parent
b064581577
commit
7f9eefb62d
19 files changed
+657
-10
No files matched your search
@@ -24,6 +24,7 @@ export G_DEBUG=fatal-warnings
|
||||
|
||||
export TEST_GPG_KEYID="472CDAFA"
|
||||
export TEST_GPG_HOME=${SRCDIR}/gpghome
|
||||
export OSTREE_GPG_HOME=${TEST_GPG_HOME}
|
||||
|
||||
if test -n "${OT_TESTS_DEBUG}"; then
|
||||
set -x
|
||||
|
||||
+1
-1
@@ -20,7 +20,7 @@
|
||||
cd ${test_tmpdir}
|
||||
mkdir repo
|
||||
${CMD_PREFIX} ostree --repo=repo init
|
||||
${CMD_PREFIX} ostree --repo=repo remote add origin $(cat httpd-address)/ostree/gnomerepo
|
||||
${CMD_PREFIX} ostree --repo=repo remote add --set=gpg-verify=false origin $(cat httpd-address)/ostree/gnomerepo
|
||||
${CMD_PREFIX} ostree --repo=repo pull origin main
|
||||
${CMD_PREFIX} ostree --repo=repo fsck
|
||||
echo "ok pull"
|
||||
|
||||
@@ -132,7 +132,7 @@ ostree admin --sysroot=sysroot status
|
||||
echo "ok upgrade bare"
|
||||
|
||||
os_repository_new_commit
|
||||
ostree --repo=sysroot/ostree/repo remote add testos file://$(pwd)/testos-repo testos/buildmaster/x86_64-runtime
|
||||
ostree --repo=sysroot/ostree/repo remote add --set=gpg-verify=false testos file://$(pwd)/testos-repo testos/buildmaster/x86_64-runtime
|
||||
ostree admin --sysroot=sysroot upgrade --os=testos
|
||||
origrev=${rev}
|
||||
rev=${newrev}
|
||||
|
||||
@@ -41,12 +41,12 @@ echo "ok deploy command"
|
||||
# Commit + upgrade twice, so that we'll rotate out the original deployment
|
||||
bootcsum1=${bootcsum}
|
||||
os_repository_new_commit
|
||||
ostree --repo=sysroot/ostree/repo remote add testos file://$(pwd)/testos-repo testos/buildmaster/x86_64-runtime
|
||||
ostree --repo=sysroot/ostree/repo remote add --set=gpg-verify=false testos file://$(pwd)/testos-repo testos/buildmaster/x86_64-runtime
|
||||
ostree admin --sysroot=sysroot upgrade --os=testos
|
||||
bootcsum2=${bootcsum}
|
||||
os_repository_new_commit "1"
|
||||
bootcsum3=${bootcsum}
|
||||
ostree --repo=sysroot/ostree/repo remote add testos file://$(pwd)/testos-repo testos/buildmaster/x86_64-runtime
|
||||
ostree --repo=sysroot/ostree/repo remote add --set=gpg-verify=false testos file://$(pwd)/testos-repo testos/buildmaster/x86_64-runtime
|
||||
ostree admin --sysroot=sysroot upgrade --os=testos
|
||||
|
||||
rev=${newrev}
|
||||
|
||||
@@ -31,7 +31,7 @@ echo "ok setup"
|
||||
cd ${test_tmpdir}
|
||||
mkdir repo2
|
||||
${CMD_PREFIX} ostree --repo=repo2 init
|
||||
${CMD_PREFIX} ostree --repo=repo2 remote add aremote file://$(pwd)/repo test2
|
||||
${CMD_PREFIX} ostree --repo=repo2 remote add --set=gpg-verify=false aremote file://$(pwd)/repo test2
|
||||
ostree --repo=repo2 pull aremote
|
||||
ostree --repo=repo2 rev-parse aremote/test2
|
||||
ostree --repo=repo2 fsck
|
||||
|
||||
Executable
+102
@@ -0,0 +1,102 @@
|
||||
#!/bin/bash
|
||||
#
|
||||
# Copyright (C) 2013 Jeremy Whiting <jeremy.whiting@collabora.com>
|
||||
#
|
||||
# This library is free software; you can redistribute it and/or
|
||||
# modify it under the terms of the GNU Lesser General Public
|
||||
# License as published by the Free Software Foundation; either
|
||||
# version 2 of the License, or (at your option) any later version.
|
||||
#
|
||||
# This library is distributed in the hope that it will be useful,
|
||||
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
# Lesser General Public License for more details.
|
||||
#
|
||||
# You should have received a copy of the GNU Lesser General Public
|
||||
# License along with this library; if not, write to the
|
||||
# Free Software Foundation, Inc., 59 Temple Place - Suite 330,
|
||||
# Boston, MA 02111-1307, USA.
|
||||
|
||||
set -e
|
||||
|
||||
if ! ostree --version | grep -q -e '\+gpgme'; then
|
||||
exit 77
|
||||
fi
|
||||
|
||||
. $(dirname $0)/libtest.sh
|
||||
|
||||
keyid="472CDAFA"
|
||||
oldpwd=`pwd`
|
||||
mkdir ostree-srv
|
||||
cd ostree-srv
|
||||
mkdir gnomerepo
|
||||
${CMD_PREFIX} ostree --repo=gnomerepo init --mode="archive-z2"
|
||||
mkdir gnomerepo-files
|
||||
cd gnomerepo-files
|
||||
echo first > firstfile
|
||||
mkdir baz
|
||||
echo moo > baz/cow
|
||||
echo alien > baz/saucer
|
||||
${CMD_PREFIX} ostree --repo=${test_tmpdir}/ostree-srv/gnomerepo commit -b main -s "A remote commit" -m "Some Commit body" --gpg-sign=$keyid --gpg-homedir=${SRCDIR}/gpghome
|
||||
mkdir baz/deeper
|
||||
${CMD_PREFIX} ostree --repo=${test_tmpdir}/ostree-srv/gnomerepo commit -b main -s "Add deeper" --gpg-sign=$keyid --gpg-homedir=${SRCDIR}/gpghome
|
||||
echo hi > baz/deeper/ohyeah
|
||||
mkdir baz/another/
|
||||
echo x > baz/another/y
|
||||
${CMD_PREFIX} ostree --repo=${test_tmpdir}/ostree-srv/gnomerepo commit -b main -s "The rest" --gpg-sign=$keyid --gpg-homedir=${SRCDIR}/gpghome
|
||||
cd ..
|
||||
rm -rf gnomerepo-files
|
||||
|
||||
cd ${test_tmpdir}
|
||||
mkdir ${test_tmpdir}/httpd
|
||||
cd httpd
|
||||
ln -s ${test_tmpdir}/ostree-srv ostree
|
||||
ostree trivial-httpd --daemonize -p ${test_tmpdir}/httpd-port
|
||||
port=$(cat ${test_tmpdir}/httpd-port)
|
||||
echo "http://127.0.0.1:${port}" > ${test_tmpdir}/httpd-address
|
||||
cd ${oldpwd}
|
||||
|
||||
export OSTREE="ostree --repo=repo"
|
||||
|
||||
repopath=${test_tmpdir}/ostree-srv/gnomerepo
|
||||
cp -a ${repopath} ${repopath}.orig
|
||||
|
||||
# Set OSTREE_GPG_HOME to a place with no keyrings, we shouldn't trust the signature
|
||||
cd ${test_tmpdir}
|
||||
mkdir repo
|
||||
${CMD_PREFIX} ostree --repo=repo init
|
||||
${CMD_PREFIX} ostree --repo=repo remote add origin $(cat httpd-address)/ostree/gnomerepo
|
||||
if env OSTREE_GPG_HOME=${test_tmpdir} ${CMD_PREFIX} ostree --repo=repo pull origin main; then
|
||||
assert_not_reached "pull with no trusted GPG keys unexpectedly succeeded!"
|
||||
fi
|
||||
rm repo -rf
|
||||
|
||||
# And a test case with valid signature
|
||||
cd ${test_tmpdir}
|
||||
mkdir repo
|
||||
${CMD_PREFIX} ostree --repo=repo init
|
||||
${CMD_PREFIX} ostree --repo=repo remote add origin $(cat httpd-address)/ostree/gnomerepo
|
||||
${CMD_PREFIX} ostree --repo=repo pull origin main
|
||||
rm repo -rf
|
||||
|
||||
# A test with corrupted detached signature
|
||||
cd ${test_tmpdir}
|
||||
find ${test_tmpdir}/ostree-srv/gnomerepo -name '*.commitmeta' | while read fname; do
|
||||
echo borkborkbork > ${fname};
|
||||
done
|
||||
mkdir repo
|
||||
${CMD_PREFIX} ostree --repo=repo init
|
||||
${CMD_PREFIX} ostree --repo=repo remote add origin $(cat httpd-address)/ostree/gnomerepo
|
||||
if ${CMD_PREFIX} ostree --repo=repo pull origin main; then
|
||||
assert_not_reached "pull with corrupted signature unexpectedly succeeded!"
|
||||
fi
|
||||
rm repo -rf
|
||||
|
||||
# And now attempt to pull the same corrupted commit, but with GPG
|
||||
# verification off
|
||||
cd ${test_tmpdir}
|
||||
mkdir repo
|
||||
${CMD_PREFIX} ostree --repo=repo init
|
||||
${CMD_PREFIX} ostree --repo=repo remote add --set=gpg-verify=false origin $(cat httpd-address)/ostree/gnomerepo
|
||||
${CMD_PREFIX} ostree --repo=repo pull origin main
|
||||
rm repo -rf
|
||||
@@ -33,7 +33,7 @@ do_corrupt_pull_test() {
|
||||
rm repo -rf
|
||||
mkdir repo
|
||||
${CMD_PREFIX} ostree --repo=repo init
|
||||
${CMD_PREFIX} ostree --repo=repo remote add origin $(cat httpd-address)/ostree/gnomerepo
|
||||
${CMD_PREFIX} ostree --repo=repo remote add --set=gpg-verify=false origin $(cat httpd-address)/ostree/gnomerepo
|
||||
if ${CMD_PREFIX} ostree --repo=repo pull origin main; then
|
||||
assert_not_reached "pull unexpectedly succeeded!"
|
||||
fi
|
||||
|
||||
@@ -32,7 +32,7 @@ cd ${test_tmpdir}
|
||||
rm repo -rf
|
||||
mkdir repo
|
||||
${CMD_PREFIX} ostree --repo=repo init
|
||||
${CMD_PREFIX} ostree --repo=repo remote add origin $(cat httpd-address)/ostree/gnomerepo
|
||||
${CMD_PREFIX} ostree --repo=repo remote add --set=gpg-verify=false origin $(cat httpd-address)/ostree/gnomerepo
|
||||
|
||||
maxtries=`find ${repopath}/objects | wc -l`
|
||||
maxtries=`expr $maxtries \* 2`
|
||||
|
||||
Reference in new issue
Block a user