Let sc_profile_locate() behave about the same way under Win32 than under Linux
git-svn-id: https://www.opensc-project.org/svnp/opensc/trunk@1213 c6295689-39f2-0310-b995-f0e70906c6a9
This commit is contained in:
parent
97da0b6149
commit
bb4bdd529d
|
@ -45,6 +45,8 @@
|
||||||
*/
|
*/
|
||||||
#define OPENSC_CONF_PATH "%windir%\\opensc.conf"
|
#define OPENSC_CONF_PATH "%windir%\\opensc.conf"
|
||||||
|
|
||||||
|
#define SC_PKCS15_PROFILE_DIRECTORY "%windir%\\"
|
||||||
|
|
||||||
#define PATH_MAX _MAX_PATH
|
#define PATH_MAX _MAX_PATH
|
||||||
|
|
||||||
/* src/common/getpass.c */
|
/* src/common/getpass.c */
|
||||||
|
|
|
@ -36,6 +36,9 @@
|
||||||
#include <opensc/scconf.h>
|
#include <opensc/scconf.h>
|
||||||
#include "pkcs15-init.h"
|
#include "pkcs15-init.h"
|
||||||
#include "profile.h"
|
#include "profile.h"
|
||||||
|
#ifdef _WIN32
|
||||||
|
#include <windows.h>
|
||||||
|
#endif
|
||||||
|
|
||||||
#define DEF_PRKEY_RSA_ACCESS 0x1D
|
#define DEF_PRKEY_RSA_ACCESS 0x1D
|
||||||
#define DEF_PRKEY_DSA_ACCESS 0x12
|
#define DEF_PRKEY_DSA_ACCESS 0x12
|
||||||
|
@ -350,6 +353,7 @@ static const char *
|
||||||
sc_profile_locate(const char *name)
|
sc_profile_locate(const char *name)
|
||||||
{
|
{
|
||||||
static char path[1024];
|
static char path[1024];
|
||||||
|
char profile_dir[MAX_PATH];
|
||||||
|
|
||||||
/* Name with suffix tagged onto it? */
|
/* Name with suffix tagged onto it? */
|
||||||
snprintf(path, sizeof(path), "%s.%s", name, SC_PKCS15_PROFILE_SUFFIX);
|
snprintf(path, sizeof(path), "%s.%s", name, SC_PKCS15_PROFILE_SUFFIX);
|
||||||
|
@ -360,14 +364,26 @@ sc_profile_locate(const char *name)
|
||||||
if (strchr(path, '/'))
|
if (strchr(path, '/'))
|
||||||
return path;
|
return path;
|
||||||
|
|
||||||
|
#ifndef _WIN32
|
||||||
|
strncpy(profile_dir, SC_PKCS15_PROFILE_DIRECTORY, sizeof(profile_dir));
|
||||||
|
#else
|
||||||
|
if (!strncmp(SC_PKCS15_PROFILE_DIRECTORY, "%windir%", 8)) {
|
||||||
|
GetWindowsDirectory(profile_dir, sizeof(profile_dir));
|
||||||
|
strncat(profile_dir, SC_PKCS15_PROFILE_DIRECTORY + 8,
|
||||||
|
sizeof(profile_dir) - strlen(profile_dir));
|
||||||
|
}
|
||||||
|
else
|
||||||
|
strncpy(profile_dir, SC_PKCS15_PROFILE_DIRECTORY, sizeof(profile_dir));
|
||||||
|
#endif
|
||||||
|
|
||||||
/* Try directory */
|
/* Try directory */
|
||||||
snprintf(path, sizeof(path), "%s/%s",
|
snprintf(path, sizeof(path), "%s/%s",
|
||||||
SC_PKCS15_PROFILE_DIRECTORY, name);
|
profile_dir, name);
|
||||||
if (access(path, R_OK) == 0)
|
if (access(path, R_OK) == 0)
|
||||||
return path;
|
return path;
|
||||||
|
|
||||||
snprintf(path, sizeof(path), "%s/%s.%s",
|
snprintf(path, sizeof(path), "%s/%s.%s",
|
||||||
SC_PKCS15_PROFILE_DIRECTORY, name,
|
profile_dir, name,
|
||||||
SC_PKCS15_PROFILE_SUFFIX);
|
SC_PKCS15_PROFILE_SUFFIX);
|
||||||
if (access(path, R_OK) == 0)
|
if (access(path, R_OK) == 0)
|
||||||
return path;
|
return path;
|
||||||
|
|
Loading…
Reference in New Issue