From 8a591414a7c920a859ea123581be29aac13ab3ac Mon Sep 17 00:00:00 2001 From: Duncan Mac-Vicar P Date: Tue, 8 May 2007 14:44:44 +0000 Subject: [PATCH] trying to fix #270125 Import key is terribly broken in 10.2. Created testcase with lot of scenarios. --- tests/zypp/KeyRing.cc | 514 +++++++++++++-------------- tests/zypp/data/KeyRing/repomd.xml.asc | 21 +- tests/zypp/data/KeyRing/repomd.xml.corrupted | 21 ++ zypp/KeyRing.cc | 34 +- zypp/target/rpm/RpmDb.cc | 14 +- 5 files changed, 295 insertions(+), 309 deletions(-) create mode 100644 tests/zypp/data/KeyRing/repomd.xml.corrupted diff --git a/tests/zypp/KeyRing.cc b/tests/zypp/KeyRing.cc index 0d40e3a..bc60be5 100644 --- a/tests/zypp/KeyRing.cc +++ b/tests/zypp/KeyRing.cc @@ -22,281 +22,123 @@ using namespace std; using namespace zypp; using namespace zypp::filesystem; -/* ------BEGIN PGP PUBLIC KEY BLOCK----- -Version: GnuPG v1.4.2 (GNU/Linux) - -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 -=pJli ------END PGP PUBLIC KEY BLOCK----- -*/ - /** - * Array version of the above key + * Keyring Callback Receiver with some features + * Allows to simulate and configure user answer + * Can record which callbacks were called */ -char susekey[]= -{ - 0x2d,0x2d,0x2d,0x2d,0x2d,0x42,0x45,0x47,0x49,0x4e,0x20,0x50,0x47, - 0x50,0x20,0x50,0x55,0x42,0x4c,0x49,0x43,0x20,0x4b,0x45,0x59,0x20, - 0x42,0x4c,0x4f,0x43,0x4b,0x2d,0x2d,0x2d,0x2d,0x2d,0x0a,0x56,0x65, - 0x72,0x73,0x69,0x6f,0x6e,0x3a,0x20,0x47,0x6e,0x75,0x50,0x47,0x20, - 0x76,0x31,0x2e,0x34,0x2e,0x32,0x20,0x28,0x47,0x4e,0x55,0x2f,0x4c, - 0x69,0x6e,0x75,0x78,0x29,0x0a,0x0a,0x6d,0x51,0x47,0x69,0x42,0x44, - 0x6e,0x75,0x39,0x49,0x45,0x52,0x42,0x41,0x43,0x54,0x38,0x59,0x33, - 0x35,0x2b,0x32,0x76,0x76,0x34,0x4d,0x47,0x56,0x4b,0x69,0x4c,0x45, - 0x4d,0x4f,0x6c,0x39,0x47,0x64,0x53,0x54,0x36,0x4d,0x43,0x6b,0x59, - 0x53,0x33,0x79,0x45,0x4b,0x65,0x75,0x65,0x4e,0x57,0x63,0x2b,0x7a, - 0x2f,0x30,0x4b,0x76,0x66,0x66,0x0a,0x34,0x4a,0x63,0x74,0x42,0x73, - 0x67,0x73,0x34,0x37,0x74,0x6a,0x6d,0x69,0x49,0x39,0x73,0x6c,0x30, - 0x65,0x48,0x6a,0x6d,0x33,0x67,0x54,0x52,0x38,0x72,0x49,0x74,0x58, - 0x4d,0x4e,0x36,0x73,0x4a,0x45,0x55,0x48,0x57,0x7a,0x44,0x50,0x2b, - 0x59,0x30,0x50,0x46,0x50,0x62,0x6f,0x4d,0x76,0x4b,0x78,0x30,0x46, - 0x58,0x6c,0x2f,0x41,0x30,0x64,0x0a,0x4d,0x2b,0x48,0x46,0x72,0x72, - 0x75,0x43,0x67,0x42,0x6c,0x57,0x74,0x36,0x46,0x41,0x2b,0x6f,0x6b, - 0x52,0x79,0x53,0x51,0x69,0x6c,0x69,0x75,0x49,0x35,0x70,0x68,0x77, - 0x71,0x6b,0x58,0x65,0x66,0x6c,0x39,0x41,0x68,0x6b,0x77,0x52,0x38, - 0x78,0x6f,0x63,0x51,0x53,0x56,0x43,0x46,0x78,0x63,0x77,0x76,0x77, - 0x43,0x67,0x6c,0x56,0x63,0x4f,0x0a,0x51,0x6c,0x69,0x48,0x75,0x38, - 0x6a,0x77,0x52,0x51,0x48,0x78,0x6c,0x52,0x45,0x30,0x74,0x6b,0x77, - 0x51,0x51,0x49,0x30,0x44,0x2b,0x77,0x66,0x51,0x77,0x4b,0x64,0x76, - 0x68,0x44,0x70,0x6c,0x78,0x48,0x4a,0x35,0x6e,0x66,0x37,0x55,0x38, - 0x63,0x2f,0x79,0x45,0x2f,0x76,0x64,0x76,0x70,0x4e,0x36,0x6c,0x46, - 0x30,0x74,0x6d,0x46,0x72,0x4b,0x0a,0x58,0x42,0x55,0x58,0x2b,0x4b, - 0x37,0x75,0x34,0x69,0x66,0x72,0x5a,0x6c,0x51,0x76,0x6a,0x2f,0x38, - 0x31,0x4d,0x34,0x49,0x4e,0x6a,0x74,0x58,0x72,0x65,0x71,0x44,0x69, - 0x4a,0x74,0x72,0x39,0x39,0x52,0x73,0x36,0x78,0x61,0x30,0x53,0x63, - 0x5a,0x71,0x49,0x54,0x75,0x5a,0x43,0x34,0x43,0x57,0x78,0x4a,0x61, - 0x39,0x47,0x79,0x6e,0x42,0x45,0x0a,0x44,0x33,0x2b,0x44,0x32,0x74, - 0x31,0x56,0x2f,0x66,0x38,0x6c,0x30,0x73,0x6d,0x73,0x75,0x59,0x6f, - 0x46,0x4f,0x46,0x37,0x49,0x62,0x34,0x39,0x49,0x6b,0x54,0x64,0x62, - 0x74,0x77,0x41,0x54,0x68,0x6c,0x5a,0x70,0x38,0x62,0x45,0x68,0x45, - 0x4c,0x42,0x65,0x47,0x61,0x50,0x64,0x4e,0x43,0x63,0x6d,0x66,0x5a, - 0x36,0x36,0x72,0x4b,0x55,0x64,0x0a,0x47,0x35,0x73,0x52,0x41,0x2f, - 0x39,0x6f,0x76,0x6e,0x63,0x31,0x6b,0x72,0x53,0x51,0x46,0x32,0x2b, - 0x73,0x71,0x42,0x39,0x2f,0x6f,0x37,0x77,0x35,0x2f,0x71,0x32,0x71, - 0x69,0x79,0x7a,0x77,0x4f,0x53,0x54,0x6e,0x6b,0x6a,0x74,0x42,0x55, - 0x56,0x4b,0x6e,0x34,0x7a,0x4c,0x55,0x4f,0x66,0x36,0x61,0x65,0x42, - 0x41,0x6f,0x56,0x36,0x4e,0x4d,0x0a,0x43,0x43,0x33,0x4b,0x6a,0x39, - 0x61,0x5a,0x48,0x66,0x41,0x2b,0x4e,0x44,0x30,0x65,0x68,0x50,0x61, - 0x56,0x47,0x4a,0x67,0x6a,0x61,0x56,0x4e,0x46,0x68,0x50,0x69,0x34, - 0x78,0x30,0x65,0x37,0x42,0x55,0x4c,0x64,0x76,0x67,0x4f,0x6f,0x41, - 0x71,0x61,0x6a,0x4c,0x66,0x76,0x6b,0x55,0x52,0x48,0x41,0x65,0x53, - 0x73,0x78,0x58,0x49,0x6f,0x45,0x0a,0x6d,0x79,0x57,0x2f,0x78,0x43, - 0x31,0x73,0x42,0x62,0x44,0x6b,0x44,0x55,0x49,0x42,0x53,0x78,0x35, - 0x6f,0x65,0x6a,0x37,0x33,0x58,0x43,0x5a,0x67,0x6e,0x6a,0x2f,0x69, - 0x6e,0x70,0x68,0x52,0x71,0x47,0x70,0x73,0x62,0x2b,0x31,0x6e,0x4b, - 0x46,0x76,0x46,0x2b,0x72,0x51,0x6f,0x55,0x33,0x56,0x54,0x52,0x53, - 0x42,0x51,0x59,0x57,0x4e,0x72,0x0a,0x59,0x57,0x64,0x6c,0x49,0x46, - 0x4e,0x70,0x5a,0x32,0x35,0x70,0x62,0x6d,0x63,0x67,0x53,0x32,0x56, - 0x35,0x49,0x44,0x78,0x69,0x64,0x57,0x6c,0x73,0x5a,0x45,0x42,0x7a, - 0x64,0x58,0x4e,0x6c,0x4c,0x6d,0x52,0x6c,0x50,0x6f,0x68,0x69,0x42, - 0x42,0x4d,0x52,0x41,0x67,0x41,0x69,0x42,0x51,0x4a,0x41,0x32,0x41, - 0x59,0x2b,0x41,0x68,0x73,0x44,0x0a,0x42,0x51,0x6b,0x4f,0x62,0x64, - 0x2b,0x39,0x42,0x41,0x73,0x48,0x41,0x77,0x49,0x44,0x46,0x51,0x49, - 0x44,0x41,0x78,0x59,0x43,0x41,0x51,0x49,0x65,0x41,0x51,0x49,0x58, - 0x67,0x41,0x41,0x4b,0x43,0x52,0x43,0x6f,0x54,0x74,0x72,0x6f,0x6e, - 0x49,0x41,0x4b,0x79,0x70,0x43,0x66,0x41,0x4a,0x39,0x52,0x75,0x5a, - 0x36,0x5a,0x53,0x56,0x37,0x51,0x0a,0x57,0x34,0x70,0x54,0x67,0x54, - 0x49,0x78,0x51,0x2b,0x41,0x42,0x50,0x70,0x30,0x73,0x49,0x77,0x43, - 0x66,0x66,0x47,0x39,0x62,0x43,0x4e,0x6e,0x72,0x45,0x54,0x50,0x6c, - 0x67,0x4f,0x6e,0x2b,0x64,0x47,0x45,0x6b,0x41,0x57,0x65,0x67,0x4b, - 0x4c,0x2b,0x49,0x52,0x67,0x51,0x51,0x45,0x51,0x49,0x41,0x42,0x67, - 0x55,0x43,0x4f,0x6e,0x42,0x65,0x0a,0x55,0x67,0x41,0x4b,0x43,0x52, - 0x43,0x65,0x51,0x4f,0x4d,0x51,0x41,0x41,0x71,0x72,0x70,0x4e,0x7a, - 0x4f,0x41,0x4b,0x43,0x4c,0x35,0x31,0x32,0x46,0x5a,0x76,0x76,0x34, - 0x56,0x5a,0x78,0x39,0x34,0x54,0x70,0x62,0x41,0x39,0x6c,0x78,0x79, - 0x6f,0x41,0x65,0x6a,0x41,0x43,0x65,0x4f,0x4f,0x31,0x48,0x49,0x62, - 0x41,0x63,0x74,0x41,0x65,0x76,0x0a,0x6b,0x35,0x4d,0x55,0x42,0x68, - 0x4e,0x65,0x4c,0x5a,0x61,0x2f,0x71,0x4d,0x32,0x4a,0x41,0x52,0x55, - 0x44,0x42,0x52,0x41,0x36,0x63,0x47,0x42,0x76,0x64,0x37,0x4c,0x6d, - 0x41,0x44,0x30,0x6c,0x30,0x39,0x6b,0x42,0x41,0x54,0x57,0x6e,0x42, - 0x2f,0x39,0x41,0x6e,0x35,0x76,0x66,0x69,0x55,0x55,0x45,0x31,0x56, - 0x51,0x6e,0x74,0x2b,0x54,0x2f,0x0a,0x45,0x59,0x6b,0x6c,0x45,0x53, - 0x33,0x74,0x58,0x58,0x61,0x4a,0x4a,0x70,0x39,0x70,0x48,0x4d,0x61, - 0x34,0x66,0x7a,0x46,0x61,0x38,0x6a,0x50,0x56,0x74,0x76,0x35,0x55, - 0x42,0x48,0x47,0x65,0x65,0x33,0x58,0x6f,0x55,0x4e,0x44,0x56,0x77, - 0x4d,0x32,0x4f,0x67,0x53,0x45,0x49,0x53,0x5a,0x78,0x62,0x7a,0x64, - 0x58,0x47,0x6e,0x71,0x49,0x6c,0x0a,0x63,0x54,0x30,0x38,0x54,0x7a, - 0x42,0x55,0x44,0x39,0x69,0x35,0x37,0x39,0x75,0x69,0x66,0x6b,0x6c, - 0x4c,0x73,0x6e,0x72,0x33,0x35,0x53,0x4a,0x44,0x5a,0x36,0x72,0x61, - 0x6d,0x35,0x31,0x2f,0x43,0x57,0x4f,0x6e,0x6e,0x61,0x56,0x68,0x55, - 0x7a,0x6e,0x65,0x4f,0x41,0x39,0x67,0x54,0x50,0x53,0x72,0x2b,0x2f, - 0x66,0x54,0x33,0x57,0x65,0x56,0x0a,0x6e,0x77,0x4a,0x69,0x51,0x43, - 0x51,0x33,0x30,0x6b,0x4e,0x4c,0x57,0x56,0x58,0x57,0x41,0x54,0x4d, - 0x6e,0x73,0x6e,0x54,0x34,0x38,0x36,0x65,0x41,0x4f,0x6c,0x54,0x36, - 0x55,0x4e,0x42,0x50,0x59,0x51,0x4c,0x70,0x55,0x70,0x72,0x46,0x35, - 0x59,0x72,0x79,0x6b,0x32,0x33,0x70,0x51,0x55,0x50,0x41,0x67,0x4a, - 0x45,0x4e,0x44,0x45,0x71,0x65,0x0a,0x55,0x36,0x69,0x49,0x4f,0x39, - 0x4f,0x74,0x31,0x5a,0x50,0x74,0x42,0x30,0x6c,0x6e,0x69,0x77,0x2b, - 0x2f,0x78,0x43,0x69,0x31,0x33,0x44,0x33,0x36,0x30,0x6f,0x31,0x74, - 0x5a,0x44,0x59,0x4f,0x70,0x30,0x68,0x48,0x48,0x4a,0x4e,0x33,0x44, - 0x33,0x45,0x4e,0x38,0x43,0x31,0x79,0x50,0x71,0x5a,0x64,0x35,0x43, - 0x76,0x76,0x7a,0x6e,0x59,0x76,0x0a,0x42,0x36,0x62,0x57,0x42,0x49, - 0x70,0x57,0x63,0x52,0x67,0x64,0x6e,0x32,0x44,0x55,0x56,0x4d,0x6d, - 0x70,0x55,0x36,0x36,0x31,0x6a,0x77,0x71,0x47,0x6c,0x52,0x7a,0x31, - 0x46,0x38,0x34,0x4a,0x47,0x2f,0x78,0x65,0x34,0x6a,0x47,0x75,0x7a, - 0x67,0x70,0x4a,0x74,0x39,0x49,0x58,0x53,0x7a,0x79,0x6f,0x68,0x45, - 0x4a,0x42,0x36,0x58,0x47,0x35,0x0a,0x2b,0x44,0x30,0x42,0x75,0x51, - 0x49,0x4e,0x42,0x44,0x6e,0x75,0x39,0x4a,0x49,0x51,0x43,0x41,0x43, - 0x45,0x6b,0x64,0x42,0x4e,0x36,0x4d,0x78,0x66,0x35,0x57,0x76,0x71, - 0x44,0x57,0x6b,0x63,0x4d,0x52,0x79,0x36,0x77,0x6e,0x72,0x64,0x39, - 0x44,0x59,0x4a,0x38,0x55,0x55,0x54,0x6d,0x49,0x54,0x32,0x69,0x51, - 0x66,0x30,0x37,0x74,0x52,0x55,0x0a,0x4b,0x4a,0x4a,0x39,0x76,0x30, - 0x4a,0x58,0x66,0x78,0x32,0x5a,0x34,0x64,0x30,0x38,0x49,0x51,0x53, - 0x4d,0x4e,0x52,0x61,0x71,0x34,0x56,0x67,0x53,0x65,0x2b,0x50,0x64, - 0x59,0x67,0x49,0x79,0x30,0x66,0x62,0x6a,0x32,0x33,0x56,0x69,0x61, - 0x35,0x2f,0x67,0x4f,0x37,0x66,0x4a,0x45,0x70,0x44,0x32,0x68,0x64, - 0x32,0x66,0x2b,0x70,0x4d,0x6e,0x0a,0x4f,0x57,0x76,0x48,0x32,0x72, - 0x4f,0x4f,0x49,0x62,0x65,0x59,0x66,0x75,0x68,0x7a,0x41,0x63,0x36, - 0x42,0x51,0x6a,0x41,0x4b,0x74,0x6d,0x67,0x52,0x30,0x45,0x52,0x55, - 0x54,0x61,0x66,0x54,0x4d,0x39,0x57,0x62,0x36,0x46,0x31,0x33,0x43, - 0x4e,0x5a,0x5a,0x4e,0x5a,0x66,0x44,0x71,0x6e,0x46,0x44,0x50,0x36, - 0x4c,0x31,0x32,0x77,0x33,0x7a,0x0a,0x33,0x46,0x37,0x46,0x46,0x58, - 0x6b,0x7a,0x30,0x37,0x52,0x73,0x33,0x41,0x49,0x74,0x6f,0x31,0x5a, - 0x66,0x59,0x5a,0x64,0x34,0x73,0x43,0x53,0x70,0x4d,0x72,0x2f,0x30, - 0x53,0x35,0x6e,0x4c,0x72,0x48,0x62,0x49,0x76,0x47,0x4c,0x70,0x32, - 0x37,0x31,0x68,0x68,0x51,0x42,0x65,0x52,0x6d,0x6d,0x6f,0x47,0x45, - 0x4b,0x4f,0x32,0x4a,0x52,0x65,0x0a,0x6c,0x47,0x67,0x55,0x4a,0x32, - 0x43,0x55,0x7a,0x4f,0x64,0x74,0x77,0x44,0x49,0x4b,0x54,0x30,0x4c, - 0x62,0x43,0x70,0x76,0x61,0x50,0x38,0x50,0x56,0x6e,0x59,0x46,0x35, - 0x49,0x46,0x6f,0x59,0x4a,0x49,0x57,0x52,0x48,0x71,0x6c,0x45,0x74, - 0x35,0x75,0x63,0x54,0x58,0x73,0x74,0x5a,0x79,0x37,0x76,0x59,0x6a, - 0x4c,0x36,0x76,0x54,0x50,0x34,0x0a,0x6c,0x35,0x78,0x73,0x2b,0x4c, - 0x49,0x4f,0x6b,0x4e,0x6d,0x50,0x68,0x71,0x6d,0x66,0x73,0x67,0x4c, - 0x7a,0x56,0x6f,0x30,0x55,0x61,0x4c,0x74,0x38,0x30,0x68,0x4f,0x77, - 0x63,0x34,0x4e,0x76,0x44,0x43,0x4f,0x4c,0x41,0x41,0x4d,0x47,0x42, - 0x2f,0x39,0x67,0x2b,0x39,0x56,0x33,0x4f,0x52,0x7a,0x77,0x34,0x4c, - 0x76,0x4f,0x31,0x70,0x77,0x52,0x0a,0x59,0x4a,0x71,0x66,0x44,0x4b, - 0x55,0x71,0x2f,0x45,0x4a,0x30,0x72,0x4e,0x4d,0x4d,0x44,0x34,0x4e, - 0x38,0x52,0x4c,0x70,0x5a,0x52,0x68,0x4b,0x48,0x4b,0x4a,0x55,0x6d, - 0x39,0x6e,0x4e,0x48,0x4c,0x62,0x6b,0x73,0x6e,0x6c,0x5a,0x77,0x72, - 0x62,0x53,0x54,0x4d,0x35,0x4c,0x70,0x43,0x2f,0x55,0x36,0x73,0x68, - 0x65,0x4c,0x50,0x2b,0x6c,0x30,0x0a,0x62,0x4c,0x56,0x6f,0x71,0x30, - 0x6c,0x6d,0x73,0x43,0x63,0x55,0x53,0x79,0x68,0x2b,0x6d,0x59,0x36, - 0x50,0x78,0x57,0x69,0x72,0x4c,0x49,0x57,0x43,0x6e,0x2f,0x49,0x41, - 0x5a,0x41,0x47,0x6e,0x58,0x62,0x36,0x5a,0x64,0x36,0x54,0x74,0x49, - 0x4a,0x6c,0x47,0x47,0x36,0x70,0x71,0x55,0x4e,0x38,0x51,0x78,0x47, - 0x4a,0x59,0x51,0x6e,0x6f,0x6e,0x0a,0x6c,0x30,0x75,0x54,0x4a,0x4b, - 0x48,0x4a,0x45,0x4e,0x62,0x49,0x39,0x73,0x57,0x48,0x51,0x64,0x63, - 0x54,0x74,0x42,0x4d,0x63,0x33,0x34,0x67,0x6f,0x72,0x48,0x46,0x43, - 0x6f,0x31,0x42,0x63,0x76,0x70,0x6e,0x63,0x31,0x4c,0x46,0x4c,0x72, - 0x57,0x6e,0x37,0x6d,0x66,0x6f,0x47,0x78,0x36,0x49,0x4e,0x51,0x6a, - 0x66,0x33,0x48,0x47,0x51,0x70,0x0a,0x4d,0x58,0x41,0x57,0x75,0x53, - 0x42,0x51,0x68,0x7a,0x6b,0x61,0x7a,0x59,0x36,0x76,0x61,0x57,0x46, - 0x70,0x61,0x38,0x62,0x42,0x4a,0x2b,0x67,0x4b,0x62,0x42,0x75,0x79, - 0x53,0x57,0x7a,0x4e,0x6d,0x33,0x72,0x46,0x74,0x54,0x35,0x48,0x52, - 0x4b,0x4d,0x57,0x70,0x4f,0x2b,0x4d,0x39,0x62,0x48,0x70,0x34,0x64, - 0x2b,0x70,0x75,0x59,0x30,0x4c,0x0a,0x31,0x59,0x77,0x4e,0x31,0x4f, - 0x4d,0x61,0x74,0x63,0x4d,0x4d,0x70,0x63,0x57,0x6e,0x5a,0x70,0x69, - 0x57,0x69,0x52,0x38,0x33,0x6f,0x69,0x33,0x32,0x2b,0x78,0x74,0x57, - 0x55,0x59,0x32,0x55,0x37,0x41,0x65,0x33,0x38,0x6d,0x4d,0x61,0x67, - 0x38,0x7a,0x46,0x62,0x70,0x65,0x71,0x50,0x51,0x55,0x73,0x44,0x76, - 0x39,0x56,0x37,0x43,0x41,0x4a,0x0a,0x31,0x64,0x62,0x72,0x69,0x45, - 0x77,0x45,0x47,0x42,0x45,0x43,0x41,0x41,0x77,0x46,0x41,0x6b,0x44, - 0x59,0x42,0x6e,0x6f,0x46,0x43,0x51,0x35,0x74,0x33,0x2b,0x67,0x41, - 0x43,0x67,0x6b,0x51,0x71,0x45,0x37,0x61,0x36,0x4a,0x79,0x41,0x43, - 0x73,0x70,0x6e,0x70,0x67,0x43,0x66,0x52,0x62,0x59,0x77,0x78,0x54, - 0x33,0x69,0x71,0x2b,0x39,0x6c,0x0a,0x2f,0x50,0x67,0x4e,0x54,0x55, - 0x4e,0x54,0x5a,0x4f,0x6c,0x6f,0x66,0x32,0x6f,0x41,0x6e,0x32,0x35, - 0x79,0x30,0x65,0x47,0x69,0x30,0x33,0x37,0x31,0x6a,0x61,0x70,0x39, - 0x6b,0x4f,0x56,0x36,0x75,0x71,0x37,0x31,0x73,0x55,0x75,0x4f,0x0a, - 0x3d,0x70,0x4a,0x6c,0x69,0x0a,0x2d,0x2d,0x2d,0x2d,0x2d,0x45,0x4e, - 0x44,0x20,0x50,0x47,0x50,0x20,0x50,0x55,0x42,0x4c,0x49,0x43,0x20, - 0x4b,0x45,0x59,0x20,0x42,0x4c,0x4f,0x43,0x4b,0x2d,0x2d,0x2d,0x2d, - 0x2d,0x0a,0x00, -}; - -size_t _susekey_size=2173; -size_t *susekey_size=&_susekey_size; - -/////////////////////////////////////////////////////////////////// -// KeyRingReceive -/////////////////////////////////////////////////////////////////// struct KeyRingReceive : public zypp::callback::ReceiveReport { KeyRingReceive() - {} + { + reset(); + connect(); + } + void reset() + { + _answer_accept_unknown_key = false; + _answer_trust_key = false; + _answer_import_key = false; + _answer_ver_failed = false; + _answer_accept_unsigned_file = false; + _asked_user_to_accept_unknown_key = false; + _asked_user_to_trust_key = false; + _asked_user_to_import_key = false; + _asked_user_to_accept_ver_failed = false; + _asked_user_to_accept_unsigned_file = false; + } + + ~KeyRingReceive() + { + disconnect(); + } + + void answerAcceptVerFailed( bool answer ) + { _answer_ver_failed = answer; } + + bool askedAcceptVerFailed() const + { return _asked_user_to_accept_ver_failed; } + + void answerAcceptUnknownKey( bool answer ) + { _answer_accept_unknown_key = answer; } + + bool askedAcceptUnknownKey() const + { return _asked_user_to_accept_unknown_key; } + + void answerTrustKey( bool answer ) + { _answer_trust_key = answer; } + + bool askedTrustKey() const + { return _asked_user_to_trust_key; } + + void answerImportKey( bool answer ) + { _answer_import_key = answer; } + + bool askedImportKey() const + { return _asked_user_to_import_key; } + + void answerAcceptUnsignedFile( bool answer ) + { _answer_accept_unsigned_file = answer; } + + bool askedAcceptUnsignedFile() const + { return _asked_user_to_accept_unsigned_file; } + virtual bool askUserToAcceptUnsignedFile( const std::string &file ) { MIL << std::endl; - return true; + _asked_user_to_accept_unsigned_file = true; + return _answer_accept_unsigned_file; } + virtual bool askUserToAcceptUnknownKey( const std::string &file, const std::string &id ) { MIL << std::endl; - return true; + _asked_user_to_accept_unknown_key = true; + return _answer_accept_unknown_key; } virtual bool askUserToImportKey( const PublicKey &key ) { MIL << std::endl; - DBG << "By default zypp-query-pool does not import keys for now." << std::endl; - return false; + _asked_user_to_import_key = true; + return _answer_import_key; } virtual bool askUserToTrustKey( const PublicKey &key ) { MIL << std::endl; - return true; + _asked_user_to_trust_key = true; + return _answer_trust_key; } virtual bool askUserToAcceptVerificationFailed( const std::string &file, const PublicKey &key ) { MIL << std::endl; - return true; + _asked_user_to_accept_ver_failed = true; + return _answer_ver_failed; } + + // how to answer + bool _answer_accept_unknown_key; + bool _answer_trust_key; + bool _answer_import_key; + bool _answer_ver_failed; + bool _answer_accept_unsigned_file; + + // we use this variables to check that the + // callbacks were called + bool _asked_user_to_accept_unknown_key; + bool _asked_user_to_trust_key; + bool _asked_user_to_import_key; + bool _asked_user_to_accept_ver_failed; + bool _asked_user_to_accept_unsigned_file; }; -class KeyRingCallbacks -{ - -private: - KeyRingReceive _keyRingReport; - -public: - KeyRingCallbacks() - { - _keyRingReport.connect(); - } - - ~KeyRingCallbacks() - { - _keyRingReport.disconnect(); - } - -}; - +/** + * Keyring Signal Receiver with some features + * Allows to simulate and configure user answer + * Can record which callbacks were called + */ struct KeyRingSignalReceiver : callback::ReceiveReport { KeyRingSignalReceiver(/*RpmDb &rpmdb*/) @@ -330,33 +172,169 @@ struct KeyRingSignalReceiver : callback::ReceiveReport void keyring_test( const string &dir ) { - KeyRingCallbacks keyring_callbacks; - KeyRingSignalReceiver receiver; - // base sandbox for playing - TmpDir tmp_dir; + PublicKey key( Pathname(dir) + "public.asc" ); - KeyRing keyring( tmp_dir.path() ); + /** + * scenario #1 + * import a not trusted key + * ask for trust, answer yes + * ask for import, answer no + */ + { + KeyRingReceive keyring_callbacks; + KeyRingSignalReceiver receiver; + // base sandbox for playing + TmpDir tmp_dir; + KeyRing keyring( tmp_dir.path() ); + + BOOST_CHECK_EQUAL( keyring.publicKeys().size(), (unsigned) 0 ); + BOOST_CHECK_EQUAL( keyring.trustedPublicKeys().size(), (unsigned) 0 ); - // create a public key from the array - TmpFile file; - ofstream str(file.path().asString().c_str(),ofstream::out); - - if (!str.good()) - ZYPP_THROW(Exception("cant open file")); - - str << susekey; - str.flush(); - str.close(); - - PublicKey key( file.path() ); + keyring.importKey( key, false ); + + BOOST_CHECK_EQUAL( keyring.publicKeys().size(), (unsigned) 1 ); + BOOST_CHECK_EQUAL( keyring.trustedPublicKeys().size(), (unsigned) 0 ); + + BOOST_CHECK_MESSAGE( keyring.isKeyKnown( key.id() ), "Imported untrusted key should be known"); + BOOST_CHECK_MESSAGE( ! keyring.isKeyTrusted( key.id() ), "Imported untrusted key should be untrusted"); + + keyring_callbacks.answerTrustKey(true); + bool to_continue = keyring.verifyFileSignatureWorkflow( Pathname(dir) + "repomd.xml", "Blah Blah", Pathname(dir) + "repomd.xml.asc"); - keyring.importKey( key, false ); - BOOST_CHECK_EQUAL( keyring.publicKeys().size(), 1 ); - BOOST_CHECK_EQUAL( keyring.trustedPublicKeys().size(), 0 ); + BOOST_CHECK_MESSAGE( ! keyring_callbacks.askedAcceptUnknownKey(), "Should not ask for unknown key, it was known"); + BOOST_CHECK_MESSAGE( keyring_callbacks.askedTrustKey(), "Verify Signature Workflow with only 1 untrusted key should ask user wether to trust"); + BOOST_CHECK_MESSAGE( keyring_callbacks.askedImportKey(), "Trusting a key should ask for import"); + BOOST_CHECK_MESSAGE( ! keyring_callbacks.askedAcceptVerFailed(), "The signature validates"); + BOOST_CHECK_MESSAGE( ! keyring_callbacks.askedAcceptUnsignedFile(), "It is a signed file, so dont ask the opposite"); + + BOOST_CHECK_MESSAGE( to_continue, "We did not import, but we trusted and signature validates."); + } - keyring.importKey( key, true ); - BOOST_CHECK_EQUAL( receiver._trusted_key_added_called, true ); - BOOST_CHECK_EQUAL( keyring.trustedPublicKeys().size(), 1 ); + /** + * scenario #1.1 + * import a not trusted key + * ask for trust, answer yes + * ask for import, answer no + * vorrupt the file and check + */ + { + KeyRingReceive keyring_callbacks; + KeyRingSignalReceiver receiver; + // base sandbox for playing + TmpDir tmp_dir; + KeyRing keyring( tmp_dir.path() ); + + BOOST_CHECK_EQUAL( keyring.publicKeys().size(), (unsigned) 0 ); + BOOST_CHECK_EQUAL( keyring.trustedPublicKeys().size(), (unsigned) 0 ); + + keyring.importKey( key, false ); + + keyring_callbacks.answerTrustKey(true); + + // now we will recheck with a corrupted file + bool to_continue = keyring.verifyFileSignatureWorkflow( Pathname(dir) + "repomd.xml.corrupted", "Blah Blah", Pathname(dir) + "repomd.xml.asc"); + + // check wether the user got the right questions + BOOST_CHECK_MESSAGE( ! keyring_callbacks.askedAcceptUnknownKey(), "Should not ask for unknown key, it was known"); + BOOST_CHECK_MESSAGE( keyring_callbacks.askedTrustKey(), "Verify Signature Workflow with only 1 untrusted key should ask user wether to trust"); + BOOST_CHECK_MESSAGE( keyring_callbacks.askedImportKey(), "Trusting a key should ask for import"); + BOOST_CHECK_MESSAGE( keyring_callbacks.askedAcceptVerFailed(), "The signature does not validates"); + BOOST_CHECK_MESSAGE( ! keyring_callbacks.askedAcceptUnsignedFile(), "It is a signed file, so dont ask the opposite"); + + BOOST_CHECK_MESSAGE( ! to_continue, "We did not continue with a corrupted file"); + } + + /** + * scenario #1.2 + * import a not trusted key + * ask for trust, answer yes + * ask for import, answer no + * check without signature + */ + { + KeyRingReceive keyring_callbacks; + KeyRingSignalReceiver receiver; + // base sandbox for playing + TmpDir tmp_dir; + KeyRing keyring( tmp_dir.path() ); + + keyring.importKey( key, false ); + + keyring_callbacks.answerTrustKey(true); + // now we will recheck with a unsigned file + bool to_continue = keyring.verifyFileSignatureWorkflow( Pathname(dir) + "repomd.xml", "Blah Blah", Pathname() ); + + // check wether the user got the right questions + BOOST_CHECK_MESSAGE( ! keyring_callbacks.askedAcceptUnknownKey(), "Should not ask for unknown key, it was known"); + BOOST_CHECK_MESSAGE( ! keyring_callbacks.askedTrustKey(), "No signature, no key to trust"); + BOOST_CHECK_MESSAGE( ! keyring_callbacks.askedImportKey(), "No signature, no key to import"); + BOOST_CHECK_MESSAGE( keyring_callbacks.askedAcceptUnsignedFile(), "Ask the user wether to accept an unsigned file"); + BOOST_CHECK_MESSAGE( ! keyring_callbacks.askedAcceptVerFailed(), "There is no signature to verify"); + + BOOST_CHECK_MESSAGE( ! to_continue, "We did not continue with a unsigned file"); + } + + /** scenario #2 + * empty keyring + * should ask for unknown key + * answer no + */ + { + KeyRingReceive keyring_callbacks; + KeyRingSignalReceiver receiver; + // base sandbox for playing + TmpDir tmp_dir; + KeyRing keyring( tmp_dir.path() ); + + BOOST_CHECK_MESSAGE( ! keyring.isKeyKnown( key.id() ), "empty keyring has not known keys"); + + //keyring_callbacks.answerAcceptUnknownKey(true); + bool to_continue = keyring.verifyFileSignatureWorkflow( Pathname(dir) + "repomd.xml", "Blah Blah", Pathname(dir) + "repomd.xml.asc"); + BOOST_CHECK_MESSAGE(keyring_callbacks.askedAcceptUnknownKey(), "Should ask to accept unknown key, empty keyring"); + BOOST_CHECK_MESSAGE( ! keyring_callbacks.askedTrustKey(), "Unknown key cant be trusted"); + BOOST_CHECK_MESSAGE( ! keyring_callbacks.askedImportKey(), "Unknown key cant be imported"); + + BOOST_CHECK_MESSAGE( ! to_continue, "We answered no to accept unknown key"); + } + + /** scenario #3 + * import trusted key + * should ask nothing + * should emit signal + */ + { + KeyRingReceive keyring_callbacks; + KeyRingSignalReceiver receiver; + // base sandbox for playing + TmpDir tmp_dir; + KeyRing keyring( tmp_dir.path() ); + + BOOST_CHECK_EQUAL( keyring.publicKeys().size(), (unsigned) 0 ); + BOOST_CHECK_EQUAL( keyring.trustedPublicKeys().size(), (unsigned) 0 ); + + keyring.importKey( key, true ); + + BOOST_CHECK_EQUAL( receiver._trusted_key_added_called, true ); + + BOOST_CHECK_EQUAL( keyring.publicKeys().size(), (unsigned) 0 ); + BOOST_CHECK_EQUAL( keyring.trustedPublicKeys().size(), (unsigned) 1 ); + + BOOST_CHECK_MESSAGE( keyring.isKeyKnown( key.id() ), "Imported trusted key should be known"); + BOOST_CHECK_MESSAGE( keyring.isKeyTrusted( key.id() ), "Imported trusted key should be trusted"); + + bool to_continue = keyring.verifyFileSignatureWorkflow( Pathname(dir) + "repomd.xml", "Blah Blah", Pathname(dir) + "repomd.xml.asc"); + + BOOST_CHECK_MESSAGE( ! keyring_callbacks.askedAcceptUnknownKey(), "Should not ask for unknown key, it was known"); + BOOST_CHECK_MESSAGE( ! keyring_callbacks.askedTrustKey(), "Verify Signature Workflow with only 1 untrusted key should ask user wether to trust"); + BOOST_CHECK_MESSAGE( ! keyring_callbacks.askedImportKey(), "Trusting a key should ask for import"); + BOOST_CHECK_MESSAGE( ! keyring_callbacks.askedAcceptVerFailed(), "The signature validates"); + BOOST_CHECK_MESSAGE( ! keyring_callbacks.askedAcceptUnsignedFile(), "It is a signed file, so dont ask the opposite"); + + BOOST_CHECK_MESSAGE( to_continue, "We did not import, but we trusted and signature validates."); + } + //keyring.importKey( key, true ); + //BOOST_CHECK_EQUAL( receiver._trusted_key_added_called, true ); + //BOOST_CHECK_EQUAL( keyring.trustedPublicKeys().size(), 1 ); } test_suite* diff --git a/tests/zypp/data/KeyRing/repomd.xml.asc b/tests/zypp/data/KeyRing/repomd.xml.asc index b3f011a..9b68fbb 100644 --- a/tests/zypp/data/KeyRing/repomd.xml.asc +++ b/tests/zypp/data/KeyRing/repomd.xml.asc @@ -1,16 +1,7 @@ ------BEGIN PGP MESSAGE----- -Version: GnuPG v1.4.5 (GNU/Linux) +-----BEGIN PGP SIGNATURE----- +Version: GnuPG v1.4.6 (GNU/Linux) -owGtkz9oFEEUxs8cATlQSG2zLmiX253/88LeXWUawUobu/nzNrfk9vbY3ZMYECwi -pLCwiU3A1sreJrYW1kK0srNQrLR393JRFDEp0s18fO99M7+Z9+xKt7OydmSODz/s -X39z6VX3re2VOCty39/JJ5ujdyvJqFkED7CssmI6CEk/DgOcusJn061BeO/u5roO -R8NeclIVNOZpNQjHdT3biKJJNp3v9P18G/vo51GOtfGmNlFrDoe9IEjabVA/nOEg -LOoxlgu10SeFM3WTGIxLTAdhW7CoXJjas/W3dsNoaXZjdNvVPF82qsYmHHIQGtIY -pZAAhDe5QIGhdkyDcFYDWKGN0El0Wr1sVmc5VrXJZ0NClGIgZMyT6Ld64ipmOF3/ -V65UlghhvCOoJKWpAkk1B0TOQAoqmFGglBRJ9EeLBYyoveLfWNJsgpOsqquz0Pwy -ngsPUdygl56nqdUubc5HrGwkJpRD4i1LEWJuLhoPAU2s8haooKC4ltCmKcI5sx4l -pAY4Zc6cG8+szHJTPjwLztJ2HjTUKGrRImiVWkmYVMyDt4oRGiMIAwAp4cxf+M8x -jGpL0JHUWAKiCYeYCUeap+CMx4jUgrP+P2iS6GQMh739UXe1087v6Wyvrex+6xyu -fv3xZO/5zU97919eff+leHR069px58XG9urTy3duHxx8PLjxef/1941u+fgn -=9GUB ------END PGP MESSAGE----- +iD8DBQBGQFwzvWHYm9mIIb4RAnbuAJsHJkj5X8M5aOxeZ2KUsHjhQ1vKOACdFrQ0 +Vxp3Zznn3w4j5SaGAqpyGWA= +=iu9H +-----END PGP SIGNATURE----- diff --git a/tests/zypp/data/KeyRing/repomd.xml.corrupted b/tests/zypp/data/KeyRing/repomd.xml.corrupted new file mode 100644 index 0000000..b655532 --- /dev/null +++ b/tests/zypp/data/KeyRing/repomd.xml.corrupted @@ -0,0 +1,21 @@ + + + + + 49589f0e6569914ada9293e8c3895cb899b58a58 + 1177395604 + 67b855adc1e7622f7962849ee43965253a797765 + + + + 4174aed6d4ffb8cfee41b64ae357ce1db3fe904a + 1177395604 + 1981b7db9252974869ce1d71443bde69fa9423ca + + + + 2a72bebe987fb613673d9db73120e95a999f143d + 1177395604 + 6a328b1ec1fab195fb69035c13fe4340ee2b9cbd + + diff --git a/zypp/KeyRing.cc b/zypp/KeyRing.cc index a7382e9..d5353d0 100644 --- a/zypp/KeyRing.cc +++ b/zypp/KeyRing.cc @@ -39,26 +39,12 @@ namespace zypp IMPL_PTR_TYPE(KeyRing); - static void dumpRegexpResults( const str::smatch &what ) - { - for ( unsigned int k=0; k < what.size(); k++) - { - XXX << "[match "<< k << "] [" << what[k] << "]" << std::endl; - } - } - static bool printLine( const std::string &line ) { MIL << line << std::endl; return true; } - static void dumpFile(const Pathname &file) - { - std::ifstream is(file.asString().c_str()); - iostr::forEachLine( is, printLine); - } - namespace { bool _keyRingDefaultAccept( getenv("ZYPP_KEYRING_DEFAULT_ACCEPT_ALL") ); @@ -168,8 +154,6 @@ namespace zypp void KeyRing::Impl::importKey( const PublicKey &key, bool trusted) { - callback::SendReport emitSignal; - importKey( key.path(), trusted ? trustedKeyRing() : generalKeyRing() ); } @@ -205,6 +189,7 @@ namespace zypp bool KeyRing::Impl::isKeyKnown( const std::string &id ) { + MIL << std::endl; if ( publicKeyExists( id, trustedKeyRing() ) ) return true; else @@ -285,7 +270,7 @@ namespace zypp bool KeyRing::Impl::verifyFileSignatureWorkflow( const Pathname &file, const std::string filedesc, const Pathname &signature) { callback::SendReport report; - callback::SendReport emitSignal; + //callback::SendReport emitSignal; MIL << "Going to verify signature for " << file << " with " << signature << std::endl; // if signature does not exists, ask user if he wants to accept unsigned file. @@ -329,8 +314,7 @@ namespace zypp if ( report->askUserToImportKey( key ) ) { MIL << "User wants to import key " << id << " " << key.name() << std::endl; - importKey( key.path(), trustedKeyRing() ); - emitSignal->trustedKeyAdded( (const KeyRing &)(*this), key ); + importKey( key, true ); which_keyring = trustedKeyRing(); } else @@ -386,6 +370,9 @@ namespace zypp std::list KeyRing::Impl::publicKeys(const Pathname &keyring) { + static str::regex rxColons("^([^:]*):([^:]*):([^:]*):([^:]*):([^:]*):([^:]*):([^:]*):([^:]*):([^:]*):([^:]*):([^:]*):([^:]*):\n$"); + static str::regex rxColonsFpr("^([^:]*):([^:]*):([^:]*):([^:]*):([^:]*):([^:]*):([^:]*):([^:]*):([^:]*):([^:]*):\n$"); + const char* argv[] = { "gpg", @@ -409,9 +396,6 @@ namespace zypp std::string line; int count = 0; - str::regex rxColons("^([^:]*):([^:]*):([^:]*):([^:]*):([^:]*):([^:]*):([^:]*):([^:]*):([^:]*):([^:]*):([^:]*):([^:]*):\n$"); - str::regex rxColonsFpr("^([^:]*):([^:]*):([^:]*):([^:]*):([^:]*):([^:]*):([^:]*):([^:]*):([^:]*):([^:]*):\n$"); - for(line = prog.receiveLine(), count=0; !line.empty(); line = prog.receiveLine(), count++ ) { //MIL << line << std::endl; @@ -632,7 +616,11 @@ namespace zypp void KeyRing::importKey( const PublicKey &key, bool trusted ) { + callback::SendReport emitSignal; _pimpl->importKey( key.path(), trusted ); + + if ( trusted ) + emitSignal->trustedKeyAdded( (const KeyRing &)(*this), key ); } std::string KeyRing::readSignatureKeyId( const Pathname &signature ) @@ -682,7 +670,7 @@ namespace zypp bool KeyRing::isKeyKnown( const std::string &id ) { - return _pimpl->isKeyTrusted(id); + return _pimpl->isKeyKnown(id); } ///////////////////////////////////////////////////////////////// diff --git a/zypp/target/rpm/RpmDb.cc b/zypp/target/rpm/RpmDb.cc index f11c27c..92a84d6 100644 --- a/zypp/target/rpm/RpmDb.cc +++ b/zypp/target/rpm/RpmDb.cc @@ -89,9 +89,17 @@ struct KeyRingSignalReceiver : callback::ReceiveReport virtual void trustedKeyAdded( const KeyRing &keyring, const PublicKey &key ) { - MIL << "trusted key added to zypp Keyring. Syncronizing keys with rpm keyring" << std::endl; - _rpmdb.importZyppKeyRingTrustedKeys(); - _rpmdb.exportTrustedKeysInZyppKeyRing(); + MIL << "trusted key added to zypp Keyring. Importing" << std::endl; + // now import the key in rpm + try + { + _rpmdb.importPubkey( key.path() ); + MIL << "Trusted key " << key.id() << " (" << key.name() << ") imported in rpm database." << std::endl; + } + catch (RpmException &e) + { + ERR << "Could not import key " << key.id() << " (" << key.name() << " from " << key.path() << " in rpm database" << std::endl; + } } virtual void trustedKeyRemoved( const KeyRing &keyring, const PublicKey &key ) -- 2.7.4