PostgreSQL Source Code
git master
|
#include <netinet/in.h>
#include "lib/stringinfo.h"
#include "libpq/libpq-be.h"
#include "storage/latch.h"
Go to the source code of this file.
Data Structures | |
struct | PQcommMethods |
Macros | |
#define | PQ_SMALL_MESSAGE_LIMIT 10000 |
#define | PQ_LARGE_MESSAGE_LIMIT (MaxAllocSize - 1) |
#define | pq_comm_reset() (PqCommMethods->comm_reset()) |
#define | pq_flush() (PqCommMethods->flush()) |
#define | pq_flush_if_writable() (PqCommMethods->flush_if_writable()) |
#define | pq_is_send_pending() (PqCommMethods->is_send_pending()) |
#define | pq_putmessage(msgtype, s, len) (PqCommMethods->putmessage(msgtype, s, len)) |
#define | pq_putmessage_noblock(msgtype, s, len) (PqCommMethods->putmessage_noblock(msgtype, s, len)) |
#define | FeBeWaitSetSocketPos 0 |
#define | FeBeWaitSetLatchPos 1 |
#define | FeBeWaitSetNEvents 3 |
Enumerations | |
enum | ssl_protocol_versions { PG_TLS_ANY = 0 , PG_TLS1_VERSION , PG_TLS1_1_VERSION , PG_TLS1_2_VERSION , PG_TLS1_3_VERSION } |
Functions | |
int | StreamServerPort (int family, const char *hostName, unsigned short portNumber, const char *unixSocketDir, pgsocket ListenSocket[], int MaxListen) |
int | StreamConnection (pgsocket server_fd, Port *port) |
void | StreamClose (pgsocket sock) |
void | TouchSocketFiles (void) |
void | RemoveSocketFiles (void) |
void | pq_init (void) |
int | pq_getbytes (char *s, size_t len) |
void | pq_startmsgread (void) |
void | pq_endmsgread (void) |
bool | pq_is_reading_msg (void) |
int | pq_getmessage (StringInfo s, int maxlen) |
int | pq_getbyte (void) |
int | pq_peekbyte (void) |
int | pq_getbyte_if_available (unsigned char *c) |
bool | pq_buffer_has_data (void) |
int | pq_putmessage_v2 (char msgtype, const char *s, size_t len) |
bool | pq_check_connection (void) |
int | secure_initialize (bool isServerStart) |
bool | secure_loaded_verify_locations (void) |
void | secure_destroy (void) |
int | secure_open_server (Port *port) |
void | secure_close (Port *port) |
ssize_t | secure_read (Port *port, void *ptr, size_t len) |
ssize_t | secure_write (Port *port, void *ptr, size_t len) |
ssize_t | secure_raw_read (Port *port, void *ptr, size_t len) |
ssize_t | secure_raw_write (Port *port, const void *ptr, size_t len) |
int | run_ssl_passphrase_command (const char *prompt, bool is_server_start, char *buf, int size) |
bool | check_ssl_key_file_permissions (const char *ssl_key_file, bool isServerStart) |
Variables | |
const PGDLLIMPORT PQcommMethods * | PqCommMethods |
PGDLLIMPORT WaitEventSet * | FeBeWaitSet |
PGDLLIMPORT char * | ssl_library |
PGDLLIMPORT char * | ssl_cert_file |
PGDLLIMPORT char * | ssl_key_file |
PGDLLIMPORT char * | ssl_ca_file |
PGDLLIMPORT char * | ssl_crl_file |
PGDLLIMPORT char * | ssl_crl_dir |
PGDLLIMPORT char * | ssl_dh_params_file |
PGDLLIMPORT char * | ssl_passphrase_command |
PGDLLIMPORT bool | ssl_passphrase_command_supports_reload |
PGDLLIMPORT char * | SSLCipherSuites |
PGDLLIMPORT char * | SSLECDHCurve |
PGDLLIMPORT bool | SSLPreferServerCiphers |
PGDLLIMPORT int | ssl_min_protocol_version |
PGDLLIMPORT int | ssl_max_protocol_version |
#define pq_comm_reset | ( | ) | (PqCommMethods->comm_reset()) |
#define pq_flush | ( | ) | (PqCommMethods->flush()) |
#define pq_flush_if_writable | ( | ) | (PqCommMethods->flush_if_writable()) |
#define pq_is_send_pending | ( | ) | (PqCommMethods->is_send_pending()) |
#define PQ_LARGE_MESSAGE_LIMIT (MaxAllocSize - 1) |
#define pq_putmessage | ( | msgtype, | |
s, | |||
len | |||
) | (PqCommMethods->putmessage(msgtype, s, len)) |
#define pq_putmessage_noblock | ( | msgtype, | |
s, | |||
len | |||
) | (PqCommMethods->putmessage_noblock(msgtype, s, len)) |
Definition at line 110 of file be-secure-common.c.
References buf, ereport, errcode(), errcode_for_file_access(), errdetail(), errmsg(), FATAL, LOG, S_IRWXG, S_IRWXO, S_ISREG, S_IWGRP, S_IXGRP, ssl_key_file, and stat.
Referenced by be_tls_init().
bool pq_buffer_has_data | ( | void | ) |
Definition at line 1137 of file pqcomm.c.
References PqRecvLength, and PqRecvPointer.
Referenced by ProcessStartupPacket().
bool pq_check_connection | ( | void | ) |
Definition at line 2033 of file pqcomm.c.
References FeBeWaitSet, FeBeWaitSetNEvents, FeBeWaitSetSocketPos, i, lengthof, ModifyWaitEvent(), MyLatch, ResetLatch(), WaitEventSetWait(), WL_LATCH_SET, and WL_SOCKET_CLOSED.
Referenced by ProcessInterrupts().
void pq_endmsgread | ( | void | ) |
Definition at line 1174 of file pqcomm.c.
References Assert(), and PqCommReadingMsg.
Referenced by ProcessRepliesIfAny(), and ProcessStartupPacket().
int pq_getbyte | ( | void | ) |
Definition at line 980 of file pqcomm.c.
References Assert(), pq_recvbuf(), PqCommReadingMsg, PqRecvBuffer, PqRecvLength, and PqRecvPointer.
Referenced by CheckSASLAuth(), CopyGetData(), recv_password_packet(), and SocketBackend().
int pq_getbyte_if_available | ( | unsigned char * | c | ) |
Definition at line 1020 of file pqcomm.c.
References Assert(), COMMERROR, EAGAIN, EINTR, ereport, errcode_for_socket_access(), errmsg(), EWOULDBLOCK, MyProcPort, PqCommReadingMsg, PqRecvBuffer, PqRecvLength, PqRecvPointer, secure_read(), and socket_set_nonblocking().
Referenced by ProcessRepliesIfAny().
int pq_getbytes | ( | char * | s, |
size_t | len | ||
) |
Definition at line 1074 of file pqcomm.c.
References Assert(), len, pq_recvbuf(), PqCommReadingMsg, PqRecvBuffer, PqRecvLength, and PqRecvPointer.
Referenced by pq_getmessage(), and ProcessStartupPacket().
int pq_getmessage | ( | StringInfo | s, |
int | maxlen | ||
) |
Definition at line 1212 of file pqcomm.c.
References Assert(), COMMERROR, StringInfoData::data, enlargeStringInfo(), ereport, errcode(), errmsg(), StringInfoData::len, len, PG_CATCH, PG_END_TRY, pg_ntoh32, PG_RE_THROW, PG_TRY, pq_discardbytes(), pq_getbytes(), PqCommReadingMsg, and resetStringInfo().
Referenced by CheckSASLAuth(), CopyGetData(), ProcessRepliesIfAny(), recv_password_packet(), and SocketBackend().
void pq_init | ( | void | ) |
Definition at line 172 of file pqcomm.c.
References AddWaitEventToSet(), Assert(), COMMERROR, CreateWaitEventSet(), elog(), ereport, errmsg(), FATAL, FeBeWaitSet, FeBeWaitSetLatchPos, FeBeWaitSetNEvents, FeBeWaitSetSocketPos, MemoryContextAlloc(), MyLatch, MyProcPort, on_proc_exit(), pg_set_noblock(), PG_USED_FOR_ASSERTS_ONLY, PGINVALID_SOCKET, PQ_SEND_BUFFER_SIZE, PqCommBusy, PqCommReadingMsg, PqRecvLength, PqRecvPointer, PqSendBuffer, PqSendBufferSize, PqSendPointer, PqSendStart, Port::sock, socket_close(), TopMemoryContext, WL_LATCH_SET, WL_POSTMASTER_DEATH, and WL_SOCKET_WRITEABLE.
Referenced by BackendInitialize().
bool pq_is_reading_msg | ( | void | ) |
Definition at line 1190 of file pqcomm.c.
References PqCommReadingMsg.
Referenced by PostgresMain().
int pq_peekbyte | ( | void | ) |
Definition at line 999 of file pqcomm.c.
References Assert(), pq_recvbuf(), PqCommReadingMsg, PqRecvBuffer, PqRecvLength, and PqRecvPointer.
int pq_putmessage_v2 | ( | char | msgtype, |
const char * | s, | ||
size_t | len | ||
) |
Definition at line 1538 of file pqcomm.c.
References Assert(), internal_putbytes(), len, and PqCommBusy.
Referenced by send_message_to_frontend().
void pq_startmsgread | ( | void | ) |
Definition at line 1150 of file pqcomm.c.
References ereport, errcode(), errmsg(), FATAL, and PqCommReadingMsg.
Referenced by CheckSASLAuth(), CopyGetData(), ProcessRepliesIfAny(), ProcessStartupPacket(), recv_password_packet(), and SocketBackend().
void RemoveSocketFiles | ( | void | ) |
Definition at line 869 of file pqcomm.c.
References lfirst, NIL, and sock_paths.
Referenced by CloseServerPorts().
int run_ssl_passphrase_command | ( | const char * | prompt, |
bool | is_server_start, | ||
char * | buf, | ||
int | size | ||
) |
Definition at line 40 of file be-secure-common.c.
References Assert(), buf, ClosePipeStream(), ereport, errcode_for_file_access(), errdetail_internal(), errmsg(), ERROR, error(), explicit_bzero(), len, LOG, OpenPipeStream(), pfree(), pg_strip_crlf(), replace_percent_placeholders(), ssl_passphrase_command, and wait_result_to_str().
Referenced by ssl_external_passwd_cb().
void secure_close | ( | Port * | port | ) |
Definition at line 133 of file be-secure.c.
References be_tls_close(), and port.
Referenced by socket_close().
void secure_destroy | ( | void | ) |
Definition at line 89 of file be-secure.c.
References be_tls_destroy().
Referenced by process_pm_reload_request().
int secure_initialize | ( | bool | isServerStart | ) |
Definition at line 76 of file be-secure.c.
References be_tls_init().
Referenced by PostmasterMain(), and process_pm_reload_request().
bool secure_loaded_verify_locations | ( | void | ) |
int secure_open_server | ( | Port * | port | ) |
Definition at line 113 of file be-secure.c.
References be_tls_open_server(), DEBUG2, ereport, errmsg_internal(), and port.
Referenced by ProcessStartupPacket().
ssize_t secure_raw_read | ( | Port * | port, |
void * | ptr, | ||
size_t | len | ||
) |
Definition at line 234 of file be-secure.c.
References len, pgwin32_noblock, port, and recv.
Referenced by be_gssapi_read(), my_sock_read(), read_or_wait(), and secure_read().
ssize_t secure_raw_write | ( | Port * | port, |
const void * | ptr, | ||
size_t | len | ||
) |
Definition at line 330 of file be-secure.c.
References len, pgwin32_noblock, port, and send.
Referenced by be_gssapi_write(), my_sock_write(), secure_open_gssapi(), and secure_write().
ssize_t secure_read | ( | Port * | port, |
void * | ptr, | ||
size_t | len | ||
) |
Definition at line 145 of file be-secure.c.
References Assert(), be_gssapi_read(), be_tls_read(), EAGAIN, ereport, errcode(), errmsg(), WaitEvent::events, EWOULDBLOCK, FATAL, FeBeWaitSet, FeBeWaitSetSocketPos, len, ModifyWaitEvent(), MyLatch, port, ProcessClientReadInterrupt(), ResetLatch(), secure_raw_read(), WaitEventSetWait(), WL_LATCH_SET, WL_POSTMASTER_DEATH, and WL_SOCKET_READABLE.
Referenced by pq_getbyte_if_available(), and pq_recvbuf().
ssize_t secure_write | ( | Port * | port, |
void * | ptr, | ||
size_t | len | ||
) |
Definition at line 258 of file be-secure.c.
References Assert(), be_gssapi_write(), be_tls_write(), EAGAIN, ereport, errcode(), errmsg(), WaitEvent::events, EWOULDBLOCK, FATAL, FeBeWaitSet, FeBeWaitSetSocketPos, len, ModifyWaitEvent(), MyLatch, port, ProcessClientWriteInterrupt(), ResetLatch(), secure_raw_write(), WaitEventSetWait(), WL_LATCH_SET, WL_POSTMASTER_DEATH, and WL_SOCKET_WRITEABLE.
Referenced by internal_flush().
void StreamClose | ( | pgsocket | sock | ) |
Definition at line 835 of file pqcomm.c.
References closesocket, elog(), and LOG.
Referenced by ClosePostmasterPorts(), CloseServerPorts(), ConnCreate(), and ServerLoop().
Definition at line 701 of file pqcomm.c.
References accept, ereport, errcode_for_socket_access(), errmsg(), LOG, pg_usleep(), PGINVALID_SOCKET, port, PQ_SEND_BUFFER_SIZE, pq_setkeepalivescount(), pq_setkeepalivesidle(), pq_setkeepalivesinterval(), pq_settcpusertimeout(), STATUS_ERROR, STATUS_OK, tcp_keepalives_count, tcp_keepalives_idle, tcp_keepalives_interval, and tcp_user_timeout.
Referenced by ConnCreate().
int StreamServerPort | ( | int | family, |
const char * | hostName, | ||
unsigned short | portNumber, | ||
const char * | unixSocketDir, | ||
pgsocket | ListenSocket[], | ||
int | MaxListen | ||
) |
Definition at line 321 of file pqcomm.c.
References _, bind, closesocket, EADDRINUSE, elog(), ereport, err(), errcode_for_socket_access(), errhint(), errmsg(), FATAL, fd(), listen, ListenSocket, Lock_AF_UNIX(), LOG, MaxConnections, MAXPGPATH, MemSet, pg_freeaddrinfo_all(), pg_getaddrinfo_all(), pg_getnameinfo_all(), PGINVALID_SOCKET, Setup_AF_UNIX(), snprintf, socket, STATUS_ERROR, STATUS_OK, UNIXSOCK_PATH, and UNIXSOCK_PATH_BUFLEN.
Referenced by PostmasterMain().
void TouchSocketFiles | ( | void | ) |
Definition at line 851 of file pqcomm.c.
References lfirst, and sock_paths.
Referenced by ServerLoop().
|
extern |
Definition at line 164 of file pqcomm.c.
Referenced by pq_check_connection(), pq_init(), secure_read(), secure_write(), SwitchBackToLocalLatch(), SwitchToSharedLatch(), and WalSndWait().
|
extern |
Definition at line 162 of file pqcomm.c.
Referenced by pq_redirect_to_shm_mq(), and pq_set_parallel_leader().
|
extern |
Definition at line 41 of file be-secure.c.
Referenced by be_tls_init().
|
extern |
Definition at line 39 of file be-secure.c.
Referenced by be_tls_init().
|
extern |
Definition at line 43 of file be-secure.c.
Referenced by be_tls_init().
|
extern |
Definition at line 42 of file be-secure.c.
Referenced by be_tls_init().
|
extern |
Definition at line 44 of file be-secure.c.
Referenced by initialize_dh().
|
extern |
Definition at line 40 of file be-secure.c.
Referenced by be_tls_init(), and check_ssl_key_file_permissions().
|
extern |
Definition at line 38 of file be-secure.c.
|
extern |
Definition at line 62 of file be-secure.c.
Referenced by be_tls_init(), and be_tls_open_server().
|
extern |
Definition at line 61 of file be-secure.c.
Referenced by be_tls_init(), and be_tls_open_server().
|
extern |
Definition at line 45 of file be-secure.c.
Referenced by default_openssl_tls_init(), run_ssl_passphrase_command(), and set_rot13().
|
extern |
Definition at line 46 of file be-secure.c.
Referenced by default_openssl_tls_init().
|
extern |
Definition at line 53 of file be-secure.c.
Referenced by be_tls_init().
|
extern |
Definition at line 56 of file be-secure.c.
Referenced by initialize_ecdh().
|
extern |
Definition at line 59 of file be-secure.c.
Referenced by be_tls_init().