PostgreSQL Source Code  git master
hbafuncs.c File Reference
#include "postgres.h"
#include "catalog/objectaddress.h"
#include "common/ip.h"
#include "funcapi.h"
#include "libpq/hba.h"
#include "miscadmin.h"
#include "utils/array.h"
#include "utils/builtins.h"
#include "utils/guc.h"
Include dependency graph for hbafuncs.c:

Go to the source code of this file.

Macros

#define MAX_HBA_OPTIONS   14
 
#define NUM_PG_HBA_FILE_RULES_ATTS   11
 
#define NUM_PG_IDENT_FILE_MAPPINGS_ATTS   7
 

Functions

static ArrayTypeget_hba_options (HbaLine *hba)
 
static void fill_hba_line (Tuplestorestate *tuple_store, TupleDesc tupdesc, int rule_number, char *filename, int lineno, HbaLine *hba, const char *err_msg)
 
static void fill_hba_view (Tuplestorestate *tuple_store, TupleDesc tupdesc)
 
static void fill_ident_line (Tuplestorestate *tuple_store, TupleDesc tupdesc, int map_number, char *filename, int lineno, IdentLine *ident, const char *err_msg)
 
static void fill_ident_view (Tuplestorestate *tuple_store, TupleDesc tupdesc)
 
Datum pg_hba_file_rules (PG_FUNCTION_ARGS)
 
Datum pg_ident_file_mappings (PG_FUNCTION_ARGS)
 

Macro Definition Documentation

◆ MAX_HBA_OPTIONS

#define MAX_HBA_OPTIONS   14

Definition at line 46 of file hbafuncs.c.

◆ NUM_PG_HBA_FILE_RULES_ATTS

#define NUM_PG_HBA_FILE_RULES_ATTS   11

Definition at line 162 of file hbafuncs.c.

◆ NUM_PG_IDENT_FILE_MAPPINGS_ATTS

#define NUM_PG_IDENT_FILE_MAPPINGS_ATTS   7

Definition at line 447 of file hbafuncs.c.

Function Documentation

◆ fill_hba_line()

static void fill_hba_line ( Tuplestorestate tuple_store,
TupleDesc  tupdesc,
int  rule_number,
char *  filename,
int  lineno,
HbaLine hba,
const char *  err_msg 
)
static

Definition at line 180 of file hbafuncs.c.

