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 typedef enum UserAuth 20 { 21 uaReject, 22 uaImplicitReject, 23 uaKrb5, 24 uaTrust, 25 uaIdent, 26 uaPassword, 27 uaMD5, 28 uaGSS, 29 uaSSPI, 30 uaPAM, 31 uaLDAP, 32 uaCert, 33 uaRADIUS, 34 uaPeer 35 } UserAuth; 36 37 typedef enum IPCompareMethod 38 { 39 ipCmpMask, 40 ipCmpSameHost, 41 ipCmpSameNet, 42 ipCmpAll 43 } IPCompareMethod; 44 45 typedef enum ConnType 46 { 47 ctLocal, 48 ctHost, 49 ctHostSSL, 50 ctHostNoSSL 51 } ConnType; 52 53 typedef struct HbaLine 54 { 55 int linenumber; 56 char *rawline; 57 ConnType conntype; 58 List *databases; 59 List *roles; 60 struct sockaddr_storage addr; 61 struct sockaddr_storage mask; 62 IPCompareMethod ip_cmp_method; 63 char *hostname; 64 UserAuth auth_method; 65 66 char *usermap; 67 char *pamservice; 68 bool ldaptls; 69 char *ldapserver; 70 int ldapport; 71 char *ldapbinddn; 72 char *ldapbindpasswd; 73 char *ldapsearchattribute; 74 char *ldapbasedn; 75 int ldapscope; 76 char *ldapprefix; 77 char *ldapsuffix; 78 bool clientcert; 79 char *krb_server_hostname; 80 char *krb_realm; 81 bool include_realm; 82 char *radiusserver; 83 char *radiussecret; 84 char *radiusidentifier; 85 int radiusport; 86 } HbaLine; 87 88 typedef struct IdentLine 89 { 90 int linenumber; 91 92 char *usermap; 93 char *ident_user; 94 char *pg_role; 95 regex_t re; 96 } IdentLine; 97 98 /* kluge to avoid including libpq/libpq-be.h here */ 99 typedef struct Port hbaPort; 100 101 extern bool load_hba(void); 102 extern bool load_ident(void); 103 extern void hba_getauthmethod(hbaPort *port); 104 extern int check_usermap(const char *usermap_name, 105 const char *pg_role, const char *auth_user, 106 bool case_sensitive); 107 extern bool pg_isblank(const char c); 108 109 #endif /* HBA_H */ 110