39
39
* Global authentication functions
40
40
*----------------------------------------------------------------
41
41
*/
42
- static void sendAuthRequest (Port * port , AuthRequest areq );
42
+ static void sendAuthRequest (Port * port , AuthRequest areq , char * extradata ,
43
+ int extralen );
43
44
static void auth_failed (Port * port , int status , char * logdetail );
44
45
static char * recv_password_packet (Port * port );
45
46
static int recv_and_check_password_packet (Port * port , char * * logdetail );
@@ -507,7 +508,7 @@ ClientAuthentication(Port *port)
507
508
508
509
case uaGSS :
509
510
#ifdef ENABLE_GSS
510
- sendAuthRequest (port , AUTH_REQ_GSS );
511
+ sendAuthRequest (port , AUTH_REQ_GSS , NULL , 0 );
511
512
status = pg_GSS_recvauth (port );
512
513
#else
513
514
Assert (false);
@@ -516,7 +517,7 @@ ClientAuthentication(Port *port)
516
517
517
518
case uaSSPI :
518
519
#ifdef ENABLE_SSPI
519
- sendAuthRequest (port , AUTH_REQ_SSPI );
520
+ sendAuthRequest (port , AUTH_REQ_SSPI , NULL , 0 );
520
521
status = pg_SSPI_recvauth (port );
521
522
#else
522
523
Assert (false);
@@ -544,7 +545,7 @@ ClientAuthentication(Port *port)
544
545
break ;
545
546
546
547
case uaPassword :
547
- sendAuthRequest (port , AUTH_REQ_PASSWORD );
548
+ sendAuthRequest (port , AUTH_REQ_PASSWORD , NULL , 0 );
548
549
status = recv_and_check_password_packet (port , & logdetail );
549
550
break ;
550
551
@@ -591,7 +592,7 @@ ClientAuthentication(Port *port)
591
592
(* ClientAuthentication_hook ) (port , status );
592
593
593
594
if (status == STATUS_OK )
594
- sendAuthRequest (port , AUTH_REQ_OK );
595
+ sendAuthRequest (port , AUTH_REQ_OK , NULL , 0 );
595
596
else
596
597
auth_failed (port , status , logdetail );
597
598
}
@@ -601,36 +602,16 @@ ClientAuthentication(Port *port)
601
602
* Send an authentication request packet to the frontend.
602
603
*/
603
604
static void
604
- sendAuthRequest (Port * port , AuthRequest areq )
605
+ sendAuthRequest (Port * port , AuthRequest areq , char * extradata , int extralen )
605
606
{
606
607
StringInfoData buf ;
607
608
608
609
CHECK_FOR_INTERRUPTS ();
609
610
610
611
pq_beginmessage (& buf , 'R' );
611
612
pq_sendint (& buf , (int32 ) areq , sizeof (int32 ));
612
-
613
- /* Add the salt for encrypted passwords. */
614
- if (areq == AUTH_REQ_MD5 )
615
- pq_sendbytes (& buf , port -> md5Salt , 4 );
616
-
617
- #if defined(ENABLE_GSS ) || defined(ENABLE_SSPI )
618
-
619
- /*
620
- * Add the authentication data for the next step of the GSSAPI or SSPI
621
- * negotiation.
622
- */
623
- else if (areq == AUTH_REQ_GSS_CONT )
624
- {
625
- if (port -> gss -> outbuf .length > 0 )
626
- {
627
- elog (DEBUG4 , "sending GSS token of length %u" ,
628
- (unsigned int ) port -> gss -> outbuf .length );
629
-
630
- pq_sendbytes (& buf , port -> gss -> outbuf .value , port -> gss -> outbuf .length );
631
- }
632
- }
633
- #endif
613
+ if (extralen > 0 )
614
+ pq_sendbytes (& buf , extradata , extralen );
634
615
635
616
pq_endmessage (& buf );
636
617
@@ -957,7 +938,8 @@ pg_GSS_recvauth(Port *port)
957
938
elog (DEBUG4 , "sending GSS response token of length %u" ,
958
939
(unsigned int ) port -> gss -> outbuf .length );
959
940
960
- sendAuthRequest (port , AUTH_REQ_GSS_CONT );
941
+ sendAuthRequest (port , AUTH_REQ_GSS_CONT ,
942
+ port -> gss -> outbuf .value , port -> gss -> outbuf .length );
961
943
962
944
gss_release_buffer (& lmin_s , & port -> gss -> outbuf );
963
945
}
@@ -1202,7 +1184,8 @@ pg_SSPI_recvauth(Port *port)
1202
1184
port -> gss -> outbuf .length = outbuf .pBuffers [0 ].cbBuffer ;
1203
1185
port -> gss -> outbuf .value = outbuf .pBuffers [0 ].pvBuffer ;
1204
1186
1205
- sendAuthRequest (port , AUTH_REQ_GSS_CONT );
1187
+ sendAuthRequest (port , AUTH_REQ_GSS_CONT ,
1188
+ port -> gss -> outbuf .value , port -> gss -> outbuf .length );
1206
1189
1207
1190
FreeContextBuffer (outbuf .pBuffers [0 ].pvBuffer );
1208
1191
}
@@ -1830,7 +1813,7 @@ pam_passwd_conv_proc(int num_msg, const struct pam_message ** msg,
1830
1813
* let's go ask the client to send a password, which we
1831
1814
* then stuff into PAM.
1832
1815
*/
1833
- sendAuthRequest (pam_port_cludge , AUTH_REQ_PASSWORD );
1816
+ sendAuthRequest (pam_port_cludge , AUTH_REQ_PASSWORD , NULL , 0 );
1834
1817
passwd = recv_password_packet (pam_port_cludge );
1835
1818
if (passwd == NULL )
1836
1819
{
@@ -2160,7 +2143,7 @@ CheckLDAPAuth(Port *port)
2160
2143
if (port -> hba -> ldapport == 0 )
2161
2144
port -> hba -> ldapport = LDAP_PORT ;
2162
2145
2163
- sendAuthRequest (port , AUTH_REQ_PASSWORD );
2146
+ sendAuthRequest (port , AUTH_REQ_PASSWORD , NULL , 0 );
2164
2147
2165
2148
passwd = recv_password_packet (port );
2166
2149
if (passwd == NULL )
@@ -2520,7 +2503,7 @@ CheckRADIUSAuth(Port *port)
2520
2503
identifier = port -> hba -> radiusidentifier ;
2521
2504
2522
2505
/* Send regular password request to client, and get the response */
2523
- sendAuthRequest (port , AUTH_REQ_PASSWORD );
2506
+ sendAuthRequest (port , AUTH_REQ_PASSWORD , NULL , 0 );
2524
2507
2525
2508
passwd = recv_password_packet (port );
2526
2509
if (passwd == NULL )
0 commit comments