PostgreSQL Source Code  git master
 All Data Structures Namespaces Files Functions Variables Typedefs Enumerations Enumerator Macros
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 "access/htup_details.h"
#include "catalog/pg_authid.h"
#include "libpq/libpq.h"
#include "mb/pg_wchar.h"
#include "miscadmin.h"
#include "pgstat.h"
#include "postmaster/autovacuum.h"
#include "postmaster/postmaster.h"
#include "storage/fd.h"
#include "storage/ipc.h"
#include "storage/latch.h"
#include "storage/pg_shmem.h"
#include "storage/proc.h"
#include "storage/procarray.h"
#include "utils/builtins.h"
#include "utils/guc.h"
#include "utils/memutils.h"
#include "utils/pidfile.h"
#include "utils/syscache.h"
#include "utils/varlena.h"
Include dependency graph for miscinit.c:

Go to the source code of this file.

Macros

#define DIRECTORY_LOCK_FILE   "postmaster.pid"
 

Functions

void SetDatabasePath (const char *path)
 
void SetDataDir (const char *dir)
 
void ChangeToDataDir (void)
 
void InitPostmasterChild (void)
 
void InitStandaloneProcess (const char *argv0)
 
void SwitchToSharedLatch (void)
 
void SwitchBackToLocalLatch (void)
 
Oid GetUserId (void)
 
Oid GetOuterUserId (void)
 
static void SetOuterUserId (Oid userid)
 
Oid GetSessionUserId (void)
 
static void SetSessionUserId (Oid userid, bool is_superuser)
 
Oid GetAuthenticatedUserId (void)
 
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)
 
void InitializeSessionUserIdStandalone (void)
 
void SetSessionAuthorization (Oid userid, bool is_superuser)
 
Oid GetCurrentRoleId (void)
 
void SetCurrentRoleId (Oid roleid, bool is_superuser)
 
char * GetUserNameFromId (Oid roleid, bool noerr)
 
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 pg_bindtextdomain (const char *domain)
 

Variables

ProcessingMode Mode = InitProcessing
 
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 bool AuthenticatedUserIsSuperuser = false
 
static bool SessionUserIsSuperuser = false
 
static int SecurityRestrictionContext = 0
 
static bool SetRoleIsActive = false
 
char * session_preload_libraries_string = NULL
 
char * shared_preload_libraries_string = NULL
 
char * local_preload_libraries_string = NULL
 
bool process_shared_preload_libraries_in_progress = false
 

Macro Definition Documentation

#define DIRECTORY_LOCK_FILE   "postmaster.pid"

Function Documentation

void AddToDataDirLockFile ( int  target_line,
const char *  str 
)

Definition at line 1158 of file miscinit.c.

References close, DIRECTORY_LOCK_FILE, ereport, errcode_for_file_access(), errmsg(), fd(), LOG, PG_BINARY, pg_fsync(), pgstat_report_wait_end(), pgstat_report_wait_start(), read, snprintf(), WAIT_EVENT_LOCK_FILE_ADDTODATADIR_READ, WAIT_EVENT_LOCK_FILE_ADDTODATADIR_SYNC, WAIT_EVENT_LOCK_FILE_ADDTODATADIR_WRITE, and write.

Referenced by InternalIpcMemoryCreate(), pmdie(), PostmasterMain(), reaper(), and sigusr1_handler().

1159 {
1160  int fd;
1161  int len;
1162  int lineno;
1163  char *srcptr;
1164  char *destptr;
1165  char srcbuffer[BLCKSZ];
1166  char destbuffer[BLCKSZ];
1167 
1168  fd = open(DIRECTORY_LOCK_FILE, O_RDWR | PG_BINARY, 0);
1169  if (fd < 0)
1170  {
1171  ereport(LOG,
1173  errmsg("could not open file \"%s\": %m",
1175  return;
1176  }
1178  len = read(fd, srcbuffer, sizeof(srcbuffer) - 1);
1180  if (len < 0)
1181  {
1182  ereport(LOG,
1184  errmsg("could not read from file \"%s\": %m",
1186  close(fd);
1187  return;
1188  }
1189  srcbuffer[len] = '\0';
1190 
1191  /*
1192  * Advance over lines we are not supposed to rewrite, then copy them to
1193  * destbuffer.
1194  */
1195  srcptr = srcbuffer;
1196  for (lineno = 1; lineno < target_line; lineno++)
1197  {
1198  char *eol = strchr(srcptr, '\n');
1199 
1200  if (eol == NULL)
1201  break; /* not enough lines in file yet */
1202  srcptr = eol + 1;
1203  }
1204  memcpy(destbuffer, srcbuffer, srcptr - srcbuffer);
1205  destptr = destbuffer + (srcptr - srcbuffer);
1206 
1207  /*
1208  * Fill in any missing lines before the target line, in case lines are
1209  * added to the file out of order.
1210  */
1211  for (; lineno < target_line; lineno++)
1212  {
1213  if (destptr < destbuffer + sizeof(destbuffer))
1214  *destptr++ = '\n';
1215  }
1216 
1217  /*
1218  * Write or rewrite the target line.
1219  */
1220  snprintf(destptr, destbuffer + sizeof(destbuffer) - destptr, "%s\n", str);
1221  destptr += strlen(destptr);
1222 
1223  /*
1224  * If there are more lines in the old file, append them to destbuffer.
1225  */
1226  if ((srcptr = strchr(srcptr, '\n')) != NULL)
1227  {
1228  srcptr++;
1229  snprintf(destptr, destbuffer + sizeof(destbuffer) - destptr, "%s",
1230  srcptr);
1231  }
1232 
1233  /*
1234  * And rewrite the data. Since we write in a single kernel call, this
1235  * update should appear atomic to onlookers.
1236  */
1237  len = strlen(destbuffer);
1238  errno = 0;
1240  if (lseek(fd, (off_t) 0, SEEK_SET) != 0 ||
1241  (int) write(fd, destbuffer, len) != len)
1242  {
1244  /* if write didn't set errno, assume problem is no disk space */
1245  if (errno == 0)
1246  errno = ENOSPC;
1247  ereport(LOG,
1249  errmsg("could not write to file \"%s\": %m",
1251  close(fd);
1252  return;
1253  }
1256  if (pg_fsync(fd) != 0)
1257  {
1258  ereport(LOG,
1260  errmsg("could not write to file \"%s\": %m",
1262  }
1264  if (close(fd) != 0)
1265  {
1266  ereport(LOG,
1268  errmsg("could not write to file \"%s\": %m",
1270  }
1271 }
#define write(a, b, c)
Definition: win32.h:14
#define DIRECTORY_LOCK_FILE
Definition: miscinit.c:55
int snprintf(char *str, size_t count, const char *fmt,...) pg_attribute_printf(3
#define LOG
Definition: elog.h:26
static int fd(const char *x, int i)
Definition: preproc-init.c:105
#define PG_BINARY
Definition: c.h:1044
int errcode_for_file_access(void)
Definition: elog.c:598
static void pgstat_report_wait_end(void)
Definition: pgstat.h:1244
#define ereport(elevel, rest)
Definition: elog.h:122
static void pgstat_report_wait_start(uint32 wait_event_info)
Definition: pgstat.h:1220
int errmsg(const char *fmt,...)
Definition: elog.c:797
int pg_fsync(int fd)
Definition: fd.c:338
#define close(a)
Definition: win32.h:12
#define read(a, b, c)
Definition: win32.h:13
void ChangeToDataDir ( void  )

Definition at line 116 of file miscinit.c.

References AssertState, DataDir, ereport, errcode_for_file_access(), errmsg(), and FATAL.

Referenced by AuxiliaryProcessMain(), PostgresMain(), and PostmasterMain().

117 {
119 
120  if (chdir(DataDir) < 0)
121  ereport(FATAL,
123  errmsg("could not change directory to \"%s\": %m",
124  DataDir)));
125 }
#define AssertState(condition)
Definition: c.h:684
#define FATAL
Definition: elog.h:52
int errcode_for_file_access(void)
Definition: elog.c:598
#define ereport(elevel, rest)
Definition: elog.h:122
int errmsg(const char *fmt,...)
Definition: elog.c:797
char * DataDir
Definition: globals.c:60
void CreateDataDirLockFile ( bool  amPostmaster)

Definition at line 1081 of file miscinit.c.

References CreateLockFile(), DataDir, and DIRECTORY_LOCK_FILE.

Referenced by AuxiliaryProcessMain(), PostgresMain(), and PostmasterMain().

1082 {
1083  CreateLockFile(DIRECTORY_LOCK_FILE, amPostmaster, "", true, DataDir);
1084 }
#define DIRECTORY_LOCK_FILE
Definition: miscinit.c:55
static void CreateLockFile(const char *filename, bool amPostmaster, const char *socketDir, bool isDDLock, const char *refName)
Definition: miscinit.c:769
char * DataDir
Definition: globals.c:60
static void CreateLockFile ( const char *  filename,
bool  amPostmaster,
const char *  socketDir,
bool  isDDLock,
const char *  refName 
)
static

Definition at line 769 of file miscinit.c.

References buffer, close, DataDir, elog, ereport, errcode(), errcode_for_file_access(), errhint(), errmsg(), FATAL, fd(), lcons(), LOCK_FILE_LINE_SHMEM_KEY, MAXPGPATH, MyStartTime, NIL, on_proc_exit(), pg_fsync(), PGSharedMemoryIsInUse(), pgstat_report_wait_end(), pgstat_report_wait_start(), PostPortNumber, pstrdup(), read, snprintf(), strlcat(), UnlinkLockFiles(), WAIT_EVENT_LOCK_FILE_CREATE_READ, WAIT_EVENT_LOCK_FILE_CREATE_SYNC, WAIT_EVENT_LOCK_FILE_CREATE_WRITE, and write.

Referenced by CreateDataDirLockFile(), and CreateSocketLockFile().

772 {
773  int fd;
774  char buffer[MAXPGPATH * 2 + 256];
775  int ntries;
776  int len;
777  int encoded_pid;
778  pid_t other_pid;
779  pid_t my_pid,
780  my_p_pid,
781  my_gp_pid;
782  const char *envvar;
783 
784  /*
785  * If the PID in the lockfile is our own PID or our parent's or
786  * grandparent's PID, then the file must be stale (probably left over from
787  * a previous system boot cycle). We need to check this because of the
788  * likelihood that a reboot will assign exactly the same PID as we had in
789  * the previous reboot, or one that's only one or two counts larger and
790  * hence the lockfile's PID now refers to an ancestor shell process. We
791  * allow pg_ctl to pass down its parent shell PID (our grandparent PID)
792  * via the environment variable PG_GRANDPARENT_PID; this is so that
793  * launching the postmaster via pg_ctl can be just as reliable as
794  * launching it directly. There is no provision for detecting
795  * further-removed ancestor processes, but if the init script is written
796  * carefully then all but the immediate parent shell will be root-owned
797  * processes and so the kill test will fail with EPERM. Note that we
798  * cannot get a false negative this way, because an existing postmaster
799  * would surely never launch a competing postmaster or pg_ctl process
800  * directly.
801  */
802  my_pid = getpid();
803 
804 #ifndef WIN32
805  my_p_pid = getppid();
806 #else
807 
808  /*
809  * Windows hasn't got getppid(), but doesn't need it since it's not using
810  * real kill() either...
811  */
812  my_p_pid = 0;
813 #endif
814 
815  envvar = getenv("PG_GRANDPARENT_PID");
816  if (envvar)
817  my_gp_pid = atoi(envvar);
818  else
819  my_gp_pid = 0;
820 
821  /*
822  * We need a loop here because of race conditions. But don't loop forever
823  * (for example, a non-writable $PGDATA directory might cause a failure
824  * that won't go away). 100 tries seems like plenty.
825  */
826  for (ntries = 0;; ntries++)
827  {
828  /*
829  * Try to create the lock file --- O_EXCL makes this atomic.
830  *
831  * Think not to make the file protection weaker than 0600. See
832  * comments below.
833  */
834  fd = open(filename, O_RDWR | O_CREAT | O_EXCL, 0600);
835  if (fd >= 0)
836  break; /* Success; exit the retry loop */
837 
838  /*
839  * Couldn't create the pid file. Probably it already exists.
840  */
841  if ((errno != EEXIST && errno != EACCES) || ntries > 100)
842  ereport(FATAL,
844  errmsg("could not create lock file \"%s\": %m",
845  filename)));
846 
847  /*
848  * Read the file to get the old owner's PID. Note race condition
849  * here: file might have been deleted since we tried to create it.
850  */
851  fd = open(filename, O_RDONLY, 0600);
852  if (fd < 0)
853  {
854  if (errno == ENOENT)
855  continue; /* race condition; try again */
856  ereport(FATAL,
858  errmsg("could not open lock file \"%s\": %m",
859  filename)));
860  }
862  if ((len = read(fd, buffer, sizeof(buffer) - 1)) < 0)
863  ereport(FATAL,
865  errmsg("could not read lock file \"%s\": %m",
866  filename)));
868  close(fd);
869 
870  if (len == 0)
871  {
872  ereport(FATAL,
873  (errcode(ERRCODE_LOCK_FILE_EXISTS),
874  errmsg("lock file \"%s\" is empty", filename),
875  errhint("Either another server is starting, or the lock file is the remnant of a previous server startup crash.")));
876  }
877 
878  buffer[len] = '\0';
879  encoded_pid = atoi(buffer);
880 
881  /* if pid < 0, the pid is for postgres, not postmaster */
882  other_pid = (pid_t) (encoded_pid < 0 ? -encoded_pid : encoded_pid);
883 
884  if (other_pid <= 0)
885  elog(FATAL, "bogus data in lock file \"%s\": \"%s\"",
886  filename, buffer);
887 
888  /*
889  * Check to see if the other process still exists
890  *
891  * Per discussion above, my_pid, my_p_pid, and my_gp_pid can be
892  * ignored as false matches.
893  *
894  * Normally kill() will fail with ESRCH if the given PID doesn't
895  * exist.
896  *
897  * We can treat the EPERM-error case as okay because that error
898  * implies that the existing process has a different userid than we
899  * do, which means it cannot be a competing postmaster. A postmaster
900  * cannot successfully attach to a data directory owned by a userid
901  * other than its own. (This is now checked directly in
902  * checkDataDir(), but has been true for a long time because of the
903  * restriction that the data directory isn't group- or
904  * world-accessible.) Also, since we create the lockfiles mode 600,
905  * we'd have failed above if the lockfile belonged to another userid
906  * --- which means that whatever process kill() is reporting about
907  * isn't the one that made the lockfile. (NOTE: this last
908  * consideration is the only one that keeps us from blowing away a
909  * Unix socket file belonging to an instance of Postgres being run by
910  * someone else, at least on machines where /tmp hasn't got a
911  * stickybit.)
912  */
913  if (other_pid != my_pid && other_pid != my_p_pid &&
914  other_pid != my_gp_pid)
915  {
916  if (kill(other_pid, 0) == 0 ||
917  (errno != ESRCH && errno != EPERM))
918  {
919  /* lockfile belongs to a live process */
920  ereport(FATAL,
921  (errcode(ERRCODE_LOCK_FILE_EXISTS),
922  errmsg("lock file \"%s\" already exists",
923  filename),
924  isDDLock ?
925  (encoded_pid < 0 ?
926  errhint("Is another postgres (PID %d) running in data directory \"%s\"?",
927  (int) other_pid, refName) :
928  errhint("Is another postmaster (PID %d) running in data directory \"%s\"?",
929  (int) other_pid, refName)) :
930  (encoded_pid < 0 ?
931  errhint("Is another postgres (PID %d) using socket file \"%s\"?",
932  (int) other_pid, refName) :
933  errhint("Is another postmaster (PID %d) using socket file \"%s\"?",
934  (int) other_pid, refName))));
935  }
936  }
937 
938  /*
939  * No, the creating process did not exist. However, it could be that
940  * the postmaster crashed (or more likely was kill -9'd by a clueless
941  * admin) but has left orphan backends behind. Check for this by
942  * looking to see if there is an associated shmem segment that is
943  * still in use.
944  *
945  * Note: because postmaster.pid is written in multiple steps, we might
946  * not find the shmem ID values in it; we can't treat that as an
947  * error.
948  */
949  if (isDDLock)
950  {
951  char *ptr = buffer;
952  unsigned long id1,
953  id2;
954  int lineno;
955 
956  for (lineno = 1; lineno < LOCK_FILE_LINE_SHMEM_KEY; lineno++)
957  {
958  if ((ptr = strchr(ptr, '\n')) == NULL)
959  break;
960  ptr++;
961  }
962 
963  if (ptr != NULL &&
964  sscanf(ptr, "%lu %lu", &id1, &id2) == 2)
965  {
966  if (PGSharedMemoryIsInUse(id1, id2))
967  ereport(FATAL,
968  (errcode(ERRCODE_LOCK_FILE_EXISTS),
969  errmsg("pre-existing shared memory block "
970  "(key %lu, ID %lu) is still in use",
971  id1, id2),
972  errhint("If you're sure there are no old "
973  "server processes still running, remove "
974  "the shared memory block "
975  "or just delete the file \"%s\".",
976  filename)));
977  }
978  }
979 
980  /*
981  * Looks like nobody's home. Unlink the file and try again to create
982  * it. Need a loop because of possible race condition against other
983  * would-be creators.
984  */
985  if (unlink(filename) < 0)
986  ereport(FATAL,
988  errmsg("could not remove old lock file \"%s\": %m",
989  filename),
990  errhint("The file seems accidentally left over, but "
991  "it could not be removed. Please remove the file "
992  "by hand and try again.")));
993  }
994 
995  /*
996  * Successfully created the file, now fill it. See comment in miscadmin.h
997  * about the contents. Note that we write the same first five lines into
998  * both datadir and socket lockfiles; although more stuff may get added to
999  * the datadir lockfile later.
1000  */
1001  snprintf(buffer, sizeof(buffer), "%d\n%s\n%ld\n%d\n%s\n",
1002  amPostmaster ? (int) my_pid : -((int) my_pid),
1003  DataDir,
1004  (long) MyStartTime,
1006  socketDir);
1007 
1008  /*
1009  * In a standalone backend, the next line (LOCK_FILE_LINE_LISTEN_ADDR)
1010  * will never receive data, so fill it in as empty now.
1011  */
1012  if (isDDLock && !amPostmaster)
1013  strlcat(buffer, "\n", sizeof(buffer));
1014 
1015  errno = 0;
1017  if (write(fd, buffer, strlen(buffer)) != strlen(buffer))
1018  {
1019  int save_errno = errno;
1020 
1021  close(fd);
1022  unlink(filename);
1023  /* if write didn't set errno, assume problem is no disk space */
1024  errno = save_errno ? save_errno : ENOSPC;
1025  ereport(FATAL,
1027  errmsg("could not write lock file \"%s\": %m", filename)));
1028  }
1030 
1032  if (pg_fsync(fd) != 0)
1033  {
1034  int save_errno = errno;
1035 
1036  close(fd);
1037  unlink(filename);
1038  errno = save_errno;
1039  ereport(FATAL,
1041  errmsg("could not write lock file \"%s\": %m", filename)));
1042  }
1044  if (close(fd) != 0)
1045  {
1046  int save_errno = errno;
1047 
1048  unlink(filename);
1049  errno = save_errno;
1050  ereport(FATAL,
1052  errmsg("could not write lock file \"%s\": %m", filename)));
1053  }
1054 
1055  /*
1056  * Arrange to unlink the lock file(s) at proc_exit. If this is the first
1057  * one, set up the on_proc_exit function to do it; then add this lock file
1058  * to the list of files to unlink.
1059  */
1060  if (lock_files == NIL)
1062 
1063  /*
1064  * Use lcons so that the lock files are unlinked in reverse order of
1065  * creation; this is critical!
1066  */
1068 }
#define NIL
Definition: pg_list.h:69
int errhint(const char *fmt,...)
Definition: elog.c:987
#define write(a, b, c)
Definition: win32.h:14
void on_proc_exit(pg_on_exit_callback function, Datum arg)
Definition: ipc.c:292
static List * lock_files
Definition: miscinit.c:60
#define LOCK_FILE_LINE_SHMEM_KEY
Definition: pidfile.h:42
char * pstrdup(const char *in)
Definition: mcxt.c:1076
pg_time_t MyStartTime
Definition: globals.c:40
int errcode(int sqlerrcode)
Definition: elog.c:575
int snprintf(char *str, size_t count, const char *fmt,...) pg_attribute_printf(3
static int fd(const char *x, int i)
Definition: preproc-init.c:105
int PostPortNumber
Definition: postmaster.c:194
#define FATAL
Definition: elog.h:52
#define MAXPGPATH
int errcode_for_file_access(void)
Definition: elog.c:598
static void pgstat_report_wait_end(void)
Definition: pgstat.h:1244
#define ereport(elevel, rest)
Definition: elog.h:122
List * lcons(void *datum, List *list)
Definition: list.c:259
WalTimeSample buffer[LAG_TRACKER_BUFFER_SIZE]
Definition: walsender.c:214
static void pgstat_report_wait_start(uint32 wait_event_info)
Definition: pgstat.h:1220
bool PGSharedMemoryIsInUse(unsigned long id1, unsigned long id2)
Definition: sysv_shmem.c:289
static void UnlinkLockFiles(int status, Datum arg)
Definition: miscinit.c:734
static char * filename
Definition: pg_dumpall.c:90
int errmsg(const char *fmt,...)
Definition: elog.c:797
char * DataDir
Definition: globals.c:60
int pg_fsync(int fd)
Definition: fd.c:338
#define elog
Definition: elog.h:219
#define close(a)
Definition: win32.h:12
#define read(a, b, c)
Definition: win32.h:13
size_t strlcat(char *dst, const char *src, size_t siz)
Definition: strlcat.c:33
void CreateSocketLockFile ( const char *  socketfile,
bool  amPostmaster,
const char *  socketDir 
)

Definition at line 1090 of file miscinit.c.

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

1092 {
1093  char lockfile[MAXPGPATH];
1094 
1095  snprintf(lockfile, sizeof(lockfile), "%s.lock", socketfile);
1096  CreateLockFile(lockfile, amPostmaster, socketDir, false, socketfile);
1097 }
int snprintf(char *str, size_t count, const char *fmt,...) pg_attribute_printf(3
static void CreateLockFile(const char *filename, bool amPostmaster, const char *socketDir, bool isDDLock, const char *refName)
Definition: miscinit.c:769
#define MAXPGPATH
Oid GetAuthenticatedUserId ( void  )

Definition at line 343 of file miscinit.c.

References AssertState, AuthenticatedUserId, and OidIsValid.

Referenced by InitializeParallelDSM().

344 {
346  return AuthenticatedUserId;
347 }
#define AssertState(condition)
Definition: c.h:684
#define OidIsValid(objectId)
Definition: c.h:532
static Oid AuthenticatedUserId
Definition: miscinit.c:156
Oid GetCurrentRoleId ( void  )

Definition at line 636 of file miscinit.c.

References InvalidOid, OuterUserId, and SetRoleIsActive.

Referenced by show_role().

637 {
638  if (SetRoleIsActive)
639  return OuterUserId;
640  else
641  return InvalidOid;
642 }
static Oid OuterUserId
Definition: miscinit.c:158
#define InvalidOid
Definition: postgres_ext.h:36
static bool SetRoleIsActive
Definition: miscinit.c:168
Oid GetOuterUserId ( void  )

Definition at line 295 of file miscinit.c.

References AssertState, OidIsValid, and OuterUserId.

Referenced by DropRole(), and RenameRole().

296 {
298  return OuterUserId;
299 }
#define AssertState(condition)
Definition: c.h:684
static Oid OuterUserId
Definition: miscinit.c:158
#define OidIsValid(objectId)
Definition: c.h:532
Oid GetSessionUserId ( void  )

Definition at line 318 of file miscinit.c.

References AssertState, OidIsValid, and SessionUserId.

Referenced by check_role(), DropRole(), get_rolespec_oid(), get_rolespec_tuple(), InitPostgres(), is_admin_of_role(), pgstat_bestart(), RenameRole(), and session_user().

319 {
321  return SessionUserId;
322 }
#define AssertState(condition)
Definition: c.h:684
static Oid SessionUserId
Definition: miscinit.c:157
#define OidIsValid(objectId)
Definition: c.h:532
Oid GetUserId ( void  )

Definition at line 284 of file miscinit.c.

References AssertState, CurrentUserId, and OidIsValid.

Referenced by AddRoleMems(), AggregateCreate(), AlterCollation(), AlterDatabase(), AlterDatabaseOwner(), AlterDatabaseSet(), AlterEventTrigger(), AlterEventTriggerOwner_internal(), AlterExtensionNamespace(), AlterForeignServer(), AlterForeignServerOwner_internal(), AlterFunction(), AlterObjectNamespace_internal(), AlterObjectOwner_internal(), AlterObjectRename_internal(), AlterOperator(), AlterOpFamilyAdd(), AlterPublication(), AlterPublicationOwner_internal(), AlterRole(), AlterRoleSet(), AlterSchemaOwner_internal(), AlterSubscription(), AlterSubscriptionOwner_internal(), AlterTableMoveAll(), AlterTableSpaceOptions(), AlterTSConfiguration(), AlterTSDictionary(), AlterTypeNamespace_oid(), AlterTypeOwner(), analyze_rel(), ATExecAddColumn(), ATExecChangeOwner(), ATPrepAlterColumnType(), ATPrepSetStatistics(), ATPrepSetTableSpace(), ATSimplePermissions(), be_lo_put(), be_lo_unlink(), binary_upgrade_create_empty_extension(), brin_desummarize_range(), brin_summarize_range(), BuildCachedPlan(), BuildDescForRelation(), BuildIndexValueDescription(), calculate_database_size(), calculate_tablespace_size(), call_pltcl_start_proc(), check_enable_rls(), check_permissions(), check_temp_tablespaces(), CheckCachedPlan(), checkDomainOwner(), checkEnumOwner(), checkFkeyPermissions(), CheckFunctionValidatorAccess(), CheckMyDatabase(), cluster_rel(), CommentObject(), compile_plperl_function(), compile_pltcl_function(), CompleteCachedPlan(), compute_return_type(), CreateCast(), CreateConversionCommand(), createdb(), CreateEventTrigger(), CreateExtensionInternal(), CreateForeignDataWrapper(), CreateForeignServer(), CreateForeignTable(), CreateFunction(), CreateOpFamily(), CreateProceduralLanguage(), CreatePublication(), CreateRole(), CreateStatistics(), CreateSubscription(), CreateTableSpace(), CreateTransform(), CreateTrigger(), current_user(), currtid_byrelname(), currtid_byreloid(), currval_oid(), DefineAggregate(), DefineCollation(), DefineDomain(), DefineEnum(), DefineIndex(), DefineOpClass(), DefineOperator(), DefineOpFamily(), DefineQueryRewrite(), DefineRange(), DefineRelation(), DefineTSConfiguration(), DefineTSDictionary(), DefineType(), DelRoleMems(), do_setval(), dropdb(), DropOwnedObjects(), DropRole(), DropSubscription(), DropTableSpace(), EnableDisableRule(), examine_simple_variable(), examine_variable(), ExecAlterDefaultPrivilegesStmt(), ExecAlterExtensionContentsStmt(), ExecAlterExtensionStmt(), ExecBuildSlotPartitionKeyDescription(), ExecBuildSlotValueDescription(), ExecCheckRTEPerms(), ExecGrant_Attribute(), ExecGrant_Database(), ExecGrant_Fdw(), ExecGrant_ForeignServer(), ExecGrant_Function(), ExecGrant_Language(), ExecGrant_Largeobject(), ExecGrant_Namespace(), ExecGrant_Relation(), ExecGrant_Tablespace(), ExecGrant_Type(), ExecInitAgg(), ExecInitExprRec(), ExecInitFunc(), ExecInitWindowAgg(), ExecSecLabelStmt(), ExecuteDoStmt(), ExecuteTruncate(), findRangeCanonicalFunction(), findRangeSubtypeDiffFunction(), FinishPreparedTransaction(), get_connect_string(), get_other_operator(), get_rel_from_relname(), get_rolespec_oid(), get_rolespec_tuple(), get_row_security_policies(), get_tables_to_cluster(), GetConfigOption(), GetConfigOptionByName(), GetConfigOptionByNum(), GetConfigOptionResetString(), 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_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(), ImportForeignSchema(), init_sexpr(), InitializeSearchPath(), InitPostgres(), InitTempTableNamespace(), inline_function(), inline_set_returning_function(), insert_username(), interpret_function_parameter_list(), inv_create(), LargeObjectCreate(), lastval(), lo_get_fragment_internal(), lo_read(), lo_truncate_internal(), lo_write(), LockTableAclCheck(), lookup_agg_function(), LookupCreationNamespace(), LookupExplicitNamespace(), MergeAttributes(), movedb(), nextval_internal(), OperatorCreate(), OperatorShellMake(), 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_activity(), pg_stat_get_backend_activity(), pg_stat_get_backend_activity_start(), pg_stat_get_backend_client_addr(), pg_stat_get_backend_client_port(), pg_stat_get_backend_start(), pg_stat_get_backend_wait_event(), pg_stat_get_backend_wait_event_type(), pg_stat_get_backend_xact_start(), pg_stat_get_progress_info(), pg_stat_get_wal_receiver(), pg_stat_statements_internal(), pgrowlocks(), pgss_store(), pgstat_get_backend_current_activity(), pltcl_fetch_interp(), postgresBeginDirectModify(), postgresBeginForeignModify(), postgresBeginForeignScan(), postgresGetForeignRelSize(), postgresImportForeignSchema(), PrepareTempTablespaces(), PrepareTransaction(), PublicationAddTables(), RangeVarCallbackForAlterRelation(), RangeVarCallbackForDropRelation(), RangeVarCallbackForPolicy(), RangeVarCallbackForReindexIndex(), RangeVarCallbackForRenameRule(), RangeVarCallbackForRenameTrigger(), RangeVarCallbackOwnsRelation(), RangeVarCallbackOwnsTable(), RangeVarGetAndCheckCreationNamespace(), ReassignOwnedObjects(), recomputeNamespacePath(), ReindexMultipleTables(), RemoveObjects(), RemoveRoleFromObjectPolicy(), renameatt_check(), RenameDatabase(), RenameSchema(), RenameTableSpace(), RenameType(), RevalidateCachedQuery(), RI_Initial_Check(), ri_ReportViolation(), select_perl_context(), set_foreign_rel_properties(), superuser(), timetravel(), transformTableLikeClause(), truncate_check_rel(), user_mapping_ddl_aclcheck(), vacuum_rel(), ValidateJoinEstimator(), and ValidateRestrictionEstimator().

285 {
287  return CurrentUserId;
288 }
#define AssertState(condition)
Definition: c.h:684
#define OidIsValid(objectId)
Definition: c.h:532
static Oid CurrentUserId
Definition: miscinit.c:159
void GetUserIdAndContext ( Oid userid,
bool sec_def_context 
)

Definition at line 438 of file miscinit.c.

References CurrentUserId, and InLocalUserIdChange().

439 {
440  *userid = CurrentUserId;
441  *sec_def_context = InLocalUserIdChange();
442 }
bool InLocalUserIdChange(void)
Definition: miscinit.c:407
static Oid CurrentUserId
Definition: miscinit.c:159
void GetUserIdAndSecContext ( Oid userid,
int *  sec_context 
)
char* GetUserNameFromId ( Oid  roleid,
bool  noerr 
)

Definition at line 692 of file miscinit.c.

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

Referenced by check_is_member_of_role(), current_user(), getObjectDescription(), getObjectIdentityParts(), insert_username(), regroleout(), RemoveRoleFromObjectPolicy(), session_user(), and timetravel().

693 {
694  HeapTuple tuple;
695  char *result;
696 
697  tuple = SearchSysCache1(AUTHOID, ObjectIdGetDatum(roleid));
698  if (!HeapTupleIsValid(tuple))
699  {
700  if (!noerr)
701  ereport(ERROR,
702  (errcode(ERRCODE_UNDEFINED_OBJECT),
703  errmsg("invalid role OID: %u", roleid)));
704  result = NULL;
705  }
706  else
707  {
708  result = pstrdup(NameStr(((Form_pg_authid) GETSTRUCT(tuple))->rolname));
709  ReleaseSysCache(tuple);
710  }
711  return result;
712 }
#define GETSTRUCT(TUP)
Definition: htup_details.h:656
char * pstrdup(const char *in)
Definition: mcxt.c:1076
int errcode(int sqlerrcode)
Definition: elog.c:575
FormData_pg_authid * Form_pg_authid
Definition: pg_authid.h:72
#define ObjectIdGetDatum(X)
Definition: postgres.h:513
#define ERROR
Definition: elog.h:43
#define ereport(elevel, rest)
Definition: elog.h:122
HeapTuple SearchSysCache1(int cacheId, Datum key1)
Definition: syscache.c:1112
void ReleaseSysCache(HeapTuple tuple)
Definition: syscache.c:1160
#define HeapTupleIsValid(tuple)
Definition: htup.h:77
int errmsg(const char *fmt,...)
Definition: elog.c:797
#define NameStr(name)
Definition: c.h:493
bool has_rolreplication ( Oid  roleid)

Definition at line 465 of file miscinit.c.

References AUTHOID, GETSTRUCT, HeapTupleIsValid, ObjectIdGetDatum, ReleaseSysCache(), and SearchSysCache1().

Referenced by check_permissions(), and InitPostgres().

466 {
467  bool result = false;
468  HeapTuple utup;
469 
470  utup = SearchSysCache1(AUTHOID, ObjectIdGetDatum(roleid));
471  if (HeapTupleIsValid(utup))
472  {
473  result = ((Form_pg_authid) GETSTRUCT(utup))->rolreplication;
474  ReleaseSysCache(utup);
475  }
476  return result;
477 }
#define GETSTRUCT(TUP)
Definition: htup_details.h:656
FormData_pg_authid * Form_pg_authid
Definition: pg_authid.h:72
#define ObjectIdGetDatum(X)
Definition: postgres.h:513
HeapTuple SearchSysCache1(int cacheId, Datum key1)
Definition: syscache.c:1112
void ReleaseSysCache(HeapTuple tuple)
Definition: syscache.c:1160
#define HeapTupleIsValid(tuple)
Definition: htup.h:77
void InitializeSessionUserId ( const char *  rolename,
Oid  roleid 
)

Definition at line 483 of file miscinit.c.

References AssertState, AuthenticatedUserId, AuthenticatedUserIsSuperuser, AUTHNAME, AUTHOID, CountUserBackends(), ereport, errcode(), errmsg(), FATAL, GETSTRUCT, HeapTupleGetOid, HeapTupleIsValid, IsBootstrapProcessingMode, IsUnderPostmaster, MyProc, NameStr, ObjectIdGetDatum, OidIsValid, PGC_BACKEND, PGC_INTERNAL, PGC_S_OVERRIDE, PointerGetDatum, ReleaseSysCache(), PGPROC::roleId, SearchSysCache1(), SetConfigOption(), and SetSessionUserId().

Referenced by InitPostgres().

484 {
485  HeapTuple roleTup;
486  Form_pg_authid rform;
487  char *rname;
488 
489  /*
490  * Don't do scans if we're bootstrapping, none of the system catalogs
491  * exist yet, and they should be owned by postgres anyway.
492  */
494 
495  /* call only once */
497 
498  if (rolename != NULL)
499  {
500  roleTup = SearchSysCache1(AUTHNAME, PointerGetDatum(rolename));
501  if (!HeapTupleIsValid(roleTup))
502  ereport(FATAL,
503  (errcode(ERRCODE_INVALID_AUTHORIZATION_SPECIFICATION),
504  errmsg("role \"%s\" does not exist", rolename)));
505  }
506  else
507  {
508  roleTup = SearchSysCache1(AUTHOID, ObjectIdGetDatum(roleid));
509  if (!HeapTupleIsValid(roleTup))
510  ereport(FATAL,
511  (errcode(ERRCODE_INVALID_AUTHORIZATION_SPECIFICATION),
512  errmsg("role with OID %u does not exist", roleid)));
513  }
514 
515  rform = (Form_pg_authid) GETSTRUCT(roleTup);
516  roleid = HeapTupleGetOid(roleTup);
517  rname = NameStr(rform->rolname);
518 
519  AuthenticatedUserId = roleid;
520  AuthenticatedUserIsSuperuser = rform->rolsuper;
521 
522  /* This sets OuterUserId/CurrentUserId too */
524 
525  /* Also mark our PGPROC entry with the authenticated user id */
526  /* (We assume this is an atomic store so no lock is needed) */
527  MyProc->roleId = roleid;
528 
529  /*
530  * These next checks are not enforced when in standalone mode, so that
531  * there is a way to recover from sillinesses like "UPDATE pg_authid SET
532  * rolcanlogin = false;".
533  */
534  if (IsUnderPostmaster)
535  {
536  /*
537  * Is role allowed to login at all?
538  */
539  if (!rform->rolcanlogin)
540  ereport(FATAL,
541  (errcode(ERRCODE_INVALID_AUTHORIZATION_SPECIFICATION),
542  errmsg("role \"%s\" is not permitted to log in",
543  rname)));
544 
545  /*
546  * Check connection limit for this role.
547  *
548  * There is a race condition here --- we create our PGPROC before
549  * checking for other PGPROCs. If two backends did this at about the
550  * same time, they might both think they were over the limit, while
551  * ideally one should succeed and one fail. Getting that to work
552  * exactly seems more trouble than it is worth, however; instead we
553  * just document that the connection limit is approximate.
554  */
555  if (rform->rolconnlimit >= 0 &&
557  CountUserBackends(roleid) > rform->rolconnlimit)
558  ereport(FATAL,
559  (errcode(ERRCODE_TOO_MANY_CONNECTIONS),
560  errmsg("too many connections for role \"%s\"",
561  rname)));
562  }
563 
564  /* Record username and superuser status as GUC settings too */
565  SetConfigOption("session_authorization", rname,
567  SetConfigOption("is_superuser",
568  AuthenticatedUserIsSuperuser ? "on" : "off",
570 
571  ReleaseSysCache(roleTup);
572 }
#define GETSTRUCT(TUP)
Definition: htup_details.h:656
#define AssertState(condition)
Definition: c.h:684
PGPROC * MyProc
Definition: proc.c:67
#define PointerGetDatum(X)
Definition: postgres.h:562
Oid roleId
Definition: proc.h:115
int errcode(int sqlerrcode)
Definition: elog.c:575
#define OidIsValid(objectId)
Definition: c.h:532
FormData_pg_authid * Form_pg_authid
Definition: pg_authid.h:72
#define ObjectIdGetDatum(X)
Definition: postgres.h:513
#define FATAL
Definition: elog.h:52
void SetConfigOption(const char *name, const char *value, GucContext context, GucSource source)
Definition: guc.c:6681
bool IsUnderPostmaster
Definition: globals.c:101
static bool AuthenticatedUserIsSuperuser
Definition: miscinit.c:162
#define ereport(elevel, rest)
Definition: elog.h:122
HeapTuple SearchSysCache1(int cacheId, Datum key1)
Definition: syscache.c:1112
void ReleaseSysCache(HeapTuple tuple)
Definition: syscache.c:1160
#define HeapTupleIsValid(tuple)
Definition: htup.h:77
int CountUserBackends(Oid roleid)
Definition: procarray.c:2840
#define IsBootstrapProcessingMode()
Definition: miscadmin.h:367
int errmsg(const char *fmt,...)
Definition: elog.c:797
#define NameStr(name)
Definition: c.h:493
#define HeapTupleGetOid(tuple)
Definition: htup_details.h:695
static void SetSessionUserId(Oid userid, bool is_superuser)
Definition: miscinit.c:326
static Oid AuthenticatedUserId
Definition: miscinit.c:156
void InitializeSessionUserIdStandalone ( void  )

Definition at line 579 of file miscinit.c.

References AssertState, AuthenticatedUserId, AuthenticatedUserIsSuperuser, BOOTSTRAP_SUPERUSERID, IsAutoVacuumWorkerProcess(), IsBackgroundWorker, IsUnderPostmaster, OidIsValid, and SetSessionUserId().

Referenced by InitPostgres().

580 {
581  /*
582  * This function should only be called in single-user mode, in autovacuum
583  * workers, and in background workers.
584  */
586 
587  /* call only once */
589 
592 
594 }
#define AssertState(condition)
Definition: c.h:684
#define OidIsValid(objectId)
Definition: c.h:532
bool IsBackgroundWorker
Definition: globals.c:103
bool IsUnderPostmaster
Definition: globals.c:101
static bool AuthenticatedUserIsSuperuser
Definition: miscinit.c:162
bool IsAutoVacuumWorkerProcess(void)
Definition: autovacuum.c:3256
#define BOOTSTRAP_SUPERUSERID
Definition: pg_authid.h:102
static void SetSessionUserId(Oid userid, bool is_superuser)
Definition: miscinit.c:326
static Oid AuthenticatedUserId
Definition: miscinit.c:156
void InitPostmasterChild ( void  )

Definition at line 176 of file miscinit.c.

References elog, FATAL, InitializeLatchSupport(), InitLatch(), IsUnderPostmaster, LocalLatchData, MyLatch, MyProcPid, MyStartTime, and on_exit_reset().

Referenced by BackendStartup(), do_start_bgworker(), pgarch_start(), pgstat_start(), StartAutoVacLauncher(), StartAutoVacWorker(), StartChildProcess(), and SysLogger_Start().

177 {
178  IsUnderPostmaster = true; /* we are a postmaster subprocess now */
179 
180  MyProcPid = getpid(); /* reset MyProcPid */
181 
182  MyStartTime = time(NULL); /* set our start time in case we call elog */
183 
184  /*
185  * make sure stderr is in binary mode before anything can possibly be
186  * written to it, in case it's actually the syslogger pipe, so the pipe
187  * chunking protocol isn't disturbed. Non-logpipe data gets translated on
188  * redirection (e.g. via pg_ctl -l) anyway.
189  */
190 #ifdef WIN32
191  _setmode(fileno(stderr), _O_BINARY);
192 #endif
193 
194  /* We don't want the postmaster's proc_exit() handlers */
195  on_exit_reset();
196 
197  /* Initialize process-local latch support */
201 
202  /*
203  * If possible, make this process a group leader, so that the postmaster
204  * can signal any child processes too. Not all processes will have
205  * children, but for consistency we make all postmaster child processes do
206  * this.
207  */
208 #ifdef HAVE_SETSID
209  if (setsid() < 0)
210  elog(FATAL, "setsid() failed: %m");
211 #endif
212 }
int MyProcPid
Definition: globals.c:39
pg_time_t MyStartTime
Definition: globals.c:40
void on_exit_reset(void)
Definition: ipc.c:396
static Latch LocalLatchData
Definition: miscinit.c:62
#define FATAL
Definition: elog.h:52
bool IsUnderPostmaster
Definition: globals.c:101
void InitializeLatchSupport(void)
Definition: latch.c:147
void InitLatch(volatile Latch *latch)
Definition: latch.c:220
struct Latch * MyLatch
Definition: globals.c:52
#define elog
Definition: elog.h:219
void InitStandaloneProcess ( const char *  argv0)

Definition at line 220 of file miscinit.c.

References Assert, elog, FATAL, find_my_exec(), get_pkglib_path(), InitializeLatchSupport(), InitLatch(), IsPostmasterEnvironment, LocalLatchData, my_exec_path, MyLatch, MyProcPid, MyStartTime, and pkglib_path.

Referenced by AuxiliaryProcessMain(), and PostgresMain().

221 {
223 
224  MyProcPid = getpid(); /* reset MyProcPid */
225 
226  MyStartTime = time(NULL); /* set our start time in case we call elog */
227 
228  /* Initialize process-local latch support */
232 
233  /* Compute paths, no postmaster to inherit from */
234  if (my_exec_path[0] == '\0')
235  {
236  if (find_my_exec(argv0, my_exec_path) < 0)
237  elog(FATAL, "%s: could not locate my own executable path",
238  argv0);
239  }
240 
241  if (pkglib_path[0] == '\0')
243 }
bool IsPostmasterEnvironment
Definition: globals.c:100
static char * argv0
Definition: pg_ctl.c:101
int MyProcPid
Definition: globals.c:39
pg_time_t MyStartTime
Definition: globals.c:40
void get_pkglib_path(const char *my_exec_path, char *ret_path)
Definition: path.c:758
static Latch LocalLatchData
Definition: miscinit.c:62
#define FATAL
Definition: elog.h:52
int find_my_exec(const char *argv0, char *retpath)
Definition: exec.c:119
char my_exec_path[MAXPGPATH]
Definition: globals.c:64
void InitializeLatchSupport(void)
Definition: latch.c:147
#define Assert(condition)
Definition: c.h:681
void InitLatch(volatile Latch *latch)
Definition: latch.c:220
struct Latch * MyLatch
Definition: globals.c:52
#define elog
Definition: elog.h:219
char pkglib_path[MAXPGPATH]
Definition: globals.c:65
bool InLocalUserIdChange ( void  )

Definition at line 407 of file miscinit.c.

References SECURITY_LOCAL_USERID_CHANGE, and SecurityRestrictionContext.

Referenced by GetUserIdAndContext(), is_admin_of_role(), and set_config_option().

408 {
410 }
static int SecurityRestrictionContext
Definition: miscinit.c:165
#define SECURITY_LOCAL_USERID_CHANGE
Definition: miscadmin.h:293
bool InNoForceRLSOperation ( void  )

Definition at line 425 of file miscinit.c.

References SECURITY_NOFORCE_RLS, and SecurityRestrictionContext.

Referenced by check_enable_rls().

426 {
428 }
static int SecurityRestrictionContext
Definition: miscinit.c:165
#define SECURITY_NOFORCE_RLS
Definition: miscadmin.h:295
bool InSecurityRestrictedOperation ( void  )

Definition at line 416 of file miscinit.c.

References SECURITY_RESTRICTED_OPERATION, and SecurityRestrictionContext.

Referenced by CheckRestrictedOperation(), DefineRelation(), is_admin_of_role(), set_config_option(), and SetUserIdAndContext().

417 {
419 }
#define SECURITY_RESTRICTED_OPERATION
Definition: miscadmin.h:294
static int SecurityRestrictionContext
Definition: miscinit.c:165
static void load_libraries ( const char *  libraries,
const char *  gucname,
bool  restricted 
)
static

Definition at line 1435 of file miscinit.c.

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

Referenced by process_session_preload_libraries(), and process_shared_preload_libraries().

1436 {
1437  char *rawstring;
1438  List *elemlist;
1439  ListCell *l;
1440 
1441  if (libraries == NULL || libraries[0] == '\0')
1442  return; /* nothing to do */
1443 
1444  /* Need a modifiable copy of string */
1445  rawstring = pstrdup(libraries);
1446 
1447  /* Parse string into list of filename paths */
1448  if (!SplitDirectoriesString(rawstring, ',', &elemlist))
1449  {
1450  /* syntax error in list */
1451  list_free_deep(elemlist);
1452  pfree(rawstring);
1453  ereport(LOG,
1454  (errcode(ERRCODE_SYNTAX_ERROR),
1455  errmsg("invalid list syntax in parameter \"%s\"",
1456  gucname)));
1457  return;
1458  }
1459 
1460  foreach(l, elemlist)
1461  {
1462  /* Note that filename was already canonicalized */
1463  char *filename = (char *) lfirst(l);
1464  char *expanded = NULL;
1465 
1466  /* If restricting, insert $libdir/plugins if not mentioned already */
1467  if (restricted && first_dir_separator(filename) == NULL)
1468  {
1469  expanded = psprintf("$libdir/plugins/%s", filename);
1470  filename = expanded;
1471  }
1472  load_file(filename, restricted);
1473  ereport(DEBUG1,
1474  (errmsg("loaded library \"%s\"", filename)));
1475  if (expanded)
1476  pfree(expanded);
1477  }
1478 
1479  list_free_deep(elemlist);
1480  pfree(rawstring);
1481 }
#define DEBUG1
Definition: elog.h:25
char * pstrdup(const char *in)
Definition: mcxt.c:1076
char * psprintf(const char *fmt,...)
Definition: psprintf.c:46
int errcode(int sqlerrcode)
Definition: elog.c:575
#define LOG
Definition: elog.h:26
void list_free_deep(List *list)
Definition: list.c:1147
bool SplitDirectoriesString(char *rawstring, char separator, List **namelist)
Definition: varlena.c:3391
void pfree(void *pointer)
Definition: mcxt.c:949
#define ereport(elevel, rest)
Definition: elog.h:122
char * first_dir_separator(const char *filename)
Definition: path.c:103
#define lfirst(lc)
Definition: pg_list.h:106
void load_file(const char *filename, bool restricted)
Definition: dfmgr.c:137
static char * filename
Definition: pg_dumpall.c:90
int errmsg(const char *fmt,...)
Definition: elog.c:797
Definition: pg_list.h:45
void pg_bindtextdomain ( const char *  domain)

Definition at line 1511 of file miscinit.c.

References get_locale_path(), MAXPGPATH, and my_exec_path.

Referenced by _PG_init().

1512 {
1513 #ifdef ENABLE_NLS
1514  if (my_exec_path[0] != '\0')
1515  {
1516  char locale_path[MAXPGPATH];
1517 
1518  get_locale_path(my_exec_path, locale_path);
1519  bindtextdomain(domain, locale_path);
1520  pg_bind_textdomain_codeset(domain);
1521  }
1522 #endif
1523 }
#define MAXPGPATH
char my_exec_path[MAXPGPATH]
Definition: globals.c:64
void get_locale_path(const char *my_exec_path, char *ret_path)
Definition: path.c:767
void process_session_preload_libraries ( void  )

Definition at line 1500 of file miscinit.c.

References load_libraries(), local_preload_libraries_string, and session_preload_libraries_string.

Referenced by PostgresMain().

1501 {
1503  "session_preload_libraries",
1504  false);
1506  "local_preload_libraries",
1507  true);
1508 }
static void load_libraries(const char *libraries, const char *gucname, bool restricted)
Definition: miscinit.c:1435
char * local_preload_libraries_string
Definition: miscinit.c:1423
char * session_preload_libraries_string
Definition: miscinit.c:1421
void process_shared_preload_libraries ( void  )

Definition at line 1487 of file miscinit.c.

References load_libraries(), process_shared_preload_libraries_in_progress, and shared_preload_libraries_string.

Referenced by PostmasterMain().

1488 {
1491  "shared_preload_libraries",
1492  false);
1494 }
bool process_shared_preload_libraries_in_progress
Definition: miscinit.c:1426
char * shared_preload_libraries_string
Definition: miscinit.c:1422
static void load_libraries(const char *libraries, const char *gucname, bool restricted)
Definition: miscinit.c:1435
bool RecheckDataDirLockFile ( void  )

Definition at line 1286 of file miscinit.c.

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

Referenced by ServerLoop().

1287 {
1288  int fd;
1289  int len;
1290  long file_pid;
1291  char buffer[BLCKSZ];
1292 
1293  fd = open(DIRECTORY_LOCK_FILE, O_RDWR | PG_BINARY, 0);
1294  if (fd < 0)
1295  {
1296  /*
1297  * There are many foreseeable false-positive error conditions. For
1298  * safety, fail only on enumerated clearly-something-is-wrong
1299  * conditions.
1300  */
1301  switch (errno)
1302  {
1303  case ENOENT:
1304  case ENOTDIR:
1305  /* disaster */
1306  ereport(LOG,
1308  errmsg("could not open file \"%s\": %m",
1310  return false;
1311  default:
1312  /* non-fatal, at least for now */
1313  ereport(LOG,
1315  errmsg("could not open file \"%s\": %m; continuing anyway",
1317  return true;
1318  }
1319  }
1321  len = read(fd, buffer, sizeof(buffer) - 1);
1323  if (len < 0)
1324  {
1325  ereport(LOG,
1327  errmsg("could not read from file \"%s\": %m",
1329  close(fd);
1330  return true; /* treat read failure as nonfatal */
1331  }
1332  buffer[len] = '\0';
1333  close(fd);
1334  file_pid = atol(buffer);
1335  if (file_pid == getpid())
1336  return true; /* all is well */
1337 
1338  /* Trouble: someone's overwritten the lock file */
1339  ereport(LOG,
1340  (errmsg("lock file \"%s\" contains wrong PID: %ld instead of %ld",
1341  DIRECTORY_LOCK_FILE, file_pid, (long) getpid())));
1342  return false;
1343 }
#define DIRECTORY_LOCK_FILE
Definition: miscinit.c:55
#define LOG
Definition: elog.h:26
static int fd(const char *x, int i)
Definition: preproc-init.c:105
#define PG_BINARY
Definition: c.h:1044
int errcode_for_file_access(void)
Definition: elog.c:598
static void pgstat_report_wait_end(void)
Definition: pgstat.h:1244
#define ereport(elevel, rest)
Definition: elog.h:122
WalTimeSample buffer[LAG_TRACKER_BUFFER_SIZE]
Definition: walsender.c:214
static void pgstat_report_wait_start(uint32 wait_event_info)
Definition: pgstat.h:1220
int errmsg(const char *fmt,...)
Definition: elog.c:797
#define close(a)
Definition: win32.h:12
#define read(a, b, c)
Definition: win32.h:13
void SetCurrentRoleId ( Oid  roleid,
bool  is_superuser 
)

Definition at line 657 of file miscinit.c.

References OidIsValid, PGC_INTERNAL, PGC_S_OVERRIDE, SessionUserId, SessionUserIsSuperuser, SetConfigOption(), SetOuterUserId(), and SetRoleIsActive.

Referenced by assign_role().

658 {
659  /*
660  * Get correct info if it's SET ROLE NONE
661  *
662  * If SessionUserId hasn't been set yet, just do nothing --- the eventual
663  * SetSessionUserId call will fix everything. This is needed since we
664  * will get called during GUC initialization.
665  */
666  if (!OidIsValid(roleid))
667  {
669  return;
670 
671  roleid = SessionUserId;
673 
674  SetRoleIsActive = false;
675  }
676  else
677  SetRoleIsActive = true;
678 
679  SetOuterUserId(roleid);
680 
681  SetConfigOption("is_superuser",
682  is_superuser ? "on" : "off",
684 }
static Oid SessionUserId
Definition: miscinit.c:157
static void SetOuterUserId(Oid userid)
Definition: miscinit.c:303
#define OidIsValid(objectId)
Definition: c.h:532
void SetConfigOption(const char *name, const char *value, GucContext context, GucSource source)
Definition: guc.c:6681
static bool SetRoleIsActive
Definition: miscinit.c:168
static bool SessionUserIsSuperuser
Definition: miscinit.c:163
static bool is_superuser(Archive *fout)
Definition: pg_dump.c:3748
void SetDatabasePath ( const char *  path)

Definition at line 83 of file miscinit.c.

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

Referenced by InitPostgres().

84 {
85  /* This should happen only once per process */
88 }
MemoryContext TopMemoryContext
Definition: mcxt.c:43
char * DatabasePath
Definition: globals.c:85
#define Assert(condition)
Definition: c.h:681
char * MemoryContextStrdup(MemoryContext context, const char *string)
Definition: mcxt.c:1063
void SetDataDir ( const char *  dir)

Definition at line 95 of file miscinit.c.

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

Referenced by SelectConfigFiles().

96 {
97  char *new;
98 
99  AssertArg(dir);
100 
101  /* If presented path is relative, convert to absolute */
102  new = make_absolute_path(dir);
103 
104  if (DataDir)
105  free(DataDir);
106  DataDir = new;
107 }
char * make_absolute_path(const char *path)
Definition: path.c:608
#define AssertArg(condition)
Definition: c.h:683
#define free(a)
Definition: header.h:65
char * DataDir
Definition: globals.c:60
static void SetOuterUserId ( Oid  userid)
static

Definition at line 303 of file miscinit.c.

References AssertArg, AssertState, CurrentUserId, OidIsValid, OuterUserId, and SecurityRestrictionContext.

Referenced by SetCurrentRoleId().

304 {
306  AssertArg(OidIsValid(userid));
307  OuterUserId = userid;
308 
309  /* We force the effective user ID to match, too */
310  CurrentUserId = userid;
311 }
#define AssertState(condition)
Definition: c.h:684
static Oid OuterUserId
Definition: miscinit.c:158
#define OidIsValid(objectId)
Definition: c.h:532
static int SecurityRestrictionContext
Definition: miscinit.c:165
#define AssertArg(condition)
Definition: c.h:683
static Oid CurrentUserId
Definition: miscinit.c:159
void SetSessionAuthorization ( Oid  userid,
bool  is_superuser 
)

Definition at line 611 of file miscinit.c.

References AssertState, AuthenticatedUserId, AuthenticatedUserIsSuperuser, ereport, errcode(), errmsg(), ERROR, OidIsValid, PGC_INTERNAL, PGC_S_OVERRIDE, SetConfigOption(), and SetSessionUserId().

Referenced by assign_session_authorization().

612 {
613  /* Must have authenticated already, else can't make permission check */
615 
616  if (userid != AuthenticatedUserId &&
618  ereport(ERROR,
619  (errcode(ERRCODE_INSUFFICIENT_PRIVILEGE),
620  errmsg("permission denied to set session authorization")));
621 
623 
624  SetConfigOption("is_superuser",
625  is_superuser ? "on" : "off",
627 }
#define AssertState(condition)
Definition: c.h:684
int errcode(int sqlerrcode)
Definition: elog.c:575
#define OidIsValid(objectId)
Definition: c.h:532
#define ERROR
Definition: elog.h:43
void SetConfigOption(const char *name, const char *value, GucContext context, GucSource source)
Definition: guc.c:6681
static bool AuthenticatedUserIsSuperuser
Definition: miscinit.c:162
#define ereport(elevel, rest)
Definition: elog.h:122
static bool is_superuser(Archive *fout)
Definition: pg_dump.c:3748
int errmsg(const char *fmt,...)
Definition: elog.c:797
static void SetSessionUserId(Oid userid, bool is_superuser)
Definition: miscinit.c:326
static Oid AuthenticatedUserId
Definition: miscinit.c:156
static void SetSessionUserId ( Oid  userid,
bool  is_superuser 
)
static

Definition at line 326 of file miscinit.c.

References AssertArg, AssertState, CurrentUserId, is_superuser(), OidIsValid, OuterUserId, SecurityRestrictionContext, SessionUserId, SessionUserIsSuperuser, and SetRoleIsActive.

Referenced by InitializeSessionUserId(), InitializeSessionUserIdStandalone(), and SetSessionAuthorization().

327 {
329  AssertArg(OidIsValid(userid));
330  SessionUserId = userid;
332  SetRoleIsActive = false;
333 
334  /* We force the effective user IDs to match, too */
335  OuterUserId = userid;
336  CurrentUserId = userid;
337 }
#define AssertState(condition)
Definition: c.h:684
static Oid SessionUserId
Definition: miscinit.c:157
static Oid OuterUserId
Definition: miscinit.c:158
#define OidIsValid(objectId)
Definition: c.h:532
static int SecurityRestrictionContext
Definition: miscinit.c:165
#define AssertArg(condition)
Definition: c.h:683
static bool SetRoleIsActive
Definition: miscinit.c:168
static bool SessionUserIsSuperuser
Definition: miscinit.c:163
static Oid CurrentUserId
Definition: miscinit.c:159
static bool is_superuser(Archive *fout)
Definition: pg_dump.c:3748
void SetUserIdAndContext ( Oid  userid,
bool  sec_def_context 
)

Definition at line 445 of file miscinit.c.

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

446 {
447  /* We throw the same error SET ROLE would. */
449  ereport(ERROR,
450  (errcode(ERRCODE_INSUFFICIENT_PRIVILEGE),
451  errmsg("cannot set parameter \"%s\" within security-restricted operation",
452  "role")));
453  CurrentUserId = userid;
454  if (sec_def_context)
456  else
458 }
int errcode(int sqlerrcode)
Definition: elog.c:575
#define ERROR
Definition: elog.h:43
static int SecurityRestrictionContext
Definition: miscinit.c:165
#define ereport(elevel, rest)
Definition: elog.h:122
#define SECURITY_LOCAL_USERID_CHANGE
Definition: miscadmin.h:293
static Oid CurrentUserId
Definition: miscinit.c:159
bool InSecurityRestrictedOperation(void)
Definition: miscinit.c:416
int errmsg(const char *fmt,...)
Definition: elog.c:797
void SetUserIdAndSecContext ( Oid  userid,
int  sec_context 
)
void SwitchBackToLocalLatch ( void  )

Definition at line 265 of file miscinit.c.

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

Referenced by AuxiliaryProcKill(), and ProcKill().

266 {
268  Assert(MyProc != NULL && MyLatch == &MyProc->procLatch);
269 
271 
272  if (FeBeWaitSet)
274 
275  SetLatch(MyLatch);
276 }
PGPROC * MyProc
Definition: proc.c:67
void ModifyWaitEvent(WaitEventSet *set, int pos, uint32 events, Latch *latch)
Definition: latch.c:736
WaitEventSet * FeBeWaitSet
Definition: pqcomm.c:186
Latch procLatch
Definition: proc.h:104
static Latch LocalLatchData
Definition: miscinit.c:62
void SetLatch(volatile Latch *latch)
Definition: latch.c:414
#define Assert(condition)
Definition: c.h:681
struct Latch * MyLatch
Definition: globals.c:52
#define WL_LATCH_SET
Definition: latch.h:124
void SwitchToSharedLatch ( void  )

Definition at line 246 of file miscinit.c.

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

Referenced by InitAuxiliaryProcess(), and InitProcess().

247 {
249  Assert(MyProc != NULL);
250 
252 
253  if (FeBeWaitSet)
255 
256  /*
257  * Set the shared latch as the local one might have been set. This
258  * shouldn't normally be necessary as code is supposed to check the
259  * condition before waiting for the latch, but a bit care can't hurt.
260  */
261  SetLatch(MyLatch);
262 }
PGPROC * MyProc
Definition: proc.c:67
void ModifyWaitEvent(WaitEventSet *set, int pos, uint32 events, Latch *latch)
Definition: latch.c:736
WaitEventSet * FeBeWaitSet
Definition: pqcomm.c:186
Latch procLatch
Definition: proc.h:104
static Latch LocalLatchData
Definition: miscinit.c:62
void SetLatch(volatile Latch *latch)
Definition: latch.c:414
#define Assert(condition)
Definition: c.h:681
struct Latch * MyLatch
Definition: globals.c:52
#define WL_LATCH_SET
Definition: latch.h:124
void TouchSocketLockFiles ( void  )

Definition at line 1108 of file miscinit.c.

References buffer, close, DIRECTORY_LOCK_FILE, fd(), lfirst, PG_BINARY, and read.

Referenced by ServerLoop().

1109 {
1110  ListCell *l;
1111 
1112  foreach(l, lock_files)
1113  {
1114  char *socketLockFile = (char *) lfirst(l);
1115 
1116  /* No need to touch the data directory lock file, we trust */
1117  if (strcmp(socketLockFile, DIRECTORY_LOCK_FILE) == 0)
1118  continue;
1119 
1120  /*
1121  * utime() is POSIX standard, utimes() is a common alternative; if we
1122  * have neither, fall back to actually reading the file (which only
1123  * sets the access time not mod time, but that should be enough in
1124  * most cases). In all paths, we ignore errors.
1125  */
1126 #ifdef HAVE_UTIME
1127  utime(socketLockFile, NULL);
1128 #else /* !HAVE_UTIME */
1129 #ifdef HAVE_UTIMES
1130  utimes(socketLockFile, NULL);
1131 #else /* !HAVE_UTIMES */
1132  int fd;
1133  char buffer[1];
1134 
1135  fd = open(socketLockFile, O_RDONLY | PG_BINARY, 0);
1136  if (fd >= 0)
1137  {
1138  read(fd, buffer, sizeof(buffer));
1139  close(fd);
1140  }
1141 #endif /* HAVE_UTIMES */
1142 #endif /* HAVE_UTIME */
1143  }
1144 }
static List * lock_files
Definition: miscinit.c:60
#define DIRECTORY_LOCK_FILE
Definition: miscinit.c:55
static int fd(const char *x, int i)
Definition: preproc-init.c:105
#define PG_BINARY
Definition: c.h:1044
#define lfirst(lc)
Definition: pg_list.h:106
WalTimeSample buffer[LAG_TRACKER_BUFFER_SIZE]
Definition: walsender.c:214
#define close(a)
Definition: win32.h:12
#define read(a, b, c)
Definition: win32.h:13
static void UnlinkLockFiles ( int  status,
Datum  arg 
)
static

Definition at line 734 of file miscinit.c.

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

Referenced by CreateLockFile().

735 {
736  ListCell *l;
737 
738  foreach(l, lock_files)
739  {
740  char *curfile = (char *) lfirst(l);
741 
742  unlink(curfile);
743  /* Should we complain if the unlink fails? */
744  }
745  /* Since we're about to exit, no need to reclaim storage */
746  lock_files = NIL;
747 
748  /*
749  * Lock file removal should always be the last externally visible action
750  * of a postmaster or standalone backend, while we won't come here at all
751  * when exiting postmaster child processes. Therefore, this is a good
752  * place to log completion of shutdown. We could alternatively teach
753  * proc_exit() to do it, but that seems uglier. In a standalone backend,
754  * use NOTICE elevel to be less chatty.
755  */
757  (errmsg("database system is shut down")));
758 }
#define NIL
Definition: pg_list.h:69
bool IsPostmasterEnvironment
Definition: globals.c:100
static List * lock_files
Definition: miscinit.c:60
#define LOG
Definition: elog.h:26
#define ereport(elevel, rest)
Definition: elog.h:122
#define NOTICE
Definition: elog.h:37
#define lfirst(lc)
Definition: pg_list.h:106
int errmsg(const char *fmt,...)
Definition: elog.c:797
void ValidatePgVersion ( const char *  path)

Definition at line 1358 of file miscinit.c.

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

Referenced by AuxiliaryProcessMain(), checkDataDir(), InitPostgres(), and PostgresMain().

1359 {
1360  char full_path[MAXPGPATH];
1361  FILE *file;
1362  int ret;
1363  long file_major;
1364  long my_major;
1365  char *endptr;
1366  char file_version_string[64];
1367  const char *my_version_string = PG_VERSION;
1368 
1369  my_major = strtol(my_version_string, &endptr, 10);
1370 
1371  snprintf(full_path, sizeof(full_path), "%s/PG_VERSION", path);
1372 
1373  file = AllocateFile(full_path, "r");
1374  if (!file)
1375  {
1376  if (errno == ENOENT)
1377  ereport(FATAL,
1378  (errcode(ERRCODE_INVALID_PARAMETER_VALUE),
1379  errmsg("\"%s\" is not a valid data directory",
1380  path),
1381  errdetail("File \"%s\" is missing.", full_path)));
1382  else
1383  ereport(FATAL,
1385  errmsg("could not open file \"%s\": %m", full_path)));
1386  }
1387 
1388  file_version_string[0] = '\0';
1389  ret = fscanf(file, "%63s", file_version_string);
1390  file_major = strtol(file_version_string, &endptr, 10);
1391 
1392  if (ret != 1 || endptr == file_version_string)
1393  ereport(FATAL,
1394  (errcode(ERRCODE_INVALID_PARAMETER_VALUE),
1395  errmsg("\"%s\" is not a valid data directory",
1396  path),
1397  errdetail("File \"%s\" does not contain valid data.",
1398  full_path),
1399  errhint("You might need to initdb.")));
1400 
1401  FreeFile(file);
1402 
1403  if (my_major != file_major)
1404  ereport(FATAL,
1405  (errcode(ERRCODE_INVALID_PARAMETER_VALUE),
1406  errmsg("database files are incompatible with server"),
1407  errdetail("The data directory was initialized by PostgreSQL version %s, "
1408  "which is not compatible with this version %s.",
1409  file_version_string, my_version_string)));
1410 }
int errhint(const char *fmt,...)
Definition: elog.c:987
int errcode(int sqlerrcode)
Definition: elog.c:575
int snprintf(char *str, size_t count, const char *fmt,...) pg_attribute_printf(3
#define FATAL
Definition: elog.h:52
#define MAXPGPATH
int errdetail(const char *fmt,...)
Definition: elog.c:873
int errcode_for_file_access(void)
Definition: elog.c:598
FILE * AllocateFile(const char *name, const char *mode)
Definition: fd.c:2117
#define ereport(elevel, rest)
Definition: elog.h:122
int FreeFile(FILE *file)
Definition: fd.c:2309
int errmsg(const char *fmt,...)
Definition: elog.c:797

Variable Documentation

bool AuthenticatedUserIsSuperuser = false
static
bool IgnoreSystemIndexes = false
char* local_preload_libraries_string = NULL

Definition at line 1423 of file miscinit.c.

Referenced by process_session_preload_libraries().

Latch LocalLatchData
static

Definition at line 62 of file miscinit.c.

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

List* lock_files = NIL
static

Definition at line 60 of file miscinit.c.

Definition at line 57 of file miscinit.c.

Oid OuterUserId = InvalidOid
static

Definition at line 158 of file miscinit.c.

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

bool process_shared_preload_libraries_in_progress = false
char* session_preload_libraries_string = NULL

Definition at line 1421 of file miscinit.c.

Referenced by process_session_preload_libraries().

Oid SessionUserId = InvalidOid
static

Definition at line 157 of file miscinit.c.

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

bool SessionUserIsSuperuser = false
static

Definition at line 163 of file miscinit.c.

Referenced by SetCurrentRoleId(), and SetSessionUserId().

bool SetRoleIsActive = false
static

Definition at line 168 of file miscinit.c.

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

char* shared_preload_libraries_string = NULL

Definition at line 1422 of file miscinit.c.

Referenced by process_shared_preload_libraries().