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-2008, PostgreSQL Global Development Group
12 * Portions Copyright (c) 1994, Regents of the University of California
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
55 * Define a fake structure compatible with GSSAPI on Unix.
63 #endif /* ENABLE_SSPI */
65 #include "libpq/hba.h"
66 #include "libpq/pqcomm.h"
67 #include "utils/timestamp.h"
70 typedef enum CAC_state
72 CAC_OK
, CAC_STARTUP
, CAC_SHUTDOWN
, CAC_RECOVERY
, CAC_TOOMANY
,
78 * GSSAPI specific state information
80 #if defined(ENABLE_GSS) | defined(ENABLE_SSPI)
83 gss_buffer_desc outbuf
; /* GSSAPI output token buffer */
85 gss_cred_id_t cred
; /* GSSAPI connection cred's */
86 gss_ctx_id_t ctx
; /* GSSAPI connection context */
87 gss_name_t name
; /* GSSAPI client name */
93 * This is used by the postmaster in its communication with frontends. It
94 * contains all state information needed during this communication before the
95 * backend is run. The Port structure is kept in malloc'd memory and is
96 * still available when a backend is running (see MyProcPort). The data
97 * it points to must also be malloc'd, or else palloc'd in TopMemoryContext,
98 * so that it survives into PostgresMain execution!
103 int sock
; /* File descriptor */
104 ProtocolVersion proto
; /* FE/BE protocol version */
105 SockAddr laddr
; /* local addr (postmaster) */
106 SockAddr raddr
; /* remote addr (client) */
107 char *remote_host
; /* name (or ip addr) of remote host */
108 char *remote_port
; /* text rep of remote port */
109 CAC_state canAcceptConnections
; /* postmaster connection status */
112 * Information that needs to be saved from the startup packet and passed
113 * into backend execution. "char *" fields are NULL if not set.
114 * guc_options points to a List of alternating option names and values.
118 char *cmdline_options
;
122 * Information that needs to be held during the authentication cycle.
125 char md5Salt
[4]; /* Password salt */
128 * Information that really has no business at all being in struct Port,
129 * but since it gets used by elog.c in the same way as database_name and
130 * other members of this struct, we may as well keep it here.
132 TimestampTz SessionStartTime
; /* backend start time */
135 * TCP keepalive settings.
137 * default values are 0 if AF_UNIX or not yet known; current values are 0
138 * if AF_UNIX or using the default. Also, -1 in a default value means we
139 * were unable to find out the default (getsockopt failed).
141 int default_keepalives_idle
;
142 int default_keepalives_interval
;
143 int default_keepalives_count
;
145 int keepalives_interval
;
146 int keepalives_count
;
148 #if defined(ENABLE_GSS) || defined(ENABLE_SSPI)
151 * If GSSAPI is supported, store GSSAPI information. Oterwise, store a
152 * NULL pointer to make sure offsets in the struct remain the same.
160 * SSL structures (keep these last so that USE_SSL doesn't affect
161 * locations of other fields)
166 char peer_dn
[128 + 1];
167 char peer_cn
[SM_USER
+ 1];
173 extern ProtocolVersion FrontendProtocol
;
175 /* TCP keepalives configuration. These are no-ops on an AF_UNIX socket. */
177 extern int pq_getkeepalivesidle(Port
*port
);
178 extern int pq_getkeepalivesinterval(Port
*port
);
179 extern int pq_getkeepalivescount(Port
*port
);
181 extern int pq_setkeepalivesidle(int idle
, Port
*port
);
182 extern int pq_setkeepalivesinterval(int interval
, Port
*port
);
183 extern int pq_setkeepalivescount(int count
, Port
*port
);
185 #endif /* LIBPQ_BE_H */