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-2007, 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.60 2007/07/12 14:36:52 mha 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>
40 #include "libpq/hba.h"
41 #include "libpq/pqcomm.h"
42 #include "utils/timestamp.h"
45 typedef enum CAC_state
47 CAC_OK, CAC_STARTUP, CAC_SHUTDOWN, CAC_RECOVERY, CAC_TOOMANY
52 * GSSAPI specific state information
57 gss_cred_id_t cred; /* GSSAPI connection cred's */
58 gss_ctx_id_t ctx; /* GSSAPI connection context */
59 gss_name_t name; /* GSSAPI client name */
60 gss_buffer_desc outbuf; /* GSSAPI output token buffer */
65 * This is used by the postmaster in its communication with frontends. It
66 * contains all state information needed during this communication before the
67 * backend is run. The Port structure is kept in malloc'd memory and is
68 * still available when a backend is running (see MyProcPort). The data
69 * it points to must also be malloc'd, or else palloc'd in TopMemoryContext,
70 * so that it survives into PostgresMain execution!
75 int sock; /* File descriptor */
76 ProtocolVersion proto; /* FE/BE protocol version */
77 SockAddr laddr; /* local addr (postmaster) */
78 SockAddr raddr; /* remote addr (client) */
79 char *remote_host; /* name (or ip addr) of remote host */
80 char *remote_port; /* text rep of remote port */
81 CAC_state canAcceptConnections; /* postmaster connection status */
84 * Information that needs to be saved from the startup packet and passed
85 * into backend execution. "char *" fields are NULL if not set.
86 * guc_options points to a List of alternating option names and values.
90 char *cmdline_options;
94 * Information that needs to be held during the authentication cycle.
98 char md5Salt[4]; /* Password salt */
99 char cryptSalt[2]; /* Password salt */
102 * Information that really has no business at all being in struct Port,
103 * but since it gets used by elog.c in the same way as database_name and
104 * other members of this struct, we may as well keep it here.
106 TimestampTz SessionStartTime; /* backend start time */
107 time_t session_start; /* same, in time_t format */
110 * TCP keepalive settings.
112 * default values are 0 if AF_UNIX or not yet known; current values are 0
113 * if AF_UNIX or using the default. Also, -1 in a default value means we
114 * were unable to find out the default (getsockopt failed).
116 int default_keepalives_idle;
117 int default_keepalives_interval;
118 int default_keepalives_count;
120 int keepalives_interval;
121 int keepalives_count;
125 * If GSSAPI is supported, store GSSAPI information.
126 * Oterwise, store a NULL pointer to make sure offsets
127 * in the struct remain the same.
135 * SSL structures (keep these last so that USE_SSL doesn't affect
136 * locations of other fields)
141 char peer_dn[128 + 1];
142 char peer_cn[SM_USER + 1];
148 extern ProtocolVersion FrontendProtocol;
150 /* TCP keepalives configuration. These are no-ops on an AF_UNIX socket. */
152 extern int pq_getkeepalivesidle(Port *port);
153 extern int pq_getkeepalivesinterval(Port *port);
154 extern int pq_getkeepalivescount(Port *port);
156 extern int pq_setkeepalivesidle(int idle, Port *port);
157 extern int pq_setkeepalivesinterval(int interval, Port *port);
158 extern int pq_setkeepalivescount(int count, Port *port);
160 #endif /* LIBPQ_BE_H */