Cleanup more code and comments related to Windows NT4 (XP days)
authorMichael Paquier <[email protected]>
Tue, 30 Aug 2022 00:52:58 +0000 (09:52 +0900)
committerMichael Paquier <[email protected]>
Tue, 30 Aug 2022 00:52:58 +0000 (09:52 +0900)
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[email protected]

src/backend/port/win32/socket.c
src/bin/pg_ctl/pg_ctl.c
src/interfaces/libpq/win32.c
src/port/dirmod.c

index 52944a0d33264c6a588c941af75d5f2449f34ab9..130b60af2230a034fcb97fa1d90edb32542abc22 100644 (file)
@@ -495,7 +495,7 @@ pgwin32_send(SOCKET s, const void *buf, int len, int flags)
                        return -1;
                }
 
-               /* No error, zero bytes (win2000+) or error+WSAEWOULDBLOCK (<=nt4) */
+               /* No error, zero bytes */
 
                if (pgwin32_waitforsinglesocket(s, FD_WRITE | FD_CLOSE, INFINITE) == 0)
                        return -1;
index d7ff3902aa7301f95e5060039fa3f7ff578349a2..bea2470d866caaffaa90817137e1ba11d7ff726a 100644 (file)
@@ -1726,9 +1726,7 @@ pgwin32_doRunAsService(void)
 
 /*
  * Mingw headers are incomplete, and so are the libraries. So we have to load
- * a whole lot of API functions dynamically. Since we have to do this anyway,
- * also load the couple of functions that *do* exist in mingw headers but not
- * on NT4. That way, we don't break on NT4.
+ * a whole lot of API functions dynamically.
  */
 typedef BOOL (WINAPI * __CreateRestrictedToken) (HANDLE, DWORD, DWORD, PSID_AND_ATTRIBUTES, DWORD, PLUID_AND_ATTRIBUTES, DWORD, PSID_AND_ATTRIBUTES, PHANDLE);
 typedef BOOL (WINAPI * __IsProcessInJob) (HANDLE, HANDLE, PBOOL);
@@ -1768,9 +1766,6 @@ InheritStdHandles(STARTUPINFO *si)
  *
  * Returns 0 on success, non-zero on failure, same as CreateProcess().
  *
- * On NT4, or any other system not containing the required functions, will
- * launch the process under the current token without doing any modifications.
- *
  * NOTE! Job object will only work when running as a service, because it's
  * automatically destroyed when pg_ctl exits.
  */
@@ -1815,14 +1810,10 @@ CreateRestrictedProcess(char *cmd, PROCESS_INFORMATION *processInfo, bool as_ser
 
        if (_CreateRestrictedToken == NULL)
        {
-               /*
-                * NT4 doesn't have CreateRestrictedToken, so just call ordinary
-                * CreateProcess
-                */
-               write_stderr(_("%s: WARNING: cannot create restricted tokens on this platform\n"), progname);
-               if (Advapi32Handle != NULL)
-                       FreeLibrary(Advapi32Handle);
-               return CreateProcess(NULL, cmd, NULL, NULL, FALSE, 0, NULL, NULL, &si, processInfo);
+               /* Log error if we cannot get the function */
+               write_stderr(_("%s: could not locate object function to create restricted token: error code %lu\n"),
+                                        progname, (unsigned long) GetLastError());
+               return 0;
        }
 
        /* Open the current token to use as a base for the restricted one */
index e57b602476baafbc8993916bdcf8fcae95717b94..447f64c0726a05ede7ebbe2447b84a48fe498bf6 100644 (file)
@@ -271,10 +271,6 @@ struct MessageDLL
  * Returns a description of the socket error by first trying
  * to find it in the lookup table, and if that fails, tries
  * to load any of the winsock dlls to find that message.
- * The DLL thing works from Nt4 (spX ?) up, but some special
- * versions of winsock might have this as well (seen on Win98 SE
- * special install)                       / Magnus Naeslund ([email protected])
- *
  */
 
 const char *
index 2818bfd2e95fa0b050a57095a76c055dcc983995..ae6301dd6cc7b6544f95a47a522016ca6a40168f 100644 (file)
@@ -7,7 +7,7 @@
  * Portions Copyright (c) 1994, Regents of the University of California
  *
  *     This includes replacement versions of functions that work on
- *     Win32 (NT4 and newer).
+ *     Windows.
  *
  * IDENTIFICATION
  *       src/port/dirmod.c