Skip to content

Commit

Permalink
Add openconnect_passphrase_from_fsid() implementation for MinGW
Browse files Browse the repository at this point in the history
This works only for Vista onwards but I don't think I care.

Signed-off-by: David Woodhouse <David.Woodhouse@intel.com>
  • Loading branch information
David Woodhouse authored and David Woodhouse committed Feb 6, 2014
1 parent f84c882 commit 1f9ed77
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 0 deletions.
2 changes: 2 additions & 0 deletions configure.ac
Expand Up @@ -85,6 +85,8 @@ case $host_os in
;;
*mingw32*|*mingw64*)
AC_MSG_NOTICE([Applying feature macros for MinGW/Windows build])
# For GetVolumeInformationByHandleW() which is Vista+
AC_DEFINE(_WIN32_WINNT,0x600)
have_win=yes
;;
*)
Expand Down
20 changes: 20 additions & 0 deletions ssl.c
Expand Up @@ -353,6 +353,26 @@ int openconnect_passphrase_from_fsid(struct openconnect_info *vpninfo)
return -ENOMEM;
return 0;
}
#elif defined(_WIN32)
#include <fileapi.h>
int openconnect_passphrase_from_fsid(struct openconnect_info *vpninfo)
{
HFILE fh;
OFSTRUCT ofstr;
DWORD serial;

fh = OpenFile(vpninfo->sslkey, &ofstr, OF_READ|OF_SHARE_DENY_NONE);
if (fh == HFILE_ERROR)
return -EIO;

if (!GetVolumeInformationByHandleW((HANDLE)fh, NULL, 0, &serial, NULL, NULL, NULL, 0))
return -EIO;

if (asprintf(&vpninfo->cert_password, "%lx", serial))
return -ENOMEM;

return -EINVAL;
}
#else
int openconnect_passphrase_from_fsid(struct openconnect_info *vpninfo)
{
Expand Down

0 comments on commit 1f9ed77

Please sign in to comment.