Make password null on startup.
This commit is contained in:
parent
c60f70b53f
commit
ab179d6940
|
@ -152,11 +152,14 @@ void DefineUser(CreateUserStmt *stmt) {
|
||||||
/* Add the stuff here for groups.
|
/* Add the stuff here for groups.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
UpdatePgPwdFile(sql);
|
||||||
|
|
||||||
|
/* This goes after the UpdatePgPwdFile to be certain that two backends to not
|
||||||
|
* attempt to write to the pg_pwd file at the same time.
|
||||||
|
*/
|
||||||
RelationUnsetLockForWrite(pg_user_rel);
|
RelationUnsetLockForWrite(pg_user_rel);
|
||||||
heap_close(pg_user_rel);
|
heap_close(pg_user_rel);
|
||||||
|
|
||||||
UpdatePgPwdFile(sql);
|
|
||||||
|
|
||||||
if (IsTransactionBlock() && !inblock)
|
if (IsTransactionBlock() && !inblock)
|
||||||
EndTransactionBlock();
|
EndTransactionBlock();
|
||||||
}
|
}
|
||||||
|
@ -195,6 +198,10 @@ extern void AlterUser(AlterUserStmt *stmt) {
|
||||||
*/
|
*/
|
||||||
pg_user_rel = heap_openr(UserRelationName);
|
pg_user_rel = heap_openr(UserRelationName);
|
||||||
pg_user_dsc = RelationGetTupleDescriptor(pg_user_rel);
|
pg_user_dsc = RelationGetTupleDescriptor(pg_user_rel);
|
||||||
|
/* Secure a write lock on pg_user so we can be sure that when the dump of
|
||||||
|
* the pg_pwd file is done, there is not another backend doing the same.
|
||||||
|
*/
|
||||||
|
RelationSetLockForWrite(pg_user_rel);
|
||||||
|
|
||||||
scan = heap_beginscan(pg_user_rel, false, false, 0, NULL);
|
scan = heap_beginscan(pg_user_rel, false, false, 0, NULL);
|
||||||
while (HeapTupleIsValid(tuple = heap_getnext(scan, 0, &buffer))) {
|
while (HeapTupleIsValid(tuple = heap_getnext(scan, 0, &buffer))) {
|
||||||
|
@ -207,9 +214,10 @@ extern void AlterUser(AlterUserStmt *stmt) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
heap_endscan(scan);
|
heap_endscan(scan);
|
||||||
heap_close(pg_user_rel);
|
|
||||||
|
|
||||||
if (!exists) {
|
if (!exists) {
|
||||||
|
RelationUnsetLockForWrite(pg_user_rel);
|
||||||
|
heap_close(pg_user_rel);
|
||||||
UserAbortTransactionBlock();
|
UserAbortTransactionBlock();
|
||||||
elog(WARN, "alterUser: user \"%s\" does not exist", stmt->user);
|
elog(WARN, "alterUser: user \"%s\" does not exist", stmt->user);
|
||||||
return;
|
return;
|
||||||
|
@ -257,6 +265,9 @@ extern void AlterUser(AlterUserStmt *stmt) {
|
||||||
|
|
||||||
UpdatePgPwdFile(sql);
|
UpdatePgPwdFile(sql);
|
||||||
|
|
||||||
|
RelationUnsetLockForWrite(pg_user_rel);
|
||||||
|
heap_close(pg_user_rel);
|
||||||
|
|
||||||
if (IsTransactionBlock() && !inblock)
|
if (IsTransactionBlock() && !inblock)
|
||||||
EndTransactionBlock();
|
EndTransactionBlock();
|
||||||
}
|
}
|
||||||
|
@ -265,7 +276,8 @@ extern void AlterUser(AlterUserStmt *stmt) {
|
||||||
extern void RemoveUser(char* user) {
|
extern void RemoveUser(char* user) {
|
||||||
|
|
||||||
char* pg_user;
|
char* pg_user;
|
||||||
Relation pg_rel;
|
Relation pg_user_rel,
|
||||||
|
pg_rel;
|
||||||
TupleDesc pg_dsc;
|
TupleDesc pg_dsc;
|
||||||
HeapScanDesc scan;
|
HeapScanDesc scan;
|
||||||
HeapTuple tuple;
|
HeapTuple tuple;
|
||||||
|
@ -295,10 +307,14 @@ extern void RemoveUser(char* user) {
|
||||||
/* Perform a scan of the pg_user relation to find the usesysid of the user to
|
/* Perform a scan of the pg_user relation to find the usesysid of the user to
|
||||||
* be deleted. If it is not found, then return a warning message.
|
* be deleted. If it is not found, then return a warning message.
|
||||||
*/
|
*/
|
||||||
pg_rel = heap_openr(UserRelationName);
|
pg_user_rel = heap_openr(UserRelationName);
|
||||||
pg_dsc = RelationGetTupleDescriptor(pg_rel);
|
pg_dsc = RelationGetTupleDescriptor(pg_user_rel);
|
||||||
|
/* Secure a write lock on pg_user so we can be sure that when the dump of
|
||||||
|
* the pg_pwd file is done, there is not another backend doing the same.
|
||||||
|
*/
|
||||||
|
RelationSetLockForWrite(pg_user_rel);
|
||||||
|
|
||||||
scan = heap_beginscan(pg_rel, false, false, 0, NULL);
|
scan = heap_beginscan(pg_user_rel, false, false, 0, NULL);
|
||||||
while (HeapTupleIsValid(tuple = heap_getnext(scan, 0, &buffer))) {
|
while (HeapTupleIsValid(tuple = heap_getnext(scan, 0, &buffer))) {
|
||||||
datum = heap_getattr(tuple, buffer, Anum_pg_user_usename, pg_dsc, &n);
|
datum = heap_getattr(tuple, buffer, Anum_pg_user_usename, pg_dsc, &n);
|
||||||
|
|
||||||
|
@ -310,9 +326,10 @@ extern void RemoveUser(char* user) {
|
||||||
ReleaseBuffer(buffer);
|
ReleaseBuffer(buffer);
|
||||||
}
|
}
|
||||||
heap_endscan(scan);
|
heap_endscan(scan);
|
||||||
heap_close(pg_rel);
|
|
||||||
|
|
||||||
if (usesysid == -1) {
|
if (usesysid == -1) {
|
||||||
|
RelationUnsetLockForWrite(pg_user_rel);
|
||||||
|
heap_close(pg_user_rel);
|
||||||
UserAbortTransactionBlock();
|
UserAbortTransactionBlock();
|
||||||
elog(WARN, "removeUser: user \"%s\" does not exist", user);
|
elog(WARN, "removeUser: user \"%s\" does not exist", user);
|
||||||
return;
|
return;
|
||||||
|
@ -373,6 +390,9 @@ extern void RemoveUser(char* user) {
|
||||||
|
|
||||||
UpdatePgPwdFile(sql);
|
UpdatePgPwdFile(sql);
|
||||||
|
|
||||||
|
RelationUnsetLockForWrite(pg_user_rel);
|
||||||
|
heap_close(pg_user_rel);
|
||||||
|
|
||||||
if (IsTransactionBlock() && !inblock)
|
if (IsTransactionBlock() && !inblock)
|
||||||
EndTransactionBlock();
|
EndTransactionBlock();
|
||||||
}
|
}
|
||||||
|
|
|
@ -8,7 +8,7 @@
|
||||||
*
|
*
|
||||||
*
|
*
|
||||||
* IDENTIFICATION
|
* IDENTIFICATION
|
||||||
* $Header: /cvsroot/pgsql/src/backend/libpq/Attic/be-pqexec.c,v 1.10 1997/12/06 22:56:35 momjian Exp $
|
* $Header: /cvsroot/pgsql/src/backend/libpq/Attic/be-pqexec.c,v 1.11 1997/12/12 16:26:14 momjian Exp $
|
||||||
*
|
*
|
||||||
*-------------------------------------------------------------------------
|
*-------------------------------------------------------------------------
|
||||||
*/
|
*/
|
||||||
|
@ -143,11 +143,11 @@ PQexec(char *query)
|
||||||
be_portalpush(entry);
|
be_portalpush(entry);
|
||||||
|
|
||||||
/* ----------------
|
/* ----------------
|
||||||
* pg_eval_dest will put the query results in a portal which will
|
* pg_exec_query_dest will put the query results in a portal which will
|
||||||
* end up on the top of the portal stack.
|
* end up on the top of the portal stack.
|
||||||
* ----------------
|
* ----------------
|
||||||
*/
|
*/
|
||||||
pg_eval_dest(query, (char **) NULL, (Oid *) NULL, 0, Local);
|
pg_exec_query_dest(query, (char **) NULL, (Oid *) NULL, 0, Local);
|
||||||
|
|
||||||
/* ----------------
|
/* ----------------
|
||||||
* pop the portal off the portal stack and return the
|
* pop the portal off the portal stack and return the
|
||||||
|
|
|
@ -17,6 +17,7 @@
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#include "postgres.h"
|
#include "postgres.h"
|
||||||
|
#include "miscadmin.h"
|
||||||
#include "libpq/crypt.h"
|
#include "libpq/crypt.h"
|
||||||
#include "utils/nabstime.h"
|
#include "utils/nabstime.h"
|
||||||
#include "utils/palloc.h"
|
#include "utils/palloc.h"
|
||||||
|
@ -129,7 +130,7 @@ MsgType crypt_salt(const char* user) {
|
||||||
|
|
||||||
crypt_getloginfo(user, &passwd, &valuntil);
|
crypt_getloginfo(user, &passwd, &valuntil);
|
||||||
|
|
||||||
if (passwd == NULL || *passwd == '\0') {
|
if (passwd == NULL || *passwd == '\0' || !strcmp(passwd, "\\N")) {
|
||||||
if (passwd) pfree((void*)passwd);
|
if (passwd) pfree((void*)passwd);
|
||||||
if (valuntil) pfree((void*)valuntil);
|
if (valuntil) pfree((void*)valuntil);
|
||||||
return STARTUP_UNSALT_MSG;
|
return STARTUP_UNSALT_MSG;
|
||||||
|
|
|
@ -7,7 +7,7 @@
|
||||||
*
|
*
|
||||||
* Copyright (c) 1994, Regents of the University of California
|
* Copyright (c) 1994, Regents of the University of California
|
||||||
*
|
*
|
||||||
* $Id: pg_user.h,v 1.7 1997/12/09 03:11:25 scrappy Exp $
|
* $Id: pg_user.h,v 1.8 1997/12/12 16:26:36 momjian Exp $
|
||||||
*
|
*
|
||||||
* NOTES
|
* NOTES
|
||||||
* the genbki.sh script reads this file and generates .bki
|
* the genbki.sh script reads this file and generates .bki
|
||||||
|
@ -65,7 +65,7 @@ typedef FormData_pg_user *Form_pg_user;
|
||||||
* initial contents of pg_user
|
* initial contents of pg_user
|
||||||
* ----------------
|
* ----------------
|
||||||
*/
|
*/
|
||||||
DATA(insert OID = 0 ( postgres PGUID t t t t "" 2116994400 ));
|
DATA(insert OID = 0 ( postgres PGUID t t t t _null_ 2116994400 ));
|
||||||
|
|
||||||
BKI_BEGIN
|
BKI_BEGIN
|
||||||
#ifdef ALLOW_PG_GROUP
|
#ifdef ALLOW_PG_GROUP
|
||||||
|
|
Loading…
Reference in New Issue