@@ -401,44 +401,37 @@ ClientAuthentication(Port *port)
401
401
*/
402
402
{
403
403
char hostinfo [NI_MAXHOST ];
404
+ const char * encryption_state ;
404
405
405
406
pg_getnameinfo_all (& port -> raddr .addr , port -> raddr .salen ,
406
407
hostinfo , sizeof (hostinfo ),
407
408
NULL , 0 ,
408
409
NI_NUMERICHOST );
409
410
410
- if (am_walsender )
411
- {
411
+ encryption_state =
412
+ #ifdef ENABLE_GSS
413
+ (port -> gss && port -> gss -> enc ) ? _ ("GSS encryption" ) :
414
+ #endif
412
415
#ifdef USE_SSL
416
+ port -> ssl_in_use ? _ ("SSL encryption" ) :
417
+ #endif
418
+ _ ("no encryption" );
419
+
420
+ if (am_walsender )
413
421
ereport (FATAL ,
414
422
(errcode (ERRCODE_INVALID_AUTHORIZATION_SPECIFICATION ),
423
+ /* translator: last %s describes encryption state */
415
424
errmsg ("pg_hba.conf rejects replication connection for host \"%s\", user \"%s\", %s" ,
416
425
hostinfo , port -> user_name ,
417
- port -> ssl_in_use ? _ ("SSL on" ) : _ ("SSL off" ))));
418
- #else
419
- ereport (FATAL ,
420
- (errcode (ERRCODE_INVALID_AUTHORIZATION_SPECIFICATION ),
421
- errmsg ("pg_hba.conf rejects replication connection for host \"%s\", user \"%s\"" ,
422
- hostinfo , port -> user_name )));
423
- #endif
424
- }
426
+ encryption_state )));
425
427
else
426
- {
427
- #ifdef USE_SSL
428
428
ereport (FATAL ,
429
429
(errcode (ERRCODE_INVALID_AUTHORIZATION_SPECIFICATION ),
430
+ /* translator: last %s describes encryption state */
430
431
errmsg ("pg_hba.conf rejects connection for host \"%s\", user \"%s\", database \"%s\", %s" ,
431
432
hostinfo , port -> user_name ,
432
433
port -> database_name ,
433
- port -> ssl_in_use ? _ ("SSL on" ) : _ ("SSL off" ))));
434
- #else
435
- ereport (FATAL ,
436
- (errcode (ERRCODE_INVALID_AUTHORIZATION_SPECIFICATION ),
437
- errmsg ("pg_hba.conf rejects connection for host \"%s\", user \"%s\", database \"%s\"" ,
438
- hostinfo , port -> user_name ,
439
- port -> database_name )));
440
- #endif
441
- }
434
+ encryption_state )));
442
435
break ;
443
436
}
444
437
@@ -454,12 +447,22 @@ ClientAuthentication(Port *port)
454
447
*/
455
448
{
456
449
char hostinfo [NI_MAXHOST ];
450
+ const char * encryption_state ;
457
451
458
452
pg_getnameinfo_all (& port -> raddr .addr , port -> raddr .salen ,
459
453
hostinfo , sizeof (hostinfo ),
460
454
NULL , 0 ,
461
455
NI_NUMERICHOST );
462
456
457
+ encryption_state =
458
+ #ifdef ENABLE_GSS
459
+ (port -> gss && port -> gss -> enc ) ? _ ("GSS encryption" ) :
460
+ #endif
461
+ #ifdef USE_SSL
462
+ port -> ssl_in_use ? _ ("SSL encryption" ) :
463
+ #endif
464
+ _ ("no encryption" );
465
+
463
466
#define HOSTNAME_LOOKUP_DETAIL (port ) \
464
467
(port->remote_hostname ? \
465
468
(port->remote_hostname_resolv == +1 ? \
@@ -482,41 +485,22 @@ ClientAuthentication(Port *port)
482
485
0))
483
486
484
487
if (am_walsender )
485
- {
486
- #ifdef USE_SSL
487
488
ereport (FATAL ,
488
489
(errcode (ERRCODE_INVALID_AUTHORIZATION_SPECIFICATION ),
490
+ /* translator: last %s describes encryption state */
489
491
errmsg ("no pg_hba.conf entry for replication connection from host \"%s\", user \"%s\", %s" ,
490
492
hostinfo , port -> user_name ,
491
- port -> ssl_in_use ? _ ( "SSL on" ) : _ ( "SSL off" ) ),
493
+ encryption_state ),
492
494
HOSTNAME_LOOKUP_DETAIL (port )));
493
- #else
494
- ereport (FATAL ,
495
- (errcode (ERRCODE_INVALID_AUTHORIZATION_SPECIFICATION ),
496
- errmsg ("no pg_hba.conf entry for replication connection from host \"%s\", user \"%s\"" ,
497
- hostinfo , port -> user_name ),
498
- HOSTNAME_LOOKUP_DETAIL (port )));
499
- #endif
500
- }
501
495
else
502
- {
503
- #ifdef USE_SSL
504
496
ereport (FATAL ,
505
497
(errcode (ERRCODE_INVALID_AUTHORIZATION_SPECIFICATION ),
498
+ /* translator: last %s describes encryption state */
506
499
errmsg ("no pg_hba.conf entry for host \"%s\", user \"%s\", database \"%s\", %s" ,
507
500
hostinfo , port -> user_name ,
508
501
port -> database_name ,
509
- port -> ssl_in_use ? _ ("SSL on" ) : _ ("SSL off" )),
510
- HOSTNAME_LOOKUP_DETAIL (port )));
511
- #else
512
- ereport (FATAL ,
513
- (errcode (ERRCODE_INVALID_AUTHORIZATION_SPECIFICATION ),
514
- errmsg ("no pg_hba.conf entry for host \"%s\", user \"%s\", database \"%s\"" ,
515
- hostinfo , port -> user_name ,
516
- port -> database_name ),
502
+ encryption_state ),
517
503
HOSTNAME_LOOKUP_DETAIL (port )));
518
- #endif
519
- }
520
504
break ;
521
505
}
522
506
0 commit comments