MCPcopy Create free account
hub / github.com/apache/cloudberry / PerformAuthentication

Function PerformAuthentication

src/backend/utils/init/postinit.c:247–361  ·  view source on GitHub ↗

* PerformAuthentication -- authenticate a remote client * * returns: nothing. Will not return at all if there's any failure. */

Source from the content-addressed store, hash-verified

245 * returns: nothing. Will not return at all if there's any failure.
246 */
247static void
248PerformAuthentication(Port *port)
249{
250 /* This should be set already, but let's make sure */
251 ClientAuthInProgress = true; /* limit visibility of log messages */
252
253 /*
254 * In EXEC_BACKEND case, we didn't inherit the contents of pg_hba.conf
255 * etcetera from the postmaster, and have to load them ourselves.
256 *
257 * FIXME: [fork/exec] Ugh. Is there a way around this overhead?
258 */
259#ifdef EXEC_BACKEND
260
261 /*
262 * load_hba() and load_ident() want to work within the PostmasterContext,
263 * so create that if it doesn't exist (which it won't). We'll delete it
264 * again later, in PostgresMain.
265 */
266 if (PostmasterContext == NULL)
267 PostmasterContext = AllocSetContextCreate(TopMemoryContext,
268 "Postmaster",
269 ALLOCSET_DEFAULT_SIZES);
270
271 if (!load_hba())
272 {
273 /*
274 * It makes no sense to continue if we fail to load the HBA file,
275 * since there is no way to connect to the database in this case.
276 */
277 ereport(FATAL,
278 (errmsg("could not load pg_hba.conf")));
279 }
280
281 if (!load_ident())
282 {
283 /*
284 * It is ok to continue if we fail to load the IDENT file, although it
285 * means that you cannot log in using any of the authentication
286 * methods that need a user name mapping. load_ident() already logged
287 * the details of error to the log.
288 */
289 }
290#endif
291
292 /*
293 * Set up a timeout in case a buggy or malicious client fails to respond
294 * during authentication. Since we're inside a transaction and might do
295 * database access, we have to use the statement_timeout infrastructure.
296 */
297 enable_timeout_after(STATEMENT_TIMEOUT, AuthenticationTimeout * 1000);
298
299 /*
300 * Now perform authentication exchange.
301 */
302 set_ps_display("authentication");
303 ClientAuthentication(port); /* might not return, if failure */
304

Callers 1

InitPostgresFunction · 0.85

Calls 15

load_hbaFunction · 0.85
load_identFunction · 0.85
enable_timeout_afterFunction · 0.85
set_ps_displayFunction · 0.85
ClientAuthenticationFunction · 0.85
disable_timeoutFunction · 0.85
initStringInfoFunction · 0.85
appendStringInfoFunction · 0.85
be_tls_get_versionFunction · 0.85
be_tls_get_cipherFunction · 0.85
be_tls_get_cipher_bitsFunction · 0.85
be_gssapi_get_princFunction · 0.85

Tested by

no test coverage detected