File tree Expand file tree Collapse file tree 4 files changed +31
-1
lines changed Expand file tree Collapse file tree 4 files changed +31
-1
lines changed Original file line number Diff line number Diff line change @@ -8898,6 +8898,15 @@ SELECT * FROM ft1_nopw LIMIT 1;
88988898 1111 | 2 | | | | | ft1 |
88998899(1 row)
89008900
8901+ -- unpriv user also cannot set sslcert / sslkey on the user mapping
8902+ -- first set password_required so we see the right error messages
8903+ ALTER USER MAPPING FOR CURRENT_USER SERVER loopback_nopw OPTIONS (SET password_required 'true');
8904+ ALTER USER MAPPING FOR CURRENT_USER SERVER loopback_nopw OPTIONS (ADD sslcert 'foo.crt');
8905+ ERROR: sslcert and sslkey are superuser-only
8906+ HINT: User mappings with the sslcert or sslkey options set may only be created or modified by the superuser
8907+ ALTER USER MAPPING FOR CURRENT_USER SERVER loopback_nopw OPTIONS (ADD sslkey 'foo.key');
8908+ ERROR: sslcert and sslkey are superuser-only
8909+ HINT: User mappings with the sslcert or sslkey options set may only be created or modified by the superuser
89018910-- We're done with the role named after a specific user and need to check the
89028911-- changes to the public mapping.
89038912DROP USER MAPPING FOR CURRENT_USER SERVER loopback_nopw;
Original file line number Diff line number Diff line change @@ -159,6 +159,16 @@ postgres_fdw_validator(PG_FUNCTION_ARGS)
159159 errmsg ("password_required=false is superuser-only" ),
160160 errhint ("User mappings with the password_required option set to false may only be created or modified by the superuser" )));
161161 }
162+ else if (strcmp (def -> defname , "sslcert" ) == 0 ||
163+ strcmp (def -> defname , "sslkey" ) == 0 )
164+ {
165+ /* similarly for sslcert / sslkey on user mapping */
166+ if (catalog == UserMappingRelationId && !superuser ())
167+ ereport (ERROR ,
168+ (errcode (ERRCODE_INSUFFICIENT_PRIVILEGE ),
169+ errmsg ("sslcert and sslkey are superuser-only" ),
170+ errhint ("User mappings with the sslcert or sslkey options set may only be created or modified by the superuser" )));
171+ }
162172 }
163173
164174 PG_RETURN_VOID ();
Original file line number Diff line number Diff line change @@ -2567,6 +2567,7 @@ SELECT * FROM ft1_nopw LIMIT 1;
25672567-- Unpriv user cannot make the mapping passwordless
25682568ALTER USER MAPPING FOR CURRENT_USER SERVER loopback_nopw OPTIONS (ADD password_required ' false' );
25692569
2570+
25702571SELECT * FROM ft1_nopw LIMIT 1 ;
25712572
25722573RESET ROLE;
@@ -2579,6 +2580,12 @@ SET ROLE regress_nosuper;
25792580-- Should finally work now
25802581SELECT * FROM ft1_nopw LIMIT 1 ;
25812582
2583+ -- unpriv user also cannot set sslcert / sslkey on the user mapping
2584+ -- first set password_required so we see the right error messages
2585+ ALTER USER MAPPING FOR CURRENT_USER SERVER loopback_nopw OPTIONS (SET password_required ' true' );
2586+ ALTER USER MAPPING FOR CURRENT_USER SERVER loopback_nopw OPTIONS (ADD sslcert ' foo.crt' );
2587+ ALTER USER MAPPING FOR CURRENT_USER SERVER loopback_nopw OPTIONS (ADD sslkey ' foo.key' );
2588+
25822589-- We're done with the role named after a specific user and need to check the
25832590-- changes to the public mapping.
25842591DROP USER MAPPING FOR CURRENT_USER SERVER loopback_nopw;
Original file line number Diff line number Diff line change 130130 </listitem>
131131 <listitem>
132132 <para>
133- <literal>sslkey</literal> and <literal>sslpassword </literal> - these may
133+ <literal>sslkey</literal> and <literal>sslcert </literal> - these may
134134 appear in <emphasis>either or both</emphasis> a connection and a user
135135 mapping. If both are present, the user mapping setting overrides the
136136 connection setting.
139139 </itemizedlist>
140140 </para>
141141
142+ <para>
143+ Only superusers may create or modify user mappings with the
144+ <literal>sslcert</literal> or <literal>sslkey</literal> settings.
145+ </para>
142146 <para>
143147 Only superusers may connect to foreign servers without password
144148 authentication, so always specify the <literal>password</literal> option
You can’t perform that action at this time.
0 commit comments