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

Commitc82725e

Browse files
committed
Let installcheck-world pass against a server requiring a password.
Give passwords to each user created in support of an ECPG connectiontest case. Use SET SESSION AUTHORIZATION, not a fresh connection, toreduce privileges during a dblink test case.To test against such a server, both the "make installcheck-world"environment and the postmaster environment must provide the defaultuser's password; $PGPASSFILE is the principal way to do so. (Thepostmaster environment needs it for dblink and postgres_fdw tests.)
1 parentf28d9b1 commitc82725e

File tree

5 files changed

+75
-61
lines changed

5 files changed

+75
-61
lines changed

‎contrib/dblink/expected/dblink.out

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -782,18 +782,17 @@ SELECT dblink_disconnect('dtest1');
782782
(1 row)
783783

784784
-- test foreign data wrapper functionality
785-
CREATEUSER dblink_regression_test;
785+
CREATEROLE dblink_regression_test;
786786
CREATE SERVER fdtest FOREIGN DATA WRAPPER dblink_fdw
787787
OPTIONS (dbname 'contrib_regression');
788788
CREATE USER MAPPING FOR public SERVER fdtest
789789
OPTIONS (server 'localhost'); -- fail, can't specify server here
790790
ERROR: invalid option "server"
791791
HINT: Valid options in this context are: user, password
792-
CREATE USER MAPPING FOR public SERVER fdtest;
792+
CREATE USER MAPPING FOR public SERVER fdtest OPTIONS (user :'USER');
793793
GRANT USAGE ON FOREIGN SERVER fdtest TO dblink_regression_test;
794794
GRANT EXECUTE ON FUNCTION dblink_connect_u(text, text) TO dblink_regression_test;
795-
\set ORIGINAL_USER :USER
796-
\c - dblink_regression_test
795+
SET SESSION AUTHORIZATION dblink_regression_test;
797796
-- should fail
798797
SELECT dblink_connect('myconn', 'fdtest');
799798
ERROR: password is required
@@ -821,7 +820,7 @@ SELECT * FROM dblink('myconn','SELECT * FROM foo') AS t(a int, b text, c text[])
821820
10 | k | {a10,b10,c10}
822821
(11 rows)
823822

824-
\c -:ORIGINAL_USER
823+
\c --
825824
REVOKE USAGE ON FOREIGN SERVER fdtest FROM dblink_regression_test;
826825
REVOKE EXECUTE ON FUNCTION dblink_connect_u(text, text) FROM dblink_regression_test;
827826
DROP USER dblink_regression_test;

‎contrib/dblink/sql/dblink.sql

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -359,25 +359,24 @@ SELECT dblink_error_message('dtest1');
359359
SELECT dblink_disconnect('dtest1');
360360

361361
-- test foreign data wrapper functionality
362-
CREATEUSERdblink_regression_test;
362+
CREATEROLE dblink_regression_test;
363363
CREATE SERVER fdtest FOREIGN DATA WRAPPER dblink_fdw
364364
OPTIONS (dbname'contrib_regression');
365365
CREATEUSERMAPPING FOR public SERVER fdtest
366366
OPTIONS (server'localhost');-- fail, can't specify server here
367-
CREATEUSERMAPPING FOR public SERVER fdtest;
367+
CREATEUSERMAPPING FOR public SERVER fdtest OPTIONS (user :'USER');
368368

369369
GRANT USAGEON FOREIGN SERVER fdtest TO dblink_regression_test;
370370
GRANT EXECUTEON FUNCTION dblink_connect_u(text,text) TO dblink_regression_test;
371371

372-
\set ORIGINAL_USER :USER
373-
\c- dblink_regression_test
372+
SET SESSION AUTHORIZATION dblink_regression_test;
374373
-- should fail
375374
SELECT dblink_connect('myconn','fdtest');
376375
-- should succeed
377376
SELECT dblink_connect_u('myconn','fdtest');
378377
SELECT*FROM dblink('myconn','SELECT * FROM foo')AS t(aint, btext, ctext[]);
379378

380-
\c-:ORIGINAL_USER
379+
\c--
381380
REVOKE USAGEON FOREIGN SERVER fdtestFROM dblink_regression_test;
382381
REVOKE EXECUTEON FUNCTION dblink_connect_u(text,text)FROM dblink_regression_test;
383382
DROPUSER dblink_regression_test;

‎src/interfaces/ecpg/test/connect/test5.pgc

Lines changed: 10 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,9 @@ exec sql end declare section;
2121
ECPGdebug(1, stderr);
2222

