Address code review feedback of PR 238 (#239)
Address feedback of PR 238
This commit is contained in:
parent
a4cbd07812
commit
3f106fe653
|
@ -41,7 +41,9 @@
|
||||||
#include <sys/types.h>
|
#include <sys/types.h>
|
||||||
|
|
||||||
#include <pwd.h>
|
#include <pwd.h>
|
||||||
|
#ifdef WINDOWS
|
||||||
#include <logonuser.h>
|
#include <logonuser.h>
|
||||||
|
#endif
|
||||||
#include <stdio.h>
|
#include <stdio.h>
|
||||||
#include <string.h>
|
#include <string.h>
|
||||||
#include <stdarg.h>
|
#include <stdarg.h>
|
||||||
|
|
|
@ -28,10 +28,10 @@
|
||||||
#include <Windows.h>
|
#include <Windows.h>
|
||||||
#include "debug.h"
|
#include "debug.h"
|
||||||
|
|
||||||
static HMODULE hMod = NULL;
|
|
||||||
|
|
||||||
/* Define the function prototype */
|
/* Define the function prototype */
|
||||||
typedef BOOL(WINAPI *LogonUserExExWType)(wchar_t*, wchar_t*, wchar_t*, DWORD, DWORD, PTOKEN_GROUPS, PHANDLE, PSID, PVOID, LPDWORD, PQUOTA_LIMITS);
|
typedef BOOL(WINAPI *LogonUserExExWType)(wchar_t*, wchar_t*, wchar_t*, DWORD, DWORD, PTOKEN_GROUPS, PHANDLE, PSID, PVOID, LPDWORD, PQUOTA_LIMITS);
|
||||||
|
static HMODULE hMod = NULL;
|
||||||
|
static LogonUserExExWType func = NULL;
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* The function uses LoadLibrary and GetProcAddress to access
|
* The function uses LoadLibrary and GetProcAddress to access
|
||||||
|
@ -41,8 +41,7 @@ BOOL
|
||||||
LogonUserExExWHelper(wchar_t *user_name, wchar_t *domain, wchar_t *password, DWORD logon_type,
|
LogonUserExExWHelper(wchar_t *user_name, wchar_t *domain, wchar_t *password, DWORD logon_type,
|
||||||
DWORD logon_provider, PTOKEN_GROUPS token_groups, PHANDLE token, PSID *logon_sid,
|
DWORD logon_provider, PTOKEN_GROUPS token_groups, PHANDLE token, PSID *logon_sid,
|
||||||
PVOID *profile_buffer, LPDWORD profile_length, PQUOTA_LIMITS quota_limits)
|
PVOID *profile_buffer, LPDWORD profile_length, PQUOTA_LIMITS quota_limits)
|
||||||
{
|
{
|
||||||
LogonUserExExWType func = NULL;
|
|
||||||
wchar_t sspicli_dll_path[MAX_PATH + 1] = { 0, };
|
wchar_t sspicli_dll_path[MAX_PATH + 1] = { 0, };
|
||||||
wchar_t system32_path[MAX_PATH + 1] = { 0, };
|
wchar_t system32_path[MAX_PATH + 1] = { 0, };
|
||||||
|
|
||||||
|
@ -60,7 +59,10 @@ LogonUserExExWHelper(wchar_t *user_name, wchar_t *domain, wchar_t *password, DWO
|
||||||
debug3("Failed to retrieve the module handle of sspicli.dll with error %d", GetLastError());
|
debug3("Failed to retrieve the module handle of sspicli.dll with error %d", GetLastError());
|
||||||
return FALSE;
|
return FALSE;
|
||||||
}
|
}
|
||||||
if ((func = (LogonUserExExWType)GetProcAddress(hMod, "LogonUserExExW")) == NULL) {
|
if (func == NULL)
|
||||||
|
func = (LogonUserExExWType)GetProcAddress(hMod, "LogonUserExExW");
|
||||||
|
|
||||||
|
if (func == NULL) {
|
||||||
debug3("GetProcAddress of LogonUserExExW failed with error $d.", GetLastError());
|
debug3("GetProcAddress of LogonUserExExW failed with error $d.", GetLastError());
|
||||||
return FALSE;
|
return FALSE;
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,10 +1,8 @@
|
||||||
/*
|
/*
|
||||||
* Author: Manoj Ampalam <manoj.ampalam@microsoft.com>
|
* Author: Yanbing Wang <yawang@microsoft.com>
|
||||||
|
*
|
||||||
|
* Support logon user call on Win32 based operating systems.
|
||||||
*
|
*
|
||||||
* Compatibility header to give us pwd-like functionality on Win32
|
|
||||||
* A lot of passwd fields are not applicable in Windows, neither are some API calls based on this structure
|
|
||||||
* Ideally, usage of this structure needs to be replaced in core SSH code to an ssh_user interface,
|
|
||||||
* that each platform can extend and implement.
|
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#ifndef LOGONUSER_H
|
#ifndef LOGONUSER_H
|
||||||
|
|
|
@ -1650,14 +1650,6 @@ static void* xmalloc(size_t size) {
|
||||||
return ptr;
|
return ptr;
|
||||||
}
|
}
|
||||||
|
|
||||||
#define SET_USER_ENV(folder_id, evn_variable) do { \
|
|
||||||
if (SHGetKnownFolderPath(&folder_id,0,NULL,&path) == S_OK) \
|
|
||||||
{ \
|
|
||||||
SetEnvironmentVariableW(evn_variable, path); \
|
|
||||||
CoTaskMemFree(path); \
|
|
||||||
} \
|
|
||||||
} while (0)
|
|
||||||
|
|
||||||
/* set user environment variables from user profile */
|
/* set user environment variables from user profile */
|
||||||
static void setup_session_user_vars()
|
static void setup_session_user_vars()
|
||||||
{
|
{
|
||||||
|
|
Loading…
Reference in New Issue