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

Commit4c04f77

Browse files
committed
From: todd brandys <brandys@eng3.hep.uiuc.edu>
An extension to the code to allow for a pg_password authentication databasethat is *seperate* from the system password file
1 parent333323f commit4c04f77

File tree

19 files changed

+494
-63
lines changed

19 files changed

+494
-63
lines changed

‎src/backend/commands/Makefile

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
# Makefile for commands
55
#
66
# IDENTIFICATION
7-
# $Header: /cvsroot/pgsql/src/backend/commands/Makefile,v 1.7 1997/11/24 05:20:49 momjian Exp $
7+
# $Header: /cvsroot/pgsql/src/backend/commands/Makefile,v 1.8 1997/12/04 00:26:44 scrappy Exp $
88
#
99
#-------------------------------------------------------------------------
1010

@@ -19,7 +19,7 @@ CFLAGS+=$(INCLUDE_OPT)
1919

2020
OBJS = async.o creatinh.o command.o copy.o defind.o define.o\
2121
remove.o rename.o vacuum.o version.o view.o cluster.o\
22-
recipe.o explain.o sequence.o trigger.o proclang.o dbcommands.o
22+
recipe.o explain.o sequence.o trigger.ouser.oproclang.o dbcommands.o
2323

2424
all: SUBSYS.o
2525

‎src/backend/libpq/Makefile

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
# Makefile for libpq subsystem (backend half of libpq interface)
55
#
66
# IDENTIFICATION
7-
# $Header: /cvsroot/pgsql/src/backend/libpq/Makefile,v 1.7 1997/04/0410:39:19 scrappy Exp $
7+
# $Header: /cvsroot/pgsql/src/backend/libpq/Makefile,v 1.8 1997/12/0400:26:47 scrappy Exp $
88
#
99
#-------------------------------------------------------------------------
1010

@@ -24,7 +24,7 @@ LDFLAGS+= $(KRBLIBS)
2424
endif
2525

2626
OBJS = be-dumpdata.o be-fsstubs.o be-pqexec.o pqcomprim.o\
27-
auth.o hba.o pqcomm.o portal.o util.o portalbuf.o pqpacket.o pqsignal.o\
27+
auth.o hba.ocrypt.opqcomm.o portal.o util.o portalbuf.o pqpacket.o pqsignal.o\
2828
password.o
2929

3030
all: SUBSYS.o

‎src/backend/libpq/auth.c

Lines changed: 30 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
*
88
*
99
* IDENTIFICATION
10-
* $Header: /cvsroot/pgsql/src/backend/libpq/auth.c,v 1.18 1997/11/17 16:10:06 thomas Exp $
10+
* $Header: /cvsroot/pgsql/src/backend/libpq/auth.c,v 1.19 1997/12/04 00:26:50 scrappy Exp $
1111
*
1212
*-------------------------------------------------------------------------
1313
*/
@@ -71,6 +71,7 @@
7171
#include<libpq/libpq-be.h>
7272
#include<libpq/hba.h>
7373
#include<libpq/password.h>
74+
#include<libpq/crypt.h>
7475

7576
staticintbe_getauthsvc(MsgTypemsgtype);
7677

@@ -122,7 +123,8 @@ static struct authsvc authsvcs[] = {
122123
#else
123124
{"kerberos",STARTUP_KRB4_MSG,1},
124125
#endif
125-
{"password",STARTUP_PASSWORD_MSG,1}
126+
{"password",STARTUP_PASSWORD_MSG,1},
127+
{"crypt",STARTUP_CRYPT_MSG,1}
126128
};
127129

128130
staticn_authsvcs=sizeof(authsvcs) /sizeof(structauthsvc);
@@ -445,6 +447,28 @@ pg_password_recvauth(Port *port, char *database, char *DataDir)
445447
returnverify_password(user,password,port,database,DataDir);
446448
}
447449