2323
exec sql connect to connectdb as main;
24+
exec sql alter user connectdb ENCRYPTED PASSWORD 'insecure';
2425
exec sql alter user connectuser ENCRYPTED PASSWORD 'connectpw';
26+
exec sql commit;
2527
exec sql disconnect; /* <-- "main" not specified */
2628

2729
strcpy(db, "connectdb");
@@ -38,28 +40,28 @@ exec sql end declare section;
3840
exec sql connect to 'connectdb' as main;
3941
exec sql disconnect main;
4042

41-
exec sql connect to as main user connectdb;
43+
exec sql connect to as main user connectdb/insecure;
4244
exec sql disconnect main;
4345

44-
exec sql connect to connectdb as main user connectuser/connectdb;
46+
exec sql connect to connectdb as main user connectuser/connectpw;
4547
exec sql disconnect main;
4648

47-
exec sql connect to unix:postgresql://localhost/connectdb as main user connectuser;
49+
exec sql connect to unix:postgresql://localhost/connectdb as main user connectuser/connectpw;
4850
exec sql disconnect main;
4951

50-
exec sql connect to "unix:postgresql://localhost/connectdb" as main user connectuser;
52+
exec sql connect to "unix:postgresql://localhost/connectdb" as main user connectuser/connectpw;
5153
exec sql disconnect main;
5254

53-
exec sql connect to 'unix:postgresql://localhost/connectdb' as main user :user;
55+
exec sql connect to 'unix:postgresql://localhost/connectdb' as main user :user USING "connectpw";
5456
exec sql disconnect main;
5557

56-
exec sql connect to unix:postgresql://localhost/connectdb?connect_timeout=14&client_encoding=latin1 as main user connectuser;
58+
exec sql connect to unix:postgresql://localhost/connectdb?connect_timeout=14&client_encoding=latin1 as main user connectuser/connectpw;
5759
exec sql disconnect main;
5860

59-
exec sql connect to "unix:postgresql://200.46.204.71/connectdb" as main user connectuser;
61+
exec sql connect to "unix:postgresql://200.46.204.71/connectdb" as main user connectuser/connectpw;
6062
exec sql disconnect main;
6163

62-
exec sql connect to unix:postgresql://localhost/ as main user connectdb;
64+
exec sql connect to unix:postgresql://localhost/ as main user connectdb IDENTIFIED BY insecure;
6365
exec sql disconnect main;
6466

6567
/* connect twice */

‎src/interfaces/ecpg/test/expected/connect-test5.c

Lines changed: 44 additions & 38 deletions
Original file line numberDiff line numberDiff line change
@@ -43,113 +43,119 @@ main(void)
4343
{ECPGconnect(__LINE__,0,"connectdb" ,NULL,NULL ,"main",0); }
4444
#line 23 "test5.pgc"
4545

46-
{ECPGdo(__LINE__,0,1,NULL,0,ECPGst_normal,"alter userconnectuser encrypted password 'connectpw'",ECPGt_EOIT,ECPGt_EORT);}
46+
{ECPGdo(__LINE__,0,1,NULL,0,ECPGst_normal,"alter userconnectdb encrypted password 'insecure'",ECPGt_EOIT,ECPGt_EORT);}
4747
#line 24 "test5.pgc"
4848

49-
{ECPGdisconnect(__LINE__,"CURRENT");}
49+
{ECPGdo(__LINE__,0,1,NULL,0,ECPGst_normal,"alter user connectuser encrypted password 'connectpw'",ECPGt_EOIT,ECPGt_EORT);}
5050
#line 25 "test5.pgc"
51+
52+
{ECPGtrans(__LINE__,NULL,"commit");}
53+
#line 26 "test5.pgc"
54+
55+
{ECPGdisconnect(__LINE__,"CURRENT");}
56+
#line 27 "test5.pgc"
5157
/* <-- "main" not specified */
5258

5359
strcpy(db,"connectdb");
5460
strcpy(id,"main");
5561
{ECPGconnect(__LINE__,0,db ,NULL,NULL ,id,0); }
56-
#line29 "test5.pgc"
62+
#line31 "test5.pgc"
5763

5864
{ECPGdisconnect(__LINE__,id);}
59-
#line30 "test5.pgc"
65+
#line32 "test5.pgc"
6066

6167

6268
{ECPGconnect(__LINE__,0,"connectdb" ,NULL,NULL ,"main",0); }
63-
#line32 "test5.pgc"
69+
#line34 "test5.pgc"
6470

6571
{ECPGdisconnect(__LINE__,"main");}
66-
#line33 "test5.pgc"
72+
#line35 "test5.pgc"
6773

6874

6975
{ECPGconnect(__LINE__,0,"connectdb" ,NULL,NULL ,"main",0); }
70-
#line35 "test5.pgc"
76+
#line37 "test5.pgc"
7177

7278
{ECPGdisconnect(__LINE__,"main");}
73-
#line36 "test5.pgc"
79+
#line38 "test5.pgc"
7480

7581

7682
{ECPGconnect(__LINE__,0,"connectdb" ,NULL,NULL ,"main",0); }
77-
#line38 "test5.pgc"
83+
#line40 "test5.pgc"
7884

7985
{ECPGdisconnect(__LINE__,"main");}
80-
#line39 "test5.pgc"
86+
#line41 "test5.pgc"
8187

8288

83-
{ECPGconnect(__LINE__,0,"" ,"connectdb" ,NULL ,"main",0); }
84-
#line41 "test5.pgc"
89+
{ECPGconnect(__LINE__,0,"" ,"connectdb" ,"insecure" ,"main",0); }
90+
#line43 "test5.pgc"
8591

8692
{ECPGdisconnect(__LINE__,"main");}
87-
#line42 "test5.pgc"
93+
#line44 "test5.pgc"
8894

8995

90-
{ECPGconnect(__LINE__,0,"connectdb" ,"connectuser" ,"connectdb" ,"main",0); }
91-
#line44 "test5.pgc"
96+
{ECPGconnect(__LINE__,0,"connectdb" ,"connectuser" ,"connectpw" ,"main",0); }
97+
#line46 "test5.pgc"
9298

9399
{ECPGdisconnect(__LINE__,"main");}
94-
#line45 "test5.pgc"
100+
#line47 "test5.pgc"
95101

96102

97-
{ECPGconnect(__LINE__,0,"unix:postgresql://localhost/connectdb" ,"connectuser" ,NULL ,"main",0); }
98-
#line47 "test5.pgc"
103+
{ECPGconnect(__LINE__,0,"unix:postgresql://localhost/connectdb" ,"connectuser" ,"connectpw" ,"main",0); }
104+
#line49 "test5.pgc"
99105

100106
{ECPGdisconnect(__LINE__,"main");}
101-
#line48 "test5.pgc"
107+
#line50 "test5.pgc"
102108

103109

104-
{ECPGconnect(__LINE__,0,"unix:postgresql://localhost/connectdb" ,"connectuser" ,NULL ,"main",0); }
105-
#line50 "test5.pgc"
110+
{ECPGconnect(__LINE__,0,"unix:postgresql://localhost/connectdb" ,"connectuser" ,"connectpw" ,"main",0); }
111+
#line52 "test5.pgc"
106112

107113
{ECPGdisconnect(__LINE__,"main");}
108-
#line51 "test5.pgc"
114+
#line53 "test5.pgc"
109115

110116

111-
{ECPGconnect(__LINE__,0,"unix:postgresql://localhost/connectdb" ,user ,NULL ,"main",0); }
112-
#line53 "test5.pgc"
117+
{ECPGconnect(__LINE__,0,"unix:postgresql://localhost/connectdb" ,user ,"connectpw" ,"main",0); }
118+
#line55 "test5.pgc"
113119

114120
{ECPGdisconnect(__LINE__,"main");}
115-
#line54 "test5.pgc"
121+
#line56 "test5.pgc"
116122

117123

118-
{ECPGconnect(__LINE__,0,"unix:postgresql://localhost/connectdb?connect_timeout=14 & client_encoding=latin1" ,"connectuser" ,NULL ,"main",0); }
119-
#line56 "test5.pgc"
124+
{ECPGconnect(__LINE__,0,"unix:postgresql://localhost/connectdb?connect_timeout=14 & client_encoding=latin1" ,"connectuser" ,"connectpw" ,"main",0); }
125+
#line58 "test5.pgc"
120126

121127
{ECPGdisconnect(__LINE__,"main");}
122-
#line57 "test5.pgc"
128+
#line59 "test5.pgc"
123129

124130

125-
{ECPGconnect(__LINE__,0,"unix:postgresql://200.46.204.71/connectdb" ,"connectuser" ,NULL ,"main",0); }
126-
#line59 "test5.pgc"
131+
{ECPGconnect(__LINE__,0,"unix:postgresql://200.46.204.71/connectdb" ,"connectuser" ,"connectpw" ,"main",0); }
132+
#line61 "test5.pgc"
127133

128134
{ECPGdisconnect(__LINE__,"main");}
129-
#line60 "test5.pgc"
135+
#line62 "test5.pgc"
130136

131137

132-
{ECPGconnect(__LINE__,0,"unix:postgresql://localhost/" ,"connectdb" ,NULL ,"main",0); }
133-
#line62 "test5.pgc"
138+
{ECPGconnect(__LINE__,0,"unix:postgresql://localhost/" ,"connectdb" ,"insecure" ,"main",0); }
139+
#line64 "test5.pgc"
134140

