HADOOP-11639. Clean up Windows native code compilation warnings related to Windows Secure Container Executor. Contributed by Remus Rusanu.

(cherry picked from commit 3836ad6c0b)
This commit is contained in:
cnauroth 2015-03-27 15:03:41 -07:00
parent 853cc04668
commit eb7068c2c9
9 changed files with 76 additions and 55 deletions

View File

@ -756,6 +756,9 @@ Release 2.7.0 - UNRELEASED
HADOOP-11691. X86 build of libwinutils is broken. HADOOP-11691. X86 build of libwinutils is broken.
(Kiran Kumar M R via cnauroth) (Kiran Kumar M R via cnauroth)
HADOOP-11639. Clean up Windows native code compilation warnings related to
Windows Secure Container Executor. (Remus Rusanu via cnauroth)
Release 2.6.1 - UNRELEASED Release 2.6.1 - UNRELEASED
INCOMPATIBLE CHANGES INCOMPATIBLE CHANGES

View File

@ -409,7 +409,7 @@ Java_org_apache_hadoop_yarn_server_nodemanager_WindowsSecureContainerExecutor_00
done: done:
if (path) (*env)->ReleaseStringChars(env, jpath, path); if (path) (*env)->ReleaseStringChars(env, jpath, path);
return hFile; return (jlong) hFile;
#endif #endif
} }

View File

@ -28,8 +28,6 @@ static ACCESS_MASK CLIENT_MASK = 1;
VOID ReportClientError(LPWSTR lpszLocation, DWORD dwError) { VOID ReportClientError(LPWSTR lpszLocation, DWORD dwError) {
LPWSTR debugMsg = NULL; LPWSTR debugMsg = NULL;
int len; int len;
WCHAR hexError[32];
HRESULT hr;
if (IsDebuggerPresent()) { if (IsDebuggerPresent()) {
len = FormatMessageW( len = FormatMessageW(
@ -49,7 +47,6 @@ DWORD PrepareRpcBindingHandle(
DWORD dwError = EXIT_FAILURE; DWORD dwError = EXIT_FAILURE;
RPC_STATUS status; RPC_STATUS status;
LPWSTR lpszStringBinding = NULL; LPWSTR lpszStringBinding = NULL;
ULONG ulCode;
RPC_SECURITY_QOS_V3 qos; RPC_SECURITY_QOS_V3 qos;
SID_IDENTIFIER_AUTHORITY authNT = SECURITY_NT_AUTHORITY; SID_IDENTIFIER_AUTHORITY authNT = SECURITY_NT_AUTHORITY;
BOOL rpcBindingInit = FALSE; BOOL rpcBindingInit = FALSE;
@ -104,7 +101,7 @@ DWORD PrepareRpcBindingHandle(
RPC_C_AUTHN_WINNT, // AuthnSvc RPC_C_AUTHN_WINNT, // AuthnSvc
NULL, // AuthnIdentity (self) NULL, // AuthnIdentity (self)
RPC_C_AUTHZ_NONE, // AuthzSvc RPC_C_AUTHZ_NONE, // AuthzSvc
&qos); (RPC_SECURITY_QOS*) &qos);
if (RPC_S_OK != status) { if (RPC_S_OK != status) {
ReportClientError(L"RpcBindingSetAuthInfoEx", status); ReportClientError(L"RpcBindingSetAuthInfoEx", status);
dwError = status; dwError = status;
@ -375,7 +372,7 @@ DWORD RpcCall_WinutilsCreateFile(
RpcEndExcept; RpcEndExcept;
if (ERROR_SUCCESS == dwError) { if (ERROR_SUCCESS == dwError) {
*hFile = response->hFile; *hFile = (HANDLE) response->hFile;
} }
done: done:
@ -479,11 +476,11 @@ DWORD RpcCall_TaskCreateAsUser(
RpcEndExcept; RpcEndExcept;
if (ERROR_SUCCESS == dwError) { if (ERROR_SUCCESS == dwError) {
*phProcess = response->hProcess; *phProcess = (HANDLE) response->hProcess;
*phThread = response->hThread; *phThread = (HANDLE) response->hThread;
*phStdIn = response->hStdIn; *phStdIn = (HANDLE) response->hStdIn;
*phStdOut = response->hStdOut; *phStdOut = (HANDLE) response->hStdOut;
*phStdErr = response->hStdErr; *phStdErr = (HANDLE) response->hStdErr;
} }
done: done:

View File

@ -18,7 +18,7 @@
#include "winutils.h" #include "winutils.h"
#include <string.h> #include <string.h>
#include <stdlib.h> #include <stdlib.h>
#import "msxml6.dll" #import "msxml6.dll" exclude("ISequentialStream", "_FILETIME")
#define ERROR_CHECK_HRESULT_DONE(hr, message) \ #define ERROR_CHECK_HRESULT_DONE(hr, message) \
if (FAILED(hr)) { \ if (FAILED(hr)) { \

View File

@ -248,8 +248,8 @@ DWORD BuildServiceSecurityDescriptor(
__out PSECURITY_DESCRIPTOR* pSD); __out PSECURITY_DESCRIPTOR* pSD);
DWORD AddNodeManagerAndUserACEsToObject( DWORD AddNodeManagerAndUserACEsToObject(
__in HANDLE hObject, __in HANDLE hProcess,
__in LPWSTR user, __in LPCWSTR user,
__in ACCESS_MASK accessMask); __in ACCESS_MASK accessMask);
@ -283,15 +283,29 @@ DWORD RpcCall_WinutilsCreateFile(
__out HANDLE* hFile); __out HANDLE* hFile);
DWORD RpcCall_WinutilsMoveFile( DWORD RpcCall_WinutilsMoveFile(
__in LPCWSTR sourcePath, __in int operation,
__in LPCWSTR destinationPath, __in LPCWSTR sourcePath,
__in BOOL replaceExisting); __in LPCWSTR destinationPath,
__in BOOL replaceExisting);
DWORD RpcCall_WinutilsDeletePath( DWORD RpcCall_WinutilsDeletePath(
__in LPCWSTR path, __in LPCWSTR path,
__in BOOL isDir, __in BOOL isDir,
__out BOOL* pDeleted); __out BOOL* pDeleted);
DWORD RpcCall_WinutilsChown(
__in LPCWSTR filePath,
__in_opt LPCWSTR ownerName,
__in_opt LPCWSTR groupName);
DWORD RpcCall_WinutilsMkDir(
__in LPCWSTR filePath);
DWORD RpcCall_WinutilsChmod(
__in LPCWSTR filePath,
__in int mode);
#ifdef __cplusplus #ifdef __cplusplus
} }
#endif #endif

View File

@ -2596,7 +2596,7 @@ LPCWSTR GetSystemTimeString() {
QueryPerformanceFrequency(&frequency); QueryPerformanceFrequency(&frequency);
qpc = (double) counter.QuadPart / (double) frequency.QuadPart; qpc = (double) counter.QuadPart / (double) frequency.QuadPart;
subSec = ((qpc - (long)qpc) * 1000000); subSec = (int)((qpc - (long)qpc) * 1000000);
hr = StringCbPrintf(buffer, sizeof(buffer), L"%02d:%02d:%02d.%06d", hr = StringCbPrintf(buffer, sizeof(buffer), L"%02d:%02d:%02d.%06d",
(int)systime.wHour, (int)systime.wMinute, (int)systime.wSecond, (int)subSec); (int)systime.wHour, (int)systime.wMinute, (int)systime.wSecond, (int)subSec);
@ -2619,7 +2619,7 @@ done:
// Native debugger: windbg, ntsd, cdb, visual studio // Native debugger: windbg, ntsd, cdb, visual studio
// //
VOID LogDebugMessage(LPCWSTR format, ...) { VOID LogDebugMessage(LPCWSTR format, ...) {
LPWSTR buffer[8192]; wchar_t buffer[8192];
va_list args; va_list args;
HRESULT hr; HRESULT hr;
@ -2657,8 +2657,8 @@ DWORD SplitStringIgnoreSpaceW(
size_t tokenCount = 0; size_t tokenCount = 0;
size_t crtSource; size_t crtSource;
size_t crtToken = 0; size_t crtToken = 0;
WCHAR* lpwszTokenStart = NULL; const WCHAR* lpwszTokenStart = NULL;
WCHAR* lpwszTokenEnd = NULL; const WCHAR* lpwszTokenEnd = NULL;
WCHAR* lpwszBuffer = NULL; WCHAR* lpwszBuffer = NULL;
size_t tokenLength = 0; size_t tokenLength = 0;
size_t cchBufferLength = 0; size_t cchBufferLength = 0;
@ -2849,7 +2849,7 @@ DWORD BuildServiceSecurityDescriptor(
} }
} }
pTokenGroup = (PTOKEN_USER) LocalAlloc(LPTR, dwBufferSize); pTokenGroup = (PTOKEN_PRIMARY_GROUP) LocalAlloc(LPTR, dwBufferSize);
if (NULL == pTokenGroup) { if (NULL == pTokenGroup) {
dwError = GetLastError(); dwError = GetLastError();
LogDebugMessage(L"LocalAlloc:pTokenGroup: %d\n", dwError); LogDebugMessage(L"LocalAlloc:pTokenGroup: %d\n", dwError);
@ -2870,11 +2870,11 @@ DWORD BuildServiceSecurityDescriptor(
owner.TrusteeForm = TRUSTEE_IS_SID; owner.TrusteeForm = TRUSTEE_IS_SID;
owner.TrusteeType = TRUSTEE_IS_UNKNOWN; owner.TrusteeType = TRUSTEE_IS_UNKNOWN;
owner.ptstrName = (LPCWSTR) pOwner; owner.ptstrName = (LPWSTR) pOwner;
group.TrusteeForm = TRUSTEE_IS_SID; group.TrusteeForm = TRUSTEE_IS_SID;
group.TrusteeType = TRUSTEE_IS_UNKNOWN; group.TrusteeType = TRUSTEE_IS_UNKNOWN;
group.ptstrName = (LPCWSTR) pTokenGroup->PrimaryGroup; group.ptstrName = (LPWSTR) pTokenGroup->PrimaryGroup;
eas = (EXPLICIT_ACCESS*) LocalAlloc(LPTR, sizeof(EXPLICIT_ACCESS) * (grantSidCount + denySidCount)); eas = (EXPLICIT_ACCESS*) LocalAlloc(LPTR, sizeof(EXPLICIT_ACCESS) * (grantSidCount + denySidCount));
if (NULL == eas) { if (NULL == eas) {
@ -2890,7 +2890,7 @@ DWORD BuildServiceSecurityDescriptor(
eas[crt].grfInheritance = NO_INHERITANCE; eas[crt].grfInheritance = NO_INHERITANCE;
eas[crt].Trustee.TrusteeForm = TRUSTEE_IS_SID; eas[crt].Trustee.TrusteeForm = TRUSTEE_IS_SID;
eas[crt].Trustee.TrusteeType = TRUSTEE_IS_UNKNOWN; eas[crt].Trustee.TrusteeType = TRUSTEE_IS_UNKNOWN;
eas[crt].Trustee.ptstrName = (LPCWSTR) pGrantSids[crt]; eas[crt].Trustee.ptstrName = (LPWSTR) pGrantSids[crt];
eas[crt].Trustee.pMultipleTrustee = NULL; eas[crt].Trustee.pMultipleTrustee = NULL;
eas[crt].Trustee.MultipleTrusteeOperation = NO_MULTIPLE_TRUSTEE; eas[crt].Trustee.MultipleTrusteeOperation = NO_MULTIPLE_TRUSTEE;
} }
@ -2902,7 +2902,7 @@ DWORD BuildServiceSecurityDescriptor(
eas[crt].grfInheritance = NO_INHERITANCE; eas[crt].grfInheritance = NO_INHERITANCE;
eas[crt].Trustee.TrusteeForm = TRUSTEE_IS_SID; eas[crt].Trustee.TrusteeForm = TRUSTEE_IS_SID;
eas[crt].Trustee.TrusteeType = TRUSTEE_IS_UNKNOWN; eas[crt].Trustee.TrusteeType = TRUSTEE_IS_UNKNOWN;
eas[crt].Trustee.ptstrName = (LPCWSTR) pDenySids[crt - grantSidCount]; eas[crt].Trustee.ptstrName = (LPWSTR) pDenySids[crt - grantSidCount];
eas[crt].Trustee.pMultipleTrustee = NULL; eas[crt].Trustee.pMultipleTrustee = NULL;
eas[crt].Trustee.MultipleTrusteeOperation = NO_MULTIPLE_TRUSTEE; eas[crt].Trustee.MultipleTrusteeOperation = NO_MULTIPLE_TRUSTEE;
} }

View File

@ -206,7 +206,7 @@ DWORD ValidateConfigurationFile() {
BOOL daclPresent = FALSE; BOOL daclPresent = FALSE;
BOOL daclDefaulted = FALSE; BOOL daclDefaulted = FALSE;
PACL pDacl = NULL; PACL pDacl = NULL;
unsigned int crt = 0, crtSid = 0; DWORD crt = 0;
WELL_KNOWN_SID_TYPE allowedSidTypes[] = { WELL_KNOWN_SID_TYPE allowedSidTypes[] = {
WinLocalSystemSid, WinLocalSystemSid,
WinBuiltinAdministratorsSid}; WinBuiltinAdministratorsSid};
@ -214,7 +214,6 @@ DWORD ValidateConfigurationFile() {
DWORD cbSid = SECURITY_MAX_SID_SIZE; DWORD cbSid = SECURITY_MAX_SID_SIZE;
PSID* allowedSids = NULL; PSID* allowedSids = NULL;
int cAllowedSids = 0; int cAllowedSids = 0;
BOOL isSidDefaulted;
PSID sidOwner = NULL; PSID sidOwner = NULL;
PSID sidGroup = NULL; PSID sidGroup = NULL;
@ -324,7 +323,7 @@ DWORD InitJobName() {
int crt = 0; int crt = 0;
// Services can be restarted // Services can be restarted
if (gJobName) LocalFree(gJobName); if (gJobName) LocalFree((HLOCAL)gJobName);
gJobName = NULL; gJobName = NULL;
dwError = GetConfigValue( dwError = GetConfigValue(
@ -382,7 +381,7 @@ DWORD InitLocalDirs() {
} }
done: done:
if (value) LocalFree(value); if (value) LocalFree((HLOCAL)value);
return dwError; return dwError;
} }
@ -437,7 +436,7 @@ DWORD ValidateLocalPath(LPCWSTR lpszPath) {
gLocalDirs[crt], gCchLocalDir[crt], gLocalDirs[crt], gCchLocalDir[crt],
NULL, // lpVersionInformation NULL, // lpVersionInformation
NULL, // lpReserved NULL, // lpReserved
NULL); // lParam (LPARAM) NULL); // lParam
if (0 == compareResult) { if (0 == compareResult) {
dwError = GetLastError(); dwError = GetLastError();
@ -500,7 +499,7 @@ done:
// Description: // Description:
// Service main entry point. // Service main entry point.
// //
VOID WINAPI SvcMain() { VOID WINAPI SvcMain(DWORD dwArg, LPTSTR* lpszArgv) {
DWORD dwError = ERROR_SUCCESS; DWORD dwError = ERROR_SUCCESS;
gSvcStatusHandle = RegisterServiceCtrlHandler( gSvcStatusHandle = RegisterServiceCtrlHandler(
@ -693,15 +692,15 @@ done:
// //
DWORD AuthInit() { DWORD AuthInit() {
DWORD dwError = ERROR_SUCCESS; DWORD dwError = ERROR_SUCCESS;
int count = 0; size_t count = 0;
int crt = 0; size_t crt = 0;
size_t len = 0; size_t len = 0;
LPCWSTR value = NULL; LPCWSTR value = NULL;
WCHAR** tokens = NULL; WCHAR** tokens = NULL;
LPWSTR lpszSD = NULL; LPWSTR lpszSD = NULL;
ULONG cchSD = 0; ULONG cchSD = 0;
DWORD dwBufferSize = 0; DWORD dwBufferSize = 0;
int allowedCount = 0; size_t allowedCount = 0;
PSID* allowedSids = NULL; PSID* allowedSids = NULL;
@ -737,7 +736,7 @@ DWORD AuthInit() {
done: done:
if (lpszSD) LocalFree(lpszSD); if (lpszSD) LocalFree(lpszSD);
if (value) LocalFree(value); if (value) LocalFree((HLOCAL)value);
if (tokens) LocalFree(tokens); if (tokens) LocalFree(tokens);
return dwError; return dwError;
} }
@ -1167,11 +1166,12 @@ error_status_t WinutilsCreateProcessAsUser(
// Note that there are no more API calls, only assignments. A failure could occur only if // Note that there are no more API calls, only assignments. A failure could occur only if
// foced (process kill) or hardware error (faulty memory, processort bit flip etc). // foced (process kill) or hardware error (faulty memory, processort bit flip etc).
(*response)->hProcess = hDuplicateProcess; // as MIDL has no 'HANDLE' type, the (LONG_PTR) is used instead
(*response)->hThread = hDuplicateThread; (*response)->hProcess = (LONG_PTR)hDuplicateProcess;
(*response)->hStdIn = hDuplicateStdIn; (*response)->hThread = (LONG_PTR)hDuplicateThread;
(*response)->hStdOut = hDuplicateStdOut; (*response)->hStdIn = (LONG_PTR)hDuplicateStdIn;
(*response)->hStdErr = hDuplicateStdErr; (*response)->hStdOut = (LONG_PTR)hDuplicateStdOut;
(*response)->hStdErr = (LONG_PTR)hDuplicateStdErr;
fMustCleanupProcess = FALSE; fMustCleanupProcess = FALSE;
@ -1276,7 +1276,8 @@ error_status_t WinutilsCreateFile(
goto done; goto done;
} }
(*response)->hFile = hDuplicateFile; // As MIDL has no 'HANDLE' type, (LONG_PTR) is used instead
(*response)->hFile = (LONG_PTR)hDuplicateFile;
hDuplicateFile = INVALID_HANDLE_VALUE; hDuplicateFile = INVALID_HANDLE_VALUE;
done: done:
@ -1302,7 +1303,6 @@ error_status_t WinutilsKillTask(
/* [in] */ handle_t IDL_handle, /* [in] */ handle_t IDL_handle,
/* [in] */ KILLTASK_REQUEST *request) { /* [in] */ KILLTASK_REQUEST *request) {
DWORD dwError = ERROR_SUCCESS; DWORD dwError = ERROR_SUCCESS;
HRESULT hr;
WCHAR bufferName[MAX_PATH]; WCHAR bufferName[MAX_PATH];
dwError = GetSecureJobObjectName(request->taskName, MAX_PATH, bufferName); dwError = GetSecureJobObjectName(request->taskName, MAX_PATH, bufferName);

View File

@ -19,6 +19,9 @@
#include <psapi.h> #include <psapi.h>
#include <PowrProf.h> #include <PowrProf.h>
#ifdef PSAPI_VERSION
#undef PSAPI_VERSION
#endif
#define PSAPI_VERSION 1 #define PSAPI_VERSION 1
#pragma comment(lib, "psapi.lib") #pragma comment(lib, "psapi.lib")
#pragma comment(lib, "Powrprof.lib") #pragma comment(lib, "Powrprof.lib")

View File

@ -22,6 +22,9 @@
#include <authz.h> #include <authz.h>
#include <sddl.h> #include <sddl.h>
#ifdef PSAPI_VERSION
#undef PSAPI_VERSION
#endif
#define PSAPI_VERSION 1 #define PSAPI_VERSION 1
#pragma comment(lib, "psapi.lib") #pragma comment(lib, "psapi.lib")
@ -231,7 +234,7 @@ DWORD BuildImpersonateSecurityDescriptor(__out PSECURITY_DESCRIPTOR* ppSD) {
LocalFree(tokens); LocalFree(tokens);
tokens = NULL; tokens = NULL;
LocalFree(value); LocalFree((HLOCAL)value);
value = NULL; value = NULL;
dwError = GetConfigValue(wsceConfigRelativePath, NM_WSCE_IMPERSONATE_DENIED, &len, &value); dwError = GetConfigValue(wsceConfigRelativePath, NM_WSCE_IMPERSONATE_DENIED, &len, &value);
@ -298,18 +301,18 @@ done:
// //
DWORD AddNodeManagerAndUserACEsToObject( DWORD AddNodeManagerAndUserACEsToObject(
__in HANDLE hObject, __in HANDLE hObject,
__in LPWSTR user, __in LPCWSTR user,
__in ACCESS_MASK accessMask) { __in ACCESS_MASK accessMask) {
DWORD dwError = ERROR_SUCCESS; DWORD dwError = ERROR_SUCCESS;
int countTokens = 0; size_t countTokens = 0;
size_t len = 0; size_t len = 0;
LPCWSTR value = NULL; LPCWSTR value = NULL;
WCHAR** tokens = NULL; WCHAR** tokens = NULL;
int crt = 0; DWORD crt = 0;
PACL pDacl = NULL; PACL pDacl = NULL;
PSECURITY_DESCRIPTOR psdProcess = NULL; PSECURITY_DESCRIPTOR psdProcess = NULL;
LPSTR lpszOldDacl = NULL, lpszNewDacl = NULL; LPWSTR lpszOldDacl = NULL, lpszNewDacl = NULL;
ULONG daclLen = 0; ULONG daclLen = 0;
PACL pNewDacl = NULL; PACL pNewDacl = NULL;
ACL_SIZE_INFORMATION si; ACL_SIZE_INFORMATION si;
@ -381,8 +384,8 @@ DWORD AddNodeManagerAndUserACEsToObject(
// ACCESS_ALLOWED_ACE struct contains the first DWORD of the SID // ACCESS_ALLOWED_ACE struct contains the first DWORD of the SID
// //
dwNewAclSize = si.AclBytesInUse + dwNewAclSize = si.AclBytesInUse +
(countTokens + 1 + sizeof(forcesSidTypes)/sizeof(forcesSidTypes[0])) * (DWORD)(countTokens + 1 + sizeof(forcesSidTypes)/sizeof(forcesSidTypes[0])) *
(sizeof(ACCESS_ALLOWED_ACE) + SECURITY_MAX_SID_SIZE - sizeof(DWORD)); (sizeof(ACCESS_ALLOWED_ACE) + SECURITY_MAX_SID_SIZE - sizeof(DWORD));
pNewDacl = (PSID) LocalAlloc(LPTR, dwNewAclSize); pNewDacl = (PSID) LocalAlloc(LPTR, dwNewAclSize);
if (!pNewDacl) { if (!pNewDacl) {
@ -511,7 +514,7 @@ DWORD AddNodeManagerAndUserACEsToObject(
goto done; goto done;
} }
LogDebugMessage(L"Old DACL: %s\nNew DACL: %s\n", lpszOldDacl, lpszNewDacl); LogDebugMessage(L"Old DACL: %ls\nNew DACL: %ls\n", lpszOldDacl, lpszNewDacl);
} }
done: done:
@ -634,7 +637,7 @@ done:
// Returns: // Returns:
// ERROR_SUCCESS: On success // ERROR_SUCCESS: On success
// GetLastError: otherwise // GetLastError: otherwise
DWORD CreateTaskImpl(__in_opt HANDLE logonHandle, __in PCWSTR jobObjName,__in PCWSTR cmdLine, DWORD CreateTaskImpl(__in_opt HANDLE logonHandle, __in PCWSTR jobObjName,__in PWSTR cmdLine,
__in LPCWSTR userName, __in long memory, __in long cpuRate) __in LPCWSTR userName, __in long memory, __in long cpuRate)
{ {
DWORD dwErrorCode = ERROR_SUCCESS; DWORD dwErrorCode = ERROR_SUCCESS;
@ -912,7 +915,7 @@ DWORD CreateTask(__in PCWSTR jobObjName,__in PWSTR cmdLine, __in long memory, __
// ERROR_SUCCESS: On success // ERROR_SUCCESS: On success
// GetLastError: otherwise // GetLastError: otherwise
DWORD CreateTaskAsUser(__in PCWSTR jobObjName, DWORD CreateTaskAsUser(__in PCWSTR jobObjName,
__in PCWSTR user, __in PCWSTR pidFilePath, __in PCWSTR cmdLine) __in PCWSTR user, __in PCWSTR pidFilePath, __in PWSTR cmdLine)
{ {
DWORD err = ERROR_SUCCESS; DWORD err = ERROR_SUCCESS;
DWORD exitCode = EXIT_FAILURE; DWORD exitCode = EXIT_FAILURE;
@ -923,6 +926,7 @@ DWORD CreateTaskAsUser(__in PCWSTR jobObjName,
FILE* pidFile = NULL; FILE* pidFile = NULL;
DWORD retLen = 0; DWORD retLen = 0;
HANDLE logonHandle = NULL; HANDLE logonHandle = NULL;
errno_t pidErrNo = 0;
err = EnableImpersonatePrivileges(); err = EnableImpersonatePrivileges();
if( err != ERROR_SUCCESS ) { if( err != ERROR_SUCCESS ) {
@ -961,8 +965,8 @@ DWORD CreateTaskAsUser(__in PCWSTR jobObjName,
profileIsLoaded = TRUE; profileIsLoaded = TRUE;
// Create the PID file // Create the PID file
pidErrNo = _wfopen_s(&pidFile, pidFilePath, L"w");
if (!(pidFile = _wfopen(pidFilePath, "w"))) { if (pidErrNo) {
err = GetLastError(); err = GetLastError();
ReportErrorCode(L"_wfopen:pidFilePath", err); ReportErrorCode(L"_wfopen:pidFilePath", err);
goto done; goto done;