2007-10-25 09:06:21 +00:00
|
|
|
# Definitions for the OpenPGP test scripts -*- sh -*-
|
|
|
|
# Copyright 1998,1999,2000,2001,2002,2003,2004,2005,2006,
|
2010-10-14 08:32:55 +00:00
|
|
|
# 2007, 2010 Free Software Foundation, Inc.
|
2007-10-25 09:06:21 +00:00
|
|
|
# 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.
|
2006-08-21 20:20:23 +00:00
|
|
|
|
|
|
|
#--------------------------------
|
|
|
|
#------ constants ---------------
|
|
|
|
#--------------------------------
|
|
|
|
|
2010-10-14 16:34:31 +00:00
|
|
|
usrname1="one@example.com"
|
2006-08-21 20:20:23 +00:00
|
|
|
usrpass1="def"
|
2010-10-14 16:34:31 +00:00
|
|
|
usrname2="two@example.com"
|
2006-08-21 20:20:23 +00:00
|
|
|
usrpass2=""
|
2010-10-14 16:34:31 +00:00
|
|
|
usrname3="three@example.com"
|
2006-08-21 20:20:23 +00:00
|
|
|
usrpass3=""
|
|
|
|
|
|
|
|
|
|
|
|
dsa_usrname1="pgp5"
|
2010-10-14 16:34:31 +00:00
|
|
|
# we use the sub key because we do not yet have the logic to to derive
|
|
|
|
# the first encryption key from a keyblock (I guess) (Well of course
|
|
|
|
# we have this by now and the notation below will lookup the primary
|
2014-10-12 20:07:12 +02:00
|
|
|
# first and then search for the encryption subkey.)
|
2006-08-21 20:20:23 +00:00
|
|
|
dsa_usrname2="0xCB879DE9"
|
|
|
|
|
|
|
|
|
|
|
|
plain_files="plain-1 plain-2 plain-3"
|
|
|
|
data_files="data-500 data-9000 data-32000 data-80000"
|
|
|
|
exp_files=""
|
|
|
|
|
|
|
|
# The testscripts expect the original language
|
|
|
|
LANG=
|
|
|
|
LANGUAGE=
|
|
|
|
LC_ALL=
|
|
|
|
LC_MESSAGES=
|
|
|
|
|
|
|
|
# Internal use.
|
|
|
|
defs_stop_on_error=no
|
|
|
|
defs_error_seen=no
|
2012-04-05 20:32:42 +02:00
|
|
|
defs_progress_active=no
|
2006-08-21 20:20:23 +00:00
|
|
|
|
|
|
|
#--------------------------------
|
|
|
|
#------ utility functions -------
|
|
|
|
#--------------------------------
|
|
|
|
|
2012-04-05 20:32:42 +02:00
|
|
|
progress_cancel () {
|
|
|
|
if [ x$defs_progress_active = xyes ]; then
|
|
|
|
echo
|
|
|
|
defs_progress_active=no
|
|
|
|
fi
|
|
|
|
}
|
|
|
|
|
2006-08-21 20:20:23 +00:00
|
|
|
fatal () {
|
2012-04-05 20:32:42 +02:00
|
|
|
progress_cancel
|
2006-08-21 20:20:23 +00:00
|
|
|
echo "$pgmname: fatal:" $* >&2
|
|
|
|
echo "$pgmname: fatal:" $* >&5
|
2010-10-14 16:34:31 +00:00
|
|
|
echo stop >gnupg-test.stop
|
2006-08-21 20:20:23 +00:00
|
|
|
exit 1;
|
|
|
|
}
|
|
|
|
|
|
|
|
error () {
|
2012-04-05 20:32:42 +02:00
|
|
|
progress_cancel
|
2006-08-21 20:20:23 +00:00
|
|
|
echo "$pgmname:" $* >&2
|
|
|
|
defs_error_seen=yes
|
|
|
|
echo "$pgmname:" $* >&5
|
|
|
|
if [ x$defs_stop_on_error != xyes ]; then
|
2011-02-10 20:16:06 +01:00
|
|
|
exit 1
|
2006-08-21 20:20:23 +00:00
|
|
|
fi
|
|
|
|
}
|
|
|
|
|
|
|
|
# Call this at the start of a test and resume_error at the end to keep
|
|
|
|
# on running all subtests without immediately exiting on error.
|
|
|
|
suspend_error () {
|
|
|
|
defs_stop_on_error=yes
|
|
|
|
}
|
|
|
|
|
|
|
|
resume_error () {
|
|
|
|
if [ x$defs_error_seen = xyes ]; then
|
|
|
|
exit 1
|
|
|
|
fi
|
|
|
|
defs_stop_on_error=no
|
|
|
|
defs_error_seen=no
|
|
|
|
}
|
|
|
|
|
|
|
|
info () {
|
2012-04-05 20:32:42 +02:00
|
|
|
progress_cancel
|
2006-08-21 20:20:23 +00:00
|
|
|
echo "$pgmname:" $* >&2
|
|
|
|
if [ -n "${verbose+set}" ]; then
|
|
|
|
echo "$pgmname:" $* >&5
|
|
|
|
fi
|
|
|
|
}
|
|
|
|
|
|
|
|
linefeed () {
|
|
|
|
echo >&2
|
|
|
|
}
|
|
|
|
|
|
|
|
echo_n_init=no
|
|
|
|
echo_n () {
|
|
|
|
if test "$echo_n_init" = "no"; then
|
|
|
|
if (echo "testing\c"; echo 1,2,3) | grep c >/dev/null; then
|
|
|
|
if (echo -n testing; echo 1,2,3) | sed s/-n/xn/ | grep xn >/dev/null; then
|
|
|
|
echo_n_n=
|
|
|
|
echo_n_c='
|
|
|
|
'
|
|
|
|
else
|
|
|
|
echo_n_n='-n'
|
|
|
|
echo_n_c=
|
|
|
|
fi
|
|
|
|
else
|
|
|
|
echo_n_n=
|
|
|
|
echo_n_c='\c'
|
|
|
|
fi
|
|
|
|
echo_n_init=yes
|
|
|
|
fi
|
|
|
|
echo $echo_n_n "${1}$echo_n_c"
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2012-04-05 20:32:42 +02:00
|
|
|
progress_end () {
|
|
|
|
if [ x$defs_progress_active = xyes ]; then
|
|
|
|
echo "<"
|
|
|
|
defs_progress_active=no
|
|
|
|
fi
|
|
|
|
}
|
|
|
|
|
|
|
|
progress () {
|
|
|
|
if [ x$defs_progress_active != xyes ]; then
|
|
|
|
echo_n " > "
|
|
|
|
defs_progress_active=yes
|
|
|
|
fi
|
|
|
|
echo_n "$* "
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
2006-08-21 20:20:23 +00:00
|
|
|
#cleanup () {
|
|
|
|
# rm $cleanup_files 2>/dev/null || true
|
|
|
|
# echo "#empty" >./gpg.conf
|
|
|
|
#}
|
|
|
|
|
|
|
|
|
|
|
|
#add_cleanup () {
|
|
|
|
# cleanup_files="$cleanup_files $*"
|
|
|
|
#}
|
|
|
|
|
|
|
|
have_pubkey_algo () {
|
2010-10-14 16:34:31 +00:00
|
|
|
if $GPG --version | grep "Pubkey:.*$1" >/dev/null
|
2006-08-21 20:20:23 +00:00
|
|
|
then
|
|
|
|
true
|
|
|
|
else
|
|
|
|
false
|
|
|
|
fi
|
|
|
|
}
|
|
|
|
|
|
|
|
have_cipher_algo () {
|
2010-10-14 16:34:31 +00:00
|
|
|
if $GPG --version | grep "Cipher:.*$1" >/dev/null
|
2006-08-21 20:20:23 +00:00
|
|
|
then
|
|
|
|
true
|
|
|
|
else
|
|
|
|
false
|
|
|
|
fi
|
|
|
|
}
|
|
|
|
|
|
|
|
have_hash_algo () {
|
2010-10-14 16:34:31 +00:00
|
|
|
if $GPG --version | grep "Hash:.*$1" >/dev/null
|
2006-08-21 20:20:23 +00:00
|
|
|
then
|
|
|
|
true
|
|
|
|
else
|
|
|
|
false
|
|
|
|
fi
|
|
|
|
}
|
|
|
|
|
2007-10-25 09:06:21 +00:00
|
|
|
all_cipher_algos () {
|
2010-10-14 16:34:31 +00:00
|
|
|
$GPG --with-colons --list-config ciphername \
|
|
|
|
| sed 's/^cfg:ciphername://; s/;/ /g'
|
2007-10-25 09:06:21 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
all_hash_algos () {
|
2010-10-14 16:34:31 +00:00
|
|
|
$GPG --with-colons --list-config digestname \
|
|
|
|
| sed 's/^cfg:digestname://; s/;/ /g'
|
2007-10-25 09:06:21 +00:00
|
|
|
}
|
|
|
|
|
2006-08-21 20:20:23 +00:00
|
|
|
set -e
|
|
|
|
pgmname=`basename $0`
|
|
|
|
#trap cleanup SIGHUP SIGINT SIGQUIT
|
|
|
|
|
|
|
|
[ -z "$srcdir" ] && fatal "not called from make"
|
|
|
|
|
2011-02-10 20:16:06 +01:00
|
|
|
#
|
2010-10-14 16:34:31 +00:00
|
|
|
if [ -f gnupg-test.stop ]; then
|
|
|
|
if [ $pgmname = "version.test" ]; then
|
|
|
|
rm gnupg-test.stop
|
|
|
|
else
|
2011-02-10 20:16:06 +01:00
|
|
|
# Skip the rest of the tests.
|
2010-10-14 16:34:31 +00:00
|
|
|
exit 77
|
|
|
|
fi
|
|
|
|
fi
|
|
|
|
|
2010-06-07 15:11:35 +00:00
|
|
|
# Always work in the current directory. We set GNUPGHOME only if it
|
|
|
|
# has not been set already. Usually it is set through the Makefile's
|
|
|
|
# TESTS_ENVIRONMENT macro.
|
|
|
|
if [ -z "$GNUPGHOME" ]; then
|
2010-10-14 08:32:55 +00:00
|
|
|
GNUPGHOME=`/bin/pwd`
|
2010-06-07 15:11:35 +00:00
|
|
|
export GNUPGHOME
|
2010-10-14 08:32:55 +00:00
|
|
|
elif [ "$GNUPGHOME" != `/bin/pwd` ]; then
|
2010-06-07 15:11:35 +00:00
|
|
|
echo "$pgmname: GNUPGHOME not set to the cwd" $* >&2
|
|
|
|
exit 1
|
|
|
|
fi
|
2006-08-21 20:20:23 +00:00
|
|
|
|
2010-10-14 16:34:31 +00:00
|
|
|
# We don't use GPG_AGENT_INFO anymore - better reset it.
|
|
|
|
unset GPG_AGENT_INFO
|
|
|
|
|
|
|
|
# (--no-permission-warning makes only sense on the commandline)
|
|
|
|
GPG="../../g10/gpg2 --no-permission-warning "
|
|
|
|
# (We may not use a relative name for gpg-agent.)
|
|
|
|
GPG_AGENT="$(cd ../../agent && /bin/pwd)/gpg-agent"
|
|
|
|
GPG_CONNECT_AGENT="../../tools/gpg-connect-agent"
|
|
|
|
GPGCONF="../../tools/gpgconf"
|
|
|
|
GPG_PRESET_PASSPHRASE="../../agent/gpg-preset-passphrase"
|
|
|
|
MKTDATA="../../tools/mk-tdata"
|
2011-02-10 20:16:06 +01:00
|
|
|
PINENTRY="$(cd $srcdir && /bin/pwd)/pinentry.sh"
|
|
|
|
# Default to empty passphrase for pinentry.sh
|
|
|
|
PINENTRY_USER_DATA=
|
2010-10-14 16:34:31 +00:00
|
|
|
|
gpg: Allow building without any trust model support.
* configure.ac: Add option --disable-trust-models
(NO_TRUST_MODELS): New ac_define and am_conditional.
* g10/Makefile.am (trust_source): New.
(gpg2_SOURCES): Factor some files out to above. Add trust.c.
* g10/gpg.c [NO_TRUST_MODELS]: Disable options --export-ownertrust,
--import-ownertrust, --update-trustdb, --check-trustdb, --fix-trustdb,
--list-trustdb, --trustdb-name, --auto-check-trustdb,
--no-auto-check-trustdb, and --force-ownertrust.
(parse_trust_model) [NO_TRUST_MODELS]: Do not build.
(main) [NO_TRUST_MODELS]: Set trust_model to always and exclude all
trustdb related option code.
* g10/keyedit.c (cmds) [NO_TRUST_MODELS]: Remove menu items "trust",
"enable", and "disable".
* g10/keylist.c (public_key_list) [NO_TRUST_MODELS]: Do not print
"tru" record.
* g10/trust.c: New.
* g10/trustdb.c (struct key_item): Move to trustdb.h.
(register_trusted_keyid): Rename to tdb_register_trusted_keyid.
(register_trusted_key): Rename to tdb_register_trusted_key.
(trust_letter, uid_trust_string_fixed, trust_value_to_string)
(string_to_trust_value, get_ownertrust_with_min, get_ownertrust_info)
(get_ownertrust_string, get_validity_info, get_validity_string)
(clean_sigs_from_uid, clean_uid_from_key, clean_key): Move to trust.c.
(mark_usable_uid_certs): Move to trust.c and make global.
(is_in_klist): Move as inline to trustdb.h.
(trustdb_check_or_update): Rename to tdb_check_or_update
(revalidation_mark): Rename to tdb_revalidation_mark.
(get_ownertrust): Rename to tdb_get_ownertrust.
(get_min_ownertrust): Rename to tdb_get_min_ownertrust.
(update_ownertrust): Rename to tdb_update_ownertrust.
(clear_ownertrusts): Rename to tdb_clear_ownertrusts.
(cache_disabled_value): Rename to tdb_cache_disabled_value.
(check_trustdb_stale): Rename to tdb_check_trustdb_stale.
(get_validity): Rename to tdb_get_validity_core, add arg MAIN_PK and
factor some code out to ...
* trust.c (get_validity): ...new.
(check_or_update_trustdb): New wrapper.
(revalidation_mark): New wrapper.
(get_ownertrust): New wrapper.
(get_ownertrust_with_min): New wrapper.
(update_ownertrust): New wrapper.
(clear_ownertrusts): New wrapper.
(cache_disabled_value): New wrapper.
(check_trustdb_stale): New wrapper.
* tests/openpgp/defs.inc (opt_always): New. Use in all tests instead
of --always-trust.
2014-02-10 17:05:54 +01:00
|
|
|
# If --check-trustdb is not an option, GPG has been build without
|
|
|
|
# trust model support. Thus we can't use --always-trust and some
|
|
|
|
# other options.
|
|
|
|
if $GPG --dump-options | grep '^--check-trustdb$' >/dev/null ; then
|
|
|
|
opt_always="--always-trust"
|
|
|
|
else
|
|
|
|
opt_always=
|
|
|
|
fi
|
|
|
|
|
2010-10-14 08:32:55 +00:00
|
|
|
# Make sure we have a valid option files even with VPATH builds.
|
2011-02-10 20:16:06 +01:00
|
|
|
for f in gpg.conf gpg-agent.conf ; do
|
2010-10-14 08:32:55 +00:00
|
|
|
if [ -f ./$f ]; then
|
|
|
|
:
|
|
|
|
elif [ -f $srcdir/$f.tmpl ]; then
|
|
|
|
cat $srcdir/$f.tmpl >$f
|
2011-02-10 20:16:06 +01:00
|
|
|
case "$f" in
|
|
|
|
gpg.conf)
|
gpg: Allow building without any trust model support.
* configure.ac: Add option --disable-trust-models
(NO_TRUST_MODELS): New ac_define and am_conditional.
* g10/Makefile.am (trust_source): New.
(gpg2_SOURCES): Factor some files out to above. Add trust.c.
* g10/gpg.c [NO_TRUST_MODELS]: Disable options --export-ownertrust,
--import-ownertrust, --update-trustdb, --check-trustdb, --fix-trustdb,
--list-trustdb, --trustdb-name, --auto-check-trustdb,
--no-auto-check-trustdb, and --force-ownertrust.
(parse_trust_model) [NO_TRUST_MODELS]: Do not build.
(main) [NO_TRUST_MODELS]: Set trust_model to always and exclude all
trustdb related option code.
* g10/keyedit.c (cmds) [NO_TRUST_MODELS]: Remove menu items "trust",
"enable", and "disable".
* g10/keylist.c (public_key_list) [NO_TRUST_MODELS]: Do not print
"tru" record.
* g10/trust.c: New.
* g10/trustdb.c (struct key_item): Move to trustdb.h.
(register_trusted_keyid): Rename to tdb_register_trusted_keyid.
(register_trusted_key): Rename to tdb_register_trusted_key.
(trust_letter, uid_trust_string_fixed, trust_value_to_string)
(string_to_trust_value, get_ownertrust_with_min, get_ownertrust_info)
(get_ownertrust_string, get_validity_info, get_validity_string)
(clean_sigs_from_uid, clean_uid_from_key, clean_key): Move to trust.c.
(mark_usable_uid_certs): Move to trust.c and make global.
(is_in_klist): Move as inline to trustdb.h.
(trustdb_check_or_update): Rename to tdb_check_or_update
(revalidation_mark): Rename to tdb_revalidation_mark.
(get_ownertrust): Rename to tdb_get_ownertrust.
(get_min_ownertrust): Rename to tdb_get_min_ownertrust.
(update_ownertrust): Rename to tdb_update_ownertrust.
(clear_ownertrusts): Rename to tdb_clear_ownertrusts.
(cache_disabled_value): Rename to tdb_cache_disabled_value.
(check_trustdb_stale): Rename to tdb_check_trustdb_stale.
(get_validity): Rename to tdb_get_validity_core, add arg MAIN_PK and
factor some code out to ...
* trust.c (get_validity): ...new.
(check_or_update_trustdb): New wrapper.
(revalidation_mark): New wrapper.
(get_ownertrust): New wrapper.
(get_ownertrust_with_min): New wrapper.
(update_ownertrust): New wrapper.
(clear_ownertrusts): New wrapper.
(cache_disabled_value): New wrapper.
(check_trustdb_stale): New wrapper.
* tests/openpgp/defs.inc (opt_always): New. Use in all tests instead
of --always-trust.
2014-02-10 17:05:54 +01:00
|
|
|
[ -n "${opt_always}" ] && echo "no-auto-check-trustdb" >>"$f"
|
2014-10-30 09:55:51 +01:00
|
|
|
echo "agent-program ${GPG_AGENT}|--debug-quick-random" >>"$f"
|
2014-03-17 17:54:36 +01:00
|
|
|
echo "allow-weak-digest-algos" >>"$f"
|
2014-10-30 09:55:51 +01:00
|
|
|
;;
|
2011-02-10 20:16:06 +01:00
|
|
|
gpg-agent.conf)
|
|
|
|
echo "pinentry-program $PINENTRY" >>"$f"
|
|
|
|
;;
|
|
|
|
esac
|
2010-10-14 08:32:55 +00:00
|
|
|
fi
|
|
|
|
done
|
|
|
|
|
2011-02-10 20:16:06 +01:00
|
|
|
if [ "${verbose:-0}" -gt "1" ]; then
|
|
|
|
exec 5>/dev/null
|
|
|
|
else
|
|
|
|
echo "Test: $pgmname" > ${pgmname}.log
|
|
|
|
echo "GNUPGHOME=$GNUPGHOME" >> ${pgmname}.log
|
|
|
|
exec 5>&2 2>>${pgmname}.log
|
|
|
|
fi
|
2006-08-21 20:20:23 +00:00
|
|
|
:
|
|
|
|
# end
|