PostgreSQL Source Code git master
Loading...
Searching...
No Matches
miscinit.c File Reference
#include "postgres.h"
#include <sys/param.h>
#include <signal.h>
#include <time.h>
#include <sys/file.h>
#include <sys/stat.h>
#include <fcntl.h>
#include <unistd.h>
#include <grp.h>
#include <pwd.h>
#include <netinet/in.h>
#include <arpa/inet.h>
#include <utime.h>
#include "access/htup_details.h"
#include "access/parallel.h"
#include "catalog/pg_authid.h"
#include "common/file_perm.h"
#include "libpq/libpq.h"
#include "libpq/pqsignal.h"
#include "mb/pg_wchar.h"
#include "miscadmin.h"
#include "pgstat.h"
#include "postmaster/autovacuum.h"
#include "postmaster/interrupt.h"
#include "postmaster/postmaster.h"
#include "replication/slotsync.h"
#include "storage/fd.h"
#include "storage/ipc.h"
#include "storage/latch.h"
#include "storage/pg_shmem.h"
#include "storage/pmsignal.h"
#include "storage/proc.h"
#include "storage/procarray.h"
#include "utils/builtins.h"
#include "utils/guc.h"
#include "utils/inval.h"
#include "utils/memutils.h"
#include "utils/pidfile.h"
#include "utils/syscache.h"
#include "utils/varlena.h"
#include "utils/wait_event.h"
#include "postmaster/proctypelist.h"
Include dependency graph for miscinit.c:

Go to the source code of this file.

Data Structures

struct  SerializedClientConnectionInfo
 

Macros

#define DIRECTORY_LOCK_FILE   "postmaster.pid"
 
#define PG_PROCTYPE(bktype, bkcategory, description, main_func, shmem_attach)    case bktype: backendDesc = description; break;
 

Typedefs

typedef struct SerializedClientConnectionInfo SerializedClientConnectionInfo
 

Functions

void InitPostmasterChild (void)
 
void InitStandaloneProcess (const char *argv0)
 
void SwitchToSharedLatch (void)
 
void InitProcessLocalLatch (void)
 
void SwitchBackToLocalLatch (void)
 
const charGetBackendTypeDesc (BackendType backendType)
 
void SetDatabasePath (const char *path)
 
void checkDataDir (void)
 
void SetDataDir (const char *dir)
 
void ChangeToDataDir (void)
 
Oid GetUserId (void)
 
Oid GetOuterUserId (void)
 
static void SetOuterUserId (Oid userid, bool is_superuser)
 
Oid GetSessionUserId (void)
 
bool GetSessionUserIsSuperuser (void)
 
static void SetSessionUserId (Oid userid, bool is_superuser)
 
const charGetSystemUser (void)
 
Oid GetAuthenticatedUserId (void)
 
void SetAuthenticatedUserId (Oid userid)
 
void GetUserIdAndSecContext (Oid *userid, int *sec_context)
 
void SetUserIdAndSecContext (Oid userid, int sec_context)
 
bool InLocalUserIdChange (void)
 
bool InSecurityRestrictedOperation (void)
 
bool InNoForceRLSOperation (void)
 
void GetUserIdAndContext (Oid *userid, bool *sec_def_context)
 
void SetUserIdAndContext (Oid userid, bool sec_def_context)
 
bool has_rolreplication (Oid roleid)
 
void InitializeSessionUserId (const char *rolename, Oid roleid, bool bypass_login_check)
 
void InitializeSessionUserIdStandalone (void)
 
void InitializeSystemUser (const char *authn_id, const char *auth_method)
 
Datum system_user (PG_FUNCTION_ARGS)
 
void SetSessionAuthorization (Oid userid, bool is_superuser)
 
Oid GetCurrentRoleId (void)
 
void SetCurrentRoleId (Oid roleid, bool is_superuser)
 
charGetUserNameFromId (Oid roleid, bool noerr)
 
Size EstimateClientConnectionInfoSpace (void)
 
void SerializeClientConnectionInfo (Size maxsize PG_USED_FOR_ASSERTS_ONLY, char *start_address)
 
void RestoreClientConnectionInfo (char *conninfo)
 
static void UnlinkLockFiles (int status, Datum arg)
 
static void CreateLockFile (const char *filename, bool amPostmaster, const char *socketDir, bool isDDLock, const char *refName)
 
void CreateDataDirLockFile (bool amPostmaster)
 
void CreateSocketLockFile (const char *socketfile, bool amPostmaster, const char *socketDir)
 
void TouchSocketLockFiles (void)
 
void AddToDataDirLockFile (int target_line, const char *str)
 
bool RecheckDataDirLockFile (void)
 
void ValidatePgVersion (const char *path)
 
static void load_libraries (const char *libraries, const char *gucname, bool restricted)
 
void process_shared_preload_libraries (void)
 
void process_session_preload_libraries (void)
 
void process_shmem_requests (void)
 
void pg_bindtextdomain (const char *domain)
 

Variables

ProcessingMode Mode = InitProcessing
 
BackendType MyBackendType
 
static Listlock_files = NIL
 
static Latch LocalLatchData
 
bool IgnoreSystemIndexes = false
 
static Oid AuthenticatedUserId = InvalidOid
 
static Oid SessionUserId = InvalidOid
 
static Oid OuterUserId = InvalidOid
 
static Oid CurrentUserId = InvalidOid
 
static const charSystemUser = NULL
 
static bool SessionUserIsSuperuser = false
 
static int SecurityRestrictionContext = 0
 
static bool SetRoleIsActive = false
 
ClientConnectionInfo MyClientConnectionInfo
 
charsession_preload_libraries_string = NULL
 
charshared_preload_libraries_string = NULL
 
charlocal_preload_libraries_string = NULL
 
bool process_shared_preload_libraries_in_progress = false
 
bool process_shared_preload_libraries_done = false
 
shmem_request_hook_type shmem_request_hook = NULL
 
bool process_shmem_requests_in_progress = false
 

Macro Definition Documentation

◆ DIRECTORY_LOCK_FILE

#define DIRECTORY_LOCK_FILE   "postmaster.pid"

Definition at line 61 of file miscinit.c.

◆ PG_PROCTYPE

#define PG_PROCTYPE (   bktype,
  bkcategory,
  description,
  main_func,
  shmem_attach 
)     case bktype: backendDesc = description; break;

Typedef Documentation

◆ SerializedClientConnectionInfo

Function Documentation

◆ AddToDataDirLockFile()

void AddToDataDirLockFile ( int  target_line,
const char str 
)

Definition at line 1520 of file miscinit.c.

