secur32 = LoadLibrary("SECUR32.DLL");
if (secur32 == NULL)
ereport(ERROR,
- (errmsg_internal("could not load secur32.dll: %d",
- (int) GetLastError())));
+ (errmsg_internal("could not load secur32.dll: error code %lu",
+ GetLastError())));
_QuerySecurityContextToken = (QUERY_SECURITY_CONTEXT_TOKEN_FN)
GetProcAddress(secur32, "QuerySecurityContextToken");
{
FreeLibrary(secur32);
ereport(ERROR,
- (errmsg_internal("could not locate QuerySecurityContextToken in secur32.dll: %d",
- (int) GetLastError())));
+ (errmsg_internal("could not locate QuerySecurityContextToken in secur32.dll: error code %lu",
+ GetLastError())));
}
r = (_QuerySecurityContextToken) (sspictx, &token);
if (!GetTokenInformation(token, TokenUser, NULL, 0, &retlen) && GetLastError() != 122)
ereport(ERROR,
- (errmsg_internal("could not get token user size: error code %d",
- (int) GetLastError())));
+ (errmsg_internal("could not get token user size: error code %lu",
+ GetLastError())));
tokenuser = malloc(retlen);
if (tokenuser == NULL)
if (!GetTokenInformation(token, TokenUser, tokenuser, retlen, &retlen))
ereport(ERROR,
- (errmsg_internal("could not get user token: error code %d",
- (int) GetLastError())));
+ (errmsg_internal("could not get user token: error code %lu",
+ GetLastError())));
if (!LookupAccountSid(NULL, tokenuser->User.Sid, accountname, &accountnamesize,
domainname, &domainnamesize, &accountnameuse))
ereport(ERROR,
- (errmsg_internal("could not look up account SID: error code %d",
- (int) GetLastError())));
+ (errmsg_internal("could not look up account SID: error code %lu",
+ GetLastError())));
free(tokenuser);
NULL);
if (dumpFile == INVALID_HANDLE_VALUE)
{
- write_stderr("could not open crash dump file \"%s\" for writing: error code %u\n",
- dumpPath, (unsigned int) GetLastError());
+ write_stderr("could not open crash dump file \"%s\" for writing: error code %lu\n",
+ dumpPath, GetLastError());
return EXCEPTION_CONTINUE_SEARCH;
}
NULL, NULL))
write_stderr("wrote crash dump to file \"%s\"\n", dumpPath);
else
- write_stderr("could not write crash dump to file \"%s\": error code %08x\n",
- dumpPath, (unsigned int) GetLastError());
+ write_stderr("could not write crash dump to file \"%s\": error code %lu\n",
+ dumpPath, GetLastError());
CloseHandle(dumpFile);
}
kernel32 = LoadLibraryEx("kernel32.dll", NULL, 0);
if (kernel32 == NULL)
ereport(FATAL,
- (errmsg_internal("could not load kernel32.dll: %d",
- (int) GetLastError())));
+ (errmsg_internal("could not load kernel32.dll: error code %lu",
+ GetLastError())));
}
if (_RegisterWaitForSingleObject == NULL)
ereport(FATAL,
- (errmsg_internal("could not locate RegisterWaitForSingleObject in kernel32.dll: %d",
- (int) GetLastError())));
+ (errmsg_internal("could not locate RegisterWaitForSingleObject in kernel32.dll: error code %lu",
+ GetLastError())));
}
return (_RegisterWaitForSingleObject)
if (!OpenProcessToken(GetCurrentProcess(), TOKEN_READ, &AccessToken))
{
- write_stderr("could not open process token: error code %d\n",
- (int) GetLastError());
+ write_stderr("could not open process token: error code %lu\n",
+ GetLastError());
exit(1);
}
SECURITY_BUILTIN_DOMAIN_RID, DOMAIN_ALIAS_RID_ADMINS, 0, 0, 0, 0, 0,
0, &AdministratorsSid))
{
- write_stderr("could not get SID for Administrators group: error code %d\n",
- (int) GetLastError());
+ write_stderr("could not get SID for Administrators group: error code %lu\n",
+ GetLastError());
exit(1);
}
SECURITY_BUILTIN_DOMAIN_RID, DOMAIN_ALIAS_RID_POWER_USERS, 0, 0, 0, 0, 0,
0, &PowerUsersSid))
{
- write_stderr("could not get SID for PowerUsers group: error code %d\n",
- (int) GetLastError());
+ write_stderr("could not get SID for PowerUsers group: error code %lu\n",
+ GetLastError());
exit(1);
}
if (!OpenProcessToken(GetCurrentProcess(), TOKEN_READ, &AccessToken))
{
- fprintf(stderr, "could not open process token: error code %d\n",
- (int) GetLastError());
+ fprintf(stderr, "could not open process token: error code %lu\n",
+ GetLastError());
return -1;
}
if (GetLastError() != ERROR_INSUFFICIENT_BUFFER)
{
- snprintf(errbuf, errsize, "could not get token information: error code %d\n",
- (int) GetLastError());
+ snprintf(errbuf, errsize, "could not get token information: error code %lu\n",
+ GetLastError());
return FALSE;
}
if (!GetTokenInformation(token, class, *InfoBuffer,
InfoBufferSize, &InfoBufferSize))
{
- snprintf(errbuf, errsize, "could not get token information: error code %d\n",
- (int) GetLastError());
+ snprintf(errbuf, errsize, "could not get token information: error code %lu\n",
+ GetLastError());
return FALSE;
}
pgwin32_signal_event = CreateEvent(NULL, TRUE, FALSE, NULL);
if (pgwin32_signal_event == NULL)
ereport(FATAL,
- (errmsg_internal("could not create signal event: %d", (int) GetLastError())));
+ (errmsg_internal("could not create signal event: error code %lu", GetLastError())));
/* Create thread for handling signals */
signal_thread_handle = CreateThread(NULL, 0, pg_signal_thread, NULL, 0, NULL);
if (pipe == INVALID_HANDLE_VALUE)
ereport(ERROR,
- (errmsg("could not create signal listener pipe for PID %d: error code %d",
- (int) pid, (int) GetLastError())));
+ (errmsg("could not create signal listener pipe for PID %d: error code %lu",
+ (int) pid, GetLastError())));
return pipe;
}
if (pipe == INVALID_HANDLE_VALUE)
{
- write_stderr("could not create signal listener pipe: error code %d; retrying\n", (int) GetLastError());
+ write_stderr("could not create signal listener pipe: error code %lu; retrying\n", GetLastError());
SleepEx(500, FALSE);
continue;
}
* is nothing else we can do other than abort the whole
* process which will be even worse.
*/
- write_stderr("could not create signal listener pipe: error code %d; retrying\n", (int) GetLastError());
+ write_stderr("could not create signal listener pipe: error code %lu; retrying\n", GetLastError());
/*
* Keep going so we at least dispatch this signal. Hopefully,
(LPTHREAD_START_ROUTINE) pg_signal_dispatch_thread,
(LPVOID) pipe, 0, NULL);
if (hThread == INVALID_HANDLE_VALUE)
- write_stderr("could not create signal dispatch thread: error code %d\n",
- (int) GetLastError());
+ write_stderr("could not create signal dispatch thread: error code %lu\n",
+ GetLastError());
else
CloseHandle(hThread);
if (waitevent == INVALID_HANDLE_VALUE)
ereport(ERROR,
- (errmsg_internal("could not create socket waiting event: %d", (int) GetLastError())));
+ (errmsg_internal("could not create socket waiting event: error code %lu", GetLastError())));
}
else if (!ResetEvent(waitevent))
ereport(ERROR,
- (errmsg_internal("could not reset socket waiting event: %d", (int) GetLastError())));
+ (errmsg_internal("could not reset socket waiting event: error code %lu", GetLastError())));
/*
* make sure we don't multiplex this kernel event object with a different
if (r == WAIT_TIMEOUT)
return 0;
ereport(ERROR,
- (errmsg_internal("unrecognized return value from WaitForMultipleObjects: %d (%d)", r, (int) GetLastError())));
+ (errmsg_internal("unrecognized return value from WaitForMultipleObjects: %d (%lu)", r, GetLastError())));
return 0;
}
ZeroMemory(&resEvents, sizeof(resEvents));
if (WSAEnumNetworkEvents(sockets[i], events[i], &resEvents) == SOCKET_ERROR)
ereport(FATAL,
- (errmsg_internal("failed to enumerate network events: %d", (int) GetLastError())));
+ (errmsg_internal("failed to enumerate network events: error code %lu", GetLastError())));
/* Read activity? */
if (readfds && FD_ISSET(sockets[i], readfds))
{
handleDLL = LoadLibraryEx("netmsg.dll", NULL, DONT_RESOLVE_DLL_REFERENCES | LOAD_LIBRARY_AS_DATAFILE);
if (handleDLL == NULL)
ereport(FATAL,
- (errmsg_internal("could not load netmsg.dll: %d", (int) GetLastError())));
+ (errmsg_internal("could not load netmsg.dll: error code %lu", GetLastError())));
}
ZeroMemory(&wserrbuf, sizeof(wserrbuf));
timerCommArea.event = CreateEvent(NULL, TRUE, FALSE, NULL);
if (timerCommArea.event == NULL)
ereport(FATAL,
- (errmsg_internal("could not create timer event: %d",
- (int) GetLastError())));
+ (errmsg_internal("could not create timer event: error code %lu",
+ GetLastError())));
MemSet(&timerCommArea.value, 0, sizeof(struct itimerval));
timerThreadHandle = CreateThread(NULL, 0, pg_timer_thread, NULL, 0, NULL);
if (timerThreadHandle == INVALID_HANDLE_VALUE)
ereport(FATAL,
- (errmsg_internal("could not create timer thread: %d",
- (int) GetLastError())));
+ (errmsg_internal("could not create timer thread: error code %lu",
+ GetLastError())));
}
/* Request the timer thread to change settings */
latch->event = CreateEvent(NULL, TRUE, FALSE, NULL);
if (latch->event == NULL)
- elog(ERROR, "CreateEvent failed: error code %d", (int) GetLastError());
+ elog(ERROR, "CreateEvent failed: error code %lu", GetLastError());
}
void
latch->event = CreateEvent(&sa, TRUE, FALSE, NULL);
if (latch->event == NULL)
- elog(ERROR, "CreateEvent failed: error code %d", (int) GetLastError());
+ elog(ERROR, "CreateEvent failed: error code %lu", GetLastError());
}
void
* will return immediately.
*/
if (!ResetEvent(latchevent))
- elog(ERROR, "ResetEvent failed: error code %d", (int) GetLastError());
+ elog(ERROR, "ResetEvent failed: error code %lu", GetLastError());
if ((wakeEvents & WL_LATCH_SET) && latch->is_set)
{
result |= WL_LATCH_SET;
rc = WaitForMultipleObjects(numevents, events, FALSE, timeout);
if (rc == WAIT_FAILED)
- elog(ERROR, "WaitForMultipleObjects() failed: error code %d", (int) GetLastError());
+ elog(ERROR, "WaitForMultipleObjects() failed: error code %lu", GetLastError());
/* Participate in Windows signal emulation */
else if (rc == WAIT_OBJECT_0 + 1)
ZeroMemory(&resEvents, sizeof(resEvents));
if (WSAEnumNetworkEvents(sock, sockevent, &resEvents) == SOCKET_ERROR)
ereport(FATAL,
- (errmsg_internal("failed to enumerate network events: %d", (int) GetLastError())));
+ (errmsg_internal("failed to enumerate network events: error code %lu", GetLastError())));
if ((wakeEvents & WL_SOCKET_READABLE) &&
(resEvents.lNetworkEvents & FD_READ))
}
/* Otherwise it must be the latch event */
else if (rc != WAIT_OBJECT_0)
- elog(ERROR, "unexpected return code from WaitForMultipleObjects(): %d", (int) rc);
+ elog(ERROR, "unexpected return code from WaitForMultipleObjects(): %lu", rc);
}
while (result == 0);
}
else
ereport(PANIC,
- (errmsg("could not create semaphore: error code %d", (int) GetLastError())));
+ (errmsg("could not create semaphore: error code %lu", GetLastError())));
}
/*
if (errno != 0)
ereport(FATAL,
- (errmsg("could not lock semaphore: error code %d", (int) GetLastError())));
+ (errmsg("could not lock semaphore: error code %lu", GetLastError())));
}
/*
{
if (!ReleaseSemaphore(*sema, 1, NULL))
ereport(FATAL,
- (errmsg("could not unlock semaphore: error code %d", (int) GetLastError())));
+ (errmsg("could not unlock semaphore: error code %lu", GetLastError())));
}
/*
/* Otherwise we are in trouble */
ereport(FATAL,
- (errmsg("could not try-lock semaphore: error code %d", (int) GetLastError())));
+ (errmsg("could not try-lock semaphore: error code %lu", GetLastError())));
/* keep compiler quiet */
return false;
bufsize = GetFullPathName(DataDir, 0, NULL, NULL);
if (bufsize == 0)
- elog(FATAL, "could not get size for full pathname of datadir %s: %lu",
+ elog(FATAL, "could not get size for full pathname of datadir %s: error code %lu",
DataDir, GetLastError());
retptr = malloc(bufsize + 18); /* 18 for Global\PostgreSQL: */
strcpy(retptr, "Global\\PostgreSQL:");
r = GetFullPathName(DataDir, bufsize, retptr + 18, NULL);
if (r == 0 || r > bufsize)
- elog(FATAL, "could not generate full pathname for datadir %s: %lu",
+ elog(FATAL, "could not generate full pathname for datadir %s: error code %lu",
DataDir, GetLastError());
/*
if (!hmap)
ereport(FATAL,
- (errmsg("could not create shared memory segment: %lu", GetLastError()),
+ (errmsg("could not create shared memory segment: error code %lu", GetLastError()),
errdetail("Failed system call was CreateFileMapping(size=%lu, name=%s).",
(unsigned long) size, szShareMem)));
*/
if (!DuplicateHandle(GetCurrentProcess(), hmap, GetCurrentProcess(), &hmap2, 0, TRUE, DUPLICATE_SAME_ACCESS))
ereport(FATAL,
- (errmsg("could not create shared memory segment: %lu", GetLastError()),
+ (errmsg("could not create shared memory segment: error code %lu", GetLastError()),
errdetail("Failed system call was DuplicateHandle.")));
/*
* care.
*/
if (!CloseHandle(hmap))
- elog(LOG, "could not close handle to shared memory: %lu", GetLastError());
+ elog(LOG, "could not close handle to shared memory: error code %lu", GetLastError());
/* Register on-exit routine to delete the new segment */
memAddress = MapViewOfFileEx(hmap2, FILE_MAP_WRITE | FILE_MAP_READ, 0, 0, 0, NULL);
if (!memAddress)
ereport(FATAL,
- (errmsg("could not create shared memory segment: %lu", GetLastError()),
+ (errmsg("could not create shared memory segment: error code %lu", GetLastError()),
errdetail("Failed system call was MapViewOfFileEx.")));
* Release memory region reservation that was made by the postmaster
*/
if (VirtualFree(UsedShmemSegAddr, 0, MEM_RELEASE) == 0)
- elog(FATAL, "failed to release reserved memory region (addr=%p): %lu",
+ elog(FATAL, "failed to release reserved memory region (addr=%p): error code %lu",
UsedShmemSegAddr, GetLastError());
hdr = (PGShmemHeader *) MapViewOfFileEx(UsedShmemSegID, FILE_MAP_READ | FILE_MAP_WRITE, 0, 0, 0, UsedShmemSegAddr);
if (!hdr)
- elog(FATAL, "could not reattach to shared memory (key=%p, addr=%p): %lu",
+ elog(FATAL, "could not reattach to shared memory (key=%p, addr=%p): error code %lu",
UsedShmemSegID, UsedShmemSegAddr, GetLastError());
if (hdr != origUsedShmemSegAddr)
elog(FATAL, "reattaching to shared memory returned unexpected address (got %p, expected %p)",
if (UsedShmemSegAddr != NULL)
{
if (!UnmapViewOfFile(UsedShmemSegAddr))
- elog(LOG, "could not unmap view of shared memory: %lu", GetLastError());
+ elog(LOG, "could not unmap view of shared memory: error code %lu", GetLastError());
UsedShmemSegAddr = NULL;
}
{
PGSharedMemoryDetach();
if (!CloseHandle(DatumGetPointer(shmId)))
- elog(LOG, "could not close handle to shared memory: %lu", GetLastError());
+ elog(LOG, "could not close handle to shared memory: error code %lu", GetLastError());
}
/*
if (address == NULL)
{
/* Don't use FATAL since we're running in the postmaster */
- elog(LOG, "could not reserve shared memory region (addr=%p) for child %p: %lu",
+ elog(LOG, "could not reserve shared memory region (addr=%p) for child %p: error code %lu",
UsedShmemSegAddr, hChild, GetLastError());
return false;
}
NULL);
if (paramHandle == INVALID_HANDLE_VALUE)
{
- elog(LOG, "could not create backend parameter file mapping: error code %d",
- (int) GetLastError());
+ elog(LOG, "could not create backend parameter file mapping: error code %lu",
+ GetLastError());
return -1;
}
param = MapViewOfFile(paramHandle, FILE_MAP_WRITE, 0, 0, sizeof(BackendParameters));
if (!param)
{
- elog(LOG, "could not map backend parameter memory: error code %d",
- (int) GetLastError());
+ elog(LOG, "could not map backend parameter memory: error code %lu",
+ GetLastError());
CloseHandle(paramHandle);
return -1;
}
if (!CreateProcess(NULL, cmdLine, NULL, NULL, TRUE, CREATE_SUSPENDED,
NULL, NULL, &si, &pi))
{
- elog(LOG, "CreateProcess call failed: %m (error code %d)",
- (int) GetLastError());
+ elog(LOG, "CreateProcess call failed: %m (error code %lu)",
+ GetLastError());
return -1;
}
*/
if (!TerminateProcess(pi.hProcess, 255))
ereport(LOG,
- (errmsg_internal("could not terminate unstarted process: error code %d",
- (int) GetLastError())));
+ (errmsg_internal("could not terminate unstarted process: error code %lu",
+ GetLastError())));
CloseHandle(pi.hProcess);
CloseHandle(pi.hThread);
return -1; /* log made by save_backend_variables */
/* Drop the parameter shared memory that is now inherited to the backend */
if (!UnmapViewOfFile(param))
- elog(LOG, "could not unmap view of backend parameter file: error code %d",
- (int) GetLastError());
+ elog(LOG, "could not unmap view of backend parameter file: error code %lu",
+ GetLastError());
if (!CloseHandle(paramHandle))
- elog(LOG, "could not close handle to backend parameter file: error code %d",
- (int) GetLastError());
+ elog(LOG, "could not close handle to backend parameter file: error code %lu",
+ GetLastError());
/*
* Reserve the memory region used by our main shared memory segment before
*/
if (!TerminateProcess(pi.hProcess, 255))
ereport(LOG,
- (errmsg_internal("could not terminate process that failed to reserve memory: error code %d",
- (int) GetLastError())));
+ (errmsg_internal("could not terminate process that failed to reserve memory: error code %lu",
+ GetLastError())));
CloseHandle(pi.hProcess);
CloseHandle(pi.hThread);
return -1; /* logging done made by
if (!TerminateProcess(pi.hProcess, 255))
{
ereport(LOG,
- (errmsg_internal("could not terminate unstartable process: error code %d",
- (int) GetLastError())));
+ (errmsg_internal("could not terminate unstartable process: error code %lu",
+ GetLastError())));
CloseHandle(pi.hProcess);
CloseHandle(pi.hThread);
return -1;
CloseHandle(pi.hProcess);
CloseHandle(pi.hThread);
ereport(LOG,
- (errmsg_internal("could not resume thread of unstarted process: error code %d",
- (int) GetLastError())));
+ (errmsg_internal("could not resume thread of unstarted process: error code %lu",
+ GetLastError())));
return -1;
}
INFINITE,
WT_EXECUTEONLYONCE | WT_EXECUTEINWAITTHREAD))
ereport(FATAL,
- (errmsg_internal("could not register process for wait: error code %d",
- (int) GetLastError())));
+ (errmsg_internal("could not register process for wait: error code %lu",
+ GetLastError())));
/* Don't close pi.hProcess here - the wait thread needs access to it */
DUPLICATE_CLOSE_SOURCE | DUPLICATE_SAME_ACCESS))
{
ereport(LOG,
- (errmsg_internal("could not duplicate handle to be written to backend parameter file: error code %d",
- (int) GetLastError())));
+ (errmsg_internal("could not duplicate handle to be written to backend parameter file: error code %lu",
+ GetLastError())));
return false;
}
paramp = MapViewOfFile(paramHandle, FILE_MAP_READ, 0, 0, 0);
if (!paramp)
{
- write_stderr("could not map view of backend variables: error code %d\n",
- (int) GetLastError());
+ write_stderr("could not map view of backend variables: error code %lu\n",
+ GetLastError());
exit(1);
}
if (!UnmapViewOfFile(paramp))
{
- write_stderr("could not unmap view of backend variables: error code %d\n",
- (int) GetLastError());
+ write_stderr("could not unmap view of backend variables: error code %lu\n",
+ GetLastError());
exit(1);
}
if (!CloseHandle(paramHandle))
{
- write_stderr("could not close handle to backend parameter variables: error code %d\n",
- (int) GetLastError());
+ write_stderr("could not close handle to backend parameter variables: error code %lu\n",
+ GetLastError());
exit(1);
}
#endif
TRUE,
DUPLICATE_SAME_ACCESS) == 0)
ereport(FATAL,
- (errmsg_internal("could not duplicate postmaster handle: error code %d",
- (int) GetLastError())));
+ (errmsg_internal("could not duplicate postmaster handle: error code %lu",
+ GetLastError())));
#endif /* WIN32 */
}
len = WideCharToMultiByte(CP_UTF8, 0, wbuf, len, dst, dstlen, NULL, NULL);
if (len == 0)
elog(ERROR,
- "could not convert string to UTF-8:error %lu", GetLastError());
+ "could not convert string to UTF-8: error code %lu", GetLastError());
dst[len] = '\0';
if (encoding != PG_UTF8)
(LPWSTR) a1p, a1len / 2);
if (!r)
ereport(ERROR,
- (errmsg("could not convert string to UTF-16: error %lu",
+ (errmsg("could not convert string to UTF-16: error code %lu",
GetLastError())));
}
((LPWSTR) a1p)[r] = 0;
(LPWSTR) a2p, a2len / 2);
if (!r)
ereport(ERROR,
- (errmsg("could not convert string to UTF-16: error %lu",
+ (errmsg("could not convert string to UTF-16: error code %lu",
GetLastError())));
}
((LPWSTR) a2p)[r] = 0;
/* Open the current token to use as a base for the restricted one */
if (!OpenProcessToken(GetCurrentProcess(), TOKEN_ALL_ACCESS, &origToken))
{
- fprintf(stderr, "Failed to open process token: %lu\n", GetLastError());
+ fprintf(stderr, "Failed to open process token: error code %lu\n", GetLastError());
return 0;
}
SECURITY_BUILTIN_DOMAIN_RID, DOMAIN_ALIAS_RID_POWER_USERS, 0, 0, 0, 0, 0,
0, &dropSids[1].Sid))
{
- fprintf(stderr, "Failed to allocate SIDs: %lu\n", GetLastError());
+ fprintf(stderr, "Failed to allocate SIDs: error code %lu\n", GetLastError());
return 0;
}
if (!b)
{
- fprintf(stderr, "Failed to create restricted token: %lu\n", GetLastError());
+ fprintf(stderr, "Failed to create restricted token: error code %lu\n", GetLastError());
return 0;
}
processInfo))
{
- fprintf(stderr, "CreateProcessAsUser failed: %lu\n", GetLastError());
+ fprintf(stderr, "CreateProcessAsUser failed: error code %lu\n", GetLastError());
return 0;
}
if (!CreateRestrictedProcess(cmdline, &pi))
{
- fprintf(stderr, "Failed to re-exec with restricted token: %lu.\n", GetLastError());
+ fprintf(stderr, "Failed to re-exec with restricted token: error code %lu\n", GetLastError());
}
else
{
if (!GetExitCodeProcess(pi.hProcess, &x))
{
- fprintf(stderr, "Failed to get exit code from subprocess: %lu\n", GetLastError());
+ fprintf(stderr, "Failed to get exit code from subprocess: error code %lu\n", GetLastError());
exit(1);
}
exit(x);
NULL, NULL, "RPCSS\0", register_username, register_password)) == NULL)
{
CloseServiceHandle(hSCM);
- write_stderr(_("%s: could not register service \"%s\": error code %d\n"), progname, register_servicename, (int) GetLastError());
+ write_stderr(_("%s: could not register service \"%s\": error code %lu\n"), progname, register_servicename, GetLastError());
exit(1);
}
CloseServiceHandle(hService);
if ((hService = OpenService(hSCM, register_servicename, DELETE)) == NULL)
{
CloseServiceHandle(hSCM);
- write_stderr(_("%s: could not open service \"%s\": error code %d\n"), progname, register_servicename, (int) GetLastError());
+ write_stderr(_("%s: could not open service \"%s\": error code %lu\n"), progname, register_servicename, GetLastError());
exit(1);
}
if (!DeleteService(hService))
{
CloseServiceHandle(hService);
CloseServiceHandle(hSCM);
- write_stderr(_("%s: could not unregister service \"%s\": error code %d\n"), progname, register_servicename, (int) GetLastError());
+ write_stderr(_("%s: could not unregister service \"%s\": error code %lu\n"), progname, register_servicename, GetLastError());
exit(1);
}
CloseServiceHandle(hService);
if (StartServiceCtrlDispatcher(st) == 0)
{
- write_stderr(_("%s: could not start service \"%s\": error code %d\n"), progname, register_servicename, (int) GetLastError());
+ write_stderr(_("%s: could not start service \"%s\": error code %lu\n"), progname, register_servicename, GetLastError());
exit(1);
}
}
/* Open the current token to use as a base for the restricted one */
if (!OpenProcessToken(GetCurrentProcess(), TOKEN_ALL_ACCESS, &origToken))
{
- write_stderr(_("%s: could not open process token: %lu\n"), progname, GetLastError());
+ write_stderr(_("%s: could not open process token: error code %lu\n"), progname, GetLastError());
return 0;
}
SECURITY_BUILTIN_DOMAIN_RID, DOMAIN_ALIAS_RID_POWER_USERS, 0, 0, 0, 0, 0,
0, &dropSids[1].Sid))
{
- write_stderr(_("%s: could not allocate SIDs: %lu\n"), progname, GetLastError());
+ write_stderr(_("%s: could not allocate SIDs: error code %lu\n"), progname, GetLastError());
return 0;
}
if (!b)
{
- write_stderr(_("%s: could not create restricted token: %lu\n"), progname, GetLastError());
+ write_stderr(_("%s: could not create restricted token: error code %lu\n"), progname, GetLastError());
return 0;
}
if (!GetTokenInformation(hToken, tic, (LPVOID) ptdd, dwSize, &dwSize))
{
- log_error("could not get token information: %lu", GetLastError());
+ log_error("could not get token information: error code %lu", GetLastError());
goto cleanup;
}
}
else
{
- log_error("could not get token information buffer size: %lu", GetLastError());
+ log_error("could not get token information buffer size: error code %lu", GetLastError());
goto cleanup;
}
}
(DWORD) sizeof(ACL_SIZE_INFORMATION),
AclSizeInformation))
{
- log_error("could not get ACL information: %lu", GetLastError());
+ log_error("could not get ACL information: error code %lu", GetLastError());
goto cleanup;
}
*/
if (!GetTokenUser(hToken, &pTokenUser))
{
- log_error("could not get user token: %lu", GetLastError());
+ log_error("could not get user token: error code %lu", GetLastError());
goto cleanup;
}
if (!InitializeAcl(pacl, dwNewAclSize, ACL_REVISION))
{
- log_error("could not initialize ACL: %lu", GetLastError());
+ log_error("could not initialize ACL: error code %lu", GetLastError());
goto cleanup;
}
{
if (!GetAce(ptdd->DefaultDacl, i, (LPVOID *) &pace))
{
- log_error("could not get ACE: %lu", GetLastError());
+ log_error("could not get ACE: error code %lu", GetLastError());
goto cleanup;
}
if (!AddAce(pacl, ACL_REVISION, MAXDWORD, pace, ((PACE_HEADER) pace)->AceSize))
{
- log_error("could not add ACE: %lu", GetLastError());
+ log_error("could not add ACE: error code %lu", GetLastError());
goto cleanup;
}
}
/* Add the new ACE for the current user */
if (!AddAccessAllowedAceEx(pacl, ACL_REVISION, OBJECT_INHERIT_ACE, GENERIC_ALL, pTokenUser->User.Sid))
{
- log_error("could not add access allowed ACE: %lu", GetLastError());
+ log_error("could not add access allowed ACE: error code %lu", GetLastError());
goto cleanup;
}
if (!SetTokenInformation(hToken, tic, (LPVOID) &tddNew, dwNewAclSize))
{
- log_error("could not set token information: %lu", GetLastError());
+ log_error("could not set token information: error code %lu", GetLastError());
goto cleanup;
}
}
else
{
- log_error("could not get token information buffer size: %lu", GetLastError());
+ log_error("could not get token information buffer size: error code %lu", GetLastError());
return FALSE;
}
}
LocalFree(*ppTokenUser);
*ppTokenUser = NULL;
- log_error("could not get token information: %lu", GetLastError());
+ log_error("could not get token information: error code %lu", GetLastError());
return FALSE;
}
/* Open the current token to use as base for the restricted one */
if (!OpenProcessToken(GetCurrentProcess(), TOKEN_ALL_ACCESS, &origToken))
{
- fprintf(stderr, _("could not open process token: %lu\n"),
+ fprintf(stderr, _("could not open process token: error code %lu\n"),
GetLastError());
exit_nicely(2);
}
!AllocateAndInitializeSid(&NtAuthority, 2,
SECURITY_BUILTIN_DOMAIN_RID, DOMAIN_ALIAS_RID_POWER_USERS, 0, 0, 0, 0, 0, 0, &dropSids[1].Sid))
{
- fprintf(stderr, _("could not allocate SIDs: %lu\n"), GetLastError());
+ fprintf(stderr, _("could not allocate SIDs: error code %lu\n"), GetLastError());
exit_nicely(2);
}
if (!b)
{
- fprintf(stderr, _("could not create restricted token: %lu\n"),
+ fprintf(stderr, _("could not create restricted token: error code %lu\n"),
GetLastError());
exit_nicely(2);
}
&si,
&pi))
{
- fprintf(stderr, _("could not start process for \"%s\": %lu\n"),
+ fprintf(stderr, _("could not start process for \"%s\": error code %lu\n"),
cmdline2, GetLastError());
exit_nicely(2);
}
r = WaitForMultipleObjects(tests_left, active_pids, FALSE, INFINITE);
if (r < WAIT_OBJECT_0 || r >= WAIT_OBJECT_0 + tests_left)
{
- fprintf(stderr, _("failed to wait for subprocesses: %lu\n"),
+ fprintf(stderr, _("failed to wait for subprocesses: error code %lu\n"),
GetLastError());
exit_nicely(2);
}
progname, strerror(errno));
#else
if (TerminateProcess(postmaster_pid, 255) == 0)
- fprintf(stderr, _("\n%s: could not kill failed postmaster: %lu\n"),
+ fprintf(stderr, _("\n%s: could not kill failed postmaster: error code %lu\n"),
progname, GetLastError());
#endif
&rootKey) != ERROR_SUCCESS)
{
ereport(LOG,
- (errmsg("could not open registry key to identify system time zone: %d",
- (int) GetLastError()),
+ (errmsg("could not open registry key to identify system time zone: error code %lu",
+ GetLastError()),
errdetail("The PostgreSQL time zone will be set to \"%s\".",
"GMT"),
errhint("You can specify the correct timezone in postgresql.conf.")));