183 {
185  bool nulls[NUM_PG_HBA_FILE_RULES_ATTS];
186  char buffer[NI_MAXHOST];
187  HeapTuple tuple;
188  int index;
189  ListCell *lc;
190  const char *typestr;
191  const char *addrstr;
192  const char *maskstr;
194 
196 
197  memset(values, 0, sizeof(values));
198  memset(nulls, 0, sizeof(nulls));
199  index = 0;
200 
201  /* rule_number, nothing on error */
202  if (err_msg)
203  nulls[index++] = true;
204  else
205  values[index++] = Int32GetDatum(rule_number);
206 
207  /* file_name */
209 
210  /* line_number */
211  values[index++] = Int32GetDatum(lineno);
212 
213  if (hba != NULL)
214  {
215  /* type */
216  /* Avoid a default: case so compiler will warn about missing cases */
217  typestr = NULL;
218  switch (hba->conntype)
219  {
220  case ctLocal:
221  typestr = "local";
222  break;
223  case ctHost:
224  typestr = "host";
225  break;
226  case ctHostSSL:
227  typestr = "hostssl";
228  break;
229  case ctHostNoSSL:
230  typestr = "hostnossl";
231  break;
232  case ctHostGSS:
233  typestr = "hostgssenc";
234  break;
235  case ctHostNoGSS:
236  typestr = "hostnogssenc";
237  break;
238  }
239  if (typestr)
240  values[index++] = CStringGetTextDatum(typestr);
241  else
242  nulls[index++] = true;
243 
244  /* database */
245  if (hba->databases)
246  {
247  /*
248  * Flatten AuthToken list to string list. It might seem that we
249  * should re-quote any quoted tokens, but that has been rejected
250  * on the grounds that it makes it harder to compare the array
251  * elements to other system catalogs. That makes entries like
252  * "all" or "samerole" formally ambiguous ... but users who name
253  * databases/roles that way are inflicting their own pain.
254  */
255  List *names = NIL;
256 
257  foreach(lc, hba->databases)
258  {
259  AuthToken *tok = lfirst(lc);
260 
261  names = lappend(names, tok->string);
262  }
264  }
265  else
266  nulls[index++] = true;
267 
268  /* user */
269  if (hba->roles)
270  {
271  /* Flatten AuthToken list to string list; see comment above */
272  List *roles = NIL;
273 
274  foreach(lc, hba->roles)
275  {
276  AuthToken *tok = lfirst(lc);
277 
278  roles = lappend(roles, tok->string);
279  }
281  }
282  else
283  nulls[index++] = true;
284 
285  /* address and netmask */
286  /* Avoid a default: case so compiler will warn about missing cases */
287  addrstr = maskstr = NULL;
288  switch (hba->ip_cmp_method)
289  {
290  case ipCmpMask:
291  if (hba->hostname)
292  {
293  addrstr = hba->hostname;
294  }
295  else
296  {
297  /*
298  * Note: if pg_getnameinfo_all fails, it'll set buffer to
299  * "???", which we want to return.
300  */
301  if (hba->addrlen > 0)
302  {
303  if (pg_getnameinfo_all(&hba->addr, hba->addrlen,
304  buffer, sizeof(buffer),
305  NULL, 0,
306  NI_NUMERICHOST) == 0)
307  clean_ipv6_addr(hba->addr.ss_family, buffer);
308  addrstr = pstrdup(buffer);
309  }
310  if (hba->masklen > 0)
311  {
312  if (pg_getnameinfo_all(&hba->mask, hba->masklen,
313  buffer, sizeof(buffer),
314  NULL, 0,
315  NI_NUMERICHOST) == 0)
316  clean_ipv6_addr(hba->mask.ss_family, buffer);
317  maskstr = pstrdup(buffer);
318  }
319  }
320  break;
321  case ipCmpAll:
322  addrstr = "all";
323  break;
324  case ipCmpSameHost:
325  addrstr = "samehost";
326  break;
327  case ipCmpSameNet:
328  addrstr = "samenet";
329  break;
330  }
331  if (addrstr)
332  values[index++] = CStringGetTextDatum(addrstr);
333  else
334  nulls[index++] = true;
335  if (maskstr)
336  values[index++] = CStringGetTextDatum(maskstr);
337  else
338  nulls[index++] = true;
339 
340  /* auth_method */
342 
343  /* options */
344  options = get_hba_options(hba);
345  if (options)
347  else
348  nulls[index++] = true;
349  }
350  else
351  {
352  /* no parsing result, so set relevant fields to nulls */
353  memset(&nulls[3], true, (NUM_PG_HBA_FILE_RULES_ATTS - 4) * sizeof(bool));
354  }
355 
356  /* error */
357  if (err_msg)
359  else
360  nulls[NUM_PG_HBA_FILE_RULES_ATTS - 1] = true;
361 
362  tuple = heap_form_tuple(tupdesc, values, nulls);
363  tuplestore_puttuple(tuple_store, tuple);
364 }
static Datum values[MAXATTR]
Definition: bootstrap.c:156
#define CStringGetTextDatum(s)
Definition: builtins.h:94
const char * hba_authname(UserAuth auth_method)
Definition: hba.c:3066
@ ipCmpAll
Definition: hba.h:54
@ ipCmpSameNet
Definition: hba.h:53
@ ipCmpMask
Definition: hba.h:51
@ ipCmpSameHost
Definition: hba.h:52
@ 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
#define NUM_PG_HBA_FILE_RULES_ATTS
Definition: hbafuncs.c:162
static ArrayType * get_hba_options(HbaLine *hba)
Definition: hbafuncs.c:53
HeapTuple heap_form_tuple(TupleDesc tupleDescriptor, const Datum *values, const bool *isnull)
Definition: heaptuple.c:1117
int pg_getnameinfo_all(const struct sockaddr_storage *addr, int salen, char *node, int nodelen, char *service, int servicelen, int flags)
Definition: ip.c:114
Assert(fmt[strlen(fmt) - 1] !='\n')
List * lappend(List *list, void *datum)
Definition: list.c:338
char * pstrdup(const char *in)
Definition: mcxt.c:1644
void clean_ipv6_addr(int addr_family, char *addr)
Definition: network.c:2095
ArrayType * strlist_to_textarray(List *list)
static char * filename
Definition: pg_dumpall.c:119
#define lfirst(lc)
Definition: pg_list.h:172
#define NIL
Definition: pg_list.h:68
static char ** options
static Datum PointerGetDatum(const void *X)
Definition: postgres.h:322
uintptr_t Datum
Definition: postgres.h:64
static Datum Int32GetDatum(int32 X)
Definition: postgres.h:212
Definition: hba.h:88
char * string
Definition: hba.h:89
UserAuth auth_method
Definition: hba.h:108
struct sockaddr_storage mask
Definition: hba.h:104
int addrlen
Definition: hba.h:103
int masklen
Definition: hba.h:105
char * hostname
Definition: hba.h:107
List * databases
Definition: hba.h:100
ConnType conntype
Definition: hba.h:99
struct sockaddr_storage addr
Definition: hba.h:102
List * roles
Definition: hba.h:101
IPCompareMethod ip_cmp_method
Definition: hba.h:106
Definition: pg_list.h:54
Definition: type.h:95
void tuplestore_puttuple(Tuplestorestate *state, HeapTuple tuple)
Definition: tuplestore.c:730

