提交 ba6d7cd0 编写于 作者: V vinnie

7190945: pkcs11 problem loading NSS libs on Ubuntu

Reviewed-by: xuelei, alanb
上级 e043ee93
/*
* Copyright (c) 2005, 2011, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 2005, 2012, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
......@@ -405,7 +405,16 @@ public final class Secmod {
+ "module: " + libraryName + ", " + commonName);
}
}
this.libraryName = (new File(libraryDir, libraryName)).getPath();
// On Ubuntu the libsoftokn3 library is located in a subdirectory
// of the system libraries directory. (Since Ubuntu 11.04.)
File libraryFile = new File(libraryDir, libraryName);
if (!libraryFile.isFile()) {
File failover = new File(libraryDir, "nss/" + libraryName);
if (failover.isFile()) {
libraryFile = failover;
}
}
this.libraryName = libraryFile.getPath();
this.commonName = commonName;
this.slot = slot;
this.type = type;
......
......@@ -167,17 +167,23 @@ public abstract class PKCS11Test {
}
String osid = osName + "-"
+ props.getProperty("os.arch") + "-" + props.getProperty("sun.arch.data.model");
String nssLibDir = osMap.get(osid);
if (nssLibDir == null) {
String[] nssLibDirs = osMap.get(osid);
if (nssLibDirs == null) {
System.out.println("Unsupported OS, skipping: " + osid);
return null;
// throw new Exception("Unsupported OS " + osName);
}
if (nssLibDir.length() == 0) {
if (nssLibDirs.length == 0) {
System.out.println("NSS not supported on this platform, skipping test");
return null;
}
System.setProperty("pkcs11test.nss.libdir", nssLibDir);
String nssLibDir = null;
for (String dir : nssLibDirs) {
if (new File(dir).exists()) {
nssLibDir = dir;
System.setProperty("pkcs11test.nss.libdir", nssLibDir);
break;
}
}
return nssLibDir;
}
......@@ -234,21 +240,23 @@ public abstract class PKCS11Test {
}
private static final Map<String,String> osMap;
private static final Map<String,String[]> osMap;
// Location of the NSS libraries on each supported platform
static {
osMap = new HashMap<String,String>();
osMap.put("SunOS-sparc-32", "/usr/lib/mps/");
osMap.put("SunOS-sparcv9-64", "/usr/lib/mps/64/");
osMap.put("SunOS-x86-32", "/usr/lib/mps/");
osMap.put("SunOS-amd64-64", "/usr/lib/mps/64/");
osMap.put("Linux-i386-32", "/usr/lib/");
osMap.put("Linux-amd64-64", "/usr/lib64/");
osMap.put("Windows-x86-32",
PKCS11_BASE + "/nss/lib/windows-i586/".replace('/', SEP));
osMap.put("Windows-amd64-64",
PKCS11_BASE + "/nss/lib/windows-amd64/".replace('/', SEP));
osMap = new HashMap<String,String[]>();
osMap.put("SunOS-sparc-32", new String[]{"/usr/lib/mps/"});
osMap.put("SunOS-sparcv9-64", new String[]{"/usr/lib/mps/64/"});
osMap.put("SunOS-x86-32", new String[]{"/usr/lib/mps/"});
osMap.put("SunOS-amd64-64", new String[]{"/usr/lib/mps/64/"});
osMap.put("Linux-i386-32", new String[]{
"/usr/lib/i386-linux-gnu/", "/usr/lib/"});
osMap.put("Linux-amd64-64", new String[]{
"/usr/lib/x86_64-linux-gnu/", "/usr/lib64/"});
osMap.put("Windows-x86-32", new String[]{
PKCS11_BASE + "/nss/lib/windows-i586/".replace('/', SEP)});
osMap.put("Windows-amd64-64", new String[]{
PKCS11_BASE + "/nss/lib/windows-amd64/".replace('/', SEP)});
}
private final static char[] hexDigits = "0123456789abcdef".toCharArray();
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册