2016-04-20 14:48:12 +02:00
|
|
|
#!/bin/sh
|
|
|
|
# Copyright 2016 g10 Code GmbH
|
|
|
|
#
|
|
|
|
# This file is free software; as a special exception the author gives
|
|
|
|
# unlimited permission to copy and/or distribute it, with or without
|
|
|
|
# modifications, as long as this notice is preserved. This file is
|
|
|
|
# distributed in the hope that it will be useful, but WITHOUT ANY
|
|
|
|
# WARRANTY, to the extent permitted by law; without even the implied
|
|
|
|
# warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
|
|
|
|
|
|
|
|
if [ -z "$srcdir" ]; then
|
|
|
|
echo "not called from make" >&2
|
|
|
|
exit 1
|
|
|
|
fi
|
|
|
|
|
2016-04-21 14:36:21 +02:00
|
|
|
unset GNUPGHOME
|
2016-04-20 14:48:12 +02:00
|
|
|
set -e
|
|
|
|
|
|
|
|
# (We may not use a relative name for gpg-agent.)
|
|
|
|
GPG_AGENT="$(cd ../../agent && /bin/pwd)/gpg-agent"
|
|
|
|
GPG="../../g10/gpg --no-permission-warning --no-greeting --no-secmem-warning
|
|
|
|
--batch --agent-program=${GPG_AGENT}|--debug-quick-random"
|
|
|
|
|
2016-04-21 14:36:21 +02:00
|
|
|
TEST="from-classic"
|
2016-04-20 14:48:12 +02:00
|
|
|
|
|
|
|
setup_home()
|
|
|
|
{
|
2016-04-21 14:36:21 +02:00
|
|
|
XGNUPGHOME="`mktemp -d`"
|
|
|
|
rm -rf -- scratch
|
|
|
|
mkdir -p "$XGNUPGHOME"
|
|
|
|
for F in $srcdir/$TEST.gpghome/*.asc; do
|
|
|
|
$GPG --dearmor <"$F" >"$XGNUPGHOME/`basename $F .asc`"
|
2016-04-20 14:48:12 +02:00
|
|
|
done
|
2016-04-21 14:36:21 +02:00
|
|
|
chmod go-rwx $XGNUPGHOME/*
|
|
|
|
export GNUPGHOME="$XGNUPGHOME"
|
|
|
|
}
|
|
|
|
|
|
|
|
cleanup_home()
|
|
|
|
{
|
|
|
|
rm -rf -- "$XGNUPGHOME"
|
2016-04-20 14:48:12 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
trigger_migration()
|
|
|
|
{
|
2016-04-21 14:36:21 +02:00
|
|
|
$GPG --list-secret-keys >/dev/null 2>&1
|
2016-04-20 14:48:12 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
assert_migrated()
|
|
|
|
{
|
|
|
|
test -f $GNUPGHOME/.gpg-v21-migrated
|
|
|
|
|
|
|
|
for KEY in D74C5F22 C40FDECF ECABF51D; do
|
|
|
|
$GPG --list-secret-keys $KEY >/dev/null
|
|
|
|
done
|
|
|
|
}
|
|
|
|
|
|
|
|
setup_home
|
|
|
|
trigger_migration
|
|
|
|
assert_migrated
|
2016-04-21 14:36:21 +02:00
|
|
|
cleanup_home
|
2016-04-20 14:55:45 +02:00
|
|
|
|
|
|
|
# Test with an existing private-keys-v1.d.
|
|
|
|
setup_home
|
|
|
|
mkdir "$GNUPGHOME/private-keys-v1.d"
|
|
|
|
trigger_migration
|
|
|
|
assert_migrated
|
2016-04-21 14:36:21 +02:00
|
|
|
cleanup_home
|
2016-04-20 14:55:45 +02:00
|
|
|
|
|
|
|
# Test with an existing private-keys-v1.d with weird permissions.
|
|
|
|
setup_home
|
|
|
|
mkdir "$GNUPGHOME/private-keys-v1.d"
|
|
|
|
chmod 0 "$GNUPGHOME/private-keys-v1.d"
|
|
|
|
trigger_migration
|
|
|
|
assert_migrated
|
2016-04-21 14:36:21 +02:00
|
|
|
cleanup_home
|
2016-04-20 14:55:45 +02:00
|
|
|
|
|
|
|
# XXX Check a case where the migration fails.
|