mirror of
https://github.com/reactos/reactos.git
synced 2025-01-04 21:38:43 +00:00
[SERVICES]
- RChangeServiceConfigA/W: Modify or delete password secrets. [ADVAPI32] - ChangeServiceConfigA, CreateServiceA: Convert passwords to Unicode before passing them to the remote functions. svn path=/trunk/; revision=71394
This commit is contained in:
parent
0977ee2d46
commit
51881431dd
3 changed files with 100 additions and 9 deletions
|
@ -481,7 +481,7 @@ ScmSetServicePassword(
|
|||
|
||||
Status = LsaStorePrivateData(PolicyHandle,
|
||||
&ServiceName,
|
||||
&Password);
|
||||
pszPassword ? &Password : NULL);
|
||||
if (!NT_SUCCESS(Status))
|
||||
{
|
||||
dwError = RtlNtStatusToDosError(Status);
|
||||
|
|
|
@ -2022,7 +2022,27 @@ DWORD RChangeServiceConfigW(
|
|||
|
||||
if (lpPassword != NULL)
|
||||
{
|
||||
/* FIXME: Decrypt and write password */
|
||||
if (wcslen((LPWSTR)lpPassword) != 0)
|
||||
{
|
||||
/* FIXME: Decrypt the password */
|
||||
|
||||
/* Write the password */
|
||||
dwError = ScmSetServicePassword(lpService->szServiceName,
|
||||
(LPCWSTR)lpPassword);
|
||||
if (dwError != ERROR_SUCCESS)
|
||||
goto done;
|
||||
}
|
||||
else
|
||||
{
|
||||
/* Delete the password */
|
||||
dwError = ScmSetServicePassword(lpService->szServiceName,
|
||||
NULL);
|
||||
if (dwError == ERROR_FILE_NOT_FOUND)
|
||||
dwError = ERROR_SUCCESS;
|
||||
|
||||
if (dwError != ERROR_SUCCESS)
|
||||
goto done;
|
||||
}
|
||||
}
|
||||
|
||||
done:
|
||||
|
@ -3460,11 +3480,34 @@ DWORD RChangeServiceConfigA(
|
|||
dwDependSize);
|
||||
|
||||
HeapFree(GetProcessHeap(), 0, lpDependenciesW);
|
||||
|
||||
if (dwError != ERROR_SUCCESS)
|
||||
goto done;
|
||||
}
|
||||
|
||||
if (lpPassword != NULL)
|
||||
{
|
||||
/* FIXME: Decrypt and write password */
|
||||
if (wcslen((LPWSTR)lpPassword) != 0)
|
||||
{
|
||||
/* FIXME: Decrypt the password */
|
||||
|
||||
/* Write the password */
|
||||
dwError = ScmSetServicePassword(lpService->szServiceName,
|
||||
(LPCWSTR)lpPassword);
|
||||
if (dwError != ERROR_SUCCESS)
|
||||
goto done;
|
||||
}
|
||||
else
|
||||
{
|
||||
/* Delete the password */
|
||||
dwError = ScmSetServicePassword(lpService->szServiceName,
|
||||
NULL);
|
||||
if (dwError == ERROR_FILE_NOT_FOUND)
|
||||
dwError = ERROR_SUCCESS;
|
||||
|
||||
if (dwError != ERROR_SUCCESS)
|
||||
goto done;
|
||||
}
|
||||
}
|
||||
|
||||
done:
|
||||
|
|
|
@ -287,6 +287,7 @@ ChangeServiceConfigA(SC_HANDLE hService,
|
|||
SIZE_T cchLength;
|
||||
LPCSTR lpStr;
|
||||
DWORD dwPasswordLength = 0;
|
||||
LPWSTR lpPasswordW = NULL;
|
||||
LPBYTE lpEncryptedPassword = NULL;
|
||||
|
||||
TRACE("ChangeServiceConfigA() called\n");
|
||||
|
@ -304,9 +305,29 @@ ChangeServiceConfigA(SC_HANDLE hService,
|
|||
dwDependenciesLength++;
|
||||
}
|
||||
|
||||
/* FIXME: Encrypt the password */
|
||||
lpEncryptedPassword = (LPBYTE)lpPassword;
|
||||
dwPasswordLength = (DWORD)(lpPassword ? (strlen(lpPassword) + 1) * sizeof(CHAR) : 0);
|
||||
if (lpPassword != NULL)
|
||||
{
|
||||
/* Convert the password to unicode */
|
||||
lpPasswordW = HeapAlloc(GetProcessHeap(),
|
||||
HEAP_ZERO_MEMORY,
|
||||
(strlen(lpPassword) + 1) * sizeof(WCHAR));
|
||||
if (lpPasswordW == NULL)
|
||||
{
|
||||
SetLastError(ERROR_NOT_ENOUGH_MEMORY);
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
MultiByteToWideChar(CP_ACP,
|
||||
0,
|
||||
lpPassword,
|
||||
-1,
|
||||
lpPasswordW,
|
||||
(int)(strlen(lpPassword) + 1));
|
||||
|
||||
/* FIXME: Encrypt the password */
|
||||
lpEncryptedPassword = (LPBYTE)lpPasswordW;
|
||||
dwPasswordLength = (DWORD)(lpPasswordW ? (wcslen(lpPasswordW) + 1) * sizeof(WCHAR) : 0);
|
||||
}
|
||||
|
||||
RpcTryExcept
|
||||
{
|
||||
|
@ -331,6 +352,9 @@ ChangeServiceConfigA(SC_HANDLE hService,
|
|||
}
|
||||
RpcEndExcept;
|
||||
|
||||
if (lpPasswordW != NULL)
|
||||
HeapFree(GetProcessHeap(), 0, lpPasswordW);
|
||||
|
||||
if (dwError != ERROR_SUCCESS)
|
||||
{
|
||||
TRACE("RChangeServiceConfigA() failed (Error %lu)\n", dwError);
|
||||
|
@ -548,6 +572,7 @@ CreateServiceA(SC_HANDLE hSCManager,
|
|||
SIZE_T cchLength;
|
||||
LPCSTR lpStr;
|
||||
DWORD dwPasswordLength = 0;
|
||||
LPWSTR lpPasswordW = NULL;
|
||||
LPBYTE lpEncryptedPassword = NULL;
|
||||
|
||||
TRACE("CreateServiceA() called\n");
|
||||
|
@ -573,9 +598,29 @@ CreateServiceA(SC_HANDLE hSCManager,
|
|||
dwDependenciesLength++;
|
||||
}
|
||||
|
||||
/* FIXME: Encrypt the password */
|
||||
lpEncryptedPassword = (LPBYTE)lpPassword;
|
||||
dwPasswordLength = (DWORD)(lpPassword ? (strlen(lpPassword) + 1) * sizeof(CHAR) : 0);
|
||||
if (lpPassword != NULL)
|
||||
{
|
||||
/* Convert the password to unicode */
|
||||
lpPasswordW = HeapAlloc(GetProcessHeap(),
|
||||
HEAP_ZERO_MEMORY,
|
||||
(strlen(lpPassword) + 1) * sizeof(WCHAR));
|
||||
if (lpPasswordW == NULL)
|
||||
{
|
||||
SetLastError(ERROR_NOT_ENOUGH_MEMORY);
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
MultiByteToWideChar(CP_ACP,
|
||||
0,
|
||||
lpPassword,
|
||||
-1,
|
||||
lpPasswordW,
|
||||
(int)(strlen(lpPassword) + 1));
|
||||
|
||||
/* FIXME: Encrypt the password */
|
||||
lpEncryptedPassword = (LPBYTE)lpPasswordW;
|
||||
dwPasswordLength = (DWORD)(lpPasswordW ? (wcslen(lpPasswordW) + 1) * sizeof(WCHAR) : 0);
|
||||
}
|
||||
|
||||
RpcTryExcept
|
||||
{
|
||||
|
@ -603,6 +648,9 @@ CreateServiceA(SC_HANDLE hSCManager,
|
|||
}
|
||||
RpcEndExcept;
|
||||
|
||||
if (lpPasswordW != NULL)
|
||||
HeapFree(GetProcessHeap(), 0, lpPasswordW);
|
||||
|
||||
if (dwError != ERROR_SUCCESS)
|
||||
{
|
||||
TRACE("RCreateServiceA() failed (Error %lu)\n", dwError);
|
||||
|
|
Loading…
Reference in a new issue