1521{
1522 int fd;
1523 int len;
1524 int lineno;
1525 char *srcptr;
1526 char *destptr;
1527 char srcbuffer[BLCKSZ];
1528 char destbuffer[BLCKSZ];
1529
1531 if (fd < 0)
1532 {
1533 ereport(LOG,
1535 errmsg("could not open file \"%s\": %m",
1537 return;
1538 }
1540 len = read(fd, srcbuffer, sizeof(srcbuffer) - 1);
1542 if (len < 0)
1543 {
1544 ereport(LOG,
1546 errmsg("could not read from file \"%s\": %m",
1548 close(fd);
1549 return;
1550 }
1551 srcbuffer[len] = '\0';
1552
1553 /*
1554 * Advance over lines we are not supposed to rewrite, then copy them to
1555 * destbuffer.
1556 */
1557 srcptr = srcbuffer;
1558 for (lineno = 1; lineno < target_line; lineno++)
1559 {
1560 char *eol = strchr(srcptr, '\n');
1561
1562 if (eol == NULL)
1563 break; /* not enough lines in file yet */
1564 srcptr = eol + 1;
1565 }
1568
1569 /*
1570 * Fill in any missing lines before the target line, in case lines are
1571 * added to the file out of order.
1572 */
1573 for (; lineno < target_line; lineno++)
1574 {
1575 if (destptr < destbuffer + sizeof(destbuffer))
1576 *destptr++ = '\n';
1577 }
1578
1579 /*
1580 * Write or rewrite the target line.
1581 */
1582 snprintf(destptr, destbuffer + sizeof(destbuffer) - destptr, "%s\n", str);
1584
1585 /*
1586 * If there are more lines in the old file, append them to destbuffer.
1587 */
1588 if ((srcptr = strchr(srcptr, '\n')) != NULL)
1589 {
1590 srcptr++;
1591 snprintf(destptr, destbuffer + sizeof(destbuffer) - destptr, "%s",
1592 srcptr);
1593 }
1594
1595 /*
1596 * And rewrite the data. Since we write in a single kernel call, this
1597 * update should appear atomic to onlookers.
1598 */
1600 errno = 0;
1602 if (pg_pwrite(fd, destbuffer, len, 0) != len)
1603 {
1605 /* if write didn't set errno, assume problem is no disk space */
1606 if (errno == 0)
1607 errno = ENOSPC;
1608 ereport(LOG,
1610 errmsg("could not write to file \"%s\": %m",
1612 close(fd);
1613 return;
1614 }
1617 if (pg_fsync(fd) != 0)
1618 {
1619 ereport(LOG,
1621 errmsg("could not write to file \"%s\": %m",
1623 }
1625 if (close(fd) != 0)
1626 {
1627 ereport(LOG,
1629 errmsg("could not write to file \"%s\": %m",
1631 }
1632}
#define PG_BINARY
Definition c.h:1376
int errcode_for_file_access(void)
Definition elog.c:897
#define LOG
Definition elog.h:31
#define ereport(elevel,...)
Definition elog.h:150
int pg_fsync(int fd)
Definition fd.c:390
const char * str
#define close(a)
Definition win32.h:12
#define read(a, b, c)
Definition win32.h:13
#define DIRECTORY_LOCK_FILE
Definition miscinit.c:61
static char * errmsg
const void size_t len
#define pg_pwrite
Definition port.h:248
#define snprintf
Definition port.h:260
static int fd(const char *x, int i)
static int fb(int x)
static void pgstat_report_wait_start(uint32 wait_event_info)
Definition wait_event.h:69
static void pgstat_report_wait_end(void)
Definition wait_event.h:85

References close, DIRECTORY_LOCK_FILE, ereport, errcode_for_file_access(), errmsg, fb(), fd(), len, LOG, PG_BINARY, pg_fsync(), pg_pwrite, pgstat_report_wait_end(), pgstat_report_wait_start(), read, snprintf, and str.

Referenced by InternalIpcMemoryCreate(), PostmasterMain(), process_pm_child_exit(), process_pm_pmsignal(), and process_pm_shutdown_request().

◆ ChangeToDataDir()

void ChangeToDataDir ( void  )

Definition at line 410 of file miscinit.c.

411{
413
414 if (chdir(DataDir) < 0)
417 errmsg("could not change directory to \"%s\": %m",
418 DataDir)));
419}
#define Assert(condition)
Definition c.h:945
#define FATAL
Definition elog.h:41
char * DataDir
Definition globals.c:71

References Assert, DataDir, ereport, errcode_for_file_access(), errmsg, FATAL, and fb().

Referenced by BootstrapModeMain(), PostgresSingleUserMain(), and PostmasterMain().

◆ checkDataDir()

void checkDataDir ( void  )

Definition at line 297 of file miscinit.c.

298{
299 struct stat stat_buf;
300
302
303 if (stat(DataDir, &stat_buf) != 0)
304 {
305 if (errno == ENOENT)
308 errmsg("data directory \"%s\" does not exist",
309 DataDir)));
310 else
313 errmsg("could not read permissions of directory \"%s\": %m",
314 DataDir)));
315 }
316
317 /* eventual chdir would fail anyway, but let's test ... */
318 if (!S_ISDIR(stat_buf.st_mode))
321 errmsg("specified data directory \"%s\" is not a directory",
322 DataDir)));
323
324 /*
325 * Check that the directory belongs to my userid; if not, reject.
326 *
327 * This check is an essential part of the interlock that prevents two
328 * postmasters from starting in the same directory (see CreateLockFile()).
329 * Do not remove or weaken it.
330 *
331 * XXX can we safely enable this check on Windows?
332 */
333#if !defined(WIN32) && !defined(__CYGWIN__)
334 if (stat_buf.st_uid != geteuid())
337 errmsg("data directory \"%s\" has wrong ownership",
338 DataDir),
339 errhint("The server must be started by the user that owns the data directory.")));
340#endif
341
342 /*
343 * Check if the directory has correct permissions. If not, reject.
344 *
345 * Only two possible modes are allowed, 0700 and 0750. The latter mode
346 * indicates that group read/execute should be allowed on all newly
347 * created files and directories.
348 *
349 * XXX temporarily suppress check when on Windows, because there may not
350 * be proper support for Unix-y file permissions. Need to think of a
351 * reasonable check to apply on Windows.
352 */
353#if !defined(WIN32) && !defined(__CYGWIN__)
354 if (stat_buf.st_mode & PG_MODE_MASK_GROUP)
357 errmsg("data directory \"%s\" has invalid permissions",
358 DataDir),
359 errdetail("Permissions should be u=rwx (0700) or u=rwx,g=rx (0750).")));
360#endif
361
362 /*
363 * Reset creation modes and mask based on the mode of the data directory.
364 *
365 * The mask was set earlier in startup to disallow group permissions on
366 * newly created files and directories. However, if group read/execute
367 * are present on the data directory then modify the create modes and mask
368 * to allow group read/execute on newly created files and directories and
369 * set the data_directory_mode GUC.
370 *
371 * Suppress when on Windows, because there may not be proper support for
372 * Unix-y file permissions.
373 */
374#if !defined(WIN32) && !defined(__CYGWIN__)
376
379#endif
380
381 /* Check for PG_VERSION */
383}
int errcode(int sqlerrcode)
Definition elog.c:874
int errhint(const char *fmt,...) pg_attribute_printf(1
int errdetail(const char *fmt,...) pg_attribute_printf(1
void SetDataDirectoryCreatePerm(int dataDirMode)
Definition file_perm.c:34
int pg_mode_mask
Definition file_perm.c:25
int pg_dir_create_mode
Definition file_perm.c:18
#define PG_MODE_MASK_GROUP
Definition file_perm.h:29
int data_directory_mode
Definition globals.c:77
void ValidatePgVersion(const char *path)
Definition miscinit.c:1719
#define stat
Definition win32_port.h:74
#define S_ISDIR(m)
Definition win32_port.h:315

References Assert, data_directory_mode, DataDir, ereport, errcode(), errcode_for_file_access(), errdetail(), errhint(), errmsg, FATAL, fb(), pg_dir_create_mode, pg_mode_mask, PG_MODE_MASK_GROUP, S_ISDIR, SetDataDirectoryCreatePerm(), stat, and ValidatePgVersion().

Referenced by BootstrapModeMain(), PostgresSingleUserMain(), and PostmasterMain().

◆ CreateDataDirLockFile()

void CreateDataDirLockFile ( bool  amPostmaster)

Definition at line 1464 of file miscinit.c.

1465{
1467}
static void CreateLockFile(const char *filename, bool amPostmaster, const char *socketDir, bool isDDLock, const char *refName)
Definition miscinit.c:1159

References CreateLockFile(), DataDir, DIRECTORY_LOCK_FILE, and fb().

Referenced by BootstrapModeMain(), PostgresSingleUserMain(), and PostmasterMain().

◆ CreateLockFile()

static void CreateLockFile ( const char filename,
bool  amPostmaster,
const char socketDir,
bool  isDDLock,
const char refName 
)
static

Definition at line 1159 of file miscinit.c.

1162{
1163 int fd;
1164 char buffer[MAXPGPATH * 2 + 256];
1165 int ntries;
1166 int len;
1167 int encoded_pid;
1169 pid_t my_pid,
1170 my_p_pid,
1171 my_gp_pid;
1172 const char *envvar;
1173
1174 /*
1175 * If the PID in the lockfile is our own PID or our parent's or
1176 * grandparent's PID, then the file must be stale (probably left over from
1177 * a previous system boot cycle). We need to check this because of the
1178 * likelihood that a reboot will assign exactly the same PID as we had in
1179 * the previous reboot, or one that's only one or two counts larger and
1180 * hence the lockfile's PID now refers to an ancestor shell process. We
1181 * allow pg_ctl to pass down its parent shell PID (our grandparent PID)
1182 * via the environment variable PG_GRANDPARENT_PID; this is so that
1183 * launching the postmaster via pg_ctl can be just as reliable as
1184 * launching it directly. There is no provision for detecting
1185 * further-removed ancestor processes, but if the init script is written
1186 * carefully then all but the immediate parent shell will be root-owned
1187 * processes and so the kill test will fail with EPERM. Note that we
1188 * cannot get a false negative this way, because an existing postmaster
1189 * would surely never launch a competing postmaster or pg_ctl process
1190 * directly.
1191 */
1192 my_pid = getpid();
1193
1194#ifndef WIN32
1195 my_p_pid = getppid();
1196#else
1197
1198 /*
1199 * Windows hasn't got getppid(), but doesn't need it since it's not using
1200 * real kill() either...
1201 */
1202 my_p_pid = 0;
1203#endif
1204
1205 envvar = getenv("PG_GRANDPARENT_PID");
1206 if (envvar)
1207 my_gp_pid = atoi(envvar);
1208 else
1209 my_gp_pid = 0;
1210
1211 /*
1212 * We need a loop here because of race conditions. But don't loop forever
1213 * (for example, a non-writable $PGDATA directory might cause a failure
1214 * that won't go away). 100 tries seems like plenty.
1215 */
1216 for (ntries = 0;; ntries++)
1217 {
1218 /*
1219 * Try to create the lock file --- O_EXCL makes this atomic.
1220 *
1221 * Think not to make the file protection weaker than 0600/0640. See
1222 * comments below.
1223 */
1225 if (fd >= 0)
1226 break; /* Success; exit the retry loop */
1227
1228 /*
1229 * Couldn't create the pid file. Probably it already exists.
1230 */
1231 if ((errno != EEXIST && errno != EACCES) || ntries > 100)
1232 ereport(FATAL,
1234 errmsg("could not create lock file \"%s\": %m",
1235 filename)));
1236
1237 /*
1238 * Read the file to get the old owner's PID. Note race condition
1239 * here: file might have been deleted since we tried to create it.
1240 */
1242 if (fd < 0)
1243 {
1244 if (errno == ENOENT)
1245 continue; /* race condition; try again */
1246 ereport(FATAL,
1248 errmsg("could not open lock file \"%s\": %m",
1249 filename)));
1250 }
1252 if ((len = read(fd, buffer, sizeof(buffer) - 1)) < 0)
1253 ereport(FATAL,
1255 errmsg("could not read lock file \"%s\": %m",
1256 filename)));
1258 close(fd);
1259
1260 if (len == 0)
1261 {
1262 ereport(FATAL,
1264 errmsg("lock file \"%s\" is empty", filename),
1265 errhint("Either another server is starting, or the lock file is the remnant of a previous server startup crash.")));
1266 }
1267
1268 buffer[len] = '\0';
1269 encoded_pid = atoi(buffer);
1270
1271 /* if pid < 0, the pid is for postgres, not postmaster */
1273
1274 if (other_pid <= 0)
1275 elog(FATAL, "bogus data in lock file \"%s\": \"%s\"",
1276 filename, buffer);
1277
1278 /*
1279 * Check to see if the other process still exists
1280 *
1281 * Per discussion above, my_pid, my_p_pid, and my_gp_pid can be
1282 * ignored as false matches.
1283 *
1284 * Normally kill() will fail with ESRCH if the given PID doesn't
1285 * exist.
1286 *
1287 * We can treat the EPERM-error case as okay because that error
1288 * implies that the existing process has a different userid than we
1289 * do, which means it cannot be a competing postmaster. A postmaster
1290 * cannot successfully attach to a data directory owned by a userid
1291 * other than its own, as enforced in checkDataDir(). Also, since we
1292 * create the lockfiles mode 0600/0640, we'd have failed above if the
1293 * lockfile belonged to another userid --- which means that whatever
1294 * process kill() is reporting about isn't the one that made the
1295 * lockfile. (NOTE: this last consideration is the only one that
1296 * keeps us from blowing away a Unix socket file belonging to an
1297 * instance of Postgres being run by someone else, at least on
1298 * machines where /tmp hasn't got a stickybit.)
1299 */
1300 if (other_pid != my_pid && other_pid != my_p_pid &&
1302 {
1303 if (kill(other_pid, 0) == 0 ||
1304 (errno != ESRCH && errno != EPERM))
1305 {
1306 /* lockfile belongs to a live process */
1307 ereport(FATAL,
1309 errmsg("lock file \"%s\" already exists",
1310 filename),
1311 isDDLock ?
1312 (encoded_pid < 0 ?
1313 errhint("Is another postgres (PID %d) running in data directory \"%s\"?",
1314 (int) other_pid, refName) :
1315 errhint("Is another postmaster (PID %d) running in data directory \"%s\"?",
1316 (int) other_pid, refName)) :
1317 (encoded_pid < 0 ?
1318 errhint("Is another postgres (PID %d) using socket file \"%s\"?",
1319 (int) other_pid, refName) :
1320 errhint("Is another postmaster (PID %d) using socket file \"%s\"?",
1321 (int) other_pid, refName))));
1322 }
1323 }
1324
1325 /*
1326 * No, the creating process did not exist. However, it could be that
1327 * the postmaster crashed (or more likely was kill -9'd by a clueless
1328 * admin) but has left orphan backends behind. Check for this by
1329 * looking to see if there is an associated shmem segment that is
1330 * still in use.
1331 *
1332 * Note: because postmaster.pid is written in multiple steps, we might
1333 * not find the shmem ID values in it; we can't treat that as an
1334 * error.
1335 */
1336 if (isDDLock)
1337 {
1338 char *ptr = buffer;
1339 unsigned long id1,
1340 id2;
1341 int lineno;
1342
1343 for (lineno = 1; lineno < LOCK_FILE_LINE_SHMEM_KEY; lineno++)
1344 {
1345 if ((ptr = strchr(ptr, '\n')) == NULL)
1346 break;
1347 ptr++;
1348 }
1349
1350 if (ptr != NULL &&
1351 sscanf(ptr, "%lu %lu", &id1, &id2) == 2)
1352 {
1354 ereport(FATAL,
1356 errmsg("pre-existing shared memory block (key %lu, ID %lu) is still in use",
1357 id1, id2),
1358 errhint("Terminate any old server processes associated with data directory \"%s\".",
1359 refName)));
1360 }
1361 }
1362
1363 /*
1364 * Looks like nobody's home. Unlink the file and try again to create
1365 * it. Need a loop because of possible race condition against other
1366 * would-be creators.
1367 */
1368 if (unlink(filename) < 0)
1369 ereport(FATAL,
1371 errmsg("could not remove old lock file \"%s\": %m",
1372 filename),
1373 errhint("The file seems accidentally left over, but "
1374 "it could not be removed. Please remove the file "
1375 "by hand and try again.")));
1376 }
1377
1378 /*
1379 * Successfully created the file, now fill it. See comment in pidfile.h
1380 * about the contents. Note that we write the same first five lines into
1381 * both datadir and socket lockfiles; although more stuff may get added to
1382 * the datadir lockfile later.
1383 */
1384 snprintf(buffer, sizeof(buffer), "%d\n%s\n" INT64_FORMAT "\n%d\n%s\n",
1385 amPostmaster ? (int) my_pid : -((int) my_pid),
1386 DataDir,
1389 socketDir);
1390
1391 /*
1392 * In a standalone backend, the next line (LOCK_FILE_LINE_LISTEN_ADDR)
1393 * will never receive data, so fill it in as empty now.
1394 */
1395 if (isDDLock && !amPostmaster)
1396 strlcat(buffer, "\n", sizeof(buffer));
1397
1398 errno = 0;
1400 if (write(fd, buffer, strlen(buffer)) != strlen(buffer))
1401 {
1402 int save_errno = errno;
1403
1404 close(fd);
1406 /* if write didn't set errno, assume problem is no disk space */
1408 ereport(FATAL,
1410 errmsg("could not write lock file \"%s\": %m", filename)));
1411 }
1413
1415 if (pg_fsync(fd) != 0)
1416 {
1417 int save_errno = errno;
1418
1419 close(fd);
1421 errno = save_errno;
1422 ereport(FATAL,
1424 errmsg("could not write lock file \"%s\": %m", filename)));
1425 }
1427 if (close(fd) != 0)
1428 {
1429 int save_errno = errno;
1430
1432 errno = save_errno;
1433 ereport(FATAL,
1435 errmsg("could not write lock file \"%s\": %m", filename)));
1436 }
1437
1438 /*
1439 * Arrange to unlink the lock file(s) at proc_exit. If this is the first
1440 * one, set up the on_proc_exit function to do it; then add this lock file
1441 * to the list of files to unlink.
1442 */
1443 if (lock_files == NIL)
1445
1446 /*
1447 * Use lcons so that the lock files are unlinked in reverse order of
1448 * creation; this is critical!
1449 */
1451}
#define INT64_FORMAT
Definition c.h:636
#define elog(elevel,...)
Definition elog.h:226
int pg_file_create_mode
Definition file_perm.c:19
pg_time_t MyStartTime
Definition globals.c:48
#define write(a, b, c)
Definition win32.h:14
void on_proc_exit(pg_on_exit_callback function, Datum arg)
Definition ipc.c:316
List * lcons(void *datum, List *list)
Definition list.c:495
char * pstrdup(const char *in)
Definition mcxt.c:1781
static List * lock_files
Definition miscinit.c:68
static void UnlinkLockFiles(int status, Datum arg)
Definition miscinit.c:1125
#define MAXPGPATH
static char * filename
Definition pg_dumpall.c:133
#define NIL
Definition pg_list.h:68
#define LOCK_FILE_LINE_SHMEM_KEY
Definition pidfile.h:43
size_t strlcat(char *dst, const char *src, size_t siz)
Definition strlcat.c:33
int PostPortNumber
Definition postmaster.c:203
bool PGSharedMemoryIsInUse(unsigned long id1, unsigned long id2)
Definition sysv_shmem.c:318
#define kill(pid, sig)
Definition win32_port.h:490

