PgUser *auth_user; /* presented login, for client it may differ from pool->user */
+ int client_auth_type; /* auth method decided by hba */
+
SocketState state:8; /* this also specifies socket location */
bool ready:1; /* server: accepts new query */
{
char md5[MD5_PASSWD_LEN + 1];
PgUser *user = client->auth_user;
+ int auth_type = client->client_auth_type;
/* disallow empty passwords */
if (!*passwd || !*user->passwd)
return false;
- switch (cf_auth_type) {
+ switch (auth_type) {
case AUTH_PLAIN:
return strcmp(user->passwd, passwd) == 0;
case AUTH_MD5:
{
uint8_t saltlen = 0;
int res;
- int auth = cf_auth_type;
+ int auth_type = client->client_auth_type;
- if (cf_auth_type == AUTH_MD5) {
+ if (auth_type == AUTH_MD5) {
saltlen = 4;
get_random_bytes((void*)client->tmp_login_salt, saltlen);
- } else if (cf_auth_type == AUTH_PLAIN) {
+ } else if (auth_type == AUTH_PLAIN) {
/* nothing to do */
} else {
return false;
}
- SEND_generic(res, client, 'R', "ib", auth, client->tmp_login_salt, saltlen);
+ SEND_generic(res, client, 'R', "ib", auth_type, client->tmp_login_salt, saltlen);
if (!res)
disconnect_client(client, false, "failed to send auth req");
return res;
client->db->name, client->auth_user->name);
}
+ /* remember method */
+ client->client_auth_type = auth;
+
switch (auth) {
case AUTH_ANY:
case AUTH_TRUST: