1 /*-------------------------------------------------------------------------
4 * This file contains definitions for structures and externs used
5 * by the postmaster during client authentication.
7 * Note that this is backend-internal and is NOT exported to clients.
8 * Structs that need to be client-visible are in pqcomm.h.
11 * Portions Copyright (c) 1996-2010, PostgreSQL Global Development Group
12 * Portions Copyright (c) 1994, Regents of the University of California
14 * $PostgreSQL: pgsql/src/include/libpq/libpq-be.h,v 1.74 2010/01/15 09:19:08 heikki Exp $
16 *-------------------------------------------------------------------------
21 #ifdef HAVE_SYS_TIME_H
25 #include <openssl/ssl.h>
26 #include <openssl/err.h>
28 #ifdef HAVE_NETINET_TCP_H
29 #include <netinet/tcp.h>
33 #if defined(HAVE_GSSAPI_H)
36 #include <gssapi/gssapi.h>
37 #endif /* HAVE_GSSAPI_H */
39 * GSSAPI brings in headers that set a lot of things in the global namespace on win32,
40 * that doesn't match the msvc build. It gives a bunch of compiler warnings that we ignore,
41 * but also defines a symbol that simply does not exist. Undefine it again.
43 #ifdef WIN32_ONLY_COMPILER
44 #undef HAVE_GETADDRINFO
46 #endif /* ENABLE_GSS */
49 #define SECURITY_WIN32
50 #if defined(WIN32) && !defined(WIN32_ONLY_COMPILER)
58 * Define a fake structure compatible with GSSAPI on Unix.
66 #endif /* ENABLE_SSPI */
68 #include "libpq/hba.h"
69 #include "libpq/pqcomm.h"
70 #include "utils/timestamp.h"
73 typedef enum CAC_state
75 CAC_OK, CAC_STARTUP, CAC_SHUTDOWN, CAC_RECOVERY, CAC_TOOMANY,
81 * GSSAPI specific state information
83 #if defined(ENABLE_GSS) | defined(ENABLE_SSPI)
86 gss_buffer_desc outbuf; /* GSSAPI output token buffer */
88 gss_cred_id_t cred; /* GSSAPI connection cred's */
89 gss_ctx_id_t ctx; /* GSSAPI connection context */
90 gss_name_t name; /* GSSAPI client name */
96 * This is used by the postmaster in its communication with frontends. It
97 * contains all state information needed during this communication before the
98 * backend is run. The Port structure is kept in malloc'd memory and is
99 * still available when a backend is running (see MyProcPort). The data
100 * it points to must also be malloc'd, or else palloc'd in TopMemoryContext,
101 * so that it survives into PostgresMain execution!
106 pgsocket sock; /* File descriptor */
107 bool noblock; /* is the socket in non-blocking mode? */
108 ProtocolVersion proto; /* FE/BE protocol version */
109 SockAddr laddr; /* local addr (postmaster) */
110 SockAddr raddr; /* remote addr (client) */
111 char *remote_host; /* name (or ip addr) of remote host */
112 char *remote_port; /* text rep of remote port */
113 CAC_state canAcceptConnections; /* postmaster connection status */
116 * Information that needs to be saved from the startup packet and passed
117 * into backend execution. "char *" fields are NULL if not set.
118 * guc_options points to a List of alternating option names and values.
122 char *cmdline_options;
126 * Information that needs to be held during the authentication cycle.
129 char md5Salt[4]; /* Password salt */
132 * Information that really has no business at all being in struct Port,
133 * but since it gets used by elog.c in the same way as database_name and
134 * other members of this struct, we may as well keep it here.
136 TimestampTz SessionStartTime; /* backend start time */
139 * TCP keepalive settings.
141 * default values are 0 if AF_UNIX or not yet known; current values are 0
142 * if AF_UNIX or using the default. Also, -1 in a default value means we
143 * were unable to find out the default (getsockopt failed).
145 int default_keepalives_idle;
146 int default_keepalives_interval;
147 int default_keepalives_count;
149 int keepalives_interval;
150 int keepalives_count;
152 #if defined(ENABLE_GSS) || defined(ENABLE_SSPI)
155 * If GSSAPI is supported, store GSSAPI information. Oterwise, store a
156 * NULL pointer to make sure offsets in the struct remain the same.
164 * SSL structures (keep these last so that USE_SSL doesn't affect
165 * locations of other fields)
170 char peer_dn[128 + 1];
171 char peer_cn[SM_USER + 1];
177 extern ProtocolVersion FrontendProtocol;
179 /* TCP keepalives configuration. These are no-ops on an AF_UNIX socket. */
181 extern int pq_getkeepalivesidle(Port *port);
182 extern int pq_getkeepalivesinterval(Port *port);
183 extern int pq_getkeepalivescount(Port *port);
185 extern int pq_setkeepalivesidle(int idle, Port *port);
186 extern int pq_setkeepalivesinterval(int interval, Port *port);
187 extern int pq_setkeepalivescount(int count, Port *port);
189 #endif /* LIBPQ_BE_H */