135141
{ECPGdisconnect(__LINE__,"main");}
136-
#line63 "test5.pgc"
142+
#line65 "test5.pgc"
137143

138144

139145
/* connect twice */
140146
{ECPGconnect(__LINE__,0,"connectdb" ,NULL,NULL ,"main",0); }
141-
#line66 "test5.pgc"
147+
#line68 "test5.pgc"
142148

143149
{ECPGconnect(__LINE__,0,"connectdb" ,NULL,NULL ,"main",0); }
144-
#line67 "test5.pgc"
150+
#line69 "test5.pgc"
145151

146152
{ECPGdisconnect(__LINE__,"main");}
147-
#line68 "test5.pgc"
153+
#line70 "test5.pgc"
148154

149155

150156
/* not connected */
151157
{ECPGdisconnect(__LINE__,"nonexistant");}
152-
#line71 "test5.pgc"
158+
#line73 "test5.pgc"
153159

154160

155161
return (0);

‎src/interfaces/ecpg/test/expected/connect-test5.stderr

Lines changed: 13 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -2,12 +2,20 @@
22
[NO_PID]: sqlca: code: 0, state: 00000
33
[NO_PID]: ECPGconnect: opening database connectdb on <DEFAULT> port <DEFAULT>
44
[NO_PID]: sqlca: code: 0, state: 00000
5-
[NO_PID]: ecpg_execute on line 24: query: alter userconnectuser encrypted password 'connectpw'; with 0 parameter(s) on connection main
5+
[NO_PID]: ecpg_execute on line 24: query: alter userconnectdb encrypted password 'insecure'; with 0 parameter(s) on connection main
66
[NO_PID]: sqlca: code: 0, state: 00000
77
[NO_PID]: ecpg_execute on line 24: using PQexec
88
[NO_PID]: sqlca: code: 0, state: 00000
99
[NO_PID]: ecpg_process_output on line 24: OK: ALTER ROLE
1010
[NO_PID]: sqlca: code: 0, state: 00000
11+
[NO_PID]: ecpg_execute on line 25: query: alter user connectuser encrypted password 'connectpw'; with 0 parameter(s) on connection main
12+
[NO_PID]: sqlca: code: 0, state: 00000
13+
[NO_PID]: ecpg_execute on line 25: using PQexec
14+
[NO_PID]: sqlca: code: 0, state: 00000
15+
[NO_PID]: ecpg_process_output on line 25: OK: ALTER ROLE
16+
[NO_PID]: sqlca: code: 0, state: 00000
17+
[NO_PID]: ECPGtrans on line 26: action "commit"; connection "main"
18+
[NO_PID]: sqlca: code: 0, state: 00000
1119
[NO_PID]: ecpg_finish: connection main closed
1220
[NO_PID]: sqlca: code: 0, state: 00000
1321
[NO_PID]: ECPGconnect: opening database connectdb on <DEFAULT> port <DEFAULT>
@@ -50,11 +58,11 @@
5058
[NO_PID]: sqlca: code: 0, state: 00000
5159
[NO_PID]: ecpg_finish: connection main closed
5260
[NO_PID]: sqlca: code: 0, state: 00000
53-
[NO_PID]: ECPGconnect: non-localhost access via sockets on line59
61+
[NO_PID]: ECPGconnect: non-localhost access via sockets on line61
5462
[NO_PID]: sqlca: code: 0, state: 00000
55-
[NO_PID]: raising sqlcode -402 on line59: could not connect to database "connectdb" on line59
63+
[NO_PID]: raising sqlcode -402 on line61: could not connect to database "connectdb" on line61
5664
[NO_PID]: sqlca: code: -402, state: 08001
57-
[NO_PID]: raising sqlcode -220 on line60: connection "main" does not exist on line60
65+
[NO_PID]: raising sqlcode -220 on line62: connection "main" does not exist on line62
5866
[NO_PID]: sqlca: code: -220, state: 08003
5967
[NO_PID]: ECPGconnect: opening database <DEFAULT> on <DEFAULT> port <DEFAULT> for user connectdb
6068
[NO_PID]: sqlca: code: 0, state: 00000
@@ -66,5 +74,5 @@
6674
[NO_PID]: sqlca: code: 0, state: 00000
6775
[NO_PID]: ecpg_finish: connection main closed
6876
[NO_PID]: sqlca: code: 0, state: 00000
69-
[NO_PID]: raising sqlcode -220 on line71: connection "nonexistant" does not exist on line71
77+
[NO_PID]: raising sqlcode -220 on line73: connection "nonexistant" does not exist on line73
7078
[NO_PID]: sqlca: code: -220, state: 08003

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp