|
PostgreSQL Source Code git master
|
#include "postgres.h"#include <ctype.h>#include <pwd.h>#include <fcntl.h>#include <sys/param.h>#include <sys/socket.h>#include <netdb.h>#include <netinet/in.h>#include <arpa/inet.h>#include <unistd.h>#include "catalog/pg_collation.h"#include "common/ip.h"#include "common/string.h"#include "libpq/hba.h"#include "libpq/ifaddr.h"#include "libpq/libpq-be.h"#include "libpq/oauth.h"#include "postmaster/postmaster.h"#include "regex/regex.h"#include "replication/walsender.h"#include "storage/fd.h"#include "utils/acl.h"#include "utils/conffiles.h"#include "utils/guc.h"#include "utils/memutils.h"#include "utils/varlena.h"
Go to the source code of this file.
Data Structures | |
| struct | check_network_data |
| struct | tokenize_error_callback_arg |
Macros | |
| #define | token_has_regexp(t) (t->regex != NULL) |
| #define | token_is_member_check(t) (!t->quoted && t->string[0] == '+') |
| #define | token_is_keyword(t, k) (!t->quoted && strcmp(t->string, k) == 0) |
| #define | token_matches(t, k) (strcmp(t->string, k) == 0) |
| #define | token_matches_insensitive(t, k) (pg_strcasecmp(t->string, k) == 0) |
| #define | INVALID_AUTH_OPTION(optname, validmethods) |
| #define | REQUIRE_AUTH_OPTION(methodval, optname, validmethods) |
| #define | MANDATORY_AUTH_ARG(argvar, argname, authname) |
| #define | IDENT_FIELD_ABSENT(field) |
| #define | IDENT_MULTI_VALUE(tokens) |
Typedefs | |
| typedef struct check_network_data | check_network_data |
| #define IDENT_FIELD_ABSENT | ( | field | ) |
| #define INVALID_AUTH_OPTION | ( | optname, | |
| validmethods | |||
| ) |
Definition at line 1241 of file hba.c.
| #define REQUIRE_AUTH_OPTION | ( | methodval, | |
| optname, | |||
| validmethods | |||
| ) |
Definition at line 1255 of file hba.c.
| #define token_matches_insensitive | ( | t, | |
| k | |||
| ) | (pg_strcasecmp(t->string, k) == 0) |
Definition at line 990 of file hba.c.
References am_db_walsender, am_walsender, dbname, fb(), is_member(), lfirst, REG_OKAY, regexec_auth_token(), token_has_regexp, token_is_keyword, and token_matches.
Referenced by check_hba().
Definition at line 2528 of file hba.c.
References HbaLine::addr, HbaLine::auth_method, check_db(), check_hostname(), check_ip(), check_role(), check_same_host_or_net(), HbaLine::conntype, ctHostGSS, ctHostNoGSS, ctHostNoSSL, ctHostSSL, ctLocal, HbaLine::databases, fb(), get_role_oid(), HbaLine::hostname, HbaLine::ip_cmp_method, ipCmpAll, ipCmpMask, ipCmpSameHost, ipCmpSameNet, lfirst, HbaLine::mask, palloc0_object, parsed_hba_lines, port, HbaLine::roles, and uaImplicitReject.
Referenced by hba_getauthmethod().
Definition at line 1075 of file hba.c.
References DEBUG2, elog, fb(), hostname, hostname_match(), ipv4eq(), ipv6eq(), pg_getnameinfo_all(), port, and pstrdup().
Referenced by check_hba().
|
static |
Definition at line 2816 of file hba.c.
References check_role(), ereport, errcode(), errmsg(), fb(), free_auth_token(), get_role_oid(), list_make1, LOG, make_auth_token(), palloc(), pfree(), pg_regerror(), REG_NOMATCH, regexec_auth_token(), regmatch_t, system_user(), token_has_regexp, token_is_member_check, token_matches, and token_matches_insensitive.
Referenced by check_usermap().
Definition at line 1166 of file hba.c.
References SockAddr::addr, fb(), and pg_range_sockaddr().
Referenced by check_hba(), and check_network_callback().
|
static |
Definition at line 1180 of file hba.c.
References check_ip(), fb(), ipCmpSameHost, and pg_sockaddr_cidr_mask().
Referenced by check_same_host_or_net().
|
static |
Definition at line 951 of file hba.c.
References fb(), is_member(), lfirst, REG_OKAY, regexec_auth_token(), token_has_regexp, token_is_keyword, token_is_member_check, token_matches, and token_matches_insensitive.
Referenced by check_hba(), and check_ident_usermap().
|
static |
Definition at line 1207 of file hba.c.
References check_network_callback(), ereport, errmsg(), fb(), LOG, check_network_data::method, and pg_foreach_ifaddr().
Referenced by check_hba().
| int check_usermap | ( | const char * | usermap_name, |
| const char * | pg_user, | ||
| const char * | system_user, | ||
| bool | case_insensitive | ||
| ) |
Definition at line 2981 of file hba.c.
References check_ident_usermap(), ereport, errmsg(), error(), fb(), lfirst, LOG, parsed_ident_lines, pg_strcasecmp(), STATUS_ERROR, STATUS_OK, and system_user().
Referenced by auth_peer(), ident_inet(), and validate().
Definition at line 287 of file hba.c.
References make_auth_token(), AuthToken::quoted, and AuthToken::string.
Referenced by parse_hba_line(), and parse_ident_line().
Definition at line 569 of file hba.c.
References CONF_FILE_START_DEPTH, fb(), FreeFile(), MemoryContextDelete(), and tokenize_context.
Referenced by fill_hba_view(), fill_ident_view(), load_hba(), load_ident(), tokenize_expand_file(), and tokenize_include_file().
Definition at line 277 of file hba.c.
References pg_regfree(), and token_has_regexp.
Referenced by check_ident_usermap().
Definition at line 3138 of file hba.c.
References UserAuthName.
Referenced by ClientAuthentication(), fill_hba_line(), InitPostgres(), ParallelWorkerMain(), and set_authn_id().
Definition at line 3125 of file hba.c.
References check_hba(), and port.
Referenced by ClientAuthentication().
Definition at line 1055 of file hba.c.
References fb(), and pg_strcasecmp().
Referenced by check_hostname().
|
static |
|
static |
Definition at line 922 of file hba.c.
References get_role_oid(), is_member_of_role_nosuper(), and OidIsValid.
Referenced by check_db(), and check_role().
Definition at line 2642 of file hba.c.
References ALLOCSET_SMALL_SIZES, AllocSetContextCreate, Assert, ereport, errcode(), errmsg(), fb(), free_auth_file(), HbaFileName, lappend(), lfirst, LOG, MemoryContextDelete(), MemoryContextSwitchTo(), newline, NIL, open_auth_file(), parse_hba_line(), parsed_hba_context, parsed_hba_lines, PostmasterContext, and tokenize_auth_file().
Referenced by PerformAuthentication(), PostmasterMain(), and process_pm_reload_request().
Definition at line 3036 of file hba.c.
References ALLOCSET_SMALL_SIZES, AllocSetContextCreate, Assert, fb(), free_auth_file(), IdentFileName, lappend(), lfirst, LOG, MemoryContextDelete(), MemoryContextSwitchTo(), newline, NIL, open_auth_file(), parse_ident_line(), parsed_ident_context, parsed_ident_lines, PostmasterContext, and tokenize_auth_file().
Referenced by PerformAuthentication(), PostmasterMain(), and process_pm_reload_request().
Definition at line 256 of file hba.c.
References fb(), and palloc0().
Referenced by check_ident_usermap(), copy_auth_token(), and next_field_expand().
|
static |
Definition at line 378 of file hba.c.
References buf, fb(), filename, initStringInfo(), lappend(), make_auth_token(), MemoryContextSwitchTo(), next_token(), NIL, pfree(), tokenize_context, and tokenize_expand_file().
Referenced by tokenize_auth_file().
|
static |
Definition at line 184 of file hba.c.
References appendStringInfoChar(), buf, fb(), pg_isblank(), and resetStringInfo().
Referenced by base_yylex(), filtered_base_yylex(), and next_field_expand().
Definition at line 594 of file hba.c.
References AllocateFile(), ALLOCSET_START_SMALL_SIZES, AllocSetContextCreate, CONF_FILE_MAX_DEPTH, CONF_FILE_START_DEPTH, CurrentMemoryContext, ereport, errcode_for_file_access(), errmsg(), fb(), filename, psprintf(), and tokenize_context.
Referenced by fill_hba_view(), fill_ident_view(), load_hba(), load_ident(), tokenize_expand_file(), and tokenize_include_file().
|
static |
Definition at line 2084 of file hba.c.
References clientCertCA, clientCertCN, clientCertDN, clientCertFull, ctHostSSL, ereport, errcode(), errcontext, errmsg(), fb(), gai_strerror(), gettext_noop, INVALID_AUTH_OPTION, lfirst, list_free(), MemSet, name, pg_freeaddrinfo_all(), pg_getaddrinfo_all(), psprintf(), pstrdup(), REQUIRE_AUTH_OPTION, SplitGUCList(), uaCert, uaGSS, uaIdent, uaLDAP, uaOAuth, uaPAM, uaPeer, uaRADIUS, uaSSPI, and val.
Referenced by parse_hba_line().
| HbaLine * parse_hba_line | ( | TokenizedAuthLine * | tok_line, |
| int | elevel | ||
| ) |
Definition at line 1325 of file hba.c.
References Assert, check_oauth_validator(), clientCertFull, copy_auth_token(), ctHost, ctHostGSS, ctHostNoGSS, ctHostNoSSL, ctHostSSL, ctLocal, EnableSSL, ereport, errcode(), errcontext, errhint(), errmsg(), fb(), gai_strerror(), ipCmpAll, ipCmpMask, ipCmpSameHost, ipCmpSameNet, lappend(), lfirst, linitial, list_head(), list_length(), lnext(), MANDATORY_AUTH_ARG, NIL, palloc0_object, parse_hba_auth_opt(), pfree(), pg_freeaddrinfo_all(), pg_getaddrinfo_all(), pg_sockaddr_cidr_mask(), psprintf(), pstrdup(), regcomp_auth_token(), str, token, token_is_keyword, uaBSD, uaCert, uaGSS, uaIdent, uaLDAP, uaMD5, uaOAuth, uaPAM, uaPassword, uaPeer, uaRADIUS, uaReject, uaSCRAM, uaSSPI, uaTrust, and val.
Referenced by fill_hba_view(), and load_hba().
| IdentLine * parse_ident_line | ( | TokenizedAuthLine * | tok_line, |
| int | elevel | ||
| ) |
Definition at line 2748 of file hba.c.
References Assert, copy_auth_token(), fb(), IDENT_FIELD_ABSENT, IDENT_MULTI_VALUE, lfirst, linitial, list_head(), lnext(), NIL, palloc0_object, pstrdup(), regcomp_auth_token(), and token.
Referenced by fill_ident_view(), and load_ident().
Definition at line 142 of file hba.c.
References fb(), and IS_HIGHBIT_SET.
Referenced by next_token().
|
static |
Definition at line 300 of file hba.c.
References Assert, ereport, errcode(), errcontext, errmsg(), fb(), filename, palloc(), palloc0_object, pfree(), pg_mb2wchar_with_len(), pg_regcomp(), pg_regerror(), psprintf(), REG_ADVANCED, and regex_t.
Referenced by parse_hba_line(), and parse_ident_line().
|
static |
Definition at line 345 of file hba.c.
References Assert, fb(), palloc(), pfree(), pg_mb2wchar_with_len(), and pg_regexec().
Referenced by check_db(), check_ident_usermap(), and check_role().
| StaticAssertDecl | ( | lengthof(UserAuthName) | = =USER_AUTH_LAST+1, |
| "UserAuthName []must match the UserAuth enum" | |||
| ) |
| void tokenize_auth_file | ( | const char * | filename, |
| FILE * | file, | ||
| List ** | tok_lines, | ||
| int | elevel, | ||
| int | depth | ||
| ) |
Definition at line 688 of file hba.c.
References ALLOCSET_SMALL_SIZES, AllocSetContextCreate, appendStringInfoChar(), appendStringInfoString(), Assert, buf, CONF_FILE_START_DEPTH, CurrentMemoryContext, ereport, errcode_for_file_access(), errmsg(), error_context_stack, fb(), tokenize_error_callback_arg::filename, filename, GetConfFilesInDir(), i, initStringInfo(), lappend(), tokenize_error_callback_arg::linenum, linitial, linitial_node, list_length(), lsecond_node, MemoryContextDelete(), MemoryContextSwitchTo(), next_field_expand(), NIL, palloc0_object, pfree(), pg_get_line_append(), pg_strip_crlf(), ErrorContextCallback::previous, psprintf(), pstrdup(), resetStringInfo(), AuthToken::string, tokenize_context, tokenize_error_callback(), and tokenize_include_file().
Referenced by fill_hba_view(), fill_ident_view(), load_hba(), load_ident(), tokenize_expand_file(), and tokenize_include_file().
Definition at line 659 of file hba.c.
References arg, errcontext, tokenize_error_callback_arg::filename, and tokenize_error_callback_arg::linenum.
Referenced by tokenize_auth_file().
|
static |
Definition at line 492 of file hba.c.
References AbsoluteConfigLocation(), fb(), free_auth_file(), lappend(), lfirst, MemoryContextSwitchTo(), NIL, open_auth_file(), pfree(), pstrdup(), tokenize_auth_file(), and tokenize_context.
Referenced by next_field_expand().
|
static |
Definition at line 437 of file hba.c.
References AbsoluteConfigLocation(), Assert, ereport, errmsg(), fb(), free_auth_file(), open_auth_file(), pfree(), and tokenize_auth_file().
Referenced by tokenize_auth_file().
|
static |
Definition at line 87 of file hba.c.
Referenced by load_hba().
Definition at line 86 of file hba.c.
Referenced by check_hba(), and load_hba().
|
static |
Definition at line 94 of file hba.c.
Referenced by load_ident().
Definition at line 93 of file hba.c.
Referenced by check_usermap(), and load_ident().
|
static |
Definition at line 80 of file hba.c.
Referenced by free_auth_file(), next_field_expand(), open_auth_file(), tokenize_auth_file(), and tokenize_expand_file().
Definition at line 102 of file hba.c.
Referenced by hba_authname().