PostgreSQL Source Code git master
Loading...
Searching...
No Matches
hba.h
Go to the documentation of this file.
1/*-------------------------------------------------------------------------
2 *
3 * hba.h
4 * Interface to hba.c
5 *
6 *
7 * src/include/libpq/hba.h
8 *
9 *-------------------------------------------------------------------------
10 */
11#ifndef HBA_H
12#define HBA_H
13
14#include "libpq/pqcomm.h" /* needed for NetBSD */
15#include "nodes/pg_list.h"
16#include "regex/regex.h"
17
18
19/*
20 * The following enum represents the authentication methods that
21 * are supported by PostgreSQL.
22 *
23 * Note: keep this in sync with the UserAuthName array in hba.c.
24 */
25typedef enum UserAuth
26{
28 uaImplicitReject, /* Not a user-visible option */
42#define USER_AUTH_LAST uaOAuth /* Must be last value of this enum */
44
45/*
46 * Data structures representing pg_hba.conf entries
47 */
48
56
66
73
79
80/*
81 * A single string token lexed from an authentication configuration file
82 * (pg_ident.conf or pg_hba.conf), together with whether the token has
83 * been quoted. If "string" begins with a slash, it may optionally
84 * contain a regular expression (currently used for pg_ident.conf when
85 * building IdentLines and for pg_hba.conf when building HbaLines).
86 */
87typedef struct AuthToken
88{
89 char *string;
90 bool quoted;
93
137
146
147typedef struct HostsLine
148{
150
152 char *rawline;
153
154 /* Required fields */
156 char *ssl_key;
157 char *ssl_cert;
158
159 /* Optional fields */
160 char *ssl_ca;
163
164 /* Internal bookkeeping */
165 void *ssl_ctx; /* associated SSL_CTX* for the above settings */
167
176
177/*
178 * TokenizedAuthLine represents one line lexed from an authentication
179 * configuration file. Each item in the "fields" list is a sub-list of
180 * AuthTokens. We don't emit a TokenizedAuthLine for empty or all-comment
181 * lines, so "fields" is never NIL (nor are any of its sub-lists).
182 *
183 * Exception: if an error occurs during tokenization, we might have
184 * fields == NIL, in which case err_msg != NULL.
185 */
186typedef struct TokenizedAuthLine
187{
188 List *fields; /* List of lists of AuthTokens */
189 char *file_name; /* File name of origin */
190 int line_num; /* Line number */
191 char *raw_line; /* Raw line text */
192 char *err_msg; /* Error message if any */
194
195/* avoid including libpq/libpq-be.h here */
196typedef struct Port Port;
197
198extern bool load_hba(void);
199extern bool load_ident(void);
200extern const char *hba_authname(UserAuth auth_method);
201extern void hba_getauthmethod(Port *port);
202extern int check_usermap(const char *usermap_name,
203 const char *pg_user, const char *system_user,
204 bool case_insensitive);
207extern FILE *open_auth_file(const char *filename, int elevel, int depth,
208 char **err_msg);
209extern void free_auth_file(FILE *file, int depth);
210extern void tokenize_auth_file(const char *filename, FILE *file,
211 List **tok_lines, int elevel, int depth);
212
213#endif /* HBA_H */
IPCompareMethod
Definition hba.h:50
@ ipCmpAll
Definition hba.h:54
@ ipCmpSameNet
Definition hba.h:53
@ ipCmpMask
Definition hba.h:51
@ ipCmpSameHost
Definition hba.h:52
HbaLine * parse_hba_line(TokenizedAuthLine *tok_line, int elevel)
Definition hba.c:1324
ConnType
Definition hba.h:58
@ ctHostNoGSS
Definition hba.h:64
@ ctHostSSL
Definition hba.h:61
@ ctHostNoSSL
Definition hba.h:62
@ ctHost
Definition hba.h:60
@ ctHostGSS
Definition hba.h:63
@ ctLocal
Definition hba.h:59
bool load_ident(void)
Definition hba.c:2846
HostsFileLoadResult
Definition hba.h:169
@ HOSTSFILE_MISSING
Definition hba.h:173
@ HOSTSFILE_LOAD_OK
Definition hba.h:170
@ HOSTSFILE_EMPTY
Definition hba.h:172
@ HOSTSFILE_DISABLED
Definition hba.h:174
@ HOSTSFILE_LOAD_FAILED
Definition hba.h:171
UserAuth
Definition hba.h:26
@ uaBSD
Definition hba.h:37
@ uaLDAP
Definition hba.h:38
@ uaPeer
Definition hba.h:40
@ uaPAM
Definition hba.h:36
@ uaPassword
Definition hba.h:31
@ uaCert
Definition hba.h:39
@ uaMD5
Definition hba.h:32
@ uaReject
Definition hba.h:27
@ uaGSS
Definition hba.h:34
@ uaSCRAM
Definition hba.h:33
@ uaImplicitReject
Definition hba.h:28
@ uaIdent
Definition hba.h:30
@ uaOAuth
Definition hba.h:41
@ uaTrust
Definition hba.h:29
@ uaSSPI
Definition hba.h:35
bool load_hba(void)
Definition hba.c:2452
IdentLine * parse_ident_line(TokenizedAuthLine *tok_line, int elevel)
Definition hba.c:2558
int check_usermap(const char *usermap_name, const char *pg_user, const char *system_user, bool case_insensitive)
Definition hba.c:2791
void free_auth_file(FILE *file, int depth)
Definition hba.c:568
ClientCertName
Definition hba.h:75
@ clientCertDN
Definition hba.h:77
@ clientCertCN
Definition hba.h:76
void hba_getauthmethod(Port *port)
Definition hba.c:2935
ClientCertMode
Definition hba.h:68
@ clientCertOff
Definition hba.h:69
@ clientCertFull
Definition hba.h:71
@ clientCertCA
Definition hba.h:70
void tokenize_auth_file(const char *filename, FILE *file, List **tok_lines, int elevel, int depth)
Definition hba.c:687
const char * hba_authname(UserAuth auth_method)
Definition hba.c:2948
FILE * open_auth_file(const char *filename, int elevel, int depth, char **err_msg)
Definition hba.c:593
Datum system_user(PG_FUNCTION_ARGS)
Definition miscinit.c:900
static char * filename
Definition pg_dumpall.c:133
static int port
Definition pg_regress.c:117
static int fb(int x)
#define regex_t
Definition regex.h:245
regex_t * regex
Definition hba.h:91
char * string
Definition hba.h:89
bool quoted
Definition hba.h:90
Definition hba.h:95
UserAuth auth_method
Definition hba.h:108
bool upn_username
Definition hba.h:129
struct sockaddr_storage mask
Definition hba.h:104
char * sourcefile
Definition hba.h:96
ClientCertName clientcertname
Definition hba.h:125
int addrlen
Definition hba.h:103
bool oauth_skip_usermap
Definition hba.h:133
char * ldapserver
Definition hba.h:114
bool include_realm
Definition hba.h:127
List * oauth_opt_vals
Definition hba.h:135
int masklen
Definition hba.h:105
ClientCertMode clientcert
Definition hba.h:124
char * ldapsearchfilter
Definition hba.h:119
char * ldapscheme
Definition hba.h:113
char * rawline
Definition hba.h:98
char * oauth_issuer
Definition hba.h:130
char * ldapprefix
Definition hba.h:122
char * ldapsearchattribute
Definition hba.h:118
char * krb_realm
Definition hba.h:126
char * ldapbasedn
Definition hba.h:120
bool pam_use_hostname
Definition hba.h:111
int linenumber
Definition hba.h:97
char * oauth_scope
Definition hba.h:131
char * oauth_validator
Definition hba.h:132
char * hostname
Definition hba.h:107
char * pamservice
Definition hba.h:110
List * databases
Definition hba.h:100
ConnType conntype
Definition hba.h:99
char * usermap
Definition hba.h:109
char * ldapsuffix
Definition hba.h:123
int ldapport
Definition hba.h:115
struct sockaddr_storage addr
Definition hba.h:102
char * ldapbindpasswd
Definition hba.h:117
List * roles
Definition hba.h:101
char * ldapbinddn
Definition hba.h:116
bool compat_realm
Definition hba.h:128
int ldapscope
Definition hba.h:121
IPCompareMethod ip_cmp_method
Definition hba.h:106
bool ldaptls
Definition hba.h:112
List * oauth_opt_keys
Definition hba.h:134
void * ssl_ctx
Definition hba.h:165
char * rawline
Definition hba.h:152
char * ssl_passphrase_cmd
Definition hba.h:161
char * sourcefile
Definition hba.h:151
char * ssl_key
Definition hba.h:156
bool ssl_passphrase_reload
Definition hba.h:162
char * ssl_ca
Definition hba.h:160
List * hostnames
Definition hba.h:155
char * ssl_cert
Definition hba.h:157
int linenumber
Definition hba.h:149
AuthToken * pg_user
Definition hba.h:144
AuthToken * system_user
Definition hba.h:143
char * usermap
Definition hba.h:142
int linenumber
Definition hba.h:140
Definition pg_list.h:54
char * raw_line
Definition hba.h:191
char * file_name
Definition hba.h:189
char * err_msg
Definition hba.h:192
List * fields
Definition hba.h:188