1
0
mirror of https://github.com/moparisthebest/curl synced 2024-12-21 23:58:49 -05:00

curl_sspi: Added Curl_sspi_version function

Added new function to get SSPI version as string.
Added required library version.lib to makefiles.
Changed curl_schannel.c to use Curl_sspi_version.
This commit is contained in:
Marc Hoersken 2012-04-14 15:00:33 +02:00 committed by Daniel Stenberg
parent 0bb5ff5d1a
commit c1311c2b8f
6 changed files with 59 additions and 4 deletions

View File

@ -190,6 +190,7 @@ endif
endif
ifdef SSPI
CFLAGS += -DUSE_WINDOWS_SSPI
DLL_LIBS += -lversion
endif
ifdef SPNEGO
CFLAGS += -DHAVE_SPNEGO

View File

@ -957,10 +957,10 @@ void Curl_schannel_cleanup() {
size_t Curl_schannel_version(char *buffer, size_t size)
{
unsigned long version = s_pSecFn ? s_pSecFn->dwVersion : 0;
return snprintf(buffer, size, "Schannel/%d.%d.%d.%d",
(version>>0)&0xff, (version>>8)&0xff,
(version>>16)&0xff, (version>>24)&0xff);
char* version = Curl_sspi_version();
size = snprintf(buffer, size, "Schannel-%s", version);
free(version);
return size;
}
#endif /* USE_SCHANNEL */

View File

@ -119,6 +119,55 @@ Curl_sspi_global_cleanup(void)
}
/*
* Curl_sspi_version()
*
* This function returns a string representing the SSPI library version.
* It will in any case return a usable string pointer which needs to be freed.
*/
char *
Curl_sspi_version()
{
VS_FIXEDFILEINFO *version_info = NULL;
LPTSTR version = NULL;
LPTSTR path = NULL;
LPVOID data = NULL;
DWORD size, handle;
if(s_hSecDll) {
path = malloc(MAX_PATH);
if(path) {
if(GetModuleFileName(s_hSecDll, path, MAX_PATH)) {
size = GetFileVersionInfoSize(path, &handle);
if(size) {
data = malloc(size);
if(data) {
if(GetFileVersionInfo(path, handle, size, data)) {
if(VerQueryValue(data, "\\", &version_info, &handle)) {
version = curl_maprintf("SSPI/%d.%d.%d.%d",
(version_info->dwProductVersionMS>>16)&0xffff,
(version_info->dwProductVersionMS>>0)&0xffff,
(version_info->dwProductVersionLS>>16)&0xffff,
(version_info->dwProductVersionLS>>0)&0xffff);
}
}
free(data);
}
}
}
free(path);
}
if(!version)
version = strdup("SSPI/Unknown");
}
if(!version)
version = strdup("");
return version;
}
/*
* Curl_sspi_status(SECURIY_STATUS status)
*
@ -219,6 +268,7 @@ Curl_sspi_status(SECURITY_STATUS status)
return curl_maprintf("%s (0x%08X)", status_const, status);
}
/*
* Curl_sspi_status_msg(SECURITY_STATUS status)
*

View File

@ -63,6 +63,7 @@
CURLcode Curl_sspi_global_init(void);
void Curl_sspi_global_cleanup(void);
char* Curl_sspi_version();
char* Curl_sspi_status(SECURITY_STATUS status);
char* Curl_sspi_status_msg(SECURITY_STATUS status);

View File

@ -199,6 +199,7 @@ ifdef METALINK
endif
ifdef SSPI
CFLAGS += -DUSE_WINDOWS_SSPI
curl_LDADD += -lversion
endif
ifdef SPNEGO
CFLAGS += -DHAVE_SPNEGO

View File

@ -149,6 +149,7 @@ USE_SSPI = yes
!IF "$(USE_SSPI)"=="yes"
CFLAGS_SSPI = /DUSE_WINDOWS_SSPI
LFLAGS_SSPI = version.lib
USE_SSPI = true
!ENDIF
@ -292,6 +293,7 @@ CONFIG_NAME_LIB = $(CONFIG_NAME_LIB)-ipv6
!IF "$(USE_SSPI)"=="true"
CFLAGS = $(CFLAGS) $(CFLAGS_SSPI)
LFLAGS = $(LFLAGS) $(LFLAGS_SSPI)
CONFIG_NAME_LIB = $(CONFIG_NAME_LIB)-sspi
!ENDIF