References close, DataDir, elog, ereport, errcode(), errcode_for_file_access(), errhint(), errmsg, FATAL, fb(), fd(), filename, INT64_FORMAT, kill, lcons(), len, LOCK_FILE_LINE_SHMEM_KEY, lock_files, MAXPGPATH, MyStartTime, NIL, on_proc_exit(), pg_file_create_mode, pg_fsync(), PGSharedMemoryIsInUse(), pgstat_report_wait_end(), pgstat_report_wait_start(), PostPortNumber, pstrdup(), read, snprintf, strlcat(), UnlinkLockFiles(), and write.

Referenced by CreateDataDirLockFile(), and CreateSocketLockFile().

◆ CreateSocketLockFile()

void CreateSocketLockFile ( const char socketfile,
bool  amPostmaster,
const char socketDir 
)

Definition at line 1473 of file miscinit.c.

1475{
1476 char lockfile[MAXPGPATH];
1477
1478 snprintf(lockfile, sizeof(lockfile), "%s.lock", socketfile);
1480}

References CreateLockFile(), fb(), MAXPGPATH, and snprintf.

Referenced by Lock_AF_UNIX().

◆ EstimateClientConnectionInfoSpace()

Size EstimateClientConnectionInfoSpace ( void  )

Definition at line 1036 of file miscinit.c.

1037{
1038 Size size = 0;
1039
1040 size = add_size(size, sizeof(SerializedClientConnectionInfo));
1041
1044
1045 return size;
1046}
size_t Size
Definition c.h:691
ClientConnectionInfo MyClientConnectionInfo
Definition miscinit.c:1019
Size add_size(Size s1, Size s2)
Definition shmem.c:485
const char * authn_id
Definition libpq-be.h:99

References add_size(), ClientConnectionInfo::authn_id, fb(), and MyClientConnectionInfo.

Referenced by InitializeParallelDSM().

◆ GetAuthenticatedUserId()

Oid GetAuthenticatedUserId ( void  )

Definition at line 546 of file miscinit.c.

547{
549 return AuthenticatedUserId;
550}
#define OidIsValid(objectId)
Definition c.h:860
static Oid AuthenticatedUserId
Definition miscinit.c:450

References Assert, AuthenticatedUserId, and OidIsValid.

Referenced by check_session_authorization(), and InitializeParallelDSM().

◆ GetBackendTypeDesc()

const char * GetBackendTypeDesc ( BackendType  backendType)

Definition at line 264 of file miscinit.c.

265{
266 const char *backendDesc = gettext_noop("unknown process type");
267
268 switch (backendType)
269 {
270#define PG_PROCTYPE(bktype, bkcategory, description, main_func, shmem_attach) \
271 case bktype: backendDesc = description; break;
273#undef PG_PROCTYPE
274 }
275 return backendDesc;
276}
#define gettext_noop(x)
Definition c.h:1287

References fb(), and gettext_noop.

Referenced by BackendInitialize(), BackendStartup(), CleanupBackend(), CountChildren(), get_backend_type_for_log(), init_ps_display(), pg_stat_get_activity(), pg_stat_io_build_tuples(), and signal_child().

◆ GetCurrentRoleId()

Oid GetCurrentRoleId ( void  )

Definition at line 936 of file miscinit.c.

937{
938 if (SetRoleIsActive)
939 return OuterUserId;
940 else
941 return InvalidOid;
942}
static Oid OuterUserId
Definition miscinit.c:452
static bool SetRoleIsActive
Definition miscinit.c:462
#define InvalidOid

References InvalidOid, OuterUserId, and SetRoleIsActive.

Referenced by check_role(), InitializeParallelDSM(), and show_role().

◆ GetOuterUserId()

Oid GetOuterUserId ( void  )

Definition at line 481 of file miscinit.c.

482{
484 return OuterUserId;
485}

References Assert, OidIsValid, and OuterUserId.

Referenced by DropRole(), and RenameRole().

◆ GetSessionUserId()

◆ GetSessionUserIsSuperuser()

bool GetSessionUserIsSuperuser ( void  )

Definition at line 516 of file miscinit.c.

517{
520}
static bool SessionUserIsSuperuser
Definition miscinit.c:457

References Assert, OidIsValid, SessionUserId, and SessionUserIsSuperuser.

Referenced by check_session_authorization(), and InitializeParallelDSM().

◆ GetSystemUser()

const char * GetSystemUser ( void  )

Definition at line 536 of file miscinit.c.

537{
538 return SystemUser;
539}
static const char * SystemUser
Definition miscinit.c:454

References SystemUser.

Referenced by system_user().

◆ GetUserId()

Oid GetUserId ( void  )

Definition at line 470 of file miscinit.c.

471{
473 return CurrentUserId;
474}
static Oid CurrentUserId
Definition miscinit.c:453

References Assert, CurrentUserId, and OidIsValid.

Referenced by AfterTriggerSaveEvent(), AggregateCreate(), all_rows_selectable(), AlterCollation(), AlterDatabase(), AlterDatabaseOwner(), AlterDatabaseRefreshColl(), AlterDatabaseSet(), AlterEventTrigger(), AlterEventTriggerOwner_internal(), AlterExtensionNamespace(), AlterForeignServer(), AlterForeignServerOwner_internal(), AlterFunction(), AlterObjectNamespace_internal(), AlterObjectOwner_internal(), AlterObjectRename_internal(), AlterOperator(), AlterOpFamilyAdd(), AlterPublication(), AlterPublicationOwner_internal(), AlterRole(), AlterRoleSet(), AlterSchemaOwner_internal(), AlterStatistics(), AlterSubscription(), AlterSubscriptionOwner_internal(), AlterSystemSetConfigFile(), AlterTableMoveAll(), AlterTableSpaceOptions(), AlterTSConfiguration(), AlterTSDictionary(), AlterType(), AlterTypeNamespace_oid(), AlterTypeOwner(), ATExecChangeOwner(), ATPrepAlterColumnType(), ATPrepSetTableSpace(), ATSimplePermissions(), bbsink_server_new(), be_lo_unlink(), binary_upgrade_check_logical_slot_pending_wal(), binary_upgrade_create_empty_extension(), brin_desummarize_range(), BuildCachedPlan(), BuildDescForRelation(), BuildIndexValueDescription(), calculate_database_size(), calculate_tablespace_size(), call_pltcl_start_proc(), check_enable_rls(), check_search_path(), check_temp_tablespaces(), CheckCachedPlan(), checkDomainOwner(), checkEnumOwner(), checkFkeyPermissions(), CheckFunctionValidatorAccess(), CheckMyDatabase(), CheckSlotPermissions(), CommentObject(), compile_plperl_function(), compile_pltcl_function(), CompleteCachedPlan(), compute_return_type(), ConfigOptionIsVisible(), convert_and_check_filename(), copy_sequence(), CreateCast(), CreateConversionCommand(), createdb(), CreateEventTrigger(), CreateExtensionInternal(), CreateForeignDataWrapper(), CreateForeignServer(), CreateForeignTable(), CreateFunction(), CreateOpFamily(), CreateProceduralLanguage(), CreatePublication(), CreateRole(), CreateStatistics(), CreateSubscription(), CreateTableSpace(), CreateTransform(), CreateTriggerFiringOn(), current_user(), currtid_internal(), currval_oid(), DefineAggregate(), DefineCollation(), DefineDomain(), DefineEnum(), DefineIndex(), DefineOpClass(), DefineOperator(), DefineOpFamily(), DefineQueryRewrite(), DefineRange(), DefineRelation(), DefineTSConfiguration(), DefineTSDictionary(), DefineType(), DoCopy(), dropdb(), DropOwnedObjects(), DropRole(), DropSubscription(), DropTableSpace(), emit_audit_message(), EnableDisableRule(), ExecAlterDefaultPrivilegesStmt(), ExecAlterExtensionContentsStmt(), ExecAlterExtensionStmt(), ExecAlterObjectDependsStmt(), ExecBuildGroupingEqual(), ExecBuildParamSetEqual(), ExecBuildSlotPartitionKeyDescription(), ExecBuildSlotValueDescription(), ExecCheckOneRelPerms(), ExecCheckpoint(), ExecGetResultRelCheckAsUser(), ExecInitAgg(), ExecInitExprRec(), ExecInitFunc(), ExecInitWindowAgg(), ExecReindex(), ExecSecLabelStmt(), execute_extension_script(), ExecuteCallStmt(), ExecuteDoStmt(), ExecuteTruncateGuts(), extension_is_trusted(), file_fdw_validator(), findRangeCanonicalFunction(), findRangeSubtypeDiffFunction(), FinishPreparedTransaction(), fmgr_security_definer(), get_connect_string(), get_other_operator(), get_rolespec_oid(), get_rolespec_tuple(), get_row_security_policies(), get_tables_to_repack(), get_tables_to_repack_partitioned(), GetConfigOptionValues(), gin_clean_pending_list(), GrantRole(), HandleFunctionRequest(), has_any_column_privilege_id(), has_any_column_privilege_name(), has_column_privilege_id_attnum(), has_column_privilege_id_name(), has_column_privilege_name_attnum(), has_column_privilege_name_name(), has_database_privilege_id(), has_database_privilege_name(), has_foreign_data_wrapper_privilege_id(), has_foreign_data_wrapper_privilege_name(), has_function_privilege_id(), has_function_privilege_name(), has_language_privilege_id(), has_language_privilege_name(), has_largeobject_privilege_id(), has_parameter_privilege_name(), has_schema_privilege_id(), has_schema_privilege_name(), has_sequence_privilege_id(), has_sequence_privilege_name(), has_server_privilege_id(), has_server_privilege_name(), has_table_privilege_id(), has_table_privilege_name(), has_tablespace_privilege_id(), has_tablespace_privilege_name(), has_type_privilege_id(), has_type_privilege_name(), have_createdb_privilege(), have_createrole_privilege(), heap_force_common(), ImportForeignSchema(), init_sexpr(), InitializeSearchPath(), InitPostgres(), InitTempTableNamespace(), inline_function(), inline_function_in_from(), insert_username(), interpret_function_parameter_list(), inv_create(), inv_open(), LargeObjectCreate(), lastval(), LockViewRecurse(), LogicalRepSyncTableStart(), lookup_agg_function(), LookupCreationNamespace(), LookupExplicitNamespace(), MergeAttributes(), movedb(), nextval_internal(), OperatorCreate(), OperatorShellMake(), pg_get_multixact_stats(), pg_get_sequence_data(), pg_has_role_id(), pg_has_role_name(), pg_import_system_collations(), pg_prewarm(), pg_sequence_last_value(), pg_sequence_parameters(), pg_signal_backend(), pg_stat_get_recovery(), pg_stat_get_wal_receiver(), pg_stat_get_wal_senders(), pg_stat_statements_internal(), pgrowlocks(), pgss_store(), pgstat_get_backend_current_activity(), pltcl_fetch_interp(), postgresBeginDirectModify(), postgresBeginForeignScan(), postgresExecForeignTruncate(), postgresGetForeignRelSize(), postgresImportForeignSchema(), PrepareTempTablespaces(), PrepareTransaction(), PublicationAddTables(), RangeVarCallbackForAlterRelation(), RangeVarCallbackForDblink(), RangeVarCallbackForDropRelation(), RangeVarCallbackForLockTable(), RangeVarCallbackForPolicy(), RangeVarCallbackForReindexIndex(), RangeVarCallbackForRenameRule(), RangeVarCallbackForRenameTrigger(), RangeVarCallbackForStats(), RangeVarCallbackMaintainsTable(), RangeVarCallbackOwnsRelation(), RangeVarGetAndCheckCreationNamespace(), ReassignOwnedObjects(), recomputeNamespacePath(), REGRESS_exec_check_perms(), REGRESS_object_access_hook(), REGRESS_object_access_hook_str(), REGRESS_utility_command(), ReindexMultipleInternal(), ReindexMultipleTables(), RemoveObjects(), renameatt_check(), RenameDatabase(), RenameRole(), RenameSchema(), RenameTableSpace(), RenameType(), RevalidateCachedQuery(), RI_Initial_Check(), ri_ReportViolation(), select_best_grantor(), select_perl_context(), set_config_option(), set_foreign_rel_properties(), SetSequence(), shell_check_detail(), superuser(), TargetPrivilegesCheck(), TerminateOtherDBBackends(), transformTableLikeClause(), truncate_check_perms(), user_mapping_ddl_aclcheck(), vacuum_is_permitted_for_relation(), validate_option_array_item(), ValidateJoinEstimator(), ValidateOperatorReference(), and ValidateRestrictionEstimator().

◆ GetUserIdAndContext()

