9
9
* Portions Copyright (c) 1996-2002, PostgreSQL Global Development Group
10
10
* Portions Copyright (c) 1994, Regents of the University of California
11
11
*
12
- * $Header: /cvsroot/pgsql/src/backend/libpq/crypt.c,v 1.50 2002/12/05 18:39:43 momjian Exp $
12
+ * $Header: /cvsroot/pgsql/src/backend/libpq/crypt.c,v 1.51 2002/12/05 18:52:42 momjian Exp $
13
13
*
14
14
*-------------------------------------------------------------------------
15
15
*/
29
29
30
30
31
31
int
32
- md5_crypt_verify (const Port * port , const char * user , char * pgpass )
32
+ md5_crypt_verify (const Port * port , const char * user , char * client_pass )
33
33
{
34
- char * passwd = NULL ,
34
+ char * shadow_pass = NULL ,
35
35
* valuntil = NULL ,
36
36
* crypt_pwd ;
37
37
int retval = STATUS_ERROR ;
38
38
List * * line ;
39
39
List * token ;
40
- char * crypt_pgpass = pgpass ;
40
+ char * crypt_client_pass = client_pass ;
41
41
42
42
if ((line = get_user_line (user )) == NULL )
43
43
return STATUS_ERROR ;
@@ -46,17 +46,17 @@ md5_crypt_verify(const Port *port, const char *user, char *pgpass)
46
46
token = lnext (lnext (* line ));
47
47
if (token )
48
48
{
49
- passwd = lfirst (token );
49
+ shadow_pass = lfirst (token );
50
50
token = lnext (token );
51
51
if (token )
52
52
valuntil = lfirst (token );
53
53
}
54
54
55
- if (passwd == NULL || * passwd == '\0' )
55
+ if (shadow_pass == NULL || * shadow_pass == '\0' )
56
56
return STATUS_ERROR ;
57
57
58
58
/* We can't do crypt with pg_shadow MD5 passwords */
59
- if (isMD5 (passwd ) && port -> auth_method == uaCrypt )
59
+ if (isMD5 (shadow_pass ) && port -> auth_method == uaCrypt )
60
60
{
61
61
elog (LOG , "Password is stored MD5 encrypted. "
62
62
"'crypt' auth method cannot be used." );
@@ -71,10 +71,10 @@ md5_crypt_verify(const Port *port, const char *user, char *pgpass)
71
71
{
72
72
case uaMD5 :
73
73
crypt_pwd = palloc (MD5_PASSWD_LEN + 1 );
74
- if (isMD5 (passwd ))
74
+ if (isMD5 (shadow_pass ))
75
75
{
76
76
/* pg_shadow already encrypted, only do salt */
77
- if (!EncryptMD5 (passwd + strlen ("md5" ),
77
+ if (!EncryptMD5 (shadow_pass + strlen ("md5" ),
78
78
(char * ) port -> md5Salt ,
79
79
sizeof (port -> md5Salt ), crypt_pwd ))
80
80
{
@@ -87,7 +87,7 @@ md5_crypt_verify(const Port *port, const char *user, char *pgpass)
87
87
/* pg_shadow plain, double-encrypt */
88
88
char * crypt_pwd2 = palloc (MD5_PASSWD_LEN + 1 );
89
89
90
- if (!EncryptMD5 (passwd , port -> user , strlen (port -> user ),
90
+ if (!EncryptMD5 (shadow_pass , port -> user , strlen (port -> user ),
91
91
crypt_pwd2 ))
92
92
{
93
93
pfree (crypt_pwd );
@@ -109,26 +109,26 @@ md5_crypt_verify(const Port *port, const char *user, char *pgpass)
109
109
char salt [3 ];
110
110
111
111
StrNCpy (salt , port -> cryptSalt , 3 );
112
- crypt_pwd = crypt (passwd , salt );
112
+ crypt_pwd = crypt (shadow_pass , salt );
113
113
break ;
114
114
}
115
115
default :
116
- if (isMD5 (passwd ))
116
+ if (isMD5 (shadow_pass ))
117
117
{
118
118
/* Encrypt user-supplied password to match MD5 in pg_shadow */
119
- crypt_pgpass = palloc (MD5_PASSWD_LEN + 1 );
120
- if (!EncryptMD5 (pgpass , port -> user , strlen (port -> user ),
121
- crypt_pgpass ))
119
+ crypt_client_pass = palloc (MD5_PASSWD_LEN + 1 );
120
+ if (!EncryptMD5 (client_pass , port -> user , strlen (port -> user ),
121
+ crypt_client_pass ))
122
122
{
123
- pfree (crypt_pgpass );
123
+ pfree (crypt_client_pass );
124
124
return STATUS_ERROR ;
125
125
}
126
126
}
127
- crypt_pwd = passwd ;
127
+ crypt_pwd = shadow_pass ;
128
128
break ;
129
129
}
130
130
131
- if (strcmp (crypt_pgpass , crypt_pwd ) == 0 )
131
+ if (strcmp (crypt_client_pass , crypt_pwd ) == 0 )
132
132
{
133
133
/*
134
134
* Password OK, now check to be sure we are not past valuntil
@@ -150,8 +150,8 @@ md5_crypt_verify(const Port *port, const char *user, char *pgpass)
150
150
151
151
if (port -> auth_method == uaMD5 )
152
152
pfree (crypt_pwd );
153
- if (crypt_pgpass != pgpass )
154
- pfree (crypt_pgpass );
153
+ if (crypt_client_pass != client_pass )
154
+ pfree (crypt_client_pass );
155
155
156
156
return retval ;
157
157
}
0 commit comments