Location via proxy:   [ UP ]  
[Report a bug]   [Manage cookies]                
Skip to content

Commit b1ec7f4

Browse files
committed
Cleanup more code and comments related to Windows NT4 (XP days)
All the code and comments cleaned up here is irrelevant since 495ed0e. Note that this removes an assumption that CreateRestrictedToken() may not exist, something that could have happened when running under Windows NT as the code stated. Rather than assuming that it may not exist, this causes pg_ctl to fail hard if the function cannot be loaded. Reported-by: Justin Pryzby Discussion: https://postgr.es/m/20220826112637.GD2342@telsasoft.com
1 parent 7fed801 commit b1ec7f4

File tree

4 files changed

+7
-20
lines changed

4 files changed

+7
-20
lines changed

src/backend/port/win32/socket.c

+1-1
Original file line numberDiff line numberDiff line change
@@ -495,7 +495,7 @@ pgwin32_send(SOCKET s, const void *buf, int len, int flags)
495495
return -1;
496496
}
497497

498-
/* No error, zero bytes (win2000+) or error+WSAEWOULDBLOCK (<=nt4) */
498+
/* No error, zero bytes */
499499

500500
if (pgwin32_waitforsinglesocket(s, FD_WRITE | FD_CLOSE, INFINITE) == 0)
501501
return -1;

src/bin/pg_ctl/pg_ctl.c

+5-14
Original file line numberDiff line numberDiff line change
@@ -1726,9 +1726,7 @@ pgwin32_doRunAsService(void)
17261726

17271727
/*
17281728
* Mingw headers are incomplete, and so are the libraries. So we have to load
1729-
* a whole lot of API functions dynamically. Since we have to do this anyway,
1730-
* also load the couple of functions that *do* exist in mingw headers but not
1731-
* on NT4. That way, we don't break on NT4.
1729+
* a whole lot of API functions dynamically.
17321730
*/
17331731
typedef BOOL (WINAPI * __CreateRestrictedToken) (HANDLE, DWORD, DWORD, PSID_AND_ATTRIBUTES, DWORD, PLUID_AND_ATTRIBUTES, DWORD, PSID_AND_ATTRIBUTES, PHANDLE);
17341732
typedef BOOL (WINAPI * __IsProcessInJob) (HANDLE, HANDLE, PBOOL);
@@ -1768,9 +1766,6 @@ InheritStdHandles(STARTUPINFO *si)
17681766
*
17691767
* Returns 0 on success, non-zero on failure, same as CreateProcess().
17701768
*
1771-
* On NT4, or any other system not containing the required functions, will
1772-
* launch the process under the current token without doing any modifications.
1773-
*
17741769
* NOTE! Job object will only work when running as a service, because it's
17751770
* automatically destroyed when pg_ctl exits.
17761771
*/
@@ -1815,14 +1810,10 @@ CreateRestrictedProcess(char *cmd, PROCESS_INFORMATION *processInfo, bool as_ser
18151810

18161811
if (_CreateRestrictedToken == NULL)
18171812
{
1818-
/*
1819-
* NT4 doesn't have CreateRestrictedToken, so just call ordinary
1820-
* CreateProcess
1821-
*/
1822-
write_stderr(_("%s: WARNING: cannot create restricted tokens on this platform\n"), progname);
1823-
if (Advapi32Handle != NULL)
1824-
FreeLibrary(Advapi32Handle);
1825-
return CreateProcess(NULL, cmd, NULL, NULL, FALSE, 0, NULL, NULL, &si, processInfo);
1813+
/* Log error if we cannot get the function */
1814+
write_stderr(_("%s: could not locate object function to create restricted token: error code %lu\n"),
1815+
progname, (unsigned long) GetLastError());
1816+
return 0;
18261817
}
18271818

18281819
/* Open the current token to use as a base for the restricted one */

src/interfaces/libpq/win32.c

-4
Original file line numberDiff line numberDiff line change
@@ -271,10 +271,6 @@ struct MessageDLL
271271
* Returns a description of the socket error by first trying
272272
* to find it in the lookup table, and if that fails, tries
273273
* to load any of the winsock dlls to find that message.
274-
* The DLL thing works from Nt4 (spX ?) up, but some special
275-
* versions of winsock might have this as well (seen on Win98 SE
276-
* special install) / Magnus Naeslund (mag@fbab.net)
277-
*
278274
*/
279275

280276
const char *

src/port/dirmod.c

+1-1
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
* Portions Copyright (c) 1994, Regents of the University of California
88
*
99
* This includes replacement versions of functions that work on
10-
* Win32 (NT4 and newer).
10+
* Windows.
1111
*
1212
* IDENTIFICATION
1313
* src/port/dirmod.c

0 commit comments

Comments
 (0)