References HbaLine::addr, HbaLine::addrlen, Assert(), HbaLine::auth_method, clean_ipv6_addr(), HbaLine::conntype, CStringGetTextDatum, ctHost, ctHostGSS, ctHostNoGSS, ctHostNoSSL, ctHostSSL, ctLocal, HbaLine::databases, filename, get_hba_options(), hba_authname(), heap_form_tuple(), HbaLine::hostname, Int32GetDatum(), HbaLine::ip_cmp_method, ipCmpAll, ipCmpMask, ipCmpSameHost, ipCmpSameNet, lappend(), lfirst, HbaLine::mask, HbaLine::masklen, TupleDescData::natts, NIL, NUM_PG_HBA_FILE_RULES_ATTS, options, pg_getnameinfo_all(), PointerGetDatum(), pstrdup(), HbaLine::roles, AuthToken::string, strlist_to_textarray(), tuplestore_puttuple(), and values.

Referenced by fill_hba_view().

◆ fill_hba_view()

static void fill_hba_view ( Tuplestorestate tuple_store,
TupleDesc  tupdesc 
)
static

Definition at line 371 of file hbafuncs.c.

372 {
373  FILE *file;
374  List *hba_lines = NIL;
375  ListCell *line;
376  int rule_number = 0;
377  MemoryContext hbacxt;
378  MemoryContext oldcxt;
379 
380  /*
381  * In the unlikely event that we can't open pg_hba.conf, we throw an
382  * error, rather than trying to report it via some sort of view entry.
383  * (Most other error conditions should result in a message in a view
384  * entry.)
385  */
386  file = open_auth_file(HbaFileName, ERROR, 0, NULL);
387 
388  tokenize_auth_file(HbaFileName, file, &hba_lines, DEBUG3, 0);
389 
390  /* Now parse all the lines */
392  "hba parser context",
394  oldcxt = MemoryContextSwitchTo(hbacxt);
395  foreach(line, hba_lines)
396  {
397  TokenizedAuthLine *tok_line = (TokenizedAuthLine *) lfirst(line);
398  HbaLine *hbaline = NULL;
399 
400  /* don't parse lines that already have errors */
401  if (tok_line->err_msg == NULL)
402  hbaline = parse_hba_line(tok_line, DEBUG3);
403 
404  /* No error, set a new rule number */
405  if (tok_line->err_msg == NULL)
406  rule_number++;
407 
408  fill_hba_line(tuple_store, tupdesc, rule_number,
409  tok_line->file_name, tok_line->line_num, hbaline,
410  tok_line->err_msg);
411  }
412 
413  /* Free tokenizer memory */
414  free_auth_file(file, 0);
415  /* Free parse_hba_line memory */
416  MemoryContextSwitchTo(oldcxt);
417  MemoryContextDelete(hbacxt);
418 }
#define DEBUG3
Definition: elog.h:28
#define ERROR
Definition: elog.h:39
char * HbaFileName
Definition: guc_tables.c:537
FILE * open_auth_file(const char *filename, int elevel, int depth, char **err_msg)
Definition: hba.c:600
void free_auth_file(FILE *file, int depth)
Definition: hba.c:575
HbaLine * parse_hba_line(TokenizedAuthLine *tok_line, int elevel)
Definition: hba.c:1327
void tokenize_auth_file(const char *filename, FILE *file, List **tok_lines, int elevel, int depth)
Definition: hba.c:691
static void fill_hba_line(Tuplestorestate *tuple_store, TupleDesc tupdesc, int rule_number, char *filename, int lineno, HbaLine *hba, const char *err_msg)
Definition: hbafuncs.c:180
MemoryContext CurrentMemoryContext
Definition: mcxt.c:135
void MemoryContextDelete(MemoryContext context)
Definition: mcxt.c:403
#define AllocSetContextCreate
Definition: memutils.h:126
#define ALLOCSET_SMALL_SIZES
Definition: memutils.h:160
static MemoryContext MemoryContextSwitchTo(MemoryContext context)
Definition: palloc.h:138
Definition: hba.h:95
int line_num
Definition: hba.h:162
char * file_name
Definition: hba.h:161
char * err_msg
Definition: hba.h:164

