dll: np: pass username as argument to launcher

This commit is contained in:
Bill Zissimopoulos 2017-10-27 15:12:18 -07:00
parent 3a8ad9c8d7
commit 11cb57a0bf

View File

@ -17,6 +17,7 @@
#include <dll/library.h>
#include <launcher/launcher.h>
#include <lmcons.h>
#include <npapi.h>
#include <wincred.h>
@ -147,7 +148,7 @@ static inline BOOLEAN FspNpParseRemoteName(PWSTR RemoteName,
return TRUE;
}
static inline BOOLEAN FspNpParseUserName(PWSTR RemoteName,
static inline BOOLEAN FspNpParseRemoteUserName(PWSTR RemoteName,
PWSTR UserName, ULONG UserNameSize/* in chars */)
{
PWSTR ClassName, InstanceName, P;
@ -168,6 +169,12 @@ static inline BOOLEAN FspNpParseUserName(PWSTR RemoteName,
return FALSE;
}
static inline BOOLEAN FspNpGetLocalUserName(
PWSTR UserName, ULONG UserNameSize/* in chars */)
{
return GetUserName(UserName, &UserNameSize);
}
static inline DWORD FspNpCallLauncherPipe(PWSTR PipeBuf, ULONG SendSize, ULONG RecvSize)
{
DWORD NpResult;
@ -489,6 +496,7 @@ DWORD APIENTRY NPAddConnection(LPNETRESOURCEW lpNetResource, LPWSTR lpPassword,
WCHAR LocalNameBuf[3];
PWSTR ClassName, InstanceName, RemoteName, P;
ULONG ClassNameLen, InstanceNameLen;
WCHAR LocalUserName[UNLEN + 1];
DWORD CredentialsKind;
PWSTR PipeBuf = 0;
#if defined(FSP_NP_CREDENTIAL_MANAGER)
@ -517,6 +525,9 @@ DWORD APIENTRY NPAddConnection(LPNETRESOURCEW lpNetResource, LPWSTR lpPassword,
return WN_ALREADY_CONNECTED;
}
if (!FspNpGetLocalUserName(LocalUserName, sizeof LocalUserName / sizeof LocalUserName[0]))
LocalUserName[0] = L'\0';
FspNpGetCredentialsKind(lpRemoteName, &CredentialsKind);
#if defined(FSP_NP_CREDENTIAL_MANAGER)
@ -571,6 +582,7 @@ DWORD APIENTRY NPAddConnection(LPNETRESOURCEW lpNetResource, LPWSTR lpPassword,
memcpy(P, InstanceName, InstanceNameLen * sizeof(WCHAR)); P += InstanceNameLen; *P++ = L'\0';
lstrcpyW(P, RemoteName); P += lstrlenW(RemoteName) + 1;
lstrcpyW(P, LocalNameBuf); P += lstrlenW(LocalNameBuf) + 1;
lstrcpyW(P, LocalUserName); P += lstrlenW(LocalUserName) + 1;
if (FSP_NP_CREDENTIALS_USERPASS == CredentialsKind)
{
lstrcpyW(P, lpUserName); P += lstrlenW(lpUserName) + 1;
@ -721,7 +733,7 @@ DWORD APIENTRY NPAddConnection3(HWND hwndOwner,
lstrcpyW(UserName, L"UNSPECIFIED");
Password[0] = L'\0';
if (FSP_NP_CREDENTIALS_PASSWORD == CredentialsKind)
FspNpParseUserName(RemoteName, UserName, sizeof UserName / sizeof UserName[0]);
FspNpParseRemoteUserName(RemoteName, UserName, sizeof UserName / sizeof UserName[0]);
do
{
NpResult = FspNpGetCredentials(