Fixed problems resulting from .gnupg pathname fix ENGINE-427
authorKrista Bennett <krista@pep-project.org>
Tue, 14 Aug 2018 08:55:46 +0200
branchENGINE-427
changeset 28217fe5b66e570d
parent 2796 91818b883629
parent 2816 0289b8c43cc0
child 2822 a33bdd73952a
child 2823 f56e57460c61
Fixed problems resulting from .gnupg pathname fix
src/pgp_gpg.c
test/include/EngineTestSuite.h
test/src/EngineTestSuite.cc
test/src/SuiteMaker.cc
test/src/engine_tests/GPGConfFixTests.cc
     1.1 --- a/.hgtags	Tue Jul 31 21:45:20 2018 +0200
     1.2 +++ b/.hgtags	Tue Aug 14 08:55:46 2018 +0200
     1.3 @@ -5,3 +5,4 @@
     1.4  3efe9ded2561d3f6d406acbcbcee01b823cb4de8 for_Outlook-1.1.10
     1.5  fa00137505b8528c77efe8df40963f5fef452cad 0.9.0 release
     1.6  b70a6082836b89f8718b23dcba0624d6db318033 ENGINE-323 fixed
     1.7 +d958333b87d0cdda1bb02f50173f1207baade54a Release 1.0.441
     2.1 --- a/build-mac/pEpEngine.xcodeproj/project.pbxproj	Tue Jul 31 21:45:20 2018 +0200
     2.2 +++ b/build-mac/pEpEngine.xcodeproj/project.pbxproj	Tue Aug 14 08:55:46 2018 +0200
     2.3 @@ -686,7 +686,7 @@
     2.4  		64796A371B455AA5004B1C24 /* Project object */ = {
     2.5  			isa = PBXProject;
     2.6  			attributes = {
     2.7 -				LastUpgradeCheck = 0920;
     2.8 +				LastUpgradeCheck = 0940;
     2.9  				ORGANIZATIONNAME = "Edouard Tisserant";
    2.10  				TargetAttributes = {
    2.11  					644297BE1BE11C65002BC73B = {
    2.12 @@ -932,12 +932,14 @@
    2.13  				CLANG_WARN_BOOL_CONVERSION = YES;
    2.14  				CLANG_WARN_COMMA = YES;
    2.15  				CLANG_WARN_CONSTANT_CONVERSION = YES;
    2.16 +				CLANG_WARN_DEPRECATED_OBJC_IMPLEMENTATIONS = YES;
    2.17  				CLANG_WARN_DIRECT_OBJC_ISA_USAGE = YES_ERROR;
    2.18  				CLANG_WARN_EMPTY_BODY = YES;
    2.19  				CLANG_WARN_ENUM_CONVERSION = YES;
    2.20  				CLANG_WARN_INFINITE_RECURSION = YES;
    2.21  				CLANG_WARN_INT_CONVERSION = YES;
    2.22  				CLANG_WARN_NON_LITERAL_NULL_CONVERSION = YES;
    2.23 +				CLANG_WARN_OBJC_IMPLICIT_RETAIN_SELF = YES;
    2.24  				CLANG_WARN_OBJC_LITERAL_CONVERSION = YES;
    2.25  				CLANG_WARN_OBJC_ROOT_CLASS = YES_ERROR;
    2.26  				CLANG_WARN_RANGE_LOOP_ANALYSIS = YES;
    2.27 @@ -993,12 +995,14 @@
    2.28  				CLANG_WARN_BOOL_CONVERSION = YES;
    2.29  				CLANG_WARN_COMMA = YES;
    2.30  				CLANG_WARN_CONSTANT_CONVERSION = YES;
    2.31 +				CLANG_WARN_DEPRECATED_OBJC_IMPLEMENTATIONS = YES;
    2.32  				CLANG_WARN_DIRECT_OBJC_ISA_USAGE = YES_ERROR;
    2.33  				CLANG_WARN_EMPTY_BODY = YES;
    2.34  				CLANG_WARN_ENUM_CONVERSION = YES;
    2.35  				CLANG_WARN_INFINITE_RECURSION = YES;
    2.36  				CLANG_WARN_INT_CONVERSION = YES;
    2.37  				CLANG_WARN_NON_LITERAL_NULL_CONVERSION = YES;
    2.38 +				CLANG_WARN_OBJC_IMPLICIT_RETAIN_SELF = YES;
    2.39  				CLANG_WARN_OBJC_LITERAL_CONVERSION = YES;
    2.40  				CLANG_WARN_OBJC_ROOT_CLASS = YES_ERROR;
    2.41  				CLANG_WARN_RANGE_LOOP_ANALYSIS = YES;
     3.1 --- a/src/keymanagement.c	Tue Jul 31 21:45:20 2018 +0200
     3.2 +++ b/src/keymanagement.c	Tue Aug 14 08:55:46 2018 +0200
     3.3 @@ -1704,6 +1704,15 @@
     3.4      if (status != PEP_STATUS_OK && status != PEP_GET_KEY_FAILED && status != PEP_KEY_UNSUITABLE)
     3.5          return status;
     3.6      status = PEP_STATUS_OK;
     3.7 +
     3.8 +    bool private = false;
     3.9 +    status = contains_priv_key(session, fpr, &private);
    3.10 +    
    3.11 +    if (status != PEP_STATUS_OK)
    3.12 +        return status;
    3.13 +        
    3.14 +    if (!private)
    3.15 +        return PEP_KEY_UNSUITABLE;
    3.16   
    3.17      if (me->fpr)
    3.18          free(me->fpr);
     4.1 --- a/src/pgp_gpg.c	Tue Jul 31 21:45:20 2018 +0200
     4.2 +++ b/src/pgp_gpg.c	Tue Aug 14 08:55:46 2018 +0200
     4.3 @@ -1559,11 +1559,8 @@
     4.4                      break;
     4.5                  case GPG_ERR_INV_VALUE:
     4.6                      return PEP_ILLEGAL_VALUE;
     4.7 -                case GPG_ERR_GENERAL:
     4.8 +                default:
     4.9                      return PEP_CANNOT_CREATE_KEY;
    4.10 -                default:
    4.11 -                    assert(0);
    4.12 -                    return PEP_UNKNOWN_ERROR;
    4.13              }
    4.14  
    4.15              /* This is the same regardless of whether we got it from genkey or createkey */
     5.1 --- a/test/convenience_scripts/DANGER_delete_keys_silently_w_pattern.py	Tue Jul 31 21:45:20 2018 +0200
     5.2 +++ b/test/convenience_scripts/DANGER_delete_keys_silently_w_pattern.py	Tue Aug 14 08:55:46 2018 +0200
     5.3 @@ -9,7 +9,7 @@
     5.4  
     5.5  args = parser.parse_args()
     5.6  
     5.7 -homedir = os.path.join(os.path.expanduser('~'),".gnupg")
     5.8 +homedir = os.path.join(os.path.expanduser('~'),"gnupg")
     5.9  print("GNUPGHOME=" + homedir + "\n")
    5.10  
    5.11  try:
     6.1 --- a/test/convenience_scripts/keygen_for_test.py	Tue Jul 31 21:45:20 2018 +0200
     6.2 +++ b/test/convenience_scripts/keygen_for_test.py	Tue Aug 14 08:55:46 2018 +0200
     6.3 @@ -16,7 +16,7 @@
     6.4  pub_path = os.path.join(args.output_root, "pub")
     6.5  priv_path = os.path.join(args.output_root, "priv")
     6.6  
     6.7 -homedir = os.path.join(os.path.expanduser('~'),".gnupg")
     6.8 +homedir = os.path.join(os.path.expanduser('~'),"gnupg")
     6.9  print("GNUPGHOME=" + homedir + "\n")
    6.10  
    6.11  try:
     7.1 --- a/test/include/EngineTestSuite.h	Tue Jul 31 21:45:20 2018 +0200
     7.2 +++ b/test/include/EngineTestSuite.h	Tue Aug 14 08:55:46 2018 +0200
     7.3 @@ -40,11 +40,11 @@
     7.4          virtual void tear_down();
     7.5          
     7.6          void set_full_env();
     7.7 -	    void set_full_env(const char* gpg_conf_copy_path, const char* gpg_agent_conf_file_copy_path, const char* db_conf_file_copy_path);
     7.8 +	void set_full_env(const char* gpg_conf_copy_path, const char* gpg_agent_conf_file_copy_path, const char* db_conf_file_copy_path);
     7.9          void restore_full_env();
    7.10          void initialise_test_home();
    7.11          void set_my_name();    
    7.12  	
    7.13 -	    void copy_conf_file_to_test_dir(const char* dest_path, const char* conf_orig_path, const char* conf_dest_name);
    7.14 +	void copy_conf_file_to_test_dir(const char* dest_path, const char* conf_orig_path, const char* conf_dest_name);
    7.15  };
    7.16  #endif
     8.1 --- a/test/python_tests/setup_test.py	Tue Jul 31 21:45:20 2018 +0200
     8.2 +++ b/test/python_tests/setup_test.py	Tue Aug 14 08:55:46 2018 +0200
     8.3 @@ -38,7 +38,7 @@
     8.4      "create own identities as part of the test setup"
     8.5  
     8.6      os.environ["HOME"] = os.path.join(mydir, arthome)
     8.7 -    os.environ["GNUPGHOME"] = os.path.join(mydir, arthome, '.gnupg')
     8.8 +    os.environ["GNUPGHOME"] = os.path.join(mydir, arthome, 'gnupg')
     8.9  
    8.10      import pEp
    8.11      me = pEp.Identity()
     9.1 --- a/test/python_tests/test_handshake.py	Tue Jul 31 21:45:20 2018 +0200
     9.2 +++ b/test/python_tests/test_handshake.py	Tue Aug 14 08:55:46 2018 +0200
     9.3 @@ -20,7 +20,7 @@
     9.4          arthome = "test1"
     9.5  
     9.6          os.environ["HOME"] = os.path.join(mydir, arthome)
     9.7 -        os.environ["GNUPGHOME"] = os.path.join(mydir, arthome, '.gnupg')
     9.8 +        os.environ["GNUPGHOME"] = os.path.join(mydir, arthome, 'gnupg')
     9.9  
    9.10          os.chdir(os.path.join(mydir, arthome))
    9.11  
    9.12 @@ -79,7 +79,7 @@
    9.13          arthome = "test2"
    9.14  
    9.15          os.environ["HOME"] = os.path.join(mydir, arthome)
    9.16 -        os.environ["GNUPGHOME"] = os.path.join(mydir, arthome, '.gnupg')
    9.17 +        os.environ["GNUPGHOME"] = os.path.join(mydir, arthome, 'gnupg')
    9.18  
    9.19          os.chdir(os.path.join(mydir, arthome))
    9.20  
    10.1 --- a/test/src/EngineTestSuite.cc	Tue Jul 31 21:45:20 2018 +0200
    10.2 +++ b/test/src/EngineTestSuite.cc	Tue Aug 14 08:55:46 2018 +0200
    10.3 @@ -119,15 +119,21 @@
    10.4      cout << "home is " << home << endl;
    10.5      assert(temp_test_home.compare(home) != 0);
    10.6      assert(temp_test_home.compare(home + "/") != 0);
    10.7 -    assert(temp_test_home.compare(home + "") != 0);
    10.8 +    assert(temp_test_home.compare(home + "/.gnupg") != 0); // This is an EXCLUSION test, so we leave this.
    10.9      assert(temp_test_home.compare(home + ".gnupg") != 0);
   10.10 +    assert(temp_test_home.compare(home + "/gnupg") != 0);
   10.11 +    assert(temp_test_home.compare(home + "gnupg") != 0);
   10.12      assert(temp_test_home.compare(prev_gpg_home) != 0);
   10.13 +    assert(temp_test_home.compare(prev_gpg_home + "/gnupg") != 0);
   10.14 +    assert(temp_test_home.compare(prev_gpg_home + "gnupg") != 0);
   10.15      assert(temp_test_home.compare(prev_gpg_home + "/.gnupg") != 0);
   10.16      assert(temp_test_home.compare(prev_gpg_home + ".gnupg") != 0);
   10.17  
   10.18      if (temp_test_home.compare(home) == 0 || temp_test_home.compare(home + "/") == 0 ||
   10.19 +        temp_test_home.compare(home + "/gnupg") == 0 || temp_test_home.compare(home + "gnupg") == 0 ||
   10.20          temp_test_home.compare(home + "/.gnupg") == 0 || temp_test_home.compare(home + ".gnupg") == 0 ||
   10.21 -        temp_test_home.compare(prev_gpg_home) == 0 || temp_test_home.compare(prev_gpg_home + "/.gnupg") == 0 ||
   10.22 +        temp_test_home.compare(prev_gpg_home) == 0 || temp_test_home.compare(prev_gpg_home + "/gnupg") == 0 ||
   10.23 +        temp_test_home.compare(prev_gpg_home + "gnupg") == 0 || temp_test_home.compare(prev_gpg_home + "/.gnupg") == 0 ||
   10.24          temp_test_home.compare(prev_gpg_home + ".gnupg") == 0)
   10.25          throw std::runtime_error("SETUP: new GNUPGHOME threatens to mess up user GNUPGHOME (and delete all their keys). NO DICE.");
   10.26      
   10.27 @@ -135,7 +141,7 @@
   10.28      
   10.29      struct stat buf;
   10.30      
   10.31 -    success = setenv("GNUPGHOME", (temp_test_home + "/.gnupg").c_str(), 1);
   10.32 +    success = setenv("GNUPGHOME", (temp_test_home + "/gnupg").c_str(), 1);
   10.33      if (success != 0)
   10.34          throw std::runtime_error("SETUP: Error when setting GNUPGHOME.");
   10.35  
   10.36 @@ -146,9 +152,9 @@
   10.37          throw std::runtime_error("SETUP: Cannot set test_home for init.");
   10.38  
   10.39      if (gpg_conf_copy_path)
   10.40 -        copy_conf_file_to_test_dir((temp_test_home + "/.gnupg").c_str(), gpg_conf_copy_path, "gpg.conf");
   10.41 +        copy_conf_file_to_test_dir((temp_test_home + "/gnupg").c_str(), gpg_conf_copy_path, "gpg.conf");
   10.42      if (gpg_agent_conf_file_copy_path)        
   10.43 -        copy_conf_file_to_test_dir((temp_test_home + "/.gnupg").c_str(), gpg_agent_conf_file_copy_path, "gpg-agent.conf");
   10.44 +        copy_conf_file_to_test_dir((temp_test_home + "/gnupg").c_str(), gpg_agent_conf_file_copy_path, "gpg-agent.conf");
   10.45      if (db_conf_file_copy_path)
   10.46          copy_conf_file_to_test_dir(temp_test_home.c_str(), db_conf_file_copy_path, ".pEp_management.db");
   10.47          
   10.48 @@ -198,3 +204,4 @@
   10.49  void EngineTestSuite::set_my_name() {
   10.50      my_name = typeid(*this).name();
   10.51  }
   10.52 +
    11.1 --- a/test/src/engine_tests/GPGConfFixTests.cc	Tue Jul 31 21:45:20 2018 +0200
    11.2 +++ b/test/src/engine_tests/GPGConfFixTests.cc	Tue Aug 14 08:55:46 2018 +0200
    11.3 @@ -96,72 +96,72 @@
    11.4  
    11.5  void GPGConfFixTests::check_conf_fix_broken_conf_old_db_0() {
    11.6      set_full_env("test_files/427_bad_gpg_conf_0", NULL, "test_files/427_old_db");
    11.7 -    TEST_ASSERT(file_bytes_equal("test_files/427_fixed_gpg_conf_0", (temp_test_home + "/.gnupg/gpg.conf").c_str()));
    11.8 +    TEST_ASSERT(file_bytes_equal("test_files/427_fixed_gpg_conf_0", (temp_test_home + "/gnupg/gpg.conf").c_str()));
    11.9  }
   11.10  
   11.11  void GPGConfFixTests::check_conf_fix_broken_conf_old_db_1() {
   11.12      set_full_env("test_files/427_bad_gpg_conf_1", NULL, "test_files/427_old_db");    
   11.13 -    TEST_ASSERT(file_bytes_equal("test_files/427_fixed_gpg_conf_1", (temp_test_home + "/.gnupg/gpg.conf").c_str()));
   11.14 +    TEST_ASSERT(file_bytes_equal("test_files/427_fixed_gpg_conf_1", (temp_test_home + "/gnupg/gpg.conf").c_str()));
   11.15      
   11.16  }
   11.17  
   11.18  void GPGConfFixTests::check_conf_fix_broken_conf_old_db_2() {
   11.19      set_full_env("test_files/427_bad_gpg_conf_2", NULL, "test_files/427_old_db");        
   11.20 -    TEST_ASSERT(file_bytes_equal("test_files/427_fixed_gpg_conf_2", (temp_test_home + "/.gnupg/gpg.conf").c_str()));    
   11.21 +    TEST_ASSERT(file_bytes_equal("test_files/427_fixed_gpg_conf_2", (temp_test_home + "/gnupg/gpg.conf").c_str()));    
   11.22  }
   11.23  
   11.24  void GPGConfFixTests::check_conf_fix_broken_conf_old_db_3() {
   11.25      set_full_env("test_files/427_bad_gpg_conf_3", NULL, "test_files/427_old_db");    
   11.26 -    TEST_ASSERT(file_bytes_equal("test_files/427_fixed_gpg_conf_3", (temp_test_home + "/.gnupg/gpg.conf").c_str()));    
   11.27 +    TEST_ASSERT(file_bytes_equal("test_files/427_fixed_gpg_conf_3", (temp_test_home + "/gnupg/gpg.conf").c_str()));    
   11.28  }
   11.29  
   11.30  void GPGConfFixTests::check_conf_fix_broken_conf_old_db_4() {
   11.31      set_full_env("test_files/427_bad_gpg_conf_4", NULL, "test_files/427_old_db");        
   11.32 -    TEST_ASSERT(file_bytes_equal("test_files/427_fixed_gpg_conf_4", (temp_test_home + "/.gnupg/gpg.conf").c_str()));    
   11.33 +    TEST_ASSERT(file_bytes_equal("test_files/427_fixed_gpg_conf_4", (temp_test_home + "/gnupg/gpg.conf").c_str()));    
   11.34  }
   11.35  
   11.36  void GPGConfFixTests::check_conf_fix_broken_conf_old_db_5() {
   11.37      set_full_env("test_files/427_bad_gpg_conf_5", NULL, "test_files/427_old_db");        
   11.38 -    TEST_ASSERT(file_bytes_equal("test_files/427_fixed_gpg_conf_5", (temp_test_home + "/.gnupg/gpg.conf").c_str()));    
   11.39 +    TEST_ASSERT(file_bytes_equal("test_files/427_fixed_gpg_conf_5", (temp_test_home + "/gnupg/gpg.conf").c_str()));    
   11.40  }
   11.41  
   11.42  void GPGConfFixTests::check_conf_fix_broken_conf_old_db_6() {
   11.43      set_full_env("test_files/427_bad_gpg_conf_6", NULL, "test_files/427_old_db");        
   11.44 -    TEST_ASSERT(file_bytes_equal("test_files/427_fixed_gpg_conf_6", (temp_test_home + "/.gnupg/gpg.conf").c_str()));    
   11.45 +    TEST_ASSERT(file_bytes_equal("test_files/427_fixed_gpg_conf_6", (temp_test_home + "/gnupg/gpg.conf").c_str()));    
   11.46  }
   11.47  
   11.48  void GPGConfFixTests::check_conf_fix_broken_agent_conf_old_db_0() {
   11.49      set_full_env(NULL, "test_files/450_bad_gpgagent_conf_0", "test_files/427_old_db");
   11.50 -    TEST_ASSERT(file_bytes_equal("test_files/450_good_gpgagent_conf_0", (temp_test_home + "/.gnupg/gpg-agent.conf").c_str()));
   11.51 +    TEST_ASSERT(file_bytes_equal("test_files/450_good_gpgagent_conf_0", (temp_test_home + "/gnupg/gpg-agent.conf").c_str()));
   11.52  }
   11.53  
   11.54  void GPGConfFixTests::check_conf_fix_broken_agent_conf_old_db_1() {
   11.55      set_full_env(NULL, "test_files/450_bad_gpgagent_conf_1", "test_files/427_old_db");    
   11.56 -    TEST_ASSERT(file_bytes_equal("test_files/450_good_gpgagent_conf_1", (temp_test_home + "/.gnupg/gpg-agent.conf").c_str()));
   11.57 +    TEST_ASSERT(file_bytes_equal("test_files/450_good_gpgagent_conf_1", (temp_test_home + "/gnupg/gpg-agent.conf").c_str()));
   11.58      
   11.59  }
   11.60  
   11.61  void GPGConfFixTests::check_conf_fix_broken_agent_conf_old_db_2() {
   11.62      set_full_env(NULL, "test_files/450_bad_gpgagent_conf_2", "test_files/427_old_db");        
   11.63 -    TEST_ASSERT(file_bytes_equal("test_files/450_good_gpgagent_conf_2", (temp_test_home + "/.gnupg/gpg-agent.conf").c_str()));    
   11.64 +    TEST_ASSERT(file_bytes_equal("test_files/450_good_gpgagent_conf_2", (temp_test_home + "/gnupg/gpg-agent.conf").c_str()));    
   11.65  }
   11.66  
   11.67  void GPGConfFixTests::check_conf_fix_broken_agent_conf_old_db_3() {
   11.68      set_full_env(NULL, "test_files/450_bad_gpgagent_conf_3", "test_files/427_old_db");    
   11.69 -    TEST_ASSERT(file_bytes_equal("test_files/450_good_gpgagent_conf_3", (temp_test_home + "/.gnupg/gpg-agent.conf").c_str()));    
   11.70 +    TEST_ASSERT(file_bytes_equal("test_files/450_good_gpgagent_conf_3", (temp_test_home + "/gnupg/gpg-agent.conf").c_str()));    
   11.71  }
   11.72  
   11.73  void GPGConfFixTests::check_conf_fix_broken_agent_conf_old_db_4() {
   11.74      set_full_env(NULL, "test_files/450_bad_gpgagent_conf_4", "test_files/427_old_db");        
   11.75 -    TEST_ASSERT(file_bytes_equal("test_files/450_good_gpgagent_conf_4", (temp_test_home + "/.gnupg/gpg-agent.conf").c_str()));    
   11.76 +    TEST_ASSERT(file_bytes_equal("test_files/450_good_gpgagent_conf_4", (temp_test_home + "/gnupg/gpg-agent.conf").c_str()));    
   11.77  }
   11.78  
   11.79  void GPGConfFixTests::check_conf_fix_broken_agent_conf_old_db_5() {
   11.80      set_full_env(NULL, "test_files/450_bad_gpgagent_conf_5", "test_files/427_old_db");        
   11.81 -    TEST_ASSERT(file_bytes_equal("test_files/450_good_gpgagent_conf_5", (temp_test_home + "/.gnupg/gpg-agent.conf").c_str()));    
   11.82 +    TEST_ASSERT(file_bytes_equal("test_files/450_good_gpgagent_conf_5", (temp_test_home + "/gnupg/gpg-agent.conf").c_str()));    
   11.83  }
   11.84  
   11.85  void GPGConfFixTests::check_conf_fix_broken_agent_conf_old_db_6() {
   11.86      set_full_env(NULL, "test_files/450_bad_gpgagent_conf_6", "test_files/427_old_db");        
   11.87 -    TEST_ASSERT(file_bytes_equal("test_files/450_good_gpgagent_conf_6", (temp_test_home + "/.gnupg/gpg-agent.conf").c_str()));    
   11.88 +    TEST_ASSERT(file_bytes_equal("test_files/450_good_gpgagent_conf_6", (temp_test_home + "/gnupg/gpg-agent.conf").c_str()));    
   11.89  }