Go to the source code of this file.
◆ get_restricted_token()
void get_restricted_token |
( |
void |
| ) |
|
Definition at line 154 of file restricted_token.c.
157 HANDLE restrictedToken;
164 if ((restrict_env = getenv(
"PG_RESTRICT_EXEC")) == NULL
165 || strcmp(restrict_env,
"1") != 0)
167 PROCESS_INFORMATION pi;
170 ZeroMemory(&pi,
sizeof(pi));
174 setenv(
"PG_RESTRICT_EXEC",
"1", 1);
176 if ((restrictedToken = CreateRestrictedProcess(cmdline, &pi)) == 0)
178 pg_log_error(
"could not re-execute with restricted token: error code %lu", GetLastError());
188 CloseHandle(restrictedToken);
189 CloseHandle(pi.hThread);
190 WaitForSingleObject(pi.hProcess, INFINITE);
192 if (!GetExitCodeProcess(pi.hProcess, &
x))
193 pg_fatal(
"could not get exit code from subprocess: error code %lu", GetLastError());
char * pg_strdup(const char *in)
#define pg_log_error(...)
References exit(), pg_fatal, pg_free(), pg_log_error, pg_strdup(), setenv, and x.
Referenced by main(), and regression_main().