References ALLOCSET_SMALL_SIZES, AllocSetContextCreate, CurrentMemoryContext, DEBUG3, TokenizedAuthLine::err_msg, ERROR, TokenizedAuthLine::file_name, fill_hba_line(), free_auth_file(), HbaFileName, lfirst, TokenizedAuthLine::line_num, MemoryContextDelete(), MemoryContextSwitchTo(), NIL, open_auth_file(), parse_hba_line(), and tokenize_auth_file().

Referenced by pg_hba_file_rules().

◆ fill_ident_line()

static void fill_ident_line ( Tuplestorestate tuple_store,
TupleDesc  tupdesc,
int  map_number,
char *  filename,
int  lineno,
IdentLine ident,
const char *  err_msg 
)
static

Definition at line 465 of file hbafuncs.c.

468 {
471  HeapTuple tuple;
472  int index;
473 
475 
476  memset(values, 0, sizeof(values));
477  memset(nulls, 0, sizeof(nulls));
478  index = 0;
479 
480  /* map_number, nothing on error */
481  if (err_msg)
482  nulls[index++] = true;
483  else
484  values[index++] = Int32GetDatum(map_number);
485 
486  /* file_name */
488 
489  /* line_number */
490  values[index++] = Int32GetDatum(lineno);
491 
492  if (ident != NULL)
493  {
494  values[index++] = CStringGetTextDatum(ident->usermap);
495  values[index++] = CStringGetTextDatum(ident->system_user->string);
496  values[index++] = CStringGetTextDatum(ident->pg_user->string);
497  }
498  else
499  {
500  /* no parsing result, so set relevant fields to nulls */
501  memset(&nulls[3], true, (NUM_PG_IDENT_FILE_MAPPINGS_ATTS - 4) * sizeof(bool));
502  }
503 
504  /* error */
505  if (err_msg)
507  else
508  nulls[NUM_PG_IDENT_FILE_MAPPINGS_ATTS - 1] = true;
509 
510  tuple = heap_form_tuple(tupdesc, values, nulls);
511  tuplestore_puttuple(tuple_store, tuple);
512 }
#define NUM_PG_IDENT_FILE_MAPPINGS_ATTS
Definition: hbafuncs.c:447
#define ident
Definition: indent_codes.h:47