450+
staticint
451+
crypt_recvauth(Port*port)
452+
{
453+
PacketBufbuf;
454+
char*user,
455+
*password;
456+
457+
if (PacketReceive(port,&buf,BLOCKING)!=STATUS_OK)
458+
{
459+
sprintf(PQerrormsg,
460+
"crypt_recvauth: failed to receive authentication packet.\n");
461+
fputs(PQerrormsg,stderr);
462+
pqdebug("%s",PQerrormsg);
463+
returnSTATUS_ERROR;
464+
}
465+
466+
user=buf.data;
467+
password=buf.data+strlen(user)+1;
468+
469+
returncrypt_verify(port,user,password);
470+
}
471+
448472
/*
449473
* be_recvauth -- server demux routine for incoming authentication information
450474
*/
@@ -571,6 +595,10 @@ be_recvauth(MsgType msgtype_arg, Port *port, char *username, StartupInfo *sp)
571595
return (STATUS_ERROR);
572596
}
573597
break;
598+
caseSTARTUP_CRYPT_MSG:
599+
if (crypt_recvauth(port)!=STATUS_OK)
600+
returnSTATUS_ERROR;
601+
break;
574602
default:
575603
sprintf(PQerrormsg,
576604
"be_recvauth: unrecognized message type: %d\n",

‎src/backend/parser/gram.y

Lines changed: 120 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@
1010
*
1111
*
1212
* IDENTIFICATION
13-
* $Header: /cvsroot/pgsql/src/backend/parser/gram.y,v 1.75 1997/12/02 16:09:15 momjian Exp $
13+
* $Header: /cvsroot/pgsql/src/backend/parser/gram.y,v 1.76 1997/12/04 00:26:57 scrappy Exp $
1414
*
1515
* HISTORY
1616
* AUTHORDATEMAJOR EVENT
@@ -40,6 +40,7 @@
4040
#include "nodes/print.h"
4141
#include "parser/gramparse.h"
4242
#include "utils/acl.h"
43+
#include "utils/palloc.h"
4344
#include "catalog/catname.h"
4445
#include "utils/elog.h"
4546
#include "access/xact.h"
@@ -83,6 +84,7 @@ Oidparam_type(int t); /* used in parse_expr.c */
8384
charchr;
8485
char*str;
8586
boolboolean;
87+
bool*pboolean;/* for pg_user privileges */
8688
List*list;
8789
Node*node;
8890
Value*value;
@@ -119,10 +121,16 @@ Oidparam_type(int t); /* used in parse_expr.c */
119121
RenameStmt, RevokeStmt, RuleStmt, TransactionStmt, ViewStmt, LoadStmt,
120122
CreatedbStmt, DestroydbStmt, VacuumStmt, RetrieveStmt, CursorStmt,
121123
ReplaceStmt, AppendStmt, NotifyStmt, DeleteStmt, ClusterStmt,
122-
ExplainStmt, VariableSetStmt, VariableShowStmt, VariableResetStmt
124+
ExplainStmt, VariableSetStmt, VariableShowStmt, VariableResetStmt,
125+
CreateUserStmt, AlterUserStmt, DropUserStmt
123126

124127
%type <str>opt_database, location
125128

129+
%type <pboolean> user_createdb_clause, user_createuser_clause
130+
%type <str> user_passwd_clause
131+
%type <str> user_valid_clause
132+
%type <list> user_group_list, user_group_clause
133+
126134
%type <node>SubSelect
127135
%type <str>join_expr, join_outer, join_spec
128136
%type <boolean> TriggerActionTime, TriggerForSpec, PLangTrusted
@@ -268,6 +276,14 @@ Oidparam_type(int t); /* used in parse_expr.c */
268276
SEQUENCE, SETOF, SHOW, STDIN, STDOUT, TRUSTED,
269277
VACUUM, VERBOSE, VERSION
270278

279+
/*
280+
* Tokens for pg_passwd support. The CREATEDB and CREATEUSER tokens should go away
281+
* when some sort of pg_privileges relation is introduced.
282+
*
283+
* Todd A. Brandys
284+
*/
285+
%token USER, PASSWORD, CREATEDB, NOCREATEDB, CREATEUSER, NOCREATEUSER, VALID, UNTIL
286+
271287
/* Special keywords, not in the query language - see the "lex" file */
272288
%token <str>IDENT, SCONST, Op
273289
%token <ival>ICONST, PARAM
@@ -318,17 +334,20 @@ stmtmulti: stmtmulti stmt ';'
318334
;
319335

320336
stmt : AddAttrStmt
337+
| AlterUserStmt
321338
| ClosePortalStmt
322339
| CopyStmt
323340
| CreateStmt
324341
| CreateSeqStmt
325342
| CreatePLangStmt
326343
| CreateTrigStmt
344+
| CreateUserStmt
327345
| ClusterStmt
328346
| DefineStmt
329347
| DestroyStmt
330348
| DropPLangStmt
331349
| DropTrigStmt
350+
| DropUserStmt
332351
| ExtendStmt
333352
| ExplainStmt
334353
| FetchStmt
@@ -356,6 +375,105 @@ stmt : AddAttrStmt
356375
| VariableResetStmt
357376
;
358377

378+
/*****************************************************************************
379+
*
380+
* Create a new postresql DBMS user
381+
*
382+
*
383+
*****************************************************************************/
384+
385+
CreateUserStmt: CREATE USER Id
386+
user_passwd_clause
387+
user_createdb_clause
388+
user_createuser_clause
389+
user_group_clause
390+
user_valid_clause
391+
{ CreateUserStmt *n = makeNode(CreateUserStmt);
392+
n->user = $3;
393+
n->password = $4;
394+
n->createdb = $5;
395+
n->createuser = $6;
396+
n->groupElts = $7;
397+
n->validUntil = $8;
398+
$$ = (Node *)n;
399+
}
400+
;
401+
402+
/*****************************************************************************
403+
*
404+
* Alter a postresql DBMS user
405+
*
406+
*
407+
*****************************************************************************/
408+
409+
AlterUserStmt: ALTER USER Id
410+
user_passwd_clause
411+
user_createdb_clause
412+
user_createuser_clause
413+
user_group_clause
414+
user_valid_clause
415+
{ AlterUserStmt *n = makeNode(AlterUserStmt);
416+
n->user = $3;
417+
n->password = $4;
418+
n->createdb = $5;
419+
n->createuser = $6;
420+
n->groupElts = $7;
421+
n->validUntil = $8;
422+
$$ = (Node *)n;
423+
}
424+
;
425+
426+
/*****************************************************************************
427+
*
428+
* Drop a postresql DBMS user
429+
*
430+
*
431+
*****************************************************************************/
432+
433+
DropUserStmt: DROP USER Id
434+
{ DropUserStmt *n = makeNode(DropUserStmt);
435+
n->user = $3;
436+
$$ = (Node *)n;
437+
}
438+
;
439+
440+
user_passwd_clause: WITH PASSWORD Id { $$ = $3; }
441+
| /*EMPTY*/ { $$ = NULL; }
442+
;
443+
444+
user_createdb_clause: CREATEDB { bool* b;
445+
$$ = (b = (bool*)palloc(sizeof(bool)));
446+
*b = true;
447+
}
448+
| NOCREATEDB { bool* b;
449+
$$ = (b = (bool*)palloc(sizeof(bool)));
450+
*b = false;
451+
}
452+
| /*EMPTY*/ { $$ = NULL; }
453+
;
454+
455+
user_createuser_clause: CREATEUSER { bool* b;
456+
$$ = (b = (bool*)palloc(sizeof(bool)));
457+
*b = true;
458+
}
459+
| NOCREATEUSER { bool* b;
460+
$$ = (b = (bool*)palloc(sizeof(bool)));
461+
*b = false;
462+
}
463+
| /*EMPTY*/ { $$ = NULL; }
464+
;
465+
466+
user_group_list: user_group_list ',' Id { $$ = lcons((void*)makeString($3), $1); }
467+
| Id { $$ = makeList((void*)makeString($1), NULL); }
468+
;
469+
470+
user_group_clause: IN GROUP user_group_list { $$ = $3; }
471+
| /*EMPTY*/ { $$ = NULL; }
472+
;
473+
474+
user_valid_clause: VALID UNTIL SCONST { $$ = $3; }
475+
| /*EMPTY*/ { $$ = NULL; }
476+
;
359477

360478
/*****************************************************************************
361479
*

‎src/backend/parser/keywords.c

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
*
88
*
99
* IDENTIFICATION
10-
* $Header: /cvsroot/pgsql/src/backend/parser/keywords.c,v 1.26 1997/11/26 01:11:08 momjian Exp $
10+
* $Header: /cvsroot/pgsql/src/backend/parser/keywords.c,v 1.27 1997/12/04 00:27:04 scrappy Exp $
1111
*
1212
*-------------------------------------------------------------------------
1313
*/
@@ -64,6 +64,8 @@ static ScanKeyword ScanKeywords[] = {
6464
{"constraint",CONSTRAINT},
6565
{"copy",COPY},
6666
{"create",CREATE},
67+
{"createdb",CREATEDB},
68+
{"createuser",CREATEUSER},
6769
{"cross",CROSS},
6870
{"current",CURRENT},
6971
{"current_date",CURRENT_DATE},
@@ -133,6 +135,8 @@ static ScanKeyword ScanKeywords[] = {
133135
{"natural",NATURAL},
134136
{"nchar",NCHAR},
135137
{"new",NEW},
138+
{"nocreatedb",NOCREATEDB},
139+
{"nocreateuser",NOCREATEUSER},
136140
{"none",NONE},
137141
{"no",NO},
138142
{"not",NOT},
@@ -149,6 +153,7 @@ static ScanKeyword ScanKeywords[] = {
149153
{"order",ORDER},
150154
{"outer",OUTER_P},
151155
{"partial",PARTIAL},
156+
{"password",PASSWORD},
152157
{"position",POSITION},
153158
{"precision",PRECISION},
154159
{"primary",PRIMARY},
@@ -188,9 +193,12 @@ static ScanKeyword ScanKeywords[] = {
188193
{"type",TYPE_P},
189194
{"union",UNION},
190195
{"unique",UNIQUE},
196+
{"until",UNTIL},
191197
{"update",UPDATE},
198+
{"user",USER},
192199
{"using",USING},
193200
{"vacuum",VACUUM},
201+
{"valid",VALID},
194202
{"values",VALUES},
195203
{"varchar",VARCHAR},
196204
{"varying",VARYING},

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp