Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commitf7a3d74

Browse files
committed
Clearify variables names so it is clear which variable is the
client-supplied password and which is from pg_shadow.
1 parent44ab596 commitf7a3d74

File tree

2 files changed

+22
-22
lines changed

2 files changed

+22
-22
lines changed

‎src/backend/libpq/crypt.c

Lines changed: 20 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@
99
* Portions Copyright (c) 1996-2002, PostgreSQL Global Development Group
1010
* Portions Copyright (c) 1994, Regents of the University of California
1111
*
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 $
1313
*
1414
*-------------------------------------------------------------------------
1515
*/
@@ -29,15 +29,15 @@
2929

3030

3131
int
32-
md5_crypt_verify(constPort*port,constchar*user,char*pgpass)
32+
md5_crypt_verify(constPort*port,constchar*user,char*client_pass)
3333
{
34-
char*passwd=NULL,
34+
char*shadow_pass=NULL,
3535
*valuntil=NULL,
3636
*crypt_pwd;
3737
intretval=STATUS_ERROR;
3838
List**line;
3939
List*token;
40-
char*crypt_pgpass=pgpass;
40+
char*crypt_client_pass=client_pass;
4141

4242
if ((line=get_user_line(user))==NULL)
4343
returnSTATUS_ERROR;
@@ -46,17 +46,17 @@ md5_crypt_verify(const Port *port, const char *user, char *pgpass)
4646
token=lnext(lnext(*line));
4747
if (token)
4848
{
49-
passwd=lfirst(token);
49+
shadow_pass=lfirst(token);
5050
token=lnext(token);
5151
if (token)
5252
valuntil=lfirst(token);
5353
}
5454

55-
if (passwd==NULL||*passwd=='\0')
55+
if (shadow_pass==NULL||*shadow_pass=='\0')
5656
returnSTATUS_ERROR;
5757

5858
/* 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)
6060
{
6161
elog(LOG,"Password is stored MD5 encrypted. "
6262
"'crypt' auth method cannot be used.");
@@ -71,10 +71,10 @@ md5_crypt_verify(const Port *port, const char *user, char *pgpass)
7171
{
7272
caseuaMD5:
7373
crypt_pwd=palloc(MD5_PASSWD_LEN+1);
74-
if (isMD5(passwd))
74+
if (isMD5(shadow_pass))
7575
{
7676
/* pg_shadow already encrypted, only do salt */
77-
if (!EncryptMD5(passwd+strlen("md5"),
77+
if (!EncryptMD5(shadow_pass+strlen("md5"),
7878
(char*)port->md5Salt,
7979
sizeof(port->md5Salt),crypt_pwd))
8080
{
@@ -87,7 +87,7 @@ md5_crypt_verify(const Port *port, const char *user, char *pgpass)
8787
/* pg_shadow plain, double-encrypt */
8888
char*crypt_pwd2=palloc(MD5_PASSWD_LEN+1);
8989

90-
if (!EncryptMD5(passwd,port->user,strlen(port->user),
90+
if (!EncryptMD5(shadow_pass,port->user,strlen(port->user),
9191
crypt_pwd2))
9292
{
9393
pfree(crypt_pwd);
@@ -109,26 +109,26 @@ md5_crypt_verify(const Port *port, const char *user, char *pgpass)
109109
charsalt[3];
110110

111111
StrNCpy(salt,port->cryptSalt,3);
112-
crypt_pwd=crypt(passwd,salt);
112+
crypt_pwd=crypt(shadow_pass,salt);
113113
break;
114114
}
115115
default:
116-
if (isMD5(passwd))
116+
if (isMD5(shadow_pass))
117117
{
118118
/* 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))
122122
{
123-
pfree(crypt_pgpass);
123+
pfree(crypt_client_pass);
124124
returnSTATUS_ERROR;
125125
}
126126
}
127-
crypt_pwd=passwd;
127+
crypt_pwd=shadow_pass;
128128
break;
129129
}
130130

131-
if (strcmp(crypt_pgpass,crypt_pwd)==0)
131+
if (strcmp(crypt_client_pass,crypt_pwd)==0)
132132
{
133133
/*
134134
* 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)
150150

151151
if (port->auth_method==uaMD5)
152152
pfree(crypt_pwd);
153-
if (crypt_pgpass!=pgpass)
154-
pfree(crypt_pgpass);
153+
if (crypt_client_pass!=client_pass)
154+
pfree(crypt_client_pass);
155155

156156
returnretval;
157157
}

‎src/include/libpq/crypt.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
* Portions Copyright (c) 1996-2002, PostgreSQL Global Development Group
77
* Portions Copyright (c) 1994, Regents of the University of California
88
*
9-
* $Id: crypt.h,v 1.23 2002/12/05 18:39:43 momjian Exp $
9+
* $Id: crypt.h,v 1.24 2002/12/05 18:52:43 momjian Exp $
1010
*
1111
*-------------------------------------------------------------------------
1212
*/
@@ -23,7 +23,7 @@
2323

2424

2525
externintmd5_crypt_verify(constPort*port,constchar*user,
26-
char*pgpass);
26+
char*client_pass);
2727
externboolmd5_hash(constvoid*buff,size_tlen,char*hexsum);
2828
externboolCheckMD5Pwd(char*passwd,char*storedpwd,char*seed);
2929

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp