Changeset d932cb369c8c7f2d18dd1310a3729834040ea4d3

Show
Ignore:
Timestamp:
02/14/09 16:23:59 (4 years ago)
Author:
Armin Burgmeier <armin@…>
Parents:
4c745f3d1d18e682c548c17d59430a68ef85955a
Children:
07e49776a394a41e8274c44947bedb7e3d0d441e
git-committer:
Armin Burgmeier <armin@arbur.net> / 2009-02-14T16:23:59Z+0100
Message:

Added /etc/ssl/certs/ca-certificates.crt as default trust file

2009-02-14 Armin Burgmeier <armin@…>

  • code/util/config.hpp:
  • code/util/config.cpp: Added ParentEntry::has_value().
  • code/core/preferences.cpp: Added /etc/ssl/certs/ca-certificates.crt as default value for the trust-file, if the file exists.
Files:
4 modified

Legend:

Unmodified
Added
Removed
  • ChangeLog

    r4c745f3 rd932cb3  
     12009-02-14  Armin Burgmeier  <armin@arbur.net> 
     2 
     3        * code/util/config.hpp: 
     4        * code/util/config.cpp: Added ParentEntry::has_value(). 
     5 
     6        * code/core/preferences.cpp: Added /etc/ssl/certs/ca-certificates.crt 
     7        as default value for the trust-file, if the file exists. 
     8 
    192009-02-03  Armin Burgmeier  <armin@arbur.net> 
    210 
  • code/core/preferences.cpp

    r6b79c69 rd932cb3  
    110110 
    111111Gobby::Preferences::Security::Security(Config::ParentEntry& entry): 
    112         trust_file(entry.get_value<std::string>("trust-file", "")), 
     112        trust_file(entry.get_value<std::string>("trust-file")), 
    113113        policy(static_cast<InfXmppConnectionSecurityPolicy>( 
    114114                entry.get_value<int>("policy", static_cast<int>( 
    115115                        INF_XMPP_CONNECTION_SECURITY_BOTH_PREFER_TLS)))) 
    116116{ 
     117        // Load default trust-file. As this accesses the filesystem, only do 
     118        // it when we really need it, i.e. when starting Gobby the first time. 
     119        if(!entry.has_value("trust-file")) 
     120        { 
     121#ifdef G_OS_WIN32 
     122                gchar* package_directory = 
     123                        g_win32_get_package_installation_directory_of_module( 
     124                                NULL); 
     125 
     126                trust_file = Glib::build_filename( 
     127                        Glib::build_filename(package_directory, "certs"), 
     128                        "ca-certificates.crt"); 
     129 
     130                g_free(package_directory); 
     131#else 
     132                // This seems to be the default location for both 
     133                // Debian and Gentoo. I don't know about other distributions. 
     134                // Maybe they need a distro-patch for this. 
     135                const std::string DEFAULT_TRUST_FILE = 
     136                        "/etc/ssl/certs/ca-certificates.crt"; 
     137                if(Glib::file_test(DEFAULT_TRUST_FILE, 
     138                                   Glib::FILE_TEST_IS_REGULAR)) 
     139                { 
     140                        trust_file = DEFAULT_TRUST_FILE; 
     141                } 
     142#endif 
     143        } 
    117144} 
    118145 
  • code/util/config.cpp

    r6b79c69 rd932cb3  
    141141} 
    142142 
     143bool Gobby::Config::ParentEntry::has_value(const Glib::ustring& name) 
     144{ 
     145        return get_value_child(name) != NULL; 
     146} 
     147 
    143148Gobby::Config::ParentEntry& Gobby::Config::ParentEntry:: 
    144149        operator[](const Glib::ustring& name) 
  • code/util/config.hpp

    r6b79c69 rd932cb3  
    4444        public: 
    4545                Entry(const Glib::ustring& name); 
    46                 virtual ~Entry() {} // compiler complains without 
     46                virtual ~Entry() {} 
    4747 
    4848                /** @brief Saves this entry into the given element. 
     
    202202                get_value_child(const Glib::ustring& name) const; 
    203203 
     204                /** @brief: Returns whether there is a child ValueEntry with 
     205                 * the given name. 
     206                 */ 
     207                bool has_value(const Glib::ustring& name); 
     208 
    204209                /** @brief Returns the value from the child with the given 
    205210                 * name.