References Assert(), CStringGetTextDatum, filename, heap_form_tuple(), ident, Int32GetDatum(), TupleDescData::natts, NUM_PG_IDENT_FILE_MAPPINGS_ATTS, tuplestore_puttuple(), and values.

Referenced by fill_ident_view().

◆ fill_ident_view()

static void fill_ident_view ( Tuplestorestate tuple_store,
TupleDesc  tupdesc 
)
static

Definition at line 518 of file hbafuncs.c.

519 {
520  FILE *file;
521  List *ident_lines = NIL;
522  ListCell *line;
523  int map_number = 0;
524  MemoryContext identcxt;
525  MemoryContext oldcxt;
526 
527  /*
528  * In the unlikely event that we can't open pg_ident.conf, we throw an
529  * error, rather than trying to report it via some sort of view entry.
530  * (Most other error conditions should result in a message in a view
531  * entry.)
532  */
533  file = open_auth_file(IdentFileName, ERROR, 0, NULL);
534 
535  tokenize_auth_file(IdentFileName, file, &ident_lines, DEBUG3, 0);
536 
537  /* Now parse all the lines */
539  "ident parser context",
541  oldcxt = MemoryContextSwitchTo(identcxt);
542  foreach(line, ident_lines)
543  {
544  TokenizedAuthLine *tok_line = (TokenizedAuthLine *) lfirst(line);
545  IdentLine *identline = NULL;
546 
547  /* don't parse lines that already have errors */
548  if (tok_line->err_msg == NULL)
549  identline = parse_ident_line(tok_line, DEBUG3);
550 
551  /* no error, set a new mapping number */
552  if (tok_line->err_msg == NULL)
553  map_number++;
554 
555  fill_ident_line(tuple_store, tupdesc, map_number,
556  tok_line->file_name, tok_line->line_num,
557  identline, tok_line->err_msg);
558  }
559 
560  /* Free tokenizer memory */
561  free_auth_file(file, 0);
562  /* Free parse_ident_line memory */
563  MemoryContextSwitchTo(oldcxt);
564  MemoryContextDelete(identcxt);
565 }
char * IdentFileName
Definition: guc_tables.c:538
IdentLine * parse_ident_line(TokenizedAuthLine *tok_line, int elevel)
Definition: hba.c:2694
static void fill_ident_line(Tuplestorestate *tuple_store, TupleDesc tupdesc, int map_number, char *filename, int lineno, IdentLine *ident, const char *err_msg)
Definition: hbafuncs.c:465
Definition: hba.h:141

References ALLOCSET_SMALL_SIZES, AllocSetContextCreate, CurrentMemoryContext, DEBUG3, TokenizedAuthLine::err_msg, ERROR, TokenizedAuthLine::file_name, fill_ident_line(), free_auth_file(), IdentFileName, lfirst, TokenizedAuthLine::line_num, MemoryContextDelete(), MemoryContextSwitchTo(), NIL, open_auth_file(), parse_ident_line(), and tokenize_auth_file().

Referenced by pg_ident_file_mappings().

◆ get_hba_options()

static ArrayType * get_hba_options ( HbaLine hba)
static

Definition at line 53 of file hbafuncs.c.

