PostgreSQL Source Code  git master
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" /* pgrminclude ignore */ /* 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  */
25 typedef enum UserAuth
26 {
28  uaImplicitReject, /* Not a user-visible option */
41  uaPeer
42 #define USER_AUTH_LAST uaPeer /* Must be last value of this enum */
43 } UserAuth;
44 
45 /*
46  * Data structures representing pg_hba.conf entries
47  */
48 
49 typedef enum IPCompareMethod
50 {
56 
57 typedef enum ConnType
58 {
65 } ConnType;
66 
67 typedef enum ClientCertMode
68 {
73 
74 typedef enum ClientCertName
75 {
79 
80 typedef struct HbaLine
81 {
83  char *rawline;
88  int addrlen; /* zero if we don't have a valid addr */
90  int masklen; /* zero if we don't have a valid mask */
92  char *hostname;
94  char *usermap;
95  char *pamservice;
97  bool ldaptls;
98  char *ldapscheme;
99  char *ldapserver;
100  int ldapport;
101  char *ldapbinddn;
105  char *ldapbasedn;
107  char *ldapprefix;
108  char *ldapsuffix;
111  char *krb_realm;
123 } HbaLine;
124 
125 typedef struct IdentLine
126 {
128 
129  char *usermap;
130  char *ident_user;
131  char *pg_role;
133 } IdentLine;
134 
135 /* kluge to avoid including libpq/libpq-be.h here */
136 typedef struct Port hbaPort;
137 
138 extern bool load_hba(void);
139 extern bool load_ident(void);
140 extern const char *hba_authname(UserAuth auth_method);
141 extern void hba_getauthmethod(hbaPort *port);
142 extern int check_usermap(const char *usermap_name,
143  const char *pg_role, const char *auth_user,
144  bool case_sensitive);
145 extern bool pg_isblank(const char c);
146 
147 #endif /* HBA_H */
int ldapscope
Definition: hba.h:106
UserAuth
Definition: hba.h:25
List * databases
Definition: hba.h:85
char * radiusports_s
Definition: hba.h:122
Definition: hba.h:80
Definition: hba.h:30
char * ldapserver
Definition: hba.h:99
struct sockaddr_storage mask
Definition: hba.h:89
Definition: hba.h:38
struct IdentLine IdentLine
int ldapport
Definition: hba.h:100
void hba_getauthmethod(hbaPort *port)
Definition: hba.c:3140
char * ldapbasedn
Definition: hba.h:105
Definition: hba.h:32
char * ldapscheme
Definition: hba.h:98
char * pamservice
Definition: hba.h:95
regex_t re
Definition: hba.h:132
Definition: hba.h:51
Definition: hba.h:35
Definition: libpq-be.h:125
struct HbaLine HbaLine
bool load_hba(void)
Definition: hba.c:2235
List * radiussecrets
Definition: hba.h:117
int check_usermap(const char *usermap_name, const char *pg_role, const char *auth_user, bool case_sensitive)
Definition: hba.c:2974
char * ldapsuffix
Definition: hba.h:108
int linenumber
Definition: hba.h:127
Definition: hba.h:34
Definition: hba.h:31
ConnType conntype
Definition: hba.h:84
char * radiusservers_s
Definition: hba.h:116
Definition: hba.h:61
bool pam_use_hostname
Definition: hba.h:96
Definition: hba.h:39
struct sockaddr_storage addr
Definition: hba.h:87
Definition: hba.h:63
char * usermap
Definition: hba.h:129
char * usermap
Definition: hba.h:94
List * radiusports
Definition: hba.h:121
Definition: hba.h:27
List * radiusservers
Definition: hba.h:115
bool include_realm
Definition: hba.h:112
Definition: hba.h:29
char * c
ConnType
Definition: hba.h:57
char * ldapbinddn
Definition: hba.h:101
char * krb_realm
Definition: hba.h:111
int linenumber
Definition: hba.h:82
IPCompareMethod
Definition: hba.h:49
char * ldapbindpasswd
Definition: hba.h:102
bool load_ident(void)
Definition: hba.c:3029
char * ldapprefix
Definition: hba.h:107
Definition: hba.h:59
static int port
Definition: pg_regress.c:92
Definition: hba.h:33
Definition: hba.h:54
char * hostname
Definition: hba.h:92
char * radiusidentifiers_s
Definition: hba.h:120
const char * hba_authname(UserAuth auth_method)
Definition: hba.c:3153
List * radiusidentifiers
Definition: hba.h:119
Definition: hba.h:37
char * radiussecrets_s
Definition: hba.h:118
List * roles
Definition: hba.h:86
char * ldapsearchfilter
Definition: hba.h:104
Definition: hba.h:125
ClientCertMode clientcert
Definition: hba.h:109
bool ldaptls
Definition: hba.h:97
char * ldapsearchattribute
Definition: hba.h:103
char * rawline
Definition: hba.h:83
bool upn_username
Definition: hba.h:114
ClientCertName
Definition: hba.h:74
char * ident_user
Definition: hba.h:130
bool pg_isblank(const char c)
Definition: hba.c:158
ClientCertName clientcertname
Definition: hba.h:110
IPCompareMethod ip_cmp_method
Definition: hba.h:91
int masklen
Definition: hba.h:90
int addrlen
Definition: hba.h:88
Definition: pg_list.h:50
ClientCertMode
Definition: hba.h:67
Definition: hba.h:36
bool compat_realm
Definition: hba.h:113
Definition: regex.h:55
Definition: hba.h:60
char * pg_role
Definition: hba.h:131
UserAuth auth_method
Definition: hba.h:93
Definition: hba.h:40