Address code review feedback of PR 238 (#239)

Address feedback of PR 238
This commit is contained in:
Yanbing 2017-11-15 13:10:54 -08:00 committed by GitHub
parent a4cbd07812
commit 3f106fe653
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
4 changed files with 12 additions and 18 deletions

View File

@ -41,7 +41,9 @@
#include <sys/types.h>
#include <pwd.h>
#ifdef WINDOWS
#include <logonuser.h>
#endif
#include <stdio.h>
#include <string.h>
#include <stdarg.h>

View File

@ -28,10 +28,10 @@
#include <Windows.h>
#include "debug.h"
static HMODULE hMod = NULL;
/* Define the function prototype */
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
@ -41,8 +41,7 @@ BOOL
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,
PVOID *profile_buffer, LPDWORD profile_length, PQUOTA_LIMITS quota_limits)
{
LogonUserExExWType func = NULL;
{
wchar_t sspicli_dll_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());
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());
return FALSE;
}

View File

@ -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

View File

@ -1650,14 +1650,6 @@ static void* xmalloc(size_t size) {
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 */
static void setup_session_user_vars()
{