54 {
55  int noptions;
57 
58  noptions = 0;
59 
60  if (hba->auth_method == uaGSS || hba->auth_method == uaSSPI)
61  {
62  if (hba->include_realm)
63  options[noptions++] =
64  CStringGetTextDatum("include_realm=true");
65 
66  if (hba->krb_realm)
67  options[noptions++] =
68  CStringGetTextDatum(psprintf("krb_realm=%s", hba->krb_realm));
69  }
70 
71  if (hba->usermap)
72  options[noptions++] =
73  CStringGetTextDatum(psprintf("map=%s", hba->usermap));
74 
75  if (hba->clientcert != clientCertOff)
76  options[noptions++] =
77  CStringGetTextDatum(psprintf("clientcert=%s", (hba->clientcert == clientCertCA) ? "verify-ca" : "verify-full"));
78 
79  if (hba->pamservice)
80  options[noptions++] =
81  CStringGetTextDatum(psprintf("pamservice=%s", hba->pamservice));
82 
83  if (hba->auth_method == uaLDAP)
84  {
85  if (hba->ldapserver)
86  options[noptions++] =
87  CStringGetTextDatum(psprintf("ldapserver=%s", hba->ldapserver));
88 
89  if (hba->ldapport)
90  options[noptions++] =
91  CStringGetTextDatum(psprintf("ldapport=%d", hba->ldapport));
92 
93  if (hba->ldaptls)
94  options[noptions++] =
95  CStringGetTextDatum("ldaptls=true");
96 
97  if (hba->ldapprefix)
98  options[noptions++] =
99  CStringGetTextDatum(psprintf("ldapprefix=%s", hba->ldapprefix));
100 
101  if (hba->ldapsuffix)
102  options[noptions++] =
103  CStringGetTextDatum(psprintf("ldapsuffix=%s", hba->ldapsuffix));
104 
105  if (hba->ldapbasedn)
106  options[noptions++] =
107  CStringGetTextDatum(psprintf("ldapbasedn=%s", hba->ldapbasedn));
108 
109  if (hba->ldapbinddn)
110  options[noptions++] =
111  CStringGetTextDatum(psprintf("ldapbinddn=%s", hba->ldapbinddn));
112 
113  if (hba->ldapbindpasswd)
114  options[noptions++] =
115  CStringGetTextDatum(psprintf("ldapbindpasswd=%s",
116  hba->ldapbindpasswd));
117 
118  if (hba->ldapsearchattribute)
119  options[noptions++] =
120  CStringGetTextDatum(psprintf("ldapsearchattribute=%s",
121  hba->ldapsearchattribute));
122 
123  if (hba->ldapsearchfilter)
124  options[noptions++] =
125  CStringGetTextDatum(psprintf("ldapsearchfilter=%s",
126  hba->ldapsearchfilter));
127 
128  if (hba->ldapscope)
129  options[noptions++] =
130  CStringGetTextDatum(psprintf("ldapscope=%d", hba->ldapscope));
131  }
132 
133  if (hba->auth_method == uaRADIUS)
134  {
135  if (hba->radiusservers_s)
136  options[noptions++] =
137  CStringGetTextDatum(psprintf("radiusservers=%s", hba->radiusservers_s));
138 
139  if (hba->radiussecrets_s)
140  options[noptions++] =
141  CStringGetTextDatum(psprintf("radiussecrets=%s", hba->radiussecrets_s));
142 
143  if (hba->radiusidentifiers_s)
144  options[noptions++] =
145  CStringGetTextDatum(psprintf("radiusidentifiers=%s", hba->radiusidentifiers_s));
146 
147  if (hba->radiusports_s)
148  options[noptions++] =
149  CStringGetTextDatum(psprintf("radiusports=%s", hba->radiusports_s));
150  }
151 
152  /* If you add more options, consider increasing MAX_HBA_OPTIONS. */
154 
155  if (noptions > 0)
156  return construct_array_builtin(options, noptions, TEXTOID);
157  else
158  return NULL;
159 }
ArrayType * construct_array_builtin(Datum *elems, int nelems, Oid elmtype)
Definition: arrayfuncs.c:3375
@ uaLDAP
Definition: hba.h:38
@ uaGSS
Definition: hba.h:34
@ uaRADIUS
Definition: hba.h:40
@ uaSSPI
Definition: hba.h:35
@ clientCertOff
Definition: hba.h:69
@ clientCertCA
Definition: hba.h:70
#define MAX_HBA_OPTIONS
Definition: hbafuncs.c:46
static size_t noptions
char * psprintf(const char *fmt,...)
Definition: psprintf.c:46
char * ldapserver
Definition: hba.h:114
bool include_realm
Definition: hba.h:127
ClientCertMode clientcert
Definition: hba.h:124
char * ldapsearchfilter
Definition: hba.h:119
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
char * radiussecrets_s
Definition: hba.h:133
char * pamservice
Definition: hba.h:110
char * usermap
Definition: hba.h:109
char * ldapsuffix
Definition: hba.h:123
int ldapport
Definition: hba.h:115
char * ldapbindpasswd
Definition: hba.h:117
char * radiusports_s
Definition: hba.h:137
char * ldapbinddn
Definition: hba.h:116
int ldapscope
Definition: hba.h:121
bool ldaptls
Definition: hba.h:112
char * radiusservers_s
Definition: hba.h:131
char * radiusidentifiers_s
Definition: hba.h:135

References Assert(), HbaLine::auth_method, HbaLine::clientcert, clientCertCA, clientCertOff, construct_array_builtin(), CStringGetTextDatum, HbaLine::include_realm, HbaLine::krb_realm, HbaLine::ldapbasedn, HbaLine::ldapbinddn, HbaLine::ldapbindpasswd, HbaLine::ldapport, HbaLine::ldapprefix, HbaLine::ldapscope, HbaLine::ldapsearchattribute, HbaLine::ldapsearchfilter, HbaLine::ldapserver, HbaLine::ldapsuffix, HbaLine::ldaptls, MAX_HBA_OPTIONS, noptions, HbaLine::pamservice, psprintf(), HbaLine::radiusidentifiers_s, HbaLine::radiusports_s, HbaLine::radiussecrets_s, HbaLine::radiusservers_s, uaGSS, uaLDAP, uaRADIUS, uaSSPI, and HbaLine::usermap.

Referenced by fill_hba_line().

◆ pg_hba_file_rules()

Datum pg_hba_file_rules ( PG_FUNCTION_ARGS  )

Definition at line 427 of file hbafuncs.c.

428 {
429  ReturnSetInfo *rsi;
430 
431  /*
432  * Build tuplestore to hold the result rows. We must use the Materialize
433  * mode to be safe against HBA file changes while the cursor is open. It's
434  * also more efficient than having to look up our current position in the
435  * parsed list every time.
436  */
437  InitMaterializedSRF(fcinfo, 0);
438 
439  /* Fill the tuplestore */
440  rsi = (ReturnSetInfo *) fcinfo->resultinfo;
441  fill_hba_view(rsi->setResult, rsi->setDesc);
442 
443  PG_RETURN_NULL();
444 }
#define PG_RETURN_NULL()
Definition: fmgr.h:345
void InitMaterializedSRF(FunctionCallInfo fcinfo, bits32 flags)
Definition: funcapi.c:76
static void fill_hba_view(Tuplestorestate *tuple_store, TupleDesc tupdesc)
Definition: hbafuncs.c:371
TupleDesc setDesc
Definition: execnodes.h:333
Tuplestorestate * setResult
Definition: execnodes.h:332

References fill_hba_view(), InitMaterializedSRF(), PG_RETURN_NULL, ReturnSetInfo::setDesc, and ReturnSetInfo::setResult.

◆ pg_ident_file_mappings()

Datum pg_ident_file_mappings ( PG_FUNCTION_ARGS  )

Definition at line 571 of file hbafuncs.c.

572 {
573  ReturnSetInfo *rsi;
574 
575  /*
576  * Build tuplestore to hold the result rows. We must use the Materialize
577  * mode to be safe against HBA file changes while the cursor is open. It's
578  * also more efficient than having to look up our current position in the
579  * parsed list every time.
580  */
581  InitMaterializedSRF(fcinfo, 0);
582 
583  /* Fill the tuplestore */
584  rsi = (ReturnSetInfo *) fcinfo->resultinfo;
585  fill_ident_view(rsi->setResult, rsi->setDesc);
586 
587  PG_RETURN_NULL();
588 }
static void fill_ident_view(Tuplestorestate *tuple_store, TupleDesc tupdesc)
Definition: hbafuncs.c:518

References fill_ident_view(), InitMaterializedSRF(), PG_RETURN_NULL, ReturnSetInfo::setDesc, and ReturnSetInfo::setResult.