* PerformAuthentication -- authenticate a remote client * * returns: nothing. Will not return at all if there's any failure. */
| 245 | * returns: nothing. Will not return at all if there's any failure. |
| 246 | */ |
| 247 | static void |
| 248 | PerformAuthentication(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 |
no test coverage detected