mirror of
https://git.tartarus.org/simon/putty.git
synced 2025-05-30 16:30:29 -05:00
Fixed GSSAPI authentication.
gssapi32.dll from MIT Kerberos as well as from Heimdal both load further DLLs from their installation directories. [SGT: I polished the original patch a bit, in particular replacing manual memory allocation with dup_mb_to_wc. This required a Recipe change to link miscucs.c and winucs.c into more of the tools.]
This commit is contained in:
parent
d2653e79ab
commit
802b4edf4d
6
Recipe
6
Recipe
@ -235,8 +235,8 @@ TERMINAL = terminal wcwidth ldiscucs logging tree234 minibidi
|
|||||||
+ config dialog conf
|
+ config dialog conf
|
||||||
|
|
||||||
# GUI front end and terminal emulator (putty, puttytel).
|
# GUI front end and terminal emulator (putty, puttytel).
|
||||||
GUITERM = TERMINAL window windlg winctrls sizetip winucs winprint
|
GUITERM = TERMINAL window windlg winctrls sizetip winprint winutils
|
||||||
+ winutils wincfg sercfg winhelp winjump miscucs
|
+ wincfg sercfg winhelp winjump
|
||||||
|
|
||||||
# Same thing on Unix.
|
# Same thing on Unix.
|
||||||
UXTERM = TERMINAL uxcfg sercfg uxucs uxprint timing callback miscucs
|
UXTERM = TERMINAL uxcfg sercfg uxucs uxprint timing callback miscucs
|
||||||
@ -262,7 +262,7 @@ SFTP = sftp int64 logging
|
|||||||
# Pageant or PuTTYgen).
|
# Pageant or PuTTYgen).
|
||||||
MISC = timing callback misc version settings tree234 proxy conf be_misc
|
MISC = timing callback misc version settings tree234 proxy conf be_misc
|
||||||
WINMISC = MISC winstore winnet winhandl cmdline windefs winmisc winproxy
|
WINMISC = MISC winstore winnet winhandl cmdline windefs winmisc winproxy
|
||||||
+ wintime winhsock errsock winsecur
|
+ wintime winhsock errsock winsecur winucs miscucs
|
||||||
UXMISC = MISC uxstore uxsel uxnet uxpeer cmdline uxmisc uxproxy time
|
UXMISC = MISC uxstore uxsel uxnet uxpeer cmdline uxmisc uxproxy time
|
||||||
|
|
||||||
# import.c and dependencies, for PuTTYgen-like utilities that have to
|
# import.c and dependencies, for PuTTYgen-like utilities that have to
|
||||||
|
@ -49,6 +49,9 @@ DECL_WINDOWS_FUNCTION(static, SECURITY_STATUS,
|
|||||||
DECL_WINDOWS_FUNCTION(static, SECURITY_STATUS,
|
DECL_WINDOWS_FUNCTION(static, SECURITY_STATUS,
|
||||||
MakeSignature,
|
MakeSignature,
|
||||||
(PCtxtHandle, ULONG, PSecBufferDesc, ULONG));
|
(PCtxtHandle, ULONG, PSecBufferDesc, ULONG));
|
||||||
|
DECL_WINDOWS_FUNCTION(static, DLL_DIRECTORY_COOKIE,
|
||||||
|
AddDllDirectory,
|
||||||
|
(PCWSTR));
|
||||||
|
|
||||||
typedef struct winSsh_gss_ctx {
|
typedef struct winSsh_gss_ctx {
|
||||||
unsigned long maj_stat;
|
unsigned long maj_stat;
|
||||||
@ -72,6 +75,11 @@ struct ssh_gss_liblist *ssh_gss_setup(Conf *conf)
|
|||||||
HKEY regkey;
|
HKEY regkey;
|
||||||
struct ssh_gss_liblist *list = snew(struct ssh_gss_liblist);
|
struct ssh_gss_liblist *list = snew(struct ssh_gss_liblist);
|
||||||
char *path;
|
char *path;
|
||||||
|
static HMODULE kernel32_module;
|
||||||
|
if (!kernel32_module) {
|
||||||
|
kernel32_module = load_system32_dll("kernel32.dll");
|
||||||
|
}
|
||||||
|
GET_WINDOWS_FUNCTION(kernel32_module, AddDllDirectory);
|
||||||
|
|
||||||
list->libraries = snewn(3, struct ssh_gss_library);
|
list->libraries = snewn(3, struct ssh_gss_library);
|
||||||
list->nlibraries = 0;
|
list->nlibraries = 0;
|
||||||
@ -93,8 +101,20 @@ struct ssh_gss_liblist *ssh_gss_setup(Conf *conf)
|
|||||||
ret = RegQueryValueEx(regkey, "InstallDir", NULL,
|
ret = RegQueryValueEx(regkey, "InstallDir", NULL,
|
||||||
&type, (LPBYTE)buffer, &size);
|
&type, (LPBYTE)buffer, &size);
|
||||||
if (ret == ERROR_SUCCESS && type == REG_SZ) {
|
if (ret == ERROR_SUCCESS && type == REG_SZ) {
|
||||||
strcat(buffer, "\\bin\\gssapi32.dll");
|
strcat (buffer, "\\bin");
|
||||||
module = LoadLibrary(buffer);
|
if(p_AddDllDirectory) {
|
||||||
|
/* Add MIT Kerberos' path to the DLL search path,
|
||||||
|
* it loads its own DLLs further down the road */
|
||||||
|
wchar_t *dllPath =
|
||||||
|
dup_mb_to_wc(DEFAULT_CODEPAGE, 0, buffer);
|
||||||
|
p_AddDllDirectory(dllPath);
|
||||||
|
sfree(dllPath);
|
||||||
|
}
|
||||||
|
strcat (buffer, "\\gssapi32.dll");
|
||||||
|
module = LoadLibraryEx (buffer, NULL,
|
||||||
|
LOAD_LIBRARY_SEARCH_SYSTEM32 |
|
||||||
|
LOAD_LIBRARY_SEARCH_DLL_LOAD_DIR |
|
||||||
|
LOAD_LIBRARY_SEARCH_USER_DIRS);
|
||||||
}
|
}
|
||||||
sfree(buffer);
|
sfree(buffer);
|
||||||
}
|
}
|
||||||
@ -152,7 +172,32 @@ struct ssh_gss_liblist *ssh_gss_setup(Conf *conf)
|
|||||||
module = NULL;
|
module = NULL;
|
||||||
path = conf_get_filename(conf, CONF_ssh_gss_custom)->path;
|
path = conf_get_filename(conf, CONF_ssh_gss_custom)->path;
|
||||||
if (*path) {
|
if (*path) {
|
||||||
module = LoadLibrary(path);
|
if(p_AddDllDirectory) {
|
||||||
|
/* Add the custom directory as well in case it chainloads
|
||||||
|
* some other DLLs (e.g a non-installed MIT Kerberos
|
||||||
|
* instance) */
|
||||||
|
int pathlen = strlen(path);
|
||||||
|
|
||||||
|
while (pathlen > 0 && path[pathlen-1] != ':' &&
|
||||||
|
path[pathlen-1] != '\\')
|
||||||
|
pathlen--;
|
||||||
|
|
||||||
|
if (pathlen > 0 && path[pathlen-1] != '\\')
|
||||||
|
pathlen--;
|
||||||
|
|
||||||
|
if (pathlen > 0) {
|
||||||
|
char *dirpath = dupprintf("%.*s", pathlen, path);
|
||||||
|
wchar_t *dllPath = dup_mb_to_wc(DEFAULT_CODEPAGE, 0, dirpath);
|
||||||
|
p_AddDllDirectory(dllPath);
|
||||||
|
sfree(dllPath);
|
||||||
|
sfree(dirpath);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
module = LoadLibraryEx(path, NULL,
|
||||||
|
LOAD_LIBRARY_SEARCH_SYSTEM32 |
|
||||||
|
LOAD_LIBRARY_SEARCH_DLL_LOAD_DIR |
|
||||||
|
LOAD_LIBRARY_SEARCH_USER_DIRS);
|
||||||
}
|
}
|
||||||
if (module) {
|
if (module) {
|
||||||
struct ssh_gss_library *lib =
|
struct ssh_gss_library *lib =
|
||||||
|
@ -176,8 +176,10 @@ void dll_hijacking_protection(void)
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (p_SetDefaultDllDirectories) {
|
if (p_SetDefaultDllDirectories) {
|
||||||
/* LOAD_LIBRARY_SEARCH_SYSTEM32 only */
|
/* LOAD_LIBRARY_SEARCH_SYSTEM32 and explicitly specified
|
||||||
p_SetDefaultDllDirectories(0x800);
|
* directories only */
|
||||||
|
p_SetDefaultDllDirectories(LOAD_LIBRARY_SEARCH_SYSTEM32 |
|
||||||
|
LOAD_LIBRARY_SEARCH_USER_DIRS);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -512,6 +512,21 @@ const char *win_strerror(int error);
|
|||||||
void restrict_process_acl(void);
|
void restrict_process_acl(void);
|
||||||
GLOBAL int restricted_acl;
|
GLOBAL int restricted_acl;
|
||||||
|
|
||||||
|
/* A few pieces of up-to-date Windows API definition needed for older
|
||||||
|
* compilers. */
|
||||||
|
#ifndef LOAD_LIBRARY_SEARCH_SYSTEM32
|
||||||
|
#define LOAD_LIBRARY_SEARCH_SYSTEM32 0x00000800
|
||||||
|
#endif
|
||||||
|
#ifndef LOAD_LIBRARY_SEARCH_USER_DIRS
|
||||||
|
#define LOAD_LIBRARY_SEARCH_USER_DIRS 0x00000400
|
||||||
|
#endif
|
||||||
|
#ifndef LOAD_LIBRARY_SEARCH_DLL_LOAD_DIR
|
||||||
|
#define LOAD_LIBRARY_SEARCH_DLL_LOAD_DIR 0x00000100
|
||||||
|
#endif
|
||||||
|
#if _MSC_VER < 1400
|
||||||
|
typedef PVOID DLL_DIRECTORY_COOKIE;
|
||||||
|
#endif
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Exports from sizetip.c.
|
* Exports from sizetip.c.
|
||||||
*/
|
*/
|
||||||
|
Loading…
x
Reference in New Issue
Block a user