pgpool2.git / summary / log / commit / refs
commit e72995ee2f9f486a9833186c15fdcd192b642923
Author: Tatsuo Ishii <ishii at sraoss.co.jp>
Date: Tue Oct 30 12:44:04 2007 +0000
Fix confusing variable name
Enhance error message
Check unsupported auth method
pool_auth.c | 37 ++++++++++++++++++++++---------------
1 file changed, 22 insertions(+), 15 deletions(-)
diff --git a/pool_auth.c b/pool_auth.c
index 6fb8d5e98..057b59c04 100644
--- a/pool_auth.c
+++ b/pool_auth.c
@@ -53,6 +53,7 @@ int pool_do_auth(POOL_CONNECTION *frontend, POOL_CONNECTION_POOL *cp)
int key;
int protoMajor;
int length;
+ int authkind;
int i;
StartupPacket *sp;
@@ -105,17 +106,17 @@ int pool_do_auth(POOL_CONNECTION *frontend, POOL_CONNECTION_POOL *cp)
* in non replication mode, we support kind = 0, 3, 4, 5
*/
- pid = pool_read_int(cp);
- if (pid < 0)
+ authkind = pool_read_int(cp);
+ if (authkind < 0)
{
- pool_error("pool_do_auth: read pid failed");
+ pool_error("pool_do_auth: read auth kind failed");
return -1;
}
- pid = ntohl(pid);
+ authkind = ntohl(authkind);
/* trust? */
- if (pid == 0)
+ if (authkind == 0)
{
int msglen;
@@ -136,15 +137,15 @@ int pool_do_auth(POOL_CONNECTION *frontend, POOL_CONNECTION_POOL *cp)
}
/* clear text password authentication? */
- else if (pid == 3)
+ else if (authkind == 3)
{
for (i=0;i<NUM_BACKENDS;i++)
{
pool_debug("trying clear text password authentication");
- pid = do_clear_text_password(CONNECTION(cp, i), frontend, 0, protoMajor);
+ authkind = do_clear_text_password(CONNECTION(cp, i), frontend, 0, protoMajor);
- if (pid < 0)
+ if (authkind < 0)
{
pool_error("do_clear_text_password failed in slot %d", i);
return -1;
@@ -153,15 +154,15 @@ int pool_do_auth(POOL_CONNECTION *frontend, POOL_CONNECTION_POOL *cp)
}
/* crypt authentication? */
- else if (pid == 4)
+ else if (authkind == 4)
{
for (i=0;i<NUM_BACKENDS;i++)
{
pool_debug("trying crypt authentication");
- pid = do_crypt(CONNECTION(cp, i), frontend, 0, protoMajor);
+ authkind = do_crypt(CONNECTION(cp, i), frontend, 0, protoMajor);
- if (pid < 0)
+ if (authkind < 0)
{
pool_error("do_crypt_text_password failed in slot %d", i);
return -1;
@@ -170,7 +171,7 @@ int pool_do_auth(POOL_CONNECTION *frontend, POOL_CONNECTION_POOL *cp)
}
/* md5 authentication? */
- else if (pid == 5)
+ else if (authkind == 5)
{
if (NUM_BACKENDS > 1)
{
@@ -186,9 +187,9 @@ int pool_do_auth(POOL_CONNECTION *frontend, POOL_CONNECTION_POOL *cp)
{
pool_debug("trying md5 authentication");
- pid = do_md5(CONNECTION(cp, i), frontend, 0, protoMajor);
+ authkind = do_md5(CONNECTION(cp, i), frontend, 0, protoMajor);
- if (pid < 0)
+ if (authkind < 0)
{
pool_error("do_md5failed in slot %d", i);
return -1;
@@ -196,7 +197,13 @@ int pool_do_auth(POOL_CONNECTION *frontend, POOL_CONNECTION_POOL *cp)
}
}
- if (pid != 0)
+ else
+ {
+ pool_error("pool_do_auth: unsupported auth kind received: %d", authkind);
+ return -1;
+ }
+
+ if (authkind != 0)
{
pool_error("pool_do_auth: backend does not return authentication ok");
return -1;
[parent: 753a4c84594c]