void GetUserIdAndContext ( Oid userid,
bool sec_def_context 
)

Definition at line 662 of file miscinit.c.

663{
664 *userid = CurrentUserId;
666}
bool InLocalUserIdChange(void)
Definition miscinit.c:631

References CurrentUserId, fb(), and InLocalUserIdChange().

◆ GetUserIdAndSecContext()

◆ GetUserNameFromId()

char * GetUserNameFromId ( Oid  roleid,
bool  noerr 
)

Definition at line 989 of file miscinit.c.

990{
991 HeapTuple tuple;
992 char *result;
993
994 tuple = SearchSysCache1(AUTHOID, ObjectIdGetDatum(roleid));
995 if (!HeapTupleIsValid(tuple))
996 {
997 if (!noerr)
1000 errmsg("invalid role OID: %u", roleid)));
1001 result = NULL;
1002 }
1003 else
1004 {
1005 result = pstrdup(NameStr(((Form_pg_authid) GETSTRUCT(tuple))->rolname));
1006 ReleaseSysCache(tuple);
1007 }
1008 return result;
1009}
#define NameStr(name)
Definition c.h:837
#define ERROR
Definition elog.h:39
#define HeapTupleIsValid(tuple)
Definition htup.h:78
static void * GETSTRUCT(const HeapTupleData *tuple)
NameData rolname
Definition pg_authid.h:36
END_CATALOG_STRUCT typedef FormData_pg_authid * Form_pg_authid
Definition pg_authid.h:60
static Datum ObjectIdGetDatum(Oid X)
Definition postgres.h:252
void ReleaseSysCache(HeapTuple tuple)
Definition syscache.c:264
HeapTuple SearchSysCache1(SysCacheIdentifier cacheId, Datum key1)
Definition syscache.c:220

References ereport, errcode(), errmsg, ERROR, fb(), Form_pg_authid, GETSTRUCT(), HeapTupleIsValid, NameStr, ObjectIdGetDatum(), pstrdup(), ReleaseSysCache(), rolname, and SearchSysCache1().

Referenced by AddRoleMems(), AlterSubscription(), AlterSubscriptionOwner_internal(), check_can_set_role(), check_object_ownership(), check_role_grantor(), check_role_membership_authorization(), current_user(), DelRoleMems(), DropOwnedObjects(), DropSubscription(), execute_extension_script(), getObjectDescription(), getObjectIdentityParts(), GetSubscription(), insert_username(), LogicalRepSyncTableStart(), ReassignOwnedObjects(), regroleout(), select_best_grantor(), session_user(), SwitchToUntrustedUser(), and TargetPrivilegesCheck().

◆ has_rolreplication()

bool has_rolreplication ( Oid  roleid)

Definition at line 689 of file miscinit.c.

690{
691 bool result = false;
693
694 /* Superusers bypass all permission checking. */
695 if (superuser_arg(roleid))
696 return true;
697
700 {
703 }
704 return result;
705}
bool rolreplication
Definition pg_authid.h:42
bool superuser_arg(Oid roleid)
Definition superuser.c:57

References fb(), Form_pg_authid, GETSTRUCT(), HeapTupleIsValid, ObjectIdGetDatum(), ReleaseSysCache(), rolreplication, SearchSysCache1(), and superuser_arg().

Referenced by AlterRole(), binary_upgrade_check_logical_slot_pending_wal(), CheckSlotPermissions(), CreateRole(), and InitPostgres().

◆ InitializeSessionUserId()

void InitializeSessionUserId ( const char rolename,
Oid  roleid,
bool  bypass_login_check 
)

Definition at line 711 of file miscinit.c.

713{
716 char *rname;
717 bool is_superuser;
718
719 /*
720 * In a parallel worker, we don't have to do anything here.
721 * ParallelWorkerMain already set our output variables, and we aren't
722 * going to enforce either rolcanlogin or rolconnlimit. Furthermore, we
723 * don't really want to perform a catalog lookup for the role: we don't
724 * want to fail if it's been dropped.
725 */
727 {
729 return;
730 }
731
732 /*
733 * Don't do scans if we're bootstrapping, none of the system catalogs
734 * exist yet, and they should be owned by postgres anyway.
735 */
737
738 /*
739 * Make sure syscache entries are flushed for recent catalog changes. This
740 * allows us to find roles that were created on-the-fly during
741 * authentication.
742 */
744
745 /*
746 * Look up the role, either by name if that's given or by OID if not.
747 */
748 if (rolename != NULL)
749 {
754 errmsg("role \"%s\" does not exist", rolename)));
755 }
756 else
757 {
762 errmsg("role with OID %u does not exist", roleid)));
763 }
764
766 roleid = rform->oid;
767 rname = NameStr(rform->rolname);
768 is_superuser = rform->rolsuper;
769
771
772 /*
773 * Set SessionUserId and related variables, including "role", via the GUC
774 * mechanisms.
775 *
776 * Note: ideally we would use PGC_S_DYNAMIC_DEFAULT here, so that
777 * session_authorization could subsequently be changed from
778 * pg_db_role_setting entries. Instead, session_authorization in
779 * pg_db_role_setting has no effect. Changing that would require solving
780 * two problems:
781 *
782 * 1. If pg_db_role_setting has values for both session_authorization and
783 * role, we could not be sure which order those would be applied in, and
784 * it would matter.
785 *
786 * 2. Sites may have years-old session_authorization entries. There's not
787 * been any particular reason to remove them. Ending the dormancy of
788 * those entries could seriously change application behavior, so only a
789 * major release should do that.
790 */
791 SetConfigOption("session_authorization", rname,
793
794 /*
795 * These next checks are not enforced when in standalone mode, so that
796 * there is a way to recover from sillinesses like "UPDATE pg_authid SET
797 * rolcanlogin = false;".
798 */
800 {
801 /*
802 * Is role allowed to login at all? (But background workers can
803 * override this by setting bypass_login_check.)
804 */
805 if (!bypass_login_check && !rform->rolcanlogin)
808 errmsg("role \"%s\" is not permitted to log in",
809 rname)));
810
811 /*
812 * Check connection limit for this role. We enforce the limit only
813 * for regular backends, since other process types have their own
814 * PGPROC pools.
815 *
816 * There is a race condition here --- we create our PGPROC before
817 * checking for other PGPROCs. If two backends did this at about the
818 * same time, they might both think they were over the limit, while
819 * ideally one should succeed and one fail. Getting that to work
820 * exactly seems more trouble than it is worth, however; instead we
821 * just document that the connection limit is approximate.
822 */
823 if (rform->rolconnlimit >= 0 &&
825 !is_superuser &&
826 CountUserBackends(roleid) > rform->rolconnlimit)
829 errmsg("too many connections for role \"%s\"",
830 rname)));
831 }
832
834}
bool InitializingParallelWorker
Definition parallel.c:123
bool is_superuser(void)
Definition common.c:2480
bool IsUnderPostmaster
Definition globals.c:120
void SetConfigOption(const char *name, const char *value, GucContext context, GucSource source)
Definition guc.c:4228
@ PGC_S_OVERRIDE
Definition guc.h:123
@ PGC_BACKEND
Definition guc.h:77
void AcceptInvalidationMessages(void)
Definition inval.c:930
#define IsBootstrapProcessingMode()
Definition miscadmin.h:477
#define AmRegularBackendProcess()
Definition miscadmin.h:381
void SetAuthenticatedUserId(Oid userid)
Definition miscinit.c:553
static Datum PointerGetDatum(const void *X)
Definition postgres.h:342
int CountUserBackends(Oid roleid)
Definition procarray.c:3690

References AcceptInvalidationMessages(), AmRegularBackendProcess, Assert, CountUserBackends(), ereport, errcode(), errmsg, FATAL, fb(), Form_pg_authid, GETSTRUCT(), HeapTupleIsValid, InitializingParallelWorker, is_superuser(), IsBootstrapProcessingMode, IsUnderPostmaster, NameStr, ObjectIdGetDatum(), PGC_BACKEND, PGC_S_OVERRIDE, PointerGetDatum(), ReleaseSysCache(), SearchSysCache1(), SetAuthenticatedUserId(), and SetConfigOption().

Referenced by InitPostgres().

◆ InitializeSessionUserIdStandalone()

void InitializeSessionUserIdStandalone ( void  )

Definition at line 841 of file miscinit.c.

842{
843 /*
844 * This function should only be called in single-user mode, in autovacuum
845 * workers, in slot sync worker and in background workers.
846 */
849
850 /* call only once */
852
854
855 /*
856 * XXX Ideally we'd do this via SetConfigOption("session_authorization"),
857 * but we lack the role name needed to do that, and we can't fetch it
858 * because one reason for this special case is to be able to start up even
859 * if something's happened to the BOOTSTRAP_SUPERUSERID's pg_authid row.
860 * Since we don't set the GUC itself, C code will see the value as NULL,
861 * and current_setting() will report an empty string within this session.
862 */
864
865 /* We could do SetConfigOption("role"), but let's be consistent */
867}
#define AmAutoVacuumWorkerProcess()
Definition miscadmin.h:383
#define AmBackgroundWorkerProcess()
Definition miscadmin.h:384
#define AmLogicalSlotSyncWorkerProcess()
Definition miscadmin.h:386
void SetSessionAuthorization(Oid userid, bool is_superuser)
Definition miscinit.c:921
void SetCurrentRoleId(Oid roleid, bool is_superuser)
Definition miscinit.c:957

References AmAutoVacuumWorkerProcess, AmBackgroundWorkerProcess, AmLogicalSlotSyncWorkerProcess, Assert, AuthenticatedUserId, fb(), InvalidOid, IsUnderPostmaster, OidIsValid, SetCurrentRoleId(), and SetSessionAuthorization().

Referenced by InitPostgres().

◆ InitializeSystemUser()

void InitializeSystemUser ( const char authn_id,
const char auth_method 
)

Definition at line 875 of file miscinit.c.

876{
877 char *system_user;
878
879 /* call only once */
881
882 /*
883 * InitializeSystemUser should be called only when authn_id is not NULL,
884 * meaning that auth_method is valid.
885 */
886 Assert(authn_id != NULL);
887
888 system_user = psprintf("%s:%s", auth_method, authn_id);
889
890 /* Store SystemUser in long-lived storage */
893}
char * MemoryContextStrdup(MemoryContext context, const char *string)
Definition mcxt.c:1768
void pfree(void *pointer)
Definition mcxt.c:1616
MemoryContext TopMemoryContext
Definition mcxt.c:166
Datum system_user(PG_FUNCTION_ARGS)
Definition miscinit.c:899
char * psprintf(const char *fmt,...)
Definition psprintf.c:43
static char * authn_id
Definition validator.c:41

References Assert, authn_id, fb(), MemoryContextStrdup(), pfree(), psprintf(), system_user(), SystemUser, and TopMemoryContext.

Referenced by InitPostgres(), and ParallelWorkerMain().

◆ InitPostmasterChild()

void InitPostmasterChild ( void  )

Definition at line 97 of file miscinit.c.

98{
99 IsUnderPostmaster = true; /* we are a postmaster subprocess now */
100
101 /*
102 * Start our win32 signal implementation. This has to be done after we
103 * read the backend variables, because we need to pick up the signal pipe
104 * from the parent process.
105 */
106#ifdef WIN32
108#endif
109
111
112 /*
113 * make sure stderr is in binary mode before anything can possibly be
114 * written to it, in case it's actually the syslogger pipe, so the pipe
115 * chunking protocol isn't disturbed. Non-logpipe data gets translated on
116 * redirection (e.g. via pg_ctl -l) anyway.
117 */
118#ifdef WIN32
119 _setmode(fileno(stderr), _O_BINARY);
120#endif
121
122 /* We don't want the postmaster's proc_exit() handlers */
124
125 /* In EXEC_BACKEND case we will not have inherited BlockSig etc values */
126#ifdef EXEC_BACKEND
127 pqinitmask();
128#endif
129
130 /* Initialize process-local latch support */
134
135 /*
136 * If possible, make this process a group leader, so that the postmaster
137 * can signal any child processes too. Not all processes will have
138 * children, but for consistency we make all postmaster child processes do
139 * this.
140 */
141#ifdef HAVE_SETSID
142 if (setsid() < 0)
143 elog(FATAL, "setsid() failed: %m");
144#endif
145
146 /*
147 * Every postmaster child process is expected to respond promptly to
148 * SIGQUIT at all times. Therefore we centrally remove SIGQUIT from
149 * BlockSig and install a suitable signal handler. (Client-facing
150 * processes may choose to replace this default choice of handler with
151 * quickdie().) All other blockable signals remain blocked for now.
152 */
154
157
158 /* Request a signal if the postmaster dies, if possible. */
160
161 /* Don't give the pipe to subprograms that we execute. */
162#ifndef WIN32
166 errmsg_internal("could not set postmaster death monitoring pipe to FD_CLOEXEC mode: %m")));
167#endif
168}
void pqinitmask(void)
Definition pqsignal.c:41
sigset_t BlockSig
Definition pqsignal.c:23
int errcode_for_socket_access(void)
Definition elog.c:976
int int errmsg_internal(const char *fmt,...) pg_attribute_printf(1
void SignalHandlerForCrashExit(SIGNAL_ARGS)
Definition interrupt.c:73
void on_exit_reset(void)
Definition ipc.c:423
void InitializeLatchWaitSet(void)
Definition latch.c:35
void InitProcessLocalLatch(void)
Definition miscinit.c:236
void PostmasterDeathSignalInit(void)
Definition pmsignal.c:407
#define pqsignal
Definition port.h:547
void InitProcessGlobals(void)
int postmaster_alive_fds[2]
Definition postmaster.c:483
#define POSTMASTER_FD_WATCH
Definition postmaster.h:83
void pgwin32_signal_initialize(void)
Definition signal.c:79
void InitializeWaitEventSupport(void)
#define SIGQUIT
Definition win32_port.h:159

References BlockSig, elog, ereport, errcode_for_socket_access(), errmsg_internal(), FATAL, fb(), InitializeLatchWaitSet(), InitializeWaitEventSupport(), InitProcessGlobals(), InitProcessLocalLatch(), IsUnderPostmaster, on_exit_reset(), pgwin32_signal_initialize(), postmaster_alive_fds, POSTMASTER_FD_WATCH, PostmasterDeathSignalInit(), pqinitmask(), pqsignal, SignalHandlerForCrashExit(), and SIGQUIT.

Referenced by postmaster_child_launch().

◆ InitProcessLocalLatch()

void InitProcessLocalLatch ( void  )

Definition at line 236 of file miscinit.c.

237{
240}
struct Latch * MyLatch
Definition globals.c:63
void InitLatch(Latch *latch)
Definition latch.c:63
static Latch LocalLatchData
Definition miscinit.c:70

References InitLatch(), LocalLatchData, and MyLatch.

Referenced by InitPostmasterChild(), InitStandaloneProcess(), and PostmasterMain().

◆ InitStandaloneProcess()

void InitStandaloneProcess ( const char argv0)

Definition at line 176 of file miscinit.c.

177{
179
181
182 /*
183 * Start our win32 signal implementation
184 */
185#ifdef WIN32
187#endif
188
190
191 /* Initialize process-local latch support */
195
196 /*
197 * For consistency with InitPostmasterChild, initialize signal mask here.
198 * But we don't unblock SIGQUIT or provide a default handler for it.
199 */
200 pqinitmask();
202
203 /* Compute paths, no postmaster to inherit from */
204 if (my_exec_path[0] == '\0')
205 {
207 elog(FATAL, "%s: could not locate my own executable path",
208 argv0);
209 }
210
211 if (pkglib_path[0] == '\0')
213}
int find_my_exec(const char *argv0, char *retpath)
Definition exec.c:161
char pkglib_path[MAXPGPATH]
Definition globals.c:82
bool IsPostmasterEnvironment
Definition globals.c:119
char my_exec_path[MAXPGPATH]
Definition globals.c:81
@ B_STANDALONE_BACKEND
Definition miscadmin.h:350
BackendType MyBackendType
Definition miscinit.c:65
static char * argv0
Definition pg_ctl.c:94
void get_pkglib_path(const char *my_exec_path, char *ret_path)
Definition path.c:956

References argv0, Assert, B_STANDALONE_BACKEND, BlockSig, elog, FATAL, fb(), find_my_exec(), get_pkglib_path(), InitializeLatchWaitSet(), InitializeWaitEventSupport(), InitProcessGlobals(), InitProcessLocalLatch(), IsPostmasterEnvironment, my_exec_path, MyBackendType, pgwin32_signal_initialize(), pkglib_path, and pqinitmask().

Referenced by BootstrapModeMain(), and PostgresSingleUserMain().

◆ InLocalUserIdChange()

bool InLocalUserIdChange ( void  )

Definition at line 631 of file miscinit.c.

632{
634}
#define SECURITY_LOCAL_USERID_CHANGE
Definition miscadmin.h:318

References SECURITY_LOCAL_USERID_CHANGE, and SecurityRestrictionContext.

Referenced by GetUserIdAndContext(), and set_config_with_handle().

◆ InNoForceRLSOperation()

bool InNoForceRLSOperation ( void  )

Definition at line 649 of file miscinit.c.

650{
652}
#define SECURITY_NOFORCE_RLS
Definition miscadmin.h:320

References SECURITY_NOFORCE_RLS, and SecurityRestrictionContext.

Referenced by check_enable_rls().

◆ InSecurityRestrictedOperation()

◆ load_libraries()

static void load_libraries ( const char libraries,
const char gucname,
bool  restricted 
)
static

Definition at line 1800 of file miscinit.c.

1801{
1802 char *rawstring;
1803 List *elemlist;
1804 ListCell *l;
1805
1806 if (libraries == NULL || libraries[0] == '\0')
1807 return; /* nothing to do */
1808
1809 /* Need a modifiable copy of string */
1810 rawstring = pstrdup(libraries);
1811
1812 /* Parse string into list of filename paths */
1814 {
1815 /* syntax error in list */
1818 ereport(LOG,
1820 errmsg("invalid list syntax in parameter \"%s\"",
1821 gucname)));
1822 return;
1823 }
1824
1825 foreach(l, elemlist)
1826 {
1827 /* Note that filename was already canonicalized */
1828 char *filename = (char *) lfirst(l);
1829 char *expanded = NULL;
1830
1831 /* If restricting, insert $libdir/plugins if not mentioned already */
1833 {
1834 expanded = psprintf("$libdir/plugins/%s", filename);
1835 filename = expanded;
1836 }
1839 (errmsg_internal("loaded library \"%s\"", filename)));
1840 if (expanded)
1841 pfree(expanded);
1842 }
1843
1846}
static bool restricted
Definition command.c:199
void load_file(const char *filename, bool restricted)
Definition dfmgr.c:149
#define DEBUG1
Definition elog.h:30
void list_free_deep(List *list)
Definition list.c:1560
#define lfirst(lc)
Definition pg_list.h:172
char * first_dir_separator(const char *filename)
Definition path.c:110
Definition pg_list.h:54
bool SplitDirectoriesString(char *rawstring, char separator, List **namelist)
Definition varlena.c:2904

References DEBUG1, ereport, errcode(), errmsg, errmsg_internal(), fb(), filename, first_dir_separator(), lfirst, list_free_deep(), load_file(), LOG, pfree(), psprintf(), pstrdup(), restricted, and SplitDirectoriesString().

