@ -47,7 +47,7 @@
*/
*/
static void sendAuthRequest ( Port * port , AuthRequest areq , const char * extradata ,
static void sendAuthRequest ( Port * port , AuthRequest areq , const char * extradata ,
int extralen ) ;
int extralen ) ;
static void auth_failed ( Port * port , int status , const char * logdetail ) ;
static void auth_failed ( Port * port , int status , char * logdetail ) ;
static char * recv_password_packet ( Port * port ) ;
static char * recv_password_packet ( Port * port ) ;
static void set_authn_id ( Port * port , const char * id ) ;
static void set_authn_id ( Port * port , const char * id ) ;
@ -56,11 +56,11 @@ static void set_authn_id(Port *port, const char *id);
* Password - based authentication methods ( password , md5 , and scram - sha - 256 )
* Password - based authentication methods ( password , md5 , and scram - sha - 256 )
* - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
* - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
*/
*/
static int CheckPasswordAuth ( Port * port , const char * * logdetail ) ;
static int CheckPasswordAuth ( Port * port , char * * logdetail ) ;
static int CheckPWChallengeAuth ( Port * port , const char * * logdetail ) ;
static int CheckPWChallengeAuth ( Port * port , char * * logdetail ) ;
static int CheckMD5Auth ( Port * port , char * shadow_pass , const char * * logdetail ) ;
static int CheckMD5Auth ( Port * port , char * shadow_pass , char * * logdetail ) ;
static int CheckSCRAMAuth ( Port * port , char * shadow_pass , const char * * logdetail ) ;
static int CheckSCRAMAuth ( Port * port , char * shadow_pass , char * * logdetail ) ;
/*----------------------------------------------------------------
/*----------------------------------------------------------------
@ -258,7 +258,7 @@ ClientAuthentication_hook_type ClientAuthentication_hook = NULL;
* particular , if logdetail isn ' t NULL , we send that string to the log .
* particular , if logdetail isn ' t NULL , we send that string to the log .
*/
*/
static void
static void
auth_failed ( Port * port , int status , const char * logdetail )
auth_failed ( Port * port , int status , char * logdetail )
{
{
const char * errstr ;
const char * errstr ;
char * cdetail ;
char * cdetail ;
@ -394,7 +394,7 @@ void
ClientAuthentication ( Port * port )
ClientAuthentication ( Port * port )
{
{
int status = STATUS_ERROR ;
int status = STATUS_ERROR ;
const char * logdetail = NULL ;
char * logdetail = NULL ;
/*
/*
* Get the authentication method to use for this frontend / database
* Get the authentication method to use for this frontend / database
@ -780,7 +780,7 @@ recv_password_packet(Port *port)
* Plaintext password authentication .
* Plaintext password authentication .
*/
*/
static int
static int
CheckPasswordAuth ( Port * port , const char * * logdetail )
CheckPasswordAuth ( Port * port , char * * logdetail )
{
{
char * passwd ;
char * passwd ;
int result ;
int result ;
@ -815,7 +815,7 @@ CheckPasswordAuth(Port *port, const char **logdetail)
* MD5 and SCRAM authentication .
* MD5 and SCRAM authentication .
*/
*/
static int
static int
CheckPWChallengeAuth ( Port * port , const char * * logdetail )
CheckPWChallengeAuth ( Port * port , char * * logdetail )
{
{
int auth_result ;
int auth_result ;
char * shadow_pass ;
char * shadow_pass ;
@ -875,7 +875,7 @@ CheckPWChallengeAuth(Port *port, const char **logdetail)
}
}
static int
static int
CheckMD5Auth ( Port * port , char * shadow_pass , const char * * logdetail )
CheckMD5Auth ( Port * port , char * shadow_pass , char * * logdetail )
{
{
char md5Salt [ 4 ] ; /* Password salt */
char md5Salt [ 4 ] ; /* Password salt */
char * passwd ;
char * passwd ;
@ -912,7 +912,7 @@ CheckMD5Auth(Port *port, char *shadow_pass, const char **logdetail)
}
}
static int
static int
CheckSCRAMAuth ( Port * port , char * shadow_pass , const char * * logdetail )
CheckSCRAMAuth ( Port * port , char * shadow_pass , char * * logdetail )
{
{
StringInfoData sasl_mechs ;
StringInfoData sasl_mechs ;
int mtype ;
int mtype ;
@ -3240,8 +3240,6 @@ PerformRadiusTransaction(const char *server, const char *secret, const char *por
md5trailer = packet - > vector ;
md5trailer = packet - > vector ;
for ( i = 0 ; i < encryptedpasswordlen ; i + = RADIUS_VECTOR_LENGTH )
for ( i = 0 ; i < encryptedpasswordlen ; i + = RADIUS_VECTOR_LENGTH )
{
{
const char * errstr = NULL ;
memcpy ( cryptvector + strlen ( secret ) , md5trailer , RADIUS_VECTOR_LENGTH ) ;
memcpy ( cryptvector + strlen ( secret ) , md5trailer , RADIUS_VECTOR_LENGTH ) ;
/*
/*
@ -3250,12 +3248,10 @@ PerformRadiusTransaction(const char *server, const char *secret, const char *por
*/
*/
md5trailer = encryptedpassword + i ;
md5trailer = encryptedpassword + i ;
if ( ! pg_md5_binary ( cryptvector , strlen ( secret ) + RADIUS_VECTOR_LENGTH ,
if ( ! pg_md5_binary ( cryptvector , strlen ( secret ) + RADIUS_VECTOR_LENGTH , encryptedpassword + i ) )
encryptedpassword + i , & errstr ) )
{
{
ereport ( LOG ,
ereport ( LOG ,
( errmsg ( " could not perform MD5 encryption of password: %s " ,
( errmsg ( " could not perform MD5 encryption of password " ) ) ) ;
errstr ) ) ) ;
pfree ( cryptvector ) ;
pfree ( cryptvector ) ;
pg_freeaddrinfo_all ( hint . ai_family , serveraddrs ) ;
pg_freeaddrinfo_all ( hint . ai_family , serveraddrs ) ;
return STATUS_ERROR ;
return STATUS_ERROR ;
@ -3340,7 +3336,6 @@ PerformRadiusTransaction(const char *server, const char *secret, const char *por
struct timeval timeout ;
struct timeval timeout ;
struct timeval now ;
struct timeval now ;
int64 timeoutval ;
int64 timeoutval ;
const char * errstr = NULL ;
gettimeofday ( & now , NULL ) ;
gettimeofday ( & now , NULL ) ;
timeoutval = ( endtime . tv_sec * 1000000 + endtime . tv_usec ) - ( now . tv_sec * 1000000 + now . tv_usec ) ;
timeoutval = ( endtime . tv_sec * 1000000 + endtime . tv_usec ) - ( now . tv_sec * 1000000 + now . tv_usec ) ;
@ -3459,11 +3454,10 @@ PerformRadiusTransaction(const char *server, const char *secret, const char *por
if ( ! pg_md5_binary ( cryptvector ,
if ( ! pg_md5_binary ( cryptvector ,
packetlength + strlen ( secret ) ,
packetlength + strlen ( secret ) ,
encryptedpassword , & errstr ) )
encryptedpassword ) )
{
{
ereport ( LOG ,
ereport ( LOG ,
( errmsg ( " could not perform MD5 encryption of received packet: %s " ,
( errmsg ( " could not perform MD5 encryption of received packet " ) ) ) ;
errstr ) ) ) ;
pfree ( cryptvector ) ;
pfree ( cryptvector ) ;
continue ;
continue ;
}
}