summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMarc Hoersken <info@marc-hoersken.de>2012-04-14 15:00:33 +0200
committerDaniel Stenberg <daniel@haxx.se>2012-06-11 19:00:35 +0200
commitc1311c2b8f34c352d771f1d5810e64141aa802b1 (patch)
treeba0b04fcc617e15274bc3c33871ef4f0a68d239d
parent0bb5ff5d1a13f51344cdc666d08db7aefc4dc5a9 (diff)
downloadcurl-c1311c2b8f34c352d771f1d5810e64141aa802b1.tar.gz
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.
-rw-r--r--lib/Makefile.m321
-rw-r--r--lib/curl_schannel.c8
-rw-r--r--lib/curl_sspi.c50
-rw-r--r--lib/curl_sspi.h1
-rw-r--r--src/Makefile.m321
-rw-r--r--winbuild/MakefileBuild.vc2
6 files changed, 59 insertions, 4 deletions
diff --git a/lib/Makefile.m32 b/lib/Makefile.m32
index abbcca3e0..11f6d7100 100644
--- a/lib/Makefile.m32
+++ b/lib/Makefile.m32
@@ -190,6 +190,7 @@ endif
endif
ifdef SSPI
CFLAGS += -DUSE_WINDOWS_SSPI
+ DLL_LIBS += -lversion
endif
ifdef SPNEGO
CFLAGS += -DHAVE_SPNEGO
diff --git a/lib/curl_schannel.c b/lib/curl_schannel.c
index c9a390638..c7b51cb96 100644
--- a/lib/curl_schannel.c
+++ b/lib/curl_schannel.c
@@ -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 */
diff --git a/lib/curl_sspi.c b/lib/curl_sspi.c
index d915710f8..d3533a293 100644
--- a/lib/curl_sspi.c
+++ b/lib/curl_sspi.c
@@ -120,6 +120,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)
*
* This function returns a string representing an SSPI 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)
*
diff --git a/lib/curl_sspi.h b/lib/curl_sspi.h
index 817487830..1865ee490 100644
--- a/lib/curl_sspi.h
+++ b/lib/curl_sspi.h
@@ -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);
diff --git a/src/Makefile.m32 b/src/Makefile.m32
index 994161406..80fa81b01 100644
--- a/src/Makefile.m32
+++ b/src/Makefile.m32
@@ -199,6 +199,7 @@ ifdef METALINK
endif
ifdef SSPI
CFLAGS += -DUSE_WINDOWS_SSPI
+ curl_LDADD += -lversion
endif
ifdef SPNEGO
CFLAGS += -DHAVE_SPNEGO
diff --git a/winbuild/MakefileBuild.vc b/winbuild/MakefileBuild.vc
index 9dfd5f62e..fefc2c65b 100644
--- a/winbuild/MakefileBuild.vc
+++ b/winbuild/MakefileBuild.vc
@@ -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