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

Commitab179d6

Browse files
committed
Make password null on startup.
1 parentc60f70b commitab179d6

File tree

4 files changed

+35
-14
lines changed

4 files changed

+35
-14
lines changed

‎src/backend/commands/user.c

Lines changed: 28 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -152,11 +152,14 @@ void DefineUser(CreateUserStmt *stmt) {
152152
/* Add the stuff here for groups.
153153
*/
154154

155+
UpdatePgPwdFile(sql);
156+
157+
/* This goes after the UpdatePgPwdFile to be certain that two backends to not
158+
* attempt to write to the pg_pwd file at the same time.
159+
*/
155160
RelationUnsetLockForWrite(pg_user_rel);
156161
heap_close(pg_user_rel);
157162

158-
UpdatePgPwdFile(sql);
159-
160163
if (IsTransactionBlock()&& !inblock)
161164
EndTransactionBlock();
162165
}
@@ -195,6 +198,10 @@ extern void AlterUser(AlterUserStmt *stmt) {
195198
*/
196199
pg_user_rel=heap_openr(UserRelationName);
197200
pg_user_dsc=RelationGetTupleDescriptor(pg_user_rel);
201+
/* Secure a write lock on pg_user so we can be sure that when the dump of
202+
* the pg_pwd file is done, there is not another backend doing the same.
203+
*/
204+
RelationSetLockForWrite(pg_user_rel);
198205

199206
scan=heap_beginscan(pg_user_rel, false, false,0,NULL);
200207
while (HeapTupleIsValid(tuple=heap_getnext(scan,0,&buffer))) {
@@ -207,9 +214,10 @@ extern void AlterUser(AlterUserStmt *stmt) {
207214
}
208215
}
209216
heap_endscan(scan);
210-
heap_close(pg_user_rel);
211217

212218
if (!exists) {
219+
RelationUnsetLockForWrite(pg_user_rel);
220+
heap_close(pg_user_rel);
213221
UserAbortTransactionBlock();
214222
elog(WARN,"alterUser: user \"%s\" does not exist",stmt->user);
215223
return;
@@ -257,6 +265,9 @@ extern void AlterUser(AlterUserStmt *stmt) {
257265

258266
UpdatePgPwdFile(sql);
259267

268+
RelationUnsetLockForWrite(pg_user_rel);
269+
heap_close(pg_user_rel);
270+
260271
if (IsTransactionBlock()&& !inblock)
261272
EndTransactionBlock();
262273
}
@@ -265,7 +276,8 @@ extern void AlterUser(AlterUserStmt *stmt) {
265276
externvoidRemoveUser(char*user) {
266277

267278
char*pg_user;
268-
Relationpg_rel;
279+
Relationpg_user_rel,
280+
pg_rel;
269281
TupleDescpg_dsc;
270282
HeapScanDescscan;
271283
HeapTupletuple;
@@ -295,10 +307,14 @@ extern void RemoveUser(char* user) {
295307
/* Perform a scan of the pg_user relation to find the usesysid of the user to
296308
* be deleted. If it is not found, then return a warning message.
297309
*/
298-
pg_rel=heap_openr(UserRelationName);
299-
pg_dsc=RelationGetTupleDescriptor(pg_rel);
310+
pg_user_rel=heap_openr(UserRelationName);
311+
pg_dsc=RelationGetTupleDescriptor(pg_user_rel);
312+
/* Secure a write lock on pg_user so we can be sure that when the dump of
313+
* the pg_pwd file is done, there is not another backend doing the same.
314+
*/
315+
RelationSetLockForWrite(pg_user_rel);
300316

301-
scan=heap_beginscan(pg_rel, false, false,0,NULL);
317+
scan=heap_beginscan(pg_user_rel, false, false,0,NULL);
302318
while (HeapTupleIsValid(tuple=heap_getnext(scan,0,&buffer))) {
303319
datum=heap_getattr(tuple,buffer,Anum_pg_user_usename,pg_dsc,&n);
304320

@@ -310,9 +326,10 @@ extern void RemoveUser(char* user) {
310326
ReleaseBuffer(buffer);
311327
}
312328
heap_endscan(scan);
313-
heap_close(pg_rel);
314329

315330
if (usesysid==-1) {
331+
RelationUnsetLockForWrite(pg_user_rel);
332+
heap_close(pg_user_rel);
316333
UserAbortTransactionBlock();
317334
elog(WARN,"removeUser: user \"%s\" does not exist",user);
318335
return;
@@ -373,6 +390,9 @@ extern void RemoveUser(char* user) {
373390

374391
UpdatePgPwdFile(sql);
375392

393+
RelationUnsetLockForWrite(pg_user_rel);
394+
heap_close(pg_user_rel);
395+
376396
if (IsTransactionBlock()&& !inblock)
377397
EndTransactionBlock();
378398
}

‎src/backend/libpq/be-pqexec.c

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88
*
99
*
1010
* IDENTIFICATION
11-
* $Header: /cvsroot/pgsql/src/backend/libpq/Attic/be-pqexec.c,v 1.10 1997/12/06 22:56:35 momjian Exp $
11+
* $Header: /cvsroot/pgsql/src/backend/libpq/Attic/be-pqexec.c,v 1.11 1997/12/12 16:26:14 momjian Exp $
1212
*
1313
*-------------------------------------------------------------------------
1414
*/
@@ -143,11 +143,11 @@ PQexec(char *query)
143143
be_portalpush(entry);
144144

145145
/* ----------------
146-
*pg_eval_dest will put the query results in a portal which will
146+
*pg_exec_query_dest will put the query results in a portal which will
147147
*end up on the top of the portal stack.
148148
* ----------------
149149
*/
150-
pg_eval_dest(query, (char**)NULL, (Oid*)NULL,0,Local);
150+
pg_exec_query_dest(query, (char**)NULL, (Oid*)NULL,0,Local);
151151

152152
/* ----------------
153153
*pop the portal off the portal stack and return the

‎src/backend/libpq/crypt.c

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@
1717
#endif
1818

1919
#include"postgres.h"
20+
#include"miscadmin.h"
2021
#include"libpq/crypt.h"
2122
#include"utils/nabstime.h"
2223
#include"utils/palloc.h"
@@ -129,7 +130,7 @@ MsgType crypt_salt(const char* user) {
129130

130131
crypt_getloginfo(user,&passwd,&valuntil);
131132

132-
if (passwd==NULL||*passwd=='\0') {
133+
if (passwd==NULL||*passwd=='\0'|| !strcmp(passwd,"\\N")) {
133134
if (passwd)pfree((void*)passwd);
134135
if (valuntil)pfree((void*)valuntil);
135136
returnSTARTUP_UNSALT_MSG;

‎src/include/catalog/pg_user.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
*
88
* Copyright (c) 1994, Regents of the University of California
99
*
10-
* $Id: pg_user.h,v 1.7 1997/12/09 03:11:25 scrappy Exp $
10+
* $Id: pg_user.h,v 1.8 1997/12/12 16:26:36 momjian Exp $
1111
*
1212
* NOTES
1313
* the genbki.sh script reads this file and generates .bki
@@ -65,7 +65,7 @@ typedef FormData_pg_user *Form_pg_user;
6565
*initial contents of pg_user
6666
* ----------------
6767
*/
68-
DATA(insertOID=0 (postgresPGUIDtttt""2116994400 ));
68+
DATA(insertOID=0 (postgresPGUIDtttt_null_2116994400 ));
6969

7070
BKI_BEGIN
7171
#ifdefALLOW_PG_GROUP

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp