Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(189)

Side by Side Diff: crypto/nss_util.cc

Issue 8143012: Fix library paths for preloading NSS on Ubuntu 11.10. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 9 years, 2 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2011 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include "crypto/nss_util.h" 5 #include "crypto/nss_util.h"
6 #include "crypto/nss_util_internal.h" 6 #include "crypto/nss_util_internal.h"
7 7
8 #include <nss.h> 8 #include <nss.h>
9 #include <plarena.h> 9 #include <plarena.h>
10 #include <prerror.h> 10 #include <prerror.h>
(...skipping 11 matching lines...) Expand all
22 22
23 #include "base/environment.h" 23 #include "base/environment.h"
24 #include "base/file_path.h" 24 #include "base/file_path.h"
25 #include "base/file_util.h" 25 #include "base/file_util.h"
26 #include "base/lazy_instance.h" 26 #include "base/lazy_instance.h"
27 #include "base/logging.h" 27 #include "base/logging.h"
28 #include "base/memory/scoped_ptr.h" 28 #include "base/memory/scoped_ptr.h"
29 #include "base/native_library.h" 29 #include "base/native_library.h"
30 #include "base/stringprintf.h" 30 #include "base/stringprintf.h"
31 #include "base/threading/thread_restrictions.h" 31 #include "base/threading/thread_restrictions.h"
32 #include "build/build_config.h"
32 #include "crypto/scoped_nss_types.h" 33 #include "crypto/scoped_nss_types.h"
33 34
34 #if defined(OS_CHROMEOS) 35 #if defined(OS_CHROMEOS)
35 #include "crypto/symmetric_key.h" 36 #include "crypto/symmetric_key.h"
36 #endif 37 #endif
37 38
38 // USE_NSS means we use NSS for everything crypto-related. If USE_NSS is not 39 // USE_NSS means we use NSS for everything crypto-related. If USE_NSS is not
39 // defined, such as on Mac and Windows, we use NSS for SSL only -- we don't 40 // defined, such as on Mac and Windows, we use NSS for SSL only -- we don't
40 // use NSS for crypto or certificate verification, and we don't use the NSS 41 // use NSS for crypto or certificate verification, and we don't use the NSS
41 // certificate and key databases. 42 // certificate and key databases.
(...skipping 601 matching lines...) Expand 10 before | Expand all | Expand 10 after
643 644
644 void LoadNSSLibraries() { 645 void LoadNSSLibraries() {
645 // Some NSS libraries are linked dynamically so load them here. 646 // Some NSS libraries are linked dynamically so load them here.
646 #if defined(USE_NSS) 647 #if defined(USE_NSS)
647 // Try to search for multiple directories to load the libraries. 648 // Try to search for multiple directories to load the libraries.
648 std::vector<FilePath> paths; 649 std::vector<FilePath> paths;
649 650
650 // Use relative path to Search PATH for the library files. 651 // Use relative path to Search PATH for the library files.
651 paths.push_back(FilePath()); 652 paths.push_back(FilePath());
652 653
653 // For Debian derivaties NSS libraries are located here. 654 // For Debian derivatives NSS libraries are located here.
654 paths.push_back(FilePath("/usr/lib/nss")); 655 paths.push_back(FilePath("/usr/lib/nss"));
655 656
657 // Ubuntu 11.10 (Oneiric) places the libraries here.
658 #if defined(ARCH_CPU_64_BITS)
659 paths.push_back(FilePath("/usr/lib/x86_64-linux-gnu/nss"));
awong 2011/10/05 18:07:42 Can we confirm with the ubuntu folks that this nss
wtc 2011/10/06 01:13:18 awong: This is true. The NSS package in Debian de
660 #elif defined(ARCH_CPU_32_BITS)
661 paths.push_back(FilePath("/usr/lib/i386-linux-gnu/nss"));
662 #endif
wtc 2011/10/06 01:06:44 Please test __x86_64__ and __i386__ or our equival
wtc 2011/10/06 17:27:24 It is OK to leave ARM processor support as a TODO.
Lambros 2011/10/06 20:32:19 Done.
663
656 // A list of library files to load. 664 // A list of library files to load.
657 std::vector<std::string> libs; 665 std::vector<std::string> libs;
658 libs.push_back("libsoftokn3.so"); 666 libs.push_back("libsoftokn3.so");
659 libs.push_back("libfreebl3.so"); 667 libs.push_back("libfreebl3.so");
660 668
661 // For each combination of library file and path, check for existence and 669 // For each combination of library file and path, check for existence and
662 // then load. 670 // then load.
663 size_t loaded = 0; 671 size_t loaded = 0;
664 for (size_t i = 0; i < libs.size(); ++i) { 672 for (size_t i = 0; i < libs.size(); ++i) {
665 for (size_t j = 0; j < paths.size(); ++j) { 673 for (size_t j = 0; j < paths.size(); ++j) {
666 FilePath path = paths[j].Append(libs[i]); 674 FilePath path = paths[j].Append(libs[i]);
667 base::NativeLibrary lib = base::LoadNativeLibrary(path, NULL); 675 base::NativeLibrary lib = base::LoadNativeLibrary(path, NULL);
668 if (lib) { 676 if (lib) {
669 ++loaded; 677 ++loaded;
670 break; 678 break;
671 } 679 }
672 } 680 }
673 } 681 }
674 682
675 if (loaded == libs.size()) { 683 if (loaded == libs.size()) {
676 VLOG(3) << "NSS libraries loaded."; 684 VLOG(3) << "NSS libraries loaded.";
677 } else { 685 } else {
678 LOG(WARNING) << "Failed to load NSS libraries."; 686 LOG(WARNING) << "Failed to load NSS libraries.";
wtc 2011/10/06 17:27:24 Can you find out why we don't see this WARNING mes
Lambros 2011/10/06 20:32:19 Chrome (Official Release build) only logs ERROR (a
679 } 687 }
680 #endif 688 #endif
681 } 689 }
682 690
683 bool CheckNSSVersion(const char* version) { 691 bool CheckNSSVersion(const char* version) {
684 return !!NSS_VersionCheck(version); 692 return !!NSS_VersionCheck(version);
685 } 693 }
686 694
687 #if defined(USE_NSS) 695 #if defined(USE_NSS)
688 bool OpenTestNSSDB(const FilePath& path, const char* description) { 696 bool OpenTestNSSDB(const FilePath& path, const char* description) {
(...skipping 86 matching lines...) Expand 10 before | Expand all | Expand 10 after
775 783
776 PK11SlotInfo* GetPublicNSSKeySlot() { 784 PK11SlotInfo* GetPublicNSSKeySlot() {
777 return g_nss_singleton.Get().GetPublicNSSKeySlot(); 785 return g_nss_singleton.Get().GetPublicNSSKeySlot();
778 } 786 }
779 787
780 PK11SlotInfo* GetPrivateNSSKeySlot() { 788 PK11SlotInfo* GetPrivateNSSKeySlot() {
781 return g_nss_singleton.Get().GetPrivateNSSKeySlot(); 789 return g_nss_singleton.Get().GetPrivateNSSKeySlot();
782 } 790 }
783 791
784 } // namespace crypto 792 } // namespace crypto
OLDNEW
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698