Referenced by process_session_preload_libraries(), and process_shared_preload_libraries().

◆ pg_bindtextdomain()

void pg_bindtextdomain ( const char domain)

Definition at line 1889 of file miscinit.c.

1890{
1891#ifdef ENABLE_NLS
1892 if (my_exec_path[0] != '\0')
1893 {
1894 char locale_path[MAXPGPATH];
1895
1897 bindtextdomain(domain, locale_path);
1899 }
1900#endif
1901}
void get_locale_path(const char *my_exec_path, char *ret_path)
Definition path.c:965

References fb(), get_locale_path(), MAXPGPATH, and my_exec_path.

Referenced by _PG_init(), and test_translation().

◆ process_session_preload_libraries()

void process_session_preload_libraries ( void  )

Definition at line 1866 of file miscinit.c.

1867{
1869 "session_preload_libraries",
1870 false);
1872 "local_preload_libraries",
1873 true);
1874}
char * session_preload_libraries_string
Definition miscinit.c:1782
char * local_preload_libraries_string
Definition miscinit.c:1784
static void load_libraries(const char *libraries, const char *gucname, bool restricted)
Definition miscinit.c:1800

References load_libraries(), local_preload_libraries_string, and session_preload_libraries_string.

Referenced by InitPostgres().

◆ process_shared_preload_libraries()

void process_shared_preload_libraries ( void  )

Definition at line 1852 of file miscinit.c.

1853{
1856 "shared_preload_libraries",
1857 false);
1860}
bool process_shared_preload_libraries_done
Definition miscinit.c:1788
char * shared_preload_libraries_string
Definition miscinit.c:1783
bool process_shared_preload_libraries_in_progress
Definition miscinit.c:1787

References load_libraries(), process_shared_preload_libraries_done, process_shared_preload_libraries_in_progress, and shared_preload_libraries_string.

Referenced by PostgresSingleUserMain(), and PostmasterMain().

◆ process_shmem_requests()

void process_shmem_requests ( void  )

Definition at line 1880 of file miscinit.c.

1881{
1886}
bool process_shmem_requests_in_progress
Definition miscinit.c:1791
shmem_request_hook_type shmem_request_hook
Definition miscinit.c:1790

References process_shmem_requests_in_progress, and shmem_request_hook.

Referenced by PostgresSingleUserMain(), and PostmasterMain().

◆ RecheckDataDirLockFile()

bool RecheckDataDirLockFile ( void  )

Definition at line 1647 of file miscinit.c.

1648{
1649 int fd;
1650 int len;
1651 long file_pid;
1652 char buffer[BLCKSZ];
1653
1655 if (fd < 0)
1656 {
1657 /*
1658 * There are many foreseeable false-positive error conditions. For
1659 * safety, fail only on enumerated clearly-something-is-wrong
1660 * conditions.
1661 */
1662 switch (errno)
1663 {
1664 case ENOENT:
1665 case ENOTDIR:
1666 /* disaster */
1667 ereport(LOG,
1669 errmsg("could not open file \"%s\": %m",
1671 return false;
1672 default:
1673 /* non-fatal, at least for now */
1674 ereport(LOG,
1676 errmsg("could not open file \"%s\": %m; continuing anyway",
1678 return true;
1679 }
1680 }
1682 len = read(fd, buffer, sizeof(buffer) - 1);
1684 if (len < 0)
1685 {
1686 ereport(LOG,
1688 errmsg("could not read from file \"%s\": %m",
1690 close(fd);
1691 return true; /* treat read failure as nonfatal */
1692 }
1693 buffer[len] = '\0';
1694 close(fd);
1695 file_pid = atol(buffer);
1696 if (file_pid == getpid())
1697 return true; /* all is well */
1698
1699 /* Trouble: someone's overwritten the lock file */
1700 ereport(LOG,
1701 (errmsg("lock file \"%s\" contains wrong PID: %ld instead of %ld",
1702 DIRECTORY_LOCK_FILE, file_pid, (long) getpid())));
1703 return false;
1704}

References close, DIRECTORY_LOCK_FILE, ereport, errcode_for_file_access(), errmsg, fb(), fd(), len, LOG, PG_BINARY, pgstat_report_wait_end(), pgstat_report_wait_start(), and read.

Referenced by ServerLoop().

◆ RestoreClientConnectionInfo()

void RestoreClientConnectionInfo ( char conninfo)

Definition at line 1085 of file miscinit.c.

1086{
1088
1089 memcpy(&serialized, conninfo, sizeof(serialized));
1090
1091 /* Copy the fields back into place */
1094
1095 if (serialized.authn_id_len >= 0)
1096 {
1097 char *authn_id;
1098
1099 authn_id = conninfo + sizeof(serialized);
1101 authn_id);
1102 }
1103}

References ClientConnectionInfo::auth_method, ClientConnectionInfo::authn_id, authn_id, fb(), MemoryContextStrdup(), MyClientConnectionInfo, and TopMemoryContext.

Referenced by ParallelWorkerMain().

◆ SerializeClientConnectionInfo()

void SerializeClientConnectionInfo ( Size maxsize  PG_USED_FOR_ASSERTS_ONLY,
char start_address 
)

Definition at line 1052 of file miscinit.c.

1054{
1056
1059
1062
1063 /* Copy serialized representation to buffer */
1064 Assert(maxsize >= sizeof(serialized));
1066
1067 maxsize -= sizeof(serialized);
1068 start_address += sizeof(serialized);
1069
1070 /* Copy authn_id into the space after the struct */
1071 if (serialized.authn_id_len >= 0)
1072 {
1073 Assert(maxsize >= (serialized.authn_id_len + 1));
1076 /* include the NULL terminator to ease deserialization */
1077 serialized.authn_id_len + 1);
1078 }
1079}

References Assert, ClientConnectionInfo::auth_method, ClientConnectionInfo::authn_id, SerializedClientConnectionInfo::authn_id_len, fb(), and MyClientConnectionInfo.

Referenced by InitializeParallelDSM().

◆ SetAuthenticatedUserId()

void SetAuthenticatedUserId ( Oid  userid)

Definition at line 553 of file miscinit.c.

554{
555 Assert(OidIsValid(userid));
556
557 /* call only once */
559
560 AuthenticatedUserId = userid;
561
562 /* Also mark our PGPROC entry with the authenticated user id */
563 /* (We assume this is an atomic store so no lock is needed) */
564 MyProc->roleId = userid;
565}
PGPROC * MyProc
Definition proc.c:68
Oid roleId
Definition proc.h:199

References Assert, AuthenticatedUserId, MyProc, OidIsValid, and PGPROC::roleId.

Referenced by InitializeSessionUserId(), and ParallelWorkerMain().

◆ SetCurrentRoleId()

void SetCurrentRoleId ( Oid  roleid,
bool  is_superuser 
)

Definition at line 957 of file miscinit.c.

958{
959 /*
960 * Get correct info if it's SET ROLE NONE
961 *
962 * If SessionUserId hasn't been set yet, do nothing beyond updating
963 * SetRoleIsActive --- the eventual SetSessionAuthorization call will
964 * update the derived state. This is needed since we will get called
965 * during GUC initialization.
966 */
967 if (!OidIsValid(roleid))
968 {
969 SetRoleIsActive = false;
970
972 return;
973
974 roleid = SessionUserId;
976 }
977 else
978 SetRoleIsActive = true;
979
981}
static void SetOuterUserId(Oid userid, bool is_superuser)
Definition miscinit.c:489

References is_superuser(), OidIsValid, SessionUserId, SessionUserIsSuperuser, SetOuterUserId(), and SetRoleIsActive.

Referenced by assign_role(), InitializeSessionUserIdStandalone(), and ParallelWorkerMain().

◆ SetDatabasePath()

void SetDatabasePath ( const char path)

Definition at line 284 of file miscinit.c.

285{
286 /* This should happen only once per process */
289}
char * DatabasePath
Definition globals.c:104

References Assert, DatabasePath, MemoryContextStrdup(), and TopMemoryContext.

Referenced by InitPostgres().

◆ SetDataDir()

void SetDataDir ( const char dir)

Definition at line 390 of file miscinit.c.

391{
392 char *new;
393
394 Assert(dir);
395
396 /* If presented path is relative, convert to absolute */
397 new = make_absolute_path(dir);
398
399 free(DataDir);
400 DataDir = new;
401}
char * make_absolute_path(const char *path)
Definition path.c:807
#define free(a)

References Assert, DataDir, free, and make_absolute_path().

Referenced by SelectConfigFiles().

◆ SetOuterUserId()

static void SetOuterUserId ( Oid  userid,
bool  is_superuser 
)
static

Definition at line 489 of file miscinit.c.

490{
492 Assert(OidIsValid(userid));
493 OuterUserId = userid;
494
495 /* We force the effective user ID to match, too */
496 CurrentUserId = userid;
497
498 /* Also update the is_superuser GUC to match OuterUserId's property */
499 SetConfigOption("is_superuser",
500 is_superuser ? "on" : "off",
502}
@ PGC_S_DYNAMIC_DEFAULT
Definition guc.h:114
@ PGC_INTERNAL
Definition guc.h:73

References Assert, CurrentUserId, is_superuser(), OidIsValid, OuterUserId, PGC_INTERNAL, PGC_S_DYNAMIC_DEFAULT, SecurityRestrictionContext, and SetConfigOption().

Referenced by SetCurrentRoleId(), and SetSessionAuthorization().

◆ SetSessionAuthorization()

void SetSessionAuthorization ( Oid  userid,
bool  is_superuser 
)

Definition at line 921 of file miscinit.c.

922{
924
925 if (!SetRoleIsActive)
927}
static void SetSessionUserId(Oid userid, bool is_superuser)
Definition miscinit.c:523

References is_superuser(), SetOuterUserId(), SetRoleIsActive, and SetSessionUserId().

Referenced by assign_session_authorization(), InitializeSessionUserIdStandalone(), and ParallelWorkerMain().

◆ SetSessionUserId()

static void SetSessionUserId ( Oid  userid,
bool  is_superuser 
)
static

◆ SetUserIdAndContext()

void SetUserIdAndContext ( Oid  userid,
bool  sec_def_context 
)

Definition at line 669 of file miscinit.c.

670{
671 /* We throw the same error SET ROLE would. */
675 errmsg("cannot set parameter \"%s\" within security-restricted operation",
676 "role")));
677 CurrentUserId = userid;
678 if (sec_def_context)
680 else
682}
bool InSecurityRestrictedOperation(void)
Definition miscinit.c:640

References CurrentUserId, ereport, errcode(), errmsg, ERROR, fb(), InSecurityRestrictedOperation(), SECURITY_LOCAL_USERID_CHANGE, and SecurityRestrictionContext.

◆ SetUserIdAndSecContext()

◆ SwitchBackToLocalLatch()

void SwitchBackToLocalLatch ( void  )

Definition at line 243 of file miscinit.c.

244{
247
249
250 if (FeBeWaitSet)
252 MyLatch);
253
255}
void SetLatch(Latch *latch)
Definition latch.c:290
#define FeBeWaitSetLatchPos
Definition libpq.h:67
WaitEventSet * FeBeWaitSet
Definition pqcomm.c:167
Latch procLatch
Definition proc.h:253
void ModifyWaitEvent(WaitEventSet *set, int pos, uint32 events, Latch *latch)
#define WL_LATCH_SET

References Assert, fb(), FeBeWaitSet, FeBeWaitSetLatchPos, LocalLatchData, ModifyWaitEvent(), MyLatch, MyProc, PGPROC::procLatch, SetLatch(), and WL_LATCH_SET.

Referenced by AuxiliaryProcKill(), and ProcKill().

◆ SwitchToSharedLatch()

void SwitchToSharedLatch ( void  )

Definition at line 216 of file miscinit.c.

217{
219 Assert(MyProc != NULL);
220
222
223 if (FeBeWaitSet)
225 MyLatch);
226
227 /*
228 * Set the shared latch as the local one might have been set. This
229 * shouldn't normally be necessary as code is supposed to check the
230 * condition before waiting for the latch, but a bit care can't hurt.
231 */
233}

References Assert, fb(), FeBeWaitSet, FeBeWaitSetLatchPos, LocalLatchData, ModifyWaitEvent(), MyLatch, MyProc, PGPROC::procLatch, SetLatch(), and WL_LATCH_SET.

Referenced by InitAuxiliaryProcess(), and InitProcess().

◆ system_user()

Datum system_user ( PG_FUNCTION_ARGS  )

Definition at line 899 of file miscinit.c.

900{
901 const char *sysuser = GetSystemUser();
902
903 if (sysuser)
905 else
907}
#define CStringGetTextDatum(s)
Definition builtins.h:98
#define PG_RETURN_NULL()
Definition fmgr.h:346
#define PG_RETURN_DATUM(x)
Definition fmgr.h:354
const char * GetSystemUser(void)
Definition miscinit.c:536

References CStringGetTextDatum, fb(), GetSystemUser(), PG_RETURN_DATUM, and PG_RETURN_NULL.

Referenced by check_ident_usermap(), check_usermap(), and InitializeSystemUser().

◆ TouchSocketLockFiles()

void TouchSocketLockFiles ( void  )

Definition at line 1491 of file miscinit.c.

1492{
1493 ListCell *l;
1494
1495 foreach(l, lock_files)
1496 {
1497 char *socketLockFile = (char *) lfirst(l);
1498
1499 /* No need to touch the data directory lock file, we trust */
1501 continue;
1502
1503 /* we just ignore any error here */
1505 }
1506}

References DIRECTORY_LOCK_FILE, fb(), lfirst, and lock_files.

Referenced by ServerLoop().

◆ UnlinkLockFiles()

static void UnlinkLockFiles ( int  status,
Datum  arg 
)
static

Definition at line 1125 of file miscinit.c.

1126{
1127 ListCell *l;
1128
1129 foreach(l, lock_files)
1130 {
1131 char *curfile = (char *) lfirst(l);
1132
1133 unlink(curfile);
1134 /* Should we complain if the unlink fails? */
1135 }
1136 /* Since we're about to exit, no need to reclaim storage */
1137
1138 /*
1139 * Lock file removal should always be the last externally visible action
1140 * of a postmaster or standalone backend, while we won't come here at all
1141 * when exiting postmaster child processes. Therefore, this is a good
1142 * place to log completion of shutdown. We could alternatively teach
1143 * proc_exit() to do it, but that seems uglier. In a standalone backend,
1144 * use NOTICE elevel to be less chatty.
1145 */
1147 (errmsg("database system is shut down")));
1148}
#define NOTICE
Definition elog.h:35

References ereport, errmsg, fb(), IsPostmasterEnvironment, lfirst, lock_files, LOG, and NOTICE.

Referenced by CreateLockFile().

◆ ValidatePgVersion()

void ValidatePgVersion ( const char path)

Definition at line 1719 of file miscinit.c.

1720{
1721 char full_path[MAXPGPATH];
1722 FILE *file;
1723 int ret;
1724 long file_major;
1725 long my_major;
1726 char *endptr;
1727 char file_version_string[64];
1728 const char *my_version_string = PG_VERSION;
1729
1730 my_major = strtol(my_version_string, &endptr, 10);
1731
1732 snprintf(full_path, sizeof(full_path), "%s/PG_VERSION", path);
1733
1734 file = AllocateFile(full_path, "r");
1735 if (!file)
1736 {
1737 if (errno == ENOENT)
1738 ereport(FATAL,
1740 errmsg("\"%s\" is not a valid data directory",
1741 path),
1742 errdetail("File \"%s\" is missing.", full_path)));
1743 else
1744 ereport(FATAL,
1746 errmsg("could not open file \"%s\": %m", full_path)));
1747 }
1748
1749 file_version_string[0] = '\0';
1750 ret = fscanf(file, "%63s", file_version_string);
1751 file_major = strtol(file_version_string, &endptr, 10);
1752
1753 if (ret != 1 || endptr == file_version_string)
1754 ereport(FATAL,
1756 errmsg("\"%s\" is not a valid data directory",
1757 path),
1758 errdetail("File \"%s\" does not contain valid data.",
1759 full_path),
1760 errhint("You might need to initdb.")));
1761
1762 FreeFile(file);
1763
1764 if (my_major != file_major)
1765 ereport(FATAL,
1767 errmsg("database files are incompatible with server"),
1768 errdetail("The data directory was initialized by PostgreSQL version %s, "
1769 "which is not compatible with this version %s.",
1771}
int FreeFile(FILE *file)
Definition fd.c:2827
FILE * AllocateFile(const char *name, const char *mode)
Definition fd.c:2628

References AllocateFile(), ereport, errcode(), errcode_for_file_access(), errdetail(), errhint(), errmsg, FATAL, fb(), FreeFile(), MAXPGPATH, and snprintf.

Referenced by checkDataDir(), and InitPostgres().

Variable Documentation

◆ AuthenticatedUserId

Oid AuthenticatedUserId = InvalidOid
static

◆ CurrentUserId

◆ IgnoreSystemIndexes

◆ local_preload_libraries_string

char* local_preload_libraries_string = NULL

Definition at line 1784 of file miscinit.c.

Referenced by process_session_preload_libraries().

◆ LocalLatchData

Latch LocalLatchData
static

Definition at line 70 of file miscinit.c.

Referenced by InitProcessLocalLatch(), SwitchBackToLocalLatch(), and SwitchToSharedLatch().

◆ lock_files

List* lock_files = NIL
static

Definition at line 68 of file miscinit.c.

Referenced by CreateLockFile(), TouchSocketLockFiles(), and UnlinkLockFiles().

◆ Mode

Definition at line 63 of file miscinit.c.

◆ MyBackendType

◆ MyClientConnectionInfo

◆ OuterUserId

Oid OuterUserId = InvalidOid
static

Definition at line 452 of file miscinit.c.

Referenced by GetCurrentRoleId(), GetOuterUserId(), and SetOuterUserId().

◆ process_shared_preload_libraries_done

bool process_shared_preload_libraries_done = false

◆ process_shared_preload_libraries_in_progress

◆ process_shmem_requests_in_progress

bool process_shmem_requests_in_progress = false

◆ SecurityRestrictionContext

◆ session_preload_libraries_string

char* session_preload_libraries_string = NULL

Definition at line 1782 of file miscinit.c.

Referenced by process_session_preload_libraries().

◆ SessionUserId

Oid SessionUserId = InvalidOid
static

◆ SessionUserIsSuperuser

bool SessionUserIsSuperuser = false
static

Definition at line 457 of file miscinit.c.

Referenced by GetSessionUserIsSuperuser(), SetCurrentRoleId(), and SetSessionUserId().

◆ SetRoleIsActive

bool SetRoleIsActive = false
static

Definition at line 462 of file miscinit.c.

Referenced by GetCurrentRoleId(), SetCurrentRoleId(), and SetSessionAuthorization().

◆ shared_preload_libraries_string

char* shared_preload_libraries_string = NULL

Definition at line 1783 of file miscinit.c.

Referenced by process_shared_preload_libraries().

◆ shmem_request_hook

shmem_request_hook_type shmem_request_hook = NULL

Definition at line 1790 of file miscinit.c.

Referenced by _PG_init(), and process_shmem_requests().

◆ SystemUser

const char* SystemUser = NULL
static

Definition at line 454 of file miscinit.c.

Referenced by GetSystemUser(), and InitializeSystemUser().