mirror of
https://github.com/PowerShell/Win32-OpenSSH.git
synced 2025-07-23 14:04:59 +02:00
Added implementation for dlopen, dlclose, dlsym and dlerror
This commit is contained in:
parent
0958df5875
commit
5a60b811fe
@ -163,6 +163,7 @@
|
||||
<ClInclude Include="$(OpenSSH-Src-Path)\contrib\win32\win32compat\inc\w32posix.h" />
|
||||
<ClInclude Include="$(OpenSSH-Src-Path)\contrib\win32\win32compat\inc\poll.h" />
|
||||
<ClInclude Include="$(OpenSSH-Src-Path)\contrib\win32\win32compat\inc\sys\statvfs.h" />
|
||||
<ClInclude Include="..\win32compat\inc\dlfcn.h" />
|
||||
<ClInclude Include="..\win32compat\inc\syslog.h" />
|
||||
</ItemGroup>
|
||||
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.targets" />
|
||||
|
@ -50,6 +50,9 @@
|
||||
<ClInclude Include="..\win32compat\inc\syslog.h">
|
||||
<Filter>inc</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="..\win32compat\inc\dlfcn.h">
|
||||
<Filter>inc</Filter>
|
||||
</ClInclude>
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<Filter Include="inc">
|
||||
|
11
contrib/win32/win32compat/inc/dlfcn.h
Normal file
11
contrib/win32/win32compat/inc/dlfcn.h
Normal file
@ -0,0 +1,11 @@
|
||||
#pragma once
|
||||
#include <Windows.h>
|
||||
#define RTLD_NOW 0
|
||||
|
||||
#define dlerror() GetLastError()
|
||||
|
||||
HMODULE *dlopen(const char *filename, int flags);
|
||||
|
||||
int dlclose(HMODULE *handle);
|
||||
|
||||
FARPROC *dlsym(HMODULE *handle, const char *symbol);
|
@ -60,4 +60,17 @@ int statvfs(const char *path, struct statvfs *buf) {
|
||||
int fstatvfs(int fd, struct statvfs *buf) {
|
||||
errno = ENOSYS;
|
||||
return -1;
|
||||
}
|
||||
|
||||
#include "inc\dlfcn.h"
|
||||
HMODULE *dlopen(const char *filename, int flags) {
|
||||
return LoadLibraryA(filename);
|
||||
}
|
||||
|
||||
int dlclose(HMODULE *handle) {
|
||||
FreeLibrary(handle);
|
||||
}
|
||||
|
||||
FARPROC *dlsym(HMODULE *handle, const char *symbol) {
|
||||
return GetProcAddress(handle, symbol);
|
||||
}
|
39
ssh-pkcs11.c
39
ssh-pkcs11.c
@ -28,11 +28,7 @@
|
||||
|
||||
#include <string.h>
|
||||
|
||||
#ifdef WIN32_FIXME
|
||||
#include <Winbase.h>
|
||||
#else
|
||||
#include <dlfcn.h>
|
||||
#endif /*WIN32_FIXME*/
|
||||
|
||||
#include "openbsd-compat/sys-queue.h"
|
||||
|
||||
@ -114,11 +110,7 @@ pkcs11_provider_finalize(struct pkcs11_provider *p)
|
||||
p->valid = 0;
|
||||
p->function_list = NULL;
|
||||
|
||||
#ifdef WIN32_FIXME
|
||||
FreeLibrary(p -> handle);
|
||||
#else
|
||||
dlclose(p->handle);
|
||||
#endif /*WIN32_FIXME*/
|
||||
}
|
||||
|
||||
/*
|
||||
@ -589,28 +581,6 @@ pkcs11_add_provider(char *provider_id, char *pin, struct sshkey ***keyp)
|
||||
goto fail;
|
||||
}
|
||||
/* open shared pkcs11-libarary */
|
||||
#ifdef WIN32_FIXME
|
||||
|
||||
handle = LoadLibrary(provider_id);
|
||||
|
||||
if (handle == NULL)
|
||||
{
|
||||
error("Cannot load OpenSC library. Error code is: %u.\n"
|
||||
"Please ensure that path to these libraries is properly "
|
||||
"set in your PATH variable.\n", GetLastError());
|
||||
goto fail;
|
||||
}
|
||||
|
||||
getfunctionlist = (CK_RV(*)(CK_FUNCTION_LIST **))GetProcAddress(handle, "C_GetFunctionList");
|
||||
|
||||
if (getfunctionlist == NULL)
|
||||
{
|
||||
error("Cannot load OpenSC library. Error code is: %u.\n", GetLastError());
|
||||
|
||||
goto fail;
|
||||
}
|
||||
|
||||
#else
|
||||
if ((handle = dlopen(provider_id, RTLD_NOW)) == NULL) {
|
||||
error("dlopen %s failed: %s", provider_id, dlerror());
|
||||
goto fail;
|
||||
@ -619,8 +589,7 @@ pkcs11_add_provider(char *provider_id, char *pin, struct sshkey ***keyp)
|
||||
error("dlsym(C_GetFunctionList) failed: %s", dlerror());
|
||||
goto fail;
|
||||
}
|
||||
#endif /*WIN32_FIXME*/
|
||||
|
||||
|
||||
p = xcalloc(1, sizeof(*p));
|
||||
p->name = xstrdup(provider_id);
|
||||
p->handle = handle;
|
||||
@ -705,13 +674,9 @@ fail:
|
||||
free(p->slotinfo);
|
||||
free(p);
|
||||
}
|
||||
#ifdef WIN32_FIXME
|
||||
if (handle)
|
||||
FreeLibrary(handle);
|
||||
#else
|
||||
|
||||
if (handle)
|
||||
dlclose(handle);
|
||||
#endif/*WIN32_FIXME*/
|
||||
|
||||
return (-1);
|
||||
}
|
||||
|
@ -382,7 +382,7 @@ _ssh_send_banner(struct ssh *ssh, char **bannerp)
|
||||
char buf[256];
|
||||
int r;
|
||||
|
||||
#ifndef WIN32_FIXME
|
||||
#ifndef WIN32_FIXME//R
|
||||
snprintf(buf, sizeof buf, "SSH-2.0-%.100s\r\n", SSH_VERSION);
|
||||
#else
|
||||
snprintf(buf, sizeof buf, "SSH-2.0-%.100sp1 Microsoft_Win32_port %s\r\n", SSH_VERSION, __DATE__ );
|
||||
|
Loading…
x
Reference in New Issue
Block a user